pierre-review 0.1.76 → 0.1.78

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.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ClaudeReviewTab-DIjf6gst.js","assets/tanstack-R-s9abdD.js","assets/markdown-BUNN1sk6.js","assets/highlight-C8vPehS1.js","assets/highlight-BEHUn5zE.css","assets/vis-C3BCkP5U.js","assets/vis-ziCVehMy.css","assets/AiFixTab-Bvs2sflj.js"])))=>i.map(i=>d[i]);
2
- import{b as Xg,R as jo,e as qe,r as x,j as n,f as Be,d as Ue,a as Gm,u as Jg,c as Zg,Q as ex,P as tx}from"./tanstack-R-s9abdD.js";import{d as Uc,M as nx,r as rx,a as sx,b as ax}from"./markdown-BUNN1sk6.js";import{r as lx}from"./highlight-C8vPehS1.js";import{D as hp,T as ox}from"./vis-C3BCkP5U.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))o(i);new MutationObserver(i=>{for(const u of i)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function a(i){const u={};return i.integrity&&(u.integrity=i.integrity),i.referrerPolicy&&(u.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?u.credentials="include":i.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(i){if(i.ep)return;i.ep=!0;const u=a(i);fetch(i.href,u)}})();const ix="modulepreload",cx=function(e){return"/app/"+e},gp={},Eu=function(s,a,o){let i=Promise.resolve();if(a&&a.length>0){let d=function(g){return Promise.all(g.map(y=>Promise.resolve(y).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const p=document.querySelector("meta[property=csp-nonce]"),m=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));i=d(a.map(g=>{if(g=cx(g),g in gp)return;gp[g]=!0;const y=g.endsWith(".css"),b=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${g}"]${b}`))return;const v=document.createElement("link");if(v.rel=y?"stylesheet":ix,y||(v.as="script"),v.crossOrigin="",v.href=g,m&&v.setAttribute("nonce",m),document.head.appendChild(v),y)return new Promise((N,I)=>{v.addEventListener("load",N),v.addEventListener("error",()=>I(new Error(`Unable to preload CSS for ${g}`)))})}))}function u(d){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=d,window.dispatchEvent(p),!p.defaultPrevented)throw d}return i.then(d=>{for(const p of d||[])p.status==="rejected"&&u(p.reason);return s().catch(u)})};var No={},Kc={exports:{}},rn={},Hc={exports:{}},Wc={};/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ClaudeReviewTab-CBzfgOYF.js","assets/tanstack-R-s9abdD.js","assets/markdown-BUNN1sk6.js","assets/highlight-C8vPehS1.js","assets/highlight-BEHUn5zE.css","assets/vis-C3BCkP5U.js","assets/vis-ziCVehMy.css","assets/AiFixTab-DMoHaevz.js"])))=>i.map(i=>d[i]);
2
+ import{b as Xg,R as No,e as qe,r as x,j as n,f as Be,d as Ue,a as Gm,u as Jg,c as Zg,Q as ex,P as tx}from"./tanstack-R-s9abdD.js";import{d as Uc,M as nx,r as rx,a as sx,b as ax}from"./markdown-BUNN1sk6.js";import{r as lx}from"./highlight-C8vPehS1.js";import{D as hp,T as ox}from"./vis-C3BCkP5U.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))o(i);new MutationObserver(i=>{for(const u of i)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function a(i){const u={};return i.integrity&&(u.integrity=i.integrity),i.referrerPolicy&&(u.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?u.credentials="include":i.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(i){if(i.ep)return;i.ep=!0;const u=a(i);fetch(i.href,u)}})();const ix="modulepreload",cx=function(e){return"/app/"+e},gp={},Eu=function(s,a,o){let i=Promise.resolve();if(a&&a.length>0){let d=function(g){return Promise.all(g.map(w=>Promise.resolve(w).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};document.getElementsByTagName("link");const p=document.querySelector("meta[property=csp-nonce]"),m=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));i=d(a.map(g=>{if(g=cx(g),g in gp)return;gp[g]=!0;const w=g.endsWith(".css"),v=w?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${g}"]${v}`))return;const y=document.createElement("link");if(y.rel=w?"stylesheet":ix,w||(y.as="script"),y.crossOrigin="",y.href=g,m&&y.setAttribute("nonce",m),document.head.appendChild(y),w)return new Promise((j,R)=>{y.addEventListener("load",j),y.addEventListener("error",()=>R(new Error(`Unable to preload CSS for ${g}`)))})}))}function u(d){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=d,window.dispatchEvent(p),!p.defaultPrevented)throw d}return i.then(d=>{for(const p of d||[])p.status==="rejected"&&u(p.reason);return s().catch(u)})};var So={},Kc={exports:{}},rn={},Hc={exports:{}},Wc={};/**
3
3
  * @license React
4
4
  * scheduler.production.min.js
5
5
  *
@@ -7,7 +7,7 @@ import{b as Xg,R as jo,e as qe,r as x,j as n,f as Be,d as Ue,a as Gm,u as Jg,c a
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */var xp;function ux(){return xp||(xp=1,(function(e){function s(C,F){var K=C.length;C.push(F);e:for(;0<K;){var ae=K-1>>>1,ne=C[ae];if(0<i(ne,F))C[ae]=F,C[K]=ne,K=ae;else break e}}function a(C){return C.length===0?null:C[0]}function o(C){if(C.length===0)return null;var F=C[0],K=C.pop();if(K!==F){C[0]=K;e:for(var ae=0,ne=C.length,Pe=ne>>>1;ae<Pe;){var se=2*(ae+1)-1,Z=C[se],je=se+1,We=C[je];if(0>i(Z,K))je<ne&&0>i(We,Z)?(C[ae]=We,C[je]=K,ae=je):(C[ae]=Z,C[se]=K,ae=se);else if(je<ne&&0>i(We,K))C[ae]=We,C[je]=K,ae=je;else break e}}return F}function i(C,F){var K=C.sortIndex-F.sortIndex;return K!==0?K:C.id-F.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var d=Date,p=d.now();e.unstable_now=function(){return d.now()-p}}var m=[],g=[],y=1,b=null,v=3,N=!1,I=!1,P=!1,E=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function S(C){for(var F=a(g);F!==null;){if(F.callback===null)o(g);else if(F.startTime<=C)o(g),F.sortIndex=F.expirationTime,s(m,F);else break;F=a(g)}}function j(C){if(P=!1,S(C),!I)if(a(m)!==null)I=!0,ee(T);else{var F=a(g);F!==null&&ce(j,F.startTime-C)}}function T(C,F){I=!1,P&&(P=!1,w(U),U=-1),N=!0;var K=v;try{for(S(F),b=a(m);b!==null&&(!(b.expirationTime>F)||C&&!Y());){var ae=b.callback;if(typeof ae=="function"){b.callback=null,v=b.priorityLevel;var ne=ae(b.expirationTime<=F);F=e.unstable_now(),typeof ne=="function"?b.callback=ne:b===a(m)&&o(m),S(F)}else o(m);b=a(m)}if(b!==null)var Pe=!0;else{var se=a(g);se!==null&&ce(j,se.startTime-F),Pe=!1}return Pe}finally{b=null,v=K,N=!1}}var M=!1,D=null,U=-1,G=5,L=-1;function Y(){return!(e.unstable_now()-L<G)}function X(){if(D!==null){var C=e.unstable_now();L=C;var F=!0;try{F=D(!0,C)}finally{F?B():(M=!1,D=null)}}else M=!1}var B;if(typeof R=="function")B=function(){R(X)};else if(typeof MessageChannel<"u"){var _=new MessageChannel,H=_.port2;_.port1.onmessage=X,B=function(){H.postMessage(null)}}else B=function(){E(X,0)};function ee(C){D=C,M||(M=!0,B())}function ce(C,F){U=E(function(){C(e.unstable_now())},F)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(C){C.callback=null},e.unstable_continueExecution=function(){I||N||(I=!0,ee(T))},e.unstable_forceFrameRate=function(C){0>C||125<C?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):G=0<C?Math.floor(1e3/C):5},e.unstable_getCurrentPriorityLevel=function(){return v},e.unstable_getFirstCallbackNode=function(){return a(m)},e.unstable_next=function(C){switch(v){case 1:case 2:case 3:var F=3;break;default:F=v}var K=v;v=F;try{return C()}finally{v=K}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(C,F){switch(C){case 1:case 2:case 3:case 4:case 5:break;default:C=3}var K=v;v=C;try{return F()}finally{v=K}},e.unstable_scheduleCallback=function(C,F,K){var ae=e.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?ae+K:ae):K=ae,C){case 1:var ne=-1;break;case 2:ne=250;break;case 5:ne=1073741823;break;case 4:ne=1e4;break;default:ne=5e3}return ne=K+ne,C={id:y++,callback:F,priorityLevel:C,startTime:K,expirationTime:ne,sortIndex:-1},K>ae?(C.sortIndex=K,s(g,C),a(m)===null&&C===a(g)&&(P?(w(U),U=-1):P=!0,ce(j,K-ae))):(C.sortIndex=ne,s(m,C),I||N||(I=!0,ee(T))),C},e.unstable_shouldYield=Y,e.unstable_wrapCallback=function(C){var F=v;return function(){var K=v;v=F;try{return C.apply(this,arguments)}finally{v=K}}}})(Wc)),Wc}var yp;function dx(){return yp||(yp=1,Hc.exports=ux()),Hc.exports}/**
10
+ */var xp;function ux(){return xp||(xp=1,(function(e){function s(C,F){var K=C.length;C.push(F);e:for(;0<K;){var ae=K-1>>>1,ne=C[ae];if(0<i(ne,F))C[ae]=F,C[K]=ne,K=ae;else break e}}function a(C){return C.length===0?null:C[0]}function o(C){if(C.length===0)return null;var F=C[0],K=C.pop();if(K!==F){C[0]=K;e:for(var ae=0,ne=C.length,Pe=ne>>>1;ae<Pe;){var se=2*(ae+1)-1,Z=C[se],je=se+1,We=C[je];if(0>i(Z,K))je<ne&&0>i(We,Z)?(C[ae]=We,C[je]=K,ae=je):(C[ae]=Z,C[se]=K,ae=se);else if(je<ne&&0>i(We,K))C[ae]=We,C[je]=K,ae=je;else break e}}return F}function i(C,F){var K=C.sortIndex-F.sortIndex;return K!==0?K:C.id-F.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;e.unstable_now=function(){return u.now()}}else{var d=Date,p=d.now();e.unstable_now=function(){return d.now()-p}}var m=[],g=[],w=1,v=null,y=3,j=!1,R=!1,P=!1,E=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function N(C){for(var F=a(g);F!==null;){if(F.callback===null)o(g);else if(F.startTime<=C)o(g),F.sortIndex=F.expirationTime,s(m,F);else break;F=a(g)}}function b(C){if(P=!1,N(C),!R)if(a(m)!==null)R=!0,ee(I);else{var F=a(g);F!==null&&ce(b,F.startTime-C)}}function I(C,F){R=!1,P&&(P=!1,S(q),q=-1),j=!0;var K=y;try{for(N(F),v=a(m);v!==null&&(!(v.expirationTime>F)||C&&!Y());){var ae=v.callback;if(typeof ae=="function"){v.callback=null,y=v.priorityLevel;var ne=ae(v.expirationTime<=F);F=e.unstable_now(),typeof ne=="function"?v.callback=ne:v===a(m)&&o(m),N(F)}else o(m);v=a(m)}if(v!==null)var Pe=!0;else{var se=a(g);se!==null&&ce(b,se.startTime-F),Pe=!1}return Pe}finally{v=null,y=K,j=!1}}var $=!1,L=null,q=-1,Q=5,_=-1;function Y(){return!(e.unstable_now()-_<Q)}function X(){if(L!==null){var C=e.unstable_now();_=C;var F=!0;try{F=L(!0,C)}finally{F?B():($=!1,L=null)}}else $=!1}var B;if(typeof T=="function")B=function(){T(X)};else if(typeof MessageChannel<"u"){var O=new MessageChannel,H=O.port2;O.port1.onmessage=X,B=function(){H.postMessage(null)}}else B=function(){E(X,0)};function ee(C){L=C,$||($=!0,B())}function ce(C,F){q=E(function(){C(e.unstable_now())},F)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(C){C.callback=null},e.unstable_continueExecution=function(){R||j||(R=!0,ee(I))},e.unstable_forceFrameRate=function(C){0>C||125<C?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Q=0<C?Math.floor(1e3/C):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_getFirstCallbackNode=function(){return a(m)},e.unstable_next=function(C){switch(y){case 1:case 2:case 3:var F=3;break;default:F=y}var K=y;y=F;try{return C()}finally{y=K}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(C,F){switch(C){case 1:case 2:case 3:case 4:case 5:break;default:C=3}var K=y;y=C;try{return F()}finally{y=K}},e.unstable_scheduleCallback=function(C,F,K){var ae=e.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?ae+K:ae):K=ae,C){case 1:var ne=-1;break;case 2:ne=250;break;case 5:ne=1073741823;break;case 4:ne=1e4;break;default:ne=5e3}return ne=K+ne,C={id:w++,callback:F,priorityLevel:C,startTime:K,expirationTime:ne,sortIndex:-1},K>ae?(C.sortIndex=K,s(g,C),a(m)===null&&C===a(g)&&(P?(S(q),q=-1):P=!0,ce(b,K-ae))):(C.sortIndex=ne,s(m,C),R||j||(R=!0,ee(I))),C},e.unstable_shouldYield=Y,e.unstable_wrapCallback=function(C){var F=y;return function(){var K=y;y=F;try{return C.apply(this,arguments)}finally{y=K}}}})(Wc)),Wc}var yp;function dx(){return yp||(yp=1,Hc.exports=ux()),Hc.exports}/**
11
11
  * @license React
12
12
  * react-dom.production.min.js
13
13
  *
@@ -15,39 +15,39 @@ import{b as Xg,R as jo,e as qe,r as x,j as n,f as Be,d as Ue,a as Gm,u as Jg,c a
15
15
  *
16
16
  * This source code is licensed under the MIT license found in the
17
17
  * LICENSE file in the root directory of this source tree.
18
- */var vp;function fx(){if(vp)return rn;vp=1;var e=Xg(),s=dx();function a(t){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+t,l=1;l<arguments.length;l++)r+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+t+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,i={};function u(t,r){d(t,r),d(t+"Capture",r)}function d(t,r){for(i[t]=r,t=0;t<r.length;t++)o.add(r[t])}var p=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,g=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,y={},b={};function v(t){return m.call(b,t)?!0:m.call(y,t)?!1:g.test(t)?b[t]=!0:(y[t]=!0,!1)}function N(t,r,l,c){if(l!==null&&l.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return c?!1:l!==null?!l.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function I(t,r,l,c){if(r===null||typeof r>"u"||N(t,r,l,c))return!0;if(c)return!1;if(l!==null)switch(l.type){case 3:return!r;case 4:return r===!1;case 5:return isNaN(r);case 6:return isNaN(r)||1>r}return!1}function P(t,r,l,c,f,h,k){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=c,this.attributeNamespace=f,this.mustUseProperty=l,this.propertyName=t,this.type=r,this.sanitizeURL=h,this.removeEmptyString=k}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){E[t]=new P(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var r=t[0];E[r]=new P(r,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){E[t]=new P(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){E[t]=new P(t,2,!1,t,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){E[t]=new P(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){E[t]=new P(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){E[t]=new P(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){E[t]=new P(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){E[t]=new P(t,5,!1,t.toLowerCase(),null,!1,!1)});var w=/[\-:]([a-z])/g;function R(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var r=t.replace(w,R);E[r]=new P(r,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var r=t.replace(w,R);E[r]=new P(r,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var r=t.replace(w,R);E[r]=new P(r,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){E[t]=new P(t,1,!1,t.toLowerCase(),null,!1,!1)}),E.xlinkHref=new P("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){E[t]=new P(t,1,!1,t.toLowerCase(),null,!0,!0)});function S(t,r,l,c){var f=E.hasOwnProperty(r)?E[r]:null;(f!==null?f.type!==0:c||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(I(r,l,f,c)&&(l=null),c||f===null?v(r)&&(l===null?t.removeAttribute(r):t.setAttribute(r,""+l)):f.mustUseProperty?t[f.propertyName]=l===null?f.type===3?!1:"":l:(r=f.attributeName,c=f.attributeNamespace,l===null?t.removeAttribute(r):(f=f.type,l=f===3||f===4&&l===!0?"":""+l,c?t.setAttributeNS(c,r,l):t.setAttribute(r,l))))}var j=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,T=Symbol.for("react.element"),M=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),U=Symbol.for("react.strict_mode"),G=Symbol.for("react.profiler"),L=Symbol.for("react.provider"),Y=Symbol.for("react.context"),X=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),ee=Symbol.for("react.lazy"),ce=Symbol.for("react.offscreen"),C=Symbol.iterator;function F(t){return t===null||typeof t!="object"?null:(t=C&&t[C]||t["@@iterator"],typeof t=="function"?t:null)}var K=Object.assign,ae;function ne(t){if(ae===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);ae=r&&r[1]||""}return`
19
- `+ae+t}var Pe=!1;function se(t,r){if(!t||Pe)return"";Pe=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(r)if(r=function(){throw Error()},Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[])}catch(Q){var c=Q}Reflect.construct(t,[],r)}else{try{r.call()}catch(Q){c=Q}t.call(r.prototype)}else{try{throw Error()}catch(Q){c=Q}t()}}catch(Q){if(Q&&c&&typeof Q.stack=="string"){for(var f=Q.stack.split(`
18
+ */var vp;function fx(){if(vp)return rn;vp=1;var e=Xg(),s=dx();function a(t){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+t,l=1;l<arguments.length;l++)r+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+t+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var o=new Set,i={};function u(t,r){d(t,r),d(t+"Capture",r)}function d(t,r){for(i[t]=r,t=0;t<r.length;t++)o.add(r[t])}var p=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,g=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,w={},v={};function y(t){return m.call(v,t)?!0:m.call(w,t)?!1:g.test(t)?v[t]=!0:(w[t]=!0,!1)}function j(t,r,l,c){if(l!==null&&l.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return c?!1:l!==null?!l.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function R(t,r,l,c){if(r===null||typeof r>"u"||j(t,r,l,c))return!0;if(c)return!1;if(l!==null)switch(l.type){case 3:return!r;case 4:return r===!1;case 5:return isNaN(r);case 6:return isNaN(r)||1>r}return!1}function P(t,r,l,c,f,h,k){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=c,this.attributeNamespace=f,this.mustUseProperty=l,this.propertyName=t,this.type=r,this.sanitizeURL=h,this.removeEmptyString=k}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){E[t]=new P(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var r=t[0];E[r]=new P(r,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){E[t]=new P(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){E[t]=new P(t,2,!1,t,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){E[t]=new P(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){E[t]=new P(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){E[t]=new P(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){E[t]=new P(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){E[t]=new P(t,5,!1,t.toLowerCase(),null,!1,!1)});var S=/[\-:]([a-z])/g;function T(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var r=t.replace(S,T);E[r]=new P(r,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var r=t.replace(S,T);E[r]=new P(r,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var r=t.replace(S,T);E[r]=new P(r,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){E[t]=new P(t,1,!1,t.toLowerCase(),null,!1,!1)}),E.xlinkHref=new P("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){E[t]=new P(t,1,!1,t.toLowerCase(),null,!0,!0)});function N(t,r,l,c){var f=E.hasOwnProperty(r)?E[r]:null;(f!==null?f.type!==0:c||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(R(r,l,f,c)&&(l=null),c||f===null?y(r)&&(l===null?t.removeAttribute(r):t.setAttribute(r,""+l)):f.mustUseProperty?t[f.propertyName]=l===null?f.type===3?!1:"":l:(r=f.attributeName,c=f.attributeNamespace,l===null?t.removeAttribute(r):(f=f.type,l=f===3||f===4&&l===!0?"":""+l,c?t.setAttributeNS(c,r,l):t.setAttribute(r,l))))}var b=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,I=Symbol.for("react.element"),$=Symbol.for("react.portal"),L=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),Q=Symbol.for("react.profiler"),_=Symbol.for("react.provider"),Y=Symbol.for("react.context"),X=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),O=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),ee=Symbol.for("react.lazy"),ce=Symbol.for("react.offscreen"),C=Symbol.iterator;function F(t){return t===null||typeof t!="object"?null:(t=C&&t[C]||t["@@iterator"],typeof t=="function"?t:null)}var K=Object.assign,ae;function ne(t){if(ae===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);ae=r&&r[1]||""}return`
19
+ `+ae+t}var Pe=!1;function se(t,r){if(!t||Pe)return"";Pe=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(r)if(r=function(){throw Error()},Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[])}catch(G){var c=G}Reflect.construct(t,[],r)}else{try{r.call()}catch(G){c=G}t.call(r.prototype)}else{try{throw Error()}catch(G){c=G}t()}}catch(G){if(G&&c&&typeof G.stack=="string"){for(var f=G.stack.split(`
20
20
  `),h=c.stack.split(`
21
- `),k=f.length-1,$=h.length-1;1<=k&&0<=$&&f[k]!==h[$];)$--;for(;1<=k&&0<=$;k--,$--)if(f[k]!==h[$]){if(k!==1||$!==1)do if(k--,$--,0>$||f[k]!==h[$]){var O=`
22
- `+f[k].replace(" at new "," at ");return t.displayName&&O.includes("<anonymous>")&&(O=O.replace("<anonymous>",t.displayName)),O}while(1<=k&&0<=$);break}}}finally{Pe=!1,Error.prepareStackTrace=l}return(t=t?t.displayName||t.name:"")?ne(t):""}function Z(t){switch(t.tag){case 5:return ne(t.type);case 16:return ne("Lazy");case 13:return ne("Suspense");case 19:return ne("SuspenseList");case 0:case 2:case 15:return t=se(t.type,!1),t;case 11:return t=se(t.type.render,!1),t;case 1:return t=se(t.type,!0),t;default:return""}}function je(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case D:return"Fragment";case M:return"Portal";case G:return"Profiler";case U:return"StrictMode";case B:return"Suspense";case _:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Y:return(t.displayName||"Context")+".Consumer";case L:return(t._context.displayName||"Context")+".Provider";case X:var r=t.render;return t=t.displayName,t||(t=r.displayName||r.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case H:return r=t.displayName||null,r!==null?r:je(t.type)||"Memo";case ee:r=t._payload,t=t._init;try{return je(t(r))}catch{}}return null}function We(t){var r=t.type;switch(t.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=r.render,t=t.displayName||t.name||"",r.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return je(r);case 8:return r===U?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r}return null}function st(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Pt(t){var r=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Lt(t){var r=Pt(t)?"checked":"value",l=Object.getOwnPropertyDescriptor(t.constructor.prototype,r),c=""+t[r];if(!t.hasOwnProperty(r)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var f=l.get,h=l.set;return Object.defineProperty(t,r,{configurable:!0,get:function(){return f.call(this)},set:function(k){c=""+k,h.call(this,k)}}),Object.defineProperty(t,r,{enumerable:l.enumerable}),{getValue:function(){return c},setValue:function(k){c=""+k},stopTracking:function(){t._valueTracker=null,delete t[r]}}}}function vn(t){t._valueTracker||(t._valueTracker=Lt(t))}function Le(t){if(!t)return!1;var r=t._valueTracker;if(!r)return!0;var l=r.getValue(),c="";return t&&(c=Pt(t)?t.checked?"true":"false":t.value),t=c,t!==l?(r.setValue(t),!0):!1}function Mn(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Fn(t,r){var l=r.checked;return K({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??t._wrapperState.initialChecked})}function _t(t,r){var l=r.defaultValue==null?"":r.defaultValue,c=r.checked!=null?r.checked:r.defaultChecked;l=st(r.value!=null?r.value:l),t._wrapperState={initialChecked:c,initialValue:l,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function Ln(t,r){r=r.checked,r!=null&&S(t,"checked",r,!1)}function Kt(t,r){Ln(t,r);var l=st(r.value),c=r.type;if(l!=null)c==="number"?(l===0&&t.value===""||t.value!=l)&&(t.value=""+l):t.value!==""+l&&(t.value=""+l);else if(c==="submit"||c==="reset"){t.removeAttribute("value");return}r.hasOwnProperty("value")?Fr(t,r.type,l):r.hasOwnProperty("defaultValue")&&Fr(t,r.type,st(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(t.defaultChecked=!!r.defaultChecked)}function pr(t,r,l){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var c=r.type;if(!(c!=="submit"&&c!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+t._wrapperState.initialValue,l||r===t.value||(t.value=r),t.defaultValue=r}l=t.name,l!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,l!==""&&(t.name=l)}function Fr(t,r,l){(r!=="number"||Mn(t.ownerDocument)!==t)&&(l==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+l&&(t.defaultValue=""+l))}var Xn=Array.isArray;function _n(t,r,l,c){if(t=t.options,r){r={};for(var f=0;f<l.length;f++)r["$"+l[f]]=!0;for(l=0;l<t.length;l++)f=r.hasOwnProperty("$"+t[l].value),t[l].selected!==f&&(t[l].selected=f),f&&c&&(t[l].defaultSelected=!0)}else{for(l=""+st(l),r=null,f=0;f<t.length;f++){if(t[f].value===l){t[f].selected=!0,c&&(t[f].defaultSelected=!0);return}r!==null||t[f].disabled||(r=t[f])}r!==null&&(r.selected=!0)}}function bn(t,r){if(r.dangerouslySetInnerHTML!=null)throw Error(a(91));return K({},r,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function re(t,r){var l=r.value;if(l==null){if(l=r.children,r=r.defaultValue,l!=null){if(r!=null)throw Error(a(92));if(Xn(l)){if(1<l.length)throw Error(a(93));l=l[0]}r=l}r==null&&(r=""),l=r}t._wrapperState={initialValue:st(l)}}function He(t,r){var l=st(r.value),c=st(r.defaultValue);l!=null&&(l=""+l,l!==t.value&&(t.value=l),r.defaultValue==null&&t.defaultValue!==l&&(t.defaultValue=l)),c!=null&&(t.defaultValue=""+c)}function it(t){var r=t.textContent;r===t._wrapperState.initialValue&&r!==""&&r!==null&&(t.value=r)}function at(t){switch(t){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function On(t,r){return t==null||t==="http://www.w3.org/1999/xhtml"?at(r):t==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var wn,on=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,l,c,f){MSApp.execUnsafeLocalFunction(function(){return t(r,l,c,f)})}:t})(function(t,r){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=r;else{for(wn=wn||document.createElement("div"),wn.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=wn.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;r.firstChild;)t.appendChild(r.firstChild)}});function os(t,r){if(r){var l=t.firstChild;if(l&&l===t.lastChild&&l.nodeType===3){l.nodeValue=r;return}}t.textContent=r}var mr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},fi=["Webkit","ms","Moz","O"];Object.keys(mr).forEach(function(t){fi.forEach(function(r){r=r+t.charAt(0).toUpperCase()+t.substring(1),mr[r]=mr[t]})});function vl(t,r,l){return r==null||typeof r=="boolean"||r===""?"":l||typeof r!="number"||r===0||mr.hasOwnProperty(t)&&mr[t]?(""+r).trim():r+"px"}function bl(t,r){t=t.style;for(var l in r)if(r.hasOwnProperty(l)){var c=l.indexOf("--")===0,f=vl(l,r[l],c);l==="float"&&(l="cssFloat"),c?t.setProperty(l,f):t[l]=f}}var pi=K({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Jn(t,r){if(r){if(pi[t]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(a(137,t));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(a(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(a(61))}if(r.style!=null&&typeof r.style!="object")throw Error(a(62))}}function Ks(t,r){if(t.indexOf("-")===-1)return typeof r.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Hs=null;function cn(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var is=null,hr=null,Dn=null;function Yt(t){if(t=qa(t)){if(typeof is!="function")throw Error(a(280));var r=t.stateNode;r&&(r=_l(r),is(t.stateNode,t.type,r))}}function gr(t){hr?Dn?Dn.push(t):Dn=[t]:hr=t}function cs(){if(hr){var t=hr,r=Dn;if(Dn=hr=null,Yt(t),r)for(t=0;t<r.length;t++)Yt(r[t])}}function xr(t,r){return t(r)}function Ta(){}var Zn=!1;function us(t,r,l){if(Zn)return t(r,l);Zn=!0;try{return xr(t,r,l)}finally{Zn=!1,(hr!==null||Dn!==null)&&(Ta(),cs())}}function Ot(t,r){var l=t.stateNode;if(l===null)return null;var c=_l(l);if(c===null)return null;l=c[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(t=t.type,c=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!c;break e;default:t=!1}if(t)return null;if(l&&typeof l!="function")throw Error(a(231,r,typeof l));return l}var Ws=!1;if(p)try{var er={};Object.defineProperty(er,"passive",{get:function(){Ws=!0}}),window.addEventListener("test",er,er),window.removeEventListener("test",er,er)}catch{Ws=!1}function wl(t,r,l,c,f,h,k,$,O){var Q=Array.prototype.slice.call(arguments,3);try{r.apply(l,Q)}catch(ue){this.onError(ue)}}var kn=!1,un=null,Vs=!1,At=null,kl={onError:function(t){kn=!0,un=t}};function yr(t,r,l,c,f,h,k,$,O){kn=!1,un=null,wl.apply(kl,arguments)}function Qs(t,r,l,c,f,h,k,$,O){if(yr.apply(this,arguments),kn){if(kn){var Q=un;kn=!1,un=null}else throw Error(a(198));Vs||(Vs=!0,At=Q)}}function tr(t){var r=t,l=t;if(t.alternate)for(;r.return;)r=r.return;else{t=r;do r=t,(r.flags&4098)!==0&&(l=r.return),t=r.return;while(t)}return r.tag===3?l:null}function vr(t){if(t.tag===13){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function Bn(t){if(tr(t)!==t)throw Error(a(188))}function Gs(t){var r=t.alternate;if(!r){if(r=tr(t),r===null)throw Error(a(188));return r!==t?null:t}for(var l=t,c=r;;){var f=l.return;if(f===null)break;var h=f.alternate;if(h===null){if(c=f.return,c!==null){l=c;continue}break}if(f.child===h.child){for(h=f.child;h;){if(h===l)return Bn(f),t;if(h===c)return Bn(f),r;h=h.sibling}throw Error(a(188))}if(l.return!==c.return)l=f,c=h;else{for(var k=!1,$=f.child;$;){if($===l){k=!0,l=f,c=h;break}if($===c){k=!0,c=f,l=h;break}$=$.sibling}if(!k){for($=h.child;$;){if($===l){k=!0,l=h,c=f;break}if($===c){k=!0,c=h,l=f;break}$=$.sibling}if(!k)throw Error(a(189))}}if(l.alternate!==c)throw Error(a(190))}if(l.tag!==3)throw Error(a(188));return l.stateNode.current===l?t:r}function br(t){return t=Gs(t),t!==null?Lr(t):null}function Lr(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var r=Lr(t);if(r!==null)return r;t=t.sibling}return null}var _r=s.unstable_scheduleCallback,Or=s.unstable_cancelCallback,Ys=s.unstable_shouldYield,mi=s.unstable_requestPaint,Je=s.unstable_now,Ea=s.unstable_getCurrentPriorityLevel,Xs=s.unstable_ImmediatePriority,ds=s.unstable_UserBlockingPriority,fs=s.unstable_NormalPriority,Js=s.unstable_LowPriority,dn=s.unstable_IdlePriority,jn=null,A=null;function W(t){if(A&&typeof A.onCommitFiberRoot=="function")try{A.onCommitFiberRoot(jn,t,void 0,(t.current.flags&128)===128)}catch{}}var J=Math.clz32?Math.clz32:le,oe=Math.log,de=Math.LN2;function le(t){return t>>>=0,t===0?32:31-(oe(t)/de|0)|0}var ve=64,me=4194304;function he(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Ie(t,r){var l=t.pendingLanes;if(l===0)return 0;var c=0,f=t.suspendedLanes,h=t.pingedLanes,k=l&268435455;if(k!==0){var $=k&~f;$!==0?c=he($):(h&=k,h!==0&&(c=he(h)))}else k=l&~f,k!==0?c=he(k):h!==0&&(c=he(h));if(c===0)return 0;if(r!==0&&r!==c&&(r&f)===0&&(f=c&-c,h=r&-r,f>=h||f===16&&(h&4194240)!==0))return r;if((c&4)!==0&&(c|=l&16),r=t.entangledLanes,r!==0)for(t=t.entanglements,r&=c;0<r;)l=31-J(r),f=1<<l,c|=t[l],r&=~f;return c}function ye(t,r){switch(t){case 1:case 2:case 4:return r+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Re(t,r){for(var l=t.suspendedLanes,c=t.pingedLanes,f=t.expirationTimes,h=t.pendingLanes;0<h;){var k=31-J(h),$=1<<k,O=f[k];O===-1?(($&l)===0||($&c)!==0)&&(f[k]=ye($,r)):O<=r&&(t.expiredLanes|=$),h&=~$}}function ze(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function we(){var t=ve;return ve<<=1,(ve&4194240)===0&&(ve=64),t}function Ae(t){for(var r=[],l=0;31>l;l++)r.push(t);return r}function Ge(t,r,l){t.pendingLanes|=r,r!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,r=31-J(r),t[r]=l}function tt(t,r){var l=t.pendingLanes&~r;t.pendingLanes=r,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=r,t.mutableReadLanes&=r,t.entangledLanes&=r,r=t.entanglements;var c=t.eventTimes;for(t=t.expirationTimes;0<l;){var f=31-J(l),h=1<<f;r[f]=0,c[f]=-1,t[f]=-1,l&=~h}}function Ct(t,r){var l=t.entangledLanes|=r;for(t=t.entanglements;l;){var c=31-J(l),f=1<<c;f&r|t[c]&r&&(t[c]|=r),l&=~f}}var $e=0;function $t(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var pt,gt,zn,ps,ms,Dr=!1,nr=[],Ht=null,Dt=null,fn=null,Br=new Map,xe=new Map,Ye=[],qn="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Xt(t,r){switch(t){case"focusin":case"focusout":Ht=null;break;case"dragenter":case"dragleave":Dt=null;break;case"mouseover":case"mouseout":fn=null;break;case"pointerover":case"pointerout":Br.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":xe.delete(r.pointerId)}}function Nn(t,r,l,c,f,h){return t===null||t.nativeEvent!==h?(t={blockedOn:r,domEventName:l,eventSystemFlags:c,nativeEvent:h,targetContainers:[f]},r!==null&&(r=qa(r),r!==null&&gt(r)),t):(t.eventSystemFlags|=c,r=t.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),t)}function hs(t,r,l,c,f){switch(r){case"focusin":return Ht=Nn(Ht,t,r,l,c,f),!0;case"dragenter":return Dt=Nn(Dt,t,r,l,c,f),!0;case"mouseover":return fn=Nn(fn,t,r,l,c,f),!0;case"pointerover":var h=f.pointerId;return Br.set(h,Nn(Br.get(h)||null,t,r,l,c,f)),!0;case"gotpointercapture":return h=f.pointerId,xe.set(h,Nn(xe.get(h)||null,t,r,l,c,f)),!0}return!1}function wr(t){var r=ys(t.target);if(r!==null){var l=tr(r);if(l!==null){if(r=l.tag,r===13){if(r=vr(l),r!==null){t.blockedOn=r,ms(t.priority,function(){zn(l)});return}}else if(r===3&&l.stateNode.current.memoizedState.isDehydrated){t.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}t.blockedOn=null}function gs(t){if(t.blockedOn!==null)return!1;for(var r=t.targetContainers;0<r.length;){var l=gi(t.domEventName,t.eventSystemFlags,r[0],t.nativeEvent);if(l===null){l=t.nativeEvent;var c=new l.constructor(l.type,l);Hs=c,l.target.dispatchEvent(c),Hs=null}else return r=qa(l),r!==null&&gt(r),t.blockedOn=l,!1;r.shift()}return!0}function jl(t,r,l){gs(t)&&l.delete(r)}function xt(){Dr=!1,Ht!==null&&gs(Ht)&&(Ht=null),Dt!==null&&gs(Dt)&&(Dt=null),fn!==null&&gs(fn)&&(fn=null),Br.forEach(jl),xe.forEach(jl)}function xs(t,r){t.blockedOn===r&&(t.blockedOn=null,Dr||(Dr=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,xt)))}function Un(t){function r(f){return xs(f,t)}if(0<nr.length){xs(nr[0],t);for(var l=1;l<nr.length;l++){var c=nr[l];c.blockedOn===t&&(c.blockedOn=null)}}for(Ht!==null&&xs(Ht,t),Dt!==null&&xs(Dt,t),fn!==null&&xs(fn,t),Br.forEach(r),xe.forEach(r),l=0;l<Ye.length;l++)c=Ye[l],c.blockedOn===t&&(c.blockedOn=null);for(;0<Ye.length&&(l=Ye[0],l.blockedOn===null);)wr(l),l.blockedOn===null&&Ye.shift()}var kr=j.ReactCurrentBatchConfig,Nl=!0;function k0(t,r,l,c){var f=$e,h=kr.transition;kr.transition=null;try{$e=1,hi(t,r,l,c)}finally{$e=f,kr.transition=h}}function j0(t,r,l,c){var f=$e,h=kr.transition;kr.transition=null;try{$e=4,hi(t,r,l,c)}finally{$e=f,kr.transition=h}}function hi(t,r,l,c){if(Nl){var f=gi(t,r,l,c);if(f===null)$i(t,r,c,Sl,l),Xt(t,c);else if(hs(f,t,r,l,c))c.stopPropagation();else if(Xt(t,c),r&4&&-1<qn.indexOf(t)){for(;f!==null;){var h=qa(f);if(h!==null&&pt(h),h=gi(t,r,l,c),h===null&&$i(t,r,c,Sl,l),h===f)break;f=h}f!==null&&c.stopPropagation()}else $i(t,r,c,null,l)}}var Sl=null;function gi(t,r,l,c){if(Sl=null,t=cn(c),t=ys(t),t!==null)if(r=tr(t),r===null)t=null;else if(l=r.tag,l===13){if(t=vr(r),t!==null)return t;t=null}else if(l===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;t=null}else r!==t&&(t=null);return Sl=t,null}function ed(t){switch(t){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Ea()){case Xs:return 1;case ds:return 4;case fs:case Js:return 16;case dn:return 536870912;default:return 16}default:return 16}}var zr=null,xi=null,Cl=null;function td(){if(Cl)return Cl;var t,r=xi,l=r.length,c,f="value"in zr?zr.value:zr.textContent,h=f.length;for(t=0;t<l&&r[t]===f[t];t++);var k=l-t;for(c=1;c<=k&&r[l-c]===f[h-c];c++);return Cl=f.slice(t,1<c?1-c:void 0)}function Rl(t){var r=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&r===13&&(t=13)):t=r,t===10&&(t=13),32<=t||t===13?t:0}function Il(){return!0}function nd(){return!1}function pn(t){function r(l,c,f,h,k){this._reactName=l,this._targetInst=f,this.type=c,this.nativeEvent=h,this.target=k,this.currentTarget=null;for(var $ in t)t.hasOwnProperty($)&&(l=t[$],this[$]=l?l(h):h[$]);return this.isDefaultPrevented=(h.defaultPrevented!=null?h.defaultPrevented:h.returnValue===!1)?Il:nd,this.isPropagationStopped=nd,this}return K(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=Il)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Il)},persist:function(){},isPersistent:Il}),r}var Zs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},yi=pn(Zs),Pa=K({},Zs,{view:0,detail:0}),N0=pn(Pa),vi,bi,Aa,Tl=K({},Pa,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ki,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==Aa&&(Aa&&t.type==="mousemove"?(vi=t.screenX-Aa.screenX,bi=t.screenY-Aa.screenY):bi=vi=0,Aa=t),vi)},movementY:function(t){return"movementY"in t?t.movementY:bi}}),rd=pn(Tl),S0=K({},Tl,{dataTransfer:0}),C0=pn(S0),R0=K({},Pa,{relatedTarget:0}),wi=pn(R0),I0=K({},Zs,{animationName:0,elapsedTime:0,pseudoElement:0}),T0=pn(I0),E0=K({},Zs,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),P0=pn(E0),A0=K({},Zs,{data:0}),sd=pn(A0),$0={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},M0={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},F0={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function L0(t){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(t):(t=F0[t])?!!r[t]:!1}function ki(){return L0}var _0=K({},Pa,{key:function(t){if(t.key){var r=$0[t.key]||t.key;if(r!=="Unidentified")return r}return t.type==="keypress"?(t=Rl(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?M0[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ki,charCode:function(t){return t.type==="keypress"?Rl(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Rl(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),O0=pn(_0),D0=K({},Tl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ad=pn(D0),B0=K({},Pa,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ki}),z0=pn(B0),q0=K({},Zs,{propertyName:0,elapsedTime:0,pseudoElement:0}),U0=pn(q0),K0=K({},Tl,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),H0=pn(K0),W0=[9,13,27,32],ji=p&&"CompositionEvent"in window,$a=null;p&&"documentMode"in document&&($a=document.documentMode);var V0=p&&"TextEvent"in window&&!$a,ld=p&&(!ji||$a&&8<$a&&11>=$a),od=" ",id=!1;function cd(t,r){switch(t){case"keyup":return W0.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ud(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ea=!1;function Q0(t,r){switch(t){case"compositionend":return ud(r);case"keypress":return r.which!==32?null:(id=!0,od);case"textInput":return t=r.data,t===od&&id?null:t;default:return null}}function G0(t,r){if(ea)return t==="compositionend"||!ji&&cd(t,r)?(t=td(),Cl=xi=zr=null,ea=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return ld&&r.locale!=="ko"?null:r.data;default:return null}}var Y0={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function dd(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r==="input"?!!Y0[t.type]:r==="textarea"}function fd(t,r,l,c){gr(c),r=Ml(r,"onChange"),0<r.length&&(l=new yi("onChange","change",null,l,c),t.push({event:l,listeners:r}))}var Ma=null,Fa=null;function X0(t){Ed(t,0)}function El(t){var r=aa(t);if(Le(r))return t}function J0(t,r){if(t==="change")return r}var pd=!1;if(p){var Ni;if(p){var Si="oninput"in document;if(!Si){var md=document.createElement("div");md.setAttribute("oninput","return;"),Si=typeof md.oninput=="function"}Ni=Si}else Ni=!1;pd=Ni&&(!document.documentMode||9<document.documentMode)}function hd(){Ma&&(Ma.detachEvent("onpropertychange",gd),Fa=Ma=null)}function gd(t){if(t.propertyName==="value"&&El(Fa)){var r=[];fd(r,Fa,t,cn(t)),us(X0,r)}}function Z0(t,r,l){t==="focusin"?(hd(),Ma=r,Fa=l,Ma.attachEvent("onpropertychange",gd)):t==="focusout"&&hd()}function eg(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return El(Fa)}function tg(t,r){if(t==="click")return El(r)}function ng(t,r){if(t==="input"||t==="change")return El(r)}function rg(t,r){return t===r&&(t!==0||1/t===1/r)||t!==t&&r!==r}var Kn=typeof Object.is=="function"?Object.is:rg;function La(t,r){if(Kn(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;var l=Object.keys(t),c=Object.keys(r);if(l.length!==c.length)return!1;for(c=0;c<l.length;c++){var f=l[c];if(!m.call(r,f)||!Kn(t[f],r[f]))return!1}return!0}function xd(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function yd(t,r){var l=xd(t);t=0;for(var c;l;){if(l.nodeType===3){if(c=t+l.textContent.length,t<=r&&c>=r)return{node:l,offset:r-t};t=c}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=xd(l)}}function vd(t,r){return t&&r?t===r?!0:t&&t.nodeType===3?!1:r&&r.nodeType===3?vd(t,r.parentNode):"contains"in t?t.contains(r):t.compareDocumentPosition?!!(t.compareDocumentPosition(r)&16):!1:!1}function bd(){for(var t=window,r=Mn();r instanceof t.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)t=r.contentWindow;else break;r=Mn(t.document)}return r}function Ci(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r&&(r==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||r==="textarea"||t.contentEditable==="true")}function sg(t){var r=bd(),l=t.focusedElem,c=t.selectionRange;if(r!==l&&l&&l.ownerDocument&&vd(l.ownerDocument.documentElement,l)){if(c!==null&&Ci(l)){if(r=c.start,t=c.end,t===void 0&&(t=r),"selectionStart"in l)l.selectionStart=r,l.selectionEnd=Math.min(t,l.value.length);else if(t=(r=l.ownerDocument||document)&&r.defaultView||window,t.getSelection){t=t.getSelection();var f=l.textContent.length,h=Math.min(c.start,f);c=c.end===void 0?h:Math.min(c.end,f),!t.extend&&h>c&&(f=c,c=h,h=f),f=yd(l,h);var k=yd(l,c);f&&k&&(t.rangeCount!==1||t.anchorNode!==f.node||t.anchorOffset!==f.offset||t.focusNode!==k.node||t.focusOffset!==k.offset)&&(r=r.createRange(),r.setStart(f.node,f.offset),t.removeAllRanges(),h>c?(t.addRange(r),t.extend(k.node,k.offset)):(r.setEnd(k.node,k.offset),t.addRange(r)))}}for(r=[],t=l;t=t.parentNode;)t.nodeType===1&&r.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<r.length;l++)t=r[l],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var ag=p&&"documentMode"in document&&11>=document.documentMode,ta=null,Ri=null,_a=null,Ii=!1;function wd(t,r,l){var c=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Ii||ta==null||ta!==Mn(c)||(c=ta,"selectionStart"in c&&Ci(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),_a&&La(_a,c)||(_a=c,c=Ml(Ri,"onSelect"),0<c.length&&(r=new yi("onSelect","select",null,r,l),t.push({event:r,listeners:c}),r.target=ta)))}function Pl(t,r){var l={};return l[t.toLowerCase()]=r.toLowerCase(),l["Webkit"+t]="webkit"+r,l["Moz"+t]="moz"+r,l}var na={animationend:Pl("Animation","AnimationEnd"),animationiteration:Pl("Animation","AnimationIteration"),animationstart:Pl("Animation","AnimationStart"),transitionend:Pl("Transition","TransitionEnd")},Ti={},kd={};p&&(kd=document.createElement("div").style,"AnimationEvent"in window||(delete na.animationend.animation,delete na.animationiteration.animation,delete na.animationstart.animation),"TransitionEvent"in window||delete na.transitionend.transition);function Al(t){if(Ti[t])return Ti[t];if(!na[t])return t;var r=na[t],l;for(l in r)if(r.hasOwnProperty(l)&&l in kd)return Ti[t]=r[l];return t}var jd=Al("animationend"),Nd=Al("animationiteration"),Sd=Al("animationstart"),Cd=Al("transitionend"),Rd=new Map,Id="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function qr(t,r){Rd.set(t,r),u(r,[t])}for(var Ei=0;Ei<Id.length;Ei++){var Pi=Id[Ei],lg=Pi.toLowerCase(),og=Pi[0].toUpperCase()+Pi.slice(1);qr(lg,"on"+og)}qr(jd,"onAnimationEnd"),qr(Nd,"onAnimationIteration"),qr(Sd,"onAnimationStart"),qr("dblclick","onDoubleClick"),qr("focusin","onFocus"),qr("focusout","onBlur"),qr(Cd,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),u("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),u("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),u("onBeforeInput",["compositionend","keypress","textInput","paste"]),u("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Oa="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),ig=new Set("cancel close invalid load scroll toggle".split(" ").concat(Oa));function Td(t,r,l){var c=t.type||"unknown-event";t.currentTarget=l,Qs(c,r,void 0,t),t.currentTarget=null}function Ed(t,r){r=(r&4)!==0;for(var l=0;l<t.length;l++){var c=t[l],f=c.event;c=c.listeners;e:{var h=void 0;if(r)for(var k=c.length-1;0<=k;k--){var $=c[k],O=$.instance,Q=$.currentTarget;if($=$.listener,O!==h&&f.isPropagationStopped())break e;Td(f,$,Q),h=O}else for(k=0;k<c.length;k++){if($=c[k],O=$.instance,Q=$.currentTarget,$=$.listener,O!==h&&f.isPropagationStopped())break e;Td(f,$,Q),h=O}}}if(Vs)throw t=At,Vs=!1,At=null,t}function Ze(t,r){var l=r[Di];l===void 0&&(l=r[Di]=new Set);var c=t+"__bubble";l.has(c)||(Pd(r,t,2,!1),l.add(c))}function Ai(t,r,l){var c=0;r&&(c|=4),Pd(l,t,c,r)}var $l="_reactListening"+Math.random().toString(36).slice(2);function Da(t){if(!t[$l]){t[$l]=!0,o.forEach(function(l){l!=="selectionchange"&&(ig.has(l)||Ai(l,!1,t),Ai(l,!0,t))});var r=t.nodeType===9?t:t.ownerDocument;r===null||r[$l]||(r[$l]=!0,Ai("selectionchange",!1,r))}}function Pd(t,r,l,c){switch(ed(r)){case 1:var f=k0;break;case 4:f=j0;break;default:f=hi}l=f.bind(null,r,l,t),f=void 0,!Ws||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(f=!0),c?f!==void 0?t.addEventListener(r,l,{capture:!0,passive:f}):t.addEventListener(r,l,!0):f!==void 0?t.addEventListener(r,l,{passive:f}):t.addEventListener(r,l,!1)}function $i(t,r,l,c,f){var h=c;if((r&1)===0&&(r&2)===0&&c!==null)e:for(;;){if(c===null)return;var k=c.tag;if(k===3||k===4){var $=c.stateNode.containerInfo;if($===f||$.nodeType===8&&$.parentNode===f)break;if(k===4)for(k=c.return;k!==null;){var O=k.tag;if((O===3||O===4)&&(O=k.stateNode.containerInfo,O===f||O.nodeType===8&&O.parentNode===f))return;k=k.return}for(;$!==null;){if(k=ys($),k===null)return;if(O=k.tag,O===5||O===6){c=h=k;continue e}$=$.parentNode}}c=c.return}us(function(){var Q=h,ue=cn(l),fe=[];e:{var ie=Rd.get(t);if(ie!==void 0){var be=yi,Ne=t;switch(t){case"keypress":if(Rl(l)===0)break e;case"keydown":case"keyup":be=O0;break;case"focusin":Ne="focus",be=wi;break;case"focusout":Ne="blur",be=wi;break;case"beforeblur":case"afterblur":be=wi;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":be=rd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":be=C0;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":be=z0;break;case jd:case Nd:case Sd:be=T0;break;case Cd:be=U0;break;case"scroll":be=N0;break;case"wheel":be=H0;break;case"copy":case"cut":case"paste":be=P0;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":be=ad}var Se=(r&4)!==0,ut=!Se&&t==="scroll",q=Se?ie!==null?ie+"Capture":null:ie;Se=[];for(var z=Q,V;z!==null;){V=z;var pe=V.stateNode;if(V.tag===5&&pe!==null&&(V=pe,q!==null&&(pe=Ot(z,q),pe!=null&&Se.push(Ba(z,pe,V)))),ut)break;z=z.return}0<Se.length&&(ie=new be(ie,Ne,null,l,ue),fe.push({event:ie,listeners:Se}))}}if((r&7)===0){e:{if(ie=t==="mouseover"||t==="pointerover",be=t==="mouseout"||t==="pointerout",ie&&l!==Hs&&(Ne=l.relatedTarget||l.fromElement)&&(ys(Ne)||Ne[jr]))break e;if((be||ie)&&(ie=ue.window===ue?ue:(ie=ue.ownerDocument)?ie.defaultView||ie.parentWindow:window,be?(Ne=l.relatedTarget||l.toElement,be=Q,Ne=Ne?ys(Ne):null,Ne!==null&&(ut=tr(Ne),Ne!==ut||Ne.tag!==5&&Ne.tag!==6)&&(Ne=null)):(be=null,Ne=Q),be!==Ne)){if(Se=rd,pe="onMouseLeave",q="onMouseEnter",z="mouse",(t==="pointerout"||t==="pointerover")&&(Se=ad,pe="onPointerLeave",q="onPointerEnter",z="pointer"),ut=be==null?ie:aa(be),V=Ne==null?ie:aa(Ne),ie=new Se(pe,z+"leave",be,l,ue),ie.target=ut,ie.relatedTarget=V,pe=null,ys(ue)===Q&&(Se=new Se(q,z+"enter",Ne,l,ue),Se.target=V,Se.relatedTarget=ut,pe=Se),ut=pe,be&&Ne)t:{for(Se=be,q=Ne,z=0,V=Se;V;V=ra(V))z++;for(V=0,pe=q;pe;pe=ra(pe))V++;for(;0<z-V;)Se=ra(Se),z--;for(;0<V-z;)q=ra(q),V--;for(;z--;){if(Se===q||q!==null&&Se===q.alternate)break t;Se=ra(Se),q=ra(q)}Se=null}else Se=null;be!==null&&Ad(fe,ie,be,Se,!1),Ne!==null&&ut!==null&&Ad(fe,ut,Ne,Se,!0)}}e:{if(ie=Q?aa(Q):window,be=ie.nodeName&&ie.nodeName.toLowerCase(),be==="select"||be==="input"&&ie.type==="file")var Ce=J0;else if(dd(ie))if(pd)Ce=ng;else{Ce=eg;var Te=Z0}else(be=ie.nodeName)&&be.toLowerCase()==="input"&&(ie.type==="checkbox"||ie.type==="radio")&&(Ce=tg);if(Ce&&(Ce=Ce(t,Q))){fd(fe,Ce,l,ue);break e}Te&&Te(t,ie,Q),t==="focusout"&&(Te=ie._wrapperState)&&Te.controlled&&ie.type==="number"&&Fr(ie,"number",ie.value)}switch(Te=Q?aa(Q):window,t){case"focusin":(dd(Te)||Te.contentEditable==="true")&&(ta=Te,Ri=Q,_a=null);break;case"focusout":_a=Ri=ta=null;break;case"mousedown":Ii=!0;break;case"contextmenu":case"mouseup":case"dragend":Ii=!1,wd(fe,l,ue);break;case"selectionchange":if(ag)break;case"keydown":case"keyup":wd(fe,l,ue)}var Ee;if(ji)e:{switch(t){case"compositionstart":var Me="onCompositionStart";break e;case"compositionend":Me="onCompositionEnd";break e;case"compositionupdate":Me="onCompositionUpdate";break e}Me=void 0}else ea?cd(t,l)&&(Me="onCompositionEnd"):t==="keydown"&&l.keyCode===229&&(Me="onCompositionStart");Me&&(ld&&l.locale!=="ko"&&(ea||Me!=="onCompositionStart"?Me==="onCompositionEnd"&&ea&&(Ee=td()):(zr=ue,xi="value"in zr?zr.value:zr.textContent,ea=!0)),Te=Ml(Q,Me),0<Te.length&&(Me=new sd(Me,t,null,l,ue),fe.push({event:Me,listeners:Te}),Ee?Me.data=Ee:(Ee=ud(l),Ee!==null&&(Me.data=Ee)))),(Ee=V0?Q0(t,l):G0(t,l))&&(Q=Ml(Q,"onBeforeInput"),0<Q.length&&(ue=new sd("onBeforeInput","beforeinput",null,l,ue),fe.push({event:ue,listeners:Q}),ue.data=Ee))}Ed(fe,r)})}function Ba(t,r,l){return{instance:t,listener:r,currentTarget:l}}function Ml(t,r){for(var l=r+"Capture",c=[];t!==null;){var f=t,h=f.stateNode;f.tag===5&&h!==null&&(f=h,h=Ot(t,l),h!=null&&c.unshift(Ba(t,h,f)),h=Ot(t,r),h!=null&&c.push(Ba(t,h,f))),t=t.return}return c}function ra(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function Ad(t,r,l,c,f){for(var h=r._reactName,k=[];l!==null&&l!==c;){var $=l,O=$.alternate,Q=$.stateNode;if(O!==null&&O===c)break;$.tag===5&&Q!==null&&($=Q,f?(O=Ot(l,h),O!=null&&k.unshift(Ba(l,O,$))):f||(O=Ot(l,h),O!=null&&k.push(Ba(l,O,$)))),l=l.return}k.length!==0&&t.push({event:r,listeners:k})}var cg=/\r\n?/g,ug=/\u0000|\uFFFD/g;function $d(t){return(typeof t=="string"?t:""+t).replace(cg,`
23
- `).replace(ug,"")}function Fl(t,r,l){if(r=$d(r),$d(t)!==r&&l)throw Error(a(425))}function Ll(){}var Mi=null,Fi=null;function Li(t,r){return t==="textarea"||t==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var _i=typeof setTimeout=="function"?setTimeout:void 0,dg=typeof clearTimeout=="function"?clearTimeout:void 0,Md=typeof Promise=="function"?Promise:void 0,fg=typeof queueMicrotask=="function"?queueMicrotask:typeof Md<"u"?function(t){return Md.resolve(null).then(t).catch(pg)}:_i;function pg(t){setTimeout(function(){throw t})}function Oi(t,r){var l=r,c=0;do{var f=l.nextSibling;if(t.removeChild(l),f&&f.nodeType===8)if(l=f.data,l==="/$"){if(c===0){t.removeChild(f),Un(r);return}c--}else l!=="$"&&l!=="$?"&&l!=="$!"||c++;l=f}while(l);Un(r)}function Ur(t){for(;t!=null;t=t.nextSibling){var r=t.nodeType;if(r===1||r===3)break;if(r===8){if(r=t.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return t}function Fd(t){t=t.previousSibling;for(var r=0;t;){if(t.nodeType===8){var l=t.data;if(l==="$"||l==="$!"||l==="$?"){if(r===0)return t;r--}else l==="/$"&&r++}t=t.previousSibling}return null}var sa=Math.random().toString(36).slice(2),rr="__reactFiber$"+sa,za="__reactProps$"+sa,jr="__reactContainer$"+sa,Di="__reactEvents$"+sa,mg="__reactListeners$"+sa,hg="__reactHandles$"+sa;function ys(t){var r=t[rr];if(r)return r;for(var l=t.parentNode;l;){if(r=l[jr]||l[rr]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(t=Fd(t);t!==null;){if(l=t[rr])return l;t=Fd(t)}return r}t=l,l=t.parentNode}return null}function qa(t){return t=t[rr]||t[jr],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function aa(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(a(33))}function _l(t){return t[za]||null}var Bi=[],la=-1;function Kr(t){return{current:t}}function et(t){0>la||(t.current=Bi[la],Bi[la]=null,la--)}function Xe(t,r){la++,Bi[la]=t.current,t.current=r}var Hr={},Bt=Kr(Hr),Jt=Kr(!1),vs=Hr;function oa(t,r){var l=t.type.contextTypes;if(!l)return Hr;var c=t.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===r)return c.__reactInternalMemoizedMaskedChildContext;var f={},h;for(h in l)f[h]=r[h];return c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=r,t.__reactInternalMemoizedMaskedChildContext=f),f}function Zt(t){return t=t.childContextTypes,t!=null}function Ol(){et(Jt),et(Bt)}function Ld(t,r,l){if(Bt.current!==Hr)throw Error(a(168));Xe(Bt,r),Xe(Jt,l)}function _d(t,r,l){var c=t.stateNode;if(r=r.childContextTypes,typeof c.getChildContext!="function")return l;c=c.getChildContext();for(var f in c)if(!(f in r))throw Error(a(108,We(t)||"Unknown",f));return K({},l,c)}function Dl(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Hr,vs=Bt.current,Xe(Bt,t),Xe(Jt,Jt.current),!0}function Od(t,r,l){var c=t.stateNode;if(!c)throw Error(a(169));l?(t=_d(t,r,vs),c.__reactInternalMemoizedMergedChildContext=t,et(Jt),et(Bt),Xe(Bt,t)):et(Jt),Xe(Jt,l)}var Nr=null,Bl=!1,zi=!1;function Dd(t){Nr===null?Nr=[t]:Nr.push(t)}function gg(t){Bl=!0,Dd(t)}function Wr(){if(!zi&&Nr!==null){zi=!0;var t=0,r=$e;try{var l=Nr;for($e=1;t<l.length;t++){var c=l[t];do c=c(!0);while(c!==null)}Nr=null,Bl=!1}catch(f){throw Nr!==null&&(Nr=Nr.slice(t+1)),_r(Xs,Wr),f}finally{$e=r,zi=!1}}return null}var ia=[],ca=0,zl=null,ql=0,Sn=[],Cn=0,bs=null,Sr=1,Cr="";function ws(t,r){ia[ca++]=ql,ia[ca++]=zl,zl=t,ql=r}function Bd(t,r,l){Sn[Cn++]=Sr,Sn[Cn++]=Cr,Sn[Cn++]=bs,bs=t;var c=Sr;t=Cr;var f=32-J(c)-1;c&=~(1<<f),l+=1;var h=32-J(r)+f;if(30<h){var k=f-f%5;h=(c&(1<<k)-1).toString(32),c>>=k,f-=k,Sr=1<<32-J(r)+f|l<<f|c,Cr=h+t}else Sr=1<<h|l<<f|c,Cr=t}function qi(t){t.return!==null&&(ws(t,1),Bd(t,1,0))}function Ui(t){for(;t===zl;)zl=ia[--ca],ia[ca]=null,ql=ia[--ca],ia[ca]=null;for(;t===bs;)bs=Sn[--Cn],Sn[Cn]=null,Cr=Sn[--Cn],Sn[Cn]=null,Sr=Sn[--Cn],Sn[Cn]=null}var mn=null,hn=null,nt=!1,Hn=null;function zd(t,r){var l=En(5,null,null,0);l.elementType="DELETED",l.stateNode=r,l.return=t,r=t.deletions,r===null?(t.deletions=[l],t.flags|=16):r.push(l)}function qd(t,r){switch(t.tag){case 5:var l=t.type;return r=r.nodeType!==1||l.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(t.stateNode=r,mn=t,hn=Ur(r.firstChild),!0):!1;case 6:return r=t.pendingProps===""||r.nodeType!==3?null:r,r!==null?(t.stateNode=r,mn=t,hn=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(l=bs!==null?{id:Sr,overflow:Cr}:null,t.memoizedState={dehydrated:r,treeContext:l,retryLane:1073741824},l=En(18,null,null,0),l.stateNode=r,l.return=t,t.child=l,mn=t,hn=null,!0):!1;default:return!1}}function Ki(t){return(t.mode&1)!==0&&(t.flags&128)===0}function Hi(t){if(nt){var r=hn;if(r){var l=r;if(!qd(t,r)){if(Ki(t))throw Error(a(418));r=Ur(l.nextSibling);var c=mn;r&&qd(t,r)?zd(c,l):(t.flags=t.flags&-4097|2,nt=!1,mn=t)}}else{if(Ki(t))throw Error(a(418));t.flags=t.flags&-4097|2,nt=!1,mn=t}}}function Ud(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;mn=t}function Ul(t){if(t!==mn)return!1;if(!nt)return Ud(t),nt=!0,!1;var r;if((r=t.tag!==3)&&!(r=t.tag!==5)&&(r=t.type,r=r!=="head"&&r!=="body"&&!Li(t.type,t.memoizedProps)),r&&(r=hn)){if(Ki(t))throw Kd(),Error(a(418));for(;r;)zd(t,r),r=Ur(r.nextSibling)}if(Ud(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(a(317));e:{for(t=t.nextSibling,r=0;t;){if(t.nodeType===8){var l=t.data;if(l==="/$"){if(r===0){hn=Ur(t.nextSibling);break e}r--}else l!=="$"&&l!=="$!"&&l!=="$?"||r++}t=t.nextSibling}hn=null}}else hn=mn?Ur(t.stateNode.nextSibling):null;return!0}function Kd(){for(var t=hn;t;)t=Ur(t.nextSibling)}function ua(){hn=mn=null,nt=!1}function Wi(t){Hn===null?Hn=[t]:Hn.push(t)}var xg=j.ReactCurrentBatchConfig;function Ua(t,r,l){if(t=l.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(a(309));var c=l.stateNode}if(!c)throw Error(a(147,t));var f=c,h=""+t;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===h?r.ref:(r=function(k){var $=f.refs;k===null?delete $[h]:$[h]=k},r._stringRef=h,r)}if(typeof t!="string")throw Error(a(284));if(!l._owner)throw Error(a(290,t))}return t}function Kl(t,r){throw t=Object.prototype.toString.call(r),Error(a(31,t==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":t))}function Hd(t){var r=t._init;return r(t._payload)}function Wd(t){function r(q,z){if(t){var V=q.deletions;V===null?(q.deletions=[z],q.flags|=16):V.push(z)}}function l(q,z){if(!t)return null;for(;z!==null;)r(q,z),z=z.sibling;return null}function c(q,z){for(q=new Map;z!==null;)z.key!==null?q.set(z.key,z):q.set(z.index,z),z=z.sibling;return q}function f(q,z){return q=es(q,z),q.index=0,q.sibling=null,q}function h(q,z,V){return q.index=V,t?(V=q.alternate,V!==null?(V=V.index,V<z?(q.flags|=2,z):V):(q.flags|=2,z)):(q.flags|=1048576,z)}function k(q){return t&&q.alternate===null&&(q.flags|=2),q}function $(q,z,V,pe){return z===null||z.tag!==6?(z=_c(V,q.mode,pe),z.return=q,z):(z=f(z,V),z.return=q,z)}function O(q,z,V,pe){var Ce=V.type;return Ce===D?ue(q,z,V.props.children,pe,V.key):z!==null&&(z.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===ee&&Hd(Ce)===z.type)?(pe=f(z,V.props),pe.ref=Ua(q,z,V),pe.return=q,pe):(pe=ho(V.type,V.key,V.props,null,q.mode,pe),pe.ref=Ua(q,z,V),pe.return=q,pe)}function Q(q,z,V,pe){return z===null||z.tag!==4||z.stateNode.containerInfo!==V.containerInfo||z.stateNode.implementation!==V.implementation?(z=Oc(V,q.mode,pe),z.return=q,z):(z=f(z,V.children||[]),z.return=q,z)}function ue(q,z,V,pe,Ce){return z===null||z.tag!==7?(z=Ts(V,q.mode,pe,Ce),z.return=q,z):(z=f(z,V),z.return=q,z)}function fe(q,z,V){if(typeof z=="string"&&z!==""||typeof z=="number")return z=_c(""+z,q.mode,V),z.return=q,z;if(typeof z=="object"&&z!==null){switch(z.$$typeof){case T:return V=ho(z.type,z.key,z.props,null,q.mode,V),V.ref=Ua(q,null,z),V.return=q,V;case M:return z=Oc(z,q.mode,V),z.return=q,z;case ee:var pe=z._init;return fe(q,pe(z._payload),V)}if(Xn(z)||F(z))return z=Ts(z,q.mode,V,null),z.return=q,z;Kl(q,z)}return null}function ie(q,z,V,pe){var Ce=z!==null?z.key:null;if(typeof V=="string"&&V!==""||typeof V=="number")return Ce!==null?null:$(q,z,""+V,pe);if(typeof V=="object"&&V!==null){switch(V.$$typeof){case T:return V.key===Ce?O(q,z,V,pe):null;case M:return V.key===Ce?Q(q,z,V,pe):null;case ee:return Ce=V._init,ie(q,z,Ce(V._payload),pe)}if(Xn(V)||F(V))return Ce!==null?null:ue(q,z,V,pe,null);Kl(q,V)}return null}function be(q,z,V,pe,Ce){if(typeof pe=="string"&&pe!==""||typeof pe=="number")return q=q.get(V)||null,$(z,q,""+pe,Ce);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case T:return q=q.get(pe.key===null?V:pe.key)||null,O(z,q,pe,Ce);case M:return q=q.get(pe.key===null?V:pe.key)||null,Q(z,q,pe,Ce);case ee:var Te=pe._init;return be(q,z,V,Te(pe._payload),Ce)}if(Xn(pe)||F(pe))return q=q.get(V)||null,ue(z,q,pe,Ce,null);Kl(z,pe)}return null}function Ne(q,z,V,pe){for(var Ce=null,Te=null,Ee=z,Me=z=0,Tt=null;Ee!==null&&Me<V.length;Me++){Ee.index>Me?(Tt=Ee,Ee=null):Tt=Ee.sibling;var Qe=ie(q,Ee,V[Me],pe);if(Qe===null){Ee===null&&(Ee=Tt);break}t&&Ee&&Qe.alternate===null&&r(q,Ee),z=h(Qe,z,Me),Te===null?Ce=Qe:Te.sibling=Qe,Te=Qe,Ee=Tt}if(Me===V.length)return l(q,Ee),nt&&ws(q,Me),Ce;if(Ee===null){for(;Me<V.length;Me++)Ee=fe(q,V[Me],pe),Ee!==null&&(z=h(Ee,z,Me),Te===null?Ce=Ee:Te.sibling=Ee,Te=Ee);return nt&&ws(q,Me),Ce}for(Ee=c(q,Ee);Me<V.length;Me++)Tt=be(Ee,q,Me,V[Me],pe),Tt!==null&&(t&&Tt.alternate!==null&&Ee.delete(Tt.key===null?Me:Tt.key),z=h(Tt,z,Me),Te===null?Ce=Tt:Te.sibling=Tt,Te=Tt);return t&&Ee.forEach(function(ts){return r(q,ts)}),nt&&ws(q,Me),Ce}function Se(q,z,V,pe){var Ce=F(V);if(typeof Ce!="function")throw Error(a(150));if(V=Ce.call(V),V==null)throw Error(a(151));for(var Te=Ce=null,Ee=z,Me=z=0,Tt=null,Qe=V.next();Ee!==null&&!Qe.done;Me++,Qe=V.next()){Ee.index>Me?(Tt=Ee,Ee=null):Tt=Ee.sibling;var ts=ie(q,Ee,Qe.value,pe);if(ts===null){Ee===null&&(Ee=Tt);break}t&&Ee&&ts.alternate===null&&r(q,Ee),z=h(ts,z,Me),Te===null?Ce=ts:Te.sibling=ts,Te=ts,Ee=Tt}if(Qe.done)return l(q,Ee),nt&&ws(q,Me),Ce;if(Ee===null){for(;!Qe.done;Me++,Qe=V.next())Qe=fe(q,Qe.value,pe),Qe!==null&&(z=h(Qe,z,Me),Te===null?Ce=Qe:Te.sibling=Qe,Te=Qe);return nt&&ws(q,Me),Ce}for(Ee=c(q,Ee);!Qe.done;Me++,Qe=V.next())Qe=be(Ee,q,Me,Qe.value,pe),Qe!==null&&(t&&Qe.alternate!==null&&Ee.delete(Qe.key===null?Me:Qe.key),z=h(Qe,z,Me),Te===null?Ce=Qe:Te.sibling=Qe,Te=Qe);return t&&Ee.forEach(function(Yg){return r(q,Yg)}),nt&&ws(q,Me),Ce}function ut(q,z,V,pe){if(typeof V=="object"&&V!==null&&V.type===D&&V.key===null&&(V=V.props.children),typeof V=="object"&&V!==null){switch(V.$$typeof){case T:e:{for(var Ce=V.key,Te=z;Te!==null;){if(Te.key===Ce){if(Ce=V.type,Ce===D){if(Te.tag===7){l(q,Te.sibling),z=f(Te,V.props.children),z.return=q,q=z;break e}}else if(Te.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===ee&&Hd(Ce)===Te.type){l(q,Te.sibling),z=f(Te,V.props),z.ref=Ua(q,Te,V),z.return=q,q=z;break e}l(q,Te);break}else r(q,Te);Te=Te.sibling}V.type===D?(z=Ts(V.props.children,q.mode,pe,V.key),z.return=q,q=z):(pe=ho(V.type,V.key,V.props,null,q.mode,pe),pe.ref=Ua(q,z,V),pe.return=q,q=pe)}return k(q);case M:e:{for(Te=V.key;z!==null;){if(z.key===Te)if(z.tag===4&&z.stateNode.containerInfo===V.containerInfo&&z.stateNode.implementation===V.implementation){l(q,z.sibling),z=f(z,V.children||[]),z.return=q,q=z;break e}else{l(q,z);break}else r(q,z);z=z.sibling}z=Oc(V,q.mode,pe),z.return=q,q=z}return k(q);case ee:return Te=V._init,ut(q,z,Te(V._payload),pe)}if(Xn(V))return Ne(q,z,V,pe);if(F(V))return Se(q,z,V,pe);Kl(q,V)}return typeof V=="string"&&V!==""||typeof V=="number"?(V=""+V,z!==null&&z.tag===6?(l(q,z.sibling),z=f(z,V),z.return=q,q=z):(l(q,z),z=_c(V,q.mode,pe),z.return=q,q=z),k(q)):l(q,z)}return ut}var da=Wd(!0),Vd=Wd(!1),Hl=Kr(null),Wl=null,fa=null,Vi=null;function Qi(){Vi=fa=Wl=null}function Gi(t){var r=Hl.current;et(Hl),t._currentValue=r}function Yi(t,r,l){for(;t!==null;){var c=t.alternate;if((t.childLanes&r)!==r?(t.childLanes|=r,c!==null&&(c.childLanes|=r)):c!==null&&(c.childLanes&r)!==r&&(c.childLanes|=r),t===l)break;t=t.return}}function pa(t,r){Wl=t,Vi=fa=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&r)!==0&&(en=!0),t.firstContext=null)}function Rn(t){var r=t._currentValue;if(Vi!==t)if(t={context:t,memoizedValue:r,next:null},fa===null){if(Wl===null)throw Error(a(308));fa=t,Wl.dependencies={lanes:0,firstContext:t}}else fa=fa.next=t;return r}var ks=null;function Xi(t){ks===null?ks=[t]:ks.push(t)}function Qd(t,r,l,c){var f=r.interleaved;return f===null?(l.next=l,Xi(r)):(l.next=f.next,f.next=l),r.interleaved=l,Rr(t,c)}function Rr(t,r){t.lanes|=r;var l=t.alternate;for(l!==null&&(l.lanes|=r),l=t,t=t.return;t!==null;)t.childLanes|=r,l=t.alternate,l!==null&&(l.childLanes|=r),l=t,t=t.return;return l.tag===3?l.stateNode:null}var Vr=!1;function Ji(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Gd(t,r){t=t.updateQueue,r.updateQueue===t&&(r.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Ir(t,r){return{eventTime:t,lane:r,tag:0,payload:null,callback:null,next:null}}function Qr(t,r,l){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(Ve&2)!==0){var f=c.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),c.pending=r,Rr(t,l)}return f=c.interleaved,f===null?(r.next=r,Xi(c)):(r.next=f.next,f.next=r),c.interleaved=r,Rr(t,l)}function Vl(t,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194240)!==0)){var c=r.lanes;c&=t.pendingLanes,l|=c,r.lanes=l,Ct(t,l)}}function Yd(t,r){var l=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,l===c)){var f=null,h=null;if(l=l.firstBaseUpdate,l!==null){do{var k={eventTime:l.eventTime,lane:l.lane,tag:l.tag,payload:l.payload,callback:l.callback,next:null};h===null?f=h=k:h=h.next=k,l=l.next}while(l!==null);h===null?f=h=r:h=h.next=r}else f=h=r;l={baseState:c.baseState,firstBaseUpdate:f,lastBaseUpdate:h,shared:c.shared,effects:c.effects},t.updateQueue=l;return}t=l.lastBaseUpdate,t===null?l.firstBaseUpdate=r:t.next=r,l.lastBaseUpdate=r}function Ql(t,r,l,c){var f=t.updateQueue;Vr=!1;var h=f.firstBaseUpdate,k=f.lastBaseUpdate,$=f.shared.pending;if($!==null){f.shared.pending=null;var O=$,Q=O.next;O.next=null,k===null?h=Q:k.next=Q,k=O;var ue=t.alternate;ue!==null&&(ue=ue.updateQueue,$=ue.lastBaseUpdate,$!==k&&($===null?ue.firstBaseUpdate=Q:$.next=Q,ue.lastBaseUpdate=O))}if(h!==null){var fe=f.baseState;k=0,ue=Q=O=null,$=h;do{var ie=$.lane,be=$.eventTime;if((c&ie)===ie){ue!==null&&(ue=ue.next={eventTime:be,lane:0,tag:$.tag,payload:$.payload,callback:$.callback,next:null});e:{var Ne=t,Se=$;switch(ie=r,be=l,Se.tag){case 1:if(Ne=Se.payload,typeof Ne=="function"){fe=Ne.call(be,fe,ie);break e}fe=Ne;break e;case 3:Ne.flags=Ne.flags&-65537|128;case 0:if(Ne=Se.payload,ie=typeof Ne=="function"?Ne.call(be,fe,ie):Ne,ie==null)break e;fe=K({},fe,ie);break e;case 2:Vr=!0}}$.callback!==null&&$.lane!==0&&(t.flags|=64,ie=f.effects,ie===null?f.effects=[$]:ie.push($))}else be={eventTime:be,lane:ie,tag:$.tag,payload:$.payload,callback:$.callback,next:null},ue===null?(Q=ue=be,O=fe):ue=ue.next=be,k|=ie;if($=$.next,$===null){if($=f.shared.pending,$===null)break;ie=$,$=ie.next,ie.next=null,f.lastBaseUpdate=ie,f.shared.pending=null}}while(!0);if(ue===null&&(O=fe),f.baseState=O,f.firstBaseUpdate=Q,f.lastBaseUpdate=ue,r=f.shared.interleaved,r!==null){f=r;do k|=f.lane,f=f.next;while(f!==r)}else h===null&&(f.shared.lanes=0);Ss|=k,t.lanes=k,t.memoizedState=fe}}function Xd(t,r,l){if(t=r.effects,r.effects=null,t!==null)for(r=0;r<t.length;r++){var c=t[r],f=c.callback;if(f!==null){if(c.callback=null,c=l,typeof f!="function")throw Error(a(191,f));f.call(c)}}}var Ka={},sr=Kr(Ka),Ha=Kr(Ka),Wa=Kr(Ka);function js(t){if(t===Ka)throw Error(a(174));return t}function Zi(t,r){switch(Xe(Wa,r),Xe(Ha,t),Xe(sr,Ka),t=r.nodeType,t){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:On(null,"");break;default:t=t===8?r.parentNode:r,r=t.namespaceURI||null,t=t.tagName,r=On(r,t)}et(sr),Xe(sr,r)}function ma(){et(sr),et(Ha),et(Wa)}function Jd(t){js(Wa.current);var r=js(sr.current),l=On(r,t.type);r!==l&&(Xe(Ha,t),Xe(sr,l))}function ec(t){Ha.current===t&&(et(sr),et(Ha))}var lt=Kr(0);function Gl(t){for(var r=t;r!==null;){if(r.tag===13){var l=r.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||l.data==="$?"||l.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var tc=[];function nc(){for(var t=0;t<tc.length;t++)tc[t]._workInProgressVersionPrimary=null;tc.length=0}var Yl=j.ReactCurrentDispatcher,rc=j.ReactCurrentBatchConfig,Ns=0,ot=null,yt=null,Rt=null,Xl=!1,Va=!1,Qa=0,yg=0;function zt(){throw Error(a(321))}function sc(t,r){if(r===null)return!1;for(var l=0;l<r.length&&l<t.length;l++)if(!Kn(t[l],r[l]))return!1;return!0}function ac(t,r,l,c,f,h){if(Ns=h,ot=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Yl.current=t===null||t.memoizedState===null?kg:jg,t=l(c,f),Va){h=0;do{if(Va=!1,Qa=0,25<=h)throw Error(a(301));h+=1,Rt=yt=null,r.updateQueue=null,Yl.current=Ng,t=l(c,f)}while(Va)}if(Yl.current=eo,r=yt!==null&&yt.next!==null,Ns=0,Rt=yt=ot=null,Xl=!1,r)throw Error(a(300));return t}function lc(){var t=Qa!==0;return Qa=0,t}function ar(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Rt===null?ot.memoizedState=Rt=t:Rt=Rt.next=t,Rt}function In(){if(yt===null){var t=ot.alternate;t=t!==null?t.memoizedState:null}else t=yt.next;var r=Rt===null?ot.memoizedState:Rt.next;if(r!==null)Rt=r,yt=t;else{if(t===null)throw Error(a(310));yt=t,t={memoizedState:yt.memoizedState,baseState:yt.baseState,baseQueue:yt.baseQueue,queue:yt.queue,next:null},Rt===null?ot.memoizedState=Rt=t:Rt=Rt.next=t}return Rt}function Ga(t,r){return typeof r=="function"?r(t):r}function oc(t){var r=In(),l=r.queue;if(l===null)throw Error(a(311));l.lastRenderedReducer=t;var c=yt,f=c.baseQueue,h=l.pending;if(h!==null){if(f!==null){var k=f.next;f.next=h.next,h.next=k}c.baseQueue=f=h,l.pending=null}if(f!==null){h=f.next,c=c.baseState;var $=k=null,O=null,Q=h;do{var ue=Q.lane;if((Ns&ue)===ue)O!==null&&(O=O.next={lane:0,action:Q.action,hasEagerState:Q.hasEagerState,eagerState:Q.eagerState,next:null}),c=Q.hasEagerState?Q.eagerState:t(c,Q.action);else{var fe={lane:ue,action:Q.action,hasEagerState:Q.hasEagerState,eagerState:Q.eagerState,next:null};O===null?($=O=fe,k=c):O=O.next=fe,ot.lanes|=ue,Ss|=ue}Q=Q.next}while(Q!==null&&Q!==h);O===null?k=c:O.next=$,Kn(c,r.memoizedState)||(en=!0),r.memoizedState=c,r.baseState=k,r.baseQueue=O,l.lastRenderedState=c}if(t=l.interleaved,t!==null){f=t;do h=f.lane,ot.lanes|=h,Ss|=h,f=f.next;while(f!==t)}else f===null&&(l.lanes=0);return[r.memoizedState,l.dispatch]}function ic(t){var r=In(),l=r.queue;if(l===null)throw Error(a(311));l.lastRenderedReducer=t;var c=l.dispatch,f=l.pending,h=r.memoizedState;if(f!==null){l.pending=null;var k=f=f.next;do h=t(h,k.action),k=k.next;while(k!==f);Kn(h,r.memoizedState)||(en=!0),r.memoizedState=h,r.baseQueue===null&&(r.baseState=h),l.lastRenderedState=h}return[h,c]}function Zd(){}function ef(t,r){var l=ot,c=In(),f=r(),h=!Kn(c.memoizedState,f);if(h&&(c.memoizedState=f,en=!0),c=c.queue,cc(rf.bind(null,l,c,t),[t]),c.getSnapshot!==r||h||Rt!==null&&Rt.memoizedState.tag&1){if(l.flags|=2048,Ya(9,nf.bind(null,l,c,f,r),void 0,null),It===null)throw Error(a(349));(Ns&30)!==0||tf(l,r,f)}return f}function tf(t,r,l){t.flags|=16384,t={getSnapshot:r,value:l},r=ot.updateQueue,r===null?(r={lastEffect:null,stores:null},ot.updateQueue=r,r.stores=[t]):(l=r.stores,l===null?r.stores=[t]:l.push(t))}function nf(t,r,l,c){r.value=l,r.getSnapshot=c,sf(r)&&af(t)}function rf(t,r,l){return l(function(){sf(r)&&af(t)})}function sf(t){var r=t.getSnapshot;t=t.value;try{var l=r();return!Kn(t,l)}catch{return!0}}function af(t){var r=Rr(t,1);r!==null&&Gn(r,t,1,-1)}function lf(t){var r=ar();return typeof t=="function"&&(t=t()),r.memoizedState=r.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ga,lastRenderedState:t},r.queue=t,t=t.dispatch=wg.bind(null,ot,t),[r.memoizedState,t]}function Ya(t,r,l,c){return t={tag:t,create:r,destroy:l,deps:c,next:null},r=ot.updateQueue,r===null?(r={lastEffect:null,stores:null},ot.updateQueue=r,r.lastEffect=t.next=t):(l=r.lastEffect,l===null?r.lastEffect=t.next=t:(c=l.next,l.next=t,t.next=c,r.lastEffect=t)),t}function of(){return In().memoizedState}function Jl(t,r,l,c){var f=ar();ot.flags|=t,f.memoizedState=Ya(1|r,l,void 0,c===void 0?null:c)}function Zl(t,r,l,c){var f=In();c=c===void 0?null:c;var h=void 0;if(yt!==null){var k=yt.memoizedState;if(h=k.destroy,c!==null&&sc(c,k.deps)){f.memoizedState=Ya(r,l,h,c);return}}ot.flags|=t,f.memoizedState=Ya(1|r,l,h,c)}function cf(t,r){return Jl(8390656,8,t,r)}function cc(t,r){return Zl(2048,8,t,r)}function uf(t,r){return Zl(4,2,t,r)}function df(t,r){return Zl(4,4,t,r)}function ff(t,r){if(typeof r=="function")return t=t(),r(t),function(){r(null)};if(r!=null)return t=t(),r.current=t,function(){r.current=null}}function pf(t,r,l){return l=l!=null?l.concat([t]):null,Zl(4,4,ff.bind(null,r,t),l)}function uc(){}function mf(t,r){var l=In();r=r===void 0?null:r;var c=l.memoizedState;return c!==null&&r!==null&&sc(r,c[1])?c[0]:(l.memoizedState=[t,r],t)}function hf(t,r){var l=In();r=r===void 0?null:r;var c=l.memoizedState;return c!==null&&r!==null&&sc(r,c[1])?c[0]:(t=t(),l.memoizedState=[t,r],t)}function gf(t,r,l){return(Ns&21)===0?(t.baseState&&(t.baseState=!1,en=!0),t.memoizedState=l):(Kn(l,r)||(l=we(),ot.lanes|=l,Ss|=l,t.baseState=!0),r)}function vg(t,r){var l=$e;$e=l!==0&&4>l?l:4,t(!0);var c=rc.transition;rc.transition={};try{t(!1),r()}finally{$e=l,rc.transition=c}}function xf(){return In().memoizedState}function bg(t,r,l){var c=Jr(t);if(l={lane:c,action:l,hasEagerState:!1,eagerState:null,next:null},yf(t))vf(r,l);else if(l=Qd(t,r,l,c),l!==null){var f=Vt();Gn(l,t,c,f),bf(l,r,c)}}function wg(t,r,l){var c=Jr(t),f={lane:c,action:l,hasEagerState:!1,eagerState:null,next:null};if(yf(t))vf(r,f);else{var h=t.alternate;if(t.lanes===0&&(h===null||h.lanes===0)&&(h=r.lastRenderedReducer,h!==null))try{var k=r.lastRenderedState,$=h(k,l);if(f.hasEagerState=!0,f.eagerState=$,Kn($,k)){var O=r.interleaved;O===null?(f.next=f,Xi(r)):(f.next=O.next,O.next=f),r.interleaved=f;return}}catch{}finally{}l=Qd(t,r,f,c),l!==null&&(f=Vt(),Gn(l,t,c,f),bf(l,r,c))}}function yf(t){var r=t.alternate;return t===ot||r!==null&&r===ot}function vf(t,r){Va=Xl=!0;var l=t.pending;l===null?r.next=r:(r.next=l.next,l.next=r),t.pending=r}function bf(t,r,l){if((l&4194240)!==0){var c=r.lanes;c&=t.pendingLanes,l|=c,r.lanes=l,Ct(t,l)}}var eo={readContext:Rn,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useInsertionEffect:zt,useLayoutEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useMutableSource:zt,useSyncExternalStore:zt,useId:zt,unstable_isNewReconciler:!1},kg={readContext:Rn,useCallback:function(t,r){return ar().memoizedState=[t,r===void 0?null:r],t},useContext:Rn,useEffect:cf,useImperativeHandle:function(t,r,l){return l=l!=null?l.concat([t]):null,Jl(4194308,4,ff.bind(null,r,t),l)},useLayoutEffect:function(t,r){return Jl(4194308,4,t,r)},useInsertionEffect:function(t,r){return Jl(4,2,t,r)},useMemo:function(t,r){var l=ar();return r=r===void 0?null:r,t=t(),l.memoizedState=[t,r],t},useReducer:function(t,r,l){var c=ar();return r=l!==void 0?l(r):r,c.memoizedState=c.baseState=r,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:r},c.queue=t,t=t.dispatch=bg.bind(null,ot,t),[c.memoizedState,t]},useRef:function(t){var r=ar();return t={current:t},r.memoizedState=t},useState:lf,useDebugValue:uc,useDeferredValue:function(t){return ar().memoizedState=t},useTransition:function(){var t=lf(!1),r=t[0];return t=vg.bind(null,t[1]),ar().memoizedState=t,[r,t]},useMutableSource:function(){},useSyncExternalStore:function(t,r,l){var c=ot,f=ar();if(nt){if(l===void 0)throw Error(a(407));l=l()}else{if(l=r(),It===null)throw Error(a(349));(Ns&30)!==0||tf(c,r,l)}f.memoizedState=l;var h={value:l,getSnapshot:r};return f.queue=h,cf(rf.bind(null,c,h,t),[t]),c.flags|=2048,Ya(9,nf.bind(null,c,h,l,r),void 0,null),l},useId:function(){var t=ar(),r=It.identifierPrefix;if(nt){var l=Cr,c=Sr;l=(c&~(1<<32-J(c)-1)).toString(32)+l,r=":"+r+"R"+l,l=Qa++,0<l&&(r+="H"+l.toString(32)),r+=":"}else l=yg++,r=":"+r+"r"+l.toString(32)+":";return t.memoizedState=r},unstable_isNewReconciler:!1},jg={readContext:Rn,useCallback:mf,useContext:Rn,useEffect:cc,useImperativeHandle:pf,useInsertionEffect:uf,useLayoutEffect:df,useMemo:hf,useReducer:oc,useRef:of,useState:function(){return oc(Ga)},useDebugValue:uc,useDeferredValue:function(t){var r=In();return gf(r,yt.memoizedState,t)},useTransition:function(){var t=oc(Ga)[0],r=In().memoizedState;return[t,r]},useMutableSource:Zd,useSyncExternalStore:ef,useId:xf,unstable_isNewReconciler:!1},Ng={readContext:Rn,useCallback:mf,useContext:Rn,useEffect:cc,useImperativeHandle:pf,useInsertionEffect:uf,useLayoutEffect:df,useMemo:hf,useReducer:ic,useRef:of,useState:function(){return ic(Ga)},useDebugValue:uc,useDeferredValue:function(t){var r=In();return yt===null?r.memoizedState=t:gf(r,yt.memoizedState,t)},useTransition:function(){var t=ic(Ga)[0],r=In().memoizedState;return[t,r]},useMutableSource:Zd,useSyncExternalStore:ef,useId:xf,unstable_isNewReconciler:!1};function Wn(t,r){if(t&&t.defaultProps){r=K({},r),t=t.defaultProps;for(var l in t)r[l]===void 0&&(r[l]=t[l]);return r}return r}function dc(t,r,l,c){r=t.memoizedState,l=l(c,r),l=l==null?r:K({},r,l),t.memoizedState=l,t.lanes===0&&(t.updateQueue.baseState=l)}var to={isMounted:function(t){return(t=t._reactInternals)?tr(t)===t:!1},enqueueSetState:function(t,r,l){t=t._reactInternals;var c=Vt(),f=Jr(t),h=Ir(c,f);h.payload=r,l!=null&&(h.callback=l),r=Qr(t,h,f),r!==null&&(Gn(r,t,f,c),Vl(r,t,f))},enqueueReplaceState:function(t,r,l){t=t._reactInternals;var c=Vt(),f=Jr(t),h=Ir(c,f);h.tag=1,h.payload=r,l!=null&&(h.callback=l),r=Qr(t,h,f),r!==null&&(Gn(r,t,f,c),Vl(r,t,f))},enqueueForceUpdate:function(t,r){t=t._reactInternals;var l=Vt(),c=Jr(t),f=Ir(l,c);f.tag=2,r!=null&&(f.callback=r),r=Qr(t,f,c),r!==null&&(Gn(r,t,c,l),Vl(r,t,c))}};function wf(t,r,l,c,f,h,k){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(c,h,k):r.prototype&&r.prototype.isPureReactComponent?!La(l,c)||!La(f,h):!0}function kf(t,r,l){var c=!1,f=Hr,h=r.contextType;return typeof h=="object"&&h!==null?h=Rn(h):(f=Zt(r)?vs:Bt.current,c=r.contextTypes,h=(c=c!=null)?oa(t,f):Hr),r=new r(l,h),t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=to,t.stateNode=r,r._reactInternals=t,c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=f,t.__reactInternalMemoizedMaskedChildContext=h),r}function jf(t,r,l,c){t=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(l,c),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(l,c),r.state!==t&&to.enqueueReplaceState(r,r.state,null)}function fc(t,r,l,c){var f=t.stateNode;f.props=l,f.state=t.memoizedState,f.refs={},Ji(t);var h=r.contextType;typeof h=="object"&&h!==null?f.context=Rn(h):(h=Zt(r)?vs:Bt.current,f.context=oa(t,h)),f.state=t.memoizedState,h=r.getDerivedStateFromProps,typeof h=="function"&&(dc(t,r,h,l),f.state=t.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof f.getSnapshotBeforeUpdate=="function"||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(r=f.state,typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount(),r!==f.state&&to.enqueueReplaceState(f,f.state,null),Ql(t,l,f,c),f.state=t.memoizedState),typeof f.componentDidMount=="function"&&(t.flags|=4194308)}function ha(t,r){try{var l="",c=r;do l+=Z(c),c=c.return;while(c);var f=l}catch(h){f=`
21
+ `),k=f.length-1,M=h.length-1;1<=k&&0<=M&&f[k]!==h[M];)M--;for(;1<=k&&0<=M;k--,M--)if(f[k]!==h[M]){if(k!==1||M!==1)do if(k--,M--,0>M||f[k]!==h[M]){var D=`
22
+ `+f[k].replace(" at new "," at ");return t.displayName&&D.includes("<anonymous>")&&(D=D.replace("<anonymous>",t.displayName)),D}while(1<=k&&0<=M);break}}}finally{Pe=!1,Error.prepareStackTrace=l}return(t=t?t.displayName||t.name:"")?ne(t):""}function Z(t){switch(t.tag){case 5:return ne(t.type);case 16:return ne("Lazy");case 13:return ne("Suspense");case 19:return ne("SuspenseList");case 0:case 2:case 15:return t=se(t.type,!1),t;case 11:return t=se(t.type.render,!1),t;case 1:return t=se(t.type,!0),t;default:return""}}function je(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case L:return"Fragment";case $:return"Portal";case Q:return"Profiler";case q:return"StrictMode";case B:return"Suspense";case O:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Y:return(t.displayName||"Context")+".Consumer";case _:return(t._context.displayName||"Context")+".Provider";case X:var r=t.render;return t=t.displayName,t||(t=r.displayName||r.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case H:return r=t.displayName||null,r!==null?r:je(t.type)||"Memo";case ee:r=t._payload,t=t._init;try{return je(t(r))}catch{}}return null}function We(t){var r=t.type;switch(t.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=r.render,t=t.displayName||t.name||"",r.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return je(r);case 8:return r===q?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r}return null}function st(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Pt(t){var r=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Lt(t){var r=Pt(t)?"checked":"value",l=Object.getOwnPropertyDescriptor(t.constructor.prototype,r),c=""+t[r];if(!t.hasOwnProperty(r)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var f=l.get,h=l.set;return Object.defineProperty(t,r,{configurable:!0,get:function(){return f.call(this)},set:function(k){c=""+k,h.call(this,k)}}),Object.defineProperty(t,r,{enumerable:l.enumerable}),{getValue:function(){return c},setValue:function(k){c=""+k},stopTracking:function(){t._valueTracker=null,delete t[r]}}}}function vn(t){t._valueTracker||(t._valueTracker=Lt(t))}function Le(t){if(!t)return!1;var r=t._valueTracker;if(!r)return!0;var l=r.getValue(),c="";return t&&(c=Pt(t)?t.checked?"true":"false":t.value),t=c,t!==l?(r.setValue(t),!0):!1}function Mn(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Fn(t,r){var l=r.checked;return K({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??t._wrapperState.initialChecked})}function _t(t,r){var l=r.defaultValue==null?"":r.defaultValue,c=r.checked!=null?r.checked:r.defaultChecked;l=st(r.value!=null?r.value:l),t._wrapperState={initialChecked:c,initialValue:l,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function Ln(t,r){r=r.checked,r!=null&&N(t,"checked",r,!1)}function Kt(t,r){Ln(t,r);var l=st(r.value),c=r.type;if(l!=null)c==="number"?(l===0&&t.value===""||t.value!=l)&&(t.value=""+l):t.value!==""+l&&(t.value=""+l);else if(c==="submit"||c==="reset"){t.removeAttribute("value");return}r.hasOwnProperty("value")?Fr(t,r.type,l):r.hasOwnProperty("defaultValue")&&Fr(t,r.type,st(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(t.defaultChecked=!!r.defaultChecked)}function pr(t,r,l){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var c=r.type;if(!(c!=="submit"&&c!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+t._wrapperState.initialValue,l||r===t.value||(t.value=r),t.defaultValue=r}l=t.name,l!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,l!==""&&(t.name=l)}function Fr(t,r,l){(r!=="number"||Mn(t.ownerDocument)!==t)&&(l==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+l&&(t.defaultValue=""+l))}var Xn=Array.isArray;function _n(t,r,l,c){if(t=t.options,r){r={};for(var f=0;f<l.length;f++)r["$"+l[f]]=!0;for(l=0;l<t.length;l++)f=r.hasOwnProperty("$"+t[l].value),t[l].selected!==f&&(t[l].selected=f),f&&c&&(t[l].defaultSelected=!0)}else{for(l=""+st(l),r=null,f=0;f<t.length;f++){if(t[f].value===l){t[f].selected=!0,c&&(t[f].defaultSelected=!0);return}r!==null||t[f].disabled||(r=t[f])}r!==null&&(r.selected=!0)}}function bn(t,r){if(r.dangerouslySetInnerHTML!=null)throw Error(a(91));return K({},r,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function re(t,r){var l=r.value;if(l==null){if(l=r.children,r=r.defaultValue,l!=null){if(r!=null)throw Error(a(92));if(Xn(l)){if(1<l.length)throw Error(a(93));l=l[0]}r=l}r==null&&(r=""),l=r}t._wrapperState={initialValue:st(l)}}function He(t,r){var l=st(r.value),c=st(r.defaultValue);l!=null&&(l=""+l,l!==t.value&&(t.value=l),r.defaultValue==null&&t.defaultValue!==l&&(t.defaultValue=l)),c!=null&&(t.defaultValue=""+c)}function it(t){var r=t.textContent;r===t._wrapperState.initialValue&&r!==""&&r!==null&&(t.value=r)}function at(t){switch(t){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function On(t,r){return t==null||t==="http://www.w3.org/1999/xhtml"?at(r):t==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var wn,on=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,l,c,f){MSApp.execUnsafeLocalFunction(function(){return t(r,l,c,f)})}:t})(function(t,r){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=r;else{for(wn=wn||document.createElement("div"),wn.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=wn.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;r.firstChild;)t.appendChild(r.firstChild)}});function os(t,r){if(r){var l=t.firstChild;if(l&&l===t.lastChild&&l.nodeType===3){l.nodeValue=r;return}}t.textContent=r}var mr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},fi=["Webkit","ms","Moz","O"];Object.keys(mr).forEach(function(t){fi.forEach(function(r){r=r+t.charAt(0).toUpperCase()+t.substring(1),mr[r]=mr[t]})});function bl(t,r,l){return r==null||typeof r=="boolean"||r===""?"":l||typeof r!="number"||r===0||mr.hasOwnProperty(t)&&mr[t]?(""+r).trim():r+"px"}function wl(t,r){t=t.style;for(var l in r)if(r.hasOwnProperty(l)){var c=l.indexOf("--")===0,f=bl(l,r[l],c);l==="float"&&(l="cssFloat"),c?t.setProperty(l,f):t[l]=f}}var pi=K({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Jn(t,r){if(r){if(pi[t]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(a(137,t));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(a(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(a(61))}if(r.style!=null&&typeof r.style!="object")throw Error(a(62))}}function Ks(t,r){if(t.indexOf("-")===-1)return typeof r.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Hs=null;function cn(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var is=null,hr=null,Dn=null;function Yt(t){if(t=qa(t)){if(typeof is!="function")throw Error(a(280));var r=t.stateNode;r&&(r=Ol(r),is(t.stateNode,t.type,r))}}function gr(t){hr?Dn?Dn.push(t):Dn=[t]:hr=t}function cs(){if(hr){var t=hr,r=Dn;if(Dn=hr=null,Yt(t),r)for(t=0;t<r.length;t++)Yt(r[t])}}function xr(t,r){return t(r)}function Ta(){}var Zn=!1;function us(t,r,l){if(Zn)return t(r,l);Zn=!0;try{return xr(t,r,l)}finally{Zn=!1,(hr!==null||Dn!==null)&&(Ta(),cs())}}function Ot(t,r){var l=t.stateNode;if(l===null)return null;var c=Ol(l);if(c===null)return null;l=c[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(t=t.type,c=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!c;break e;default:t=!1}if(t)return null;if(l&&typeof l!="function")throw Error(a(231,r,typeof l));return l}var Ws=!1;if(p)try{var er={};Object.defineProperty(er,"passive",{get:function(){Ws=!0}}),window.addEventListener("test",er,er),window.removeEventListener("test",er,er)}catch{Ws=!1}function kl(t,r,l,c,f,h,k,M,D){var G=Array.prototype.slice.call(arguments,3);try{r.apply(l,G)}catch(ue){this.onError(ue)}}var kn=!1,un=null,Vs=!1,At=null,jl={onError:function(t){kn=!0,un=t}};function yr(t,r,l,c,f,h,k,M,D){kn=!1,un=null,kl.apply(jl,arguments)}function Qs(t,r,l,c,f,h,k,M,D){if(yr.apply(this,arguments),kn){if(kn){var G=un;kn=!1,un=null}else throw Error(a(198));Vs||(Vs=!0,At=G)}}function tr(t){var r=t,l=t;if(t.alternate)for(;r.return;)r=r.return;else{t=r;do r=t,(r.flags&4098)!==0&&(l=r.return),t=r.return;while(t)}return r.tag===3?l:null}function vr(t){if(t.tag===13){var r=t.memoizedState;if(r===null&&(t=t.alternate,t!==null&&(r=t.memoizedState)),r!==null)return r.dehydrated}return null}function Bn(t){if(tr(t)!==t)throw Error(a(188))}function Gs(t){var r=t.alternate;if(!r){if(r=tr(t),r===null)throw Error(a(188));return r!==t?null:t}for(var l=t,c=r;;){var f=l.return;if(f===null)break;var h=f.alternate;if(h===null){if(c=f.return,c!==null){l=c;continue}break}if(f.child===h.child){for(h=f.child;h;){if(h===l)return Bn(f),t;if(h===c)return Bn(f),r;h=h.sibling}throw Error(a(188))}if(l.return!==c.return)l=f,c=h;else{for(var k=!1,M=f.child;M;){if(M===l){k=!0,l=f,c=h;break}if(M===c){k=!0,c=f,l=h;break}M=M.sibling}if(!k){for(M=h.child;M;){if(M===l){k=!0,l=h,c=f;break}if(M===c){k=!0,c=h,l=f;break}M=M.sibling}if(!k)throw Error(a(189))}}if(l.alternate!==c)throw Error(a(190))}if(l.tag!==3)throw Error(a(188));return l.stateNode.current===l?t:r}function br(t){return t=Gs(t),t!==null?Lr(t):null}function Lr(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var r=Lr(t);if(r!==null)return r;t=t.sibling}return null}var _r=s.unstable_scheduleCallback,Or=s.unstable_cancelCallback,Ys=s.unstable_shouldYield,mi=s.unstable_requestPaint,Je=s.unstable_now,Ea=s.unstable_getCurrentPriorityLevel,Xs=s.unstable_ImmediatePriority,ds=s.unstable_UserBlockingPriority,fs=s.unstable_NormalPriority,Js=s.unstable_LowPriority,dn=s.unstable_IdlePriority,jn=null,A=null;function W(t){if(A&&typeof A.onCommitFiberRoot=="function")try{A.onCommitFiberRoot(jn,t,void 0,(t.current.flags&128)===128)}catch{}}var J=Math.clz32?Math.clz32:le,oe=Math.log,de=Math.LN2;function le(t){return t>>>=0,t===0?32:31-(oe(t)/de|0)|0}var ve=64,me=4194304;function he(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Ie(t,r){var l=t.pendingLanes;if(l===0)return 0;var c=0,f=t.suspendedLanes,h=t.pingedLanes,k=l&268435455;if(k!==0){var M=k&~f;M!==0?c=he(M):(h&=k,h!==0&&(c=he(h)))}else k=l&~f,k!==0?c=he(k):h!==0&&(c=he(h));if(c===0)return 0;if(r!==0&&r!==c&&(r&f)===0&&(f=c&-c,h=r&-r,f>=h||f===16&&(h&4194240)!==0))return r;if((c&4)!==0&&(c|=l&16),r=t.entangledLanes,r!==0)for(t=t.entanglements,r&=c;0<r;)l=31-J(r),f=1<<l,c|=t[l],r&=~f;return c}function ye(t,r){switch(t){case 1:case 2:case 4:return r+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Re(t,r){for(var l=t.suspendedLanes,c=t.pingedLanes,f=t.expirationTimes,h=t.pendingLanes;0<h;){var k=31-J(h),M=1<<k,D=f[k];D===-1?((M&l)===0||(M&c)!==0)&&(f[k]=ye(M,r)):D<=r&&(t.expiredLanes|=M),h&=~M}}function ze(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function we(){var t=ve;return ve<<=1,(ve&4194240)===0&&(ve=64),t}function Ae(t){for(var r=[],l=0;31>l;l++)r.push(t);return r}function Ge(t,r,l){t.pendingLanes|=r,r!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,r=31-J(r),t[r]=l}function tt(t,r){var l=t.pendingLanes&~r;t.pendingLanes=r,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=r,t.mutableReadLanes&=r,t.entangledLanes&=r,r=t.entanglements;var c=t.eventTimes;for(t=t.expirationTimes;0<l;){var f=31-J(l),h=1<<f;r[f]=0,c[f]=-1,t[f]=-1,l&=~h}}function Ct(t,r){var l=t.entangledLanes|=r;for(t=t.entanglements;l;){var c=31-J(l),f=1<<c;f&r|t[c]&r&&(t[c]|=r),l&=~f}}var $e=0;function $t(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var pt,gt,zn,ps,ms,Dr=!1,nr=[],Ht=null,Dt=null,fn=null,Br=new Map,xe=new Map,Ye=[],qn="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Xt(t,r){switch(t){case"focusin":case"focusout":Ht=null;break;case"dragenter":case"dragleave":Dt=null;break;case"mouseover":case"mouseout":fn=null;break;case"pointerover":case"pointerout":Br.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":xe.delete(r.pointerId)}}function Nn(t,r,l,c,f,h){return t===null||t.nativeEvent!==h?(t={blockedOn:r,domEventName:l,eventSystemFlags:c,nativeEvent:h,targetContainers:[f]},r!==null&&(r=qa(r),r!==null&&gt(r)),t):(t.eventSystemFlags|=c,r=t.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),t)}function hs(t,r,l,c,f){switch(r){case"focusin":return Ht=Nn(Ht,t,r,l,c,f),!0;case"dragenter":return Dt=Nn(Dt,t,r,l,c,f),!0;case"mouseover":return fn=Nn(fn,t,r,l,c,f),!0;case"pointerover":var h=f.pointerId;return Br.set(h,Nn(Br.get(h)||null,t,r,l,c,f)),!0;case"gotpointercapture":return h=f.pointerId,xe.set(h,Nn(xe.get(h)||null,t,r,l,c,f)),!0}return!1}function wr(t){var r=ys(t.target);if(r!==null){var l=tr(r);if(l!==null){if(r=l.tag,r===13){if(r=vr(l),r!==null){t.blockedOn=r,ms(t.priority,function(){zn(l)});return}}else if(r===3&&l.stateNode.current.memoizedState.isDehydrated){t.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}t.blockedOn=null}function gs(t){if(t.blockedOn!==null)return!1;for(var r=t.targetContainers;0<r.length;){var l=gi(t.domEventName,t.eventSystemFlags,r[0],t.nativeEvent);if(l===null){l=t.nativeEvent;var c=new l.constructor(l.type,l);Hs=c,l.target.dispatchEvent(c),Hs=null}else return r=qa(l),r!==null&&gt(r),t.blockedOn=l,!1;r.shift()}return!0}function Nl(t,r,l){gs(t)&&l.delete(r)}function xt(){Dr=!1,Ht!==null&&gs(Ht)&&(Ht=null),Dt!==null&&gs(Dt)&&(Dt=null),fn!==null&&gs(fn)&&(fn=null),Br.forEach(Nl),xe.forEach(Nl)}function xs(t,r){t.blockedOn===r&&(t.blockedOn=null,Dr||(Dr=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,xt)))}function Un(t){function r(f){return xs(f,t)}if(0<nr.length){xs(nr[0],t);for(var l=1;l<nr.length;l++){var c=nr[l];c.blockedOn===t&&(c.blockedOn=null)}}for(Ht!==null&&xs(Ht,t),Dt!==null&&xs(Dt,t),fn!==null&&xs(fn,t),Br.forEach(r),xe.forEach(r),l=0;l<Ye.length;l++)c=Ye[l],c.blockedOn===t&&(c.blockedOn=null);for(;0<Ye.length&&(l=Ye[0],l.blockedOn===null);)wr(l),l.blockedOn===null&&Ye.shift()}var kr=b.ReactCurrentBatchConfig,Sl=!0;function k0(t,r,l,c){var f=$e,h=kr.transition;kr.transition=null;try{$e=1,hi(t,r,l,c)}finally{$e=f,kr.transition=h}}function j0(t,r,l,c){var f=$e,h=kr.transition;kr.transition=null;try{$e=4,hi(t,r,l,c)}finally{$e=f,kr.transition=h}}function hi(t,r,l,c){if(Sl){var f=gi(t,r,l,c);if(f===null)$i(t,r,c,Cl,l),Xt(t,c);else if(hs(f,t,r,l,c))c.stopPropagation();else if(Xt(t,c),r&4&&-1<qn.indexOf(t)){for(;f!==null;){var h=qa(f);if(h!==null&&pt(h),h=gi(t,r,l,c),h===null&&$i(t,r,c,Cl,l),h===f)break;f=h}f!==null&&c.stopPropagation()}else $i(t,r,c,null,l)}}var Cl=null;function gi(t,r,l,c){if(Cl=null,t=cn(c),t=ys(t),t!==null)if(r=tr(t),r===null)t=null;else if(l=r.tag,l===13){if(t=vr(r),t!==null)return t;t=null}else if(l===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;t=null}else r!==t&&(t=null);return Cl=t,null}function ed(t){switch(t){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Ea()){case Xs:return 1;case ds:return 4;case fs:case Js:return 16;case dn:return 536870912;default:return 16}default:return 16}}var zr=null,xi=null,Rl=null;function td(){if(Rl)return Rl;var t,r=xi,l=r.length,c,f="value"in zr?zr.value:zr.textContent,h=f.length;for(t=0;t<l&&r[t]===f[t];t++);var k=l-t;for(c=1;c<=k&&r[l-c]===f[h-c];c++);return Rl=f.slice(t,1<c?1-c:void 0)}function Il(t){var r=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&r===13&&(t=13)):t=r,t===10&&(t=13),32<=t||t===13?t:0}function Tl(){return!0}function nd(){return!1}function pn(t){function r(l,c,f,h,k){this._reactName=l,this._targetInst=f,this.type=c,this.nativeEvent=h,this.target=k,this.currentTarget=null;for(var M in t)t.hasOwnProperty(M)&&(l=t[M],this[M]=l?l(h):h[M]);return this.isDefaultPrevented=(h.defaultPrevented!=null?h.defaultPrevented:h.returnValue===!1)?Tl:nd,this.isPropagationStopped=nd,this}return K(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=Tl)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Tl)},persist:function(){},isPersistent:Tl}),r}var Zs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},yi=pn(Zs),Pa=K({},Zs,{view:0,detail:0}),N0=pn(Pa),vi,bi,Aa,El=K({},Pa,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ki,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==Aa&&(Aa&&t.type==="mousemove"?(vi=t.screenX-Aa.screenX,bi=t.screenY-Aa.screenY):bi=vi=0,Aa=t),vi)},movementY:function(t){return"movementY"in t?t.movementY:bi}}),rd=pn(El),S0=K({},El,{dataTransfer:0}),C0=pn(S0),R0=K({},Pa,{relatedTarget:0}),wi=pn(R0),I0=K({},Zs,{animationName:0,elapsedTime:0,pseudoElement:0}),T0=pn(I0),E0=K({},Zs,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),P0=pn(E0),A0=K({},Zs,{data:0}),sd=pn(A0),$0={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},M0={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},F0={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function L0(t){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(t):(t=F0[t])?!!r[t]:!1}function ki(){return L0}var _0=K({},Pa,{key:function(t){if(t.key){var r=$0[t.key]||t.key;if(r!=="Unidentified")return r}return t.type==="keypress"?(t=Il(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?M0[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ki,charCode:function(t){return t.type==="keypress"?Il(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Il(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),O0=pn(_0),D0=K({},El,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ad=pn(D0),B0=K({},Pa,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ki}),z0=pn(B0),q0=K({},Zs,{propertyName:0,elapsedTime:0,pseudoElement:0}),U0=pn(q0),K0=K({},El,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),H0=pn(K0),W0=[9,13,27,32],ji=p&&"CompositionEvent"in window,$a=null;p&&"documentMode"in document&&($a=document.documentMode);var V0=p&&"TextEvent"in window&&!$a,ld=p&&(!ji||$a&&8<$a&&11>=$a),od=" ",id=!1;function cd(t,r){switch(t){case"keyup":return W0.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ud(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ea=!1;function Q0(t,r){switch(t){case"compositionend":return ud(r);case"keypress":return r.which!==32?null:(id=!0,od);case"textInput":return t=r.data,t===od&&id?null:t;default:return null}}function G0(t,r){if(ea)return t==="compositionend"||!ji&&cd(t,r)?(t=td(),Rl=xi=zr=null,ea=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return ld&&r.locale!=="ko"?null:r.data;default:return null}}var Y0={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function dd(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r==="input"?!!Y0[t.type]:r==="textarea"}function fd(t,r,l,c){gr(c),r=Fl(r,"onChange"),0<r.length&&(l=new yi("onChange","change",null,l,c),t.push({event:l,listeners:r}))}var Ma=null,Fa=null;function X0(t){Ed(t,0)}function Pl(t){var r=aa(t);if(Le(r))return t}function J0(t,r){if(t==="change")return r}var pd=!1;if(p){var Ni;if(p){var Si="oninput"in document;if(!Si){var md=document.createElement("div");md.setAttribute("oninput","return;"),Si=typeof md.oninput=="function"}Ni=Si}else Ni=!1;pd=Ni&&(!document.documentMode||9<document.documentMode)}function hd(){Ma&&(Ma.detachEvent("onpropertychange",gd),Fa=Ma=null)}function gd(t){if(t.propertyName==="value"&&Pl(Fa)){var r=[];fd(r,Fa,t,cn(t)),us(X0,r)}}function Z0(t,r,l){t==="focusin"?(hd(),Ma=r,Fa=l,Ma.attachEvent("onpropertychange",gd)):t==="focusout"&&hd()}function eg(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return Pl(Fa)}function tg(t,r){if(t==="click")return Pl(r)}function ng(t,r){if(t==="input"||t==="change")return Pl(r)}function rg(t,r){return t===r&&(t!==0||1/t===1/r)||t!==t&&r!==r}var Kn=typeof Object.is=="function"?Object.is:rg;function La(t,r){if(Kn(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;var l=Object.keys(t),c=Object.keys(r);if(l.length!==c.length)return!1;for(c=0;c<l.length;c++){var f=l[c];if(!m.call(r,f)||!Kn(t[f],r[f]))return!1}return!0}function xd(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function yd(t,r){var l=xd(t);t=0;for(var c;l;){if(l.nodeType===3){if(c=t+l.textContent.length,t<=r&&c>=r)return{node:l,offset:r-t};t=c}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=xd(l)}}function vd(t,r){return t&&r?t===r?!0:t&&t.nodeType===3?!1:r&&r.nodeType===3?vd(t,r.parentNode):"contains"in t?t.contains(r):t.compareDocumentPosition?!!(t.compareDocumentPosition(r)&16):!1:!1}function bd(){for(var t=window,r=Mn();r instanceof t.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)t=r.contentWindow;else break;r=Mn(t.document)}return r}function Ci(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r&&(r==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||r==="textarea"||t.contentEditable==="true")}function sg(t){var r=bd(),l=t.focusedElem,c=t.selectionRange;if(r!==l&&l&&l.ownerDocument&&vd(l.ownerDocument.documentElement,l)){if(c!==null&&Ci(l)){if(r=c.start,t=c.end,t===void 0&&(t=r),"selectionStart"in l)l.selectionStart=r,l.selectionEnd=Math.min(t,l.value.length);else if(t=(r=l.ownerDocument||document)&&r.defaultView||window,t.getSelection){t=t.getSelection();var f=l.textContent.length,h=Math.min(c.start,f);c=c.end===void 0?h:Math.min(c.end,f),!t.extend&&h>c&&(f=c,c=h,h=f),f=yd(l,h);var k=yd(l,c);f&&k&&(t.rangeCount!==1||t.anchorNode!==f.node||t.anchorOffset!==f.offset||t.focusNode!==k.node||t.focusOffset!==k.offset)&&(r=r.createRange(),r.setStart(f.node,f.offset),t.removeAllRanges(),h>c?(t.addRange(r),t.extend(k.node,k.offset)):(r.setEnd(k.node,k.offset),t.addRange(r)))}}for(r=[],t=l;t=t.parentNode;)t.nodeType===1&&r.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<r.length;l++)t=r[l],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var ag=p&&"documentMode"in document&&11>=document.documentMode,ta=null,Ri=null,_a=null,Ii=!1;function wd(t,r,l){var c=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Ii||ta==null||ta!==Mn(c)||(c=ta,"selectionStart"in c&&Ci(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),_a&&La(_a,c)||(_a=c,c=Fl(Ri,"onSelect"),0<c.length&&(r=new yi("onSelect","select",null,r,l),t.push({event:r,listeners:c}),r.target=ta)))}function Al(t,r){var l={};return l[t.toLowerCase()]=r.toLowerCase(),l["Webkit"+t]="webkit"+r,l["Moz"+t]="moz"+r,l}var na={animationend:Al("Animation","AnimationEnd"),animationiteration:Al("Animation","AnimationIteration"),animationstart:Al("Animation","AnimationStart"),transitionend:Al("Transition","TransitionEnd")},Ti={},kd={};p&&(kd=document.createElement("div").style,"AnimationEvent"in window||(delete na.animationend.animation,delete na.animationiteration.animation,delete na.animationstart.animation),"TransitionEvent"in window||delete na.transitionend.transition);function $l(t){if(Ti[t])return Ti[t];if(!na[t])return t;var r=na[t],l;for(l in r)if(r.hasOwnProperty(l)&&l in kd)return Ti[t]=r[l];return t}var jd=$l("animationend"),Nd=$l("animationiteration"),Sd=$l("animationstart"),Cd=$l("transitionend"),Rd=new Map,Id="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function qr(t,r){Rd.set(t,r),u(r,[t])}for(var Ei=0;Ei<Id.length;Ei++){var Pi=Id[Ei],lg=Pi.toLowerCase(),og=Pi[0].toUpperCase()+Pi.slice(1);qr(lg,"on"+og)}qr(jd,"onAnimationEnd"),qr(Nd,"onAnimationIteration"),qr(Sd,"onAnimationStart"),qr("dblclick","onDoubleClick"),qr("focusin","onFocus"),qr("focusout","onBlur"),qr(Cd,"onTransitionEnd"),d("onMouseEnter",["mouseout","mouseover"]),d("onMouseLeave",["mouseout","mouseover"]),d("onPointerEnter",["pointerout","pointerover"]),d("onPointerLeave",["pointerout","pointerover"]),u("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),u("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),u("onBeforeInput",["compositionend","keypress","textInput","paste"]),u("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Oa="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),ig=new Set("cancel close invalid load scroll toggle".split(" ").concat(Oa));function Td(t,r,l){var c=t.type||"unknown-event";t.currentTarget=l,Qs(c,r,void 0,t),t.currentTarget=null}function Ed(t,r){r=(r&4)!==0;for(var l=0;l<t.length;l++){var c=t[l],f=c.event;c=c.listeners;e:{var h=void 0;if(r)for(var k=c.length-1;0<=k;k--){var M=c[k],D=M.instance,G=M.currentTarget;if(M=M.listener,D!==h&&f.isPropagationStopped())break e;Td(f,M,G),h=D}else for(k=0;k<c.length;k++){if(M=c[k],D=M.instance,G=M.currentTarget,M=M.listener,D!==h&&f.isPropagationStopped())break e;Td(f,M,G),h=D}}}if(Vs)throw t=At,Vs=!1,At=null,t}function Ze(t,r){var l=r[Di];l===void 0&&(l=r[Di]=new Set);var c=t+"__bubble";l.has(c)||(Pd(r,t,2,!1),l.add(c))}function Ai(t,r,l){var c=0;r&&(c|=4),Pd(l,t,c,r)}var Ml="_reactListening"+Math.random().toString(36).slice(2);function Da(t){if(!t[Ml]){t[Ml]=!0,o.forEach(function(l){l!=="selectionchange"&&(ig.has(l)||Ai(l,!1,t),Ai(l,!0,t))});var r=t.nodeType===9?t:t.ownerDocument;r===null||r[Ml]||(r[Ml]=!0,Ai("selectionchange",!1,r))}}function Pd(t,r,l,c){switch(ed(r)){case 1:var f=k0;break;case 4:f=j0;break;default:f=hi}l=f.bind(null,r,l,t),f=void 0,!Ws||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(f=!0),c?f!==void 0?t.addEventListener(r,l,{capture:!0,passive:f}):t.addEventListener(r,l,!0):f!==void 0?t.addEventListener(r,l,{passive:f}):t.addEventListener(r,l,!1)}function $i(t,r,l,c,f){var h=c;if((r&1)===0&&(r&2)===0&&c!==null)e:for(;;){if(c===null)return;var k=c.tag;if(k===3||k===4){var M=c.stateNode.containerInfo;if(M===f||M.nodeType===8&&M.parentNode===f)break;if(k===4)for(k=c.return;k!==null;){var D=k.tag;if((D===3||D===4)&&(D=k.stateNode.containerInfo,D===f||D.nodeType===8&&D.parentNode===f))return;k=k.return}for(;M!==null;){if(k=ys(M),k===null)return;if(D=k.tag,D===5||D===6){c=h=k;continue e}M=M.parentNode}}c=c.return}us(function(){var G=h,ue=cn(l),fe=[];e:{var ie=Rd.get(t);if(ie!==void 0){var be=yi,Ne=t;switch(t){case"keypress":if(Il(l)===0)break e;case"keydown":case"keyup":be=O0;break;case"focusin":Ne="focus",be=wi;break;case"focusout":Ne="blur",be=wi;break;case"beforeblur":case"afterblur":be=wi;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":be=rd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":be=C0;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":be=z0;break;case jd:case Nd:case Sd:be=T0;break;case Cd:be=U0;break;case"scroll":be=N0;break;case"wheel":be=H0;break;case"copy":case"cut":case"paste":be=P0;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":be=ad}var Se=(r&4)!==0,ut=!Se&&t==="scroll",U=Se?ie!==null?ie+"Capture":null:ie;Se=[];for(var z=G,V;z!==null;){V=z;var pe=V.stateNode;if(V.tag===5&&pe!==null&&(V=pe,U!==null&&(pe=Ot(z,U),pe!=null&&Se.push(Ba(z,pe,V)))),ut)break;z=z.return}0<Se.length&&(ie=new be(ie,Ne,null,l,ue),fe.push({event:ie,listeners:Se}))}}if((r&7)===0){e:{if(ie=t==="mouseover"||t==="pointerover",be=t==="mouseout"||t==="pointerout",ie&&l!==Hs&&(Ne=l.relatedTarget||l.fromElement)&&(ys(Ne)||Ne[jr]))break e;if((be||ie)&&(ie=ue.window===ue?ue:(ie=ue.ownerDocument)?ie.defaultView||ie.parentWindow:window,be?(Ne=l.relatedTarget||l.toElement,be=G,Ne=Ne?ys(Ne):null,Ne!==null&&(ut=tr(Ne),Ne!==ut||Ne.tag!==5&&Ne.tag!==6)&&(Ne=null)):(be=null,Ne=G),be!==Ne)){if(Se=rd,pe="onMouseLeave",U="onMouseEnter",z="mouse",(t==="pointerout"||t==="pointerover")&&(Se=ad,pe="onPointerLeave",U="onPointerEnter",z="pointer"),ut=be==null?ie:aa(be),V=Ne==null?ie:aa(Ne),ie=new Se(pe,z+"leave",be,l,ue),ie.target=ut,ie.relatedTarget=V,pe=null,ys(ue)===G&&(Se=new Se(U,z+"enter",Ne,l,ue),Se.target=V,Se.relatedTarget=ut,pe=Se),ut=pe,be&&Ne)t:{for(Se=be,U=Ne,z=0,V=Se;V;V=ra(V))z++;for(V=0,pe=U;pe;pe=ra(pe))V++;for(;0<z-V;)Se=ra(Se),z--;for(;0<V-z;)U=ra(U),V--;for(;z--;){if(Se===U||U!==null&&Se===U.alternate)break t;Se=ra(Se),U=ra(U)}Se=null}else Se=null;be!==null&&Ad(fe,ie,be,Se,!1),Ne!==null&&ut!==null&&Ad(fe,ut,Ne,Se,!0)}}e:{if(ie=G?aa(G):window,be=ie.nodeName&&ie.nodeName.toLowerCase(),be==="select"||be==="input"&&ie.type==="file")var Ce=J0;else if(dd(ie))if(pd)Ce=ng;else{Ce=eg;var Te=Z0}else(be=ie.nodeName)&&be.toLowerCase()==="input"&&(ie.type==="checkbox"||ie.type==="radio")&&(Ce=tg);if(Ce&&(Ce=Ce(t,G))){fd(fe,Ce,l,ue);break e}Te&&Te(t,ie,G),t==="focusout"&&(Te=ie._wrapperState)&&Te.controlled&&ie.type==="number"&&Fr(ie,"number",ie.value)}switch(Te=G?aa(G):window,t){case"focusin":(dd(Te)||Te.contentEditable==="true")&&(ta=Te,Ri=G,_a=null);break;case"focusout":_a=Ri=ta=null;break;case"mousedown":Ii=!0;break;case"contextmenu":case"mouseup":case"dragend":Ii=!1,wd(fe,l,ue);break;case"selectionchange":if(ag)break;case"keydown":case"keyup":wd(fe,l,ue)}var Ee;if(ji)e:{switch(t){case"compositionstart":var Me="onCompositionStart";break e;case"compositionend":Me="onCompositionEnd";break e;case"compositionupdate":Me="onCompositionUpdate";break e}Me=void 0}else ea?cd(t,l)&&(Me="onCompositionEnd"):t==="keydown"&&l.keyCode===229&&(Me="onCompositionStart");Me&&(ld&&l.locale!=="ko"&&(ea||Me!=="onCompositionStart"?Me==="onCompositionEnd"&&ea&&(Ee=td()):(zr=ue,xi="value"in zr?zr.value:zr.textContent,ea=!0)),Te=Fl(G,Me),0<Te.length&&(Me=new sd(Me,t,null,l,ue),fe.push({event:Me,listeners:Te}),Ee?Me.data=Ee:(Ee=ud(l),Ee!==null&&(Me.data=Ee)))),(Ee=V0?Q0(t,l):G0(t,l))&&(G=Fl(G,"onBeforeInput"),0<G.length&&(ue=new sd("onBeforeInput","beforeinput",null,l,ue),fe.push({event:ue,listeners:G}),ue.data=Ee))}Ed(fe,r)})}function Ba(t,r,l){return{instance:t,listener:r,currentTarget:l}}function Fl(t,r){for(var l=r+"Capture",c=[];t!==null;){var f=t,h=f.stateNode;f.tag===5&&h!==null&&(f=h,h=Ot(t,l),h!=null&&c.unshift(Ba(t,h,f)),h=Ot(t,r),h!=null&&c.push(Ba(t,h,f))),t=t.return}return c}function ra(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function Ad(t,r,l,c,f){for(var h=r._reactName,k=[];l!==null&&l!==c;){var M=l,D=M.alternate,G=M.stateNode;if(D!==null&&D===c)break;M.tag===5&&G!==null&&(M=G,f?(D=Ot(l,h),D!=null&&k.unshift(Ba(l,D,M))):f||(D=Ot(l,h),D!=null&&k.push(Ba(l,D,M)))),l=l.return}k.length!==0&&t.push({event:r,listeners:k})}var cg=/\r\n?/g,ug=/\u0000|\uFFFD/g;function $d(t){return(typeof t=="string"?t:""+t).replace(cg,`
23
+ `).replace(ug,"")}function Ll(t,r,l){if(r=$d(r),$d(t)!==r&&l)throw Error(a(425))}function _l(){}var Mi=null,Fi=null;function Li(t,r){return t==="textarea"||t==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var _i=typeof setTimeout=="function"?setTimeout:void 0,dg=typeof clearTimeout=="function"?clearTimeout:void 0,Md=typeof Promise=="function"?Promise:void 0,fg=typeof queueMicrotask=="function"?queueMicrotask:typeof Md<"u"?function(t){return Md.resolve(null).then(t).catch(pg)}:_i;function pg(t){setTimeout(function(){throw t})}function Oi(t,r){var l=r,c=0;do{var f=l.nextSibling;if(t.removeChild(l),f&&f.nodeType===8)if(l=f.data,l==="/$"){if(c===0){t.removeChild(f),Un(r);return}c--}else l!=="$"&&l!=="$?"&&l!=="$!"||c++;l=f}while(l);Un(r)}function Ur(t){for(;t!=null;t=t.nextSibling){var r=t.nodeType;if(r===1||r===3)break;if(r===8){if(r=t.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return t}function Fd(t){t=t.previousSibling;for(var r=0;t;){if(t.nodeType===8){var l=t.data;if(l==="$"||l==="$!"||l==="$?"){if(r===0)return t;r--}else l==="/$"&&r++}t=t.previousSibling}return null}var sa=Math.random().toString(36).slice(2),rr="__reactFiber$"+sa,za="__reactProps$"+sa,jr="__reactContainer$"+sa,Di="__reactEvents$"+sa,mg="__reactListeners$"+sa,hg="__reactHandles$"+sa;function ys(t){var r=t[rr];if(r)return r;for(var l=t.parentNode;l;){if(r=l[jr]||l[rr]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(t=Fd(t);t!==null;){if(l=t[rr])return l;t=Fd(t)}return r}t=l,l=t.parentNode}return null}function qa(t){return t=t[rr]||t[jr],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function aa(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(a(33))}function Ol(t){return t[za]||null}var Bi=[],la=-1;function Kr(t){return{current:t}}function et(t){0>la||(t.current=Bi[la],Bi[la]=null,la--)}function Xe(t,r){la++,Bi[la]=t.current,t.current=r}var Hr={},Bt=Kr(Hr),Jt=Kr(!1),vs=Hr;function oa(t,r){var l=t.type.contextTypes;if(!l)return Hr;var c=t.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===r)return c.__reactInternalMemoizedMaskedChildContext;var f={},h;for(h in l)f[h]=r[h];return c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=r,t.__reactInternalMemoizedMaskedChildContext=f),f}function Zt(t){return t=t.childContextTypes,t!=null}function Dl(){et(Jt),et(Bt)}function Ld(t,r,l){if(Bt.current!==Hr)throw Error(a(168));Xe(Bt,r),Xe(Jt,l)}function _d(t,r,l){var c=t.stateNode;if(r=r.childContextTypes,typeof c.getChildContext!="function")return l;c=c.getChildContext();for(var f in c)if(!(f in r))throw Error(a(108,We(t)||"Unknown",f));return K({},l,c)}function Bl(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Hr,vs=Bt.current,Xe(Bt,t),Xe(Jt,Jt.current),!0}function Od(t,r,l){var c=t.stateNode;if(!c)throw Error(a(169));l?(t=_d(t,r,vs),c.__reactInternalMemoizedMergedChildContext=t,et(Jt),et(Bt),Xe(Bt,t)):et(Jt),Xe(Jt,l)}var Nr=null,zl=!1,zi=!1;function Dd(t){Nr===null?Nr=[t]:Nr.push(t)}function gg(t){zl=!0,Dd(t)}function Wr(){if(!zi&&Nr!==null){zi=!0;var t=0,r=$e;try{var l=Nr;for($e=1;t<l.length;t++){var c=l[t];do c=c(!0);while(c!==null)}Nr=null,zl=!1}catch(f){throw Nr!==null&&(Nr=Nr.slice(t+1)),_r(Xs,Wr),f}finally{$e=r,zi=!1}}return null}var ia=[],ca=0,ql=null,Ul=0,Sn=[],Cn=0,bs=null,Sr=1,Cr="";function ws(t,r){ia[ca++]=Ul,ia[ca++]=ql,ql=t,Ul=r}function Bd(t,r,l){Sn[Cn++]=Sr,Sn[Cn++]=Cr,Sn[Cn++]=bs,bs=t;var c=Sr;t=Cr;var f=32-J(c)-1;c&=~(1<<f),l+=1;var h=32-J(r)+f;if(30<h){var k=f-f%5;h=(c&(1<<k)-1).toString(32),c>>=k,f-=k,Sr=1<<32-J(r)+f|l<<f|c,Cr=h+t}else Sr=1<<h|l<<f|c,Cr=t}function qi(t){t.return!==null&&(ws(t,1),Bd(t,1,0))}function Ui(t){for(;t===ql;)ql=ia[--ca],ia[ca]=null,Ul=ia[--ca],ia[ca]=null;for(;t===bs;)bs=Sn[--Cn],Sn[Cn]=null,Cr=Sn[--Cn],Sn[Cn]=null,Sr=Sn[--Cn],Sn[Cn]=null}var mn=null,hn=null,nt=!1,Hn=null;function zd(t,r){var l=En(5,null,null,0);l.elementType="DELETED",l.stateNode=r,l.return=t,r=t.deletions,r===null?(t.deletions=[l],t.flags|=16):r.push(l)}function qd(t,r){switch(t.tag){case 5:var l=t.type;return r=r.nodeType!==1||l.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(t.stateNode=r,mn=t,hn=Ur(r.firstChild),!0):!1;case 6:return r=t.pendingProps===""||r.nodeType!==3?null:r,r!==null?(t.stateNode=r,mn=t,hn=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(l=bs!==null?{id:Sr,overflow:Cr}:null,t.memoizedState={dehydrated:r,treeContext:l,retryLane:1073741824},l=En(18,null,null,0),l.stateNode=r,l.return=t,t.child=l,mn=t,hn=null,!0):!1;default:return!1}}function Ki(t){return(t.mode&1)!==0&&(t.flags&128)===0}function Hi(t){if(nt){var r=hn;if(r){var l=r;if(!qd(t,r)){if(Ki(t))throw Error(a(418));r=Ur(l.nextSibling);var c=mn;r&&qd(t,r)?zd(c,l):(t.flags=t.flags&-4097|2,nt=!1,mn=t)}}else{if(Ki(t))throw Error(a(418));t.flags=t.flags&-4097|2,nt=!1,mn=t}}}function Ud(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;mn=t}function Kl(t){if(t!==mn)return!1;if(!nt)return Ud(t),nt=!0,!1;var r;if((r=t.tag!==3)&&!(r=t.tag!==5)&&(r=t.type,r=r!=="head"&&r!=="body"&&!Li(t.type,t.memoizedProps)),r&&(r=hn)){if(Ki(t))throw Kd(),Error(a(418));for(;r;)zd(t,r),r=Ur(r.nextSibling)}if(Ud(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(a(317));e:{for(t=t.nextSibling,r=0;t;){if(t.nodeType===8){var l=t.data;if(l==="/$"){if(r===0){hn=Ur(t.nextSibling);break e}r--}else l!=="$"&&l!=="$!"&&l!=="$?"||r++}t=t.nextSibling}hn=null}}else hn=mn?Ur(t.stateNode.nextSibling):null;return!0}function Kd(){for(var t=hn;t;)t=Ur(t.nextSibling)}function ua(){hn=mn=null,nt=!1}function Wi(t){Hn===null?Hn=[t]:Hn.push(t)}var xg=b.ReactCurrentBatchConfig;function Ua(t,r,l){if(t=l.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(a(309));var c=l.stateNode}if(!c)throw Error(a(147,t));var f=c,h=""+t;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===h?r.ref:(r=function(k){var M=f.refs;k===null?delete M[h]:M[h]=k},r._stringRef=h,r)}if(typeof t!="string")throw Error(a(284));if(!l._owner)throw Error(a(290,t))}return t}function Hl(t,r){throw t=Object.prototype.toString.call(r),Error(a(31,t==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":t))}function Hd(t){var r=t._init;return r(t._payload)}function Wd(t){function r(U,z){if(t){var V=U.deletions;V===null?(U.deletions=[z],U.flags|=16):V.push(z)}}function l(U,z){if(!t)return null;for(;z!==null;)r(U,z),z=z.sibling;return null}function c(U,z){for(U=new Map;z!==null;)z.key!==null?U.set(z.key,z):U.set(z.index,z),z=z.sibling;return U}function f(U,z){return U=es(U,z),U.index=0,U.sibling=null,U}function h(U,z,V){return U.index=V,t?(V=U.alternate,V!==null?(V=V.index,V<z?(U.flags|=2,z):V):(U.flags|=2,z)):(U.flags|=1048576,z)}function k(U){return t&&U.alternate===null&&(U.flags|=2),U}function M(U,z,V,pe){return z===null||z.tag!==6?(z=_c(V,U.mode,pe),z.return=U,z):(z=f(z,V),z.return=U,z)}function D(U,z,V,pe){var Ce=V.type;return Ce===L?ue(U,z,V.props.children,pe,V.key):z!==null&&(z.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===ee&&Hd(Ce)===z.type)?(pe=f(z,V.props),pe.ref=Ua(U,z,V),pe.return=U,pe):(pe=go(V.type,V.key,V.props,null,U.mode,pe),pe.ref=Ua(U,z,V),pe.return=U,pe)}function G(U,z,V,pe){return z===null||z.tag!==4||z.stateNode.containerInfo!==V.containerInfo||z.stateNode.implementation!==V.implementation?(z=Oc(V,U.mode,pe),z.return=U,z):(z=f(z,V.children||[]),z.return=U,z)}function ue(U,z,V,pe,Ce){return z===null||z.tag!==7?(z=Ts(V,U.mode,pe,Ce),z.return=U,z):(z=f(z,V),z.return=U,z)}function fe(U,z,V){if(typeof z=="string"&&z!==""||typeof z=="number")return z=_c(""+z,U.mode,V),z.return=U,z;if(typeof z=="object"&&z!==null){switch(z.$$typeof){case I:return V=go(z.type,z.key,z.props,null,U.mode,V),V.ref=Ua(U,null,z),V.return=U,V;case $:return z=Oc(z,U.mode,V),z.return=U,z;case ee:var pe=z._init;return fe(U,pe(z._payload),V)}if(Xn(z)||F(z))return z=Ts(z,U.mode,V,null),z.return=U,z;Hl(U,z)}return null}function ie(U,z,V,pe){var Ce=z!==null?z.key:null;if(typeof V=="string"&&V!==""||typeof V=="number")return Ce!==null?null:M(U,z,""+V,pe);if(typeof V=="object"&&V!==null){switch(V.$$typeof){case I:return V.key===Ce?D(U,z,V,pe):null;case $:return V.key===Ce?G(U,z,V,pe):null;case ee:return Ce=V._init,ie(U,z,Ce(V._payload),pe)}if(Xn(V)||F(V))return Ce!==null?null:ue(U,z,V,pe,null);Hl(U,V)}return null}function be(U,z,V,pe,Ce){if(typeof pe=="string"&&pe!==""||typeof pe=="number")return U=U.get(V)||null,M(z,U,""+pe,Ce);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case I:return U=U.get(pe.key===null?V:pe.key)||null,D(z,U,pe,Ce);case $:return U=U.get(pe.key===null?V:pe.key)||null,G(z,U,pe,Ce);case ee:var Te=pe._init;return be(U,z,V,Te(pe._payload),Ce)}if(Xn(pe)||F(pe))return U=U.get(V)||null,ue(z,U,pe,Ce,null);Hl(z,pe)}return null}function Ne(U,z,V,pe){for(var Ce=null,Te=null,Ee=z,Me=z=0,Tt=null;Ee!==null&&Me<V.length;Me++){Ee.index>Me?(Tt=Ee,Ee=null):Tt=Ee.sibling;var Qe=ie(U,Ee,V[Me],pe);if(Qe===null){Ee===null&&(Ee=Tt);break}t&&Ee&&Qe.alternate===null&&r(U,Ee),z=h(Qe,z,Me),Te===null?Ce=Qe:Te.sibling=Qe,Te=Qe,Ee=Tt}if(Me===V.length)return l(U,Ee),nt&&ws(U,Me),Ce;if(Ee===null){for(;Me<V.length;Me++)Ee=fe(U,V[Me],pe),Ee!==null&&(z=h(Ee,z,Me),Te===null?Ce=Ee:Te.sibling=Ee,Te=Ee);return nt&&ws(U,Me),Ce}for(Ee=c(U,Ee);Me<V.length;Me++)Tt=be(Ee,U,Me,V[Me],pe),Tt!==null&&(t&&Tt.alternate!==null&&Ee.delete(Tt.key===null?Me:Tt.key),z=h(Tt,z,Me),Te===null?Ce=Tt:Te.sibling=Tt,Te=Tt);return t&&Ee.forEach(function(ts){return r(U,ts)}),nt&&ws(U,Me),Ce}function Se(U,z,V,pe){var Ce=F(V);if(typeof Ce!="function")throw Error(a(150));if(V=Ce.call(V),V==null)throw Error(a(151));for(var Te=Ce=null,Ee=z,Me=z=0,Tt=null,Qe=V.next();Ee!==null&&!Qe.done;Me++,Qe=V.next()){Ee.index>Me?(Tt=Ee,Ee=null):Tt=Ee.sibling;var ts=ie(U,Ee,Qe.value,pe);if(ts===null){Ee===null&&(Ee=Tt);break}t&&Ee&&ts.alternate===null&&r(U,Ee),z=h(ts,z,Me),Te===null?Ce=ts:Te.sibling=ts,Te=ts,Ee=Tt}if(Qe.done)return l(U,Ee),nt&&ws(U,Me),Ce;if(Ee===null){for(;!Qe.done;Me++,Qe=V.next())Qe=fe(U,Qe.value,pe),Qe!==null&&(z=h(Qe,z,Me),Te===null?Ce=Qe:Te.sibling=Qe,Te=Qe);return nt&&ws(U,Me),Ce}for(Ee=c(U,Ee);!Qe.done;Me++,Qe=V.next())Qe=be(Ee,U,Me,Qe.value,pe),Qe!==null&&(t&&Qe.alternate!==null&&Ee.delete(Qe.key===null?Me:Qe.key),z=h(Qe,z,Me),Te===null?Ce=Qe:Te.sibling=Qe,Te=Qe);return t&&Ee.forEach(function(Yg){return r(U,Yg)}),nt&&ws(U,Me),Ce}function ut(U,z,V,pe){if(typeof V=="object"&&V!==null&&V.type===L&&V.key===null&&(V=V.props.children),typeof V=="object"&&V!==null){switch(V.$$typeof){case I:e:{for(var Ce=V.key,Te=z;Te!==null;){if(Te.key===Ce){if(Ce=V.type,Ce===L){if(Te.tag===7){l(U,Te.sibling),z=f(Te,V.props.children),z.return=U,U=z;break e}}else if(Te.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===ee&&Hd(Ce)===Te.type){l(U,Te.sibling),z=f(Te,V.props),z.ref=Ua(U,Te,V),z.return=U,U=z;break e}l(U,Te);break}else r(U,Te);Te=Te.sibling}V.type===L?(z=Ts(V.props.children,U.mode,pe,V.key),z.return=U,U=z):(pe=go(V.type,V.key,V.props,null,U.mode,pe),pe.ref=Ua(U,z,V),pe.return=U,U=pe)}return k(U);case $:e:{for(Te=V.key;z!==null;){if(z.key===Te)if(z.tag===4&&z.stateNode.containerInfo===V.containerInfo&&z.stateNode.implementation===V.implementation){l(U,z.sibling),z=f(z,V.children||[]),z.return=U,U=z;break e}else{l(U,z);break}else r(U,z);z=z.sibling}z=Oc(V,U.mode,pe),z.return=U,U=z}return k(U);case ee:return Te=V._init,ut(U,z,Te(V._payload),pe)}if(Xn(V))return Ne(U,z,V,pe);if(F(V))return Se(U,z,V,pe);Hl(U,V)}return typeof V=="string"&&V!==""||typeof V=="number"?(V=""+V,z!==null&&z.tag===6?(l(U,z.sibling),z=f(z,V),z.return=U,U=z):(l(U,z),z=_c(V,U.mode,pe),z.return=U,U=z),k(U)):l(U,z)}return ut}var da=Wd(!0),Vd=Wd(!1),Wl=Kr(null),Vl=null,fa=null,Vi=null;function Qi(){Vi=fa=Vl=null}function Gi(t){var r=Wl.current;et(Wl),t._currentValue=r}function Yi(t,r,l){for(;t!==null;){var c=t.alternate;if((t.childLanes&r)!==r?(t.childLanes|=r,c!==null&&(c.childLanes|=r)):c!==null&&(c.childLanes&r)!==r&&(c.childLanes|=r),t===l)break;t=t.return}}function pa(t,r){Vl=t,Vi=fa=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&r)!==0&&(en=!0),t.firstContext=null)}function Rn(t){var r=t._currentValue;if(Vi!==t)if(t={context:t,memoizedValue:r,next:null},fa===null){if(Vl===null)throw Error(a(308));fa=t,Vl.dependencies={lanes:0,firstContext:t}}else fa=fa.next=t;return r}var ks=null;function Xi(t){ks===null?ks=[t]:ks.push(t)}function Qd(t,r,l,c){var f=r.interleaved;return f===null?(l.next=l,Xi(r)):(l.next=f.next,f.next=l),r.interleaved=l,Rr(t,c)}function Rr(t,r){t.lanes|=r;var l=t.alternate;for(l!==null&&(l.lanes|=r),l=t,t=t.return;t!==null;)t.childLanes|=r,l=t.alternate,l!==null&&(l.childLanes|=r),l=t,t=t.return;return l.tag===3?l.stateNode:null}var Vr=!1;function Ji(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Gd(t,r){t=t.updateQueue,r.updateQueue===t&&(r.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Ir(t,r){return{eventTime:t,lane:r,tag:0,payload:null,callback:null,next:null}}function Qr(t,r,l){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(Ve&2)!==0){var f=c.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),c.pending=r,Rr(t,l)}return f=c.interleaved,f===null?(r.next=r,Xi(c)):(r.next=f.next,f.next=r),c.interleaved=r,Rr(t,l)}function Ql(t,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194240)!==0)){var c=r.lanes;c&=t.pendingLanes,l|=c,r.lanes=l,Ct(t,l)}}function Yd(t,r){var l=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,l===c)){var f=null,h=null;if(l=l.firstBaseUpdate,l!==null){do{var k={eventTime:l.eventTime,lane:l.lane,tag:l.tag,payload:l.payload,callback:l.callback,next:null};h===null?f=h=k:h=h.next=k,l=l.next}while(l!==null);h===null?f=h=r:h=h.next=r}else f=h=r;l={baseState:c.baseState,firstBaseUpdate:f,lastBaseUpdate:h,shared:c.shared,effects:c.effects},t.updateQueue=l;return}t=l.lastBaseUpdate,t===null?l.firstBaseUpdate=r:t.next=r,l.lastBaseUpdate=r}function Gl(t,r,l,c){var f=t.updateQueue;Vr=!1;var h=f.firstBaseUpdate,k=f.lastBaseUpdate,M=f.shared.pending;if(M!==null){f.shared.pending=null;var D=M,G=D.next;D.next=null,k===null?h=G:k.next=G,k=D;var ue=t.alternate;ue!==null&&(ue=ue.updateQueue,M=ue.lastBaseUpdate,M!==k&&(M===null?ue.firstBaseUpdate=G:M.next=G,ue.lastBaseUpdate=D))}if(h!==null){var fe=f.baseState;k=0,ue=G=D=null,M=h;do{var ie=M.lane,be=M.eventTime;if((c&ie)===ie){ue!==null&&(ue=ue.next={eventTime:be,lane:0,tag:M.tag,payload:M.payload,callback:M.callback,next:null});e:{var Ne=t,Se=M;switch(ie=r,be=l,Se.tag){case 1:if(Ne=Se.payload,typeof Ne=="function"){fe=Ne.call(be,fe,ie);break e}fe=Ne;break e;case 3:Ne.flags=Ne.flags&-65537|128;case 0:if(Ne=Se.payload,ie=typeof Ne=="function"?Ne.call(be,fe,ie):Ne,ie==null)break e;fe=K({},fe,ie);break e;case 2:Vr=!0}}M.callback!==null&&M.lane!==0&&(t.flags|=64,ie=f.effects,ie===null?f.effects=[M]:ie.push(M))}else be={eventTime:be,lane:ie,tag:M.tag,payload:M.payload,callback:M.callback,next:null},ue===null?(G=ue=be,D=fe):ue=ue.next=be,k|=ie;if(M=M.next,M===null){if(M=f.shared.pending,M===null)break;ie=M,M=ie.next,ie.next=null,f.lastBaseUpdate=ie,f.shared.pending=null}}while(!0);if(ue===null&&(D=fe),f.baseState=D,f.firstBaseUpdate=G,f.lastBaseUpdate=ue,r=f.shared.interleaved,r!==null){f=r;do k|=f.lane,f=f.next;while(f!==r)}else h===null&&(f.shared.lanes=0);Ss|=k,t.lanes=k,t.memoizedState=fe}}function Xd(t,r,l){if(t=r.effects,r.effects=null,t!==null)for(r=0;r<t.length;r++){var c=t[r],f=c.callback;if(f!==null){if(c.callback=null,c=l,typeof f!="function")throw Error(a(191,f));f.call(c)}}}var Ka={},sr=Kr(Ka),Ha=Kr(Ka),Wa=Kr(Ka);function js(t){if(t===Ka)throw Error(a(174));return t}function Zi(t,r){switch(Xe(Wa,r),Xe(Ha,t),Xe(sr,Ka),t=r.nodeType,t){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:On(null,"");break;default:t=t===8?r.parentNode:r,r=t.namespaceURI||null,t=t.tagName,r=On(r,t)}et(sr),Xe(sr,r)}function ma(){et(sr),et(Ha),et(Wa)}function Jd(t){js(Wa.current);var r=js(sr.current),l=On(r,t.type);r!==l&&(Xe(Ha,t),Xe(sr,l))}function ec(t){Ha.current===t&&(et(sr),et(Ha))}var lt=Kr(0);function Yl(t){for(var r=t;r!==null;){if(r.tag===13){var l=r.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||l.data==="$?"||l.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var tc=[];function nc(){for(var t=0;t<tc.length;t++)tc[t]._workInProgressVersionPrimary=null;tc.length=0}var Xl=b.ReactCurrentDispatcher,rc=b.ReactCurrentBatchConfig,Ns=0,ot=null,yt=null,Rt=null,Jl=!1,Va=!1,Qa=0,yg=0;function zt(){throw Error(a(321))}function sc(t,r){if(r===null)return!1;for(var l=0;l<r.length&&l<t.length;l++)if(!Kn(t[l],r[l]))return!1;return!0}function ac(t,r,l,c,f,h){if(Ns=h,ot=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Xl.current=t===null||t.memoizedState===null?kg:jg,t=l(c,f),Va){h=0;do{if(Va=!1,Qa=0,25<=h)throw Error(a(301));h+=1,Rt=yt=null,r.updateQueue=null,Xl.current=Ng,t=l(c,f)}while(Va)}if(Xl.current=to,r=yt!==null&&yt.next!==null,Ns=0,Rt=yt=ot=null,Jl=!1,r)throw Error(a(300));return t}function lc(){var t=Qa!==0;return Qa=0,t}function ar(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Rt===null?ot.memoizedState=Rt=t:Rt=Rt.next=t,Rt}function In(){if(yt===null){var t=ot.alternate;t=t!==null?t.memoizedState:null}else t=yt.next;var r=Rt===null?ot.memoizedState:Rt.next;if(r!==null)Rt=r,yt=t;else{if(t===null)throw Error(a(310));yt=t,t={memoizedState:yt.memoizedState,baseState:yt.baseState,baseQueue:yt.baseQueue,queue:yt.queue,next:null},Rt===null?ot.memoizedState=Rt=t:Rt=Rt.next=t}return Rt}function Ga(t,r){return typeof r=="function"?r(t):r}function oc(t){var r=In(),l=r.queue;if(l===null)throw Error(a(311));l.lastRenderedReducer=t;var c=yt,f=c.baseQueue,h=l.pending;if(h!==null){if(f!==null){var k=f.next;f.next=h.next,h.next=k}c.baseQueue=f=h,l.pending=null}if(f!==null){h=f.next,c=c.baseState;var M=k=null,D=null,G=h;do{var ue=G.lane;if((Ns&ue)===ue)D!==null&&(D=D.next={lane:0,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null}),c=G.hasEagerState?G.eagerState:t(c,G.action);else{var fe={lane:ue,action:G.action,hasEagerState:G.hasEagerState,eagerState:G.eagerState,next:null};D===null?(M=D=fe,k=c):D=D.next=fe,ot.lanes|=ue,Ss|=ue}G=G.next}while(G!==null&&G!==h);D===null?k=c:D.next=M,Kn(c,r.memoizedState)||(en=!0),r.memoizedState=c,r.baseState=k,r.baseQueue=D,l.lastRenderedState=c}if(t=l.interleaved,t!==null){f=t;do h=f.lane,ot.lanes|=h,Ss|=h,f=f.next;while(f!==t)}else f===null&&(l.lanes=0);return[r.memoizedState,l.dispatch]}function ic(t){var r=In(),l=r.queue;if(l===null)throw Error(a(311));l.lastRenderedReducer=t;var c=l.dispatch,f=l.pending,h=r.memoizedState;if(f!==null){l.pending=null;var k=f=f.next;do h=t(h,k.action),k=k.next;while(k!==f);Kn(h,r.memoizedState)||(en=!0),r.memoizedState=h,r.baseQueue===null&&(r.baseState=h),l.lastRenderedState=h}return[h,c]}function Zd(){}function ef(t,r){var l=ot,c=In(),f=r(),h=!Kn(c.memoizedState,f);if(h&&(c.memoizedState=f,en=!0),c=c.queue,cc(rf.bind(null,l,c,t),[t]),c.getSnapshot!==r||h||Rt!==null&&Rt.memoizedState.tag&1){if(l.flags|=2048,Ya(9,nf.bind(null,l,c,f,r),void 0,null),It===null)throw Error(a(349));(Ns&30)!==0||tf(l,r,f)}return f}function tf(t,r,l){t.flags|=16384,t={getSnapshot:r,value:l},r=ot.updateQueue,r===null?(r={lastEffect:null,stores:null},ot.updateQueue=r,r.stores=[t]):(l=r.stores,l===null?r.stores=[t]:l.push(t))}function nf(t,r,l,c){r.value=l,r.getSnapshot=c,sf(r)&&af(t)}function rf(t,r,l){return l(function(){sf(r)&&af(t)})}function sf(t){var r=t.getSnapshot;t=t.value;try{var l=r();return!Kn(t,l)}catch{return!0}}function af(t){var r=Rr(t,1);r!==null&&Gn(r,t,1,-1)}function lf(t){var r=ar();return typeof t=="function"&&(t=t()),r.memoizedState=r.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ga,lastRenderedState:t},r.queue=t,t=t.dispatch=wg.bind(null,ot,t),[r.memoizedState,t]}function Ya(t,r,l,c){return t={tag:t,create:r,destroy:l,deps:c,next:null},r=ot.updateQueue,r===null?(r={lastEffect:null,stores:null},ot.updateQueue=r,r.lastEffect=t.next=t):(l=r.lastEffect,l===null?r.lastEffect=t.next=t:(c=l.next,l.next=t,t.next=c,r.lastEffect=t)),t}function of(){return In().memoizedState}function Zl(t,r,l,c){var f=ar();ot.flags|=t,f.memoizedState=Ya(1|r,l,void 0,c===void 0?null:c)}function eo(t,r,l,c){var f=In();c=c===void 0?null:c;var h=void 0;if(yt!==null){var k=yt.memoizedState;if(h=k.destroy,c!==null&&sc(c,k.deps)){f.memoizedState=Ya(r,l,h,c);return}}ot.flags|=t,f.memoizedState=Ya(1|r,l,h,c)}function cf(t,r){return Zl(8390656,8,t,r)}function cc(t,r){return eo(2048,8,t,r)}function uf(t,r){return eo(4,2,t,r)}function df(t,r){return eo(4,4,t,r)}function ff(t,r){if(typeof r=="function")return t=t(),r(t),function(){r(null)};if(r!=null)return t=t(),r.current=t,function(){r.current=null}}function pf(t,r,l){return l=l!=null?l.concat([t]):null,eo(4,4,ff.bind(null,r,t),l)}function uc(){}function mf(t,r){var l=In();r=r===void 0?null:r;var c=l.memoizedState;return c!==null&&r!==null&&sc(r,c[1])?c[0]:(l.memoizedState=[t,r],t)}function hf(t,r){var l=In();r=r===void 0?null:r;var c=l.memoizedState;return c!==null&&r!==null&&sc(r,c[1])?c[0]:(t=t(),l.memoizedState=[t,r],t)}function gf(t,r,l){return(Ns&21)===0?(t.baseState&&(t.baseState=!1,en=!0),t.memoizedState=l):(Kn(l,r)||(l=we(),ot.lanes|=l,Ss|=l,t.baseState=!0),r)}function vg(t,r){var l=$e;$e=l!==0&&4>l?l:4,t(!0);var c=rc.transition;rc.transition={};try{t(!1),r()}finally{$e=l,rc.transition=c}}function xf(){return In().memoizedState}function bg(t,r,l){var c=Jr(t);if(l={lane:c,action:l,hasEagerState:!1,eagerState:null,next:null},yf(t))vf(r,l);else if(l=Qd(t,r,l,c),l!==null){var f=Vt();Gn(l,t,c,f),bf(l,r,c)}}function wg(t,r,l){var c=Jr(t),f={lane:c,action:l,hasEagerState:!1,eagerState:null,next:null};if(yf(t))vf(r,f);else{var h=t.alternate;if(t.lanes===0&&(h===null||h.lanes===0)&&(h=r.lastRenderedReducer,h!==null))try{var k=r.lastRenderedState,M=h(k,l);if(f.hasEagerState=!0,f.eagerState=M,Kn(M,k)){var D=r.interleaved;D===null?(f.next=f,Xi(r)):(f.next=D.next,D.next=f),r.interleaved=f;return}}catch{}finally{}l=Qd(t,r,f,c),l!==null&&(f=Vt(),Gn(l,t,c,f),bf(l,r,c))}}function yf(t){var r=t.alternate;return t===ot||r!==null&&r===ot}function vf(t,r){Va=Jl=!0;var l=t.pending;l===null?r.next=r:(r.next=l.next,l.next=r),t.pending=r}function bf(t,r,l){if((l&4194240)!==0){var c=r.lanes;c&=t.pendingLanes,l|=c,r.lanes=l,Ct(t,l)}}var to={readContext:Rn,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useInsertionEffect:zt,useLayoutEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useMutableSource:zt,useSyncExternalStore:zt,useId:zt,unstable_isNewReconciler:!1},kg={readContext:Rn,useCallback:function(t,r){return ar().memoizedState=[t,r===void 0?null:r],t},useContext:Rn,useEffect:cf,useImperativeHandle:function(t,r,l){return l=l!=null?l.concat([t]):null,Zl(4194308,4,ff.bind(null,r,t),l)},useLayoutEffect:function(t,r){return Zl(4194308,4,t,r)},useInsertionEffect:function(t,r){return Zl(4,2,t,r)},useMemo:function(t,r){var l=ar();return r=r===void 0?null:r,t=t(),l.memoizedState=[t,r],t},useReducer:function(t,r,l){var c=ar();return r=l!==void 0?l(r):r,c.memoizedState=c.baseState=r,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:r},c.queue=t,t=t.dispatch=bg.bind(null,ot,t),[c.memoizedState,t]},useRef:function(t){var r=ar();return t={current:t},r.memoizedState=t},useState:lf,useDebugValue:uc,useDeferredValue:function(t){return ar().memoizedState=t},useTransition:function(){var t=lf(!1),r=t[0];return t=vg.bind(null,t[1]),ar().memoizedState=t,[r,t]},useMutableSource:function(){},useSyncExternalStore:function(t,r,l){var c=ot,f=ar();if(nt){if(l===void 0)throw Error(a(407));l=l()}else{if(l=r(),It===null)throw Error(a(349));(Ns&30)!==0||tf(c,r,l)}f.memoizedState=l;var h={value:l,getSnapshot:r};return f.queue=h,cf(rf.bind(null,c,h,t),[t]),c.flags|=2048,Ya(9,nf.bind(null,c,h,l,r),void 0,null),l},useId:function(){var t=ar(),r=It.identifierPrefix;if(nt){var l=Cr,c=Sr;l=(c&~(1<<32-J(c)-1)).toString(32)+l,r=":"+r+"R"+l,l=Qa++,0<l&&(r+="H"+l.toString(32)),r+=":"}else l=yg++,r=":"+r+"r"+l.toString(32)+":";return t.memoizedState=r},unstable_isNewReconciler:!1},jg={readContext:Rn,useCallback:mf,useContext:Rn,useEffect:cc,useImperativeHandle:pf,useInsertionEffect:uf,useLayoutEffect:df,useMemo:hf,useReducer:oc,useRef:of,useState:function(){return oc(Ga)},useDebugValue:uc,useDeferredValue:function(t){var r=In();return gf(r,yt.memoizedState,t)},useTransition:function(){var t=oc(Ga)[0],r=In().memoizedState;return[t,r]},useMutableSource:Zd,useSyncExternalStore:ef,useId:xf,unstable_isNewReconciler:!1},Ng={readContext:Rn,useCallback:mf,useContext:Rn,useEffect:cc,useImperativeHandle:pf,useInsertionEffect:uf,useLayoutEffect:df,useMemo:hf,useReducer:ic,useRef:of,useState:function(){return ic(Ga)},useDebugValue:uc,useDeferredValue:function(t){var r=In();return yt===null?r.memoizedState=t:gf(r,yt.memoizedState,t)},useTransition:function(){var t=ic(Ga)[0],r=In().memoizedState;return[t,r]},useMutableSource:Zd,useSyncExternalStore:ef,useId:xf,unstable_isNewReconciler:!1};function Wn(t,r){if(t&&t.defaultProps){r=K({},r),t=t.defaultProps;for(var l in t)r[l]===void 0&&(r[l]=t[l]);return r}return r}function dc(t,r,l,c){r=t.memoizedState,l=l(c,r),l=l==null?r:K({},r,l),t.memoizedState=l,t.lanes===0&&(t.updateQueue.baseState=l)}var no={isMounted:function(t){return(t=t._reactInternals)?tr(t)===t:!1},enqueueSetState:function(t,r,l){t=t._reactInternals;var c=Vt(),f=Jr(t),h=Ir(c,f);h.payload=r,l!=null&&(h.callback=l),r=Qr(t,h,f),r!==null&&(Gn(r,t,f,c),Ql(r,t,f))},enqueueReplaceState:function(t,r,l){t=t._reactInternals;var c=Vt(),f=Jr(t),h=Ir(c,f);h.tag=1,h.payload=r,l!=null&&(h.callback=l),r=Qr(t,h,f),r!==null&&(Gn(r,t,f,c),Ql(r,t,f))},enqueueForceUpdate:function(t,r){t=t._reactInternals;var l=Vt(),c=Jr(t),f=Ir(l,c);f.tag=2,r!=null&&(f.callback=r),r=Qr(t,f,c),r!==null&&(Gn(r,t,c,l),Ql(r,t,c))}};function wf(t,r,l,c,f,h,k){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(c,h,k):r.prototype&&r.prototype.isPureReactComponent?!La(l,c)||!La(f,h):!0}function kf(t,r,l){var c=!1,f=Hr,h=r.contextType;return typeof h=="object"&&h!==null?h=Rn(h):(f=Zt(r)?vs:Bt.current,c=r.contextTypes,h=(c=c!=null)?oa(t,f):Hr),r=new r(l,h),t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=no,t.stateNode=r,r._reactInternals=t,c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=f,t.__reactInternalMemoizedMaskedChildContext=h),r}function jf(t,r,l,c){t=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(l,c),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(l,c),r.state!==t&&no.enqueueReplaceState(r,r.state,null)}function fc(t,r,l,c){var f=t.stateNode;f.props=l,f.state=t.memoizedState,f.refs={},Ji(t);var h=r.contextType;typeof h=="object"&&h!==null?f.context=Rn(h):(h=Zt(r)?vs:Bt.current,f.context=oa(t,h)),f.state=t.memoizedState,h=r.getDerivedStateFromProps,typeof h=="function"&&(dc(t,r,h,l),f.state=t.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof f.getSnapshotBeforeUpdate=="function"||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(r=f.state,typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount(),r!==f.state&&no.enqueueReplaceState(f,f.state,null),Gl(t,l,f,c),f.state=t.memoizedState),typeof f.componentDidMount=="function"&&(t.flags|=4194308)}function ha(t,r){try{var l="",c=r;do l+=Z(c),c=c.return;while(c);var f=l}catch(h){f=`
24
24
  Error generating stack: `+h.message+`
25
- `+h.stack}return{value:t,source:r,stack:f,digest:null}}function pc(t,r,l){return{value:t,source:null,stack:l??null,digest:r??null}}function mc(t,r){try{console.error(r.value)}catch(l){setTimeout(function(){throw l})}}var Sg=typeof WeakMap=="function"?WeakMap:Map;function Nf(t,r,l){l=Ir(-1,l),l.tag=3,l.payload={element:null};var c=r.value;return l.callback=function(){io||(io=!0,Tc=c),mc(t,r)},l}function Sf(t,r,l){l=Ir(-1,l),l.tag=3;var c=t.type.getDerivedStateFromError;if(typeof c=="function"){var f=r.value;l.payload=function(){return c(f)},l.callback=function(){mc(t,r)}}var h=t.stateNode;return h!==null&&typeof h.componentDidCatch=="function"&&(l.callback=function(){mc(t,r),typeof c!="function"&&(Yr===null?Yr=new Set([this]):Yr.add(this));var k=r.stack;this.componentDidCatch(r.value,{componentStack:k!==null?k:""})}),l}function Cf(t,r,l){var c=t.pingCache;if(c===null){c=t.pingCache=new Sg;var f=new Set;c.set(r,f)}else f=c.get(r),f===void 0&&(f=new Set,c.set(r,f));f.has(l)||(f.add(l),t=Dg.bind(null,t,r,l),r.then(t,t))}function Rf(t){do{var r;if((r=t.tag===13)&&(r=t.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return t;t=t.return}while(t!==null);return null}function If(t,r,l,c,f){return(t.mode&1)===0?(t===r?t.flags|=65536:(t.flags|=128,l.flags|=131072,l.flags&=-52805,l.tag===1&&(l.alternate===null?l.tag=17:(r=Ir(-1,1),r.tag=2,Qr(l,r,1))),l.lanes|=1),t):(t.flags|=65536,t.lanes=f,t)}var Cg=j.ReactCurrentOwner,en=!1;function Wt(t,r,l,c){r.child=t===null?Vd(r,null,l,c):da(r,t.child,l,c)}function Tf(t,r,l,c,f){l=l.render;var h=r.ref;return pa(r,f),c=ac(t,r,l,c,h,f),l=lc(),t!==null&&!en?(r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~f,Tr(t,r,f)):(nt&&l&&qi(r),r.flags|=1,Wt(t,r,c,f),r.child)}function Ef(t,r,l,c,f){if(t===null){var h=l.type;return typeof h=="function"&&!Lc(h)&&h.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(r.tag=15,r.type=h,Pf(t,r,h,c,f)):(t=ho(l.type,null,c,r,r.mode,f),t.ref=r.ref,t.return=r,r.child=t)}if(h=t.child,(t.lanes&f)===0){var k=h.memoizedProps;if(l=l.compare,l=l!==null?l:La,l(k,c)&&t.ref===r.ref)return Tr(t,r,f)}return r.flags|=1,t=es(h,c),t.ref=r.ref,t.return=r,r.child=t}function Pf(t,r,l,c,f){if(t!==null){var h=t.memoizedProps;if(La(h,c)&&t.ref===r.ref)if(en=!1,r.pendingProps=c=h,(t.lanes&f)!==0)(t.flags&131072)!==0&&(en=!0);else return r.lanes=t.lanes,Tr(t,r,f)}return hc(t,r,l,c,f)}function Af(t,r,l){var c=r.pendingProps,f=c.children,h=t!==null?t.memoizedState:null;if(c.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},Xe(xa,gn),gn|=l;else{if((l&1073741824)===0)return t=h!==null?h.baseLanes|l:l,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:t,cachePool:null,transitions:null},r.updateQueue=null,Xe(xa,gn),gn|=t,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=h!==null?h.baseLanes:l,Xe(xa,gn),gn|=c}else h!==null?(c=h.baseLanes|l,r.memoizedState=null):c=l,Xe(xa,gn),gn|=c;return Wt(t,r,f,l),r.child}function $f(t,r){var l=r.ref;(t===null&&l!==null||t!==null&&t.ref!==l)&&(r.flags|=512,r.flags|=2097152)}function hc(t,r,l,c,f){var h=Zt(l)?vs:Bt.current;return h=oa(r,h),pa(r,f),l=ac(t,r,l,c,h,f),c=lc(),t!==null&&!en?(r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~f,Tr(t,r,f)):(nt&&c&&qi(r),r.flags|=1,Wt(t,r,l,f),r.child)}function Mf(t,r,l,c,f){if(Zt(l)){var h=!0;Dl(r)}else h=!1;if(pa(r,f),r.stateNode===null)ro(t,r),kf(r,l,c),fc(r,l,c,f),c=!0;else if(t===null){var k=r.stateNode,$=r.memoizedProps;k.props=$;var O=k.context,Q=l.contextType;typeof Q=="object"&&Q!==null?Q=Rn(Q):(Q=Zt(l)?vs:Bt.current,Q=oa(r,Q));var ue=l.getDerivedStateFromProps,fe=typeof ue=="function"||typeof k.getSnapshotBeforeUpdate=="function";fe||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||($!==c||O!==Q)&&jf(r,k,c,Q),Vr=!1;var ie=r.memoizedState;k.state=ie,Ql(r,c,k,f),O=r.memoizedState,$!==c||ie!==O||Jt.current||Vr?(typeof ue=="function"&&(dc(r,l,ue,c),O=r.memoizedState),($=Vr||wf(r,l,$,c,ie,O,Q))?(fe||typeof k.UNSAFE_componentWillMount!="function"&&typeof k.componentWillMount!="function"||(typeof k.componentWillMount=="function"&&k.componentWillMount(),typeof k.UNSAFE_componentWillMount=="function"&&k.UNSAFE_componentWillMount()),typeof k.componentDidMount=="function"&&(r.flags|=4194308)):(typeof k.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=O),k.props=c,k.state=O,k.context=Q,c=$):(typeof k.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{k=r.stateNode,Gd(t,r),$=r.memoizedProps,Q=r.type===r.elementType?$:Wn(r.type,$),k.props=Q,fe=r.pendingProps,ie=k.context,O=l.contextType,typeof O=="object"&&O!==null?O=Rn(O):(O=Zt(l)?vs:Bt.current,O=oa(r,O));var be=l.getDerivedStateFromProps;(ue=typeof be=="function"||typeof k.getSnapshotBeforeUpdate=="function")||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||($!==fe||ie!==O)&&jf(r,k,c,O),Vr=!1,ie=r.memoizedState,k.state=ie,Ql(r,c,k,f);var Ne=r.memoizedState;$!==fe||ie!==Ne||Jt.current||Vr?(typeof be=="function"&&(dc(r,l,be,c),Ne=r.memoizedState),(Q=Vr||wf(r,l,Q,c,ie,Ne,O)||!1)?(ue||typeof k.UNSAFE_componentWillUpdate!="function"&&typeof k.componentWillUpdate!="function"||(typeof k.componentWillUpdate=="function"&&k.componentWillUpdate(c,Ne,O),typeof k.UNSAFE_componentWillUpdate=="function"&&k.UNSAFE_componentWillUpdate(c,Ne,O)),typeof k.componentDidUpdate=="function"&&(r.flags|=4),typeof k.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof k.componentDidUpdate!="function"||$===t.memoizedProps&&ie===t.memoizedState||(r.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||$===t.memoizedProps&&ie===t.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=Ne),k.props=c,k.state=Ne,k.context=O,c=Q):(typeof k.componentDidUpdate!="function"||$===t.memoizedProps&&ie===t.memoizedState||(r.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||$===t.memoizedProps&&ie===t.memoizedState||(r.flags|=1024),c=!1)}return gc(t,r,l,c,h,f)}function gc(t,r,l,c,f,h){$f(t,r);var k=(r.flags&128)!==0;if(!c&&!k)return f&&Od(r,l,!1),Tr(t,r,h);c=r.stateNode,Cg.current=r;var $=k&&typeof l.getDerivedStateFromError!="function"?null:c.render();return r.flags|=1,t!==null&&k?(r.child=da(r,t.child,null,h),r.child=da(r,null,$,h)):Wt(t,r,$,h),r.memoizedState=c.state,f&&Od(r,l,!0),r.child}function Ff(t){var r=t.stateNode;r.pendingContext?Ld(t,r.pendingContext,r.pendingContext!==r.context):r.context&&Ld(t,r.context,!1),Zi(t,r.containerInfo)}function Lf(t,r,l,c,f){return ua(),Wi(f),r.flags|=256,Wt(t,r,l,c),r.child}var xc={dehydrated:null,treeContext:null,retryLane:0};function yc(t){return{baseLanes:t,cachePool:null,transitions:null}}function _f(t,r,l){var c=r.pendingProps,f=lt.current,h=!1,k=(r.flags&128)!==0,$;if(($=k)||($=t!==null&&t.memoizedState===null?!1:(f&2)!==0),$?(h=!0,r.flags&=-129):(t===null||t.memoizedState!==null)&&(f|=1),Xe(lt,f&1),t===null)return Hi(r),t=r.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((r.mode&1)===0?r.lanes=1:t.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(k=c.children,t=c.fallback,h?(c=r.mode,h=r.child,k={mode:"hidden",children:k},(c&1)===0&&h!==null?(h.childLanes=0,h.pendingProps=k):h=go(k,c,0,null),t=Ts(t,c,l,null),h.return=r,t.return=r,h.sibling=t,r.child=h,r.child.memoizedState=yc(l),r.memoizedState=xc,t):vc(r,k));if(f=t.memoizedState,f!==null&&($=f.dehydrated,$!==null))return Rg(t,r,k,c,$,f,l);if(h){h=c.fallback,k=r.mode,f=t.child,$=f.sibling;var O={mode:"hidden",children:c.children};return(k&1)===0&&r.child!==f?(c=r.child,c.childLanes=0,c.pendingProps=O,r.deletions=null):(c=es(f,O),c.subtreeFlags=f.subtreeFlags&14680064),$!==null?h=es($,h):(h=Ts(h,k,l,null),h.flags|=2),h.return=r,c.return=r,c.sibling=h,r.child=c,c=h,h=r.child,k=t.child.memoizedState,k=k===null?yc(l):{baseLanes:k.baseLanes|l,cachePool:null,transitions:k.transitions},h.memoizedState=k,h.childLanes=t.childLanes&~l,r.memoizedState=xc,c}return h=t.child,t=h.sibling,c=es(h,{mode:"visible",children:c.children}),(r.mode&1)===0&&(c.lanes=l),c.return=r,c.sibling=null,t!==null&&(l=r.deletions,l===null?(r.deletions=[t],r.flags|=16):l.push(t)),r.child=c,r.memoizedState=null,c}function vc(t,r){return r=go({mode:"visible",children:r},t.mode,0,null),r.return=t,t.child=r}function no(t,r,l,c){return c!==null&&Wi(c),da(r,t.child,null,l),t=vc(r,r.pendingProps.children),t.flags|=2,r.memoizedState=null,t}function Rg(t,r,l,c,f,h,k){if(l)return r.flags&256?(r.flags&=-257,c=pc(Error(a(422))),no(t,r,k,c)):r.memoizedState!==null?(r.child=t.child,r.flags|=128,null):(h=c.fallback,f=r.mode,c=go({mode:"visible",children:c.children},f,0,null),h=Ts(h,f,k,null),h.flags|=2,c.return=r,h.return=r,c.sibling=h,r.child=c,(r.mode&1)!==0&&da(r,t.child,null,k),r.child.memoizedState=yc(k),r.memoizedState=xc,h);if((r.mode&1)===0)return no(t,r,k,null);if(f.data==="$!"){if(c=f.nextSibling&&f.nextSibling.dataset,c)var $=c.dgst;return c=$,h=Error(a(419)),c=pc(h,c,void 0),no(t,r,k,c)}if($=(k&t.childLanes)!==0,en||$){if(c=It,c!==null){switch(k&-k){case 4:f=2;break;case 16:f=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:f=32;break;case 536870912:f=268435456;break;default:f=0}f=(f&(c.suspendedLanes|k))!==0?0:f,f!==0&&f!==h.retryLane&&(h.retryLane=f,Rr(t,f),Gn(c,t,f,-1))}return Fc(),c=pc(Error(a(421))),no(t,r,k,c)}return f.data==="$?"?(r.flags|=128,r.child=t.child,r=Bg.bind(null,t),f._reactRetry=r,null):(t=h.treeContext,hn=Ur(f.nextSibling),mn=r,nt=!0,Hn=null,t!==null&&(Sn[Cn++]=Sr,Sn[Cn++]=Cr,Sn[Cn++]=bs,Sr=t.id,Cr=t.overflow,bs=r),r=vc(r,c.children),r.flags|=4096,r)}function Of(t,r,l){t.lanes|=r;var c=t.alternate;c!==null&&(c.lanes|=r),Yi(t.return,r,l)}function bc(t,r,l,c,f){var h=t.memoizedState;h===null?t.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:l,tailMode:f}:(h.isBackwards=r,h.rendering=null,h.renderingStartTime=0,h.last=c,h.tail=l,h.tailMode=f)}function Df(t,r,l){var c=r.pendingProps,f=c.revealOrder,h=c.tail;if(Wt(t,r,c.children,l),c=lt.current,(c&2)!==0)c=c&1|2,r.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=r.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Of(t,l,r);else if(t.tag===19)Of(t,l,r);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===r)break e;for(;t.sibling===null;){if(t.return===null||t.return===r)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}c&=1}if(Xe(lt,c),(r.mode&1)===0)r.memoizedState=null;else switch(f){case"forwards":for(l=r.child,f=null;l!==null;)t=l.alternate,t!==null&&Gl(t)===null&&(f=l),l=l.sibling;l=f,l===null?(f=r.child,r.child=null):(f=l.sibling,l.sibling=null),bc(r,!1,f,l,h);break;case"backwards":for(l=null,f=r.child,r.child=null;f!==null;){if(t=f.alternate,t!==null&&Gl(t)===null){r.child=f;break}t=f.sibling,f.sibling=l,l=f,f=t}bc(r,!0,l,null,h);break;case"together":bc(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function ro(t,r){(r.mode&1)===0&&t!==null&&(t.alternate=null,r.alternate=null,r.flags|=2)}function Tr(t,r,l){if(t!==null&&(r.dependencies=t.dependencies),Ss|=r.lanes,(l&r.childLanes)===0)return null;if(t!==null&&r.child!==t.child)throw Error(a(153));if(r.child!==null){for(t=r.child,l=es(t,t.pendingProps),r.child=l,l.return=r;t.sibling!==null;)t=t.sibling,l=l.sibling=es(t,t.pendingProps),l.return=r;l.sibling=null}return r.child}function Ig(t,r,l){switch(r.tag){case 3:Ff(r),ua();break;case 5:Jd(r);break;case 1:Zt(r.type)&&Dl(r);break;case 4:Zi(r,r.stateNode.containerInfo);break;case 10:var c=r.type._context,f=r.memoizedProps.value;Xe(Hl,c._currentValue),c._currentValue=f;break;case 13:if(c=r.memoizedState,c!==null)return c.dehydrated!==null?(Xe(lt,lt.current&1),r.flags|=128,null):(l&r.child.childLanes)!==0?_f(t,r,l):(Xe(lt,lt.current&1),t=Tr(t,r,l),t!==null?t.sibling:null);Xe(lt,lt.current&1);break;case 19:if(c=(l&r.childLanes)!==0,(t.flags&128)!==0){if(c)return Df(t,r,l);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Xe(lt,lt.current),c)break;return null;case 22:case 23:return r.lanes=0,Af(t,r,l)}return Tr(t,r,l)}var Bf,wc,zf,qf;Bf=function(t,r){for(var l=r.child;l!==null;){if(l.tag===5||l.tag===6)t.appendChild(l.stateNode);else if(l.tag!==4&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===r)break;for(;l.sibling===null;){if(l.return===null||l.return===r)return;l=l.return}l.sibling.return=l.return,l=l.sibling}},wc=function(){},zf=function(t,r,l,c){var f=t.memoizedProps;if(f!==c){t=r.stateNode,js(sr.current);var h=null;switch(l){case"input":f=Fn(t,f),c=Fn(t,c),h=[];break;case"select":f=K({},f,{value:void 0}),c=K({},c,{value:void 0}),h=[];break;case"textarea":f=bn(t,f),c=bn(t,c),h=[];break;default:typeof f.onClick!="function"&&typeof c.onClick=="function"&&(t.onclick=Ll)}Jn(l,c);var k;l=null;for(Q in f)if(!c.hasOwnProperty(Q)&&f.hasOwnProperty(Q)&&f[Q]!=null)if(Q==="style"){var $=f[Q];for(k in $)$.hasOwnProperty(k)&&(l||(l={}),l[k]="")}else Q!=="dangerouslySetInnerHTML"&&Q!=="children"&&Q!=="suppressContentEditableWarning"&&Q!=="suppressHydrationWarning"&&Q!=="autoFocus"&&(i.hasOwnProperty(Q)?h||(h=[]):(h=h||[]).push(Q,null));for(Q in c){var O=c[Q];if($=f!=null?f[Q]:void 0,c.hasOwnProperty(Q)&&O!==$&&(O!=null||$!=null))if(Q==="style")if($){for(k in $)!$.hasOwnProperty(k)||O&&O.hasOwnProperty(k)||(l||(l={}),l[k]="");for(k in O)O.hasOwnProperty(k)&&$[k]!==O[k]&&(l||(l={}),l[k]=O[k])}else l||(h||(h=[]),h.push(Q,l)),l=O;else Q==="dangerouslySetInnerHTML"?(O=O?O.__html:void 0,$=$?$.__html:void 0,O!=null&&$!==O&&(h=h||[]).push(Q,O)):Q==="children"?typeof O!="string"&&typeof O!="number"||(h=h||[]).push(Q,""+O):Q!=="suppressContentEditableWarning"&&Q!=="suppressHydrationWarning"&&(i.hasOwnProperty(Q)?(O!=null&&Q==="onScroll"&&Ze("scroll",t),h||$===O||(h=[])):(h=h||[]).push(Q,O))}l&&(h=h||[]).push("style",l);var Q=h;(r.updateQueue=Q)&&(r.flags|=4)}},qf=function(t,r,l,c){l!==c&&(r.flags|=4)};function Xa(t,r){if(!nt)switch(t.tailMode){case"hidden":r=t.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?t.tail=null:l.sibling=null;break;case"collapsed":l=t.tail;for(var c=null;l!==null;)l.alternate!==null&&(c=l),l=l.sibling;c===null?r||t.tail===null?t.tail=null:t.tail.sibling=null:c.sibling=null}}function qt(t){var r=t.alternate!==null&&t.alternate.child===t.child,l=0,c=0;if(r)for(var f=t.child;f!==null;)l|=f.lanes|f.childLanes,c|=f.subtreeFlags&14680064,c|=f.flags&14680064,f.return=t,f=f.sibling;else for(f=t.child;f!==null;)l|=f.lanes|f.childLanes,c|=f.subtreeFlags,c|=f.flags,f.return=t,f=f.sibling;return t.subtreeFlags|=c,t.childLanes=l,r}function Tg(t,r,l){var c=r.pendingProps;switch(Ui(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return qt(r),null;case 1:return Zt(r.type)&&Ol(),qt(r),null;case 3:return c=r.stateNode,ma(),et(Jt),et(Bt),nc(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(t===null||t.child===null)&&(Ul(r)?r.flags|=4:t===null||t.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Hn!==null&&(Ac(Hn),Hn=null))),wc(t,r),qt(r),null;case 5:ec(r);var f=js(Wa.current);if(l=r.type,t!==null&&r.stateNode!=null)zf(t,r,l,c,f),t.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!c){if(r.stateNode===null)throw Error(a(166));return qt(r),null}if(t=js(sr.current),Ul(r)){c=r.stateNode,l=r.type;var h=r.memoizedProps;switch(c[rr]=r,c[za]=h,t=(r.mode&1)!==0,l){case"dialog":Ze("cancel",c),Ze("close",c);break;case"iframe":case"object":case"embed":Ze("load",c);break;case"video":case"audio":for(f=0;f<Oa.length;f++)Ze(Oa[f],c);break;case"source":Ze("error",c);break;case"img":case"image":case"link":Ze("error",c),Ze("load",c);break;case"details":Ze("toggle",c);break;case"input":_t(c,h),Ze("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!h.multiple},Ze("invalid",c);break;case"textarea":re(c,h),Ze("invalid",c)}Jn(l,h),f=null;for(var k in h)if(h.hasOwnProperty(k)){var $=h[k];k==="children"?typeof $=="string"?c.textContent!==$&&(h.suppressHydrationWarning!==!0&&Fl(c.textContent,$,t),f=["children",$]):typeof $=="number"&&c.textContent!==""+$&&(h.suppressHydrationWarning!==!0&&Fl(c.textContent,$,t),f=["children",""+$]):i.hasOwnProperty(k)&&$!=null&&k==="onScroll"&&Ze("scroll",c)}switch(l){case"input":vn(c),pr(c,h,!0);break;case"textarea":vn(c),it(c);break;case"select":case"option":break;default:typeof h.onClick=="function"&&(c.onclick=Ll)}c=f,r.updateQueue=c,c!==null&&(r.flags|=4)}else{k=f.nodeType===9?f:f.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=at(l)),t==="http://www.w3.org/1999/xhtml"?l==="script"?(t=k.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof c.is=="string"?t=k.createElement(l,{is:c.is}):(t=k.createElement(l),l==="select"&&(k=t,c.multiple?k.multiple=!0:c.size&&(k.size=c.size))):t=k.createElementNS(t,l),t[rr]=r,t[za]=c,Bf(t,r,!1,!1),r.stateNode=t;e:{switch(k=Ks(l,c),l){case"dialog":Ze("cancel",t),Ze("close",t),f=c;break;case"iframe":case"object":case"embed":Ze("load",t),f=c;break;case"video":case"audio":for(f=0;f<Oa.length;f++)Ze(Oa[f],t);f=c;break;case"source":Ze("error",t),f=c;break;case"img":case"image":case"link":Ze("error",t),Ze("load",t),f=c;break;case"details":Ze("toggle",t),f=c;break;case"input":_t(t,c),f=Fn(t,c),Ze("invalid",t);break;case"option":f=c;break;case"select":t._wrapperState={wasMultiple:!!c.multiple},f=K({},c,{value:void 0}),Ze("invalid",t);break;case"textarea":re(t,c),f=bn(t,c),Ze("invalid",t);break;default:f=c}Jn(l,f),$=f;for(h in $)if($.hasOwnProperty(h)){var O=$[h];h==="style"?bl(t,O):h==="dangerouslySetInnerHTML"?(O=O?O.__html:void 0,O!=null&&on(t,O)):h==="children"?typeof O=="string"?(l!=="textarea"||O!=="")&&os(t,O):typeof O=="number"&&os(t,""+O):h!=="suppressContentEditableWarning"&&h!=="suppressHydrationWarning"&&h!=="autoFocus"&&(i.hasOwnProperty(h)?O!=null&&h==="onScroll"&&Ze("scroll",t):O!=null&&S(t,h,O,k))}switch(l){case"input":vn(t),pr(t,c,!1);break;case"textarea":vn(t),it(t);break;case"option":c.value!=null&&t.setAttribute("value",""+st(c.value));break;case"select":t.multiple=!!c.multiple,h=c.value,h!=null?_n(t,!!c.multiple,h,!1):c.defaultValue!=null&&_n(t,!!c.multiple,c.defaultValue,!0);break;default:typeof f.onClick=="function"&&(t.onclick=Ll)}switch(l){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}}c&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return qt(r),null;case 6:if(t&&r.stateNode!=null)qf(t,r,t.memoizedProps,c);else{if(typeof c!="string"&&r.stateNode===null)throw Error(a(166));if(l=js(Wa.current),js(sr.current),Ul(r)){if(c=r.stateNode,l=r.memoizedProps,c[rr]=r,(h=c.nodeValue!==l)&&(t=mn,t!==null))switch(t.tag){case 3:Fl(c.nodeValue,l,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&Fl(c.nodeValue,l,(t.mode&1)!==0)}h&&(r.flags|=4)}else c=(l.nodeType===9?l:l.ownerDocument).createTextNode(c),c[rr]=r,r.stateNode=c}return qt(r),null;case 13:if(et(lt),c=r.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(nt&&hn!==null&&(r.mode&1)!==0&&(r.flags&128)===0)Kd(),ua(),r.flags|=98560,h=!1;else if(h=Ul(r),c!==null&&c.dehydrated!==null){if(t===null){if(!h)throw Error(a(318));if(h=r.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(a(317));h[rr]=r}else ua(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;qt(r),h=!1}else Hn!==null&&(Ac(Hn),Hn=null),h=!0;if(!h)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=l,r):(c=c!==null,c!==(t!==null&&t.memoizedState!==null)&&c&&(r.child.flags|=8192,(r.mode&1)!==0&&(t===null||(lt.current&1)!==0?vt===0&&(vt=3):Fc())),r.updateQueue!==null&&(r.flags|=4),qt(r),null);case 4:return ma(),wc(t,r),t===null&&Da(r.stateNode.containerInfo),qt(r),null;case 10:return Gi(r.type._context),qt(r),null;case 17:return Zt(r.type)&&Ol(),qt(r),null;case 19:if(et(lt),h=r.memoizedState,h===null)return qt(r),null;if(c=(r.flags&128)!==0,k=h.rendering,k===null)if(c)Xa(h,!1);else{if(vt!==0||t!==null&&(t.flags&128)!==0)for(t=r.child;t!==null;){if(k=Gl(t),k!==null){for(r.flags|=128,Xa(h,!1),c=k.updateQueue,c!==null&&(r.updateQueue=c,r.flags|=4),r.subtreeFlags=0,c=l,l=r.child;l!==null;)h=l,t=c,h.flags&=14680066,k=h.alternate,k===null?(h.childLanes=0,h.lanes=t,h.child=null,h.subtreeFlags=0,h.memoizedProps=null,h.memoizedState=null,h.updateQueue=null,h.dependencies=null,h.stateNode=null):(h.childLanes=k.childLanes,h.lanes=k.lanes,h.child=k.child,h.subtreeFlags=0,h.deletions=null,h.memoizedProps=k.memoizedProps,h.memoizedState=k.memoizedState,h.updateQueue=k.updateQueue,h.type=k.type,t=k.dependencies,h.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),l=l.sibling;return Xe(lt,lt.current&1|2),r.child}t=t.sibling}h.tail!==null&&Je()>ya&&(r.flags|=128,c=!0,Xa(h,!1),r.lanes=4194304)}else{if(!c)if(t=Gl(k),t!==null){if(r.flags|=128,c=!0,l=t.updateQueue,l!==null&&(r.updateQueue=l,r.flags|=4),Xa(h,!0),h.tail===null&&h.tailMode==="hidden"&&!k.alternate&&!nt)return qt(r),null}else 2*Je()-h.renderingStartTime>ya&&l!==1073741824&&(r.flags|=128,c=!0,Xa(h,!1),r.lanes=4194304);h.isBackwards?(k.sibling=r.child,r.child=k):(l=h.last,l!==null?l.sibling=k:r.child=k,h.last=k)}return h.tail!==null?(r=h.tail,h.rendering=r,h.tail=r.sibling,h.renderingStartTime=Je(),r.sibling=null,l=lt.current,Xe(lt,c?l&1|2:l&1),r):(qt(r),null);case 22:case 23:return Mc(),c=r.memoizedState!==null,t!==null&&t.memoizedState!==null!==c&&(r.flags|=8192),c&&(r.mode&1)!==0?(gn&1073741824)!==0&&(qt(r),r.subtreeFlags&6&&(r.flags|=8192)):qt(r),null;case 24:return null;case 25:return null}throw Error(a(156,r.tag))}function Eg(t,r){switch(Ui(r),r.tag){case 1:return Zt(r.type)&&Ol(),t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 3:return ma(),et(Jt),et(Bt),nc(),t=r.flags,(t&65536)!==0&&(t&128)===0?(r.flags=t&-65537|128,r):null;case 5:return ec(r),null;case 13:if(et(lt),t=r.memoizedState,t!==null&&t.dehydrated!==null){if(r.alternate===null)throw Error(a(340));ua()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 19:return et(lt),null;case 4:return ma(),null;case 10:return Gi(r.type._context),null;case 22:case 23:return Mc(),null;case 24:return null;default:return null}}var so=!1,Ut=!1,Pg=typeof WeakSet=="function"?WeakSet:Set,ke=null;function ga(t,r){var l=t.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(c){ct(t,r,c)}else l.current=null}function kc(t,r,l){try{l()}catch(c){ct(t,r,c)}}var Uf=!1;function Ag(t,r){if(Mi=Nl,t=bd(),Ci(t)){if("selectionStart"in t)var l={start:t.selectionStart,end:t.selectionEnd};else e:{l=(l=t.ownerDocument)&&l.defaultView||window;var c=l.getSelection&&l.getSelection();if(c&&c.rangeCount!==0){l=c.anchorNode;var f=c.anchorOffset,h=c.focusNode;c=c.focusOffset;try{l.nodeType,h.nodeType}catch{l=null;break e}var k=0,$=-1,O=-1,Q=0,ue=0,fe=t,ie=null;t:for(;;){for(var be;fe!==l||f!==0&&fe.nodeType!==3||($=k+f),fe!==h||c!==0&&fe.nodeType!==3||(O=k+c),fe.nodeType===3&&(k+=fe.nodeValue.length),(be=fe.firstChild)!==null;)ie=fe,fe=be;for(;;){if(fe===t)break t;if(ie===l&&++Q===f&&($=k),ie===h&&++ue===c&&(O=k),(be=fe.nextSibling)!==null)break;fe=ie,ie=fe.parentNode}fe=be}l=$===-1||O===-1?null:{start:$,end:O}}else l=null}l=l||{start:0,end:0}}else l=null;for(Fi={focusedElem:t,selectionRange:l},Nl=!1,ke=r;ke!==null;)if(r=ke,t=r.child,(r.subtreeFlags&1028)!==0&&t!==null)t.return=r,ke=t;else for(;ke!==null;){r=ke;try{var Ne=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(Ne!==null){var Se=Ne.memoizedProps,ut=Ne.memoizedState,q=r.stateNode,z=q.getSnapshotBeforeUpdate(r.elementType===r.type?Se:Wn(r.type,Se),ut);q.__reactInternalSnapshotBeforeUpdate=z}break;case 3:var V=r.stateNode.containerInfo;V.nodeType===1?V.textContent="":V.nodeType===9&&V.documentElement&&V.removeChild(V.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(a(163))}}catch(pe){ct(r,r.return,pe)}if(t=r.sibling,t!==null){t.return=r.return,ke=t;break}ke=r.return}return Ne=Uf,Uf=!1,Ne}function Ja(t,r,l){var c=r.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var f=c=c.next;do{if((f.tag&t)===t){var h=f.destroy;f.destroy=void 0,h!==void 0&&kc(r,l,h)}f=f.next}while(f!==c)}}function ao(t,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&t)===t){var c=l.create;l.destroy=c()}l=l.next}while(l!==r)}}function jc(t){var r=t.ref;if(r!==null){var l=t.stateNode;switch(t.tag){case 5:t=l;break;default:t=l}typeof r=="function"?r(t):r.current=t}}function Kf(t){var r=t.alternate;r!==null&&(t.alternate=null,Kf(r)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(r=t.stateNode,r!==null&&(delete r[rr],delete r[za],delete r[Di],delete r[mg],delete r[hg])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function Hf(t){return t.tag===5||t.tag===3||t.tag===4}function Wf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Hf(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Nc(t,r,l){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?l.nodeType===8?l.parentNode.insertBefore(t,r):l.insertBefore(t,r):(l.nodeType===8?(r=l.parentNode,r.insertBefore(t,l)):(r=l,r.appendChild(t)),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=Ll));else if(c!==4&&(t=t.child,t!==null))for(Nc(t,r,l),t=t.sibling;t!==null;)Nc(t,r,l),t=t.sibling}function Sc(t,r,l){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?l.insertBefore(t,r):l.appendChild(t);else if(c!==4&&(t=t.child,t!==null))for(Sc(t,r,l),t=t.sibling;t!==null;)Sc(t,r,l),t=t.sibling}var Mt=null,Vn=!1;function Gr(t,r,l){for(l=l.child;l!==null;)Vf(t,r,l),l=l.sibling}function Vf(t,r,l){if(A&&typeof A.onCommitFiberUnmount=="function")try{A.onCommitFiberUnmount(jn,l)}catch{}switch(l.tag){case 5:Ut||ga(l,r);case 6:var c=Mt,f=Vn;Mt=null,Gr(t,r,l),Mt=c,Vn=f,Mt!==null&&(Vn?(t=Mt,l=l.stateNode,t.nodeType===8?t.parentNode.removeChild(l):t.removeChild(l)):Mt.removeChild(l.stateNode));break;case 18:Mt!==null&&(Vn?(t=Mt,l=l.stateNode,t.nodeType===8?Oi(t.parentNode,l):t.nodeType===1&&Oi(t,l),Un(t)):Oi(Mt,l.stateNode));break;case 4:c=Mt,f=Vn,Mt=l.stateNode.containerInfo,Vn=!0,Gr(t,r,l),Mt=c,Vn=f;break;case 0:case 11:case 14:case 15:if(!Ut&&(c=l.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){f=c=c.next;do{var h=f,k=h.destroy;h=h.tag,k!==void 0&&((h&2)!==0||(h&4)!==0)&&kc(l,r,k),f=f.next}while(f!==c)}Gr(t,r,l);break;case 1:if(!Ut&&(ga(l,r),c=l.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=l.memoizedProps,c.state=l.memoizedState,c.componentWillUnmount()}catch($){ct(l,r,$)}Gr(t,r,l);break;case 21:Gr(t,r,l);break;case 22:l.mode&1?(Ut=(c=Ut)||l.memoizedState!==null,Gr(t,r,l),Ut=c):Gr(t,r,l);break;default:Gr(t,r,l)}}function Qf(t){var r=t.updateQueue;if(r!==null){t.updateQueue=null;var l=t.stateNode;l===null&&(l=t.stateNode=new Pg),r.forEach(function(c){var f=zg.bind(null,t,c);l.has(c)||(l.add(c),c.then(f,f))})}}function Qn(t,r){var l=r.deletions;if(l!==null)for(var c=0;c<l.length;c++){var f=l[c];try{var h=t,k=r,$=k;e:for(;$!==null;){switch($.tag){case 5:Mt=$.stateNode,Vn=!1;break e;case 3:Mt=$.stateNode.containerInfo,Vn=!0;break e;case 4:Mt=$.stateNode.containerInfo,Vn=!0;break e}$=$.return}if(Mt===null)throw Error(a(160));Vf(h,k,f),Mt=null,Vn=!1;var O=f.alternate;O!==null&&(O.return=null),f.return=null}catch(Q){ct(f,r,Q)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)Gf(r,t),r=r.sibling}function Gf(t,r){var l=t.alternate,c=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(Qn(r,t),lr(t),c&4){try{Ja(3,t,t.return),ao(3,t)}catch(Se){ct(t,t.return,Se)}try{Ja(5,t,t.return)}catch(Se){ct(t,t.return,Se)}}break;case 1:Qn(r,t),lr(t),c&512&&l!==null&&ga(l,l.return);break;case 5:if(Qn(r,t),lr(t),c&512&&l!==null&&ga(l,l.return),t.flags&32){var f=t.stateNode;try{os(f,"")}catch(Se){ct(t,t.return,Se)}}if(c&4&&(f=t.stateNode,f!=null)){var h=t.memoizedProps,k=l!==null?l.memoizedProps:h,$=t.type,O=t.updateQueue;if(t.updateQueue=null,O!==null)try{$==="input"&&h.type==="radio"&&h.name!=null&&Ln(f,h),Ks($,k);var Q=Ks($,h);for(k=0;k<O.length;k+=2){var ue=O[k],fe=O[k+1];ue==="style"?bl(f,fe):ue==="dangerouslySetInnerHTML"?on(f,fe):ue==="children"?os(f,fe):S(f,ue,fe,Q)}switch($){case"input":Kt(f,h);break;case"textarea":He(f,h);break;case"select":var ie=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!h.multiple;var be=h.value;be!=null?_n(f,!!h.multiple,be,!1):ie!==!!h.multiple&&(h.defaultValue!=null?_n(f,!!h.multiple,h.defaultValue,!0):_n(f,!!h.multiple,h.multiple?[]:"",!1))}f[za]=h}catch(Se){ct(t,t.return,Se)}}break;case 6:if(Qn(r,t),lr(t),c&4){if(t.stateNode===null)throw Error(a(162));f=t.stateNode,h=t.memoizedProps;try{f.nodeValue=h}catch(Se){ct(t,t.return,Se)}}break;case 3:if(Qn(r,t),lr(t),c&4&&l!==null&&l.memoizedState.isDehydrated)try{Un(r.containerInfo)}catch(Se){ct(t,t.return,Se)}break;case 4:Qn(r,t),lr(t);break;case 13:Qn(r,t),lr(t),f=t.child,f.flags&8192&&(h=f.memoizedState!==null,f.stateNode.isHidden=h,!h||f.alternate!==null&&f.alternate.memoizedState!==null||(Ic=Je())),c&4&&Qf(t);break;case 22:if(ue=l!==null&&l.memoizedState!==null,t.mode&1?(Ut=(Q=Ut)||ue,Qn(r,t),Ut=Q):Qn(r,t),lr(t),c&8192){if(Q=t.memoizedState!==null,(t.stateNode.isHidden=Q)&&!ue&&(t.mode&1)!==0)for(ke=t,ue=t.child;ue!==null;){for(fe=ke=ue;ke!==null;){switch(ie=ke,be=ie.child,ie.tag){case 0:case 11:case 14:case 15:Ja(4,ie,ie.return);break;case 1:ga(ie,ie.return);var Ne=ie.stateNode;if(typeof Ne.componentWillUnmount=="function"){c=ie,l=ie.return;try{r=c,Ne.props=r.memoizedProps,Ne.state=r.memoizedState,Ne.componentWillUnmount()}catch(Se){ct(c,l,Se)}}break;case 5:ga(ie,ie.return);break;case 22:if(ie.memoizedState!==null){Jf(fe);continue}}be!==null?(be.return=ie,ke=be):Jf(fe)}ue=ue.sibling}e:for(ue=null,fe=t;;){if(fe.tag===5){if(ue===null){ue=fe;try{f=fe.stateNode,Q?(h=f.style,typeof h.setProperty=="function"?h.setProperty("display","none","important"):h.display="none"):($=fe.stateNode,O=fe.memoizedProps.style,k=O!=null&&O.hasOwnProperty("display")?O.display:null,$.style.display=vl("display",k))}catch(Se){ct(t,t.return,Se)}}}else if(fe.tag===6){if(ue===null)try{fe.stateNode.nodeValue=Q?"":fe.memoizedProps}catch(Se){ct(t,t.return,Se)}}else if((fe.tag!==22&&fe.tag!==23||fe.memoizedState===null||fe===t)&&fe.child!==null){fe.child.return=fe,fe=fe.child;continue}if(fe===t)break e;for(;fe.sibling===null;){if(fe.return===null||fe.return===t)break e;ue===fe&&(ue=null),fe=fe.return}ue===fe&&(ue=null),fe.sibling.return=fe.return,fe=fe.sibling}}break;case 19:Qn(r,t),lr(t),c&4&&Qf(t);break;case 21:break;default:Qn(r,t),lr(t)}}function lr(t){var r=t.flags;if(r&2){try{e:{for(var l=t.return;l!==null;){if(Hf(l)){var c=l;break e}l=l.return}throw Error(a(160))}switch(c.tag){case 5:var f=c.stateNode;c.flags&32&&(os(f,""),c.flags&=-33);var h=Wf(t);Sc(t,h,f);break;case 3:case 4:var k=c.stateNode.containerInfo,$=Wf(t);Nc(t,$,k);break;default:throw Error(a(161))}}catch(O){ct(t,t.return,O)}t.flags&=-3}r&4096&&(t.flags&=-4097)}function $g(t,r,l){ke=t,Yf(t)}function Yf(t,r,l){for(var c=(t.mode&1)!==0;ke!==null;){var f=ke,h=f.child;if(f.tag===22&&c){var k=f.memoizedState!==null||so;if(!k){var $=f.alternate,O=$!==null&&$.memoizedState!==null||Ut;$=so;var Q=Ut;if(so=k,(Ut=O)&&!Q)for(ke=f;ke!==null;)k=ke,O=k.child,k.tag===22&&k.memoizedState!==null?Zf(f):O!==null?(O.return=k,ke=O):Zf(f);for(;h!==null;)ke=h,Yf(h),h=h.sibling;ke=f,so=$,Ut=Q}Xf(t)}else(f.subtreeFlags&8772)!==0&&h!==null?(h.return=f,ke=h):Xf(t)}}function Xf(t){for(;ke!==null;){var r=ke;if((r.flags&8772)!==0){var l=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:Ut||ao(5,r);break;case 1:var c=r.stateNode;if(r.flags&4&&!Ut)if(l===null)c.componentDidMount();else{var f=r.elementType===r.type?l.memoizedProps:Wn(r.type,l.memoizedProps);c.componentDidUpdate(f,l.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var h=r.updateQueue;h!==null&&Xd(r,h,c);break;case 3:var k=r.updateQueue;if(k!==null){if(l=null,r.child!==null)switch(r.child.tag){case 5:l=r.child.stateNode;break;case 1:l=r.child.stateNode}Xd(r,k,l)}break;case 5:var $=r.stateNode;if(l===null&&r.flags&4){l=$;var O=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":O.autoFocus&&l.focus();break;case"img":O.src&&(l.src=O.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var Q=r.alternate;if(Q!==null){var ue=Q.memoizedState;if(ue!==null){var fe=ue.dehydrated;fe!==null&&Un(fe)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(a(163))}Ut||r.flags&512&&jc(r)}catch(ie){ct(r,r.return,ie)}}if(r===t){ke=null;break}if(l=r.sibling,l!==null){l.return=r.return,ke=l;break}ke=r.return}}function Jf(t){for(;ke!==null;){var r=ke;if(r===t){ke=null;break}var l=r.sibling;if(l!==null){l.return=r.return,ke=l;break}ke=r.return}}function Zf(t){for(;ke!==null;){var r=ke;try{switch(r.tag){case 0:case 11:case 15:var l=r.return;try{ao(4,r)}catch(O){ct(r,l,O)}break;case 1:var c=r.stateNode;if(typeof c.componentDidMount=="function"){var f=r.return;try{c.componentDidMount()}catch(O){ct(r,f,O)}}var h=r.return;try{jc(r)}catch(O){ct(r,h,O)}break;case 5:var k=r.return;try{jc(r)}catch(O){ct(r,k,O)}}}catch(O){ct(r,r.return,O)}if(r===t){ke=null;break}var $=r.sibling;if($!==null){$.return=r.return,ke=$;break}ke=r.return}}var Mg=Math.ceil,lo=j.ReactCurrentDispatcher,Cc=j.ReactCurrentOwner,Tn=j.ReactCurrentBatchConfig,Ve=0,It=null,mt=null,Ft=0,gn=0,xa=Kr(0),vt=0,Za=null,Ss=0,oo=0,Rc=0,el=null,tn=null,Ic=0,ya=1/0,Er=null,io=!1,Tc=null,Yr=null,co=!1,Xr=null,uo=0,tl=0,Ec=null,fo=-1,po=0;function Vt(){return(Ve&6)!==0?Je():fo!==-1?fo:fo=Je()}function Jr(t){return(t.mode&1)===0?1:(Ve&2)!==0&&Ft!==0?Ft&-Ft:xg.transition!==null?(po===0&&(po=we()),po):(t=$e,t!==0||(t=window.event,t=t===void 0?16:ed(t.type)),t)}function Gn(t,r,l,c){if(50<tl)throw tl=0,Ec=null,Error(a(185));Ge(t,l,c),((Ve&2)===0||t!==It)&&(t===It&&((Ve&2)===0&&(oo|=l),vt===4&&Zr(t,Ft)),nn(t,c),l===1&&Ve===0&&(r.mode&1)===0&&(ya=Je()+500,Bl&&Wr()))}function nn(t,r){var l=t.callbackNode;Re(t,r);var c=Ie(t,t===It?Ft:0);if(c===0)l!==null&&Or(l),t.callbackNode=null,t.callbackPriority=0;else if(r=c&-c,t.callbackPriority!==r){if(l!=null&&Or(l),r===1)t.tag===0?gg(tp.bind(null,t)):Dd(tp.bind(null,t)),fg(function(){(Ve&6)===0&&Wr()}),l=null;else{switch($t(c)){case 1:l=Xs;break;case 4:l=ds;break;case 16:l=fs;break;case 536870912:l=dn;break;default:l=fs}l=cp(l,ep.bind(null,t))}t.callbackPriority=r,t.callbackNode=l}}function ep(t,r){if(fo=-1,po=0,(Ve&6)!==0)throw Error(a(327));var l=t.callbackNode;if(va()&&t.callbackNode!==l)return null;var c=Ie(t,t===It?Ft:0);if(c===0)return null;if((c&30)!==0||(c&t.expiredLanes)!==0||r)r=mo(t,c);else{r=c;var f=Ve;Ve|=2;var h=rp();(It!==t||Ft!==r)&&(Er=null,ya=Je()+500,Rs(t,r));do try{_g();break}catch($){np(t,$)}while(!0);Qi(),lo.current=h,Ve=f,mt!==null?r=0:(It=null,Ft=0,r=vt)}if(r!==0){if(r===2&&(f=ze(t),f!==0&&(c=f,r=Pc(t,f))),r===1)throw l=Za,Rs(t,0),Zr(t,c),nn(t,Je()),l;if(r===6)Zr(t,c);else{if(f=t.current.alternate,(c&30)===0&&!Fg(f)&&(r=mo(t,c),r===2&&(h=ze(t),h!==0&&(c=h,r=Pc(t,h))),r===1))throw l=Za,Rs(t,0),Zr(t,c),nn(t,Je()),l;switch(t.finishedWork=f,t.finishedLanes=c,r){case 0:case 1:throw Error(a(345));case 2:Is(t,tn,Er);break;case 3:if(Zr(t,c),(c&130023424)===c&&(r=Ic+500-Je(),10<r)){if(Ie(t,0)!==0)break;if(f=t.suspendedLanes,(f&c)!==c){Vt(),t.pingedLanes|=t.suspendedLanes&f;break}t.timeoutHandle=_i(Is.bind(null,t,tn,Er),r);break}Is(t,tn,Er);break;case 4:if(Zr(t,c),(c&4194240)===c)break;for(r=t.eventTimes,f=-1;0<c;){var k=31-J(c);h=1<<k,k=r[k],k>f&&(f=k),c&=~h}if(c=f,c=Je()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*Mg(c/1960))-c,10<c){t.timeoutHandle=_i(Is.bind(null,t,tn,Er),c);break}Is(t,tn,Er);break;case 5:Is(t,tn,Er);break;default:throw Error(a(329))}}}return nn(t,Je()),t.callbackNode===l?ep.bind(null,t):null}function Pc(t,r){var l=el;return t.current.memoizedState.isDehydrated&&(Rs(t,r).flags|=256),t=mo(t,r),t!==2&&(r=tn,tn=l,r!==null&&Ac(r)),t}function Ac(t){tn===null?tn=t:tn.push.apply(tn,t)}function Fg(t){for(var r=t;;){if(r.flags&16384){var l=r.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var c=0;c<l.length;c++){var f=l[c],h=f.getSnapshot;f=f.value;try{if(!Kn(h(),f))return!1}catch{return!1}}}if(l=r.child,r.subtreeFlags&16384&&l!==null)l.return=r,r=l;else{if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Zr(t,r){for(r&=~Rc,r&=~oo,t.suspendedLanes|=r,t.pingedLanes&=~r,t=t.expirationTimes;0<r;){var l=31-J(r),c=1<<l;t[l]=-1,r&=~c}}function tp(t){if((Ve&6)!==0)throw Error(a(327));va();var r=Ie(t,0);if((r&1)===0)return nn(t,Je()),null;var l=mo(t,r);if(t.tag!==0&&l===2){var c=ze(t);c!==0&&(r=c,l=Pc(t,c))}if(l===1)throw l=Za,Rs(t,0),Zr(t,r),nn(t,Je()),l;if(l===6)throw Error(a(345));return t.finishedWork=t.current.alternate,t.finishedLanes=r,Is(t,tn,Er),nn(t,Je()),null}function $c(t,r){var l=Ve;Ve|=1;try{return t(r)}finally{Ve=l,Ve===0&&(ya=Je()+500,Bl&&Wr())}}function Cs(t){Xr!==null&&Xr.tag===0&&(Ve&6)===0&&va();var r=Ve;Ve|=1;var l=Tn.transition,c=$e;try{if(Tn.transition=null,$e=1,t)return t()}finally{$e=c,Tn.transition=l,Ve=r,(Ve&6)===0&&Wr()}}function Mc(){gn=xa.current,et(xa)}function Rs(t,r){t.finishedWork=null,t.finishedLanes=0;var l=t.timeoutHandle;if(l!==-1&&(t.timeoutHandle=-1,dg(l)),mt!==null)for(l=mt.return;l!==null;){var c=l;switch(Ui(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&Ol();break;case 3:ma(),et(Jt),et(Bt),nc();break;case 5:ec(c);break;case 4:ma();break;case 13:et(lt);break;case 19:et(lt);break;case 10:Gi(c.type._context);break;case 22:case 23:Mc()}l=l.return}if(It=t,mt=t=es(t.current,null),Ft=gn=r,vt=0,Za=null,Rc=oo=Ss=0,tn=el=null,ks!==null){for(r=0;r<ks.length;r++)if(l=ks[r],c=l.interleaved,c!==null){l.interleaved=null;var f=c.next,h=l.pending;if(h!==null){var k=h.next;h.next=f,c.next=k}l.pending=c}ks=null}return t}function np(t,r){do{var l=mt;try{if(Qi(),Yl.current=eo,Xl){for(var c=ot.memoizedState;c!==null;){var f=c.queue;f!==null&&(f.pending=null),c=c.next}Xl=!1}if(Ns=0,Rt=yt=ot=null,Va=!1,Qa=0,Cc.current=null,l===null||l.return===null){vt=1,Za=r,mt=null;break}e:{var h=t,k=l.return,$=l,O=r;if(r=Ft,$.flags|=32768,O!==null&&typeof O=="object"&&typeof O.then=="function"){var Q=O,ue=$,fe=ue.tag;if((ue.mode&1)===0&&(fe===0||fe===11||fe===15)){var ie=ue.alternate;ie?(ue.updateQueue=ie.updateQueue,ue.memoizedState=ie.memoizedState,ue.lanes=ie.lanes):(ue.updateQueue=null,ue.memoizedState=null)}var be=Rf(k);if(be!==null){be.flags&=-257,If(be,k,$,h,r),be.mode&1&&Cf(h,Q,r),r=be,O=Q;var Ne=r.updateQueue;if(Ne===null){var Se=new Set;Se.add(O),r.updateQueue=Se}else Ne.add(O);break e}else{if((r&1)===0){Cf(h,Q,r),Fc();break e}O=Error(a(426))}}else if(nt&&$.mode&1){var ut=Rf(k);if(ut!==null){(ut.flags&65536)===0&&(ut.flags|=256),If(ut,k,$,h,r),Wi(ha(O,$));break e}}h=O=ha(O,$),vt!==4&&(vt=2),el===null?el=[h]:el.push(h),h=k;do{switch(h.tag){case 3:h.flags|=65536,r&=-r,h.lanes|=r;var q=Nf(h,O,r);Yd(h,q);break e;case 1:$=O;var z=h.type,V=h.stateNode;if((h.flags&128)===0&&(typeof z.getDerivedStateFromError=="function"||V!==null&&typeof V.componentDidCatch=="function"&&(Yr===null||!Yr.has(V)))){h.flags|=65536,r&=-r,h.lanes|=r;var pe=Sf(h,$,r);Yd(h,pe);break e}}h=h.return}while(h!==null)}ap(l)}catch(Ce){r=Ce,mt===l&&l!==null&&(mt=l=l.return);continue}break}while(!0)}function rp(){var t=lo.current;return lo.current=eo,t===null?eo:t}function Fc(){(vt===0||vt===3||vt===2)&&(vt=4),It===null||(Ss&268435455)===0&&(oo&268435455)===0||Zr(It,Ft)}function mo(t,r){var l=Ve;Ve|=2;var c=rp();(It!==t||Ft!==r)&&(Er=null,Rs(t,r));do try{Lg();break}catch(f){np(t,f)}while(!0);if(Qi(),Ve=l,lo.current=c,mt!==null)throw Error(a(261));return It=null,Ft=0,vt}function Lg(){for(;mt!==null;)sp(mt)}function _g(){for(;mt!==null&&!Ys();)sp(mt)}function sp(t){var r=ip(t.alternate,t,gn);t.memoizedProps=t.pendingProps,r===null?ap(t):mt=r,Cc.current=null}function ap(t){var r=t;do{var l=r.alternate;if(t=r.return,(r.flags&32768)===0){if(l=Tg(l,r,gn),l!==null){mt=l;return}}else{if(l=Eg(l,r),l!==null){l.flags&=32767,mt=l;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{vt=6,mt=null;return}}if(r=r.sibling,r!==null){mt=r;return}mt=r=t}while(r!==null);vt===0&&(vt=5)}function Is(t,r,l){var c=$e,f=Tn.transition;try{Tn.transition=null,$e=1,Og(t,r,l,c)}finally{Tn.transition=f,$e=c}return null}function Og(t,r,l,c){do va();while(Xr!==null);if((Ve&6)!==0)throw Error(a(327));l=t.finishedWork;var f=t.finishedLanes;if(l===null)return null;if(t.finishedWork=null,t.finishedLanes=0,l===t.current)throw Error(a(177));t.callbackNode=null,t.callbackPriority=0;var h=l.lanes|l.childLanes;if(tt(t,h),t===It&&(mt=It=null,Ft=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||co||(co=!0,cp(fs,function(){return va(),null})),h=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||h){h=Tn.transition,Tn.transition=null;var k=$e;$e=1;var $=Ve;Ve|=4,Cc.current=null,Ag(t,l),Gf(l,t),sg(Fi),Nl=!!Mi,Fi=Mi=null,t.current=l,$g(l),mi(),Ve=$,$e=k,Tn.transition=h}else t.current=l;if(co&&(co=!1,Xr=t,uo=f),h=t.pendingLanes,h===0&&(Yr=null),W(l.stateNode),nn(t,Je()),r!==null)for(c=t.onRecoverableError,l=0;l<r.length;l++)f=r[l],c(f.value,{componentStack:f.stack,digest:f.digest});if(io)throw io=!1,t=Tc,Tc=null,t;return(uo&1)!==0&&t.tag!==0&&va(),h=t.pendingLanes,(h&1)!==0?t===Ec?tl++:(tl=0,Ec=t):tl=0,Wr(),null}function va(){if(Xr!==null){var t=$t(uo),r=Tn.transition,l=$e;try{if(Tn.transition=null,$e=16>t?16:t,Xr===null)var c=!1;else{if(t=Xr,Xr=null,uo=0,(Ve&6)!==0)throw Error(a(331));var f=Ve;for(Ve|=4,ke=t.current;ke!==null;){var h=ke,k=h.child;if((ke.flags&16)!==0){var $=h.deletions;if($!==null){for(var O=0;O<$.length;O++){var Q=$[O];for(ke=Q;ke!==null;){var ue=ke;switch(ue.tag){case 0:case 11:case 15:Ja(8,ue,h)}var fe=ue.child;if(fe!==null)fe.return=ue,ke=fe;else for(;ke!==null;){ue=ke;var ie=ue.sibling,be=ue.return;if(Kf(ue),ue===Q){ke=null;break}if(ie!==null){ie.return=be,ke=ie;break}ke=be}}}var Ne=h.alternate;if(Ne!==null){var Se=Ne.child;if(Se!==null){Ne.child=null;do{var ut=Se.sibling;Se.sibling=null,Se=ut}while(Se!==null)}}ke=h}}if((h.subtreeFlags&2064)!==0&&k!==null)k.return=h,ke=k;else e:for(;ke!==null;){if(h=ke,(h.flags&2048)!==0)switch(h.tag){case 0:case 11:case 15:Ja(9,h,h.return)}var q=h.sibling;if(q!==null){q.return=h.return,ke=q;break e}ke=h.return}}var z=t.current;for(ke=z;ke!==null;){k=ke;var V=k.child;if((k.subtreeFlags&2064)!==0&&V!==null)V.return=k,ke=V;else e:for(k=z;ke!==null;){if($=ke,($.flags&2048)!==0)try{switch($.tag){case 0:case 11:case 15:ao(9,$)}}catch(Ce){ct($,$.return,Ce)}if($===k){ke=null;break e}var pe=$.sibling;if(pe!==null){pe.return=$.return,ke=pe;break e}ke=$.return}}if(Ve=f,Wr(),A&&typeof A.onPostCommitFiberRoot=="function")try{A.onPostCommitFiberRoot(jn,t)}catch{}c=!0}return c}finally{$e=l,Tn.transition=r}}return!1}function lp(t,r,l){r=ha(l,r),r=Nf(t,r,1),t=Qr(t,r,1),r=Vt(),t!==null&&(Ge(t,1,r),nn(t,r))}function ct(t,r,l){if(t.tag===3)lp(t,t,l);else for(;r!==null;){if(r.tag===3){lp(r,t,l);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Yr===null||!Yr.has(c))){t=ha(l,t),t=Sf(r,t,1),r=Qr(r,t,1),t=Vt(),r!==null&&(Ge(r,1,t),nn(r,t));break}}r=r.return}}function Dg(t,r,l){var c=t.pingCache;c!==null&&c.delete(r),r=Vt(),t.pingedLanes|=t.suspendedLanes&l,It===t&&(Ft&l)===l&&(vt===4||vt===3&&(Ft&130023424)===Ft&&500>Je()-Ic?Rs(t,0):Rc|=l),nn(t,r)}function op(t,r){r===0&&((t.mode&1)===0?r=1:(r=me,me<<=1,(me&130023424)===0&&(me=4194304)));var l=Vt();t=Rr(t,r),t!==null&&(Ge(t,r,l),nn(t,l))}function Bg(t){var r=t.memoizedState,l=0;r!==null&&(l=r.retryLane),op(t,l)}function zg(t,r){var l=0;switch(t.tag){case 13:var c=t.stateNode,f=t.memoizedState;f!==null&&(l=f.retryLane);break;case 19:c=t.stateNode;break;default:throw Error(a(314))}c!==null&&c.delete(r),op(t,l)}var ip;ip=function(t,r,l){if(t!==null)if(t.memoizedProps!==r.pendingProps||Jt.current)en=!0;else{if((t.lanes&l)===0&&(r.flags&128)===0)return en=!1,Ig(t,r,l);en=(t.flags&131072)!==0}else en=!1,nt&&(r.flags&1048576)!==0&&Bd(r,ql,r.index);switch(r.lanes=0,r.tag){case 2:var c=r.type;ro(t,r),t=r.pendingProps;var f=oa(r,Bt.current);pa(r,l),f=ac(null,r,c,t,f,l);var h=lc();return r.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,Zt(c)?(h=!0,Dl(r)):h=!1,r.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Ji(r),f.updater=to,r.stateNode=f,f._reactInternals=r,fc(r,c,t,l),r=gc(null,r,c,!0,h,l)):(r.tag=0,nt&&h&&qi(r),Wt(null,r,f,l),r=r.child),r;case 16:c=r.elementType;e:{switch(ro(t,r),t=r.pendingProps,f=c._init,c=f(c._payload),r.type=c,f=r.tag=Ug(c),t=Wn(c,t),f){case 0:r=hc(null,r,c,t,l);break e;case 1:r=Mf(null,r,c,t,l);break e;case 11:r=Tf(null,r,c,t,l);break e;case 14:r=Ef(null,r,c,Wn(c.type,t),l);break e}throw Error(a(306,c,""))}return r;case 0:return c=r.type,f=r.pendingProps,f=r.elementType===c?f:Wn(c,f),hc(t,r,c,f,l);case 1:return c=r.type,f=r.pendingProps,f=r.elementType===c?f:Wn(c,f),Mf(t,r,c,f,l);case 3:e:{if(Ff(r),t===null)throw Error(a(387));c=r.pendingProps,h=r.memoizedState,f=h.element,Gd(t,r),Ql(r,c,null,l);var k=r.memoizedState;if(c=k.element,h.isDehydrated)if(h={element:c,isDehydrated:!1,cache:k.cache,pendingSuspenseBoundaries:k.pendingSuspenseBoundaries,transitions:k.transitions},r.updateQueue.baseState=h,r.memoizedState=h,r.flags&256){f=ha(Error(a(423)),r),r=Lf(t,r,c,l,f);break e}else if(c!==f){f=ha(Error(a(424)),r),r=Lf(t,r,c,l,f);break e}else for(hn=Ur(r.stateNode.containerInfo.firstChild),mn=r,nt=!0,Hn=null,l=Vd(r,null,c,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(ua(),c===f){r=Tr(t,r,l);break e}Wt(t,r,c,l)}r=r.child}return r;case 5:return Jd(r),t===null&&Hi(r),c=r.type,f=r.pendingProps,h=t!==null?t.memoizedProps:null,k=f.children,Li(c,f)?k=null:h!==null&&Li(c,h)&&(r.flags|=32),$f(t,r),Wt(t,r,k,l),r.child;case 6:return t===null&&Hi(r),null;case 13:return _f(t,r,l);case 4:return Zi(r,r.stateNode.containerInfo),c=r.pendingProps,t===null?r.child=da(r,null,c,l):Wt(t,r,c,l),r.child;case 11:return c=r.type,f=r.pendingProps,f=r.elementType===c?f:Wn(c,f),Tf(t,r,c,f,l);case 7:return Wt(t,r,r.pendingProps,l),r.child;case 8:return Wt(t,r,r.pendingProps.children,l),r.child;case 12:return Wt(t,r,r.pendingProps.children,l),r.child;case 10:e:{if(c=r.type._context,f=r.pendingProps,h=r.memoizedProps,k=f.value,Xe(Hl,c._currentValue),c._currentValue=k,h!==null)if(Kn(h.value,k)){if(h.children===f.children&&!Jt.current){r=Tr(t,r,l);break e}}else for(h=r.child,h!==null&&(h.return=r);h!==null;){var $=h.dependencies;if($!==null){k=h.child;for(var O=$.firstContext;O!==null;){if(O.context===c){if(h.tag===1){O=Ir(-1,l&-l),O.tag=2;var Q=h.updateQueue;if(Q!==null){Q=Q.shared;var ue=Q.pending;ue===null?O.next=O:(O.next=ue.next,ue.next=O),Q.pending=O}}h.lanes|=l,O=h.alternate,O!==null&&(O.lanes|=l),Yi(h.return,l,r),$.lanes|=l;break}O=O.next}}else if(h.tag===10)k=h.type===r.type?null:h.child;else if(h.tag===18){if(k=h.return,k===null)throw Error(a(341));k.lanes|=l,$=k.alternate,$!==null&&($.lanes|=l),Yi(k,l,r),k=h.sibling}else k=h.child;if(k!==null)k.return=h;else for(k=h;k!==null;){if(k===r){k=null;break}if(h=k.sibling,h!==null){h.return=k.return,k=h;break}k=k.return}h=k}Wt(t,r,f.children,l),r=r.child}return r;case 9:return f=r.type,c=r.pendingProps.children,pa(r,l),f=Rn(f),c=c(f),r.flags|=1,Wt(t,r,c,l),r.child;case 14:return c=r.type,f=Wn(c,r.pendingProps),f=Wn(c.type,f),Ef(t,r,c,f,l);case 15:return Pf(t,r,r.type,r.pendingProps,l);case 17:return c=r.type,f=r.pendingProps,f=r.elementType===c?f:Wn(c,f),ro(t,r),r.tag=1,Zt(c)?(t=!0,Dl(r)):t=!1,pa(r,l),kf(r,c,f),fc(r,c,f,l),gc(null,r,c,!0,t,l);case 19:return Df(t,r,l);case 22:return Af(t,r,l)}throw Error(a(156,r.tag))};function cp(t,r){return _r(t,r)}function qg(t,r,l,c){this.tag=t,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function En(t,r,l,c){return new qg(t,r,l,c)}function Lc(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Ug(t){if(typeof t=="function")return Lc(t)?1:0;if(t!=null){if(t=t.$$typeof,t===X)return 11;if(t===H)return 14}return 2}function es(t,r){var l=t.alternate;return l===null?(l=En(t.tag,r,t.key,t.mode),l.elementType=t.elementType,l.type=t.type,l.stateNode=t.stateNode,l.alternate=t,t.alternate=l):(l.pendingProps=r,l.type=t.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=t.flags&14680064,l.childLanes=t.childLanes,l.lanes=t.lanes,l.child=t.child,l.memoizedProps=t.memoizedProps,l.memoizedState=t.memoizedState,l.updateQueue=t.updateQueue,r=t.dependencies,l.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},l.sibling=t.sibling,l.index=t.index,l.ref=t.ref,l}function ho(t,r,l,c,f,h){var k=2;if(c=t,typeof t=="function")Lc(t)&&(k=1);else if(typeof t=="string")k=5;else e:switch(t){case D:return Ts(l.children,f,h,r);case U:k=8,f|=8;break;case G:return t=En(12,l,r,f|2),t.elementType=G,t.lanes=h,t;case B:return t=En(13,l,r,f),t.elementType=B,t.lanes=h,t;case _:return t=En(19,l,r,f),t.elementType=_,t.lanes=h,t;case ce:return go(l,f,h,r);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case L:k=10;break e;case Y:k=9;break e;case X:k=11;break e;case H:k=14;break e;case ee:k=16,c=null;break e}throw Error(a(130,t==null?t:typeof t,""))}return r=En(k,l,r,f),r.elementType=t,r.type=c,r.lanes=h,r}function Ts(t,r,l,c){return t=En(7,t,c,r),t.lanes=l,t}function go(t,r,l,c){return t=En(22,t,c,r),t.elementType=ce,t.lanes=l,t.stateNode={isHidden:!1},t}function _c(t,r,l){return t=En(6,t,null,r),t.lanes=l,t}function Oc(t,r,l){return r=En(4,t.children!==null?t.children:[],t.key,r),r.lanes=l,r.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},r}function Kg(t,r,l,c,f){this.tag=r,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ae(0),this.expirationTimes=Ae(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ae(0),this.identifierPrefix=c,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Dc(t,r,l,c,f,h,k,$,O){return t=new Kg(t,r,l,$,O),r===1?(r=1,h===!0&&(r|=8)):r=0,h=En(3,null,null,r),t.current=h,h.stateNode=t,h.memoizedState={element:c,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ji(h),t}function Hg(t,r,l){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:M,key:c==null?null:""+c,children:t,containerInfo:r,implementation:l}}function up(t){if(!t)return Hr;t=t._reactInternals;e:{if(tr(t)!==t||t.tag!==1)throw Error(a(170));var r=t;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(Zt(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(a(171))}if(t.tag===1){var l=t.type;if(Zt(l))return _d(t,l,r)}return r}function dp(t,r,l,c,f,h,k,$,O){return t=Dc(l,c,!0,t,f,h,k,$,O),t.context=up(null),l=t.current,c=Vt(),f=Jr(l),h=Ir(c,f),h.callback=r??null,Qr(l,h,f),t.current.lanes=f,Ge(t,f,c),nn(t,c),t}function xo(t,r,l,c){var f=r.current,h=Vt(),k=Jr(f);return l=up(l),r.context===null?r.context=l:r.pendingContext=l,r=Ir(h,k),r.payload={element:t},c=c===void 0?null:c,c!==null&&(r.callback=c),t=Qr(f,r,k),t!==null&&(Gn(t,f,k,h),Vl(t,f,k)),k}function yo(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function fp(t,r){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var l=t.retryLane;t.retryLane=l!==0&&l<r?l:r}}function Bc(t,r){fp(t,r),(t=t.alternate)&&fp(t,r)}function Wg(){return null}var pp=typeof reportError=="function"?reportError:function(t){console.error(t)};function zc(t){this._internalRoot=t}vo.prototype.render=zc.prototype.render=function(t){var r=this._internalRoot;if(r===null)throw Error(a(409));xo(t,r,null,null)},vo.prototype.unmount=zc.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var r=t.containerInfo;Cs(function(){xo(null,t,null,null)}),r[jr]=null}};function vo(t){this._internalRoot=t}vo.prototype.unstable_scheduleHydration=function(t){if(t){var r=ps();t={blockedOn:null,target:t,priority:r};for(var l=0;l<Ye.length&&r!==0&&r<Ye[l].priority;l++);Ye.splice(l,0,t),l===0&&wr(t)}};function qc(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function bo(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function mp(){}function Vg(t,r,l,c,f){if(f){if(typeof c=="function"){var h=c;c=function(){var Q=yo(k);h.call(Q)}}var k=dp(r,c,t,0,null,!1,!1,"",mp);return t._reactRootContainer=k,t[jr]=k.current,Da(t.nodeType===8?t.parentNode:t),Cs(),k}for(;f=t.lastChild;)t.removeChild(f);if(typeof c=="function"){var $=c;c=function(){var Q=yo(O);$.call(Q)}}var O=Dc(t,0,!1,null,null,!1,!1,"",mp);return t._reactRootContainer=O,t[jr]=O.current,Da(t.nodeType===8?t.parentNode:t),Cs(function(){xo(r,O,l,c)}),O}function wo(t,r,l,c,f){var h=l._reactRootContainer;if(h){var k=h;if(typeof f=="function"){var $=f;f=function(){var O=yo(k);$.call(O)}}xo(r,k,t,f)}else k=Vg(l,r,t,f,c);return yo(k)}pt=function(t){switch(t.tag){case 3:var r=t.stateNode;if(r.current.memoizedState.isDehydrated){var l=he(r.pendingLanes);l!==0&&(Ct(r,l|1),nn(r,Je()),(Ve&6)===0&&(ya=Je()+500,Wr()))}break;case 13:Cs(function(){var c=Rr(t,1);if(c!==null){var f=Vt();Gn(c,t,1,f)}}),Bc(t,1)}},gt=function(t){if(t.tag===13){var r=Rr(t,134217728);if(r!==null){var l=Vt();Gn(r,t,134217728,l)}Bc(t,134217728)}},zn=function(t){if(t.tag===13){var r=Jr(t),l=Rr(t,r);if(l!==null){var c=Vt();Gn(l,t,r,c)}Bc(t,r)}},ps=function(){return $e},ms=function(t,r){var l=$e;try{return $e=t,r()}finally{$e=l}},is=function(t,r,l){switch(r){case"input":if(Kt(t,l),r=l.name,l.type==="radio"&&r!=null){for(l=t;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<l.length;r++){var c=l[r];if(c!==t&&c.form===t.form){var f=_l(c);if(!f)throw Error(a(90));Le(c),Kt(c,f)}}}break;case"textarea":He(t,l);break;case"select":r=l.value,r!=null&&_n(t,!!l.multiple,r,!1)}},xr=$c,Ta=Cs;var Qg={usingClientEntryPoint:!1,Events:[qa,aa,_l,gr,cs,$c]},nl={findFiberByHostInstance:ys,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Gg={bundleType:nl.bundleType,version:nl.version,rendererPackageName:nl.rendererPackageName,rendererConfig:nl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:j.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=br(t),t===null?null:t.stateNode},findFiberByHostInstance:nl.findFiberByHostInstance||Wg,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var ko=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ko.isDisabled&&ko.supportsFiber)try{jn=ko.inject(Gg),A=ko}catch{}}return rn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Qg,rn.createPortal=function(t,r){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!qc(r))throw Error(a(200));return Hg(t,r,null,l)},rn.createRoot=function(t,r){if(!qc(t))throw Error(a(299));var l=!1,c="",f=pp;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onRecoverableError!==void 0&&(f=r.onRecoverableError)),r=Dc(t,1,!1,null,null,l,!1,c,f),t[jr]=r.current,Da(t.nodeType===8?t.parentNode:t),new zc(r)},rn.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var r=t._reactInternals;if(r===void 0)throw typeof t.render=="function"?Error(a(188)):(t=Object.keys(t).join(","),Error(a(268,t)));return t=br(r),t=t===null?null:t.stateNode,t},rn.flushSync=function(t){return Cs(t)},rn.hydrate=function(t,r,l){if(!bo(r))throw Error(a(200));return wo(null,t,r,!0,l)},rn.hydrateRoot=function(t,r,l){if(!qc(t))throw Error(a(405));var c=l!=null&&l.hydratedSources||null,f=!1,h="",k=pp;if(l!=null&&(l.unstable_strictMode===!0&&(f=!0),l.identifierPrefix!==void 0&&(h=l.identifierPrefix),l.onRecoverableError!==void 0&&(k=l.onRecoverableError)),r=dp(r,null,t,1,l??null,f,!1,h,k),t[jr]=r.current,Da(t),c)for(t=0;t<c.length;t++)l=c[t],f=l._getVersion,f=f(l._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[l,f]:r.mutableSourceEagerHydrationData.push(l,f);return new vo(r)},rn.render=function(t,r,l){if(!bo(r))throw Error(a(200));return wo(null,t,r,!1,l)},rn.unmountComponentAtNode=function(t){if(!bo(t))throw Error(a(40));return t._reactRootContainer?(Cs(function(){wo(null,null,t,!1,function(){t._reactRootContainer=null,t[jr]=null})}),!0):!1},rn.unstable_batchedUpdates=$c,rn.unstable_renderSubtreeIntoContainer=function(t,r,l,c){if(!bo(l))throw Error(a(200));if(t==null||t._reactInternals===void 0)throw Error(a(38));return wo(t,r,l,!1,c)},rn.version="18.3.1-next-f1338f8080-20240426",rn}var bp;function Ym(){if(bp)return Kc.exports;bp=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(s){console.error(s)}}return e(),Kc.exports=fx(),Kc.exports}var wp;function px(){if(wp)return No;wp=1;var e=Ym();return No.createRoot=e.createRoot,No.hydrateRoot=e.hydrateRoot,No}var mx=px();const Pu=["untouched","replied_unresolved","likely_addressed","resolved"],hx=["draft","open","merged","closed"],gx=["approved","changes_requested","commented","dismissed"],kp={pr_opened:"lifecycle",pr_merged:"lifecycle",pr_closed:"lifecycle",pr_reopened:"lifecycle",pr_ready_for_review:"lifecycle",review_submitted:"reviews",review_comment:"review_comments",pr_comment:"pr_comments",commit_pushed:"commits"},xx={coderabbitai:"coderabbit","greptile-apps":"greptile","copilot-pull-request-reviewer":"copilot","qodo-ai":"qodo","qodo-merge":"qodo","qodo-merge-pro":"qodo","qodo-merge-for-open-source":"qodo","codiumai-pr-agent-free":"qodo","sourcery-ai":"sourcery","bito-code-review":"bito","ellipsis-dev":"ellipsis","korbit-ai":"korbit","baz-reviewer":"baz","graphite-app":"graphite",cursor:"cursor","devin-ai-integration":"devin","entelligence-ai-pr-reviews":"entelligence"};function Xm(e){if(!e)return null;const s=e.toLowerCase().replace(/\[bot\]$/,"");return xx[s]??null}const jp=15,yx=["awaiting_your_review","your_pr_new_comments"];function hu(e){return yx.includes(e)}const yN=["claude-sonnet-5","claude-opus-4-8","claude-sonnet-4-6","claude-haiku-4-5"],vN={"claude-sonnet-5":"Claude Sonnet 5 (best value)","claude-opus-4-8":"Claude Opus 4.8 (most thorough)","claude-sonnet-4-6":"Claude Sonnet 4.6","claude-haiku-4-5":"Claude Haiku 4.5 (fast, cheap)"},Np=["open_prs","merges","lead_time","review_latency","merge_ci","ci_recovery","ci_red"],vx=1250;class Gt extends Error{constructor(s,a){super(a),this.status=s,this.name="ApiError"}}async function Fe(e){if(!e.ok){let s=`${e.status} ${e.statusText}`;try{const a=await e.json();a.message&&(s=a.message)}catch{}throw new Gt(e.status,s)}if(e.status!==204)return await e.json()}function De(e){return fetch(e,{credentials:"same-origin"}).then(s=>Fe(s))}function _e(e,s){return s===void 0?{method:e,credentials:"same-origin"}:{method:e,credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify(s)}}const ge={listRepos:()=>De("/api/repos"),searchRepos:(e,s)=>De(`/api/repos/search?q=${encodeURIComponent(e)}${s?`&cursor=${encodeURIComponent(s)}`:""}`),addRepo:e=>fetch("/api/repos",_e("POST",e)).then(s=>Fe(s)),setRepoInboxWatch:(e,s)=>fetch(`/api/repos/${e}`,_e("PATCH",{inboxWatch:s})).then(a=>Fe(a)),deleteRepo:e=>fetch(`/api/repos/${e}`,_e("DELETE")).then(s=>Fe(s)),syncRepo:(e,s=!1)=>fetch(`/api/repos/${e}/sync${s?"?full=true":""}`,_e("POST")).then(a=>Fe(a)),cancelSync:e=>fetch(`/api/repos/${e}/cancel`,_e("POST")).then(s=>Fe(s)),syncStatus:e=>De(`/api/repos/${e}/sync-status`),listUsers:()=>De("/api/users"),mergers:()=>De("/api/mergers"),setUserBot:(e,s)=>fetch(`/api/users/${e}`,_e("PATCH",{isBot:s})).then(a=>Fe(a)),timeline:e=>De(`/api/timeline${e?`?${e}`:""}`),openPrs:e=>De(`/api/open-prs${e?`?${e}`:""}`),insights:e=>De(`/api/insights${e?`?${e}`:""}`),repoAnalytics:e=>De(`/api/insights/${e}/analytics`),pr:e=>De(`/api/prs/${e}`),thread:e=>De(`/api/threads/${e}`),mentionCandidates:e=>De(`/api/prs/${e}/mention-candidates`),prFiles:e=>De(`/api/prs/${e}/files`),checkLogs:(e,s,a)=>De(`/api/prs/${e}/checks/${s}/logs${a?`?tail=${a}`:""}`),rerunCi:(e,s)=>fetch(`/api/prs/${e}/ci/rerun`,_e("POST",s)).then(a=>Fe(a)),replyToThread:(e,s)=>fetch(`/api/threads/${e}/reply`,_e("POST",s)).then(a=>Fe(a)),resolveThread:(e,s)=>fetch(`/api/threads/${e}/resolve`,_e("POST",s)).then(a=>Fe(a)),resolveBotThreads:(e,s)=>fetch(`/api/prs/${e}/resolve-bot-threads`,_e("POST",s)).then(a=>Fe(a)),createPrComment:(e,s)=>fetch(`/api/prs/${e}/comment`,_e("POST",s)).then(a=>Fe(a)),approvePr:(e,s)=>fetch(`/api/prs/${e}/approve`,_e("POST",s??{})).then(a=>Fe(a)),mergeOptions:e=>De(`/api/prs/${e}/merge-options`),mergePr:(e,s)=>fetch(`/api/prs/${e}/merge`,_e("POST",s)).then(a=>Fe(a)),updatePrBranch:(e,s)=>fetch(`/api/prs/${e}/update-branch`,_e("POST",s??{})).then(a=>Fe(a)),addReviewComment:(e,s)=>fetch(`/api/prs/${e}/review-comment`,_e("POST",s)).then(a=>Fe(a)),requestReviewers:(e,s)=>fetch(`/api/prs/${e}/request-reviewers`,_e("POST",s)).then(a=>Fe(a)),inbox:e=>De(`/api/activity${e?`?${e}`:""}`),consolidatedFeed:e=>De(`/api/activity/feed${e?`?${e}`:""}`),markFeedSeen:()=>fetch("/api/activity/feed/mark-seen",_e("POST")).then(e=>Fe(e)),teamInsights:()=>De("/api/pro/insights"),teamMetricsDetail:()=>De("/api/pro/insights/metrics-detail"),aiUsage:()=>De("/api/pro/ai-usage"),sprintReport:()=>De("/api/pro/sprint-report"),refreshSprintReport:()=>fetch("/api/pro/sprint-report/refresh",_e("POST")).then(e=>Fe(e)),retroReport:()=>De("/api/pro/retro"),refreshRetroReport:()=>fetch("/api/pro/retro/refresh",_e("POST")).then(e=>Fe(e)),repoClaudeReviews:e=>De(`/api/repos/${e}/claude-reviews`),repoDigests:e=>De(`/api/pro/activity/digests${e?`?${e}`:""}`),refreshRepoDigests:e=>fetch(`/api/pro/activity/digests/refresh${e?`?${e}`:""}`,_e("POST")).then(s=>Fe(s)),repoDigest:e=>De(`/api/pro/activity/digests/${e}`),reviewLearnings:e=>De(`/api/pro/prs/${e}/review-learnings`),reviewActions:e=>De(`/api/pro/claude-reviews/${e}/actions`),proSettings:()=>De("/api/pro/settings"),updateProSettings:e=>fetch("/api/pro/settings",_e("PUT",e)).then(s=>Fe(s)),testSlackDigest:()=>fetch("/api/pro/slack/test",_e("POST")).then(e=>Fe(e)),me:()=>De("/api/me"),logout:()=>fetch("/api/auth/logout",{method:"POST",credentials:"same-origin"}),myTurn:()=>De("/api/my-turn"),myTurnDone:()=>De("/api/my-turn/done"),dismissMyTurn:(e,s)=>fetch("/api/my-turn/dismiss",_e("POST",{kind:e,refId:s})).then(a=>Fe(a)),undismissMyTurn:(e,s)=>fetch("/api/my-turn/undismiss",_e("POST",{kind:e,refId:s})).then(a=>Fe(a)),markPrViewed:(e,s)=>fetch(`/api/prs/${e}/mark-viewed`,_e("POST",s?{sha:s}:{})).then(a=>Fe(a)),markAllViewed:e=>fetch("/api/prs/mark-all-viewed",_e("POST",e&&e.length>0?{repoIds:e}:{})).then(s=>Fe(s)),dismissPr:e=>fetch(`/api/prs/${e}/dismiss`,_e("POST")).then(s=>Fe(s)),claudeReview:e=>De(`/api/prs/${e}/claude-review`),setClaudeKey:e=>fetch("/api/claude-review/key",_e("PUT",{key:e})).then(s=>Fe(s)),claudeReviewById:e=>De(`/api/claude-reviews/${e}`),generateClaudeReview:(e,s,a)=>fetch(`/api/prs/${e}/claude-review`,_e("POST",{model:s,mode:a})).then(o=>Fe(o)),claudeReviewStatus:e=>De(`/api/prs/${e}/claude-review/status`),cancelClaudeReview:e=>fetch(`/api/prs/${e}/claude-review/cancel`,_e("POST")).then(s=>Fe(s)),updateClaudeReview:(e,s)=>fetch(`/api/claude-reviews/${e}`,_e("PATCH",s)).then(a=>Fe(a)),updateClaudeFinding:(e,s)=>fetch(`/api/claude-findings/${e}`,_e("PATCH",s)).then(a=>Fe(a)),postClaudeFinding:e=>fetch(`/api/claude-findings/${e}/post`,_e("POST")).then(s=>Fe(s)),activeClaudeReviews:()=>De("/api/claude-reviews/active"),listAllClaudeReviews:()=>De("/api/claude-reviews"),postClaudeReview:(e,s,a=!1)=>fetch(`/api/claude-reviews/${e}/post${a?"?dryRun=true":""}`,_e("POST",{userVerdict:s})).then(o=>Fe(o)),aiFixSummary:e=>De(`/api/pro/prs/${e}/summary`),refreshAiFixSummary:e=>fetch(`/api/pro/prs/${e}/summary/refresh`,_e("POST")).then(s=>Fe(s)),aiFixCiAnalysis:e=>De(`/api/pro/prs/${e}/ci-analysis`),refreshAiFixCiAnalysis:(e,s)=>fetch(`/api/pro/prs/${e}/ci-analysis`,_e("POST",{checks:s})).then(a=>Fe(a)),aiFix:e=>De(`/api/pro/prs/${e}/ai-fix`),aiFixStatus:e=>De(`/api/pro/prs/${e}/ai-fix/status`),startAiFix:(e,s)=>fetch(`/api/pro/prs/${e}/ai-fix`,_e("POST",s)).then(a=>Fe(a)),cancelAiFix:e=>fetch(`/api/pro/prs/${e}/ai-fix/cancel`,_e("POST")).then(s=>Fe(s)),pushAiFix:(e,s)=>fetch(`/api/pro/ai-fixes/${e}/push`,_e("POST",s)).then(a=>Fe(a)),aiFixMergePreview:e=>fetch(`/api/pro/ai-fixes/${e}/merge-preview`,_e("POST")).then(s=>Fe(s)),startAiFixRebase:(e,s)=>fetch(`/api/pro/ai-fixes/${e}/rebase`,_e("POST",s)).then(a=>Fe(a)),cancelAiFixRebase:e=>fetch(`/api/pro/ai-fixes/${e}/rebase/cancel`,_e("POST")).then(s=>Fe(s)),cancelAiFixPush:e=>fetch(`/api/pro/ai-fixes/${e}/push/cancel`,_e("POST")).then(s=>Fe(s)),botReviewers:()=>De("/api/bot-reviewers"),setReviewerOverride:(e,s)=>fetch(`/api/bot-reviewers/${e}`,_e("PATCH",s)).then(a=>Fe(a)),botAnalytics:e=>De(`/api/bot-analytics?window=${encodeURIComponent(e)}`),botVendorPrs:(e,s)=>De(`/api/bot-analytics/${encodeURIComponent(e)}/prs?window=${encodeURIComponent(s)}`),prBotDedup:e=>De(`/api/prs/${e}/bot-dedup`),botMuteRules:()=>De("/api/bot-mute-rules"),addBotMuteRule:e=>fetch("/api/bot-mute-rules",_e("POST",e)).then(s=>Fe(s)),deleteBotMuteRule:e=>fetch(`/api/bot-mute-rules/${e}`,_e("DELETE")).then(s=>Fe(s))},Sp=e=>{let s;const a=new Set,o=(g,y)=>{const b=typeof g=="function"?g(s):g;if(!Object.is(b,s)){const v=s;s=y??(typeof b!="object"||b===null)?b:Object.assign({},s,b),a.forEach(N=>N(s,v))}},i=()=>s,p={setState:o,getState:i,getInitialState:()=>m,subscribe:g=>(a.add(g),()=>a.delete(g))},m=s=e(o,i,p);return p},bx=(e=>e?Sp(e):Sp),wx=e=>e;function kx(e,s=wx){const a=jo.useSyncExternalStore(e.subscribe,jo.useCallback(()=>s(e.getState()),[e,s]),jo.useCallback(()=>s(e.getInitialState()),[e,s]));return jo.useDebugValue(a),a}const Cp=e=>{const s=bx(e),a=o=>kx(s,o);return Object.assign(a,s),a},ml=(e=>e?Cp(e):Cp),Po=e=>`pr-detail:${e}`,jx=e=>`pr-focus:${e}`,Nx="metrics-detail",Sx="bot-prs";function Au(e){const s=/^(pr-detail|pr-focus):(\d+)$/.exec(e);return s?{kind:s[1],prId:Number(s[2])}:null}const $u="pierre:tabs",Jm="pierre:pinnedTabs";function Rp(e){return{id:e.id,number:typeof e.number=="number"?e.number:0,title:typeof e.title=="string"?e.title:"",repoFullName:typeof e.repoFullName=="string"?e.repoFullName:"",authorLogin:typeof e.authorLogin=="string"?e.authorLogin:null,authorDisplayName:typeof e.authorDisplayName=="string"?e.authorDisplayName:null,authorAvatarUrl:typeof e.authorAvatarUrl=="string"?e.authorAvatarUrl:null}}function Cx(){try{const e=localStorage.getItem($u);if(e){const a=JSON.parse(e);if(Array.isArray(a))return a.filter(o=>o!=null&&typeof o=="object"&&typeof o.key=="string").map(o=>{const i=Au(o.key);return i?{key:o.key,kind:i.kind,prId:i.prId,meta:o.meta!=null&&typeof o.meta=="object"?Rp(o.meta):null}:null}).filter(o=>o!=null)}const s=localStorage.getItem(Jm);if(s){const a=JSON.parse(s);if(Array.isArray(a))return a.filter(o=>o!=null&&typeof o=="object"&&typeof o.id=="number").map(o=>{const i=Rp(o);return{key:Po(i.id),kind:"pr-detail",prId:i.id,meta:i}})}}catch{}return[]}function So(e){try{localStorage.setItem($u,JSON.stringify(e.filter(s=>s.kind==="pr-detail"||s.kind==="pr-focus")))}catch{}}function Rx(e,s){return e.number===s.number&&e.title===s.title&&e.repoFullName===s.repoFullName&&e.authorLogin===s.authorLogin&&e.authorDisplayName===s.authorDisplayName&&e.authorAvatarUrl===s.authorAvatarUrl}const Oe=ml((e,s)=>{const a=(o,i)=>{const u=s(),d=(i==null?void 0:i.fromActivity)??u.activeTab==="activity",p=u.tabs.some(g=>g.key===o.key),m=p?u.tabs.map(g=>g.key===o.key&&o.meta!=null?{...g,meta:o.meta}:g):[...u.tabs,o];if(d&&!u.activityReturnArmed)try{history.pushState({pierreTab:1},"")}catch{}(!p||o.meta!=null)&&So(m),e({tabs:m,activeTab:o.key,activityReturnArmed:d||u.activityReturnArmed,activityReturnItemId:d?(i==null?void 0:i.returnItemId)??null:u.activityReturnItemId,boardReturnTabKey:d?null:u.boardReturnTabKey})};return{tabs:Cx(),activeTab:"timeline",activityReturnArmed:!1,activityReturnItemId:null,activityFlashItemId:null,boardReturnTabKey:null,pin:o=>e(i=>{const u=Po(o.id);if(i.tabs.some(p=>p.key===u))return i;const d=[...i.tabs,{key:u,kind:"pr-detail",prId:o.id,meta:o}];return So(d),{tabs:d}}),openPrDetailTab:(o,i)=>a({key:Po(o.id),kind:"pr-detail",prId:o.id,meta:o},i),openPrFocusTab:(o,i)=>a({key:jx(o.id),kind:"pr-focus",prId:o.id,meta:o},i),openMetricsTab:o=>a({key:Nx,kind:"metrics-detail",prId:0,meta:null},o),openBotPrsTab:o=>a({key:Sx,kind:"bot-prs",prId:0,meta:null},o),syncMeta:o=>e(i=>{let u=!1;const d=i.tabs.map(p=>p.prId!==o.id||p.meta==null||Rx(p.meta,o)?p:(u=!0,{...p,meta:o}));return u?(So(d),{tabs:d}):i}),closeTab:o=>e(i=>{const u=i.tabs.findIndex(g=>g.key===o);if(u===-1)return i;const d=i.tabs.filter(g=>g.key!==o);So(d);const p=i.boardReturnTabKey===o?null:i.boardReturnTabKey;if(i.activeTab!==o)return{tabs:d,boardReturnTabKey:p};const m=u-1>=0?i.tabs[u-1].key:d.length>0?d[0].key:"timeline";return{tabs:d,activeTab:m,boardReturnTabKey:p}}),unpin:o=>s().closeTab(Po(o)),setActiveTab:o=>e({activeTab:o}),showTimeline:()=>{s().activeTab!=="timeline"&&e({activeTab:"timeline"})},showBoardFromDetail:()=>{const o=s(),i=Au(o.activeTab);if((i==null?void 0:i.kind)==="pr-detail"&&o.activityReturnArmed&&o.boardReturnTabKey==null){try{history.pushState({pierreTab:1},"")}catch{}e({activeTab:"timeline",boardReturnTabKey:o.activeTab});return}o.activeTab!=="timeline"&&e({activeTab:"timeline"})},showActivity:()=>{s().activeTab!=="activity"&&e({activeTab:"activity"})},navigateBack:()=>{const o=s();if(o.boardReturnTabKey!=null){const i=o.tabs.some(u=>u.key===o.boardReturnTabKey);e({activeTab:i?o.boardReturnTabKey:"timeline",boardReturnTabKey:null});return}o.activityReturnArmed&&e({activeTab:"activity",activityReturnArmed:!1,activityFlashItemId:o.activityReturnItemId,activityReturnItemId:null})},clearActivityFlashItem:()=>{s().activityFlashItemId!=null&&e({activityFlashItemId:null})},clear:()=>{try{localStorage.removeItem($u),localStorage.removeItem(Jm)}catch{}e({tabs:[],activeTab:"timeline",activityReturnArmed:!1,activityReturnItemId:null,activityFlashItemId:null,boardReturnTabKey:null})}}}),cl=["review_comments","pr_comments","commits"],_o=cl.filter(e=>e!=="commits"),ul=hx,dl=gx,Oo=[...dl],Do=ul.filter(e=>e!=="closed"),Ip=1440*60*1e3,Ix={"7d":7,"14d":14,"30d":30,"90d":90};function Es(e,s){return e.includes(s)?e.filter(a=>a!==s):[...e,s]}function Qo(){return{repoIds:null,userIds:null,excludeBots:!1,allowedBotIds:[],excludeStale:!0,preset:"14d",customFrom:null,customTo:null,categories:[..._o],prStatuses:[...Do],reviewStates:[...Oo],derivedStates:[],searchQuery:"",stripFilter:"all"}}function gu(e){return{repoIds:e.repoIds,userIds:e.userIds,excludeBots:e.excludeBots,allowedBotIds:e.allowedBotIds,excludeStale:e.excludeStale,preset:e.preset,customFrom:e.customFrom,customTo:e.customTo,categories:e.categories,prStatuses:e.prStatuses,reviewStates:e.reviewStates,derivedStates:e.derivedStates,searchQuery:e.searchQuery,stripFilter:e.stripFilter}}function Go(e){const s=Qo(),a={};for(const o of Object.keys(s))o in e&&e[o]!==void 0&&(a[o]=e[o]);return a}function Ps(e,s){if(e==null||s==null)return e===s;if(e.length!==s.length)return!1;const a=new Set(e);return s.every(o=>a.has(o))}function Tx(e,s){const a={...Qo(),...Go(e)};return Ps(a.repoIds,s.repoIds)&&Ps(a.userIds,s.userIds)&&a.excludeBots===s.excludeBots&&Ps(a.allowedBotIds,s.allowedBotIds)&&a.excludeStale===s.excludeStale&&a.preset===s.preset&&(a.preset!=="custom"||a.customFrom===s.customFrom&&a.customTo===s.customTo)&&Ps(a.categories,s.categories)&&Ps(a.prStatuses,s.prStatuses)&&Ps(a.reviewStates,s.reviewStates)&&Ps(a.derivedStates,s.derivedStates)&&a.searchQuery===s.searchQuery&&a.stripFilter===s.stripFilter}function Ex(){return{...Qo(),feedMyTurnOnly:!1,feedClaudeOnly:!1,feedBotLens:"all",botAnalyticsWindow:"rolling_14",selectedPrId:null,selectedThreadId:null,threadBotFilter:null,selectedCommentId:null,activityFocus:null,commentFocus:null,claudeTabFocus:null,changesThreadFocus:null,aiFixTabFocus:null,metricsFocus:null,botPrsFocus:null,stripCollapsed:!0,activityRepoId:"feed",activityThreadFilter:null,expandedFileGroups:[],collapsedFileGroups:[],expandedDiffHunks:[],timelineFocusPr:null,timelineFocusAt:null,timelineFocusEvent:null,timelineCenterAt:null,rangeResetSignal:0,syncModalSignal:0,syncModalRepoId:null,claudeReviewKickoff:0}}const te=ml((e,s)=>({...Ex(),setRepoIds:a=>e({repoIds:a}),toggleRepo:a=>e(o=>({repoIds:Es(o.repoIds??[],a)})),showRepo:a=>{const{repoIds:o}=s();o==null||o.includes(a)||e({repoIds:[...o,a]})},setUserIds:a=>e({userIds:a}),setExcludeBots:a=>e({excludeBots:a}),setAllowedBotIds:a=>e({allowedBotIds:a}),toggleAllowedBot:a=>e(o=>({allowedBotIds:Es(o.allowedBotIds,a)})),setExcludeStale:a=>e({excludeStale:a}),setPreset:a=>e(o=>({preset:a,rangeResetSignal:o.rangeResetSignal+1})),setCustomRange:(a,o)=>e({preset:"custom",customFrom:a,customTo:o}),toggleCategory:a=>e(o=>({categories:Es(o.categories,a)})),setCategories:a=>e({categories:a}),togglePrStatus:a=>e(o=>({prStatuses:Es(o.prStatuses,a)})),setPrStatuses:a=>e({prStatuses:a}),toggleReviewState:a=>e(o=>({reviewStates:Es(o.reviewStates,a)})),setReviewStates:a=>e({reviewStates:a}),toggleDerivedState:a=>e(o=>({derivedStates:Es(o.derivedStates,a)})),setDerivedStates:a=>e({derivedStates:a}),toggleFeedMyTurnOnly:()=>e(a=>({feedMyTurnOnly:!a.feedMyTurnOnly,feedClaudeOnly:!1})),setFeedMyTurnOnly:a=>e(a?{feedMyTurnOnly:!0,feedClaudeOnly:!1}:{feedMyTurnOnly:!1}),toggleFeedClaudeOnly:()=>e(a=>({feedClaudeOnly:!a.feedClaudeOnly,feedMyTurnOnly:!1})),setFeedClaudeOnly:a=>e(a?{feedClaudeOnly:!0,feedMyTurnOnly:!1}:{feedClaudeOnly:!1}),cycleFeedBotLens:()=>e(a=>({feedBotLens:a.feedBotLens==="all"?"hide":a.feedBotLens==="hide"?"only":"all"})),setFeedBotLens:a=>e({feedBotLens:a}),setBotAnalyticsWindow:a=>e({botAnalyticsWindow:a}),setThreadBotFilter:a=>e(o=>({threadBotFilter:o.threadBotFilter===a?null:a})),selectPr:a=>e({selectedPrId:a,selectedThreadId:null,selectedCommentId:null,threadBotFilter:null}),selectThread:(a,o)=>e(i=>({selectedPrId:a??i.selectedPrId,selectedThreadId:o,selectedCommentId:null})),clearSelection:()=>e({selectedPrId:null,selectedThreadId:null,selectedCommentId:null,threadBotFilter:null}),openPrFocused:(a,o=null,i=null,u=null)=>{Oe.getState().showBoardFromDetail(),e({selectedPrId:a,selectedThreadId:o,selectedCommentId:null,timelineFocusPr:a,timelineFocusAt:i,timelineFocusEvent:u})},showEventOnTimeline:(a,o,i)=>{Oe.getState().showBoardFromDetail(),e({selectedPrId:a,timelineFocusPr:a,timelineFocusAt:o,timelineFocusEvent:i})},focusEventInTab:(a,o,i,u=null)=>e({selectedPrId:a,selectedThreadId:u,selectedCommentId:null,timelineFocusPr:a,timelineFocusAt:o,timelineFocusEvent:i}),consumeTimelineFocus:()=>e({timelineFocusPr:null,timelineFocusAt:null,timelineFocusEvent:null}),centerTimelineNow:()=>{Oe.getState().showTimeline(),e({timelineCenterAt:Date.now()})},consumeTimelineCenter:()=>e({timelineCenterAt:null}),showActivityEntry:(a,o)=>e({selectedPrId:a,selectedThreadId:null,selectedCommentId:null,activityFocus:{prId:a,...o}}),consumeActivityFocus:()=>e({activityFocus:null}),showPrComment:(a,o)=>e({selectedPrId:a,selectedThreadId:null,selectedCommentId:o,commentFocus:{prId:a,commentId:o}}),consumeCommentFocus:()=>e({commentFocus:null}),openClaudeReview:(a,o)=>{Oe.getState().openPrDetailTab(a,o),e({selectedPrId:a.id,selectedThreadId:null,selectedCommentId:null,claudeTabFocus:{prId:a.id}})},consumeClaudeTabFocus:()=>e({claudeTabFocus:null}),showThreadInChanges:(a,o)=>e({changesThreadFocus:{prId:a,threadId:o}}),consumeChangesThreadFocus:()=>e({changesThreadFocus:null}),openAiFixFromReview:(a,o)=>e({selectedPrId:a,selectedThreadId:null,selectedCommentId:null,aiFixTabFocus:{prId:a,reviewText:o}}),consumeAiFixTabFocus:()=>e({aiFixTabFocus:null}),openMetricsDetail:a=>{e({metricsFocus:a}),Oe.getState().openMetricsTab({fromActivity:!0})},consumeMetricsFocus:()=>e({metricsFocus:null}),openBotPrsDetail:a=>{e({botPrsFocus:a}),Oe.getState().openBotPrsTab({fromActivity:!0})},consumeBotPrsFocus:()=>e({botPrsFocus:null}),requestSyncModal:a=>e(o=>({syncModalSignal:o.syncModalSignal+1,syncModalRepoId:a})),bumpClaudeReviewKickoff:()=>e(a=>({claudeReviewKickoff:a.claudeReviewKickoff+1})),setStripCollapsed:a=>e({stripCollapsed:a}),setStripFilter:a=>e({stripFilter:a}),setActivityRepo:a=>e(o=>o.activityRepoId===a?{}:{activityRepoId:a,activityThreadFilter:null}),setActivityThreadFilter:a=>e(o=>({activityThreadFilter:o.activityThreadFilter===a?null:a})),setSearchQuery:a=>e({searchQuery:a}),toggleFileGroup:(a,o)=>e(i=>{const u=o?!i.collapsedFileGroups.includes(a):i.expandedFileGroups.includes(a);return o?{collapsedFileGroups:u?[...i.collapsedFileGroups,a]:i.collapsedFileGroups.filter(d=>d!==a)}:{expandedFileGroups:u?i.expandedFileGroups.filter(d=>d!==a):[...i.expandedFileGroups,a]}}),toggleDiffHunk:a=>e(o=>({expandedDiffHunks:Es(o.expandedDiffHunks,a)})),resetAllFilters:()=>e(a=>({...Qo(),rangeResetSignal:a.rangeResetSignal+1})),hydrate:a=>e(a)}));function Ao(e){return Px(e)}function Px(e){if(e.preset==="custom"&&(e.customFrom||e.customTo)){const o=e.customTo?new Date(`${e.customTo}T23:59:59Z`):new Date;return{from:e.customFrom?new Date(`${e.customFrom}T00:00:00Z`):new Date(o.getTime()-14*Ip),to:o}}const s=Ix[e.preset==="custom"?"14d":e.preset],a=new Date;return{from:new Date(a.getTime()-s*Ip),to:a}}function Zm(e){const s=new Set(e);return s.add("lifecycle"),s.add("reviews"),Object.keys(kp).filter(a=>s.has(kp[a]))}function Tp(e){return new Date(Math.floor(e.getTime()/6e4)*6e4)}function eh(e,s=!0){const a=new URLSearchParams;return e.repoIds&&e.repoIds.length>0&&a.set("repoIds",e.repoIds.join(",")),s&&e.userIds&&e.userIds.length>0&&a.set("userIds",e.userIds.join(",")),a.toString()}function th(e,s=!0,a=!0,o=!0,i=!0,u,d=!0,p){if(p&&p.length>0)return`prIds=${p.join(",")}`;const{from:m,to:g}=Ao(e),y=u!=null&&u<m.getTime()?new Date(u):m,b=new URLSearchParams;return b.set("from",Tp(y).toISOString()),b.set("to",Tp(g).toISOString()),e.repoIds&&e.repoIds.length>0&&b.set("repoIds",e.repoIds.join(",")),s&&e.userIds&&e.userIds.length>0&&b.set("userIds",e.userIds.join(",")),e.categories.length<cl.length&&b.set("types",Zm(e.categories).join(",")),a&&e.prStatuses.length<ul.length&&b.set("statuses",e.prStatuses.join(",")),i&&e.reviewStates.length<dl.length&&b.set("reviewStates",e.reviewStates.join(",")),d?(b.set("excludeBots",String(e.excludeBots)),e.excludeBots&&e.allowedBotIds.length>0&&b.set("allowBotIds",e.allowedBotIds.join(","))):b.set("excludeBots","false"),o&&e.excludeStale&&b.set("excludeStale","true"),b.toString()}function Mr(){return qe({queryKey:["repos"],queryFn:ge.listRepos})}function $n(){return qe({queryKey:["users"],queryFn:ge.listUsers})}function Mu(){return qe({queryKey:["mergers"],queryFn:ge.mergers})}function nh(e){const s=te(a=>th(a,!(e!=null&&e.dropMembers),!0,!0,!0,(e==null?void 0:e.fromMs)??null,!0,e==null?void 0:e.prIds));return qe({queryKey:["timeline",s],queryFn:()=>ge.timeline(s),placeholderData:a=>a})}function Fu(){const e=te(s=>th(s,!1,!1,!1,!1,null,!1));return qe({queryKey:["timeline",e],queryFn:()=>ge.timeline(e),placeholderData:s=>s})}function rh(){const e=te(eh);return qe({queryKey:["open-prs",e],queryFn:()=>ge.openPrs(e),placeholderData:s=>s})}function Lu(){const e=te(s=>eh(s,!1));return qe({queryKey:["open-prs",e],queryFn:()=>ge.openPrs(e),placeholderData:s=>s})}function _u(){return qe({queryKey:["me"],queryFn:ge.me,retry:!1})}function yn(){var e;return((e=_u().data)==null?void 0:e.pro)??{activityDigest:!1,reviewMemory:!1,aiAnalysis:!1,prSummary:!1,aiFix:!1,teamInsights:!1,claudeReview:!1,slackDigest:!1,issueLinks:!1}}function sh(){return qe({queryKey:["my-turn"],queryFn:ge.myTurn})}function ah(e){return qe({queryKey:["repo-analytics",e],queryFn:()=>ge.repoAnalytics(e),enabled:e!=null})}const Ou=["activity","consolidated-feed","feed-head","repo-digests","team-insights","sprint-report"];function Ax(e,s){const a=new URLSearchParams;return s&&s.length>0&&a.set("userIds",s.join(",")),a.toString()}function $x(e,s){const a=Ax(e,s);return qe({queryKey:["activity",a],queryFn:()=>ge.inbox(a),staleTime:1/0,refetchOnMount:!1,placeholderData:o=>o})}function Yn(e,s,a=!0){const o=x.useRef(s);o.current=s,x.useEffect(()=>{if(!a)return;function i(u){const d=e.current;d&&!d.contains(u.target)&&o.current()}return document.addEventListener("pointerdown",i,!0),()=>document.removeEventListener("pointerdown",i,!0)},[e,a])}const Mx={lifecycle:"PR state events",reviews:"Reviews",review_comments:"Review comments",pr_comments:"PR comments",commits:"Commits"},Fx={approved:"Approved",changes_requested:"Changes requested",commented:"Commented",dismissed:"Dismissed",pending:"Pending"},Lx={approved:"#22c55e",changes_requested:"#f97316",commented:"#9ca3af",dismissed:"#9ca3af",pending:"#9ca3af"};function Ep(e,s){if(e.length!==s.length)return!1;const a=new Set(e);return s.every(o=>a.has(o))}function _x({categories:e,onToggleCategory:s,onSetCategories:a,reviewStates:o,onToggleReviewState:i,onSetReviewStates:u}){const[d,p]=x.useState(!1),m=x.useRef(null),g=Ep(e,_o)&&Ep(o,Oo),y=e.length+o.length,b=cl.length+dl.length,v=()=>{a([..._o]),u([...Oo])};return Yn(m,()=>p(!1),d),x.useEffect(()=>{if(!d)return;const N=I=>{I.key==="Escape"&&(I.stopPropagation(),p(!1))};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[d]),n.jsxs("div",{ref:m,className:"relative",children:[n.jsxs("span",{className:"inline-flex items-center whitespace-nowrap rounded-full border border-gray-300 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[n.jsxs("button",{type:"button",onClick:()=>p(N=>!N),"aria-haspopup":"true","aria-expanded":d,className:`inline-flex items-center gap-1 py-0.5 pl-2.5 ${g?"pr-2.5":"pr-1"}`,children:["Events",g?"":` (${y})`,n.jsx("span",{"aria-hidden":!0,className:"text-[9px]",children:"▾"})]}),!g&&n.jsx("button",{type:"button",onClick:v,title:"Reset event filters to default","aria-label":"Reset event filters to default",className:"py-0.5 pl-0.5 pr-2 opacity-60 hover:opacity-100",children:"✕"})]}),d&&n.jsxs("div",{role:"dialog","aria-label":"Event types",className:"absolute left-0 top-full z-[60] mt-1 w-60 rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[n.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[n.jsx("p",{className:"px-1 pb-0.5 pt-1 text-[11px] uppercase tracking-wide text-gray-400",children:"Reviews"}),dl.map(N=>n.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[n.jsx("input",{type:"checkbox",checked:o.includes(N),onChange:()=>i(N)}),n.jsx("span",{"aria-hidden":!0,className:"h-2.5 w-2.5 shrink-0 rounded-full",style:{backgroundColor:Lx[N]}}),n.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:Fx[N]})]},N)),n.jsx("div",{className:"my-1 border-t border-gray-200 dark:border-gray-700"}),cl.map(N=>n.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[n.jsx("input",{type:"checkbox",checked:e.includes(N),onChange:()=>s(N)}),n.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:Mx[N]})]},N))]}),!g&&n.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-gray-200 pt-2 dark:border-gray-700",children:[n.jsxs("span",{className:"text-[11px] text-gray-400",children:[y," of ",b," shown"]}),n.jsx("button",{type:"button",onClick:v,className:"text-[11px] text-gray-400 hover:text-gray-600",children:"Reset to default"})]})]})]})}function Ox(e,s=300){const[a,o]=x.useState(e);return x.useEffect(()=>{const i=setTimeout(()=>o(e),s);return()=>clearTimeout(i)},[e,s]),a}const Dx=[{owner:"mrdoob",name:"three.js",category:"Graphics",why:"The de-facto JavaScript 3D library (WebGL/WebGPU) behind most browser 3D and creative coding."},{owner:"bevyengine",name:"bevy",category:"Game engines",why:"A refreshingly simple, data-driven game engine in Rust with one of open source’s most active engine communities."},{owner:"obsproject",name:"obs-studio",category:"Media",why:"The industry-standard open-source live-streaming and screen-recording suite."},{owner:"huggingface",name:"transformers",category:"Machine learning",why:"The model-definition framework behind state-of-the-art NLP/vision/audio models; hub of the open ML ecosystem."},{owner:"pytorch",name:"pytorch",category:"Machine learning",why:"Meta’s deep-learning framework that dominates research and increasingly production training."},{owner:"ollama",name:"ollama",category:"Machine learning",why:"The easiest way to run open LLMs locally; explosive recent adoption."},{owner:"ggml-org",name:"llama.cpp",category:"Machine learning",why:"Highly optimized C/C++ LLM inference that made local, quantized model serving mainstream."},{owner:"numpy",name:"numpy",category:"Scientific computing",why:"The foundational N-dimensional array library underpinning essentially all of Python’s scientific stack."},{owner:"pola-rs",name:"polars",category:"Data science",why:"A blazing-fast multi-threaded DataFrame query engine in Rust; the modern challenger to pandas."},{owner:"jupyter",name:"notebook",category:"Data science",why:"The interactive notebook that became the lingua franca of data science and research computing."},{owner:"rust-lang",name:"rust",category:"Languages",why:"The Rust language and compiler; a memory-safe systems language topping developer-love surveys."},{owner:"golang",name:"go",category:"Languages",why:"Google’s Go language and toolchain; the backbone of modern cloud and infrastructure software."},{owner:"ziglang",name:"zig",category:"Languages",why:"A fast-growing low-level language aiming to be a simpler, safer C; also a drop-in C/C++ compiler."},{owner:"duckdb",name:"duckdb",category:"Databases",why:"An in-process analytical SQL database — the “SQLite for analytics” — surging across data tooling."},{owner:"redis",name:"redis",category:"Databases",why:"The ubiquitous in-memory data store used for caching, queues, and real-time data."},{owner:"cockroachdb",name:"cockroach",category:"Databases",why:"A distributed, PostgreSQL-compatible SQL database built for resilience and horizontal scale."},{owner:"sveltejs",name:"svelte",category:"Web frameworks",why:"A compiler-first UI framework producing tiny, fast apps; consistently top-rated for satisfaction."},{owner:"denoland",name:"deno",category:"Runtimes",why:"A secure, TypeScript-first JavaScript runtime from Node’s original creator."},{owner:"neovim",name:"neovim",category:"Dev tools",why:"The hyperextensible, Lua-scriptable Vim fork that became the modern terminal editor of choice."},{owner:"openssl",name:"openssl",category:"Security",why:"The cryptography and TLS library securing a huge fraction of the internet’s traffic."},{owner:"d3",name:"d3",category:"Visualization",why:"The canonical library for bespoke, data-driven SVG/Canvas visualizations."},{owner:"tldraw",name:"tldraw",category:"Visualization",why:"An infinite-canvas drawing SDK and whiteboard; a slick showcase of modern web UI and real-time collab."}],Vc=2,Bx=["repos","timeline","open-prs","users","my-turn","me",...Ou];function Pp(e){return e>=1e6?`${(e/1e6).toFixed(1)}m`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function Ap({login:e,src:s}){return s?n.jsx("img",{src:s,alt:e,width:20,height:20,className:"mt-0.5 h-5 w-5 shrink-0 rounded-full"}):n.jsx("span",{className:"mt-0.5 flex h-5 w-5 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",children:e.slice(0,2).toUpperCase()})}function $p(){return n.jsx("span",{className:"inline-block h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-gray-300 border-t-blue-500 dark:border-gray-600 dark:border-t-blue-400"})}function zx(){var Pe,se;const e=Be(),s=te(Z=>Z.requestSyncModal),a=te(Z=>Z.showRepo),o=x.useRef(null),i=x.useRef(null),u=x.useId(),[d,p]=x.useState(""),[m,g]=x.useState(!1),[y,b]=x.useState(0),[v,N]=x.useState(new Set),I=Z=>`${Z.owner}/${Z.name}`.toLowerCase(),[P,E]=x.useState([null]),[w,R]=x.useState(0),S=d.trim(),j=Ox(S,300),T=m&&j.length>=Vc,M=m&&j.length<Vc,D=T||M,U=P[w]??null,{data:G}=Mr(),L=((G==null?void 0:G.length)??0)>=jp,Y=x.useMemo(()=>new Set((G??[]).map(Z=>`${Z.owner}/${Z.name}`.toLowerCase())),[G]),X=x.useMemo(()=>Dx.filter(Z=>!Y.has(`${Z.owner}/${Z.name}`.toLowerCase())&&!v.has(`${Z.owner}/${Z.name}`.toLowerCase())),[Y,v]);x.useEffect(()=>{E([null]),R(0),b(0)},[j]);const B=qe({queryKey:["repo-search",j,U],queryFn:()=>ge.searchRepos(j,U??void 0),enabled:T,placeholderData:Z=>Z,staleTime:6e4}),_=Ue({mutationFn:Z=>ge.addRepo({owner:Z.owner,name:Z.name,watch:Z.watch}),onMutate:Z=>{N(je=>new Set(je).add(I(Z)))},onSuccess:Z=>{for(const je of Bx)e.invalidateQueries({queryKey:[je]});e.invalidateQueries({queryKey:["repo-search"]}),s(Z.id),a(Z.id)}}),H=(((Pe=B.data)==null?void 0:Pe.results)??[]).filter(Z=>!v.has(`${Z.owner}/${Z.name}`.toLowerCase())),ee=((se=B.data)==null?void 0:se.hasNextPage)??!1,ce=S.length>=Vc&&S!==j,C=T&&(ce||B.isFetching||B.isPlaceholderData),F=M?X:H;x.useEffect(()=>{b(Z=>F.length?Math.min(Z,F.length-1):0)},[F]),Yn(o,()=>g(!1),m),x.useEffect(()=>{var Z,je;(je=(Z=i.current)==null?void 0:Z.querySelector(`[data-idx="${y}"]`))==null||je.scrollIntoView({block:"nearest"})},[y,F]);function K(){var je;const Z=(je=B.data)==null?void 0:je.cursor;!ee||Z==null||(E(We=>[...We.slice(0,w+1),Z]),R(We=>We+1),b(0))}function ae(){w!==0&&(R(Z=>Z-1),b(0))}function ne(Z){if(Z.key==="Escape"){g(!1);return}if(D){if(Z.key==="ArrowDown")Z.preventDefault(),b(je=>Math.min(je+1,Math.max(F.length-1,0)));else if(Z.key==="ArrowUp")Z.preventDefault(),b(je=>Math.max(je-1,0));else if(Z.key==="Enter"){Z.preventDefault();const je=F[y];je&&!_.isPending&&!L&&_.mutate({owner:je.owner,name:je.name,watch:"isOwnedOrMember"in je?je.isOwnedOrMember:void 0})}}}return n.jsxs("div",{ref:o,className:"relative",children:[n.jsx("input",{id:"add-repo-input",type:"search",value:d,onChange:Z=>{p(Z.target.value),g(!0)},onFocus:()=>g(!0),onKeyDown:ne,placeholder:"Search repos to add…",role:"combobox","aria-expanded":D,"aria-controls":u,"aria-autocomplete":"list","aria-activedescendant":D&&F[y]?`${u}-opt-${y}`:void 0,className:"w-44 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"}),D&&n.jsxs("div",{id:u,role:"listbox","aria-label":"Repository search results",className:"absolute left-0 top-full z-[60] mt-1 max-h-96 w-96 overflow-y-auto rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[L&&n.jsxs("div",{className:"sticky top-0 z-20 border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-[11px] text-amber-700 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-300",children:["You’re watching the maximum of ",jp," repos. Remove one to add another."]}),M?n.jsxs("div",{children:[n.jsx("div",{className:"sticky top-0 z-10 border-b border-gray-200 bg-white px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wide text-gray-400 dark:border-gray-700 dark:bg-gray-900",children:"Suggested repos"}),X.length===0?n.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"You’re already watching all the suggestions."}):n.jsx("div",{ref:i,children:X.map((Z,je)=>{var st,Pt;const We=_.isPending&&((st=_.variables)==null?void 0:st.owner)===Z.owner&&((Pt=_.variables)==null?void 0:Pt.name)===Z.name;return n.jsxs("div",{className:`flex items-stretch ${je===y?"bg-gray-100 dark:bg-gray-800":""} hover:bg-gray-100 dark:hover:bg-gray-800`,children:[n.jsxs("button",{id:`${u}-opt-${je}`,"data-idx":je,type:"button",role:"option","aria-selected":je===y,disabled:_.isPending||L,onMouseEnter:()=>b(je),onClick:()=>_.mutate({owner:Z.owner,name:Z.name}),className:"flex min-w-0 flex-1 items-start gap-2 px-3 py-2 text-left disabled:opacity-60",children:[n.jsx(Ap,{login:Z.owner,src:null}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsxs("span",{className:"truncate text-xs font-medium text-gray-800 dark:text-gray-100",title:`${Z.owner}/${Z.name}`,children:[Z.owner,"/",Z.name]}),n.jsx("span",{className:"shrink-0 rounded bg-gray-100 px-1 text-[9px] uppercase tracking-wide text-gray-500 dark:bg-gray-800 dark:text-gray-400",children:Z.category})]}),n.jsx("span",{className:"mt-0.5 line-clamp-2 text-[11px] text-gray-500 dark:text-gray-400",children:Z.why})]}),n.jsx("span",{className:"mt-0.5 shrink-0 rounded bg-blue-600 px-1.5 py-0.5 text-[10px] text-white",children:We?"Adding…":"Add"})]}),n.jsx("a",{href:`https://github.com/${Z.owner}/${Z.name}`,target:"_blank",rel:"noopener noreferrer",onClick:Lt=>Lt.stopPropagation(),title:"Open on GitHub","aria-label":`Open ${Z.owner}/${Z.name} on GitHub`,className:"flex shrink-0 items-center px-2 text-[10px] text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",children:"↗"})]},`${Z.owner}/${Z.name}`)})})]}):B.isError?n.jsx("div",{className:"px-3 py-2 text-xs text-red-500",children:B.error instanceof Gt?B.error.message:"Search failed"}):C&&H.length===0?n.jsxs("div",{className:"flex items-center justify-center gap-2 px-3 py-6 text-xs text-gray-500",children:[n.jsx($p,{}),n.jsx("span",{children:"Searching…"})]}):H.length===0?n.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"No matching repositories."}):n.jsxs("div",{ref:i,children:[C&&n.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-2 border-b border-gray-200 bg-white/95 px-3 py-1.5 text-[11px] text-gray-500 backdrop-blur dark:border-gray-700 dark:bg-gray-900/95 dark:text-gray-400",children:[n.jsx($p,{}),n.jsx("span",{children:"Searching…"})]}),H.map((Z,je)=>{var st,Pt;const We=_.isPending&&((st=_.variables)==null?void 0:st.owner)===Z.owner&&((Pt=_.variables)==null?void 0:Pt.name)===Z.name;return n.jsxs("div",{className:`flex items-stretch ${je===y?"bg-gray-100 dark:bg-gray-800":""} hover:bg-gray-100 dark:hover:bg-gray-800`,children:[n.jsxs("button",{id:`${u}-opt-${je}`,"data-idx":je,type:"button",role:"option","aria-selected":je===y,disabled:_.isPending,onMouseEnter:()=>b(je),onClick:()=>_.mutate({owner:Z.owner,name:Z.name,watch:Z.isOwnedOrMember}),className:"flex min-w-0 flex-1 items-start gap-2 px-3 py-2 text-left disabled:opacity-60",children:[n.jsx(Ap,{login:Z.owner,src:Z.ownerAvatarUrl}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"truncate text-xs font-medium text-gray-800 dark:text-gray-100",title:Z.fullName,children:Z.fullName}),Z.isPrivate&&n.jsx("span",{className:"shrink-0 rounded bg-gray-200 px-1 text-[9px] uppercase tracking-wide text-gray-500 dark:bg-gray-700 dark:text-gray-300",children:"private"}),Z.isOwnedOrMember&&n.jsx("span",{className:"shrink-0 rounded bg-sky-100 px-1 text-[9px] uppercase tracking-wide text-sky-700 dark:bg-sky-900/50 dark:text-sky-300",children:"yours"})]}),Z.description&&n.jsx("span",{className:"mt-0.5 line-clamp-2 text-[11px] text-gray-500 dark:text-gray-400",children:Z.description}),n.jsxs("span",{className:"mt-0.5 flex items-center gap-2 text-[10px] text-gray-400",children:[n.jsxs("span",{title:`${Z.stargazerCount} stars`,children:["★ ",Pp(Z.stargazerCount)]}),n.jsx("span",{"aria-hidden":!0,children:"·"}),n.jsxs("span",{title:`${Z.openPrCount} open pull requests`,children:[Pp(Z.openPrCount)," open PR",Z.openPrCount===1?"":"s"]})]})]}),n.jsx("span",{className:"mt-0.5 shrink-0 rounded bg-blue-600 px-1.5 py-0.5 text-[10px] text-white",children:We?"Adding…":"Add"})]}),n.jsx("a",{href:Z.url||`https://github.com/${Z.owner}/${Z.name}`,target:"_blank",rel:"noopener noreferrer",onClick:Lt=>Lt.stopPropagation(),title:"Open on GitHub","aria-label":`Open ${Z.fullName} on GitHub`,className:"flex shrink-0 items-center px-2 text-[10px] text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",children:"↗"})]},Z.githubNodeId)})]}),!M&&(w>0||ee)&&n.jsxs("div",{className:"sticky bottom-0 flex items-center justify-between border-t border-gray-200 bg-white px-3 py-1.5 text-[11px] dark:border-gray-700 dark:bg-gray-900",children:[n.jsx("button",{type:"button",onClick:ae,disabled:w===0,className:"text-gray-500 hover:text-gray-800 disabled:opacity-30 dark:text-gray-400 dark:hover:text-gray-100",children:"← Prev"}),n.jsxs("span",{className:"text-gray-400",children:["Page ",w+1]}),n.jsx("button",{type:"button",onClick:K,disabled:!ee,className:"text-gray-500 hover:text-gray-800 disabled:opacity-30 dark:text-gray-400 dark:hover:text-gray-100",children:"Next →"})]}),_.error&&n.jsx("div",{className:"border-t border-gray-200 px-3 py-1.5 text-[11px] text-red-500 dark:border-gray-700",children:_.error instanceof Gt?_.error.message:"Failed to add repo"})]})]})}function bN(e){return Math.max(0,Math.round(e*vx))}const jt={untouched:{label:"Untouched",color:"#ef4444",description:"No reply, and no follow-up commit touched the file."},replied_unresolved:{label:"Replied",color:"#f59e0b",description:"Someone replied, but the thread is unresolved and no later commit touched the file."},likely_addressed:{label:"Likely addressed",color:"#3b82f6",description:"A commit touched this file after the last comment. Heuristic — it may be a false positive."},resolved:{label:"Resolved",color:"#22c55e",description:"Marked resolved on GitHub."}},qx={open:{label:"Open",color:"#3b82f6"},merged:{label:"Merged",color:"#22c55e"},closed:{label:"Closed",color:"#9ca3af"}},lh={pr_opened:{label:"PR opened",color:"#3b82f6",shape:"dot"},pr_merged:{label:"PR merged",color:"#8957e5",shape:"dot"},pr_closed:{label:"PR closed",color:"#9ca3af",shape:"dot"},pr_reopened:{label:"PR reopened",color:"#3b82f6",shape:"dot"},pr_ready_for_review:{label:"Ready for review",color:"#3b82f6",shape:"dot"},review_submitted:{label:"Review",color:"#22c55e",shape:"triangle"},review_comment:{label:"Review comment",color:"#f59e0b",shape:"dot"},pr_comment:{label:"PR comment",color:"#a78bfa",shape:"square"},commit_pushed:{label:"Commit",color:"#6b7280",shape:"diamond"}},oh={awaiting_your_review:{label:"Awaiting your review",color:"#3b82f6",myTurn:!0},your_pr_new_comments:{label:"Your PR · new comments",color:"#22c55e",myTurn:!0},ci_failing:{label:"CI failing",color:"#ef4444",myTurn:!1},merge_conflicts:{label:"Merge conflicts",color:"#f97316",myTurn:!1},approved_ready:{label:"Approved · ready to merge",color:"#22c55e",myTurn:!1},stalled:{label:"Stalled",color:"#eab308",myTurn:!1},untouched_threads:{label:"Untouched threads",color:"#f59e0b",myTurn:!1},in_progress:{label:"In progress",color:"#9ca3af",myTurn:!1}},Mp={requested:{label:"Review requested",title:"A review was requested from you on this PR"},authored:{label:"You authored",title:"You opened this PR"},merged:{label:"You merged",title:"You merged this PR"},reviewed:{label:"You reviewed",title:"You previously reviewed this PR"},commented:{label:"You commented",title:"You previously commented on this PR"}},qs={coderabbit:{label:"CodeRabbit",color:"#ff7a45"},greptile:{label:"Greptile",color:"#16a34a"},copilot:{label:"Copilot",color:"#8957e5"},qodo:{label:"Qodo",color:"#7c3aed"},sourcery:{label:"Sourcery",color:"#0d9488"},bito:{label:"Bito",color:"#e11d48"},ellipsis:{label:"Ellipsis",color:"#64748b"},korbit:{label:"Korbit",color:"#2563eb"},baz:{label:"Baz",color:"#db2777"},graphite:{label:"Graphite",color:"#475569"},cursor:{label:"Cursor",color:"#334155"},devin:{label:"Devin",color:"#0891b2"},entelligence:{label:"Entelligence",color:"#ca8a04"},in_house:{label:"In-house AI",color:"#6b7280"},pierre:{label:"Pierre · Claude",color:"#d97757"}};function an(e){return qs[e]}function ih(e){const s=Xm(e==null?void 0:e.githubLogin);return s?{kind:s,...qs[s]}:null}const Ux=new Set(["awaiting_your_review","your_pr_new_comments","ci_failing","merge_conflicts","untouched_threads"]);function Kx(e){return e.isStalled||e.threadCounts.untouched>0||Ux.has(e.reasonTag)}const ur={success:{label:"CI passing",color:"#22c55e"},failure:{label:"CI failing",color:"#ef4444"},error:{label:"CI error",color:"#ef4444"},pending:{label:"CI running",color:"#eab308"},expected:{label:"CI expected",color:"#9ca3af"},unknown:null},Hx={success:{label:"passed",color:"#22c55e",icon:"✓"},failure:{label:"failed",color:"#ef4444",icon:"✕"},pending:{label:"running",color:"#eab308",icon:"•"},neutral:{label:"neutral",color:"#9ca3af",icon:"–"},skipped:{label:"skipped",color:"#9ca3af",icon:"⤼"},error:{label:"error",color:"#ef4444",icon:"!"},unknown:{label:"unknown",color:"#9ca3af",icon:"?"}};function Yo(e,s){return e==="conflicting"||s==="dirty"?"conflicts":s==="behind"?"behind":s==="unstable"?"unstable":null}function ft(e,s){return e?e.displayName||e.githubLogin:s==null?"unknown":`user ${s}`}function Du(e){return`https://github.com/${encodeURIComponent(e)}`}function ch(e,s){const a=s?`@${s} `:"",o=(e??"").trim();return o===""?a:`${o.split(`
25
+ `+h.stack}return{value:t,source:r,stack:f,digest:null}}function pc(t,r,l){return{value:t,source:null,stack:l??null,digest:r??null}}function mc(t,r){try{console.error(r.value)}catch(l){setTimeout(function(){throw l})}}var Sg=typeof WeakMap=="function"?WeakMap:Map;function Nf(t,r,l){l=Ir(-1,l),l.tag=3,l.payload={element:null};var c=r.value;return l.callback=function(){co||(co=!0,Tc=c),mc(t,r)},l}function Sf(t,r,l){l=Ir(-1,l),l.tag=3;var c=t.type.getDerivedStateFromError;if(typeof c=="function"){var f=r.value;l.payload=function(){return c(f)},l.callback=function(){mc(t,r)}}var h=t.stateNode;return h!==null&&typeof h.componentDidCatch=="function"&&(l.callback=function(){mc(t,r),typeof c!="function"&&(Yr===null?Yr=new Set([this]):Yr.add(this));var k=r.stack;this.componentDidCatch(r.value,{componentStack:k!==null?k:""})}),l}function Cf(t,r,l){var c=t.pingCache;if(c===null){c=t.pingCache=new Sg;var f=new Set;c.set(r,f)}else f=c.get(r),f===void 0&&(f=new Set,c.set(r,f));f.has(l)||(f.add(l),t=Dg.bind(null,t,r,l),r.then(t,t))}function Rf(t){do{var r;if((r=t.tag===13)&&(r=t.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return t;t=t.return}while(t!==null);return null}function If(t,r,l,c,f){return(t.mode&1)===0?(t===r?t.flags|=65536:(t.flags|=128,l.flags|=131072,l.flags&=-52805,l.tag===1&&(l.alternate===null?l.tag=17:(r=Ir(-1,1),r.tag=2,Qr(l,r,1))),l.lanes|=1),t):(t.flags|=65536,t.lanes=f,t)}var Cg=b.ReactCurrentOwner,en=!1;function Wt(t,r,l,c){r.child=t===null?Vd(r,null,l,c):da(r,t.child,l,c)}function Tf(t,r,l,c,f){l=l.render;var h=r.ref;return pa(r,f),c=ac(t,r,l,c,h,f),l=lc(),t!==null&&!en?(r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~f,Tr(t,r,f)):(nt&&l&&qi(r),r.flags|=1,Wt(t,r,c,f),r.child)}function Ef(t,r,l,c,f){if(t===null){var h=l.type;return typeof h=="function"&&!Lc(h)&&h.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(r.tag=15,r.type=h,Pf(t,r,h,c,f)):(t=go(l.type,null,c,r,r.mode,f),t.ref=r.ref,t.return=r,r.child=t)}if(h=t.child,(t.lanes&f)===0){var k=h.memoizedProps;if(l=l.compare,l=l!==null?l:La,l(k,c)&&t.ref===r.ref)return Tr(t,r,f)}return r.flags|=1,t=es(h,c),t.ref=r.ref,t.return=r,r.child=t}function Pf(t,r,l,c,f){if(t!==null){var h=t.memoizedProps;if(La(h,c)&&t.ref===r.ref)if(en=!1,r.pendingProps=c=h,(t.lanes&f)!==0)(t.flags&131072)!==0&&(en=!0);else return r.lanes=t.lanes,Tr(t,r,f)}return hc(t,r,l,c,f)}function Af(t,r,l){var c=r.pendingProps,f=c.children,h=t!==null?t.memoizedState:null;if(c.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},Xe(xa,gn),gn|=l;else{if((l&1073741824)===0)return t=h!==null?h.baseLanes|l:l,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:t,cachePool:null,transitions:null},r.updateQueue=null,Xe(xa,gn),gn|=t,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=h!==null?h.baseLanes:l,Xe(xa,gn),gn|=c}else h!==null?(c=h.baseLanes|l,r.memoizedState=null):c=l,Xe(xa,gn),gn|=c;return Wt(t,r,f,l),r.child}function $f(t,r){var l=r.ref;(t===null&&l!==null||t!==null&&t.ref!==l)&&(r.flags|=512,r.flags|=2097152)}function hc(t,r,l,c,f){var h=Zt(l)?vs:Bt.current;return h=oa(r,h),pa(r,f),l=ac(t,r,l,c,h,f),c=lc(),t!==null&&!en?(r.updateQueue=t.updateQueue,r.flags&=-2053,t.lanes&=~f,Tr(t,r,f)):(nt&&c&&qi(r),r.flags|=1,Wt(t,r,l,f),r.child)}function Mf(t,r,l,c,f){if(Zt(l)){var h=!0;Bl(r)}else h=!1;if(pa(r,f),r.stateNode===null)so(t,r),kf(r,l,c),fc(r,l,c,f),c=!0;else if(t===null){var k=r.stateNode,M=r.memoizedProps;k.props=M;var D=k.context,G=l.contextType;typeof G=="object"&&G!==null?G=Rn(G):(G=Zt(l)?vs:Bt.current,G=oa(r,G));var ue=l.getDerivedStateFromProps,fe=typeof ue=="function"||typeof k.getSnapshotBeforeUpdate=="function";fe||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(M!==c||D!==G)&&jf(r,k,c,G),Vr=!1;var ie=r.memoizedState;k.state=ie,Gl(r,c,k,f),D=r.memoizedState,M!==c||ie!==D||Jt.current||Vr?(typeof ue=="function"&&(dc(r,l,ue,c),D=r.memoizedState),(M=Vr||wf(r,l,M,c,ie,D,G))?(fe||typeof k.UNSAFE_componentWillMount!="function"&&typeof k.componentWillMount!="function"||(typeof k.componentWillMount=="function"&&k.componentWillMount(),typeof k.UNSAFE_componentWillMount=="function"&&k.UNSAFE_componentWillMount()),typeof k.componentDidMount=="function"&&(r.flags|=4194308)):(typeof k.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=c,r.memoizedState=D),k.props=c,k.state=D,k.context=G,c=M):(typeof k.componentDidMount=="function"&&(r.flags|=4194308),c=!1)}else{k=r.stateNode,Gd(t,r),M=r.memoizedProps,G=r.type===r.elementType?M:Wn(r.type,M),k.props=G,fe=r.pendingProps,ie=k.context,D=l.contextType,typeof D=="object"&&D!==null?D=Rn(D):(D=Zt(l)?vs:Bt.current,D=oa(r,D));var be=l.getDerivedStateFromProps;(ue=typeof be=="function"||typeof k.getSnapshotBeforeUpdate=="function")||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(M!==fe||ie!==D)&&jf(r,k,c,D),Vr=!1,ie=r.memoizedState,k.state=ie,Gl(r,c,k,f);var Ne=r.memoizedState;M!==fe||ie!==Ne||Jt.current||Vr?(typeof be=="function"&&(dc(r,l,be,c),Ne=r.memoizedState),(G=Vr||wf(r,l,G,c,ie,Ne,D)||!1)?(ue||typeof k.UNSAFE_componentWillUpdate!="function"&&typeof k.componentWillUpdate!="function"||(typeof k.componentWillUpdate=="function"&&k.componentWillUpdate(c,Ne,D),typeof k.UNSAFE_componentWillUpdate=="function"&&k.UNSAFE_componentWillUpdate(c,Ne,D)),typeof k.componentDidUpdate=="function"&&(r.flags|=4),typeof k.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof k.componentDidUpdate!="function"||M===t.memoizedProps&&ie===t.memoizedState||(r.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||M===t.memoizedProps&&ie===t.memoizedState||(r.flags|=1024),r.memoizedProps=c,r.memoizedState=Ne),k.props=c,k.state=Ne,k.context=D,c=G):(typeof k.componentDidUpdate!="function"||M===t.memoizedProps&&ie===t.memoizedState||(r.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||M===t.memoizedProps&&ie===t.memoizedState||(r.flags|=1024),c=!1)}return gc(t,r,l,c,h,f)}function gc(t,r,l,c,f,h){$f(t,r);var k=(r.flags&128)!==0;if(!c&&!k)return f&&Od(r,l,!1),Tr(t,r,h);c=r.stateNode,Cg.current=r;var M=k&&typeof l.getDerivedStateFromError!="function"?null:c.render();return r.flags|=1,t!==null&&k?(r.child=da(r,t.child,null,h),r.child=da(r,null,M,h)):Wt(t,r,M,h),r.memoizedState=c.state,f&&Od(r,l,!0),r.child}function Ff(t){var r=t.stateNode;r.pendingContext?Ld(t,r.pendingContext,r.pendingContext!==r.context):r.context&&Ld(t,r.context,!1),Zi(t,r.containerInfo)}function Lf(t,r,l,c,f){return ua(),Wi(f),r.flags|=256,Wt(t,r,l,c),r.child}var xc={dehydrated:null,treeContext:null,retryLane:0};function yc(t){return{baseLanes:t,cachePool:null,transitions:null}}function _f(t,r,l){var c=r.pendingProps,f=lt.current,h=!1,k=(r.flags&128)!==0,M;if((M=k)||(M=t!==null&&t.memoizedState===null?!1:(f&2)!==0),M?(h=!0,r.flags&=-129):(t===null||t.memoizedState!==null)&&(f|=1),Xe(lt,f&1),t===null)return Hi(r),t=r.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((r.mode&1)===0?r.lanes=1:t.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(k=c.children,t=c.fallback,h?(c=r.mode,h=r.child,k={mode:"hidden",children:k},(c&1)===0&&h!==null?(h.childLanes=0,h.pendingProps=k):h=xo(k,c,0,null),t=Ts(t,c,l,null),h.return=r,t.return=r,h.sibling=t,r.child=h,r.child.memoizedState=yc(l),r.memoizedState=xc,t):vc(r,k));if(f=t.memoizedState,f!==null&&(M=f.dehydrated,M!==null))return Rg(t,r,k,c,M,f,l);if(h){h=c.fallback,k=r.mode,f=t.child,M=f.sibling;var D={mode:"hidden",children:c.children};return(k&1)===0&&r.child!==f?(c=r.child,c.childLanes=0,c.pendingProps=D,r.deletions=null):(c=es(f,D),c.subtreeFlags=f.subtreeFlags&14680064),M!==null?h=es(M,h):(h=Ts(h,k,l,null),h.flags|=2),h.return=r,c.return=r,c.sibling=h,r.child=c,c=h,h=r.child,k=t.child.memoizedState,k=k===null?yc(l):{baseLanes:k.baseLanes|l,cachePool:null,transitions:k.transitions},h.memoizedState=k,h.childLanes=t.childLanes&~l,r.memoizedState=xc,c}return h=t.child,t=h.sibling,c=es(h,{mode:"visible",children:c.children}),(r.mode&1)===0&&(c.lanes=l),c.return=r,c.sibling=null,t!==null&&(l=r.deletions,l===null?(r.deletions=[t],r.flags|=16):l.push(t)),r.child=c,r.memoizedState=null,c}function vc(t,r){return r=xo({mode:"visible",children:r},t.mode,0,null),r.return=t,t.child=r}function ro(t,r,l,c){return c!==null&&Wi(c),da(r,t.child,null,l),t=vc(r,r.pendingProps.children),t.flags|=2,r.memoizedState=null,t}function Rg(t,r,l,c,f,h,k){if(l)return r.flags&256?(r.flags&=-257,c=pc(Error(a(422))),ro(t,r,k,c)):r.memoizedState!==null?(r.child=t.child,r.flags|=128,null):(h=c.fallback,f=r.mode,c=xo({mode:"visible",children:c.children},f,0,null),h=Ts(h,f,k,null),h.flags|=2,c.return=r,h.return=r,c.sibling=h,r.child=c,(r.mode&1)!==0&&da(r,t.child,null,k),r.child.memoizedState=yc(k),r.memoizedState=xc,h);if((r.mode&1)===0)return ro(t,r,k,null);if(f.data==="$!"){if(c=f.nextSibling&&f.nextSibling.dataset,c)var M=c.dgst;return c=M,h=Error(a(419)),c=pc(h,c,void 0),ro(t,r,k,c)}if(M=(k&t.childLanes)!==0,en||M){if(c=It,c!==null){switch(k&-k){case 4:f=2;break;case 16:f=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:f=32;break;case 536870912:f=268435456;break;default:f=0}f=(f&(c.suspendedLanes|k))!==0?0:f,f!==0&&f!==h.retryLane&&(h.retryLane=f,Rr(t,f),Gn(c,t,f,-1))}return Fc(),c=pc(Error(a(421))),ro(t,r,k,c)}return f.data==="$?"?(r.flags|=128,r.child=t.child,r=Bg.bind(null,t),f._reactRetry=r,null):(t=h.treeContext,hn=Ur(f.nextSibling),mn=r,nt=!0,Hn=null,t!==null&&(Sn[Cn++]=Sr,Sn[Cn++]=Cr,Sn[Cn++]=bs,Sr=t.id,Cr=t.overflow,bs=r),r=vc(r,c.children),r.flags|=4096,r)}function Of(t,r,l){t.lanes|=r;var c=t.alternate;c!==null&&(c.lanes|=r),Yi(t.return,r,l)}function bc(t,r,l,c,f){var h=t.memoizedState;h===null?t.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:c,tail:l,tailMode:f}:(h.isBackwards=r,h.rendering=null,h.renderingStartTime=0,h.last=c,h.tail=l,h.tailMode=f)}function Df(t,r,l){var c=r.pendingProps,f=c.revealOrder,h=c.tail;if(Wt(t,r,c.children,l),c=lt.current,(c&2)!==0)c=c&1|2,r.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=r.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Of(t,l,r);else if(t.tag===19)Of(t,l,r);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===r)break e;for(;t.sibling===null;){if(t.return===null||t.return===r)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}c&=1}if(Xe(lt,c),(r.mode&1)===0)r.memoizedState=null;else switch(f){case"forwards":for(l=r.child,f=null;l!==null;)t=l.alternate,t!==null&&Yl(t)===null&&(f=l),l=l.sibling;l=f,l===null?(f=r.child,r.child=null):(f=l.sibling,l.sibling=null),bc(r,!1,f,l,h);break;case"backwards":for(l=null,f=r.child,r.child=null;f!==null;){if(t=f.alternate,t!==null&&Yl(t)===null){r.child=f;break}t=f.sibling,f.sibling=l,l=f,f=t}bc(r,!0,l,null,h);break;case"together":bc(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function so(t,r){(r.mode&1)===0&&t!==null&&(t.alternate=null,r.alternate=null,r.flags|=2)}function Tr(t,r,l){if(t!==null&&(r.dependencies=t.dependencies),Ss|=r.lanes,(l&r.childLanes)===0)return null;if(t!==null&&r.child!==t.child)throw Error(a(153));if(r.child!==null){for(t=r.child,l=es(t,t.pendingProps),r.child=l,l.return=r;t.sibling!==null;)t=t.sibling,l=l.sibling=es(t,t.pendingProps),l.return=r;l.sibling=null}return r.child}function Ig(t,r,l){switch(r.tag){case 3:Ff(r),ua();break;case 5:Jd(r);break;case 1:Zt(r.type)&&Bl(r);break;case 4:Zi(r,r.stateNode.containerInfo);break;case 10:var c=r.type._context,f=r.memoizedProps.value;Xe(Wl,c._currentValue),c._currentValue=f;break;case 13:if(c=r.memoizedState,c!==null)return c.dehydrated!==null?(Xe(lt,lt.current&1),r.flags|=128,null):(l&r.child.childLanes)!==0?_f(t,r,l):(Xe(lt,lt.current&1),t=Tr(t,r,l),t!==null?t.sibling:null);Xe(lt,lt.current&1);break;case 19:if(c=(l&r.childLanes)!==0,(t.flags&128)!==0){if(c)return Df(t,r,l);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Xe(lt,lt.current),c)break;return null;case 22:case 23:return r.lanes=0,Af(t,r,l)}return Tr(t,r,l)}var Bf,wc,zf,qf;Bf=function(t,r){for(var l=r.child;l!==null;){if(l.tag===5||l.tag===6)t.appendChild(l.stateNode);else if(l.tag!==4&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===r)break;for(;l.sibling===null;){if(l.return===null||l.return===r)return;l=l.return}l.sibling.return=l.return,l=l.sibling}},wc=function(){},zf=function(t,r,l,c){var f=t.memoizedProps;if(f!==c){t=r.stateNode,js(sr.current);var h=null;switch(l){case"input":f=Fn(t,f),c=Fn(t,c),h=[];break;case"select":f=K({},f,{value:void 0}),c=K({},c,{value:void 0}),h=[];break;case"textarea":f=bn(t,f),c=bn(t,c),h=[];break;default:typeof f.onClick!="function"&&typeof c.onClick=="function"&&(t.onclick=_l)}Jn(l,c);var k;l=null;for(G in f)if(!c.hasOwnProperty(G)&&f.hasOwnProperty(G)&&f[G]!=null)if(G==="style"){var M=f[G];for(k in M)M.hasOwnProperty(k)&&(l||(l={}),l[k]="")}else G!=="dangerouslySetInnerHTML"&&G!=="children"&&G!=="suppressContentEditableWarning"&&G!=="suppressHydrationWarning"&&G!=="autoFocus"&&(i.hasOwnProperty(G)?h||(h=[]):(h=h||[]).push(G,null));for(G in c){var D=c[G];if(M=f!=null?f[G]:void 0,c.hasOwnProperty(G)&&D!==M&&(D!=null||M!=null))if(G==="style")if(M){for(k in M)!M.hasOwnProperty(k)||D&&D.hasOwnProperty(k)||(l||(l={}),l[k]="");for(k in D)D.hasOwnProperty(k)&&M[k]!==D[k]&&(l||(l={}),l[k]=D[k])}else l||(h||(h=[]),h.push(G,l)),l=D;else G==="dangerouslySetInnerHTML"?(D=D?D.__html:void 0,M=M?M.__html:void 0,D!=null&&M!==D&&(h=h||[]).push(G,D)):G==="children"?typeof D!="string"&&typeof D!="number"||(h=h||[]).push(G,""+D):G!=="suppressContentEditableWarning"&&G!=="suppressHydrationWarning"&&(i.hasOwnProperty(G)?(D!=null&&G==="onScroll"&&Ze("scroll",t),h||M===D||(h=[])):(h=h||[]).push(G,D))}l&&(h=h||[]).push("style",l);var G=h;(r.updateQueue=G)&&(r.flags|=4)}},qf=function(t,r,l,c){l!==c&&(r.flags|=4)};function Xa(t,r){if(!nt)switch(t.tailMode){case"hidden":r=t.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?t.tail=null:l.sibling=null;break;case"collapsed":l=t.tail;for(var c=null;l!==null;)l.alternate!==null&&(c=l),l=l.sibling;c===null?r||t.tail===null?t.tail=null:t.tail.sibling=null:c.sibling=null}}function qt(t){var r=t.alternate!==null&&t.alternate.child===t.child,l=0,c=0;if(r)for(var f=t.child;f!==null;)l|=f.lanes|f.childLanes,c|=f.subtreeFlags&14680064,c|=f.flags&14680064,f.return=t,f=f.sibling;else for(f=t.child;f!==null;)l|=f.lanes|f.childLanes,c|=f.subtreeFlags,c|=f.flags,f.return=t,f=f.sibling;return t.subtreeFlags|=c,t.childLanes=l,r}function Tg(t,r,l){var c=r.pendingProps;switch(Ui(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return qt(r),null;case 1:return Zt(r.type)&&Dl(),qt(r),null;case 3:return c=r.stateNode,ma(),et(Jt),et(Bt),nc(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(t===null||t.child===null)&&(Kl(r)?r.flags|=4:t===null||t.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Hn!==null&&(Ac(Hn),Hn=null))),wc(t,r),qt(r),null;case 5:ec(r);var f=js(Wa.current);if(l=r.type,t!==null&&r.stateNode!=null)zf(t,r,l,c,f),t.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!c){if(r.stateNode===null)throw Error(a(166));return qt(r),null}if(t=js(sr.current),Kl(r)){c=r.stateNode,l=r.type;var h=r.memoizedProps;switch(c[rr]=r,c[za]=h,t=(r.mode&1)!==0,l){case"dialog":Ze("cancel",c),Ze("close",c);break;case"iframe":case"object":case"embed":Ze("load",c);break;case"video":case"audio":for(f=0;f<Oa.length;f++)Ze(Oa[f],c);break;case"source":Ze("error",c);break;case"img":case"image":case"link":Ze("error",c),Ze("load",c);break;case"details":Ze("toggle",c);break;case"input":_t(c,h),Ze("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!h.multiple},Ze("invalid",c);break;case"textarea":re(c,h),Ze("invalid",c)}Jn(l,h),f=null;for(var k in h)if(h.hasOwnProperty(k)){var M=h[k];k==="children"?typeof M=="string"?c.textContent!==M&&(h.suppressHydrationWarning!==!0&&Ll(c.textContent,M,t),f=["children",M]):typeof M=="number"&&c.textContent!==""+M&&(h.suppressHydrationWarning!==!0&&Ll(c.textContent,M,t),f=["children",""+M]):i.hasOwnProperty(k)&&M!=null&&k==="onScroll"&&Ze("scroll",c)}switch(l){case"input":vn(c),pr(c,h,!0);break;case"textarea":vn(c),it(c);break;case"select":case"option":break;default:typeof h.onClick=="function"&&(c.onclick=_l)}c=f,r.updateQueue=c,c!==null&&(r.flags|=4)}else{k=f.nodeType===9?f:f.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=at(l)),t==="http://www.w3.org/1999/xhtml"?l==="script"?(t=k.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof c.is=="string"?t=k.createElement(l,{is:c.is}):(t=k.createElement(l),l==="select"&&(k=t,c.multiple?k.multiple=!0:c.size&&(k.size=c.size))):t=k.createElementNS(t,l),t[rr]=r,t[za]=c,Bf(t,r,!1,!1),r.stateNode=t;e:{switch(k=Ks(l,c),l){case"dialog":Ze("cancel",t),Ze("close",t),f=c;break;case"iframe":case"object":case"embed":Ze("load",t),f=c;break;case"video":case"audio":for(f=0;f<Oa.length;f++)Ze(Oa[f],t);f=c;break;case"source":Ze("error",t),f=c;break;case"img":case"image":case"link":Ze("error",t),Ze("load",t),f=c;break;case"details":Ze("toggle",t),f=c;break;case"input":_t(t,c),f=Fn(t,c),Ze("invalid",t);break;case"option":f=c;break;case"select":t._wrapperState={wasMultiple:!!c.multiple},f=K({},c,{value:void 0}),Ze("invalid",t);break;case"textarea":re(t,c),f=bn(t,c),Ze("invalid",t);break;default:f=c}Jn(l,f),M=f;for(h in M)if(M.hasOwnProperty(h)){var D=M[h];h==="style"?wl(t,D):h==="dangerouslySetInnerHTML"?(D=D?D.__html:void 0,D!=null&&on(t,D)):h==="children"?typeof D=="string"?(l!=="textarea"||D!=="")&&os(t,D):typeof D=="number"&&os(t,""+D):h!=="suppressContentEditableWarning"&&h!=="suppressHydrationWarning"&&h!=="autoFocus"&&(i.hasOwnProperty(h)?D!=null&&h==="onScroll"&&Ze("scroll",t):D!=null&&N(t,h,D,k))}switch(l){case"input":vn(t),pr(t,c,!1);break;case"textarea":vn(t),it(t);break;case"option":c.value!=null&&t.setAttribute("value",""+st(c.value));break;case"select":t.multiple=!!c.multiple,h=c.value,h!=null?_n(t,!!c.multiple,h,!1):c.defaultValue!=null&&_n(t,!!c.multiple,c.defaultValue,!0);break;default:typeof f.onClick=="function"&&(t.onclick=_l)}switch(l){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}}c&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return qt(r),null;case 6:if(t&&r.stateNode!=null)qf(t,r,t.memoizedProps,c);else{if(typeof c!="string"&&r.stateNode===null)throw Error(a(166));if(l=js(Wa.current),js(sr.current),Kl(r)){if(c=r.stateNode,l=r.memoizedProps,c[rr]=r,(h=c.nodeValue!==l)&&(t=mn,t!==null))switch(t.tag){case 3:Ll(c.nodeValue,l,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&Ll(c.nodeValue,l,(t.mode&1)!==0)}h&&(r.flags|=4)}else c=(l.nodeType===9?l:l.ownerDocument).createTextNode(c),c[rr]=r,r.stateNode=c}return qt(r),null;case 13:if(et(lt),c=r.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(nt&&hn!==null&&(r.mode&1)!==0&&(r.flags&128)===0)Kd(),ua(),r.flags|=98560,h=!1;else if(h=Kl(r),c!==null&&c.dehydrated!==null){if(t===null){if(!h)throw Error(a(318));if(h=r.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(a(317));h[rr]=r}else ua(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;qt(r),h=!1}else Hn!==null&&(Ac(Hn),Hn=null),h=!0;if(!h)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=l,r):(c=c!==null,c!==(t!==null&&t.memoizedState!==null)&&c&&(r.child.flags|=8192,(r.mode&1)!==0&&(t===null||(lt.current&1)!==0?vt===0&&(vt=3):Fc())),r.updateQueue!==null&&(r.flags|=4),qt(r),null);case 4:return ma(),wc(t,r),t===null&&Da(r.stateNode.containerInfo),qt(r),null;case 10:return Gi(r.type._context),qt(r),null;case 17:return Zt(r.type)&&Dl(),qt(r),null;case 19:if(et(lt),h=r.memoizedState,h===null)return qt(r),null;if(c=(r.flags&128)!==0,k=h.rendering,k===null)if(c)Xa(h,!1);else{if(vt!==0||t!==null&&(t.flags&128)!==0)for(t=r.child;t!==null;){if(k=Yl(t),k!==null){for(r.flags|=128,Xa(h,!1),c=k.updateQueue,c!==null&&(r.updateQueue=c,r.flags|=4),r.subtreeFlags=0,c=l,l=r.child;l!==null;)h=l,t=c,h.flags&=14680066,k=h.alternate,k===null?(h.childLanes=0,h.lanes=t,h.child=null,h.subtreeFlags=0,h.memoizedProps=null,h.memoizedState=null,h.updateQueue=null,h.dependencies=null,h.stateNode=null):(h.childLanes=k.childLanes,h.lanes=k.lanes,h.child=k.child,h.subtreeFlags=0,h.deletions=null,h.memoizedProps=k.memoizedProps,h.memoizedState=k.memoizedState,h.updateQueue=k.updateQueue,h.type=k.type,t=k.dependencies,h.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),l=l.sibling;return Xe(lt,lt.current&1|2),r.child}t=t.sibling}h.tail!==null&&Je()>ya&&(r.flags|=128,c=!0,Xa(h,!1),r.lanes=4194304)}else{if(!c)if(t=Yl(k),t!==null){if(r.flags|=128,c=!0,l=t.updateQueue,l!==null&&(r.updateQueue=l,r.flags|=4),Xa(h,!0),h.tail===null&&h.tailMode==="hidden"&&!k.alternate&&!nt)return qt(r),null}else 2*Je()-h.renderingStartTime>ya&&l!==1073741824&&(r.flags|=128,c=!0,Xa(h,!1),r.lanes=4194304);h.isBackwards?(k.sibling=r.child,r.child=k):(l=h.last,l!==null?l.sibling=k:r.child=k,h.last=k)}return h.tail!==null?(r=h.tail,h.rendering=r,h.tail=r.sibling,h.renderingStartTime=Je(),r.sibling=null,l=lt.current,Xe(lt,c?l&1|2:l&1),r):(qt(r),null);case 22:case 23:return Mc(),c=r.memoizedState!==null,t!==null&&t.memoizedState!==null!==c&&(r.flags|=8192),c&&(r.mode&1)!==0?(gn&1073741824)!==0&&(qt(r),r.subtreeFlags&6&&(r.flags|=8192)):qt(r),null;case 24:return null;case 25:return null}throw Error(a(156,r.tag))}function Eg(t,r){switch(Ui(r),r.tag){case 1:return Zt(r.type)&&Dl(),t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 3:return ma(),et(Jt),et(Bt),nc(),t=r.flags,(t&65536)!==0&&(t&128)===0?(r.flags=t&-65537|128,r):null;case 5:return ec(r),null;case 13:if(et(lt),t=r.memoizedState,t!==null&&t.dehydrated!==null){if(r.alternate===null)throw Error(a(340));ua()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 19:return et(lt),null;case 4:return ma(),null;case 10:return Gi(r.type._context),null;case 22:case 23:return Mc(),null;case 24:return null;default:return null}}var ao=!1,Ut=!1,Pg=typeof WeakSet=="function"?WeakSet:Set,ke=null;function ga(t,r){var l=t.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(c){ct(t,r,c)}else l.current=null}function kc(t,r,l){try{l()}catch(c){ct(t,r,c)}}var Uf=!1;function Ag(t,r){if(Mi=Sl,t=bd(),Ci(t)){if("selectionStart"in t)var l={start:t.selectionStart,end:t.selectionEnd};else e:{l=(l=t.ownerDocument)&&l.defaultView||window;var c=l.getSelection&&l.getSelection();if(c&&c.rangeCount!==0){l=c.anchorNode;var f=c.anchorOffset,h=c.focusNode;c=c.focusOffset;try{l.nodeType,h.nodeType}catch{l=null;break e}var k=0,M=-1,D=-1,G=0,ue=0,fe=t,ie=null;t:for(;;){for(var be;fe!==l||f!==0&&fe.nodeType!==3||(M=k+f),fe!==h||c!==0&&fe.nodeType!==3||(D=k+c),fe.nodeType===3&&(k+=fe.nodeValue.length),(be=fe.firstChild)!==null;)ie=fe,fe=be;for(;;){if(fe===t)break t;if(ie===l&&++G===f&&(M=k),ie===h&&++ue===c&&(D=k),(be=fe.nextSibling)!==null)break;fe=ie,ie=fe.parentNode}fe=be}l=M===-1||D===-1?null:{start:M,end:D}}else l=null}l=l||{start:0,end:0}}else l=null;for(Fi={focusedElem:t,selectionRange:l},Sl=!1,ke=r;ke!==null;)if(r=ke,t=r.child,(r.subtreeFlags&1028)!==0&&t!==null)t.return=r,ke=t;else for(;ke!==null;){r=ke;try{var Ne=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(Ne!==null){var Se=Ne.memoizedProps,ut=Ne.memoizedState,U=r.stateNode,z=U.getSnapshotBeforeUpdate(r.elementType===r.type?Se:Wn(r.type,Se),ut);U.__reactInternalSnapshotBeforeUpdate=z}break;case 3:var V=r.stateNode.containerInfo;V.nodeType===1?V.textContent="":V.nodeType===9&&V.documentElement&&V.removeChild(V.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(a(163))}}catch(pe){ct(r,r.return,pe)}if(t=r.sibling,t!==null){t.return=r.return,ke=t;break}ke=r.return}return Ne=Uf,Uf=!1,Ne}function Ja(t,r,l){var c=r.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var f=c=c.next;do{if((f.tag&t)===t){var h=f.destroy;f.destroy=void 0,h!==void 0&&kc(r,l,h)}f=f.next}while(f!==c)}}function lo(t,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&t)===t){var c=l.create;l.destroy=c()}l=l.next}while(l!==r)}}function jc(t){var r=t.ref;if(r!==null){var l=t.stateNode;switch(t.tag){case 5:t=l;break;default:t=l}typeof r=="function"?r(t):r.current=t}}function Kf(t){var r=t.alternate;r!==null&&(t.alternate=null,Kf(r)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(r=t.stateNode,r!==null&&(delete r[rr],delete r[za],delete r[Di],delete r[mg],delete r[hg])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function Hf(t){return t.tag===5||t.tag===3||t.tag===4}function Wf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Hf(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Nc(t,r,l){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?l.nodeType===8?l.parentNode.insertBefore(t,r):l.insertBefore(t,r):(l.nodeType===8?(r=l.parentNode,r.insertBefore(t,l)):(r=l,r.appendChild(t)),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=_l));else if(c!==4&&(t=t.child,t!==null))for(Nc(t,r,l),t=t.sibling;t!==null;)Nc(t,r,l),t=t.sibling}function Sc(t,r,l){var c=t.tag;if(c===5||c===6)t=t.stateNode,r?l.insertBefore(t,r):l.appendChild(t);else if(c!==4&&(t=t.child,t!==null))for(Sc(t,r,l),t=t.sibling;t!==null;)Sc(t,r,l),t=t.sibling}var Mt=null,Vn=!1;function Gr(t,r,l){for(l=l.child;l!==null;)Vf(t,r,l),l=l.sibling}function Vf(t,r,l){if(A&&typeof A.onCommitFiberUnmount=="function")try{A.onCommitFiberUnmount(jn,l)}catch{}switch(l.tag){case 5:Ut||ga(l,r);case 6:var c=Mt,f=Vn;Mt=null,Gr(t,r,l),Mt=c,Vn=f,Mt!==null&&(Vn?(t=Mt,l=l.stateNode,t.nodeType===8?t.parentNode.removeChild(l):t.removeChild(l)):Mt.removeChild(l.stateNode));break;case 18:Mt!==null&&(Vn?(t=Mt,l=l.stateNode,t.nodeType===8?Oi(t.parentNode,l):t.nodeType===1&&Oi(t,l),Un(t)):Oi(Mt,l.stateNode));break;case 4:c=Mt,f=Vn,Mt=l.stateNode.containerInfo,Vn=!0,Gr(t,r,l),Mt=c,Vn=f;break;case 0:case 11:case 14:case 15:if(!Ut&&(c=l.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){f=c=c.next;do{var h=f,k=h.destroy;h=h.tag,k!==void 0&&((h&2)!==0||(h&4)!==0)&&kc(l,r,k),f=f.next}while(f!==c)}Gr(t,r,l);break;case 1:if(!Ut&&(ga(l,r),c=l.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=l.memoizedProps,c.state=l.memoizedState,c.componentWillUnmount()}catch(M){ct(l,r,M)}Gr(t,r,l);break;case 21:Gr(t,r,l);break;case 22:l.mode&1?(Ut=(c=Ut)||l.memoizedState!==null,Gr(t,r,l),Ut=c):Gr(t,r,l);break;default:Gr(t,r,l)}}function Qf(t){var r=t.updateQueue;if(r!==null){t.updateQueue=null;var l=t.stateNode;l===null&&(l=t.stateNode=new Pg),r.forEach(function(c){var f=zg.bind(null,t,c);l.has(c)||(l.add(c),c.then(f,f))})}}function Qn(t,r){var l=r.deletions;if(l!==null)for(var c=0;c<l.length;c++){var f=l[c];try{var h=t,k=r,M=k;e:for(;M!==null;){switch(M.tag){case 5:Mt=M.stateNode,Vn=!1;break e;case 3:Mt=M.stateNode.containerInfo,Vn=!0;break e;case 4:Mt=M.stateNode.containerInfo,Vn=!0;break e}M=M.return}if(Mt===null)throw Error(a(160));Vf(h,k,f),Mt=null,Vn=!1;var D=f.alternate;D!==null&&(D.return=null),f.return=null}catch(G){ct(f,r,G)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)Gf(r,t),r=r.sibling}function Gf(t,r){var l=t.alternate,c=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(Qn(r,t),lr(t),c&4){try{Ja(3,t,t.return),lo(3,t)}catch(Se){ct(t,t.return,Se)}try{Ja(5,t,t.return)}catch(Se){ct(t,t.return,Se)}}break;case 1:Qn(r,t),lr(t),c&512&&l!==null&&ga(l,l.return);break;case 5:if(Qn(r,t),lr(t),c&512&&l!==null&&ga(l,l.return),t.flags&32){var f=t.stateNode;try{os(f,"")}catch(Se){ct(t,t.return,Se)}}if(c&4&&(f=t.stateNode,f!=null)){var h=t.memoizedProps,k=l!==null?l.memoizedProps:h,M=t.type,D=t.updateQueue;if(t.updateQueue=null,D!==null)try{M==="input"&&h.type==="radio"&&h.name!=null&&Ln(f,h),Ks(M,k);var G=Ks(M,h);for(k=0;k<D.length;k+=2){var ue=D[k],fe=D[k+1];ue==="style"?wl(f,fe):ue==="dangerouslySetInnerHTML"?on(f,fe):ue==="children"?os(f,fe):N(f,ue,fe,G)}switch(M){case"input":Kt(f,h);break;case"textarea":He(f,h);break;case"select":var ie=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!h.multiple;var be=h.value;be!=null?_n(f,!!h.multiple,be,!1):ie!==!!h.multiple&&(h.defaultValue!=null?_n(f,!!h.multiple,h.defaultValue,!0):_n(f,!!h.multiple,h.multiple?[]:"",!1))}f[za]=h}catch(Se){ct(t,t.return,Se)}}break;case 6:if(Qn(r,t),lr(t),c&4){if(t.stateNode===null)throw Error(a(162));f=t.stateNode,h=t.memoizedProps;try{f.nodeValue=h}catch(Se){ct(t,t.return,Se)}}break;case 3:if(Qn(r,t),lr(t),c&4&&l!==null&&l.memoizedState.isDehydrated)try{Un(r.containerInfo)}catch(Se){ct(t,t.return,Se)}break;case 4:Qn(r,t),lr(t);break;case 13:Qn(r,t),lr(t),f=t.child,f.flags&8192&&(h=f.memoizedState!==null,f.stateNode.isHidden=h,!h||f.alternate!==null&&f.alternate.memoizedState!==null||(Ic=Je())),c&4&&Qf(t);break;case 22:if(ue=l!==null&&l.memoizedState!==null,t.mode&1?(Ut=(G=Ut)||ue,Qn(r,t),Ut=G):Qn(r,t),lr(t),c&8192){if(G=t.memoizedState!==null,(t.stateNode.isHidden=G)&&!ue&&(t.mode&1)!==0)for(ke=t,ue=t.child;ue!==null;){for(fe=ke=ue;ke!==null;){switch(ie=ke,be=ie.child,ie.tag){case 0:case 11:case 14:case 15:Ja(4,ie,ie.return);break;case 1:ga(ie,ie.return);var Ne=ie.stateNode;if(typeof Ne.componentWillUnmount=="function"){c=ie,l=ie.return;try{r=c,Ne.props=r.memoizedProps,Ne.state=r.memoizedState,Ne.componentWillUnmount()}catch(Se){ct(c,l,Se)}}break;case 5:ga(ie,ie.return);break;case 22:if(ie.memoizedState!==null){Jf(fe);continue}}be!==null?(be.return=ie,ke=be):Jf(fe)}ue=ue.sibling}e:for(ue=null,fe=t;;){if(fe.tag===5){if(ue===null){ue=fe;try{f=fe.stateNode,G?(h=f.style,typeof h.setProperty=="function"?h.setProperty("display","none","important"):h.display="none"):(M=fe.stateNode,D=fe.memoizedProps.style,k=D!=null&&D.hasOwnProperty("display")?D.display:null,M.style.display=bl("display",k))}catch(Se){ct(t,t.return,Se)}}}else if(fe.tag===6){if(ue===null)try{fe.stateNode.nodeValue=G?"":fe.memoizedProps}catch(Se){ct(t,t.return,Se)}}else if((fe.tag!==22&&fe.tag!==23||fe.memoizedState===null||fe===t)&&fe.child!==null){fe.child.return=fe,fe=fe.child;continue}if(fe===t)break e;for(;fe.sibling===null;){if(fe.return===null||fe.return===t)break e;ue===fe&&(ue=null),fe=fe.return}ue===fe&&(ue=null),fe.sibling.return=fe.return,fe=fe.sibling}}break;case 19:Qn(r,t),lr(t),c&4&&Qf(t);break;case 21:break;default:Qn(r,t),lr(t)}}function lr(t){var r=t.flags;if(r&2){try{e:{for(var l=t.return;l!==null;){if(Hf(l)){var c=l;break e}l=l.return}throw Error(a(160))}switch(c.tag){case 5:var f=c.stateNode;c.flags&32&&(os(f,""),c.flags&=-33);var h=Wf(t);Sc(t,h,f);break;case 3:case 4:var k=c.stateNode.containerInfo,M=Wf(t);Nc(t,M,k);break;default:throw Error(a(161))}}catch(D){ct(t,t.return,D)}t.flags&=-3}r&4096&&(t.flags&=-4097)}function $g(t,r,l){ke=t,Yf(t)}function Yf(t,r,l){for(var c=(t.mode&1)!==0;ke!==null;){var f=ke,h=f.child;if(f.tag===22&&c){var k=f.memoizedState!==null||ao;if(!k){var M=f.alternate,D=M!==null&&M.memoizedState!==null||Ut;M=ao;var G=Ut;if(ao=k,(Ut=D)&&!G)for(ke=f;ke!==null;)k=ke,D=k.child,k.tag===22&&k.memoizedState!==null?Zf(f):D!==null?(D.return=k,ke=D):Zf(f);for(;h!==null;)ke=h,Yf(h),h=h.sibling;ke=f,ao=M,Ut=G}Xf(t)}else(f.subtreeFlags&8772)!==0&&h!==null?(h.return=f,ke=h):Xf(t)}}function Xf(t){for(;ke!==null;){var r=ke;if((r.flags&8772)!==0){var l=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:Ut||lo(5,r);break;case 1:var c=r.stateNode;if(r.flags&4&&!Ut)if(l===null)c.componentDidMount();else{var f=r.elementType===r.type?l.memoizedProps:Wn(r.type,l.memoizedProps);c.componentDidUpdate(f,l.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var h=r.updateQueue;h!==null&&Xd(r,h,c);break;case 3:var k=r.updateQueue;if(k!==null){if(l=null,r.child!==null)switch(r.child.tag){case 5:l=r.child.stateNode;break;case 1:l=r.child.stateNode}Xd(r,k,l)}break;case 5:var M=r.stateNode;if(l===null&&r.flags&4){l=M;var D=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":D.autoFocus&&l.focus();break;case"img":D.src&&(l.src=D.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var G=r.alternate;if(G!==null){var ue=G.memoizedState;if(ue!==null){var fe=ue.dehydrated;fe!==null&&Un(fe)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(a(163))}Ut||r.flags&512&&jc(r)}catch(ie){ct(r,r.return,ie)}}if(r===t){ke=null;break}if(l=r.sibling,l!==null){l.return=r.return,ke=l;break}ke=r.return}}function Jf(t){for(;ke!==null;){var r=ke;if(r===t){ke=null;break}var l=r.sibling;if(l!==null){l.return=r.return,ke=l;break}ke=r.return}}function Zf(t){for(;ke!==null;){var r=ke;try{switch(r.tag){case 0:case 11:case 15:var l=r.return;try{lo(4,r)}catch(D){ct(r,l,D)}break;case 1:var c=r.stateNode;if(typeof c.componentDidMount=="function"){var f=r.return;try{c.componentDidMount()}catch(D){ct(r,f,D)}}var h=r.return;try{jc(r)}catch(D){ct(r,h,D)}break;case 5:var k=r.return;try{jc(r)}catch(D){ct(r,k,D)}}}catch(D){ct(r,r.return,D)}if(r===t){ke=null;break}var M=r.sibling;if(M!==null){M.return=r.return,ke=M;break}ke=r.return}}var Mg=Math.ceil,oo=b.ReactCurrentDispatcher,Cc=b.ReactCurrentOwner,Tn=b.ReactCurrentBatchConfig,Ve=0,It=null,mt=null,Ft=0,gn=0,xa=Kr(0),vt=0,Za=null,Ss=0,io=0,Rc=0,el=null,tn=null,Ic=0,ya=1/0,Er=null,co=!1,Tc=null,Yr=null,uo=!1,Xr=null,fo=0,tl=0,Ec=null,po=-1,mo=0;function Vt(){return(Ve&6)!==0?Je():po!==-1?po:po=Je()}function Jr(t){return(t.mode&1)===0?1:(Ve&2)!==0&&Ft!==0?Ft&-Ft:xg.transition!==null?(mo===0&&(mo=we()),mo):(t=$e,t!==0||(t=window.event,t=t===void 0?16:ed(t.type)),t)}function Gn(t,r,l,c){if(50<tl)throw tl=0,Ec=null,Error(a(185));Ge(t,l,c),((Ve&2)===0||t!==It)&&(t===It&&((Ve&2)===0&&(io|=l),vt===4&&Zr(t,Ft)),nn(t,c),l===1&&Ve===0&&(r.mode&1)===0&&(ya=Je()+500,zl&&Wr()))}function nn(t,r){var l=t.callbackNode;Re(t,r);var c=Ie(t,t===It?Ft:0);if(c===0)l!==null&&Or(l),t.callbackNode=null,t.callbackPriority=0;else if(r=c&-c,t.callbackPriority!==r){if(l!=null&&Or(l),r===1)t.tag===0?gg(tp.bind(null,t)):Dd(tp.bind(null,t)),fg(function(){(Ve&6)===0&&Wr()}),l=null;else{switch($t(c)){case 1:l=Xs;break;case 4:l=ds;break;case 16:l=fs;break;case 536870912:l=dn;break;default:l=fs}l=cp(l,ep.bind(null,t))}t.callbackPriority=r,t.callbackNode=l}}function ep(t,r){if(po=-1,mo=0,(Ve&6)!==0)throw Error(a(327));var l=t.callbackNode;if(va()&&t.callbackNode!==l)return null;var c=Ie(t,t===It?Ft:0);if(c===0)return null;if((c&30)!==0||(c&t.expiredLanes)!==0||r)r=ho(t,c);else{r=c;var f=Ve;Ve|=2;var h=rp();(It!==t||Ft!==r)&&(Er=null,ya=Je()+500,Rs(t,r));do try{_g();break}catch(M){np(t,M)}while(!0);Qi(),oo.current=h,Ve=f,mt!==null?r=0:(It=null,Ft=0,r=vt)}if(r!==0){if(r===2&&(f=ze(t),f!==0&&(c=f,r=Pc(t,f))),r===1)throw l=Za,Rs(t,0),Zr(t,c),nn(t,Je()),l;if(r===6)Zr(t,c);else{if(f=t.current.alternate,(c&30)===0&&!Fg(f)&&(r=ho(t,c),r===2&&(h=ze(t),h!==0&&(c=h,r=Pc(t,h))),r===1))throw l=Za,Rs(t,0),Zr(t,c),nn(t,Je()),l;switch(t.finishedWork=f,t.finishedLanes=c,r){case 0:case 1:throw Error(a(345));case 2:Is(t,tn,Er);break;case 3:if(Zr(t,c),(c&130023424)===c&&(r=Ic+500-Je(),10<r)){if(Ie(t,0)!==0)break;if(f=t.suspendedLanes,(f&c)!==c){Vt(),t.pingedLanes|=t.suspendedLanes&f;break}t.timeoutHandle=_i(Is.bind(null,t,tn,Er),r);break}Is(t,tn,Er);break;case 4:if(Zr(t,c),(c&4194240)===c)break;for(r=t.eventTimes,f=-1;0<c;){var k=31-J(c);h=1<<k,k=r[k],k>f&&(f=k),c&=~h}if(c=f,c=Je()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*Mg(c/1960))-c,10<c){t.timeoutHandle=_i(Is.bind(null,t,tn,Er),c);break}Is(t,tn,Er);break;case 5:Is(t,tn,Er);break;default:throw Error(a(329))}}}return nn(t,Je()),t.callbackNode===l?ep.bind(null,t):null}function Pc(t,r){var l=el;return t.current.memoizedState.isDehydrated&&(Rs(t,r).flags|=256),t=ho(t,r),t!==2&&(r=tn,tn=l,r!==null&&Ac(r)),t}function Ac(t){tn===null?tn=t:tn.push.apply(tn,t)}function Fg(t){for(var r=t;;){if(r.flags&16384){var l=r.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var c=0;c<l.length;c++){var f=l[c],h=f.getSnapshot;f=f.value;try{if(!Kn(h(),f))return!1}catch{return!1}}}if(l=r.child,r.subtreeFlags&16384&&l!==null)l.return=r,r=l;else{if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Zr(t,r){for(r&=~Rc,r&=~io,t.suspendedLanes|=r,t.pingedLanes&=~r,t=t.expirationTimes;0<r;){var l=31-J(r),c=1<<l;t[l]=-1,r&=~c}}function tp(t){if((Ve&6)!==0)throw Error(a(327));va();var r=Ie(t,0);if((r&1)===0)return nn(t,Je()),null;var l=ho(t,r);if(t.tag!==0&&l===2){var c=ze(t);c!==0&&(r=c,l=Pc(t,c))}if(l===1)throw l=Za,Rs(t,0),Zr(t,r),nn(t,Je()),l;if(l===6)throw Error(a(345));return t.finishedWork=t.current.alternate,t.finishedLanes=r,Is(t,tn,Er),nn(t,Je()),null}function $c(t,r){var l=Ve;Ve|=1;try{return t(r)}finally{Ve=l,Ve===0&&(ya=Je()+500,zl&&Wr())}}function Cs(t){Xr!==null&&Xr.tag===0&&(Ve&6)===0&&va();var r=Ve;Ve|=1;var l=Tn.transition,c=$e;try{if(Tn.transition=null,$e=1,t)return t()}finally{$e=c,Tn.transition=l,Ve=r,(Ve&6)===0&&Wr()}}function Mc(){gn=xa.current,et(xa)}function Rs(t,r){t.finishedWork=null,t.finishedLanes=0;var l=t.timeoutHandle;if(l!==-1&&(t.timeoutHandle=-1,dg(l)),mt!==null)for(l=mt.return;l!==null;){var c=l;switch(Ui(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&Dl();break;case 3:ma(),et(Jt),et(Bt),nc();break;case 5:ec(c);break;case 4:ma();break;case 13:et(lt);break;case 19:et(lt);break;case 10:Gi(c.type._context);break;case 22:case 23:Mc()}l=l.return}if(It=t,mt=t=es(t.current,null),Ft=gn=r,vt=0,Za=null,Rc=io=Ss=0,tn=el=null,ks!==null){for(r=0;r<ks.length;r++)if(l=ks[r],c=l.interleaved,c!==null){l.interleaved=null;var f=c.next,h=l.pending;if(h!==null){var k=h.next;h.next=f,c.next=k}l.pending=c}ks=null}return t}function np(t,r){do{var l=mt;try{if(Qi(),Xl.current=to,Jl){for(var c=ot.memoizedState;c!==null;){var f=c.queue;f!==null&&(f.pending=null),c=c.next}Jl=!1}if(Ns=0,Rt=yt=ot=null,Va=!1,Qa=0,Cc.current=null,l===null||l.return===null){vt=1,Za=r,mt=null;break}e:{var h=t,k=l.return,M=l,D=r;if(r=Ft,M.flags|=32768,D!==null&&typeof D=="object"&&typeof D.then=="function"){var G=D,ue=M,fe=ue.tag;if((ue.mode&1)===0&&(fe===0||fe===11||fe===15)){var ie=ue.alternate;ie?(ue.updateQueue=ie.updateQueue,ue.memoizedState=ie.memoizedState,ue.lanes=ie.lanes):(ue.updateQueue=null,ue.memoizedState=null)}var be=Rf(k);if(be!==null){be.flags&=-257,If(be,k,M,h,r),be.mode&1&&Cf(h,G,r),r=be,D=G;var Ne=r.updateQueue;if(Ne===null){var Se=new Set;Se.add(D),r.updateQueue=Se}else Ne.add(D);break e}else{if((r&1)===0){Cf(h,G,r),Fc();break e}D=Error(a(426))}}else if(nt&&M.mode&1){var ut=Rf(k);if(ut!==null){(ut.flags&65536)===0&&(ut.flags|=256),If(ut,k,M,h,r),Wi(ha(D,M));break e}}h=D=ha(D,M),vt!==4&&(vt=2),el===null?el=[h]:el.push(h),h=k;do{switch(h.tag){case 3:h.flags|=65536,r&=-r,h.lanes|=r;var U=Nf(h,D,r);Yd(h,U);break e;case 1:M=D;var z=h.type,V=h.stateNode;if((h.flags&128)===0&&(typeof z.getDerivedStateFromError=="function"||V!==null&&typeof V.componentDidCatch=="function"&&(Yr===null||!Yr.has(V)))){h.flags|=65536,r&=-r,h.lanes|=r;var pe=Sf(h,M,r);Yd(h,pe);break e}}h=h.return}while(h!==null)}ap(l)}catch(Ce){r=Ce,mt===l&&l!==null&&(mt=l=l.return);continue}break}while(!0)}function rp(){var t=oo.current;return oo.current=to,t===null?to:t}function Fc(){(vt===0||vt===3||vt===2)&&(vt=4),It===null||(Ss&268435455)===0&&(io&268435455)===0||Zr(It,Ft)}function ho(t,r){var l=Ve;Ve|=2;var c=rp();(It!==t||Ft!==r)&&(Er=null,Rs(t,r));do try{Lg();break}catch(f){np(t,f)}while(!0);if(Qi(),Ve=l,oo.current=c,mt!==null)throw Error(a(261));return It=null,Ft=0,vt}function Lg(){for(;mt!==null;)sp(mt)}function _g(){for(;mt!==null&&!Ys();)sp(mt)}function sp(t){var r=ip(t.alternate,t,gn);t.memoizedProps=t.pendingProps,r===null?ap(t):mt=r,Cc.current=null}function ap(t){var r=t;do{var l=r.alternate;if(t=r.return,(r.flags&32768)===0){if(l=Tg(l,r,gn),l!==null){mt=l;return}}else{if(l=Eg(l,r),l!==null){l.flags&=32767,mt=l;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{vt=6,mt=null;return}}if(r=r.sibling,r!==null){mt=r;return}mt=r=t}while(r!==null);vt===0&&(vt=5)}function Is(t,r,l){var c=$e,f=Tn.transition;try{Tn.transition=null,$e=1,Og(t,r,l,c)}finally{Tn.transition=f,$e=c}return null}function Og(t,r,l,c){do va();while(Xr!==null);if((Ve&6)!==0)throw Error(a(327));l=t.finishedWork;var f=t.finishedLanes;if(l===null)return null;if(t.finishedWork=null,t.finishedLanes=0,l===t.current)throw Error(a(177));t.callbackNode=null,t.callbackPriority=0;var h=l.lanes|l.childLanes;if(tt(t,h),t===It&&(mt=It=null,Ft=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||uo||(uo=!0,cp(fs,function(){return va(),null})),h=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||h){h=Tn.transition,Tn.transition=null;var k=$e;$e=1;var M=Ve;Ve|=4,Cc.current=null,Ag(t,l),Gf(l,t),sg(Fi),Sl=!!Mi,Fi=Mi=null,t.current=l,$g(l),mi(),Ve=M,$e=k,Tn.transition=h}else t.current=l;if(uo&&(uo=!1,Xr=t,fo=f),h=t.pendingLanes,h===0&&(Yr=null),W(l.stateNode),nn(t,Je()),r!==null)for(c=t.onRecoverableError,l=0;l<r.length;l++)f=r[l],c(f.value,{componentStack:f.stack,digest:f.digest});if(co)throw co=!1,t=Tc,Tc=null,t;return(fo&1)!==0&&t.tag!==0&&va(),h=t.pendingLanes,(h&1)!==0?t===Ec?tl++:(tl=0,Ec=t):tl=0,Wr(),null}function va(){if(Xr!==null){var t=$t(fo),r=Tn.transition,l=$e;try{if(Tn.transition=null,$e=16>t?16:t,Xr===null)var c=!1;else{if(t=Xr,Xr=null,fo=0,(Ve&6)!==0)throw Error(a(331));var f=Ve;for(Ve|=4,ke=t.current;ke!==null;){var h=ke,k=h.child;if((ke.flags&16)!==0){var M=h.deletions;if(M!==null){for(var D=0;D<M.length;D++){var G=M[D];for(ke=G;ke!==null;){var ue=ke;switch(ue.tag){case 0:case 11:case 15:Ja(8,ue,h)}var fe=ue.child;if(fe!==null)fe.return=ue,ke=fe;else for(;ke!==null;){ue=ke;var ie=ue.sibling,be=ue.return;if(Kf(ue),ue===G){ke=null;break}if(ie!==null){ie.return=be,ke=ie;break}ke=be}}}var Ne=h.alternate;if(Ne!==null){var Se=Ne.child;if(Se!==null){Ne.child=null;do{var ut=Se.sibling;Se.sibling=null,Se=ut}while(Se!==null)}}ke=h}}if((h.subtreeFlags&2064)!==0&&k!==null)k.return=h,ke=k;else e:for(;ke!==null;){if(h=ke,(h.flags&2048)!==0)switch(h.tag){case 0:case 11:case 15:Ja(9,h,h.return)}var U=h.sibling;if(U!==null){U.return=h.return,ke=U;break e}ke=h.return}}var z=t.current;for(ke=z;ke!==null;){k=ke;var V=k.child;if((k.subtreeFlags&2064)!==0&&V!==null)V.return=k,ke=V;else e:for(k=z;ke!==null;){if(M=ke,(M.flags&2048)!==0)try{switch(M.tag){case 0:case 11:case 15:lo(9,M)}}catch(Ce){ct(M,M.return,Ce)}if(M===k){ke=null;break e}var pe=M.sibling;if(pe!==null){pe.return=M.return,ke=pe;break e}ke=M.return}}if(Ve=f,Wr(),A&&typeof A.onPostCommitFiberRoot=="function")try{A.onPostCommitFiberRoot(jn,t)}catch{}c=!0}return c}finally{$e=l,Tn.transition=r}}return!1}function lp(t,r,l){r=ha(l,r),r=Nf(t,r,1),t=Qr(t,r,1),r=Vt(),t!==null&&(Ge(t,1,r),nn(t,r))}function ct(t,r,l){if(t.tag===3)lp(t,t,l);else for(;r!==null;){if(r.tag===3){lp(r,t,l);break}else if(r.tag===1){var c=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Yr===null||!Yr.has(c))){t=ha(l,t),t=Sf(r,t,1),r=Qr(r,t,1),t=Vt(),r!==null&&(Ge(r,1,t),nn(r,t));break}}r=r.return}}function Dg(t,r,l){var c=t.pingCache;c!==null&&c.delete(r),r=Vt(),t.pingedLanes|=t.suspendedLanes&l,It===t&&(Ft&l)===l&&(vt===4||vt===3&&(Ft&130023424)===Ft&&500>Je()-Ic?Rs(t,0):Rc|=l),nn(t,r)}function op(t,r){r===0&&((t.mode&1)===0?r=1:(r=me,me<<=1,(me&130023424)===0&&(me=4194304)));var l=Vt();t=Rr(t,r),t!==null&&(Ge(t,r,l),nn(t,l))}function Bg(t){var r=t.memoizedState,l=0;r!==null&&(l=r.retryLane),op(t,l)}function zg(t,r){var l=0;switch(t.tag){case 13:var c=t.stateNode,f=t.memoizedState;f!==null&&(l=f.retryLane);break;case 19:c=t.stateNode;break;default:throw Error(a(314))}c!==null&&c.delete(r),op(t,l)}var ip;ip=function(t,r,l){if(t!==null)if(t.memoizedProps!==r.pendingProps||Jt.current)en=!0;else{if((t.lanes&l)===0&&(r.flags&128)===0)return en=!1,Ig(t,r,l);en=(t.flags&131072)!==0}else en=!1,nt&&(r.flags&1048576)!==0&&Bd(r,Ul,r.index);switch(r.lanes=0,r.tag){case 2:var c=r.type;so(t,r),t=r.pendingProps;var f=oa(r,Bt.current);pa(r,l),f=ac(null,r,c,t,f,l);var h=lc();return r.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,Zt(c)?(h=!0,Bl(r)):h=!1,r.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Ji(r),f.updater=no,r.stateNode=f,f._reactInternals=r,fc(r,c,t,l),r=gc(null,r,c,!0,h,l)):(r.tag=0,nt&&h&&qi(r),Wt(null,r,f,l),r=r.child),r;case 16:c=r.elementType;e:{switch(so(t,r),t=r.pendingProps,f=c._init,c=f(c._payload),r.type=c,f=r.tag=Ug(c),t=Wn(c,t),f){case 0:r=hc(null,r,c,t,l);break e;case 1:r=Mf(null,r,c,t,l);break e;case 11:r=Tf(null,r,c,t,l);break e;case 14:r=Ef(null,r,c,Wn(c.type,t),l);break e}throw Error(a(306,c,""))}return r;case 0:return c=r.type,f=r.pendingProps,f=r.elementType===c?f:Wn(c,f),hc(t,r,c,f,l);case 1:return c=r.type,f=r.pendingProps,f=r.elementType===c?f:Wn(c,f),Mf(t,r,c,f,l);case 3:e:{if(Ff(r),t===null)throw Error(a(387));c=r.pendingProps,h=r.memoizedState,f=h.element,Gd(t,r),Gl(r,c,null,l);var k=r.memoizedState;if(c=k.element,h.isDehydrated)if(h={element:c,isDehydrated:!1,cache:k.cache,pendingSuspenseBoundaries:k.pendingSuspenseBoundaries,transitions:k.transitions},r.updateQueue.baseState=h,r.memoizedState=h,r.flags&256){f=ha(Error(a(423)),r),r=Lf(t,r,c,l,f);break e}else if(c!==f){f=ha(Error(a(424)),r),r=Lf(t,r,c,l,f);break e}else for(hn=Ur(r.stateNode.containerInfo.firstChild),mn=r,nt=!0,Hn=null,l=Vd(r,null,c,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(ua(),c===f){r=Tr(t,r,l);break e}Wt(t,r,c,l)}r=r.child}return r;case 5:return Jd(r),t===null&&Hi(r),c=r.type,f=r.pendingProps,h=t!==null?t.memoizedProps:null,k=f.children,Li(c,f)?k=null:h!==null&&Li(c,h)&&(r.flags|=32),$f(t,r),Wt(t,r,k,l),r.child;case 6:return t===null&&Hi(r),null;case 13:return _f(t,r,l);case 4:return Zi(r,r.stateNode.containerInfo),c=r.pendingProps,t===null?r.child=da(r,null,c,l):Wt(t,r,c,l),r.child;case 11:return c=r.type,f=r.pendingProps,f=r.elementType===c?f:Wn(c,f),Tf(t,r,c,f,l);case 7:return Wt(t,r,r.pendingProps,l),r.child;case 8:return Wt(t,r,r.pendingProps.children,l),r.child;case 12:return Wt(t,r,r.pendingProps.children,l),r.child;case 10:e:{if(c=r.type._context,f=r.pendingProps,h=r.memoizedProps,k=f.value,Xe(Wl,c._currentValue),c._currentValue=k,h!==null)if(Kn(h.value,k)){if(h.children===f.children&&!Jt.current){r=Tr(t,r,l);break e}}else for(h=r.child,h!==null&&(h.return=r);h!==null;){var M=h.dependencies;if(M!==null){k=h.child;for(var D=M.firstContext;D!==null;){if(D.context===c){if(h.tag===1){D=Ir(-1,l&-l),D.tag=2;var G=h.updateQueue;if(G!==null){G=G.shared;var ue=G.pending;ue===null?D.next=D:(D.next=ue.next,ue.next=D),G.pending=D}}h.lanes|=l,D=h.alternate,D!==null&&(D.lanes|=l),Yi(h.return,l,r),M.lanes|=l;break}D=D.next}}else if(h.tag===10)k=h.type===r.type?null:h.child;else if(h.tag===18){if(k=h.return,k===null)throw Error(a(341));k.lanes|=l,M=k.alternate,M!==null&&(M.lanes|=l),Yi(k,l,r),k=h.sibling}else k=h.child;if(k!==null)k.return=h;else for(k=h;k!==null;){if(k===r){k=null;break}if(h=k.sibling,h!==null){h.return=k.return,k=h;break}k=k.return}h=k}Wt(t,r,f.children,l),r=r.child}return r;case 9:return f=r.type,c=r.pendingProps.children,pa(r,l),f=Rn(f),c=c(f),r.flags|=1,Wt(t,r,c,l),r.child;case 14:return c=r.type,f=Wn(c,r.pendingProps),f=Wn(c.type,f),Ef(t,r,c,f,l);case 15:return Pf(t,r,r.type,r.pendingProps,l);case 17:return c=r.type,f=r.pendingProps,f=r.elementType===c?f:Wn(c,f),so(t,r),r.tag=1,Zt(c)?(t=!0,Bl(r)):t=!1,pa(r,l),kf(r,c,f),fc(r,c,f,l),gc(null,r,c,!0,t,l);case 19:return Df(t,r,l);case 22:return Af(t,r,l)}throw Error(a(156,r.tag))};function cp(t,r){return _r(t,r)}function qg(t,r,l,c){this.tag=t,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function En(t,r,l,c){return new qg(t,r,l,c)}function Lc(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Ug(t){if(typeof t=="function")return Lc(t)?1:0;if(t!=null){if(t=t.$$typeof,t===X)return 11;if(t===H)return 14}return 2}function es(t,r){var l=t.alternate;return l===null?(l=En(t.tag,r,t.key,t.mode),l.elementType=t.elementType,l.type=t.type,l.stateNode=t.stateNode,l.alternate=t,t.alternate=l):(l.pendingProps=r,l.type=t.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=t.flags&14680064,l.childLanes=t.childLanes,l.lanes=t.lanes,l.child=t.child,l.memoizedProps=t.memoizedProps,l.memoizedState=t.memoizedState,l.updateQueue=t.updateQueue,r=t.dependencies,l.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},l.sibling=t.sibling,l.index=t.index,l.ref=t.ref,l}function go(t,r,l,c,f,h){var k=2;if(c=t,typeof t=="function")Lc(t)&&(k=1);else if(typeof t=="string")k=5;else e:switch(t){case L:return Ts(l.children,f,h,r);case q:k=8,f|=8;break;case Q:return t=En(12,l,r,f|2),t.elementType=Q,t.lanes=h,t;case B:return t=En(13,l,r,f),t.elementType=B,t.lanes=h,t;case O:return t=En(19,l,r,f),t.elementType=O,t.lanes=h,t;case ce:return xo(l,f,h,r);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case _:k=10;break e;case Y:k=9;break e;case X:k=11;break e;case H:k=14;break e;case ee:k=16,c=null;break e}throw Error(a(130,t==null?t:typeof t,""))}return r=En(k,l,r,f),r.elementType=t,r.type=c,r.lanes=h,r}function Ts(t,r,l,c){return t=En(7,t,c,r),t.lanes=l,t}function xo(t,r,l,c){return t=En(22,t,c,r),t.elementType=ce,t.lanes=l,t.stateNode={isHidden:!1},t}function _c(t,r,l){return t=En(6,t,null,r),t.lanes=l,t}function Oc(t,r,l){return r=En(4,t.children!==null?t.children:[],t.key,r),r.lanes=l,r.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},r}function Kg(t,r,l,c,f){this.tag=r,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ae(0),this.expirationTimes=Ae(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ae(0),this.identifierPrefix=c,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Dc(t,r,l,c,f,h,k,M,D){return t=new Kg(t,r,l,M,D),r===1?(r=1,h===!0&&(r|=8)):r=0,h=En(3,null,null,r),t.current=h,h.stateNode=t,h.memoizedState={element:c,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ji(h),t}function Hg(t,r,l){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:$,key:c==null?null:""+c,children:t,containerInfo:r,implementation:l}}function up(t){if(!t)return Hr;t=t._reactInternals;e:{if(tr(t)!==t||t.tag!==1)throw Error(a(170));var r=t;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(Zt(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(a(171))}if(t.tag===1){var l=t.type;if(Zt(l))return _d(t,l,r)}return r}function dp(t,r,l,c,f,h,k,M,D){return t=Dc(l,c,!0,t,f,h,k,M,D),t.context=up(null),l=t.current,c=Vt(),f=Jr(l),h=Ir(c,f),h.callback=r??null,Qr(l,h,f),t.current.lanes=f,Ge(t,f,c),nn(t,c),t}function yo(t,r,l,c){var f=r.current,h=Vt(),k=Jr(f);return l=up(l),r.context===null?r.context=l:r.pendingContext=l,r=Ir(h,k),r.payload={element:t},c=c===void 0?null:c,c!==null&&(r.callback=c),t=Qr(f,r,k),t!==null&&(Gn(t,f,k,h),Ql(t,f,k)),k}function vo(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function fp(t,r){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var l=t.retryLane;t.retryLane=l!==0&&l<r?l:r}}function Bc(t,r){fp(t,r),(t=t.alternate)&&fp(t,r)}function Wg(){return null}var pp=typeof reportError=="function"?reportError:function(t){console.error(t)};function zc(t){this._internalRoot=t}bo.prototype.render=zc.prototype.render=function(t){var r=this._internalRoot;if(r===null)throw Error(a(409));yo(t,r,null,null)},bo.prototype.unmount=zc.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var r=t.containerInfo;Cs(function(){yo(null,t,null,null)}),r[jr]=null}};function bo(t){this._internalRoot=t}bo.prototype.unstable_scheduleHydration=function(t){if(t){var r=ps();t={blockedOn:null,target:t,priority:r};for(var l=0;l<Ye.length&&r!==0&&r<Ye[l].priority;l++);Ye.splice(l,0,t),l===0&&wr(t)}};function qc(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function wo(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function mp(){}function Vg(t,r,l,c,f){if(f){if(typeof c=="function"){var h=c;c=function(){var G=vo(k);h.call(G)}}var k=dp(r,c,t,0,null,!1,!1,"",mp);return t._reactRootContainer=k,t[jr]=k.current,Da(t.nodeType===8?t.parentNode:t),Cs(),k}for(;f=t.lastChild;)t.removeChild(f);if(typeof c=="function"){var M=c;c=function(){var G=vo(D);M.call(G)}}var D=Dc(t,0,!1,null,null,!1,!1,"",mp);return t._reactRootContainer=D,t[jr]=D.current,Da(t.nodeType===8?t.parentNode:t),Cs(function(){yo(r,D,l,c)}),D}function ko(t,r,l,c,f){var h=l._reactRootContainer;if(h){var k=h;if(typeof f=="function"){var M=f;f=function(){var D=vo(k);M.call(D)}}yo(r,k,t,f)}else k=Vg(l,r,t,f,c);return vo(k)}pt=function(t){switch(t.tag){case 3:var r=t.stateNode;if(r.current.memoizedState.isDehydrated){var l=he(r.pendingLanes);l!==0&&(Ct(r,l|1),nn(r,Je()),(Ve&6)===0&&(ya=Je()+500,Wr()))}break;case 13:Cs(function(){var c=Rr(t,1);if(c!==null){var f=Vt();Gn(c,t,1,f)}}),Bc(t,1)}},gt=function(t){if(t.tag===13){var r=Rr(t,134217728);if(r!==null){var l=Vt();Gn(r,t,134217728,l)}Bc(t,134217728)}},zn=function(t){if(t.tag===13){var r=Jr(t),l=Rr(t,r);if(l!==null){var c=Vt();Gn(l,t,r,c)}Bc(t,r)}},ps=function(){return $e},ms=function(t,r){var l=$e;try{return $e=t,r()}finally{$e=l}},is=function(t,r,l){switch(r){case"input":if(Kt(t,l),r=l.name,l.type==="radio"&&r!=null){for(l=t;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<l.length;r++){var c=l[r];if(c!==t&&c.form===t.form){var f=Ol(c);if(!f)throw Error(a(90));Le(c),Kt(c,f)}}}break;case"textarea":He(t,l);break;case"select":r=l.value,r!=null&&_n(t,!!l.multiple,r,!1)}},xr=$c,Ta=Cs;var Qg={usingClientEntryPoint:!1,Events:[qa,aa,Ol,gr,cs,$c]},nl={findFiberByHostInstance:ys,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Gg={bundleType:nl.bundleType,version:nl.version,rendererPackageName:nl.rendererPackageName,rendererConfig:nl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:b.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=br(t),t===null?null:t.stateNode},findFiberByHostInstance:nl.findFiberByHostInstance||Wg,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var jo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!jo.isDisabled&&jo.supportsFiber)try{jn=jo.inject(Gg),A=jo}catch{}}return rn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Qg,rn.createPortal=function(t,r){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!qc(r))throw Error(a(200));return Hg(t,r,null,l)},rn.createRoot=function(t,r){if(!qc(t))throw Error(a(299));var l=!1,c="",f=pp;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(c=r.identifierPrefix),r.onRecoverableError!==void 0&&(f=r.onRecoverableError)),r=Dc(t,1,!1,null,null,l,!1,c,f),t[jr]=r.current,Da(t.nodeType===8?t.parentNode:t),new zc(r)},rn.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var r=t._reactInternals;if(r===void 0)throw typeof t.render=="function"?Error(a(188)):(t=Object.keys(t).join(","),Error(a(268,t)));return t=br(r),t=t===null?null:t.stateNode,t},rn.flushSync=function(t){return Cs(t)},rn.hydrate=function(t,r,l){if(!wo(r))throw Error(a(200));return ko(null,t,r,!0,l)},rn.hydrateRoot=function(t,r,l){if(!qc(t))throw Error(a(405));var c=l!=null&&l.hydratedSources||null,f=!1,h="",k=pp;if(l!=null&&(l.unstable_strictMode===!0&&(f=!0),l.identifierPrefix!==void 0&&(h=l.identifierPrefix),l.onRecoverableError!==void 0&&(k=l.onRecoverableError)),r=dp(r,null,t,1,l??null,f,!1,h,k),t[jr]=r.current,Da(t),c)for(t=0;t<c.length;t++)l=c[t],f=l._getVersion,f=f(l._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[l,f]:r.mutableSourceEagerHydrationData.push(l,f);return new bo(r)},rn.render=function(t,r,l){if(!wo(r))throw Error(a(200));return ko(null,t,r,!1,l)},rn.unmountComponentAtNode=function(t){if(!wo(t))throw Error(a(40));return t._reactRootContainer?(Cs(function(){ko(null,null,t,!1,function(){t._reactRootContainer=null,t[jr]=null})}),!0):!1},rn.unstable_batchedUpdates=$c,rn.unstable_renderSubtreeIntoContainer=function(t,r,l,c){if(!wo(l))throw Error(a(200));if(t==null||t._reactInternals===void 0)throw Error(a(38));return ko(t,r,l,!1,c)},rn.version="18.3.1-next-f1338f8080-20240426",rn}var bp;function Ym(){if(bp)return Kc.exports;bp=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(s){console.error(s)}}return e(),Kc.exports=fx(),Kc.exports}var wp;function px(){if(wp)return So;wp=1;var e=Ym();return So.createRoot=e.createRoot,So.hydrateRoot=e.hydrateRoot,So}var mx=px();const Pu=["untouched","replied_unresolved","likely_addressed","resolved"],hx=["draft","open","merged","closed"],gx=["approved","changes_requested","commented","dismissed"],kp={pr_opened:"lifecycle",pr_merged:"lifecycle",pr_closed:"lifecycle",pr_reopened:"lifecycle",pr_ready_for_review:"lifecycle",review_submitted:"reviews",review_comment:"review_comments",pr_comment:"pr_comments",commit_pushed:"commits"},xx={coderabbitai:"coderabbit","greptile-apps":"greptile","copilot-pull-request-reviewer":"copilot","qodo-ai":"qodo","qodo-merge":"qodo","qodo-merge-pro":"qodo","qodo-merge-for-open-source":"qodo","codiumai-pr-agent-free":"qodo","sourcery-ai":"sourcery","bito-code-review":"bito","ellipsis-dev":"ellipsis","korbit-ai":"korbit","baz-reviewer":"baz","graphite-app":"graphite",cursor:"cursor","devin-ai-integration":"devin","entelligence-ai-pr-reviews":"entelligence"};function Xm(e){if(!e)return null;const s=e.toLowerCase().replace(/\[bot\]$/,"");return xx[s]??null}const jp=15,yx=["awaiting_your_review","your_pr_new_comments"];function hu(e){return yx.includes(e)}const vN=["claude-sonnet-5","claude-opus-4-8","claude-sonnet-4-6","claude-haiku-4-5"],bN={"claude-sonnet-5":"Claude Sonnet 5 (best value)","claude-opus-4-8":"Claude Opus 4.8 (most thorough)","claude-sonnet-4-6":"Claude Sonnet 4.6","claude-haiku-4-5":"Claude Haiku 4.5 (fast, cheap)"},Np=["open_prs","merges","lead_time","review_latency","merge_ci","ci_recovery","ci_red"],vx=1250;class Gt extends Error{constructor(s,a){super(a),this.status=s,this.name="ApiError"}}async function Fe(e){if(!e.ok){let s=`${e.status} ${e.statusText}`;try{const a=await e.json();a.message&&(s=a.message)}catch{}throw new Gt(e.status,s)}if(e.status!==204)return await e.json()}function _e(e){return fetch(e,{credentials:"same-origin"}).then(s=>Fe(s))}function Oe(e,s){return s===void 0?{method:e,credentials:"same-origin"}:{method:e,credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify(s)}}const ge={listRepos:()=>_e("/api/repos"),searchRepos:(e,s)=>_e(`/api/repos/search?q=${encodeURIComponent(e)}${s?`&cursor=${encodeURIComponent(s)}`:""}`),addRepo:e=>fetch("/api/repos",Oe("POST",e)).then(s=>Fe(s)),setRepoInboxWatch:(e,s)=>fetch(`/api/repos/${e}`,Oe("PATCH",{inboxWatch:s})).then(a=>Fe(a)),deleteRepo:e=>fetch(`/api/repos/${e}`,Oe("DELETE")).then(s=>Fe(s)),syncRepo:(e,s=!1)=>fetch(`/api/repos/${e}/sync${s?"?full=true":""}`,Oe("POST")).then(a=>Fe(a)),cancelSync:e=>fetch(`/api/repos/${e}/cancel`,Oe("POST")).then(s=>Fe(s)),syncStatus:e=>_e(`/api/repos/${e}/sync-status`),listUsers:()=>_e("/api/users"),mergers:()=>_e("/api/mergers"),setUserBot:(e,s)=>fetch(`/api/users/${e}`,Oe("PATCH",{isBot:s})).then(a=>Fe(a)),timeline:e=>_e(`/api/timeline${e?`?${e}`:""}`),openPrs:e=>_e(`/api/open-prs${e?`?${e}`:""}`),insights:e=>_e(`/api/insights${e?`?${e}`:""}`),repoAnalytics:e=>_e(`/api/insights/${e}/analytics`),pr:e=>_e(`/api/prs/${e}`),suggestedReviewers:e=>_e(`/api/prs/${e}/suggested-reviewers`),thread:e=>_e(`/api/threads/${e}`),mentionCandidates:e=>_e(`/api/prs/${e}/mention-candidates`),prFiles:e=>_e(`/api/prs/${e}/files`),checkLogs:(e,s,a)=>_e(`/api/prs/${e}/checks/${s}/logs${a?`?tail=${a}`:""}`),rerunCi:(e,s)=>fetch(`/api/prs/${e}/ci/rerun`,Oe("POST",s)).then(a=>Fe(a)),replyToThread:(e,s)=>fetch(`/api/threads/${e}/reply`,Oe("POST",s)).then(a=>Fe(a)),resolveThread:(e,s)=>fetch(`/api/threads/${e}/resolve`,Oe("POST",s)).then(a=>Fe(a)),resolveBotThreads:(e,s)=>fetch(`/api/prs/${e}/resolve-bot-threads`,Oe("POST",s)).then(a=>Fe(a)),createPrComment:(e,s)=>fetch(`/api/prs/${e}/comment`,Oe("POST",s)).then(a=>Fe(a)),approvePr:(e,s)=>fetch(`/api/prs/${e}/approve`,Oe("POST",s??{})).then(a=>Fe(a)),mergeOptions:e=>_e(`/api/prs/${e}/merge-options`),mergePr:(e,s)=>fetch(`/api/prs/${e}/merge`,Oe("POST",s)).then(a=>Fe(a)),updatePrBranch:(e,s)=>fetch(`/api/prs/${e}/update-branch`,Oe("POST",s??{})).then(a=>Fe(a)),addReviewComment:(e,s)=>fetch(`/api/prs/${e}/review-comment`,Oe("POST",s)).then(a=>Fe(a)),requestReviewers:(e,s)=>fetch(`/api/prs/${e}/request-reviewers`,Oe("POST",s)).then(a=>Fe(a)),inbox:e=>_e(`/api/activity${e?`?${e}`:""}`),consolidatedFeed:e=>_e(`/api/activity/feed${e?`?${e}`:""}`),markFeedSeen:()=>fetch("/api/activity/feed/mark-seen",Oe("POST")).then(e=>Fe(e)),teamInsights:()=>_e("/api/pro/insights"),teamMetricsDetail:()=>_e("/api/pro/insights/metrics-detail"),aiUsage:()=>_e("/api/pro/ai-usage"),sprintReport:()=>_e("/api/pro/sprint-report"),refreshSprintReport:()=>fetch("/api/pro/sprint-report/refresh",Oe("POST")).then(e=>Fe(e)),retroReport:()=>_e("/api/pro/retro"),refreshRetroReport:()=>fetch("/api/pro/retro/refresh",Oe("POST")).then(e=>Fe(e)),repoClaudeReviews:e=>_e(`/api/repos/${e}/claude-reviews`),repoDigests:e=>_e(`/api/pro/activity/digests${e?`?${e}`:""}`),refreshRepoDigests:e=>fetch(`/api/pro/activity/digests/refresh${e?`?${e}`:""}`,Oe("POST")).then(s=>Fe(s)),repoDigest:e=>_e(`/api/pro/activity/digests/${e}`),reviewLearnings:e=>_e(`/api/pro/prs/${e}/review-learnings`),reviewActions:e=>_e(`/api/pro/claude-reviews/${e}/actions`),proSettings:()=>_e("/api/pro/settings"),updateProSettings:e=>fetch("/api/pro/settings",Oe("PUT",e)).then(s=>Fe(s)),testSlackDigest:()=>fetch("/api/pro/slack/test",Oe("POST")).then(e=>Fe(e)),me:()=>_e("/api/me"),logout:()=>fetch("/api/auth/logout",{method:"POST",credentials:"same-origin"}),myTurn:()=>_e("/api/my-turn"),myTurnDone:()=>_e("/api/my-turn/done"),dismissMyTurn:(e,s)=>fetch("/api/my-turn/dismiss",Oe("POST",{kind:e,refId:s})).then(a=>Fe(a)),undismissMyTurn:(e,s)=>fetch("/api/my-turn/undismiss",Oe("POST",{kind:e,refId:s})).then(a=>Fe(a)),markPrViewed:(e,s)=>fetch(`/api/prs/${e}/mark-viewed`,Oe("POST",s?{sha:s}:{})).then(a=>Fe(a)),markAllViewed:e=>fetch("/api/prs/mark-all-viewed",Oe("POST",e&&e.length>0?{repoIds:e}:{})).then(s=>Fe(s)),dismissPr:e=>fetch(`/api/prs/${e}/dismiss`,Oe("POST")).then(s=>Fe(s)),claudeReview:e=>_e(`/api/prs/${e}/claude-review`),setClaudeKey:e=>fetch("/api/claude-review/key",Oe("PUT",{key:e})).then(s=>Fe(s)),claudeReviewById:e=>_e(`/api/claude-reviews/${e}`),generateClaudeReview:(e,s,a)=>fetch(`/api/prs/${e}/claude-review`,Oe("POST",{model:s,mode:a})).then(o=>Fe(o)),claudeReviewStatus:e=>_e(`/api/prs/${e}/claude-review/status`),cancelClaudeReview:e=>fetch(`/api/prs/${e}/claude-review/cancel`,Oe("POST")).then(s=>Fe(s)),updateClaudeReview:(e,s)=>fetch(`/api/claude-reviews/${e}`,Oe("PATCH",s)).then(a=>Fe(a)),updateClaudeFinding:(e,s)=>fetch(`/api/claude-findings/${e}`,Oe("PATCH",s)).then(a=>Fe(a)),postClaudeFinding:e=>fetch(`/api/claude-findings/${e}/post`,Oe("POST")).then(s=>Fe(s)),activeClaudeReviews:()=>_e("/api/claude-reviews/active"),listAllClaudeReviews:()=>_e("/api/claude-reviews"),postClaudeReview:(e,s,a=!1)=>fetch(`/api/claude-reviews/${e}/post${a?"?dryRun=true":""}`,Oe("POST",{userVerdict:s})).then(o=>Fe(o)),aiFixSummary:e=>_e(`/api/pro/prs/${e}/summary`),refreshAiFixSummary:e=>fetch(`/api/pro/prs/${e}/summary/refresh`,Oe("POST")).then(s=>Fe(s)),aiFixCiAnalysis:e=>_e(`/api/pro/prs/${e}/ci-analysis`),refreshAiFixCiAnalysis:(e,s)=>fetch(`/api/pro/prs/${e}/ci-analysis`,Oe("POST",{checks:s})).then(a=>Fe(a)),aiFix:e=>_e(`/api/pro/prs/${e}/ai-fix`),aiFixStatus:e=>_e(`/api/pro/prs/${e}/ai-fix/status`),startAiFix:(e,s)=>fetch(`/api/pro/prs/${e}/ai-fix`,Oe("POST",s)).then(a=>Fe(a)),cancelAiFix:e=>fetch(`/api/pro/prs/${e}/ai-fix/cancel`,Oe("POST")).then(s=>Fe(s)),pushAiFix:(e,s)=>fetch(`/api/pro/ai-fixes/${e}/push`,Oe("POST",s)).then(a=>Fe(a)),aiFixMergePreview:e=>fetch(`/api/pro/ai-fixes/${e}/merge-preview`,Oe("POST")).then(s=>Fe(s)),startAiFixRebase:(e,s)=>fetch(`/api/pro/ai-fixes/${e}/rebase`,Oe("POST",s)).then(a=>Fe(a)),cancelAiFixRebase:e=>fetch(`/api/pro/ai-fixes/${e}/rebase/cancel`,Oe("POST")).then(s=>Fe(s)),cancelAiFixPush:e=>fetch(`/api/pro/ai-fixes/${e}/push/cancel`,Oe("POST")).then(s=>Fe(s)),botReviewers:()=>_e("/api/bot-reviewers"),setReviewerOverride:(e,s)=>fetch(`/api/bot-reviewers/${e}`,Oe("PATCH",s)).then(a=>Fe(a)),botAnalytics:e=>_e(`/api/bot-analytics?window=${encodeURIComponent(e)}`),botVendorPrs:(e,s)=>_e(`/api/bot-analytics/${encodeURIComponent(e)}/prs?window=${encodeURIComponent(s)}`),prBotDedup:e=>_e(`/api/prs/${e}/bot-dedup`),botMuteRules:()=>_e("/api/bot-mute-rules"),addBotMuteRule:e=>fetch("/api/bot-mute-rules",Oe("POST",e)).then(s=>Fe(s)),deleteBotMuteRule:e=>fetch(`/api/bot-mute-rules/${e}`,Oe("DELETE")).then(s=>Fe(s))},Sp=e=>{let s;const a=new Set,o=(g,w)=>{const v=typeof g=="function"?g(s):g;if(!Object.is(v,s)){const y=s;s=w??(typeof v!="object"||v===null)?v:Object.assign({},s,v),a.forEach(j=>j(s,y))}},i=()=>s,p={setState:o,getState:i,getInitialState:()=>m,subscribe:g=>(a.add(g),()=>a.delete(g))},m=s=e(o,i,p);return p},bx=(e=>e?Sp(e):Sp),wx=e=>e;function kx(e,s=wx){const a=No.useSyncExternalStore(e.subscribe,No.useCallback(()=>s(e.getState()),[e,s]),No.useCallback(()=>s(e.getInitialState()),[e,s]));return No.useDebugValue(a),a}const Cp=e=>{const s=bx(e),a=o=>kx(s,o);return Object.assign(a,s),a},ml=(e=>e?Cp(e):Cp),Ao=e=>`pr-detail:${e}`,jx=e=>`pr-focus:${e}`,Nx="metrics-detail",Sx="bot-prs";function Au(e){const s=/^(pr-detail|pr-focus):(\d+)$/.exec(e);return s?{kind:s[1],prId:Number(s[2])}:null}const $u="pierre:tabs",Jm="pierre:pinnedTabs";function Rp(e){return{id:e.id,number:typeof e.number=="number"?e.number:0,title:typeof e.title=="string"?e.title:"",repoFullName:typeof e.repoFullName=="string"?e.repoFullName:"",authorLogin:typeof e.authorLogin=="string"?e.authorLogin:null,authorDisplayName:typeof e.authorDisplayName=="string"?e.authorDisplayName:null,authorAvatarUrl:typeof e.authorAvatarUrl=="string"?e.authorAvatarUrl:null}}function Cx(){try{const e=localStorage.getItem($u);if(e){const a=JSON.parse(e);if(Array.isArray(a))return a.filter(o=>o!=null&&typeof o=="object"&&typeof o.key=="string").map(o=>{const i=Au(o.key);return i?{key:o.key,kind:i.kind,prId:i.prId,meta:o.meta!=null&&typeof o.meta=="object"?Rp(o.meta):null}:null}).filter(o=>o!=null)}const s=localStorage.getItem(Jm);if(s){const a=JSON.parse(s);if(Array.isArray(a))return a.filter(o=>o!=null&&typeof o=="object"&&typeof o.id=="number").map(o=>{const i=Rp(o);return{key:Ao(i.id),kind:"pr-detail",prId:i.id,meta:i}})}}catch{}return[]}function Co(e){try{localStorage.setItem($u,JSON.stringify(e.filter(s=>s.kind==="pr-detail"||s.kind==="pr-focus")))}catch{}}function Rx(e,s){return e.number===s.number&&e.title===s.title&&e.repoFullName===s.repoFullName&&e.authorLogin===s.authorLogin&&e.authorDisplayName===s.authorDisplayName&&e.authorAvatarUrl===s.authorAvatarUrl}const De=ml((e,s)=>{const a=(o,i)=>{const u=s(),d=(i==null?void 0:i.fromActivity)??u.activeTab==="activity",p=u.tabs.some(g=>g.key===o.key),m=p?u.tabs.map(g=>g.key===o.key&&o.meta!=null?{...g,meta:o.meta}:g):[...u.tabs,o];if(d&&!u.activityReturnArmed)try{history.pushState({pierreTab:1},"")}catch{}(!p||o.meta!=null)&&Co(m),e({tabs:m,activeTab:o.key,activityReturnArmed:d||u.activityReturnArmed,activityReturnItemId:d?(i==null?void 0:i.returnItemId)??null:u.activityReturnItemId,boardReturnTabKey:d?null:u.boardReturnTabKey})};return{tabs:Cx(),activeTab:"timeline",activityReturnArmed:!1,activityReturnItemId:null,activityFlashItemId:null,boardReturnTabKey:null,pin:o=>e(i=>{const u=Ao(o.id);if(i.tabs.some(p=>p.key===u))return i;const d=[...i.tabs,{key:u,kind:"pr-detail",prId:o.id,meta:o}];return Co(d),{tabs:d}}),openPrDetailTab:(o,i)=>a({key:Ao(o.id),kind:"pr-detail",prId:o.id,meta:o},i),openPrFocusTab:(o,i)=>a({key:jx(o.id),kind:"pr-focus",prId:o.id,meta:o},i),openMetricsTab:o=>a({key:Nx,kind:"metrics-detail",prId:0,meta:null},o),openBotPrsTab:o=>a({key:Sx,kind:"bot-prs",prId:0,meta:null},o),syncMeta:o=>e(i=>{let u=!1;const d=i.tabs.map(p=>p.prId!==o.id||p.meta==null||Rx(p.meta,o)?p:(u=!0,{...p,meta:o}));return u?(Co(d),{tabs:d}):i}),closeTab:o=>e(i=>{const u=i.tabs.findIndex(g=>g.key===o);if(u===-1)return i;const d=i.tabs.filter(g=>g.key!==o);Co(d);const p=i.boardReturnTabKey===o?null:i.boardReturnTabKey;if(i.activeTab!==o)return{tabs:d,boardReturnTabKey:p};const m=u-1>=0?i.tabs[u-1].key:d.length>0?d[0].key:"timeline";return{tabs:d,activeTab:m,boardReturnTabKey:p}}),unpin:o=>s().closeTab(Ao(o)),setActiveTab:o=>e({activeTab:o}),showTimeline:()=>{s().activeTab!=="timeline"&&e({activeTab:"timeline"})},showBoardFromDetail:()=>{const o=s(),i=Au(o.activeTab);if((i==null?void 0:i.kind)==="pr-detail"&&o.activityReturnArmed&&o.boardReturnTabKey==null){try{history.pushState({pierreTab:1},"")}catch{}e({activeTab:"timeline",boardReturnTabKey:o.activeTab});return}o.activeTab!=="timeline"&&e({activeTab:"timeline"})},showActivity:()=>{s().activeTab!=="activity"&&e({activeTab:"activity"})},navigateBack:()=>{const o=s();if(o.boardReturnTabKey!=null){const i=o.tabs.some(u=>u.key===o.boardReturnTabKey);e({activeTab:i?o.boardReturnTabKey:"timeline",boardReturnTabKey:null});return}o.activityReturnArmed&&e({activeTab:"activity",activityReturnArmed:!1,activityFlashItemId:o.activityReturnItemId,activityReturnItemId:null})},clearActivityFlashItem:()=>{s().activityFlashItemId!=null&&e({activityFlashItemId:null})},clear:()=>{try{localStorage.removeItem($u),localStorage.removeItem(Jm)}catch{}e({tabs:[],activeTab:"timeline",activityReturnArmed:!1,activityReturnItemId:null,activityFlashItemId:null,boardReturnTabKey:null})}}}),cl=["review_comments","pr_comments","commits"],Oo=cl.filter(e=>e!=="commits"),ul=hx,dl=gx,Do=[...dl],Bo=ul.filter(e=>e!=="closed"),Ip=1440*60*1e3,Ix={"7d":7,"14d":14,"30d":30,"90d":90};function Es(e,s){return e.includes(s)?e.filter(a=>a!==s):[...e,s]}function Go(){return{repoIds:null,userIds:null,excludeBots:!1,allowedBotIds:[],excludeStale:!0,preset:"14d",customFrom:null,customTo:null,categories:[...Oo],prStatuses:[...Bo],reviewStates:[...Do],derivedStates:[],searchQuery:"",stripFilter:"all"}}function gu(e){return{repoIds:e.repoIds,userIds:e.userIds,excludeBots:e.excludeBots,allowedBotIds:e.allowedBotIds,excludeStale:e.excludeStale,preset:e.preset,customFrom:e.customFrom,customTo:e.customTo,categories:e.categories,prStatuses:e.prStatuses,reviewStates:e.reviewStates,derivedStates:e.derivedStates,searchQuery:e.searchQuery,stripFilter:e.stripFilter}}function Yo(e){const s=Go(),a={};for(const o of Object.keys(s))o in e&&e[o]!==void 0&&(a[o]=e[o]);return a}function Ps(e,s){if(e==null||s==null)return e===s;if(e.length!==s.length)return!1;const a=new Set(e);return s.every(o=>a.has(o))}function Tx(e,s){const a={...Go(),...Yo(e)};return Ps(a.repoIds,s.repoIds)&&Ps(a.userIds,s.userIds)&&a.excludeBots===s.excludeBots&&Ps(a.allowedBotIds,s.allowedBotIds)&&a.excludeStale===s.excludeStale&&a.preset===s.preset&&(a.preset!=="custom"||a.customFrom===s.customFrom&&a.customTo===s.customTo)&&Ps(a.categories,s.categories)&&Ps(a.prStatuses,s.prStatuses)&&Ps(a.reviewStates,s.reviewStates)&&Ps(a.derivedStates,s.derivedStates)&&a.searchQuery===s.searchQuery&&a.stripFilter===s.stripFilter}function Ex(){return{...Go(),feedMyTurnOnly:!1,feedClaudeOnly:!1,feedBotLens:"all",botAnalyticsWindow:"rolling_14",selectedPrId:null,selectedThreadId:null,threadBotFilter:null,selectedCommentId:null,activityFocus:null,commentFocus:null,claudeTabFocus:null,changesThreadFocus:null,aiFixTabFocus:null,metricsFocus:null,botPrsFocus:null,stripCollapsed:!0,activityRepoId:"feed",activityThreadFilter:null,expandedFileGroups:[],collapsedFileGroups:[],expandedDiffHunks:[],timelineFocusPr:null,timelineFocusAt:null,timelineFocusEvent:null,timelineCenterAt:null,rangeResetSignal:0,syncModalSignal:0,syncModalRepoId:null,claudeReviewKickoff:0}}const te=ml((e,s)=>({...Ex(),setRepoIds:a=>e({repoIds:a}),toggleRepo:a=>e(o=>({repoIds:Es(o.repoIds??[],a)})),showRepo:a=>{const{repoIds:o}=s();o==null||o.includes(a)||e({repoIds:[...o,a]})},setUserIds:a=>e({userIds:a}),setExcludeBots:a=>e({excludeBots:a}),setAllowedBotIds:a=>e({allowedBotIds:a}),toggleAllowedBot:a=>e(o=>({allowedBotIds:Es(o.allowedBotIds,a)})),setExcludeStale:a=>e({excludeStale:a}),setPreset:a=>e(o=>({preset:a,rangeResetSignal:o.rangeResetSignal+1})),setCustomRange:(a,o)=>e({preset:"custom",customFrom:a,customTo:o}),toggleCategory:a=>e(o=>({categories:Es(o.categories,a)})),setCategories:a=>e({categories:a}),togglePrStatus:a=>e(o=>({prStatuses:Es(o.prStatuses,a)})),setPrStatuses:a=>e({prStatuses:a}),toggleReviewState:a=>e(o=>({reviewStates:Es(o.reviewStates,a)})),setReviewStates:a=>e({reviewStates:a}),toggleDerivedState:a=>e(o=>({derivedStates:Es(o.derivedStates,a)})),setDerivedStates:a=>e({derivedStates:a}),toggleFeedMyTurnOnly:()=>e(a=>({feedMyTurnOnly:!a.feedMyTurnOnly,feedClaudeOnly:!1})),setFeedMyTurnOnly:a=>e(a?{feedMyTurnOnly:!0,feedClaudeOnly:!1}:{feedMyTurnOnly:!1}),toggleFeedClaudeOnly:()=>e(a=>({feedClaudeOnly:!a.feedClaudeOnly,feedMyTurnOnly:!1})),setFeedClaudeOnly:a=>e(a?{feedClaudeOnly:!0,feedMyTurnOnly:!1}:{feedClaudeOnly:!1}),cycleFeedBotLens:()=>e(a=>({feedBotLens:a.feedBotLens==="all"?"hide":a.feedBotLens==="hide"?"only":"all"})),setFeedBotLens:a=>e({feedBotLens:a}),setBotAnalyticsWindow:a=>e({botAnalyticsWindow:a}),setThreadBotFilter:a=>e(o=>({threadBotFilter:o.threadBotFilter===a?null:a})),selectPr:a=>e({selectedPrId:a,selectedThreadId:null,selectedCommentId:null,threadBotFilter:null}),selectThread:(a,o)=>e(i=>({selectedPrId:a??i.selectedPrId,selectedThreadId:o,selectedCommentId:null})),clearSelection:()=>e({selectedPrId:null,selectedThreadId:null,selectedCommentId:null,threadBotFilter:null}),openPrFocused:(a,o=null,i=null,u=null)=>{De.getState().showBoardFromDetail(),e({selectedPrId:a,selectedThreadId:o,selectedCommentId:null,timelineFocusPr:a,timelineFocusAt:i,timelineFocusEvent:u})},showEventOnTimeline:(a,o,i)=>{De.getState().showBoardFromDetail(),e({selectedPrId:a,timelineFocusPr:a,timelineFocusAt:o,timelineFocusEvent:i})},focusEventInTab:(a,o,i,u=null)=>e({selectedPrId:a,selectedThreadId:u,selectedCommentId:null,timelineFocusPr:a,timelineFocusAt:o,timelineFocusEvent:i}),consumeTimelineFocus:()=>e({timelineFocusPr:null,timelineFocusAt:null,timelineFocusEvent:null}),centerTimelineNow:()=>{De.getState().showTimeline(),e({timelineCenterAt:Date.now()})},consumeTimelineCenter:()=>e({timelineCenterAt:null}),showActivityEntry:(a,o)=>e({selectedPrId:a,selectedThreadId:null,selectedCommentId:null,activityFocus:{prId:a,...o}}),consumeActivityFocus:()=>e({activityFocus:null}),showPrComment:(a,o)=>e({selectedPrId:a,selectedThreadId:null,selectedCommentId:o,commentFocus:{prId:a,commentId:o}}),consumeCommentFocus:()=>e({commentFocus:null}),openClaudeReview:(a,o)=>{De.getState().openPrDetailTab(a,o),e({selectedPrId:a.id,selectedThreadId:null,selectedCommentId:null,claudeTabFocus:{prId:a.id}})},consumeClaudeTabFocus:()=>e({claudeTabFocus:null}),showThreadInChanges:(a,o)=>e({changesThreadFocus:{prId:a,threadId:o}}),consumeChangesThreadFocus:()=>e({changesThreadFocus:null}),openAiFixFromReview:(a,o)=>e({selectedPrId:a,selectedThreadId:null,selectedCommentId:null,aiFixTabFocus:{prId:a,reviewText:o}}),consumeAiFixTabFocus:()=>e({aiFixTabFocus:null}),openMetricsDetail:a=>{e({metricsFocus:a}),De.getState().openMetricsTab({fromActivity:!0})},consumeMetricsFocus:()=>e({metricsFocus:null}),openBotPrsDetail:a=>{e({botPrsFocus:a}),De.getState().openBotPrsTab({fromActivity:!0})},consumeBotPrsFocus:()=>e({botPrsFocus:null}),requestSyncModal:a=>e(o=>({syncModalSignal:o.syncModalSignal+1,syncModalRepoId:a})),bumpClaudeReviewKickoff:()=>e(a=>({claudeReviewKickoff:a.claudeReviewKickoff+1})),setStripCollapsed:a=>e({stripCollapsed:a}),setStripFilter:a=>e({stripFilter:a}),setActivityRepo:a=>e(o=>o.activityRepoId===a?{}:{activityRepoId:a,activityThreadFilter:null}),setActivityThreadFilter:a=>e(o=>({activityThreadFilter:o.activityThreadFilter===a?null:a})),setSearchQuery:a=>e({searchQuery:a}),toggleFileGroup:(a,o)=>e(i=>{const u=o?!i.collapsedFileGroups.includes(a):i.expandedFileGroups.includes(a);return o?{collapsedFileGroups:u?[...i.collapsedFileGroups,a]:i.collapsedFileGroups.filter(d=>d!==a)}:{expandedFileGroups:u?i.expandedFileGroups.filter(d=>d!==a):[...i.expandedFileGroups,a]}}),toggleDiffHunk:a=>e(o=>({expandedDiffHunks:Es(o.expandedDiffHunks,a)})),resetAllFilters:()=>e(a=>({...Go(),rangeResetSignal:a.rangeResetSignal+1})),hydrate:a=>e(a)}));function $o(e){return Px(e)}function Px(e){if(e.preset==="custom"&&(e.customFrom||e.customTo)){const o=e.customTo?new Date(`${e.customTo}T23:59:59Z`):new Date;return{from:e.customFrom?new Date(`${e.customFrom}T00:00:00Z`):new Date(o.getTime()-14*Ip),to:o}}const s=Ix[e.preset==="custom"?"14d":e.preset],a=new Date;return{from:new Date(a.getTime()-s*Ip),to:a}}function Zm(e){const s=new Set(e);return s.add("lifecycle"),s.add("reviews"),Object.keys(kp).filter(a=>s.has(kp[a]))}function Tp(e){return new Date(Math.floor(e.getTime()/6e4)*6e4)}function eh(e,s=!0){const a=new URLSearchParams;return e.repoIds&&e.repoIds.length>0&&a.set("repoIds",e.repoIds.join(",")),s&&e.userIds&&e.userIds.length>0&&a.set("userIds",e.userIds.join(",")),a.toString()}function th(e,s=!0,a=!0,o=!0,i=!0,u,d=!0,p){if(p&&p.length>0)return`prIds=${p.join(",")}`;const{from:m,to:g}=$o(e),w=u!=null&&u<m.getTime()?new Date(u):m,v=new URLSearchParams;return v.set("from",Tp(w).toISOString()),v.set("to",Tp(g).toISOString()),e.repoIds&&e.repoIds.length>0&&v.set("repoIds",e.repoIds.join(",")),s&&e.userIds&&e.userIds.length>0&&v.set("userIds",e.userIds.join(",")),e.categories.length<cl.length&&v.set("types",Zm(e.categories).join(",")),a&&e.prStatuses.length<ul.length&&v.set("statuses",e.prStatuses.join(",")),i&&e.reviewStates.length<dl.length&&v.set("reviewStates",e.reviewStates.join(",")),d?(v.set("excludeBots",String(e.excludeBots)),e.excludeBots&&e.allowedBotIds.length>0&&v.set("allowBotIds",e.allowedBotIds.join(","))):v.set("excludeBots","false"),o&&e.excludeStale&&v.set("excludeStale","true"),v.toString()}function Mr(){return qe({queryKey:["repos"],queryFn:ge.listRepos})}function $n(){return qe({queryKey:["users"],queryFn:ge.listUsers})}function Mu(){return qe({queryKey:["mergers"],queryFn:ge.mergers})}function nh(e){const s=te(a=>th(a,!(e!=null&&e.dropMembers),!0,!0,!0,(e==null?void 0:e.fromMs)??null,!0,e==null?void 0:e.prIds));return qe({queryKey:["timeline",s],queryFn:()=>ge.timeline(s),placeholderData:a=>a})}function Fu(){const e=te(s=>th(s,!1,!1,!1,!1,null,!1));return qe({queryKey:["timeline",e],queryFn:()=>ge.timeline(e),placeholderData:s=>s})}function rh(){const e=te(eh);return qe({queryKey:["open-prs",e],queryFn:()=>ge.openPrs(e),placeholderData:s=>s})}function Lu(){const e=te(s=>eh(s,!1));return qe({queryKey:["open-prs",e],queryFn:()=>ge.openPrs(e),placeholderData:s=>s})}function _u(){return qe({queryKey:["me"],queryFn:ge.me,retry:!1})}function yn(){var e;return((e=_u().data)==null?void 0:e.pro)??{activityDigest:!1,reviewMemory:!1,aiAnalysis:!1,prSummary:!1,aiFix:!1,teamInsights:!1,claudeReview:!1,slackDigest:!1,issueLinks:!1}}function sh(){return qe({queryKey:["my-turn"],queryFn:ge.myTurn})}function ah(e){return qe({queryKey:["repo-analytics",e],queryFn:()=>ge.repoAnalytics(e),enabled:e!=null})}const Ou=["activity","consolidated-feed","feed-head","repo-digests","team-insights","sprint-report"];function Ax(e,s){const a=new URLSearchParams;return s&&s.length>0&&a.set("userIds",s.join(",")),a.toString()}function $x(e,s){const a=Ax(e,s);return qe({queryKey:["activity",a],queryFn:()=>ge.inbox(a),staleTime:1/0,refetchOnMount:!1,placeholderData:o=>o})}function Yn(e,s,a=!0){const o=x.useRef(s);o.current=s,x.useEffect(()=>{if(!a)return;function i(u){const d=e.current;d&&!d.contains(u.target)&&o.current()}return document.addEventListener("pointerdown",i,!0),()=>document.removeEventListener("pointerdown",i,!0)},[e,a])}const Mx={lifecycle:"PR state events",reviews:"Reviews",review_comments:"Review comments",pr_comments:"PR comments",commits:"Commits"},Fx={approved:"Approved",changes_requested:"Changes requested",commented:"Commented",dismissed:"Dismissed",pending:"Pending"},Lx={approved:"#22c55e",changes_requested:"#f97316",commented:"#9ca3af",dismissed:"#9ca3af",pending:"#9ca3af"};function Ep(e,s){if(e.length!==s.length)return!1;const a=new Set(e);return s.every(o=>a.has(o))}function _x({categories:e,onToggleCategory:s,onSetCategories:a,reviewStates:o,onToggleReviewState:i,onSetReviewStates:u}){const[d,p]=x.useState(!1),m=x.useRef(null),g=Ep(e,Oo)&&Ep(o,Do),w=e.length+o.length,v=cl.length+dl.length,y=()=>{a([...Oo]),u([...Do])};return Yn(m,()=>p(!1),d),x.useEffect(()=>{if(!d)return;const j=R=>{R.key==="Escape"&&(R.stopPropagation(),p(!1))};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[d]),n.jsxs("div",{ref:m,className:"relative",children:[n.jsxs("span",{className:"inline-flex items-center whitespace-nowrap rounded-full border border-gray-300 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[n.jsxs("button",{type:"button",onClick:()=>p(j=>!j),"aria-haspopup":"true","aria-expanded":d,className:`inline-flex items-center gap-1 py-0.5 pl-2.5 ${g?"pr-2.5":"pr-1"}`,children:["Events",g?"":` (${w})`,n.jsx("span",{"aria-hidden":!0,className:"text-[9px]",children:"▾"})]}),!g&&n.jsx("button",{type:"button",onClick:y,title:"Reset event filters to default","aria-label":"Reset event filters to default",className:"py-0.5 pl-0.5 pr-2 opacity-60 hover:opacity-100",children:"✕"})]}),d&&n.jsxs("div",{role:"dialog","aria-label":"Event types",className:"absolute left-0 top-full z-[60] mt-1 w-60 rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[n.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[n.jsx("p",{className:"px-1 pb-0.5 pt-1 text-[11px] uppercase tracking-wide text-gray-400",children:"Reviews"}),dl.map(j=>n.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[n.jsx("input",{type:"checkbox",checked:o.includes(j),onChange:()=>i(j)}),n.jsx("span",{"aria-hidden":!0,className:"h-2.5 w-2.5 shrink-0 rounded-full",style:{backgroundColor:Lx[j]}}),n.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:Fx[j]})]},j)),n.jsx("div",{className:"my-1 border-t border-gray-200 dark:border-gray-700"}),cl.map(j=>n.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[n.jsx("input",{type:"checkbox",checked:e.includes(j),onChange:()=>s(j)}),n.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:Mx[j]})]},j))]}),!g&&n.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-gray-200 pt-2 dark:border-gray-700",children:[n.jsxs("span",{className:"text-[11px] text-gray-400",children:[w," of ",v," shown"]}),n.jsx("button",{type:"button",onClick:y,className:"text-[11px] text-gray-400 hover:text-gray-600",children:"Reset to default"})]})]})]})}function Ox(e,s=300){const[a,o]=x.useState(e);return x.useEffect(()=>{const i=setTimeout(()=>o(e),s);return()=>clearTimeout(i)},[e,s]),a}const Dx=[{owner:"mrdoob",name:"three.js",category:"Graphics",why:"The de-facto JavaScript 3D library (WebGL/WebGPU) behind most browser 3D and creative coding."},{owner:"bevyengine",name:"bevy",category:"Game engines",why:"A refreshingly simple, data-driven game engine in Rust with one of open source’s most active engine communities."},{owner:"obsproject",name:"obs-studio",category:"Media",why:"The industry-standard open-source live-streaming and screen-recording suite."},{owner:"huggingface",name:"transformers",category:"Machine learning",why:"The model-definition framework behind state-of-the-art NLP/vision/audio models; hub of the open ML ecosystem."},{owner:"pytorch",name:"pytorch",category:"Machine learning",why:"Meta’s deep-learning framework that dominates research and increasingly production training."},{owner:"ollama",name:"ollama",category:"Machine learning",why:"The easiest way to run open LLMs locally; explosive recent adoption."},{owner:"ggml-org",name:"llama.cpp",category:"Machine learning",why:"Highly optimized C/C++ LLM inference that made local, quantized model serving mainstream."},{owner:"numpy",name:"numpy",category:"Scientific computing",why:"The foundational N-dimensional array library underpinning essentially all of Python’s scientific stack."},{owner:"pola-rs",name:"polars",category:"Data science",why:"A blazing-fast multi-threaded DataFrame query engine in Rust; the modern challenger to pandas."},{owner:"jupyter",name:"notebook",category:"Data science",why:"The interactive notebook that became the lingua franca of data science and research computing."},{owner:"rust-lang",name:"rust",category:"Languages",why:"The Rust language and compiler; a memory-safe systems language topping developer-love surveys."},{owner:"golang",name:"go",category:"Languages",why:"Google’s Go language and toolchain; the backbone of modern cloud and infrastructure software."},{owner:"ziglang",name:"zig",category:"Languages",why:"A fast-growing low-level language aiming to be a simpler, safer C; also a drop-in C/C++ compiler."},{owner:"duckdb",name:"duckdb",category:"Databases",why:"An in-process analytical SQL database — the “SQLite for analytics” — surging across data tooling."},{owner:"redis",name:"redis",category:"Databases",why:"The ubiquitous in-memory data store used for caching, queues, and real-time data."},{owner:"cockroachdb",name:"cockroach",category:"Databases",why:"A distributed, PostgreSQL-compatible SQL database built for resilience and horizontal scale."},{owner:"sveltejs",name:"svelte",category:"Web frameworks",why:"A compiler-first UI framework producing tiny, fast apps; consistently top-rated for satisfaction."},{owner:"denoland",name:"deno",category:"Runtimes",why:"A secure, TypeScript-first JavaScript runtime from Node’s original creator."},{owner:"neovim",name:"neovim",category:"Dev tools",why:"The hyperextensible, Lua-scriptable Vim fork that became the modern terminal editor of choice."},{owner:"openssl",name:"openssl",category:"Security",why:"The cryptography and TLS library securing a huge fraction of the internet’s traffic."},{owner:"d3",name:"d3",category:"Visualization",why:"The canonical library for bespoke, data-driven SVG/Canvas visualizations."},{owner:"tldraw",name:"tldraw",category:"Visualization",why:"An infinite-canvas drawing SDK and whiteboard; a slick showcase of modern web UI and real-time collab."}],Vc=2,Bx=["repos","timeline","open-prs","users","my-turn","me",...Ou];function Pp(e){return e>=1e6?`${(e/1e6).toFixed(1)}m`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function Ap({login:e,src:s}){return s?n.jsx("img",{src:s,alt:e,width:20,height:20,className:"mt-0.5 h-5 w-5 shrink-0 rounded-full"}):n.jsx("span",{className:"mt-0.5 flex h-5 w-5 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",children:e.slice(0,2).toUpperCase()})}function $p(){return n.jsx("span",{className:"inline-block h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-gray-300 border-t-blue-500 dark:border-gray-600 dark:border-t-blue-400"})}function zx(){var Pe,se;const e=Be(),s=te(Z=>Z.requestSyncModal),a=te(Z=>Z.showRepo),o=x.useRef(null),i=x.useRef(null),u=x.useId(),[d,p]=x.useState(""),[m,g]=x.useState(!1),[w,v]=x.useState(0),[y,j]=x.useState(new Set),R=Z=>`${Z.owner}/${Z.name}`.toLowerCase(),[P,E]=x.useState([null]),[S,T]=x.useState(0),N=d.trim(),b=Ox(N,300),I=m&&b.length>=Vc,$=m&&b.length<Vc,L=I||$,q=P[S]??null,{data:Q}=Mr(),_=((Q==null?void 0:Q.length)??0)>=jp,Y=x.useMemo(()=>new Set((Q??[]).map(Z=>`${Z.owner}/${Z.name}`.toLowerCase())),[Q]),X=x.useMemo(()=>Dx.filter(Z=>!Y.has(`${Z.owner}/${Z.name}`.toLowerCase())&&!y.has(`${Z.owner}/${Z.name}`.toLowerCase())),[Y,y]);x.useEffect(()=>{E([null]),T(0),v(0)},[b]);const B=qe({queryKey:["repo-search",b,q],queryFn:()=>ge.searchRepos(b,q??void 0),enabled:I,placeholderData:Z=>Z,staleTime:6e4}),O=Ue({mutationFn:Z=>ge.addRepo({owner:Z.owner,name:Z.name,watch:Z.watch}),onMutate:Z=>{j(je=>new Set(je).add(R(Z)))},onSuccess:Z=>{for(const je of Bx)e.invalidateQueries({queryKey:[je]});e.invalidateQueries({queryKey:["repo-search"]}),s(Z.id),a(Z.id)}}),H=(((Pe=B.data)==null?void 0:Pe.results)??[]).filter(Z=>!y.has(`${Z.owner}/${Z.name}`.toLowerCase())),ee=((se=B.data)==null?void 0:se.hasNextPage)??!1,ce=N.length>=Vc&&N!==b,C=I&&(ce||B.isFetching||B.isPlaceholderData),F=$?X:H;x.useEffect(()=>{v(Z=>F.length?Math.min(Z,F.length-1):0)},[F]),Yn(o,()=>g(!1),m),x.useEffect(()=>{var Z,je;(je=(Z=i.current)==null?void 0:Z.querySelector(`[data-idx="${w}"]`))==null||je.scrollIntoView({block:"nearest"})},[w,F]);function K(){var je;const Z=(je=B.data)==null?void 0:je.cursor;!ee||Z==null||(E(We=>[...We.slice(0,S+1),Z]),T(We=>We+1),v(0))}function ae(){S!==0&&(T(Z=>Z-1),v(0))}function ne(Z){if(Z.key==="Escape"){g(!1);return}if(L){if(Z.key==="ArrowDown")Z.preventDefault(),v(je=>Math.min(je+1,Math.max(F.length-1,0)));else if(Z.key==="ArrowUp")Z.preventDefault(),v(je=>Math.max(je-1,0));else if(Z.key==="Enter"){Z.preventDefault();const je=F[w];je&&!O.isPending&&!_&&O.mutate({owner:je.owner,name:je.name,watch:"isOwnedOrMember"in je?je.isOwnedOrMember:void 0})}}}return n.jsxs("div",{ref:o,className:"relative",children:[n.jsx("input",{id:"add-repo-input",type:"search",value:d,onChange:Z=>{p(Z.target.value),g(!0)},onFocus:()=>g(!0),onKeyDown:ne,placeholder:"Search repos to add…",role:"combobox","aria-expanded":L,"aria-controls":u,"aria-autocomplete":"list","aria-activedescendant":L&&F[w]?`${u}-opt-${w}`:void 0,className:"w-44 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"}),L&&n.jsxs("div",{id:u,role:"listbox","aria-label":"Repository search results",className:"absolute left-0 top-full z-[60] mt-1 max-h-96 w-96 overflow-y-auto rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[_&&n.jsxs("div",{className:"sticky top-0 z-20 border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-[11px] text-amber-700 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-300",children:["You’re watching the maximum of ",jp," repos. Remove one to add another."]}),$?n.jsxs("div",{children:[n.jsx("div",{className:"sticky top-0 z-10 border-b border-gray-200 bg-white px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wide text-gray-400 dark:border-gray-700 dark:bg-gray-900",children:"Suggested repos"}),X.length===0?n.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"You’re already watching all the suggestions."}):n.jsx("div",{ref:i,children:X.map((Z,je)=>{var st,Pt;const We=O.isPending&&((st=O.variables)==null?void 0:st.owner)===Z.owner&&((Pt=O.variables)==null?void 0:Pt.name)===Z.name;return n.jsxs("div",{className:`flex items-stretch ${je===w?"bg-gray-100 dark:bg-gray-800":""} hover:bg-gray-100 dark:hover:bg-gray-800`,children:[n.jsxs("button",{id:`${u}-opt-${je}`,"data-idx":je,type:"button",role:"option","aria-selected":je===w,disabled:O.isPending||_,onMouseEnter:()=>v(je),onClick:()=>O.mutate({owner:Z.owner,name:Z.name}),className:"flex min-w-0 flex-1 items-start gap-2 px-3 py-2 text-left disabled:opacity-60",children:[n.jsx(Ap,{login:Z.owner,src:null}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsxs("span",{className:"truncate text-xs font-medium text-gray-800 dark:text-gray-100",title:`${Z.owner}/${Z.name}`,children:[Z.owner,"/",Z.name]}),n.jsx("span",{className:"shrink-0 rounded bg-gray-100 px-1 text-[9px] uppercase tracking-wide text-gray-500 dark:bg-gray-800 dark:text-gray-400",children:Z.category})]}),n.jsx("span",{className:"mt-0.5 line-clamp-2 text-[11px] text-gray-500 dark:text-gray-400",children:Z.why})]}),n.jsx("span",{className:"mt-0.5 shrink-0 rounded bg-blue-600 px-1.5 py-0.5 text-[10px] text-white",children:We?"Adding…":"Add"})]}),n.jsx("a",{href:`https://github.com/${Z.owner}/${Z.name}`,target:"_blank",rel:"noopener noreferrer",onClick:Lt=>Lt.stopPropagation(),title:"Open on GitHub","aria-label":`Open ${Z.owner}/${Z.name} on GitHub`,className:"flex shrink-0 items-center px-2 text-[10px] text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",children:"↗"})]},`${Z.owner}/${Z.name}`)})})]}):B.isError?n.jsx("div",{className:"px-3 py-2 text-xs text-red-500",children:B.error instanceof Gt?B.error.message:"Search failed"}):C&&H.length===0?n.jsxs("div",{className:"flex items-center justify-center gap-2 px-3 py-6 text-xs text-gray-500",children:[n.jsx($p,{}),n.jsx("span",{children:"Searching…"})]}):H.length===0?n.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"No matching repositories."}):n.jsxs("div",{ref:i,children:[C&&n.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-2 border-b border-gray-200 bg-white/95 px-3 py-1.5 text-[11px] text-gray-500 backdrop-blur dark:border-gray-700 dark:bg-gray-900/95 dark:text-gray-400",children:[n.jsx($p,{}),n.jsx("span",{children:"Searching…"})]}),H.map((Z,je)=>{var st,Pt;const We=O.isPending&&((st=O.variables)==null?void 0:st.owner)===Z.owner&&((Pt=O.variables)==null?void 0:Pt.name)===Z.name;return n.jsxs("div",{className:`flex items-stretch ${je===w?"bg-gray-100 dark:bg-gray-800":""} hover:bg-gray-100 dark:hover:bg-gray-800`,children:[n.jsxs("button",{id:`${u}-opt-${je}`,"data-idx":je,type:"button",role:"option","aria-selected":je===w,disabled:O.isPending,onMouseEnter:()=>v(je),onClick:()=>O.mutate({owner:Z.owner,name:Z.name,watch:Z.isOwnedOrMember}),className:"flex min-w-0 flex-1 items-start gap-2 px-3 py-2 text-left disabled:opacity-60",children:[n.jsx(Ap,{login:Z.owner,src:Z.ownerAvatarUrl}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"truncate text-xs font-medium text-gray-800 dark:text-gray-100",title:Z.fullName,children:Z.fullName}),Z.isPrivate&&n.jsx("span",{className:"shrink-0 rounded bg-gray-200 px-1 text-[9px] uppercase tracking-wide text-gray-500 dark:bg-gray-700 dark:text-gray-300",children:"private"}),Z.isOwnedOrMember&&n.jsx("span",{className:"shrink-0 rounded bg-sky-100 px-1 text-[9px] uppercase tracking-wide text-sky-700 dark:bg-sky-900/50 dark:text-sky-300",children:"yours"})]}),Z.description&&n.jsx("span",{className:"mt-0.5 line-clamp-2 text-[11px] text-gray-500 dark:text-gray-400",children:Z.description}),n.jsxs("span",{className:"mt-0.5 flex items-center gap-2 text-[10px] text-gray-400",children:[n.jsxs("span",{title:`${Z.stargazerCount} stars`,children:["★ ",Pp(Z.stargazerCount)]}),n.jsx("span",{"aria-hidden":!0,children:"·"}),n.jsxs("span",{title:`${Z.openPrCount} open pull requests`,children:[Pp(Z.openPrCount)," open PR",Z.openPrCount===1?"":"s"]})]})]}),n.jsx("span",{className:"mt-0.5 shrink-0 rounded bg-blue-600 px-1.5 py-0.5 text-[10px] text-white",children:We?"Adding…":"Add"})]}),n.jsx("a",{href:Z.url||`https://github.com/${Z.owner}/${Z.name}`,target:"_blank",rel:"noopener noreferrer",onClick:Lt=>Lt.stopPropagation(),title:"Open on GitHub","aria-label":`Open ${Z.fullName} on GitHub`,className:"flex shrink-0 items-center px-2 text-[10px] text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",children:"↗"})]},Z.githubNodeId)})]}),!$&&(S>0||ee)&&n.jsxs("div",{className:"sticky bottom-0 flex items-center justify-between border-t border-gray-200 bg-white px-3 py-1.5 text-[11px] dark:border-gray-700 dark:bg-gray-900",children:[n.jsx("button",{type:"button",onClick:ae,disabled:S===0,className:"text-gray-500 hover:text-gray-800 disabled:opacity-30 dark:text-gray-400 dark:hover:text-gray-100",children:"← Prev"}),n.jsxs("span",{className:"text-gray-400",children:["Page ",S+1]}),n.jsx("button",{type:"button",onClick:K,disabled:!ee,className:"text-gray-500 hover:text-gray-800 disabled:opacity-30 dark:text-gray-400 dark:hover:text-gray-100",children:"Next →"})]}),O.error&&n.jsx("div",{className:"border-t border-gray-200 px-3 py-1.5 text-[11px] text-red-500 dark:border-gray-700",children:O.error instanceof Gt?O.error.message:"Failed to add repo"})]})]})}function wN(e){return Math.max(0,Math.round(e*vx))}const jt={untouched:{label:"Untouched",color:"#ef4444",description:"No reply, and no follow-up commit touched the file."},replied_unresolved:{label:"Replied",color:"#f59e0b",description:"Someone replied, but the thread is unresolved and no later commit touched the file."},likely_addressed:{label:"Likely addressed",color:"#3b82f6",description:"A commit touched this file after the last comment. Heuristic — it may be a false positive."},resolved:{label:"Resolved",color:"#22c55e",description:"Marked resolved on GitHub."}},qx={open:{label:"Open",color:"#3b82f6"},merged:{label:"Merged",color:"#22c55e"},closed:{label:"Closed",color:"#9ca3af"}},lh={pr_opened:{label:"PR opened",color:"#3b82f6",shape:"dot"},pr_merged:{label:"PR merged",color:"#8957e5",shape:"dot"},pr_closed:{label:"PR closed",color:"#9ca3af",shape:"dot"},pr_reopened:{label:"PR reopened",color:"#3b82f6",shape:"dot"},pr_ready_for_review:{label:"Ready for review",color:"#3b82f6",shape:"dot"},review_submitted:{label:"Review",color:"#22c55e",shape:"triangle"},review_comment:{label:"Review comment",color:"#f59e0b",shape:"dot"},pr_comment:{label:"PR comment",color:"#a78bfa",shape:"square"},commit_pushed:{label:"Commit",color:"#6b7280",shape:"diamond"}},oh={awaiting_your_review:{label:"Awaiting your review",color:"#3b82f6",myTurn:!0},your_pr_new_comments:{label:"Your PR · new comments",color:"#22c55e",myTurn:!0},ci_failing:{label:"CI failing",color:"#ef4444",myTurn:!1},merge_conflicts:{label:"Merge conflicts",color:"#f97316",myTurn:!1},approved_ready:{label:"Approved · ready to merge",color:"#22c55e",myTurn:!1},stalled:{label:"Stalled",color:"#eab308",myTurn:!1},untouched_threads:{label:"Untouched threads",color:"#f59e0b",myTurn:!1},in_progress:{label:"In progress",color:"#9ca3af",myTurn:!1}},Mp={requested:{label:"Review requested",title:"A review was requested from you on this PR"},authored:{label:"You authored",title:"You opened this PR"},merged:{label:"You merged",title:"You merged this PR"},reviewed:{label:"You reviewed",title:"You previously reviewed this PR"},commented:{label:"You commented",title:"You previously commented on this PR"}},qs={coderabbit:{label:"CodeRabbit",color:"#ff7a45"},greptile:{label:"Greptile",color:"#16a34a"},copilot:{label:"Copilot",color:"#8957e5"},qodo:{label:"Qodo",color:"#7c3aed"},sourcery:{label:"Sourcery",color:"#0d9488"},bito:{label:"Bito",color:"#e11d48"},ellipsis:{label:"Ellipsis",color:"#64748b"},korbit:{label:"Korbit",color:"#2563eb"},baz:{label:"Baz",color:"#db2777"},graphite:{label:"Graphite",color:"#475569"},cursor:{label:"Cursor",color:"#334155"},devin:{label:"Devin",color:"#0891b2"},entelligence:{label:"Entelligence",color:"#ca8a04"},in_house:{label:"In-house AI",color:"#6b7280"},pierre:{label:"Pierre · Claude",color:"#d97757"}};function an(e){return qs[e]}function ih(e){const s=Xm(e==null?void 0:e.githubLogin);return s?{kind:s,...qs[s]}:null}const Ux=new Set(["awaiting_your_review","your_pr_new_comments","ci_failing","merge_conflicts","untouched_threads"]);function Kx(e){return e.isStalled||e.threadCounts.untouched>0||Ux.has(e.reasonTag)}const ur={success:{label:"CI passing",color:"#22c55e"},failure:{label:"CI failing",color:"#ef4444"},error:{label:"CI error",color:"#ef4444"},pending:{label:"CI running",color:"#eab308"},expected:{label:"CI expected",color:"#9ca3af"},unknown:null},Hx={success:{label:"passed",color:"#22c55e",icon:"✓"},failure:{label:"failed",color:"#ef4444",icon:"✕"},pending:{label:"running",color:"#eab308",icon:"•"},neutral:{label:"neutral",color:"#9ca3af",icon:"–"},skipped:{label:"skipped",color:"#9ca3af",icon:"⤼"},error:{label:"error",color:"#ef4444",icon:"!"},unknown:{label:"unknown",color:"#9ca3af",icon:"?"}};function Xo(e,s){return e==="conflicting"||s==="dirty"?"conflicts":s==="behind"?"behind":s==="unstable"?"unstable":null}function ft(e,s){return e?e.displayName||e.githubLogin:s==null?"unknown":`user ${s}`}function Du(e){return`https://github.com/${encodeURIComponent(e)}`}function ch(e,s){const a=s?`@${s} `:"",o=(e??"").trim();return o===""?a:`${o.split(`
26
26
  `).map(u=>`> ${u}`).join(`
27
27
  `)}
28
28
 
29
- ${a}`}function ln(e){const s=new Map;for(const a of e??[])s.set(a.id,a);return s}function Wx(e){return new Date(e).toLocaleDateString(void 0,{day:"2-digit",month:"2-digit",year:"numeric"})}function St(e){const s=new Date(e).getTime(),a=Date.now()-s,o=Math.abs(a),i=6e4,u=60*i,d=24*u,p=(m,g)=>`${m} ${g}${m===1?"":"s"} ago`;return o<i?"just now":o<u?p(Math.round(a/i),"min"):o<d?p(Math.round(a/u),"hour"):o<30*d?p(Math.round(a/d),"day"):Wx(e)}function Ra(e){return new Date(e).toLocaleString(void 0,{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}function kt(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const uh="Watched — new PRs here flow into your My Turn inbox";function Vx(){return`<span class="tl-repo-watch" title="${kt(uh)}" aria-label="Watched repo"><svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><path d="M8 4C4.6 4 1.9 6.2 1 8c.9 1.8 3.6 4 7 4s6.1-2.2 7-4c-.9-1.8-3.6-4-7-4Z" fill="none" stroke="currentColor" stroke-width="1.2"/><circle cx="8" cy="8" r="1.9" fill="currentColor"/></svg></span>`}function Bu({size:e=12,className:s=""}){return n.jsx("span",{className:`inline-flex shrink-0 items-center text-sky-500 ${s}`,title:uh,"aria-label":"Watched repo",children:n.jsxs("svg",{viewBox:"0 0 16 16",width:e,height:e,"aria-hidden":"true",children:[n.jsx("path",{d:"M8 4C4.6 4 1.9 6.2 1 8c.9 1.8 3.6 4 7 4s6.1-2.2 7-4c-.9-1.8-3.6-4-7-4Z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.9",fill:"currentColor"})]})})}function Qx({repos:e,repoIds:s,onToggle:a,onOnly:o,onShowAll:i,onToggleWatch:u,watchPending:d,onRemove:p,removePending:m}){const[g,y]=x.useState(!1),[b,v]=x.useState(""),N=x.useRef(null),I=e.length,P=j=>s==null||s.includes(j),E=s==null?I:s.length,w=s!=null&&E<I;Yn(N,()=>y(!1),g),x.useEffect(()=>{if(!g)return;const j=T=>{T.key==="Escape"&&(T.stopPropagation(),y(!1))};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[g]);const R=b.trim().toLowerCase(),S=e.filter(j=>!R||j.fullName.toLowerCase().includes(R));return n.jsxs("div",{ref:N,className:"relative",children:[n.jsxs("span",{className:"inline-flex items-center whitespace-nowrap rounded-full border border-gray-300 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[n.jsxs("button",{type:"button",onClick:()=>y(j=>!j),"aria-haspopup":"true","aria-expanded":g,className:`inline-flex items-center gap-1 py-0.5 pl-2.5 ${w?"pr-1":"pr-2.5"}`,children:["Repos",I>0?` (${w?`${E}/${I}`:I})`:"",n.jsx("span",{"aria-hidden":!0,className:"text-[9px]",children:"▾"})]}),w&&n.jsx("button",{type:"button",onClick:()=>i(),title:"Show all repos","aria-label":"Show all repos",className:"py-0.5 pl-0.5 pr-2 opacity-60 hover:opacity-100",children:"✕"})]}),g&&n.jsxs("div",{role:"dialog","aria-label":"Repositories",className:"absolute left-0 top-full z-[60] mt-1 w-[28rem] max-w-[calc(100vw-2rem)] rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[I>8&&n.jsx("input",{autoFocus:!0,type:"search",value:b,onChange:j=>v(j.target.value),placeholder:"Filter repos…","aria-label":"Filter repos",className:"mb-2 w-full 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"}),n.jsx("div",{className:"max-h-72 overflow-y-auto",children:I===0?n.jsx("div",{className:"px-1 py-2 text-xs text-gray-500",children:"No repos yet — search to add one."}):S.length===0?n.jsx("div",{className:"px-1 py-2 text-xs text-gray-500",children:"No repos match."}):S.map(j=>{const T=P(j.id)&&E<=1;return n.jsxs("div",{className:"group flex items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[n.jsxs("label",{className:`flex min-w-0 flex-1 items-center gap-2 ${T?"cursor-default":"cursor-pointer"}`,children:[n.jsx("input",{type:"checkbox",checked:P(j.id),disabled:T,onChange:()=>a(j.id),title:T?"At least one repo must stay shown":void 0}),n.jsxs("span",{className:"min-w-0 truncate",title:j.fullName,children:[n.jsxs("span",{className:"text-gray-400",children:[j.owner,"/"]}),n.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-100",children:j.name})]}),j.inboxWatch&&n.jsx(Bu,{size:11}),j.lastSyncStatus==="error"&&n.jsx("span",{className:"shrink-0 text-red-500",title:j.lastSyncError??"Last sync failed","aria-label":"Last sync failed",children:"⚠"})]}),n.jsx("button",{type:"button",onClick:()=>u(j),disabled:d,"aria-pressed":j.inboxWatch,title:j.inboxWatch?`Watching ${j.fullName} — new PRs go to your inbox. Click to stop.`:`Watch ${j.fullName}: new open PRs go to your My Turn inbox`,"aria-label":j.inboxWatch?`Stop watching ${j.fullName} for the inbox`:`Watch ${j.fullName} for the inbox`,className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide disabled:opacity-30 ${j.inboxWatch?"text-sky-600 hover:bg-sky-100 dark:text-sky-400 dark:hover:bg-sky-900/40":"text-gray-400 opacity-0 hover:bg-gray-200 hover:text-gray-700 focus:opacity-100 group-hover:opacity-100 dark:hover:bg-gray-700 dark:hover:text-gray-200"}`,children:j.inboxWatch?"watching":"watch"}),!(P(j.id)&&E===1)&&n.jsx("button",{type:"button",onClick:()=>o(j.id),title:`Show only ${j.fullName}`,"aria-label":`Show only ${j.fullName}`,className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-gray-400 opacity-0 hover:bg-gray-200 hover:text-gray-700 focus:opacity-100 group-hover:opacity-100 dark:hover:bg-gray-700 dark:hover:text-gray-200",children:"only"}),n.jsx("button",{type:"button",onClick:()=>p(j),disabled:m,title:`Remove ${j.fullName}`,"aria-label":`Remove ${j.fullName}`,className:"shrink-0 px-1 text-gray-400 opacity-0 hover:text-red-500 focus:opacity-100 group-hover:opacity-100 disabled:opacity-30",children:"✕"})]},j.id)})}),w&&n.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-gray-200 pt-2 dark:border-gray-700",children:[n.jsxs("span",{className:"text-[11px] text-gray-400",children:[E," of ",I," shown"]}),n.jsx("button",{type:"button",onClick:()=>i(),className:"text-[11px] text-gray-400 hover:text-gray-600",children:"Show all"})]})]})]})}const dh="pierre:savedViews",xu="pierre:activeView";function fh(){try{const e=localStorage.getItem(dh);if(!e)return[];const s=JSON.parse(e);return Array.isArray(s)?s:[]}catch{return[]}}function Gx(){try{const e=localStorage.getItem(xu);return e?fh().find(s=>s.name===e)??null:null}catch{return null}}function Yx(){const[e,s]=x.useState(fh),a=te(p=>{var g;const m=gu(p);return((g=e.find(y=>Tx(y.state,m)))==null?void 0:g.name)??null});x.useEffect(()=>{try{a!=null?localStorage.setItem(xu,a):localStorage.removeItem(xu)}catch{}},[a]);const o=x.useCallback(p=>{const m=[...p].sort((g,y)=>g.name.localeCompare(y.name));s(m);try{localStorage.setItem(dh,JSON.stringify(m))}catch{}},[]),i=x.useCallback(p=>{const m=p.trim();if(!m)return;const g=gu(te.getState());o([...e.filter(y=>y.name!==m),{name:m,state:g}])},[e,o]),u=x.useCallback(p=>o(e.filter(m=>m.name!==p)),[e,o]),d=x.useCallback(p=>{te.getState().hydrate({...Go(p.state),rangeResetSignal:te.getState().rangeResetSignal+1})},[]);return{views:e,activeName:a,save:i,remove:u,apply:d}}function Xx({disabled:e}){const{views:s,activeName:a,save:o,remove:i,apply:u}=Yx(),[d,p]=x.useState(!1),[m,g]=x.useState(""),y=x.useRef(null);Yn(y,()=>p(!1),d);const b=()=>{m.trim()&&(o(m),g(""))};return n.jsxs("div",{ref:y,className:"relative",children:[n.jsx("button",{type:"button",disabled:e,onClick:()=>p(v=>!v),"aria-haspopup":"true","aria-expanded":d,title:e?"Exit focus mode to change filters":a!=null?`Active view: ${a}`:"Saved filter views",className:`inline-flex max-w-[12rem] items-center whitespace-nowrap rounded border px-2 py-0.5 text-xs transition ${e?"cursor-not-allowed border-gray-300 text-gray-600 opacity-45 dark:border-gray-700 dark:text-gray-300":a!=null?"border-blue-400 text-blue-700 hover:border-blue-500 dark:border-blue-600 dark:text-blue-300":"border-gray-300 text-gray-600 hover:border-gray-400 hover:text-gray-800 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500 dark:hover:text-gray-100"}`,children:a!=null?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"shrink-0",children:"Views: "}),n.jsx("span",{className:"min-w-0 truncate font-medium",children:a}),n.jsx("span",{className:"shrink-0",children:" ▾"})]}):n.jsxs(n.Fragment,{children:["Views",s.length>0?` (${s.length})`:""," ▾"]})}),d&&!e&&n.jsxs("div",{className:"absolute right-0 top-full z-[60] mt-1 w-60 rounded-lg border border-gray-200 bg-white p-1.5 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[s.length===0?n.jsx("div",{className:"px-2 py-1.5 text-xs text-gray-500",children:"No saved views yet."}):n.jsx("div",{className:"max-h-60 overflow-auto",children:s.map(v=>{const N=v.name===a;return n.jsxs("div",{className:`flex items-center gap-1 rounded ${N?"bg-blue-50 dark:bg-blue-900/20":"hover:bg-gray-100 dark:hover:bg-gray-800"}`,children:[n.jsxs("button",{type:"button",onClick:()=>{u(v),p(!1)},title:N?`"${v.name}" is active`:`Apply "${v.name}"`,className:`flex min-w-0 flex-1 items-center gap-1 px-2 py-1.5 text-left text-xs ${N?"font-medium text-blue-700 dark:text-blue-300":""}`,children:[n.jsx("span",{"aria-hidden":!0,className:"w-3 shrink-0 text-blue-500",children:N?"✓":""}),n.jsx("span",{className:"min-w-0 truncate",children:v.name})]}),n.jsx("button",{type:"button",onClick:()=>o(v.name),disabled:N,title:N?`"${v.name}" already matches the current filters`:`Overwrite "${v.name}" with the current filters`,"aria-label":`Overwrite view ${v.name} with current filters`,className:"px-1.5 py-1.5 text-xs text-gray-400 hover:text-blue-500 disabled:cursor-default disabled:opacity-30 disabled:hover:text-gray-400",children:"↻"}),n.jsx("button",{type:"button",onClick:()=>i(v.name),title:`Delete "${v.name}"`,"aria-label":`Delete view ${v.name}`,className:"px-2 py-1.5 text-xs text-gray-400 hover:text-red-500",children:"✕"})]},v.name)})}),n.jsxs("div",{className:"mt-1 flex items-center gap-1 border-t border-gray-200 pt-1.5 dark:border-gray-800",children:[n.jsx("input",{type:"text",value:m,placeholder:"Save current as…",onChange:v=>g(v.target.value),onKeyDown:v=>{v.key==="Enter"&&b()},className:"min-w-0 flex-1 rounded border border-gray-300 bg-transparent px-1.5 py-0.5 text-xs focus:border-blue-500 focus:outline-none dark:border-gray-700"}),n.jsx("button",{type:"button",onClick:b,disabled:!m.trim(),className:"shrink-0 rounded border border-blue-400 px-1.5 py-0.5 text-xs text-blue-600 hover:bg-blue-50 disabled:opacity-40 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",children:"Save"})]})]})]})}const Jx={draft:"Draft",open:"Open",merged:"Merged",closed:"Closed"},Fp=!0,Zx="A stale PR is an open PR with no commits, comments or reviews in the selected time range. Unchecked hides them; check to include them.";function ey(e,s){if(e.length!==s.length)return!1;const a=new Set(e);return s.every(o=>a.has(o))}function ty({statuses:e,onToggle:s,onSet:a,excludeStale:o,onExcludeStaleChange:i}){const[u,d]=x.useState(!1),p=x.useRef(null),m=ey(e,Do)&&o===Fp,g=e.length+(o?0:1),y=ul.length+1,b=()=>{a([...Do]),i(Fp)};return Yn(p,()=>d(!1),u),x.useEffect(()=>{if(!u)return;const v=N=>{N.key==="Escape"&&(N.stopPropagation(),d(!1))};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[u]),n.jsxs("div",{ref:p,className:"relative",children:[n.jsxs("span",{className:"inline-flex items-center whitespace-nowrap rounded-full border border-gray-300 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[n.jsxs("button",{type:"button",onClick:()=>d(v=>!v),"aria-haspopup":"true","aria-expanded":u,className:`inline-flex items-center gap-1 py-0.5 pl-2.5 ${m?"pr-2.5":"pr-1"}`,children:["Status",m?"":` (${g})`,n.jsx("span",{"aria-hidden":!0,className:"text-[9px]",children:"▾"})]}),!m&&n.jsx("button",{type:"button",onClick:b,title:"Reset statuses to default","aria-label":"Reset statuses to default",className:"py-0.5 pl-0.5 pr-2 opacity-60 hover:opacity-100",children:"✕"})]}),u&&n.jsxs("div",{role:"dialog","aria-label":"PR statuses",className:"absolute left-0 top-full z-[60] mt-1 w-60 rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[n.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[ul.map(v=>n.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[n.jsx("input",{type:"checkbox",checked:e.includes(v),onChange:()=>s(v)}),n.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:Jx[v]})]},v)),n.jsx("div",{className:"my-1 border-t border-gray-200 dark:border-gray-700"}),n.jsxs("label",{title:Zx,className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[n.jsx("input",{type:"checkbox",checked:!o,onChange:()=>i(!o)}),n.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:"Show stale PRs"})]})]}),!m&&n.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-gray-200 pt-2 dark:border-gray-700",children:[n.jsxs("span",{className:"text-[11px] text-gray-400",children:[g," of ",y," shown"]}),n.jsx("button",{type:"button",onClick:b,className:"text-[11px] text-gray-400 hover:text-gray-600",children:"Reset to default"})]})]})]})}function ny({derivedStates:e,onToggle:s,onClear:a}){const[o,i]=x.useState(!1),u=x.useRef(null),d=e.length>0,p=e.length;return Yn(u,()=>i(!1),o),x.useEffect(()=>{if(!o)return;const m=g=>{g.key==="Escape"&&(g.stopPropagation(),i(!1))};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[o]),n.jsxs("div",{ref:u,className:"relative",children:[n.jsxs("span",{className:"inline-flex items-center whitespace-nowrap rounded-full border border-gray-300 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[n.jsxs("button",{type:"button",onClick:()=>i(m=>!m),"aria-haspopup":"true","aria-expanded":o,className:`inline-flex items-center gap-1 py-0.5 pl-2.5 ${d?"pr-1":"pr-2.5"}`,children:["Threads",d?` (${p})`:"",n.jsx("span",{"aria-hidden":!0,className:"text-[9px]",children:"▾"})]}),d&&n.jsx("button",{type:"button",onClick:a,title:"Clear the thread-state filter","aria-label":"Clear the thread-state filter",className:"py-0.5 pl-0.5 pr-2 opacity-60 hover:opacity-100",children:"✕"})]}),o&&n.jsxs("div",{role:"dialog","aria-label":"Thread states",className:"absolute left-0 top-full z-[60] mt-1 w-64 rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[n.jsx("p",{className:"px-1 pb-1.5 text-[11px] leading-snug text-gray-400",children:"Show only PRs with a review thread that is:"}),n.jsx("div",{className:"max-h-72 overflow-y-auto",children:Pu.map(m=>{const g=jt[m];return n.jsxs("label",{title:g.description,className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[n.jsx("input",{type:"checkbox",checked:e.includes(m),onChange:()=>s(m)}),n.jsx("span",{"aria-hidden":!0,className:"h-2.5 w-2.5 shrink-0 rounded-full",style:{backgroundColor:g.color}}),n.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:g.label})]},m)})}),d&&n.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-gray-200 pt-2 dark:border-gray-700",children:[n.jsxs("span",{className:"text-[11px] text-gray-400",children:[p," selected"]}),n.jsx("button",{type:"button",onClick:a,className:"text-[11px] text-gray-400 hover:text-gray-600",children:"Clear"})]})]})]})}const ry={...Uc,tagNames:[...Uc.tagNames??[],"img"],attributes:{...Uc.attributes,img:["src","alt","title","width","height"]}},cr=x.memo(function({children:s}){return n.jsx("div",{className:"md-body",children:n.jsx(nx,{remarkPlugins:[ax],rehypePlugins:[rx,[sx,ry],[lx,{detect:!0,ignoreMissing:!0}]],components:{a:({node:a,...o})=>n.jsx("a",{...o,target:"_blank",rel:"noreferrer noopener"}),img:({node:a,...o})=>n.jsx("img",{...o,loading:"lazy",referrerPolicy:"no-referrer"})},children:s})})});function sy(){const{data:e}=Mu();return x.useMemo(()=>{const s=new Map;for(const a of e??[])s.set(a.repoId,new Set(a.userIds));return s},[e])}function zu({className:e}){return n.jsxs("svg",{viewBox:"0 0 16 16",width:"11",height:"11","aria-hidden":"true",className:["inline-block shrink-0",e].filter(Boolean).join(" "),children:[n.jsx("title",{children:"Has merge rights — has merged a PR in this repo"}),n.jsx("path",{fill:"#8957e5",d:"M8 .8 2.2 2.9v4.2c0 3.3 2.5 6.4 5.8 7.3 3.3-.9 5.8-4 5.8-7.3V2.9L8 .8Z"}),n.jsx("path",{d:"M5.2 8 7.1 9.9 10.9 6",fill:"none",stroke:"#fff",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})]})}function sn({user:e,fallbackId:s,repoId:a,className:o}){var g;const i=sy(),d=a!=null&&e!=null&&(((g=i.get(a))==null?void 0:g.has(e.id))??!1)?n.jsx(zu,{}):null,p=ft(e,s),m=e!=null&&e.githubLogin?n.jsx("a",{href:Du(e.githubLogin),target:"_blank",rel:"noreferrer noopener",onClick:y=>y.stopPropagation(),title:`@${e.githubLogin} on GitHub`,className:[o,"hover:underline"].filter(Boolean).join(" "),children:p}):n.jsx("span",{className:o,children:p});return d?n.jsxs("span",{className:"inline-flex items-center gap-1",children:[m,d]}):m}function ht({user:e,size:s=24}){const a=ft(e,null);return e!=null&&e.avatarUrl?n.jsx("img",{src:e.avatarUrl,alt:a,width:s,height:s,className:"shrink-0 rounded-full",style:{width:s,height:s}}):n.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-full bg-gray-300 text-[10px] font-semibold text-gray-700 dark:bg-gray-700 dark:text-gray-200",style:{width:s,height:s},children:a.slice(0,2).toUpperCase()})}function Lp(){return n.jsx("span",{className:"flex-none",title:"Maintainer — has merged a PR in the selected repo(s)",children:n.jsxs("svg",{viewBox:"0 0 16 16",width:"11",height:"11","aria-hidden":"true",children:[n.jsx("path",{fill:"#8957e5",d:"M8 .8 2.2 2.9v4.2c0 3.3 2.5 6.4 5.8 7.3 3.3-.9 5.8-4 5.8-7.3V2.9L8 .8Z"}),n.jsx("path",{d:"M5.2 8 7.1 9.9 10.9 6",fill:"none",stroke:"#fff",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})]})})}function ay({sections:e,botSections:s,userIds:a,maintainerIds:o,onApply:i,excludeBots:u,onExcludeBotsChange:d,allowedBotIds:p,onToggleAllowedBot:m}){const[g,y]=x.useState(!1),[b,v]=x.useState(new Set),[N,I]=x.useState(""),P=x.useRef(null),E=(a==null?void 0:a.length)??0,w=()=>{v(new Set(a??[])),I(""),y(!0)},R=N.trim().toLowerCase(),S=X=>!R||X.githubLogin.toLowerCase().includes(R)||(X.displayName??"").toLowerCase().includes(R),j=e.map(X=>({...X,members:X.members.filter(S)})).filter(X=>X.members.length>0),T=e.reduce((X,B)=>X+B.members.length,0),M=new Set(p),D=s.map(X=>({...X,members:X.members.filter(S)})).filter(X=>X.members.length>0);Yn(P,()=>y(!1),g),x.useEffect(()=>{if(!g)return;const X=B=>{B.key==="Escape"&&(B.stopPropagation(),y(!1))};return document.addEventListener("keydown",X),()=>document.removeEventListener("keydown",X)},[g]);const U=X=>v(B=>{const _=new Set(B);return _.has(X)?_.delete(X):_.add(X),_}),G=(X,B)=>v(_=>{const H=new Set(_);for(const ee of X)B?H.add(ee):H.delete(ee);return H}),L=()=>{const X=[...b];i(X.length?X:null),y(!1)},Y=()=>v(new Set);return n.jsxs("div",{ref:P,className:"relative",children:[n.jsxs("span",{className:"inline-flex items-center whitespace-nowrap rounded-full border border-gray-300 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[n.jsxs("button",{type:"button",onClick:()=>g?y(!1):w(),"aria-haspopup":"true","aria-expanded":g,className:`inline-flex items-center gap-1 py-0.5 pl-2.5 ${E>0?"pr-1":"pr-2.5"}`,children:["Members",E>0?` (${E})`:"",n.jsx("span",{"aria-hidden":!0,className:"text-[9px]",children:"▾"})]}),E>0&&n.jsx("button",{type:"button",onClick:()=>{i(null),y(!1)},title:"Clear members filter","aria-label":"Clear members filter",className:"py-0.5 pl-0.5 pr-2 opacity-60 hover:opacity-100",children:"✕"})]}),g&&n.jsxs("div",{role:"dialog","aria-label":"Select members",className:"absolute left-0 top-full z-[60] mt-1 w-80 rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[n.jsx("input",{autoFocus:!0,type:"search",value:N,onChange:X=>I(X.target.value),placeholder:"Filter members…","aria-label":"Filter members",className:"mb-2 w-full 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"}),o.size>0&&(()=>{const X=[...o],B=X.every(_=>b.has(_));return n.jsxs("button",{type:"button",onClick:()=>G(X,!B),title:"Select every maintainer in the current filter",className:`mb-2 flex w-full items-center gap-2 rounded px-2 py-1 text-xs transition ${B?"bg-[#8957e5]/15 text-[#8957e5]":"text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800"}`,children:[n.jsx(Lp,{}),n.jsx("span",{className:"font-medium",children:"Maintainers"}),n.jsxs("span",{className:"text-gray-400",children:["(",X.length,")"]}),n.jsx("span",{className:"ml-auto text-[10px] text-gray-400",children:B?"clear":"select all"})]})})(),n.jsx("div",{className:"max-h-72 overflow-y-auto",children:T===0?n.jsx("div",{className:"px-1 py-2 text-xs text-gray-500",children:"No members in range."}):j.length===0?n.jsx("div",{className:"px-1 py-2 text-xs text-gray-500",children:"No members match."}):j.map(X=>{const B=X.members.map(H=>H.id),_=B.every(H=>b.has(H));return n.jsxs("div",{className:"mb-1 last:mb-0",children:[n.jsxs("div",{className:"sticky top-0 flex items-center justify-between bg-white px-1 pb-0.5 pt-1 dark:bg-gray-900",children:[n.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:X.label}),n.jsx("button",{type:"button",onClick:()=>G(B,!_),className:"text-[10px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:_?"none":"all"})]}),X.members.map(H=>n.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[n.jsx("input",{type:"checkbox",checked:b.has(H.id),onChange:()=>U(H.id)}),n.jsx(ht,{user:H,size:16}),n.jsx("span",{className:"min-w-0 truncate",title:H.githubLogin,children:ft(H,H.id)}),o.has(H.id)&&n.jsx(Lp,{})]},`${X.key}:${H.id}`))]},X.key)})}),n.jsxs("label",{className:"mt-2 flex cursor-pointer items-center gap-2 border-t border-gray-200 pt-2 text-xs text-gray-600 dark:border-gray-700 dark:text-gray-300",children:[n.jsx("input",{type:"checkbox",checked:u,onChange:X=>d(X.target.checked)}),"Exclude bots"]}),D.length>0&&n.jsxs("div",{className:"mt-2 border-t border-gray-200 pt-2 dark:border-gray-700",children:[n.jsxs("div",{className:"mb-1 flex items-center gap-1.5 px-1",children:[n.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"Bots"}),n.jsx("span",{className:"text-[10px] text-gray-400",children:u?"· ticked stay visible":"· all shown (bots not excluded)"})]}),n.jsx("div",{className:"max-h-40 overflow-y-auto",children:D.map(X=>n.jsxs("div",{className:"mb-1 last:mb-0",children:[n.jsx("div",{className:"sticky top-0 bg-white px-1 pb-0.5 pt-1 text-[10px] font-semibold uppercase tracking-wide text-gray-400 dark:bg-gray-900",children:X.label}),X.members.map(B=>n.jsxs("label",{className:`flex items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800 ${u?"cursor-pointer":"cursor-pointer opacity-60"}`,title:u?"Keep this bot visible even though bots are excluded":'Bots are currently shown; enable "Exclude bots" for this to take effect',children:[n.jsx("input",{type:"checkbox",checked:M.has(B.id),onChange:()=>m(B.id)}),n.jsx(ht,{user:B,size:16}),n.jsx("span",{className:"min-w-0 truncate",title:B.githubLogin,children:ft(B,B.id)})]},`${X.key}:${B.id}`))]},X.key))})]}),n.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[n.jsx("button",{type:"button",onClick:Y,className:"text-[11px] text-gray-400 hover:text-gray-600",children:"Clear all"}),n.jsx("button",{type:"button",onClick:L,className:"rounded bg-blue-600 px-2.5 py-0.5 text-xs text-white",children:"Apply"})]})]})]})}const ly=["7d","14d","30d","90d"];function oy({active:e,onClick:s,children:a,color:o,title:i,onRemove:u,removeTitle:d,removeDisabled:p}){const m=`whitespace-nowrap rounded-full border text-xs transition ${e?"border-transparent bg-blue-600 text-white":"border-gray-300 text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500"}`,g=e&&o?{backgroundColor:o}:void 0;return u?n.jsxs("span",{className:`inline-flex items-center ${m}`,style:g,children:[n.jsx("button",{type:"button",onClick:s,title:i,className:"py-0.5 pl-2.5 pr-1",children:a}),n.jsx("button",{type:"button",onClick:u,disabled:p,title:d,"aria-label":d,className:"py-0.5 pl-0.5 pr-2 opacity-50 hover:opacity-100 disabled:opacity-30",children:"✕"})]}):n.jsx("button",{type:"button",onClick:s,title:i,className:`${m} px-2.5 py-0.5`,style:g,children:a})}function ba({label:e,children:s}){return n.jsxs("div",{className:"flex items-center gap-1.5",children:[e!=null&&n.jsx("span",{className:"text-[11px] uppercase tracking-wide text-gray-400",children:e}),s]})}function iy(){const{data:e}=Mr(),{data:s}=$n(),{data:a}=Fu(),{data:o}=Lu(),{data:i}=Mu(),u=te(),p=Oe(w=>w.activeTab)==="activity",m=Be(),g=Ue({mutationFn:w=>ge.deleteRepo(w),onMutate:async w=>{await m.cancelQueries({queryKey:["repos"]});const R=m.getQueryData(["repos"]);return m.setQueryData(["repos"],S=>S==null?void 0:S.filter(j=>j.id!==w)),{previous:R}},onError:(w,R,S)=>{S!=null&&S.previous&&m.setQueryData(["repos"],S.previous)},onSuccess:(w,R)=>{var T;const S=te.getState(),j=(T=S.repoIds)==null?void 0:T.filter(M=>M!==R);S.setRepoIds(j&&j.length?j:null)},onSettled:()=>{for(const w of["repos","timeline","open-prs","users","my-turn","me"])m.invalidateQueries({queryKey:[w]})}}),y=Ue({mutationFn:w=>ge.setRepoInboxWatch(w.id,w.watch),onMutate:async({id:w,watch:R})=>{await m.cancelQueries({queryKey:["repos"]});const S=m.getQueryData(["repos"]);return m.setQueryData(["repos"],j=>j==null?void 0:j.map(T=>T.id===w?{...T,inboxWatch:R}:T)),{previous:S}},onError:(w,R,S)=>{S!=null&&S.previous&&m.setQueryData(["repos"],S.previous)},onSettled:()=>{for(const w of["repos","my-turn","my-turn-done","me",...Ou])m.invalidateQueries({queryKey:[w]})}}),b=w=>{const R=(e??[]).map(j=>j.id),S=new Set(te.getState().repoIds??R);S.has(w)?S.delete(w):S.add(w),u.setRepoIds(S.size===0||S.size===R.length?null:R.filter(j=>S.has(j)))},v=w=>{const R=(e??[]).map(S=>S.id);u.setRepoIds(R.length<=1?null:[w])},N=w=>{window.confirm(`Remove ${w.fullName}? This deletes all of its locally-synced data.`)&&g.mutate(w.id)},{sections:I,botSections:P,maintainerIds:E}=x.useMemo(()=>{const w=u.repoIds!=null&&u.repoIds.length>0,R=w?new Set(u.repoIds):null,S=new Map((s??[]).map(F=>[F.id,F])),j=F=>{if(F==null)return null;const K=S.get(F);return K&&!K.isBot?K:null},T=F=>{if(F==null)return null;const K=S.get(F);return K&&K.isBot?K:null},M=new Map,D=(F,K)=>{if(K==null||R&&!R.has(F))return;let ae=M.get(F);ae||M.set(F,ae=new Set),ae.add(K)};for(const F of(a==null?void 0:a.events)??[])D(F.repoId,F.actorId);for(const F of(a==null?void 0:a.prs)??[])D(F.repoId,F.authorId);for(const F of(o==null?void 0:o.prs)??[])D(F.repoId,F.authorId);const U=new Set;for(const F of i??[])if(!(R&&!R.has(F.repoId)))for(const K of F.userIds)j(K)&&(U.add(K),D(F.repoId,K));const G=(F,K)=>(F.displayName||F.githubLogin).localeCompare(K.displayName||K.githubLogin),L=(F,K)=>{const ae=(U.has(F.id)?0:1)-(U.has(K.id)?0:1);return ae!==0?ae:G(F,K)},Y=[],X=new Set;for(const F of e??[]){if(R&&!R.has(F.id))continue;const K=M.get(F.id);if(!K||K.size===0)continue;const ae=[...K].map(j).filter(ne=>ne!=null).sort(L);if(ae.length){Y.push({key:`repo:${F.id}`,label:F.name,members:ae});for(const ne of ae)X.add(ne.id)}}const B=u.userIds??[],H=[...w?new Set([...X,...B]):new Set((s??[]).filter(F=>!F.isBot).map(F=>F.id))].map(j).filter(F=>F!=null).filter(F=>!X.has(F.id)).sort(G);H.length&&Y.push({key:"other",label:w?"Other":"No recent activity",members:H});const ee=[],ce=new Set;for(const F of e??[]){if(R&&!R.has(F.id))continue;const K=M.get(F.id);if(!K)continue;const ae=[...K].map(T).filter(ne=>ne!=null).sort(G);if(ae.length){ee.push({key:`bot:${F.id}`,label:F.name,members:ae});for(const ne of ae)ce.add(ne.id)}}const C=(u.allowedBotIds??[]).map(T).filter(F=>F!=null).filter(F=>!ce.has(F.id)).sort(G);return C.length&&ee.push({key:"bot:other",label:"Other bots",members:C}),{sections:Y,botSections:ee,maintainerIds:U}},[s,a,o,i,e,u.repoIds,u.userIds,u.allowedBotIds]);return n.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 border-b border-gray-200 bg-gray-50 px-4 py-2 dark:border-gray-800 dark:bg-gray-900",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[n.jsxs(ba,{children:[n.jsx(Qx,{repos:e??[],repoIds:u.repoIds,onToggle:b,onOnly:v,onShowAll:()=>u.setRepoIds(null),onToggleWatch:w=>y.mutate({id:w.id,watch:!w.inboxWatch}),watchPending:!1,onRemove:N,removePending:!1}),g.error&&n.jsx("span",{className:"max-w-[14rem] truncate text-xs text-red-500",title:String(g.error),children:g.error instanceof Gt?g.error.message:"Failed to remove repo"}),n.jsx(zx,{})]}),n.jsx(ba,{children:n.jsx(ay,{sections:I,botSections:P,userIds:u.userIds,maintainerIds:E,onApply:w=>u.setUserIds(w),excludeBots:u.excludeBots,onExcludeBotsChange:u.setExcludeBots,allowedBotIds:u.allowedBotIds,onToggleAllowedBot:u.toggleAllowedBot})}),!p&&n.jsx(ba,{children:n.jsx(ty,{statuses:u.prStatuses,onToggle:u.togglePrStatus,onSet:u.setPrStatuses,excludeStale:u.excludeStale,onExcludeStaleChange:u.setExcludeStale})}),!p&&n.jsx(ba,{children:n.jsx(_x,{categories:u.categories,onToggleCategory:w=>u.toggleCategory(w),onSetCategories:w=>u.setCategories(w),reviewStates:u.reviewStates,onToggleReviewState:w=>u.toggleReviewState(w),onSetReviewStates:w=>u.setReviewStates(w)})}),!p&&n.jsx(ba,{children:n.jsx(ny,{derivedStates:u.derivedStates,onToggle:w=>u.toggleDerivedState(w),onClear:()=>u.setDerivedStates([])})}),!p&&n.jsxs(ba,{label:"Range",children:[ly.map(w=>n.jsx(oy,{active:u.preset===w,onClick:()=>u.setPreset(w),children:w},w)),n.jsx("button",{type:"button",onClick:()=>u.centerTimelineNow(),title:"Recenter the timeline on the current time (keeps the zoom)",className:"whitespace-nowrap rounded-full border border-sky-300 px-2.5 py-0.5 text-xs text-sky-600 transition hover:border-sky-400 hover:bg-sky-50 dark:border-sky-700 dark:text-sky-400 dark:hover:bg-sky-900/30",children:"Now"})]})]}),!p&&n.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[n.jsx(Xx,{disabled:!1}),n.jsx("button",{type:"button",onClick:()=>u.resetAllFilters(),title:"Reset all filters to their defaults",className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-xs text-gray-600 transition hover:border-gray-400 hover:text-gray-800 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500 dark:hover:text-gray-100",children:"Clear filters"})]})]})}function cy(e){if(!e)return null;const s=e.commits+e.comments+e.reviews;return s>0?`${s} new`:null}function uy({pr:e}){const s=ur[e.ciStatus],a=Yo(e.mergeable,e.mergeStateStatus),o=cy(e.newSinceLastViewed),i=e.threadCounts;return n.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px]",children:[s&&n.jsxs("span",{className:"inline-flex items-center gap-1",title:s.label,children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:s.color}}),n.jsx("span",{className:"text-gray-500",children:s.label})]}),a&&n.jsxs("span",{className:"inline-flex items-center gap-0.5 text-orange-500",title:`Merge state: ${a}`,children:["⚠ ",a]}),o&&n.jsxs("span",{className:"inline-flex items-center gap-0.5 font-medium text-sky-500",title:"New since you last looked",children:["👁 ",o]}),i.untouched>0&&n.jsxs("span",{className:"text-red-500",title:"Untouched threads",children:["🔴 ",i.untouched]}),i.replied_unresolved>0&&n.jsxs("span",{className:"text-amber-500",title:"Replied, unresolved",children:["🟡 ",i.replied_unresolved]}),i.likely_addressed>0&&n.jsxs("span",{className:"text-blue-500",title:"Likely addressed",children:["🔵 ",i.likely_addressed]}),i.resolved>0&&n.jsxs("span",{className:"text-green-600",title:"Resolved",children:["✓ ",i.resolved]})]})}function dy({tag:e}){const s=oh[e];return n.jsxs("span",{className:"inline-flex items-center gap-1 truncate text-[11px] font-medium",style:{color:s.color},title:s.label,children:[n.jsx("span",{"aria-hidden":!0,children:"⏵"}),s.label]})}function fy({pr:e,repoFullName:s,repoWatched:a=!1,usersById:o}){const i=te(N=>N.openPrFocused),u=te(N=>N.selectedPrId),d=Be(),p=Ue({mutationFn:N=>ge.dismissPr(N),onSuccess:()=>{d.invalidateQueries({queryKey:["open-prs"]}),d.invalidateQueries({queryKey:["timeline"]}),d.invalidateQueries({queryKey:["my-turn"]}),d.invalidateQueries({queryKey:["me"]})}}),m=e.authorId!=null?o.get(e.authorId):void 0,g=hu(e.reasonTag),y=u===e.id,b=e.newSinceLastViewed,v=!!b&&b.commits+b.comments+b.reviews>0;return n.jsxs("div",{role:"button",tabIndex:0,onClick:()=>i(e.id),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&i(e.id)},className:`relative flex w-52 shrink-0 cursor-pointer flex-col gap-1 rounded-lg border p-2 text-left transition ${y?"border-blue-500 ring-1 ring-blue-500":"border-gray-200 hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-500"} ${g?"my-turn-ring":""} bg-white dark:bg-gray-900`,children:[v&&n.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),p.mutate(e.id)},disabled:p.isPending,className:"absolute right-1.5 top-1.5 rounded px-1 text-[10px] text-gray-400 hover:bg-gray-200/60 hover:text-gray-600 dark:hover:bg-gray-700/60",title:"Mark viewed (clear the new badge)",children:"✓ seen"}),n.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-400",children:[n.jsx("span",{className:"truncate",children:s}),a&&n.jsx(Bu,{size:10}),n.jsx("span",{children:"·"}),n.jsxs("span",{className:"shrink-0",children:["#",e.number]}),n.jsx("a",{href:`https://github.com/${s}/pull/${e.number}`,target:"_blank",rel:"noreferrer noopener",onClick:N=>N.stopPropagation(),className:"shrink-0 text-gray-400 hover:text-blue-500",title:"Open on GitHub",children:"↗"}),e.isDraft&&n.jsx("span",{className:"ml-1 rounded bg-gray-500/20 px-1 text-[9px] uppercase",children:"draft"})]}),n.jsx("div",{className:"line-clamp-2 text-xs font-semibold leading-snug",title:e.title,children:e.title}),n.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-gray-500",children:[n.jsx(ht,{user:m,size:14}),n.jsx("span",{className:"truncate",children:ft(m,e.authorId)}),n.jsx("span",{children:"·"}),n.jsx("span",{className:"shrink-0",children:St(e.openedAt)})]}),n.jsx(uy,{pr:e}),n.jsx("div",{className:"mt-auto pt-0.5",children:n.jsx(dy,{tag:e.reasonTag})})]})}const _p={all:"all open",my_turn:"my turn",needs_attention:"needs attention"};function py(){const{data:e,isLoading:s}=rh(),{data:a}=Mr(),{data:o}=$n(),i=te(M=>M.stripCollapsed),u=te(M=>M.setStripCollapsed),d=te(M=>M.stripFilter),p=te(M=>M.setStripFilter),m=x.useRef(null);x.useEffect(()=>{const M=m.current;M&&(i?M.setAttribute("inert",""):M.removeAttribute("inert"))},[i]);const g=x.useMemo(()=>{const M=new Map;for(const D of a??[])M.set(D.id,{fullName:D.fullName,inboxWatch:D.inboxWatch});return M},[a]),y=x.useMemo(()=>ln(o),[o]),b=(e==null?void 0:e.prs)??[],v=b.filter(M=>hu(M.reasonTag)).length,N=b.filter(M=>M.reasonTag==="stalled").length,I=x.useMemo(()=>[...d==="my_turn"?b.filter(D=>hu(D.reasonTag)):d==="needs_attention"?b.filter(D=>D.reasonTag!=="in_progress"):b].sort((D,U)=>Date.parse(U.openedAt)-Date.parse(D.openedAt)),[b,d]),P=6,E=4,w=x.useRef(null),R=x.useRef(208+P),S=I.length,[j,T]=x.useState({start:0,end:24});return x.useEffect(()=>{const M=w.current;if(!M)return;let D=null;const U=()=>{D=null;const Y=Array.from(M.children).filter(H=>!H.hasAttribute("aria-hidden"));if(Y.length>=2){const H=Y[1].offsetLeft-Y[0].offsetLeft;H>0&&(R.current=H)}const X=R.current,B=Math.max(0,Math.floor(M.scrollLeft/X)-E),_=Math.min(S,Math.ceil((M.scrollLeft+M.clientWidth)/X)+E);T(H=>H.start===B&&H.end===_?H:{start:B,end:_})},G=()=>{D==null&&(D=requestAnimationFrame(U))};U(),M.addEventListener("scroll",G,{passive:!0});const L=new ResizeObserver(G);return L.observe(M),()=>{M.removeEventListener("scroll",G),L.disconnect(),D!=null&&cancelAnimationFrame(D)}},[S,d]),!s&&b.length===0?null:n.jsxs("div",{"data-testid":"open-pr-strip",className:"shrink-0 border-b border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/50",children:[n.jsxs("div",{className:"flex items-center gap-2 px-4 py-1",children:[n.jsx("button",{type:"button",onClick:()=>u(!i),"aria-expanded":!i,title:i?"Expand":"Collapse",className:"text-[11px] font-semibold uppercase tracking-wide text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:"Open PRs"}),!i&&n.jsx("div",{className:"flex items-center gap-1",children:Object.keys(_p).map(M=>n.jsxs("button",{type:"button",onClick:()=>p(M),className:`rounded-full px-2 py-0.5 text-[11px] ${d===M?"bg-blue-600 text-white":"text-gray-500 hover:text-gray-700 dark:hover:text-gray-300"}`,children:[_p[M],M==="my_turn"&&v>0&&` (${v})`]},M))}),i&&n.jsxs("span",{className:"text-xs text-gray-500",children:[b.length," open · ",v," my turn · ",N," stalled"]}),n.jsx("button",{type:"button",onClick:()=>u(!i),className:"ml-auto rounded px-1.5 text-xs text-gray-400 hover:text-gray-600",title:i?"Expand":"Collapse",children:i?"▾":"▴"})]}),n.jsx("div",{ref:m,className:`grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none ${i?"grid-rows-[0fr]":"grid-rows-[1fr]"}`,children:n.jsx("div",{className:"min-h-0 overflow-hidden",children:n.jsx("div",{ref:w,className:"flex items-stretch gap-1.5 overflow-x-auto px-3 pb-1.5 pt-0.5",children:I.length===0?n.jsx("div",{className:"flex items-center text-xs text-gray-500",children:d==="my_turn"?"Nothing needs you right now.":"No PRs match this filter."}):n.jsxs(n.Fragment,{children:[j.start>0&&n.jsx("div",{"aria-hidden":!0,className:"shrink-0",style:{width:j.start*R.current-P}}),I.slice(j.start,j.end).map(M=>{var D,U;return n.jsx(fy,{pr:M,repoFullName:((D=g.get(M.repoId))==null?void 0:D.fullName)??`repo ${M.repoId}`,repoWatched:((U=g.get(M.repoId))==null?void 0:U.inboxWatch)??!1,usersById:y},M.id)}),j.end<S&&n.jsx("div",{"aria-hidden":!0,className:"shrink-0",style:{width:(S-j.end)*R.current}})]})})})})]})}function Xo({size:e=14,className:s,title:a}){return n.jsxs("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:s,"aria-hidden":a==null?!0:void 0,role:a!=null?"img":void 0,children:[a!=null&&n.jsx("title",{children:a}),n.jsx("circle",{cx:"11",cy:"11",r:"8"}),n.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function my({size:e=15,className:s,title:a}){return n.jsxs("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:s,"aria-hidden":a==null?!0:void 0,role:a!=null?"img":void 0,children:[a!=null&&n.jsx("title",{children:a}),n.jsx("line",{x1:"4",y1:"7",x2:"14",y2:"7"}),n.jsx("line",{x1:"9",y1:"12",x2:"20",y2:"12"}),n.jsx("line",{x1:"4",y1:"17",x2:"12",y2:"17"})]})}function hy({size:e=15,className:s,title:a}){return n.jsxs("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"currentColor",className:s,"aria-hidden":a==null?!0:void 0,role:a!=null?"img":void 0,children:[a!=null&&n.jsx("title",{children:a}),n.jsx("path",{d:"M12 .5C5.37.5 0 5.87 0 12.5c0 5.3 3.44 9.8 8.21 11.39.6.11.82-.26.82-.58 0-.29-.01-1.05-.02-2.06-3.34.73-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.09-.75.08-.73.08-.73 1.21.09 1.85 1.24 1.85 1.24 1.07 1.84 2.81 1.31 3.5 1 .11-.78.42-1.31.76-1.61-2.67-.3-5.47-1.34-5.47-5.95 0-1.31.47-2.39 1.24-3.23-.12-.3-.54-1.53.12-3.18 0 0 1.01-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.29-1.55 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.77.84 1.24 1.92 1.24 3.23 0 4.62-2.81 5.64-5.49 5.94.43.37.81 1.1.81 2.22 0 1.6-.01 2.9-.01 3.29 0 .32.22.7.83.58A12 12 0 0 0 24 12.5C24 5.87 18.63.5 12 .5z"})]})}function ph({size:e=13,className:s,title:a}){return n.jsxs("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:s,"aria-hidden":a==null?!0:void 0,role:a!=null?"img":void 0,children:[a!=null&&n.jsx("title",{children:a}),n.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),n.jsx("polyline",{points:"15 3 21 3 21 9"}),n.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}const gy=n.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"4",y1:"20",x2:"4",y2:"12"}),n.jsx("line",{x1:"10",y1:"20",x2:"10",y2:"6"}),n.jsx("line",{x1:"16",y1:"20",x2:"16",y2:"14"}),n.jsx("line",{x1:"20",y1:"20",x2:"20",y2:"9"})]});function xy({tab:e}){const s=Oe(g=>g.activeTab===e.key),a=Oe(g=>g.setActiveTab),o=Oe(g=>g.closeTab);if(e.kind==="metrics-detail")return n.jsxs("div",{role:"presentation",className:`group flex shrink-0 items-center gap-1 rounded-t-md border border-b-0 pl-2 pr-1 ${s?"border-gray-300 bg-white dark:border-gray-700 dark:bg-gray-950":"border-transparent bg-transparent hover:bg-gray-200/60 dark:hover:bg-gray-800/60"}`,children:[n.jsxs("button",{type:"button",role:"tab","aria-selected":s,onClick:()=>a(e.key),className:"flex items-center gap-1.5 py-1.5 text-left",title:"Flow metrics — drill-down",children:[n.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-violet-500",children:gy}),n.jsx("span",{className:`text-xs font-medium ${s?"text-violet-600 dark:text-violet-400":"text-gray-600 dark:text-gray-300"}`,children:"Flow metrics"})]}),n.jsx("button",{type:"button",onClick:()=>o(e.key),className:"shrink-0 self-center rounded px-1 py-0.5 text-xs leading-none text-gray-400 hover:bg-gray-200 hover:text-gray-700 dark:hover:bg-gray-700 dark:hover:text-gray-200",title:"Close this tab","aria-label":"Close flow-metrics tab",children:"✕"})]});if(e.kind==="bot-prs")return n.jsxs("div",{role:"presentation",className:`group flex shrink-0 items-center gap-1 rounded-t-md border border-b-0 pl-2 pr-1 ${s?"border-gray-300 bg-white dark:border-gray-700 dark:bg-gray-950":"border-transparent bg-transparent hover:bg-gray-200/60 dark:hover:bg-gray-800/60"}`,children:[n.jsxs("button",{type:"button",role:"tab","aria-selected":s,onClick:()=>a(e.key),className:"flex items-center gap-1.5 py-1.5 text-left",title:"Bot PRs — the PRs a review bot touched",children:[n.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:"🤖"}),n.jsx("span",{className:`text-xs font-medium ${s?"text-violet-600 dark:text-violet-400":"text-gray-600 dark:text-gray-300"}`,children:"Bot PRs"})]}),n.jsx("button",{type:"button",onClick:()=>o(e.key),className:"shrink-0 self-center rounded px-1 py-0.5 text-xs leading-none text-gray-400 hover:bg-gray-200 hover:text-gray-700 dark:hover:bg-gray-700 dark:hover:text-gray-200",title:"Close this tab","aria-label":"Close bot-PRs tab",children:"✕"})]});const i=e.kind==="pr-focus",u=e.meta,d=(u==null?void 0:u.authorDisplayName)??(u==null?void 0:u.authorLogin)??"unknown",p=`${(u==null?void 0:u.repoFullName)??""} #${(u==null?void 0:u.number)??""} · ${(u==null?void 0:u.title)??""}${i?" (focus)":""}`,m=`Close ${i?"focus":"detail"} tab for PR #${(u==null?void 0:u.number)??""}`;return n.jsxs("div",{role:"presentation",className:`group flex w-52 shrink-0 items-center gap-1 rounded-t-md border border-b-0 pl-2 pr-1 ${s?"border-gray-300 bg-white dark:border-gray-700 dark:bg-gray-950":"border-transparent bg-transparent hover:bg-gray-200/60 dark:hover:bg-gray-800/60"}`,children:[n.jsxs("button",{type:"button",role:"tab","aria-selected":s,onClick:()=>a(e.key),className:"flex min-w-0 flex-1 items-center gap-1.5 py-1 text-left",title:p,children:[i?n.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-sky-500",children:n.jsx(Xo,{size:14})}):(u==null?void 0:u.authorAvatarUrl)!=null?n.jsx("img",{src:u.authorAvatarUrl,alt:d,width:16,height:16,className:"shrink-0 rounded-full",style:{width:16,height:16}}):n.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-full bg-gray-300 text-[8px] font-semibold text-gray-700 dark:bg-gray-700 dark:text-gray-200",style:{width:16,height:16},children:d.slice(0,2).toUpperCase()}),n.jsxs("span",{className:"flex min-w-0 flex-col leading-tight",children:[n.jsxs("span",{className:`truncate text-xs font-medium ${s?"text-blue-600 dark:text-blue-400":"text-gray-600 dark:text-gray-300"}`,children:[n.jsxs("span",{className:"text-gray-400",children:["#",u==null?void 0:u.number]})," ",u==null?void 0:u.title]}),n.jsx("span",{className:"truncate text-[10px] text-gray-500",children:i?"PR focus":d})]})]}),n.jsx("button",{type:"button",onClick:()=>o(e.key),className:"shrink-0 self-center rounded px-1 py-0.5 text-xs leading-none text-gray-400 hover:bg-gray-200 hover:text-gray-700 dark:hover:bg-gray-700 dark:hover:text-gray-200",title:"Close this tab","aria-label":m,children:"✕"})]})}function Op({active:e,onClick:s,icon:a,label:o,title:i}){return n.jsxs("button",{type:"button",role:"tab","aria-selected":e,onClick:s,title:i,className:`flex shrink-0 items-center gap-1.5 rounded-t-md border border-b-0 px-3 py-1.5 text-xs font-semibold ${e?"border-gray-300 bg-white text-blue-600 dark:border-gray-700 dark:bg-gray-950 dark:text-blue-400":"border-transparent bg-transparent text-gray-600 hover:bg-gray-200/60 dark:text-gray-300 dark:hover:bg-gray-800/60"}`,children:[n.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:a}),o]})}const yy=n.jsxs("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12"}),n.jsx("path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"})]}),vy=n.jsxs("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"4",y1:"7",x2:"20",y2:"7"}),n.jsx("line",{x1:"4",y1:"12",x2:"14",y2:"12"}),n.jsx("line",{x1:"4",y1:"17",x2:"18",y2:"17"})]});function by(){const e=Oe(i=>i.tabs),s=Oe(i=>i.activeTab),a=Oe(i=>i.setActiveTab),o=Oe(i=>i.showTimeline);return n.jsxs("div",{"data-testid":"pinned-tabs",role:"tablist","aria-label":"Views",className:"flex min-h-[42px] shrink-0 items-end gap-1 overflow-x-auto bg-gray-100 px-2 pt-1 dark:bg-gray-900",children:[n.jsx(Op,{active:s==="activity",onClick:()=>a("activity"),icon:yy,label:"Activity",title:"Activity — per-repo triage console"}),n.jsx(Op,{active:s==="timeline",onClick:o,icon:vy,label:"Timeline",title:"Timeline — the activity board"}),e.map(i=>n.jsx(xy,{tab:i},i.key))]})}const Jo=1e3*60*45;function Zo(e){return qe({queryKey:["pr",e],queryFn:()=>ge.pr(e),enabled:e!=null,staleTime:1/0,gcTime:Jo})}function qu(e){return qe({queryKey:["thread",e],queryFn:()=>ge.thread(e),enabled:e!=null,staleTime:1/0,gcTime:Jo})}function wy(e){return qe({queryKey:["mention-candidates",e],queryFn:()=>ge.mentionCandidates(e),enabled:e!=null,staleTime:1e3*60*5,gcTime:Jo})}function ky(e){return qe({queryKey:["pr-files",e],queryFn:()=>ge.prFiles(e),enabled:e!=null,staleTime:1/0,gcTime:Jo})}const mh=x.createContext(null);function yu({prId:e,at:s,event:a,title:o="Show this on the timeline",className:i=""}){const u=te(y=>y.showEventOnTimeline),d=te(y=>y.focusEventInTab),p=Oe(y=>y.openPrFocusTab),m=x.useContext(mh),g=()=>{if(m!=null&&m.id===e){const y=a.type==="review_comment"?a.refId:null;p(m),d(e,s,a,y)}else u(e,s,a)};return n.jsx("button",{type:"button",onClick:g,className:`shrink-0 rounded p-0.5 text-blue-500 hover:text-blue-600 ${i}`,title:o,"aria-label":o,children:n.jsx(Xo,{size:13})})}function jy(){const e=Be();return Ue({mutationFn:s=>ge.replyToThread(s.threadId,{body:s.body}),onSuccess:(s,a)=>{e.invalidateQueries({queryKey:["pr",a.prId]}),e.invalidateQueries({queryKey:["thread",a.threadId]}),e.invalidateQueries({queryKey:["my-turn"]}),e.invalidateQueries({queryKey:["me"]}),e.invalidateQueries({queryKey:["consolidated-feed"]})}})}function Ny(){const e=Be();return Ue({mutationFn:s=>ge.resolveThread(s.threadId,{resolved:s.resolved}),onSuccess:(s,a)=>{e.invalidateQueries({queryKey:["pr",a.prId]}),e.invalidateQueries({queryKey:["thread",a.threadId]}),e.invalidateQueries({queryKey:["my-turn"]}),e.invalidateQueries({queryKey:["me"]}),e.invalidateQueries({queryKey:["consolidated-feed"]})}})}function Sy(){const e=Be();return Ue({mutationFn:s=>ge.resolveBotThreads(s.prId,{threadIds:s.threadIds}),onSuccess:(s,a)=>{e.invalidateQueries({queryKey:["pr",a.prId]}),e.invalidateQueries({queryKey:["my-turn"]}),e.invalidateQueries({queryKey:["me"]}),e.invalidateQueries({queryKey:["consolidated-feed"]}),e.invalidateQueries({queryKey:["activity"]})}})}function Cy(e){const s=Be();return Ue({mutationFn:a=>ge.createPrComment(e,{body:a}),onSuccess:()=>{s.invalidateQueries({queryKey:["pr",e]}),s.invalidateQueries({queryKey:["my-turn"]}),s.invalidateQueries({queryKey:["me"]}),s.invalidateQueries({queryKey:["consolidated-feed"]})}})}function Ry(e){const s=Be();return Ue({mutationFn:a=>ge.approvePr(e,a!==void 0?{body:a}:void 0),onSuccess:()=>{s.invalidateQueries({queryKey:["pr",e]}),s.invalidateQueries({queryKey:["timeline"]}),s.invalidateQueries({queryKey:["open-prs"]}),s.invalidateQueries({queryKey:["my-turn"]}),s.invalidateQueries({queryKey:["me"]})}})}function Iy(e,s){return qe({queryKey:["merge-options",e],queryFn:()=>ge.mergeOptions(e),enabled:s,staleTime:3e4})}function Ty(e){const s=Be();return Ue({mutationFn:a=>ge.mergePr(e,{method:a}),onSuccess:()=>{s.invalidateQueries({queryKey:["pr",e]}),s.invalidateQueries({queryKey:["merge-options",e]}),s.invalidateQueries({queryKey:["timeline"]}),s.invalidateQueries({queryKey:["open-prs"]}),s.invalidateQueries({queryKey:["my-turn"]}),s.invalidateQueries({queryKey:["me"]}),s.invalidateQueries({queryKey:["activity"]}),s.invalidateQueries({queryKey:["consolidated-feed"]}),s.invalidateQueries({queryKey:["mergers"]})}})}function Ey(e){const s=Be();return Ue({mutationFn:a=>ge.updatePrBranch(e,a),onSuccess:()=>{s.invalidateQueries({queryKey:["pr",e]}),s.invalidateQueries({queryKey:["merge-options",e]}),s.invalidateQueries({queryKey:["timeline"]}),s.invalidateQueries({queryKey:["open-prs"]})}})}function Py(e){const s=Be();return Ue({mutationFn:a=>ge.addReviewComment(e,a),onSuccess:()=>{s.invalidateQueries({queryKey:["pr",e]}),s.invalidateQueries({queryKey:["my-turn"]})}})}function hh(e){const s=Be();return Ue({mutationFn:a=>ge.requestReviewers(e,a),onSuccess:()=>{s.invalidateQueries({queryKey:["team-insights"]}),s.invalidateQueries({queryKey:["pr",e]})}})}function gh(e,s=!0){return qe({queryKey:["bot-analytics",e],queryFn:()=>ge.botAnalytics(e),enabled:s,refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4})}function xh(e=!0){return qe({queryKey:["bot-reviewers"],queryFn:()=>ge.botReviewers(),enabled:e,staleTime:6e4})}function yh(){const e=Be();return Ue({mutationFn:({userId:s,body:a})=>ge.setReviewerOverride(s,a),onSuccess:()=>{e.invalidateQueries({queryKey:["bot-reviewers"]}),e.invalidateQueries({queryKey:["bot-analytics"]})}})}function Ay(e,s=!0){return qe({queryKey:["bot-dedup",e],queryFn:()=>ge.prBotDedup(e),enabled:s&&e!=null,staleTime:6e4})}function $y(e=!0){return qe({queryKey:["bot-mute-rules"],queryFn:()=>ge.botMuteRules(),enabled:e,staleTime:6e4})}function Uu(){const e=Be();return Ue({mutationFn:s=>ge.addBotMuteRule(s),onSuccess:()=>{e.invalidateQueries({queryKey:["bot-mute-rules"]}),e.invalidateQueries({queryKey:["bot-analytics"]})}})}function My(){const e=Be();return Ue({mutationFn:s=>ge.deleteBotMuteRule(s),onSuccess:()=>{e.invalidateQueries({queryKey:["bot-mute-rules"]}),e.invalidateQueries({queryKey:["bot-analytics"]})}})}function vh({state:e,count:s}){const a=jt[e];return n.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium",style:{backgroundColor:`${a.color}22`,color:a.color},title:a.description,children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:a.color}}),a.label,s!==void 0&&n.jsxs("span",{className:"opacity-70",children:["· ",s]})]})}function bh(){return n.jsx("span",{className:"rounded bg-sky-500/20 px-1 text-[10px] font-semibold uppercase text-sky-500",children:"new"})}function wh(e,s){return s?Date.parse(e)>Date.parse(s):!1}function Fy({comment:e,usersById:s,repoId:a,isNew:o,anchor:i,showLink:u}){const d=e.authorId!=null?s.get(e.authorId):void 0;return n.jsxs("div",{className:`pl-2 ${o?"comment-new":""}`,children:[n.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u&&n.jsxs(n.Fragment,{children:[u,n.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"·"})]}),n.jsx(ht,{user:d,size:18}),n.jsx(sn,{user:d,fallbackId:e.authorId,repoId:a,className:"font-semibold"}),n.jsx("span",{className:"text-gray-400",children:St(e.createdAt)}),o&&n.jsx(bh,{})]}),i&&n.jsx("div",{className:"mt-1.5",children:i}),n.jsx("div",{className:"mt-1 text-sm",children:n.jsx(cr,{children:e.body})})]})}function Ly(e){return e.startsWith("@@")?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":"ctx"}const _y={add:"bg-green-500/15 text-green-300",del:"bg-red-500/15 text-red-300",meta:"text-sky-400/80",ctx:"text-gray-400"};function Oy({hunk:e}){if(!e)return null;const s=e.replace(/\n$/,"").split(`
30
- `);return n.jsx("pre",{className:"overflow-x-auto rounded-md border border-gray-200 bg-gray-50 text-[12px] leading-[1.45] dark:border-gray-800 dark:bg-gray-900",children:n.jsx("code",{className:"block font-mono",children:s.map((a,o)=>{const i=Ly(a);return n.jsx("span",{className:`block whitespace-pre px-3 ${_y[i]}`,children:a||" "},o)})})})}function Dy(e){return e.startsWith("+")?"add":e.startsWith("-")?"del":"ctx"}const Dp={add:"border-green-500 text-green-600 dark:text-green-300",del:"border-red-500 text-red-600 dark:text-red-300",ctx:"border-gray-400 text-gray-600 dark:text-gray-300"};function By({diffHunk:e,threadId:s}){const a=te(p=>p.expandedDiffHunks.includes(s)),o=te(p=>p.toggleDiffHunk);if(!e)return null;const i=e.replace(/\n$/,"").split(`
31
- `),u=i.at(-1)??"",d=Dy(u);return a?n.jsxs("div",{className:"space-y-1",children:[n.jsx(Oy,{hunk:e}),n.jsx("button",{type:"button",onClick:()=>o(s),className:"text-[11px] text-gray-400 hover:text-gray-600",children:"⌃ Hide code context"})]}):i.length<=1?n.jsx("pre",{className:`overflow-x-auto border-l-2 bg-gray-50 py-0.5 pl-2 font-mono text-[12px] leading-snug dark:bg-gray-900/60 ${Dp[d]}`,children:u||" "}):n.jsxs("button",{type:"button",onClick:()=>o(s),title:"Show the full code context",className:`flex w-full items-center gap-2 overflow-hidden rounded-r border-l-2 bg-gray-50 py-0.5 pl-2 pr-2 text-left font-mono text-[12px] leading-snug hover:bg-gray-100 dark:bg-gray-900/60 dark:hover:bg-gray-800/60 ${Dp[d]}`,children:[n.jsx("span",{className:"min-w-0 flex-1 truncate",children:u||" "}),n.jsxs("span",{className:"shrink-0 font-sans text-[10px] text-gray-400",children:["⌄ ",i.length," lines"]})]})}function zy({threadId:e}){const s=Be(),a=Ue({mutationFn:()=>ge.dismissMyTurn("thread",e),onSuccess:()=>{s.invalidateQueries({queryKey:["my-turn"]}),s.invalidateQueries({queryKey:["my-turn-done"]}),s.invalidateQueries({queryKey:["me"]})}});return n.jsx("button",{type:"button",onClick:()=>a.mutate(),disabled:a.isPending,title:"Awaiting your response (in My Turn) — mark it done",className:"rounded border border-amber-300 bg-amber-50 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700 hover:bg-amber-100 disabled:opacity-50 dark:border-amber-700/60 dark:bg-amber-900/20 dark:text-amber-300",children:"✓ Done"})}function qy({prId:e,threadId:s,isResolved:a}){const o=Ny(),i=o.error instanceof Gt?o.error.message:o.error?"Failed to update the thread.":null;return n.jsxs("span",{className:"flex items-center gap-1.5",children:[i&&n.jsx("span",{className:"text-[10px] text-red-500",children:i}),n.jsx("button",{type:"button",onClick:()=>o.mutate({prId:e,threadId:s,resolved:!a}),disabled:o.isPending,title:a?"Reopen this thread on GitHub":"Mark this thread resolved on GitHub",className:"rounded border border-gray-300 px-1.5 py-0.5 text-[10px] font-semibold text-gray-600 hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:a?"Unresolve":"Resolve"})]})}const Uy=8;function Bp(e,s){let a=s-1;for(;a>=0;){const o=e[a];if(o==="@"){const i=a>0?e[a-1]:"";if(a===0||/[\s(]/.test(i)){const u=e.slice(a+1,s);if(/^[A-Za-z0-9-]*$/.test(u))return{query:u,start:a}}return null}if(/\s/.test(o))return null;a-=1}return null}function Ky(e,s){var o;if(s==="")return!0;const a=s.toLowerCase();return e.githubLogin.toLowerCase().includes(a)||(((o=e.displayName)==null?void 0:o.toLowerCase().includes(a))??!1)}const Hy=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]);function ei({prId:e,value:s,onChange:a,rows:o=3,placeholder:i,autoFocus:u,disabled:d,className:p,ariaLabel:m,onKeyDown:g,onBlur:y}){const b=x.useRef(null),{data:v}=wy(e),[N,I]=x.useState(0),[P,E]=x.useState(!1),[w,R]=x.useState(0),S=x.useRef(null);x.useLayoutEffect(()=>{if(S.current!=null&&b.current){const L=S.current;b.current.setSelectionRange(L,L),S.current=null}});const j=P?Bp(s,N):null,T=x.useMemo(()=>j==null||!v?[]:v.filter(L=>Ky(L,j.query)).slice(0,Uy),[j,v]);x.useEffect(()=>{R(L=>L>=T.length?0:L)},[T.length]);const M=P&&j!=null&&T.length>0,D=()=>{const L=b.current;L&&I(L.selectionStart??0)},U=L=>{const Y=Bp(s,N);if(!Y)return;let X=N;for(;X<s.length&&/[A-Za-z0-9-]/.test(s[X]);)X+=1;const B=s.slice(0,Y.start),_=s.slice(X),H=`@${L.githubLogin} `;S.current=B.length+H.length,I(B.length+H.length),E(!1),a(B+H+_)},G=L=>{if(M&&Hy.has(L.key)){if(L.key==="ArrowDown")L.preventDefault(),R(Y=>(Y+1)%T.length);else if(L.key==="ArrowUp")L.preventDefault(),R(Y=>(Y-1+T.length)%T.length);else if(L.key==="Enter"||L.key==="Tab"){L.preventDefault();const Y=T[w]??T[0];Y&&U(Y)}else L.key==="Escape"&&(L.preventDefault(),E(!1));return}g==null||g(L)};return n.jsxs("div",{className:"relative",children:[n.jsx("textarea",{ref:b,value:s,rows:o,placeholder:i,autoFocus:u,disabled:d,"aria-label":m,className:p,onChange:L=>{a(L.target.value),I(L.target.selectionStart??L.target.value.length),E(!0)},onKeyDown:G,onKeyUp:D,onClick:()=>{D(),E(!0)},onBlur:L=>{window.setTimeout(()=>E(!1),120),y==null||y(L)}}),M&&n.jsx("ul",{role:"listbox",className:"absolute left-0 right-0 z-30 mt-0.5 max-h-56 overflow-auto rounded-md border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:T.map((L,Y)=>n.jsx("li",{children:n.jsxs("button",{type:"button",role:"option","aria-selected":Y===w,onMouseDown:X=>{X.preventDefault(),U(L)},onMouseEnter:()=>R(Y),className:`flex w-full items-center gap-2 px-2 py-1 text-left text-xs ${Y===w?"bg-sky-50 dark:bg-sky-950/40":"hover:bg-gray-50 dark:hover:bg-gray-800/60"}`,children:[n.jsx(ht,{user:L,size:18}),n.jsxs("span",{className:"font-medium text-gray-800 dark:text-gray-100",children:["@",L.githubLogin]}),L.displayName&&n.jsx("span",{className:"truncate text-gray-400",children:L.displayName})]})},L.id))})]})}function Wy({prId:e,threadId:s}){const[a,o]=x.useState(!1),[i,u]=x.useState(""),d=jy(),p=d.error instanceof Gt?d.error.message:d.error?"Failed to post the reply.":null,m=()=>{const g=i.trim();!g||d.isPending||d.mutate({prId:e,threadId:s,body:g},{onSuccess:()=>{u(""),o(!1)}})};return a?n.jsxs("div",{className:"space-y-1",children:[n.jsx(ei,{prId:e,value:i,onChange:u,rows:3,autoFocus:!0,placeholder:"Reply to this thread (markdown, @ to mention)…",className:"w-full rounded border border-gray-300 bg-white px-2 py-1.5 text-xs dark:border-gray-700 dark:bg-gray-900"}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("button",{type:"button",onClick:m,disabled:d.isPending||i.trim().length===0,className:"whitespace-nowrap rounded border border-blue-400 px-2 py-0.5 text-xs text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",children:d.isPending?"Sending…":"Send"}),n.jsx("button",{type:"button",onClick:()=>{o(!1),u(""),d.reset()},disabled:d.isPending,className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-xs hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:"Cancel"}),p&&n.jsx("span",{className:"text-[10px] text-red-500",children:p})]})]}):n.jsx("button",{type:"button",onClick:()=>o(!0),className:"text-blue-500 hover:underline",children:"Reply"})}function hl({thread:e,usersById:s,prUrl:a,repoId:o,selected:i,viewedSince:u,inMyTurn:d=!1,highlightCommentId:p}){var g;const m=((g=e.comments[0])==null?void 0:g.diffHunk)??null;return n.jsxs("div",{className:`rounded-md border px-2.5 py-2 ${i?"border-amber-400 bg-amber-400/5":"border-gray-200 dark:border-gray-800"}`,children:[n.jsxs("div",{className:"mb-2 flex items-center gap-2 text-[11px] text-gray-400",children:[n.jsx(yu,{prId:e.prId,at:e.createdAt,event:{type:"review_comment",refId:e.id},title:"Show this thread on the timeline"}),n.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"·"}),e.line!=null?n.jsxs("span",{children:["line ",e.line]}):n.jsx("span",{children:"file-level"}),e.isOutdated&&n.jsx("span",{children:"· outdated"}),n.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[d&&n.jsx(zy,{threadId:e.id}),n.jsx(qy,{prId:e.prId,threadId:e.id,isResolved:e.isResolved}),n.jsx(vh,{state:e.derivedState})]})]}),n.jsx("div",{className:"space-y-3",children:e.comments.map((y,b)=>n.jsx(Fy,{comment:y,usersById:s,repoId:o,isNew:p!=null?y.id===p:wh(y.createdAt,u),anchor:b===0?n.jsx(By,{diffHunk:m,threadId:e.id}):void 0,showLink:b>0?n.jsx(yu,{prId:e.prId,at:y.createdAt,event:{type:"review_comment",refId:e.id},title:"Show this reply on the timeline"}):void 0},y.id))}),n.jsxs("div",{className:"mt-2 space-y-1.5 pl-2 text-[11px]",children:[n.jsx(Wy,{prId:e.prId,threadId:e.id}),n.jsx("div",{children:n.jsxs("a",{href:e.url??`${a}/files`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:["↗ ",e.url?"View thread on GitHub":"Reply on GitHub"]})})]})]})}const Vy=["untouched","replied_unresolved","likely_addressed","resolved"];function Qy(e){const s={untouched:0,replied_unresolved:0,likely_addressed:0,resolved:0};for(const a of e)s[a.derivedState]+=1;return s}function Gy({counts:e}){const s=Vy.filter(a=>e[a]>0);return n.jsx("span",{className:"inline-flex items-center gap-1.5",children:s.map(a=>{const o=jt[a];return n.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[10px] font-semibold",style:{color:o.color},title:`${o.label}: ${e[a]}`,children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:o.color}}),e[a]]},a)})})}function Yy(e){return[...e].sort((s,a)=>a.createdAt.localeCompare(s.createdAt))}function Xy({path:e,threads:s,usersById:a,prUrl:o,repoId:i,selectedThreadId:u,viewedSince:d,awaitingThreadIds:p,registerRef:m}){const g=Qy(s),y=s.some(T=>T.derivedState!=="resolved"),b=u!=null&&s.some(T=>T.id===u),v=y,N=te(T=>T.expandedFileGroups),I=te(T=>T.collapsedFileGroups),P=te(T=>T.toggleFileGroup),E=v?!I.includes(e):N.includes(e),w=b||E,R=e.split("/"),S=R.at(-1),j=R.slice(0,-1).join("/");return n.jsxs("div",{className:"border-b border-gray-100 dark:border-gray-800",children:[n.jsxs("button",{type:"button",onClick:()=>P(e,v),className:"flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-gray-50 dark:hover:bg-gray-900",children:[n.jsx("span",{className:"text-gray-400",children:w?"▾":"▸"}),n.jsxs("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:e,children:[j&&n.jsxs("span",{className:"text-gray-400",children:[j,"/"]}),n.jsx("span",{className:"font-semibold",children:S})]}),n.jsx(Gy,{counts:g})]}),w&&n.jsx("div",{className:"space-y-2 px-3 pb-3",children:Yy(s).map(T=>n.jsx("div",{ref:M=>m(T.id,M),children:n.jsx(hl,{thread:T,usersById:a,prUrl:o,repoId:i,selected:T.id===u,viewedSince:d,inMyTurn:p.has(T.id)})},T.id))})]})}function Jy(e){const s=new Map;for(const o of e){const i=s.get(o.path)??[];i.push(o),s.set(o.path,i)}const a=[...s.entries()].map(([o,i])=>({path:o,threads:i,newest:i.reduce((u,d)=>d.createdAt>u?d.createdAt:u,"")}));return a.sort((o,i)=>i.newest.localeCompare(o.newest)||o.path.localeCompare(i.path)),a}function zp(e,s){var o,i;const a=e.originalCommenterId??((o=e.comments[0])==null?void 0:o.authorId)??null;return a==null?null:Xm((i=s.get(a))==null?void 0:i.githubLogin)}function Zy({threads:e,usersById:s,prUrl:a,prId:o,repoId:i,selectedThreadId:u,viewedSince:d,botFilter:p=null}){const m=x.useRef(new Map),g=te(D=>D.setThreadBotFilter),y=Sy(),[b,v]=x.useState(!1),{data:N}=sh(),I=x.useMemo(()=>new Set(((N==null?void 0:N.threadsAwaiting)??[]).map(D=>D.threadId)),[N]),{data:P}=Ay(o??null),E=(P==null?void 0:P.clusters)??[],w=D=>{var U;(U=m.current.get(D))==null||U.scrollIntoView({behavior:"smooth",block:"center"})},R=x.useMemo(()=>p?e.filter(D=>zp(D,s)===p):e,[e,p,s]),S=x.useMemo(()=>R.filter(D=>!D.isResolved&&D.derivedState==="likely_addressed"&&zp(D,s)).map(D=>D.id),[R,s]);x.useEffect(()=>{if(u==null)return;const D=m.current.get(u);D&&D.scrollIntoView({behavior:"smooth",block:"nearest"})},[u]),x.useEffect(()=>{S.length===0&&v(!1)},[S.length]);const j=x.useMemo(()=>Jy(R),[R]),T=p?qs[p]:null,M=()=>{o==null||S.length===0||y.mutate({prId:o,threadIds:S},{onSettled:()=>v(!1)})};return n.jsxs("div",{children:[T&&n.jsxs("div",{className:"sticky top-0 z-10 flex flex-wrap items-center gap-2 border-b border-gray-100 bg-white/95 px-3 py-2 text-xs backdrop-blur dark:border-gray-800 dark:bg-gray-900/95",style:{boxShadow:`inset 3px 0 0 ${T.color}`},children:[n.jsxs("span",{className:"font-medium",style:{color:T.color},children:["🤖 ",T.label]}),n.jsxs("span",{className:"text-gray-500",children:[R.length," thread",R.length===1?"":"s"]}),n.jsx("button",{type:"button",onClick:()=>g(null),className:"rounded px-1.5 py-0.5 text-gray-500 underline-offset-2 hover:underline",children:"Show all threads"}),S.length>0&&n.jsx("span",{className:"ml-auto flex items-center gap-2",children:b?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"text-gray-500",children:["Resolve ",S.length," likely-addressed thread",S.length===1?"":"s"," on GitHub?"]}),n.jsx("button",{type:"button",disabled:y.isPending,onClick:M,className:"rounded bg-green-600 px-2 py-0.5 font-medium text-white hover:bg-green-700 disabled:opacity-60",children:y.isPending?"Resolving…":"Yes, resolve"}),n.jsx("button",{type:"button",disabled:y.isPending,onClick:()=>v(!1),className:"rounded px-2 py-0.5 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300",children:"Cancel"})]}):n.jsxs("button",{type:"button",onClick:()=>v(!0),className:"rounded border px-2 py-0.5 font-medium hover:opacity-80",style:{borderColor:T.color,color:T.color},title:"A later commit touched the file these threads flag — resolve them in one click (you approve each batch).",children:["Resolve ",S.length," addressed"]})})]}),y.data&&(y.data.resolved>0||y.data.failed>0)&&n.jsxs("div",{className:"px-3 py-1.5 text-xs text-gray-500",children:["Resolved ",y.data.resolved,y.data.failed>0&&` · ${y.data.failed} failed`,"."]}),E.length>0&&n.jsxs("div",{"data-testid":"bot-dedup",className:"mx-3 my-2 rounded-md border border-sky-200 bg-sky-50/60 px-3 py-2 text-xs dark:border-sky-800 dark:bg-sky-950/30",children:[n.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 font-medium text-sky-800 dark:text-sky-200",children:[n.jsx("span",{"aria-hidden":"true",children:"🤖"}),"Multiple bots flagged the same ",E.length===1?"line":"lines"]}),n.jsx("ul",{className:"space-y-1.5",children:E.map((D,U)=>{const G=D.path.split("/").pop()??D.path,L=D.members.length===2?"both flagged":"all flagged";return n.jsxs("li",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-1",children:[D.members.map((Y,X)=>{const B=an(Y.kind);return n.jsxs(x.Fragment,{children:[X>0&&n.jsx("span",{className:"text-gray-400",children:"+"}),n.jsx("button",{type:"button",onClick:()=>w(Y.threadId),className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium hover:opacity-80",style:{color:B.color,background:`${B.color}1a`},title:`Jump to ${Y.label}'s thread`,children:Y.label})]},Y.threadId)}),n.jsxs("span",{className:"text-gray-600 dark:text-gray-300",children:[L," ",n.jsx("code",{className:"font-mono",children:G}),D.line!=null?`:${D.line}`:""]}),D.conflict?n.jsx("span",{className:"rounded bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700 dark:bg-amber-900/40 dark:text-amber-300",title:"The bots disagree on severity/verdict here — worth a human look.",children:"bots disagree here"}):D.consensus?n.jsx("span",{className:"rounded bg-green-100 px-1.5 py-0.5 text-[10px] font-semibold text-green-700 dark:bg-green-900/40 dark:text-green-300",title:"The bots agree here — one fix likely clears both.",children:"consensus"}):null]},`${D.path}:${D.line??"x"}:${U}`)})})]}),R.length===0?n.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500",children:p?"No threads from this bot on this PR.":"No review threads on this PR."}):j.map(D=>n.jsx(Xy,{path:D.path,threads:D.threads,usersById:s,prUrl:a,repoId:i,selectedThreadId:u,viewedSince:d,awaitingThreadIds:I,registerRef:(U,G)=>{G?m.current.set(U,G):m.current.delete(U)}},D.path))]})}function ev({prId:e,alreadyApproved:s}){const[a,o]=x.useState(!1),[i,u]=x.useState(""),d=Ry(e);if(s||d.isSuccess)return n.jsxs("button",{type:"button",disabled:!0,title:"You've already approved this PR — your approval still stands",className:"inline-flex cursor-default items-center gap-1 rounded border border-green-500/40 px-2 py-0.5 text-sm font-medium text-green-700/70 dark:border-green-700/50 dark:text-green-400/70",children:[n.jsx("span",{"aria-hidden":!0,children:"✓"})," Approved"]});const p=d.error instanceof Gt?d.error.message:d.error?"Failed to approve the PR.":null,m=()=>{if(d.isPending)return;const g=i.trim();d.mutate(g||void 0,{onSuccess:()=>{u(""),o(!1)}})};return a?n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(ei,{prId:e,value:i,onChange:u,rows:3,autoFocus:!0,placeholder:"Optional approval message (markdown)…",className:"w-full rounded border border-gray-300 bg-white px-2 py-1.5 text-sm dark:border-gray-700 dark:bg-gray-900"}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("button",{type:"button",onClick:m,disabled:d.isPending,className:"whitespace-nowrap rounded border border-green-500 px-2 py-0.5 text-sm font-medium text-green-700 hover:bg-green-50 disabled:opacity-50 dark:border-green-600 dark:text-green-400 dark:hover:bg-green-900/30",children:d.isPending?"Approving…":"Approve"}),n.jsx("button",{type:"button",onClick:()=>{o(!1),u(""),d.reset()},disabled:d.isPending,className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-sm hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:"Cancel"}),p&&n.jsx("span",{className:"text-xs text-red-500",children:p})]})]}):n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs("button",{type:"button",onClick:()=>o(!0),className:"inline-flex items-center gap-1 rounded border border-green-500 px-2 py-0.5 text-sm font-medium text-green-700 hover:bg-green-50 dark:border-green-600 dark:text-green-400 dark:hover:bg-green-900/30",children:[n.jsx("span",{"aria-hidden":!0,children:"✓"})," Approve"]}),p&&n.jsx("span",{className:"text-xs text-red-500",children:p})]})}const tv={merge:"Create a merge commit",squash:"Squash and merge",rebase:"Rebase and merge"},nv={merge:"Merge",squash:"Squash and merge",rebase:"Rebase and merge"};function rv({prId:e,githubUrl:s}){const[a,o]=x.useState(!1),{data:i,isLoading:u,isError:d}=Iy(e,a),p=Ty(e),m=Ey(e),[g,y]=x.useState(null),[b,v]=x.useState("rebase"),N=g&&(i!=null&&i.allowedMethods.includes(g))?g:(i==null?void 0:i.defaultMethod)??"merge",I=p.error instanceof Gt?p.error.message:p.error?"Failed to merge the PR.":null,P=m.error instanceof Gt?m.error.message:m.error?"Failed to update the branch.":null,E=x.useMemo(()=>{if(i==null||!i.behind)return null;const R=i.behindBy;return`${R>0?R:"Some"} commit${R===1?"":"s"} behind ${i.baseRef}`},[i]);if(!a)return n.jsxs("button",{type:"button",onClick:()=>o(!0),className:"inline-flex items-center gap-1 rounded border border-violet-500 px-2 py-0.5 text-sm font-medium text-violet-700 hover:bg-violet-50 dark:border-violet-600 dark:text-violet-300 dark:hover:bg-violet-900/30",children:[n.jsx("span",{"aria-hidden":!0,children:"⇱"})," Merge ▾"]});if(u)return n.jsx("div",{className:"text-xs text-gray-400",children:"Checking merge status…"});if(d||i==null)return n.jsxs("div",{className:"flex items-center gap-2 text-xs text-red-500",children:["Couldn’t load merge status.",n.jsx("button",{type:"button",onClick:()=>o(!1),className:"rounded border border-gray-300 px-1.5 py-0.5 text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300",children:"Close"})]});const w=!i.conflicts&&!i.blocked&&i.allowedMethods.length>0;return n.jsxs("div",{className:"space-y-2",children:[i.conflicts&&n.jsxs("div",{className:"rounded border border-amber-300 bg-amber-50/60 px-2 py-1.5 text-xs text-amber-800 dark:border-amber-800/60 dark:bg-amber-950/20 dark:text-amber-200",children:["⚠ This PR conflicts with ",n.jsx("span",{className:"font-mono",children:i.baseRef}),". Resolve the conflicts on"," ",n.jsx("a",{href:s,target:"_blank",rel:"noreferrer noopener",className:"font-medium underline",children:"GitHub ↗"}),"."]}),i.canUpdateBranch&&n.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[n.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[E,"."]}),i.canRebaseUpdate&&n.jsxs("select",{value:b,onChange:R=>v(R.target.value),disabled:m.isPending,className:"rounded border border-gray-300 bg-white px-1 py-0.5 text-xs dark:border-gray-700 dark:bg-gray-900",title:"How to bring in the base branch",children:[n.jsxs("option",{value:"rebase",children:["Rebase onto ",i.baseRef]}),n.jsxs("option",{value:"merge",children:["Merge ",i.baseRef," in"]})]}),n.jsx("button",{type:"button",onClick:()=>m.mutate(i.canRebaseUpdate?{strategy:b}:{strategy:"merge"}),disabled:m.isPending,className:"rounded border border-sky-500 px-2 py-0.5 font-medium text-sky-700 hover:bg-sky-50 disabled:opacity-50 dark:border-sky-600 dark:text-sky-300 dark:hover:bg-sky-900/30",title:"Bring in the latest base-branch changes before merging",children:m.isPending?"Updating…":"Update branch"}),P&&n.jsx("span",{className:"text-red-500",children:P})]}),i.blocked&&n.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Merging is blocked by branch protection (required reviews or checks aren’t satisfied yet)."}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.allowedMethods.length>1&&n.jsx("select",{value:N,onChange:R=>y(R.target.value),disabled:!w||p.isPending,className:"rounded border border-gray-300 bg-white px-1.5 py-0.5 text-sm dark:border-gray-700 dark:bg-gray-900",children:i.allowedMethods.map(R=>n.jsx("option",{value:R,children:tv[R]},R))}),n.jsx("button",{type:"button",onClick:()=>p.mutate(N),disabled:!w||p.isPending,className:"whitespace-nowrap rounded border border-violet-500 px-2 py-0.5 text-sm font-medium text-violet-700 hover:bg-violet-50 disabled:opacity-50 dark:border-violet-600 dark:text-violet-300 dark:hover:bg-violet-900/30",title:w?"Merge this PR":"This PR can’t be merged right now",children:p.isPending?"Merging…":nv[N]}),n.jsx("button",{type:"button",onClick:()=>{o(!1),p.reset(),m.reset()},disabled:p.isPending,className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-sm hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:"Cancel"}),I&&n.jsx("span",{className:"text-xs text-red-500",children:I})]})]})}function sv(e){const s=Be();return Ue({mutationFn:async({runIds:a,mode:o})=>{const i=await Promise.allSettled(a.map(p=>ge.rerunCi(e,{runId:p,mode:o}))),u=i.filter(p=>p.status==="fulfilled").length,d=i.length-u;if(u===0){const p=i.find(m=>m.status==="rejected");throw(p==null?void 0:p.reason)instanceof Error?p.reason:new Error("Re-run failed")}return{mode:o,queued:u,failed:d}},onSuccess:()=>void s.invalidateQueries({queryKey:["pr",e]})})}const av=/\/actions\/runs\/\d+\/job\/(\d+)/,lv=/\/actions\/runs\/(\d+)/;function ov(e){if(e.jobId!=null)return e.jobId;const s=e.url?av.exec(e.url):null;return s?Number(s[1]):null}function iv(e){if(e.runId!=null)return e.runId;const s=e.url?lv.exec(e.url):null;return s?Number(s[1]):null}function cv({prId:e,check:s}){var b,v;const a=Hx[s.state],o=ov(s),i=o!=null&&(s.state==="failure"||s.state==="error"),[u,d]=x.useState(!1),p=qe({queryKey:["check-logs",e,o],queryFn:()=>ge.checkLogs(e,o,200),enabled:u&&i,staleTime:1/0,gcTime:5*6e4}),m=x.useRef(null);x.useLayoutEffect(()=>{var N;if(u&&((N=p.data)!=null&&N.available)){const I=m.current;I&&(I.scrollTop=I.scrollHeight)}},[u,p.data]);const g=n.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full text-[10px] font-bold text-white",style:{backgroundColor:a.color},title:a.label,children:a.icon}),y=s.url?n.jsx("a",{href:s.url,target:"_blank",rel:"noreferrer noopener",onClick:N=>N.stopPropagation(),className:"text-blue-500 hover:underline",children:"Open on GitHub ↗"}):null;if(!i){const N=n.jsxs("span",{className:"flex items-center gap-2",children:[g,n.jsx("span",{className:"min-w-0 truncate",title:s.name,children:s.name}),n.jsx("span",{className:"ml-auto shrink-0 text-xs text-gray-400",children:a.label})]});return n.jsx("li",{className:"text-xs",children:s.url?n.jsx("a",{href:s.url,target:"_blank",rel:"noreferrer noopener",className:"block rounded px-1 py-0.5 hover:bg-gray-100 dark:hover:bg-gray-800",children:N}):n.jsx("div",{className:"px-1 py-0.5",children:N})})}return n.jsxs("li",{className:"text-xs",children:[n.jsx("button",{type:"button",onClick:()=>d(N=>!N),"aria-expanded":u,className:"block w-full rounded px-1 py-0.5 text-left hover:bg-gray-100 dark:hover:bg-gray-800",children:n.jsxs("span",{className:"flex items-center gap-2",children:[g,n.jsx("span",{className:"min-w-0 truncate",title:s.name,children:s.name}),n.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5 text-gray-400",children:[n.jsx("span",{className:"text-xs",children:a.label}),n.jsx("span",{className:"text-[10px] font-medium text-blue-500",children:u?"▾ hide logs":"▸ logs"})]})]})}),u&&n.jsx("div",{className:"mb-1 mt-1",children:p.isLoading?n.jsx("div",{className:"px-1 py-2 text-gray-400",children:"Loading logs…"}):(b=p.data)!=null&&b.available?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"mb-1 flex items-center justify-between px-1 text-[10px] text-gray-400",children:[n.jsxs("span",{children:["last ",p.data.returnedLines," of ",p.data.totalLines," lines"]}),y]}),n.jsx("pre",{ref:m,className:"max-h-[40rem] overflow-auto whitespace-pre rounded bg-gray-900 p-2 font-mono text-[11px] leading-[1.45] text-gray-100",children:p.data.text||"(empty log)"})]}):n.jsxs("div",{className:"px-1 py-2 text-gray-400",children:[((v=p.data)==null?void 0:v.reason)??"Couldn't load logs."," ",y]})})]})}function uv({prId:e,checks:s}){return n.jsx("ul",{className:"space-y-1",children:s.map((a,o)=>n.jsx(cv,{prId:e,check:a},`${a.name}-${o}`))})}function qp(e,s){const a=new Set;for(const o of e){if(s&&o.state!=="failure"&&o.state!=="error")continue;const i=iv(o);i!=null&&a.add(i)}return[...a]}function dv({prId:e,checks:s,viewerCanPush:a}){const o=sv(e),[i,u]=x.useState(null),d=qp(s,!1),p=qp(s,!0);if(!a||d.length===0)return null;const m=(g,y)=>{y.length!==0&&(u(null),o.mutate({runIds:y,mode:g},{onSuccess:b=>u(b)}))};return n.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[n.jsx("button",{type:"button",className:"whitespace-nowrap rounded border border-blue-400 px-2.5 py-1 text-xs text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",disabled:o.isPending||p.length===0,onClick:()=>m("failed",p),title:"Re-run only the failed jobs of the failing workflow run(s)",children:o.isPending?"Requesting…":"Re-run failed jobs"}),n.jsx("button",{type:"button",className:"whitespace-nowrap rounded border border-gray-300 px-2.5 py-1 text-xs hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",disabled:o.isPending,onClick:()=>m("all",d),title:"Re-run the entire workflow run(s) from scratch",children:"Re-run all jobs"}),i&&!o.isPending&&n.jsxs("span",{className:"text-[11px] text-gray-500",children:["Re-run requested — CI updates on the next sync.",i.failed>0&&` (${i.failed} run${i.failed===1?"":"s"} couldn't be re-run.)`]}),o.isError&&n.jsx("span",{className:"text-[11px] text-red-500",children:o.error instanceof Error?o.error.message:"Re-run failed"})]})}async function ti(e,s){const a=await fetch(e,{method:s.method??"GET",credentials:"same-origin",headers:{Accept:"text/event-stream",...s.body!==void 0?{"content-type":"application/json"}:{}},body:s.body!==void 0?JSON.stringify(s.body):void 0,signal:s.signal});if(!a.ok){let p=`${a.status} ${a.statusText}`;try{const m=await a.json();m.message&&(p=m.message)}catch{}throw new Gt(a.status,p)}if(!a.body)throw new Gt(a.status,"stream has no body");const o=a.body.getReader(),i=new TextDecoder;let u="";const d=p=>{const m=[];for(const g of p.split(`
29
+ ${a}`}function ln(e){const s=new Map;for(const a of e??[])s.set(a.id,a);return s}function Wx(e){return new Date(e).toLocaleDateString(void 0,{day:"2-digit",month:"2-digit",year:"numeric"})}function St(e){const s=new Date(e).getTime(),a=Date.now()-s,o=Math.abs(a),i=6e4,u=60*i,d=24*u,p=(m,g)=>`${m} ${g}${m===1?"":"s"} ago`;return o<i?"just now":o<u?p(Math.round(a/i),"min"):o<d?p(Math.round(a/u),"hour"):o<30*d?p(Math.round(a/d),"day"):Wx(e)}function Ra(e){return new Date(e).toLocaleString(void 0,{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}function kt(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const uh="Watched — new PRs here flow into your My Turn inbox";function Vx(){return`<span class="tl-repo-watch" title="${kt(uh)}" aria-label="Watched repo"><svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><path d="M8 4C4.6 4 1.9 6.2 1 8c.9 1.8 3.6 4 7 4s6.1-2.2 7-4c-.9-1.8-3.6-4-7-4Z" fill="none" stroke="currentColor" stroke-width="1.2"/><circle cx="8" cy="8" r="1.9" fill="currentColor"/></svg></span>`}function Bu({size:e=12,className:s=""}){return n.jsx("span",{className:`inline-flex shrink-0 items-center text-sky-500 ${s}`,title:uh,"aria-label":"Watched repo",children:n.jsxs("svg",{viewBox:"0 0 16 16",width:e,height:e,"aria-hidden":"true",children:[n.jsx("path",{d:"M8 4C4.6 4 1.9 6.2 1 8c.9 1.8 3.6 4 7 4s6.1-2.2 7-4c-.9-1.8-3.6-4-7-4Z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.9",fill:"currentColor"})]})})}function Qx({repos:e,repoIds:s,onToggle:a,onOnly:o,onShowAll:i,onToggleWatch:u,watchPending:d,onRemove:p,removePending:m}){const[g,w]=x.useState(!1),[v,y]=x.useState(""),j=x.useRef(null),R=e.length,P=b=>s==null||s.includes(b),E=s==null?R:s.length,S=s!=null&&E<R;Yn(j,()=>w(!1),g),x.useEffect(()=>{if(!g)return;const b=I=>{I.key==="Escape"&&(I.stopPropagation(),w(!1))};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[g]);const T=v.trim().toLowerCase(),N=e.filter(b=>!T||b.fullName.toLowerCase().includes(T));return n.jsxs("div",{ref:j,className:"relative",children:[n.jsxs("span",{className:"inline-flex items-center whitespace-nowrap rounded-full border border-gray-300 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[n.jsxs("button",{type:"button",onClick:()=>w(b=>!b),"aria-haspopup":"true","aria-expanded":g,className:`inline-flex items-center gap-1 py-0.5 pl-2.5 ${S?"pr-1":"pr-2.5"}`,children:["Repos",R>0?` (${S?`${E}/${R}`:R})`:"",n.jsx("span",{"aria-hidden":!0,className:"text-[9px]",children:"▾"})]}),S&&n.jsx("button",{type:"button",onClick:()=>i(),title:"Show all repos","aria-label":"Show all repos",className:"py-0.5 pl-0.5 pr-2 opacity-60 hover:opacity-100",children:"✕"})]}),g&&n.jsxs("div",{role:"dialog","aria-label":"Repositories",className:"absolute left-0 top-full z-[60] mt-1 w-[28rem] max-w-[calc(100vw-2rem)] rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[R>8&&n.jsx("input",{autoFocus:!0,type:"search",value:v,onChange:b=>y(b.target.value),placeholder:"Filter repos…","aria-label":"Filter repos",className:"mb-2 w-full 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"}),n.jsx("div",{className:"max-h-72 overflow-y-auto",children:R===0?n.jsx("div",{className:"px-1 py-2 text-xs text-gray-500",children:"No repos yet — search to add one."}):N.length===0?n.jsx("div",{className:"px-1 py-2 text-xs text-gray-500",children:"No repos match."}):N.map(b=>{const I=P(b.id)&&E<=1;return n.jsxs("div",{className:"group flex items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[n.jsxs("label",{className:`flex min-w-0 flex-1 items-center gap-2 ${I?"cursor-default":"cursor-pointer"}`,children:[n.jsx("input",{type:"checkbox",checked:P(b.id),disabled:I,onChange:()=>a(b.id),title:I?"At least one repo must stay shown":void 0}),n.jsxs("span",{className:"min-w-0 truncate",title:b.fullName,children:[n.jsxs("span",{className:"text-gray-400",children:[b.owner,"/"]}),n.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-100",children:b.name})]}),b.inboxWatch&&n.jsx(Bu,{size:11}),b.lastSyncStatus==="error"&&n.jsx("span",{className:"shrink-0 text-red-500",title:b.lastSyncError??"Last sync failed","aria-label":"Last sync failed",children:"⚠"})]}),n.jsx("button",{type:"button",onClick:()=>u(b),disabled:d,"aria-pressed":b.inboxWatch,title:b.inboxWatch?`Watching ${b.fullName} — new PRs go to your inbox. Click to stop.`:`Watch ${b.fullName}: new open PRs go to your My Turn inbox`,"aria-label":b.inboxWatch?`Stop watching ${b.fullName} for the inbox`:`Watch ${b.fullName} for the inbox`,className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide disabled:opacity-30 ${b.inboxWatch?"text-sky-600 hover:bg-sky-100 dark:text-sky-400 dark:hover:bg-sky-900/40":"text-gray-400 opacity-0 hover:bg-gray-200 hover:text-gray-700 focus:opacity-100 group-hover:opacity-100 dark:hover:bg-gray-700 dark:hover:text-gray-200"}`,children:b.inboxWatch?"watching":"watch"}),!(P(b.id)&&E===1)&&n.jsx("button",{type:"button",onClick:()=>o(b.id),title:`Show only ${b.fullName}`,"aria-label":`Show only ${b.fullName}`,className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-gray-400 opacity-0 hover:bg-gray-200 hover:text-gray-700 focus:opacity-100 group-hover:opacity-100 dark:hover:bg-gray-700 dark:hover:text-gray-200",children:"only"}),n.jsx("button",{type:"button",onClick:()=>p(b),disabled:m,title:`Remove ${b.fullName}`,"aria-label":`Remove ${b.fullName}`,className:"shrink-0 px-1 text-gray-400 opacity-0 hover:text-red-500 focus:opacity-100 group-hover:opacity-100 disabled:opacity-30",children:"✕"})]},b.id)})}),S&&n.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-gray-200 pt-2 dark:border-gray-700",children:[n.jsxs("span",{className:"text-[11px] text-gray-400",children:[E," of ",R," shown"]}),n.jsx("button",{type:"button",onClick:()=>i(),className:"text-[11px] text-gray-400 hover:text-gray-600",children:"Show all"})]})]})]})}const dh="pierre:savedViews",xu="pierre:activeView";function fh(){try{const e=localStorage.getItem(dh);if(!e)return[];const s=JSON.parse(e);return Array.isArray(s)?s:[]}catch{return[]}}function Gx(){try{const e=localStorage.getItem(xu);return e?fh().find(s=>s.name===e)??null:null}catch{return null}}function Yx(){const[e,s]=x.useState(fh),a=te(p=>{var g;const m=gu(p);return((g=e.find(w=>Tx(w.state,m)))==null?void 0:g.name)??null});x.useEffect(()=>{try{a!=null?localStorage.setItem(xu,a):localStorage.removeItem(xu)}catch{}},[a]);const o=x.useCallback(p=>{const m=[...p].sort((g,w)=>g.name.localeCompare(w.name));s(m);try{localStorage.setItem(dh,JSON.stringify(m))}catch{}},[]),i=x.useCallback(p=>{const m=p.trim();if(!m)return;const g=gu(te.getState());o([...e.filter(w=>w.name!==m),{name:m,state:g}])},[e,o]),u=x.useCallback(p=>o(e.filter(m=>m.name!==p)),[e,o]),d=x.useCallback(p=>{te.getState().hydrate({...Yo(p.state),rangeResetSignal:te.getState().rangeResetSignal+1})},[]);return{views:e,activeName:a,save:i,remove:u,apply:d}}function Xx({disabled:e}){const{views:s,activeName:a,save:o,remove:i,apply:u}=Yx(),[d,p]=x.useState(!1),[m,g]=x.useState(""),w=x.useRef(null);Yn(w,()=>p(!1),d);const v=()=>{m.trim()&&(o(m),g(""))};return n.jsxs("div",{ref:w,className:"relative",children:[n.jsx("button",{type:"button",disabled:e,onClick:()=>p(y=>!y),"aria-haspopup":"true","aria-expanded":d,title:e?"Exit focus mode to change filters":a!=null?`Active view: ${a}`:"Saved filter views",className:`inline-flex max-w-[12rem] items-center whitespace-nowrap rounded border px-2 py-0.5 text-xs transition ${e?"cursor-not-allowed border-gray-300 text-gray-600 opacity-45 dark:border-gray-700 dark:text-gray-300":a!=null?"border-blue-400 text-blue-700 hover:border-blue-500 dark:border-blue-600 dark:text-blue-300":"border-gray-300 text-gray-600 hover:border-gray-400 hover:text-gray-800 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500 dark:hover:text-gray-100"}`,children:a!=null?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"shrink-0",children:"Views: "}),n.jsx("span",{className:"min-w-0 truncate font-medium",children:a}),n.jsx("span",{className:"shrink-0",children:" ▾"})]}):n.jsxs(n.Fragment,{children:["Views",s.length>0?` (${s.length})`:""," ▾"]})}),d&&!e&&n.jsxs("div",{className:"absolute right-0 top-full z-[60] mt-1 w-60 rounded-lg border border-gray-200 bg-white p-1.5 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[s.length===0?n.jsx("div",{className:"px-2 py-1.5 text-xs text-gray-500",children:"No saved views yet."}):n.jsx("div",{className:"max-h-60 overflow-auto",children:s.map(y=>{const j=y.name===a;return n.jsxs("div",{className:`flex items-center gap-1 rounded ${j?"bg-blue-50 dark:bg-blue-900/20":"hover:bg-gray-100 dark:hover:bg-gray-800"}`,children:[n.jsxs("button",{type:"button",onClick:()=>{u(y),p(!1)},title:j?`"${y.name}" is active`:`Apply "${y.name}"`,className:`flex min-w-0 flex-1 items-center gap-1 px-2 py-1.5 text-left text-xs ${j?"font-medium text-blue-700 dark:text-blue-300":""}`,children:[n.jsx("span",{"aria-hidden":!0,className:"w-3 shrink-0 text-blue-500",children:j?"✓":""}),n.jsx("span",{className:"min-w-0 truncate",children:y.name})]}),n.jsx("button",{type:"button",onClick:()=>o(y.name),disabled:j,title:j?`"${y.name}" already matches the current filters`:`Overwrite "${y.name}" with the current filters`,"aria-label":`Overwrite view ${y.name} with current filters`,className:"px-1.5 py-1.5 text-xs text-gray-400 hover:text-blue-500 disabled:cursor-default disabled:opacity-30 disabled:hover:text-gray-400",children:"↻"}),n.jsx("button",{type:"button",onClick:()=>i(y.name),title:`Delete "${y.name}"`,"aria-label":`Delete view ${y.name}`,className:"px-2 py-1.5 text-xs text-gray-400 hover:text-red-500",children:"✕"})]},y.name)})}),n.jsxs("div",{className:"mt-1 flex items-center gap-1 border-t border-gray-200 pt-1.5 dark:border-gray-800",children:[n.jsx("input",{type:"text",value:m,placeholder:"Save current as…",onChange:y=>g(y.target.value),onKeyDown:y=>{y.key==="Enter"&&v()},className:"min-w-0 flex-1 rounded border border-gray-300 bg-transparent px-1.5 py-0.5 text-xs focus:border-blue-500 focus:outline-none dark:border-gray-700"}),n.jsx("button",{type:"button",onClick:v,disabled:!m.trim(),className:"shrink-0 rounded border border-blue-400 px-1.5 py-0.5 text-xs text-blue-600 hover:bg-blue-50 disabled:opacity-40 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",children:"Save"})]})]})]})}const Jx={draft:"Draft",open:"Open",merged:"Merged",closed:"Closed"},Fp=!0,Zx="A stale PR is an open PR with no commits, comments or reviews in the selected time range. Unchecked hides them; check to include them.";function ey(e,s){if(e.length!==s.length)return!1;const a=new Set(e);return s.every(o=>a.has(o))}function ty({statuses:e,onToggle:s,onSet:a,excludeStale:o,onExcludeStaleChange:i}){const[u,d]=x.useState(!1),p=x.useRef(null),m=ey(e,Bo)&&o===Fp,g=e.length+(o?0:1),w=ul.length+1,v=()=>{a([...Bo]),i(Fp)};return Yn(p,()=>d(!1),u),x.useEffect(()=>{if(!u)return;const y=j=>{j.key==="Escape"&&(j.stopPropagation(),d(!1))};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[u]),n.jsxs("div",{ref:p,className:"relative",children:[n.jsxs("span",{className:"inline-flex items-center whitespace-nowrap rounded-full border border-gray-300 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[n.jsxs("button",{type:"button",onClick:()=>d(y=>!y),"aria-haspopup":"true","aria-expanded":u,className:`inline-flex items-center gap-1 py-0.5 pl-2.5 ${m?"pr-2.5":"pr-1"}`,children:["Status",m?"":` (${g})`,n.jsx("span",{"aria-hidden":!0,className:"text-[9px]",children:"▾"})]}),!m&&n.jsx("button",{type:"button",onClick:v,title:"Reset statuses to default","aria-label":"Reset statuses to default",className:"py-0.5 pl-0.5 pr-2 opacity-60 hover:opacity-100",children:"✕"})]}),u&&n.jsxs("div",{role:"dialog","aria-label":"PR statuses",className:"absolute left-0 top-full z-[60] mt-1 w-60 rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[n.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[ul.map(y=>n.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[n.jsx("input",{type:"checkbox",checked:e.includes(y),onChange:()=>s(y)}),n.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:Jx[y]})]},y)),n.jsx("div",{className:"my-1 border-t border-gray-200 dark:border-gray-700"}),n.jsxs("label",{title:Zx,className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[n.jsx("input",{type:"checkbox",checked:!o,onChange:()=>i(!o)}),n.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:"Show stale PRs"})]})]}),!m&&n.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-gray-200 pt-2 dark:border-gray-700",children:[n.jsxs("span",{className:"text-[11px] text-gray-400",children:[g," of ",w," shown"]}),n.jsx("button",{type:"button",onClick:v,className:"text-[11px] text-gray-400 hover:text-gray-600",children:"Reset to default"})]})]})]})}function ny({derivedStates:e,onToggle:s,onClear:a}){const[o,i]=x.useState(!1),u=x.useRef(null),d=e.length>0,p=e.length;return Yn(u,()=>i(!1),o),x.useEffect(()=>{if(!o)return;const m=g=>{g.key==="Escape"&&(g.stopPropagation(),i(!1))};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[o]),n.jsxs("div",{ref:u,className:"relative",children:[n.jsxs("span",{className:"inline-flex items-center whitespace-nowrap rounded-full border border-gray-300 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[n.jsxs("button",{type:"button",onClick:()=>i(m=>!m),"aria-haspopup":"true","aria-expanded":o,className:`inline-flex items-center gap-1 py-0.5 pl-2.5 ${d?"pr-1":"pr-2.5"}`,children:["Threads",d?` (${p})`:"",n.jsx("span",{"aria-hidden":!0,className:"text-[9px]",children:"▾"})]}),d&&n.jsx("button",{type:"button",onClick:a,title:"Clear the thread-state filter","aria-label":"Clear the thread-state filter",className:"py-0.5 pl-0.5 pr-2 opacity-60 hover:opacity-100",children:"✕"})]}),o&&n.jsxs("div",{role:"dialog","aria-label":"Thread states",className:"absolute left-0 top-full z-[60] mt-1 w-64 rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[n.jsx("p",{className:"px-1 pb-1.5 text-[11px] leading-snug text-gray-400",children:"Show only PRs with a review thread that is:"}),n.jsx("div",{className:"max-h-72 overflow-y-auto",children:Pu.map(m=>{const g=jt[m];return n.jsxs("label",{title:g.description,className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[n.jsx("input",{type:"checkbox",checked:e.includes(m),onChange:()=>s(m)}),n.jsx("span",{"aria-hidden":!0,className:"h-2.5 w-2.5 shrink-0 rounded-full",style:{backgroundColor:g.color}}),n.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:g.label})]},m)})}),d&&n.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-gray-200 pt-2 dark:border-gray-700",children:[n.jsxs("span",{className:"text-[11px] text-gray-400",children:[p," selected"]}),n.jsx("button",{type:"button",onClick:a,className:"text-[11px] text-gray-400 hover:text-gray-600",children:"Clear"})]})]})]})}const ry={...Uc,tagNames:[...Uc.tagNames??[],"img"],attributes:{...Uc.attributes,img:["src","alt","title","width","height"]}},cr=x.memo(function({children:s}){return n.jsx("div",{className:"md-body",children:n.jsx(nx,{remarkPlugins:[ax],rehypePlugins:[rx,[sx,ry],[lx,{detect:!0,ignoreMissing:!0}]],components:{a:({node:a,...o})=>n.jsx("a",{...o,target:"_blank",rel:"noreferrer noopener"}),img:({node:a,...o})=>n.jsx("img",{...o,loading:"lazy",referrerPolicy:"no-referrer"})},children:s})})});function sy(){const{data:e}=Mu();return x.useMemo(()=>{const s=new Map;for(const a of e??[])s.set(a.repoId,new Set(a.userIds));return s},[e])}function zu({className:e}){return n.jsxs("svg",{viewBox:"0 0 16 16",width:"11",height:"11","aria-hidden":"true",className:["inline-block shrink-0",e].filter(Boolean).join(" "),children:[n.jsx("title",{children:"Has merge rights — has merged a PR in this repo"}),n.jsx("path",{fill:"#8957e5",d:"M8 .8 2.2 2.9v4.2c0 3.3 2.5 6.4 5.8 7.3 3.3-.9 5.8-4 5.8-7.3V2.9L8 .8Z"}),n.jsx("path",{d:"M5.2 8 7.1 9.9 10.9 6",fill:"none",stroke:"#fff",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})]})}function sn({user:e,fallbackId:s,repoId:a,className:o}){var g;const i=sy(),d=a!=null&&e!=null&&(((g=i.get(a))==null?void 0:g.has(e.id))??!1)?n.jsx(zu,{}):null,p=ft(e,s),m=e!=null&&e.githubLogin?n.jsx("a",{href:Du(e.githubLogin),target:"_blank",rel:"noreferrer noopener",onClick:w=>w.stopPropagation(),title:`@${e.githubLogin} on GitHub`,className:[o,"hover:underline"].filter(Boolean).join(" "),children:p}):n.jsx("span",{className:o,children:p});return d?n.jsxs("span",{className:"inline-flex items-center gap-1",children:[m,d]}):m}function ht({user:e,size:s=24}){const a=ft(e,null);return e!=null&&e.avatarUrl?n.jsx("img",{src:e.avatarUrl,alt:a,width:s,height:s,className:"shrink-0 rounded-full",style:{width:s,height:s}}):n.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-full bg-gray-300 text-[10px] font-semibold text-gray-700 dark:bg-gray-700 dark:text-gray-200",style:{width:s,height:s},children:a.slice(0,2).toUpperCase()})}function Lp(){return n.jsx("span",{className:"flex-none",title:"Maintainer — has merged a PR in the selected repo(s)",children:n.jsxs("svg",{viewBox:"0 0 16 16",width:"11",height:"11","aria-hidden":"true",children:[n.jsx("path",{fill:"#8957e5",d:"M8 .8 2.2 2.9v4.2c0 3.3 2.5 6.4 5.8 7.3 3.3-.9 5.8-4 5.8-7.3V2.9L8 .8Z"}),n.jsx("path",{d:"M5.2 8 7.1 9.9 10.9 6",fill:"none",stroke:"#fff",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})]})})}function ay({sections:e,botSections:s,userIds:a,maintainerIds:o,onApply:i,excludeBots:u,onExcludeBotsChange:d,allowedBotIds:p,onToggleAllowedBot:m}){const[g,w]=x.useState(!1),[v,y]=x.useState(new Set),[j,R]=x.useState(""),P=x.useRef(null),E=(a==null?void 0:a.length)??0,S=()=>{y(new Set(a??[])),R(""),w(!0)},T=j.trim().toLowerCase(),N=X=>!T||X.githubLogin.toLowerCase().includes(T)||(X.displayName??"").toLowerCase().includes(T),b=e.map(X=>({...X,members:X.members.filter(N)})).filter(X=>X.members.length>0),I=e.reduce((X,B)=>X+B.members.length,0),$=new Set(p),L=s.map(X=>({...X,members:X.members.filter(N)})).filter(X=>X.members.length>0);Yn(P,()=>w(!1),g),x.useEffect(()=>{if(!g)return;const X=B=>{B.key==="Escape"&&(B.stopPropagation(),w(!1))};return document.addEventListener("keydown",X),()=>document.removeEventListener("keydown",X)},[g]);const q=X=>y(B=>{const O=new Set(B);return O.has(X)?O.delete(X):O.add(X),O}),Q=(X,B)=>y(O=>{const H=new Set(O);for(const ee of X)B?H.add(ee):H.delete(ee);return H}),_=()=>{const X=[...v];i(X.length?X:null),w(!1)},Y=()=>y(new Set);return n.jsxs("div",{ref:P,className:"relative",children:[n.jsxs("span",{className:"inline-flex items-center whitespace-nowrap rounded-full border border-gray-300 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[n.jsxs("button",{type:"button",onClick:()=>g?w(!1):S(),"aria-haspopup":"true","aria-expanded":g,className:`inline-flex items-center gap-1 py-0.5 pl-2.5 ${E>0?"pr-1":"pr-2.5"}`,children:["Members",E>0?` (${E})`:"",n.jsx("span",{"aria-hidden":!0,className:"text-[9px]",children:"▾"})]}),E>0&&n.jsx("button",{type:"button",onClick:()=>{i(null),w(!1)},title:"Clear members filter","aria-label":"Clear members filter",className:"py-0.5 pl-0.5 pr-2 opacity-60 hover:opacity-100",children:"✕"})]}),g&&n.jsxs("div",{role:"dialog","aria-label":"Select members",className:"absolute left-0 top-full z-[60] mt-1 w-80 rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[n.jsx("input",{autoFocus:!0,type:"search",value:j,onChange:X=>R(X.target.value),placeholder:"Filter members…","aria-label":"Filter members",className:"mb-2 w-full 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"}),o.size>0&&(()=>{const X=[...o],B=X.every(O=>v.has(O));return n.jsxs("button",{type:"button",onClick:()=>Q(X,!B),title:"Select every maintainer in the current filter",className:`mb-2 flex w-full items-center gap-2 rounded px-2 py-1 text-xs transition ${B?"bg-[#8957e5]/15 text-[#8957e5]":"text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800"}`,children:[n.jsx(Lp,{}),n.jsx("span",{className:"font-medium",children:"Maintainers"}),n.jsxs("span",{className:"text-gray-400",children:["(",X.length,")"]}),n.jsx("span",{className:"ml-auto text-[10px] text-gray-400",children:B?"clear":"select all"})]})})(),n.jsx("div",{className:"max-h-72 overflow-y-auto",children:I===0?n.jsx("div",{className:"px-1 py-2 text-xs text-gray-500",children:"No members in range."}):b.length===0?n.jsx("div",{className:"px-1 py-2 text-xs text-gray-500",children:"No members match."}):b.map(X=>{const B=X.members.map(H=>H.id),O=B.every(H=>v.has(H));return n.jsxs("div",{className:"mb-1 last:mb-0",children:[n.jsxs("div",{className:"sticky top-0 flex items-center justify-between bg-white px-1 pb-0.5 pt-1 dark:bg-gray-900",children:[n.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:X.label}),n.jsx("button",{type:"button",onClick:()=>Q(B,!O),className:"text-[10px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:O?"none":"all"})]}),X.members.map(H=>n.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[n.jsx("input",{type:"checkbox",checked:v.has(H.id),onChange:()=>q(H.id)}),n.jsx(ht,{user:H,size:16}),n.jsx("span",{className:"min-w-0 truncate",title:H.githubLogin,children:ft(H,H.id)}),o.has(H.id)&&n.jsx(Lp,{})]},`${X.key}:${H.id}`))]},X.key)})}),n.jsxs("label",{className:"mt-2 flex cursor-pointer items-center gap-2 border-t border-gray-200 pt-2 text-xs text-gray-600 dark:border-gray-700 dark:text-gray-300",children:[n.jsx("input",{type:"checkbox",checked:u,onChange:X=>d(X.target.checked)}),"Exclude bots"]}),L.length>0&&n.jsxs("div",{className:"mt-2 border-t border-gray-200 pt-2 dark:border-gray-700",children:[n.jsxs("div",{className:"mb-1 flex items-center gap-1.5 px-1",children:[n.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"Bots"}),n.jsx("span",{className:"text-[10px] text-gray-400",children:u?"· ticked stay visible":"· all shown (bots not excluded)"})]}),n.jsx("div",{className:"max-h-40 overflow-y-auto",children:L.map(X=>n.jsxs("div",{className:"mb-1 last:mb-0",children:[n.jsx("div",{className:"sticky top-0 bg-white px-1 pb-0.5 pt-1 text-[10px] font-semibold uppercase tracking-wide text-gray-400 dark:bg-gray-900",children:X.label}),X.members.map(B=>n.jsxs("label",{className:`flex items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800 ${u?"cursor-pointer":"cursor-pointer opacity-60"}`,title:u?"Keep this bot visible even though bots are excluded":'Bots are currently shown; enable "Exclude bots" for this to take effect',children:[n.jsx("input",{type:"checkbox",checked:$.has(B.id),onChange:()=>m(B.id)}),n.jsx(ht,{user:B,size:16}),n.jsx("span",{className:"min-w-0 truncate",title:B.githubLogin,children:ft(B,B.id)})]},`${X.key}:${B.id}`))]},X.key))})]}),n.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[n.jsx("button",{type:"button",onClick:Y,className:"text-[11px] text-gray-400 hover:text-gray-600",children:"Clear all"}),n.jsx("button",{type:"button",onClick:_,className:"rounded bg-blue-600 px-2.5 py-0.5 text-xs text-white",children:"Apply"})]})]})]})}const ly=["7d","14d","30d","90d"];function oy({active:e,onClick:s,children:a,color:o,title:i,onRemove:u,removeTitle:d,removeDisabled:p}){const m=`whitespace-nowrap rounded-full border text-xs transition ${e?"border-transparent bg-blue-600 text-white":"border-gray-300 text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500"}`,g=e&&o?{backgroundColor:o}:void 0;return u?n.jsxs("span",{className:`inline-flex items-center ${m}`,style:g,children:[n.jsx("button",{type:"button",onClick:s,title:i,className:"py-0.5 pl-2.5 pr-1",children:a}),n.jsx("button",{type:"button",onClick:u,disabled:p,title:d,"aria-label":d,className:"py-0.5 pl-0.5 pr-2 opacity-50 hover:opacity-100 disabled:opacity-30",children:"✕"})]}):n.jsx("button",{type:"button",onClick:s,title:i,className:`${m} px-2.5 py-0.5`,style:g,children:a})}function ba({label:e,children:s}){return n.jsxs("div",{className:"flex items-center gap-1.5",children:[e!=null&&n.jsx("span",{className:"text-[11px] uppercase tracking-wide text-gray-400",children:e}),s]})}function iy(){const{data:e}=Mr(),{data:s}=$n(),{data:a}=Fu(),{data:o}=Lu(),{data:i}=Mu(),u=te(),p=De(S=>S.activeTab)==="activity",m=Be(),g=Ue({mutationFn:S=>ge.deleteRepo(S),onMutate:async S=>{await m.cancelQueries({queryKey:["repos"]});const T=m.getQueryData(["repos"]);return m.setQueryData(["repos"],N=>N==null?void 0:N.filter(b=>b.id!==S)),{previous:T}},onError:(S,T,N)=>{N!=null&&N.previous&&m.setQueryData(["repos"],N.previous)},onSuccess:(S,T)=>{var I;const N=te.getState(),b=(I=N.repoIds)==null?void 0:I.filter($=>$!==T);N.setRepoIds(b&&b.length?b:null)},onSettled:()=>{for(const S of["repos","timeline","open-prs","users","my-turn","me"])m.invalidateQueries({queryKey:[S]})}}),w=Ue({mutationFn:S=>ge.setRepoInboxWatch(S.id,S.watch),onMutate:async({id:S,watch:T})=>{await m.cancelQueries({queryKey:["repos"]});const N=m.getQueryData(["repos"]);return m.setQueryData(["repos"],b=>b==null?void 0:b.map(I=>I.id===S?{...I,inboxWatch:T}:I)),{previous:N}},onError:(S,T,N)=>{N!=null&&N.previous&&m.setQueryData(["repos"],N.previous)},onSettled:()=>{for(const S of["repos","my-turn","my-turn-done","me",...Ou])m.invalidateQueries({queryKey:[S]})}}),v=S=>{const T=(e??[]).map(b=>b.id),N=new Set(te.getState().repoIds??T);N.has(S)?N.delete(S):N.add(S),u.setRepoIds(N.size===0||N.size===T.length?null:T.filter(b=>N.has(b)))},y=S=>{const T=(e??[]).map(N=>N.id);u.setRepoIds(T.length<=1?null:[S])},j=S=>{window.confirm(`Remove ${S.fullName}? This deletes all of its locally-synced data.`)&&g.mutate(S.id)},{sections:R,botSections:P,maintainerIds:E}=x.useMemo(()=>{const S=u.repoIds!=null&&u.repoIds.length>0,T=S?new Set(u.repoIds):null,N=new Map((s??[]).map(F=>[F.id,F])),b=F=>{if(F==null)return null;const K=N.get(F);return K&&!K.isBot?K:null},I=F=>{if(F==null)return null;const K=N.get(F);return K&&K.isBot?K:null},$=new Map,L=(F,K)=>{if(K==null||T&&!T.has(F))return;let ae=$.get(F);ae||$.set(F,ae=new Set),ae.add(K)};for(const F of(a==null?void 0:a.events)??[])L(F.repoId,F.actorId);for(const F of(a==null?void 0:a.prs)??[])L(F.repoId,F.authorId);for(const F of(o==null?void 0:o.prs)??[])L(F.repoId,F.authorId);const q=new Set;for(const F of i??[])if(!(T&&!T.has(F.repoId)))for(const K of F.userIds)b(K)&&(q.add(K),L(F.repoId,K));const Q=(F,K)=>(F.displayName||F.githubLogin).localeCompare(K.displayName||K.githubLogin),_=(F,K)=>{const ae=(q.has(F.id)?0:1)-(q.has(K.id)?0:1);return ae!==0?ae:Q(F,K)},Y=[],X=new Set;for(const F of e??[]){if(T&&!T.has(F.id))continue;const K=$.get(F.id);if(!K||K.size===0)continue;const ae=[...K].map(b).filter(ne=>ne!=null).sort(_);if(ae.length){Y.push({key:`repo:${F.id}`,label:F.name,members:ae});for(const ne of ae)X.add(ne.id)}}const B=u.userIds??[],H=[...S?new Set([...X,...B]):new Set((s??[]).filter(F=>!F.isBot).map(F=>F.id))].map(b).filter(F=>F!=null).filter(F=>!X.has(F.id)).sort(Q);H.length&&Y.push({key:"other",label:S?"Other":"No recent activity",members:H});const ee=[],ce=new Set;for(const F of e??[]){if(T&&!T.has(F.id))continue;const K=$.get(F.id);if(!K)continue;const ae=[...K].map(I).filter(ne=>ne!=null).sort(Q);if(ae.length){ee.push({key:`bot:${F.id}`,label:F.name,members:ae});for(const ne of ae)ce.add(ne.id)}}const C=(u.allowedBotIds??[]).map(I).filter(F=>F!=null).filter(F=>!ce.has(F.id)).sort(Q);return C.length&&ee.push({key:"bot:other",label:"Other bots",members:C}),{sections:Y,botSections:ee,maintainerIds:q}},[s,a,o,i,e,u.repoIds,u.userIds,u.allowedBotIds]);return n.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 border-b border-gray-200 bg-gray-50 px-4 py-2 dark:border-gray-800 dark:bg-gray-900",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[n.jsxs(ba,{children:[n.jsx(Qx,{repos:e??[],repoIds:u.repoIds,onToggle:v,onOnly:y,onShowAll:()=>u.setRepoIds(null),onToggleWatch:S=>w.mutate({id:S.id,watch:!S.inboxWatch}),watchPending:!1,onRemove:j,removePending:!1}),g.error&&n.jsx("span",{className:"max-w-[14rem] truncate text-xs text-red-500",title:String(g.error),children:g.error instanceof Gt?g.error.message:"Failed to remove repo"}),n.jsx(zx,{})]}),n.jsx(ba,{children:n.jsx(ay,{sections:R,botSections:P,userIds:u.userIds,maintainerIds:E,onApply:S=>u.setUserIds(S),excludeBots:u.excludeBots,onExcludeBotsChange:u.setExcludeBots,allowedBotIds:u.allowedBotIds,onToggleAllowedBot:u.toggleAllowedBot})}),!p&&n.jsx(ba,{children:n.jsx(ty,{statuses:u.prStatuses,onToggle:u.togglePrStatus,onSet:u.setPrStatuses,excludeStale:u.excludeStale,onExcludeStaleChange:u.setExcludeStale})}),!p&&n.jsx(ba,{children:n.jsx(_x,{categories:u.categories,onToggleCategory:S=>u.toggleCategory(S),onSetCategories:S=>u.setCategories(S),reviewStates:u.reviewStates,onToggleReviewState:S=>u.toggleReviewState(S),onSetReviewStates:S=>u.setReviewStates(S)})}),!p&&n.jsx(ba,{children:n.jsx(ny,{derivedStates:u.derivedStates,onToggle:S=>u.toggleDerivedState(S),onClear:()=>u.setDerivedStates([])})}),!p&&n.jsxs(ba,{label:"Range",children:[ly.map(S=>n.jsx(oy,{active:u.preset===S,onClick:()=>u.setPreset(S),children:S},S)),n.jsx("button",{type:"button",onClick:()=>u.centerTimelineNow(),title:"Recenter the timeline on the current time (keeps the zoom)",className:"whitespace-nowrap rounded-full border border-sky-300 px-2.5 py-0.5 text-xs text-sky-600 transition hover:border-sky-400 hover:bg-sky-50 dark:border-sky-700 dark:text-sky-400 dark:hover:bg-sky-900/30",children:"Now"})]})]}),!p&&n.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[n.jsx(Xx,{disabled:!1}),n.jsx("button",{type:"button",onClick:()=>u.resetAllFilters(),title:"Reset all filters to their defaults",className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-xs text-gray-600 transition hover:border-gray-400 hover:text-gray-800 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500 dark:hover:text-gray-100",children:"Clear filters"})]})]})}function cy(e){if(!e)return null;const s=e.commits+e.comments+e.reviews;return s>0?`${s} new`:null}function uy({pr:e}){const s=ur[e.ciStatus],a=Xo(e.mergeable,e.mergeStateStatus),o=cy(e.newSinceLastViewed),i=e.threadCounts;return n.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px]",children:[s&&n.jsxs("span",{className:"inline-flex items-center gap-1",title:s.label,children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:s.color}}),n.jsx("span",{className:"text-gray-500",children:s.label})]}),a&&n.jsxs("span",{className:"inline-flex items-center gap-0.5 text-orange-500",title:`Merge state: ${a}`,children:["⚠ ",a]}),o&&n.jsxs("span",{className:"inline-flex items-center gap-0.5 font-medium text-sky-500",title:"New since you last looked",children:["👁 ",o]}),i.untouched>0&&n.jsxs("span",{className:"text-red-500",title:"Untouched threads",children:["🔴 ",i.untouched]}),i.replied_unresolved>0&&n.jsxs("span",{className:"text-amber-500",title:"Replied, unresolved",children:["🟡 ",i.replied_unresolved]}),i.likely_addressed>0&&n.jsxs("span",{className:"text-blue-500",title:"Likely addressed",children:["🔵 ",i.likely_addressed]}),i.resolved>0&&n.jsxs("span",{className:"text-green-600",title:"Resolved",children:["✓ ",i.resolved]})]})}function dy({tag:e}){const s=oh[e];return n.jsxs("span",{className:"inline-flex items-center gap-1 truncate text-[11px] font-medium",style:{color:s.color},title:s.label,children:[n.jsx("span",{"aria-hidden":!0,children:"⏵"}),s.label]})}function fy({pr:e,repoFullName:s,repoWatched:a=!1,usersById:o}){const i=te(j=>j.openPrFocused),u=te(j=>j.selectedPrId),d=Be(),p=Ue({mutationFn:j=>ge.dismissPr(j),onSuccess:()=>{d.invalidateQueries({queryKey:["open-prs"]}),d.invalidateQueries({queryKey:["timeline"]}),d.invalidateQueries({queryKey:["my-turn"]}),d.invalidateQueries({queryKey:["me"]})}}),m=e.authorId!=null?o.get(e.authorId):void 0,g=hu(e.reasonTag),w=u===e.id,v=e.newSinceLastViewed,y=!!v&&v.commits+v.comments+v.reviews>0;return n.jsxs("div",{role:"button",tabIndex:0,onClick:()=>i(e.id),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&i(e.id)},className:`relative flex w-52 shrink-0 cursor-pointer flex-col gap-1 rounded-lg border p-2 text-left transition ${w?"border-blue-500 ring-1 ring-blue-500":"border-gray-200 hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-500"} ${g?"my-turn-ring":""} bg-white dark:bg-gray-900`,children:[y&&n.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),p.mutate(e.id)},disabled:p.isPending,className:"absolute right-1.5 top-1.5 rounded px-1 text-[10px] text-gray-400 hover:bg-gray-200/60 hover:text-gray-600 dark:hover:bg-gray-700/60",title:"Mark viewed (clear the new badge)",children:"✓ seen"}),n.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-400",children:[n.jsx("span",{className:"truncate",children:s}),a&&n.jsx(Bu,{size:10}),n.jsx("span",{children:"·"}),n.jsxs("span",{className:"shrink-0",children:["#",e.number]}),n.jsx("a",{href:`https://github.com/${s}/pull/${e.number}`,target:"_blank",rel:"noreferrer noopener",onClick:j=>j.stopPropagation(),className:"shrink-0 text-gray-400 hover:text-blue-500",title:"Open on GitHub",children:"↗"}),e.isDraft&&n.jsx("span",{className:"ml-1 rounded bg-gray-500/20 px-1 text-[9px] uppercase",children:"draft"})]}),n.jsx("div",{className:"line-clamp-2 text-xs font-semibold leading-snug",title:e.title,children:e.title}),n.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-gray-500",children:[n.jsx(ht,{user:m,size:14}),n.jsx("span",{className:"truncate",children:ft(m,e.authorId)}),n.jsx("span",{children:"·"}),n.jsx("span",{className:"shrink-0",children:St(e.openedAt)})]}),n.jsx(uy,{pr:e}),n.jsx("div",{className:"mt-auto pt-0.5",children:n.jsx(dy,{tag:e.reasonTag})})]})}const _p={all:"all open",my_turn:"my turn",needs_attention:"needs attention"};function py(){const{data:e,isLoading:s}=rh(),{data:a}=Mr(),{data:o}=$n(),i=te($=>$.stripCollapsed),u=te($=>$.setStripCollapsed),d=te($=>$.stripFilter),p=te($=>$.setStripFilter),m=x.useRef(null);x.useEffect(()=>{const $=m.current;$&&(i?$.setAttribute("inert",""):$.removeAttribute("inert"))},[i]);const g=x.useMemo(()=>{const $=new Map;for(const L of a??[])$.set(L.id,{fullName:L.fullName,inboxWatch:L.inboxWatch});return $},[a]),w=x.useMemo(()=>ln(o),[o]),v=(e==null?void 0:e.prs)??[],y=v.filter($=>hu($.reasonTag)).length,j=v.filter($=>$.reasonTag==="stalled").length,R=x.useMemo(()=>[...d==="my_turn"?v.filter(L=>hu(L.reasonTag)):d==="needs_attention"?v.filter(L=>L.reasonTag!=="in_progress"):v].sort((L,q)=>Date.parse(q.openedAt)-Date.parse(L.openedAt)),[v,d]),P=6,E=4,S=x.useRef(null),T=x.useRef(208+P),N=R.length,[b,I]=x.useState({start:0,end:24});return x.useEffect(()=>{const $=S.current;if(!$)return;let L=null;const q=()=>{L=null;const Y=Array.from($.children).filter(H=>!H.hasAttribute("aria-hidden"));if(Y.length>=2){const H=Y[1].offsetLeft-Y[0].offsetLeft;H>0&&(T.current=H)}const X=T.current,B=Math.max(0,Math.floor($.scrollLeft/X)-E),O=Math.min(N,Math.ceil(($.scrollLeft+$.clientWidth)/X)+E);I(H=>H.start===B&&H.end===O?H:{start:B,end:O})},Q=()=>{L==null&&(L=requestAnimationFrame(q))};q(),$.addEventListener("scroll",Q,{passive:!0});const _=new ResizeObserver(Q);return _.observe($),()=>{$.removeEventListener("scroll",Q),_.disconnect(),L!=null&&cancelAnimationFrame(L)}},[N,d]),!s&&v.length===0?null:n.jsxs("div",{"data-testid":"open-pr-strip",className:"shrink-0 border-b border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/50",children:[n.jsxs("div",{className:"flex items-center gap-2 px-4 py-1",children:[n.jsx("button",{type:"button",onClick:()=>u(!i),"aria-expanded":!i,title:i?"Expand":"Collapse",className:"text-[11px] font-semibold uppercase tracking-wide text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:"Open PRs"}),!i&&n.jsx("div",{className:"flex items-center gap-1",children:Object.keys(_p).map($=>n.jsxs("button",{type:"button",onClick:()=>p($),className:`rounded-full px-2 py-0.5 text-[11px] ${d===$?"bg-blue-600 text-white":"text-gray-500 hover:text-gray-700 dark:hover:text-gray-300"}`,children:[_p[$],$==="my_turn"&&y>0&&` (${y})`]},$))}),i&&n.jsxs("span",{className:"text-xs text-gray-500",children:[v.length," open · ",y," my turn · ",j," stalled"]}),n.jsx("button",{type:"button",onClick:()=>u(!i),className:"ml-auto rounded px-1.5 text-xs text-gray-400 hover:text-gray-600",title:i?"Expand":"Collapse",children:i?"▾":"▴"})]}),n.jsx("div",{ref:m,className:`grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none ${i?"grid-rows-[0fr]":"grid-rows-[1fr]"}`,children:n.jsx("div",{className:"min-h-0 overflow-hidden",children:n.jsx("div",{ref:S,className:"flex items-stretch gap-1.5 overflow-x-auto px-3 pb-1.5 pt-0.5",children:R.length===0?n.jsx("div",{className:"flex items-center text-xs text-gray-500",children:d==="my_turn"?"Nothing needs you right now.":"No PRs match this filter."}):n.jsxs(n.Fragment,{children:[b.start>0&&n.jsx("div",{"aria-hidden":!0,className:"shrink-0",style:{width:b.start*T.current-P}}),R.slice(b.start,b.end).map($=>{var L,q;return n.jsx(fy,{pr:$,repoFullName:((L=g.get($.repoId))==null?void 0:L.fullName)??`repo ${$.repoId}`,repoWatched:((q=g.get($.repoId))==null?void 0:q.inboxWatch)??!1,usersById:w},$.id)}),b.end<N&&n.jsx("div",{"aria-hidden":!0,className:"shrink-0",style:{width:(N-b.end)*T.current}})]})})})})]})}function Jo({size:e=14,className:s,title:a}){return n.jsxs("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:s,"aria-hidden":a==null?!0:void 0,role:a!=null?"img":void 0,children:[a!=null&&n.jsx("title",{children:a}),n.jsx("circle",{cx:"11",cy:"11",r:"8"}),n.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function my({size:e=15,className:s,title:a}){return n.jsxs("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:s,"aria-hidden":a==null?!0:void 0,role:a!=null?"img":void 0,children:[a!=null&&n.jsx("title",{children:a}),n.jsx("line",{x1:"4",y1:"7",x2:"14",y2:"7"}),n.jsx("line",{x1:"9",y1:"12",x2:"20",y2:"12"}),n.jsx("line",{x1:"4",y1:"17",x2:"12",y2:"17"})]})}function hy({size:e=15,className:s,title:a}){return n.jsxs("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"currentColor",className:s,"aria-hidden":a==null?!0:void 0,role:a!=null?"img":void 0,children:[a!=null&&n.jsx("title",{children:a}),n.jsx("path",{d:"M12 .5C5.37.5 0 5.87 0 12.5c0 5.3 3.44 9.8 8.21 11.39.6.11.82-.26.82-.58 0-.29-.01-1.05-.02-2.06-3.34.73-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.09-.75.08-.73.08-.73 1.21.09 1.85 1.24 1.85 1.24 1.07 1.84 2.81 1.31 3.5 1 .11-.78.42-1.31.76-1.61-2.67-.3-5.47-1.34-5.47-5.95 0-1.31.47-2.39 1.24-3.23-.12-.3-.54-1.53.12-3.18 0 0 1.01-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.29-1.55 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.77.84 1.24 1.92 1.24 3.23 0 4.62-2.81 5.64-5.49 5.94.43.37.81 1.1.81 2.22 0 1.6-.01 2.9-.01 3.29 0 .32.22.7.83.58A12 12 0 0 0 24 12.5C24 5.87 18.63.5 12 .5z"})]})}function ph({size:e=13,className:s,title:a}){return n.jsxs("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:s,"aria-hidden":a==null?!0:void 0,role:a!=null?"img":void 0,children:[a!=null&&n.jsx("title",{children:a}),n.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),n.jsx("polyline",{points:"15 3 21 3 21 9"}),n.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}const gy=n.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"4",y1:"20",x2:"4",y2:"12"}),n.jsx("line",{x1:"10",y1:"20",x2:"10",y2:"6"}),n.jsx("line",{x1:"16",y1:"20",x2:"16",y2:"14"}),n.jsx("line",{x1:"20",y1:"20",x2:"20",y2:"9"})]});function xy({tab:e}){const s=De(g=>g.activeTab===e.key),a=De(g=>g.setActiveTab),o=De(g=>g.closeTab);if(e.kind==="metrics-detail")return n.jsxs("div",{role:"presentation",className:`group flex shrink-0 items-center gap-1 rounded-t-md border border-b-0 pl-2 pr-1 ${s?"border-gray-300 bg-white dark:border-gray-700 dark:bg-gray-950":"border-transparent bg-transparent hover:bg-gray-200/60 dark:hover:bg-gray-800/60"}`,children:[n.jsxs("button",{type:"button",role:"tab","aria-selected":s,onClick:()=>a(e.key),className:"flex items-center gap-1.5 py-1.5 text-left",title:"Flow metrics — drill-down",children:[n.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-violet-500",children:gy}),n.jsx("span",{className:`text-xs font-medium ${s?"text-violet-600 dark:text-violet-400":"text-gray-600 dark:text-gray-300"}`,children:"Flow metrics"})]}),n.jsx("button",{type:"button",onClick:()=>o(e.key),className:"shrink-0 self-center rounded px-1 py-0.5 text-xs leading-none text-gray-400 hover:bg-gray-200 hover:text-gray-700 dark:hover:bg-gray-700 dark:hover:text-gray-200",title:"Close this tab","aria-label":"Close flow-metrics tab",children:"✕"})]});if(e.kind==="bot-prs")return n.jsxs("div",{role:"presentation",className:`group flex shrink-0 items-center gap-1 rounded-t-md border border-b-0 pl-2 pr-1 ${s?"border-gray-300 bg-white dark:border-gray-700 dark:bg-gray-950":"border-transparent bg-transparent hover:bg-gray-200/60 dark:hover:bg-gray-800/60"}`,children:[n.jsxs("button",{type:"button",role:"tab","aria-selected":s,onClick:()=>a(e.key),className:"flex items-center gap-1.5 py-1.5 text-left",title:"Bot PRs — the PRs a review bot touched",children:[n.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:"🤖"}),n.jsx("span",{className:`text-xs font-medium ${s?"text-violet-600 dark:text-violet-400":"text-gray-600 dark:text-gray-300"}`,children:"Bot PRs"})]}),n.jsx("button",{type:"button",onClick:()=>o(e.key),className:"shrink-0 self-center rounded px-1 py-0.5 text-xs leading-none text-gray-400 hover:bg-gray-200 hover:text-gray-700 dark:hover:bg-gray-700 dark:hover:text-gray-200",title:"Close this tab","aria-label":"Close bot-PRs tab",children:"✕"})]});const i=e.kind==="pr-focus",u=e.meta,d=(u==null?void 0:u.authorDisplayName)??(u==null?void 0:u.authorLogin)??"unknown",p=`${(u==null?void 0:u.repoFullName)??""} #${(u==null?void 0:u.number)??""} · ${(u==null?void 0:u.title)??""}${i?" (focus)":""}`,m=`Close ${i?"focus":"detail"} tab for PR #${(u==null?void 0:u.number)??""}`;return n.jsxs("div",{role:"presentation",className:`group flex w-52 shrink-0 items-center gap-1 rounded-t-md border border-b-0 pl-2 pr-1 ${s?"border-gray-300 bg-white dark:border-gray-700 dark:bg-gray-950":"border-transparent bg-transparent hover:bg-gray-200/60 dark:hover:bg-gray-800/60"}`,children:[n.jsxs("button",{type:"button",role:"tab","aria-selected":s,onClick:()=>a(e.key),className:"flex min-w-0 flex-1 items-center gap-1.5 py-1 text-left",title:p,children:[i?n.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-sky-500",children:n.jsx(Jo,{size:14})}):(u==null?void 0:u.authorAvatarUrl)!=null?n.jsx("img",{src:u.authorAvatarUrl,alt:d,width:16,height:16,className:"shrink-0 rounded-full",style:{width:16,height:16}}):n.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-full bg-gray-300 text-[8px] font-semibold text-gray-700 dark:bg-gray-700 dark:text-gray-200",style:{width:16,height:16},children:d.slice(0,2).toUpperCase()}),n.jsxs("span",{className:"flex min-w-0 flex-col leading-tight",children:[n.jsxs("span",{className:`truncate text-xs font-medium ${s?"text-blue-600 dark:text-blue-400":"text-gray-600 dark:text-gray-300"}`,children:[n.jsxs("span",{className:"text-gray-400",children:["#",u==null?void 0:u.number]})," ",u==null?void 0:u.title]}),n.jsx("span",{className:"truncate text-[10px] text-gray-500",children:i?"PR focus":d})]})]}),n.jsx("button",{type:"button",onClick:()=>o(e.key),className:"shrink-0 self-center rounded px-1 py-0.5 text-xs leading-none text-gray-400 hover:bg-gray-200 hover:text-gray-700 dark:hover:bg-gray-700 dark:hover:text-gray-200",title:"Close this tab","aria-label":m,children:"✕"})]})}function Op({active:e,onClick:s,icon:a,label:o,title:i}){return n.jsxs("button",{type:"button",role:"tab","aria-selected":e,onClick:s,title:i,className:`flex shrink-0 items-center gap-1.5 rounded-t-md border border-b-0 px-3 py-1.5 text-xs font-semibold ${e?"border-gray-300 bg-white text-blue-600 dark:border-gray-700 dark:bg-gray-950 dark:text-blue-400":"border-transparent bg-transparent text-gray-600 hover:bg-gray-200/60 dark:text-gray-300 dark:hover:bg-gray-800/60"}`,children:[n.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:a}),o]})}const yy=n.jsxs("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12"}),n.jsx("path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"})]}),vy=n.jsxs("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"4",y1:"7",x2:"20",y2:"7"}),n.jsx("line",{x1:"4",y1:"12",x2:"14",y2:"12"}),n.jsx("line",{x1:"4",y1:"17",x2:"18",y2:"17"})]});function by(){const e=De(i=>i.tabs),s=De(i=>i.activeTab),a=De(i=>i.setActiveTab),o=De(i=>i.showTimeline);return n.jsxs("div",{"data-testid":"pinned-tabs",role:"tablist","aria-label":"Views",className:"flex min-h-[42px] shrink-0 items-end gap-1 overflow-x-auto bg-gray-100 px-2 pt-1 dark:bg-gray-900",children:[n.jsx(Op,{active:s==="activity",onClick:()=>a("activity"),icon:yy,label:"Activity",title:"Activity — per-repo triage console"}),n.jsx(Op,{active:s==="timeline",onClick:o,icon:vy,label:"Timeline",title:"Timeline — the activity board"}),e.map(i=>n.jsx(xy,{tab:i},i.key))]})}const hl=1e3*60*45;function Zo(e){return qe({queryKey:["pr",e],queryFn:()=>ge.pr(e),enabled:e!=null,staleTime:1/0,gcTime:hl})}function qu(e){return qe({queryKey:["thread",e],queryFn:()=>ge.thread(e),enabled:e!=null,staleTime:1/0,gcTime:hl})}function wy(e){return qe({queryKey:["mention-candidates",e],queryFn:()=>ge.mentionCandidates(e),enabled:e!=null,staleTime:1e3*60*5,gcTime:hl})}function ky(e,s=!0){return qe({queryKey:["suggested-reviewers",e],queryFn:()=>ge.suggestedReviewers(e),enabled:e!=null&&s,staleTime:1e3*60*2,gcTime:hl})}function jy(e){return qe({queryKey:["pr-files",e],queryFn:()=>ge.prFiles(e),enabled:e!=null,staleTime:1/0,gcTime:hl})}const mh=x.createContext(null);function yu({prId:e,at:s,event:a,title:o="Show this on the timeline",className:i=""}){const u=te(w=>w.showEventOnTimeline),d=te(w=>w.focusEventInTab),p=De(w=>w.openPrFocusTab),m=x.useContext(mh),g=()=>{if(m!=null&&m.id===e){const w=a.type==="review_comment"?a.refId:null;p(m),d(e,s,a,w)}else u(e,s,a)};return n.jsx("button",{type:"button",onClick:g,className:`shrink-0 rounded p-0.5 text-blue-500 hover:text-blue-600 ${i}`,title:o,"aria-label":o,children:n.jsx(Jo,{size:13})})}function Ny(){const e=Be();return Ue({mutationFn:s=>ge.replyToThread(s.threadId,{body:s.body}),onSuccess:(s,a)=>{e.invalidateQueries({queryKey:["pr",a.prId]}),e.invalidateQueries({queryKey:["thread",a.threadId]}),e.invalidateQueries({queryKey:["my-turn"]}),e.invalidateQueries({queryKey:["me"]}),e.invalidateQueries({queryKey:["consolidated-feed"]})}})}function Sy(){const e=Be();return Ue({mutationFn:s=>ge.resolveThread(s.threadId,{resolved:s.resolved}),onSuccess:(s,a)=>{e.invalidateQueries({queryKey:["pr",a.prId]}),e.invalidateQueries({queryKey:["thread",a.threadId]}),e.invalidateQueries({queryKey:["my-turn"]}),e.invalidateQueries({queryKey:["me"]}),e.invalidateQueries({queryKey:["consolidated-feed"]})}})}function Cy(){const e=Be();return Ue({mutationFn:s=>ge.resolveBotThreads(s.prId,{threadIds:s.threadIds}),onSuccess:(s,a)=>{e.invalidateQueries({queryKey:["pr",a.prId]}),e.invalidateQueries({queryKey:["my-turn"]}),e.invalidateQueries({queryKey:["me"]}),e.invalidateQueries({queryKey:["consolidated-feed"]}),e.invalidateQueries({queryKey:["activity"]})}})}function Ry(e){const s=Be();return Ue({mutationFn:a=>ge.createPrComment(e,{body:a}),onSuccess:()=>{s.invalidateQueries({queryKey:["pr",e]}),s.invalidateQueries({queryKey:["my-turn"]}),s.invalidateQueries({queryKey:["me"]}),s.invalidateQueries({queryKey:["consolidated-feed"]})}})}function Iy(e){const s=Be();return Ue({mutationFn:a=>ge.approvePr(e,a!==void 0?{body:a}:void 0),onSuccess:()=>{s.invalidateQueries({queryKey:["pr",e]}),s.invalidateQueries({queryKey:["timeline"]}),s.invalidateQueries({queryKey:["open-prs"]}),s.invalidateQueries({queryKey:["my-turn"]}),s.invalidateQueries({queryKey:["me"]})}})}function Ty(e,s){return qe({queryKey:["merge-options",e],queryFn:()=>ge.mergeOptions(e),enabled:s,staleTime:3e4})}function Ey(e){const s=Be();return Ue({mutationFn:a=>ge.mergePr(e,{method:a}),onSuccess:()=>{s.invalidateQueries({queryKey:["pr",e]}),s.invalidateQueries({queryKey:["merge-options",e]}),s.invalidateQueries({queryKey:["timeline"]}),s.invalidateQueries({queryKey:["open-prs"]}),s.invalidateQueries({queryKey:["my-turn"]}),s.invalidateQueries({queryKey:["me"]}),s.invalidateQueries({queryKey:["activity"]}),s.invalidateQueries({queryKey:["consolidated-feed"]}),s.invalidateQueries({queryKey:["mergers"]})}})}function Py(e){const s=Be();return Ue({mutationFn:a=>ge.updatePrBranch(e,a),onSuccess:()=>{s.invalidateQueries({queryKey:["pr",e]}),s.invalidateQueries({queryKey:["merge-options",e]}),s.invalidateQueries({queryKey:["timeline"]}),s.invalidateQueries({queryKey:["open-prs"]})}})}function Ay(e){const s=Be();return Ue({mutationFn:a=>ge.addReviewComment(e,a),onSuccess:()=>{s.invalidateQueries({queryKey:["pr",e]}),s.invalidateQueries({queryKey:["my-turn"]})}})}function hh(e){const s=Be();return Ue({mutationFn:a=>ge.requestReviewers(e,a),onSuccess:()=>{s.invalidateQueries({queryKey:["team-insights"]}),s.invalidateQueries({queryKey:["pr",e]}),s.invalidateQueries({queryKey:["suggested-reviewers",e]})}})}function gh(e,s=!0){return qe({queryKey:["bot-analytics",e],queryFn:()=>ge.botAnalytics(e),enabled:s,refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4})}function xh(e=!0){return qe({queryKey:["bot-reviewers"],queryFn:()=>ge.botReviewers(),enabled:e,staleTime:6e4})}function yh(){const e=Be();return Ue({mutationFn:({userId:s,body:a})=>ge.setReviewerOverride(s,a),onSuccess:()=>{e.invalidateQueries({queryKey:["bot-reviewers"]}),e.invalidateQueries({queryKey:["bot-analytics"]})}})}function $y(e,s=!0){return qe({queryKey:["bot-dedup",e],queryFn:()=>ge.prBotDedup(e),enabled:s&&e!=null,staleTime:6e4})}function My(e=!0){return qe({queryKey:["bot-mute-rules"],queryFn:()=>ge.botMuteRules(),enabled:e,staleTime:6e4})}function Uu(){const e=Be();return Ue({mutationFn:s=>ge.addBotMuteRule(s),onSuccess:()=>{e.invalidateQueries({queryKey:["bot-mute-rules"]}),e.invalidateQueries({queryKey:["bot-analytics"]})}})}function Fy(){const e=Be();return Ue({mutationFn:s=>ge.deleteBotMuteRule(s),onSuccess:()=>{e.invalidateQueries({queryKey:["bot-mute-rules"]}),e.invalidateQueries({queryKey:["bot-analytics"]})}})}function vh({state:e,count:s}){const a=jt[e];return n.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium",style:{backgroundColor:`${a.color}22`,color:a.color},title:a.description,children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:a.color}}),a.label,s!==void 0&&n.jsxs("span",{className:"opacity-70",children:["· ",s]})]})}function bh(){return n.jsx("span",{className:"rounded bg-sky-500/20 px-1 text-[10px] font-semibold uppercase text-sky-500",children:"new"})}function wh(e,s){return s?Date.parse(e)>Date.parse(s):!1}function Ly({comment:e,usersById:s,repoId:a,isNew:o,anchor:i,showLink:u}){const d=e.authorId!=null?s.get(e.authorId):void 0;return n.jsxs("div",{className:`pl-2 ${o?"comment-new":""}`,children:[n.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u&&n.jsxs(n.Fragment,{children:[u,n.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"·"})]}),n.jsx(ht,{user:d,size:18}),n.jsx(sn,{user:d,fallbackId:e.authorId,repoId:a,className:"font-semibold"}),n.jsx("span",{className:"text-gray-400",children:St(e.createdAt)}),o&&n.jsx(bh,{})]}),i&&n.jsx("div",{className:"mt-1.5",children:i}),n.jsx("div",{className:"mt-1 text-sm",children:n.jsx(cr,{children:e.body})})]})}function _y(e){return e.startsWith("@@")?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":"ctx"}const Oy={add:"bg-green-500/15 text-green-300",del:"bg-red-500/15 text-red-300",meta:"text-sky-400/80",ctx:"text-gray-400"};function Dy({hunk:e}){if(!e)return null;const s=e.replace(/\n$/,"").split(`
30
+ `);return n.jsx("pre",{className:"overflow-x-auto rounded-md border border-gray-200 bg-gray-50 text-[12px] leading-[1.45] dark:border-gray-800 dark:bg-gray-900",children:n.jsx("code",{className:"block font-mono",children:s.map((a,o)=>{const i=_y(a);return n.jsx("span",{className:`block whitespace-pre px-3 ${Oy[i]}`,children:a||" "},o)})})})}function By(e){return e.startsWith("+")?"add":e.startsWith("-")?"del":"ctx"}const Dp={add:"border-green-500 text-green-600 dark:text-green-300",del:"border-red-500 text-red-600 dark:text-red-300",ctx:"border-gray-400 text-gray-600 dark:text-gray-300"};function zy({diffHunk:e,threadId:s}){const a=te(p=>p.expandedDiffHunks.includes(s)),o=te(p=>p.toggleDiffHunk);if(!e)return null;const i=e.replace(/\n$/,"").split(`
31
+ `),u=i.at(-1)??"",d=By(u);return a?n.jsxs("div",{className:"space-y-1",children:[n.jsx(Dy,{hunk:e}),n.jsx("button",{type:"button",onClick:()=>o(s),className:"text-[11px] text-gray-400 hover:text-gray-600",children:"⌃ Hide code context"})]}):i.length<=1?n.jsx("pre",{className:`overflow-x-auto border-l-2 bg-gray-50 py-0.5 pl-2 font-mono text-[12px] leading-snug dark:bg-gray-900/60 ${Dp[d]}`,children:u||" "}):n.jsxs("button",{type:"button",onClick:()=>o(s),title:"Show the full code context",className:`flex w-full items-center gap-2 overflow-hidden rounded-r border-l-2 bg-gray-50 py-0.5 pl-2 pr-2 text-left font-mono text-[12px] leading-snug hover:bg-gray-100 dark:bg-gray-900/60 dark:hover:bg-gray-800/60 ${Dp[d]}`,children:[n.jsx("span",{className:"min-w-0 flex-1 truncate",children:u||" "}),n.jsxs("span",{className:"shrink-0 font-sans text-[10px] text-gray-400",children:["⌄ ",i.length," lines"]})]})}function qy({threadId:e}){const s=Be(),a=Ue({mutationFn:()=>ge.dismissMyTurn("thread",e),onSuccess:()=>{s.invalidateQueries({queryKey:["my-turn"]}),s.invalidateQueries({queryKey:["my-turn-done"]}),s.invalidateQueries({queryKey:["me"]})}});return n.jsx("button",{type:"button",onClick:()=>a.mutate(),disabled:a.isPending,title:"Awaiting your response (in My Turn) — mark it done",className:"rounded border border-amber-300 bg-amber-50 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700 hover:bg-amber-100 disabled:opacity-50 dark:border-amber-700/60 dark:bg-amber-900/20 dark:text-amber-300",children:"✓ Done"})}function Uy({prId:e,threadId:s,isResolved:a}){const o=Sy(),i=o.error instanceof Gt?o.error.message:o.error?"Failed to update the thread.":null;return n.jsxs("span",{className:"flex items-center gap-1.5",children:[i&&n.jsx("span",{className:"text-[10px] text-red-500",children:i}),n.jsx("button",{type:"button",onClick:()=>o.mutate({prId:e,threadId:s,resolved:!a}),disabled:o.isPending,title:a?"Reopen this thread on GitHub":"Mark this thread resolved on GitHub",className:"rounded border border-gray-300 px-1.5 py-0.5 text-[10px] font-semibold text-gray-600 hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:a?"Unresolve":"Resolve"})]})}const Ky=8;function Bp(e,s){let a=s-1;for(;a>=0;){const o=e[a];if(o==="@"){const i=a>0?e[a-1]:"";if(a===0||/[\s(]/.test(i)){const u=e.slice(a+1,s);if(/^[A-Za-z0-9-]*$/.test(u))return{query:u,start:a}}return null}if(/\s/.test(o))return null;a-=1}return null}function Hy(e,s){var o;if(s==="")return!0;const a=s.toLowerCase();return e.githubLogin.toLowerCase().includes(a)||(((o=e.displayName)==null?void 0:o.toLowerCase().includes(a))??!1)}const Wy=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]);function ei({prId:e,value:s,onChange:a,rows:o=3,placeholder:i,autoFocus:u,disabled:d,className:p,ariaLabel:m,onKeyDown:g,onBlur:w}){const v=x.useRef(null),{data:y}=wy(e),[j,R]=x.useState(0),[P,E]=x.useState(!1),[S,T]=x.useState(0),N=x.useRef(null);x.useLayoutEffect(()=>{if(N.current!=null&&v.current){const _=N.current;v.current.setSelectionRange(_,_),N.current=null}});const b=P?Bp(s,j):null,I=x.useMemo(()=>b==null||!y?[]:y.filter(_=>Hy(_,b.query)).slice(0,Ky),[b,y]);x.useEffect(()=>{T(_=>_>=I.length?0:_)},[I.length]);const $=P&&b!=null&&I.length>0,L=()=>{const _=v.current;_&&R(_.selectionStart??0)},q=_=>{const Y=Bp(s,j);if(!Y)return;let X=j;for(;X<s.length&&/[A-Za-z0-9-]/.test(s[X]);)X+=1;const B=s.slice(0,Y.start),O=s.slice(X),H=`@${_.githubLogin} `;N.current=B.length+H.length,R(B.length+H.length),E(!1),a(B+H+O)},Q=_=>{if($&&Wy.has(_.key)){if(_.key==="ArrowDown")_.preventDefault(),T(Y=>(Y+1)%I.length);else if(_.key==="ArrowUp")_.preventDefault(),T(Y=>(Y-1+I.length)%I.length);else if(_.key==="Enter"||_.key==="Tab"){_.preventDefault();const Y=I[S]??I[0];Y&&q(Y)}else _.key==="Escape"&&(_.preventDefault(),E(!1));return}g==null||g(_)};return n.jsxs("div",{className:"relative",children:[n.jsx("textarea",{ref:v,value:s,rows:o,placeholder:i,autoFocus:u,disabled:d,"aria-label":m,className:p,onChange:_=>{a(_.target.value),R(_.target.selectionStart??_.target.value.length),E(!0)},onKeyDown:Q,onKeyUp:L,onClick:()=>{L(),E(!0)},onBlur:_=>{window.setTimeout(()=>E(!1),120),w==null||w(_)}}),$&&n.jsx("ul",{role:"listbox",className:"absolute left-0 right-0 z-30 mt-0.5 max-h-56 overflow-auto rounded-md border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:I.map((_,Y)=>n.jsx("li",{children:n.jsxs("button",{type:"button",role:"option","aria-selected":Y===S,onMouseDown:X=>{X.preventDefault(),q(_)},onMouseEnter:()=>T(Y),className:`flex w-full items-center gap-2 px-2 py-1 text-left text-xs ${Y===S?"bg-sky-50 dark:bg-sky-950/40":"hover:bg-gray-50 dark:hover:bg-gray-800/60"}`,children:[n.jsx(ht,{user:_,size:18}),n.jsxs("span",{className:"font-medium text-gray-800 dark:text-gray-100",children:["@",_.githubLogin]}),_.displayName&&n.jsx("span",{className:"truncate text-gray-400",children:_.displayName})]})},_.id))})]})}function Vy({prId:e,threadId:s}){const[a,o]=x.useState(!1),[i,u]=x.useState(""),d=Ny(),p=d.error instanceof Gt?d.error.message:d.error?"Failed to post the reply.":null,m=()=>{const g=i.trim();!g||d.isPending||d.mutate({prId:e,threadId:s,body:g},{onSuccess:()=>{u(""),o(!1)}})};return a?n.jsxs("div",{className:"space-y-1",children:[n.jsx(ei,{prId:e,value:i,onChange:u,rows:3,autoFocus:!0,placeholder:"Reply to this thread (markdown, @ to mention)…",className:"w-full rounded border border-gray-300 bg-white px-2 py-1.5 text-xs dark:border-gray-700 dark:bg-gray-900"}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("button",{type:"button",onClick:m,disabled:d.isPending||i.trim().length===0,className:"whitespace-nowrap rounded border border-blue-400 px-2 py-0.5 text-xs text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",children:d.isPending?"Sending…":"Send"}),n.jsx("button",{type:"button",onClick:()=>{o(!1),u(""),d.reset()},disabled:d.isPending,className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-xs hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:"Cancel"}),p&&n.jsx("span",{className:"text-[10px] text-red-500",children:p})]})]}):n.jsx("button",{type:"button",onClick:()=>o(!0),className:"text-blue-500 hover:underline",children:"Reply"})}function gl({thread:e,usersById:s,prUrl:a,repoId:o,selected:i,viewedSince:u,inMyTurn:d=!1,highlightCommentId:p}){var g;const m=((g=e.comments[0])==null?void 0:g.diffHunk)??null;return n.jsxs("div",{className:`rounded-md border px-2.5 py-2 ${i?"border-amber-400 bg-amber-400/5":"border-gray-200 dark:border-gray-800"}`,children:[n.jsxs("div",{className:"mb-2 flex items-center gap-2 text-[11px] text-gray-400",children:[n.jsx(yu,{prId:e.prId,at:e.createdAt,event:{type:"review_comment",refId:e.id},title:"Show this thread on the timeline"}),n.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"·"}),e.line!=null?n.jsxs("span",{children:["line ",e.line]}):n.jsx("span",{children:"file-level"}),e.isOutdated&&n.jsx("span",{children:"· outdated"}),n.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[d&&n.jsx(qy,{threadId:e.id}),n.jsx(Uy,{prId:e.prId,threadId:e.id,isResolved:e.isResolved}),n.jsx(vh,{state:e.derivedState})]})]}),n.jsx("div",{className:"space-y-3",children:e.comments.map((w,v)=>n.jsx(Ly,{comment:w,usersById:s,repoId:o,isNew:p!=null?w.id===p:wh(w.createdAt,u),anchor:v===0?n.jsx(zy,{diffHunk:m,threadId:e.id}):void 0,showLink:v>0?n.jsx(yu,{prId:e.prId,at:w.createdAt,event:{type:"review_comment",refId:e.id},title:"Show this reply on the timeline"}):void 0},w.id))}),n.jsxs("div",{className:"mt-2 space-y-1.5 pl-2 text-[11px]",children:[n.jsx(Vy,{prId:e.prId,threadId:e.id}),n.jsx("div",{children:n.jsxs("a",{href:e.url??`${a}/files`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:["↗ ",e.url?"View thread on GitHub":"Reply on GitHub"]})})]})]})}const Qy=["untouched","replied_unresolved","likely_addressed","resolved"];function Gy(e){const s={untouched:0,replied_unresolved:0,likely_addressed:0,resolved:0};for(const a of e)s[a.derivedState]+=1;return s}function Yy({counts:e}){const s=Qy.filter(a=>e[a]>0);return n.jsx("span",{className:"inline-flex items-center gap-1.5",children:s.map(a=>{const o=jt[a];return n.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[10px] font-semibold",style:{color:o.color},title:`${o.label}: ${e[a]}`,children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:o.color}}),e[a]]},a)})})}function Xy(e){return[...e].sort((s,a)=>a.createdAt.localeCompare(s.createdAt))}function Jy({path:e,threads:s,usersById:a,prUrl:o,repoId:i,selectedThreadId:u,viewedSince:d,awaitingThreadIds:p,registerRef:m}){const g=Gy(s),w=s.some(I=>I.derivedState!=="resolved"),v=u!=null&&s.some(I=>I.id===u),y=w,j=te(I=>I.expandedFileGroups),R=te(I=>I.collapsedFileGroups),P=te(I=>I.toggleFileGroup),E=y?!R.includes(e):j.includes(e),S=v||E,T=e.split("/"),N=T.at(-1),b=T.slice(0,-1).join("/");return n.jsxs("div",{className:"border-b border-gray-100 dark:border-gray-800",children:[n.jsxs("button",{type:"button",onClick:()=>P(e,y),className:"flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-gray-50 dark:hover:bg-gray-900",children:[n.jsx("span",{className:"text-gray-400",children:S?"▾":"▸"}),n.jsxs("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:e,children:[b&&n.jsxs("span",{className:"text-gray-400",children:[b,"/"]}),n.jsx("span",{className:"font-semibold",children:N})]}),n.jsx(Yy,{counts:g})]}),S&&n.jsx("div",{className:"space-y-2 px-3 pb-3",children:Xy(s).map(I=>n.jsx("div",{ref:$=>m(I.id,$),children:n.jsx(gl,{thread:I,usersById:a,prUrl:o,repoId:i,selected:I.id===u,viewedSince:d,inMyTurn:p.has(I.id)})},I.id))})]})}function Zy(e){const s=new Map;for(const o of e){const i=s.get(o.path)??[];i.push(o),s.set(o.path,i)}const a=[...s.entries()].map(([o,i])=>({path:o,threads:i,newest:i.reduce((u,d)=>d.createdAt>u?d.createdAt:u,"")}));return a.sort((o,i)=>i.newest.localeCompare(o.newest)||o.path.localeCompare(i.path)),a}function zp(e,s){var o,i;const a=e.originalCommenterId??((o=e.comments[0])==null?void 0:o.authorId)??null;return a==null?null:Xm((i=s.get(a))==null?void 0:i.githubLogin)}function ev({threads:e,usersById:s,prUrl:a,prId:o,repoId:i,selectedThreadId:u,viewedSince:d,botFilter:p=null}){const m=x.useRef(new Map),g=te(L=>L.setThreadBotFilter),w=Cy(),[v,y]=x.useState(!1),{data:j}=sh(),R=x.useMemo(()=>new Set(((j==null?void 0:j.threadsAwaiting)??[]).map(L=>L.threadId)),[j]),{data:P}=$y(o??null),E=(P==null?void 0:P.clusters)??[],S=L=>{var q;(q=m.current.get(L))==null||q.scrollIntoView({behavior:"smooth",block:"center"})},T=x.useMemo(()=>p?e.filter(L=>zp(L,s)===p):e,[e,p,s]),N=x.useMemo(()=>T.filter(L=>!L.isResolved&&L.derivedState==="likely_addressed"&&zp(L,s)).map(L=>L.id),[T,s]);x.useEffect(()=>{if(u==null)return;const L=m.current.get(u);L&&L.scrollIntoView({behavior:"smooth",block:"nearest"})},[u]),x.useEffect(()=>{N.length===0&&y(!1)},[N.length]);const b=x.useMemo(()=>Zy(T),[T]),I=p?qs[p]:null,$=()=>{o==null||N.length===0||w.mutate({prId:o,threadIds:N},{onSettled:()=>y(!1)})};return n.jsxs("div",{children:[I&&n.jsxs("div",{className:"sticky top-0 z-10 flex flex-wrap items-center gap-2 border-b border-gray-100 bg-white/95 px-3 py-2 text-xs backdrop-blur dark:border-gray-800 dark:bg-gray-900/95",style:{boxShadow:`inset 3px 0 0 ${I.color}`},children:[n.jsxs("span",{className:"font-medium",style:{color:I.color},children:["🤖 ",I.label]}),n.jsxs("span",{className:"text-gray-500",children:[T.length," thread",T.length===1?"":"s"]}),n.jsx("button",{type:"button",onClick:()=>g(null),className:"rounded px-1.5 py-0.5 text-gray-500 underline-offset-2 hover:underline",children:"Show all threads"}),N.length>0&&n.jsx("span",{className:"ml-auto flex items-center gap-2",children:v?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"text-gray-500",children:["Resolve ",N.length," likely-addressed thread",N.length===1?"":"s"," on GitHub?"]}),n.jsx("button",{type:"button",disabled:w.isPending,onClick:$,className:"rounded bg-green-600 px-2 py-0.5 font-medium text-white hover:bg-green-700 disabled:opacity-60",children:w.isPending?"Resolving…":"Yes, resolve"}),n.jsx("button",{type:"button",disabled:w.isPending,onClick:()=>y(!1),className:"rounded px-2 py-0.5 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300",children:"Cancel"})]}):n.jsxs("button",{type:"button",onClick:()=>y(!0),className:"rounded border px-2 py-0.5 font-medium hover:opacity-80",style:{borderColor:I.color,color:I.color},title:"A later commit touched the file these threads flag — resolve them in one click (you approve each batch).",children:["Resolve ",N.length," addressed"]})})]}),w.data&&(w.data.resolved>0||w.data.failed>0)&&n.jsxs("div",{className:"px-3 py-1.5 text-xs text-gray-500",children:["Resolved ",w.data.resolved,w.data.failed>0&&` · ${w.data.failed} failed`,"."]}),E.length>0&&n.jsxs("div",{"data-testid":"bot-dedup",className:"mx-3 my-2 rounded-md border border-sky-200 bg-sky-50/60 px-3 py-2 text-xs dark:border-sky-800 dark:bg-sky-950/30",children:[n.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 font-medium text-sky-800 dark:text-sky-200",children:[n.jsx("span",{"aria-hidden":"true",children:"🤖"}),"Multiple bots flagged the same ",E.length===1?"line":"lines"]}),n.jsx("ul",{className:"space-y-1.5",children:E.map((L,q)=>{const Q=L.path.split("/").pop()??L.path,_=L.members.length===2?"both flagged":"all flagged";return n.jsxs("li",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-1",children:[L.members.map((Y,X)=>{const B=an(Y.kind);return n.jsxs(x.Fragment,{children:[X>0&&n.jsx("span",{className:"text-gray-400",children:"+"}),n.jsx("button",{type:"button",onClick:()=>S(Y.threadId),className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium hover:opacity-80",style:{color:B.color,background:`${B.color}1a`},title:`Jump to ${Y.label}'s thread`,children:Y.label})]},Y.threadId)}),n.jsxs("span",{className:"text-gray-600 dark:text-gray-300",children:[_," ",n.jsx("code",{className:"font-mono",children:Q}),L.line!=null?`:${L.line}`:""]}),L.conflict?n.jsx("span",{className:"rounded bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700 dark:bg-amber-900/40 dark:text-amber-300",title:"The bots disagree on severity/verdict here — worth a human look.",children:"bots disagree here"}):L.consensus?n.jsx("span",{className:"rounded bg-green-100 px-1.5 py-0.5 text-[10px] font-semibold text-green-700 dark:bg-green-900/40 dark:text-green-300",title:"The bots agree here — one fix likely clears both.",children:"consensus"}):null]},`${L.path}:${L.line??"x"}:${q}`)})})]}),T.length===0?n.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500",children:p?"No threads from this bot on this PR.":"No review threads on this PR."}):b.map(L=>n.jsx(Jy,{path:L.path,threads:L.threads,usersById:s,prUrl:a,repoId:i,selectedThreadId:u,viewedSince:d,awaitingThreadIds:R,registerRef:(q,Q)=>{Q?m.current.set(q,Q):m.current.delete(q)}},L.path))]})}function tv({prId:e,alreadyApproved:s}){const[a,o]=x.useState(!1),[i,u]=x.useState(""),d=Iy(e);if(s||d.isSuccess)return n.jsxs("button",{type:"button",disabled:!0,title:"You've already approved this PR — your approval still stands",className:"inline-flex cursor-default items-center gap-1 rounded border border-green-500/40 px-2 py-0.5 text-sm font-medium text-green-700/70 dark:border-green-700/50 dark:text-green-400/70",children:[n.jsx("span",{"aria-hidden":!0,children:"✓"})," Approved"]});const p=d.error instanceof Gt?d.error.message:d.error?"Failed to approve the PR.":null,m=()=>{if(d.isPending)return;const g=i.trim();d.mutate(g||void 0,{onSuccess:()=>{u(""),o(!1)}})};return a?n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(ei,{prId:e,value:i,onChange:u,rows:3,autoFocus:!0,placeholder:"Optional approval message (markdown)…",className:"w-full rounded border border-gray-300 bg-white px-2 py-1.5 text-sm dark:border-gray-700 dark:bg-gray-900"}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("button",{type:"button",onClick:m,disabled:d.isPending,className:"whitespace-nowrap rounded border border-green-500 px-2 py-0.5 text-sm font-medium text-green-700 hover:bg-green-50 disabled:opacity-50 dark:border-green-600 dark:text-green-400 dark:hover:bg-green-900/30",children:d.isPending?"Approving…":"Approve"}),n.jsx("button",{type:"button",onClick:()=>{o(!1),u(""),d.reset()},disabled:d.isPending,className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-sm hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:"Cancel"}),p&&n.jsx("span",{className:"text-xs text-red-500",children:p})]})]}):n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs("button",{type:"button",onClick:()=>o(!0),className:"inline-flex items-center gap-1 rounded border border-green-500 px-2 py-0.5 text-sm font-medium text-green-700 hover:bg-green-50 dark:border-green-600 dark:text-green-400 dark:hover:bg-green-900/30",children:[n.jsx("span",{"aria-hidden":!0,children:"✓"})," Approve"]}),p&&n.jsx("span",{className:"text-xs text-red-500",children:p})]})}const nv={merge:"Create a merge commit",squash:"Squash and merge",rebase:"Rebase and merge"},rv={merge:"Merge",squash:"Squash and merge",rebase:"Rebase and merge"};function sv({prId:e,githubUrl:s}){const[a,o]=x.useState(!1),{data:i,isLoading:u,isError:d}=Ty(e,a),p=Ey(e),m=Py(e),[g,w]=x.useState(null),[v,y]=x.useState("rebase"),j=g&&(i!=null&&i.allowedMethods.includes(g))?g:(i==null?void 0:i.defaultMethod)??"merge",R=p.error instanceof Gt?p.error.message:p.error?"Failed to merge the PR.":null,P=m.error instanceof Gt?m.error.message:m.error?"Failed to update the branch.":null,E=x.useMemo(()=>{if(i==null||!i.behind)return null;const T=i.behindBy;return`${T>0?T:"Some"} commit${T===1?"":"s"} behind ${i.baseRef}`},[i]);if(!a)return n.jsxs("button",{type:"button",onClick:()=>o(!0),className:"inline-flex items-center gap-1 rounded border border-violet-500 px-2 py-0.5 text-sm font-medium text-violet-700 hover:bg-violet-50 dark:border-violet-600 dark:text-violet-300 dark:hover:bg-violet-900/30",children:[n.jsx("span",{"aria-hidden":!0,children:"⇱"})," Merge ▾"]});if(u)return n.jsx("div",{className:"text-xs text-gray-400",children:"Checking merge status…"});if(d||i==null)return n.jsxs("div",{className:"flex items-center gap-2 text-xs text-red-500",children:["Couldn’t load merge status.",n.jsx("button",{type:"button",onClick:()=>o(!1),className:"rounded border border-gray-300 px-1.5 py-0.5 text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300",children:"Close"})]});const S=!i.conflicts&&!i.blocked&&i.allowedMethods.length>0;return n.jsxs("div",{className:"space-y-2",children:[i.conflicts&&n.jsxs("div",{className:"rounded border border-amber-300 bg-amber-50/60 px-2 py-1.5 text-xs text-amber-800 dark:border-amber-800/60 dark:bg-amber-950/20 dark:text-amber-200",children:["⚠ This PR conflicts with ",n.jsx("span",{className:"font-mono",children:i.baseRef}),". Resolve the conflicts on"," ",n.jsx("a",{href:s,target:"_blank",rel:"noreferrer noopener",className:"font-medium underline",children:"GitHub ↗"}),"."]}),i.canUpdateBranch&&n.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[n.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[E,"."]}),i.canRebaseUpdate&&n.jsxs("select",{value:v,onChange:T=>y(T.target.value),disabled:m.isPending,className:"rounded border border-gray-300 bg-white px-1 py-0.5 text-xs dark:border-gray-700 dark:bg-gray-900",title:"How to bring in the base branch",children:[n.jsxs("option",{value:"rebase",children:["Rebase onto ",i.baseRef]}),n.jsxs("option",{value:"merge",children:["Merge ",i.baseRef," in"]})]}),n.jsx("button",{type:"button",onClick:()=>m.mutate(i.canRebaseUpdate?{strategy:v}:{strategy:"merge"}),disabled:m.isPending,className:"rounded border border-sky-500 px-2 py-0.5 font-medium text-sky-700 hover:bg-sky-50 disabled:opacity-50 dark:border-sky-600 dark:text-sky-300 dark:hover:bg-sky-900/30",title:"Bring in the latest base-branch changes before merging",children:m.isPending?"Updating…":"Update branch"}),P&&n.jsx("span",{className:"text-red-500",children:P})]}),i.blocked&&n.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Merging is blocked by branch protection (required reviews or checks aren’t satisfied yet)."}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.allowedMethods.length>1&&n.jsx("select",{value:j,onChange:T=>w(T.target.value),disabled:!S||p.isPending,className:"rounded border border-gray-300 bg-white px-1.5 py-0.5 text-sm dark:border-gray-700 dark:bg-gray-900",children:i.allowedMethods.map(T=>n.jsx("option",{value:T,children:nv[T]},T))}),n.jsx("button",{type:"button",onClick:()=>p.mutate(j),disabled:!S||p.isPending,className:"whitespace-nowrap rounded border border-violet-500 px-2 py-0.5 text-sm font-medium text-violet-700 hover:bg-violet-50 disabled:opacity-50 dark:border-violet-600 dark:text-violet-300 dark:hover:bg-violet-900/30",title:S?"Merge this PR":"This PR can’t be merged right now",children:p.isPending?"Merging…":rv[j]}),n.jsx("button",{type:"button",onClick:()=>{o(!1),p.reset(),m.reset()},disabled:p.isPending,className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-sm hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:"Cancel"}),R&&n.jsx("span",{className:"text-xs text-red-500",children:R})]})]})}function av(e){const s=Be();return Ue({mutationFn:async({runIds:a,mode:o})=>{const i=await Promise.allSettled(a.map(p=>ge.rerunCi(e,{runId:p,mode:o}))),u=i.filter(p=>p.status==="fulfilled").length,d=i.length-u;if(u===0){const p=i.find(m=>m.status==="rejected");throw(p==null?void 0:p.reason)instanceof Error?p.reason:new Error("Re-run failed")}return{mode:o,queued:u,failed:d}},onSuccess:()=>void s.invalidateQueries({queryKey:["pr",e]})})}const lv=/\/actions\/runs\/\d+\/job\/(\d+)/,ov=/\/actions\/runs\/(\d+)/;function iv(e){if(e.jobId!=null)return e.jobId;const s=e.url?lv.exec(e.url):null;return s?Number(s[1]):null}function cv(e){if(e.runId!=null)return e.runId;const s=e.url?ov.exec(e.url):null;return s?Number(s[1]):null}function uv({prId:e,check:s}){var v,y;const a=Hx[s.state],o=iv(s),i=o!=null&&(s.state==="failure"||s.state==="error"),[u,d]=x.useState(!1),p=qe({queryKey:["check-logs",e,o],queryFn:()=>ge.checkLogs(e,o,200),enabled:u&&i,staleTime:1/0,gcTime:5*6e4}),m=x.useRef(null);x.useLayoutEffect(()=>{var j;if(u&&((j=p.data)!=null&&j.available)){const R=m.current;R&&(R.scrollTop=R.scrollHeight)}},[u,p.data]);const g=n.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full text-[10px] font-bold text-white",style:{backgroundColor:a.color},title:a.label,children:a.icon}),w=s.url?n.jsx("a",{href:s.url,target:"_blank",rel:"noreferrer noopener",onClick:j=>j.stopPropagation(),className:"text-blue-500 hover:underline",children:"Open on GitHub ↗"}):null;if(!i){const j=n.jsxs("span",{className:"flex items-center gap-2",children:[g,n.jsx("span",{className:"min-w-0 truncate",title:s.name,children:s.name}),n.jsx("span",{className:"ml-auto shrink-0 text-xs text-gray-400",children:a.label})]});return n.jsx("li",{className:"text-xs",children:s.url?n.jsx("a",{href:s.url,target:"_blank",rel:"noreferrer noopener",className:"block rounded px-1 py-0.5 hover:bg-gray-100 dark:hover:bg-gray-800",children:j}):n.jsx("div",{className:"px-1 py-0.5",children:j})})}return n.jsxs("li",{className:"text-xs",children:[n.jsx("button",{type:"button",onClick:()=>d(j=>!j),"aria-expanded":u,className:"block w-full rounded px-1 py-0.5 text-left hover:bg-gray-100 dark:hover:bg-gray-800",children:n.jsxs("span",{className:"flex items-center gap-2",children:[g,n.jsx("span",{className:"min-w-0 truncate",title:s.name,children:s.name}),n.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5 text-gray-400",children:[n.jsx("span",{className:"text-xs",children:a.label}),n.jsx("span",{className:"text-[10px] font-medium text-blue-500",children:u?"▾ hide logs":"▸ logs"})]})]})}),u&&n.jsx("div",{className:"mb-1 mt-1",children:p.isLoading?n.jsx("div",{className:"px-1 py-2 text-gray-400",children:"Loading logs…"}):(v=p.data)!=null&&v.available?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"mb-1 flex items-center justify-between px-1 text-[10px] text-gray-400",children:[n.jsxs("span",{children:["last ",p.data.returnedLines," of ",p.data.totalLines," lines"]}),w]}),n.jsx("pre",{ref:m,className:"max-h-[40rem] overflow-auto whitespace-pre rounded bg-gray-900 p-2 font-mono text-[11px] leading-[1.45] text-gray-100",children:p.data.text||"(empty log)"})]}):n.jsxs("div",{className:"px-1 py-2 text-gray-400",children:[((y=p.data)==null?void 0:y.reason)??"Couldn't load logs."," ",w]})})]})}function dv({prId:e,checks:s}){return n.jsx("ul",{className:"space-y-1",children:s.map((a,o)=>n.jsx(uv,{prId:e,check:a},`${a.name}-${o}`))})}function qp(e,s){const a=new Set;for(const o of e){if(s&&o.state!=="failure"&&o.state!=="error")continue;const i=cv(o);i!=null&&a.add(i)}return[...a]}function fv({prId:e,checks:s,viewerCanPush:a}){const o=av(e),[i,u]=x.useState(null),d=qp(s,!1),p=qp(s,!0);if(!a||d.length===0)return null;const m=(g,w)=>{w.length!==0&&(u(null),o.mutate({runIds:w,mode:g},{onSuccess:v=>u(v)}))};return n.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[n.jsx("button",{type:"button",className:"whitespace-nowrap rounded border border-blue-400 px-2.5 py-1 text-xs text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",disabled:o.isPending||p.length===0,onClick:()=>m("failed",p),title:"Re-run only the failed jobs of the failing workflow run(s)",children:o.isPending?"Requesting…":"Re-run failed jobs"}),n.jsx("button",{type:"button",className:"whitespace-nowrap rounded border border-gray-300 px-2.5 py-1 text-xs hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",disabled:o.isPending,onClick:()=>m("all",d),title:"Re-run the entire workflow run(s) from scratch",children:"Re-run all jobs"}),i&&!o.isPending&&n.jsxs("span",{className:"text-[11px] text-gray-500",children:["Re-run requested — CI updates on the next sync.",i.failed>0&&` (${i.failed} run${i.failed===1?"":"s"} couldn't be re-run.)`]}),o.isError&&n.jsx("span",{className:"text-[11px] text-red-500",children:o.error instanceof Error?o.error.message:"Re-run failed"})]})}async function ti(e,s){const a=await fetch(e,{method:s.method??"GET",credentials:"same-origin",headers:{Accept:"text/event-stream",...s.body!==void 0?{"content-type":"application/json"}:{}},body:s.body!==void 0?JSON.stringify(s.body):void 0,signal:s.signal});if(!a.ok){let p=`${a.status} ${a.statusText}`;try{const m=await a.json();m.message&&(p=m.message)}catch{}throw new Gt(a.status,p)}if(!a.body)throw new Gt(a.status,"stream has no body");const o=a.body.getReader(),i=new TextDecoder;let u="";const d=p=>{const m=[];for(const g of p.split(`
32
32
  `))g.startsWith("data:")&&m.push(g.slice(5).replace(/^ /,""));if(m.length!==0)try{s.onEvent(JSON.parse(m.join(`
33
33
  `)))}catch{}};try{for(;;){const{done:p,value:m}=await o.read();if(p)break;u+=i.decode(m,{stream:!0}).replace(/\r\n/g,`
34
34
  `);let g;for(;(g=u.indexOf(`
35
35
 
36
- `))!==-1;)d(u.slice(0,g)),u=u.slice(g+2)}u.trim()&&d(u)}finally{try{o.releaseLock()}catch{}}}function wN(e,s){return qe({queryKey:["ai-fix",e],queryFn:()=>ge.aiFix(e),enabled:e!=null&&s})}function fv(e,s){return qe({queryKey:["ai-fix-summary",e],queryFn:()=>ge.aiFixSummary(e),enabled:e!=null&&s})}function kN(e,s){return qe({queryKey:["ai-fix-ci",e],queryFn:()=>ge.aiFixCiAnalysis(e),enabled:e!=null&&s})}function pv(e){const s=Be();return Ue({mutationFn:()=>ge.refreshAiFixSummary(e),onSuccess:a=>s.setQueryData(["ai-fix-summary",e],a)})}function jN(e){const s=Be();return Ue({mutationFn:a=>ge.refreshAiFixCiAnalysis(e,a),onSuccess:a=>s.setQueryData(["ai-fix-ci",e],a)})}function NN(e){const s=Be();return Ue({mutationFn:a=>ge.startAiFix(e,a),onSuccess:()=>void s.invalidateQueries({queryKey:["ai-fix",e]})})}function SN(e){const s=Be();return Ue({mutationFn:()=>ge.cancelAiFix(e),onSuccess:()=>void s.invalidateQueries({queryKey:["ai-fix",e]})})}function CN(e){const s=Be();return Ue({mutationFn:a=>ge.pushAiFix(a.fixId,a.body),onSuccess:()=>void s.invalidateQueries({queryKey:["ai-fix",e]})})}function RN(){return Ue({mutationFn:e=>ge.aiFixMergePreview(e)})}function IN(){return Ue({mutationFn:e=>ge.startAiFixRebase(e.fixId,e.body)})}function TN(){return Ue({mutationFn:e=>ge.cancelAiFixRebase(e)})}function EN(){return Ue({mutationFn:e=>ge.cancelAiFixPush(e)})}function PN(e,s,a,o){const i=Be(),[u,d]=x.useState(null);return x.useEffect(()=>{if(e==null||s==null||!o){d(null);return}const p=new AbortController;let m=!1;const g=()=>{m||(m=!0,i.invalidateQueries({queryKey:["ai-fix",e]}))};return ti(`/api/pro/ai-fixes/${s}/${a}/stream`,{signal:p.signal,onEvent:y=>{y.type==="done"?(g(),d({status:y.status,fixId:y.fixId,progress:null,error:y.error??null})):d({status:y.status,fixId:y.fixId,progress:y.progress})}}).catch(()=>{}),()=>p.abort()},[e,s,a,o,i]),{status:u}}function AN(e,s){const a=Be(),[o,i]=x.useState(null);return x.useEffect(()=>{if(e==null||!s){i(null);return}const u=new AbortController;let d=!1;const p=()=>{d||(d=!0,a.invalidateQueries({queryKey:["ai-fix",e]}))};return ti(`/api/pro/prs/${e}/ai-fix/stream`,{signal:u.signal,onEvent:m=>{m.type==="done"?(p(),i({status:m.status,fixId:m.fixId,progress:null})):i({status:m.status,fixId:m.fixId,progress:m.progress})}}).catch(()=>{}),()=>u.abort()},[e,s,a]),{status:o}}function kh({pr:e}){const{prSummary:s}=yn(),{data:a}=fv(e.id,s),o=pv(e.id),i=(a==null?void 0:a.headSha)!=null&&a.headSha!==e.headSha,u=(a==null?void 0:a.creditsExhausted)===!0;return s?n.jsxs("div",{children:[n.jsx("div",{className:"px-4 pb-1 pt-2 text-xs font-semibold uppercase tracking-wide text-gray-400",children:"AI summary"}),n.jsxs("div",{className:"px-4 pb-3",children:[a!=null&&a.summary?n.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:n.jsx(cr,{children:a.summary})}):n.jsx("p",{className:"text-sm text-gray-500",children:"Generate a plain-language overview of what this PR does."}),n.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[n.jsx("button",{type:"button",className:"whitespace-nowrap rounded border border-blue-400 px-2.5 py-1 text-xs text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",disabled:o.isPending||u,onClick:()=>o.mutate(),children:o.isPending?"Generating…":a!=null&&a.summary?"Regenerate":"Generate summary"}),u&&n.jsx("span",{className:"text-[11px] text-amber-600 dark:text-amber-400",children:"Out of AI credits this month"}),i&&n.jsx("span",{className:"text-[11px] text-amber-600 dark:text-amber-400",children:"PR has changed since this was generated"}),o.isError&&n.jsx("span",{className:"text-[11px] text-red-500",children:o.error instanceof Gt||o.error instanceof Error?o.error.message:"Something went wrong"})]})]})]}):null}const mv={approved:{icon:"✓",cls:"bg-green-500/10 text-green-700 dark:text-green-400",title:"Approved"},changes_requested:{icon:"✗",cls:"bg-red-500/10 text-red-700 dark:text-red-400",title:"Requested changes"},commented:{icon:"",cls:"bg-gray-500/10 text-gray-600 dark:text-gray-300",title:"Reviewed (commented)"},dismissed:{icon:"",cls:"bg-gray-500/10 text-gray-400",title:"Review dismissed"},pending:{icon:"",cls:"bg-gray-500/10 text-gray-400",title:"Review pending"}};function Qt({label:e,children:s}){return n.jsxs("div",{className:"flex gap-3 px-4 py-1.5 text-sm",children:[n.jsx("span",{className:"w-28 shrink-0 text-xs uppercase tracking-wide text-gray-400",children:e}),n.jsx("div",{className:"min-w-0 flex-1",children:s})]})}function Up({kind:e,provenance:s}){const a=an(e),o=e==="pierre"&&s?s==="ai_verbatim"?" · verbatim":" · curated":"";return n.jsxs("span",{"data-testid":"reviewer-provenance",className:"inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[10px] font-medium",style:{color:a.color,background:`${a.color}1a`},title:`Automated reviewer — ${a.label}${o}`,children:[n.jsx("span",{"aria-hidden":!0,children:"🤖"}),a.label,o]})}function hv({pr:e,usersById:s}){var g;const a=hh(e.id),[o,i]=x.useState(new Set),[u,d]=x.useState(null),p=y=>y.kind==="team"?`team:${y.teamSlug}`:`user:${y.login}`,m=y=>{const b=y.kind==="team"?{teamSlugs:y.teamSlug?[y.teamSlug]:[]}:y.userId!=null?{userIds:[y.userId]}:{logins:y.login?[y.login]:[]},v=p(y);d(v),a.mutate(b,{onSuccess:()=>i(N=>new Set(N).add(v)),onSettled:()=>d(null)})};return n.jsxs(Qt,{label:"Suggested",children:[n.jsx("div",{className:"flex flex-col gap-1.5 text-xs",children:(e.suggestedReviewers??[]).map(y=>{const b=p(y),v=o.has(b),N=y.userId!=null?s.get(y.userId):void 0;return n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsx("span",{className:"inline-flex items-center gap-1 rounded bg-gray-500/10 px-1.5 py-0.5",children:y.kind==="team"?n.jsxs("span",{className:"font-medium",children:["@",y.teamName]}):N?n.jsxs(n.Fragment,{children:[n.jsx(ht,{user:N,size:14}),n.jsx(sn,{user:N,fallbackId:y.userId,repoId:e.repoId})]}):n.jsxs("span",{children:["@",y.login]})}),n.jsx("span",{className:"text-gray-400",children:y.reason}),e.viewerCanPush&&n.jsx("button",{type:"button",onClick:()=>m(y),disabled:u!==null||v,className:"rounded border border-violet-300 px-1.5 py-0.5 font-medium text-violet-700 hover:bg-violet-50 disabled:opacity-50 dark:border-violet-700 dark:text-violet-300 dark:hover:bg-violet-900/20",title:"Request this reviewer on GitHub",children:v?"✓ Requested":u===b?"Assigning…":"Assign"})]},b)})}),a.isError&&n.jsx("div",{className:"mt-1 text-[11px] text-red-500",children:((g=a.error)==null?void 0:g.message)??"Couldn’t request the reviewer."})]})}function gv({body:e}){const[s,a]=x.useState(!1),[o,i]=x.useState(!1),[u,d]=x.useState(!1),p=x.useRef(null);return x.useEffect(()=>{const m=p.current;if(!m)return;const g=160,y=384,b=()=>{const E=m.clientWidth,w=Array.from(m.querySelectorAll("img"));let R=!1,S=E>0;for(const j of w){if(!(j.naturalWidth>0&&j.naturalHeight>0)){j.complete||(S=!1);continue}const M=E?Math.min(j.naturalWidth,E):j.naturalWidth,D=Math.min(j.naturalHeight*M/j.naturalWidth,y),U=E>0&&D>g;j.classList.toggle("pr-summary-tall-img",U),U&&(R=!0)}return d(R),S},v=new MutationObserver(()=>b());v.observe(m,{childList:!0,subtree:!0});let N=0,I=0;const P=()=>{!b()&&N++<240&&(I=requestAnimationFrame(P))};return P(),()=>{v.disconnect(),cancelAnimationFrame(I)}},[e]),x.useLayoutEffect(()=>{if(s)return;const m=p.current;m&&i(m.scrollHeight-m.clientHeight>1)},[e,s]),x.useEffect(()=>{if(s)return;const m=p.current;if(!m)return;const g=new ResizeObserver(()=>{i(m.scrollHeight-m.clientHeight>1)});return g.observe(m),()=>g.disconnect()},[e,s]),n.jsxs("div",{children:[n.jsx("div",{className:"px-4 pb-1 pt-2 text-xs font-semibold uppercase tracking-wide text-gray-400",children:"Summary"}),n.jsxs("div",{className:"px-4 pb-3 text-sm",children:[n.jsx("div",{ref:p,className:`overflow-hidden${s?"":" pr-summary-collapsed"}`,style:s?void 0:{display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical"},children:n.jsx(cr,{children:e})}),(o||u||s)&&n.jsx("button",{type:"button",onClick:()=>a(m=>!m),className:"mt-1 text-xs font-medium text-blue-500 hover:underline",children:s?"Show less":"Show more"})]})]})}function xv({pr:e,usersById:s}){var P,E;const a=ur[e.ciStatus],o=Yo(e.mergeable,e.mergeStateStatus),i=e.checkRuns,u=i.reduce((w,R)=>(w[R.state]=(w[R.state]??0)+1,w),{}),d=new Map;for(const w of e.reviews)w.authorId==null||w.state!=="approved"&&w.state!=="changes_requested"&&w.state!=="dismissed"||d.set(w.authorId,w.state);const p=[...d].filter(([,w])=>w==="approved").map(([w])=>w),m=new Map;for(const w of e.reviews)w.authorId==null||w.state==="pending"||m.set(w.authorId,w.state);const g=[...m.keys()],y=new Map,b=new Set;for(const w of e.reviews)w.authorId==null||w.state==="pending"||(w.automatedKind!=null?y.set(w.authorId,{kind:w.automatedKind,provenance:w.provenance??null}):b.add(w.authorId));const v=g.length>0&&g.every(w=>y.has(w)&&!b.has(w)),N=te(w=>w.setThreadBotFilter),I=(()=>{var R;const w=new Map;for(const S of e.threads){const j=S.originalCommenterId??((R=S.comments[0])==null?void 0:R.authorId)??null;if(j==null)continue;const T=ih(s.get(j));if(!T)continue;const M=w.get(T.kind)??{threads:0,unresolved:0};M.threads+=1,(S.derivedState==="untouched"||S.derivedState==="replied_unresolved")&&(M.unresolved+=1),w.set(T.kind,M)}return[...w.entries()].map(([S,j])=>({kind:S,...qs[S],...j})).sort((S,j)=>j.threads-S.threads)})();return n.jsxs(n.Fragment,{children:[((P=e.authNotice)==null?void 0:P.kind)==="saml_sso"&&n.jsxs("div",{className:"mx-4 mt-2 rounded-md border border-amber-400/50 bg-amber-400/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200",children:[n.jsxs("strong",{className:"font-semibold",children:["Some data from ",e.authNotice.org," is hidden."]})," ","Your GitHub sign-in isn’t authorized for ",e.authNotice.org,"’s SAML SSO, so the description, CI jobs and comment bodies couldn’t be loaded. Fix:"," ",n.jsxs("a",{className:"underline underline-offset-2",href:`https://github.com/orgs/${e.authNotice.org}/sso`,target:"_blank",rel:"noreferrer",children:["start an SSO session for ",e.authNotice.org]}),", then revoke the app at"," ",n.jsx("a",{className:"underline underline-offset-2",href:"https://github.com/settings/applications",target:"_blank",rel:"noreferrer",children:"Authorized OAuth Apps"})," ","and sign in again. (If GitHub only offers “Request”, an org owner must approve the app.)"]}),n.jsxs("div",{className:"divide-y divide-gray-100 py-1 dark:divide-gray-800",children:[n.jsx(Qt,{label:"CI",children:a?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{backgroundColor:a.color}}),a.label,i.length>0&&n.jsxs("span",{className:"text-xs text-gray-400",children:["·"," ",[u.success?`${u.success} passed`:null,u.failure?`${u.failure} failed`:null,u.pending?`${u.pending} running`:null].filter(Boolean).join(" · ")]})]}):n.jsx("span",{className:"text-gray-400",children:"no checks reported"})}),n.jsx(Qt,{label:"Mergeable",children:o?n.jsxs("span",{className:"font-medium text-orange-500",children:["⚠ ",o]}):e.mergeable==="mergeable"?n.jsx("span",{className:"text-green-500",children:"clean"}):n.jsx("span",{className:"text-gray-400",children:e.mergeStateStatus})}),g.length>0&&n.jsx(Qt,{label:"Reviewers",children:n.jsx("div",{className:"flex flex-wrap gap-2 text-xs",children:g.map(w=>{const R=s.get(w),S=mv[m.get(w)],j=y.get(w);return n.jsxs("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 ${S.cls}`,title:S.title,children:[S.icon&&n.jsx("span",{"aria-hidden":!0,children:S.icon}),n.jsx(ht,{user:R,size:14}),n.jsx(sn,{user:R,fallbackId:w,repoId:e.repoId}),j&&n.jsx(Up,{kind:j.kind,provenance:j.provenance})]},w)})})}),v&&n.jsx(Qt,{label:"Coverage",children:n.jsxs("span",{"data-testid":"only-bots-reviewed",className:"inline-flex items-center gap-1 rounded bg-amber-400/10 px-1.5 py-0.5 text-xs font-medium text-amber-700 dark:text-amber-300",title:"Every review on this PR came from an automated reviewer — no human has reviewed it yet.",children:[n.jsx("span",{"aria-hidden":!0,children:"🤖"}),"only bots reviewed"]})}),I.length>0&&n.jsx(Qt,{label:"Bots",children:n.jsx("div",{className:"flex flex-wrap gap-2 text-xs",children:I.map(w=>n.jsxs("button",{type:"button",onClick:()=>N(w.kind),className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium transition-opacity hover:opacity-80",style:{color:w.color,background:`${w.color}1a`},title:`${w.label} opened ${w.threads} review thread${w.threads===1?"":"s"} on this PR${w.unresolved>0?` · ${w.unresolved} still need a look`:" · all acted on"} — click to filter the Threads tab`,children:[n.jsx("span",{"aria-hidden":!0,children:"🤖"}),w.label,n.jsxs("span",{className:"tabular-nums opacity-70",children:["· ",w.threads]}),w.unresolved>0&&n.jsxs("span",{className:"tabular-nums font-semibold",children:["· ",w.unresolved," unresolved"]})]},w.kind))})}),p.length>0&&n.jsx(Qt,{label:"Approvers",children:n.jsx("div",{className:"flex flex-wrap gap-2 text-xs",children:p.map(w=>{const R=s.get(w),S=y.get(w);return n.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-green-500/10 px-1.5 py-0.5 text-green-700 dark:text-green-400",title:"Approved this PR",children:[n.jsx("span",{className:"text-green-600 dark:text-green-500",children:"✓"}),n.jsx(ht,{user:R,size:14}),n.jsx(sn,{user:R,fallbackId:w,repoId:e.repoId}),S&&n.jsx(Up,{kind:S.kind,provenance:S.provenance})]},w)})})}),e.viewerCanApprove&&n.jsx(Qt,{label:"Review",children:n.jsx(ev,{prId:e.id,alreadyApproved:e.viewerHasApprovedStanding})}),e.viewerCanPush&&e.state==="open"&&!e.isDraft&&n.jsx(Qt,{label:"Merge",children:n.jsx(rv,{prId:e.id,githubUrl:e.githubUrl})}),e.mergedById!=null&&n.jsx(Qt,{label:"Merged by",children:n.jsxs("div",{className:"text-xs",children:[n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(ht,{user:s.get(e.mergedById),size:14}),n.jsx(sn,{user:s.get(e.mergedById),fallbackId:e.mergedById,repoId:e.repoId})]}),e.mergedAt!=null&&n.jsx("div",{className:"mt-0.5 text-gray-400",title:Ra(e.mergedAt),children:Ra(e.mergedAt)})]})}),e.tickets!=null&&n.jsx(Qt,{label:"Ticket",children:e.tickets.length===0?n.jsx("span",{className:"text-xs text-gray-400",children:"No ticket found"}):n.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.tickets.map(w=>n.jsx("a",{href:w.url,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-center rounded border border-sky-200 bg-sky-50 px-1.5 py-0.5 text-xs font-medium text-sky-700 hover:bg-sky-100 dark:border-sky-900 dark:bg-sky-950 dark:text-sky-300",title:`Open ${w.key} in ${w.provider==="jira"?"Jira":"Linear"}`,children:w.key},w.key))})}),e.body!=null&&e.body.trim()!==""&&n.jsx(gv,{body:e.body}),n.jsx(kh,{pr:e}),i.length>0&&n.jsxs(Qt,{label:"Checks",children:[n.jsx(uv,{prId:e.id,checks:i}),n.jsx(dv,{prId:e.id,checks:i,viewerCanPush:e.viewerCanPush})]}),e.labels.length>0&&n.jsx(Qt,{label:"Labels",children:n.jsx("div",{className:"flex flex-wrap gap-1",children:e.labels.map(w=>n.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs",style:{borderColor:`#${w.color}`},children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:`#${w.color}`}}),w.name]},w.name))})}),e.requestedReviewers.length>0&&n.jsx(Qt,{label:"Requested",children:n.jsx("div",{className:"flex flex-wrap gap-2 text-xs",children:e.requestedReviewers.map((w,R)=>n.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5",children:w.teamName?`@${w.teamName}`:n.jsx(sn,{user:w.userId!=null?s.get(w.userId):void 0,fallbackId:w.userId,repoId:e.repoId})},R))})}),(((E=e.suggestedReviewers)==null?void 0:E.length)??0)>0&&n.jsx(hv,{pr:e,usersById:s}),n.jsx(Qt,{label:"Meta",children:n.jsxs("div",{className:"space-y-0.5 text-xs text-gray-500",children:[n.jsx("div",{children:e.repoFullName}),n.jsxs("div",{children:["opened ",St(e.openedAt)]}),n.jsxs("div",{children:["updated ",St(e.updatedAt)]})]})})]})]})}function yv(e){const s=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(e);return s?{oldStart:Number(s[1]),newStart:Number(s[2])}:null}function vv(e){if(!e)return[];const s=[];let a=0,o=0;for(const i of e.replace(/\n$/,"").split(`
37
- `)){const u=yv(i);if(u){a=u.oldStart,o=u.newStart,s.push({kind:"hunk",text:i});continue}const d=i[0];d==="+"?(s.push({kind:"add",text:i,newLine:o}),o+=1):d==="-"?(s.push({kind:"del",text:i,oldLine:a}),a+=1):d==="\\"?s.push({kind:"context",text:i}):(s.push({kind:"context",text:i,oldLine:a,newLine:o}),a+=1,o+=1)}return s}function bv(e){return e?e.replace(/\n$/,"").split(`
38
- `).length:0}function Kp(e){let s=e.trim();return s==="/dev/null"?null:(s.startsWith('"')&&s.endsWith('"')&&(s=s.slice(1,-1)),(s.startsWith("a/")||s.startsWith("b/"))&&(s=s.slice(2)),s)}function wv(e){const s=/^diff --git a\/(.+) b\/(.+)$/.exec(e);return s?{oldPath:s[1]??null,newPath:s[2]??null}:{oldPath:null,newPath:null}}function $N(e){if(!e)return[];const s=e.replace(/\n$/,"").split(`
39
- `),a=s.length,o=[];let i=0;for(;i<a&&!(s[i]??"").startsWith("diff --git ");)i++;for(;i<a;){const u=wv(s[i]??"");i++;let d="modified",p=null,m=null,g=null,y=null,b=!1;const v=[];let N=!1;for(;i<a;i++){const R=s[i]??"";if(R.startsWith("diff --git "))break;if(N){v.push(R);continue}R.startsWith("@@")?(N=!0,v.push(R)):R.startsWith("new file mode")?d="added":R.startsWith("deleted file mode")?d="removed":R.startsWith("rename from ")?(d="renamed",g=R.slice(12)):R.startsWith("rename to ")?(d="renamed",y=R.slice(10)):R.startsWith("copy from ")?(d="copied",g=R.slice(10)):R.startsWith("copy to ")?(d="copied",y=R.slice(8)):R.startsWith("Binary files ")||R.startsWith("GIT binary patch")?b=!0:R.startsWith("--- ")?p=Kp(R.slice(4)):R.startsWith("+++ ")&&(m=Kp(R.slice(4)))}const I=m||y||u.newPath||u.oldPath||p||"(unknown)",P=d==="renamed"||d==="copied"?g||p||u.oldPath:null;let E=0,w=0;for(const R of v)R.startsWith("+")&&!R.startsWith("+++")?E++:R.startsWith("-")&&!R.startsWith("---")&&w++;o.push({path:I,previousPath:P,status:d,additions:E,deletions:w,patch:b?null:v.join(`
40
- `)})}return o}const kv=250,jv=400;function Nv(e){return e.patch==null||bv(e.patch)>kv||e.additions+e.deletions>jv}const Sv={added:{icon:"A",label:"added",cls:"text-green-600 dark:text-green-400"},removed:{icon:"D",label:"removed",cls:"text-red-500 dark:text-red-400"},modified:{icon:"M",label:"modified",cls:"text-amber-600 dark:text-amber-400"},renamed:{icon:"R",label:"renamed",cls:"text-sky-600 dark:text-sky-400"},copied:{icon:"C",label:"copied",cls:"text-sky-600 dark:text-sky-400"},changed:{icon:"M",label:"changed",cls:"text-amber-600 dark:text-amber-400"},unchanged:{icon:"·",label:"unchanged",cls:"text-gray-400"}};function jh(e){return e.kind==="add"&&e.newLine!=null?{line:e.newLine,side:"RIGHT"}:e.kind==="context"&&e.newLine!=null?{line:e.newLine,side:"RIGHT"}:e.kind==="del"&&e.oldLine!=null?{line:e.oldLine,side:"LEFT"}:null}function Cv(e,s){if(s==null)return null;let a=null,o=null;return e.forEach((i,u)=>{const d=jh(i);!d||d.line!==s||(d.side==="RIGHT"?a=u:o=u)}),a??o}const Rv={hunk:"bg-sky-500/5 text-sky-600 dark:text-sky-400 select-none",add:"bg-green-500/10",del:"bg-red-500/10",context:""};function Hp(e){return e==null?"":String(e)}function Iv({row:e,filePath:s,fileUrl:a,commenting:o,open:i,onOpen:u,onClose:d}){const p=o?jh(e):null,m=e.kind==="hunk"?e.text:e.text.slice(1)||" ";return n.jsxs(n.Fragment,{children:[n.jsxs("tr",{className:`group ${Rv[e.kind]}`,children:[n.jsx("td",{className:"w-9 select-none border-r border-gray-200 px-1 text-right align-top text-gray-400 dark:border-gray-800",children:e.kind==="hunk"?"":Hp(e.oldLine)}),n.jsx("td",{className:"w-9 select-none border-r border-gray-200 px-1 text-right align-top text-gray-400 dark:border-gray-800",children:e.kind==="hunk"?"":Hp(e.newLine)}),n.jsx("td",{className:"select-none px-1 align-top",children:n.jsx("div",{className:"flex w-4 justify-center",children:o&&p&&!i&&n.jsx("button",{type:"button",onClick:u,title:"Comment on this line",className:"rounded bg-blue-500 px-1 text-[10px] font-bold leading-tight text-white opacity-0 transition-opacity hover:bg-blue-600 group-hover:opacity-100",children:"+"})})}),n.jsxs("td",{className:"w-full whitespace-pre px-2 align-top",children:[e.kind!=="hunk"&&n.jsx("span",{className:"select-none text-gray-400",children:e.kind==="add"?"+":e.kind==="del"?"-":" "}),m]})]}),i&&o&&p&&n.jsx("tr",{children:n.jsx("td",{colSpan:4,className:"px-2 py-1.5",children:n.jsx(Tv,{prId:o.prId,filePath:s,fileUrl:a,line:p.line,side:p.side,onClose:d})})})]})}function Wp({thread:e,ctx:s}){const a=x.useRef(null),o=s.focusThreadId!=null&&s.focusThreadId===e.id;return x.useEffect(()=>{var i;o&&a.current&&(a.current.scrollIntoView({block:"center",behavior:"smooth"}),(i=s.onThreadShown)==null||i.call(s))},[o]),n.jsx("tr",{ref:a,children:n.jsx("td",{colSpan:4,className:"bg-gray-50 px-2 py-2 dark:bg-gray-900/40",children:n.jsx("div",{className:`rounded font-sans ${o?"ring-2 ring-amber-400/70":""}`,children:n.jsx(hl,{thread:e,usersById:s.usersById,prUrl:s.prUrl,selected:o})})})})}function Tv({prId:e,filePath:s,fileUrl:a,line:o,side:i,onClose:u}){const[d,p]=x.useState(""),[m,g]=x.useState(null),y=Py(e),b=y.error instanceof Gt?y.error.message:y.error?"Failed to post the comment.":null,v=()=>{const N=d.trim();!N||y.isPending||(g(null),y.mutate({path:s,line:o,side:i,body:N},{onSuccess:I=>{if(I.commentId===null){g({text:"Couldn't place this comment in the diff — open it on GitHub instead.",url:a,tone:"warn"});return}if(p(""),I.anchored===!1){g({text:`Posted on the nearest changed line (${I.side==="LEFT"?"old":"new"} line ${I.line}). It’ll appear in the Threads tab after the next sync.`,url:I.url,tone:"warn"});return}g({text:"Comment posted. It’ll appear in the Threads tab after the next sync.",url:I.url,tone:"ok"})}}))};return n.jsxs("div",{className:"space-y-1 rounded border border-gray-300 bg-white p-2 font-sans dark:border-gray-700 dark:bg-gray-900",children:[n.jsxs("div",{className:"text-[10px] text-gray-400",children:["Commenting on ",i==="LEFT"?"old":"new"," line ",o]}),n.jsx(ei,{prId:e,value:d,onChange:p,rows:3,autoFocus:!0,placeholder:"Add an inline review comment (markdown)…",className:"w-full rounded border border-gray-300 bg-white px-2 py-1.5 text-xs dark:border-gray-700 dark:bg-gray-950"}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("button",{type:"button",onClick:v,disabled:y.isPending||d.trim().length===0,className:"whitespace-nowrap rounded border border-blue-400 px-2 py-0.5 text-xs text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",children:y.isPending?"Sending…":"Send"}),n.jsx("button",{type:"button",onClick:()=>{p(""),g(null),y.reset(),u()},disabled:y.isPending,className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-xs hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:(m==null?void 0:m.tone)==="ok"?"Close":"Cancel"}),b&&n.jsx("span",{className:"text-[10px] text-red-500",children:b})]}),m&&n.jsxs("div",{className:m.tone==="ok"?"text-[10px] text-green-600 dark:text-green-400":"text-[10px] text-amber-600 dark:text-amber-400",children:[m.text,m.url&&n.jsxs(n.Fragment,{children:[" ",n.jsx("a",{href:m.url,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"Open on GitHub ↗"})]})]})]})}function Ev({file:e,commenting:s,threads:a,threadCtx:o}){const i=x.useMemo(()=>vv(e.patch),[e.patch]),{byRow:u,unanchored:d}=x.useMemo(()=>{const P=new Map,E=[];for(const w of a){const R=Cv(i,w.line);if(R==null)E.push(w);else{const S=P.get(R)??[];S.push(w),P.set(R,S)}}return{byRow:P,unanchored:E}},[i,a]),p=(o==null?void 0:o.focusThreadId)!=null&&a.some(P=>P.id===o.focusThreadId),[m,g]=x.useState(()=>!Nv(e)||a.length>0);x.useEffect(()=>{p&&g(!0)},[p]);const[y,b]=x.useState(null),v=Sv[e.status],N=e.previousPath?`${e.previousPath} → ${e.path}`:e.path,I=e.githubUrl??null;return n.jsxs("div",{children:[n.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-2 border-b border-gray-100 bg-white px-3 py-1.5 text-xs hover:bg-gray-50 dark:border-gray-800 dark:bg-gray-950 dark:hover:bg-gray-900",children:[n.jsxs("button",{type:"button",onClick:()=>g(P=>!P),className:"flex min-w-0 flex-1 items-center gap-2 text-left",title:m?"Collapse this file":"Expand this file",children:[n.jsx("span",{className:"w-3 shrink-0 select-none text-gray-400",children:m?"▾":"▸"}),n.jsx("span",{className:`w-3 shrink-0 select-none text-center font-mono font-bold ${v.cls}`,title:v.label,children:v.icon}),n.jsx("code",{className:"min-w-0 flex-1 truncate font-mono",children:N})]}),a.length>0&&n.jsxs("span",{className:"shrink-0 rounded bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:text-amber-300",title:`${a.length} unresolved thread${a.length===1?"":"s"} on this file`,children:[a.length," 💬"]}),n.jsxs("span",{className:"shrink-0 font-mono tabular-nums",children:[n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions]})," ",n.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions]})]}),I&&n.jsx("a",{href:I,target:"_blank",rel:"noreferrer noopener",className:"shrink-0 text-blue-500 hover:underline",title:"View this file's diff on GitHub",children:"↗"})]}),m&&n.jsx("div",{className:"border-b border-gray-100 dark:border-gray-800",children:e.patch==null?n.jsxs("div",{className:"px-3 py-3 text-center text-xs text-gray-500",children:[I?n.jsxs(n.Fragment,{children:["Diff is too large or binary —"," ",n.jsx("a",{href:I,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"view on GitHub ↗"})]}):"Binary file — no textual diff.",o&&a.length>0&&n.jsx("div",{className:"mt-2 space-y-2 text-left",children:a.map(P=>n.jsx("div",{className:"font-sans",children:n.jsx(hl,{thread:P,usersById:o.usersById,prUrl:o.prUrl,selected:o.focusThreadId===P.id})},P.id))})]}):i.length===0?n.jsx("div",{className:"px-3 py-3 text-center text-xs text-gray-500",children:"No textual diff for this file."}):n.jsx("table",{className:"w-full border-collapse font-mono text-[12px] leading-[1.45]",children:n.jsxs("tbody",{children:[o&&d.map(P=>n.jsx(Wp,{thread:P,ctx:o},`u-${P.id}`)),i.map((P,E)=>{var w;return n.jsxs(x.Fragment,{children:[n.jsx(Iv,{row:P,filePath:e.path,fileUrl:I,commenting:s,open:y===E,onOpen:()=>b(E),onClose:()=>b(null)}),o&&((w=u.get(E))==null?void 0:w.map(R=>n.jsx(Wp,{thread:R,ctx:o},R.id)))]},E)})]})})})]})}function Pv({files:e,commenting:s,threadCtx:a}){const o=x.useMemo(()=>{const i=new Map;for(const u of(a==null?void 0:a.threads)??[]){const d=i.get(u.path)??[];d.push(u),i.set(u.path,d)}return i},[a==null?void 0:a.threads]);return n.jsx("div",{children:e.map(i=>n.jsx(Ev,{file:i,commenting:s??null,threads:o.get(i.path)??[],threadCtx:a??null},i.path))})}function Av({file:e}){const s=e.path.split("/"),a=s.at(-1),o=s.slice(0,-1).join("/");return n.jsxs("a",{href:e.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"group flex items-center gap-3 px-4 py-1.5 text-sm hover:bg-gray-50 dark:hover:bg-gray-900",title:`${e.path} — view this file's diff on GitHub`,children:[n.jsxs("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:[o&&n.jsxs("span",{className:"text-gray-400",children:[o,"/"]}),n.jsx("span",{className:"font-semibold",children:a})]}),n.jsxs("span",{className:"shrink-0 font-mono text-xs tabular-nums",children:[n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions]})," ",n.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions]})]}),n.jsx("span",{className:"shrink-0 text-gray-300 group-hover:text-blue-500 dark:text-gray-600",children:"↗"})]})}function Qc({pr:e,extra:s}){return n.jsxs("div",{className:"flex items-center gap-3 border-b border-gray-200 px-4 py-2 text-xs dark:border-gray-800",children:[n.jsxs("span",{className:"font-semibold text-gray-600 dark:text-gray-300",children:[e.changedFilesCount," file",e.changedFilesCount===1?"":"s"," changed"]}),n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions.toLocaleString()]}),n.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions.toLocaleString()]}),s,n.jsx("a",{href:`${e.githubUrl}/files`,target:"_blank",rel:"noreferrer noopener",className:"ml-auto text-blue-500 hover:underline",children:"Files changed ↗"})]})}function $v({pr:e,focusThreadId:s,onThreadShown:a}){const{data:o,isLoading:i,isError:u}=ky(e.id),{data:d}=$n(),p=x.useMemo(()=>ln(d),[d]),m={threads:e.threads.filter(b=>!b.isResolved||b.id===s),usersById:p,prUrl:e.githubUrl,focusThreadId:s??null,onThreadShown:a};if(e.files.length===0&&e.changedFilesCount===0&&!i)return n.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500",children:"No file changes on this PR."});if(i)return n.jsxs("div",{children:[n.jsx(Qc,{pr:e}),n.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500",children:"Loading diff…"})]});const g=(o==null?void 0:o.files)??[];return!u&&g.length>0?n.jsxs("div",{children:[n.jsx(Qc,{pr:e,extra:m.threads.length>0?n.jsxs("span",{className:"rounded bg-amber-500/15 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300",children:[m.threads.length," inline thread",m.threads.length===1?"":"s"]}):void 0}),n.jsx(Pv,{files:g,commenting:{prId:e.id},threadCtx:m}),(o==null?void 0:o.truncated)&&n.jsxs("div",{className:"px-4 py-2 text-xs text-gray-400",children:["Large diff — not all files are shown."," ",n.jsx("a",{href:`${e.githubUrl}/files`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"View all on GitHub ↗"})]})]}):n.jsxs("div",{children:[n.jsx(Qc,{pr:e}),n.jsxs("div",{className:"px-4 py-2 text-xs text-gray-400",children:[u?"The full diff couldn’t be loaded — showing the changed-file list.":"Inline diffs aren’t available for this PR — showing the changed-file list."," ",n.jsx("a",{href:`${e.githubUrl}/files`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"View on GitHub ↗"})]}),e.files.length>0&&n.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-800",children:e.files.map(b=>n.jsx(Av,{file:b},b.path))})]})}function Ku({prId:e,initialBody:s,autoFocus:a,onCancel:o,onDone:i}){const[u,d]=x.useState(s??""),p=Cy(e),m=p.error instanceof Gt?p.error.message:p.error?"Failed to post the comment.":null,g=()=>{const y=u.trim();!y||p.isPending||p.mutate(y,{onSuccess:()=>{d(""),i==null||i()}})};return n.jsxs("div",{className:"space-y-1.5 px-3 pb-3",children:[n.jsx(ei,{prId:e,value:u,onChange:d,rows:3,autoFocus:a,placeholder:"Add a comment to this PR (markdown, @ to mention)…",className:"w-full rounded border border-gray-300 bg-white px-2 py-1.5 text-sm dark:border-gray-700 dark:bg-gray-900"}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("button",{type:"button",onClick:g,disabled:p.isPending||u.trim().length===0,className:"whitespace-nowrap rounded border border-blue-400 px-2 py-0.5 text-sm text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",children:p.isPending?"Commenting…":o?"Reply":"Comment"}),o&&n.jsx("button",{type:"button",onClick:()=>{p.reset(),o()},disabled:p.isPending,className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-sm hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:"Cancel"}),m&&n.jsx("span",{className:"text-xs text-red-500",children:m})]})]})}const Mv=x.lazy(()=>Eu(()=>import("./ClaudeReviewTab-DIjf6gst.js"),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.ClaudeReviewTab}))),Fv=x.lazy(()=>Eu(()=>import("./AiFixTab-Bvs2sflj.js"),__vite__mapDeps([7,1,2,3,4,5,6])).then(e=>({default:e.AiFixTab})));function Lv(e){if(!e)return null;const s=[];return e.comments>0&&s.push(`${e.comments} new comment${e.comments===1?"":"s"}`),e.reviews>0&&s.push(`${e.reviews} new review${e.reviews===1?"":"s"}`),e.commits>0&&s.push(`${e.commits} new commit${e.commits===1?"":"s"}`),s.length?s.join(" · "):null}function rl(e,s){const a=e.authorId!=null?s.get(e.authorId):void 0;return{id:e.id,number:e.number,title:e.title,repoFullName:e.repoFullName,authorLogin:(a==null?void 0:a.githubLogin)??null,authorDisplayName:(a==null?void 0:a.displayName)??null,authorAvatarUrl:(a==null?void 0:a.avatarUrl)??null}}const _v={overview:"Overview",threads:"Threads",activity:"Activity",changes:"Changes",claude_review:"Claude Review",ai_fix:"AI Analysis and Fix"};function Ov(e){var a;const s=[];s.push({key:"opened",time:e.openedAt,label:"opened this PR",actorId:e.authorId,href:e.githubUrl,event:{type:"pr_opened",refId:null}});for(const o of e.commits)s.push({key:`commit:${o.id}`,time:o.committedAt,label:"pushed a commit",actorId:o.authorId??o.committerId,detail:(a=o.message)==null?void 0:a.split(`
41
- `)[0],href:`${e.githubUrl}/commits/${o.sha}`,event:{type:"commit_pushed",refId:o.id}});for(const o of e.reviews)s.push({key:`review:${o.id}`,time:o.submittedAt,label:`reviewed (${o.state.replace("_"," ")})`,actorId:o.authorId,detail:o.body??void 0,href:o.url??e.githubUrl,event:{type:"review_submitted",refId:o.id}});for(const o of e.comments)s.push({key:`comment:${o.id}`,time:o.createdAt,label:"commented",actorId:o.authorId,detail:o.body,href:o.url??e.githubUrl,event:{type:"pr_comment",refId:o.id}});return e.mergedAt?s.push({key:"merged",time:e.mergedAt,label:"merged this PR",actorId:e.authorId,href:e.githubUrl,event:{type:"pr_merged",refId:null}}):e.closedAt&&s.push({key:"closed",time:e.closedAt,label:"closed this PR",actorId:e.authorId,href:e.githubUrl,event:{type:"pr_closed",refId:null}}),s.sort((o,i)=>i.time.localeCompare(o.time))}function Dv({pr:e,usersById:s,since:a,onClearSince:o,focusEvent:i,onConsumed:u}){const d=x.useMemo(()=>Ov(e),[e]),p=a?d.filter(v=>v.time>a):d,m=te(v=>v.showEventOnTimeline),g=x.useRef(new Map),[y,b]=x.useState(null);return x.useEffect(()=>{var N;if(!i)return;const v=d.find(I=>I.event.type===i.type&&I.event.refId===i.refId);u(),v&&((N=g.current.get(v.key))==null||N.scrollIntoView({behavior:"smooth",block:"center"}),b(v.key))},[i,d,u]),x.useEffect(()=>{if(y==null)return;const v=setTimeout(()=>b(null),1800);return()=>clearTimeout(v)},[y]),n.jsxs("ul",{className:"divide-y divide-gray-100 dark:divide-gray-800",children:[a&&n.jsxs("li",{className:"flex items-center gap-2 bg-sky-500/5 px-3 py-1.5 text-xs text-sky-600 dark:text-sky-400",children:[n.jsxs("span",{children:["Showing ",p.length," since you last looked"]}),n.jsx("button",{type:"button",onClick:o,className:"ml-auto text-gray-400 hover:text-gray-600",children:"show all"})]}),p.map(v=>{const N=v.actorId!=null?s.get(v.actorId):void 0;return n.jsxs("li",{ref:I=>{I?g.current.set(v.key,I):g.current.delete(v.key)},className:`flex items-start gap-2 px-3 py-2 text-sm ${v.key===y?"activity-flash":""}`,children:[n.jsx(ht,{user:N,size:20}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[n.jsx(sn,{user:N,fallbackId:v.actorId,repoId:e.repoId,className:"font-medium"}),n.jsx("span",{className:"text-gray-500",children:v.label}),n.jsxs("span",{className:"text-xs text-gray-400",title:Ra(v.time),children:["· ",Ra(v.time)]})]}),v.detail&&n.jsx("div",{className:"mt-0.5 truncate text-xs text-gray-500",title:v.detail,children:v.detail.split(`
42
- `)[0]}),n.jsxs("div",{className:"mt-1 flex items-center gap-3 text-xs",children:[n.jsx("button",{type:"button",onClick:()=>m(e.id,v.time,v.event),className:"text-blue-500 hover:underline",title:"Show this event on the timeline",children:"Show"}),v.href&&n.jsx("a",{href:v.href,target:"_blank",rel:"noreferrer noopener",className:"text-gray-400 hover:text-blue-500",children:"Open on GitHub ↗"})]})]})]},v.key)})]})}function Bv({pr:e,usersById:s,viewedSince:a,focusCommentId:o,selectedCommentId:i,onFocusConsumed:u}){const d=x.useRef(new Map),[p,m]=x.useState(null),[g,y]=x.useState(null);if(x.useEffect(()=>{if(o==null)return;u();const v=d.current.get(o);v&&(v.scrollIntoView({behavior:"smooth",block:"center"}),m(o))},[o,u]),x.useEffect(()=>{if(p==null)return;const v=setTimeout(()=>m(null),1800);return()=>clearTimeout(v)},[p]),e.comments.length===0)return n.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500",children:"No PR comments on this PR."});const b=[...e.comments].sort((v,N)=>v.createdAt.localeCompare(N.createdAt));return n.jsx("div",{className:"space-y-2 px-3 pb-3",children:b.map(v=>{var P;const N=v.authorId!=null?s.get(v.authorId):void 0,I=wh(v.createdAt,a);return n.jsxs("div",{ref:E=>{E?d.current.set(v.id,E):d.current.delete(v.id)},className:`rounded-md border px-2.5 py-2 ${v.id===i?"border-amber-400 bg-amber-400/5":"border-gray-200 dark:border-gray-800"} ${I?"comment-new":""} ${v.id===p?"activity-flash":""}`,children:[n.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[n.jsx(yu,{prId:e.id,at:v.createdAt,event:{type:"pr_comment",refId:v.id},title:"Show this comment on the timeline"}),n.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"·"}),n.jsx(ht,{user:N,size:18}),n.jsx(sn,{user:N,fallbackId:v.authorId,repoId:e.repoId,className:"font-semibold"}),n.jsx("span",{className:"text-gray-400",title:Ra(v.createdAt),children:St(v.createdAt)}),I&&n.jsx(bh,{})]}),n.jsx("div",{className:"mt-1 text-sm",children:n.jsx(cr,{children:v.body})}),n.jsxs("div",{className:"mt-2 flex items-center gap-3 pl-2 text-[11px]",children:[g!==v.id&&n.jsx("button",{type:"button",onClick:()=>y(v.id),className:"text-blue-500 hover:underline",children:"Reply"}),v.url&&n.jsx("a",{href:v.url,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"↗ View comment on GitHub"})]}),g===v.id&&n.jsx("div",{className:"mt-2",children:n.jsx(Ku,{prId:e.id,initialBody:ch(v.body,((P=s.get(v.authorId??-1))==null?void 0:P.githubLogin)??null),autoFocus:!0,onCancel:()=>y(null),onDone:()=>y(null)})})]},v.id)})})}function Nh({prId:e,selectedThreadId:s}){var Pe;const{data:a,isLoading:o,error:i}=Zo(e),{data:u}=Mr(),{aiAnalysis:d,aiFix:p,claudeReview:m}=yn(),g=d||p,[y,b]=x.useState("overview"),[v,N]=x.useState(null),I=Be(),P=te(se=>se.openPrFocused),E=Oe(se=>se.openPrFocusTab),w=Oe(se=>se.openPrDetailTab),R=te(se=>se.activityFocus),S=te(se=>se.consumeActivityFocus),j=x.useMemo(()=>R&&a&&R.prId===a.id?{type:R.type,refId:R.refId}:null,[R,a]),T=te(se=>se.commentFocus),M=te(se=>se.consumeCommentFocus),D=te(se=>se.selectedCommentId),U=te(se=>se.claudeTabFocus),G=te(se=>se.consumeClaudeTabFocus),L=te(se=>se.changesThreadFocus),Y=te(se=>se.consumeChangesThreadFocus),[X,B]=x.useState(null),_=te(se=>se.aiFixTabFocus),H=T&&a&&T.prId===a.id?T.commentId:null,ee=Oe(se=>se.syncMeta);x.useEffect(()=>{s!=null&&b("threads")},[s]);const ce=te(se=>se.threadBotFilter);x.useEffect(()=>{ce!=null&&b("threads")},[ce]),x.useEffect(()=>{j&&(b("activity"),N(null))},[j]),x.useEffect(()=>{m&&U&&a&&U.prId===a.id&&(b("claude_review"),G())},[U,a,m,G]),x.useEffect(()=>{L&&a&&L.prId===a.id&&(b("changes"),B(L.threadId),Y())},[L,a,Y]),x.useEffect(()=>{g&&_&&a&&_.prId===a.id&&b("ai_fix")},[_,a,g]),x.useEffect(()=>{H!=null&&b("overview")},[H]);const C=Ue({mutationFn:se=>ge.markPrViewed(se),onSuccess:()=>{I.invalidateQueries({queryKey:["open-prs"]}),I.invalidateQueries({queryKey:["timeline"]}),I.invalidateQueries({queryKey:["my-turn"]}),I.invalidateQueries({queryKey:["me"]})}}),F=x.useRef(null);x.useEffect(()=>{a&&F.current!==a.id&&(F.current=a.id,C.mutate(a.id))},[a,C]);const K=x.useMemo(()=>ln(a==null?void 0:a.users),[a]);if(x.useEffect(()=>{a!=null&&ee(rl(a,K))},[a,K,ee]),o)return n.jsx("div",{className:"p-4 text-sm text-gray-500",children:"Loading PR…"});if(i||!a)return n.jsx("div",{className:"p-4 text-sm text-red-500",children:i?String(i):"PR not found"});const ae=qx[a.state],ne=a.authorId!=null?K.get(a.authorId):void 0;return n.jsx(mh.Provider,{value:rl(a,K),children:n.jsxs("div",{className:"flex h-full flex-col",children:[n.jsxs("div",{className:"border-b border-gray-200 px-4 py-2 pr-28 dark:border-gray-800",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"rounded px-1.5 py-0.5 text-xs font-semibold text-white",style:{backgroundColor:ae.color},children:a.isDraft?"Draft":ae.label}),n.jsxs("button",{type:"button",onClick:()=>w(rl(a,K)),className:"min-w-0 truncate text-left text-sm font-semibold hover:underline",title:"Open full-screen in its own tab",children:[n.jsxs("span",{className:"text-gray-400",children:["#",a.number]})," ",a.title]}),n.jsx("button",{type:"button",onClick:()=>w(rl(a,K)),className:"shrink-0 rounded p-0.5 text-blue-500 hover:text-blue-600",title:"Open full-screen — this PR in its own tab","aria-label":"Open this PR full-screen in its own tab",children:n.jsx(ph,{size:13})}),n.jsx("button",{type:"button",onClick:()=>P(a.id),className:"shrink-0 rounded p-0.5 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",title:"Show this PR on the timeline","aria-label":"Show this PR on the timeline",children:n.jsx(my,{size:15})}),n.jsx("button",{type:"button",onClick:()=>E(rl(a,K)),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 (✕ on the tab to close)","aria-label":"Focus this PR in its own timeline tab",children:n.jsx(Xo,{size:15})}),n.jsx("a",{href:a.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"shrink-0 rounded p-0.5 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",title:"Open this PR on GitHub","aria-label":"Open this PR on GitHub",children:n.jsx(hy,{size:15})}),a.isStalled&&n.jsx("span",{className:"rounded bg-orange-500/15 px-1.5 py-0.5 text-xs font-medium text-orange-500",title:"Open, no recent commits, and has open threads",children:"Stalled"}),(()=>{const se=Lv(a.newSinceLastViewed);return se?n.jsxs("button",{type:"button",onClick:()=>{b("activity"),N(a.lastViewedAt)},className:"ml-auto shrink-0 rounded bg-sky-500/15 px-1.5 py-0.5 text-xs font-medium text-sky-500 hover:bg-sky-500/25",title:"Filter activity to what's new since you last looked",children:["👁 ",se]}):null})()]}),n.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs text-gray-500",children:[n.jsx(ht,{user:ne,size:16}),n.jsx(sn,{user:ne,fallbackId:a.authorId,repoId:a.repoId}),n.jsx("span",{children:"·"}),n.jsxs("span",{className:"inline-flex items-center gap-1",children:[a.repoFullName,((Pe=u==null?void 0:u.find(se=>se.id===a.repoId))==null?void 0:Pe.inboxWatch)&&n.jsx(Bu,{size:11})]}),n.jsx("span",{children:"·"}),n.jsxs("span",{children:["opened ",St(a.openedAt)]}),a.changedFilesCount>0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsxs("button",{type:"button",onClick:()=>b("changes"),className:"inline-flex shrink-0 items-center gap-1 font-medium",title:"View the files changed by this PR",children:[n.jsxs("span",{className:"text-gray-500",children:[a.changedFilesCount," file",a.changedFilesCount===1?"":"s"]}),n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",a.additions.toLocaleString()]}),n.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",a.deletions.toLocaleString()]})]})]})]})]}),n.jsx("div",{className:"flex gap-1 border-b border-gray-200 px-3 dark:border-gray-800",children:["overview","threads","activity","changes",...m?["claude_review"]:[],...g?["ai_fix"]:[]].map(se=>{const Z=a.checkRuns.filter(je=>je.state==="failure"||je.state==="error").length;return n.jsxs("button",{type:"button",onClick:()=>b(se),className:`-mb-px border-b-2 px-3 py-1.5 text-xs ${y===se?"border-blue-500 text-blue-500":"border-transparent text-gray-500 hover:text-gray-700"}`,children:[_v[se],se==="overview"&&Z>0&&n.jsx("span",{className:"ml-1 text-red-500",title:`${Z} failing`,children:"●"}),se==="threads"&&a.threads.length>0&&n.jsx("span",{className:"ml-1 opacity-60",title:`${a.threads.length} threads`,children:a.threads.length}),se==="changes"&&a.changedFilesCount>0&&n.jsx("span",{className:"ml-1 opacity-60",title:`${a.changedFilesCount} files changed`,children:a.changedFilesCount})]},se)})}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:n.jsx(x.Suspense,{fallback:n.jsx("div",{className:"px-4 py-6 text-sm text-gray-400",children:"Loading…"}),children:y==="overview"?n.jsxs("div",{children:[n.jsx(xv,{pr:a,usersById:K}),n.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-800",children:[n.jsxs("div",{className:"px-4 pb-1 pt-2 text-xs font-semibold uppercase tracking-wide text-gray-400",children:["PR comments",a.comments.length>0&&n.jsxs("span",{className:"ml-1 font-normal opacity-70",children:["· ",a.comments.length]})]}),n.jsx(Bv,{pr:a,usersById:K,viewedSince:a.lastViewedAt,focusCommentId:H,selectedCommentId:D,onFocusConsumed:M}),n.jsx(Ku,{prId:a.id})]})]}):y==="threads"?n.jsx(Zy,{threads:a.threads,usersById:K,prUrl:a.githubUrl,prId:a.id,repoId:a.repoId,selectedThreadId:s,viewedSince:a.lastViewedAt,botFilter:ce}):y==="activity"?n.jsx(Dv,{pr:a,usersById:K,since:v,onClearSince:()=>N(null),focusEvent:j,onConsumed:S}):y==="changes"?n.jsx($v,{pr:a,focusThreadId:X,onThreadShown:()=>B(null)}):y==="ai_fix"?n.jsx(Fv,{pr:a}):n.jsx(Mv,{pr:a,usersById:K})})})]})})}const zv=["untouched","replied_unresolved","likely_addressed","resolved"],qv={open:"Open",merged:"Merged",closed:"Closed"};function Uv(e){const s=ur[e.ciStatus];return s?`<span class="pr-ci pr-ci-lead" style="background:${s.color}" title="${s.label}"></span>`:""}function Kv(e){return e?`${e.avatarUrl?`<img class="pr-avatar" src="${kt(e.avatarUrl)}" width="14" height="14" loading="lazy" alt="" />`:""}<span class="pr-author">${kt(e.label)}</span>`:""}function Hv(e,s={}){const{author:a}=s,o=e.isDraft?'<span class="pr-draft-tag">draft</span>':"";return'<div class="pr-bar-inner">'+(e.state==="open"?Uv(e):"")+`<span class="pr-num">#${e.number}</span>`+Kv(a)+`${o}<span class="pr-title">${kt(e.title)}</span></div>`}function Vp(e,s,a=""){return`<div class="pr-tt-row ${a}"><span class="pr-tt-dot" style="background:${e}"></span><span>${s}</span></div>`}function Wv(e,s={}){const{author:a,hasComments:o=!1}=s,i=[];i.push(`<div class="pr-tt-title">#${e.number} ${kt(e.title)}</div>`);const u=[];a!=null&&a.label&&u.push(kt(a.label)),u.push(qv[e.state]),e.isDraft&&u.push("draft"),e.isStalled&&u.push("stalled"),i.push(`<div class="pr-tt-meta">${u.join(" · ")}</div>`);const d=ur[e.ciStatus];d&&i.push(Vp(d.color,d.label));const p=Yo(e.mergeable,e.mergeStateStatus);p&&i.push(`<div class="pr-tt-row pr-tt-warn"><span class="pr-tt-warn-icon">⚠</span><span>merge: ${kt(p)}</span></div>`);const m=zv.filter(g=>e.threadCounts[g]>0);if(m.length>0){i.push('<div class="pr-tt-section">Review threads</div>');for(const g of m){const y=jt[g];i.push(Vp(y.color,`${y.label}: ${e.threadCounts[g]}`))}}else o&&i.push('<div class="pr-tt-row pr-tt-quiet">Has comments</div>');return`<div class="pr-tt">${i.join("")}</div>`}function Vv(e,s=!1){const a=["pr-bar",`pr-${e.state}`];return e.state==="open"?a.push("pr-emph"):a.push("pr-muted"),e.isDraft&&a.push("pr-draft"),e.isStalled&&a.push("pr-stalled"),e.reviewRequestedFromMe&&a.push("pr-myturn"),e.state==="open"&&(e.isChangesRequested?a.push("pr-changes-requested"):e.isApproved?a.push("pr-approved"):s&&a.push("pr-commented")),a.join(" ")}function Qv(){return{comments:0,reviews:0,prsOpen:0,prsMerged:0,prsClosed:0}}function Gv(e,s){const a=new Map,o=i=>{let u=a.get(i);return u||(u=Qv(),a.set(i,u)),u};for(const i of e)i.actorId!=null&&(i.type==="pr_comment"||i.type==="review_comment"?o(i.actorId).comments++:i.type==="review_submitted"&&o(i.actorId).reviews++);for(const i of s){if(i.authorId==null)continue;const u=o(i.authorId);i.state==="open"?u.prsOpen++:i.state==="merged"?u.prsMerged++:u.prsClosed++}return a}const Yv='<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><path fill="#8957e5" d="M8 .8 2.2 2.9v4.2c0 3.3 2.5 6.4 5.8 7.3 3.3-.9 5.8-4 5.8-7.3V2.9L8 .8Z"/><path d="M5.2 8 7.1 9.9 10.9 6" fill="none" stroke="#fff" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>',Xv='<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><rect x="2" y="9" width="3" height="5" rx="0.5" fill="currentColor"/><rect x="6.5" y="6" width="3" height="8" rx="0.5" fill="currentColor"/><rect x="11" y="3" width="3" height="11" rx="0.5" fill="currentColor"/></svg>';function Jv(e,s,a,o=!1,i,u=!1){const d=ft(e,s),p=e!=null&&e.avatarUrl?`<img class="tl-user-avatar" src="${kt(e.avatarUrl)}" width="18" height="18" loading="lazy" referrerpolicy="no-referrer" alt="" />`:`<span class="tl-user-avatar tl-user-avatar-fallback">${kt((d[0]??"?").toUpperCase())}</span>`,m=e!=null&&e.githubLogin?`<a class="tl-user-name tl-user-name-link" href="${kt(Du(e.githubLogin))}" target="_blank" rel="noreferrer noopener" title="${kt(`@${e.githubLogin} on GitHub`)}" onclick="event.stopPropagation()">${kt(d)}</a>`:`<span class="tl-user-name">${kt(d)}</span>`,g=o?`<span class="tl-merger" title="Has merge rights — has merged a PR in this repo">${Yv}</span>`:"",y=i?`<button type="button" class="tl-stats-toggle" data-stats-gid="${kt(i)}" title="Show metrics" aria-label="Show contributor metrics">${Xv}</button>`:"",b=u?"Expand row":"Collapse row";return'<div class="tl-user">'+(i?`<button type="button" class="tl-collapse-caret" data-collapse-gid="${kt(i)}" title="${kt(b)}" aria-label="${kt(b)}">${u?"▸":"▾"}</button>`:"")+p+`<span class="tl-user-main"><span class="tl-user-name-line">${m}${g}${y}</span></span></div>`}function ni(){return typeof window<"u"}function Ia(e){return Hu(e)?(e.nodeName||"").toLowerCase():"#document"}function xn(e){var s;return(e==null||(s=e.ownerDocument)==null?void 0:s.defaultView)||window}function dr(e){var s;return(s=(Hu(e)?e.ownerDocument:e.document)||window.document)==null?void 0:s.documentElement}function Hu(e){return ni()?e instanceof Node||e instanceof xn(e).Node:!1}function dt(e){return ni()?e instanceof Element||e instanceof xn(e).Element:!1}function fr(e){return ni()?e instanceof HTMLElement||e instanceof xn(e).HTMLElement:!1}function vu(e){return!ni()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof xn(e).ShadowRoot}function gl(e){const{overflow:s,overflowX:a,overflowY:o,display:i}=An(e);return/auto|scroll|overlay|hidden|clip/.test(s+o+a)&&i!=="inline"&&i!=="contents"}function Zv(e){return/^(table|td|th)$/.test(Ia(e))}function ri(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const eb=/transform|translate|scale|rotate|perspective|filter/,tb=/paint|layout|strict|content/,As=e=>!!e&&e!=="none";let Gc;function Wu(e){const s=dt(e)?An(e):e;return As(s.transform)||As(s.translate)||As(s.scale)||As(s.rotate)||As(s.perspective)||!si()&&(As(s.backdropFilter)||As(s.filter))||eb.test(s.willChange||"")||tb.test(s.contain||"")}function nb(e){let s=$r(e);for(;fr(s)&&!Ar(s);){if(Wu(s))return s;if(ri(s))return null;s=$r(s)}return null}function si(){return Gc==null&&(Gc=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Gc}function Ar(e){return/^(html|body|#document)$/.test(Ia(e))}function An(e){return xn(e).getComputedStyle(e)}function ai(e){return dt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $r(e){if(Ia(e)==="html")return e;const s=e.assignedSlot||e.parentNode||vu(e)&&e.host||dr(e);return vu(s)?s.host:s}function Sh(e){const s=$r(e);return Ar(s)?e.ownerDocument?e.ownerDocument.body:e.body:fr(s)&&gl(s)?s:Sh(s)}function ls(e,s,a){var o;s===void 0&&(s=[]),a===void 0&&(a=!0);const i=Sh(e),u=i===((o=e.ownerDocument)==null?void 0:o.body),d=xn(i);if(u){const p=bu(d);return s.concat(d,d.visualViewport||[],gl(i)?i:[],p&&a?ls(p):[])}else return s.concat(i,ls(i,[],a))}function bu(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const Bo=Math.min,Fs=Math.max,zo=Math.round,Co=Math.floor,ir=e=>({x:e,y:e}),rb={left:"right",right:"left",bottom:"top",top:"bottom"};function Qp(e,s,a){return Fs(e,Bo(s,a))}function li(e,s){return typeof e=="function"?e(s):e}function Ds(e){return e.split("-")[0]}function oi(e){return e.split("-")[1]}function Ch(e){return e==="x"?"y":"x"}function Rh(e){return e==="y"?"height":"width"}function as(e){const s=e[0];return s==="t"||s==="b"?"y":"x"}function Ih(e){return Ch(as(e))}function sb(e,s,a){a===void 0&&(a=!1);const o=oi(e),i=Ih(e),u=Rh(i);let d=i==="x"?o===(a?"end":"start")?"right":"left":o==="start"?"bottom":"top";return s.reference[u]>s.floating[u]&&(d=qo(d)),[d,qo(d)]}function ab(e){const s=qo(e);return[wu(e),s,wu(s)]}function wu(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Gp=["left","right"],Yp=["right","left"],lb=["top","bottom"],ob=["bottom","top"];function ib(e,s,a){switch(e){case"top":case"bottom":return a?s?Yp:Gp:s?Gp:Yp;case"left":case"right":return s?lb:ob;default:return[]}}function cb(e,s,a,o){const i=oi(e);let u=ib(Ds(e),a==="start",o);return i&&(u=u.map(d=>d+"-"+i),s&&(u=u.concat(u.map(wu)))),u}function qo(e){const s=Ds(e);return rb[s]+e.slice(s.length)}function ub(e){return{top:0,right:0,bottom:0,left:0,...e}}function db(e){return typeof e!="number"?ub(e):{top:e,right:e,bottom:e,left:e}}function Uo(e){const{x:s,y:a,width:o,height:i}=e;return{width:o,height:i,top:a,left:s,right:s+o,bottom:a+i,x:s,y:a}}/*!
36
+ `))!==-1;)d(u.slice(0,g)),u=u.slice(g+2)}u.trim()&&d(u)}finally{try{o.releaseLock()}catch{}}}function kN(e,s){return qe({queryKey:["ai-fix",e],queryFn:()=>ge.aiFix(e),enabled:e!=null&&s})}function pv(e,s){return qe({queryKey:["ai-fix-summary",e],queryFn:()=>ge.aiFixSummary(e),enabled:e!=null&&s})}function jN(e,s){return qe({queryKey:["ai-fix-ci",e],queryFn:()=>ge.aiFixCiAnalysis(e),enabled:e!=null&&s})}function mv(e){const s=Be();return Ue({mutationFn:()=>ge.refreshAiFixSummary(e),onSuccess:a=>s.setQueryData(["ai-fix-summary",e],a)})}function NN(e){const s=Be();return Ue({mutationFn:a=>ge.refreshAiFixCiAnalysis(e,a),onSuccess:a=>s.setQueryData(["ai-fix-ci",e],a)})}function SN(e){const s=Be();return Ue({mutationFn:a=>ge.startAiFix(e,a),onSuccess:()=>void s.invalidateQueries({queryKey:["ai-fix",e]})})}function CN(e){const s=Be();return Ue({mutationFn:()=>ge.cancelAiFix(e),onSuccess:()=>void s.invalidateQueries({queryKey:["ai-fix",e]})})}function RN(e){const s=Be();return Ue({mutationFn:a=>ge.pushAiFix(a.fixId,a.body),onSuccess:()=>void s.invalidateQueries({queryKey:["ai-fix",e]})})}function IN(){return Ue({mutationFn:e=>ge.aiFixMergePreview(e)})}function TN(){return Ue({mutationFn:e=>ge.startAiFixRebase(e.fixId,e.body)})}function EN(){return Ue({mutationFn:e=>ge.cancelAiFixRebase(e)})}function PN(){return Ue({mutationFn:e=>ge.cancelAiFixPush(e)})}function AN(e,s,a,o){const i=Be(),[u,d]=x.useState(null);return x.useEffect(()=>{if(e==null||s==null||!o){d(null);return}const p=new AbortController;let m=!1;const g=()=>{m||(m=!0,i.invalidateQueries({queryKey:["ai-fix",e]}))};return ti(`/api/pro/ai-fixes/${s}/${a}/stream`,{signal:p.signal,onEvent:w=>{w.type==="done"?(g(),d({status:w.status,fixId:w.fixId,progress:null,error:w.error??null})):d({status:w.status,fixId:w.fixId,progress:w.progress})}}).catch(()=>{}),()=>p.abort()},[e,s,a,o,i]),{status:u}}function $N(e,s){const a=Be(),[o,i]=x.useState(null);return x.useEffect(()=>{if(e==null||!s){i(null);return}const u=new AbortController;let d=!1;const p=()=>{d||(d=!0,a.invalidateQueries({queryKey:["ai-fix",e]}))};return ti(`/api/pro/prs/${e}/ai-fix/stream`,{signal:u.signal,onEvent:m=>{m.type==="done"?(p(),i({status:m.status,fixId:m.fixId,progress:null})):i({status:m.status,fixId:m.fixId,progress:m.progress})}}).catch(()=>{}),()=>u.abort()},[e,s,a]),{status:o}}function kh({pr:e}){const{prSummary:s}=yn(),{data:a}=pv(e.id,s),o=mv(e.id),i=(a==null?void 0:a.headSha)!=null&&a.headSha!==e.headSha,u=(a==null?void 0:a.creditsExhausted)===!0;return s?n.jsxs("div",{children:[n.jsx("div",{className:"px-4 pb-1 pt-2 text-xs font-semibold uppercase tracking-wide text-gray-400",children:"AI summary"}),n.jsxs("div",{className:"px-4 pb-3",children:[a!=null&&a.summary?n.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:n.jsx(cr,{children:a.summary})}):n.jsx("p",{className:"text-sm text-gray-500",children:"Generate a plain-language overview of what this PR does."}),n.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[n.jsx("button",{type:"button",className:"whitespace-nowrap rounded border border-blue-400 px-2.5 py-1 text-xs text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",disabled:o.isPending||u,onClick:()=>o.mutate(),children:o.isPending?"Generating…":a!=null&&a.summary?"Regenerate":"Generate summary"}),u&&n.jsx("span",{className:"text-[11px] text-amber-600 dark:text-amber-400",children:"Out of AI credits this month"}),i&&n.jsx("span",{className:"text-[11px] text-amber-600 dark:text-amber-400",children:"PR has changed since this was generated"}),o.isError&&n.jsx("span",{className:"text-[11px] text-red-500",children:o.error instanceof Gt||o.error instanceof Error?o.error.message:"Something went wrong"})]})]})]}):null}const hv={approved:{icon:"✓",cls:"bg-green-500/10 text-green-700 dark:text-green-400",title:"Approved"},changes_requested:{icon:"✗",cls:"bg-red-500/10 text-red-700 dark:text-red-400",title:"Requested changes"},commented:{icon:"",cls:"bg-gray-500/10 text-gray-600 dark:text-gray-300",title:"Reviewed (commented)"},dismissed:{icon:"",cls:"bg-gray-500/10 text-gray-400",title:"Review dismissed"},pending:{icon:"",cls:"bg-gray-500/10 text-gray-400",title:"Review pending"}};function Qt({label:e,children:s}){return n.jsxs("div",{className:"flex gap-3 px-4 py-1.5 text-sm",children:[n.jsx("span",{className:"w-28 shrink-0 text-xs uppercase tracking-wide text-gray-400",children:e}),n.jsx("div",{className:"min-w-0 flex-1",children:s})]})}function Up({kind:e,provenance:s}){const a=an(e),o=e==="pierre"&&s?s==="ai_verbatim"?" · verbatim":" · curated":"";return n.jsxs("span",{"data-testid":"reviewer-provenance",className:"inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[10px] font-medium",style:{color:a.color,background:`${a.color}1a`},title:`Automated reviewer — ${a.label}${o}`,children:[n.jsx("span",{"aria-hidden":!0,children:"🤖"}),a.label,o]})}function gv({pr:e,suggestions:s,usersById:a}){var w;const o=hh(e.id),[i,u]=x.useState(new Set),[d,p]=x.useState(null),m=v=>v.kind==="team"?`team:${v.teamSlug}`:`user:${v.login}`,g=v=>{const y=v.kind==="team"?{teamSlugs:v.teamSlug?[v.teamSlug]:[]}:v.userId!=null?{userIds:[v.userId]}:{logins:v.login?[v.login]:[]},j=m(v);p(j),o.mutate(y,{onSuccess:()=>u(R=>new Set(R).add(j)),onSettled:()=>p(null)})};return n.jsxs(Qt,{label:"Suggested",children:[n.jsx("div",{className:"flex flex-col gap-1.5 text-xs",children:s.map(v=>{const y=m(v),j=i.has(y),R=v.userId!=null?a.get(v.userId):void 0;return n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsx("span",{className:"inline-flex items-center gap-1 rounded bg-gray-500/10 px-1.5 py-0.5",children:v.kind==="team"?n.jsxs("span",{className:"font-medium",children:["@",v.teamName]}):R?n.jsxs(n.Fragment,{children:[n.jsx(ht,{user:R,size:14}),n.jsx(sn,{user:R,fallbackId:v.userId,repoId:e.repoId})]}):n.jsxs("span",{children:["@",v.login]})}),n.jsx("span",{className:"text-gray-400",children:v.reason}),e.viewerCanPush&&n.jsx("button",{type:"button",onClick:()=>g(v),disabled:d!==null||j,className:"rounded border border-violet-300 px-1.5 py-0.5 font-medium text-violet-700 hover:bg-violet-50 disabled:opacity-50 dark:border-violet-700 dark:text-violet-300 dark:hover:bg-violet-900/20",title:"Request this reviewer on GitHub",children:j?"✓ Requested":d===y?"Assigning…":"Assign"})]},y)})}),o.isError&&n.jsx("div",{className:"mt-1 text-[11px] text-red-500",children:((w=o.error)==null?void 0:w.message)??"Couldn’t request the reviewer."})]})}function xv({body:e}){const[s,a]=x.useState(!1),[o,i]=x.useState(!1),[u,d]=x.useState(!1),p=x.useRef(null);return x.useEffect(()=>{const m=p.current;if(!m)return;const g=160,w=384,v=()=>{const E=m.clientWidth,S=Array.from(m.querySelectorAll("img"));let T=!1,N=E>0;for(const b of S){if(!(b.naturalWidth>0&&b.naturalHeight>0)){b.complete||(N=!1);continue}const $=E?Math.min(b.naturalWidth,E):b.naturalWidth,L=Math.min(b.naturalHeight*$/b.naturalWidth,w),q=E>0&&L>g;b.classList.toggle("pr-summary-tall-img",q),q&&(T=!0)}return d(T),N},y=new MutationObserver(()=>v());y.observe(m,{childList:!0,subtree:!0});let j=0,R=0;const P=()=>{!v()&&j++<240&&(R=requestAnimationFrame(P))};return P(),()=>{y.disconnect(),cancelAnimationFrame(R)}},[e]),x.useLayoutEffect(()=>{if(s)return;const m=p.current;m&&i(m.scrollHeight-m.clientHeight>1)},[e,s]),x.useEffect(()=>{if(s)return;const m=p.current;if(!m)return;const g=new ResizeObserver(()=>{i(m.scrollHeight-m.clientHeight>1)});return g.observe(m),()=>g.disconnect()},[e,s]),n.jsxs("div",{children:[n.jsx("div",{className:"px-4 pb-1 pt-2 text-xs font-semibold uppercase tracking-wide text-gray-400",children:"Summary"}),n.jsxs("div",{className:"px-4 pb-3 text-sm",children:[n.jsx("div",{ref:p,className:`overflow-hidden${s?"":" pr-summary-collapsed"}`,style:s?void 0:{display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical"},children:n.jsx(cr,{children:e})}),(o||u||s)&&n.jsx("button",{type:"button",onClick:()=>a(m=>!m),className:"mt-1 text-xs font-medium text-blue-500 hover:underline",children:s?"Show less":"Show more"})]})]})}function yv({pr:e,usersById:s}){var T,N;const{data:a}=ky(e.id),o=(a==null?void 0:a.suggestedReviewers)??[],i=(((T=a==null?void 0:a.users)==null?void 0:T.length)??0)>0?new Map([...s,...a.users.map(b=>[b.id,b])]):s,u=ur[e.ciStatus],d=Xo(e.mergeable,e.mergeStateStatus),p=e.checkRuns,m=p.reduce((b,I)=>(b[I.state]=(b[I.state]??0)+1,b),{}),g=new Map;for(const b of e.reviews)b.authorId==null||b.state!=="approved"&&b.state!=="changes_requested"&&b.state!=="dismissed"||g.set(b.authorId,b.state);const w=[...g].filter(([,b])=>b==="approved").map(([b])=>b),v=new Map;for(const b of e.reviews)b.authorId==null||b.state==="pending"||v.set(b.authorId,b.state);const y=[...v.keys()],j=new Map,R=new Set;for(const b of e.reviews)b.authorId==null||b.state==="pending"||(b.automatedKind!=null?j.set(b.authorId,{kind:b.automatedKind,provenance:b.provenance??null}):R.add(b.authorId));const P=y.length>0&&y.every(b=>j.has(b)&&!R.has(b)),E=te(b=>b.setThreadBotFilter),S=(()=>{var I;const b=new Map;for(const $ of e.threads){const L=$.originalCommenterId??((I=$.comments[0])==null?void 0:I.authorId)??null;if(L==null)continue;const q=ih(s.get(L));if(!q)continue;const Q=b.get(q.kind)??{threads:0,unresolved:0};Q.threads+=1,($.derivedState==="untouched"||$.derivedState==="replied_unresolved")&&(Q.unresolved+=1),b.set(q.kind,Q)}return[...b.entries()].map(([$,L])=>({kind:$,...qs[$],...L})).sort(($,L)=>L.threads-$.threads)})();return n.jsxs(n.Fragment,{children:[((N=e.authNotice)==null?void 0:N.kind)==="saml_sso"&&n.jsxs("div",{className:"mx-4 mt-2 rounded-md border border-amber-400/50 bg-amber-400/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200",children:[n.jsxs("strong",{className:"font-semibold",children:["Some data from ",e.authNotice.org," is hidden."]})," ","Your GitHub sign-in isn’t authorized for ",e.authNotice.org,"’s SAML SSO, so the description, CI jobs and comment bodies couldn’t be loaded. Fix:"," ",n.jsxs("a",{className:"underline underline-offset-2",href:`https://github.com/orgs/${e.authNotice.org}/sso`,target:"_blank",rel:"noreferrer",children:["start an SSO session for ",e.authNotice.org]}),", then revoke the app at"," ",n.jsx("a",{className:"underline underline-offset-2",href:"https://github.com/settings/applications",target:"_blank",rel:"noreferrer",children:"Authorized OAuth Apps"})," ","and sign in again. (If GitHub only offers “Request”, an org owner must approve the app.)"]}),n.jsxs("div",{className:"divide-y divide-gray-100 py-1 dark:divide-gray-800",children:[n.jsx(Qt,{label:"CI",children:u?n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{backgroundColor:u.color}}),u.label,p.length>0&&n.jsxs("span",{className:"text-xs text-gray-400",children:["·"," ",[m.success?`${m.success} passed`:null,m.failure?`${m.failure} failed`:null,m.pending?`${m.pending} running`:null].filter(Boolean).join(" · ")]})]}):n.jsx("span",{className:"text-gray-400",children:"no checks reported"})}),n.jsx(Qt,{label:"Mergeable",children:d?n.jsxs("span",{className:"font-medium text-orange-500",children:["⚠ ",d]}):e.mergeable==="mergeable"?n.jsx("span",{className:"text-green-500",children:"clean"}):n.jsx("span",{className:"text-gray-400",children:e.mergeStateStatus})}),y.length>0&&n.jsx(Qt,{label:"Reviewers",children:n.jsx("div",{className:"flex flex-wrap gap-2 text-xs",children:y.map(b=>{const I=s.get(b),$=hv[v.get(b)],L=j.get(b);return n.jsxs("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 ${$.cls}`,title:$.title,children:[$.icon&&n.jsx("span",{"aria-hidden":!0,children:$.icon}),n.jsx(ht,{user:I,size:14}),n.jsx(sn,{user:I,fallbackId:b,repoId:e.repoId}),L&&n.jsx(Up,{kind:L.kind,provenance:L.provenance})]},b)})})}),P&&n.jsx(Qt,{label:"Coverage",children:n.jsxs("span",{"data-testid":"only-bots-reviewed",className:"inline-flex items-center gap-1 rounded bg-amber-400/10 px-1.5 py-0.5 text-xs font-medium text-amber-700 dark:text-amber-300",title:"Every review on this PR came from an automated reviewer — no human has reviewed it yet.",children:[n.jsx("span",{"aria-hidden":!0,children:"🤖"}),"only bots reviewed"]})}),S.length>0&&n.jsx(Qt,{label:"Bots",children:n.jsx("div",{className:"flex flex-wrap gap-2 text-xs",children:S.map(b=>n.jsxs("button",{type:"button",onClick:()=>E(b.kind),className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium transition-opacity hover:opacity-80",style:{color:b.color,background:`${b.color}1a`},title:`${b.label} opened ${b.threads} review thread${b.threads===1?"":"s"} on this PR${b.unresolved>0?` · ${b.unresolved} still need a look`:" · all acted on"} — click to filter the Threads tab`,children:[n.jsx("span",{"aria-hidden":!0,children:"🤖"}),b.label,n.jsxs("span",{className:"tabular-nums opacity-70",children:["· ",b.threads]}),b.unresolved>0&&n.jsxs("span",{className:"tabular-nums font-semibold",children:["· ",b.unresolved," unresolved"]})]},b.kind))})}),w.length>0&&n.jsx(Qt,{label:"Approvers",children:n.jsx("div",{className:"flex flex-wrap gap-2 text-xs",children:w.map(b=>{const I=s.get(b),$=j.get(b);return n.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-green-500/10 px-1.5 py-0.5 text-green-700 dark:text-green-400",title:"Approved this PR",children:[n.jsx("span",{className:"text-green-600 dark:text-green-500",children:"✓"}),n.jsx(ht,{user:I,size:14}),n.jsx(sn,{user:I,fallbackId:b,repoId:e.repoId}),$&&n.jsx(Up,{kind:$.kind,provenance:$.provenance})]},b)})})}),e.viewerCanApprove&&n.jsx(Qt,{label:"Review",children:n.jsx(tv,{prId:e.id,alreadyApproved:e.viewerHasApprovedStanding})}),e.viewerCanPush&&e.state==="open"&&!e.isDraft&&n.jsx(Qt,{label:"Merge",children:n.jsx(sv,{prId:e.id,githubUrl:e.githubUrl})}),e.mergedById!=null&&n.jsx(Qt,{label:"Merged by",children:n.jsxs("div",{className:"text-xs",children:[n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(ht,{user:s.get(e.mergedById),size:14}),n.jsx(sn,{user:s.get(e.mergedById),fallbackId:e.mergedById,repoId:e.repoId})]}),e.mergedAt!=null&&n.jsx("div",{className:"mt-0.5 text-gray-400",title:Ra(e.mergedAt),children:Ra(e.mergedAt)})]})}),e.tickets!=null&&n.jsx(Qt,{label:"Ticket",children:e.tickets.length===0?n.jsx("span",{className:"text-xs text-gray-400",children:"No ticket found"}):n.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.tickets.map(b=>n.jsx("a",{href:b.url,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-center rounded border border-sky-200 bg-sky-50 px-1.5 py-0.5 text-xs font-medium text-sky-700 hover:bg-sky-100 dark:border-sky-900 dark:bg-sky-950 dark:text-sky-300",title:`Open ${b.key} in ${b.provider==="jira"?"Jira":"Linear"}`,children:b.key},b.key))})}),e.body!=null&&e.body.trim()!==""&&n.jsx(xv,{body:e.body}),n.jsx(kh,{pr:e}),p.length>0&&n.jsxs(Qt,{label:"Checks",children:[n.jsx(dv,{prId:e.id,checks:p}),n.jsx(fv,{prId:e.id,checks:p,viewerCanPush:e.viewerCanPush})]}),e.labels.length>0&&n.jsx(Qt,{label:"Labels",children:n.jsx("div",{className:"flex flex-wrap gap-1",children:e.labels.map(b=>n.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs",style:{borderColor:`#${b.color}`},children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:`#${b.color}`}}),b.name]},b.name))})}),e.requestedReviewers.length>0&&n.jsx(Qt,{label:"Requested",children:n.jsx("div",{className:"flex flex-wrap gap-2 text-xs",children:e.requestedReviewers.map((b,I)=>n.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5",children:b.teamName?`@${b.teamName}`:n.jsx(sn,{user:b.userId!=null?s.get(b.userId):void 0,fallbackId:b.userId,repoId:e.repoId})},I))})}),o.length>0&&n.jsx(gv,{pr:e,suggestions:o,usersById:i}),n.jsx(Qt,{label:"Meta",children:n.jsxs("div",{className:"space-y-0.5 text-xs text-gray-500",children:[n.jsx("div",{children:e.repoFullName}),n.jsxs("div",{children:["opened ",St(e.openedAt)]}),n.jsxs("div",{children:["updated ",St(e.updatedAt)]})]})})]})]})}function vv(e){const s=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(e);return s?{oldStart:Number(s[1]),newStart:Number(s[2])}:null}function bv(e){if(!e)return[];const s=[];let a=0,o=0;for(const i of e.replace(/\n$/,"").split(`
37
+ `)){const u=vv(i);if(u){a=u.oldStart,o=u.newStart,s.push({kind:"hunk",text:i});continue}const d=i[0];d==="+"?(s.push({kind:"add",text:i,newLine:o}),o+=1):d==="-"?(s.push({kind:"del",text:i,oldLine:a}),a+=1):d==="\\"?s.push({kind:"context",text:i}):(s.push({kind:"context",text:i,oldLine:a,newLine:o}),a+=1,o+=1)}return s}function wv(e){return e?e.replace(/\n$/,"").split(`
38
+ `).length:0}function Kp(e){let s=e.trim();return s==="/dev/null"?null:(s.startsWith('"')&&s.endsWith('"')&&(s=s.slice(1,-1)),(s.startsWith("a/")||s.startsWith("b/"))&&(s=s.slice(2)),s)}function kv(e){const s=/^diff --git a\/(.+) b\/(.+)$/.exec(e);return s?{oldPath:s[1]??null,newPath:s[2]??null}:{oldPath:null,newPath:null}}function MN(e){if(!e)return[];const s=e.replace(/\n$/,"").split(`
39
+ `),a=s.length,o=[];let i=0;for(;i<a&&!(s[i]??"").startsWith("diff --git ");)i++;for(;i<a;){const u=kv(s[i]??"");i++;let d="modified",p=null,m=null,g=null,w=null,v=!1;const y=[];let j=!1;for(;i<a;i++){const T=s[i]??"";if(T.startsWith("diff --git "))break;if(j){y.push(T);continue}T.startsWith("@@")?(j=!0,y.push(T)):T.startsWith("new file mode")?d="added":T.startsWith("deleted file mode")?d="removed":T.startsWith("rename from ")?(d="renamed",g=T.slice(12)):T.startsWith("rename to ")?(d="renamed",w=T.slice(10)):T.startsWith("copy from ")?(d="copied",g=T.slice(10)):T.startsWith("copy to ")?(d="copied",w=T.slice(8)):T.startsWith("Binary files ")||T.startsWith("GIT binary patch")?v=!0:T.startsWith("--- ")?p=Kp(T.slice(4)):T.startsWith("+++ ")&&(m=Kp(T.slice(4)))}const R=m||w||u.newPath||u.oldPath||p||"(unknown)",P=d==="renamed"||d==="copied"?g||p||u.oldPath:null;let E=0,S=0;for(const T of y)T.startsWith("+")&&!T.startsWith("+++")?E++:T.startsWith("-")&&!T.startsWith("---")&&S++;o.push({path:R,previousPath:P,status:d,additions:E,deletions:S,patch:v?null:y.join(`
40
+ `)})}return o}const jv=250,Nv=400;function Sv(e){return e.patch==null||wv(e.patch)>jv||e.additions+e.deletions>Nv}const Cv={added:{icon:"A",label:"added",cls:"text-green-600 dark:text-green-400"},removed:{icon:"D",label:"removed",cls:"text-red-500 dark:text-red-400"},modified:{icon:"M",label:"modified",cls:"text-amber-600 dark:text-amber-400"},renamed:{icon:"R",label:"renamed",cls:"text-sky-600 dark:text-sky-400"},copied:{icon:"C",label:"copied",cls:"text-sky-600 dark:text-sky-400"},changed:{icon:"M",label:"changed",cls:"text-amber-600 dark:text-amber-400"},unchanged:{icon:"·",label:"unchanged",cls:"text-gray-400"}};function jh(e){return e.kind==="add"&&e.newLine!=null?{line:e.newLine,side:"RIGHT"}:e.kind==="context"&&e.newLine!=null?{line:e.newLine,side:"RIGHT"}:e.kind==="del"&&e.oldLine!=null?{line:e.oldLine,side:"LEFT"}:null}function Rv(e,s){if(s==null)return null;let a=null,o=null;return e.forEach((i,u)=>{const d=jh(i);!d||d.line!==s||(d.side==="RIGHT"?a=u:o=u)}),a??o}const Iv={hunk:"bg-sky-500/5 text-sky-600 dark:text-sky-400 select-none",add:"bg-green-500/10",del:"bg-red-500/10",context:""};function Hp(e){return e==null?"":String(e)}function Tv({row:e,filePath:s,fileUrl:a,commenting:o,open:i,onOpen:u,onClose:d}){const p=o?jh(e):null,m=e.kind==="hunk"?e.text:e.text.slice(1)||" ";return n.jsxs(n.Fragment,{children:[n.jsxs("tr",{className:`group ${Iv[e.kind]}`,children:[n.jsx("td",{className:"w-9 select-none border-r border-gray-200 px-1 text-right align-top text-gray-400 dark:border-gray-800",children:e.kind==="hunk"?"":Hp(e.oldLine)}),n.jsx("td",{className:"w-9 select-none border-r border-gray-200 px-1 text-right align-top text-gray-400 dark:border-gray-800",children:e.kind==="hunk"?"":Hp(e.newLine)}),n.jsx("td",{className:"select-none px-1 align-top",children:n.jsx("div",{className:"flex w-4 justify-center",children:o&&p&&!i&&n.jsx("button",{type:"button",onClick:u,title:"Comment on this line",className:"rounded bg-blue-500 px-1 text-[10px] font-bold leading-tight text-white opacity-0 transition-opacity hover:bg-blue-600 group-hover:opacity-100",children:"+"})})}),n.jsxs("td",{className:"w-full whitespace-pre px-2 align-top",children:[e.kind!=="hunk"&&n.jsx("span",{className:"select-none text-gray-400",children:e.kind==="add"?"+":e.kind==="del"?"-":" "}),m]})]}),i&&o&&p&&n.jsx("tr",{children:n.jsx("td",{colSpan:4,className:"px-2 py-1.5",children:n.jsx(Ev,{prId:o.prId,filePath:s,fileUrl:a,line:p.line,side:p.side,onClose:d})})})]})}function Wp({thread:e,ctx:s}){const a=x.useRef(null),o=s.focusThreadId!=null&&s.focusThreadId===e.id;return x.useEffect(()=>{var i;o&&a.current&&(a.current.scrollIntoView({block:"center",behavior:"smooth"}),(i=s.onThreadShown)==null||i.call(s))},[o]),n.jsx("tr",{ref:a,children:n.jsx("td",{colSpan:4,className:"bg-gray-50 px-2 py-2 dark:bg-gray-900/40",children:n.jsx("div",{className:`rounded font-sans ${o?"ring-2 ring-amber-400/70":""}`,children:n.jsx(gl,{thread:e,usersById:s.usersById,prUrl:s.prUrl,selected:o})})})})}function Ev({prId:e,filePath:s,fileUrl:a,line:o,side:i,onClose:u}){const[d,p]=x.useState(""),[m,g]=x.useState(null),w=Ay(e),v=w.error instanceof Gt?w.error.message:w.error?"Failed to post the comment.":null,y=()=>{const j=d.trim();!j||w.isPending||(g(null),w.mutate({path:s,line:o,side:i,body:j},{onSuccess:R=>{if(R.commentId===null){g({text:"Couldn't place this comment in the diff — open it on GitHub instead.",url:a,tone:"warn"});return}if(p(""),R.anchored===!1){g({text:`Posted on the nearest changed line (${R.side==="LEFT"?"old":"new"} line ${R.line}). It’ll appear in the Threads tab after the next sync.`,url:R.url,tone:"warn"});return}g({text:"Comment posted. It’ll appear in the Threads tab after the next sync.",url:R.url,tone:"ok"})}}))};return n.jsxs("div",{className:"space-y-1 rounded border border-gray-300 bg-white p-2 font-sans dark:border-gray-700 dark:bg-gray-900",children:[n.jsxs("div",{className:"text-[10px] text-gray-400",children:["Commenting on ",i==="LEFT"?"old":"new"," line ",o]}),n.jsx(ei,{prId:e,value:d,onChange:p,rows:3,autoFocus:!0,placeholder:"Add an inline review comment (markdown)…",className:"w-full rounded border border-gray-300 bg-white px-2 py-1.5 text-xs dark:border-gray-700 dark:bg-gray-950"}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("button",{type:"button",onClick:y,disabled:w.isPending||d.trim().length===0,className:"whitespace-nowrap rounded border border-blue-400 px-2 py-0.5 text-xs text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",children:w.isPending?"Sending…":"Send"}),n.jsx("button",{type:"button",onClick:()=>{p(""),g(null),w.reset(),u()},disabled:w.isPending,className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-xs hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:(m==null?void 0:m.tone)==="ok"?"Close":"Cancel"}),v&&n.jsx("span",{className:"text-[10px] text-red-500",children:v})]}),m&&n.jsxs("div",{className:m.tone==="ok"?"text-[10px] text-green-600 dark:text-green-400":"text-[10px] text-amber-600 dark:text-amber-400",children:[m.text,m.url&&n.jsxs(n.Fragment,{children:[" ",n.jsx("a",{href:m.url,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"Open on GitHub ↗"})]})]})]})}function Pv({file:e,commenting:s,threads:a,threadCtx:o}){const i=x.useMemo(()=>bv(e.patch),[e.patch]),{byRow:u,unanchored:d}=x.useMemo(()=>{const P=new Map,E=[];for(const S of a){const T=Rv(i,S.line);if(T==null)E.push(S);else{const N=P.get(T)??[];N.push(S),P.set(T,N)}}return{byRow:P,unanchored:E}},[i,a]),p=(o==null?void 0:o.focusThreadId)!=null&&a.some(P=>P.id===o.focusThreadId),[m,g]=x.useState(()=>!Sv(e)||a.length>0);x.useEffect(()=>{p&&g(!0)},[p]);const[w,v]=x.useState(null),y=Cv[e.status],j=e.previousPath?`${e.previousPath} → ${e.path}`:e.path,R=e.githubUrl??null;return n.jsxs("div",{children:[n.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-2 border-b border-gray-100 bg-white px-3 py-1.5 text-xs hover:bg-gray-50 dark:border-gray-800 dark:bg-gray-950 dark:hover:bg-gray-900",children:[n.jsxs("button",{type:"button",onClick:()=>g(P=>!P),className:"flex min-w-0 flex-1 items-center gap-2 text-left",title:m?"Collapse this file":"Expand this file",children:[n.jsx("span",{className:"w-3 shrink-0 select-none text-gray-400",children:m?"▾":"▸"}),n.jsx("span",{className:`w-3 shrink-0 select-none text-center font-mono font-bold ${y.cls}`,title:y.label,children:y.icon}),n.jsx("code",{className:"min-w-0 flex-1 truncate font-mono",children:j})]}),a.length>0&&n.jsxs("span",{className:"shrink-0 rounded bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:text-amber-300",title:`${a.length} unresolved thread${a.length===1?"":"s"} on this file`,children:[a.length," 💬"]}),n.jsxs("span",{className:"shrink-0 font-mono tabular-nums",children:[n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions]})," ",n.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions]})]}),R&&n.jsx("a",{href:R,target:"_blank",rel:"noreferrer noopener",className:"shrink-0 text-blue-500 hover:underline",title:"View this file's diff on GitHub",children:"↗"})]}),m&&n.jsx("div",{className:"border-b border-gray-100 dark:border-gray-800",children:e.patch==null?n.jsxs("div",{className:"px-3 py-3 text-center text-xs text-gray-500",children:[R?n.jsxs(n.Fragment,{children:["Diff is too large or binary —"," ",n.jsx("a",{href:R,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"view on GitHub ↗"})]}):"Binary file — no textual diff.",o&&a.length>0&&n.jsx("div",{className:"mt-2 space-y-2 text-left",children:a.map(P=>n.jsx("div",{className:"font-sans",children:n.jsx(gl,{thread:P,usersById:o.usersById,prUrl:o.prUrl,selected:o.focusThreadId===P.id})},P.id))})]}):i.length===0?n.jsx("div",{className:"px-3 py-3 text-center text-xs text-gray-500",children:"No textual diff for this file."}):n.jsx("table",{className:"w-full border-collapse font-mono text-[12px] leading-[1.45]",children:n.jsxs("tbody",{children:[o&&d.map(P=>n.jsx(Wp,{thread:P,ctx:o},`u-${P.id}`)),i.map((P,E)=>{var S;return n.jsxs(x.Fragment,{children:[n.jsx(Tv,{row:P,filePath:e.path,fileUrl:R,commenting:s,open:w===E,onOpen:()=>v(E),onClose:()=>v(null)}),o&&((S=u.get(E))==null?void 0:S.map(T=>n.jsx(Wp,{thread:T,ctx:o},T.id)))]},E)})]})})})]})}function Av({files:e,commenting:s,threadCtx:a}){const o=x.useMemo(()=>{const i=new Map;for(const u of(a==null?void 0:a.threads)??[]){const d=i.get(u.path)??[];d.push(u),i.set(u.path,d)}return i},[a==null?void 0:a.threads]);return n.jsx("div",{children:e.map(i=>n.jsx(Pv,{file:i,commenting:s??null,threads:o.get(i.path)??[],threadCtx:a??null},i.path))})}function $v({file:e}){const s=e.path.split("/"),a=s.at(-1),o=s.slice(0,-1).join("/");return n.jsxs("a",{href:e.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"group flex items-center gap-3 px-4 py-1.5 text-sm hover:bg-gray-50 dark:hover:bg-gray-900",title:`${e.path} — view this file's diff on GitHub`,children:[n.jsxs("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:[o&&n.jsxs("span",{className:"text-gray-400",children:[o,"/"]}),n.jsx("span",{className:"font-semibold",children:a})]}),n.jsxs("span",{className:"shrink-0 font-mono text-xs tabular-nums",children:[n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions]})," ",n.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions]})]}),n.jsx("span",{className:"shrink-0 text-gray-300 group-hover:text-blue-500 dark:text-gray-600",children:"↗"})]})}function Qc({pr:e,extra:s}){return n.jsxs("div",{className:"flex items-center gap-3 border-b border-gray-200 px-4 py-2 text-xs dark:border-gray-800",children:[n.jsxs("span",{className:"font-semibold text-gray-600 dark:text-gray-300",children:[e.changedFilesCount," file",e.changedFilesCount===1?"":"s"," changed"]}),n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions.toLocaleString()]}),n.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions.toLocaleString()]}),s,n.jsx("a",{href:`${e.githubUrl}/files`,target:"_blank",rel:"noreferrer noopener",className:"ml-auto text-blue-500 hover:underline",children:"Files changed ↗"})]})}function Mv({pr:e,focusThreadId:s,onThreadShown:a}){const{data:o,isLoading:i,isError:u}=jy(e.id),{data:d}=$n(),p=x.useMemo(()=>ln(d),[d]),m={threads:e.threads.filter(v=>!v.isResolved||v.id===s),usersById:p,prUrl:e.githubUrl,focusThreadId:s??null,onThreadShown:a};if(e.files.length===0&&e.changedFilesCount===0&&!i)return n.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500",children:"No file changes on this PR."});if(i)return n.jsxs("div",{children:[n.jsx(Qc,{pr:e}),n.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500",children:"Loading diff…"})]});const g=(o==null?void 0:o.files)??[];return!u&&g.length>0?n.jsxs("div",{children:[n.jsx(Qc,{pr:e,extra:m.threads.length>0?n.jsxs("span",{className:"rounded bg-amber-500/15 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300",children:[m.threads.length," inline thread",m.threads.length===1?"":"s"]}):void 0}),n.jsx(Av,{files:g,commenting:{prId:e.id},threadCtx:m}),(o==null?void 0:o.truncated)&&n.jsxs("div",{className:"px-4 py-2 text-xs text-gray-400",children:["Large diff — not all files are shown."," ",n.jsx("a",{href:`${e.githubUrl}/files`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"View all on GitHub ↗"})]})]}):n.jsxs("div",{children:[n.jsx(Qc,{pr:e}),n.jsxs("div",{className:"px-4 py-2 text-xs text-gray-400",children:[u?"The full diff couldn’t be loaded — showing the changed-file list.":"Inline diffs aren’t available for this PR — showing the changed-file list."," ",n.jsx("a",{href:`${e.githubUrl}/files`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"View on GitHub ↗"})]}),e.files.length>0&&n.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-800",children:e.files.map(v=>n.jsx($v,{file:v},v.path))})]})}function Ku({prId:e,initialBody:s,autoFocus:a,onCancel:o,onDone:i}){const[u,d]=x.useState(s??""),p=Ry(e),m=p.error instanceof Gt?p.error.message:p.error?"Failed to post the comment.":null,g=()=>{const w=u.trim();!w||p.isPending||p.mutate(w,{onSuccess:()=>{d(""),i==null||i()}})};return n.jsxs("div",{className:"space-y-1.5 px-3 pb-3",children:[n.jsx(ei,{prId:e,value:u,onChange:d,rows:3,autoFocus:a,placeholder:"Add a comment to this PR (markdown, @ to mention)…",className:"w-full rounded border border-gray-300 bg-white px-2 py-1.5 text-sm dark:border-gray-700 dark:bg-gray-900"}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("button",{type:"button",onClick:g,disabled:p.isPending||u.trim().length===0,className:"whitespace-nowrap rounded border border-blue-400 px-2 py-0.5 text-sm text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",children:p.isPending?"Commenting…":o?"Reply":"Comment"}),o&&n.jsx("button",{type:"button",onClick:()=>{p.reset(),o()},disabled:p.isPending,className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-sm hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:"Cancel"}),m&&n.jsx("span",{className:"text-xs text-red-500",children:m})]})]})}const Fv=x.lazy(()=>Eu(()=>import("./ClaudeReviewTab-CBzfgOYF.js"),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.ClaudeReviewTab}))),Lv=x.lazy(()=>Eu(()=>import("./AiFixTab-DMoHaevz.js"),__vite__mapDeps([7,1,2,3,4,5,6])).then(e=>({default:e.AiFixTab})));function _v(e){if(!e)return null;const s=[];return e.comments>0&&s.push(`${e.comments} new comment${e.comments===1?"":"s"}`),e.reviews>0&&s.push(`${e.reviews} new review${e.reviews===1?"":"s"}`),e.commits>0&&s.push(`${e.commits} new commit${e.commits===1?"":"s"}`),s.length?s.join(" · "):null}function rl(e,s){const a=e.authorId!=null?s.get(e.authorId):void 0;return{id:e.id,number:e.number,title:e.title,repoFullName:e.repoFullName,authorLogin:(a==null?void 0:a.githubLogin)??null,authorDisplayName:(a==null?void 0:a.displayName)??null,authorAvatarUrl:(a==null?void 0:a.avatarUrl)??null}}const Ov={overview:"Overview",threads:"Threads",activity:"Activity",changes:"Changes",claude_review:"Claude Review",ai_fix:"AI Analysis and Fix"};function Dv(e){var a;const s=[];s.push({key:"opened",time:e.openedAt,label:"opened this PR",actorId:e.authorId,href:e.githubUrl,event:{type:"pr_opened",refId:null}});for(const o of e.commits)s.push({key:`commit:${o.id}`,time:o.committedAt,label:"pushed a commit",actorId:o.authorId??o.committerId,detail:(a=o.message)==null?void 0:a.split(`
41
+ `)[0],href:`${e.githubUrl}/commits/${o.sha}`,event:{type:"commit_pushed",refId:o.id}});for(const o of e.reviews)s.push({key:`review:${o.id}`,time:o.submittedAt,label:`reviewed (${o.state.replace("_"," ")})`,actorId:o.authorId,detail:o.body??void 0,href:o.url??e.githubUrl,event:{type:"review_submitted",refId:o.id}});for(const o of e.comments)s.push({key:`comment:${o.id}`,time:o.createdAt,label:"commented",actorId:o.authorId,detail:o.body,href:o.url??e.githubUrl,event:{type:"pr_comment",refId:o.id}});return e.mergedAt?s.push({key:"merged",time:e.mergedAt,label:"merged this PR",actorId:e.authorId,href:e.githubUrl,event:{type:"pr_merged",refId:null}}):e.closedAt&&s.push({key:"closed",time:e.closedAt,label:"closed this PR",actorId:e.authorId,href:e.githubUrl,event:{type:"pr_closed",refId:null}}),s.sort((o,i)=>i.time.localeCompare(o.time))}function Bv({pr:e,usersById:s,since:a,onClearSince:o,focusEvent:i,onConsumed:u}){const d=x.useMemo(()=>Dv(e),[e]),p=a?d.filter(y=>y.time>a):d,m=te(y=>y.showEventOnTimeline),g=x.useRef(new Map),[w,v]=x.useState(null);return x.useEffect(()=>{var j;if(!i)return;const y=d.find(R=>R.event.type===i.type&&R.event.refId===i.refId);u(),y&&((j=g.current.get(y.key))==null||j.scrollIntoView({behavior:"smooth",block:"center"}),v(y.key))},[i,d,u]),x.useEffect(()=>{if(w==null)return;const y=setTimeout(()=>v(null),1800);return()=>clearTimeout(y)},[w]),n.jsxs("ul",{className:"divide-y divide-gray-100 dark:divide-gray-800",children:[a&&n.jsxs("li",{className:"flex items-center gap-2 bg-sky-500/5 px-3 py-1.5 text-xs text-sky-600 dark:text-sky-400",children:[n.jsxs("span",{children:["Showing ",p.length," since you last looked"]}),n.jsx("button",{type:"button",onClick:o,className:"ml-auto text-gray-400 hover:text-gray-600",children:"show all"})]}),p.map(y=>{const j=y.actorId!=null?s.get(y.actorId):void 0;return n.jsxs("li",{ref:R=>{R?g.current.set(y.key,R):g.current.delete(y.key)},className:`flex items-start gap-2 px-3 py-2 text-sm ${y.key===w?"activity-flash":""}`,children:[n.jsx(ht,{user:j,size:20}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[n.jsx(sn,{user:j,fallbackId:y.actorId,repoId:e.repoId,className:"font-medium"}),n.jsx("span",{className:"text-gray-500",children:y.label}),n.jsxs("span",{className:"text-xs text-gray-400",title:Ra(y.time),children:["· ",Ra(y.time)]})]}),y.detail&&n.jsx("div",{className:"mt-0.5 truncate text-xs text-gray-500",title:y.detail,children:y.detail.split(`
42
+ `)[0]}),n.jsxs("div",{className:"mt-1 flex items-center gap-3 text-xs",children:[n.jsx("button",{type:"button",onClick:()=>m(e.id,y.time,y.event),className:"text-blue-500 hover:underline",title:"Show this event on the timeline",children:"Show"}),y.href&&n.jsx("a",{href:y.href,target:"_blank",rel:"noreferrer noopener",className:"text-gray-400 hover:text-blue-500",children:"Open on GitHub ↗"})]})]})]},y.key)})]})}function zv({pr:e,usersById:s,viewedSince:a,focusCommentId:o,selectedCommentId:i,onFocusConsumed:u}){const d=x.useRef(new Map),[p,m]=x.useState(null),[g,w]=x.useState(null);if(x.useEffect(()=>{if(o==null)return;u();const y=d.current.get(o);y&&(y.scrollIntoView({behavior:"smooth",block:"center"}),m(o))},[o,u]),x.useEffect(()=>{if(p==null)return;const y=setTimeout(()=>m(null),1800);return()=>clearTimeout(y)},[p]),e.comments.length===0)return n.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500",children:"No PR comments on this PR."});const v=[...e.comments].sort((y,j)=>y.createdAt.localeCompare(j.createdAt));return n.jsx("div",{className:"space-y-2 px-3 pb-3",children:v.map(y=>{var P;const j=y.authorId!=null?s.get(y.authorId):void 0,R=wh(y.createdAt,a);return n.jsxs("div",{ref:E=>{E?d.current.set(y.id,E):d.current.delete(y.id)},className:`rounded-md border px-2.5 py-2 ${y.id===i?"border-amber-400 bg-amber-400/5":"border-gray-200 dark:border-gray-800"} ${R?"comment-new":""} ${y.id===p?"activity-flash":""}`,children:[n.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[n.jsx(yu,{prId:e.id,at:y.createdAt,event:{type:"pr_comment",refId:y.id},title:"Show this comment on the timeline"}),n.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"·"}),n.jsx(ht,{user:j,size:18}),n.jsx(sn,{user:j,fallbackId:y.authorId,repoId:e.repoId,className:"font-semibold"}),n.jsx("span",{className:"text-gray-400",title:Ra(y.createdAt),children:St(y.createdAt)}),R&&n.jsx(bh,{})]}),n.jsx("div",{className:"mt-1 text-sm",children:n.jsx(cr,{children:y.body})}),n.jsxs("div",{className:"mt-2 flex items-center gap-3 pl-2 text-[11px]",children:[g!==y.id&&n.jsx("button",{type:"button",onClick:()=>w(y.id),className:"text-blue-500 hover:underline",children:"Reply"}),y.url&&n.jsx("a",{href:y.url,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"↗ View comment on GitHub"})]}),g===y.id&&n.jsx("div",{className:"mt-2",children:n.jsx(Ku,{prId:e.id,initialBody:ch(y.body,((P=s.get(y.authorId??-1))==null?void 0:P.githubLogin)??null),autoFocus:!0,onCancel:()=>w(null),onDone:()=>w(null)})})]},y.id)})})}function Nh({prId:e,selectedThreadId:s}){var Pe;const{data:a,isLoading:o,error:i}=Zo(e),{data:u}=Mr(),{aiAnalysis:d,aiFix:p,claudeReview:m}=yn(),g=d||p,[w,v]=x.useState("overview"),[y,j]=x.useState(null),R=Be(),P=te(se=>se.openPrFocused),E=De(se=>se.openPrFocusTab),S=De(se=>se.openPrDetailTab),T=te(se=>se.activityFocus),N=te(se=>se.consumeActivityFocus),b=x.useMemo(()=>T&&a&&T.prId===a.id?{type:T.type,refId:T.refId}:null,[T,a]),I=te(se=>se.commentFocus),$=te(se=>se.consumeCommentFocus),L=te(se=>se.selectedCommentId),q=te(se=>se.claudeTabFocus),Q=te(se=>se.consumeClaudeTabFocus),_=te(se=>se.changesThreadFocus),Y=te(se=>se.consumeChangesThreadFocus),[X,B]=x.useState(null),O=te(se=>se.aiFixTabFocus),H=I&&a&&I.prId===a.id?I.commentId:null,ee=De(se=>se.syncMeta);x.useEffect(()=>{s!=null&&v("threads")},[s]);const ce=te(se=>se.threadBotFilter);x.useEffect(()=>{ce!=null&&v("threads")},[ce]),x.useEffect(()=>{b&&(v("activity"),j(null))},[b]),x.useEffect(()=>{m&&q&&a&&q.prId===a.id&&(v("claude_review"),Q())},[q,a,m,Q]),x.useEffect(()=>{_&&a&&_.prId===a.id&&(v("changes"),B(_.threadId),Y())},[_,a,Y]),x.useEffect(()=>{g&&O&&a&&O.prId===a.id&&v("ai_fix")},[O,a,g]),x.useEffect(()=>{H!=null&&v("overview")},[H]);const C=Ue({mutationFn:se=>ge.markPrViewed(se),onSuccess:()=>{R.invalidateQueries({queryKey:["open-prs"]}),R.invalidateQueries({queryKey:["timeline"]}),R.invalidateQueries({queryKey:["my-turn"]}),R.invalidateQueries({queryKey:["me"]})}}),F=x.useRef(null);x.useEffect(()=>{a&&F.current!==a.id&&(F.current=a.id,C.mutate(a.id))},[a,C]);const K=x.useMemo(()=>ln(a==null?void 0:a.users),[a]);if(x.useEffect(()=>{a!=null&&ee(rl(a,K))},[a,K,ee]),o)return n.jsx("div",{className:"p-4 text-sm text-gray-500",children:"Loading PR…"});if(i||!a)return n.jsx("div",{className:"p-4 text-sm text-red-500",children:i?String(i):"PR not found"});const ae=qx[a.state],ne=a.authorId!=null?K.get(a.authorId):void 0;return n.jsx(mh.Provider,{value:rl(a,K),children:n.jsxs("div",{className:"flex h-full flex-col",children:[n.jsxs("div",{className:"border-b border-gray-200 px-4 py-2 pr-28 dark:border-gray-800",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"rounded px-1.5 py-0.5 text-xs font-semibold text-white",style:{backgroundColor:ae.color},children:a.isDraft?"Draft":ae.label}),n.jsxs("button",{type:"button",onClick:()=>S(rl(a,K)),className:"min-w-0 truncate text-left text-sm font-semibold hover:underline",title:"Open full-screen in its own tab",children:[n.jsxs("span",{className:"text-gray-400",children:["#",a.number]})," ",a.title]}),n.jsx("button",{type:"button",onClick:()=>S(rl(a,K)),className:"shrink-0 rounded p-0.5 text-blue-500 hover:text-blue-600",title:"Open full-screen — this PR in its own tab","aria-label":"Open this PR full-screen in its own tab",children:n.jsx(ph,{size:13})}),n.jsx("button",{type:"button",onClick:()=>P(a.id),className:"shrink-0 rounded p-0.5 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",title:"Show this PR on the timeline","aria-label":"Show this PR on the timeline",children:n.jsx(my,{size:15})}),n.jsx("button",{type:"button",onClick:()=>E(rl(a,K)),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 (✕ on the tab to close)","aria-label":"Focus this PR in its own timeline tab",children:n.jsx(Jo,{size:15})}),n.jsx("a",{href:a.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"shrink-0 rounded p-0.5 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",title:"Open this PR on GitHub","aria-label":"Open this PR on GitHub",children:n.jsx(hy,{size:15})}),a.isStalled&&n.jsx("span",{className:"rounded bg-orange-500/15 px-1.5 py-0.5 text-xs font-medium text-orange-500",title:"Open, no recent commits, and has open threads",children:"Stalled"}),(()=>{const se=_v(a.newSinceLastViewed);return se?n.jsxs("button",{type:"button",onClick:()=>{v("activity"),j(a.lastViewedAt)},className:"ml-auto shrink-0 rounded bg-sky-500/15 px-1.5 py-0.5 text-xs font-medium text-sky-500 hover:bg-sky-500/25",title:"Filter activity to what's new since you last looked",children:["👁 ",se]}):null})()]}),n.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs text-gray-500",children:[n.jsx(ht,{user:ne,size:16}),n.jsx(sn,{user:ne,fallbackId:a.authorId,repoId:a.repoId}),n.jsx("span",{children:"·"}),n.jsxs("span",{className:"inline-flex items-center gap-1",children:[a.repoFullName,((Pe=u==null?void 0:u.find(se=>se.id===a.repoId))==null?void 0:Pe.inboxWatch)&&n.jsx(Bu,{size:11})]}),n.jsx("span",{children:"·"}),n.jsxs("span",{children:["opened ",St(a.openedAt)]}),a.changedFilesCount>0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsxs("button",{type:"button",onClick:()=>v("changes"),className:"inline-flex shrink-0 items-center gap-1 font-medium",title:"View the files changed by this PR",children:[n.jsxs("span",{className:"text-gray-500",children:[a.changedFilesCount," file",a.changedFilesCount===1?"":"s"]}),n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",a.additions.toLocaleString()]}),n.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",a.deletions.toLocaleString()]})]})]})]})]}),n.jsx("div",{className:"flex gap-1 border-b border-gray-200 px-3 dark:border-gray-800",children:["overview","threads","activity","changes",...m?["claude_review"]:[],...g?["ai_fix"]:[]].map(se=>{const Z=a.checkRuns.filter(je=>je.state==="failure"||je.state==="error").length;return n.jsxs("button",{type:"button",onClick:()=>v(se),className:`-mb-px border-b-2 px-3 py-1.5 text-xs ${w===se?"border-blue-500 text-blue-500":"border-transparent text-gray-500 hover:text-gray-700"}`,children:[Ov[se],se==="overview"&&Z>0&&n.jsx("span",{className:"ml-1 text-red-500",title:`${Z} failing`,children:"●"}),se==="threads"&&a.threads.length>0&&n.jsx("span",{className:"ml-1 opacity-60",title:`${a.threads.length} threads`,children:a.threads.length}),se==="changes"&&a.changedFilesCount>0&&n.jsx("span",{className:"ml-1 opacity-60",title:`${a.changedFilesCount} files changed`,children:a.changedFilesCount})]},se)})}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:n.jsx(x.Suspense,{fallback:n.jsx("div",{className:"px-4 py-6 text-sm text-gray-400",children:"Loading…"}),children:w==="overview"?n.jsxs("div",{children:[n.jsx(yv,{pr:a,usersById:K}),n.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-800",children:[n.jsxs("div",{className:"px-4 pb-1 pt-2 text-xs font-semibold uppercase tracking-wide text-gray-400",children:["PR comments",a.comments.length>0&&n.jsxs("span",{className:"ml-1 font-normal opacity-70",children:["· ",a.comments.length]})]}),n.jsx(zv,{pr:a,usersById:K,viewedSince:a.lastViewedAt,focusCommentId:H,selectedCommentId:L,onFocusConsumed:$}),n.jsx(Ku,{prId:a.id})]})]}):w==="threads"?n.jsx(ev,{threads:a.threads,usersById:K,prUrl:a.githubUrl,prId:a.id,repoId:a.repoId,selectedThreadId:s,viewedSince:a.lastViewedAt,botFilter:ce}):w==="activity"?n.jsx(Bv,{pr:a,usersById:K,since:y,onClearSince:()=>j(null),focusEvent:b,onConsumed:N}):w==="changes"?n.jsx(Mv,{pr:a,focusThreadId:X,onThreadShown:()=>B(null)}):w==="ai_fix"?n.jsx(Lv,{pr:a}):n.jsx(Fv,{pr:a,usersById:K})})})]})})}const qv=["untouched","replied_unresolved","likely_addressed","resolved"],Uv={open:"Open",merged:"Merged",closed:"Closed"};function Kv(e){const s=ur[e.ciStatus];return s?`<span class="pr-ci pr-ci-lead" style="background:${s.color}" title="${s.label}"></span>`:""}function Hv(e){return e?`${e.avatarUrl?`<img class="pr-avatar" src="${kt(e.avatarUrl)}" width="14" height="14" loading="lazy" alt="" />`:""}<span class="pr-author">${kt(e.label)}</span>`:""}function Wv(e,s={}){const{author:a}=s,o=e.isDraft?'<span class="pr-draft-tag">draft</span>':"";return'<div class="pr-bar-inner">'+(e.state==="open"?Kv(e):"")+`<span class="pr-num">#${e.number}</span>`+Hv(a)+`${o}<span class="pr-title">${kt(e.title)}</span></div>`}function Vp(e,s,a=""){return`<div class="pr-tt-row ${a}"><span class="pr-tt-dot" style="background:${e}"></span><span>${s}</span></div>`}function Vv(e,s={}){const{author:a,hasComments:o=!1}=s,i=[];i.push(`<div class="pr-tt-title">#${e.number} ${kt(e.title)}</div>`);const u=[];a!=null&&a.label&&u.push(kt(a.label)),u.push(Uv[e.state]),e.isDraft&&u.push("draft"),e.isStalled&&u.push("stalled"),i.push(`<div class="pr-tt-meta">${u.join(" · ")}</div>`);const d=ur[e.ciStatus];d&&i.push(Vp(d.color,d.label));const p=Xo(e.mergeable,e.mergeStateStatus);p&&i.push(`<div class="pr-tt-row pr-tt-warn"><span class="pr-tt-warn-icon">⚠</span><span>merge: ${kt(p)}</span></div>`);const m=qv.filter(g=>e.threadCounts[g]>0);if(m.length>0){i.push('<div class="pr-tt-section">Review threads</div>');for(const g of m){const w=jt[g];i.push(Vp(w.color,`${w.label}: ${e.threadCounts[g]}`))}}else o&&i.push('<div class="pr-tt-row pr-tt-quiet">Has comments</div>');return`<div class="pr-tt">${i.join("")}</div>`}function Qv(e,s=!1){const a=["pr-bar",`pr-${e.state}`];return e.state==="open"?a.push("pr-emph"):a.push("pr-muted"),e.isDraft&&a.push("pr-draft"),e.isStalled&&a.push("pr-stalled"),e.reviewRequestedFromMe&&a.push("pr-myturn"),e.state==="open"&&(e.isChangesRequested?a.push("pr-changes-requested"):e.isApproved?a.push("pr-approved"):s&&a.push("pr-commented")),a.join(" ")}function Gv(){return{comments:0,reviews:0,prsOpen:0,prsMerged:0,prsClosed:0}}function Yv(e,s){const a=new Map,o=i=>{let u=a.get(i);return u||(u=Gv(),a.set(i,u)),u};for(const i of e)i.actorId!=null&&(i.type==="pr_comment"||i.type==="review_comment"?o(i.actorId).comments++:i.type==="review_submitted"&&o(i.actorId).reviews++);for(const i of s){if(i.authorId==null)continue;const u=o(i.authorId);i.state==="open"?u.prsOpen++:i.state==="merged"?u.prsMerged++:u.prsClosed++}return a}const Xv='<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><path fill="#8957e5" d="M8 .8 2.2 2.9v4.2c0 3.3 2.5 6.4 5.8 7.3 3.3-.9 5.8-4 5.8-7.3V2.9L8 .8Z"/><path d="M5.2 8 7.1 9.9 10.9 6" fill="none" stroke="#fff" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>',Jv='<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><rect x="2" y="9" width="3" height="5" rx="0.5" fill="currentColor"/><rect x="6.5" y="6" width="3" height="8" rx="0.5" fill="currentColor"/><rect x="11" y="3" width="3" height="11" rx="0.5" fill="currentColor"/></svg>';function Zv(e,s,a,o=!1,i,u=!1){const d=ft(e,s),p=e!=null&&e.avatarUrl?`<img class="tl-user-avatar" src="${kt(e.avatarUrl)}" width="18" height="18" loading="lazy" referrerpolicy="no-referrer" alt="" />`:`<span class="tl-user-avatar tl-user-avatar-fallback">${kt((d[0]??"?").toUpperCase())}</span>`,m=e!=null&&e.githubLogin?`<a class="tl-user-name tl-user-name-link" href="${kt(Du(e.githubLogin))}" target="_blank" rel="noreferrer noopener" title="${kt(`@${e.githubLogin} on GitHub`)}" onclick="event.stopPropagation()">${kt(d)}</a>`:`<span class="tl-user-name">${kt(d)}</span>`,g=o?`<span class="tl-merger" title="Has merge rights — has merged a PR in this repo">${Xv}</span>`:"",w=i?`<button type="button" class="tl-stats-toggle" data-stats-gid="${kt(i)}" title="Show metrics" aria-label="Show contributor metrics">${Jv}</button>`:"",v=u?"Expand row":"Collapse row";return'<div class="tl-user">'+(i?`<button type="button" class="tl-collapse-caret" data-collapse-gid="${kt(i)}" title="${kt(v)}" aria-label="${kt(v)}">${u?"▸":"▾"}</button>`:"")+p+`<span class="tl-user-main"><span class="tl-user-name-line">${m}${g}${w}</span></span></div>`}function ni(){return typeof window<"u"}function Ia(e){return Hu(e)?(e.nodeName||"").toLowerCase():"#document"}function xn(e){var s;return(e==null||(s=e.ownerDocument)==null?void 0:s.defaultView)||window}function dr(e){var s;return(s=(Hu(e)?e.ownerDocument:e.document)||window.document)==null?void 0:s.documentElement}function Hu(e){return ni()?e instanceof Node||e instanceof xn(e).Node:!1}function dt(e){return ni()?e instanceof Element||e instanceof xn(e).Element:!1}function fr(e){return ni()?e instanceof HTMLElement||e instanceof xn(e).HTMLElement:!1}function vu(e){return!ni()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof xn(e).ShadowRoot}function xl(e){const{overflow:s,overflowX:a,overflowY:o,display:i}=An(e);return/auto|scroll|overlay|hidden|clip/.test(s+o+a)&&i!=="inline"&&i!=="contents"}function eb(e){return/^(table|td|th)$/.test(Ia(e))}function ri(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const tb=/transform|translate|scale|rotate|perspective|filter/,nb=/paint|layout|strict|content/,As=e=>!!e&&e!=="none";let Gc;function Wu(e){const s=dt(e)?An(e):e;return As(s.transform)||As(s.translate)||As(s.scale)||As(s.rotate)||As(s.perspective)||!si()&&(As(s.backdropFilter)||As(s.filter))||tb.test(s.willChange||"")||nb.test(s.contain||"")}function rb(e){let s=$r(e);for(;fr(s)&&!Ar(s);){if(Wu(s))return s;if(ri(s))return null;s=$r(s)}return null}function si(){return Gc==null&&(Gc=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Gc}function Ar(e){return/^(html|body|#document)$/.test(Ia(e))}function An(e){return xn(e).getComputedStyle(e)}function ai(e){return dt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $r(e){if(Ia(e)==="html")return e;const s=e.assignedSlot||e.parentNode||vu(e)&&e.host||dr(e);return vu(s)?s.host:s}function Sh(e){const s=$r(e);return Ar(s)?e.ownerDocument?e.ownerDocument.body:e.body:fr(s)&&xl(s)?s:Sh(s)}function ls(e,s,a){var o;s===void 0&&(s=[]),a===void 0&&(a=!0);const i=Sh(e),u=i===((o=e.ownerDocument)==null?void 0:o.body),d=xn(i);if(u){const p=bu(d);return s.concat(d,d.visualViewport||[],xl(i)?i:[],p&&a?ls(p):[])}else return s.concat(i,ls(i,[],a))}function bu(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const zo=Math.min,Fs=Math.max,qo=Math.round,Ro=Math.floor,ir=e=>({x:e,y:e}),sb={left:"right",right:"left",bottom:"top",top:"bottom"};function Qp(e,s,a){return Fs(e,zo(s,a))}function li(e,s){return typeof e=="function"?e(s):e}function Ds(e){return e.split("-")[0]}function oi(e){return e.split("-")[1]}function Ch(e){return e==="x"?"y":"x"}function Rh(e){return e==="y"?"height":"width"}function as(e){const s=e[0];return s==="t"||s==="b"?"y":"x"}function Ih(e){return Ch(as(e))}function ab(e,s,a){a===void 0&&(a=!1);const o=oi(e),i=Ih(e),u=Rh(i);let d=i==="x"?o===(a?"end":"start")?"right":"left":o==="start"?"bottom":"top";return s.reference[u]>s.floating[u]&&(d=Uo(d)),[d,Uo(d)]}function lb(e){const s=Uo(e);return[wu(e),s,wu(s)]}function wu(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Gp=["left","right"],Yp=["right","left"],ob=["top","bottom"],ib=["bottom","top"];function cb(e,s,a){switch(e){case"top":case"bottom":return a?s?Yp:Gp:s?Gp:Yp;case"left":case"right":return s?ob:ib;default:return[]}}function ub(e,s,a,o){const i=oi(e);let u=cb(Ds(e),a==="start",o);return i&&(u=u.map(d=>d+"-"+i),s&&(u=u.concat(u.map(wu)))),u}function Uo(e){const s=Ds(e);return sb[s]+e.slice(s.length)}function db(e){return{top:0,right:0,bottom:0,left:0,...e}}function fb(e){return typeof e!="number"?db(e):{top:e,right:e,bottom:e,left:e}}function Ko(e){const{x:s,y:a,width:o,height:i}=e;return{width:o,height:i,top:a,left:s,right:s+o,bottom:a+i,x:s,y:a}}/*!
43
43
  * tabbable 6.4.0
44
44
  * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
45
- */var fb=["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] *)"],ku=fb.join(","),Th=typeof Element>"u",fl=Th?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Ko=!Th&&Element.prototype.getRootNode?function(e){var s;return e==null||(s=e.getRootNode)===null||s===void 0?void 0:s.call(e)}:function(e){return e==null?void 0:e.ownerDocument},Ho=function(s,a){var o;a===void 0&&(a=!0);var i=s==null||(o=s.getAttribute)===null||o===void 0?void 0:o.call(s,"inert"),u=i===""||i==="true",d=u||a&&s&&(typeof s.closest=="function"?s.closest("[inert]"):Ho(s.parentNode));return d},pb=function(s){var a,o=s==null||(a=s.getAttribute)===null||a===void 0?void 0:a.call(s,"contenteditable");return o===""||o==="true"},mb=function(s,a,o){if(Ho(s))return[];var i=Array.prototype.slice.apply(s.querySelectorAll(ku));return a&&fl.call(s,ku)&&i.unshift(s),i=i.filter(o),i},ju=function(s,a,o){for(var i=[],u=Array.from(s);u.length;){var d=u.shift();if(!Ho(d,!1))if(d.tagName==="SLOT"){var p=d.assignedElements(),m=p.length?p:d.children,g=ju(m,!0,o);o.flatten?i.push.apply(i,g):i.push({scopeParent:d,candidates:g})}else{var y=fl.call(d,ku);y&&o.filter(d)&&(a||!s.includes(d))&&i.push(d);var b=d.shadowRoot||typeof o.getShadowRoot=="function"&&o.getShadowRoot(d),v=!Ho(b,!1)&&(!o.shadowRootFilter||o.shadowRootFilter(d));if(b&&v){var N=ju(b===!0?d.children:b.children,!0,o);o.flatten?i.push.apply(i,N):i.push({scopeParent:d,candidates:N})}else u.unshift.apply(u,d.children)}}return i},Eh=function(s){return!isNaN(parseInt(s.getAttribute("tabindex"),10))},Ph=function(s){if(!s)throw new Error("No node provided");return s.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(s.tagName)||pb(s))&&!Eh(s)?0:s.tabIndex},hb=function(s,a){var o=Ph(s);return o<0&&a&&!Eh(s)?0:o},gb=function(s,a){return s.tabIndex===a.tabIndex?s.documentOrder-a.documentOrder:s.tabIndex-a.tabIndex},Ah=function(s){return s.tagName==="INPUT"},xb=function(s){return Ah(s)&&s.type==="hidden"},yb=function(s){var a=s.tagName==="DETAILS"&&Array.prototype.slice.apply(s.children).some(function(o){return o.tagName==="SUMMARY"});return a},vb=function(s,a){for(var o=0;o<s.length;o++)if(s[o].checked&&s[o].form===a)return s[o]},bb=function(s){if(!s.name)return!0;var a=s.form||Ko(s),o=function(p){return a.querySelectorAll('input[type="radio"][name="'+p+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=o(window.CSS.escape(s.name));else try{i=o(s.name)}catch(d){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",d.message),!1}var u=vb(i,s.form);return!u||u===s},wb=function(s){return Ah(s)&&s.type==="radio"},kb=function(s){return wb(s)&&!bb(s)},jb=function(s){var a,o=s&&Ko(s),i=(a=o)===null||a===void 0?void 0:a.host,u=!1;if(o&&o!==s){var d,p,m;for(u=!!((d=i)!==null&&d!==void 0&&(p=d.ownerDocument)!==null&&p!==void 0&&p.contains(i)||s!=null&&(m=s.ownerDocument)!==null&&m!==void 0&&m.contains(s));!u&&i;){var g,y,b;o=Ko(i),i=(g=o)===null||g===void 0?void 0:g.host,u=!!((y=i)!==null&&y!==void 0&&(b=y.ownerDocument)!==null&&b!==void 0&&b.contains(i))}}return u},Xp=function(s){var a=s.getBoundingClientRect(),o=a.width,i=a.height;return o===0&&i===0},Nb=function(s,a){var o=a.displayCheck,i=a.getShadowRoot;if(o==="full-native"&&"checkVisibility"in s){var u=s.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!u}if(getComputedStyle(s).visibility==="hidden")return!0;var d=fl.call(s,"details>summary:first-of-type"),p=d?s.parentElement:s;if(fl.call(p,"details:not([open]) *"))return!0;if(!o||o==="full"||o==="full-native"||o==="legacy-full"){if(typeof i=="function"){for(var m=s;s;){var g=s.parentElement,y=Ko(s);if(g&&!g.shadowRoot&&i(g)===!0)return Xp(s);s.assignedSlot?s=s.assignedSlot:!g&&y!==s.ownerDocument?s=y.host:s=g}s=m}if(jb(s))return!s.getClientRects().length;if(o!=="legacy-full")return!0}else if(o==="non-zero-area")return Xp(s);return!1},Sb=function(s){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(s.tagName))for(var a=s.parentElement;a;){if(a.tagName==="FIELDSET"&&a.disabled){for(var o=0;o<a.children.length;o++){var i=a.children.item(o);if(i.tagName==="LEGEND")return fl.call(a,"fieldset[disabled] *")?!0:!i.contains(s)}return!0}a=a.parentElement}return!1},Cb=function(s,a){return!(a.disabled||xb(a)||Nb(a,s)||yb(a)||Sb(a))},Jp=function(s,a){return!(kb(a)||Ph(a)<0||!Cb(s,a))},Rb=function(s){var a=parseInt(s.getAttribute("tabindex"),10);return!!(isNaN(a)||a>=0)},$h=function(s){var a=[],o=[];return s.forEach(function(i,u){var d=!!i.scopeParent,p=d?i.scopeParent:i,m=hb(p,d),g=d?$h(i.candidates):p;m===0?d?a.push.apply(a,g):a.push(p):o.push({documentOrder:u,tabIndex:m,item:i,isScope:d,content:g})}),o.sort(gb).reduce(function(i,u){return u.isScope?i.push.apply(i,u.content):i.push(u.content),i},[]).concat(a)},Mh=function(s,a){a=a||{};var o;return a.getShadowRoot?o=ju([s],a.includeContainer,{filter:Jp.bind(null,a),flatten:!1,getShadowRoot:a.getShadowRoot,shadowRootFilter:Rb}):o=mb(s,a.includeContainer,Jp.bind(null,a)),$h(o)};function Ib(){return/apple/i.test(navigator.vendor)}function Tb(e){let s=e.activeElement;for(;((a=s)==null||(a=a.shadowRoot)==null?void 0:a.activeElement)!=null;){var a;s=s.shadowRoot.activeElement}return s}function Nu(e,s){if(!e||!s)return!1;const a=s.getRootNode==null?void 0:s.getRootNode();if(e.contains(s))return!0;if(a&&vu(a)){let o=s;for(;o;){if(e===o)return!0;o=o.parentNode||o.host}}return!1}function sl(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Yc(e,s){if(s==null)return!1;if("composedPath"in e)return e.composedPath().includes(s);const a=e;return a.target!=null&&s.contains(a.target)}function Eb(e){return e.matches("html,body")}function pl(e){return(e==null?void 0:e.ownerDocument)||document}function $o(e,s,a){return a===void 0&&(a=!0),e.filter(i=>{var u;return i.parentId===s&&(!a||((u=i.context)==null?void 0:u.open))}).flatMap(i=>[i,...$o(e,i.id,a)])}function Pb(e){return"nativeEvent"in e}var Ab=typeof document<"u",$b=function(){},Ls=Ab?x.useLayoutEffect:$b;const Mb={...Gm},Fb=Mb.useInsertionEffect,Lb=Fb||(e=>e());function Na(e){const s=x.useRef(()=>{});return Lb(()=>{s.current=e}),x.useCallback(function(){for(var a=arguments.length,o=new Array(a),i=0;i<a;i++)o[i]=arguments[i];return s.current==null?void 0:s.current(...o)},[])}const Fh=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Lh(e,s){const a=Mh(e,Fh()),o=a.length;if(o===0)return;const i=Tb(pl(e)),u=a.indexOf(i),d=u===-1?s===1?0:o-1:u+s;return a[d]}function _b(e){return Lh(pl(e).body,1)||e}function Ob(e){return Lh(pl(e).body,-1)||e}function Xc(e,s){const a=s||e.currentTarget,o=e.relatedTarget;return!o||!Nu(a,o)}function Db(e){Mh(e,Fh()).forEach(a=>{a.dataset.tabindex=a.getAttribute("tabindex")||"",a.setAttribute("tabindex","-1")})}function Zp(e){e.querySelectorAll("[data-tabindex]").forEach(a=>{const o=a.dataset.tabindex;delete a.dataset.tabindex,o?a.setAttribute("tabindex",o):a.removeAttribute("tabindex")})}var _h=Ym();function em(e,s,a){let{reference:o,floating:i}=e;const u=as(s),d=Ih(s),p=Rh(d),m=Ds(s),g=u==="y",y=o.x+o.width/2-i.width/2,b=o.y+o.height/2-i.height/2,v=o[p]/2-i[p]/2;let N;switch(m){case"top":N={x:y,y:o.y-i.height};break;case"bottom":N={x:y,y:o.y+o.height};break;case"right":N={x:o.x+o.width,y:b};break;case"left":N={x:o.x-i.width,y:b};break;default:N={x:o.x,y:o.y}}switch(oi(s)){case"start":N[d]-=v*(a&&g?-1:1);break;case"end":N[d]+=v*(a&&g?-1:1);break}return N}async function Bb(e,s){var a;s===void 0&&(s={});const{x:o,y:i,platform:u,rects:d,elements:p,strategy:m}=e,{boundary:g="clippingAncestors",rootBoundary:y="viewport",elementContext:b="floating",altBoundary:v=!1,padding:N=0}=li(s,e),I=db(N),E=p[v?b==="floating"?"reference":"floating":b],w=Uo(await u.getClippingRect({element:(a=await(u.isElement==null?void 0:u.isElement(E)))==null||a?E:E.contextElement||await(u.getDocumentElement==null?void 0:u.getDocumentElement(p.floating)),boundary:g,rootBoundary:y,strategy:m})),R=b==="floating"?{x:o,y:i,width:d.floating.width,height:d.floating.height}:d.reference,S=await(u.getOffsetParent==null?void 0:u.getOffsetParent(p.floating)),j=await(u.isElement==null?void 0:u.isElement(S))?await(u.getScale==null?void 0:u.getScale(S))||{x:1,y:1}:{x:1,y:1},T=Uo(u.convertOffsetParentRelativeRectToViewportRelativeRect?await u.convertOffsetParentRelativeRectToViewportRelativeRect({elements:p,rect:R,offsetParent:S,strategy:m}):R);return{top:(w.top-T.top+I.top)/j.y,bottom:(T.bottom-w.bottom+I.bottom)/j.y,left:(w.left-T.left+I.left)/j.x,right:(T.right-w.right+I.right)/j.x}}const zb=50,qb=async(e,s,a)=>{const{placement:o="bottom",strategy:i="absolute",middleware:u=[],platform:d}=a,p=d.detectOverflow?d:{...d,detectOverflow:Bb},m=await(d.isRTL==null?void 0:d.isRTL(s));let g=await d.getElementRects({reference:e,floating:s,strategy:i}),{x:y,y:b}=em(g,o,m),v=o,N=0;const I={};for(let P=0;P<u.length;P++){const E=u[P];if(!E)continue;const{name:w,fn:R}=E,{x:S,y:j,data:T,reset:M}=await R({x:y,y:b,initialPlacement:o,placement:v,strategy:i,middlewareData:I,rects:g,platform:p,elements:{reference:e,floating:s}});y=S??y,b=j??b,I[w]={...I[w],...T},M&&N<zb&&(N++,typeof M=="object"&&(M.placement&&(v=M.placement),M.rects&&(g=M.rects===!0?await d.getElementRects({reference:e,floating:s,strategy:i}):M.rects),{x:y,y:b}=em(g,v,m)),P=-1)}return{x:y,y:b,placement:v,strategy:i,middlewareData:I}},Ub=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(s){var a,o;const{placement:i,middlewareData:u,rects:d,initialPlacement:p,platform:m,elements:g}=s,{mainAxis:y=!0,crossAxis:b=!0,fallbackPlacements:v,fallbackStrategy:N="bestFit",fallbackAxisSideDirection:I="none",flipAlignment:P=!0,...E}=li(e,s);if((a=u.arrow)!=null&&a.alignmentOffset)return{};const w=Ds(i),R=as(p),S=Ds(p)===p,j=await(m.isRTL==null?void 0:m.isRTL(g.floating)),T=v||(S||!P?[qo(p)]:ab(p)),M=I!=="none";!v&&M&&T.push(...cb(p,P,I,j));const D=[p,...T],U=await m.detectOverflow(s,E),G=[];let L=((o=u.flip)==null?void 0:o.overflows)||[];if(y&&G.push(U[w]),b){const _=sb(i,d,j);G.push(U[_[0]],U[_[1]])}if(L=[...L,{placement:i,overflows:G}],!G.every(_=>_<=0)){var Y,X;const _=(((Y=u.flip)==null?void 0:Y.index)||0)+1,H=D[_];if(H&&(!(b==="alignment"?R!==as(H):!1)||L.every(C=>as(C.placement)===R?C.overflows[0]>0:!0)))return{data:{index:_,overflows:L},reset:{placement:H}};let ee=(X=L.filter(ce=>ce.overflows[0]<=0).sort((ce,C)=>ce.overflows[1]-C.overflows[1])[0])==null?void 0:X.placement;if(!ee)switch(N){case"bestFit":{var B;const ce=(B=L.filter(C=>{if(M){const F=as(C.placement);return F===R||F==="y"}return!0}).map(C=>[C.placement,C.overflows.filter(F=>F>0).reduce((F,K)=>F+K,0)]).sort((C,F)=>C[1]-F[1])[0])==null?void 0:B[0];ce&&(ee=ce);break}case"initialPlacement":ee=p;break}if(i!==ee)return{reset:{placement:ee}}}return{}}}},Kb=new Set(["left","top"]);async function Hb(e,s){const{placement:a,platform:o,elements:i}=e,u=await(o.isRTL==null?void 0:o.isRTL(i.floating)),d=Ds(a),p=oi(a),m=as(a)==="y",g=Kb.has(d)?-1:1,y=u&&m?-1:1,b=li(s,e);let{mainAxis:v,crossAxis:N,alignmentAxis:I}=typeof b=="number"?{mainAxis:b,crossAxis:0,alignmentAxis:null}:{mainAxis:b.mainAxis||0,crossAxis:b.crossAxis||0,alignmentAxis:b.alignmentAxis};return p&&typeof I=="number"&&(N=p==="end"?I*-1:I),m?{x:N*y,y:v*g}:{x:v*g,y:N*y}}const Wb=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(s){var a,o;const{x:i,y:u,placement:d,middlewareData:p}=s,m=await Hb(s,e);return d===((a=p.offset)==null?void 0:a.placement)&&(o=p.arrow)!=null&&o.alignmentOffset?{}:{x:i+m.x,y:u+m.y,data:{...m,placement:d}}}}},Vb=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(s){const{x:a,y:o,placement:i,platform:u}=s,{mainAxis:d=!0,crossAxis:p=!1,limiter:m={fn:w=>{let{x:R,y:S}=w;return{x:R,y:S}}},...g}=li(e,s),y={x:a,y:o},b=await u.detectOverflow(s,g),v=as(Ds(i)),N=Ch(v);let I=y[N],P=y[v];if(d){const w=N==="y"?"top":"left",R=N==="y"?"bottom":"right",S=I+b[w],j=I-b[R];I=Qp(S,I,j)}if(p){const w=v==="y"?"top":"left",R=v==="y"?"bottom":"right",S=P+b[w],j=P-b[R];P=Qp(S,P,j)}const E=m.fn({...s,[N]:I,[v]:P});return{...E,data:{x:E.x-a,y:E.y-o,enabled:{[N]:d,[v]:p}}}}}};function Oh(e){const s=An(e);let a=parseFloat(s.width)||0,o=parseFloat(s.height)||0;const i=fr(e),u=i?e.offsetWidth:a,d=i?e.offsetHeight:o,p=zo(a)!==u||zo(o)!==d;return p&&(a=u,o=d),{width:a,height:o,$:p}}function Vu(e){return dt(e)?e:e.contextElement}function Ca(e){const s=Vu(e);if(!fr(s))return ir(1);const a=s.getBoundingClientRect(),{width:o,height:i,$:u}=Oh(s);let d=(u?zo(a.width):a.width)/o,p=(u?zo(a.height):a.height)/i;return(!d||!Number.isFinite(d))&&(d=1),(!p||!Number.isFinite(p))&&(p=1),{x:d,y:p}}const Qb=ir(0);function Dh(e){const s=xn(e);return!si()||!s.visualViewport?Qb:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function Gb(e,s,a){return s===void 0&&(s=!1),!a||s&&a!==xn(e)?!1:s}function Bs(e,s,a,o){s===void 0&&(s=!1),a===void 0&&(a=!1);const i=e.getBoundingClientRect(),u=Vu(e);let d=ir(1);s&&(o?dt(o)&&(d=Ca(o)):d=Ca(e));const p=Gb(u,a,o)?Dh(u):ir(0);let m=(i.left+p.x)/d.x,g=(i.top+p.y)/d.y,y=i.width/d.x,b=i.height/d.y;if(u){const v=xn(u),N=o&&dt(o)?xn(o):o;let I=v,P=bu(I);for(;P&&o&&N!==I;){const E=Ca(P),w=P.getBoundingClientRect(),R=An(P),S=w.left+(P.clientLeft+parseFloat(R.paddingLeft))*E.x,j=w.top+(P.clientTop+parseFloat(R.paddingTop))*E.y;m*=E.x,g*=E.y,y*=E.x,b*=E.y,m+=S,g+=j,I=xn(P),P=bu(I)}}return Uo({width:y,height:b,x:m,y:g})}function ii(e,s){const a=ai(e).scrollLeft;return s?s.left+a:Bs(dr(e)).left+a}function Bh(e,s){const a=e.getBoundingClientRect(),o=a.left+s.scrollLeft-ii(e,a),i=a.top+s.scrollTop;return{x:o,y:i}}function Yb(e){let{elements:s,rect:a,offsetParent:o,strategy:i}=e;const u=i==="fixed",d=dr(o),p=s?ri(s.floating):!1;if(o===d||p&&u)return a;let m={scrollLeft:0,scrollTop:0},g=ir(1);const y=ir(0),b=fr(o);if((b||!b&&!u)&&((Ia(o)!=="body"||gl(d))&&(m=ai(o)),b)){const N=Bs(o);g=Ca(o),y.x=N.x+o.clientLeft,y.y=N.y+o.clientTop}const v=d&&!b&&!u?Bh(d,m):ir(0);return{width:a.width*g.x,height:a.height*g.y,x:a.x*g.x-m.scrollLeft*g.x+y.x+v.x,y:a.y*g.y-m.scrollTop*g.y+y.y+v.y}}function Xb(e){return Array.from(e.getClientRects())}function Jb(e){const s=dr(e),a=ai(e),o=e.ownerDocument.body,i=Fs(s.scrollWidth,s.clientWidth,o.scrollWidth,o.clientWidth),u=Fs(s.scrollHeight,s.clientHeight,o.scrollHeight,o.clientHeight);let d=-a.scrollLeft+ii(e);const p=-a.scrollTop;return An(o).direction==="rtl"&&(d+=Fs(s.clientWidth,o.clientWidth)-i),{width:i,height:u,x:d,y:p}}const tm=25;function Zb(e,s){const a=xn(e),o=dr(e),i=a.visualViewport;let u=o.clientWidth,d=o.clientHeight,p=0,m=0;if(i){u=i.width,d=i.height;const y=si();(!y||y&&s==="fixed")&&(p=i.offsetLeft,m=i.offsetTop)}const g=ii(o);if(g<=0){const y=o.ownerDocument,b=y.body,v=getComputedStyle(b),N=y.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,I=Math.abs(o.clientWidth-b.clientWidth-N);I<=tm&&(u-=I)}else g<=tm&&(u+=g);return{width:u,height:d,x:p,y:m}}function ew(e,s){const a=Bs(e,!0,s==="fixed"),o=a.top+e.clientTop,i=a.left+e.clientLeft,u=fr(e)?Ca(e):ir(1),d=e.clientWidth*u.x,p=e.clientHeight*u.y,m=i*u.x,g=o*u.y;return{width:d,height:p,x:m,y:g}}function nm(e,s,a){let o;if(s==="viewport")o=Zb(e,a);else if(s==="document")o=Jb(dr(e));else if(dt(s))o=ew(s,a);else{const i=Dh(e);o={x:s.x-i.x,y:s.y-i.y,width:s.width,height:s.height}}return Uo(o)}function zh(e,s){const a=$r(e);return a===s||!dt(a)||Ar(a)?!1:An(a).position==="fixed"||zh(a,s)}function tw(e,s){const a=s.get(e);if(a)return a;let o=ls(e,[],!1).filter(p=>dt(p)&&Ia(p)!=="body"),i=null;const u=An(e).position==="fixed";let d=u?$r(e):e;for(;dt(d)&&!Ar(d);){const p=An(d),m=Wu(d);!m&&p.position==="fixed"&&(i=null),(u?!m&&!i:!m&&p.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||gl(d)&&!m&&zh(e,d))?o=o.filter(y=>y!==d):i=p,d=$r(d)}return s.set(e,o),o}function nw(e){let{element:s,boundary:a,rootBoundary:o,strategy:i}=e;const d=[...a==="clippingAncestors"?ri(s)?[]:tw(s,this._c):[].concat(a),o],p=nm(s,d[0],i);let m=p.top,g=p.right,y=p.bottom,b=p.left;for(let v=1;v<d.length;v++){const N=nm(s,d[v],i);m=Fs(N.top,m),g=Bo(N.right,g),y=Bo(N.bottom,y),b=Fs(N.left,b)}return{width:g-b,height:y-m,x:b,y:m}}function rw(e){const{width:s,height:a}=Oh(e);return{width:s,height:a}}function sw(e,s,a){const o=fr(s),i=dr(s),u=a==="fixed",d=Bs(e,!0,u,s);let p={scrollLeft:0,scrollTop:0};const m=ir(0);function g(){m.x=ii(i)}if(o||!o&&!u)if((Ia(s)!=="body"||gl(i))&&(p=ai(s)),o){const N=Bs(s,!0,u,s);m.x=N.x+s.clientLeft,m.y=N.y+s.clientTop}else i&&g();u&&!o&&i&&g();const y=i&&!o&&!u?Bh(i,p):ir(0),b=d.left+p.scrollLeft-m.x-y.x,v=d.top+p.scrollTop-m.y-y.y;return{x:b,y:v,width:d.width,height:d.height}}function Jc(e){return An(e).position==="static"}function rm(e,s){if(!fr(e)||An(e).position==="fixed")return null;if(s)return s(e);let a=e.offsetParent;return dr(e)===a&&(a=a.ownerDocument.body),a}function qh(e,s){const a=xn(e);if(ri(e))return a;if(!fr(e)){let i=$r(e);for(;i&&!Ar(i);){if(dt(i)&&!Jc(i))return i;i=$r(i)}return a}let o=rm(e,s);for(;o&&Zv(o)&&Jc(o);)o=rm(o,s);return o&&Ar(o)&&Jc(o)&&!Wu(o)?a:o||nb(e)||a}const aw=async function(e){const s=this.getOffsetParent||qh,a=this.getDimensions,o=await a(e.floating);return{reference:sw(e.reference,await s(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function lw(e){return An(e).direction==="rtl"}const ow={convertOffsetParentRelativeRectToViewportRelativeRect:Yb,getDocumentElement:dr,getClippingRect:nw,getOffsetParent:qh,getElementRects:aw,getClientRects:Xb,getDimensions:rw,getScale:Ca,isElement:dt,isRTL:lw};function Uh(e,s){return e.x===s.x&&e.y===s.y&&e.width===s.width&&e.height===s.height}function iw(e,s){let a=null,o;const i=dr(e);function u(){var p;clearTimeout(o),(p=a)==null||p.disconnect(),a=null}function d(p,m){p===void 0&&(p=!1),m===void 0&&(m=1),u();const g=e.getBoundingClientRect(),{left:y,top:b,width:v,height:N}=g;if(p||s(),!v||!N)return;const I=Co(b),P=Co(i.clientWidth-(y+v)),E=Co(i.clientHeight-(b+N)),w=Co(y),S={rootMargin:-I+"px "+-P+"px "+-E+"px "+-w+"px",threshold:Fs(0,Bo(1,m))||1};let j=!0;function T(M){const D=M[0].intersectionRatio;if(D!==m){if(!j)return d();D?d(!1,D):o=setTimeout(()=>{d(!1,1e-7)},1e3)}D===1&&!Uh(g,e.getBoundingClientRect())&&d(),j=!1}try{a=new IntersectionObserver(T,{...S,root:i.ownerDocument})}catch{a=new IntersectionObserver(T,S)}a.observe(e)}return d(!0),u}function Kh(e,s,a,o){o===void 0&&(o={});const{ancestorScroll:i=!0,ancestorResize:u=!0,elementResize:d=typeof ResizeObserver=="function",layoutShift:p=typeof IntersectionObserver=="function",animationFrame:m=!1}=o,g=Vu(e),y=i||u?[...g?ls(g):[],...s?ls(s):[]]:[];y.forEach(w=>{i&&w.addEventListener("scroll",a,{passive:!0}),u&&w.addEventListener("resize",a)});const b=g&&p?iw(g,a):null;let v=-1,N=null;d&&(N=new ResizeObserver(w=>{let[R]=w;R&&R.target===g&&N&&s&&(N.unobserve(s),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var S;(S=N)==null||S.observe(s)})),a()}),g&&!m&&N.observe(g),s&&N.observe(s));let I,P=m?Bs(e):null;m&&E();function E(){const w=Bs(e);P&&!Uh(P,w)&&a(),P=w,I=requestAnimationFrame(E)}return a(),()=>{var w;y.forEach(R=>{i&&R.removeEventListener("scroll",a),u&&R.removeEventListener("resize",a)}),b==null||b(),(w=N)==null||w.disconnect(),N=null,m&&cancelAnimationFrame(I)}}const cw=Wb,uw=Vb,dw=Ub,fw=(e,s,a)=>{const o=new Map,i={platform:ow,...a},u={...i.platform,_c:o};return qb(e,s,{...i,platform:u})};var pw=typeof document<"u",mw=function(){},Mo=pw?x.useLayoutEffect:mw;function Wo(e,s){if(e===s)return!0;if(typeof e!=typeof s)return!1;if(typeof e=="function"&&e.toString()===s.toString())return!0;let a,o,i;if(e&&s&&typeof e=="object"){if(Array.isArray(e)){if(a=e.length,a!==s.length)return!1;for(o=a;o--!==0;)if(!Wo(e[o],s[o]))return!1;return!0}if(i=Object.keys(e),a=i.length,a!==Object.keys(s).length)return!1;for(o=a;o--!==0;)if(!{}.hasOwnProperty.call(s,i[o]))return!1;for(o=a;o--!==0;){const u=i[o];if(!(u==="_owner"&&e.$$typeof)&&!Wo(e[u],s[u]))return!1}return!0}return e!==e&&s!==s}function Hh(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function sm(e,s){const a=Hh(e);return Math.round(s*a)/a}function Zc(e){const s=x.useRef(e);return Mo(()=>{s.current=e}),s}function hw(e){e===void 0&&(e={});const{placement:s="bottom",strategy:a="absolute",middleware:o=[],platform:i,elements:{reference:u,floating:d}={},transform:p=!0,whileElementsMounted:m,open:g}=e,[y,b]=x.useState({x:0,y:0,strategy:a,placement:s,middlewareData:{},isPositioned:!1}),[v,N]=x.useState(o);Wo(v,o)||N(o);const[I,P]=x.useState(null),[E,w]=x.useState(null),R=x.useCallback(C=>{C!==M.current&&(M.current=C,P(C))},[]),S=x.useCallback(C=>{C!==D.current&&(D.current=C,w(C))},[]),j=u||I,T=d||E,M=x.useRef(null),D=x.useRef(null),U=x.useRef(y),G=m!=null,L=Zc(m),Y=Zc(i),X=Zc(g),B=x.useCallback(()=>{if(!M.current||!D.current)return;const C={placement:s,strategy:a,middleware:v};Y.current&&(C.platform=Y.current),fw(M.current,D.current,C).then(F=>{const K={...F,isPositioned:X.current!==!1};_.current&&!Wo(U.current,K)&&(U.current=K,_h.flushSync(()=>{b(K)}))})},[v,s,a,Y,X]);Mo(()=>{g===!1&&U.current.isPositioned&&(U.current.isPositioned=!1,b(C=>({...C,isPositioned:!1})))},[g]);const _=x.useRef(!1);Mo(()=>(_.current=!0,()=>{_.current=!1}),[]),Mo(()=>{if(j&&(M.current=j),T&&(D.current=T),j&&T){if(L.current)return L.current(j,T,B);B()}},[j,T,B,L,G]);const H=x.useMemo(()=>({reference:M,floating:D,setReference:R,setFloating:S}),[R,S]),ee=x.useMemo(()=>({reference:j,floating:T}),[j,T]),ce=x.useMemo(()=>{const C={position:a,left:0,top:0};if(!ee.floating)return C;const F=sm(ee.floating,y.x),K=sm(ee.floating,y.y);return p?{...C,transform:"translate("+F+"px, "+K+"px)",...Hh(ee.floating)>=1.5&&{willChange:"transform"}}:{position:a,left:F,top:K}},[a,p,ee.floating,y.x,y.y]);return x.useMemo(()=>({...y,update:B,refs:H,elements:ee,floatingStyles:ce}),[y,B,H,ee,ce])}const Wh=(e,s)=>{const a=cw(e);return{name:a.name,fn:a.fn,options:[e,s]}},Vh=(e,s)=>{const a=uw(e);return{name:a.name,fn:a.fn,options:[e,s]}},Qh=(e,s)=>{const a=dw(e);return{name:a.name,fn:a.fn,options:[e,s]}},gw="data-floating-ui-focusable",am="active",lm="selected",xw={...Gm};let om=!1,yw=0;const im=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+yw++;function vw(){const[e,s]=x.useState(()=>om?im():void 0);return Ls(()=>{e==null&&s(im())},[]),x.useEffect(()=>{om=!0},[]),e}const bw=xw.useId,Gh=bw||vw;function ww(){const e=new Map;return{emit(s,a){var o;(o=e.get(s))==null||o.forEach(i=>i(a))},on(s,a){e.has(s)||e.set(s,new Set),e.get(s).add(a)},off(s,a){var o;(o=e.get(s))==null||o.delete(a)}}}const kw=x.createContext(null),jw=x.createContext(null),Nw=()=>{var e;return((e=x.useContext(kw))==null?void 0:e.id)||null},Yh=()=>x.useContext(jw);function Qu(e){return"data-floating-ui-"+e}const Sw={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},cm=x.forwardRef(function(s,a){const[o,i]=x.useState();Ls(()=>{Ib()&&i("button")},[]);const u={ref:a,tabIndex:0,role:o,"aria-hidden":o?void 0:!0,[Qu("focus-guard")]:"",style:Sw};return n.jsx("span",{...s,...u})}),Cw={clipPath:"inset(50%)",position:"fixed",top:0,left:0},Xh=x.createContext(null),um=Qu("portal");function Rw(e){e===void 0&&(e={});const{id:s,root:a}=e,o=Gh(),i=Iw(),[u,d]=x.useState(null),p=x.useRef(null);return Ls(()=>()=>{u==null||u.remove(),queueMicrotask(()=>{p.current=null})},[u]),Ls(()=>{if(!o||p.current)return;const m=s?document.getElementById(s):null;if(!m)return;const g=document.createElement("div");g.id=o,g.setAttribute(um,""),m.appendChild(g),p.current=g,d(g)},[s,o]),Ls(()=>{if(a===null||!o||p.current)return;let m=a||(i==null?void 0:i.portalNode);m&&!Hu(m)&&(m=m.current),m=m||document.body;let g=null;s&&(g=document.createElement("div"),g.id=s,m.appendChild(g));const y=document.createElement("div");y.id=o,y.setAttribute(um,""),m=g||m,m.appendChild(y),p.current=y,d(y)},[s,a,o,i]),u}function Jh(e){const{children:s,id:a,root:o,preserveTabOrder:i=!0}=e,u=Rw({id:a,root:o}),[d,p]=x.useState(null),m=x.useRef(null),g=x.useRef(null),y=x.useRef(null),b=x.useRef(null),v=d==null?void 0:d.modal,N=d==null?void 0:d.open,I=!!d&&!d.modal&&d.open&&i&&!!(o||u);return x.useEffect(()=>{if(!u||!i||v)return;function P(E){u&&Xc(E)&&(E.type==="focusin"?Zp:Db)(u)}return u.addEventListener("focusin",P,!0),u.addEventListener("focusout",P,!0),()=>{u.removeEventListener("focusin",P,!0),u.removeEventListener("focusout",P,!0)}},[u,i,v]),x.useEffect(()=>{u&&(N||Zp(u))},[N,u]),n.jsxs(Xh.Provider,{value:x.useMemo(()=>({preserveTabOrder:i,beforeOutsideRef:m,afterOutsideRef:g,beforeInsideRef:y,afterInsideRef:b,portalNode:u,setFocusManagerState:p}),[i,u]),children:[I&&u&&n.jsx(cm,{"data-type":"outside",ref:m,onFocus:P=>{if(Xc(P,u)){var E;(E=y.current)==null||E.focus()}else{const w=d?d.domReference:null,R=Ob(w);R==null||R.focus()}}}),I&&u&&n.jsx("span",{"aria-owns":u.id,style:Cw}),u&&_h.createPortal(s,u),I&&u&&n.jsx(cm,{"data-type":"outside",ref:g,onFocus:P=>{if(Xc(P,u)){var E;(E=b.current)==null||E.focus()}else{const w=d?d.domReference:null,R=_b(w);R==null||R.focus(),d!=null&&d.closeOnFocusOut&&(d==null||d.onOpenChange(!1,P.nativeEvent,"focus-out"))}}})]})}const Iw=()=>x.useContext(Xh),Tw={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Ew={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},dm=e=>{var s,a;return{escapeKey:typeof e=="boolean"?e:(s=e==null?void 0:e.escapeKey)!=null?s:!1,outsidePress:typeof e=="boolean"?e:(a=e==null?void 0:e.outsidePress)!=null?a:!0}};function Zh(e,s){s===void 0&&(s={});const{open:a,onOpenChange:o,elements:i,dataRef:u}=e,{enabled:d=!0,escapeKey:p=!0,outsidePress:m=!0,outsidePressEvent:g="pointerdown",referencePress:y=!1,referencePressEvent:b="pointerdown",ancestorScroll:v=!1,bubbles:N,capture:I}=s,P=Yh(),E=Na(typeof m=="function"?m:()=>!1),w=typeof m=="function"?E:m,R=x.useRef(!1),{escapeKey:S,outsidePress:j}=dm(N),{escapeKey:T,outsidePress:M}=dm(I),D=x.useRef(!1),U=Na(_=>{var H;if(!a||!d||!p||_.key!=="Escape"||D.current)return;const ee=(H=u.current.floatingContext)==null?void 0:H.nodeId,ce=P?$o(P.nodesRef.current,ee):[];if(!S&&(_.stopPropagation(),ce.length>0)){let C=!0;if(ce.forEach(F=>{var K;if((K=F.context)!=null&&K.open&&!F.context.dataRef.current.__escapeKeyBubbles){C=!1;return}}),!C)return}o(!1,Pb(_)?_.nativeEvent:_,"escape-key")}),G=Na(_=>{var H;const ee=()=>{var ce;U(_),(ce=sl(_))==null||ce.removeEventListener("keydown",ee)};(H=sl(_))==null||H.addEventListener("keydown",ee)}),L=Na(_=>{var H;const ee=u.current.insideReactTree;u.current.insideReactTree=!1;const ce=R.current;if(R.current=!1,g==="click"&&ce||ee||typeof w=="function"&&!w(_))return;const C=sl(_),F="["+Qu("inert")+"]",K=pl(i.floating).querySelectorAll(F);let ae=dt(C)?C:null;for(;ae&&!Ar(ae);){const Z=$r(ae);if(Ar(Z)||!dt(Z))break;ae=Z}if(K.length&&dt(C)&&!Eb(C)&&!Nu(C,i.floating)&&Array.from(K).every(Z=>!Nu(ae,Z)))return;if(fr(C)&&B){const Z=Ar(C),je=An(C),We=/auto|scroll/,st=Z||We.test(je.overflowX),Pt=Z||We.test(je.overflowY),Lt=st&&C.clientWidth>0&&C.scrollWidth>C.clientWidth,vn=Pt&&C.clientHeight>0&&C.scrollHeight>C.clientHeight,Le=je.direction==="rtl",Mn=vn&&(Le?_.offsetX<=C.offsetWidth-C.clientWidth:_.offsetX>C.clientWidth),Fn=Lt&&_.offsetY>C.clientHeight;if(Mn||Fn)return}const ne=(H=u.current.floatingContext)==null?void 0:H.nodeId,Pe=P&&$o(P.nodesRef.current,ne).some(Z=>{var je;return Yc(_,(je=Z.context)==null?void 0:je.elements.floating)});if(Yc(_,i.floating)||Yc(_,i.domReference)||Pe)return;const se=P?$o(P.nodesRef.current,ne):[];if(se.length>0){let Z=!0;if(se.forEach(je=>{var We;if((We=je.context)!=null&&We.open&&!je.context.dataRef.current.__outsidePressBubbles){Z=!1;return}}),!Z)return}o(!1,_,"outside-press")}),Y=Na(_=>{var H;const ee=()=>{var ce;L(_),(ce=sl(_))==null||ce.removeEventListener(g,ee)};(H=sl(_))==null||H.addEventListener(g,ee)});x.useEffect(()=>{if(!a||!d)return;u.current.__escapeKeyBubbles=S,u.current.__outsidePressBubbles=j;let _=-1;function H(K){o(!1,K,"ancestor-scroll")}function ee(){window.clearTimeout(_),D.current=!0}function ce(){_=window.setTimeout(()=>{D.current=!1},si()?5:0)}const C=pl(i.floating);p&&(C.addEventListener("keydown",T?G:U,T),C.addEventListener("compositionstart",ee),C.addEventListener("compositionend",ce)),w&&C.addEventListener(g,M?Y:L,M);let F=[];return v&&(dt(i.domReference)&&(F=ls(i.domReference)),dt(i.floating)&&(F=F.concat(ls(i.floating))),!dt(i.reference)&&i.reference&&i.reference.contextElement&&(F=F.concat(ls(i.reference.contextElement)))),F=F.filter(K=>{var ae;return K!==((ae=C.defaultView)==null?void 0:ae.visualViewport)}),F.forEach(K=>{K.addEventListener("scroll",H,{passive:!0})}),()=>{p&&(C.removeEventListener("keydown",T?G:U,T),C.removeEventListener("compositionstart",ee),C.removeEventListener("compositionend",ce)),w&&C.removeEventListener(g,M?Y:L,M),F.forEach(K=>{K.removeEventListener("scroll",H)}),window.clearTimeout(_)}},[u,i,p,w,g,a,o,v,d,S,j,U,T,G,L,M,Y]),x.useEffect(()=>{u.current.insideReactTree=!1},[u,w,g]);const X=x.useMemo(()=>({onKeyDown:U,...y&&{[Tw[b]]:_=>{o(!1,_.nativeEvent,"reference-press")},...b!=="click"&&{onClick(_){o(!1,_.nativeEvent,"reference-press")}}}}),[U,o,y,b]),B=x.useMemo(()=>{function _(H){H.button===0&&(R.current=!0)}return{onKeyDown:U,onMouseDown:_,onMouseUp:_,[Ew[g]]:()=>{u.current.insideReactTree=!0}}},[U,g,u]);return x.useMemo(()=>d?{reference:X,floating:B}:{},[d,X,B])}function Pw(e){const{open:s=!1,onOpenChange:a,elements:o}=e,i=Gh(),u=x.useRef({}),[d]=x.useState(()=>ww()),p=Nw()!=null,[m,g]=x.useState(o.reference),y=Na((N,I,P)=>{u.current.openEvent=N?I:void 0,d.emit("openchange",{open:N,event:I,reason:P,nested:p}),a==null||a(N,I,P)}),b=x.useMemo(()=>({setPositionReference:g}),[]),v=x.useMemo(()=>({reference:m||o.reference||null,floating:o.floating||null,domReference:o.reference}),[m,o.reference,o.floating]);return x.useMemo(()=>({dataRef:u,open:s,onOpenChange:y,elements:v,events:d,floatingId:i,refs:b}),[s,y,v,d,i,b])}function e0(e){e===void 0&&(e={});const{nodeId:s}=e,a=Pw({...e,elements:{reference:null,floating:null,...e.elements}}),o=e.rootContext||a,i=o.elements,[u,d]=x.useState(null),[p,m]=x.useState(null),y=(i==null?void 0:i.domReference)||u,b=x.useRef(null),v=Yh();Ls(()=>{y&&(b.current=y)},[y]);const N=hw({...e,elements:{...i,...p&&{reference:p}}}),I=x.useCallback(S=>{const j=dt(S)?{getBoundingClientRect:()=>S.getBoundingClientRect(),getClientRects:()=>S.getClientRects(),contextElement:S}:S;m(j),N.refs.setReference(j)},[N.refs]),P=x.useCallback(S=>{(dt(S)||S===null)&&(b.current=S,d(S)),(dt(N.refs.reference.current)||N.refs.reference.current===null||S!==null&&!dt(S))&&N.refs.setReference(S)},[N.refs]),E=x.useMemo(()=>({...N.refs,setReference:P,setPositionReference:I,domReference:b}),[N.refs,P,I]),w=x.useMemo(()=>({...N.elements,domReference:y}),[N.elements,y]),R=x.useMemo(()=>({...N,...o,refs:E,elements:w,nodeId:s}),[N,E,w,s,o]);return Ls(()=>{o.dataRef.current.floatingContext=R;const S=v==null?void 0:v.nodesRef.current.find(j=>j.id===s);S&&(S.context=R)}),x.useMemo(()=>({...N,context:R,refs:E,elements:w}),[N,E,w,R])}function eu(e,s,a){const o=new Map,i=a==="item";let u=e;if(i&&e){const{[am]:d,[lm]:p,...m}=e;u=m}return{...a==="floating"&&{tabIndex:-1,[gw]:""},...u,...s.map(d=>{const p=d?d[a]:null;return typeof p=="function"?e?p(e):null:p}).concat(e).reduce((d,p)=>(p&&Object.entries(p).forEach(m=>{let[g,y]=m;if(!(i&&[am,lm].includes(g)))if(g.indexOf("on")===0){if(o.has(g)||o.set(g,[]),typeof y=="function"){var b;(b=o.get(g))==null||b.push(y),d[g]=function(){for(var v,N=arguments.length,I=new Array(N),P=0;P<N;P++)I[P]=arguments[P];return(v=o.get(g))==null?void 0:v.map(E=>E(...I)).find(E=>E!==void 0)}}}else d[g]=y}),d),{})}}function t0(e){e===void 0&&(e=[]);const s=e.map(p=>p==null?void 0:p.reference),a=e.map(p=>p==null?void 0:p.floating),o=e.map(p=>p==null?void 0:p.item),i=x.useCallback(p=>eu(p,e,"reference"),s),u=x.useCallback(p=>eu(p,e,"floating"),a),d=x.useCallback(p=>eu(p,e,"item"),o);return x.useMemo(()=>({getReferenceProps:i,getFloatingProps:u,getItemProps:d}),[i,u,d])}function Aw({gid:e,uid:s,user:a,stats:o,x:i,y:u,onDismiss:d}){const{refs:p,floatingStyles:m,context:g,isPositioned:y}=e0({open:!0,onOpenChange:w=>{w||d()},strategy:"fixed",placement:"right-start",middleware:[Wh(8),Qh({fallbackPlacements:["left-start","bottom-start"]}),Vh({padding:8})],whileElementsMounted:(w,R,S)=>Kh(w,R,S,{animationFrame:!0})}),b=Zh(g,{outsidePress:w=>{var R,S;return!((S=(R=w.target)==null?void 0:R.closest)!=null&&S.call(R,"[data-stats-gid]"))}}),{getFloatingProps:v}=t0([b]),N=x.useRef(null);x.useEffect(()=>{N.current=null},[e]),x.useEffect(()=>{const w=()=>({x:i,y:u,top:u,left:i,right:i,bottom:u,width:0,height:0});p.setReference({getBoundingClientRect:()=>{const R=document.querySelector(`[data-stats-gid="${e}"]`);if(R){const S=R.getBoundingClientRect();return N.current=S,S}return N.current??w()}})},[p,e,i,u]);const I=ft(a,s),P=o.prsOpen+o.prsMerged+o.prsClosed,E=[{label:"Comments",value:o.comments},{label:"Reviews given",value:o.reviews},{label:"PRs open",value:o.prsOpen,dot:"#3b82f6"},{label:"PRs merged",value:o.prsMerged,dot:"#22c55e"},{label:"PRs closed",value:o.prsClosed,dot:"#9ca3af"}];return n.jsx(Jh,{children:n.jsxs("div",{ref:p.setFloating,style:{...m,visibility:y?"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:[n.jsx("div",{className:"mb-1 truncate text-sm font-semibold text-gray-800 dark:text-gray-100",title:I,children:I}),n.jsx("div",{className:"mb-2 text-[10px] uppercase tracking-wide text-gray-400",children:"In this window"}),n.jsx("table",{className:"w-full text-xs",children:n.jsxs("tbody",{children:[E.map(w=>n.jsxs("tr",{className:"border-t border-gray-100 first:border-0 dark:border-gray-800",children:[n.jsx("td",{className:"py-1 pr-2 text-gray-500 dark:text-gray-400",children:n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[w.dot&&n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:w.dot}}),w.label]})}),n.jsx("td",{className:"py-1 text-right font-medium tabular-nums text-gray-800 dark:text-gray-100",children:w.value})]},w.label)),n.jsxs("tr",{className:"border-t border-gray-200 dark:border-gray-700",children:[n.jsx("td",{className:"py-1 pr-2 text-gray-500 dark:text-gray-400",children:"PRs authored"}),n.jsx("td",{className:"py-1 text-right font-medium tabular-nums text-gray-800 dark:text-gray-100",children:P})]})]})})]})})}const bt={reviewComment:"#f59e0b",prComment:"#9ca3af",approved:"#22c55e",changes:"#f97316",commented:"#9ca3af",dismissed:"#9ca3af",commit:"#6b7280",lifecycle:"#3b82f6"};function Us(e){return`<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true">${e}</svg>`}const fm=e=>Us(`<circle cx="8" cy="8" r="5" fill="${e}"/>`),$w=e=>Us(`<circle cx="8" cy="8" r="4.5" fill="none" stroke="${e}" stroke-width="2"/>`),Mw=e=>Us(`<circle cx="8" cy="8" r="4.5" fill="none" stroke="${e}" stroke-width="1.6" stroke-dasharray="2.2 2"/>`),Fw=e=>Us(`<rect x="3.5" y="3.5" width="9" height="9" rx="1.5" fill="${e}"/>`),Lw=e=>Us(`<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"/>`),_w=e=>Us(`<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"/>`),Ow=e=>Us(`<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 n0(e){switch(e.type){case"review_comment":return{svg:fm(bt.reviewComment),color:bt.reviewComment,label:"Review comment",round:!0};case"pr_comment":return{svg:$w(bt.prComment),color:bt.prComment,label:"PR comment",round:!0};case"commit_pushed":return{svg:Fw(bt.commit),color:bt.commit,label:"Commit pushed"};case"review_submitted":switch(e.reviewState){case"approved":return{svg:Lw(bt.approved),color:bt.approved,label:"Approved"};case"changes_requested":return{svg:_w(bt.changes),color:bt.changes,label:"Changes requested"};case"dismissed":return{svg:Mw(bt.dismissed),color:bt.dismissed,label:"Review dismissed",round:!0};default:return{svg:Ow(bt.commented),color:bt.commented,label:"Review comment"}}default:return{svg:fm(bt.lifecycle),color:bt.lifecycle,label:"Event",round:!0}}}function Dw(e){const s=n0(e);return`<div class="ev-marker-inner${s.round?" ev-round":""}">${s.svg}</div>`}function tu(e){return`<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true">${e}</svg>`}const Bw={commit:{color:bt.commit,glyph:tu('<rect x="3.5" y="3.5" width="9" height="9" rx="1.5" fill="#fff"/>'),label:"commits"},comment:{color:bt.reviewComment,glyph:tu('<circle cx="8" cy="8" r="5" fill="#fff"/>'),label:"comments"},review:{color:bt.approved,glyph:tu('<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 zw(e,s){const a=Bw[s];return`<div class="ev-cluster-inner" style="background:${a.color}" title="${e} ${a.label}">${a.glyph}+${e}</div>`}function qw(e,s){const a=lh[e.type],o=ft(e.actorId!=null?s.get(e.actorId):void 0,e.actorId);return`${a.label} · ${o} · ${St(e.occurredAt)}`}const pm=Number.MAX_SAFE_INTEGER,Uw="2000-01-01T00:00:00Z",Kw="2100-01-01T00:00:00Z";function Hw(e){if(!e||e.end<=e.start)return{start:Uw,end:Kw};const s=e.end-e.start;return{start:new Date(e.start-s*3).toISOString(),end:new Date(e.end+s*3).toISOString()}}const Ww=new Set(["review_comment","pr_comment","review_submitted","commit_pushed"]);function Vw(e){return Ww.has(e.type)}function Qw(e){return e.type==="commit_pushed"?"commit":e.type==="review_submitted"?"review":"comment"}const r0=9,Gw=3;function Yw(e){return(23+(1+String(e).length)*6.5)/2}function Xw(e,s,a,o,i,u,d=8,p){const m=Math.max(1,d*u),g=[],y=new Map,b=new Map,v=new Set,N=new Map;for(const P of e){if(!Vw(P))continue;const E=s(P),w=Qw(P),R=P.prId,S=R!=null?o.get(R):void 0,j=P.actorId!=null&&(S==null?void 0:S.authorId)!=null&&P.actorId===S.authorId,T=j?`${E}::${w}::own::${R}`:`${E}::${w}::cross::${R??"none"}`,M=N.get(T);if(M){M.events.push(P);continue}j||v.add(E);const D=j?i.get(R)??0:0;N.set(T,{group:E,kind:w,ownWork:j,subgroup:j?`ev:${D}`:"cross",sortKey:j?D*2+1:pm,events:[P]})}for(const{group:P,kind:E,ownWork:w,subgroup:R,sortKey:S,events:j}of N.values()){const T=L=>`${L} ${w?"ev-own":"ev-cross"}`,M=[...j].sort((L,Y)=>Date.parse(L.occurredAt)-Date.parse(Y.occurredAt));let D=[],U=-1/0;const G=()=>{if(D.length!==0){if(D.length===1){const L=D[0],Y=`ev:${L.id}`;g.push({id:Y,group:P,subgroup:R,sortKey:S,type:"point",start:L.occurredAt,content:Dw(L),className:`${T("ev-marker")} ev-key-${L.id}`,title:qw(L,a),selectable:!1}),b.set(Y,r0)}else{const L=D.reduce((X,B)=>X+Date.parse(B.occurredAt),0)/D.length,Y=`cl:${P}:${E}:${D[0].id}`;y.set(Y,D.map(X=>X.id)),g.push({id:Y,group:P,subgroup:R,sortKey:S,type:"point",start:new Date(L).toISOString(),content:zw(D.length,E),className:`${T("ev-cluster")} ${D.map(X=>`ev-key-${X.id}`).join(" ")}`,title:`${D.length} ${E}s`,selectable:!1}),b.set(Y,Yw(D.length))}D=[]}};for(const L of M){const Y=Date.parse(L.occurredAt);D.length>0&&Y-U>m&&G(),D.push(L),U=Y}G()}Jw(g,u,b);const I=Hw(p);for(const P of v)g.push({id:`xsep:${P}`,group:P,subgroup:"cross",sortKey:pm,type:"background",start:I.start,end:I.end,content:"",className:"cross-sep"});return{items:g,clusterMembers:y}}function Jw(e,s,a){if(s<=0)return;const o=new Map;for(const i of e){if(i.type!=="point")continue;const u=`${String(i.group)}\0${String(i.subgroup??"")}`,d=o.get(u);d?d.push(i):o.set(u,[i])}for(const i of o.values()){if(i.length<2)continue;i.sort((p,m)=>nu(p)-nu(m));let u=-1/0,d=0;for(const p of i){const m=a.get(String(p.id))??r0;let g=nu(p);const y=(d+m+Gw)*s;g-u<y&&(g=u+y,p.start=new Date(g).toISOString()),u=g,d=m}}}function nu(e){const s=e.start;return s instanceof Date?s.valueOf():typeof s=="number"?s:Date.parse(String(s))}function Ms(e){return e.authorId!=null?`repo:${e.repoId}:user:${e.authorId}`:`repo:${e.repoId}`}function ru(e){return Date.parse(e.openedAt)}function mm(e,s){const a=e.mergedAt??e.closedAt;return a?Date.parse(a):s}function Zw(e,s=()=>0,a=Date.now()){const o=new Map;for(const u of e){const d=Ms(u),p=o.get(d);p?p.push(u):o.set(d,[u])}const i=new Map;for(const u of o.values()){const d=[...u].sort((g,y)=>ru(g)-ru(y)),p=[],m=[];for(const g of d){const y=ru(g),b=s(g);let v=p.findIndex((N,I)=>N<=y&&m[I]===b);v===-1?(v=p.length,p.push(mm(g,a)),m.push(b)):p[v]=mm(g,a),i.set(g.id,v)}}return i}function s0(e,s){const[a,o]=x.useState(()=>{try{const i=localStorage.getItem(e);return i!=null?JSON.parse(i):s}catch{return s}});return x.useEffect(()=>{try{localStorage.setItem(e,JSON.stringify(a))}catch{}},[e,a]),[a,o]}function e1(e){return e?e.replace(/\n$/,"").split(`
46
- `).at(-1)??null:null}function t1({ev:e,pr:s,usersById:a,onOpen:o}){const i=s.authorId!=null?a.get(s.authorId):void 0,u=e.actorId!=null&&s.authorId!=null&&e.actorId!==s.authorId;return n.jsxs("div",{className:"flex items-baseline gap-1 text-[11px] text-gray-500",children:[n.jsx("span",{children:"on"}),u&&n.jsxs("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:[ft(i,s.authorId),"’s"]}),n.jsxs("button",{type:"button",onClick:o,className:"font-medium text-blue-500 hover:underline",children:["#",s.number]}),n.jsx("span",{className:"truncate text-gray-400",title:s.title,children:s.title})]})}function hm({ev:e,usersById:s,prsById:a,onNavigate:o}){var G;const i=te(L=>L.selectThread),u=te(L=>L.selectPr),d=te(L=>L.showActivityEntry),p=te(L=>L.showPrComment),m=n0(e),g=e.actorId!=null?s.get(e.actorId):void 0,y=ft(g,e.actorId),b=e.type==="review_comment"&&e.threadId!=null,{data:v}=qu(b?e.threadId:null),N=Date.parse(e.occurredAt),I=(v==null?void 0:v.comments.find(L=>Date.parse(L.createdAt)===N&&L.authorId===e.actorId))??(v==null?void 0:v.comments[0]),P=v?e1((I==null?void 0:I.diffHunk)??((G=v.comments[0])==null?void 0:G.diffHunk)??null):null,E=e.type==="commit_pushed",w=e.type==="pr_comment",R=e.type==="review_submitted",{data:S}=Zo((E||w)&&e.prId!=null?e.prId:null),j=E&&S?S.commits.find(L=>L.id===e.refId):void 0,T=w&&S?S.comments.find(L=>L.id===e.refId):void 0,M=e.prId!=null?a.get(e.prId):void 0,D=()=>{e.threadId!=null?i(e.prId,e.threadId):w&&e.prId!=null&&e.refId!=null?p(e.prId,e.refId):R&&e.prId!=null&&e.refId!=null?d(e.prId,{type:e.type,refId:e.refId}):e.prId!=null&&u(e.prId),o()},U=()=>{e.prId!=null&&(d(e.prId,{type:e.type,refId:e.refId}),o())};return n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[n.jsx("span",{className:"inline-block h-3 w-3",dangerouslySetInnerHTML:{__html:m.svg}}),n.jsx("span",{className:"font-semibold",children:y}),n.jsxs("span",{className:"text-gray-500",children:["· ",m.label]}),n.jsx("span",{className:"ml-auto text-gray-400",children:St(e.occurredAt)})]}),M&&n.jsx(t1,{ev:e,pr:M,usersById:s,onOpen:D}),E&&n.jsx("div",{className:"text-[11px]",children:j?n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("code",{className:"rounded bg-gray-100 px-1 font-mono text-gray-600 dark:bg-gray-800 dark:text-gray-300",children:j.sha.slice(0,7)}),j.message&&n.jsx("span",{className:"truncate text-gray-600 dark:text-gray-300",children:j.message.split(`
47
- `)[0]})]}):n.jsx("span",{className:"text-gray-400",children:"loading commit…"})}),v&&n.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[n.jsxs("code",{className:"truncate font-mono text-gray-600 dark:text-gray-300",children:[v.path,v.line!=null?`:${v.line}`:""]}),n.jsx("span",{className:"ml-auto shrink-0",children:n.jsx(vh,{state:v.derivedState})})]}),P&&n.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:P}),I&&n.jsxs("div",{className:"text-xs",children:[n.jsx(cr,{children:I.body}),v&&v.comments.length>1&&n.jsxs("div",{className:"mt-1 text-[11px] text-gray-400",children:["+",v.comments.length-1," more in thread"]})]}),w&&n.jsx("div",{className:"text-xs",children:T?n.jsx(cr,{children:T.body}):n.jsx("span",{className:"text-gray-400",children:"loading comment…"})}),n.jsxs("div",{className:"flex items-center gap-3 pt-0.5 text-[11px]",children:[!E&&n.jsx("button",{type:"button",onClick:D,className:"text-blue-500 hover:underline",children:"Open in detail pane"}),E&&e.prId!=null&&n.jsx("button",{type:"button",onClick:U,className:"text-blue-500 hover:underline",title:"Show this commit in the PR's Activity tab",children:"View in Activity"}),E&&j&&S&&n.jsx("a",{href:`${S.githubUrl}/commits/${j.sha}`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"Open commit on GitHub ↗"}),w&&T&&S&&n.jsx("a",{href:T.url??S.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"Open on GitHub ↗"})]})]})}function n1({state:e,eventsById:s,usersById:a,prsById:o,focusPrId:i,onContextFocus:u,onDismiss:d,onNavigate:p}){var L;const[m,g]=s0("pierre:popoverSize",null),{refs:y,floatingStyles:b,context:v,isPositioned:N}=e0({open:!0,onOpenChange:Y=>{Y||d()},strategy:"fixed",placement:"right-start",middleware:[Wh(24),Qh({fallbackPlacements:["left-start","bottom"]}),Vh({padding:8})],whileElementsMounted:(Y,X,B)=>Kh(Y,X,B,{animationFrame:!0})}),I=Zh(v,{outsidePress:!1}),{getFloatingProps:P}=t0([I]),E=e.eventIds[0]??null,w=x.useRef(null);x.useEffect(()=>{w.current=null},[E]),x.useEffect(()=>{const Y=()=>({x:e.x,y:e.y,top:e.y,left:e.x,right:e.x,bottom:e.y,width:0,height:0});y.setReference({getBoundingClientRect:()=>{if(E!=null){const X=document.querySelector(`.ev-key-${E}`),B=(X==null?void 0:X.querySelector(".ev-marker-inner, .ev-cluster-inner"))??X;if(B){const _=B.getBoundingClientRect();return w.current=_,_}}return w.current??Y()}})},[y,E,e.x,e.y]);const R=e.eventIds.map(Y=>s.get(Y)).filter(Y=>Y!=null).filter(Y=>i==null||Y.prId===i),S=((L=R[0])==null?void 0:L.prId)??null;x.useEffect(()=>{u({groupIds:null,prId:S,eventId:null})},[S,u]);const j=Y=>{const X=Y.currentTarget;g({width:X.offsetWidth,height:X.offsetHeight})},[T,M]=x.useState({x:0,y:0}),D=x.useRef(null);x.useEffect(()=>{const Y=B=>{const _=D.current;_&&M({x:_.ox+(B.clientX-_.sx),y:_.oy+(B.clientY-_.sy)})},X=()=>{D.current=null};return window.addEventListener("pointermove",Y),window.addEventListener("pointerup",X),()=>{window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",X)}},[]);const U=Y=>{Y.button===0&&(Y.preventDefault(),D.current={sx:Y.clientX,sy:Y.clientY,ox:T.x,oy:T.y})},G=`${b.transform??""} translate(${T.x}px, ${T.y}px)`.trim();return n.jsx(Jh,{children:n.jsxs("div",{ref:y.setFloating,style:{...b,transform:G,visibility:N?"visible":"hidden",width:(m==null?void 0:m.width)??420,height:(m==null?void 0:m.height)??340,minWidth:240,minHeight:120,maxWidth:"92vw",maxHeight:"80vh",resize:"both",overflow:"hidden"},...P(),onPointerUp:j,"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:[n.jsxs("div",{className:"tl-modal-header",onPointerDown:U,children:[n.jsx("svg",{className:"tl-grip",width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:n.jsxs("g",{fill:"currentColor",children:[n.jsx("circle",{cx:"2",cy:"2",r:"1"}),n.jsx("circle",{cx:"8",cy:"2",r:"1"}),n.jsx("circle",{cx:"2",cy:"5",r:"1"}),n.jsx("circle",{cx:"8",cy:"5",r:"1"}),n.jsx("circle",{cx:"2",cy:"8",r:"1"}),n.jsx("circle",{cx:"8",cy:"8",r:"1"})]})}),n.jsx("span",{className:"tl-modal-title",children:R.length>1?`${R.length} events`:"Activity"}),n.jsx("button",{type:"button",className:"tl-modal-close",onPointerDown:Y=>Y.stopPropagation(),onClick:d,"aria-label":"Close",title:"Close",children:"✕"})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-2",children:R.length===1?n.jsx(hm,{ev:R[0],usersById:a,prsById:o,onNavigate:p}):n.jsx("div",{className:"divide-y divide-gray-200 dark:divide-gray-800",children:R.map(Y=>n.jsx("div",{className:"py-2 first:pt-0 last:pb-0",children:n.jsx(hm,{ev:Y,usersById:a,prsById:o,onNavigate:p})},Y.id))})})]})})}const r1=1e3*60*60,s1={stack:!1,stackSubgroups:!0,groupHeightMode:"fixed",orientation:{axis:"top",item:"top"},zoomMin:r1,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}},a1=12,l1=2;function gm(e){return[...new Set(e)]}function xm(e,s){var i,u;if(!e)return 0;const a=e.body,o=s==null?void 0:s.querySelector(".vis-panel.vis-center");return((u=(i=a==null?void 0:a.domProps)==null?void 0:i.center)==null?void 0:u.width)||(o==null?void 0:o.clientWidth)||(s==null?void 0:s.clientWidth)||0}function ol(e){return Date.parse(String(e.start))}function o1(e){return e.end!=null?Date.parse(String(e.end)):ol(e)}function i1(e,s){if(s<=0)return;const a=a1*s,o=new Map;for(const i of e){const u=`${String(i.group)}|${String(i.subgroup??"")}`,d=o.get(u);d?d.push(i):o.set(u,[i])}for(const i of o.values())if(i.length!==0){i.sort((u,d)=>ol(u)-ol(d));for(let u=0;u<i.length;u++){const d=i[u],p=ol(d),m=o1(d),g=u+1<i.length?ol(i[u+1]):Number.POSITIVE_INFINITY,y=Math.min(Math.max(m,p+a),g);y!==m&&(d.end=new Date(y).toISOString())}}}function ym(e,s){const a=s.getTime()-e.getTime(),o=Math.max(a*.06,14400*1e3),i=Math.max(a*.03,7200*1e3);return{start:new Date(e.getTime()-i),end:new Date(s.getTime()+o)}}function c1(e){const s=document.createElement("div");return s.innerHTML=e,s.firstElementChild??s}function u1(){const e=typeof navigator<"u"?navigator.platform||navigator.userAgent:"";return/Mac|iP(hone|ad|od)/.test(e)?"metaKey":"ctrlKey"}function d1(e){return e.actorId!=null?`repo:${e.repoId}:user:${e.actorId}`:`repo:${e.repoId}`}const f1=/^repo:\d+:user:\d+$/;function wa(e){return`tlg-${e.replace(/:/g,"-")}`}function p1(e){return new Date(e.mergedAt??e.closedAt??new Date().toISOString()).getTime()}function vm({mode:e}={}){const s=(e==null?void 0:e.kind)==="isolate"?e.prId:null,a=x.useRef(null),o=x.useRef(null),i=x.useRef(new hp),u=x.useRef(new hp),d=x.useRef(new Map),p=x.useRef(new Map),m=x.useRef(new Map),g=x.useRef([]),y=x.useRef(null),b=x.useRef(new Map),v=x.useRef(new Map),N=x.useRef(new Map),I=x.useRef({active:!1,states:[]}),P=x.useRef([]),E=x.useRef(null),w=x.useRef(null),R=x.useRef(new Set),S=x.useRef(new Set),j=x.useRef(!1);if(!j.current){j.current=!0;try{const A=localStorage.getItem("pierre:collapsedRows");if(A){const W=JSON.parse(A);Array.isArray(W)&&(S.current=new Set(W.map(String)))}}catch{}}const T=x.useRef(new Map),M=x.useRef(null),D=x.useRef(null),U=x.useRef(null),G=x.useRef(null),L=x.useRef(null),Y=x.useRef(null),X=x.useRef(null),B=x.useRef(null),_=x.useRef(null),H=x.useRef(0),ee=x.useRef(!1),ce=x.useRef(null),C=x.useRef(null),F=x.useRef(null),K=x.useRef(null),ae=x.useRef(null),ne=x.useRef(null),Pe=x.useRef(null),[se,Z]=x.useState(null),je=x.useRef(null);je.current=se;const[We,st]=x.useState(null),Pt=x.useRef(new Map),[Lt,vn]=x.useState(!1),{data:Le,isLoading:Mn,error:Fn}=nh(s!=null?{prIds:[s]}:void 0),{data:_t}=rh(),{data:Ln}=Fu(),{data:Kt}=Lu(),{data:pr}=Mr(),{data:Fr}=$n(),{data:Xn}=Mu(),_n=Be(),bn=te(A=>A.derivedStates),re=te(A=>A.categories),He=te(A=>A.userIds),it=te(A=>A.selectPr),at=te(A=>A.selectedPrId),On=x.useRef(at),[wn,on]=x.useState(0),[os,mr]=x.useState(0),fi=te(A=>A.preset),vl=te(A=>A.customFrom),bl=te(A=>A.customTo),pi=te(A=>A.rangeResetSignal),Jn=x.useMemo(()=>{const A=new Map;for(const W of pr??[])A.set(W.id,W);return A},[pr]),Ks=x.useRef(Jn);Ks.current=Jn;const Hs=x.useMemo(()=>{const A=new Map;for(const W of Xn??[])A.set(W.repoId,new Set(W.userIds));return A},[Xn]),cn=x.useMemo(()=>ln(Fr),[Fr]);b.current=cn;const is=x.useRef(!1);x.useEffect(()=>{if(!Le)return;let A=!1;for(const W of Le.events)if(W.actorId!=null&&!cn.has(W.actorId)){A=!0;break}if(!A){for(const W of Le.prs)if(W.authorId!=null&&!cn.has(W.authorId)){A=!0;break}}if(!A){is.current=!1;return}is.current||(is.current=!0,_n.invalidateQueries({queryKey:["users"]}))},[Le,cn,_n]);const hr=x.useMemo(()=>{const A=new Map;for(const W of(Le==null?void 0:Le.prs)??[])A.set(W.id,W);return A},[Le]);v.current=hr;const Dn=x.useCallback(A=>{const W=i.current,J=E.current;if(J!=null&&J!==A){const oe=W.get(`pr:${J}`);oe&&typeof oe.className=="string"&&W.update({id:`pr:${J}`,className:oe.className.replace(/\s*pr-cross-linked/g,"")})}if(A!=null){const oe=W.get(`pr:${A}`);oe&&typeof oe.className=="string"&&!oe.className.includes("pr-cross-linked")&&W.update({id:`pr:${A}`,className:`${oe.className} pr-cross-linked`})}E.current=A},[]),Yt=x.useCallback(A=>{const W=i.current,J=D.current;if(J!=null){const le=W.get(J);le&&typeof le.className=="string"&&le.className.includes("ev-cross-linked")&&W.update({id:J,className:le.className.replace(/\s*ev-cross-linked/g,"")}),D.current=null}if(M.current=A,A==null)return;const oe=W.get(`ev:${A}`)?`ev:${A}`:m.current.get(A)??null;if(oe==null)return;const de=W.get(oe);de&&typeof de.className=="string"&&!de.className.includes("ev-cross-linked")&&(W.update({id:oe,className:`${de.className} ev-cross-linked`}),D.current=oe)},[]),gr=x.useCallback(A=>{const W=i.current;for(const de of W.getIds()){const le=W.get(de);le&&typeof le.className=="string"&&le.className.includes("ev-exit-glow")&&W.update({id:de,className:le.className.replace(/\s*ev-exit-glow/g,"")})}if(G.current=null,U.current=A,A==null)return;const J=W.get(`ev:${A}`)?`ev:${A}`:m.current.get(A)??null;if(J==null)return;const oe=W.get(J);oe&&typeof oe.className=="string"&&!oe.className.includes("ev-exit-glow")&&(W.update({id:J,className:`${oe.className} ev-exit-glow`}),G.current=J)},[]),cs=x.useCallback(A=>{const W=i.current;for(const de of W.getIds()){const le=W.get(de);le&&typeof le.className=="string"&&le.className.includes("ev-selected")&&W.update({id:de,className:le.className.replace(/\s*ev-selected/g,"")})}if(Pe.current=null,ne.current=A,A==null)return;const J=W.get(`ev:${A}`)?`ev:${A}`:m.current.get(A)??null;if(J==null)return;const oe=W.get(J);oe&&typeof oe.className=="string"&&!oe.className.includes("ev-selected")&&(W.update({id:J,className:`${oe.className} ev-selected`}),Pe.current=J)},[]),xr=x.useCallback(()=>{const A=i.current,W=R.current,J=[],oe=[],de=w.current!=null;for(const le of g.current){const ve=String(le.id),me=W.has(String(le.group))||!de&&S.current.has(String(le.group)),he=A.get(ve)!=null;me&&he?J.push(ve):!me&&!he&&oe.push(le)}J.length&&A.remove(J),oe.length&&A.add(oe)},[]),Ta=x.useCallback(()=>{try{localStorage.setItem("pierre:collapsedRows",JSON.stringify([...S.current]))}catch{}},[]),Zn=x.useCallback((A,W)=>{var he,Ie;const J=u.current;if(!J.get(A))return;const oe=i.current.get(),de=new Set;for(const ye of oe)ye.group===A&&typeof ye.subgroup=="string"&&de.add(ye.subgroup);const le={};for(const ye of de)le[ye]=!W;const ve=J.get(A);ve&&(J.remove(A),J.add({...ve,subgroupVisibility:le,heightMode:W?"auto":"fixed"})),W?S.current.add(A):S.current.delete(A),Ta(),xr();const me=o.current;(Ie=(he=me==null?void 0:me.itemSet)==null?void 0:he.markDirty)==null||Ie.call(he,{restackGroups:!0}),me==null||me.redraw()},[Ta,xr]),us=x.useCallback(A=>{const W=u.current.getIds().map(String).filter(de=>f1.test(de)),J=A&&A.length?new Set(A):null,oe=[];for(const de of W){const le=J!=null&&!J.has(de);le?R.current.add(de):R.current.delete(de),oe.push({id:de,visible:!le})}oe.length&&u.current.update(oe),w.current=J?A:null,xr()},[xr]),Ot=x.useCallback(()=>{const A=o.current,W=a.current,J=y.current;if(!A||!W||!J)return;const oe=A.getWindow(),de=oe.end.valueOf()-oe.start.valueOf();B.current=de;const le=W.clientWidth||1e3,ve=de/le;let me;if(ee.current&&ce.current!=null)me=J.events.filter(we=>we.prId===ce.current);else if(me=J.events,I.current.active){const{states:we}=I.current;me=me.filter(Ae=>Ae.type==="review_comment"&&Ae.prId!=null&&Ae.derivedState!=null&&we.includes(Ae.derivedState))}const he=new Set(Zm(P.current));me=me.filter(we=>he.has(we.type));const{items:Ie,clusterMembers:ye}=Xw(me,d1,b.current,v.current,N.current,ve,8,{start:oe.start.valueOf(),end:oe.end.valueOf()});p.current=ye;const Re=new Map;for(const[we,Ae]of ye)for(const Ge of Ae)Re.set(Ge,we);m.current=Re;const ze=i.current.getIds().filter(we=>{const Ae=String(we);return Ae.startsWith("ev:")||Ae.startsWith("cl:")||Ae.startsWith("xsep:")});if(i.current.remove(ze),i.current.add(Ie),g.current=Ie.filter(we=>String(we.id).startsWith("xsep:")),xr(),M.current!=null){const we=M.current;D.current=null,M.current=null,Yt(we)}if(U.current!=null){const we=U.current;G.current=null,U.current=null,gr(we)}if(ne.current!=null){const we=ne.current;Pe.current=null,ne.current=null,cs(we)}},[Yt,gr,cs,xr]),Ws=x.useCallback(()=>{const A=C.current;if(!A)return;const W=()=>{A.childElementCount&&A.replaceChildren(),A.style.display="none"},J=a.current,oe=ce.current;if(!ee.current||oe==null||!J){W();return}const de=J.querySelector(".vis-panel.vis-center"),le=v.current.get(oe);if(!de||!le){W();return}const ve=wa(Ms(le)),me=J.querySelector(`.vis-foreground .vis-group.${ve} .vis-item.pr-bar.vis-selected`)??J.querySelector(`.vis-foreground .vis-group.${ve} .vis-item.pr-bar:not(.pr-focus-hidden)`);if(!me||me.offsetHeight===0){W();return}const Ie=(A.parentElement??J).getBoundingClientRect(),ye=de.getBoundingClientRect();A.style.display="block",A.style.left=`${ye.left-Ie.left}px`,A.style.top=`${ye.top-Ie.top}px`,A.style.width=`${ye.width}px`,A.style.height=`${ye.height}px`;const Re=me.getBoundingClientRect(),ze=Re.top-ye.top,we=Re.bottom-ye.top,Ae=Re.left-ye.left,Ge=Re.right-ye.left,tt="http://www.w3.org/2000/svg",Ct=document.createDocumentFragment(),$e=J.querySelectorAll(".vis-foreground .vis-item.ev-cross");for(const $t of $e){if($t.offsetHeight===0)continue;const gt=($t.querySelector(".ev-marker-inner, .ev-cluster-inner")??$t).getBoundingClientRect(),zn=gt.left+gt.width/2-ye.left,ps=gt.top-ye.top,ms=gt.bottom-ye.top,Dr=Math.max(Ae,Math.min(zn,Ge));let nr,Ht;if(ps>=we)nr=ps,Ht=we;else if(ms<=ze)nr=ms,Ht=ze;else continue;const Dt=document.createElementNS(tt,"path");Dt.setAttribute("d",`M ${zn.toFixed(1)} ${nr.toFixed(1)} L ${Dr.toFixed(1)} ${Ht.toFixed(1)}`),Ct.appendChild(Dt)}A.replaceChildren(Ct)},[]),er=x.useCallback(()=>{var J;const A=ee.current&&ce.current!=null,W=(((J=C.current)==null?void 0:J.childElementCount)??0)>0;!A&&!W||F.current==null&&(F.current=requestAnimationFrame(()=>{F.current=null,Ws()}))},[Ws]),wl=x.useCallback((A,W)=>{const J=u.current;for(const[he,Ie]of T.current){if(!J.get(he))continue;const ye={};for(const Re of Ie)ye[Re]=!0;J.update({id:he,subgroupVisibility:ye})}if(T.current.clear(),!A||A.length===0||W==null)return;const oe=N.current.get(W),de=v.current.get(W),le=i.current.get(`pr:${W}`),ve=de?Ms(de):le&&typeof le.group=="string"?le.group:null,me=i.current.get();for(const he of A){const Ie=new Set(["cross"]);he===ve&&oe!=null&&(Ie.add(`bar:${oe}`),Ie.add(`ev:${oe}`));const ye=new Set;for(const we of me)we.group===he&&typeof we.subgroup=="string"&&ye.add(we.subgroup);const Re=[...ye].filter(we=>!Ie.has(we)),ze={};for(const we of Re)ze[we]=!1;for(const we of ye)Ie.has(we)&&(ze[we]=!0);Object.keys(ze).length!==0&&(J.update({id:he,subgroupVisibility:ze}),Re.length&&T.current.set(he,Re))}},[]),kn=x.useCallback(A=>{const W=i.current,J=[];for(const oe of W.getIds()){const de=String(oe);if(!de.startsWith("pr:"))continue;const le=W.get(oe);if(!le||typeof le.className!="string")continue;const ve=Number.parseInt(de.slice(3),10),me=le.className.includes("pr-focus-hidden"),he=A!=null&&ve!==A;he&&!me?J.push({id:oe,className:`${le.className} pr-focus-hidden`}):!he&&me&&J.push({id:oe,className:le.className.replace(/\s*pr-focus-hidden/g,"")})}J.length&&W.update(J)},[]),un=x.useCallback(A=>{gr(null);const W=ee.current;wl((A==null?void 0:A.groupIds)??null,(A==null?void 0:A.prId)??null),us((A==null?void 0:A.groupIds)??null),Dn((A==null?void 0:A.prId)??null),Yt((A==null?void 0:A.eventId)??null);const J=!!(A!=null&&A.groupIds&&A.groupIds.length>0);if(vn(J),J||(ee.current=!1,ce.current=null),J&&(A==null?void 0:A.prId)!=null){const oe=te.getState();oe.selectedPrId!==A.prId&&oe.selectPr(A.prId)}if(!J&&W&&(kn(null),Ot()),!J&&S.current.size>0)for(const oe of S.current)Zn(oe,!0)},[wl,us,Dn,Yt,gr,kn,Ot,Zn]),Vs=x.useCallback(A=>{ee.current||un(A)},[un]),At=x.useCallback(()=>{const A=a.current;return A?A.querySelector(".vis-panel.vis-left.vis-vertical-scroll")??A.querySelector(".vis-panel.vis-right.vis-vertical-scroll"):null},[]),kl=x.useCallback(()=>{const A=K.current,W=a.current;if(!A||!W)return;const J=()=>{A.style.display!=="none"&&(A.style.display="none")},oe=At();if(!oe){J();return}const le=(A.parentElement??W).getBoundingClientRect(),ve=oe.getBoundingClientRect(),me=ve.top,he=1;let Ie=null;for(const Ae of W.querySelectorAll(".vis-labelset .vis-label.tl-repo-header")){const Ge=Ae.getBoundingClientRect();Ge.height<1||Ge.top<=me+he&&(Ie=Ae)}if(!Ie){J();return}if(Ie.getBoundingClientRect().top>=me-he){J();return}const ze=((Ie.querySelector(".vis-inner")??Ie).textContent??"").trim();if(!ze){J();return}const we=[...Ie.classList].find(Ae=>Ae.startsWith("tl-repo-tint-"))??"";A.dataset.repo!==ze&&(A.textContent=ze,A.dataset.repo=ze),A.dataset.tint!==we&&(A.className=`tl-repo-sticky${we?` ${we}`:""}`,A.dataset.tint=we),A.style.left=`${ve.left-le.left}px`,A.style.top=`${ve.top-le.top}px`,A.style.width=`${ve.width}px`,A.style.display!=="block"&&(A.style.display="block")},[At]),yr=x.useCallback(()=>{ae.current==null&&(ae.current=requestAnimationFrame(()=>{ae.current=null,kl()}))},[kl]),Qs=x.useCallback(()=>{const A=At(),W=a.current;if(!A||!W)return null;const J=A.getBoundingClientRect().top;let oe=null,de=0,le=1/0;for(const ve of W.querySelectorAll(".vis-labelset .vis-label")){const me=ve.getBoundingClientRect();if(me.height<4||me.bottom<=J+1)continue;const he=[...ve.classList].find(ye=>ye.startsWith("tlg-"));if(!he)continue;const Ie=Math.abs(me.top-J);Ie<le&&(le=Ie,oe=he,de=me.top-J)}return{token:oe,offset:de,scrollTop:A.scrollTop}},[At]),tr=x.useCallback((A,W)=>{const J=o.current,oe=y.current;if(!J||!oe)return;const de=(W==null?void 0:W.pr)??v.current.get(A);if(!de)return;Z(null);const le=de.repoId,ve=new Set;de.authorId!=null&&ve.add(de.authorId);let me=1/0,he=-1/0;const Ie=Re=>{Re<me&&(me=Re),Re>he&&(he=Re)};Ie(new Date(de.openedAt).getTime()),Ie(p1(de));for(const Re of oe.events)Re.prId===A&&(Re.actorId!=null&&ve.add(Re.actorId),Ie(new Date(Re.occurredAt).getTime()));const ye=[...ve].map(Re=>`repo:${le}:user:${Re}`);if((W==null?void 0:W.fitWindow)!==!1&&Number.isFinite(me)&&Number.isFinite(he)){const Re=Math.max((he-me)*.08,432e5);J.setWindow(me-Re,he+Re,{animation:!0})}ee.current=!0,ce.current=A,un({groupIds:ye.length?ye:null,prId:A,eventId:(W==null?void 0:W.anchorEventId)??null}),Ot(),kn(A),J.setSelection([`pr:${A}`]),(W==null?void 0:W.anchorEventId)!=null&&Yt(W.anchorEventId)},[un,Ot,kn,Yt]),vr=x.useCallback(A=>{const W=At();if(!W||o.current==null||!W.isConnected)return;const J=Math.max(0,W.scrollHeight-W.clientHeight);W.scrollTop=Math.max(0,Math.min(J,A)),W.dispatchEvent(new Event("scroll"))},[At]),Bn=x.useRef(!1),Gs=x.useRef(0),br=x.useCallback((A,W,J=".ev-cross-linked",oe=".pr-cross-linked")=>{const de=a.current,le=At(),ve=de==null?void 0:de.querySelector(".vis-panel.vis-center");if(!de||!le||!ve)return;const me=`.vis-labelset .vis-label.${A}`;let he;const Ie=tt=>{const Ct=ve.getBoundingClientRect(),$e=tt.getBoundingClientRect();return $e.top+$e.height/2-Ct.top-Ct.height/2},ye=()=>{const tt=$t=>[...de.querySelectorAll($t)].filter(pt=>pt.offsetHeight>0).sort((pt,gt)=>gt.offsetHeight-pt.offsetHeight)[0];if(W){const $t=tt(J);if($t)return{delta:Ie($t),settleable:!0};const pt=de.querySelector(`.vis-foreground .vis-group.${A}`);if(pt){const gt=ve.getBoundingClientRect();return{delta:pt.getBoundingClientRect().bottom-12-(gt.top+gt.height/2),settleable:!1}}return null}if(he&&he.isConnected&&he.offsetHeight>0)return{delta:Ie(he),settleable:!0};const Ct=tt(oe);if(Ct)return he=Ct,{delta:Ie(Ct),settleable:!0};const $e=de.querySelector(me);return $e?{delta:Ie($e),settleable:!0}:null},Re=de.querySelector(me);Re&&vr(Re.offsetTop-8);let ze=0,we=0;const Ae=++Gs.current;Bn.current=!0,window.setTimeout(()=>{Gs.current===Ae&&(Bn.current=!1)},2500);const Ge=()=>{if(Gs.current!==Ae)return;const tt=ye();tt!=null&&(Math.abs(tt.delta)>6?(vr(le.scrollTop+tt.delta),we=0):tt.settleable?we+=1:we=0),we<6&&ze++<90?requestAnimationFrame(Ge):Bn.current=!1};requestAnimationFrame(()=>requestAnimationFrame(Ge))},[At,vr]),Lr=x.useCallback(A=>{const W=a.current,J=()=>{var me;const ve=At();if(!ve||!W)return!0;if(A.token){const he=W.querySelector(`.vis-labelset .vis-label.${A.token}`);if(he&&he.offsetHeight>0){const ye=he.getBoundingClientRect().top-ve.getBoundingClientRect().top-A.offset;return Math.abs(ye)>1?(vr(ve.scrollTop+ye),!1):!0}}return vr(A.scrollTop),Math.abs((((me=At())==null?void 0:me.scrollTop)??A.scrollTop)-A.scrollTop)<=2};J();let oe=0,de=0;const le=()=>{J()?de+=1:de=0,de<3&&oe++<30&&requestAnimationFrame(le)};requestAnimationFrame(le)},[At,vr]),_r=x.useCallback((A,W,J)=>{J.length!==0&&(w.current||un(null),st(null),Z({x:A,y:W,eventIds:J}))},[un]),Or=x.useCallback(()=>{Z(null),w.current||un(null)},[un]),Ys=x.useCallback(()=>{je.current?Or():w.current||(On.current!=null?te.getState().clearSelection():U.current!=null&&gr(null))},[Or,gr]),mi=x.useCallback(()=>{Z(null)},[]);x.useEffect(()=>{cs(se&&!Lt?se.eventIds[0]??null:null)},[se,Lt,cs]);const Je=(se==null?void 0:se.eventIds[0])??null;x.useEffect(()=>{if(Je==null)return;const A=d.current.get(Je);(A==null?void 0:A.prId)!=null&&te.getState().selectPr(A.prId)},[Je]);const Ea=x.useCallback(A=>{const W=Ks.current.get(A.repoId),J=A.authorId!=null?b.current.get(A.authorId):void 0;return{id:A.id,number:A.number,title:A.title,repoFullName:(W==null?void 0:W.fullName)??`repo ${A.repoId}`,authorLogin:(J==null?void 0:J.githubLogin)??null,authorDisplayName:(J==null?void 0:J.displayName)??null,authorAvatarUrl:(J==null?void 0:J.avatarUrl)??null}},[]);x.useEffect(()=>{if(!a.current)return;const{from:A,to:W}=Ao(te.getState()),{start:J,end:oe}=ym(A,W),de=new ox(a.current,i.current,u.current,{...s1,start:J,end:oe,zoomKey:u1()});de.on("click",he=>{var Ge,tt,Ct;const Ie=he.item,ye=((Ge=he.event)==null?void 0:Ge.srcEvent)??he.event,Re=(ye==null?void 0:ye.clientX)??he.pageX??0,ze=(ye==null?void 0:ye.clientY)??he.pageY??0,we=(ye==null?void 0:ye.target)??null;if((tt=we==null?void 0:we.closest)!=null&&tt.call(we,"[data-collapse-gid]")||(Ct=we==null?void 0:we.closest)!=null&&Ct.call(we,"[data-stats-gid]"))return;if(Ie==null){if(((ye==null?void 0:ye.detail)??0)>=2)return;Ys();return}const Ae=String(Ie);if(Ae.startsWith("pr:"))je.current&&!ee.current&&!w.current&&Or(),it(Number.parseInt(Ae.slice(3),10));else if(Ae.startsWith("ev:")){const $e=Number.parseInt(Ae.slice(3),10);if(ee.current){Yt($e),_r(Re,ze,[$e]);return}_r(Re,ze,[$e])}else if(Ae.startsWith("cl:")){const $e=p.current.get(Ae)??[];if($e.length===0)return;const $t=$e[0];if(ee.current){Yt($t),_r(Re,ze,$e);return}_r(Re,ze,$e)}}),de.on("doubleClick",he=>{const Ie=he.item;if(Ie==null||ee.current)return;const ye=String(Ie);if(ye.startsWith("pr:")){const Re=Number.parseInt(ye.slice(3),10),ze=v.current.get(Re);ze&&Oe.getState().openPrFocusTab(Ea(ze));return}if(ye.startsWith("ev:")||ye.startsWith("cl:")){const ze=(ye.startsWith("ev:")?[Number.parseInt(ye.slice(3),10)]:p.current.get(ye)??[])[0]??null;if(ze==null)return;const we=d.current.get(ze);if((we==null?void 0:we.prId)==null)return;const Ae=v.current.get(we.prId);Ae&&Oe.getState().openPrFocusTab(Ea(Ae))}});let le=null,ve=null;de.on("rangechanged",()=>{const he=de.getWindow(),Ie=he.end.valueOf()-he.start.valueOf(),ye=B.current;if(ye==null||Math.abs(Ie-ye)/ye>.02){le&&clearTimeout(le);const Ge=()=>{if(Bn.current){le=setTimeout(Ge,120);return}le=null;const tt=Qs();Ot(),de.redraw(),tt&&Lr(tt)};le=setTimeout(Ge,120)}const ze=X.current;if(ze==null||ee.current||w.current)return;const we=de.getWindow(),Ae=we.end.valueOf()-we.start.valueOf();Math.abs(Ae-ze)/ze<=.02||(ve&&clearTimeout(ve),ve=setTimeout(()=>mr(Ge=>Ge+1),160))}),de.on("changed",er);const me=At();return me==null||me.addEventListener("scroll",er,{passive:!0}),de.on("changed",yr),me==null||me.addEventListener("scroll",yr,{passive:!0}),window.addEventListener("resize",yr,{passive:!0}),yr(),o.current=de,()=>{Gs.current+=1,Bn.current=!1,le&&clearTimeout(le),ve&&clearTimeout(ve),me==null||me.removeEventListener("scroll",er),me==null||me.removeEventListener("scroll",yr),window.removeEventListener("resize",yr),F.current!=null&&(cancelAnimationFrame(F.current),F.current=null),ae.current!=null&&(cancelAnimationFrame(ae.current),ae.current=null),de.destroy(),o.current=null}},[it,Ot,_r,Ys,Or,Yt,Ea,Qs,Lr,er,yr,At]),x.useEffect(()=>{const A=a.current;if(!A)return;const W=J=>{var he;const oe=J.target,de=(he=oe==null?void 0:oe.closest)==null?void 0:he.call(oe,"[data-collapse-gid]");if(!de)return;const le=de.getAttribute("data-collapse-gid");if(!le||(J.stopPropagation(),J.preventDefault(),ee.current||w.current))return;const ve=!S.current.has(le);Zn(le,ve),de.textContent=ve?"▸":"▾";const me=ve?"Expand row":"Collapse row";de.setAttribute("title",me),de.setAttribute("aria-label",me)};return A.addEventListener("click",W,!0),()=>A.removeEventListener("click",W,!0)},[Zn]),x.useEffect(()=>{const A=a.current;if(!A)return;const W=J=>{var me;const oe=J.target,de=(me=oe==null?void 0:oe.closest)==null?void 0:me.call(oe,"[data-stats-gid]");if(!de)return;const le=de.getAttribute("data-stats-gid");if(!le)return;J.stopPropagation(),J.preventDefault();const ve=Number(le.split(":user:")[1]);Number.isFinite(ve)&&(Z(null),st(he=>he&&he.gid===le?null:{gid:le,uid:ve,x:J.clientX,y:J.clientY}))};return A.addEventListener("click",W,!0),()=>A.removeEventListener("click",W,!0)},[]),x.useEffect(()=>{const A=a.current;if(!A)return;const W=J=>{const oe=J.target;!oe||!oe.isConnected||oe.closest(".vis-timeline")||Ys()};return A.addEventListener("click",W),()=>A.removeEventListener("click",W)},[Ys]);const Xs=x.useCallback((A,W)=>{_.current!=null&&(cancelAnimationFrame(_.current),_.current=null);const J=he=>{const Ie=o.current;if(!Ie||he<=0)return;const ye=Ie.getWindow();i1(A,(ye.end.valueOf()-ye.start.valueOf())/he),i.current.update(A),H.current=he,W==null||W()},oe=xm(o.current,a.current);if(oe>0&&Math.abs(oe-H.current)<1){J(oe);return}let de=-1,le=0,ve=0;const me=()=>{const he=xm(o.current,a.current);if(he>0&&he===de?le+=1:(le=0,de=he),he>0&&le>=2||ve++>40){_.current=null,J(he);return}_.current=requestAnimationFrame(me)};_.current=requestAnimationFrame(me)},[]);x.useEffect(()=>()=>{_.current!=null&&cancelAnimationFrame(_.current)},[]),x.useEffect(()=>{let A=null;const W=()=>{A&&clearTimeout(A),A=setTimeout(()=>mr(J=>J+1),200)};return window.addEventListener("resize",W),()=>{window.removeEventListener("resize",W),A&&clearTimeout(A)}},[]);const ds=x.useRef(!1);x.useEffect(()=>{const A=()=>{!document.hidden&&ds.current&&(ds.current=!1,mr(W=>W+1))};return document.addEventListener("visibilitychange",A),()=>document.removeEventListener("visibilitychange",A)},[]),x.useEffect(()=>{var Br;if(!Le)return;if(y.current=Le,document.hidden){ds.current=!0;return}ds.current=!1;const A=L.current,W=A&&!Le.prs.some(xe=>xe.id===A.id)?[...Le.prs,A]:Le.prs,J=He&&He.length>0?new Set(He):null,oe=xe=>!J||xe.authorId!=null&&J.has(xe.authorId),de=bn.length>0,le=new Set;if(de){const xe=new Set(bn);for(const Ye of Le.events)Ye.type==="review_comment"&&Ye.prId!=null&&Ye.derivedState!=null&&xe.has(Ye.derivedState)&&le.add(Ye.prId)}const ve=xe=>!de||le.has(xe.id),me=W.filter(xe=>xe.id===s||xe.id===On.current||xe.id===(A==null?void 0:A.id)||oe(xe)&&ve(xe));I.current={active:de,states:bn},P.current=re;const he=new Map;for(const xe of Le.events)he.set(xe.id,xe);d.current=he;const Ie=new Set;for(const xe of Le.events)xe.prId!=null&&(xe.type==="review_comment"||xe.type==="pr_comment")&&Ie.add(xe.prId);const ye=(Br=o.current)==null?void 0:Br.getWindow();X.current=ye?ye.end.valueOf()-ye.start.valueOf():null;const Re=Zw(W);N.current=Re;const ze=Gv(Le.events,W);Pt.current=ze;let we=Le.events;if(s==null&&!ee.current&&de){const xe=new Set(bn);we=Le.events.filter(Ye=>Ye.type==="review_comment"&&Ye.prId!=null&&Ye.derivedState!=null&&xe.has(Ye.derivedState))}const Ae=gm([...me.map(xe=>xe.repoId),...we.map(xe=>xe.repoId)]).sort((xe,Ye)=>{const qn=Jn.get(xe),Xt=Jn.get(Ye);return!qn||!Xt?(qn?0:1)-(Xt?0:1)||xe-Ye:qn.owner.localeCompare(Xt.owner)||qn.name.localeCompare(Xt.name)||xe-Ye}),Ge=[],tt=0,Ct=1e6;Ae.forEach((xe,Ye)=>{const qn=gm([...we.filter(xt=>xt.repoId===xe&&xt.actorId!=null).map(xt=>xt.actorId),...me.filter(xt=>xt.repoId===xe&&xt.authorId!=null).map(xt=>xt.authorId)]),Xt=Hs.get(xe),Nn=qn.map(xt=>`repo:${xe}:user:${xt}`),hs=`tl-repo-tint-${Ye%l1}`,wr=Jn.get(xe),gs=(wr==null?void 0:wr.fullName)??`repo ${xe}`,jl=wr!=null&&wr.inboxWatch?`${kt(gs)}${Vx()}`:kt(gs);Ge.push({id:`repo:${xe}`,content:jl,nestedGroups:Nn.length?Nn:void 0,treeLevel:1,order:Ye,subgroupOrder:"sortKey",className:`tl-repo-header ${hs}`}),qn.forEach((xt,xs)=>{const Un=`repo:${xe}:user:${xt}`,kr=(Xt==null?void 0:Xt.has(xt))??!1;Ge.push({id:Un,content:c1(Jv(cn.get(xt),xt,ze.get(xt),kr,Un,S.current.has(Un))),treeLevel:2,order:(kr?tt:Ct)+xs,subgroupOrder:"sortKey",heightMode:S.current.has(Un)?"auto":"fixed",className:`tl-user-row ${wa(Un)} ${hs}`})})});const $e=ee.current?ce.current:null,$t=me.map(xe=>{const Ye=xe.authorId!=null?cn.get(xe.authorId):void 0,qn=Ms(xe),Xt=Re.get(xe.id)??0,Nn={author:{label:ft(Ye,xe.authorId),avatarUrl:(Ye==null?void 0:Ye.avatarUrl)??null},hasComments:Ie.has(xe.id)};return{id:`pr:${xe.id}`,group:qn,subgroup:`bar:${Xt}`,sortKey:Xt*2,type:"range",start:xe.openedAt,end:xe.mergedAt??xe.closedAt??new Date().toISOString(),content:Hv(xe,Nn),className:(()=>{const hs=Vv(xe,Nn.hasComments);return $e!=null&&xe.id!==$e?`${hs} pr-focus-hidden`:hs})(),title:Wv(xe,Nn)}}),pt=o.current,gt=pt==null?void 0:pt.getWindow(),zn=A?null:Qs(),ps=Bn.current,ms=new Set(Ge.map(xe=>String(xe.id)));u.current.update(Ge);const Dr=u.current.getIds().map(String).filter(xe=>!ms.has(xe));Dr.length&&u.current.remove(Dr);const nr=new Set($t.map(xe=>String(xe.id))),Ht=i.current.getIds().map(String).filter(xe=>xe.startsWith("pr:")&&!nr.has(xe));if(i.current.update($t),Ht.length&&i.current.remove(Ht),Xs($t,()=>{zn&&!Bn.current&&!ps&&Lr(zn)}),Ot(),pt&&gt){const xe=pt.getWindow();(xe.start.valueOf()!==gt.start.valueOf()||xe.end.valueOf()!==gt.end.valueOf())&&pt.setWindow(gt.start,gt.end,{animation:!1})}const Dt=On.current;if(Dt!=null&&pt&&i.current.get(`pr:${Dt}`)&&!pt.getSelection().map(String).includes(`pr:${Dt}`)&&pt.setSelection([`pr:${Dt}`]),E.current!=null){const xe=E.current;E.current=null,Dn(xe)}if(w.current&&us(w.current),ee.current&&ce.current!=null&&kn(ce.current),!w.current&&!ee.current&&S.current.size>0)for(const xe of S.current)Zn(xe,!0);const fn=L.current;(!fn||Le.prs.some(xe=>xe.id===fn.id)||On.current!==fn.id&&ce.current!==fn.id)&&(L.current=null),zn&&!Bn.current&&Lr(zn)},[Le,bn,_t,He,Jn,cn,Hs,wn,os,Ot,Dn,us,kn,Zn,Qs,Lr,Xs]),x.useEffect(()=>{P.current=re,o.current&&y.current&&Ot()},[re,Ot]),x.useEffect(()=>{On.current=at;const A=o.current;if(!A)return;if(at!=null&&!i.current.get(`pr:${at}`)){on(de=>de+1);return}const W=at!=null?[`pr:${at}`]:[],J=A.getSelection().map(String);J.length===W.length&&W.every(de=>J.includes(de))||A.setSelection(W)},[at]);const fs=x.useRef(!1);x.useEffect(()=>{if(s==null||fs.current||!o.current||!y.current)return;te.getState().selectedPrId!==s&&te.getState().selectPr(s);const W=v.current.get(s)??(Le==null?void 0:Le.prs.find(ve=>ve.id===s))??(_t==null?void 0:_t.prs.find(ve=>ve.id===s))??(Kt==null?void 0:Kt.prs.find(ve=>ve.id===s));if(!W)return;fs.current=!0,tr(s,{fitWindow:!0,pr:W});const J=wa(Ms(W)),oe=te.getState(),le=oe.timelineFocusPr===s&&oe.timelineFocusEvent!=null?null:window.setTimeout(()=>br(J,!1),320);return()=>{le!=null&&window.clearTimeout(le)}},[s,Le,_t,Kt,tr,br]),x.useEffect(()=>{const A=o.current;if(!A||s!=null)return;const{from:W,to:J}=Ao(te.getState()),{start:oe,end:de}=ym(W,J);A.setWindow(oe,de,{animation:!1})},[fi,vl,bl,pi,s]);const Js=te(A=>A.timelineCenterAt);x.useEffect(()=>{if(Js==null)return;const A=o.current;if(!A)return;const W=A.getWindow(),J=W.end.valueOf()-W.start.valueOf();A.setWindow(Js-J/2,Js+J/2,{animation:!0}),te.getState().consumeTimelineCenter()},[Js]);const dn=te(A=>A.timelineFocusPr),jn=te(A=>A.timelineFocusAt);return x.useEffect(()=>{if(dn==null)return;const A=o.current;if(!A)return;const W=Le==null?void 0:Le.prs.find(le=>le.id===dn);if(W){const le=te.getState().timelineFocusEvent;if(le&&Le){const ye=Le.events.filter(Ae=>Ae.prId===dn&&Ae.type===le.type&&(le.refId==null||Ae.refId===le.refId)),Re=jn!=null&&ye.find(Ae=>Ae.occurredAt===jn)||ye[0],ze=(Re==null?void 0:Re.actorId)??W.authorId,we=Re!=null&&(i.current.get(`ev:${Re.id}`)!=null||m.current.get(Re.id)!=null);if(jn){const Ae=Date.parse(jn),Ge=A.getWindow(),tt=Ge.end.valueOf()-Ge.start.valueOf();A.setWindow(Ae-tt/2,Ae+tt/2,{animation:!0})}if(A.setSelection([`pr:${dn}`]),Re!=null&&Yt(Re.id),ze!=null){const Ae=wa(`repo:${W.repoId}:user:${ze}`);window.setTimeout(()=>br(Ae,we),120)}te.getState().consumeTimelineFocus();return}const ve=A.getWindow(),me=ve.end.valueOf()-ve.start.valueOf();let he;if(jn)he=Date.parse(jn);else{const ye=new Date(W.openedAt).getTime(),Re=new Date(W.mergedAt??W.closedAt??new Date().toISOString()).getTime();he=(ye+Re)/2}A.setWindow(he-me/2,he+me/2,{animation:!0}),A.setSelection([`pr:${dn}`]);const Ie=wa(Ms(W));window.setTimeout(()=>{br(Ie,!1,".ev-cross-linked",".pr-bar.vis-selected")},120),te.getState().consumeTimelineFocus();return}const J=le=>{L.current=le,on(me=>me+1);const ve=wa(Ms(le));Y.current!=null&&window.clearTimeout(Y.current),Y.current=window.setTimeout(()=>{Y.current=null,A.setSelection([`pr:${le.id}`]),br(ve,!1,".ev-cross-linked",".pr-bar.vis-selected")},360),te.getState().consumeTimelineFocus()},oe=Le&&!Le.prs.some(le=>le.id===dn)?Ln==null?void 0:Ln.prs.find(le=>le.id===dn):void 0;if(oe){J(oe);return}const de=(_t==null?void 0:_t.prs.find(le=>le.id===dn))??(Kt==null?void 0:Kt.prs.find(le=>le.id===dn));if(de){const{from:le}=Ao(te.getState()),ve=new Date(de.openedAt).getTime();if(ve<le.getTime()){const me=new Date(ve-864e5).toISOString().slice(0,10),he=new Date().toISOString().slice(0,10);te.getState().setCustomRange(me,he);return}if(Le&&!Le.prs.some(me=>me.id===de.id)){J(de);return}}te.getState().consumeTimelineFocus()},[dn,jn,Le,_t,Ln,Kt,br,Yt]),n.jsxs("div",{className:`relative h-full w-full${Lt?" tl-focus-active":""}`,children:[Mn&&!Le&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-gray-500",children:"Loading timeline…"}),Fn&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-red-500",children:String(Fn)}),Le&&Le.prs.length===0&&Le.events.length===0&&n.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."}),n.jsx("div",{ref:a,className:"h-full w-full"}),n.jsx("svg",{ref:C,className:"tl-cross-connectors","aria-hidden":"true",style:{display:"none"}}),n.jsx("div",{ref:K,className:"tl-repo-sticky","aria-hidden":"true",style:{display:"none"}}),se&&n.jsx(n1,{state:se,eventsById:d.current,usersById:cn,prsById:hr,focusPrId:Lt?ce.current:null,onContextFocus:Vs,onDismiss:Or,onNavigate:mi}),We&&n.jsx(Aw,{gid:We.gid,uid:We.uid,user:cn.get(We.uid),stats:Pt.current.get(We.uid)??{comments:0,reviews:0,prsOpen:0,prsMerged:0,prsClosed:0},x:We.x,y:We.y,onDismiss:()=>st(null)})]})}const Fo=Pu;function m1(e){return Fo.reduce((s,a)=>s+e[a],0)}function Gu({counts:e,compact:s=!1,activeState:a=null,onSegmentClick:o,className:i=""}){const u=m1(e);return s?n.jsx("span",{className:`inline-flex h-1.5 w-16 overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700 ${i}`,"aria-hidden":"true",children:u>0&&Fo.map(d=>e[d]>0?n.jsx("span",{style:{width:`${e[d]/u*100}%`,background:jt[d].color}},d):null)}):n.jsxs("div",{className:i,children:[n.jsx("div",{className:"flex h-2.5 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",children:u===0?null:Fo.map(d=>{if(e[d]===0)return null;const p=jt[d],m=n.jsx("span",{title:`${p.label}: ${e[d]}`,style:{width:`${e[d]/u*100}%`,background:p.color,opacity:a==null||a===d?1:.35},className:"block h-full"},d);return o?n.jsx("button",{type:"button",onClick:()=>o(d),title:`${p.label}: ${e[d]} — click to filter`,style:{width:`${e[d]/u*100}%`,background:p.color,opacity:a==null||a===d?1:.35},className:"block h-full transition-opacity hover:opacity-100","aria-pressed":a===d},d):m})}),n.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5",children:[Fo.map(d=>{const p=jt[d],m=a===d,g=a!=null&&!m,y=n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{background:p.color}}),n.jsx("span",{className:"tabular-nums",children:e[d]}),n.jsx("span",{children:p.label.toLowerCase()})]}),b=`flex items-center gap-1 text-[10px] ${g?"text-gray-400 opacity-60":"text-gray-600 dark:text-gray-300"}`;return o?n.jsx("button",{type:"button",onClick:()=>o(d),className:`${b} hover:underline`,"aria-pressed":m,title:p.description,children:y},d):n.jsx("span",{className:b,title:p.description,children:y},d)}),n.jsx("span",{className:"ml-auto text-[10px] tabular-nums text-gray-400",children:u})]})]})}function ci(e){return qe({queryKey:["ai-usage"],queryFn:()=>ge.aiUsage(),enabled:e,staleTime:3e4})}function h1(e){return e&&e.length>0?`repoIds=${e.join(",")}`:""}function g1(e,s){const a=h1(e);return qe({queryKey:["repo-digests",a],queryFn:()=>ge.repoDigests(a),enabled:s,staleTime:1/0})}function x1(e,s){return qe({queryKey:["repo-digest",e],queryFn:()=>ge.repoDigest(e),enabled:s&&e!=null,staleTime:1/0})}function y1(e,s){e.setQueriesData({queryKey:["repo-digests"]},a=>{if(!a)return a;const o=a.digests.findIndex(u=>u.repoId===s.repoId);if(o===-1)return a;const i=a.digests.slice();return i[o]=s,{...a,digests:i}})}const v1=5e3;function a0(e){return!e||e.total<=0?{value:null}:{value:e.completed/e.total*100,sub:`${e.completed}/${e.total}`}}function l0(){const e=Be(),[s,a]=x.useState(!1),[o,i]=x.useState(()=>new Set),[u,d]=x.useState(null),[p,m]=x.useState(null),g=x.useRef(null);return x.useEffect(()=>()=>{var b;return(b=g.current)==null?void 0:b.abort()},[]),x.useEffect(()=>{if(p==null)return;const b=window.setTimeout(()=>m(null),v1);return()=>window.clearTimeout(b)},[p]),{mutate:x.useCallback(b=>{var T;(T=g.current)==null||T.abort();const v=new AbortController;g.current=v,a(!0),m(null),i(new Set),d(null);const N=M=>i(D=>{if(!D.has(M))return D;const U=new Set(D);return U.delete(M),U}),I=b==null?void 0:Array.isArray(b)?b.length>0?`repoIds=${b.join(",")}`:void 0:`repoIds=${b}`,P=`/api/pro/activity/digests/refresh/stream${I?`?${I}`:""}`;let E=!1,w=!1,R=[],S=0,j=0;ti(P,{method:"POST",signal:v.signal,onEvent:M=>{switch(M.type){case"start":M.throttled&&(E=!0),M.creditsExhausted&&(w=!0);break;case"plan":R=M.toRegenerate,S=R.length,i(new Set(R)),d({completed:0,total:S});break;case"repo":j+=1,d({completed:j,total:S}),e.setQueryData(["repo-digest",M.digest.repoId],M.digest),y1(e,M.digest),N(M.digest.repoId);break;case"error":j+=1,d({completed:j,total:S}),N(M.repoId);break}}}).catch(()=>{}).finally(()=>{if(g.current===v){g.current=null,a(!1),i(new Set),d(null),m(w?"Out of AI credits this month — summaries resume on the 1st.":E?"Refreshed moments ago — showing the latest. Try again shortly.":S===0?"Already up to date — no new activity since the last digest.":null),e.invalidateQueries({queryKey:["ai-usage"]});for(const M of R)e.invalidateQueries({queryKey:["repo-digest",M]});R.length>0&&e.invalidateQueries({queryKey:["repo-digests"]})}})},[e]),isPending:s,refreshingRepoIds:o,progress:u,notice:p}}function b1(e){return{id:e.prId,number:e.prNumber,title:e.title??`#${e.prNumber}`,repoFullName:e.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null}}function o0(){const e=Oe(s=>s.openPrDetailTab);return s=>{s.prId!=null&&e(b1(s),{fromActivity:!0})}}const i0="pierre:collapsedDigests";function w1(){try{const e=localStorage.getItem(i0),s=e?JSON.parse(e):[];return new Set(Array.isArray(s)?s.filter(a=>typeof a=="number"):[])}catch{return new Set}}function k1(e){try{localStorage.setItem(i0,JSON.stringify([...e]))}catch{}}const bm=ml((e,s)=>({collapsed:w1(),toggle:a=>{const o=new Set(s().collapsed);o.has(a)?o.delete(a):o.add(a),k1(o),e({collapsed:o})}})),c0="pierre:insightsDigestsExpanded";function j1(){try{const e=localStorage.getItem(c0),s=e?JSON.parse(e):[];return new Set(Array.isArray(s)?s.filter(a=>typeof a=="number"):[])}catch{return new Set}}const wm=ml((e,s)=>({expanded:j1(),toggle:a=>{const o=new Set(s().expanded);o.has(a)?o.delete(a):o.add(a);try{localStorage.setItem(c0,JSON.stringify([...o]))}catch{}e({expanded:o})}})),u0="pierre:sprintReportUi";function N1(){const e={collapsed:!1,reposOpen:!1};try{const s=localStorage.getItem(u0);if(!s)return e;const a=JSON.parse(s);if(a==null||typeof a!="object")return e;const o=a;return{collapsed:typeof o.collapsed=="boolean"?o.collapsed:!1,reposOpen:typeof o.reposOpen=="boolean"?o.reposOpen:!1}}catch{return e}}const Ro=ml((e,s)=>{const a=()=>{try{const{collapsed:o,reposOpen:i}=s();localStorage.setItem(u0,JSON.stringify({collapsed:o,reposOpen:i}))}catch{}};return{...N1(),setCollapsed:o=>{e({collapsed:o}),a()},setReposOpen:o=>{e({reposOpen:o}),a()}}});function S1(e){const s=new Map,a=new Map;for(const o of e)o.prId!=null&&(s.set(`${o.repoFullName}#${o.prNumber}`,o),a.has(o.prNumber)||a.set(o.prNumber,o));return{byKey:s,byNumber:a}}const Yu=/([A-Za-z0-9][\w.-]*\/[A-Za-z0-9][\w.-]*)#(\d+)|#(\d+)/.source;function d0(e,s){const a=e[1]!=null,o=Number(a?e[2]:e[3]);return a?s.byKey.get(`${e[1]}#${o}`)??s.byNumber.get(o):s.byNumber.get(o)}function km(e,s,a,o=""){const i=[];let u=0,d=0;const p=new RegExp(Yu,"g");let m;for(;(m=p.exec(e))!=null;){m.index>u&&i.push(e.slice(u,m.index));const g=m[1]!=null,y=Number(g?m[2]:m[3]),b=g?s.byKey.get(`${m[1]}#${y}`)??s.byNumber.get(y):s.byNumber.get(y);if(b!=null){const v=`${b.repoFullName}#${b.prNumber}`;i.push(n.jsx("button",{type:"button",onClick:()=>a(b),className:"font-semibold text-sky-600 hover:underline dark:text-sky-400",title:b.title??v,children:v},`${o}r${d++}`))}else i.push(m[0]);u=m.index+m[0].length}return u<e.length&&i.push(e.slice(u)),i}function il(e,s,a){return e.split(/(\*\*[^*]+\*\*)/g).flatMap((i,u)=>{const d=/^\*\*([^*]+)\*\*$/.exec(i);return d!=null?[n.jsx("strong",{children:km(d[1]??"",s,a,`b${u}-`)},`b${u}`)]:km(i,s,a,`t${u}-`)})}const jm=e=>{const s=e.additions+e.deletions,a=e.openedAt?Math.max(0,(Date.now()-Date.parse(e.openedAt))/36e5):0;return s*a},Nm=(e,s)=>jm(s)-jm(e),Sm=e=>Number.isFinite(e)&&e>=1e4?`${Math.round(e/1e3)}k`:String(e??0);function C1(e,s){const a=[],o=new Set,i=new RegExp(Yu,"g");let u;for(;(u=i.exec(e))!=null;){const d=d0(u,s);if((d==null?void 0:d.prId)!=null){const p=`${d.repoFullName}#${d.prNumber}`;o.has(p)||(o.add(p),a.push(d))}}return a}function R1(e,s){const a=e.replace(new RegExp(Yu,"g"),(o,...i)=>{const u=i.slice(0,3),d=d0([o,...u],s);return(d==null?void 0:d.prId)!=null?"":o}).replace(/\s{2,}/g," ").replace(/\s*[,;](?:\s*[,;])+\s*/g,", ").replace(/,\s*(?:and|or)\s*,/gi,",").replace(/(^|[:,])\s*(?:and|or)\b\s*/gi,"$1 ").replace(/\s+(?:and|or)\s*([,.;:])/gi,"$1").replace(/:\s*,/g,":").replace(/\s+([,.;:])/g,"$1").replace(/,(?:\s*,)+/g,",").replace(/[\s,;:]+([.!?])/g,"$1").replace(/\s{2,}/g," ").replace(/^[\s:,.\-–—·•]+/,"").replace(/[\s,;:]+$/,"").trim();return/^[a-z]/.test(a)?a[0].toUpperCase()+a.slice(1):a}function I1(e,s){const a=e.split(`
48
- `).map(p=>p.replace(/`/g,"").trim()).filter(p=>p!==""&&!/^[-–—*_]{3,}$/.test(p)),o=[];let i=[],u=!1;const d=()=>{i.length!==0&&(i.sort((p,m)=>Nm(p.prs[0],m.prs[0])),o.push({kind:"prtable",groups:i}),i=[])};for(const p of a){const m=/^#{1,6}\s+(.*)$/.exec(p),g=p.replace(/^[-*]\s+/,"");if(!u){u=!0,o.push({kind:"headline",text:m?m[1]??"":g});continue}const y=C1(p,s);if(y.length>0){y.sort(Nm),i.push({prs:y,summary:R1(g,s)});continue}const b=/^\*\*(.+)\*\*$/.exec(g);d(),m?o.push({kind:"header",text:m[1]}):b?o.push({kind:"subhead",text:b[1]}):o.push({kind:"prose",text:g})}return d(),o}function T1({groups:e,onOpenPr:s,usersById:a,index:o}){return n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full min-w-[852px] table-fixed border-collapse text-[12px]",children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:"320px"}}),n.jsx("col",{style:{width:"24px"}}),n.jsx("col",{style:{width:"84px"}}),n.jsx("col",{style:{width:"110px"}}),n.jsx("col",{style:{width:"104px"}}),n.jsx("col",{})]}),n.jsx("thead",{children:n.jsxs("tr",{className:"text-left text-[9px] font-semibold uppercase tracking-wide text-gray-400",children:[n.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"Pull request"}),n.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"CI"}),n.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"Age"}),n.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"Author"}),n.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"Diff"}),n.jsx("th",{className:"pb-1 font-semibold",children:"Summary"})]})}),n.jsx("tbody",{children:e.map((i,u)=>i.prs.map((d,p)=>{const m=d.ciStatus?ur[d.ciStatus]:null,g=d.authorId!=null?a.get(d.authorId):void 0;return n.jsxs("tr",{className:"border-t border-gray-100 align-top dark:border-gray-800/60",children:[n.jsx("td",{className:"py-1 pr-2",children:n.jsxs("button",{type:"button",onClick:()=>s(d),className:"block text-left leading-snug hover:underline",title:`${d.repoFullName}#${d.prNumber}${d.title?` — ${d.title}`:""}`,children:[n.jsxs("span",{className:"font-semibold text-sky-600 dark:text-sky-400",children:["#",d.prNumber]})," ",n.jsx("span",{className:"text-gray-700 dark:text-gray-200",children:d.title??""})]})}),n.jsx("td",{className:"py-1 pr-2",children:n.jsx("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400",title:(m==null?void 0:m.label)??"no checks",children:n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:m?{background:m.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"},"aria-hidden":!0})})}),n.jsx("td",{className:"whitespace-nowrap py-1 pr-2 text-[11px] text-gray-500 dark:text-gray-400",children:d.openedAt?St(d.openedAt):"—"}),n.jsx("td",{className:"overflow-hidden py-1 pr-2",children:n.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-[11px] text-gray-600 dark:text-gray-300",children:[n.jsx("span",{className:"shrink-0",children:n.jsx(ht,{user:g,size:13})}),n.jsx("span",{className:"min-w-0 truncate",children:g?n.jsx(sn,{user:g,fallbackId:d.authorId??0}):d.authorLogin??"—"})]})}),n.jsxs("td",{className:"whitespace-nowrap py-1 pr-2 text-[11px]",children:[n.jsxs("span",{className:"font-mono text-green-600 dark:text-green-400",children:["+",Sm(d.additions)]})," ",n.jsxs("span",{className:"font-mono text-red-500 dark:text-red-400",children:["−",Sm(d.deletions)]})]}),p===0&&n.jsx("td",{rowSpan:i.prs.length,className:"py-1 align-top text-[12px] leading-relaxed text-gray-700 dark:text-gray-200",children:i.summary?il(i.summary,o,s):null})]},`${u}-${d.prId}`)}))})]})})}function Xu({markdown:e,prRefs:s,onOpenPr:a}){const{data:o}=$n(),i=x.useMemo(()=>ln(o),[o]),u=x.useMemo(()=>S1(s),[s]),d=x.useMemo(()=>I1(e,u),[e,u]),p=m=>m;return n.jsx("div",{className:"space-y-1.5",children:d.map((m,g)=>m.kind==="prtable"?n.jsx(T1,{groups:m.groups,onOpenPr:a,usersById:i,index:u},g):m.kind==="headline"?n.jsx("div",{className:"border-l-2 border-violet-400 pl-2 text-[13px] font-semibold leading-relaxed text-gray-800 dark:border-violet-500 dark:text-gray-100",children:p(il(m.text??"",u,a))},g):m.kind==="header"?n.jsx("div",{className:"pt-1 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:p(il(m.text??"",u,a))},g):m.kind==="subhead"?n.jsx("div",{className:"pt-1.5 text-[12px] font-semibold text-gray-700 dark:text-gray-200",children:p(il(m.text??"",u,a))},g):n.jsxs("div",{className:"flex gap-1.5 text-[13px] leading-relaxed text-gray-700 dark:text-gray-200",children:[n.jsx("span",{"aria-hidden":"true",className:"select-none text-gray-400",children:"•"}),n.jsx("span",{className:"min-w-0",children:p(il(m.text??"",u,a))})]},g))})}function E1({markdown:e,prRefs:s,onOpenPr:a}){return n.jsx(Xu,{markdown:e,prRefs:s,onOpenPr:a})}function P1(e){if(!e)return"Haiku";const s=e.toLowerCase();return s.includes("haiku")?"Haiku":s.includes("sonnet")?"Sonnet":s.includes("opus")?"Opus":e}function f0({digest:e,isLoading:s,title:a,collapsed:o,onToggle:i,onRegenerate:u,regenerating:d=!1,onOpenPr:p,showProBadge:m=!0,outOfCredits:g=!1}){return n.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:[n.jsxs("div",{onClick:i,className:"-mx-1 flex cursor-pointer select-none items-center gap-2 rounded px-1 hover:bg-violet-500/5",children:[n.jsxs("button",{type:"button",onClick:y=>{y.stopPropagation(),i()},"aria-expanded":!o,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:o?"Expand digest":"Collapse digest",children:[n.jsx("span",{"aria-hidden":"true",className:"text-[9px]",children:o?"▸":"▾"}),n.jsx("span",{"aria-hidden":"true",children:"✨"}),n.jsx("span",{className:"truncate normal-case",children:a})]}),m&&n.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"}),n.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-gray-400",children:[e!=null&&n.jsxs("span",{title:e.model,children:[P1(e.model)," · ",St(e.generatedAt),e.stale?" · stale":""]}),u!=null&&n.jsxs("button",{type:"button",onClick:y=>{y.stopPropagation(),u==null||u()},disabled:d||g,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:g?"Out of AI credits — resets next month":e==null?"Generate this repo's digest (runs the cheap-tier model)":"Regenerate this repo's digest (runs the cheap-tier model)",children:[n.jsx("span",{"aria-hidden":"true",children:"↻"}),g?"Out of credits":d?e==null?"Generating…":"Regenerating…":e==null?"Generate":"Regenerate"]})]})]}),!o&&n.jsx("div",{className:"mt-1",children:d?n.jsx(A1,{}):s?n.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()!==""?n.jsx("div",{className:"digest-fade-in",children:n.jsx(E1,{markdown:e.summary,prRefs:e.prRefs,onOpenPr:p})},e.generatedAt):n.jsx("p",{className:"text-xs text-gray-400",children:"No digest yet — click Generate to summarise this repo's recent activity."})})]})}function A1(){return n.jsx("div",{className:"space-y-1.5 py-0.5","aria-hidden":"true",children:["92%","80%","66%","74%"].map((e,s)=>n.jsx("div",{className:"digest-skeleton-line h-3",style:{width:e}},s))})}function p0({active:e,label:s="Regenerating digests",timeConstantSec:a=5,value:o,sub:i}){const[u,d]=x.useState(null),p=o!=null;if(x.useEffect(()=>{if(e){if(p){d(Math.max(0,Math.min(100,o)));return}const y=performance.now();d(8);const b=window.setInterval(()=>{const v=(performance.now()-y)/1e3;d(Math.min(92,8+84*(1-Math.exp(-v/a))))},200);return()=>window.clearInterval(b)}d(y=>y==null?null:100);const g=window.setTimeout(()=>d(null),500);return()=>window.clearTimeout(g)},[e,p,o,a]),u==null)return null;const m=Math.round(u);return n.jsxs("div",{className:"flex items-center gap-2 px-0.5","aria-live":"polite",children:[n.jsx("div",{className:"h-1 flex-1 overflow-hidden rounded-full bg-violet-100 dark:bg-violet-950/40",role:"progressbar","aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s,children:n.jsx("div",{className:"h-full rounded-full bg-violet-500 transition-[width] duration-200 ease-out dark:bg-violet-400",style:{width:`${u}%`}})}),n.jsx("span",{className:"shrink-0 whitespace-nowrap text-right text-[10px] tabular-nums text-violet-500 dark:text-violet-300",children:i??`${m}%`})]})}function $1({repoId:e}){var b,v;const{activityDigest:s}=yn(),{data:a,isLoading:o}=x1(e,s),i=l0(),u=o0(),d=ci(s),p=((b=d.data)==null?void 0:b.allowanceCredits)!=null&&(d.data.remainingCredits??0)<=0,m=bm(N=>N.collapsed.has(e)),g=bm(N=>N.toggle),y=i.refreshingRepoIds.has(e);return s?n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(f0,{digest:a,isLoading:o,title:"Digest",collapsed:m,onToggle:()=>g(e),onRegenerate:a==null||a.stale?()=>i.mutate(e):void 0,regenerating:y,onOpenPr:u,outOfCredits:p}),n.jsx(p0,{active:i.isPending&&(((v=i.progress)==null?void 0:v.total)??0)>0,label:"Regenerating digest",...a0(i.progress)}),i.notice!=null&&n.jsx("p",{className:"px-0.5 text-[11px] text-gray-400","aria-live":"polite",children:i.notice})]}):null}function M1({stats:e}){return n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-gray-500 dark:text-gray-400",children:[n.jsxs("span",{children:[n.jsx("span",{className:"font-semibold text-gray-700 dark:text-gray-200 tabular-nums",children:e.openPrs})," ","open"]}),n.jsxs("span",{children:[n.jsx("span",{className:"tabular-nums",children:e.draftPrs})," draft"]}),e.stalledPrs>0&&n.jsxs("span",{className:"text-amber-500",children:[n.jsx("span",{className:"tabular-nums",children:e.stalledPrs})," stalled ⏱"]}),e.medianHoursToFirstReview!=null&&n.jsxs("span",{title:"Median hours to first review",children:["TTFR"," ",n.jsx("span",{className:"tabular-nums",children:e.medianHoursToFirstReview<1?`${Math.round(e.medianHoursToFirstReview*60)}m`:`${Math.round(e.medianHoursToFirstReview)}h`})]}),e.oldestUnreviewed!=null&&n.jsxs("a",{href:e.oldestUnreviewed.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"hover:underline",title:e.oldestUnreviewed.title,children:["oldest unreviewed #",e.oldestUnreviewed.number," ·"," ",St(e.oldestUnreviewed.openedAt)]}),e.botThreads>0&&n.jsxs("span",{className:"text-sky-600 dark:text-sky-400",title:"Review-bot threads on open PRs, and the share a later commit has likely addressed (resolved or likely_addressed). An approximate signal — likely_addressed is a heuristic.",children:["🤖 ",n.jsx("span",{className:"tabular-nums",children:e.botThreads})," bot thread",e.botThreads===1?"":"s"," ·"," ",n.jsxs("span",{className:"tabular-nums",children:[Math.round(e.botThreadsActedOn/e.botThreads*100),"%"]})," ","acted on"]})]})}function F1({repo:e}){const s=e.maintainerIds.length;return n.jsxs("div",{className:"space-y-2 rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"min-w-0 truncate text-base font-semibold text-gray-800 dark:text-gray-100",children:e.repoFullName}),s>0&&n.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 text-[11px] text-gray-400",title:`${s} maintainer${s===1?"":"s"} (have merged here)`,children:[n.jsx(zu,{}),s]}),e.attentionCount>0&&n.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]}),n.jsx("span",{className:"ml-auto shrink-0 text-[11px] tabular-nums text-gray-400",children:e.stats.openPrs>0?`[${e.stats.openPrs}]`:"[—]"})]}),n.jsx(M1,{stats:e.stats}),n.jsx(Gu,{counts:e.threadTotals}),n.jsx($1,{repoId:e.repoId})]})}function xl(){const e=x.useRef(null),[s,a]=x.useState(0);return x.useEffect(()=>{const o=e.current;if(!o)return;const i=new ResizeObserver(u=>{var p;const d=(p=u[0])==null?void 0:p.contentRect.width;d!=null&&a(d)});return i.observe(o),a(o.clientWidth),()=>i.disconnect()},[]),[e,s]}const Ke={blue:"#3b82f6",green:"#22c55e",gray:"#9ca3af",orange:"#f97316",amber:"#f59e0b",purple:"#8957e5",red:"#ef4444",teal:"#14b8a6",pink:"#ec4899",slate:"#64748b"},Cm=[Ke.blue,Ke.green,Ke.amber,Ke.purple,Ke.teal,Ke.pink,Ke.slate];function Pn(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 s=e/24;return`${s<10?s.toFixed(1):Math.round(s)}d`}function _s(e){return new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function zs(e){return Math.abs(e)>=1e3?`${(e/1e3).toFixed(e%1e3===0?0:1)}k`:`${Math.round(e)}`}function Ju(e){if(e<=0)return 1;const s=Math.floor(Math.log10(e)),a=Math.pow(10,s),o=e/a;return(o<=1?1:o<=2?2:o<=5?5:10)*a}function ui({series:e}){return n.jsx("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5",children:e.map(s=>n.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-500 dark:text-gray-400",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-[2px]",style:{background:s.color}}),s.label]},s.label))})}function yl({x:e,y:s,width:a,children:o}){const i=Math.max(58,Math.min(e,Math.max(58,a-58)));return n.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:i,top:Math.max(s-6,0)},children:o})}function Et({title:e,note:s,children:a}){return n.jsxs("div",{className:"rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[n.jsxs("div",{className:"mb-1 flex items-baseline justify-between gap-2",children:[n.jsx("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-200",children:e}),s&&n.jsx("span",{className:"text-[10px] text-gray-400",children:s})]}),a]})}function wt({label:e="No data in this window"}){return n.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 Os({labels:e,series:s,area:a=!1,curved:o=!1,formatY:i=zs,height:u=132}){const[d,p]=xl(),[m,g]=x.useState(null),y=30,b=8,v=8,N=16,I=e.length,P=Math.max(p-y-b,1),E=u-v-N,w=Ju(Math.max(1,...s.flatMap(B=>B.values.map(_=>_??0)))),R=B=>y+(I<=1?P/2:B/(I-1)*P),S=B=>v+E*(1-B/w),j=v+E,T=B=>B.values.map((_,H)=>_==null?null:`${R(H)},${S(_)}`).reduce((_,H)=>H==null?{d:_.d,pen:!1}:{d:`${_.d}${_.pen?" L":" M"} ${H}`,pen:!0},{d:"",pen:!1}).d,M=B=>{const _=B.values.map((H,ee)=>H==null?null:[R(ee),S(H)]).filter(H=>H!=null);return _.length<2?"":`M ${_[0][0]} ${j} `+_.map(([H,ee])=>`L ${H} ${ee}`).join(" ")+` L ${_[_.length-1][0]} ${j} Z`},D=B=>{let _="";for(let H=0;H<B.length-1;H++){const ee=B[H-1]??B[H],ce=B[H],C=B[H+1],F=B[H+2]??C,K=ce[0]+(C[0]-ee[0])/6,ae=ce[1]+(C[1]-ee[1])/6,ne=C[0]-(F[0]-ce[0])/6,Pe=C[1]-(F[1]-ce[1])/6;_+=` C ${K} ${ae} ${ne} ${Pe} ${C[0]} ${C[1]}`}return _},U=B=>{const _=[];let H=[];return B.values.forEach((ee,ce)=>{ee==null?(H.length&&_.push(H),H=[]):H.push([R(ce),S(ee)])}),H.length&&_.push(H),_.map(ee=>{const ce=`M ${ee[0][0]} ${ee[0][1]}`;return ee.length<2?ce:ce+D(ee)}).join(" ")},G=B=>{const _=B.values.map((ce,C)=>ce==null?null:[R(C),S(ce)]).filter(ce=>ce!=null);if(_.length<2)return"";const H=_[0],ee=_[_.length-1];return`M ${H[0]} ${j} L ${H[0]} ${H[1]}`+D(_)+` L ${ee[0]} ${j} Z`},L=o?U:T,Y=o?G:M,X=B=>{const _=B.nativeEvent.offsetX,H=I<=1?0:Math.round((_-y)/P*(I-1));g(Math.max(0,Math.min(I-1,H)))};return n.jsxs("div",{children:[n.jsxs("div",{ref:d,className:"relative",style:{height:u},children:[p>0&&n.jsxs("svg",{width:p,height:u,className:"block",children:[[0,w].map(B=>n.jsxs("g",{children:[n.jsx("line",{x1:y,y1:S(B),x2:p-b,y2:S(B),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),n.jsx("text",{x:y-4,y:S(B)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:i(B)})]},B)),a&&s[0]&&Y(s[0])&&n.jsx("path",{d:Y(s[0]),fill:s[0].color,opacity:.12}),m!=null&&n.jsx("line",{x1:R(m),y1:v,x2:R(m),y2:j,className:"text-gray-300 dark:text-gray-600",stroke:"currentColor",strokeWidth:1}),s.map(B=>n.jsx("path",{d:L(B),fill:"none",stroke:B.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"},B.key)),s.map(B=>B.values.map((_,H)=>_==null?null:n.jsx("circle",{cx:R(H),cy:S(_),r:m===H?3:1.8,fill:B.color},`${B.key}-${H}`))),n.jsx("text",{x:y,y:u-4,className:"fill-gray-400 text-[8px]",children:e[0]?_s(e[0]):""}),n.jsx("text",{x:p-b,y:u-4,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:e[I-1]?_s(e[I-1]):""}),n.jsx("rect",{x:0,y:0,width:p,height:u,fill:"transparent",onMouseMove:X,onMouseLeave:()=>g(null)})]}),m!=null&&p>0&&n.jsxs(yl,{x:R(m),y:v,width:p,children:[n.jsx("div",{className:"font-medium",children:e[m]?_s(e[m]):""}),s.map(B=>n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-[1px]",style:{background:B.color}}),B.label,": ",B.values[m]==null?"—":i(B.values[m])]},B.key))]})]}),s.length>1&&n.jsx(ui,{series:s})]})}function L1({repoId:e,onOpenCharts:s}){const{data:a,isLoading:o}=ah(e),i=(a==null?void 0:a.weekBuckets)??[],u=[{key:"opened",label:"Opened",color:Ke.blue,values:(a==null?void 0:a.throughput.opened)??[]},{key:"merged",label:"Merged",color:Ke.green,values:(a==null?void 0:a.throughput.merged)??[]}],d=u.some(p=>p.values.some(m=>m>0));return n.jsxs("div",{className:"rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[n.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[n.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:["PR merge rate",a?` · ${a.windowDays/7}-wk`:""]}),n.jsx("button",{type:"button",onClick:s,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"})]}),o&&a==null?n.jsx("div",{className:"h-[132px] animate-pulse rounded bg-gray-50 dark:bg-gray-900/40"}):d?n.jsx(Os,{labels:i,series:u,area:!0,curved:!0}):n.jsx(wt,{})]})}function _1({prs:e,repoFullName:s}){const{data:a}=$n(),o=Oe(p=>p.openPrDetailTab),i=x.useMemo(()=>ln(a),[a]);if(e.length===0)return null;const u=e.reduce((p,m)=>p+(m.isDraft?1:0),0),d=e.length-u;return n.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800",children:[n.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 · ",d,u>0&&n.jsxs("span",{className:"font-normal normal-case text-gray-400",children:[" ","· ",u," draft",u===1?"":"s"]})]}),n.jsx("ul",{className:"divide-y divide-gray-100 dark:divide-gray-800/70",children:e.map(p=>{const m=ur[p.ciStatus],g=p.authorId!=null?i.get(p.authorId):void 0,y=oh[p.reasonTag],b=Yo(p.mergeable,p.mergeStateStatus),v=p.isApproved?{label:"approved",color:"#22c55e"}:p.isChangesRequested?{label:"changes",color:"#ef4444"}:null;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>o({id:p.id,number:p.number,title:p.title,repoFullName:s,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:[n.jsx("span",{"aria-hidden":"true",title:(m==null?void 0:m.label)??"no checks",className:"inline-block h-2 w-2 shrink-0 rounded-full",style:m!=null?{background:m.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"}}),Kx(p)&&n.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:"⚠"}),n.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[n.jsxs("span",{className:"text-gray-400",children:["#",p.number]})," ",n.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:p.title})]}),n.jsx(ht,{user:g,size:16}),n.jsx("span",{className:"max-w-[7rem] shrink-0 truncate text-gray-500 dark:text-gray-400",title:ft(g,p.authorId),children:ft(g,p.authorId)}),p.isDraft&&n.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"}),v!=null&&n.jsx("span",{className:"shrink-0 rounded px-1 text-[10px] font-semibold",style:{color:v.color,background:v.color+"1a"},children:v.label}),b!=null&&n.jsx("span",{className:"shrink-0 rounded bg-orange-500/15 px-1 text-[10px] font-medium text-orange-600 dark:text-orange-400",children:b}),n.jsx(Gu,{counts:p.threadCounts,compact:!0}),y.myTurn?n.jsx("span",{className:"hidden shrink-0 rounded px-1 text-[10px] font-medium sm:inline",style:{color:y.color,background:y.color+"1a"},title:ft(g,p.authorId),children:y.label}):n.jsx("span",{className:"hidden shrink-0 text-[10px] text-gray-400 sm:inline",children:St(p.updatedAt)})]})},p.id)})})]})}function O1(){const e=Be();return Ue({mutationFn:()=>ge.markFeedSeen(),onSuccess:()=>void e.invalidateQueries({queryKey:["me"]})})}const D1=50;function m0(e,s,a,o){const i=new URLSearchParams;return e&&e.length>0&&i.set("repoIds",e.join(",")),s&&s.length>0&&i.set("userIds",s.join(",")),a&&(i.set("excludeBots","true"),o.length>0&&i.set("allowBotIds",o.join(","))),i.toString()}function B1(e){var u,d,p,m,g;const s=m0(e.repoIds,e.userIds,e.excludeBots??!1,e.allowedBotIds??[]),a=Jg({queryKey:["consolidated-feed",s],initialPageParam:0,queryFn:({pageParam:y})=>{const b=new URLSearchParams(s);return b.set("limit",String(D1)),b.set("offset",String(y)),ge.consolidatedFeed(b.toString())},getNextPageParam:(y,b)=>{var I;const v=b.reduce((P,E)=>P+E.items.length,0),N=((I=b[0])==null?void 0:I.total)??0;return v<N?v:void 0},enabled:e.enabled??!0,staleTime:1/0,refetchOnMount:!1,placeholderData:y=>y}),{items:o,users:i}=x.useMemo(()=>{var N;const y=((N=a.data)==null?void 0:N.pages)??[],b=y.flatMap(I=>I.items),v=new Map;for(const I of y)for(const P of I.users)v.set(P.id,P);return{items:b,users:[...v.values()]}},[a.data]);return{items:o,users:i,total:((d=(u=a.data)==null?void 0:u.pages[0])==null?void 0:d.total)??0,generatedAt:((m=(p=a.data)==null?void 0:p.pages[0])==null?void 0:m.generatedAt)??null,latestId:((g=o[0])==null?void 0:g.id)??null,hasMore:a.hasNextPage,loadMore:a.fetchNextPage,isFetchingMore:a.isFetchingNextPage,isLoading:a.isLoading,isFetching:a.isFetching}}function z1(e){var p,m,g;const s=Be(),a=m0(e.repoIds,e.userIds,e.excludeBots??!1,e.allowedBotIds??[]),o=qe({queryKey:["feed-head",a],queryFn:()=>{const y=new URLSearchParams(a);return y.set("limit","1"),y.set("offset","0"),ge.consolidatedFeed(y.toString())},enabled:e.enabled??!0,refetchInterval:6e4,refetchIntervalInBackground:!1,staleTime:3e4}),i=((m=(p=o.data)==null?void 0:p.items[0])==null?void 0:m.id)??null,u=((g=o.data)==null?void 0:g.total)??0;return{hasNew:e.feedSettled&&i!=null&&(e.loadedLatestId==null||i!==e.loadedLatestId||u>e.loadedTotal),refresh:()=>{s.invalidateQueries({queryKey:["consolidated-feed"]}),s.invalidateQueries({queryKey:["feed-head"]})}}}function q1(e){if(e.kind==="claude_review")return{color:"#8957e5",label:"Claude Review"};if(e.kind==="review_submitted"&&e.reviewState!=null)return{color:U1[e.reviewState].color,label:`Review: ${K1[e.reviewState]}`};const s=lh[e.kind];return{color:(s==null?void 0:s.color)??"#6b7280",label:(s==null?void 0:s.label)??e.kind}}const U1={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"}},K1={approved:"Approved",changes_requested:"Request Changes",commented:"Comment",dismissed:"Dismissed",pending:"Pending"},H1={APPROVE:{label:"approve",color:"#22c55e"},REQUEST_CHANGES:{label:"request changes",color:"#ef4444"},COMMENT:{label:"comment",color:"#9ca3af"}};function W1(e,s){const a=ih(e);if(a)return{userId:(e==null?void 0:e.id)??null,kind:a.kind,label:a.label,color:a.color};if(e){const o=s.get(e.id);if(o&&o.automated&&o.kind!=null)return{userId:e.id,kind:o.kind,label:o.label,color:an(o.kind).color}}return null}function Rm(e){for(let s=(e==null?void 0:e.parentElement)??null;s;s=s.parentElement){const a=getComputedStyle(s).overflowY;if((a==="auto"||a==="scroll"||a==="overlay")&&s.scrollHeight>s.clientHeight)return s}return null}function su({repoId:e}){var bn;const s=te(re=>re.userIds),a=te(re=>re.excludeBots),o=te(re=>re.allowedBotIds),i=te(re=>re.feedMyTurnOnly),u=te(re=>re.toggleFeedMyTurnOnly),d=te(re=>re.feedClaudeOnly),p=te(re=>re.toggleFeedClaudeOnly),m=te(re=>re.feedBotLens),g=te(re=>re.cycleFeedBotLens),y=te(re=>re.showThreadInChanges),b=te(re=>re.selectPr),v=te(re=>re.showPrComment),N=te(re=>re.openClaudeReview),I=te(re=>re.focusEventInTab),P=Oe(re=>re.openPrDetailTab),E=Oe(re=>re.openPrFocusTab),{claudeReview:w}=yn(),{data:R}=xh(),S=yh(),j=x.useMemo(()=>{const re=new Map;for(const He of(R==null?void 0:R.reviewers)??[])He.classification.automated&&He.classification.kind!=null&&re.set(He.userId,He.classification);return re},[R]),T=S.isPending?((bn=S.variables)==null?void 0:bn.userId)??null:null,M=re=>{S.mutate({userId:re,body:{automated:!1}})},D=Oe(re=>re.activityFlashItemId),U=Oe(re=>re.clearActivityFlashItem),G=e!=null?[e]:null,L=O1(),Y=x.useRef(!1);x.useEffect(()=>{e==null&&!Y.current&&(Y.current=!0,L.mutate())},[e,L]);const{items:X,users:B,total:_,latestId:H,isLoading:ee,hasMore:ce,loadMore:C,isFetchingMore:F}=B1({repoIds:G,userIds:s,excludeBots:a,allowedBotIds:o}),K=x.useRef(null),{hasNew:ae,refresh:ne}=z1({repoIds:G,userIds:s,excludeBots:a,allowedBotIds:o,loadedLatestId:H,loadedTotal:_,feedSettled:!ee}),Pe=()=>{var re;ne(),(re=Rm(K.current))==null||re.scrollTo({top:0,behavior:"smooth"})},se=x.useMemo(()=>ln(B),[B]),Z=X.filter(re=>re.isMyTurn).length,je=X.filter(re=>re.kind==="claude_review").length,We=re=>{var He;return re.actorId!=null&&(((He=se.get(re.actorId))==null?void 0:He.isBot)??!1)},st=X.filter(We).length,Pt=i?X.filter(re=>re.isMyTurn):d?X.filter(re=>re.kind==="claude_review"):X,Lt=m==="hide"?Pt.filter(re=>!We(re)):m==="only"?Pt.filter(We):Pt,vn=x.useRef(new Map),[Le,Mn]=x.useState(null);x.useEffect(()=>{if(D==null)return;const re=D,He=requestAnimationFrame(()=>{const it=vn.current.get(re);it&&(it.scrollIntoView({block:"center",behavior:"smooth"}),Mn(re),window.setTimeout(()=>Mn(at=>at===re?null:at),1800)),U()});return()=>cancelAnimationFrame(He)},[D,U]);const Fn=x.useRef(null),_t=x.useRef(!1),Ln=x.useRef(()=>{});Ln.current=()=>{ce&&!F&&X.length>0&&C()};const Kt=ce&&X.length>0;x.useEffect(()=>{const re=Fn.current;if(!re)return;const He=new IntersectionObserver(it=>{var at;_t.current=((at=it[0])==null?void 0:at.isIntersecting)??!1,_t.current&&Ln.current()},{root:Rm(re),rootMargin:"0px 0px 600px 0px"});return He.observe(re),()=>He.disconnect()},[Kt]),x.useEffect(()=>{!F&&_t.current&&Ln.current()},[F,X.length,ce]);const pr=(re,He)=>({id:He,number:re.prNumber??0,title:re.prTitle??`#${re.prNumber??""}`,repoFullName:re.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null});function Fr(re){const He=re.prId;if(He==null)return;const it=pr(re,He),at={fromActivity:!0,returnItemId:re.id};if(re.kind==="claude_review"){N(it,at);return}P(it,at),re.threadId!=null?y(He,re.threadId):re.commentId!=null?v(He,re.commentId):b(He)}function Xn(re,He){const it=re.prId;it!=null&&(P(pr(re,it),{fromActivity:!0,returnItemId:re.id}),y(it,He))}function _n(re){const He=re.prId;if(He!=null&&(E(pr(re,He),{fromActivity:!0,returnItemId:re.id}),re.kind!=="claude_review")){const it=re.threadId??re.commentId??null,at=re.kind==="review_comment"?re.threadId:null;I(He,re.occurredAt,{type:re.kind,refId:it},at)}}return n.jsxs("div",{className:"space-y-3","data-testid":"feed-view",ref:K,children:[ae&&n.jsx("div",{className:"sticky top-0 z-10",children:n.jsxs("button",{type:"button",onClick:Pe,"data-testid":"feed-new-activity",className:"flex w-full items-center justify-center gap-2 rounded-full border border-sky-400 bg-sky-50 px-3 py-1.5 text-xs font-semibold text-sky-700 shadow-sm transition-colors hover:bg-sky-100 dark:border-sky-500/60 dark:bg-sky-950/50 dark:text-sky-300 dark:hover:bg-sky-900/60",children:[n.jsx("span",{"aria-hidden":"true",children:"↑"})," New activity — Refresh"]})}),n.jsxs("div",{className:"flex items-center gap-2 px-0.5",children:[n.jsxs("button",{type:"button",onClick:u,"aria-pressed":i,className:`flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${i?"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 (My Turn)",children:[n.jsx("span",{"aria-hidden":"true",children:"★"})," My Turn",Z>0&&n.jsx("span",{className:"tabular-nums opacity-70",children:Z})]}),w&&n.jsxs("button",{type:"button",onClick:p,"aria-pressed":d,className:`flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${d?"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:[n.jsx("span",{"aria-hidden":"true",children:"✨"})," Claude Reviews",je>0&&n.jsx("span",{className:"tabular-nums opacity-70",children:je})]}),st>0&&n.jsxs("button",{type:"button",onClick:g,"aria-pressed":m!=="all",className:`flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${m!=="all"?"border-sky-400 bg-sky-50 text-sky-700 dark:border-sky-500/60 dark:bg-sky-950/30 dark:text-sky-300":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:"Tame the bot firehose: click to cycle all activity → hide bot noise → bot activity only",children:[n.jsx("span",{"aria-hidden":"true",children:"🤖"}),m==="hide"?"Bots hidden":m==="only"?"Bots only":"Bots",m==="all"&&n.jsx("span",{className:"tabular-nums opacity-70",children:st})]}),X.length>0&&n.jsxs("span",{className:"text-[11px] text-gray-400",children:[Lt.length," of ",X.length]})]}),X.length===0?n.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."}):Lt.length===0?n.jsx("div",{className:"flex h-32 items-center justify-center text-sm text-gray-400",children:d?"No Claude Reviews in this window.":m==="only"?"No bot activity in this window.":m==="hide"?"Only bot activity here — nothing from humans in this window.":"Nothing needs your attention right now."}):n.jsx("ul",{className:"space-y-2",children:Lt.map(re=>{const He=re.actorId!=null?se.get(re.actorId):void 0,it=re.mergedById!=null?se.get(re.mergedById):void 0,at=it!=null||re.mergedById!=null?ft(it,re.mergedById):null,On=(re.reviewers??[]).map(on=>ft(se.get(on.userId),on.userId)),wn=W1(He,j);return n.jsx(J1,{item:re,actorUser:He,automatedTag:wn,onNotBot:M,overridePending:(wn==null?void 0:wn.userId)!=null&&T===wn.userId,mergedByLabel:at,reviewerLabels:On,usersById:se,flash:Le===re.id,innerRef:on=>{on?vn.current.set(re.id,on):vn.current.delete(re.id)},onOpen:()=>Fr(re),onOpenThread:on=>Xn(re,on),onFocus:()=>_n(re)},re.id)})}),Kt&&n.jsx("div",{ref:Fn,className:"flex justify-center pt-1",children:F?n.jsxs("span",{className:"flex items-center gap-2 py-1.5 text-xs text-gray-400",children:[n.jsx("span",{className:"h-3 w-3 animate-spin rounded-full border-2 border-gray-300 border-t-transparent dark:border-gray-600 dark:border-t-transparent"}),"Loading more…"]}):n.jsx("button",{type:"button",onClick:()=>void C(),className:"rounded-full border border-gray-300 px-4 py-1.5 text-xs font-medium text-gray-600 hover:border-gray-400 hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500 dark:hover:bg-gray-800/50",children:"Load more"})})]})}function V1({item:e}){const{data:s,isLoading:a}=qu(e.threadId),{data:o}=$n(),i=x.useMemo(()=>ln(o),[o]),u=x.useMemo(()=>{if(!s||e.actorId==null)return null;const p=new Date(e.occurredAt).getTime();let m=null;for(const g of s.comments){if(g.authorId!==e.actorId)continue;const y=Math.abs(new Date(g.createdAt).getTime()-p);(m==null||y<m.dist)&&(m={id:g.id,dist:y})}return(m==null?void 0:m.id)??null},[s,e.actorId,e.occurredAt]),d=e.prNumber!=null?`https://github.com/${e.repoFullName}/pull/${e.prNumber}`:"";return a?n.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Loading conversation…"}):s?n.jsx(hl,{thread:s,usersById:i,prUrl:d,repoId:e.repoId,highlightCommentId:u}):n.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Couldn’t load this conversation."})}function Q1({prId:e}){var i;const{data:s,isLoading:a}=Zo(e);if(a)return n.jsx("div",{className:"mt-1 px-1 text-xs text-gray-400",children:"Loading summary…"});const o=(i=s==null?void 0:s.body)==null?void 0:i.trim();return o?n.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:n.jsx(cr,{children:o})}):n.jsx("div",{className:"mt-1 px-1 text-xs text-gray-400",children:"No description."})}function G1({item:e}){const[s,a]=x.useState(!1),o=e.ciStatus!=null&&e.ciStatus!=="unknown"?ur[e.ciStatus]:null,i=e.changedFilesCount,u=e.prId;return n.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[(o!=null||i!=null)&&n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-gray-500 dark:text-gray-400",children:[o!=null&&n.jsxs("span",{className:"inline-flex items-center gap-1 font-medium",style:{color:o.color},children:[n.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-2 rounded-full",style:{background:o.color}}),o.label]}),i!=null&&n.jsxs("span",{children:[i," ",i===1?"file":"files"," changed"]})]}),u!=null&&n.jsxs("div",{onClick:d=>d.stopPropagation(),children:[n.jsx("button",{type:"button",onClick:()=>a(d=>!d),className:"text-[11px] font-medium text-sky-600 hover:underline dark:text-sky-400",children:s?"Hide summary":"Show summary"}),s&&n.jsx(Q1,{prId:u})]})]})}function Y1({thread:e,author:s,onOpen:a}){const o=jt[e.derivedState],i=e.path.split("/").pop()??e.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:a,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:[n.jsxs("span",{className:"flex items-center gap-1.5 text-[11px]",children:[n.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-2 shrink-0 rounded-full",style:{background:o.color}}),n.jsxs("code",{className:"truncate font-mono text-gray-600 group-hover/th:text-sky-600 dark:text-gray-300",children:[i,e.line!=null?`:${e.line}`:""]}),n.jsx("span",{className:"shrink-0 text-gray-400",children:o.label.toLowerCase()})]}),e.excerpt.trim()!==""&&n.jsxs("span",{className:"mt-0.5 block truncate text-xs italic text-gray-500 dark:text-gray-400",children:[s!=null?`${ft(s,e.authorId)}: `:"","“",e.excerpt,"”"]})]})})}const X1=160;function J1({item:e,actorUser:s,automatedTag:a,onNotBot:o,overridePending:i,mergedByLabel:u,reviewerLabels:d,usersById:p,flash:m,innerRef:g,onOpen:y,onOpenThread:b,onFocus:v}){const N=q1(e),I=e.isMyTurn,P=e.kind==="claude_review",E=e.kind==="pr_merged",w=P?"Claude":e.actorId==null&&e.kind==="commit_pushed"?"A contributor":ft(s,e.actorId),R=e.prNumber!=null?`#${e.prNumber}${e.prTitle!=null?` ${e.prTitle}`:""}`:"",S=e.claudeVerdict!=null?H1[e.claudeVerdict]:null,j=e.affectedThreads??[],T=e.myTurnReasons[0],M=e.kind==="review_comment"&&e.threadId!=null,D=e.kind==="pr_comment"&&e.prId!=null,U=e.kind==="pr_opened",[G,L]=x.useState(!1),Y=E&&u!=null&&e.mergedById!==e.actorId,X=E&&d.length>0,B=x.useRef(null),_=x.useRef(null),[H,ee]=x.useState(!1),[ce,C]=x.useState(!1),F=e.content!=null&&e.content.trim()!=="";x.useEffect(()=>{const ae=B.current,ne=_.current;if(!ae||!ne)return;const Pe=()=>{H||C(ae.scrollHeight>ae.clientHeight+4)};Pe();const se=new ResizeObserver(Pe);return se.observe(ne),()=>se.disconnect()},[e.content,H]);const K=ae=>{ae.target.closest("a,button")||y()};return n.jsx("li",{ref:g,children:n.jsxs("article",{onClick:K,className:`cursor-pointer rounded-md border p-2.5 text-sm transition-colors ${m?"border-sky-400 ring-2 ring-sky-400/60 dark:border-sky-500":I?"border-yellow-400 bg-yellow-50/40 dark:border-yellow-500/50 dark:bg-yellow-950/15":P?"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:[n.jsxs("div",{className:"flex items-center gap-2",children:[e.prId!=null&&n.jsx("button",{type:"button",onClick:ae=>{ae.stopPropagation(),v()},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:n.jsx(Xo,{size:13})}),n.jsx("span",{className:"shrink-0 text-[11px] text-gray-400",title:Ra(e.occurredAt),children:St(e.occurredAt)}),n.jsx(ht,{user:s,size:20}),n.jsx("span",{className:"truncate font-medium text-gray-800 dark:text-gray-100",children:w}),a&&n.jsxs("span",{className:"group/bot inline-flex shrink-0 items-center gap-1",children:[n.jsxs("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium",style:{color:a.color,background:`${a.color}1a`},title:`${a.label} — an automated reviewer Pierre triages`,children:[n.jsx("span",{"aria-hidden":!0,children:"🤖"}),a.label]}),a.userId!=null&&n.jsx("button",{type:"button",onClick:ae=>{ae.stopPropagation(),a.userId!=null&&o(a.userId)},disabled:i,className:"text-[9px] text-gray-400 underline underline-offset-2 opacity-0 transition-opacity hover:text-gray-600 disabled:opacity-40 group-hover/bot:opacity-100 dark:hover:text-gray-200",title:"Not a bot? Reclassify this reviewer as human",children:i?"saving…":"not a bot?"})]}),n.jsx("span",{className:"inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium",style:{color:N.color,background:N.color+"1a"},children:N.label}),S!=null&&n.jsx("span",{className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",style:{color:S.color,background:S.color+"1a"},children:S.label}),I&&n.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:"My Turn"}),I&&T!=null&&n.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(ae=>Mp[ae].title).join(" · "),children:Mp[T].label})]}),n.jsxs("div",{className:"mt-1 flex items-baseline gap-1.5 text-xs",children:[n.jsx("span",{className:"shrink-0 text-gray-400",children:e.repoFullName}),R!==""&&n.jsx("button",{type:"button",onClick:y,className:"min-w-0 truncate font-medium text-gray-700 hover:text-sky-600 hover:underline dark:text-gray-200",children:R}),e.path!=null&&n.jsxs("span",{className:"shrink-0 text-gray-400",children:["· ",e.path.split("/").pop()]})]}),U&&n.jsx(G1,{item:e}),F&&!M&&n.jsxs("div",{className:"mt-1.5 rounded bg-gray-50 px-2 py-1.5 text-sm dark:bg-gray-900/50",children:[n.jsx("div",{ref:B,className:H?"":"overflow-hidden",style:H?void 0:{maxHeight:X1},children:n.jsx("div",{ref:_,children:n.jsx(cr,{children:e.content})})}),(ce||H)&&n.jsx("button",{type:"button",onClick:()=>ee(ae=>!ae),className:"mt-1 text-[11px] font-medium text-sky-600 hover:underline dark:text-sky-400",children:H?"Show less":"Show more"})]}),e.mergedComments.length>0&&n.jsx("div",{className:"mt-1.5 space-y-1.5",children:e.mergedComments.map(ae=>n.jsxs("div",{className:"rounded bg-gray-50 px-2 py-1.5 text-sm dark:bg-gray-900/50",children:[n.jsx("div",{className:"mb-0.5 text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"Also commented"}),n.jsx("div",{className:"max-h-72 overflow-auto",children:n.jsx(cr,{children:ae.content})})]},ae.commentId))}),j.length>0&&n.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[e.changeSummary!=null&&n.jsx("div",{className:"text-[11px] font-medium text-gray-500 dark:text-gray-400",children:e.changeSummary}),n.jsx("ul",{className:"space-y-1.5",children:j.map(ae=>n.jsx(Y1,{thread:ae,author:ae.authorId!=null?p.get(ae.authorId):void 0,onOpen:()=>b(ae.threadId)},ae.threadId))})]}),(Y||X)&&n.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:[Y&&n.jsxs("span",{children:["Merged by ",n.jsx("span",{className:"font-medium",children:u})]}),X&&n.jsxs("span",{children:["Reviewed by ",n.jsx("span",{className:"font-medium",children:d.join(", ")})]})]}),M&&n.jsx("div",{className:"mt-1.5",onClick:ae=>ae.stopPropagation(),children:n.jsx(V1,{item:e})}),D&&e.prId!=null&&n.jsx("div",{className:"mt-1.5",children:G?n.jsx("div",{onClick:ae=>ae.stopPropagation(),children:n.jsx(Ku,{prId:e.prId,initialBody:ch(e.content,(s==null?void 0:s.githubLogin)??null),autoFocus:!0,onCancel:()=>L(!1),onDone:()=>L(!1)})}):n.jsx("button",{type:"button",onClick:ae=>{ae.stopPropagation(),L(!0)},className:"text-[11px] font-medium text-sky-600 hover:underline dark:text-sky-400",children:"Reply"})})]})})}function Z1(e){return qe({queryKey:["team-insights"],queryFn:()=>ge.teamInsights(),enabled:e,refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4})}function ek(){const e=yn();return e.teamInsights||e.activityDigest||e.slackDigest||e.issueLinks}function h0(e){return qe({queryKey:["pro-settings"],queryFn:ge.proSettings,enabled:e,staleTime:6e4})}function tk(){const e=Be();return Ue({mutationFn:s=>ge.updateProSettings(s),onSuccess:(s,a)=>{e.setQueryData(["pro-settings"],s),a.issue&&(e.invalidateQueries({queryKey:["pr"]}),e.invalidateQueries({queryKey:["thread"]})),a.sprint&&(e.invalidateQueries({queryKey:["team-insights"]}),e.invalidateQueries({queryKey:["team-metrics-detail"]}),e.invalidateQueries({queryKey:["sprint-report"]}))}})}const nk=[{key:"rolling_7",label:"7d"},{key:"rolling_14",label:"14d"},{key:"rolling_30",label:"30d"},{key:"sprint",label:"Sprint"}],rk={keep:{label:"Keep",className:"bg-green-500/10 text-green-700 dark:text-green-300 border border-green-500/30",title:"Healthy signal-to-noise — worth keeping on."},tune:{label:"Tune",className:"bg-amber-500/10 text-amber-700 dark:text-amber-300 border border-amber-500/30",title:"A lot of comments go untouched — consider muting the noisy paths/severities."},kill:{label:"Kill",className:"bg-red-500/10 text-red-700 dark:text-red-300 border border-red-500/30",title:"High volume, low acted-on, high untouched — probably not paying for itself."}};function Su(e){return e==null?"—":`${Math.round(e)}%`}function sk(e){return e==null?"—":`$${e.toFixed(2)}`}function ak(e,s){return e.map(a=>{const o=s.get(a.kind)??null,i=o!=null&&a.actedOn>0?o/a.actedOn:null;return{...a,costMonthlyUsd:o,costPerActedOnUsd:i}})}function lk({vendors:e}){const{labels:s,series:a}=x.useMemo(()=>{const o=new Set;for(const d of e)for(const p of d.trend)o.add(p.weekStart);const i=Array.from(o).sort().slice(-12),u=e.filter(d=>d.trend.length>0).map(d=>{const p=new Map(d.trend.map(m=>[m.weekStart,m.threads]));return{key:d.kind,label:d.label,color:an(d.kind).color,values:i.map(m=>p.get(m)??null)}});return{labels:i,series:u}},[e]);return s.length<2||a.length===0?n.jsx(wt,{label:"Not enough weekly history yet"}):n.jsx(Os,{labels:s,series:a,height:140,curved:!0})}function ok({suggestions:e}){var a;const s=Uu();return e.length===0?null:n.jsxs("div",{className:"rounded-lg border border-amber-300/50 bg-amber-50/50 p-3 dark:border-amber-500/30 dark:bg-amber-950/20",children:[n.jsx("div",{className:"mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-amber-700 dark:text-amber-300",children:"Tuning suggestions"}),n.jsx("ul",{className:"space-y-1.5",children:e.map((o,i)=>{const u=an(o.vendorKind),d=s.isPending;return n.jsxs("li",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]",children:[n.jsxs("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium",style:{color:u.color,background:`${u.color}1a`},children:["🤖 ",u.label]}),n.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:o.rationale}),n.jsx("button",{type:"button",onClick:()=>s.mutate({vendorKind:o.vendorKind,pathGlob:o.pathGlob,severity:o.severity,action:"hide"}),disabled:d,className:"ml-auto shrink-0 rounded border border-amber-400 px-1.5 py-0.5 font-medium text-amber-700 hover:bg-amber-100 disabled:opacity-50 dark:border-amber-600 dark:text-amber-200 dark:hover:bg-amber-900/30",title:"Hide this vendor's matching threads from the feed",children:d?"Adding…":"Create mute rule"})]},`${o.vendorKind}:${o.pathGlob??"*"}:${o.severity??"*"}:${i}`)})}),s.isError&&n.jsx("div",{className:"mt-1 text-[11px] text-red-500",children:((a=s.error)==null?void 0:a.message)??"Couldn’t create the rule."})]})}function ik({vendors:e,onOpenVendor:s}){return n.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-200 dark:border-gray-800",children:n.jsxs("table",{className:"w-full min-w-[680px] border-collapse text-[11px]",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-200 text-left text-gray-500 dark:border-gray-800 dark:text-gray-400",children:[n.jsx("th",{className:"px-2 py-1.5 font-medium",children:"Vendor"}),n.jsx("th",{className:"px-2 py-1.5 text-right font-medium",children:"Threads"}),n.jsx("th",{className:"px-2 py-1.5 text-right font-medium",children:"Comments"}),n.jsx("th",{className:"px-2 py-1.5 text-right font-medium",title:"A later commit likely addressed the thread, it was resolved, or a human replied/resolved after the bot",children:"Acted on"}),n.jsx("th",{className:"px-2 py-1.5 text-right font-medium",title:"Threads with no reply and no follow-up commit",children:"Untouched"}),n.jsx("th",{className:"px-2 py-1.5 text-right font-medium",title:"Untouched threads' oldest age",children:"Oldest"}),n.jsx("th",{className:"px-2 py-1.5 text-right font-medium",title:"Low-value / untouched share — the noise floor",children:"Noise"}),n.jsx("th",{className:"px-2 py-1.5 text-right font-medium",title:"Monthly vendor cost ÷ acted-on threads (from Pro settings)",children:"$/acted-on"}),n.jsx("th",{className:"px-2 py-1.5 text-center font-medium",children:"Verdict"})]})}),n.jsx("tbody",{children:e.map(a=>{const o=an(a.kind),i=rk[a.verdict];return n.jsxs("tr",{className:"border-b border-gray-100 last:border-0 dark:border-gray-800/60",children:[n.jsxs("td",{className:"px-2 py-1.5",children:[n.jsxs("button",{type:"button",onClick:()=>s(a.kind),title:"View this bot's PRs",className:"inline-flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 font-medium hover:underline",style:{color:o.color,background:`${o.color}1a`},children:["🤖 ",a.label]}),a.reviewers>1&&n.jsxs("span",{className:"ml-1 text-gray-400",children:["×",a.reviewers]})]}),n.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums",children:a.threads}),n.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums text-gray-500",children:a.comments}),n.jsxs("td",{className:"px-2 py-1.5 text-right tabular-nums",children:[n.jsx("span",{className:"text-gray-700 dark:text-gray-200",children:a.actedOn}),n.jsx("span",{className:"ml-1 text-gray-400",children:Su(a.actedOnPct)})]}),n.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums",children:n.jsx("span",{className:a.untouched>0?"text-amber-600 dark:text-amber-400":"text-gray-400",children:a.untouched})}),n.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums text-gray-500",children:a.oldestUntouchedDays!=null?`${a.oldestUntouchedDays}d`:"—"}),n.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums text-gray-500",children:Su(a.noiseRatioPct)}),n.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums text-gray-500",title:a.costMonthlyUsd!=null?`$${a.costMonthlyUsd}/mo`:"Set a monthly cost in Settings → Review bots",children:sk(a.costPerActedOnUsd)}),n.jsx("td",{className:"px-2 py-1.5 text-center",children:n.jsx("span",{className:`inline-block rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide ${i.className}`,title:i.title,children:i.label})})]},a.kind)})})]})})}function ck(){const e=te(b=>b.botAnalyticsWindow),s=te(b=>b.setBotAnalyticsWindow),a=te(b=>b.openBotPrsDetail),{data:o,isLoading:i,isError:u}=gh(e),{data:d}=h0(!0),p=x.useMemo(()=>new Map(((d==null?void 0:d.bots.cost)??[]).map(b=>[b.kind,b.monthlyUsd])),[d==null?void 0:d.bots.cost]),m=x.useMemo(()=>o?ak(o.vendors,p):[],[o,p]),g=n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("h3",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"Review-bot ROI"}),n.jsx("span",{className:"rounded bg-violet-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:"Pro"}),n.jsx("div",{className:"ml-auto inline-flex overflow-hidden rounded border border-gray-300 dark:border-gray-700",children:nk.map(b=>n.jsx("button",{type:"button",onClick:()=>s(b.key),className:`px-2 py-0.5 text-[11px] font-medium ${e===b.key?"bg-violet-500/15 text-violet-700 dark:text-violet-300":"text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800"}`,children:b.label},b.key))})]});let y;if(i)y=n.jsx("div",{className:"h-28 animate-pulse rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/40"});else if(u)y=n.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load bot analytics."});else if(!o||m.length===0)y=n.jsxs("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:["No automated-reviewer activity in this window.",n.jsx("div",{className:"mt-1 text-[11px]",children:"When review bots (CodeRabbit, Copilot, in-house AI…) comment on your PRs, their signal-to-noise lands here."})]});else{const b=o.totals;y=n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:[n.jsx("span",{className:"font-semibold tabular-nums text-gray-700 dark:text-gray-200",children:b.threads})," ","bot thread",b.threads===1?"":"s"," · ",b.comments," comment",b.comments===1?"":"s"," ·"," ",n.jsx("span",{className:"tabular-nums",children:Su(b.actedOnPct)})," acted on ·"," ",n.jsx("span",{className:"tabular-nums text-amber-600 dark:text-amber-400",children:b.untouched})," ","untouched ·"," ",n.jsxs("span",{title:"PRs whose only reviews/comments came from bots — no human review or comment since they opened",className:"cursor-help",children:[n.jsx("b",{className:"tabular-nums text-gray-700 dark:text-gray-200",children:b.botOnlyPrs})," ","bot-only PR",b.botOnlyPrs===1?"":"s"]})]}),n.jsx(ik,{vendors:m,onOpenVendor:a}),n.jsx(Et,{title:"Weekly thread volume",note:"last 12 weeks",children:n.jsx(lk,{vendors:m})}),n.jsx(ok,{suggestions:o.suggestions}),n.jsx("div",{className:"text-[11px] text-gray-400",children:"“Acted on” = a later commit likely addressed the thread, it was resolved, or a human replied/resolved after the bot (approximate). Verdicts + cost are deterministic — no AI. Set per-vendor monthly cost in Settings → Review bots to see $/acted-on."})]})}return n.jsxs("div",{className:"space-y-2","data-testid":"bot-roi-panel",children:[g,y]})}function uk(e){return qe({queryKey:["retro-report"],queryFn:ge.retroReport,enabled:e,staleTime:6e4})}const dk=5e3;function fk(){const e=Be(),[s,a]=x.useState(null);x.useEffect(()=>{if(s==null)return;const i=window.setTimeout(()=>a(null),dk);return()=>window.clearTimeout(i)},[s]);const o=Ue({mutationFn:ge.refreshRetroReport,onSuccess:i=>{var u;e.setQueryData(["retro-report"],i),e.invalidateQueries({queryKey:["ai-usage"]}),a(i.creditsExhausted?"Out of AI credits this month — summaries resume on the 1st.":i.throttled&&((u=i.report)!=null&&u.stale)?"Refreshed moments ago — showing the latest. Try again shortly.":null)}});return Object.assign(o,{notice:s})}function pk(e){return{id:e.prId,number:e.prNumber,title:e.title??`#${e.prNumber}`,repoFullName:e.repoFullName,authorLogin:e.authorLogin,authorDisplayName:null,authorAvatarUrl:null}}function Im(e){const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function mk(){return n.jsxs("div",{className:"space-y-1.5 py-0.5","aria-hidden":"true",children:[n.jsx("div",{className:"digest-skeleton-line h-3.5",style:{width:"52%"}}),["94%","88%","96%","72%","84%","68%","90%"].map((e,s)=>n.jsx("div",{className:"digest-skeleton-line h-3",style:{width:e}},s))]})}function hk(){var y,b;const{activityDigest:e}=yn(),s=Oe(v=>v.openPrDetailTab),{data:a,isLoading:o}=uk(e),i=fk(),u=ci(e),d=((y=u.data)==null?void 0:y.allowanceCredits)!=null&&(u.data.remainingCredits??0)<=0;if(!e)return null;const p=(a==null?void 0:a.report)??null,m=i.isPending,g=p!=null?`${Im(p.window.from)} – ${Im(p.window.to)}`:null;return n.jsx("div",{className:"mx-auto max-w-3xl p-4",children:n.jsxs("div",{className:"rounded-lg border border-violet-200 bg-violet-50/40 p-4 dark:border-violet-900/60 dark:bg-violet-950/20",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("span",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:[n.jsx("span",{"aria-hidden":"true",children:"✨"})," Retro"]}),n.jsx("span",{className:"shrink-0 rounded bg-violet-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:"Pro"}),g!=null&&n.jsxs("span",{className:"text-xs text-gray-400",children:["· ",g]}),n.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-gray-400",children:[p!=null&&n.jsxs("span",{title:p.model,children:["Haiku",p.stale?" · stale":""]}),p==null?n.jsx("button",{type:"button",onClick:()=>i.mutate(),disabled:m||d,className:"flex items-center gap-0.5 rounded border border-violet-300 px-1.5 py-0.5 font-medium text-violet-600 hover:border-violet-400 disabled:opacity-50 dark:border-violet-800 dark:text-violet-300 dark:hover:border-violet-600",title:d?"Out of AI credits — resets next month":"Generate a retrospective of the sprint window (runs the Haiku model)",children:d?"Out of credits":m?"Generating…":"Generate"}):p.stale&&n.jsxs("button",{type:"button",onClick:()=>i.mutate(),disabled:m||d,className:"flex items-center gap-0.5 rounded border border-violet-300 px-1.5 py-0.5 font-medium text-violet-600 hover:border-violet-400 disabled:opacity-50 dark:border-violet-800 dark:text-violet-300 dark:hover:border-violet-600",title:d?"Out of AI credits — resets next month":"Regenerate — the window has more activity since this was written (runs the Haiku model)",children:[n.jsx("span",{"aria-hidden":"true",children:"↻"}),d?"Out of credits":m?"Regenerating…":"Regenerate"]})]})]}),n.jsxs("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:["A retrospective of the period: what shipped and what it did, review-thread resolutions, CI failures & root causes, recurring themes, tone, and follow-ups. The window follows your ",n.jsx("span",{className:"font-medium",children:"Sprint"})," setting (sprint-to-date / 7 / 14 days)."]}),i.isError&&n.jsx("div",{className:"mt-2 text-[11px] text-red-500",children:((b=i.error)==null?void 0:b.message)??"Couldn’t generate the retro."}),!i.isError&&i.notice&&n.jsx("div",{className:"mt-2 text-[11px] text-gray-400",children:i.notice}),d&&n.jsx("div",{className:"mt-2 text-[11px] text-amber-600 dark:text-amber-400",children:"Out of AI credits this month — summaries resume on the 1st. Existing retros still show."}),n.jsx("div",{className:"mt-3",children:m?n.jsx(mk,{}):o?n.jsx("div",{className:"h-24 animate-pulse rounded bg-violet-500/5"}):p?n.jsxs("div",{className:"digest-fade-in",children:[n.jsx(Xu,{markdown:p.summary,prRefs:p.prRefs,onOpenPr:v=>s(pk(v),{fromActivity:!0})}),n.jsxs("div",{className:"mt-2 text-[10px] text-gray-400",children:["Generated ",new Date(p.generatedAt).toLocaleString()]})]},p.generatedAt):n.jsxs("div",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:["Tells the story of the past period — what merged, which review threads got resolved and how quickly, why CI failed, the themes that kept coming up, and what followed. Click ",n.jsx("span",{className:"font-medium",children:"Generate"})," above."]})})]})})}function gk(e){return qe({queryKey:["sprint-report"],queryFn:ge.sprintReport,enabled:e,staleTime:6e4})}const xk=5e3;function yk(){const e=Be(),[s,a]=x.useState(null);x.useEffect(()=>{if(s==null)return;const i=window.setTimeout(()=>a(null),xk);return()=>window.clearTimeout(i)},[s]);const o=Ue({mutationFn:ge.refreshSprintReport,onSuccess:i=>{var u;e.setQueryData(["sprint-report"],i),e.invalidateQueries({queryKey:["ai-usage"]}),a(i.creditsExhausted?"Out of AI credits this month — summaries resume on the 1st.":i.throttled&&((u=i.report)!=null&&u.stale)?"Refreshed moments ago — showing the latest. Try again shortly.":null)}});return Object.assign(o,{notice:s})}function vk({digests:e,isLoading:s,anyWatched:a,refreshingRepoIds:o,onRegenerateRepo:i,outOfCredits:u=!1,embedded:d=!1}){const{activityDigest:p}=yn(),{data:m}=Mr(),g=wm(I=>I.expanded),y=wm(I=>I.toggle),b=o0(),v=x.useMemo(()=>(m??[]).filter(I=>I.inboxWatch),[m]),N=x.useMemo(()=>new Map(e.map(I=>[I.repoId,I])),[e]);return p?n.jsxs("div",{className:"space-y-2",children:[!d&&n.jsx("div",{className:"flex items-center gap-2 px-0.5",children:n.jsxs("span",{className:"flex items-center gap-1 text-[11px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:[n.jsx("span",{"aria-hidden":"true",children:"✨"})," Repo summaries · watched repos"]})}),!a||v.length===0?n.jsx("p",{className:"px-0.5 text-xs text-gray-400",children:"No watched repos in view — Watch a repo (the eye toggle) to get a summary here."}):s&&e.length===0?n.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"}):n.jsx("div",{className:"space-y-2",children:v.map(I=>{const P=N.get(I.id);return n.jsx(f0,{digest:P,isLoading:!1,title:I.fullName,collapsed:!g.has(I.id),onToggle:()=>y(I.id),onRegenerate:(P==null||P.stale)&&i?()=>i(I.id):void 0,regenerating:o.has(I.id),onOpenPr:b,showProBadge:!1,outOfCredits:u},I.id)})})]}):null}function bk(e){return{id:e.prId,number:e.prNumber,title:e.title??`#${e.prNumber}`,repoFullName:e.repoFullName,authorLogin:e.authorLogin,authorDisplayName:null,authorAvatarUrl:null}}function wk({digests:e,digestsLoading:s=!1,anyWatched:a=!1,refreshingRepoIds:o,onRegenerateRepo:i,onRegenerateAllDigests:u,cascadeBusy:d=!1}){var D,U;const{activityDigest:p}=yn(),m=Oe(G=>G.openPrDetailTab),{data:g,isLoading:y}=gk(p),b=yk(),v=ci(p),N=((D=v.data)==null?void 0:D.allowanceCredits)!=null&&(v.data.remainingCredits??0)<=0,I=Ro(G=>G.collapsed),P=Ro(G=>G.setCollapsed),E=Ro(G=>G.reposOpen),w=Ro(G=>G.setReposOpen),R=e!==void 0&&a,S=(e==null?void 0:e.length)??0;if(!p)return null;const j=(g==null?void 0:g.report)??null,T=b.isPending||d,M=()=>{b.mutate(),u==null||u()};return n.jsxs("div",{className:"rounded-lg border border-violet-200 bg-violet-50/40 p-3 dark:border-violet-900/60 dark:bg-violet-950/20","data-testid":"sprint-report",children:[n.jsxs("div",{onClick:()=>P(!I),className:"-mx-1 flex cursor-pointer select-none items-center gap-2 rounded px-1 hover:bg-violet-500/5",children:[n.jsxs("button",{type:"button",onClick:G=>{G.stopPropagation(),P(!I)},"aria-expanded":!I,className:"flex items-center gap-1.5 text-sm font-semibold text-gray-700 hover:text-gray-900 dark:text-gray-200 dark:hover:text-white",children:[n.jsx("span",{className:"w-3 select-none text-gray-400",children:I?"▸":"▾"}),n.jsx("span",{"aria-hidden":"true",children:"✨"})," Sprint report"]}),n.jsx("span",{className:"shrink-0 rounded bg-violet-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:"Pro"}),n.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-gray-400",children:[j!=null&&n.jsxs("span",{title:j.model,children:["Haiku "," · ",St(j.generatedAt),j.stale?" · stale":""]}),j==null?n.jsx("button",{type:"button",onClick:G=>{G.stopPropagation(),M()},disabled:T||N,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:N?"Out of AI credits — resets next month":"Generate the first sprint report from the current Insights, and every watched repo’s summary (runs the Haiku model)",children:N?"Out of credits":T?"Generating…":"Generate"}):j.stale&&n.jsxs("button",{type:"button",onClick:G=>{G.stopPropagation(),M()},disabled:T||N,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:N?"Out of AI credits — resets next month":"Regenerate the sprint report and every changed repo summary — the Insights changed since it was written (runs the Haiku model)",children:[n.jsx("span",{"aria-hidden":"true",children:"↻"}),N?"Out of credits":T?"Regenerating…":"Regenerate"]})]})]}),b.isError&&n.jsx("div",{className:"mt-2 text-[11px] text-red-500",children:((U=b.error)==null?void 0:U.message)??"Couldn’t generate the report."}),!b.isError&&b.notice&&n.jsx("div",{className:"mt-2 text-[11px] text-gray-400",children:b.notice}),N&&n.jsx("div",{className:"mt-2 text-[11px] text-amber-600 dark:text-amber-400",children:"Out of AI credits this month — summaries resume on the 1st. Existing reports still show."}),!I&&n.jsx("div",{className:"mt-2",children:T?n.jsx(kk,{}):y?n.jsx("div",{className:"h-16 animate-pulse rounded bg-violet-500/5"}):j?n.jsxs("div",{className:"digest-fade-in",children:[n.jsx(Xu,{markdown:j.summary,prRefs:j.prRefs,onOpenPr:G=>m(bk(G),{fromActivity:!0})}),n.jsxs("div",{className:"mt-1.5 text-[10px] text-gray-400",children:["Generated ",new Date(j.generatedAt).toLocaleString()]})]},j.generatedAt):n.jsxs("div",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:["A prioritised, PR-linked summary of what needs attention this sprint — generated from the Insights below. Click"," ",n.jsx("span",{className:"font-medium",children:"Generate"})," above."]})}),!I&&R&&n.jsxs("div",{className:"mt-3 border-t border-violet-200/60 pt-2 dark:border-violet-900/40",children:[n.jsxs("button",{type:"button",onClick:()=>w(!E),className:"flex w-full items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:[n.jsx("span",{className:"w-3 select-none text-gray-400",children:E?"▾":"▸"}),n.jsx("span",{"aria-hidden":"true",children:"✨"})," Repo summaries",n.jsxs("span",{className:"font-normal text-gray-400",children:["· ",S]})]}),E&&n.jsx("div",{className:"mt-2",children:n.jsx(vk,{embedded:!0,digests:e??[],isLoading:s,anyWatched:a,refreshingRepoIds:o??new Set,onRegenerateRepo:i,outOfCredits:N})})]})]})}function kk(){return n.jsxs("div",{className:"space-y-1.5 py-0.5","aria-hidden":"true",children:[n.jsx("div",{className:"digest-skeleton-line h-3.5",style:{width:"58%"}}),["94%","88%","72%","80%","64%"].map((e,s)=>n.jsx("div",{className:"digest-skeleton-line h-3",style:{width:e}},s))]})}function ss({labels:e,series:s,mode:a="grouped",formatY:o=zs,formatValue:i=o,height:u=132,rotateLabels:d=!1}){const[p,m]=xl(),[g,y]=x.useState(null),b=30,v=8,N=8,I=d?40:16,P=e.length,E=Math.max(m-b-v,1),w=u-N-I,R=/^\d{4}-\d{2}-\d{2}T/.test(e[0]??""),S=B=>s.reduce((_,H)=>_+(H.values[B]??0),0),j=Ju(a==="stacked"?Math.max(1,...e.map((B,_)=>S(_))):Math.max(1,...s.flatMap(B=>B.values.map(_=>_??0)))),T=E/Math.max(P,1),M=B=>b+B*T+T*.15,D=T*.7,U=B=>N+w*(1-B/j),G=N+w,L=B=>{const _=Math.floor((B.nativeEvent.offsetX-b)/T);y(Math.max(0,Math.min(P-1,_)))},Y=B=>{const _=e[B]??"";return R?_s(_):_},X=!R||P<=8;return n.jsxs("div",{children:[n.jsxs("div",{ref:p,className:"relative",style:{height:u},children:[m>0&&n.jsxs("svg",{width:m,height:u,className:"block",children:[[0,j].map(B=>n.jsxs("g",{children:[n.jsx("line",{x1:b,y1:U(B),x2:m-v,y2:U(B),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),n.jsx("text",{x:b-4,y:U(B)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:o(B)})]},B)),g!=null&&n.jsx("rect",{x:b+g*T,y:N,width:T,height:w,className:"text-gray-400/10 dark:text-gray-300/10",fill:"currentColor"}),e.map((B,_)=>{if(a==="stacked"){let ee=0;return s.map(ce=>{const C=ce.values[_]??0;if(C<=0)return null;const F=U(ee+C),K=U(ee)-F;return ee+=C,n.jsx("rect",{x:M(_),y:F,width:D,height:Math.max(K,0),fill:ce.color},`${_}-${ce.key}`)})}const H=D/Math.max(s.length,1);return s.map((ee,ce)=>{const C=ee.values[_]??0;return C<=0?null:n.jsx("rect",{x:M(_)+ce*H,y:U(C),width:Math.max(H-.5,.5),height:G-U(C),fill:ee.color},`${_}-${ee.key}`)})}),e.map((B,_)=>{if(!(X||_===0||_===P-1))return null;const H=b+_*T+T/2;if(d){const ee=G+9;return n.jsx("text",{x:H,y:ee,textAnchor:"end",transform:`rotate(-35 ${H} ${ee})`,className:"fill-gray-400 text-[8px]",children:Y(_)},`lbl-${_}`)}return n.jsx("text",{x:H,y:u-4,textAnchor:"middle",className:"fill-gray-400 text-[8px]",children:Y(_)},`lbl-${_}`)}),n.jsx("rect",{x:0,y:0,width:m,height:u,fill:"transparent",onMouseMove:L,onMouseLeave:()=>y(null)})]}),g!=null&&m>0&&n.jsxs(yl,{x:b+g*T+T/2,y:N,width:m,children:[n.jsx("div",{className:"font-medium",children:Y(g)}),s.map(B=>n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-[1px]",style:{background:B.color}}),B.label,": ",i(B.values[g]??0)]},B.key)),a==="stacked"&&s.length>1&&n.jsxs("div",{className:"mt-0.5 border-t border-gray-200 pt-0.5 dark:border-gray-700",children:["total: ",i(S(g))]})]})]}),s.length>1&&n.jsx(ui,{series:s})]})}const Tm=e=>`${Math.round(e)}%`,jk=e=>String(Math.round(e));function al({label:e,stat:s,format:a,betterWhen:o,sub:i,onActivate:u}){const{value:d,previous:p,lowConfidence:m}=s,g=d!=null&&p!=null?d-p:null,y=g!=null&&g!==0&&g>0==(o==="up"),b=g!=null&&g!==0&&!m;return n.jsxs(Cu,{onActivate:u,children:[n.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wide text-gray-400",children:e}),n.jsx("div",{className:"text-lg font-semibold text-gray-800 dark:text-gray-100",children:d==null?"—":a(d)}),b?n.jsxs("div",{className:`text-[11px] ${y?"text-green-600 dark:text-green-400":"text-red-500 dark:text-red-400"}`,children:[g>0?"▲":"▼"," ",a(Math.abs(g))," ",n.jsx("span",{className:"text-gray-400",children:"vs last"})]}):m?n.jsx("div",{className:"text-[11px] text-gray-400",title:"Too few data points to read a trend yet (small sample)",children:p==null?"building baseline":`was ${a(p)}`}):n.jsx("div",{className:"text-[11px] text-gray-400",children:p==null?i:"no change"}),n.jsx("div",{className:"mt-0.5 text-[10px] text-gray-400",children:i})]})}function Cu({onActivate:e,children:s}){const a="block w-full rounded-lg border border-gray-200 bg-white p-2 text-left dark:border-gray-800 dark:bg-gray-900/40";return e?n.jsx("button",{type:"button",onClick:e,title:"Inspect the PRs behind this metric",className:`${a} cursor-pointer transition hover:border-gray-300 hover:bg-gray-50/70 focus:outline-none focus-visible:ring-2 focus-visible:ring-sky-400 dark:hover:border-gray-600 dark:hover:bg-gray-900/60`,children:s}):n.jsx("div",{className:a,children:s})}function Nk({metrics:e,onOpenMetric:s}){const[a,o]=x.useState(!1),i=e.weekBuckets,u=e.comparisonMode??"rolling_14",d=Math.max(1,Math.min(e.sprintDays,Math.ceil(e.elapsedDays??e.sprintDays))),p=u==="sprint"?`day ${d} of ${e.sprintDays} · vs same point last sprint`:`rolling ${e.sprintDays} days · vs prior ${e.sprintDays} days`,m=E=>E.reduce((w,R)=>w+R,0),g=E=>s?()=>s(E):void 0,y=[{key:"opened",label:"Opened",color:Ke.blue,values:e.throughput.opened},{key:"merged",label:"Merged",color:Ke.green,values:e.throughput.merged}],b=[{key:"lead",label:"Lead time",color:Ke.purple,values:e.leadTimeTrend}],v=[{key:"ci",label:"Merge CI success",color:Ke.green,values:e.ciSuccessTrend}],N=[{key:"recovery",label:"CI recovery",color:Ke.orange,values:e.ciRecoveryTrend}],I=[{key:"failures",label:"Failures",color:Ke.red,values:e.ciFailureReasons.map(E=>E.count)}],P=e.ciFailureReasons.map(E=>E.stage);return n.jsxs("div",{className:"space-y-3 rounded-lg border border-gray-200 bg-gray-50/50 p-3 dark:border-gray-800 dark:bg-gray-900/20","data-testid":"flow-metrics",children:[n.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[n.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-300",children:"Flow metrics"}),n.jsxs("span",{className:"text-[11px] text-gray-400",children:["DORA-ish · ",p,s?" · tap a tile to drill in":""]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-7",children:[n.jsxs(Cu,{onActivate:g("open_prs"),children:[n.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wide text-gray-400",children:"Open PRs"}),n.jsx("div",{className:"text-lg font-semibold text-gray-800 dark:text-gray-100",children:e.openPrs}),n.jsx("div",{className:"text-[11px] text-gray-400",children:"across all repos"}),n.jsx("div",{className:"mt-0.5 text-[10px] text-gray-400",children:"currently open"})]}),n.jsx(al,{label:"Merges",stat:e.merges,format:jk,betterWhen:"up",sub:"deploy frequency",onActivate:g("merges")}),n.jsx(al,{label:"Lead time",stat:e.leadTimeHours,format:Pn,betterWhen:"down",sub:"open → merge",onActivate:g("lead_time")}),n.jsx(al,{label:"Review latency",stat:e.timeToFirstReviewHours,format:Pn,betterWhen:"down",sub:"to first review",onActivate:g("review_latency")}),n.jsx(al,{label:"Merge CI",stat:e.mergeCiSuccessPct,format:Tm,betterWhen:"up",sub:"green at merge",onActivate:g("merge_ci")}),n.jsx(al,{label:"CI recovery",stat:e.ciRecoveryHours,format:Pn,betterWhen:"down",sub:"red → green",onActivate:g("ci_recovery")}),n.jsxs(Cu,{onActivate:g("ci_red"),children:[n.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wide text-gray-400",children:"CI red now"}),n.jsx("div",{className:`text-lg font-semibold ${e.ciFailingNow>0?"text-red-500 dark:text-red-400":"text-gray-800 dark:text-gray-100"}`,children:e.ciFailingNow}),n.jsx("div",{className:"text-[11px] text-gray-400",children:e.ciFailingNow>0&&e.ciFailingMedianAgeHours!=null?`~${Pn(e.ciFailingMedianAgeHours)} unresolved`:"all green"}),n.jsx("div",{className:"mt-0.5 text-[10px] text-gray-400",children:"recovery pressure"})]})]}),n.jsx("h4",{className:"pt-1 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"12-week trend"}),n.jsxs("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-3",children:[n.jsx(Et,{title:"Throughput",note:"opened vs merged · weekly",children:m(e.throughput.opened)+m(e.throughput.merged)===0?n.jsx(wt,{}):n.jsx(ss,{labels:i,series:y,mode:"grouped"})}),n.jsx(Et,{title:"CI recovery time",note:"median red→green · weekly",children:e.ciRecoveryTrend.every(E=>E==null)?n.jsx(wt,{label:"No CI recoveries yet — accrues from sync"}):n.jsx(Os,{labels:i,series:N,area:!0,curved:!0,formatY:Pn})}),n.jsx(Et,{title:"CI failures by stage",note:"which checks fail · window",children:P.length===0?n.jsx(wt,{label:"No CI failures recorded yet"}):n.jsx(ss,{labels:P,series:I,rotateLabels:!0})})]}),n.jsxs("div",{children:[n.jsxs("button",{type:"button",onClick:()=>o(E=>!E),className:"text-[11px] font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:[a?"▾":"▸"," More charts — lead time · merge CI success"]}),a&&n.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-3 lg:grid-cols-2",children:[n.jsx(Et,{title:"Lead time for changes",note:"median open→merge · weekly",children:e.leadTimeTrend.every(E=>E==null)?n.jsx(wt,{}):n.jsx(Os,{labels:i,series:b,area:!0,curved:!0,formatY:Pn})}),n.jsx(Et,{title:"Merge CI success",note:"% green at merge · weekly",children:e.ciSuccessTrend.every(E=>E==null)?n.jsx(wt,{}):n.jsx(Os,{labels:i,series:v,curved:!0,formatY:Tm})})]})]})]})}function Em(e){const s=new Date(e);return new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth()+1,1)).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Pm({label:e,credits:s,hint:a}){return n.jsxs("div",{className:"flex items-baseline justify-between gap-3 py-1",children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-[12px] font-medium text-gray-700 dark:text-gray-200",children:e}),n.jsx("div",{className:"text-[10px] text-gray-400",children:a})]}),n.jsxs("div",{className:"whitespace-nowrap text-sm font-semibold tabular-nums text-gray-800 dark:text-gray-100",children:[s.toLocaleString()," ",n.jsx("span",{className:"text-[10px] font-normal text-gray-400",children:"cr"})]})]})}function Sk(){const{data:e,isLoading:s,isError:a}=ci(!0),o=e?new Date(e.monthStart).toLocaleDateString(void 0,{month:"long"}):"";return n.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white p-3 dark:border-gray-800 dark:bg-gray-900/40",children:[n.jsxs("div",{className:"mb-1 flex items-baseline gap-2",children:[n.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-300",children:"AI usage"}),n.jsx("span",{className:"text-[11px] text-gray-400",children:o?`${o} to date · credits`:"month to date · credits"})]}),s?n.jsx("div",{className:"h-16 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"}):a||!e?n.jsx("div",{className:"text-[11px] text-gray-400",children:"Usage isn’t available."}):(()=>{const i=e.allowanceCredits,u=i!=null,d=e.remainingCredits??0,p=u&&d<=0,m=u&&i>0?Math.min(100,Math.round(e.totalCredits/i*100)):0;return n.jsxs(n.Fragment,{children:[u&&n.jsxs("div",{className:"mb-2",children:[n.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[n.jsxs("div",{className:"text-[13px] font-semibold tabular-nums text-gray-800 dark:text-gray-100",children:[e.totalCredits.toLocaleString(),n.jsxs("span",{className:"text-gray-400",children:[" / ",i.toLocaleString()]})," ",n.jsx("span",{className:"text-[10px] font-normal text-gray-400",children:"cr"})]}),n.jsx("div",{className:`text-[11px] tabular-nums ${p?"font-medium text-amber-600 dark:text-amber-400":"text-gray-500 dark:text-gray-400"}`,children:p?"out of credits":`${d.toLocaleString()} left`})]}),n.jsx("div",{className:"mt-1 h-1.5 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",children:n.jsx("div",{className:`h-full rounded-full ${p?"bg-amber-500":"bg-violet-500"}`,style:{width:`${m}%`}})}),n.jsx("div",{className:"mt-1 text-[10px] text-gray-400",children:p?`Out of AI credits — resets ${Em(e.monthStart)}.`:`digest ≈ 9 cr · sprint ≈ 10 cr · resets ${Em(e.monthStart)}`})]}),n.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:[n.jsx(Pm,{label:"Summaries",credits:e.summaryCredits,hint:"digests · sprint report · analyses"}),n.jsx(Pm,{label:"Agentic tools",credits:e.agentCredits,hint:"Claude Review · AI Fix"})]}),!u&&n.jsxs("div",{className:"mt-1 flex items-baseline justify-between gap-3 border-t border-gray-200 pt-1.5 dark:border-gray-700",children:[n.jsx("div",{className:"text-[12px] font-semibold text-gray-700 dark:text-gray-200",children:"Total this month"}),n.jsxs("div",{className:"whitespace-nowrap text-base font-semibold tabular-nums text-violet-600 dark:text-violet-300",children:[e.totalCredits.toLocaleString()," ",n.jsx("span",{className:"text-[10px] font-normal text-gray-400",children:"cr"})]})]}),n.jsx("div",{className:"mt-1.5 text-[10px] text-gray-400",children:"An approximate measure of model usage across everything Pierre runs for you."})]})})()]})}const Ck={high:{border:"border-l-red-400 dark:border-l-red-500",dot:"bg-red-500"},warn:{border:"border-l-amber-400 dark:border-l-amber-500",dot:"bg-amber-500"},info:{border:"border-l-sky-400 dark:border-l-sky-500",dot:"bg-sky-500"}},Rk={bot_signal:"Review-bot signal",bot_only_review:"Only a bot reviewed",stalled_review:"Stalled review",untouched_thread:"Untouched thread",reviewer_load:"Review load",reviewer_routing:"Needs a reviewer"},Am=new Set(["bot_signal","bot_only_review"]),Ik=[{key:"overview",label:"Overview"},{key:"bots",label:"Bots"},{key:"retro",label:"Retro"}];function $m(e){return e<48?`${e}h`:`${Math.round(e/24)}d`}function ka(e,s){const a=e.authorId!=null?s.get(e.authorId):void 0;return{id:e.prId,number:e.prNumber,title:e.prTitle,repoFullName:e.repoFullName,authorLogin:(a==null?void 0:a.githubLogin)??null,authorDisplayName:(a==null?void 0:a.displayName)??null,authorAvatarUrl:(a==null?void 0:a.avatarUrl)??null}}function Lo({id:e,usersById:s}){const a=s.get(e);return n.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-gray-500/10 px-1.5 py-0.5 text-[11px]",children:[n.jsx(ht,{user:a,size:13}),n.jsx(sn,{user:a,fallbackId:e})]})}function Tk({kind:e}){const s=an(e);return n.jsxs("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium",style:{color:s.color,background:`${s.color}1a`},title:"This thread was opened by an automated reviewer",children:["🤖 ",s.label]})}function au({pr:e}){const s=e.ciStatus?ur[e.ciStatus]:null;return n.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-gray-500 dark:text-gray-400",children:[n.jsxs("span",{className:"inline-flex items-center gap-1",title:(s==null?void 0:s.label)??"no checks",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:s?{background:s.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"},"aria-hidden":!0}),(s==null?void 0:s.label)??"no checks"]}),n.jsxs("span",{children:[e.changedFiles," file",e.changedFiles===1?"":"s"]}),n.jsxs("span",{className:"font-mono",children:[n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions]})," ",n.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions]})]})]})}function lu({prId:e}){const[s,a]=x.useState(!1);return n.jsxs("div",{className:"mt-2",children:[n.jsxs("button",{type:"button",onClick:()=>a(o=>!o),className:"text-[11px] font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:[s?"▾":"▸"," PR summary"]}),s&&n.jsx(Ek,{prId:e})]})}function Ek({prId:e}){const{data:s,isLoading:a}=Zo(e);if(a)return n.jsx("div",{className:"mt-1 text-[11px] text-gray-400",children:"Loading…"});if(!s)return n.jsx("div",{className:"mt-1 text-[11px] text-gray-400",children:"Couldn’t load this PR."});const o=s.body!=null&&s.body.trim()!=="";return n.jsxs("div",{className:"mt-1 space-y-2 rounded border border-gray-200 bg-gray-50 p-2 dark:border-gray-800 dark:bg-gray-900/40",children:[o?n.jsx("div",{className:"max-h-64 overflow-auto text-sm",children:n.jsx(cr,{children:s.body})}):n.jsx("div",{className:"text-[11px] italic text-gray-400",children:"No PR description."}),n.jsx(kh,{pr:s})]})}function Pk({card:e}){const{data:s,isLoading:a}=qu(e.threadId),{data:o}=$n(),i=x.useMemo(()=>ln(o),[o]),u=`https://github.com/${e.repoFullName}/pull/${e.prNumber}`;return a?n.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Loading conversation…"}):s?n.jsx(hl,{thread:s,usersById:i,prUrl:u,repoId:e.repoId}):n.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Couldn’t load this conversation."})}function Ak({card:e,usersById:s}){var u;const a=hh(e.prId),o=e.suggestedReviewers.map(d=>d.userId),i=a.isSuccess;return n.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[n.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-gray-500",children:[n.jsx("span",{className:"font-medium",children:"Suggested reviewers"}),n.jsx("button",{type:"button",onClick:()=>a.mutate({userIds:o}),disabled:a.isPending||i||o.length===0,className:"rounded border border-violet-300 px-1.5 py-0.5 font-medium text-violet-700 hover:bg-violet-50 disabled:opacity-50 dark:border-violet-700 dark:text-violet-300 dark:hover:bg-violet-900/20",title:"Request these reviewers on GitHub",children:i?"✓ Requested":a.isPending?"Assigning…":`Assign${o.length>1?" all":""}`})]}),n.jsx("ul",{className:"space-y-1",children:e.suggestedReviewers.map(d=>n.jsxs("li",{className:"flex flex-wrap items-center gap-1.5 text-[11px] text-gray-500",children:[n.jsx(Lo,{id:d.userId,usersById:s}),n.jsx("span",{className:"text-gray-400",children:d.reason})]},d.userId))}),a.isError&&n.jsx("div",{className:"text-[11px] text-red-500",children:((u=a.error)==null?void 0:u.message)??"Couldn’t request reviewers."})]})}function Sa({card:e,right:s,onActivate:a,children:o,innerRef:i,flash:u=!1}){const d=Ck[e.severity],p=a?m=>{m.target.closest("a,button,textarea,input,[data-noactivate]")||a()}:void 0;return n.jsxs("li",{ref:i,onClick:p,className:`rounded-lg border border-l-4 border-gray-200 bg-white p-3 dark:border-gray-800 dark:bg-gray-900/40 ${d.border}${u?" ring-2 ring-sky-400/70":""}${a?" cursor-pointer hover:bg-gray-50/70 dark:hover:bg-gray-900/60":""}`,children:[n.jsxs("div",{className:"mb-1.5 flex items-center gap-2 text-[11px]",children:[n.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${d.dot}`,"aria-hidden":!0}),n.jsx("span",{className:"font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:Rk[e.kind]}),n.jsx("span",{className:"ml-auto text-gray-400",children:s})]}),o]})}function ou({card:e,onOpen:s}){return n.jsxs("div",{className:"flex min-w-0 items-baseline gap-1.5 text-sm",children:[n.jsxs("button",{type:"button",onClick:s,className:"min-w-0 truncate text-left font-medium text-gray-800 hover:underline dark:text-gray-100",title:"Open this PR on its Overview tab",children:[n.jsxs("span",{className:"text-gray-400",children:[e.repoFullName," #",e.prNumber]})," ",e.prTitle]}),n.jsx("a",{href:e.githubUrl,target:"_blank",rel:"noreferrer noopener",onClick:a=>a.stopPropagation(),className:"shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",title:"Open on GitHub",children:"↗"})]})}function $k({card:e,innerRef:s,flash:a,onOpen:o}){return n.jsxs(Sa,{card:e,innerRef:s,flash:a,right:`${e.prs.length} PR${e.prs.length===1?"":"s"}`,children:[n.jsxs("div",{className:"text-sm text-gray-800 dark:text-gray-100",children:["🤖 Only a bot reviewed"," ",n.jsx("span",{className:"font-semibold tabular-nums",children:e.prs.length})," PR",e.prs.length===1?"":"s"," — no human review"]}),n.jsx("ul",{className:"mt-1.5 space-y-1",children:e.prs.map(i=>n.jsxs("li",{className:"flex min-w-0 items-baseline gap-1.5 text-[11px]",children:[n.jsxs("button",{type:"button",onClick:()=>o({id:i.prId,number:i.number,title:i.title,repoFullName:i.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null},e.id),className:"min-w-0 truncate text-left text-gray-600 hover:underline dark:text-gray-300",title:"Open this PR on its Overview tab",children:[n.jsxs("span",{className:"text-gray-400",children:[i.repoFullName," #",i.number]})," ",i.title]}),n.jsx("span",{className:"shrink-0 rounded bg-gray-500/10 px-1 py-0.5 text-[10px] uppercase tracking-wide text-gray-500",children:i.state}),n.jsx("span",{className:"shrink-0 rounded px-1 py-0.5 text-[10px] font-medium text-amber-700 dark:text-amber-300",style:{background:"#f59e0b1a"},title:"The only review on this PR",children:i.botLabel}),n.jsx("a",{href:i.githubUrl,target:"_blank",rel:"noreferrer noopener",onClick:u=>u.stopPropagation(),className:"shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",title:"Open on GitHub",children:"↗"})]},i.prId))}),n.jsx("div",{className:"mt-2 text-[11px] text-gray-400",children:"A trust/safety hook — deterministic (no AI). Consider a human pass before these ship."})]})}function Mm({initialSubTab:e}={}){var H,ee,ce;const s=Oe(C=>C.openPrDetailTab),a=te(C=>C.showThreadInChanges),o=te(C=>C.openMetricsDetail),i=te(C=>C.openBotPrsDetail),{data:u,isLoading:d,isError:p}=Z1(!0),m=x.useMemo(()=>ln(u==null?void 0:u.users),[u==null?void 0:u.users]),[g,y]=x.useState(e??"overview");x.useEffect(()=>{e&&y(e)},[e]);const b=Oe(C=>C.activityFlashItemId),v=Oe(C=>C.clearActivityFlashItem),N=x.useRef(new Map),[I,P]=x.useState(null);x.useEffect(()=>{if(b==null)return;const C=b,F=requestAnimationFrame(()=>{const K=N.current.get(C);K&&(K.scrollIntoView({block:"center",behavior:"smooth"}),P(C),window.setTimeout(()=>P(ae=>ae===C?null:ae),1800)),v()});return()=>cancelAnimationFrame(F)},[b,v]);const E=(C,F)=>{F?N.current.set(C,F):N.current.delete(C)},{activityDigest:w,teamInsights:R}=yn(),{data:S}=Mr(),j=x.useMemo(()=>(S??[]).filter(C=>C.inboxWatch).map(C=>C.id),[S]),T=g1(j,w&&j.length>0),M=l0(),[D,U]=x.useState(!1),G=(C,F)=>s(C,{fromActivity:!0,returnItemId:F}),L=C=>{s(ka(C,m),{fromActivity:!0,returnItemId:C.id}),a(C.prId,C.threadId)},Y=(u==null?void 0:u.cards)??[],X=Y.filter(C=>!Am.has(C.kind)),B=Y.filter(C=>Am.has(C.kind)),_=C=>{switch(C.kind){case"stalled_review":return n.jsxs(Sa,{card:C,innerRef:F=>E(C.id,F),flash:I===C.id,right:`waiting ${$m(C.ageHours)}`,onActivate:()=>G(ka(C,m),C.id),children:[n.jsx(ou,{card:C,onOpen:()=>G(ka(C,m),C.id)}),n.jsx(au,{pr:C}),n.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5 text-[11px] text-gray-500",children:[n.jsx("span",{children:"waiting on"}),C.requestedReviewerIds.length>0?C.requestedReviewerIds.map(F=>n.jsx(Lo,{id:F,usersById:m},F)):n.jsx("span",{className:"italic",children:"no reviewer requested"})]}),n.jsx(lu,{prId:C.prId})]},C.id);case"untouched_thread":return n.jsxs(Sa,{card:C,innerRef:F=>E(C.id,F),flash:I===C.id,right:`${$m(C.ageHours)} old`,children:[n.jsxs("div",{className:"-m-1 cursor-pointer rounded p-1 hover:bg-gray-50/70 dark:hover:bg-gray-900/60",onClick:F=>{F.target.closest("a,button")||L(C)},children:[n.jsx(ou,{card:C,onOpen:()=>G(ka(C,m),C.id)}),n.jsx(au,{pr:C}),n.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5 text-[11px] text-gray-500",children:[n.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 font-mono",children:C.path}),n.jsx("span",{children:"· no reply since"}),C.originalCommenterId!=null&&n.jsx(Lo,{id:C.originalCommenterId,usersById:m}),C.botKind!=null&&n.jsx(Tk,{kind:C.botKind})]})]}),n.jsx("div",{className:"mt-2",children:n.jsx(Pk,{card:C})}),n.jsx(lu,{prId:C.prId})]},C.id);case"reviewer_routing":return n.jsxs(Sa,{card:C,innerRef:F=>E(C.id,F),flash:I===C.id,right:"unassigned",onActivate:()=>G(ka(C,m),C.id),children:[n.jsx(ou,{card:C,onOpen:()=>G(ka(C,m),C.id)}),n.jsx(au,{pr:C}),C.topPaths.length>0&&n.jsxs("div",{className:"mt-1 truncate text-[11px] text-gray-400",children:["touches"," ",n.jsx("span",{className:"font-mono",children:C.topPaths.slice(0,3).join(", ")})]}),n.jsx(Ak,{card:C,usersById:m}),n.jsx(lu,{prId:C.prId})]},C.id);case"reviewer_load":return n.jsxs(Sa,{card:C,innerRef:F=>E(C.id,F),flash:I===C.id,right:`${C.reviewsThisSprint} review${C.reviewsThisSprint===1?"":"s"} this sprint`,children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[n.jsx(Lo,{id:C.reviewerId,usersById:m}),n.jsxs("span",{className:"font-semibold text-gray-800 dark:text-gray-100",children:[C.pendingCount," pending review",C.pendingCount===1?"":"s"]})]}),C.pendingPrs.length>0&&n.jsx("ul",{className:"mt-1.5 space-y-0.5",children:C.pendingPrs.map(F=>n.jsx("li",{className:"truncate text-[11px]",children:n.jsxs("button",{type:"button",onClick:()=>G({id:F.prId,number:F.prNumber,title:F.prTitle,repoFullName:F.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null},C.id),className:"text-left text-gray-500 hover:underline dark:text-gray-400",children:[n.jsxs("span",{className:"text-gray-400",children:[F.repoFullName," #",F.prNumber]})," ",F.prTitle]})},F.prId))})]},C.id);case"bot_signal":return n.jsxs(Sa,{card:C,innerRef:F=>E(C.id,F),flash:I===C.id,right:C.actedOnPct!=null?`${C.actedOnPct}% acted on`:void 0,children:[n.jsxs("div",{className:"text-sm text-gray-800 dark:text-gray-100",children:[n.jsx("span",{className:"font-semibold tabular-nums",children:C.totalThreads})," ","review-bot thread",C.totalThreads===1?"":"s"," this sprint ·"," ",n.jsx("span",{className:"tabular-nums",children:C.totalUntouched})," untouched",C.oldestUntouchedDays!=null&&C.totalUntouched>0&&n.jsxs(n.Fragment,{children:[", oldest"," ",n.jsx("span",{className:"tabular-nums",children:C.oldestUntouchedDays}),"d"]})]}),n.jsx("ul",{className:"mt-2 space-y-1",children:C.vendors.map(F=>{const K=an(F.kind),ae=F.threads>0?Math.round(F.actedOn/F.threads*100):0;return n.jsxs("li",{className:"flex flex-wrap items-center gap-x-2 text-[11px]",children:[n.jsxs("button",{type:"button",onClick:()=>i(F.kind),className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium hover:underline",style:{color:K.color,background:`${K.color}1a`},title:"View this bot's PRs",children:["🤖 ",K.label]}),n.jsxs("span",{className:"tabular-nums text-gray-500",children:[F.threads," thread",F.threads===1?"":"s"]}),n.jsx("span",{className:"text-gray-400",children:"·"}),n.jsxs("span",{className:"tabular-nums text-gray-500",children:[ae,"% acted on"]}),F.untouched>0&&n.jsxs("span",{className:"tabular-nums text-amber-600 dark:text-amber-400",children:["· ",F.untouched," untouched"]})]},F.kind)})}),n.jsx("div",{className:"mt-2 text-[11px] text-gray-400",children:"“Acted on” = a later commit touched the flagged file (approximate). Deterministic across every repo + bot — no AI."})]},C.id);case"bot_only_review":return n.jsx($k,{card:C,innerRef:F=>E(C.id,F),flash:I===C.id,onOpen:G},C.id);default:return null}};return n.jsxs("div",{className:"space-y-3","data-testid":"insights-view",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("h2",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"Insights"}),n.jsx("span",{className:"rounded bg-violet-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:"Pro"}),(u==null?void 0:u.sprint)&&n.jsxs("span",{className:"text-[11px] text-gray-400",children:["sprint: last ",((H=u.metrics)==null?void 0:H.sprintDays)??14,"d · ",Y.length," item",Y.length===1?"":"s"]}),n.jsx("div",{className:"ml-auto flex items-center gap-1.5",children:n.jsxs("button",{type:"button",onClick:()=>U(C=>!C),className:`rounded border px-1.5 py-0.5 text-[11px] font-medium ${D?"border-violet-300 bg-violet-50 text-violet-700 dark:border-violet-700 dark:bg-violet-950/30 dark:text-violet-300":"border-gray-300 hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-500"}`,title:"Show your month-to-date AI usage (in credits)",children:[D?"▾":"▸"," Track usage"]})})]}),D&&n.jsx(Sk,{}),n.jsx("div",{role:"tablist",className:"flex flex-wrap gap-1 border-b border-gray-200 dark:border-gray-800",children:Ik.map(({key:C,label:F})=>{const K=C===g;return n.jsx("button",{type:"button",role:"tab","aria-selected":K,onClick:()=>y(C),className:`-mb-px rounded-t-md border border-b-0 px-3 py-1.5 text-xs font-medium ${K?"border-gray-300 bg-white text-violet-600 dark:border-gray-700 dark:bg-gray-950 dark:text-violet-300":"border-transparent text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-900/60"}`,children:F},C)})}),g==="overview"?n.jsxs("div",{className:"space-y-3",children:[(u==null?void 0:u.metrics)&&n.jsx(Nk,{metrics:u.metrics,onOpenMetric:o}),n.jsx(wk,{digests:((ee=T.data)==null?void 0:ee.digests)??[],digestsLoading:T.isLoading,anyWatched:j.length>0,refreshingRepoIds:M.refreshingRepoIds,onRegenerateRepo:C=>M.mutate(C),onRegenerateAllDigests:j.length>0?()=>M.mutate(j):void 0,cascadeBusy:M.isPending}),n.jsx(p0,{active:M.isPending&&(((ce=M.progress)==null?void 0:ce.total)??0)>0,label:"Regenerating summaries",...a0(M.progress)}),d?n.jsx("div",{className:"space-y-3",children:[0,1,2].map(C=>n.jsx("div",{className:"h-20 animate-pulse rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/40"},C))}):p?n.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load insights."}):X.length===0?n.jsxs("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:["Nothing needs attention across your watched repos right now. 🎉",n.jsx("div",{className:"mt-1 text-[11px]",children:"Stalled reviews, untouched threads, reviewer load and un-assigned PRs will surface here."})]}):n.jsx("ul",{className:"space-y-2",children:X.map(C=>_(C))})]}):g==="bots"?n.jsxs("div",{className:"space-y-3",children:[R&&n.jsx(ck,{}),p?n.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load insights."}):B.length>0?n.jsx("ul",{className:"space-y-2",children:B.map(C=>_(C))}):null]}):n.jsx(hk,{})]})}function Fm({labels:e,series:s,formatValue:a=zs,height:o=132}){const[i,u]=xl(),[d,p]=x.useState(null),m=30,g=8,y=8,b=16,v=e.length,N=Math.max(u-m-g,1),I=o-y-b,P=(U,G)=>U.values[G]??0,E=U=>s.reduce((G,L)=>G+P(L,U),0),w=Ju(Math.max(1,...e.map((U,G)=>E(G)))),R=U=>m+(v<=1?N/2:U/(v-1)*N),S=U=>y+I*(1-U/w),j=y+I,T=[];{const U=e.map(()=>0);for(const G of s)T.push([...U]),e.forEach((L,Y)=>U[Y]=(U[Y]??0)+P(G,Y))}const M=(U,G)=>{const L=T[G],Y=e.map((B,_)=>[R(_),S(L[_]+P(U,_))]),X=e.map((B,_)=>[R(_),S(L[_])]).reverse();return`M ${Y.map(([B,_])=>`${B},${_}`).join(" L ")} L ${X.map(([B,_])=>`${B},${_}`).join(" L ")} Z`},D=U=>{const G=v<=1?0:Math.round((U.nativeEvent.offsetX-m)/N*(v-1));p(Math.max(0,Math.min(v-1,G)))};return n.jsxs("div",{children:[n.jsxs("div",{ref:i,className:"relative",style:{height:o},children:[u>0&&n.jsxs("svg",{width:u,height:o,className:"block",children:[[0,w].map(U=>n.jsxs("g",{children:[n.jsx("line",{x1:m,y1:S(U),x2:u-g,y2:S(U),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),n.jsx("text",{x:m-4,y:S(U)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:zs(U)})]},U)),s.map((U,G)=>n.jsx("path",{d:M(U,G),fill:U.color,opacity:.85},U.key)),d!=null&&n.jsx("line",{x1:R(d),y1:y,x2:R(d),y2:j,className:"text-gray-400 dark:text-gray-300",stroke:"currentColor",strokeWidth:1}),n.jsx("text",{x:m,y:o-4,className:"fill-gray-400 text-[8px]",children:e[0]?_s(e[0]):""}),n.jsx("text",{x:u-g,y:o-4,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:e[v-1]?_s(e[v-1]):""}),n.jsx("rect",{x:0,y:0,width:u,height:o,fill:"transparent",onMouseMove:D,onMouseLeave:()=>p(null)})]}),d!=null&&u>0&&n.jsxs(yl,{x:R(d),y,width:u,children:[n.jsx("div",{className:"font-medium",children:e[d]?_s(e[d]):""}),s.map(U=>n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-[1px]",style:{background:U.color}}),U.label,": ",a(P(U,d))]},U.key)),n.jsxs("div",{className:"mt-0.5 border-t border-gray-200 pt-0.5 dark:border-gray-700",children:["total: ",a(E(d))]})]})]}),s.length>1&&n.jsx(ui,{series:s})]})}function Mk({points:e,xLabel:s,yLabel:a,formatX:o=zs,formatY:i=zs,fit:u=!1,height:d=150}){const[p,m]=xl(),[g,y]=x.useState(null),b=32,v=8,N=8,I=18,P=Math.max(m-b-v,1),E=d-N-I,w=L=>Math.log10(1+Math.max(0,L)),R=w(Math.max(1,...e.map(L=>L.x))),S=w(Math.max(1,...e.map(L=>L.y))),j=L=>b+w(L)/(R||1)*P,T=L=>N+E*(1-w(L)/(S||1)),M=L=>[0,1,10,100,1e3,1e4].filter(Y=>w(Y)<=L+.01),D=(()=>{if(!u)return null;const L=e.filter(se=>se.x>0&&se.y>0);if(L.length<4)return null;const Y=L.map(se=>Math.log10(se.x)),X=L.map(se=>Math.log10(se.y)),B=L.length,_=Y.reduce((se,Z)=>se+Z,0)/B,H=X.reduce((se,Z)=>se+Z,0)/B;let ee=0,ce=0;for(let se=0;se<B;se++)ee+=(Y[se]-_)**2,ce+=(Y[se]-_)*(X[se]-H);if(ee===0)return null;const C=ce/ee,F=H-C*_,K=Math.min(...Y),ae=Math.max(...Y);if(ae<=K)return null;const ne=24;let Pe="";for(let se=0;se<=ne;se++){const Z=K+se/ne*(ae-K),je=10**Z,We=10**(F+C*Z);Pe+=`${se===0?"M":" L"} ${j(je).toFixed(1)} ${T(We).toFixed(1)}`}return{d:Pe,slope:C}})(),U=L=>{const Y=L.nativeEvent.offsetX,X=L.nativeEvent.offsetY;let B=-1,_=196;e.forEach((H,ee)=>{const ce=j(H.x)-Y,C=T(H.y)-X,F=ce*ce+C*C;F<_&&(_=F,B=ee)}),y(B>=0?B:null)},G=g!=null?e[g]:null;return n.jsxs("div",{children:[n.jsxs("div",{ref:p,className:"relative",style:{height:d},children:[m>0&&n.jsxs("svg",{width:m,height:d,className:"block",children:[M(S).map(L=>n.jsxs("g",{children:[n.jsx("line",{x1:b,y1:T(L),x2:m-v,y2:T(L),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),n.jsx("text",{x:b-4,y:T(L)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:i(L)})]},`y${L}`)),M(R).map(L=>n.jsx("text",{x:j(L),y:d-8,textAnchor:"middle",className:"fill-gray-400 text-[8px]",children:o(L)},`x${L}`)),e.map((L,Y)=>n.jsx("circle",{cx:j(L.x),cy:T(L.y),r:g===Y?4:2.2,fill:L.merged?Ke.green:Ke.gray,opacity:g==null||g===Y?.75:.3},Y)),D&&n.jsx("path",{d:D.d,fill:"none",stroke:Ke.amber,strokeWidth:1.5,strokeDasharray:"4 3",opacity:.95}),D&&n.jsxs("text",{x:b+5,y:N+9,fill:Ke.amber,className:"text-[8px] font-semibold",children:["≈ ",a," ∝ ",s,"^",D.slope.toFixed(1)]}),n.jsxs("text",{x:b,y:d-1,className:"fill-gray-400 text-[8px]",children:[s," →"]}),n.jsx("rect",{x:0,y:0,width:m,height:d,fill:"transparent",onMouseMove:U,onMouseLeave:()=>y(null)})]}),G&&m>0&&n.jsxs(yl,{x:j(G.x),y:T(G.y),width:m,children:[n.jsx("div",{className:"font-medium",children:G.label}),n.jsxs("div",{children:[s,": ",o(G.x)]}),n.jsxs("div",{children:[a,": ",i(G.y)]})]})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("span",{className:"text-[9px] text-gray-400",children:[a," (log) ↑"]}),n.jsx(ui,{series:[{label:"merged",color:Ke.green},{label:"closed",color:Ke.gray}]})]})]})}const iu=[1,2,3,4,5,6,0],Fk=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Lk=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function _k({cells:e,height:s}){const[a,o]=xl(),[i,u]=x.useState(null),d=26,p=2,m=14,y=Math.max(o-d-2,1)/24,b=s??p+7*m+14,v=Math.max(1,...e),N=P=>{const E=Math.floor((P.nativeEvent.offsetX-d)/y),w=Math.floor((P.nativeEvent.offsetY-p)/m);if(E<0||E>23||w<0||w>6){u(null);return}u({row:w,col:E})},I=(P,E)=>e[iu[P]*24+E]??0;return n.jsx("div",{children:n.jsxs("div",{ref:a,className:"relative",style:{height:b},children:[o>0&&n.jsxs("svg",{width:o,height:b,className:"block",children:[Fk.map((P,E)=>n.jsx("text",{x:d-4,y:p+E*m+m-4,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:P},P)),iu.map((P,E)=>Array.from({length:24},(w,R)=>{const S=I(E,R),j=(i==null?void 0:i.row)===E&&(i==null?void 0:i.col)===R;return n.jsx("rect",{x:d+R*y,y:p+E*m,width:Math.max(y-1,1),height:m-1,rx:1.5,fill:S>0?Ke.blue:"currentColor",className:S>0?"":"text-gray-100 dark:text-gray-800",fillOpacity:S>0?.15+.85*(S/v):1,stroke:j?Ke.blue:"none",strokeWidth:j?1.5:0},`${E}-${R}`)})),[0,6,12,18].map(P=>n.jsxs("text",{x:d+P*y,y:b-3,className:"fill-gray-400 text-[8px]",children:[P,":00"]},P)),n.jsx("rect",{x:0,y:0,width:o,height:b,fill:"transparent",onMouseMove:N,onMouseLeave:()=>u(null)})]}),i&&o>0&&n.jsxs(yl,{x:d+i.col*y+y/2,y:p+i.row*m,width:o,children:[Lk[iu[i.row]]," ",String(i.col).padStart(2,"0"),":00 ·"," ",I(i.row,i.col)," events"]})]})})}const ns=e=>e.reduce((s,a)=>s+a,0);function ll({title:e,children:s}){return n.jsxs("div",{children:[n.jsx("h3",{className:"mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:e}),n.jsx("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:s})]})}function Ok({data:e}){const{data:s}=$n(),a=ln(s),o=e.weekBuckets,i=`${e.windowDays/7}-wk · weekly`,u=[{key:"opened",label:"Opened",color:Ke.blue,values:e.throughput.opened},{key:"merged",label:"Merged",color:Ke.green,values:e.throughput.merged},{key:"closed",label:"Closed",color:Ke.gray,values:e.throughput.closed}],d=[{key:"open",label:"Open",color:Ke.blue,values:e.backlog.open},{key:"stalled",label:"Stalled",color:Ke.orange,values:e.backlog.stalled}],p=[{key:"median",label:"Median to 1st review",color:Ke.blue,values:e.reviewLatencyTrend.medianHours}],m=[{key:"ttfr",label:"Open → 1st review",color:Ke.amber,values:e.cycleBreakdown.toFirstReview},{key:"rtm",label:"1st review → close",color:Ke.blue,values:e.cycleBreakdown.reviewToMerge}],g=[{key:"count",label:"PRs",color:Ke.blue,values:e.reviewLatencyDist.map(S=>S.count)}],y=e.reviewLatencyDist.map(S=>S.label),b=[{key:"untouched",label:jt.untouched.label,color:jt.untouched.color,values:e.threadMix.untouched},{key:"replied",label:jt.replied_unresolved.label,color:jt.replied_unresolved.color,values:e.threadMix.replied_unresolved},{key:"likely",label:jt.likely_addressed.label,color:jt.likely_addressed.color,values:e.threadMix.likely_addressed},{key:"resolved",label:jt.resolved.label,color:jt.resolved.color,values:e.threadMix.resolved}],v=[{key:"approved",label:"Approved",color:Ke.green,values:e.reviewVerdicts.approved},{key:"changes",label:"Changes requested",color:Ke.orange,values:e.reviewVerdicts.changes_requested},{key:"commented",label:"Commented",color:Ke.gray,values:e.reviewVerdicts.commented},{key:"dismissed",label:"Dismissed",color:Ke.slate,values:e.reviewVerdicts.dismissed}],N=e.reviewerLoad.map((S,j)=>({key:String(S.userId),label:S.userId===-1?"Others":ft(a.get(S.userId),S.userId),color:Cm[j%Cm.length],values:S.weekly})),I=[{key:"count",label:"PRs",color:Ke.purple,values:e.sizeDist.map(S=>S.count)}],P=e.sizeDist.map(S=>S.label),E=e.sizeVsCycle.map(S=>({x:S.loc,y:S.hoursOpen,label:`#${S.prNumber}`,merged:S.merged})),w=e.sizeCycleByBucket.map(S=>S.label),R=[{key:"median",label:"Median time open",color:Ke.teal,values:e.sizeCycleByBucket.map(S=>S.medianHours??0)}];return n.jsxs("div",{className:"space-y-4",children:[n.jsxs(ll,{title:"Flow & throughput",children:[n.jsx(Et,{title:"PR throughput",note:i,children:ns(u.flatMap(S=>S.values))===0?n.jsx(wt,{}):n.jsx(ss,{labels:o,series:u,mode:"grouped"})}),n.jsx(Et,{title:"Open backlog & stalled",note:"weekly snapshot",children:Math.max(0,...e.backlog.open)===0?n.jsx(wt,{}):n.jsx(Os,{labels:o,series:d,curved:!0})})]}),n.jsxs(ll,{title:"Speed & latency",children:[n.jsx(Et,{title:"Time to first review",note:"weekly median",children:e.reviewLatencyTrend.medianHours.every(S=>S==null)?n.jsx(wt,{}):n.jsx(Os,{labels:o,series:p,area:!0,formatY:Pn,curved:!0})}),n.jsx(Et,{title:"Cycle-time breakdown",note:"by close week",children:ns(e.cycleBreakdown.count)===0?n.jsx(wt,{}):n.jsx(ss,{labels:o,series:m,mode:"stacked",formatY:Pn})}),n.jsx(Et,{title:"Review-latency distribution",note:"open → 1st review",children:ns(g[0].values)===0?n.jsx(wt,{}):n.jsx(ss,{labels:y,series:g})})]}),n.jsxs(ll,{title:"Review health",children:[n.jsx(Et,{title:"Thread-resolution mix",note:"by thread created week",children:ns(b.flatMap(S=>S.values))===0?n.jsx(wt,{}):n.jsx(Fm,{labels:o,series:b})}),n.jsx(Et,{title:"Review verdicts",note:i,children:ns(v.flatMap(S=>S.values))===0?n.jsx(wt,{}):n.jsx(ss,{labels:o,series:v,mode:"stacked"})}),n.jsx(Et,{title:"Reviews by reviewer",note:i,children:N.length===0?n.jsx(wt,{}):n.jsx(Fm,{labels:o,series:N})})]}),n.jsxs(ll,{title:"Size & risk",children:[n.jsx(Et,{title:"PR size distribution",note:"opened, by LOC",children:ns(I[0].values)===0?n.jsx(wt,{}):n.jsx(ss,{labels:P,series:I})}),n.jsx(Et,{title:"Median time open by size",note:"PRs closed in window",children:ns(e.sizeCycleByBucket.map(S=>S.count))===0?n.jsx(wt,{}):n.jsx(ss,{labels:w,series:R,formatY:Pn,formatValue:Pn})}),n.jsx(Et,{title:"Size vs. time open",note:"log–log · power-law fit",children:E.length===0?n.jsx(wt,{}):n.jsx(Mk,{points:E,xLabel:"LOC",yLabel:"time open",formatX:zs,formatY:Pn,fit:!0})})]}),n.jsx(ll,{title:"Cadence",children:n.jsx(Et,{title:"Activity heatmap",note:"by weekday × hour (UTC)",children:ns(e.activityHeatmap)===0?n.jsx(wt,{}):n.jsx(_k,{cells:e.activityHeatmap})})})]})}function Dk({repoId:e,repoName:s,onClose:a}){const{data:o,isLoading:i,error:u}=ah(e);return x.useEffect(()=>{if(e==null)return;const d=p=>{p.key==="Escape"&&(p.stopImmediatePropagation(),a())};return window.addEventListener("keydown",d,!0),()=>window.removeEventListener("keydown",d,!0)},[e,a]),e==null?null:n.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4",onClick:a,role:"presentation",children:n.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:d=>d.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Repo analytics",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("h2",{className:"truncate text-sm font-semibold",children:s??"Analytics"}),n.jsxs("p",{className:"text-[11px] text-gray-400",children:["Charts over the last ",o?o.windowDays/7:12," weeks"]})]}),n.jsx("button",{type:"button",onClick:a,className:"shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":"Close (Esc)",title:"Close (Esc)",children:"✕"})]}),n.jsxs("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-3",children:[i&&!o&&n.jsx("div",{className:"py-12 text-center text-sm text-gray-500",children:"Loading analytics…"}),u&&n.jsx("div",{className:"py-12 text-center text-sm text-red-500",children:"Failed to load analytics."}),o&&n.jsx(Ok,{data:o})]})]})})}let Ru=!1;function Bk(){Ru=!0}function zk(e){return[...e].sort((s,a)=>a.attentionCount!==s.attentionCount?a.attentionCount-s.attentionCount:s.hasUnread!==a.hasUnread?s.hasUnread?-1:1:s.repoFullName.localeCompare(a.repoFullName))}function qk(){const[,e]=x.useState(0);x.useEffect(()=>{const s=window.setInterval(()=>e(a=>a+1),3e4);return()=>window.clearInterval(s)},[])}function Uk({fullName:e,maintainerCount:s,hasUnread:a,attentionCount:o,openPrs:i,threadTotals:u,selected:d,onSelect:p}){const m=u!=null||a||o>0||i!=null;return n.jsxs("button",{type:"button",onClick:p,"aria-pressed":d,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 ${d?"border-sky-500 bg-sky-50 dark:bg-sky-950/30":"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800/50"}`,children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-gray-700 dark:text-gray-200",children:e}),s>0&&n.jsx(zu,{})]}),m&&n.jsxs("span",{className:"flex items-center gap-1.5 pl-0.5",children:[a&&n.jsx("span",{"aria-hidden":"true",title:"New activity",className:"inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-sky-500"}),u!=null&&n.jsx(Gu,{counts:u,compact:!0}),o>0&&n.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:["⚠",o]}),n.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-gray-400",children:i==null?"":i>0?`[${i}]`:"[—]"})]})]})}function Kk(){qk();const e=te(S=>S.userIds),s=te(S=>S.activityRepoId),a=te(S=>S.setActivityRepo),{teamInsights:o}=yn(),{data:i,isFetching:u,isLoading:d}=$x(null,e),{data:p}=Mr(),[m,g]=x.useState(null),y=x.useMemo(()=>zk((i==null?void 0:i.repos)??[]),[i==null?void 0:i.repos]),b=typeof s=="number"?y.find(S=>S.repoId===s)??null:null,v=s==="feed"||s==null,N=s==="insights",I=s==="retro";x.useEffect(()=>{!Ru&&o&&(Ru=!0,te.getState().activityRepoId==="feed"&&a("insights"))},[o,a]);const P=(i==null?void 0:i.generatedAt)??null,E=i!=null?y.map(S=>({repoId:S.repoId,fullName:S.repoFullName,maintainerCount:S.maintainerIds.length,hasUnread:S.hasUnread,attentionCount:S.attentionCount,openPrs:S.stats.openPrs,threadTotals:S.threadTotals})):(p??[]).map(S=>({repoId:S.id,fullName:S.fullName,maintainerCount:0,hasUnread:!1,attentionCount:0,openPrs:null,threadTotals:null})),w=i!=null&&y.length===0,R=(p??[]).length>0;return n.jsxs("div",{className:"flex h-full min-h-0 flex-col md:flex-row",children:[n.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:[n.jsx("div",{className:"flex items-center gap-2 border-b border-gray-200 px-3 py-2 dark:border-gray-800",children:n.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"State of play"})}),P!=null&&n.jsx("div",{className:"px-3 py-1 text-[10px] text-gray-400",title:new Date(P).toLocaleString(),children:St(P)}),u&&i!=null&&n.jsx("div",{className:"h-0.5 w-full overflow-hidden bg-sky-100 dark:bg-sky-950",children:n.jsx("div",{className:"h-full w-1/3 animate-pulse bg-sky-500"})}),n.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 ${u&&i!=null?"opacity-60 transition-opacity":""}`,children:[o&&n.jsxs("button",{type:"button",onClick:()=>a("insights"),"aria-pressed":N,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 ${N?"border-sky-500 bg-sky-50 dark:bg-sky-950/30":"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800/50"}`,title:"Team review-intelligence across your watched repos (Pro)",children:[n.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-violet-500",children:"◈"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-semibold text-gray-700 dark:text-gray-200",children:"Insights"}),n.jsx("span",{className:"shrink-0 rounded bg-violet-500/10 px-1 text-[9px] font-semibold uppercase text-violet-600 dark:text-violet-300",children:"Pro"})]}),n.jsxs("button",{type:"button",onClick:()=>a("feed"),"aria-pressed":v,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 ${v?"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:[n.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-sky-500",children:"✦"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-semibold text-gray-700 dark:text-gray-200",children:"Feed"})]}),E.map(S=>n.jsx(Uk,{fullName:S.fullName,maintainerCount:S.maintainerCount,hasUnread:S.hasUnread,attentionCount:S.attentionCount,openPrs:S.openPrs,threadTotals:S.threadTotals,selected:s===S.repoId,onSelect:()=>a(S.repoId)},S.repoId)),n.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(S=>n.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-400",title:jt[S].description,children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{background:jt[S].color}}),jt[S].label.toLowerCase()]},S))})]})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-3",children:N?n.jsx(Mm,{}):I?n.jsx(Mm,{initialSubTab:"retro"}):w?n.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-gray-400",children:R?"No watched repos yet. Open the repos dropdown in the filter bar and toggle Watch on a repo to populate the Activity console.":"No repos yet. Add a repo from the filter bar to populate the Activity console."}):v?n.jsx(su,{}):d&&i==null?n.jsx("div",{className:"space-y-3",children:[0,1,2].map(S=>n.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"},S))}):b!=null?n.jsxs("div",{className:"space-y-3","data-testid":"repo-console",children:[n.jsx(F1,{repo:b}),n.jsx(L1,{repoId:b.repoId,onOpenCharts:()=>g({repoId:b.repoId,name:b.repoFullName})}),n.jsx(_1,{prs:b.prs,repoFullName:b.repoFullName}),n.jsx(su,{repoId:b.repoId})]}):n.jsx(su,{})}),n.jsx(Dk,{repoId:(m==null?void 0:m.repoId)??null,repoName:(m==null?void 0:m.name)??null,onClose:()=>g(null)})]})}function Hk(e){return qe({queryKey:["team-metrics-detail"],queryFn:()=>ge.teamMetricsDetail(),enabled:e,refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4})}function Wk({repos:e,selected:s,onChange:a}){const[o,i]=x.useState(!1),u=x.useRef(null);Yn(u,()=>i(!1),o),x.useEffect(()=>{if(!o)return;const v=N=>{N.key==="Escape"&&(N.stopPropagation(),i(!1))};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[o]);const d=e.map(v=>v.id),p=d.length,m=s==null,g=v=>m||s.includes(v),y=v=>{const N=m?d:s,I=N.includes(v)?N.filter(P=>P!==v):[...N,v];a(I.length===p?null:I)},b=m?p:s.length;return n.jsxs("div",{ref:u,className:"relative",children:[n.jsxs("span",{className:"inline-flex items-center whitespace-nowrap rounded-full border border-gray-300 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[n.jsxs("button",{type:"button",onClick:()=>i(v=>!v),"aria-haspopup":"true","aria-expanded":o,className:`inline-flex items-center gap-1 py-0.5 pl-2.5 ${m?"pr-2.5":"pr-1"}`,children:[m?"All team repos":`Repos (${b}/${p})`,n.jsx("span",{"aria-hidden":!0,className:"text-[9px]",children:"▾"})]}),!m&&n.jsx("button",{type:"button",onClick:()=>a(null),title:"Show all team repos","aria-label":"Show all team repos",className:"py-0.5 pl-0.5 pr-2 opacity-60 hover:opacity-100",children:"✕"})]}),o&&n.jsxs("div",{role:"dialog","aria-label":"Filter by repo",className:"absolute right-0 top-full z-[60] mt-1 w-64 rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[n.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs font-medium hover:bg-gray-100 dark:hover:bg-gray-800",children:[n.jsx("input",{type:"checkbox",checked:m,onChange:()=>a(null)}),n.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:"All team repos"})]}),n.jsx("div",{className:"my-1 border-t border-gray-200 dark:border-gray-700"}),n.jsx("div",{className:"max-h-72 overflow-y-auto",children:p===0?n.jsx("div",{className:"px-1 py-2 text-xs text-gray-500",children:"No repos with data."}):e.map(v=>{const N=s!=null&&s.length===1&&s[0]===v.id;return n.jsxs("div",{className:"group flex items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[n.jsxs("label",{className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2",children:[n.jsx("input",{type:"checkbox",checked:g(v.id),onChange:()=>y(v.id)}),n.jsx("span",{className:"min-w-0 truncate text-gray-800 dark:text-gray-100",title:v.fullName,children:v.fullName})]}),p>1&&!N&&n.jsx("button",{type:"button",onClick:()=>a([v.id]),title:`Show only ${v.fullName}`,"aria-label":`Show only ${v.fullName}`,className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-gray-400 opacity-0 hover:bg-gray-200 hover:text-gray-700 focus:opacity-100 group-hover:opacity-100 dark:hover:bg-gray-700 dark:hover:text-gray-200",children:"only"})]},v.id)})})]})]})}const Lm={open_prs:{label:"Open PRs",blurb:"All currently-open PRs · longest-open first"},merges:{label:"Merges",blurb:"Merged this sprint · newest first"},lead_time:{label:"Lead time",blurb:"Open → merge (merged + open) · longest first"},review_latency:{label:"Review latency",blurb:"Open → first review · longest first"},merge_ci:{label:"Merge CI",blurb:"Merged PRs · CI-failed-at-merge first"},ci_recovery:{label:"CI recovery",blurb:"Red → green · slowest first"},ci_red:{label:"CI red now",blurb:"Currently-failing branches · longest red first"}};function cu(e,s){if(!e)return[];switch(s){case"open_prs":return e.openPrs;case"merges":return e.merges;case"lead_time":return e.leadTime;case"review_latency":return e.reviewLatency;case"merge_ci":return e.mergeCi;case"ci_recovery":return e.ciRecovery;case"ci_red":return e.ciRed}}function Vk({ci:e}){const s=e?ur[e]:null;return n.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:s?{background:s.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"},"aria-hidden":!0}),(s==null?void 0:s.label)??"no checks"]})}function Qk({pr:e}){return n.jsxs("span",{className:"whitespace-nowrap text-[11px]",children:[n.jsxs("span",{className:"text-gray-400",children:[e.changedFiles,"f"]})," ",n.jsxs("span",{className:"font-mono text-green-600 dark:text-green-400",children:["+",e.additions]})," ",n.jsxs("span",{className:"font-mono text-red-500 dark:text-red-400",children:["−",e.deletions]})]})}function _m({id:e,usersById:s}){const a=e!=null?s.get(e):void 0;return n.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-600 dark:text-gray-300",children:[n.jsx(ht,{user:a,size:14}),n.jsx(sn,{user:a,fallbackId:e??0})]})}function Gk({ids:e,usersById:s}){return e.length===0?n.jsx("span",{className:"text-[11px] italic text-gray-400",children:"none"}):n.jsx("span",{className:"flex flex-wrap gap-1",children:e.map(a=>{const o=s.get(a);return n.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-gray-500/10 px-1 py-0.5 text-[10px]",children:[n.jsx(ht,{user:o,size:11}),n.jsx(sn,{user:o,fallbackId:a})]},a)})})}function Yk(e){switch(e){case"open_prs":return"Open for";case"merges":case"lead_time":return"Lead time";case"review_latency":return"Latency";case"merge_ci":return"CI @ merge";case"ci_recovery":return"Recovery";case"ci_red":return"Red for"}}function Xk({m:e,pr:s}){const a=o=>o==null?"—":Pn(o);switch(e){case"open_prs":case"merges":case"lead_time":return n.jsx("span",{className:"font-medium",children:a(s.leadTimeHours)});case"review_latency":return n.jsx("span",{className:"font-medium",children:a(s.reviewLatencyHours)});case"ci_recovery":return n.jsx("span",{className:"font-medium text-orange-600 dark:text-orange-400",children:a(s.recoveryHours)});case"ci_red":return n.jsx("span",{className:"font-medium text-red-500 dark:text-red-400",children:a(s.redAgeHours)});case"merge_ci":{const o=s.ciStatus==="failure"||s.ciStatus==="error";return n.jsx("span",{className:`font-medium ${o?"text-red-500 dark:text-red-400":"text-gray-500"}`,children:s.ciStatus??"—"})}}}function Jk({m:e,pr:s,usersById:a,onOpen:o}){const i=e==="review_latency",u=e==="merges"||e==="merge_ci";return n.jsxs("tr",{className:"border-t border-gray-100 align-top hover:bg-gray-50/70 dark:border-gray-800/60 dark:hover:bg-gray-900/40",children:[n.jsx("td",{className:"py-1.5 pr-3",children:n.jsxs("button",{type:"button",onClick:()=>o(s),className:"block max-w-md text-left hover:underline",title:`${s.repoFullName} #${s.prNumber} — ${s.prTitle}`,children:[n.jsxs("span",{className:"block truncate font-mono text-[11px] text-gray-400",children:[s.repoFullName," #",s.prNumber]}),n.jsx("span",{className:"block truncate text-sm font-medium text-gray-800 dark:text-gray-100",children:s.prTitle})]})}),n.jsx("td",{className:"py-1.5 pr-3",children:n.jsx(Xk,{m:e,pr:s})}),n.jsx("td",{className:"py-1.5 pr-3",children:n.jsx(Vk,{ci:s.ciStatus})}),n.jsx("td",{className:"py-1.5 pr-3",children:n.jsx(Qk,{pr:s})}),n.jsx("td",{className:"py-1.5 pr-3",children:n.jsx(_m,{id:s.authorId,usersById:a})}),n.jsx("td",{className:"py-1.5 pr-3 text-[11px] text-gray-500 dark:text-gray-400",children:i?n.jsx(Gk,{ids:s.reviewerIds,usersById:a}):u?n.jsx(_m,{id:s.mergedById,usersById:a}):St(s.openedAt)})]})}function Zk({m:e,rows:s,usersById:a,onOpen:o}){const i=e==="review_latency"?"Reviewers":e==="merges"||e==="merge_ci"?"Merged by":"Opened";return n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full min-w-[720px] border-collapse text-sm",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"text-left text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:[n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Pull request"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:Yk(e)}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"CI"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Diff"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Author"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:i})]})}),n.jsx("tbody",{children:s.map(u=>n.jsx(Jk,{m:e,pr:u,usersById:a,onOpen:o},u.prId))})]})})}function ej(){const e=te(T=>T.metricsFocus),s=te(T=>T.consumeMetricsFocus),a=Oe(T=>T.openPrDetailTab),{data:o,isLoading:i,isError:u,refetch:d,isFetching:p}=Hk(!0),{data:m}=$n(),g=x.useMemo(()=>ln(m),[m]),[y,b]=x.useState(e??"merges");x.useEffect(()=>{e&&(b(e),s())},[e,s]);const v=(o==null?void 0:o.detail)??null,[N,I]=x.useState({}),P=N[y]??null,E=T=>I(M=>({...M,[y]:T})),w=x.useMemo(()=>{const T=new Map;if(v)for(const M of Np)for(const D of cu(v,M))T.set(D.repoId,D.repoFullName);return[...T.entries()].map(([M,D])=>({id:M,fullName:D})).sort((M,D)=>M.fullName.localeCompare(D.fullName))},[v]),R=cu(v,y),S=P==null?R:R.filter(T=>P.includes(T.repoId)),j=T=>{const M=T.authorId!=null?g.get(T.authorId):void 0,D={id:T.prId,number:T.prNumber,title:T.prTitle,repoFullName:T.repoFullName,authorLogin:(M==null?void 0:M.githubLogin)??null,authorDisplayName:(M==null?void 0:M.displayName)??null,authorAvatarUrl:(M==null?void 0:M.avatarUrl)??null};a(D)};return n.jsxs("div",{className:"mx-auto max-w-6xl space-y-4 p-4",children:[n.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[n.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:"Flow metrics"}),n.jsx("span",{className:"rounded bg-violet-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:"Pro"}),v&&n.jsx("span",{className:"text-[11px] text-gray-400",children:"sprint: last 2 weeks · where issues cluster"}),n.jsxs("button",{type:"button",onClick:()=>void d(),disabled:p,className:"ml-auto rounded border border-gray-300 px-1.5 py-0.5 text-[11px] font-medium hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:[n.jsx("span",{"aria-hidden":!0,className:p?"animate-spin":"",children:"↻"})," ","Refresh"]})]}),n.jsx("div",{role:"tablist",className:"flex flex-wrap gap-1 border-b border-gray-200 dark:border-gray-800",children:Np.map(T=>{const M=T===y,D=cu(v,T).length;return n.jsxs("button",{type:"button",role:"tab","aria-selected":M,onClick:()=>b(T),className:`-mb-px rounded-t-md border border-b-0 px-3 py-1.5 text-xs font-medium ${M?"border-gray-300 bg-white text-violet-600 dark:border-gray-700 dark:bg-gray-950 dark:text-violet-300":"border-transparent text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-900/60"}`,children:[Lm[T].label,v?n.jsx("span",{className:"ml-1 text-gray-400",children:D}):null]},T)})}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("div",{className:"text-[11px] text-gray-400",children:Lm[y].blurb}),S.length!==R.length&&n.jsxs("span",{className:"text-[11px] text-gray-400",children:["· ",S.length," of ",R.length]}),n.jsx("div",{className:"ml-auto",children:n.jsx(Wk,{repos:w,selected:P,onChange:E})})]}),i?n.jsx("div",{className:"space-y-2",children:[0,1,2,3].map(T=>n.jsx("div",{className:"h-8 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"},T))}):u?n.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load the metric detail."}):S.length===0?n.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:R.length===0?"Nothing to show for this metric in the current sprint. 🎉":"No PRs for the selected repos — adjust the repo filter."}):n.jsx(Zk,{m:y,rows:S,usersById:g,onOpen:j})]})}function tj(e,s,a=!0){return qe({queryKey:["bot-vendor-prs",e,s],queryFn:()=>ge.botVendorPrs(e,s),enabled:a&&e!=null,refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4})}const nj=[{key:"rolling_7",label:"7d"},{key:"rolling_14",label:"14d"},{key:"rolling_30",label:"30d"},{key:"sprint",label:"Sprint"}],rj=[];function sj({ci:e}){const s=e?ur[e]:null;return n.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:s?{background:s.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"},"aria-hidden":!0}),(s==null?void 0:s.label)??"no checks"]})}function aj({pr:e}){return n.jsxs("span",{className:"whitespace-nowrap text-[11px]",children:[n.jsxs("span",{className:"text-gray-400",children:[e.changedFiles,"f"]})," ",n.jsxs("span",{className:"font-mono text-green-600 dark:text-green-400",children:["+",e.additions]})," ",n.jsxs("span",{className:"font-mono text-red-500 dark:text-red-400",children:["−",e.deletions]})]})}function lj({id:e,usersById:s}){const a=e!=null?s.get(e):void 0;return n.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-600 dark:text-gray-300",children:[n.jsx(ht,{user:a,size:14}),n.jsx(sn,{user:a,fallbackId:e??0})]})}function oj({pr:e}){return n.jsxs("span",{className:"whitespace-nowrap text-[11px] tabular-nums",children:[n.jsx("span",{className:"text-gray-700 dark:text-gray-200",children:e.botThreads}),e.botUntouched>0&&n.jsxs("span",{className:"ml-1 text-amber-600 dark:text-amber-400",title:`${e.botUntouched} still untouched — no reply, no follow-up commit`,children:[e.botUntouched," untouched"]})]})}function ij({pr:e}){const s=e.botThreads>0?Math.round(e.botActedOn/e.botThreads*100):null;return n.jsxs("span",{className:"whitespace-nowrap text-[11px] tabular-nums",children:[n.jsx("span",{className:"text-gray-700 dark:text-gray-200",children:e.botActedOn}),s!=null&&n.jsxs("span",{className:"ml-1 text-gray-400",children:[s,"%"]})]})}function cj({pr:e,usersById:s,onOpen:a}){return n.jsxs("tr",{className:"border-t border-gray-100 align-top hover:bg-gray-50/70 dark:border-gray-800/60 dark:hover:bg-gray-900/40",children:[n.jsx("td",{className:"py-1.5 pr-3",children:n.jsxs("button",{type:"button",onClick:()=>a(e),className:"block max-w-md text-left hover:underline",title:`${e.repoFullName} #${e.prNumber} — ${e.prTitle}`,children:[n.jsxs("span",{className:"block truncate font-mono text-[11px] text-gray-400",children:[e.repoFullName," #",e.prNumber]}),n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-gray-800 dark:text-gray-100",children:e.prTitle}),e.botOnly&&n.jsx("span",{className:"shrink-0 rounded bg-amber-500/10 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-amber-700 dark:text-amber-300",title:"Only bots touched this PR — no human review or comment",children:"bot-only"})]})]})}),n.jsx("td",{className:"py-1.5 pr-3",children:n.jsx(oj,{pr:e})}),n.jsx("td",{className:"py-1.5 pr-3",children:n.jsx(ij,{pr:e})}),n.jsx("td",{className:"py-1.5 pr-3",children:n.jsx(sj,{ci:e.ciStatus})}),n.jsx("td",{className:"py-1.5 pr-3",children:n.jsx(aj,{pr:e})}),n.jsx("td",{className:"py-1.5 pr-3",children:n.jsx(lj,{id:e.authorId,usersById:s})}),n.jsx("td",{className:"py-1.5 pr-3 text-[11px] text-gray-500 dark:text-gray-400",children:e.lastBotActivityAt?St(e.lastBotActivityAt):"—"})]})}function uj({rows:e,usersById:s,onOpen:a}){return n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full min-w-[720px] border-collapse text-sm",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"text-left text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:[n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Pull request"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Bot threads"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Acted on"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"CI"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Diff"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Author"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Last activity"})]})}),n.jsx("tbody",{children:e.map(o=>n.jsx(cj,{pr:o,usersById:s,onOpen:a},o.prId))})]})})}function dj(){var w,R,S;const e=te(j=>j.botPrsFocus),s=te(j=>j.consumeBotPrsFocus),a=te(j=>j.botAnalyticsWindow),o=te(j=>j.setBotAnalyticsWindow),i=Oe(j=>j.openPrDetailTab),{data:u}=$n(),d=x.useMemo(()=>ln(u),[u]),p=gh(a),m=((w=p.data)==null?void 0:w.vendors)??rj,[g,y]=x.useState(e);x.useEffect(()=>{e&&(y(e),s())},[e,s]),x.useEffect(()=>{m.length!==0&&y(j=>j!=null&&m.some(T=>T.kind===j)?j:m[0].kind)},[m]);const b=tj(g,a),v=((R=b.data)==null?void 0:R.prs)??[],N=((S=p.data)==null?void 0:S.totals.botOnlyPrs)??0,I=j=>{const T=j.authorId!=null?d.get(j.authorId):void 0,M={id:j.prId,number:j.prNumber,title:j.prTitle,repoFullName:j.repoFullName,authorLogin:(T==null?void 0:T.githubLogin)??null,authorDisplayName:(T==null?void 0:T.displayName)??null,authorAvatarUrl:(T==null?void 0:T.avatarUrl)??null};i(M)},P=p.isFetching||b.isFetching,E=()=>{p.refetch(),b.refetch()};return n.jsxs("div",{className:"mx-auto max-w-6xl space-y-4 p-4",children:[n.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[n.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:"Bot PRs"}),n.jsx("span",{className:"rounded bg-violet-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:"Pro"}),n.jsxs("span",{className:"text-[11px] text-gray-400",children:["PRs an automated reviewer touched · most-recent activity first",N>0&&n.jsxs(n.Fragment,{children:[" · ",n.jsxs("span",{className:"text-amber-600 dark:text-amber-400",children:[N," bot-only"]})]})]}),n.jsx("div",{className:"ml-auto inline-flex overflow-hidden rounded border border-gray-300 dark:border-gray-700",children:nj.map(j=>n.jsx("button",{type:"button",onClick:()=>o(j.key),className:`px-2 py-0.5 text-[11px] font-medium ${a===j.key?"bg-violet-500/15 text-violet-700 dark:text-violet-300":"text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800"}`,children:j.label},j.key))}),n.jsxs("button",{type:"button",onClick:E,disabled:P,className:"rounded border border-gray-300 px-1.5 py-0.5 text-[11px] font-medium hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:[n.jsx("span",{"aria-hidden":!0,className:P?"animate-spin":"",children:"↻"})," ","Refresh"]})]}),p.isLoading?n.jsx("div",{className:"space-y-2",children:[0,1,2,3].map(j=>n.jsx("div",{className:"h-8 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"},j))}):p.isError?n.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load bot analytics."}):m.length===0?n.jsxs("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:["No automated-reviewer activity in this window.",n.jsx("div",{className:"mt-1 text-[11px]",children:"When review bots (CodeRabbit, Copilot, in-house AI…) comment on your PRs, the PRs they touched land here."})]}):n.jsxs(n.Fragment,{children:[n.jsx("div",{role:"tablist",className:"flex flex-wrap gap-1 border-b border-gray-200 dark:border-gray-800",children:m.map(j=>{const T=j.kind===g,M=an(j.kind);return n.jsxs("button",{type:"button",role:"tab","aria-selected":T,onClick:()=>y(j.kind),className:`-mb-px flex items-center gap-1 rounded-t-md border border-b-0 px-3 py-1.5 text-xs font-medium ${T?"border-gray-300 bg-white dark:border-gray-700 dark:bg-gray-950":"border-transparent text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-900/60"}`,style:T?{color:M.color}:void 0,children:[n.jsx("span",{"aria-hidden":!0,children:"🤖"}),j.label,n.jsx("span",{className:"ml-1 text-gray-400",children:j.threads})]},j.kind)})}),b.isLoading?n.jsx("div",{className:"space-y-2",children:[0,1,2,3].map(j=>n.jsx("div",{className:"h-8 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"},j))}):b.isError?n.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load the PR list."}):v.length===0?n.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:"No PRs for this bot in the window."}):n.jsx(uj,{rows:v,usersById:d,onOpen:I})]})]})}function fj(){const e=te(g=>g.selectedPrId),s=te(g=>g.selectedThreadId),a=te(g=>g.clearSelection),o=x.useDeferredValue(e),i=e??o,u=Oe(g=>g.activeTab),d=Au(u),p=(d==null?void 0:d.kind)==="pr-detail"?d.prId:null,m=i!=null&&i!==p;return n.jsxs("div",{className:"relative h-full","data-testid":"detail-pane",children:[e!=null&&n.jsx("div",{className:"absolute right-2 top-1.5 z-10 flex items-center gap-2",children:n.jsx("button",{type:"button","data-testid":"detail-clear",onClick:a,className:"rounded px-2 py-0.5 text-xs text-gray-400 hover:text-gray-600",title:"Clear selection (Esc)",children:"✕"})}),m?n.jsx(Nh,{prId:i,selectedThreadId:s},i):n.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."})]})}function MN(e){return qe({queryKey:["claude-review",e],queryFn:()=>ge.claudeReview(e),enabled:e!=null})}function FN(e){return qe({queryKey:["claude-review-by-id",e],queryFn:()=>ge.claudeReviewById(e),enabled:e!=null})}function LN(e,s){const a=Be(),[o,i]=x.useState(null);return x.useEffect(()=>{if(e==null||!s){i(null);return}const u=new AbortController;let d=!1;const p=()=>{d||(d=!0,a.invalidateQueries({queryKey:["claude-review",e]}))};return ti(`/api/prs/${e}/claude-review/stream`,{signal:u.signal,onEvent:m=>{m.type==="done"?(p(),i({status:m.status,reviewId:m.reviewId,progress:null})):i({status:m.status,reviewId:m.reviewId,progress:m.progress})}}).catch(()=>{}),()=>u.abort()},[e,s,a]),{status:o}}function _N(e){const s=Be();return Ue({mutationFn:a=>ge.generateClaudeReview(e,a.model,a.mode),onSuccess:()=>{te.getState().bumpClaudeReviewKickoff(),s.invalidateQueries({queryKey:["claude-review",e]}),s.invalidateQueries({queryKey:["claude-review-status",e]})}})}function ON(e){const s=Be();return Ue({mutationFn:a=>ge.postClaudeFinding(a.findingId),onSuccess:()=>void s.invalidateQueries({queryKey:["claude-review",e]})})}function DN(e){const s=Be();return Ue({mutationFn:()=>ge.cancelClaudeReview(e),onSuccess:()=>void s.invalidateQueries({queryKey:["claude-review",e]})})}function BN(e){const s=Be();return Ue({mutationFn:a=>ge.updateClaudeReview(a.reviewId,{userBody:a.userBody,userVerdict:a.userVerdict}),onSuccess:()=>void s.invalidateQueries({queryKey:["claude-review",e]})})}function zN(e){const s=Be();return Ue({mutationFn:a=>ge.updateClaudeFinding(a.findingId,{included:a.included,editedBody:a.editedBody}),onSuccess:()=>void s.invalidateQueries({queryKey:["claude-review",e]})})}function pj(e){return qe({queryKey:["claude-reviews-active"],queryFn:ge.activeClaudeReviews,enabled:e,refetchInterval:2500})}function qN(e){const s=Be();return Ue({mutationFn:a=>ge.setClaudeKey(a),onSuccess:()=>void s.invalidateQueries({queryKey:["claude-review",e]})})}function UN(e){const s=Be();return Ue({mutationFn:a=>ge.postClaudeReview(a.reviewId,a.userVerdict,a.dryRun??!1),onSuccess:(a,o)=>{o.dryRun||s.invalidateQueries({queryKey:["claude-review",e]})}})}const g0="pierre:notifications",uu="pierre:notif-pref";function Om(){try{return localStorage.getItem(g0)==="1"}catch{return!1}}function x0(){const[e,s]=x.useState(Om);x.useEffect(()=>{const o=()=>s(Om());return window.addEventListener(uu,o),window.addEventListener("storage",o),()=>{window.removeEventListener(uu,o),window.removeEventListener("storage",o)}},[]);const a=x.useCallback(o=>{try{localStorage.setItem(g0,o?"1":"0")}catch{}s(o),window.dispatchEvent(new Event(uu))},[]);return[e,a]}const mj="pierre:reviewSoundMuted";let Io=null;function y0(){try{if(Io!=null)return Io;const e=window,s=window.AudioContext??e.webkitAudioContext;return s==null?null:(Io=new s,Io)}catch{return null}}function hj(){try{return localStorage.getItem(mj)==="true"}catch{return!1}}function KN(){try{const e=y0();e!=null&&e.state==="suspended"&&e.resume()}catch{}}function Dm(e,s,a,o){const i=e.createOscillator(),u=e.createGain();i.type="sine",i.frequency.value=s;const d=.12;u.gain.setValueAtTime(1e-4,a),u.gain.exponentialRampToValueAtTime(d,a+.02),u.gain.exponentialRampToValueAtTime(1e-4,a+o),i.connect(u),u.connect(e.destination),i.start(a),i.stop(a+o+.02)}function gj(){try{if(hj())return;const e=y0();if(e==null)return;e.state==="suspended"&&e.resume();const s=e.currentTime+.01;Dm(e,660,s,.15),Dm(e,990,s+.13,.18)}catch{}}function xj(e){if(e.length===0||typeof Notification>"u"||Notification.permission!=="granted")return;const s=e.length===1?"Claude review ready":`${e.length} Claude reviews ready`,a=e.length===1?`${e[0].repoFullName} #${e[0].prNumber}`:e.slice(0,3).map(o=>`${o.repoFullName} #${o.prNumber}`).join(" · ");try{const o=new Notification(s,{body:a,tag:"pierre-claude-review"});o.onclick=()=>{window.focus(),o.close()}}catch{}}const yj={cloning:"Cloning",fetching_diff:"Fetching diff",deciding:"Deciding scope",reviewing:"Reviewing",persisting:"Saving findings"};function vj(){const e=yn().claudeReview,s=te(j=>j.claudeReviewKickoff),a=te(j=>j.openClaudeReview),[o]=x0(),i=x.useRef(o);i.current=o;const[u,d]=x.useState(!1);x.useEffect(()=>{s>0&&d(!0)},[s]);const{data:p,dataUpdatedAt:m}=pj(e&&u);x.useEffect(()=>{u&&((p==null?void 0:p.reviews.length)??0)===0&&d(!1)},[m]);const[g,y]=x.useState({}),[b,v]=x.useState({}),N=x.useRef(null),I=((p==null?void 0:p.reviews)??[]).map(j=>`${j.reviewId}:${j.phase??""}`).join(",");x.useEffect(()=>{const j=(p==null?void 0:p.reviews)??[],T=new Set(j.map(D=>D.reviewId)),M=N.current;if(M!=null){const D=[];for(const[U,G]of M)T.has(U)||D.push(G);D.length>0&&(gj(),i.current&&xj(D))}N.current=new Map(j.map(D=>[D.reviewId,{repoFullName:D.repoFullName,prNumber:D.prNumber,prTitle:D.prTitle}])),y(D=>{const U={...D};for(const G of j)U[G.reviewId]={reviewId:G.reviewId,prId:G.prId,repoFullName:G.repoFullName,prNumber:G.prNumber,prTitle:G.prTitle,phase:G.phase,done:!1};for(const G of Object.values(U))!T.has(G.reviewId)&&!G.done&&(U[G.reviewId]={...G,done:!0});return U})},[I]);const P=Object.values(g).filter(j=>!b[j.reviewId]);if(!e||P.length===0)return null;const E=P.filter(j=>!j.done),w=E.length===0,R=()=>{v(j=>{const T={...j};for(const M of P)T[M.reviewId]=!0;return T})},S=j=>v(T=>({...T,[j]:!0}));return n.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:n.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:[n.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 px-3 py-1.5 dark:border-gray-800",children:[n.jsxs("span",{className:"text-xs font-semibold",children:["Claude reviews",E.length>0&&n.jsxs("span",{className:"ml-1 font-normal text-gray-400",children:["· ",E.length," running"]})]}),w&&n.jsx("button",{type:"button",onClick:R,className:"text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:"Dismiss all"})]}),n.jsx("ul",{className:"max-h-64 divide-y divide-gray-100 overflow-auto dark:divide-gray-800",children:P.map(j=>n.jsxs("li",{className:"px-3 py-2 text-xs",children:[n.jsxs("button",{type:"button",onClick:()=>a({id:j.prId,number:j.prNumber,title:j.prTitle,repoFullName:j.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null}),className:"block w-full text-left",title:"Open this review",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[j.done?n.jsx("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full bg-green-500"}):n.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"}),n.jsxs("span",{className:"truncate font-medium text-blue-600 hover:underline dark:text-blue-400",children:[j.repoFullName," #",j.prNumber]})]}),n.jsx("div",{className:"mt-0.5 truncate text-gray-500",children:j.prTitle}),n.jsx("div",{className:"mt-0.5 text-gray-400",children:j.done?"Ready — click to view":`${j.phase!=null?yj[j.phase]??j.phase:"Starting"}…`})]}),j.done&&n.jsx("div",{className:"mt-1 text-right",children:n.jsx("button",{type:"button",onClick:()=>S(j.reviewId),className:"text-[11px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:"dismiss"})})]},j.reviewId))})]})})}function bj({repos:e,statuses:s,cancelling:a,onCancel:o}){const i=m=>s==null?void 0:s.find(g=>g.repoId===m),u=m=>{if(s===void 0)return!0;const g=i(m);return g===void 0||g.status==="running"},d=e.filter(m=>!u(m.id)).length,p=e.length>0&&d===e.length;return n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",role:"presentation",children:n.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:[n.jsx("div",{className:"mb-3 flex items-center justify-between",children:n.jsx("h2",{className:"text-sm font-semibold",children:a?"Cancelling…":e.length===0?"Starting sync…":p?"Sync complete":`Syncing ${e.length} repo${e.length===1?"":"s"}`})}),n.jsx("ul",{className:"space-y-3",children:e.map(m=>{var I,P;const g=i(m.id),y=u(m.id),b=(g==null?void 0:g.status)==="error",v=((I=g==null?void 0:g.progress)==null?void 0:I.prsProcessed)??0,N=y?Math.round((((P=g==null?void 0:g.progress)==null?void 0:P.percent)??0)*100):100;return n.jsxs("li",{children:[n.jsxs("div",{className:"mb-1 flex items-baseline justify-between gap-2 text-xs",children:[n.jsx("span",{className:"truncate font-medium",title:m.fullName,children:m.fullName}),n.jsx("span",{className:"shrink-0 text-gray-500",children:b?n.jsx("span",{className:"text-red-500",children:"error"}):y?`${N}%${v>0?` · ${v} PRs`:""}`:n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["✓ done",v>0?` · ${v} PRs`:""]})})]}),n.jsx("div",{className:"h-2 w-full overflow-hidden rounded bg-gray-200 dark:bg-gray-800",children:n.jsx("div",{className:`h-2 rounded transition-all duration-500 ${b?"bg-red-500":y?"bg-blue-500":"bg-green-500"}`,style:{width:`${b?100:N}%`}})})]},m.id)})}),n.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 text-xs text-gray-500",children:[n.jsxs("span",{children:[d," of ",e.length," repo",e.length===1?"":"s"," complete"]}),n.jsx("button",{type:"button",onClick:o,disabled:a,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:a?"Cancelling…":"Cancel"})]})]})})}function Bm({spinning:e=!1,size:s=14}){return n.jsxs("svg",{viewBox:"0 0 24 24",width:s,height:s,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:e?"animate-spin":void 0,children:[n.jsx("polyline",{points:"23 4 23 10 17 10"}),n.jsx("polyline",{points:"1 20 1 14 7 14"}),n.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function wj({size:e=14}){return n.jsxs("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[n.jsx("path",{d:"M12 3v12"}),n.jsx("polyline",{points:"7 10 12 15 17 10"}),n.jsx("line",{x1:"5",y1:"21",x2:"19",y2:"21"})]})}function kj(e){let s=null;for(const a of e){const o=a.lastIncrementalSyncAt??a.lastFullSyncAt;o&&(!s||o>s)&&(s=o)}return s}const Vo=5,Iu=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function v0(e){const s=new Date,a=new Date(s);return a.setSeconds(0,0),a.setMinutes(Math.floor(s.getMinutes()/e)*e+e),a}function jj(e){const s=v0(Vo),a=Math.max(1,Math.round((s.getTime()-Date.now())/6e4)),o=e?[`Last synced ${Iu(new Date(e))}`]:[];return o.push(`Syncs automatically every ${Vo} minutes`),o.push(`Next sync ~${Iu(s)} (in ${a} min)`),o.join(`
49
- `)}function Nj(){const e=Be(),[s,a]=x.useState(!1),[o,i]=x.useState(!1),[u,d]=x.useState(!1),[p,m]=x.useState(!1),[g,y]=x.useState([]),[b,v]=x.useState(!1),N=x.useRef(null),{data:I}=qe({queryKey:["repos"],queryFn:ge.listRepos,refetchInterval:s?3e3:3e4}),P=(I??[]).map(ne=>ne.id).join(","),{data:E}=qe({queryKey:["sync-status",P],enabled:s&&!!I&&I.length>0,queryFn:()=>Promise.all((I??[]).map(ne=>ge.syncStatus(ne.id))),refetchInterval:1500}),w=new Set(g),R=w.size===0?I??[]:(I??[]).filter(ne=>w.has(ne.id)),S=new Set(R.map(ne=>ne.id)),j=E==null?void 0:E.filter(ne=>S.has(ne.repoId)),T=(j??[]).filter(ne=>ne.status==="running"),M=T.length,D=M>0&&T.every(ne=>{var Pe;return((Pe=ne.progress)==null?void 0:Pe.foregroundComplete)===!0}),U=kj(I??[]),G=x.useRef(U),L=x.useRef(!1),Y=x.useRef(null),X=()=>{Y.current!=null&&(clearTimeout(Y.current),Y.current=null)},B=()=>{d(!1),L.current=!1,X()};x.useEffect(()=>X,[]),Yn(N,()=>v(!1),b),x.useEffect(()=>{if(!b)return;const ne=Pe=>{Pe.key==="Escape"&&(Pe.stopPropagation(),v(!1))};return document.addEventListener("keydown",ne),()=>document.removeEventListener("keydown",ne)},[b]);const _=()=>{e.invalidateQueries({queryKey:["timeline"]}),e.invalidateQueries({queryKey:["open-prs"]}),e.invalidateQueries({queryKey:["users"]}),e.invalidateQueries({queryKey:["mergers"]}),e.invalidateQueries({queryKey:["my-turn"]}),e.invalidateQueries({queryKey:["me"]});for(const ne of Ou)e.invalidateQueries({queryKey:[ne]})};x.useEffect(()=>{G.current!==U&&(G.current=U,_())},[U]),x.useEffect(()=>{!s||!D||L.current||(L.current=!0,i(!1),_())},[s,D]),x.useEffect(()=>{M>0&&d(!0)},[M]),x.useEffect(()=>{s&&u&&E&&M===0&&(a(!1),d(!1),_(),X(),Y.current=setTimeout(()=>{i(!1),Y.current=null},1e3))},[s,u,E,M]);const H=te(ne=>ne.syncModalSignal),ee=te(ne=>ne.syncModalRepoId),ce=x.useRef(H);if(x.useEffect(()=>{H!==ce.current&&(ce.current=H,ee!=null&&(o?y(ne=>ne.includes(ee)?ne:[...ne,ee]):(y([ee]),i(!0),a(!0),B()),e.invalidateQueries({queryKey:["repos"]}),e.invalidateQueries({queryKey:["sync-status"]})))},[H,e]),!I||I.length===0)return null;const C=I.find(ne=>ne.lastSyncStatus==="error"),F=async(ne=!1)=>{a(!0),i(!0),y([]),B(),await Promise.allSettled(I.map(Pe=>ge.syncRepo(Pe.id,ne))),e.invalidateQueries({queryKey:["repos"]}),e.invalidateQueries({queryKey:["sync-status"]})},K=async()=>{m(!0),X();const ne=(j??[]).filter(se=>se.status==="running").map(se=>se.repoId),Pe=ne.length?ne:R.map(se=>se.id);await Promise.allSettled(Pe.map(se=>ge.cancelSync(se))),a(!1),d(!1),m(!1),i(!1),e.invalidateQueries({queryKey:["repos"]}),_()},ae=D?"loading older history…":M>0?`syncing ${M} repo${M===1?"":"s"}…`:"syncing…";return n.jsxs(n.Fragment,{children:[o&&n.jsx(bj,{repos:R,statuses:j,cancelling:p,onCancel:()=>void K()}),n.jsxs("div",{ref:N,className:"relative",children:[n.jsxs("button",{type:"button",onClick:()=>v(ne=>!ne),"aria-haspopup":"menu","aria-expanded":b,title:C?`Sync error: ${C.fullName}${C.lastSyncError?` — ${C.lastSyncError}`:""}`:jj(U),className:`relative flex items-center gap-1 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 ${b?"bg-gray-100 dark:bg-gray-800":""}`,children:[n.jsx(Bm,{spinning:s}),n.jsx("span",{className:"hidden sm:inline",children:"Sync"}),C&&!s&&n.jsx("span",{"aria-hidden":!0,className:"absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-red-500 ring-1 ring-white dark:ring-gray-900"}),n.jsx("span",{"aria-hidden":!0,className:"text-[9px] text-gray-400",children:"▾"})]}),b&&n.jsxs("div",{role:"menu","aria-label":"Sync menu",className:"absolute right-0 top-full z-[60] mt-1 w-64 rounded-lg border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[n.jsx("div",{className:"px-3 py-1.5 text-[11px] leading-snug text-gray-500 dark:text-gray-400",children:C?n.jsxs("span",{className:"text-red-500",children:["Sync error: ",C.fullName]}):s?n.jsx("span",{children:ae}):U?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"text-gray-600 dark:text-gray-300",children:["Synced ",St(U)]}),n.jsx("br",{}),n.jsxs("span",{children:["Auto-syncs every ",Vo," min · next ~",Iu(v0(Vo))]})]}):"Not synced yet"}),n.jsx("div",{className:"my-1 border-t border-gray-100 dark:border-gray-800"}),n.jsxs("button",{role:"menuitem",type:"button",disabled:s,onClick:()=>{v(!1),F(!1)},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-gray-700 hover:bg-gray-100 disabled:opacity-50 dark:text-gray-200 dark:hover:bg-gray-800",children:[n.jsx(Bm,{spinning:s}),"Sync now"]}),n.jsxs("button",{role:"menuitem",type:"button",disabled:s,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?")&&(v(!1),F(!0))},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-gray-700 hover:bg-gray-100 disabled:opacity-50 dark:text-gray-200 dark:hover:bg-gray-800",title:"Force a full backfill for all repos",children:[n.jsx(wj,{}),"Deep re-sync…"]})]})]})]})}function Sj(){const e=te(j=>j.searchQuery),s=te(j=>j.setSearchQuery),a=Oe(j=>j.openPrFocusTab),{data:o}=Fu(),{data:i}=Lu(),{data:u}=Mr(),{data:d}=$n(),[p,m]=x.useState(!1),[g,y]=x.useState(-1),b=x.useRef(null),v=x.useMemo(()=>{const j=new Map;for(const T of u??[])j.set(T.id,T.fullName);return j},[u]),N=x.useMemo(()=>ln(d),[d]),I=x.useMemo(()=>{const j=new Map;for(const T of(o==null?void 0:o.prs)??[])j.set(T.id,T);for(const T of(i==null?void 0:i.prs)??[])j.has(T.id)||j.set(T.id,T);return[...j.values()]},[o,i]),P=x.useMemo(()=>{const j=e.trim().toLowerCase();if(!j)return[];const T=j.replace(/^#/,""),M=T.length>0&&/^\d+$/.test(T),D=I.filter(U=>U.title.toLowerCase().includes(j)||M&&String(U.number).includes(T));if(M){const U=G=>{const L=String(G.number);return L===T?0:L.startsWith(T)?1:L.includes(T)?2:3};D.sort((G,L)=>U(G)-U(L))}return D.slice(0,30)},[I,e]),E=p&&e.trim().length>0,w=g>=0&&g<P.length?P[g].id:null;Yn(b,()=>m(!1),E),x.useEffect(()=>{var j,T;w!=null&&((T=(j=b.current)==null?void 0:j.querySelector(`#pr-result-${w}`))==null||T.scrollIntoView({block:"nearest"}))},[w]);const R=j=>{if(!j)return;const T=j.authorId!=null?N.get(j.authorId):void 0;a({id:j.id,number:j.number,title:j.title,repoFullName:v.get(j.repoId)??`repo ${j.repoId}`,authorLogin:(T==null?void 0:T.githubLogin)??null,authorDisplayName:(T==null?void 0:T.displayName)??null,authorAvatarUrl:(T==null?void 0:T.avatarUrl)??null}),m(!1)},S=j=>{if(j.key==="Escape"){m(!1),j.target.blur();return}!E||P.length===0||(j.key==="ArrowDown"?(j.preventDefault(),y(T=>(T+1)%P.length)):j.key==="ArrowUp"?(j.preventDefault(),y(T=>T<=0?P.length-1:T-1)):j.key==="Enter"&&(j.preventDefault(),R(P[g>=0?g:0])))};return n.jsxs("div",{ref:b,className:"relative",children:[n.jsx("input",{type:"search",value:e,placeholder:"Search PRs (title or number)…",onChange:j=>{s(j.target.value),y(-1),m(!0)},onFocus:()=>m(!0),onKeyDown:S,role:"combobox","aria-expanded":E,"aria-controls":"pr-search-results","aria-autocomplete":"list","aria-activedescendant":w!=null?`pr-result-${w}`:void 0,"aria-label":"Search PRs by title or number",className:"w-56 rounded border border-gray-300 bg-transparent px-2 py-0.5 text-xs focus:border-blue-500 focus:outline-none dark:border-gray-700"}),E&&n.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:P.length===0?n.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"No matching PRs."}):P.map((j,T)=>{const M=j.authorId!=null?N.get(j.authorId):void 0;return n.jsxs("button",{id:`pr-result-${j.id}`,type:"button",role:"option","aria-selected":T===g,onMouseEnter:()=>y(T),onClick:()=>R(j),className:`flex w-full flex-col gap-0.5 px-3 py-1.5 text-left ${T===g?"bg-gray-100 dark:bg-gray-800":""} hover:bg-gray-100 dark:hover:bg-gray-800`,children:[n.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-400",children:[n.jsx(ht,{user:M,size:12}),n.jsx("span",{className:"truncate",title:ft(M,j.authorId),children:ft(M,j.authorId)}),n.jsx("span",{"aria-hidden":!0,children:"·"}),n.jsxs("span",{className:"shrink-0",children:[v.get(j.repoId)??`repo ${j.repoId}`," · #",j.number]})]}),n.jsx("span",{className:"truncate text-xs",title:j.title,children:j.title})]},j.id)})})]})}function Cj(){const{data:e}=_u(),s=Oe(y=>y.activeTab),a=Oe(y=>y.showActivity),o=te(y=>y.setActivityRepo),i=te(y=>y.setFeedMyTurnOnly),[u,d]=x.useState(!1);if(u||!(e!=null&&e.user)||s==="activity")return null;const p=e.newFeedItems??0;if(p<=0)return null;const m=e.feedLastSeenAt,g=()=>{Bk(),o("feed"),i(!0),a(),d(!0)};return n.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:[n.jsxs("button",{type:"button",onClick:g,title:"Show your feed",className:"flex min-w-0 flex-1 items-center gap-2 text-left hover:underline",children:[n.jsx("span",{className:"font-medium",children:"Welcome back"}),n.jsxs("span",{className:"min-w-0 truncate text-amber-700/80 dark:text-amber-300/80",children:["· ",p," new item",p===1?"":"s"," in your feed",m?` since you were last here ${St(m)}`:""]})]}),n.jsx("button",{type:"button",onClick:g,className:"shrink-0 rounded border border-amber-400 px-2 py-0.5 font-medium hover:bg-amber-100 dark:border-amber-700 dark:hover:bg-amber-900/40",children:"Show feed"}),n.jsx("button",{type:"button",onClick:()=>d(!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 Rj({onClose:e}){return x.useEffect(()=>{const s=a=>{a.key==="Escape"&&(a.stopImmediatePropagation(),e())};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[e]),n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:e,role:"presentation",children:n.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:s=>s.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Pierre help",children:[n.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[n.jsx("h2",{className:"brand-title",children:"Pierre"}),n.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:"✕"})]}),n.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:[n.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."}),n.jsxs(rs,{title:"Track repositories",children:["Add repos in the filter bar’s ",n.jsx("em",{children:"add repo"})," box as ",n.jsx(Ij,{children:"owner/name"}),". Pierre syncs their PR activity every few minutes into a local file — nothing leaves your machine."]}),n.jsxs(rs,{title:"Read the timeline",children:["Rows are grouped ",n.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."]}),n.jsxs(rs,{title:"Focus mode",children:["To isolate one PR and just its contributors: double-click its bar, click"," ",n.jsx("strong",{children:"Focus"})," in the detail pane, or click a cross-person marker. Leave focus with the ",n.jsx("strong",{children:"✕"})," on the header"," ",n.jsx("strong",{children:"Focus mode"})," badge, ",n.jsx(ja,{children:"Esc"}),", or the browser"," ",n.jsx("strong",{children:"Back"})," button."]}),n.jsxs(rs,{title:"Detail pane",children:["Selecting a PR opens the bottom pane with ",n.jsx("strong",{children:"Overview"})," (checks, summary, comments), ",n.jsx("strong",{children:"Threads"}),", and ",n.jsx("strong",{children:"Activity"}),". The ",n.jsx("em",{children:"Show"})," links jump back to that moment on the timeline; drag the divider to resize the pane."]}),n.jsxs(rs,{title:"Filter",children:["Narrow by date range, members (auto-scoped to who’s active in view), event categories, and thread states. ",n.jsx("em",{children:"Exclude bots"})," hides renovate / dependabot / CI noise."]}),n.jsxs(rs,{title:"Open-PRs strip",children:["The collapsible strip up top lists currently-open PRs — toggle between"," ",n.jsx("strong",{children:"all"}),", ",n.jsx("strong",{children:"my turn"}),", and"," ",n.jsx("strong",{children:"needs attention"}),"."]}),n.jsxs(rs,{title:"Activity & Insights",children:["Clicking an item in the ",n.jsx("strong",{children:"Activity Feed"})," opens that PR's detail tab, where ",n.jsx("strong",{children:"Show"})," / ",n.jsx("strong",{children:"Focus"})," drive the timeline; the feed's ",n.jsx("strong",{children:"My Turn only"})," toggle narrows it to what needs you."," ",n.jsx("strong",{children:"Insights"})," opens a per-repo snapshot (open / merged / stalled, time-to-first-review, review load). Save filter combinations as named ",n.jsx("strong",{children:"Views"}),", and use the bell to get notified when something new lands in your queue."]}),n.jsxs(rs,{title:"Keyboard",children:[n.jsx(ja,{children:"/"})," focus the filter · ",n.jsx(ja,{children:"j"}),"/",n.jsx(ja,{children:"k"})," cycle PRs ·"," ",n.jsx(ja,{children:"i"})," Insights · ",n.jsx(ja,{children:"Esc"})," exit focus, else clear the selection."]})]})]})})}function rs({title:e,children:s}){return n.jsxs("section",{children:[n.jsx("h3",{className:"mb-1 font-semibold text-gray-800 dark:text-gray-100",children:e}),n.jsx("p",{children:s})]})}function Ij({children:e}){return n.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 ja({children:e}){return n.jsx("kbd",{className:"rounded border border-gray-300 bg-gray-100 px-1 text-[11px] font-medium text-gray-600 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",children:e})}function or({title:e,desc:s,children:a}){return n.jsxs("section",{className:"border-b border-gray-100 pb-4 last:border-b-0 dark:border-gray-800",children:[n.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:e}),s!=null&&n.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:s}),n.jsx("div",{className:"mt-2.5 space-y-2.5",children:a})]})}function Nt({label:e,htmlFor:s,hint:a,children:o}){return n.jsxs("label",{htmlFor:s,className:"flex flex-col gap-1 text-xs",children:[n.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:e}),o,a!=null&&n.jsx("span",{className:"text-[11px] text-gray-400",children:a})]})}const rt="w-full rounded border border-gray-300 bg-white px-2 py-1 text-xs text-gray-800 outline-none focus:border-sky-400 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100";function Pr({dirty:e,saving:s,onClick:a}){return n.jsx("button",{type:"button",onClick:a,disabled:!e||s,className:"self-start rounded bg-sky-600 px-3 py-1 text-xs font-medium text-white hover:bg-sky-700 disabled:cursor-not-allowed disabled:opacity-40",children:s?"Saving…":"Save"})}const Tj=[7,14,21,28],zm=[{value:"rolling_14",label:"Rolling 14 days (default)",hint:"Trailing 14 days vs the prior 14 — always a full window, no sprint needed. Best if you don’t run fixed sprints."},{value:"rolling_7",label:"Rolling 7 days",hint:"Trailing 7 days vs the prior 7 — a tighter, more responsive momentum read."},{value:"sprint",label:"Sprint position (like-for-like)",hint:"This sprint SO FAR vs the SAME point in the previous sprint (e.g. day 3 vs day 3). Needs a start date + cadence below."}];function Ej({settings:e,save:s,saving:a}){var j,T;const o=e.sprint.comparisonMode,i=e.sprint.cadenceDays??14,u=((j=e.sprint.startDate)==null?void 0:j.slice(0,10))??"",[d,p]=x.useState(o),[m,g]=x.useState(i),[y,b]=x.useState(!Tj.includes(i)),[v,N]=x.useState(u),I=d==="sprint",P=d!==o||I&&(m!==i||v!==u),E=u!==""||e.sprint.cadenceDays!=null,w=(T=zm.find(M=>M.value===d))==null?void 0:T.hint,R=()=>s({sprint:I?{comparisonMode:d,cadenceDays:m,startDate:v===""?null:v}:{comparisonMode:d}}),S=()=>{const M=d==="sprint"?"rolling_14":d;p(M),N(""),b(!1),g(14),s({sprint:{comparisonMode:M,cadenceDays:null,startDate:null}})};return n.jsxs(or,{title:"Sprint",desc:"How the Insights flow-metrics compare over time. Open PRs always count, regardless of the window.",children:[n.jsx(Nt,{label:"Comparison window",hint:w,children:n.jsx("select",{className:rt,value:d,onChange:M=>p(M.target.value),children:zm.map(M=>n.jsx("option",{value:M.value,children:M.label},M.value))})}),I&&n.jsxs(n.Fragment,{children:[n.jsx(Nt,{label:"Cadence",children:n.jsxs("select",{className:rt,value:y?"custom":String(m),onChange:M=>{M.target.value==="custom"?b(!0):(b(!1),g(Number(M.target.value)))},children:[n.jsx("option",{value:"7",children:"1 week"}),n.jsx("option",{value:"14",children:"2 weeks"}),n.jsx("option",{value:"21",children:"3 weeks"}),n.jsx("option",{value:"28",children:"4 weeks"}),n.jsx("option",{value:"custom",children:"Custom…"})]})}),y&&n.jsx(Nt,{label:"Sprint length (days)",children:n.jsx("input",{type:"number",min:1,max:90,className:rt,value:m,onChange:M=>g(Math.max(1,Math.min(90,Number(M.target.value)||1)))})}),n.jsx(Nt,{label:"Start date",hint:"The day your first/any sprint began — cadence rolls forward from here.",children:n.jsx("input",{type:"date",className:rt,value:v,onChange:M=>N(M.target.value)})}),v===""&&n.jsx("p",{className:"text-[11px] text-amber-600 dark:text-amber-400",children:"Set a start date to use sprint-position comparison — until then the Insights fall back to a rolling 14-day window."})]}),n.jsx(Pr,{dirty:P,saving:a,onClick:R}),E&&n.jsx("div",{className:"mt-3 border-t border-gray-100 pt-3 dark:border-gray-800",children:n.jsx("button",{type:"button",onClick:S,disabled:a,className:"text-[11px] text-gray-400 underline hover:text-red-500 disabled:opacity-50",title:"Remove the sprint start date + cadence and use a rolling 14-day tracker",children:"Clear sprint dates (disable sprints)"})})]})}const qm=Array.from({length:24},(e,s)=>s),Um=e=>{const s=e<12;return`${e%12===0?12:e%12}:00 ${s?"AM":"PM"}`};function Pj({settings:e,save:s,saving:a}){const o=e.slack,[i,u]=x.useState(""),[d,p]=x.useState(o.cadence),[m,g]=x.useState(o.hour1),[y,b]=x.useState(o.hour2),[v,N]=x.useState({busy:!1,msg:null,ok:!1}),I=async()=>{N({busy:!0,msg:null,ok:!1});try{const E=await ge.testSlackDigest();N({busy:!1,ok:E.sent,msg:E.sent?"Sent — check Slack.":E.message??"Not sent."})}catch(E){N({busy:!1,ok:!1,msg:E.message})}},P=i.trim()!==""||d!==o.cadence||m!==o.hour1||y!==o.hour2;return n.jsxs(or,{title:"Slack digest",desc:"Deliver the sprint + repo digest to a Slack channel on a schedule. Report is generated fresh at send time.",children:[n.jsx(Nt,{label:"Incoming webhook URL",hint:o.configured?n.jsx("span",{className:"text-emerald-500",children:"A webhook is configured. Enter a new URL to replace it, or clear it to disable."}):"Create one at api.slack.com/apps → Incoming Webhooks.",children:n.jsx("input",{type:"url",className:rt,placeholder:o.configured?"•••••••• (unchanged)":"https://hooks.slack.com/services/…",value:i,onChange:E=>u(E.target.value)})}),n.jsx(Nt,{label:"Cadence",children:n.jsxs("select",{className:rt,value:d,onChange:E=>p(E.target.value),children:[n.jsx("option",{value:"off",children:"Off"}),n.jsx("option",{value:"daily",children:"Daily"}),n.jsx("option",{value:"twice_daily",children:"Twice daily"})]})}),d!=="off"&&n.jsxs("div",{className:"flex gap-2",children:[n.jsx(Nt,{label:"Send at",hint:e.slack.timezone??"server time",children:n.jsx("select",{className:rt,value:m,onChange:E=>g(Number(E.target.value)),children:qm.map(E=>n.jsx("option",{value:E,children:Um(E)},E))})}),d==="twice_daily"&&n.jsx(Nt,{label:"And at",children:n.jsx("select",{className:rt,value:y,onChange:E=>b(Number(E.target.value)),children:qm.map(E=>n.jsx("option",{value:E,children:Um(E)},E))})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Pr,{dirty:P,saving:a,onClick:()=>{const E={cadence:d,hour1:m,hour2:y};i.trim()!==""&&(E.webhookUrl=i.trim()),s({slack:E}),u("")}}),o.configured&&n.jsx("button",{type:"button",onClick:I,disabled:v.busy,className:"rounded border border-gray-300 px-3 py-1 text-xs font-medium text-gray-600 hover:bg-gray-100 disabled:opacity-40 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:v.busy?"Sending…":"Send test"}),o.configured&&n.jsx("button",{type:"button",onClick:()=>{u(""),s({slack:{webhookUrl:""}})},disabled:a,className:"rounded px-2 py-1 text-xs font-medium text-red-500 hover:bg-red-50 disabled:opacity-40 dark:hover:bg-red-950",children:"Remove webhook"}),v.msg!=null&&n.jsx("span",{className:`text-[11px] ${v.ok?"text-emerald-500":"text-red-500"}`,children:v.msg})]})]})}const To=5,Aj=[{value:"manual",label:"Manual",desc:"Only regenerate when you click Refresh."},{value:"interval",label:"Every N minutes",desc:"Regenerate on a timer (unchanged repos cost nothing)."},{value:"on_change",label:"When a change is detected",desc:"Regenerate after a sync that changed a watched repo."}];function $j({settings:e,save:s,saving:a}){const o=e.aiUpdate,[i,u]=x.useState(o.mode),[d,p]=x.useState(o.intervalMinutes),m=i!==o.mode||i==="interval"&&d!==o.intervalMinutes;return n.jsxs(or,{title:"AI summary updates",desc:"Controls when the Pro Haiku digests / sprint report regenerate.",children:[n.jsx("div",{className:"space-y-1.5",children:Aj.map(g=>n.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[n.jsx("input",{type:"radio",name:"ai-update-mode",className:"mt-0.5",checked:i===g.value,onChange:()=>u(g.value)}),n.jsxs("span",{children:[n.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:g.label}),n.jsx("span",{className:"block text-[11px] text-gray-400",children:g.desc})]})]},g.value))}),i==="interval"&&n.jsx(Nt,{label:"Interval (minutes)",hint:`Minimum ${To}.`,children:n.jsx("input",{type:"number",min:To,className:rt,value:d,onChange:g=>p(Math.max(To,Number(g.target.value)||To))})}),n.jsx(Pr,{dirty:m,saving:a,onClick:()=>s({aiUpdate:{mode:i,intervalMinutes:d}})})]})}const Mj={jira:"https://your-org.atlassian.net",linear:"https://linear.app/your-workspace"};function Fj({settings:e,save:s,saving:a}){const o=e.issue,[i,u]=x.useState(o.provider??""),[d,p]=x.useState(o.baseUrl??""),m=o.projectKeys.join(", "),[g,y]=x.useState(m),b=g.split(/[\s,]+/).map(N=>N.trim().toUpperCase()).filter(N=>N!==""),v=(i||null)!==o.provider||d.trim()!==(o.baseUrl??"")||b.join(",")!==o.projectKeys.join(",");return n.jsxs(or,{title:"Issue tracker",desc:"Link Jira/Linear tickets detected in a PR's title or branch into the PR details.",children:[n.jsx(Nt,{label:"Provider",children:n.jsxs("select",{className:rt,value:i,onChange:N=>u(N.target.value),children:[n.jsx("option",{value:"",children:"None"}),n.jsx("option",{value:"jira",children:"Jira"}),n.jsx("option",{value:"linear",children:"Linear"})]})}),i!==""&&n.jsxs(n.Fragment,{children:[n.jsx(Nt,{label:"Base URL",hint:i==="jira"?"Tickets link to {base}/browse/KEY-123.":"Tickets link to {base}/issue/KEY-123.",children:n.jsx("input",{type:"url",className:rt,placeholder:Mj[i],value:d,onChange:N=>p(N.target.value)})}),n.jsx(Nt,{label:"Project keys",hint:"Optional, comma-separated (e.g. ENG, PROJ). When set, ONLY these prefixes are detected (in the title AND branch) — the most reliable way to avoid false matches like GPT-4 or node-18. Leave blank to detect uppercase keys in the PR title only.",children:n.jsx("input",{type:"text",className:rt,placeholder:"ENG, PROJ",value:g,onChange:N=>y(N.target.value)})})]}),n.jsx(Pr,{dirty:v,saving:a,onClick:()=>s({issue:{provider:i===""?null:i,baseUrl:d.trim()===""?null:d.trim(),projectKeys:b}})})]})}const Lj=Object.keys(qs),_j=8;function Oj(){var E;const e=xh(),s=yh(),a=Uu(),[o,i]=x.useState({}),[u,d]=x.useState(""),p=w=>o[w.userId]??{kind:w.classification.kind??"in_house",label:w.classification.label},m=(w,R)=>i(S=>({...S,[w.userId]:{...p(w),...R}})),g=s.isPending,y=((E=e.data)==null?void 0:E.reviewers)??[],b=y.filter(w=>w.classification.automated===!0),v=y.filter(w=>w.classification.automated!==!0),N=u.trim().toLowerCase(),I=x.useMemo(()=>N===""?[]:v.filter(w=>`${w.login} ${w.displayName??""}`.toLowerCase().includes(N)).slice(0,_j),[v,N]),P=w=>{s.mutate({userId:w.userId,body:{automated:!0,kind:"in_house"}}),d("")};return n.jsxs(or,{title:"Review bots",desc:"Reviewers we treat as an AI/automated reviewer. Override any row — a manual choice sticks. To mark a human reviewer as a bot, search below.",children:[e.isLoading?n.jsx("p",{className:"py-3 text-center text-[11px] text-gray-400",children:"Loading…"}):e.isError?n.jsx("p",{className:"py-3 text-center text-[11px] text-red-500",children:e.error.message}):y.length===0?n.jsx("p",{className:"py-3 text-center text-[11px] text-gray-400",children:"No reviewers detected yet — sync a repo first."}):n.jsxs(n.Fragment,{children:[b.length===0?n.jsx("p",{className:"py-2 text-center text-[11px] text-gray-400",children:"No automated reviewers yet — search below to mark one."}):n.jsx("ul",{className:"divide-y divide-gray-100 rounded border border-gray-200 dark:divide-gray-800 dark:border-gray-700",children:b.map(w=>{const R=w.classification,S=p(w),j=an(R.kind??"in_house");return n.jsxs("li",{className:"flex flex-col gap-1.5 px-2.5 py-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[w.avatarUrl!=null&&n.jsx("img",{src:w.avatarUrl,alt:"",className:"h-5 w-5 shrink-0 rounded-full"}),n.jsxs("span",{className:"truncate text-xs font-medium text-gray-800 dark:text-gray-100",title:w.sampleReviewBody??void 0,children:[w.login,w.displayName!=null&&w.displayName!==w.login&&n.jsx("span",{className:"ml-1 font-normal text-gray-400",children:w.displayName})]}),n.jsxs("span",{className:"ml-auto shrink-0 text-[10px] text-gray-400",children:[w.threadsLast90d," threads · 90d"]})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px] font-medium",style:{color:j.color,backgroundColor:`${j.color}1a`},children:[n.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:j.color}}),j.label]}),R.confidence!=="high"&&n.jsxs("span",{className:"text-[10px] text-amber-500",title:R.reasons.join(" · "),children:["likely (",R.confidence,")"]}),w.isManualOverride?n.jsx("span",{className:"rounded bg-sky-50 px-1 py-0.5 text-[9px] font-medium uppercase tracking-wide text-sky-600 dark:bg-sky-950 dark:text-sky-300",children:"manual"}):n.jsx("span",{className:"text-[9px] uppercase tracking-wide text-gray-300 dark:text-gray-600",title:R.reasons.join(" · "),children:R.source.replace(/_/g," ")})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsx("select",{className:`${rt} w-auto py-0.5`,value:S.kind,onChange:T=>m(w,{kind:T.target.value}),"aria-label":"Reviewer kind",children:Lj.map(T=>n.jsx("option",{value:T,children:an(T).label},T))}),n.jsx("input",{className:`${rt} w-28 py-0.5`,value:S.label,placeholder:"Label",onChange:T=>m(w,{label:T.target.value}),"aria-label":"Reviewer label"}),n.jsx("button",{type:"button",disabled:g,onClick:()=>s.mutate({userId:w.userId,body:{automated:!0,kind:S.kind,label:S.label}}),className:"rounded bg-sky-600 px-2 py-0.5 text-[11px] font-medium text-white hover:bg-sky-700 disabled:opacity-40",children:"Apply"}),n.jsx("button",{type:"button",disabled:g,onClick:()=>s.mutate({userId:w.userId,body:{automated:!1,kind:null}}),className:"rounded border border-gray-300 px-2 py-0.5 text-[11px] font-medium text-gray-600 hover:bg-gray-100 disabled:opacity-40 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:"Not a bot"}),n.jsx("button",{type:"button",disabled:a.isPending,onClick:()=>a.mutate({vendorKind:R.kind??S.kind,action:"hide"}),title:"Hide this vendor's threads (adds a mute rule)",className:"rounded px-1.5 py-0.5 text-[11px] font-medium text-gray-500 hover:bg-gray-100 disabled:opacity-40 dark:text-gray-400 dark:hover:bg-gray-800",children:"Mute"})]})]},w.userId)})}),n.jsxs("div",{className:"mt-1 space-y-1.5",children:[n.jsxs("label",{className:"flex flex-col gap-1 text-xs",children:[n.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:"Add a review bot"}),n.jsx("input",{className:rt,value:u,placeholder:"Search reviewers by name or login…",onChange:w=>d(w.target.value),"aria-label":"Search reviewers to mark as a review bot"})]}),N===""?n.jsx("p",{className:"text-[10px] text-gray-400",children:"Type a reviewer's name to mark them as a bot. They default to In-house AI — set the exact vendor above once added."}):I.length===0?n.jsx("p",{className:"text-[10px] text-gray-400",children:"No matching reviewers."}):n.jsx("ul",{className:"divide-y divide-gray-100 rounded border border-gray-200 dark:divide-gray-800 dark:border-gray-700",children:I.map(w=>n.jsxs("li",{className:"flex items-center gap-2 px-2.5 py-1.5",children:[w.avatarUrl!=null&&n.jsx("img",{src:w.avatarUrl,alt:"",className:"h-5 w-5 shrink-0 rounded-full"}),n.jsxs("span",{className:"truncate text-xs font-medium text-gray-800 dark:text-gray-100",children:[w.login,w.displayName!=null&&w.displayName!==w.login&&n.jsx("span",{className:"ml-1 font-normal text-gray-400",children:w.displayName})]}),n.jsxs("span",{className:"ml-auto shrink-0 text-[10px] text-gray-400",children:[w.threadsLast90d," · 90d"]}),n.jsx("button",{type:"button",disabled:g,onClick:()=>P(w),className:"shrink-0 rounded bg-sky-600 px-2 py-0.5 text-[11px] font-medium text-white hover:bg-sky-700 disabled:opacity-40",children:"Treat as review bot"})]},w.userId))})]})]}),s.isError&&n.jsx("p",{className:"text-[11px] text-red-500",children:s.error.message})]})}const Dj=Object.keys(qs),Bj=e=>e==null?"Any bot":an(e).label;function zj({settings:e,save:s,saving:a}){var U,G;const o=$y(),i=Uu(),u=My(),d=e.bots,[p,m]=x.useState(d.autoResolve),[g,y]=x.useState(d.autoResolveDays),b=p!==d.autoResolve||g!==d.autoResolveDays,[v,N]=x.useState("any"),[I,P]=x.useState(""),[E,w]=x.useState(""),[R,S]=x.useState("hide"),[j,T]=x.useState(7),M=()=>{i.mutate({vendorKind:v==="any"?null:v,pathGlob:I.trim()===""?null:I.trim(),severity:E.trim()===""?null:E.trim(),action:R,autoResolveDays:R==="auto_resolve"?Math.min(90,Math.max(1,j)):null},{onSuccess:()=>{P(""),w("")}})},D=((U=o.data)==null?void 0:U.rules)??[];return n.jsxs(or,{title:"Mute & auto-triage rules",desc:"Hide low-value bot threads, or (with auto-resolve on) let a background job resolve likely-addressed bot threads older than a threshold. Auto-resolve only ever touches likely-addressed threads and never merges.",children:[n.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[n.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[n.jsx("input",{type:"checkbox",checked:p,onChange:L=>m(L.target.checked)}),n.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:"Enable standing auto-resolve"})]}),n.jsx(Nt,{label:"Older than (days)",children:n.jsx("input",{type:"number",min:1,max:90,className:`${rt} w-20`,value:g,onChange:L=>y(Math.min(90,Math.max(1,Number(L.target.value)||1)))})}),n.jsx(Pr,{dirty:b,saving:a,onClick:()=>s({bots:{autoResolve:p,autoResolveDays:g}})})]}),n.jsx("div",{className:"mt-1 space-y-1",children:o.isLoading?n.jsx("p",{className:"py-2 text-center text-[11px] text-gray-400",children:"Loading rules…"}):D.length===0?n.jsx("p",{className:"py-2 text-center text-[11px] text-gray-400",children:"No rules yet."}):n.jsx("ul",{className:"divide-y divide-gray-100 rounded border border-gray-200 dark:divide-gray-800 dark:border-gray-700",children:D.map(L=>n.jsxs("li",{className:"flex items-center gap-2 px-2 py-1.5 text-[11px]",children:[n.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:Bj(L.vendorKind)}),n.jsx("span",{className:"text-gray-400",children:L.pathGlob??"any path"}),n.jsx("span",{className:"text-gray-400",children:L.severity??"any severity"}),n.jsx("span",{className:`ml-auto rounded px-1.5 py-0.5 font-medium ${L.action==="auto_resolve"?"bg-amber-50 text-amber-600 dark:bg-amber-950 dark:text-amber-300":"bg-gray-100 text-gray-500 dark:bg-gray-800 dark:text-gray-300"}`,children:L.action==="auto_resolve"?`Auto-resolve · ${L.autoResolveDays??"?"}d`:"Hide"}),n.jsx("button",{type:"button",disabled:u.isPending,onClick:()=>u.mutate(L.id),className:"text-gray-400 hover:text-red-500 disabled:opacity-40","aria-label":"Delete rule",title:"Delete rule",children:"✕"})]},L.id))})}),n.jsxs("div",{className:"flex flex-wrap items-end gap-2 rounded border border-dashed border-gray-200 p-2 dark:border-gray-700",children:[n.jsx(Nt,{label:"Vendor",children:n.jsxs("select",{className:`${rt} w-auto`,value:v,onChange:L=>N(L.target.value),children:[n.jsx("option",{value:"any",children:"Any bot"}),Dj.map(L=>n.jsx("option",{value:L,children:an(L).label},L))]})}),n.jsx(Nt,{label:"Path glob",children:n.jsx("input",{className:`${rt} w-28`,value:I,placeholder:"e.g. tests/**",onChange:L=>P(L.target.value)})}),n.jsx(Nt,{label:"Severity",children:n.jsx("input",{className:`${rt} w-24`,value:E,placeholder:"e.g. nitpick",onChange:L=>w(L.target.value)})}),n.jsx(Nt,{label:"Action",children:n.jsxs("select",{className:`${rt} w-auto`,value:R,onChange:L=>S(L.target.value),children:[n.jsx("option",{value:"hide",children:"Hide"}),n.jsx("option",{value:"auto_resolve",children:"Auto-resolve"})]})}),R==="auto_resolve"&&n.jsx(Nt,{label:"Days",children:n.jsx("input",{type:"number",min:1,max:90,className:`${rt} w-16`,value:j,onChange:L=>T(Math.min(90,Math.max(1,Number(L.target.value)||1)))})}),n.jsx("button",{type:"button",disabled:i.isPending,onClick:M,className:"self-start rounded bg-sky-600 px-3 py-1 text-xs font-medium text-white hover:bg-sky-700 disabled:opacity-40",children:i.isPending?"Adding…":"Add rule"})]}),(i.isError||u.isError)&&n.jsx("p",{className:"text-[11px] text-red-500",children:(G=i.error??u.error)==null?void 0:G.message})]})}const Km=Object.keys(qs);function $s({label:e,hint:s,checked:a,onChange:o}){return n.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[n.jsx("input",{type:"checkbox",className:"mt-0.5",checked:a,onChange:i=>o(i.target.checked)}),n.jsxs("span",{children:[n.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:e}),s!=null&&n.jsx("span",{className:"block text-[11px] text-gray-400",children:s})]})]})}function qj({settings:e,save:s,saving:a}){const o=yn(),i=e.bots,[u,d]=x.useState(i.inhouseDetect),[p,m]=x.useState(i.autoTagHighConfidence),[g,y]=x.useState(i.deepDetect),[b,v]=x.useState(i.aiTiebreak),[N,I]=x.useState(i.loginAllowlist.join(`
50
- `)),P=N.split(/[\n,]/).map(B=>B.trim()).filter(Boolean),E=u!==i.inhouseDetect||p!==i.autoTagHighConfidence||g!==i.deepDetect||b!==i.aiTiebreak||P.join(`
45
+ */var pb=["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] *)"],ku=pb.join(","),Th=typeof Element>"u",fl=Th?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Ho=!Th&&Element.prototype.getRootNode?function(e){var s;return e==null||(s=e.getRootNode)===null||s===void 0?void 0:s.call(e)}:function(e){return e==null?void 0:e.ownerDocument},Wo=function(s,a){var o;a===void 0&&(a=!0);var i=s==null||(o=s.getAttribute)===null||o===void 0?void 0:o.call(s,"inert"),u=i===""||i==="true",d=u||a&&s&&(typeof s.closest=="function"?s.closest("[inert]"):Wo(s.parentNode));return d},mb=function(s){var a,o=s==null||(a=s.getAttribute)===null||a===void 0?void 0:a.call(s,"contenteditable");return o===""||o==="true"},hb=function(s,a,o){if(Wo(s))return[];var i=Array.prototype.slice.apply(s.querySelectorAll(ku));return a&&fl.call(s,ku)&&i.unshift(s),i=i.filter(o),i},ju=function(s,a,o){for(var i=[],u=Array.from(s);u.length;){var d=u.shift();if(!Wo(d,!1))if(d.tagName==="SLOT"){var p=d.assignedElements(),m=p.length?p:d.children,g=ju(m,!0,o);o.flatten?i.push.apply(i,g):i.push({scopeParent:d,candidates:g})}else{var w=fl.call(d,ku);w&&o.filter(d)&&(a||!s.includes(d))&&i.push(d);var v=d.shadowRoot||typeof o.getShadowRoot=="function"&&o.getShadowRoot(d),y=!Wo(v,!1)&&(!o.shadowRootFilter||o.shadowRootFilter(d));if(v&&y){var j=ju(v===!0?d.children:v.children,!0,o);o.flatten?i.push.apply(i,j):i.push({scopeParent:d,candidates:j})}else u.unshift.apply(u,d.children)}}return i},Eh=function(s){return!isNaN(parseInt(s.getAttribute("tabindex"),10))},Ph=function(s){if(!s)throw new Error("No node provided");return s.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(s.tagName)||mb(s))&&!Eh(s)?0:s.tabIndex},gb=function(s,a){var o=Ph(s);return o<0&&a&&!Eh(s)?0:o},xb=function(s,a){return s.tabIndex===a.tabIndex?s.documentOrder-a.documentOrder:s.tabIndex-a.tabIndex},Ah=function(s){return s.tagName==="INPUT"},yb=function(s){return Ah(s)&&s.type==="hidden"},vb=function(s){var a=s.tagName==="DETAILS"&&Array.prototype.slice.apply(s.children).some(function(o){return o.tagName==="SUMMARY"});return a},bb=function(s,a){for(var o=0;o<s.length;o++)if(s[o].checked&&s[o].form===a)return s[o]},wb=function(s){if(!s.name)return!0;var a=s.form||Ho(s),o=function(p){return a.querySelectorAll('input[type="radio"][name="'+p+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=o(window.CSS.escape(s.name));else try{i=o(s.name)}catch(d){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",d.message),!1}var u=bb(i,s.form);return!u||u===s},kb=function(s){return Ah(s)&&s.type==="radio"},jb=function(s){return kb(s)&&!wb(s)},Nb=function(s){var a,o=s&&Ho(s),i=(a=o)===null||a===void 0?void 0:a.host,u=!1;if(o&&o!==s){var d,p,m;for(u=!!((d=i)!==null&&d!==void 0&&(p=d.ownerDocument)!==null&&p!==void 0&&p.contains(i)||s!=null&&(m=s.ownerDocument)!==null&&m!==void 0&&m.contains(s));!u&&i;){var g,w,v;o=Ho(i),i=(g=o)===null||g===void 0?void 0:g.host,u=!!((w=i)!==null&&w!==void 0&&(v=w.ownerDocument)!==null&&v!==void 0&&v.contains(i))}}return u},Xp=function(s){var a=s.getBoundingClientRect(),o=a.width,i=a.height;return o===0&&i===0},Sb=function(s,a){var o=a.displayCheck,i=a.getShadowRoot;if(o==="full-native"&&"checkVisibility"in s){var u=s.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!u}if(getComputedStyle(s).visibility==="hidden")return!0;var d=fl.call(s,"details>summary:first-of-type"),p=d?s.parentElement:s;if(fl.call(p,"details:not([open]) *"))return!0;if(!o||o==="full"||o==="full-native"||o==="legacy-full"){if(typeof i=="function"){for(var m=s;s;){var g=s.parentElement,w=Ho(s);if(g&&!g.shadowRoot&&i(g)===!0)return Xp(s);s.assignedSlot?s=s.assignedSlot:!g&&w!==s.ownerDocument?s=w.host:s=g}s=m}if(Nb(s))return!s.getClientRects().length;if(o!=="legacy-full")return!0}else if(o==="non-zero-area")return Xp(s);return!1},Cb=function(s){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(s.tagName))for(var a=s.parentElement;a;){if(a.tagName==="FIELDSET"&&a.disabled){for(var o=0;o<a.children.length;o++){var i=a.children.item(o);if(i.tagName==="LEGEND")return fl.call(a,"fieldset[disabled] *")?!0:!i.contains(s)}return!0}a=a.parentElement}return!1},Rb=function(s,a){return!(a.disabled||yb(a)||Sb(a,s)||vb(a)||Cb(a))},Jp=function(s,a){return!(jb(a)||Ph(a)<0||!Rb(s,a))},Ib=function(s){var a=parseInt(s.getAttribute("tabindex"),10);return!!(isNaN(a)||a>=0)},$h=function(s){var a=[],o=[];return s.forEach(function(i,u){var d=!!i.scopeParent,p=d?i.scopeParent:i,m=gb(p,d),g=d?$h(i.candidates):p;m===0?d?a.push.apply(a,g):a.push(p):o.push({documentOrder:u,tabIndex:m,item:i,isScope:d,content:g})}),o.sort(xb).reduce(function(i,u){return u.isScope?i.push.apply(i,u.content):i.push(u.content),i},[]).concat(a)},Mh=function(s,a){a=a||{};var o;return a.getShadowRoot?o=ju([s],a.includeContainer,{filter:Jp.bind(null,a),flatten:!1,getShadowRoot:a.getShadowRoot,shadowRootFilter:Ib}):o=hb(s,a.includeContainer,Jp.bind(null,a)),$h(o)};function Tb(){return/apple/i.test(navigator.vendor)}function Eb(e){let s=e.activeElement;for(;((a=s)==null||(a=a.shadowRoot)==null?void 0:a.activeElement)!=null;){var a;s=s.shadowRoot.activeElement}return s}function Nu(e,s){if(!e||!s)return!1;const a=s.getRootNode==null?void 0:s.getRootNode();if(e.contains(s))return!0;if(a&&vu(a)){let o=s;for(;o;){if(e===o)return!0;o=o.parentNode||o.host}}return!1}function sl(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Yc(e,s){if(s==null)return!1;if("composedPath"in e)return e.composedPath().includes(s);const a=e;return a.target!=null&&s.contains(a.target)}function Pb(e){return e.matches("html,body")}function pl(e){return(e==null?void 0:e.ownerDocument)||document}function Mo(e,s,a){return a===void 0&&(a=!0),e.filter(i=>{var u;return i.parentId===s&&(!a||((u=i.context)==null?void 0:u.open))}).flatMap(i=>[i,...Mo(e,i.id,a)])}function Ab(e){return"nativeEvent"in e}var $b=typeof document<"u",Mb=function(){},Ls=$b?x.useLayoutEffect:Mb;const Fb={...Gm},Lb=Fb.useInsertionEffect,_b=Lb||(e=>e());function Na(e){const s=x.useRef(()=>{});return _b(()=>{s.current=e}),x.useCallback(function(){for(var a=arguments.length,o=new Array(a),i=0;i<a;i++)o[i]=arguments[i];return s.current==null?void 0:s.current(...o)},[])}const Fh=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Lh(e,s){const a=Mh(e,Fh()),o=a.length;if(o===0)return;const i=Eb(pl(e)),u=a.indexOf(i),d=u===-1?s===1?0:o-1:u+s;return a[d]}function Ob(e){return Lh(pl(e).body,1)||e}function Db(e){return Lh(pl(e).body,-1)||e}function Xc(e,s){const a=s||e.currentTarget,o=e.relatedTarget;return!o||!Nu(a,o)}function Bb(e){Mh(e,Fh()).forEach(a=>{a.dataset.tabindex=a.getAttribute("tabindex")||"",a.setAttribute("tabindex","-1")})}function Zp(e){e.querySelectorAll("[data-tabindex]").forEach(a=>{const o=a.dataset.tabindex;delete a.dataset.tabindex,o?a.setAttribute("tabindex",o):a.removeAttribute("tabindex")})}var _h=Ym();function em(e,s,a){let{reference:o,floating:i}=e;const u=as(s),d=Ih(s),p=Rh(d),m=Ds(s),g=u==="y",w=o.x+o.width/2-i.width/2,v=o.y+o.height/2-i.height/2,y=o[p]/2-i[p]/2;let j;switch(m){case"top":j={x:w,y:o.y-i.height};break;case"bottom":j={x:w,y:o.y+o.height};break;case"right":j={x:o.x+o.width,y:v};break;case"left":j={x:o.x-i.width,y:v};break;default:j={x:o.x,y:o.y}}switch(oi(s)){case"start":j[d]-=y*(a&&g?-1:1);break;case"end":j[d]+=y*(a&&g?-1:1);break}return j}async function zb(e,s){var a;s===void 0&&(s={});const{x:o,y:i,platform:u,rects:d,elements:p,strategy:m}=e,{boundary:g="clippingAncestors",rootBoundary:w="viewport",elementContext:v="floating",altBoundary:y=!1,padding:j=0}=li(s,e),R=fb(j),E=p[y?v==="floating"?"reference":"floating":v],S=Ko(await u.getClippingRect({element:(a=await(u.isElement==null?void 0:u.isElement(E)))==null||a?E:E.contextElement||await(u.getDocumentElement==null?void 0:u.getDocumentElement(p.floating)),boundary:g,rootBoundary:w,strategy:m})),T=v==="floating"?{x:o,y:i,width:d.floating.width,height:d.floating.height}:d.reference,N=await(u.getOffsetParent==null?void 0:u.getOffsetParent(p.floating)),b=await(u.isElement==null?void 0:u.isElement(N))?await(u.getScale==null?void 0:u.getScale(N))||{x:1,y:1}:{x:1,y:1},I=Ko(u.convertOffsetParentRelativeRectToViewportRelativeRect?await u.convertOffsetParentRelativeRectToViewportRelativeRect({elements:p,rect:T,offsetParent:N,strategy:m}):T);return{top:(S.top-I.top+R.top)/b.y,bottom:(I.bottom-S.bottom+R.bottom)/b.y,left:(S.left-I.left+R.left)/b.x,right:(I.right-S.right+R.right)/b.x}}const qb=50,Ub=async(e,s,a)=>{const{placement:o="bottom",strategy:i="absolute",middleware:u=[],platform:d}=a,p=d.detectOverflow?d:{...d,detectOverflow:zb},m=await(d.isRTL==null?void 0:d.isRTL(s));let g=await d.getElementRects({reference:e,floating:s,strategy:i}),{x:w,y:v}=em(g,o,m),y=o,j=0;const R={};for(let P=0;P<u.length;P++){const E=u[P];if(!E)continue;const{name:S,fn:T}=E,{x:N,y:b,data:I,reset:$}=await T({x:w,y:v,initialPlacement:o,placement:y,strategy:i,middlewareData:R,rects:g,platform:p,elements:{reference:e,floating:s}});w=N??w,v=b??v,R[S]={...R[S],...I},$&&j<qb&&(j++,typeof $=="object"&&($.placement&&(y=$.placement),$.rects&&(g=$.rects===!0?await d.getElementRects({reference:e,floating:s,strategy:i}):$.rects),{x:w,y:v}=em(g,y,m)),P=-1)}return{x:w,y:v,placement:y,strategy:i,middlewareData:R}},Kb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(s){var a,o;const{placement:i,middlewareData:u,rects:d,initialPlacement:p,platform:m,elements:g}=s,{mainAxis:w=!0,crossAxis:v=!0,fallbackPlacements:y,fallbackStrategy:j="bestFit",fallbackAxisSideDirection:R="none",flipAlignment:P=!0,...E}=li(e,s);if((a=u.arrow)!=null&&a.alignmentOffset)return{};const S=Ds(i),T=as(p),N=Ds(p)===p,b=await(m.isRTL==null?void 0:m.isRTL(g.floating)),I=y||(N||!P?[Uo(p)]:lb(p)),$=R!=="none";!y&&$&&I.push(...ub(p,P,R,b));const L=[p,...I],q=await m.detectOverflow(s,E),Q=[];let _=((o=u.flip)==null?void 0:o.overflows)||[];if(w&&Q.push(q[S]),v){const O=ab(i,d,b);Q.push(q[O[0]],q[O[1]])}if(_=[..._,{placement:i,overflows:Q}],!Q.every(O=>O<=0)){var Y,X;const O=(((Y=u.flip)==null?void 0:Y.index)||0)+1,H=L[O];if(H&&(!(v==="alignment"?T!==as(H):!1)||_.every(C=>as(C.placement)===T?C.overflows[0]>0:!0)))return{data:{index:O,overflows:_},reset:{placement:H}};let ee=(X=_.filter(ce=>ce.overflows[0]<=0).sort((ce,C)=>ce.overflows[1]-C.overflows[1])[0])==null?void 0:X.placement;if(!ee)switch(j){case"bestFit":{var B;const ce=(B=_.filter(C=>{if($){const F=as(C.placement);return F===T||F==="y"}return!0}).map(C=>[C.placement,C.overflows.filter(F=>F>0).reduce((F,K)=>F+K,0)]).sort((C,F)=>C[1]-F[1])[0])==null?void 0:B[0];ce&&(ee=ce);break}case"initialPlacement":ee=p;break}if(i!==ee)return{reset:{placement:ee}}}return{}}}},Hb=new Set(["left","top"]);async function Wb(e,s){const{placement:a,platform:o,elements:i}=e,u=await(o.isRTL==null?void 0:o.isRTL(i.floating)),d=Ds(a),p=oi(a),m=as(a)==="y",g=Hb.has(d)?-1:1,w=u&&m?-1:1,v=li(s,e);let{mainAxis:y,crossAxis:j,alignmentAxis:R}=typeof v=="number"?{mainAxis:v,crossAxis:0,alignmentAxis:null}:{mainAxis:v.mainAxis||0,crossAxis:v.crossAxis||0,alignmentAxis:v.alignmentAxis};return p&&typeof R=="number"&&(j=p==="end"?R*-1:R),m?{x:j*w,y:y*g}:{x:y*g,y:j*w}}const Vb=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(s){var a,o;const{x:i,y:u,placement:d,middlewareData:p}=s,m=await Wb(s,e);return d===((a=p.offset)==null?void 0:a.placement)&&(o=p.arrow)!=null&&o.alignmentOffset?{}:{x:i+m.x,y:u+m.y,data:{...m,placement:d}}}}},Qb=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(s){const{x:a,y:o,placement:i,platform:u}=s,{mainAxis:d=!0,crossAxis:p=!1,limiter:m={fn:S=>{let{x:T,y:N}=S;return{x:T,y:N}}},...g}=li(e,s),w={x:a,y:o},v=await u.detectOverflow(s,g),y=as(Ds(i)),j=Ch(y);let R=w[j],P=w[y];if(d){const S=j==="y"?"top":"left",T=j==="y"?"bottom":"right",N=R+v[S],b=R-v[T];R=Qp(N,R,b)}if(p){const S=y==="y"?"top":"left",T=y==="y"?"bottom":"right",N=P+v[S],b=P-v[T];P=Qp(N,P,b)}const E=m.fn({...s,[j]:R,[y]:P});return{...E,data:{x:E.x-a,y:E.y-o,enabled:{[j]:d,[y]:p}}}}}};function Oh(e){const s=An(e);let a=parseFloat(s.width)||0,o=parseFloat(s.height)||0;const i=fr(e),u=i?e.offsetWidth:a,d=i?e.offsetHeight:o,p=qo(a)!==u||qo(o)!==d;return p&&(a=u,o=d),{width:a,height:o,$:p}}function Vu(e){return dt(e)?e:e.contextElement}function Ca(e){const s=Vu(e);if(!fr(s))return ir(1);const a=s.getBoundingClientRect(),{width:o,height:i,$:u}=Oh(s);let d=(u?qo(a.width):a.width)/o,p=(u?qo(a.height):a.height)/i;return(!d||!Number.isFinite(d))&&(d=1),(!p||!Number.isFinite(p))&&(p=1),{x:d,y:p}}const Gb=ir(0);function Dh(e){const s=xn(e);return!si()||!s.visualViewport?Gb:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function Yb(e,s,a){return s===void 0&&(s=!1),!a||s&&a!==xn(e)?!1:s}function Bs(e,s,a,o){s===void 0&&(s=!1),a===void 0&&(a=!1);const i=e.getBoundingClientRect(),u=Vu(e);let d=ir(1);s&&(o?dt(o)&&(d=Ca(o)):d=Ca(e));const p=Yb(u,a,o)?Dh(u):ir(0);let m=(i.left+p.x)/d.x,g=(i.top+p.y)/d.y,w=i.width/d.x,v=i.height/d.y;if(u){const y=xn(u),j=o&&dt(o)?xn(o):o;let R=y,P=bu(R);for(;P&&o&&j!==R;){const E=Ca(P),S=P.getBoundingClientRect(),T=An(P),N=S.left+(P.clientLeft+parseFloat(T.paddingLeft))*E.x,b=S.top+(P.clientTop+parseFloat(T.paddingTop))*E.y;m*=E.x,g*=E.y,w*=E.x,v*=E.y,m+=N,g+=b,R=xn(P),P=bu(R)}}return Ko({width:w,height:v,x:m,y:g})}function ii(e,s){const a=ai(e).scrollLeft;return s?s.left+a:Bs(dr(e)).left+a}function Bh(e,s){const a=e.getBoundingClientRect(),o=a.left+s.scrollLeft-ii(e,a),i=a.top+s.scrollTop;return{x:o,y:i}}function Xb(e){let{elements:s,rect:a,offsetParent:o,strategy:i}=e;const u=i==="fixed",d=dr(o),p=s?ri(s.floating):!1;if(o===d||p&&u)return a;let m={scrollLeft:0,scrollTop:0},g=ir(1);const w=ir(0),v=fr(o);if((v||!v&&!u)&&((Ia(o)!=="body"||xl(d))&&(m=ai(o)),v)){const j=Bs(o);g=Ca(o),w.x=j.x+o.clientLeft,w.y=j.y+o.clientTop}const y=d&&!v&&!u?Bh(d,m):ir(0);return{width:a.width*g.x,height:a.height*g.y,x:a.x*g.x-m.scrollLeft*g.x+w.x+y.x,y:a.y*g.y-m.scrollTop*g.y+w.y+y.y}}function Jb(e){return Array.from(e.getClientRects())}function Zb(e){const s=dr(e),a=ai(e),o=e.ownerDocument.body,i=Fs(s.scrollWidth,s.clientWidth,o.scrollWidth,o.clientWidth),u=Fs(s.scrollHeight,s.clientHeight,o.scrollHeight,o.clientHeight);let d=-a.scrollLeft+ii(e);const p=-a.scrollTop;return An(o).direction==="rtl"&&(d+=Fs(s.clientWidth,o.clientWidth)-i),{width:i,height:u,x:d,y:p}}const tm=25;function ew(e,s){const a=xn(e),o=dr(e),i=a.visualViewport;let u=o.clientWidth,d=o.clientHeight,p=0,m=0;if(i){u=i.width,d=i.height;const w=si();(!w||w&&s==="fixed")&&(p=i.offsetLeft,m=i.offsetTop)}const g=ii(o);if(g<=0){const w=o.ownerDocument,v=w.body,y=getComputedStyle(v),j=w.compatMode==="CSS1Compat"&&parseFloat(y.marginLeft)+parseFloat(y.marginRight)||0,R=Math.abs(o.clientWidth-v.clientWidth-j);R<=tm&&(u-=R)}else g<=tm&&(u+=g);return{width:u,height:d,x:p,y:m}}function tw(e,s){const a=Bs(e,!0,s==="fixed"),o=a.top+e.clientTop,i=a.left+e.clientLeft,u=fr(e)?Ca(e):ir(1),d=e.clientWidth*u.x,p=e.clientHeight*u.y,m=i*u.x,g=o*u.y;return{width:d,height:p,x:m,y:g}}function nm(e,s,a){let o;if(s==="viewport")o=ew(e,a);else if(s==="document")o=Zb(dr(e));else if(dt(s))o=tw(s,a);else{const i=Dh(e);o={x:s.x-i.x,y:s.y-i.y,width:s.width,height:s.height}}return Ko(o)}function zh(e,s){const a=$r(e);return a===s||!dt(a)||Ar(a)?!1:An(a).position==="fixed"||zh(a,s)}function nw(e,s){const a=s.get(e);if(a)return a;let o=ls(e,[],!1).filter(p=>dt(p)&&Ia(p)!=="body"),i=null;const u=An(e).position==="fixed";let d=u?$r(e):e;for(;dt(d)&&!Ar(d);){const p=An(d),m=Wu(d);!m&&p.position==="fixed"&&(i=null),(u?!m&&!i:!m&&p.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||xl(d)&&!m&&zh(e,d))?o=o.filter(w=>w!==d):i=p,d=$r(d)}return s.set(e,o),o}function rw(e){let{element:s,boundary:a,rootBoundary:o,strategy:i}=e;const d=[...a==="clippingAncestors"?ri(s)?[]:nw(s,this._c):[].concat(a),o],p=nm(s,d[0],i);let m=p.top,g=p.right,w=p.bottom,v=p.left;for(let y=1;y<d.length;y++){const j=nm(s,d[y],i);m=Fs(j.top,m),g=zo(j.right,g),w=zo(j.bottom,w),v=Fs(j.left,v)}return{width:g-v,height:w-m,x:v,y:m}}function sw(e){const{width:s,height:a}=Oh(e);return{width:s,height:a}}function aw(e,s,a){const o=fr(s),i=dr(s),u=a==="fixed",d=Bs(e,!0,u,s);let p={scrollLeft:0,scrollTop:0};const m=ir(0);function g(){m.x=ii(i)}if(o||!o&&!u)if((Ia(s)!=="body"||xl(i))&&(p=ai(s)),o){const j=Bs(s,!0,u,s);m.x=j.x+s.clientLeft,m.y=j.y+s.clientTop}else i&&g();u&&!o&&i&&g();const w=i&&!o&&!u?Bh(i,p):ir(0),v=d.left+p.scrollLeft-m.x-w.x,y=d.top+p.scrollTop-m.y-w.y;return{x:v,y,width:d.width,height:d.height}}function Jc(e){return An(e).position==="static"}function rm(e,s){if(!fr(e)||An(e).position==="fixed")return null;if(s)return s(e);let a=e.offsetParent;return dr(e)===a&&(a=a.ownerDocument.body),a}function qh(e,s){const a=xn(e);if(ri(e))return a;if(!fr(e)){let i=$r(e);for(;i&&!Ar(i);){if(dt(i)&&!Jc(i))return i;i=$r(i)}return a}let o=rm(e,s);for(;o&&eb(o)&&Jc(o);)o=rm(o,s);return o&&Ar(o)&&Jc(o)&&!Wu(o)?a:o||rb(e)||a}const lw=async function(e){const s=this.getOffsetParent||qh,a=this.getDimensions,o=await a(e.floating);return{reference:aw(e.reference,await s(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function ow(e){return An(e).direction==="rtl"}const iw={convertOffsetParentRelativeRectToViewportRelativeRect:Xb,getDocumentElement:dr,getClippingRect:rw,getOffsetParent:qh,getElementRects:lw,getClientRects:Jb,getDimensions:sw,getScale:Ca,isElement:dt,isRTL:ow};function Uh(e,s){return e.x===s.x&&e.y===s.y&&e.width===s.width&&e.height===s.height}function cw(e,s){let a=null,o;const i=dr(e);function u(){var p;clearTimeout(o),(p=a)==null||p.disconnect(),a=null}function d(p,m){p===void 0&&(p=!1),m===void 0&&(m=1),u();const g=e.getBoundingClientRect(),{left:w,top:v,width:y,height:j}=g;if(p||s(),!y||!j)return;const R=Ro(v),P=Ro(i.clientWidth-(w+y)),E=Ro(i.clientHeight-(v+j)),S=Ro(w),N={rootMargin:-R+"px "+-P+"px "+-E+"px "+-S+"px",threshold:Fs(0,zo(1,m))||1};let b=!0;function I($){const L=$[0].intersectionRatio;if(L!==m){if(!b)return d();L?d(!1,L):o=setTimeout(()=>{d(!1,1e-7)},1e3)}L===1&&!Uh(g,e.getBoundingClientRect())&&d(),b=!1}try{a=new IntersectionObserver(I,{...N,root:i.ownerDocument})}catch{a=new IntersectionObserver(I,N)}a.observe(e)}return d(!0),u}function Kh(e,s,a,o){o===void 0&&(o={});const{ancestorScroll:i=!0,ancestorResize:u=!0,elementResize:d=typeof ResizeObserver=="function",layoutShift:p=typeof IntersectionObserver=="function",animationFrame:m=!1}=o,g=Vu(e),w=i||u?[...g?ls(g):[],...s?ls(s):[]]:[];w.forEach(S=>{i&&S.addEventListener("scroll",a,{passive:!0}),u&&S.addEventListener("resize",a)});const v=g&&p?cw(g,a):null;let y=-1,j=null;d&&(j=new ResizeObserver(S=>{let[T]=S;T&&T.target===g&&j&&s&&(j.unobserve(s),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{var N;(N=j)==null||N.observe(s)})),a()}),g&&!m&&j.observe(g),s&&j.observe(s));let R,P=m?Bs(e):null;m&&E();function E(){const S=Bs(e);P&&!Uh(P,S)&&a(),P=S,R=requestAnimationFrame(E)}return a(),()=>{var S;w.forEach(T=>{i&&T.removeEventListener("scroll",a),u&&T.removeEventListener("resize",a)}),v==null||v(),(S=j)==null||S.disconnect(),j=null,m&&cancelAnimationFrame(R)}}const uw=Vb,dw=Qb,fw=Kb,pw=(e,s,a)=>{const o=new Map,i={platform:iw,...a},u={...i.platform,_c:o};return Ub(e,s,{...i,platform:u})};var mw=typeof document<"u",hw=function(){},Fo=mw?x.useLayoutEffect:hw;function Vo(e,s){if(e===s)return!0;if(typeof e!=typeof s)return!1;if(typeof e=="function"&&e.toString()===s.toString())return!0;let a,o,i;if(e&&s&&typeof e=="object"){if(Array.isArray(e)){if(a=e.length,a!==s.length)return!1;for(o=a;o--!==0;)if(!Vo(e[o],s[o]))return!1;return!0}if(i=Object.keys(e),a=i.length,a!==Object.keys(s).length)return!1;for(o=a;o--!==0;)if(!{}.hasOwnProperty.call(s,i[o]))return!1;for(o=a;o--!==0;){const u=i[o];if(!(u==="_owner"&&e.$$typeof)&&!Vo(e[u],s[u]))return!1}return!0}return e!==e&&s!==s}function Hh(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function sm(e,s){const a=Hh(e);return Math.round(s*a)/a}function Zc(e){const s=x.useRef(e);return Fo(()=>{s.current=e}),s}function gw(e){e===void 0&&(e={});const{placement:s="bottom",strategy:a="absolute",middleware:o=[],platform:i,elements:{reference:u,floating:d}={},transform:p=!0,whileElementsMounted:m,open:g}=e,[w,v]=x.useState({x:0,y:0,strategy:a,placement:s,middlewareData:{},isPositioned:!1}),[y,j]=x.useState(o);Vo(y,o)||j(o);const[R,P]=x.useState(null),[E,S]=x.useState(null),T=x.useCallback(C=>{C!==$.current&&($.current=C,P(C))},[]),N=x.useCallback(C=>{C!==L.current&&(L.current=C,S(C))},[]),b=u||R,I=d||E,$=x.useRef(null),L=x.useRef(null),q=x.useRef(w),Q=m!=null,_=Zc(m),Y=Zc(i),X=Zc(g),B=x.useCallback(()=>{if(!$.current||!L.current)return;const C={placement:s,strategy:a,middleware:y};Y.current&&(C.platform=Y.current),pw($.current,L.current,C).then(F=>{const K={...F,isPositioned:X.current!==!1};O.current&&!Vo(q.current,K)&&(q.current=K,_h.flushSync(()=>{v(K)}))})},[y,s,a,Y,X]);Fo(()=>{g===!1&&q.current.isPositioned&&(q.current.isPositioned=!1,v(C=>({...C,isPositioned:!1})))},[g]);const O=x.useRef(!1);Fo(()=>(O.current=!0,()=>{O.current=!1}),[]),Fo(()=>{if(b&&($.current=b),I&&(L.current=I),b&&I){if(_.current)return _.current(b,I,B);B()}},[b,I,B,_,Q]);const H=x.useMemo(()=>({reference:$,floating:L,setReference:T,setFloating:N}),[T,N]),ee=x.useMemo(()=>({reference:b,floating:I}),[b,I]),ce=x.useMemo(()=>{const C={position:a,left:0,top:0};if(!ee.floating)return C;const F=sm(ee.floating,w.x),K=sm(ee.floating,w.y);return p?{...C,transform:"translate("+F+"px, "+K+"px)",...Hh(ee.floating)>=1.5&&{willChange:"transform"}}:{position:a,left:F,top:K}},[a,p,ee.floating,w.x,w.y]);return x.useMemo(()=>({...w,update:B,refs:H,elements:ee,floatingStyles:ce}),[w,B,H,ee,ce])}const Wh=(e,s)=>{const a=uw(e);return{name:a.name,fn:a.fn,options:[e,s]}},Vh=(e,s)=>{const a=dw(e);return{name:a.name,fn:a.fn,options:[e,s]}},Qh=(e,s)=>{const a=fw(e);return{name:a.name,fn:a.fn,options:[e,s]}},xw="data-floating-ui-focusable",am="active",lm="selected",yw={...Gm};let om=!1,vw=0;const im=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+vw++;function bw(){const[e,s]=x.useState(()=>om?im():void 0);return Ls(()=>{e==null&&s(im())},[]),x.useEffect(()=>{om=!0},[]),e}const ww=yw.useId,Gh=ww||bw;function kw(){const e=new Map;return{emit(s,a){var o;(o=e.get(s))==null||o.forEach(i=>i(a))},on(s,a){e.has(s)||e.set(s,new Set),e.get(s).add(a)},off(s,a){var o;(o=e.get(s))==null||o.delete(a)}}}const jw=x.createContext(null),Nw=x.createContext(null),Sw=()=>{var e;return((e=x.useContext(jw))==null?void 0:e.id)||null},Yh=()=>x.useContext(Nw);function Qu(e){return"data-floating-ui-"+e}const Cw={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},cm=x.forwardRef(function(s,a){const[o,i]=x.useState();Ls(()=>{Tb()&&i("button")},[]);const u={ref:a,tabIndex:0,role:o,"aria-hidden":o?void 0:!0,[Qu("focus-guard")]:"",style:Cw};return n.jsx("span",{...s,...u})}),Rw={clipPath:"inset(50%)",position:"fixed",top:0,left:0},Xh=x.createContext(null),um=Qu("portal");function Iw(e){e===void 0&&(e={});const{id:s,root:a}=e,o=Gh(),i=Tw(),[u,d]=x.useState(null),p=x.useRef(null);return Ls(()=>()=>{u==null||u.remove(),queueMicrotask(()=>{p.current=null})},[u]),Ls(()=>{if(!o||p.current)return;const m=s?document.getElementById(s):null;if(!m)return;const g=document.createElement("div");g.id=o,g.setAttribute(um,""),m.appendChild(g),p.current=g,d(g)},[s,o]),Ls(()=>{if(a===null||!o||p.current)return;let m=a||(i==null?void 0:i.portalNode);m&&!Hu(m)&&(m=m.current),m=m||document.body;let g=null;s&&(g=document.createElement("div"),g.id=s,m.appendChild(g));const w=document.createElement("div");w.id=o,w.setAttribute(um,""),m=g||m,m.appendChild(w),p.current=w,d(w)},[s,a,o,i]),u}function Jh(e){const{children:s,id:a,root:o,preserveTabOrder:i=!0}=e,u=Iw({id:a,root:o}),[d,p]=x.useState(null),m=x.useRef(null),g=x.useRef(null),w=x.useRef(null),v=x.useRef(null),y=d==null?void 0:d.modal,j=d==null?void 0:d.open,R=!!d&&!d.modal&&d.open&&i&&!!(o||u);return x.useEffect(()=>{if(!u||!i||y)return;function P(E){u&&Xc(E)&&(E.type==="focusin"?Zp:Bb)(u)}return u.addEventListener("focusin",P,!0),u.addEventListener("focusout",P,!0),()=>{u.removeEventListener("focusin",P,!0),u.removeEventListener("focusout",P,!0)}},[u,i,y]),x.useEffect(()=>{u&&(j||Zp(u))},[j,u]),n.jsxs(Xh.Provider,{value:x.useMemo(()=>({preserveTabOrder:i,beforeOutsideRef:m,afterOutsideRef:g,beforeInsideRef:w,afterInsideRef:v,portalNode:u,setFocusManagerState:p}),[i,u]),children:[R&&u&&n.jsx(cm,{"data-type":"outside",ref:m,onFocus:P=>{if(Xc(P,u)){var E;(E=w.current)==null||E.focus()}else{const S=d?d.domReference:null,T=Db(S);T==null||T.focus()}}}),R&&u&&n.jsx("span",{"aria-owns":u.id,style:Rw}),u&&_h.createPortal(s,u),R&&u&&n.jsx(cm,{"data-type":"outside",ref:g,onFocus:P=>{if(Xc(P,u)){var E;(E=v.current)==null||E.focus()}else{const S=d?d.domReference:null,T=Ob(S);T==null||T.focus(),d!=null&&d.closeOnFocusOut&&(d==null||d.onOpenChange(!1,P.nativeEvent,"focus-out"))}}})]})}const Tw=()=>x.useContext(Xh),Ew={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Pw={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},dm=e=>{var s,a;return{escapeKey:typeof e=="boolean"?e:(s=e==null?void 0:e.escapeKey)!=null?s:!1,outsidePress:typeof e=="boolean"?e:(a=e==null?void 0:e.outsidePress)!=null?a:!0}};function Zh(e,s){s===void 0&&(s={});const{open:a,onOpenChange:o,elements:i,dataRef:u}=e,{enabled:d=!0,escapeKey:p=!0,outsidePress:m=!0,outsidePressEvent:g="pointerdown",referencePress:w=!1,referencePressEvent:v="pointerdown",ancestorScroll:y=!1,bubbles:j,capture:R}=s,P=Yh(),E=Na(typeof m=="function"?m:()=>!1),S=typeof m=="function"?E:m,T=x.useRef(!1),{escapeKey:N,outsidePress:b}=dm(j),{escapeKey:I,outsidePress:$}=dm(R),L=x.useRef(!1),q=Na(O=>{var H;if(!a||!d||!p||O.key!=="Escape"||L.current)return;const ee=(H=u.current.floatingContext)==null?void 0:H.nodeId,ce=P?Mo(P.nodesRef.current,ee):[];if(!N&&(O.stopPropagation(),ce.length>0)){let C=!0;if(ce.forEach(F=>{var K;if((K=F.context)!=null&&K.open&&!F.context.dataRef.current.__escapeKeyBubbles){C=!1;return}}),!C)return}o(!1,Ab(O)?O.nativeEvent:O,"escape-key")}),Q=Na(O=>{var H;const ee=()=>{var ce;q(O),(ce=sl(O))==null||ce.removeEventListener("keydown",ee)};(H=sl(O))==null||H.addEventListener("keydown",ee)}),_=Na(O=>{var H;const ee=u.current.insideReactTree;u.current.insideReactTree=!1;const ce=T.current;if(T.current=!1,g==="click"&&ce||ee||typeof S=="function"&&!S(O))return;const C=sl(O),F="["+Qu("inert")+"]",K=pl(i.floating).querySelectorAll(F);let ae=dt(C)?C:null;for(;ae&&!Ar(ae);){const Z=$r(ae);if(Ar(Z)||!dt(Z))break;ae=Z}if(K.length&&dt(C)&&!Pb(C)&&!Nu(C,i.floating)&&Array.from(K).every(Z=>!Nu(ae,Z)))return;if(fr(C)&&B){const Z=Ar(C),je=An(C),We=/auto|scroll/,st=Z||We.test(je.overflowX),Pt=Z||We.test(je.overflowY),Lt=st&&C.clientWidth>0&&C.scrollWidth>C.clientWidth,vn=Pt&&C.clientHeight>0&&C.scrollHeight>C.clientHeight,Le=je.direction==="rtl",Mn=vn&&(Le?O.offsetX<=C.offsetWidth-C.clientWidth:O.offsetX>C.clientWidth),Fn=Lt&&O.offsetY>C.clientHeight;if(Mn||Fn)return}const ne=(H=u.current.floatingContext)==null?void 0:H.nodeId,Pe=P&&Mo(P.nodesRef.current,ne).some(Z=>{var je;return Yc(O,(je=Z.context)==null?void 0:je.elements.floating)});if(Yc(O,i.floating)||Yc(O,i.domReference)||Pe)return;const se=P?Mo(P.nodesRef.current,ne):[];if(se.length>0){let Z=!0;if(se.forEach(je=>{var We;if((We=je.context)!=null&&We.open&&!je.context.dataRef.current.__outsidePressBubbles){Z=!1;return}}),!Z)return}o(!1,O,"outside-press")}),Y=Na(O=>{var H;const ee=()=>{var ce;_(O),(ce=sl(O))==null||ce.removeEventListener(g,ee)};(H=sl(O))==null||H.addEventListener(g,ee)});x.useEffect(()=>{if(!a||!d)return;u.current.__escapeKeyBubbles=N,u.current.__outsidePressBubbles=b;let O=-1;function H(K){o(!1,K,"ancestor-scroll")}function ee(){window.clearTimeout(O),L.current=!0}function ce(){O=window.setTimeout(()=>{L.current=!1},si()?5:0)}const C=pl(i.floating);p&&(C.addEventListener("keydown",I?Q:q,I),C.addEventListener("compositionstart",ee),C.addEventListener("compositionend",ce)),S&&C.addEventListener(g,$?Y:_,$);let F=[];return y&&(dt(i.domReference)&&(F=ls(i.domReference)),dt(i.floating)&&(F=F.concat(ls(i.floating))),!dt(i.reference)&&i.reference&&i.reference.contextElement&&(F=F.concat(ls(i.reference.contextElement)))),F=F.filter(K=>{var ae;return K!==((ae=C.defaultView)==null?void 0:ae.visualViewport)}),F.forEach(K=>{K.addEventListener("scroll",H,{passive:!0})}),()=>{p&&(C.removeEventListener("keydown",I?Q:q,I),C.removeEventListener("compositionstart",ee),C.removeEventListener("compositionend",ce)),S&&C.removeEventListener(g,$?Y:_,$),F.forEach(K=>{K.removeEventListener("scroll",H)}),window.clearTimeout(O)}},[u,i,p,S,g,a,o,y,d,N,b,q,I,Q,_,$,Y]),x.useEffect(()=>{u.current.insideReactTree=!1},[u,S,g]);const X=x.useMemo(()=>({onKeyDown:q,...w&&{[Ew[v]]:O=>{o(!1,O.nativeEvent,"reference-press")},...v!=="click"&&{onClick(O){o(!1,O.nativeEvent,"reference-press")}}}}),[q,o,w,v]),B=x.useMemo(()=>{function O(H){H.button===0&&(T.current=!0)}return{onKeyDown:q,onMouseDown:O,onMouseUp:O,[Pw[g]]:()=>{u.current.insideReactTree=!0}}},[q,g,u]);return x.useMemo(()=>d?{reference:X,floating:B}:{},[d,X,B])}function Aw(e){const{open:s=!1,onOpenChange:a,elements:o}=e,i=Gh(),u=x.useRef({}),[d]=x.useState(()=>kw()),p=Sw()!=null,[m,g]=x.useState(o.reference),w=Na((j,R,P)=>{u.current.openEvent=j?R:void 0,d.emit("openchange",{open:j,event:R,reason:P,nested:p}),a==null||a(j,R,P)}),v=x.useMemo(()=>({setPositionReference:g}),[]),y=x.useMemo(()=>({reference:m||o.reference||null,floating:o.floating||null,domReference:o.reference}),[m,o.reference,o.floating]);return x.useMemo(()=>({dataRef:u,open:s,onOpenChange:w,elements:y,events:d,floatingId:i,refs:v}),[s,w,y,d,i,v])}function e0(e){e===void 0&&(e={});const{nodeId:s}=e,a=Aw({...e,elements:{reference:null,floating:null,...e.elements}}),o=e.rootContext||a,i=o.elements,[u,d]=x.useState(null),[p,m]=x.useState(null),w=(i==null?void 0:i.domReference)||u,v=x.useRef(null),y=Yh();Ls(()=>{w&&(v.current=w)},[w]);const j=gw({...e,elements:{...i,...p&&{reference:p}}}),R=x.useCallback(N=>{const b=dt(N)?{getBoundingClientRect:()=>N.getBoundingClientRect(),getClientRects:()=>N.getClientRects(),contextElement:N}:N;m(b),j.refs.setReference(b)},[j.refs]),P=x.useCallback(N=>{(dt(N)||N===null)&&(v.current=N,d(N)),(dt(j.refs.reference.current)||j.refs.reference.current===null||N!==null&&!dt(N))&&j.refs.setReference(N)},[j.refs]),E=x.useMemo(()=>({...j.refs,setReference:P,setPositionReference:R,domReference:v}),[j.refs,P,R]),S=x.useMemo(()=>({...j.elements,domReference:w}),[j.elements,w]),T=x.useMemo(()=>({...j,...o,refs:E,elements:S,nodeId:s}),[j,E,S,s,o]);return Ls(()=>{o.dataRef.current.floatingContext=T;const N=y==null?void 0:y.nodesRef.current.find(b=>b.id===s);N&&(N.context=T)}),x.useMemo(()=>({...j,context:T,refs:E,elements:S}),[j,E,S,T])}function eu(e,s,a){const o=new Map,i=a==="item";let u=e;if(i&&e){const{[am]:d,[lm]:p,...m}=e;u=m}return{...a==="floating"&&{tabIndex:-1,[xw]:""},...u,...s.map(d=>{const p=d?d[a]:null;return typeof p=="function"?e?p(e):null:p}).concat(e).reduce((d,p)=>(p&&Object.entries(p).forEach(m=>{let[g,w]=m;if(!(i&&[am,lm].includes(g)))if(g.indexOf("on")===0){if(o.has(g)||o.set(g,[]),typeof w=="function"){var v;(v=o.get(g))==null||v.push(w),d[g]=function(){for(var y,j=arguments.length,R=new Array(j),P=0;P<j;P++)R[P]=arguments[P];return(y=o.get(g))==null?void 0:y.map(E=>E(...R)).find(E=>E!==void 0)}}}else d[g]=w}),d),{})}}function t0(e){e===void 0&&(e=[]);const s=e.map(p=>p==null?void 0:p.reference),a=e.map(p=>p==null?void 0:p.floating),o=e.map(p=>p==null?void 0:p.item),i=x.useCallback(p=>eu(p,e,"reference"),s),u=x.useCallback(p=>eu(p,e,"floating"),a),d=x.useCallback(p=>eu(p,e,"item"),o);return x.useMemo(()=>({getReferenceProps:i,getFloatingProps:u,getItemProps:d}),[i,u,d])}function $w({gid:e,uid:s,user:a,stats:o,x:i,y:u,onDismiss:d}){const{refs:p,floatingStyles:m,context:g,isPositioned:w}=e0({open:!0,onOpenChange:S=>{S||d()},strategy:"fixed",placement:"right-start",middleware:[Wh(8),Qh({fallbackPlacements:["left-start","bottom-start"]}),Vh({padding:8})],whileElementsMounted:(S,T,N)=>Kh(S,T,N,{animationFrame:!0})}),v=Zh(g,{outsidePress:S=>{var T,N;return!((N=(T=S.target)==null?void 0:T.closest)!=null&&N.call(T,"[data-stats-gid]"))}}),{getFloatingProps:y}=t0([v]),j=x.useRef(null);x.useEffect(()=>{j.current=null},[e]),x.useEffect(()=>{const S=()=>({x:i,y:u,top:u,left:i,right:i,bottom:u,width:0,height:0});p.setReference({getBoundingClientRect:()=>{const T=document.querySelector(`[data-stats-gid="${e}"]`);if(T){const N=T.getBoundingClientRect();return j.current=N,N}return j.current??S()}})},[p,e,i,u]);const R=ft(a,s),P=o.prsOpen+o.prsMerged+o.prsClosed,E=[{label:"Comments",value:o.comments},{label:"Reviews given",value:o.reviews},{label:"PRs open",value:o.prsOpen,dot:"#3b82f6"},{label:"PRs merged",value:o.prsMerged,dot:"#22c55e"},{label:"PRs closed",value:o.prsClosed,dot:"#9ca3af"}];return n.jsx(Jh,{children:n.jsxs("div",{ref:p.setFloating,style:{...m,visibility:w?"visible":"hidden"},...y(),"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:[n.jsx("div",{className:"mb-1 truncate text-sm font-semibold text-gray-800 dark:text-gray-100",title:R,children:R}),n.jsx("div",{className:"mb-2 text-[10px] uppercase tracking-wide text-gray-400",children:"In this window"}),n.jsx("table",{className:"w-full text-xs",children:n.jsxs("tbody",{children:[E.map(S=>n.jsxs("tr",{className:"border-t border-gray-100 first:border-0 dark:border-gray-800",children:[n.jsx("td",{className:"py-1 pr-2 text-gray-500 dark:text-gray-400",children:n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[S.dot&&n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:S.dot}}),S.label]})}),n.jsx("td",{className:"py-1 text-right font-medium tabular-nums text-gray-800 dark:text-gray-100",children:S.value})]},S.label)),n.jsxs("tr",{className:"border-t border-gray-200 dark:border-gray-700",children:[n.jsx("td",{className:"py-1 pr-2 text-gray-500 dark:text-gray-400",children:"PRs authored"}),n.jsx("td",{className:"py-1 text-right font-medium tabular-nums text-gray-800 dark:text-gray-100",children:P})]})]})})]})})}const bt={reviewComment:"#f59e0b",prComment:"#9ca3af",approved:"#22c55e",changes:"#f97316",commented:"#9ca3af",dismissed:"#9ca3af",commit:"#6b7280",lifecycle:"#3b82f6"};function Us(e){return`<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true">${e}</svg>`}const fm=e=>Us(`<circle cx="8" cy="8" r="5" fill="${e}"/>`),Mw=e=>Us(`<circle cx="8" cy="8" r="4.5" fill="none" stroke="${e}" stroke-width="2"/>`),Fw=e=>Us(`<circle cx="8" cy="8" r="4.5" fill="none" stroke="${e}" stroke-width="1.6" stroke-dasharray="2.2 2"/>`),Lw=e=>Us(`<rect x="3.5" y="3.5" width="9" height="9" rx="1.5" fill="${e}"/>`),_w=e=>Us(`<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"/>`),Ow=e=>Us(`<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"/>`),Dw=e=>Us(`<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 n0(e){switch(e.type){case"review_comment":return{svg:fm(bt.reviewComment),color:bt.reviewComment,label:"Review comment",round:!0};case"pr_comment":return{svg:Mw(bt.prComment),color:bt.prComment,label:"PR comment",round:!0};case"commit_pushed":return{svg:Lw(bt.commit),color:bt.commit,label:"Commit pushed"};case"review_submitted":switch(e.reviewState){case"approved":return{svg:_w(bt.approved),color:bt.approved,label:"Approved"};case"changes_requested":return{svg:Ow(bt.changes),color:bt.changes,label:"Changes requested"};case"dismissed":return{svg:Fw(bt.dismissed),color:bt.dismissed,label:"Review dismissed",round:!0};default:return{svg:Dw(bt.commented),color:bt.commented,label:"Review comment"}}default:return{svg:fm(bt.lifecycle),color:bt.lifecycle,label:"Event",round:!0}}}function Bw(e){const s=n0(e);return`<div class="ev-marker-inner${s.round?" ev-round":""}">${s.svg}</div>`}function tu(e){return`<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true">${e}</svg>`}const zw={commit:{color:bt.commit,glyph:tu('<rect x="3.5" y="3.5" width="9" height="9" rx="1.5" fill="#fff"/>'),label:"commits"},comment:{color:bt.reviewComment,glyph:tu('<circle cx="8" cy="8" r="5" fill="#fff"/>'),label:"comments"},review:{color:bt.approved,glyph:tu('<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 qw(e,s){const a=zw[s];return`<div class="ev-cluster-inner" style="background:${a.color}" title="${e} ${a.label}">${a.glyph}+${e}</div>`}function Uw(e,s){const a=lh[e.type],o=ft(e.actorId!=null?s.get(e.actorId):void 0,e.actorId);return`${a.label} · ${o} · ${St(e.occurredAt)}`}const pm=Number.MAX_SAFE_INTEGER,Kw="2000-01-01T00:00:00Z",Hw="2100-01-01T00:00:00Z";function Ww(e){if(!e||e.end<=e.start)return{start:Kw,end:Hw};const s=e.end-e.start;return{start:new Date(e.start-s*3).toISOString(),end:new Date(e.end+s*3).toISOString()}}const Vw=new Set(["review_comment","pr_comment","review_submitted","commit_pushed"]);function Qw(e){return Vw.has(e.type)}function Gw(e){return e.type==="commit_pushed"?"commit":e.type==="review_submitted"?"review":"comment"}const r0=9,Yw=3;function Xw(e){return(23+(1+String(e).length)*6.5)/2}function Jw(e,s,a,o,i,u,d=8,p){const m=Math.max(1,d*u),g=[],w=new Map,v=new Map,y=new Set,j=new Map;for(const P of e){if(!Qw(P))continue;const E=s(P),S=Gw(P),T=P.prId,N=T!=null?o.get(T):void 0,b=P.actorId!=null&&(N==null?void 0:N.authorId)!=null&&P.actorId===N.authorId,I=b?`${E}::${S}::own::${T}`:`${E}::${S}::cross::${T??"none"}`,$=j.get(I);if($){$.events.push(P);continue}b||y.add(E);const L=b?i.get(T)??0:0;j.set(I,{group:E,kind:S,ownWork:b,subgroup:b?`ev:${L}`:"cross",sortKey:b?L*2+1:pm,events:[P]})}for(const{group:P,kind:E,ownWork:S,subgroup:T,sortKey:N,events:b}of j.values()){const I=_=>`${_} ${S?"ev-own":"ev-cross"}`,$=[...b].sort((_,Y)=>Date.parse(_.occurredAt)-Date.parse(Y.occurredAt));let L=[],q=-1/0;const Q=()=>{if(L.length!==0){if(L.length===1){const _=L[0],Y=`ev:${_.id}`;g.push({id:Y,group:P,subgroup:T,sortKey:N,type:"point",start:_.occurredAt,content:Bw(_),className:`${I("ev-marker")} ev-key-${_.id}`,title:Uw(_,a),selectable:!1}),v.set(Y,r0)}else{const _=L.reduce((X,B)=>X+Date.parse(B.occurredAt),0)/L.length,Y=`cl:${P}:${E}:${L[0].id}`;w.set(Y,L.map(X=>X.id)),g.push({id:Y,group:P,subgroup:T,sortKey:N,type:"point",start:new Date(_).toISOString(),content:qw(L.length,E),className:`${I("ev-cluster")} ${L.map(X=>`ev-key-${X.id}`).join(" ")}`,title:`${L.length} ${E}s`,selectable:!1}),v.set(Y,Xw(L.length))}L=[]}};for(const _ of $){const Y=Date.parse(_.occurredAt);L.length>0&&Y-q>m&&Q(),L.push(_),q=Y}Q()}Zw(g,u,v);const R=Ww(p);for(const P of y)g.push({id:`xsep:${P}`,group:P,subgroup:"cross",sortKey:pm,type:"background",start:R.start,end:R.end,content:"",className:"cross-sep"});return{items:g,clusterMembers:w}}function Zw(e,s,a){if(s<=0)return;const o=new Map;for(const i of e){if(i.type!=="point")continue;const u=`${String(i.group)}\0${String(i.subgroup??"")}`,d=o.get(u);d?d.push(i):o.set(u,[i])}for(const i of o.values()){if(i.length<2)continue;i.sort((p,m)=>nu(p)-nu(m));let u=-1/0,d=0;for(const p of i){const m=a.get(String(p.id))??r0;let g=nu(p);const w=(d+m+Yw)*s;g-u<w&&(g=u+w,p.start=new Date(g).toISOString()),u=g,d=m}}}function nu(e){const s=e.start;return s instanceof Date?s.valueOf():typeof s=="number"?s:Date.parse(String(s))}function Ms(e){return e.authorId!=null?`repo:${e.repoId}:user:${e.authorId}`:`repo:${e.repoId}`}function ru(e){return Date.parse(e.openedAt)}function mm(e,s){const a=e.mergedAt??e.closedAt;return a?Date.parse(a):s}function e1(e,s=()=>0,a=Date.now()){const o=new Map;for(const u of e){const d=Ms(u),p=o.get(d);p?p.push(u):o.set(d,[u])}const i=new Map;for(const u of o.values()){const d=[...u].sort((g,w)=>ru(g)-ru(w)),p=[],m=[];for(const g of d){const w=ru(g),v=s(g);let y=p.findIndex((j,R)=>j<=w&&m[R]===v);y===-1?(y=p.length,p.push(mm(g,a)),m.push(v)):p[y]=mm(g,a),i.set(g.id,y)}}return i}function s0(e,s){const[a,o]=x.useState(()=>{try{const i=localStorage.getItem(e);return i!=null?JSON.parse(i):s}catch{return s}});return x.useEffect(()=>{try{localStorage.setItem(e,JSON.stringify(a))}catch{}},[e,a]),[a,o]}function t1(e){return e?e.replace(/\n$/,"").split(`
46
+ `).at(-1)??null:null}function n1({ev:e,pr:s,usersById:a,onOpen:o}){const i=s.authorId!=null?a.get(s.authorId):void 0,u=e.actorId!=null&&s.authorId!=null&&e.actorId!==s.authorId;return n.jsxs("div",{className:"flex items-baseline gap-1 text-[11px] text-gray-500",children:[n.jsx("span",{children:"on"}),u&&n.jsxs("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:[ft(i,s.authorId),"’s"]}),n.jsxs("button",{type:"button",onClick:o,className:"font-medium text-blue-500 hover:underline",children:["#",s.number]}),n.jsx("span",{className:"truncate text-gray-400",title:s.title,children:s.title})]})}function hm({ev:e,usersById:s,prsById:a,onNavigate:o}){var Q;const i=te(_=>_.selectThread),u=te(_=>_.selectPr),d=te(_=>_.showActivityEntry),p=te(_=>_.showPrComment),m=n0(e),g=e.actorId!=null?s.get(e.actorId):void 0,w=ft(g,e.actorId),v=e.type==="review_comment"&&e.threadId!=null,{data:y}=qu(v?e.threadId:null),j=Date.parse(e.occurredAt),R=(y==null?void 0:y.comments.find(_=>Date.parse(_.createdAt)===j&&_.authorId===e.actorId))??(y==null?void 0:y.comments[0]),P=y?t1((R==null?void 0:R.diffHunk)??((Q=y.comments[0])==null?void 0:Q.diffHunk)??null):null,E=e.type==="commit_pushed",S=e.type==="pr_comment",T=e.type==="review_submitted",{data:N}=Zo((E||S)&&e.prId!=null?e.prId:null),b=E&&N?N.commits.find(_=>_.id===e.refId):void 0,I=S&&N?N.comments.find(_=>_.id===e.refId):void 0,$=e.prId!=null?a.get(e.prId):void 0,L=()=>{e.threadId!=null?i(e.prId,e.threadId):S&&e.prId!=null&&e.refId!=null?p(e.prId,e.refId):T&&e.prId!=null&&e.refId!=null?d(e.prId,{type:e.type,refId:e.refId}):e.prId!=null&&u(e.prId),o()},q=()=>{e.prId!=null&&(d(e.prId,{type:e.type,refId:e.refId}),o())};return n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[n.jsx("span",{className:"inline-block h-3 w-3",dangerouslySetInnerHTML:{__html:m.svg}}),n.jsx("span",{className:"font-semibold",children:w}),n.jsxs("span",{className:"text-gray-500",children:["· ",m.label]}),n.jsx("span",{className:"ml-auto text-gray-400",children:St(e.occurredAt)})]}),$&&n.jsx(n1,{ev:e,pr:$,usersById:s,onOpen:L}),E&&n.jsx("div",{className:"text-[11px]",children:b?n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("code",{className:"rounded bg-gray-100 px-1 font-mono text-gray-600 dark:bg-gray-800 dark:text-gray-300",children:b.sha.slice(0,7)}),b.message&&n.jsx("span",{className:"truncate text-gray-600 dark:text-gray-300",children:b.message.split(`
47
+ `)[0]})]}):n.jsx("span",{className:"text-gray-400",children:"loading commit…"})}),y&&n.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[n.jsxs("code",{className:"truncate font-mono text-gray-600 dark:text-gray-300",children:[y.path,y.line!=null?`:${y.line}`:""]}),n.jsx("span",{className:"ml-auto shrink-0",children:n.jsx(vh,{state:y.derivedState})})]}),P&&n.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:P}),R&&n.jsxs("div",{className:"text-xs",children:[n.jsx(cr,{children:R.body}),y&&y.comments.length>1&&n.jsxs("div",{className:"mt-1 text-[11px] text-gray-400",children:["+",y.comments.length-1," more in thread"]})]}),S&&n.jsx("div",{className:"text-xs",children:I?n.jsx(cr,{children:I.body}):n.jsx("span",{className:"text-gray-400",children:"loading comment…"})}),n.jsxs("div",{className:"flex items-center gap-3 pt-0.5 text-[11px]",children:[!E&&n.jsx("button",{type:"button",onClick:L,className:"text-blue-500 hover:underline",children:"Open in detail pane"}),E&&e.prId!=null&&n.jsx("button",{type:"button",onClick:q,className:"text-blue-500 hover:underline",title:"Show this commit in the PR's Activity tab",children:"View in Activity"}),E&&b&&N&&n.jsx("a",{href:`${N.githubUrl}/commits/${b.sha}`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"Open commit on GitHub ↗"}),S&&I&&N&&n.jsx("a",{href:I.url??N.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"Open on GitHub ↗"})]})]})}function r1({state:e,eventsById:s,usersById:a,prsById:o,focusPrId:i,onContextFocus:u,onDismiss:d,onNavigate:p}){var _;const[m,g]=s0("pierre:popoverSize",null),{refs:w,floatingStyles:v,context:y,isPositioned:j}=e0({open:!0,onOpenChange:Y=>{Y||d()},strategy:"fixed",placement:"right-start",middleware:[Wh(24),Qh({fallbackPlacements:["left-start","bottom"]}),Vh({padding:8})],whileElementsMounted:(Y,X,B)=>Kh(Y,X,B,{animationFrame:!0})}),R=Zh(y,{outsidePress:!1}),{getFloatingProps:P}=t0([R]),E=e.eventIds[0]??null,S=x.useRef(null);x.useEffect(()=>{S.current=null},[E]),x.useEffect(()=>{const Y=()=>({x:e.x,y:e.y,top:e.y,left:e.x,right:e.x,bottom:e.y,width:0,height:0});w.setReference({getBoundingClientRect:()=>{if(E!=null){const X=document.querySelector(`.ev-key-${E}`),B=(X==null?void 0:X.querySelector(".ev-marker-inner, .ev-cluster-inner"))??X;if(B){const O=B.getBoundingClientRect();return S.current=O,O}}return S.current??Y()}})},[w,E,e.x,e.y]);const T=e.eventIds.map(Y=>s.get(Y)).filter(Y=>Y!=null).filter(Y=>i==null||Y.prId===i),N=((_=T[0])==null?void 0:_.prId)??null;x.useEffect(()=>{u({groupIds:null,prId:N,eventId:null})},[N,u]);const b=Y=>{const X=Y.currentTarget;g({width:X.offsetWidth,height:X.offsetHeight})},[I,$]=x.useState({x:0,y:0}),L=x.useRef(null);x.useEffect(()=>{const Y=B=>{const O=L.current;O&&$({x:O.ox+(B.clientX-O.sx),y:O.oy+(B.clientY-O.sy)})},X=()=>{L.current=null};return window.addEventListener("pointermove",Y),window.addEventListener("pointerup",X),()=>{window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",X)}},[]);const q=Y=>{Y.button===0&&(Y.preventDefault(),L.current={sx:Y.clientX,sy:Y.clientY,ox:I.x,oy:I.y})},Q=`${v.transform??""} translate(${I.x}px, ${I.y}px)`.trim();return n.jsx(Jh,{children:n.jsxs("div",{ref:w.setFloating,style:{...v,transform:Q,visibility:j?"visible":"hidden",width:(m==null?void 0:m.width)??420,height:(m==null?void 0:m.height)??340,minWidth:240,minHeight:120,maxWidth:"92vw",maxHeight:"80vh",resize:"both",overflow:"hidden"},...P(),onPointerUp:b,"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:[n.jsxs("div",{className:"tl-modal-header",onPointerDown:q,children:[n.jsx("svg",{className:"tl-grip",width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:n.jsxs("g",{fill:"currentColor",children:[n.jsx("circle",{cx:"2",cy:"2",r:"1"}),n.jsx("circle",{cx:"8",cy:"2",r:"1"}),n.jsx("circle",{cx:"2",cy:"5",r:"1"}),n.jsx("circle",{cx:"8",cy:"5",r:"1"}),n.jsx("circle",{cx:"2",cy:"8",r:"1"}),n.jsx("circle",{cx:"8",cy:"8",r:"1"})]})}),n.jsx("span",{className:"tl-modal-title",children:T.length>1?`${T.length} events`:"Activity"}),n.jsx("button",{type:"button",className:"tl-modal-close",onPointerDown:Y=>Y.stopPropagation(),onClick:d,"aria-label":"Close",title:"Close",children:"✕"})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-2",children:T.length===1?n.jsx(hm,{ev:T[0],usersById:a,prsById:o,onNavigate:p}):n.jsx("div",{className:"divide-y divide-gray-200 dark:divide-gray-800",children:T.map(Y=>n.jsx("div",{className:"py-2 first:pt-0 last:pb-0",children:n.jsx(hm,{ev:Y,usersById:a,prsById:o,onNavigate:p})},Y.id))})})]})})}const s1=1e3*60*60,a1={stack:!1,stackSubgroups:!0,groupHeightMode:"fixed",orientation:{axis:"top",item:"top"},zoomMin:s1,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}},l1=12,o1=2;function gm(e){return[...new Set(e)]}function xm(e,s){var i,u;if(!e)return 0;const a=e.body,o=s==null?void 0:s.querySelector(".vis-panel.vis-center");return((u=(i=a==null?void 0:a.domProps)==null?void 0:i.center)==null?void 0:u.width)||(o==null?void 0:o.clientWidth)||(s==null?void 0:s.clientWidth)||0}function ol(e){return Date.parse(String(e.start))}function i1(e){return e.end!=null?Date.parse(String(e.end)):ol(e)}function c1(e,s){if(s<=0)return;const a=l1*s,o=new Map;for(const i of e){const u=`${String(i.group)}|${String(i.subgroup??"")}`,d=o.get(u);d?d.push(i):o.set(u,[i])}for(const i of o.values())if(i.length!==0){i.sort((u,d)=>ol(u)-ol(d));for(let u=0;u<i.length;u++){const d=i[u],p=ol(d),m=i1(d),g=u+1<i.length?ol(i[u+1]):Number.POSITIVE_INFINITY,w=Math.min(Math.max(m,p+a),g);w!==m&&(d.end=new Date(w).toISOString())}}}function ym(e,s){const a=s.getTime()-e.getTime(),o=Math.max(a*.06,14400*1e3),i=Math.max(a*.03,7200*1e3);return{start:new Date(e.getTime()-i),end:new Date(s.getTime()+o)}}function u1(e){const s=document.createElement("div");return s.innerHTML=e,s.firstElementChild??s}function d1(){const e=typeof navigator<"u"?navigator.platform||navigator.userAgent:"";return/Mac|iP(hone|ad|od)/.test(e)?"metaKey":"ctrlKey"}function f1(e){return e.actorId!=null?`repo:${e.repoId}:user:${e.actorId}`:`repo:${e.repoId}`}const p1=/^repo:\d+:user:\d+$/;function wa(e){return`tlg-${e.replace(/:/g,"-")}`}function m1(e){return new Date(e.mergedAt??e.closedAt??new Date().toISOString()).getTime()}function vm({mode:e}={}){const s=(e==null?void 0:e.kind)==="isolate"?e.prId:null,a=x.useRef(null),o=x.useRef(null),i=x.useRef(new hp),u=x.useRef(new hp),d=x.useRef(new Map),p=x.useRef(new Map),m=x.useRef(new Map),g=x.useRef([]),w=x.useRef(null),v=x.useRef(new Map),y=x.useRef(new Map),j=x.useRef(new Map),R=x.useRef({active:!1,states:[]}),P=x.useRef([]),E=x.useRef(null),S=x.useRef(null),T=x.useRef(new Set),N=x.useRef(new Set),b=x.useRef(!1);if(!b.current){b.current=!0;try{const A=localStorage.getItem("pierre:collapsedRows");if(A){const W=JSON.parse(A);Array.isArray(W)&&(N.current=new Set(W.map(String)))}}catch{}}const I=x.useRef(new Map),$=x.useRef(null),L=x.useRef(null),q=x.useRef(null),Q=x.useRef(null),_=x.useRef(null),Y=x.useRef(null),X=x.useRef(null),B=x.useRef(null),O=x.useRef(null),H=x.useRef(0),ee=x.useRef(!1),ce=x.useRef(null),C=x.useRef(null),F=x.useRef(null),K=x.useRef(null),ae=x.useRef(null),ne=x.useRef(null),Pe=x.useRef(null),[se,Z]=x.useState(null),je=x.useRef(null);je.current=se;const[We,st]=x.useState(null),Pt=x.useRef(new Map),[Lt,vn]=x.useState(!1),{data:Le,isLoading:Mn,error:Fn}=nh(s!=null?{prIds:[s]}:void 0),{data:_t}=rh(),{data:Ln}=Fu(),{data:Kt}=Lu(),{data:pr}=Mr(),{data:Fr}=$n(),{data:Xn}=Mu(),_n=Be(),bn=te(A=>A.derivedStates),re=te(A=>A.categories),He=te(A=>A.userIds),it=te(A=>A.selectPr),at=te(A=>A.selectedPrId),On=x.useRef(at),[wn,on]=x.useState(0),[os,mr]=x.useState(0),fi=te(A=>A.preset),bl=te(A=>A.customFrom),wl=te(A=>A.customTo),pi=te(A=>A.rangeResetSignal),Jn=x.useMemo(()=>{const A=new Map;for(const W of pr??[])A.set(W.id,W);return A},[pr]),Ks=x.useRef(Jn);Ks.current=Jn;const Hs=x.useMemo(()=>{const A=new Map;for(const W of Xn??[])A.set(W.repoId,new Set(W.userIds));return A},[Xn]),cn=x.useMemo(()=>ln(Fr),[Fr]);v.current=cn;const is=x.useRef(!1);x.useEffect(()=>{if(!Le)return;let A=!1;for(const W of Le.events)if(W.actorId!=null&&!cn.has(W.actorId)){A=!0;break}if(!A){for(const W of Le.prs)if(W.authorId!=null&&!cn.has(W.authorId)){A=!0;break}}if(!A){is.current=!1;return}is.current||(is.current=!0,_n.invalidateQueries({queryKey:["users"]}))},[Le,cn,_n]);const hr=x.useMemo(()=>{const A=new Map;for(const W of(Le==null?void 0:Le.prs)??[])A.set(W.id,W);return A},[Le]);y.current=hr;const Dn=x.useCallback(A=>{const W=i.current,J=E.current;if(J!=null&&J!==A){const oe=W.get(`pr:${J}`);oe&&typeof oe.className=="string"&&W.update({id:`pr:${J}`,className:oe.className.replace(/\s*pr-cross-linked/g,"")})}if(A!=null){const oe=W.get(`pr:${A}`);oe&&typeof oe.className=="string"&&!oe.className.includes("pr-cross-linked")&&W.update({id:`pr:${A}`,className:`${oe.className} pr-cross-linked`})}E.current=A},[]),Yt=x.useCallback(A=>{const W=i.current,J=L.current;if(J!=null){const le=W.get(J);le&&typeof le.className=="string"&&le.className.includes("ev-cross-linked")&&W.update({id:J,className:le.className.replace(/\s*ev-cross-linked/g,"")}),L.current=null}if($.current=A,A==null)return;const oe=W.get(`ev:${A}`)?`ev:${A}`:m.current.get(A)??null;if(oe==null)return;const de=W.get(oe);de&&typeof de.className=="string"&&!de.className.includes("ev-cross-linked")&&(W.update({id:oe,className:`${de.className} ev-cross-linked`}),L.current=oe)},[]),gr=x.useCallback(A=>{const W=i.current;for(const de of W.getIds()){const le=W.get(de);le&&typeof le.className=="string"&&le.className.includes("ev-exit-glow")&&W.update({id:de,className:le.className.replace(/\s*ev-exit-glow/g,"")})}if(Q.current=null,q.current=A,A==null)return;const J=W.get(`ev:${A}`)?`ev:${A}`:m.current.get(A)??null;if(J==null)return;const oe=W.get(J);oe&&typeof oe.className=="string"&&!oe.className.includes("ev-exit-glow")&&(W.update({id:J,className:`${oe.className} ev-exit-glow`}),Q.current=J)},[]),cs=x.useCallback(A=>{const W=i.current;for(const de of W.getIds()){const le=W.get(de);le&&typeof le.className=="string"&&le.className.includes("ev-selected")&&W.update({id:de,className:le.className.replace(/\s*ev-selected/g,"")})}if(Pe.current=null,ne.current=A,A==null)return;const J=W.get(`ev:${A}`)?`ev:${A}`:m.current.get(A)??null;if(J==null)return;const oe=W.get(J);oe&&typeof oe.className=="string"&&!oe.className.includes("ev-selected")&&(W.update({id:J,className:`${oe.className} ev-selected`}),Pe.current=J)},[]),xr=x.useCallback(()=>{const A=i.current,W=T.current,J=[],oe=[],de=S.current!=null;for(const le of g.current){const ve=String(le.id),me=W.has(String(le.group))||!de&&N.current.has(String(le.group)),he=A.get(ve)!=null;me&&he?J.push(ve):!me&&!he&&oe.push(le)}J.length&&A.remove(J),oe.length&&A.add(oe)},[]),Ta=x.useCallback(()=>{try{localStorage.setItem("pierre:collapsedRows",JSON.stringify([...N.current]))}catch{}},[]),Zn=x.useCallback((A,W)=>{var he,Ie;const J=u.current;if(!J.get(A))return;const oe=i.current.get(),de=new Set;for(const ye of oe)ye.group===A&&typeof ye.subgroup=="string"&&de.add(ye.subgroup);const le={};for(const ye of de)le[ye]=!W;const ve=J.get(A);ve&&(J.remove(A),J.add({...ve,subgroupVisibility:le,heightMode:W?"auto":"fixed"})),W?N.current.add(A):N.current.delete(A),Ta(),xr();const me=o.current;(Ie=(he=me==null?void 0:me.itemSet)==null?void 0:he.markDirty)==null||Ie.call(he,{restackGroups:!0}),me==null||me.redraw()},[Ta,xr]),us=x.useCallback(A=>{const W=u.current.getIds().map(String).filter(de=>p1.test(de)),J=A&&A.length?new Set(A):null,oe=[];for(const de of W){const le=J!=null&&!J.has(de);le?T.current.add(de):T.current.delete(de),oe.push({id:de,visible:!le})}oe.length&&u.current.update(oe),S.current=J?A:null,xr()},[xr]),Ot=x.useCallback(()=>{const A=o.current,W=a.current,J=w.current;if(!A||!W||!J)return;const oe=A.getWindow(),de=oe.end.valueOf()-oe.start.valueOf();B.current=de;const le=W.clientWidth||1e3,ve=de/le;let me;if(ee.current&&ce.current!=null)me=J.events.filter(we=>we.prId===ce.current);else if(me=J.events,R.current.active){const{states:we}=R.current;me=me.filter(Ae=>Ae.type==="review_comment"&&Ae.prId!=null&&Ae.derivedState!=null&&we.includes(Ae.derivedState))}const he=new Set(Zm(P.current));me=me.filter(we=>he.has(we.type));const{items:Ie,clusterMembers:ye}=Jw(me,f1,v.current,y.current,j.current,ve,8,{start:oe.start.valueOf(),end:oe.end.valueOf()});p.current=ye;const Re=new Map;for(const[we,Ae]of ye)for(const Ge of Ae)Re.set(Ge,we);m.current=Re;const ze=i.current.getIds().filter(we=>{const Ae=String(we);return Ae.startsWith("ev:")||Ae.startsWith("cl:")||Ae.startsWith("xsep:")});if(i.current.remove(ze),i.current.add(Ie),g.current=Ie.filter(we=>String(we.id).startsWith("xsep:")),xr(),$.current!=null){const we=$.current;L.current=null,$.current=null,Yt(we)}if(q.current!=null){const we=q.current;Q.current=null,q.current=null,gr(we)}if(ne.current!=null){const we=ne.current;Pe.current=null,ne.current=null,cs(we)}},[Yt,gr,cs,xr]),Ws=x.useCallback(()=>{const A=C.current;if(!A)return;const W=()=>{A.childElementCount&&A.replaceChildren(),A.style.display="none"},J=a.current,oe=ce.current;if(!ee.current||oe==null||!J){W();return}const de=J.querySelector(".vis-panel.vis-center"),le=y.current.get(oe);if(!de||!le){W();return}const ve=wa(Ms(le)),me=J.querySelector(`.vis-foreground .vis-group.${ve} .vis-item.pr-bar.vis-selected`)??J.querySelector(`.vis-foreground .vis-group.${ve} .vis-item.pr-bar:not(.pr-focus-hidden)`);if(!me||me.offsetHeight===0){W();return}const Ie=(A.parentElement??J).getBoundingClientRect(),ye=de.getBoundingClientRect();A.style.display="block",A.style.left=`${ye.left-Ie.left}px`,A.style.top=`${ye.top-Ie.top}px`,A.style.width=`${ye.width}px`,A.style.height=`${ye.height}px`;const Re=me.getBoundingClientRect(),ze=Re.top-ye.top,we=Re.bottom-ye.top,Ae=Re.left-ye.left,Ge=Re.right-ye.left,tt="http://www.w3.org/2000/svg",Ct=document.createDocumentFragment(),$e=J.querySelectorAll(".vis-foreground .vis-item.ev-cross");for(const $t of $e){if($t.offsetHeight===0)continue;const gt=($t.querySelector(".ev-marker-inner, .ev-cluster-inner")??$t).getBoundingClientRect(),zn=gt.left+gt.width/2-ye.left,ps=gt.top-ye.top,ms=gt.bottom-ye.top,Dr=Math.max(Ae,Math.min(zn,Ge));let nr,Ht;if(ps>=we)nr=ps,Ht=we;else if(ms<=ze)nr=ms,Ht=ze;else continue;const Dt=document.createElementNS(tt,"path");Dt.setAttribute("d",`M ${zn.toFixed(1)} ${nr.toFixed(1)} L ${Dr.toFixed(1)} ${Ht.toFixed(1)}`),Ct.appendChild(Dt)}A.replaceChildren(Ct)},[]),er=x.useCallback(()=>{var J;const A=ee.current&&ce.current!=null,W=(((J=C.current)==null?void 0:J.childElementCount)??0)>0;!A&&!W||F.current==null&&(F.current=requestAnimationFrame(()=>{F.current=null,Ws()}))},[Ws]),kl=x.useCallback((A,W)=>{const J=u.current;for(const[he,Ie]of I.current){if(!J.get(he))continue;const ye={};for(const Re of Ie)ye[Re]=!0;J.update({id:he,subgroupVisibility:ye})}if(I.current.clear(),!A||A.length===0||W==null)return;const oe=j.current.get(W),de=y.current.get(W),le=i.current.get(`pr:${W}`),ve=de?Ms(de):le&&typeof le.group=="string"?le.group:null,me=i.current.get();for(const he of A){const Ie=new Set(["cross"]);he===ve&&oe!=null&&(Ie.add(`bar:${oe}`),Ie.add(`ev:${oe}`));const ye=new Set;for(const we of me)we.group===he&&typeof we.subgroup=="string"&&ye.add(we.subgroup);const Re=[...ye].filter(we=>!Ie.has(we)),ze={};for(const we of Re)ze[we]=!1;for(const we of ye)Ie.has(we)&&(ze[we]=!0);Object.keys(ze).length!==0&&(J.update({id:he,subgroupVisibility:ze}),Re.length&&I.current.set(he,Re))}},[]),kn=x.useCallback(A=>{const W=i.current,J=[];for(const oe of W.getIds()){const de=String(oe);if(!de.startsWith("pr:"))continue;const le=W.get(oe);if(!le||typeof le.className!="string")continue;const ve=Number.parseInt(de.slice(3),10),me=le.className.includes("pr-focus-hidden"),he=A!=null&&ve!==A;he&&!me?J.push({id:oe,className:`${le.className} pr-focus-hidden`}):!he&&me&&J.push({id:oe,className:le.className.replace(/\s*pr-focus-hidden/g,"")})}J.length&&W.update(J)},[]),un=x.useCallback(A=>{gr(null);const W=ee.current;kl((A==null?void 0:A.groupIds)??null,(A==null?void 0:A.prId)??null),us((A==null?void 0:A.groupIds)??null),Dn((A==null?void 0:A.prId)??null),Yt((A==null?void 0:A.eventId)??null);const J=!!(A!=null&&A.groupIds&&A.groupIds.length>0);if(vn(J),J||(ee.current=!1,ce.current=null),J&&(A==null?void 0:A.prId)!=null){const oe=te.getState();oe.selectedPrId!==A.prId&&oe.selectPr(A.prId)}if(!J&&W&&(kn(null),Ot()),!J&&N.current.size>0)for(const oe of N.current)Zn(oe,!0)},[kl,us,Dn,Yt,gr,kn,Ot,Zn]),Vs=x.useCallback(A=>{ee.current||un(A)},[un]),At=x.useCallback(()=>{const A=a.current;return A?A.querySelector(".vis-panel.vis-left.vis-vertical-scroll")??A.querySelector(".vis-panel.vis-right.vis-vertical-scroll"):null},[]),jl=x.useCallback(()=>{const A=K.current,W=a.current;if(!A||!W)return;const J=()=>{A.style.display!=="none"&&(A.style.display="none")},oe=At();if(!oe){J();return}const le=(A.parentElement??W).getBoundingClientRect(),ve=oe.getBoundingClientRect(),me=ve.top,he=1;let Ie=null;for(const Ae of W.querySelectorAll(".vis-labelset .vis-label.tl-repo-header")){const Ge=Ae.getBoundingClientRect();Ge.height<1||Ge.top<=me+he&&(Ie=Ae)}if(!Ie){J();return}if(Ie.getBoundingClientRect().top>=me-he){J();return}const ze=((Ie.querySelector(".vis-inner")??Ie).textContent??"").trim();if(!ze){J();return}const we=[...Ie.classList].find(Ae=>Ae.startsWith("tl-repo-tint-"))??"";A.dataset.repo!==ze&&(A.textContent=ze,A.dataset.repo=ze),A.dataset.tint!==we&&(A.className=`tl-repo-sticky${we?` ${we}`:""}`,A.dataset.tint=we),A.style.left=`${ve.left-le.left}px`,A.style.top=`${ve.top-le.top}px`,A.style.width=`${ve.width}px`,A.style.display!=="block"&&(A.style.display="block")},[At]),yr=x.useCallback(()=>{ae.current==null&&(ae.current=requestAnimationFrame(()=>{ae.current=null,jl()}))},[jl]),Qs=x.useCallback(()=>{const A=At(),W=a.current;if(!A||!W)return null;const J=A.getBoundingClientRect().top;let oe=null,de=0,le=1/0;for(const ve of W.querySelectorAll(".vis-labelset .vis-label")){const me=ve.getBoundingClientRect();if(me.height<4||me.bottom<=J+1)continue;const he=[...ve.classList].find(ye=>ye.startsWith("tlg-"));if(!he)continue;const Ie=Math.abs(me.top-J);Ie<le&&(le=Ie,oe=he,de=me.top-J)}return{token:oe,offset:de,scrollTop:A.scrollTop}},[At]),tr=x.useCallback((A,W)=>{const J=o.current,oe=w.current;if(!J||!oe)return;const de=(W==null?void 0:W.pr)??y.current.get(A);if(!de)return;Z(null);const le=de.repoId,ve=new Set;de.authorId!=null&&ve.add(de.authorId);let me=1/0,he=-1/0;const Ie=Re=>{Re<me&&(me=Re),Re>he&&(he=Re)};Ie(new Date(de.openedAt).getTime()),Ie(m1(de));for(const Re of oe.events)Re.prId===A&&(Re.actorId!=null&&ve.add(Re.actorId),Ie(new Date(Re.occurredAt).getTime()));const ye=[...ve].map(Re=>`repo:${le}:user:${Re}`);if((W==null?void 0:W.fitWindow)!==!1&&Number.isFinite(me)&&Number.isFinite(he)){const Re=Math.max((he-me)*.08,432e5);J.setWindow(me-Re,he+Re,{animation:!0})}ee.current=!0,ce.current=A,un({groupIds:ye.length?ye:null,prId:A,eventId:(W==null?void 0:W.anchorEventId)??null}),Ot(),kn(A),J.setSelection([`pr:${A}`]),(W==null?void 0:W.anchorEventId)!=null&&Yt(W.anchorEventId)},[un,Ot,kn,Yt]),vr=x.useCallback(A=>{const W=At();if(!W||o.current==null||!W.isConnected)return;const J=Math.max(0,W.scrollHeight-W.clientHeight);W.scrollTop=Math.max(0,Math.min(J,A)),W.dispatchEvent(new Event("scroll"))},[At]),Bn=x.useRef(!1),Gs=x.useRef(0),br=x.useCallback((A,W,J=".ev-cross-linked",oe=".pr-cross-linked")=>{const de=a.current,le=At(),ve=de==null?void 0:de.querySelector(".vis-panel.vis-center");if(!de||!le||!ve)return;const me=`.vis-labelset .vis-label.${A}`;let he;const Ie=tt=>{const Ct=ve.getBoundingClientRect(),$e=tt.getBoundingClientRect();return $e.top+$e.height/2-Ct.top-Ct.height/2},ye=()=>{const tt=$t=>[...de.querySelectorAll($t)].filter(pt=>pt.offsetHeight>0).sort((pt,gt)=>gt.offsetHeight-pt.offsetHeight)[0];if(W){const $t=tt(J);if($t)return{delta:Ie($t),settleable:!0};const pt=de.querySelector(`.vis-foreground .vis-group.${A}`);if(pt){const gt=ve.getBoundingClientRect();return{delta:pt.getBoundingClientRect().bottom-12-(gt.top+gt.height/2),settleable:!1}}return null}if(he&&he.isConnected&&he.offsetHeight>0)return{delta:Ie(he),settleable:!0};const Ct=tt(oe);if(Ct)return he=Ct,{delta:Ie(Ct),settleable:!0};const $e=de.querySelector(me);return $e?{delta:Ie($e),settleable:!0}:null},Re=de.querySelector(me);Re&&vr(Re.offsetTop-8);let ze=0,we=0;const Ae=++Gs.current;Bn.current=!0,window.setTimeout(()=>{Gs.current===Ae&&(Bn.current=!1)},2500);const Ge=()=>{if(Gs.current!==Ae)return;const tt=ye();tt!=null&&(Math.abs(tt.delta)>6?(vr(le.scrollTop+tt.delta),we=0):tt.settleable?we+=1:we=0),we<6&&ze++<90?requestAnimationFrame(Ge):Bn.current=!1};requestAnimationFrame(()=>requestAnimationFrame(Ge))},[At,vr]),Lr=x.useCallback(A=>{const W=a.current,J=()=>{var me;const ve=At();if(!ve||!W)return!0;if(A.token){const he=W.querySelector(`.vis-labelset .vis-label.${A.token}`);if(he&&he.offsetHeight>0){const ye=he.getBoundingClientRect().top-ve.getBoundingClientRect().top-A.offset;return Math.abs(ye)>1?(vr(ve.scrollTop+ye),!1):!0}}return vr(A.scrollTop),Math.abs((((me=At())==null?void 0:me.scrollTop)??A.scrollTop)-A.scrollTop)<=2};J();let oe=0,de=0;const le=()=>{J()?de+=1:de=0,de<3&&oe++<30&&requestAnimationFrame(le)};requestAnimationFrame(le)},[At,vr]),_r=x.useCallback((A,W,J)=>{J.length!==0&&(S.current||un(null),st(null),Z({x:A,y:W,eventIds:J}))},[un]),Or=x.useCallback(()=>{Z(null),S.current||un(null)},[un]),Ys=x.useCallback(()=>{je.current?Or():S.current||(On.current!=null?te.getState().clearSelection():q.current!=null&&gr(null))},[Or,gr]),mi=x.useCallback(()=>{Z(null)},[]);x.useEffect(()=>{cs(se&&!Lt?se.eventIds[0]??null:null)},[se,Lt,cs]);const Je=(se==null?void 0:se.eventIds[0])??null;x.useEffect(()=>{if(Je==null)return;const A=d.current.get(Je);(A==null?void 0:A.prId)!=null&&te.getState().selectPr(A.prId)},[Je]);const Ea=x.useCallback(A=>{const W=Ks.current.get(A.repoId),J=A.authorId!=null?v.current.get(A.authorId):void 0;return{id:A.id,number:A.number,title:A.title,repoFullName:(W==null?void 0:W.fullName)??`repo ${A.repoId}`,authorLogin:(J==null?void 0:J.githubLogin)??null,authorDisplayName:(J==null?void 0:J.displayName)??null,authorAvatarUrl:(J==null?void 0:J.avatarUrl)??null}},[]);x.useEffect(()=>{if(!a.current)return;const{from:A,to:W}=$o(te.getState()),{start:J,end:oe}=ym(A,W),de=new ox(a.current,i.current,u.current,{...a1,start:J,end:oe,zoomKey:d1()});de.on("click",he=>{var Ge,tt,Ct;const Ie=he.item,ye=((Ge=he.event)==null?void 0:Ge.srcEvent)??he.event,Re=(ye==null?void 0:ye.clientX)??he.pageX??0,ze=(ye==null?void 0:ye.clientY)??he.pageY??0,we=(ye==null?void 0:ye.target)??null;if((tt=we==null?void 0:we.closest)!=null&&tt.call(we,"[data-collapse-gid]")||(Ct=we==null?void 0:we.closest)!=null&&Ct.call(we,"[data-stats-gid]"))return;if(Ie==null){if(((ye==null?void 0:ye.detail)??0)>=2)return;Ys();return}const Ae=String(Ie);if(Ae.startsWith("pr:"))je.current&&!ee.current&&!S.current&&Or(),it(Number.parseInt(Ae.slice(3),10));else if(Ae.startsWith("ev:")){const $e=Number.parseInt(Ae.slice(3),10);if(ee.current){Yt($e),_r(Re,ze,[$e]);return}_r(Re,ze,[$e])}else if(Ae.startsWith("cl:")){const $e=p.current.get(Ae)??[];if($e.length===0)return;const $t=$e[0];if(ee.current){Yt($t),_r(Re,ze,$e);return}_r(Re,ze,$e)}}),de.on("doubleClick",he=>{const Ie=he.item;if(Ie==null||ee.current)return;const ye=String(Ie);if(ye.startsWith("pr:")){const Re=Number.parseInt(ye.slice(3),10),ze=y.current.get(Re);ze&&De.getState().openPrFocusTab(Ea(ze));return}if(ye.startsWith("ev:")||ye.startsWith("cl:")){const ze=(ye.startsWith("ev:")?[Number.parseInt(ye.slice(3),10)]:p.current.get(ye)??[])[0]??null;if(ze==null)return;const we=d.current.get(ze);if((we==null?void 0:we.prId)==null)return;const Ae=y.current.get(we.prId);Ae&&De.getState().openPrFocusTab(Ea(Ae))}});let le=null,ve=null;de.on("rangechanged",()=>{const he=de.getWindow(),Ie=he.end.valueOf()-he.start.valueOf(),ye=B.current;if(ye==null||Math.abs(Ie-ye)/ye>.02){le&&clearTimeout(le);const Ge=()=>{if(Bn.current){le=setTimeout(Ge,120);return}le=null;const tt=Qs();Ot(),de.redraw(),tt&&Lr(tt)};le=setTimeout(Ge,120)}const ze=X.current;if(ze==null||ee.current||S.current)return;const we=de.getWindow(),Ae=we.end.valueOf()-we.start.valueOf();Math.abs(Ae-ze)/ze<=.02||(ve&&clearTimeout(ve),ve=setTimeout(()=>mr(Ge=>Ge+1),160))}),de.on("changed",er);const me=At();return me==null||me.addEventListener("scroll",er,{passive:!0}),de.on("changed",yr),me==null||me.addEventListener("scroll",yr,{passive:!0}),window.addEventListener("resize",yr,{passive:!0}),yr(),o.current=de,()=>{Gs.current+=1,Bn.current=!1,le&&clearTimeout(le),ve&&clearTimeout(ve),me==null||me.removeEventListener("scroll",er),me==null||me.removeEventListener("scroll",yr),window.removeEventListener("resize",yr),F.current!=null&&(cancelAnimationFrame(F.current),F.current=null),ae.current!=null&&(cancelAnimationFrame(ae.current),ae.current=null),de.destroy(),o.current=null}},[it,Ot,_r,Ys,Or,Yt,Ea,Qs,Lr,er,yr,At]),x.useEffect(()=>{const A=a.current;if(!A)return;const W=J=>{var he;const oe=J.target,de=(he=oe==null?void 0:oe.closest)==null?void 0:he.call(oe,"[data-collapse-gid]");if(!de)return;const le=de.getAttribute("data-collapse-gid");if(!le||(J.stopPropagation(),J.preventDefault(),ee.current||S.current))return;const ve=!N.current.has(le);Zn(le,ve),de.textContent=ve?"▸":"▾";const me=ve?"Expand row":"Collapse row";de.setAttribute("title",me),de.setAttribute("aria-label",me)};return A.addEventListener("click",W,!0),()=>A.removeEventListener("click",W,!0)},[Zn]),x.useEffect(()=>{const A=a.current;if(!A)return;const W=J=>{var me;const oe=J.target,de=(me=oe==null?void 0:oe.closest)==null?void 0:me.call(oe,"[data-stats-gid]");if(!de)return;const le=de.getAttribute("data-stats-gid");if(!le)return;J.stopPropagation(),J.preventDefault();const ve=Number(le.split(":user:")[1]);Number.isFinite(ve)&&(Z(null),st(he=>he&&he.gid===le?null:{gid:le,uid:ve,x:J.clientX,y:J.clientY}))};return A.addEventListener("click",W,!0),()=>A.removeEventListener("click",W,!0)},[]),x.useEffect(()=>{const A=a.current;if(!A)return;const W=J=>{const oe=J.target;!oe||!oe.isConnected||oe.closest(".vis-timeline")||Ys()};return A.addEventListener("click",W),()=>A.removeEventListener("click",W)},[Ys]);const Xs=x.useCallback((A,W)=>{O.current!=null&&(cancelAnimationFrame(O.current),O.current=null);const J=he=>{const Ie=o.current;if(!Ie||he<=0)return;const ye=Ie.getWindow();c1(A,(ye.end.valueOf()-ye.start.valueOf())/he),i.current.update(A),H.current=he,W==null||W()},oe=xm(o.current,a.current);if(oe>0&&Math.abs(oe-H.current)<1){J(oe);return}let de=-1,le=0,ve=0;const me=()=>{const he=xm(o.current,a.current);if(he>0&&he===de?le+=1:(le=0,de=he),he>0&&le>=2||ve++>40){O.current=null,J(he);return}O.current=requestAnimationFrame(me)};O.current=requestAnimationFrame(me)},[]);x.useEffect(()=>()=>{O.current!=null&&cancelAnimationFrame(O.current)},[]),x.useEffect(()=>{let A=null;const W=()=>{A&&clearTimeout(A),A=setTimeout(()=>mr(J=>J+1),200)};return window.addEventListener("resize",W),()=>{window.removeEventListener("resize",W),A&&clearTimeout(A)}},[]);const ds=x.useRef(!1);x.useEffect(()=>{const A=()=>{!document.hidden&&ds.current&&(ds.current=!1,mr(W=>W+1))};return document.addEventListener("visibilitychange",A),()=>document.removeEventListener("visibilitychange",A)},[]),x.useEffect(()=>{var Br;if(!Le)return;if(w.current=Le,document.hidden){ds.current=!0;return}ds.current=!1;const A=_.current,W=A&&!Le.prs.some(xe=>xe.id===A.id)?[...Le.prs,A]:Le.prs,J=He&&He.length>0?new Set(He):null,oe=xe=>!J||xe.authorId!=null&&J.has(xe.authorId),de=bn.length>0,le=new Set;if(de){const xe=new Set(bn);for(const Ye of Le.events)Ye.type==="review_comment"&&Ye.prId!=null&&Ye.derivedState!=null&&xe.has(Ye.derivedState)&&le.add(Ye.prId)}const ve=xe=>!de||le.has(xe.id),me=W.filter(xe=>xe.id===s||xe.id===On.current||xe.id===(A==null?void 0:A.id)||oe(xe)&&ve(xe));R.current={active:de,states:bn},P.current=re;const he=new Map;for(const xe of Le.events)he.set(xe.id,xe);d.current=he;const Ie=new Set;for(const xe of Le.events)xe.prId!=null&&(xe.type==="review_comment"||xe.type==="pr_comment")&&Ie.add(xe.prId);const ye=(Br=o.current)==null?void 0:Br.getWindow();X.current=ye?ye.end.valueOf()-ye.start.valueOf():null;const Re=e1(W);j.current=Re;const ze=Yv(Le.events,W);Pt.current=ze;let we=Le.events;if(s==null&&!ee.current&&de){const xe=new Set(bn);we=Le.events.filter(Ye=>Ye.type==="review_comment"&&Ye.prId!=null&&Ye.derivedState!=null&&xe.has(Ye.derivedState))}const Ae=gm([...me.map(xe=>xe.repoId),...we.map(xe=>xe.repoId)]).sort((xe,Ye)=>{const qn=Jn.get(xe),Xt=Jn.get(Ye);return!qn||!Xt?(qn?0:1)-(Xt?0:1)||xe-Ye:qn.owner.localeCompare(Xt.owner)||qn.name.localeCompare(Xt.name)||xe-Ye}),Ge=[],tt=0,Ct=1e6;Ae.forEach((xe,Ye)=>{const qn=gm([...we.filter(xt=>xt.repoId===xe&&xt.actorId!=null).map(xt=>xt.actorId),...me.filter(xt=>xt.repoId===xe&&xt.authorId!=null).map(xt=>xt.authorId)]),Xt=Hs.get(xe),Nn=qn.map(xt=>`repo:${xe}:user:${xt}`),hs=`tl-repo-tint-${Ye%o1}`,wr=Jn.get(xe),gs=(wr==null?void 0:wr.fullName)??`repo ${xe}`,Nl=wr!=null&&wr.inboxWatch?`${kt(gs)}${Vx()}`:kt(gs);Ge.push({id:`repo:${xe}`,content:Nl,nestedGroups:Nn.length?Nn:void 0,treeLevel:1,order:Ye,subgroupOrder:"sortKey",className:`tl-repo-header ${hs}`}),qn.forEach((xt,xs)=>{const Un=`repo:${xe}:user:${xt}`,kr=(Xt==null?void 0:Xt.has(xt))??!1;Ge.push({id:Un,content:u1(Zv(cn.get(xt),xt,ze.get(xt),kr,Un,N.current.has(Un))),treeLevel:2,order:(kr?tt:Ct)+xs,subgroupOrder:"sortKey",heightMode:N.current.has(Un)?"auto":"fixed",className:`tl-user-row ${wa(Un)} ${hs}`})})});const $e=ee.current?ce.current:null,$t=me.map(xe=>{const Ye=xe.authorId!=null?cn.get(xe.authorId):void 0,qn=Ms(xe),Xt=Re.get(xe.id)??0,Nn={author:{label:ft(Ye,xe.authorId),avatarUrl:(Ye==null?void 0:Ye.avatarUrl)??null},hasComments:Ie.has(xe.id)};return{id:`pr:${xe.id}`,group:qn,subgroup:`bar:${Xt}`,sortKey:Xt*2,type:"range",start:xe.openedAt,end:xe.mergedAt??xe.closedAt??new Date().toISOString(),content:Wv(xe,Nn),className:(()=>{const hs=Qv(xe,Nn.hasComments);return $e!=null&&xe.id!==$e?`${hs} pr-focus-hidden`:hs})(),title:Vv(xe,Nn)}}),pt=o.current,gt=pt==null?void 0:pt.getWindow(),zn=A?null:Qs(),ps=Bn.current,ms=new Set(Ge.map(xe=>String(xe.id)));u.current.update(Ge);const Dr=u.current.getIds().map(String).filter(xe=>!ms.has(xe));Dr.length&&u.current.remove(Dr);const nr=new Set($t.map(xe=>String(xe.id))),Ht=i.current.getIds().map(String).filter(xe=>xe.startsWith("pr:")&&!nr.has(xe));if(i.current.update($t),Ht.length&&i.current.remove(Ht),Xs($t,()=>{zn&&!Bn.current&&!ps&&Lr(zn)}),Ot(),pt&&gt){const xe=pt.getWindow();(xe.start.valueOf()!==gt.start.valueOf()||xe.end.valueOf()!==gt.end.valueOf())&&pt.setWindow(gt.start,gt.end,{animation:!1})}const Dt=On.current;if(Dt!=null&&pt&&i.current.get(`pr:${Dt}`)&&!pt.getSelection().map(String).includes(`pr:${Dt}`)&&pt.setSelection([`pr:${Dt}`]),E.current!=null){const xe=E.current;E.current=null,Dn(xe)}if(S.current&&us(S.current),ee.current&&ce.current!=null&&kn(ce.current),!S.current&&!ee.current&&N.current.size>0)for(const xe of N.current)Zn(xe,!0);const fn=_.current;(!fn||Le.prs.some(xe=>xe.id===fn.id)||On.current!==fn.id&&ce.current!==fn.id)&&(_.current=null),zn&&!Bn.current&&Lr(zn)},[Le,bn,_t,He,Jn,cn,Hs,wn,os,Ot,Dn,us,kn,Zn,Qs,Lr,Xs]),x.useEffect(()=>{P.current=re,o.current&&w.current&&Ot()},[re,Ot]),x.useEffect(()=>{On.current=at;const A=o.current;if(!A)return;if(at!=null&&!i.current.get(`pr:${at}`)){on(de=>de+1);return}const W=at!=null?[`pr:${at}`]:[],J=A.getSelection().map(String);J.length===W.length&&W.every(de=>J.includes(de))||A.setSelection(W)},[at]);const fs=x.useRef(!1);x.useEffect(()=>{if(s==null||fs.current||!o.current||!w.current)return;te.getState().selectedPrId!==s&&te.getState().selectPr(s);const W=y.current.get(s)??(Le==null?void 0:Le.prs.find(ve=>ve.id===s))??(_t==null?void 0:_t.prs.find(ve=>ve.id===s))??(Kt==null?void 0:Kt.prs.find(ve=>ve.id===s));if(!W)return;fs.current=!0,tr(s,{fitWindow:!0,pr:W});const J=wa(Ms(W)),oe=te.getState(),le=oe.timelineFocusPr===s&&oe.timelineFocusEvent!=null?null:window.setTimeout(()=>br(J,!1),320);return()=>{le!=null&&window.clearTimeout(le)}},[s,Le,_t,Kt,tr,br]),x.useEffect(()=>{const A=o.current;if(!A||s!=null)return;const{from:W,to:J}=$o(te.getState()),{start:oe,end:de}=ym(W,J);A.setWindow(oe,de,{animation:!1})},[fi,bl,wl,pi,s]);const Js=te(A=>A.timelineCenterAt);x.useEffect(()=>{if(Js==null)return;const A=o.current;if(!A)return;const W=A.getWindow(),J=W.end.valueOf()-W.start.valueOf();A.setWindow(Js-J/2,Js+J/2,{animation:!0}),te.getState().consumeTimelineCenter()},[Js]);const dn=te(A=>A.timelineFocusPr),jn=te(A=>A.timelineFocusAt);return x.useEffect(()=>{if(dn==null)return;const A=o.current;if(!A)return;const W=Le==null?void 0:Le.prs.find(le=>le.id===dn);if(W){const le=te.getState().timelineFocusEvent;if(le&&Le){const ye=Le.events.filter(Ae=>Ae.prId===dn&&Ae.type===le.type&&(le.refId==null||Ae.refId===le.refId)),Re=jn!=null&&ye.find(Ae=>Ae.occurredAt===jn)||ye[0],ze=(Re==null?void 0:Re.actorId)??W.authorId,we=Re!=null&&(i.current.get(`ev:${Re.id}`)!=null||m.current.get(Re.id)!=null);if(jn){const Ae=Date.parse(jn),Ge=A.getWindow(),tt=Ge.end.valueOf()-Ge.start.valueOf();A.setWindow(Ae-tt/2,Ae+tt/2,{animation:!0})}if(A.setSelection([`pr:${dn}`]),Re!=null&&Yt(Re.id),ze!=null){const Ae=wa(`repo:${W.repoId}:user:${ze}`);window.setTimeout(()=>br(Ae,we),120)}te.getState().consumeTimelineFocus();return}const ve=A.getWindow(),me=ve.end.valueOf()-ve.start.valueOf();let he;if(jn)he=Date.parse(jn);else{const ye=new Date(W.openedAt).getTime(),Re=new Date(W.mergedAt??W.closedAt??new Date().toISOString()).getTime();he=(ye+Re)/2}A.setWindow(he-me/2,he+me/2,{animation:!0}),A.setSelection([`pr:${dn}`]);const Ie=wa(Ms(W));window.setTimeout(()=>{br(Ie,!1,".ev-cross-linked",".pr-bar.vis-selected")},120),te.getState().consumeTimelineFocus();return}const J=le=>{_.current=le,on(me=>me+1);const ve=wa(Ms(le));Y.current!=null&&window.clearTimeout(Y.current),Y.current=window.setTimeout(()=>{Y.current=null,A.setSelection([`pr:${le.id}`]),br(ve,!1,".ev-cross-linked",".pr-bar.vis-selected")},360),te.getState().consumeTimelineFocus()},oe=Le&&!Le.prs.some(le=>le.id===dn)?Ln==null?void 0:Ln.prs.find(le=>le.id===dn):void 0;if(oe){J(oe);return}const de=(_t==null?void 0:_t.prs.find(le=>le.id===dn))??(Kt==null?void 0:Kt.prs.find(le=>le.id===dn));if(de){const{from:le}=$o(te.getState()),ve=new Date(de.openedAt).getTime();if(ve<le.getTime()){const me=new Date(ve-864e5).toISOString().slice(0,10),he=new Date().toISOString().slice(0,10);te.getState().setCustomRange(me,he);return}if(Le&&!Le.prs.some(me=>me.id===de.id)){J(de);return}}te.getState().consumeTimelineFocus()},[dn,jn,Le,_t,Ln,Kt,br,Yt]),n.jsxs("div",{className:`relative h-full w-full${Lt?" tl-focus-active":""}`,children:[Mn&&!Le&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-gray-500",children:"Loading timeline…"}),Fn&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-red-500",children:String(Fn)}),Le&&Le.prs.length===0&&Le.events.length===0&&n.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."}),n.jsx("div",{ref:a,className:"h-full w-full"}),n.jsx("svg",{ref:C,className:"tl-cross-connectors","aria-hidden":"true",style:{display:"none"}}),n.jsx("div",{ref:K,className:"tl-repo-sticky","aria-hidden":"true",style:{display:"none"}}),se&&n.jsx(r1,{state:se,eventsById:d.current,usersById:cn,prsById:hr,focusPrId:Lt?ce.current:null,onContextFocus:Vs,onDismiss:Or,onNavigate:mi}),We&&n.jsx($w,{gid:We.gid,uid:We.uid,user:cn.get(We.uid),stats:Pt.current.get(We.uid)??{comments:0,reviews:0,prsOpen:0,prsMerged:0,prsClosed:0},x:We.x,y:We.y,onDismiss:()=>st(null)})]})}const Lo=Pu;function h1(e){return Lo.reduce((s,a)=>s+e[a],0)}function Gu({counts:e,compact:s=!1,activeState:a=null,onSegmentClick:o,className:i=""}){const u=h1(e);return s?n.jsx("span",{className:`inline-flex h-1.5 w-16 overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700 ${i}`,"aria-hidden":"true",children:u>0&&Lo.map(d=>e[d]>0?n.jsx("span",{style:{width:`${e[d]/u*100}%`,background:jt[d].color}},d):null)}):n.jsxs("div",{className:i,children:[n.jsx("div",{className:"flex h-2.5 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",children:u===0?null:Lo.map(d=>{if(e[d]===0)return null;const p=jt[d],m=n.jsx("span",{title:`${p.label}: ${e[d]}`,style:{width:`${e[d]/u*100}%`,background:p.color,opacity:a==null||a===d?1:.35},className:"block h-full"},d);return o?n.jsx("button",{type:"button",onClick:()=>o(d),title:`${p.label}: ${e[d]} — click to filter`,style:{width:`${e[d]/u*100}%`,background:p.color,opacity:a==null||a===d?1:.35},className:"block h-full transition-opacity hover:opacity-100","aria-pressed":a===d},d):m})}),n.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5",children:[Lo.map(d=>{const p=jt[d],m=a===d,g=a!=null&&!m,w=n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{background:p.color}}),n.jsx("span",{className:"tabular-nums",children:e[d]}),n.jsx("span",{children:p.label.toLowerCase()})]}),v=`flex items-center gap-1 text-[10px] ${g?"text-gray-400 opacity-60":"text-gray-600 dark:text-gray-300"}`;return o?n.jsx("button",{type:"button",onClick:()=>o(d),className:`${v} hover:underline`,"aria-pressed":m,title:p.description,children:w},d):n.jsx("span",{className:v,title:p.description,children:w},d)}),n.jsx("span",{className:"ml-auto text-[10px] tabular-nums text-gray-400",children:u})]})]})}function ci(e){return qe({queryKey:["ai-usage"],queryFn:()=>ge.aiUsage(),enabled:e,staleTime:3e4})}function g1(e){return e&&e.length>0?`repoIds=${e.join(",")}`:""}function x1(e,s){const a=g1(e);return qe({queryKey:["repo-digests",a],queryFn:()=>ge.repoDigests(a),enabled:s,staleTime:1/0})}function y1(e,s){return qe({queryKey:["repo-digest",e],queryFn:()=>ge.repoDigest(e),enabled:s&&e!=null,staleTime:1/0})}function v1(e,s){e.setQueriesData({queryKey:["repo-digests"]},a=>{if(!a)return a;const o=a.digests.findIndex(u=>u.repoId===s.repoId);if(o===-1)return a;const i=a.digests.slice();return i[o]=s,{...a,digests:i}})}const b1=5e3;function a0(e){return!e||e.total<=0?{value:null}:{value:e.completed/e.total*100,sub:`${e.completed}/${e.total}`}}function l0(){const e=Be(),[s,a]=x.useState(!1),[o,i]=x.useState(()=>new Set),[u,d]=x.useState(null),[p,m]=x.useState(null),g=x.useRef(null);return x.useEffect(()=>()=>{var v;return(v=g.current)==null?void 0:v.abort()},[]),x.useEffect(()=>{if(p==null)return;const v=window.setTimeout(()=>m(null),b1);return()=>window.clearTimeout(v)},[p]),{mutate:x.useCallback(v=>{var I;(I=g.current)==null||I.abort();const y=new AbortController;g.current=y,a(!0),m(null),i(new Set),d(null);const j=$=>i(L=>{if(!L.has($))return L;const q=new Set(L);return q.delete($),q}),R=v==null?void 0:Array.isArray(v)?v.length>0?`repoIds=${v.join(",")}`:void 0:`repoIds=${v}`,P=`/api/pro/activity/digests/refresh/stream${R?`?${R}`:""}`;let E=!1,S=!1,T=[],N=0,b=0;ti(P,{method:"POST",signal:y.signal,onEvent:$=>{switch($.type){case"start":$.throttled&&(E=!0),$.creditsExhausted&&(S=!0);break;case"plan":T=$.toRegenerate,N=T.length,i(new Set(T)),d({completed:0,total:N});break;case"repo":b+=1,d({completed:b,total:N}),e.setQueryData(["repo-digest",$.digest.repoId],$.digest),v1(e,$.digest),j($.digest.repoId);break;case"error":b+=1,d({completed:b,total:N}),j($.repoId);break}}}).catch(()=>{}).finally(()=>{if(g.current===y){g.current=null,a(!1),i(new Set),d(null),m(S?"Out of AI credits this month — summaries resume on the 1st.":E?"Refreshed moments ago — showing the latest. Try again shortly.":N===0?"Already up to date — no new activity since the last digest.":null),e.invalidateQueries({queryKey:["ai-usage"]});for(const $ of T)e.invalidateQueries({queryKey:["repo-digest",$]});T.length>0&&e.invalidateQueries({queryKey:["repo-digests"]})}})},[e]),isPending:s,refreshingRepoIds:o,progress:u,notice:p}}function w1(e){return{id:e.prId,number:e.prNumber,title:e.title??`#${e.prNumber}`,repoFullName:e.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null}}function o0(){const e=De(s=>s.openPrDetailTab);return s=>{s.prId!=null&&e(w1(s),{fromActivity:!0})}}const i0="pierre:collapsedDigests";function k1(){try{const e=localStorage.getItem(i0),s=e?JSON.parse(e):[];return new Set(Array.isArray(s)?s.filter(a=>typeof a=="number"):[])}catch{return new Set}}function j1(e){try{localStorage.setItem(i0,JSON.stringify([...e]))}catch{}}const bm=ml((e,s)=>({collapsed:k1(),toggle:a=>{const o=new Set(s().collapsed);o.has(a)?o.delete(a):o.add(a),j1(o),e({collapsed:o})}})),c0="pierre:insightsDigestsExpanded";function N1(){try{const e=localStorage.getItem(c0),s=e?JSON.parse(e):[];return new Set(Array.isArray(s)?s.filter(a=>typeof a=="number"):[])}catch{return new Set}}const wm=ml((e,s)=>({expanded:N1(),toggle:a=>{const o=new Set(s().expanded);o.has(a)?o.delete(a):o.add(a);try{localStorage.setItem(c0,JSON.stringify([...o]))}catch{}e({expanded:o})}})),u0="pierre:sprintReportUi";function S1(){const e={collapsed:!1,reposOpen:!1};try{const s=localStorage.getItem(u0);if(!s)return e;const a=JSON.parse(s);if(a==null||typeof a!="object")return e;const o=a;return{collapsed:typeof o.collapsed=="boolean"?o.collapsed:!1,reposOpen:typeof o.reposOpen=="boolean"?o.reposOpen:!1}}catch{return e}}const Io=ml((e,s)=>{const a=()=>{try{const{collapsed:o,reposOpen:i}=s();localStorage.setItem(u0,JSON.stringify({collapsed:o,reposOpen:i}))}catch{}};return{...S1(),setCollapsed:o=>{e({collapsed:o}),a()},setReposOpen:o=>{e({reposOpen:o}),a()}}});function C1(e){const s=new Map,a=new Map;for(const o of e)o.prId!=null&&(s.set(`${o.repoFullName}#${o.prNumber}`,o),a.has(o.prNumber)||a.set(o.prNumber,o));return{byKey:s,byNumber:a}}const Yu=/([A-Za-z0-9][\w.-]*\/[A-Za-z0-9][\w.-]*)#(\d+)|#(\d+)/.source;function d0(e,s){const a=e[1]!=null,o=Number(a?e[2]:e[3]);return a?s.byKey.get(`${e[1]}#${o}`)??s.byNumber.get(o):s.byNumber.get(o)}function km(e,s,a,o=""){const i=[];let u=0,d=0;const p=new RegExp(Yu,"g");let m;for(;(m=p.exec(e))!=null;){m.index>u&&i.push(e.slice(u,m.index));const g=m[1]!=null,w=Number(g?m[2]:m[3]),v=g?s.byKey.get(`${m[1]}#${w}`)??s.byNumber.get(w):s.byNumber.get(w);if(v!=null){const y=`${v.repoFullName}#${v.prNumber}`;i.push(n.jsx("button",{type:"button",onClick:()=>a(v),className:"font-semibold text-sky-600 hover:underline dark:text-sky-400",title:v.title??y,children:y},`${o}r${d++}`))}else i.push(m[0]);u=m.index+m[0].length}return u<e.length&&i.push(e.slice(u)),i}function il(e,s,a){return e.split(/(\*\*[^*]+\*\*)/g).flatMap((i,u)=>{const d=/^\*\*([^*]+)\*\*$/.exec(i);return d!=null?[n.jsx("strong",{children:km(d[1]??"",s,a,`b${u}-`)},`b${u}`)]:km(i,s,a,`t${u}-`)})}const jm=e=>{const s=e.additions+e.deletions,a=e.openedAt?Math.max(0,(Date.now()-Date.parse(e.openedAt))/36e5):0;return s*a},Nm=(e,s)=>jm(s)-jm(e),Sm=e=>Number.isFinite(e)&&e>=1e4?`${Math.round(e/1e3)}k`:String(e??0);function R1(e,s){const a=[],o=new Set,i=new RegExp(Yu,"g");let u;for(;(u=i.exec(e))!=null;){const d=d0(u,s);if((d==null?void 0:d.prId)!=null){const p=`${d.repoFullName}#${d.prNumber}`;o.has(p)||(o.add(p),a.push(d))}}return a}function I1(e,s){const a=e.replace(new RegExp(Yu,"g"),(o,...i)=>{const u=i.slice(0,3),d=d0([o,...u],s);return(d==null?void 0:d.prId)!=null?"":o}).replace(/\s{2,}/g," ").replace(/\s*[,;](?:\s*[,;])+\s*/g,", ").replace(/,\s*(?:and|or)\s*,/gi,",").replace(/(^|[:,])\s*(?:and|or)\b\s*/gi,"$1 ").replace(/\s+(?:and|or)\s*([,.;:])/gi,"$1").replace(/:\s*,/g,":").replace(/\s+([,.;:])/g,"$1").replace(/,(?:\s*,)+/g,",").replace(/[\s,;:]+([.!?])/g,"$1").replace(/\s{2,}/g," ").replace(/^[\s:,.\-–—·•]+/,"").replace(/[\s,;:]+$/,"").trim();return/^[a-z]/.test(a)?a[0].toUpperCase()+a.slice(1):a}function T1(e,s){const a=e.split(`
48
+ `).map(p=>p.replace(/`/g,"").trim()).filter(p=>p!==""&&!/^[-–—*_]{3,}$/.test(p)),o=[];let i=[],u=!1;const d=()=>{i.length!==0&&(i.sort((p,m)=>Nm(p.prs[0],m.prs[0])),o.push({kind:"prtable",groups:i}),i=[])};for(const p of a){const m=/^#{1,6}\s+(.*)$/.exec(p),g=p.replace(/^[-*]\s+/,"");if(!u){u=!0,o.push({kind:"headline",text:m?m[1]??"":g});continue}const w=R1(p,s);if(w.length>0){w.sort(Nm),i.push({prs:w,summary:I1(g,s)});continue}const v=/^\*\*(.+)\*\*$/.exec(g);d(),m?o.push({kind:"header",text:m[1]}):v?o.push({kind:"subhead",text:v[1]}):o.push({kind:"prose",text:g})}return d(),o}function E1({groups:e,onOpenPr:s,usersById:a,index:o}){return n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full min-w-[852px] table-fixed border-collapse text-[12px]",children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:"320px"}}),n.jsx("col",{style:{width:"24px"}}),n.jsx("col",{style:{width:"84px"}}),n.jsx("col",{style:{width:"110px"}}),n.jsx("col",{style:{width:"104px"}}),n.jsx("col",{})]}),n.jsx("thead",{children:n.jsxs("tr",{className:"text-left text-[9px] font-semibold uppercase tracking-wide text-gray-400",children:[n.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"Pull request"}),n.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"CI"}),n.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"Age"}),n.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"Author"}),n.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"Diff"}),n.jsx("th",{className:"pb-1 font-semibold",children:"Summary"})]})}),n.jsx("tbody",{children:e.map((i,u)=>i.prs.map((d,p)=>{const m=d.ciStatus?ur[d.ciStatus]:null,g=d.authorId!=null?a.get(d.authorId):void 0;return n.jsxs("tr",{className:"border-t border-gray-100 align-top dark:border-gray-800/60",children:[n.jsx("td",{className:"py-1 pr-2",children:n.jsxs("button",{type:"button",onClick:()=>s(d),className:"block text-left leading-snug hover:underline",title:`${d.repoFullName}#${d.prNumber}${d.title?` — ${d.title}`:""}`,children:[n.jsxs("span",{className:"font-semibold text-sky-600 dark:text-sky-400",children:["#",d.prNumber]})," ",n.jsx("span",{className:"text-gray-700 dark:text-gray-200",children:d.title??""})]})}),n.jsx("td",{className:"py-1 pr-2",children:n.jsx("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400",title:(m==null?void 0:m.label)??"no checks",children:n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:m?{background:m.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"},"aria-hidden":!0})})}),n.jsx("td",{className:"whitespace-nowrap py-1 pr-2 text-[11px] text-gray-500 dark:text-gray-400",children:d.openedAt?St(d.openedAt):"—"}),n.jsx("td",{className:"overflow-hidden py-1 pr-2",children:n.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-[11px] text-gray-600 dark:text-gray-300",children:[n.jsx("span",{className:"shrink-0",children:n.jsx(ht,{user:g,size:13})}),n.jsx("span",{className:"min-w-0 truncate",children:g?n.jsx(sn,{user:g,fallbackId:d.authorId??0}):d.authorLogin??"—"})]})}),n.jsxs("td",{className:"whitespace-nowrap py-1 pr-2 text-[11px]",children:[n.jsxs("span",{className:"font-mono text-green-600 dark:text-green-400",children:["+",Sm(d.additions)]})," ",n.jsxs("span",{className:"font-mono text-red-500 dark:text-red-400",children:["−",Sm(d.deletions)]})]}),p===0&&n.jsx("td",{rowSpan:i.prs.length,className:"py-1 align-top text-[12px] leading-relaxed text-gray-700 dark:text-gray-200",children:i.summary?il(i.summary,o,s):null})]},`${u}-${d.prId}`)}))})]})})}function Xu({markdown:e,prRefs:s,onOpenPr:a}){const{data:o}=$n(),i=x.useMemo(()=>ln(o),[o]),u=x.useMemo(()=>C1(s),[s]),d=x.useMemo(()=>T1(e,u),[e,u]),p=m=>m;return n.jsx("div",{className:"space-y-1.5",children:d.map((m,g)=>m.kind==="prtable"?n.jsx(E1,{groups:m.groups,onOpenPr:a,usersById:i,index:u},g):m.kind==="headline"?n.jsx("div",{className:"border-l-2 border-violet-400 pl-2 text-[13px] font-semibold leading-relaxed text-gray-800 dark:border-violet-500 dark:text-gray-100",children:p(il(m.text??"",u,a))},g):m.kind==="header"?n.jsx("div",{className:"pt-1 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:p(il(m.text??"",u,a))},g):m.kind==="subhead"?n.jsx("div",{className:"pt-1.5 text-[12px] font-semibold text-gray-700 dark:text-gray-200",children:p(il(m.text??"",u,a))},g):n.jsxs("div",{className:"flex gap-1.5 text-[13px] leading-relaxed text-gray-700 dark:text-gray-200",children:[n.jsx("span",{"aria-hidden":"true",className:"select-none text-gray-400",children:"•"}),n.jsx("span",{className:"min-w-0",children:p(il(m.text??"",u,a))})]},g))})}function P1({markdown:e,prRefs:s,onOpenPr:a}){return n.jsx(Xu,{markdown:e,prRefs:s,onOpenPr:a})}function A1(e){if(!e)return"Haiku";const s=e.toLowerCase();return s.includes("haiku")?"Haiku":s.includes("sonnet")?"Sonnet":s.includes("opus")?"Opus":e}function f0({digest:e,isLoading:s,title:a,collapsed:o,onToggle:i,onRegenerate:u,regenerating:d=!1,onOpenPr:p,showProBadge:m=!0,outOfCredits:g=!1}){return n.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:[n.jsxs("div",{onClick:i,className:"-mx-1 flex cursor-pointer select-none items-center gap-2 rounded px-1 hover:bg-violet-500/5",children:[n.jsxs("button",{type:"button",onClick:w=>{w.stopPropagation(),i()},"aria-expanded":!o,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:o?"Expand digest":"Collapse digest",children:[n.jsx("span",{"aria-hidden":"true",className:"text-[9px]",children:o?"▸":"▾"}),n.jsx("span",{"aria-hidden":"true",children:"✨"}),n.jsx("span",{className:"truncate normal-case",children:a})]}),m&&n.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"}),n.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-gray-400",children:[e!=null&&n.jsxs("span",{title:e.model,children:[A1(e.model)," · ",St(e.generatedAt),e.stale?" · stale":""]}),u!=null&&n.jsxs("button",{type:"button",onClick:w=>{w.stopPropagation(),u==null||u()},disabled:d||g,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:g?"Out of AI credits — resets next month":e==null?"Generate this repo's digest (runs the cheap-tier model)":"Regenerate this repo's digest (runs the cheap-tier model)",children:[n.jsx("span",{"aria-hidden":"true",children:"↻"}),g?"Out of credits":d?e==null?"Generating…":"Regenerating…":e==null?"Generate":"Regenerate"]})]})]}),!o&&n.jsx("div",{className:"mt-1",children:d?n.jsx($1,{}):s?n.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()!==""?n.jsx("div",{className:"digest-fade-in",children:n.jsx(P1,{markdown:e.summary,prRefs:e.prRefs,onOpenPr:p})},e.generatedAt):n.jsx("p",{className:"text-xs text-gray-400",children:"No digest yet — click Generate to summarise this repo's recent activity."})})]})}function $1(){return n.jsx("div",{className:"space-y-1.5 py-0.5","aria-hidden":"true",children:["92%","80%","66%","74%"].map((e,s)=>n.jsx("div",{className:"digest-skeleton-line h-3",style:{width:e}},s))})}function p0({active:e,label:s="Regenerating digests",timeConstantSec:a=5,value:o,sub:i}){const[u,d]=x.useState(null),p=o!=null;if(x.useEffect(()=>{if(e){if(p){d(Math.max(0,Math.min(100,o)));return}const w=performance.now();d(8);const v=window.setInterval(()=>{const y=(performance.now()-w)/1e3;d(Math.min(92,8+84*(1-Math.exp(-y/a))))},200);return()=>window.clearInterval(v)}d(w=>w==null?null:100);const g=window.setTimeout(()=>d(null),500);return()=>window.clearTimeout(g)},[e,p,o,a]),u==null)return null;const m=Math.round(u);return n.jsxs("div",{className:"flex items-center gap-2 px-0.5","aria-live":"polite",children:[n.jsx("div",{className:"h-1 flex-1 overflow-hidden rounded-full bg-violet-100 dark:bg-violet-950/40",role:"progressbar","aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s,children:n.jsx("div",{className:"h-full rounded-full bg-violet-500 transition-[width] duration-200 ease-out dark:bg-violet-400",style:{width:`${u}%`}})}),n.jsx("span",{className:"shrink-0 whitespace-nowrap text-right text-[10px] tabular-nums text-violet-500 dark:text-violet-300",children:i??`${m}%`})]})}function M1({repoId:e}){var v,y;const{activityDigest:s}=yn(),{data:a,isLoading:o}=y1(e,s),i=l0(),u=o0(),d=ci(s),p=((v=d.data)==null?void 0:v.allowanceCredits)!=null&&(d.data.remainingCredits??0)<=0,m=bm(j=>j.collapsed.has(e)),g=bm(j=>j.toggle),w=i.refreshingRepoIds.has(e);return s?n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(f0,{digest:a,isLoading:o,title:"Digest",collapsed:m,onToggle:()=>g(e),onRegenerate:a==null||a.stale?()=>i.mutate(e):void 0,regenerating:w,onOpenPr:u,outOfCredits:p}),n.jsx(p0,{active:i.isPending&&(((y=i.progress)==null?void 0:y.total)??0)>0,label:"Regenerating digest",...a0(i.progress)}),i.notice!=null&&n.jsx("p",{className:"px-0.5 text-[11px] text-gray-400","aria-live":"polite",children:i.notice})]}):null}function F1({stats:e}){return n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-gray-500 dark:text-gray-400",children:[n.jsxs("span",{children:[n.jsx("span",{className:"font-semibold text-gray-700 dark:text-gray-200 tabular-nums",children:e.openPrs})," ","open"]}),n.jsxs("span",{children:[n.jsx("span",{className:"tabular-nums",children:e.draftPrs})," draft"]}),e.stalledPrs>0&&n.jsxs("span",{className:"text-amber-500",children:[n.jsx("span",{className:"tabular-nums",children:e.stalledPrs})," stalled ⏱"]}),e.medianHoursToFirstReview!=null&&n.jsxs("span",{title:"Median hours to first review",children:["TTFR"," ",n.jsx("span",{className:"tabular-nums",children:e.medianHoursToFirstReview<1?`${Math.round(e.medianHoursToFirstReview*60)}m`:`${Math.round(e.medianHoursToFirstReview)}h`})]}),e.oldestUnreviewed!=null&&n.jsxs("a",{href:e.oldestUnreviewed.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"hover:underline",title:e.oldestUnreviewed.title,children:["oldest unreviewed #",e.oldestUnreviewed.number," ·"," ",St(e.oldestUnreviewed.openedAt)]}),e.botThreads>0&&n.jsxs("span",{className:"text-sky-600 dark:text-sky-400",title:"Review-bot threads on open PRs, and the share a later commit has likely addressed (resolved or likely_addressed). An approximate signal — likely_addressed is a heuristic.",children:["🤖 ",n.jsx("span",{className:"tabular-nums",children:e.botThreads})," bot thread",e.botThreads===1?"":"s"," ·"," ",n.jsxs("span",{className:"tabular-nums",children:[Math.round(e.botThreadsActedOn/e.botThreads*100),"%"]})," ","acted on"]})]})}function L1({repo:e}){const s=e.maintainerIds.length;return n.jsxs("div",{className:"space-y-2 rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"min-w-0 truncate text-base font-semibold text-gray-800 dark:text-gray-100",children:e.repoFullName}),s>0&&n.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 text-[11px] text-gray-400",title:`${s} maintainer${s===1?"":"s"} (have merged here)`,children:[n.jsx(zu,{}),s]}),e.attentionCount>0&&n.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]}),n.jsx("span",{className:"ml-auto shrink-0 text-[11px] tabular-nums text-gray-400",children:e.stats.openPrs>0?`[${e.stats.openPrs}]`:"[—]"})]}),n.jsx(F1,{stats:e.stats}),n.jsx(Gu,{counts:e.threadTotals}),n.jsx(M1,{repoId:e.repoId})]})}function yl(){const e=x.useRef(null),[s,a]=x.useState(0);return x.useEffect(()=>{const o=e.current;if(!o)return;const i=new ResizeObserver(u=>{var p;const d=(p=u[0])==null?void 0:p.contentRect.width;d!=null&&a(d)});return i.observe(o),a(o.clientWidth),()=>i.disconnect()},[]),[e,s]}const Ke={blue:"#3b82f6",green:"#22c55e",gray:"#9ca3af",orange:"#f97316",amber:"#f59e0b",purple:"#8957e5",red:"#ef4444",teal:"#14b8a6",pink:"#ec4899",slate:"#64748b"},Cm=[Ke.blue,Ke.green,Ke.amber,Ke.purple,Ke.teal,Ke.pink,Ke.slate];function Pn(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 s=e/24;return`${s<10?s.toFixed(1):Math.round(s)}d`}function _s(e){return new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function zs(e){return Math.abs(e)>=1e3?`${(e/1e3).toFixed(e%1e3===0?0:1)}k`:`${Math.round(e)}`}function Ju(e){if(e<=0)return 1;const s=Math.floor(Math.log10(e)),a=Math.pow(10,s),o=e/a;return(o<=1?1:o<=2?2:o<=5?5:10)*a}function ui({series:e}){return n.jsx("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5",children:e.map(s=>n.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-500 dark:text-gray-400",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-[2px]",style:{background:s.color}}),s.label]},s.label))})}function vl({x:e,y:s,width:a,children:o}){const i=Math.max(58,Math.min(e,Math.max(58,a-58)));return n.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:i,top:Math.max(s-6,0)},children:o})}function Et({title:e,note:s,children:a}){return n.jsxs("div",{className:"rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[n.jsxs("div",{className:"mb-1 flex items-baseline justify-between gap-2",children:[n.jsx("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-200",children:e}),s&&n.jsx("span",{className:"text-[10px] text-gray-400",children:s})]}),a]})}function wt({label:e="No data in this window"}){return n.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 Os({labels:e,series:s,area:a=!1,curved:o=!1,formatY:i=zs,height:u=132}){const[d,p]=yl(),[m,g]=x.useState(null),w=30,v=8,y=8,j=16,R=e.length,P=Math.max(p-w-v,1),E=u-y-j,S=Ju(Math.max(1,...s.flatMap(B=>B.values.map(O=>O??0)))),T=B=>w+(R<=1?P/2:B/(R-1)*P),N=B=>y+E*(1-B/S),b=y+E,I=B=>B.values.map((O,H)=>O==null?null:`${T(H)},${N(O)}`).reduce((O,H)=>H==null?{d:O.d,pen:!1}:{d:`${O.d}${O.pen?" L":" M"} ${H}`,pen:!0},{d:"",pen:!1}).d,$=B=>{const O=B.values.map((H,ee)=>H==null?null:[T(ee),N(H)]).filter(H=>H!=null);return O.length<2?"":`M ${O[0][0]} ${b} `+O.map(([H,ee])=>`L ${H} ${ee}`).join(" ")+` L ${O[O.length-1][0]} ${b} Z`},L=B=>{let O="";for(let H=0;H<B.length-1;H++){const ee=B[H-1]??B[H],ce=B[H],C=B[H+1],F=B[H+2]??C,K=ce[0]+(C[0]-ee[0])/6,ae=ce[1]+(C[1]-ee[1])/6,ne=C[0]-(F[0]-ce[0])/6,Pe=C[1]-(F[1]-ce[1])/6;O+=` C ${K} ${ae} ${ne} ${Pe} ${C[0]} ${C[1]}`}return O},q=B=>{const O=[];let H=[];return B.values.forEach((ee,ce)=>{ee==null?(H.length&&O.push(H),H=[]):H.push([T(ce),N(ee)])}),H.length&&O.push(H),O.map(ee=>{const ce=`M ${ee[0][0]} ${ee[0][1]}`;return ee.length<2?ce:ce+L(ee)}).join(" ")},Q=B=>{const O=B.values.map((ce,C)=>ce==null?null:[T(C),N(ce)]).filter(ce=>ce!=null);if(O.length<2)return"";const H=O[0],ee=O[O.length-1];return`M ${H[0]} ${b} L ${H[0]} ${H[1]}`+L(O)+` L ${ee[0]} ${b} Z`},_=o?q:I,Y=o?Q:$,X=B=>{const O=B.nativeEvent.offsetX,H=R<=1?0:Math.round((O-w)/P*(R-1));g(Math.max(0,Math.min(R-1,H)))};return n.jsxs("div",{children:[n.jsxs("div",{ref:d,className:"relative",style:{height:u},children:[p>0&&n.jsxs("svg",{width:p,height:u,className:"block",children:[[0,S].map(B=>n.jsxs("g",{children:[n.jsx("line",{x1:w,y1:N(B),x2:p-v,y2:N(B),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),n.jsx("text",{x:w-4,y:N(B)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:i(B)})]},B)),a&&s[0]&&Y(s[0])&&n.jsx("path",{d:Y(s[0]),fill:s[0].color,opacity:.12}),m!=null&&n.jsx("line",{x1:T(m),y1:y,x2:T(m),y2:b,className:"text-gray-300 dark:text-gray-600",stroke:"currentColor",strokeWidth:1}),s.map(B=>n.jsx("path",{d:_(B),fill:"none",stroke:B.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"},B.key)),s.map(B=>B.values.map((O,H)=>O==null?null:n.jsx("circle",{cx:T(H),cy:N(O),r:m===H?3:1.8,fill:B.color},`${B.key}-${H}`))),n.jsx("text",{x:w,y:u-4,className:"fill-gray-400 text-[8px]",children:e[0]?_s(e[0]):""}),n.jsx("text",{x:p-v,y:u-4,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:e[R-1]?_s(e[R-1]):""}),n.jsx("rect",{x:0,y:0,width:p,height:u,fill:"transparent",onMouseMove:X,onMouseLeave:()=>g(null)})]}),m!=null&&p>0&&n.jsxs(vl,{x:T(m),y,width:p,children:[n.jsx("div",{className:"font-medium",children:e[m]?_s(e[m]):""}),s.map(B=>n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-[1px]",style:{background:B.color}}),B.label,": ",B.values[m]==null?"—":i(B.values[m])]},B.key))]})]}),s.length>1&&n.jsx(ui,{series:s})]})}function _1({repoId:e,onOpenCharts:s}){const{data:a,isLoading:o}=ah(e),i=(a==null?void 0:a.weekBuckets)??[],u=[{key:"opened",label:"Opened",color:Ke.blue,values:(a==null?void 0:a.throughput.opened)??[]},{key:"merged",label:"Merged",color:Ke.green,values:(a==null?void 0:a.throughput.merged)??[]}],d=u.some(p=>p.values.some(m=>m>0));return n.jsxs("div",{className:"rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[n.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[n.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:["PR merge rate",a?` · ${a.windowDays/7}-wk`:""]}),n.jsx("button",{type:"button",onClick:s,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"})]}),o&&a==null?n.jsx("div",{className:"h-[132px] animate-pulse rounded bg-gray-50 dark:bg-gray-900/40"}):d?n.jsx(Os,{labels:i,series:u,area:!0,curved:!0}):n.jsx(wt,{})]})}function O1({prs:e,repoFullName:s}){const{data:a}=$n(),o=De(p=>p.openPrDetailTab),i=x.useMemo(()=>ln(a),[a]);if(e.length===0)return null;const u=e.reduce((p,m)=>p+(m.isDraft?1:0),0),d=e.length-u;return n.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800",children:[n.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 · ",d,u>0&&n.jsxs("span",{className:"font-normal normal-case text-gray-400",children:[" ","· ",u," draft",u===1?"":"s"]})]}),n.jsx("ul",{className:"divide-y divide-gray-100 dark:divide-gray-800/70",children:e.map(p=>{const m=ur[p.ciStatus],g=p.authorId!=null?i.get(p.authorId):void 0,w=oh[p.reasonTag],v=Xo(p.mergeable,p.mergeStateStatus),y=p.isApproved?{label:"approved",color:"#22c55e"}:p.isChangesRequested?{label:"changes",color:"#ef4444"}:null;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>o({id:p.id,number:p.number,title:p.title,repoFullName:s,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:[n.jsx("span",{"aria-hidden":"true",title:(m==null?void 0:m.label)??"no checks",className:"inline-block h-2 w-2 shrink-0 rounded-full",style:m!=null?{background:m.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"}}),Kx(p)&&n.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:"⚠"}),n.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[n.jsxs("span",{className:"text-gray-400",children:["#",p.number]})," ",n.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:p.title})]}),n.jsx(ht,{user:g,size:16}),n.jsx("span",{className:"max-w-[7rem] shrink-0 truncate text-gray-500 dark:text-gray-400",title:ft(g,p.authorId),children:ft(g,p.authorId)}),p.isDraft&&n.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"}),y!=null&&n.jsx("span",{className:"shrink-0 rounded px-1 text-[10px] font-semibold",style:{color:y.color,background:y.color+"1a"},children:y.label}),v!=null&&n.jsx("span",{className:"shrink-0 rounded bg-orange-500/15 px-1 text-[10px] font-medium text-orange-600 dark:text-orange-400",children:v}),n.jsx(Gu,{counts:p.threadCounts,compact:!0}),w.myTurn?n.jsx("span",{className:"hidden shrink-0 rounded px-1 text-[10px] font-medium sm:inline",style:{color:w.color,background:w.color+"1a"},title:ft(g,p.authorId),children:w.label}):n.jsx("span",{className:"hidden shrink-0 text-[10px] text-gray-400 sm:inline",children:St(p.updatedAt)})]})},p.id)})})]})}function D1(){const e=Be();return Ue({mutationFn:()=>ge.markFeedSeen(),onSuccess:()=>void e.invalidateQueries({queryKey:["me"]})})}const B1=50;function m0(e,s,a,o){const i=new URLSearchParams;return e&&e.length>0&&i.set("repoIds",e.join(",")),s&&s.length>0&&i.set("userIds",s.join(",")),a&&(i.set("excludeBots","true"),o.length>0&&i.set("allowBotIds",o.join(","))),i.toString()}function z1(e){var u,d,p,m,g;const s=m0(e.repoIds,e.userIds,e.excludeBots??!1,e.allowedBotIds??[]),a=Jg({queryKey:["consolidated-feed",s],initialPageParam:0,queryFn:({pageParam:w})=>{const v=new URLSearchParams(s);return v.set("limit",String(B1)),v.set("offset",String(w)),ge.consolidatedFeed(v.toString())},getNextPageParam:(w,v)=>{var R;const y=v.reduce((P,E)=>P+E.items.length,0),j=((R=v[0])==null?void 0:R.total)??0;return y<j?y:void 0},enabled:e.enabled??!0,staleTime:1/0,refetchOnMount:!1,placeholderData:w=>w}),{items:o,users:i}=x.useMemo(()=>{var j;const w=((j=a.data)==null?void 0:j.pages)??[],v=w.flatMap(R=>R.items),y=new Map;for(const R of w)for(const P of R.users)y.set(P.id,P);return{items:v,users:[...y.values()]}},[a.data]);return{items:o,users:i,total:((d=(u=a.data)==null?void 0:u.pages[0])==null?void 0:d.total)??0,generatedAt:((m=(p=a.data)==null?void 0:p.pages[0])==null?void 0:m.generatedAt)??null,latestId:((g=o[0])==null?void 0:g.id)??null,hasMore:a.hasNextPage,loadMore:a.fetchNextPage,isFetchingMore:a.isFetchingNextPage,isLoading:a.isLoading,isFetching:a.isFetching}}function q1(e){var p,m,g;const s=Be(),a=m0(e.repoIds,e.userIds,e.excludeBots??!1,e.allowedBotIds??[]),o=qe({queryKey:["feed-head",a],queryFn:()=>{const w=new URLSearchParams(a);return w.set("limit","1"),w.set("offset","0"),ge.consolidatedFeed(w.toString())},enabled:e.enabled??!0,refetchInterval:6e4,refetchIntervalInBackground:!1,staleTime:3e4}),i=((m=(p=o.data)==null?void 0:p.items[0])==null?void 0:m.id)??null,u=((g=o.data)==null?void 0:g.total)??0;return{hasNew:e.feedSettled&&i!=null&&(e.loadedLatestId==null||i!==e.loadedLatestId||u>e.loadedTotal),refresh:()=>{s.invalidateQueries({queryKey:["consolidated-feed"]}),s.invalidateQueries({queryKey:["feed-head"]})}}}function U1(e){if(e.kind==="claude_review")return{color:"#8957e5",label:"Claude Review"};if(e.kind==="review_submitted"&&e.reviewState!=null)return{color:K1[e.reviewState].color,label:`Review: ${H1[e.reviewState]}`};const s=lh[e.kind];return{color:(s==null?void 0:s.color)??"#6b7280",label:(s==null?void 0:s.label)??e.kind}}const K1={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"}},H1={approved:"Approved",changes_requested:"Request Changes",commented:"Comment",dismissed:"Dismissed",pending:"Pending"},W1={APPROVE:{label:"approve",color:"#22c55e"},REQUEST_CHANGES:{label:"request changes",color:"#ef4444"},COMMENT:{label:"comment",color:"#9ca3af"}};function V1(e,s){const a=ih(e);if(a)return{userId:(e==null?void 0:e.id)??null,kind:a.kind,label:a.label,color:a.color};if(e){const o=s.get(e.id);if(o&&o.automated&&o.kind!=null)return{userId:e.id,kind:o.kind,label:o.label,color:an(o.kind).color}}return null}function Rm(e){for(let s=(e==null?void 0:e.parentElement)??null;s;s=s.parentElement){const a=getComputedStyle(s).overflowY;if((a==="auto"||a==="scroll"||a==="overlay")&&s.scrollHeight>s.clientHeight)return s}return null}function su({repoId:e}){var bn;const s=te(re=>re.userIds),a=te(re=>re.excludeBots),o=te(re=>re.allowedBotIds),i=te(re=>re.feedMyTurnOnly),u=te(re=>re.toggleFeedMyTurnOnly),d=te(re=>re.feedClaudeOnly),p=te(re=>re.toggleFeedClaudeOnly),m=te(re=>re.feedBotLens),g=te(re=>re.cycleFeedBotLens),w=te(re=>re.showThreadInChanges),v=te(re=>re.selectPr),y=te(re=>re.showPrComment),j=te(re=>re.openClaudeReview),R=te(re=>re.focusEventInTab),P=De(re=>re.openPrDetailTab),E=De(re=>re.openPrFocusTab),{claudeReview:S}=yn(),{data:T}=xh(),N=yh(),b=x.useMemo(()=>{const re=new Map;for(const He of(T==null?void 0:T.reviewers)??[])He.classification.automated&&He.classification.kind!=null&&re.set(He.userId,He.classification);return re},[T]),I=N.isPending?((bn=N.variables)==null?void 0:bn.userId)??null:null,$=re=>{N.mutate({userId:re,body:{automated:!1}})},L=De(re=>re.activityFlashItemId),q=De(re=>re.clearActivityFlashItem),Q=e!=null?[e]:null,_=D1(),Y=x.useRef(!1);x.useEffect(()=>{e==null&&!Y.current&&(Y.current=!0,_.mutate())},[e,_]);const{items:X,users:B,total:O,latestId:H,isLoading:ee,hasMore:ce,loadMore:C,isFetchingMore:F}=z1({repoIds:Q,userIds:s,excludeBots:a,allowedBotIds:o}),K=x.useRef(null),{hasNew:ae,refresh:ne}=q1({repoIds:Q,userIds:s,excludeBots:a,allowedBotIds:o,loadedLatestId:H,loadedTotal:O,feedSettled:!ee}),Pe=()=>{var re;ne(),(re=Rm(K.current))==null||re.scrollTo({top:0,behavior:"smooth"})},se=x.useMemo(()=>ln(B),[B]),Z=X.filter(re=>re.isMyTurn).length,je=X.filter(re=>re.kind==="claude_review").length,We=re=>{var He;return re.actorId!=null&&(((He=se.get(re.actorId))==null?void 0:He.isBot)??!1)},st=X.filter(We).length,Pt=i?X.filter(re=>re.isMyTurn):d?X.filter(re=>re.kind==="claude_review"):X,Lt=m==="hide"?Pt.filter(re=>!We(re)):m==="only"?Pt.filter(We):Pt,vn=x.useRef(new Map),[Le,Mn]=x.useState(null);x.useEffect(()=>{if(L==null)return;const re=L,He=requestAnimationFrame(()=>{const it=vn.current.get(re);it&&(it.scrollIntoView({block:"center",behavior:"smooth"}),Mn(re),window.setTimeout(()=>Mn(at=>at===re?null:at),1800)),q()});return()=>cancelAnimationFrame(He)},[L,q]);const Fn=x.useRef(null),_t=x.useRef(!1),Ln=x.useRef(()=>{});Ln.current=()=>{ce&&!F&&X.length>0&&C()};const Kt=ce&&X.length>0;x.useEffect(()=>{const re=Fn.current;if(!re)return;const He=new IntersectionObserver(it=>{var at;_t.current=((at=it[0])==null?void 0:at.isIntersecting)??!1,_t.current&&Ln.current()},{root:Rm(re),rootMargin:"0px 0px 600px 0px"});return He.observe(re),()=>He.disconnect()},[Kt]),x.useEffect(()=>{!F&&_t.current&&Ln.current()},[F,X.length,ce]);const pr=(re,He)=>({id:He,number:re.prNumber??0,title:re.prTitle??`#${re.prNumber??""}`,repoFullName:re.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null});function Fr(re){const He=re.prId;if(He==null)return;const it=pr(re,He),at={fromActivity:!0,returnItemId:re.id};if(re.kind==="claude_review"){j(it,at);return}P(it,at),re.threadId!=null?w(He,re.threadId):re.commentId!=null?y(He,re.commentId):v(He)}function Xn(re,He){const it=re.prId;it!=null&&(P(pr(re,it),{fromActivity:!0,returnItemId:re.id}),w(it,He))}function _n(re){const He=re.prId;if(He!=null&&(E(pr(re,He),{fromActivity:!0,returnItemId:re.id}),re.kind!=="claude_review")){const it=re.threadId??re.commentId??null,at=re.kind==="review_comment"?re.threadId:null;R(He,re.occurredAt,{type:re.kind,refId:it},at)}}return n.jsxs("div",{className:"space-y-3","data-testid":"feed-view",ref:K,children:[ae&&n.jsx("div",{className:"sticky top-0 z-10",children:n.jsxs("button",{type:"button",onClick:Pe,"data-testid":"feed-new-activity",className:"flex w-full items-center justify-center gap-2 rounded-full border border-sky-400 bg-sky-50 px-3 py-1.5 text-xs font-semibold text-sky-700 shadow-sm transition-colors hover:bg-sky-100 dark:border-sky-500/60 dark:bg-sky-950/50 dark:text-sky-300 dark:hover:bg-sky-900/60",children:[n.jsx("span",{"aria-hidden":"true",children:"↑"})," New activity — Refresh"]})}),n.jsxs("div",{className:"flex items-center gap-2 px-0.5",children:[n.jsxs("button",{type:"button",onClick:u,"aria-pressed":i,className:`flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${i?"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 (My Turn)",children:[n.jsx("span",{"aria-hidden":"true",children:"★"})," My Turn",Z>0&&n.jsx("span",{className:"tabular-nums opacity-70",children:Z})]}),S&&n.jsxs("button",{type:"button",onClick:p,"aria-pressed":d,className:`flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${d?"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:[n.jsx("span",{"aria-hidden":"true",children:"✨"})," Claude Reviews",je>0&&n.jsx("span",{className:"tabular-nums opacity-70",children:je})]}),st>0&&n.jsxs("button",{type:"button",onClick:g,"aria-pressed":m!=="all",className:`flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${m!=="all"?"border-sky-400 bg-sky-50 text-sky-700 dark:border-sky-500/60 dark:bg-sky-950/30 dark:text-sky-300":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:"Tame the bot firehose: click to cycle all activity → hide bot noise → bot activity only",children:[n.jsx("span",{"aria-hidden":"true",children:"🤖"}),m==="hide"?"Bots hidden":m==="only"?"Bots only":"Bots",m==="all"&&n.jsx("span",{className:"tabular-nums opacity-70",children:st})]}),X.length>0&&n.jsxs("span",{className:"text-[11px] text-gray-400",children:[Lt.length," of ",X.length]})]}),X.length===0?n.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."}):Lt.length===0?n.jsx("div",{className:"flex h-32 items-center justify-center text-sm text-gray-400",children:d?"No Claude Reviews in this window.":m==="only"?"No bot activity in this window.":m==="hide"?"Only bot activity here — nothing from humans in this window.":"Nothing needs your attention right now."}):n.jsx("ul",{className:"space-y-2",children:Lt.map(re=>{const He=re.actorId!=null?se.get(re.actorId):void 0,it=re.mergedById!=null?se.get(re.mergedById):void 0,at=it!=null||re.mergedById!=null?ft(it,re.mergedById):null,On=(re.reviewers??[]).map(on=>ft(se.get(on.userId),on.userId)),wn=V1(He,b);return n.jsx(Z1,{item:re,actorUser:He,automatedTag:wn,onNotBot:$,overridePending:(wn==null?void 0:wn.userId)!=null&&I===wn.userId,mergedByLabel:at,reviewerLabels:On,usersById:se,flash:Le===re.id,innerRef:on=>{on?vn.current.set(re.id,on):vn.current.delete(re.id)},onOpen:()=>Fr(re),onOpenThread:on=>Xn(re,on),onFocus:()=>_n(re)},re.id)})}),Kt&&n.jsx("div",{ref:Fn,className:"flex justify-center pt-1",children:F?n.jsxs("span",{className:"flex items-center gap-2 py-1.5 text-xs text-gray-400",children:[n.jsx("span",{className:"h-3 w-3 animate-spin rounded-full border-2 border-gray-300 border-t-transparent dark:border-gray-600 dark:border-t-transparent"}),"Loading more…"]}):n.jsx("button",{type:"button",onClick:()=>void C(),className:"rounded-full border border-gray-300 px-4 py-1.5 text-xs font-medium text-gray-600 hover:border-gray-400 hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500 dark:hover:bg-gray-800/50",children:"Load more"})})]})}function Q1({item:e}){const{data:s,isLoading:a}=qu(e.threadId),{data:o}=$n(),i=x.useMemo(()=>ln(o),[o]),u=x.useMemo(()=>{if(!s||e.actorId==null)return null;const p=new Date(e.occurredAt).getTime();let m=null;for(const g of s.comments){if(g.authorId!==e.actorId)continue;const w=Math.abs(new Date(g.createdAt).getTime()-p);(m==null||w<m.dist)&&(m={id:g.id,dist:w})}return(m==null?void 0:m.id)??null},[s,e.actorId,e.occurredAt]),d=e.prNumber!=null?`https://github.com/${e.repoFullName}/pull/${e.prNumber}`:"";return a?n.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Loading conversation…"}):s?n.jsx(gl,{thread:s,usersById:i,prUrl:d,repoId:e.repoId,highlightCommentId:u}):n.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Couldn’t load this conversation."})}function G1({prId:e}){var i;const{data:s,isLoading:a}=Zo(e);if(a)return n.jsx("div",{className:"mt-1 px-1 text-xs text-gray-400",children:"Loading summary…"});const o=(i=s==null?void 0:s.body)==null?void 0:i.trim();return o?n.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:n.jsx(cr,{children:o})}):n.jsx("div",{className:"mt-1 px-1 text-xs text-gray-400",children:"No description."})}function Y1({item:e}){const[s,a]=x.useState(!1),o=e.ciStatus!=null&&e.ciStatus!=="unknown"?ur[e.ciStatus]:null,i=e.changedFilesCount,u=e.prId;return n.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[(o!=null||i!=null)&&n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-gray-500 dark:text-gray-400",children:[o!=null&&n.jsxs("span",{className:"inline-flex items-center gap-1 font-medium",style:{color:o.color},children:[n.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-2 rounded-full",style:{background:o.color}}),o.label]}),i!=null&&n.jsxs("span",{children:[i," ",i===1?"file":"files"," changed"]})]}),u!=null&&n.jsxs("div",{onClick:d=>d.stopPropagation(),children:[n.jsx("button",{type:"button",onClick:()=>a(d=>!d),className:"text-[11px] font-medium text-sky-600 hover:underline dark:text-sky-400",children:s?"Hide summary":"Show summary"}),s&&n.jsx(G1,{prId:u})]})]})}function X1({thread:e,author:s,onOpen:a}){const o=jt[e.derivedState],i=e.path.split("/").pop()??e.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:a,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:[n.jsxs("span",{className:"flex items-center gap-1.5 text-[11px]",children:[n.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-2 shrink-0 rounded-full",style:{background:o.color}}),n.jsxs("code",{className:"truncate font-mono text-gray-600 group-hover/th:text-sky-600 dark:text-gray-300",children:[i,e.line!=null?`:${e.line}`:""]}),n.jsx("span",{className:"shrink-0 text-gray-400",children:o.label.toLowerCase()})]}),e.excerpt.trim()!==""&&n.jsxs("span",{className:"mt-0.5 block truncate text-xs italic text-gray-500 dark:text-gray-400",children:[s!=null?`${ft(s,e.authorId)}: `:"","“",e.excerpt,"”"]})]})})}const J1=160;function Z1({item:e,actorUser:s,automatedTag:a,onNotBot:o,overridePending:i,mergedByLabel:u,reviewerLabels:d,usersById:p,flash:m,innerRef:g,onOpen:w,onOpenThread:v,onFocus:y}){const j=U1(e),R=e.isMyTurn,P=e.kind==="claude_review",E=e.kind==="pr_merged",S=P?"Claude":e.actorId==null&&e.kind==="commit_pushed"?"A contributor":ft(s,e.actorId),T=e.prNumber!=null?`#${e.prNumber}${e.prTitle!=null?` ${e.prTitle}`:""}`:"",N=e.claudeVerdict!=null?W1[e.claudeVerdict]:null,b=e.affectedThreads??[],I=e.myTurnReasons[0],$=e.kind==="review_comment"&&e.threadId!=null,L=e.kind==="pr_comment"&&e.prId!=null,q=e.kind==="pr_opened",[Q,_]=x.useState(!1),Y=E&&u!=null&&e.mergedById!==e.actorId,X=E&&d.length>0,B=x.useRef(null),O=x.useRef(null),[H,ee]=x.useState(!1),[ce,C]=x.useState(!1),F=e.content!=null&&e.content.trim()!=="";x.useEffect(()=>{const ae=B.current,ne=O.current;if(!ae||!ne)return;const Pe=()=>{H||C(ae.scrollHeight>ae.clientHeight+4)};Pe();const se=new ResizeObserver(Pe);return se.observe(ne),()=>se.disconnect()},[e.content,H]);const K=ae=>{ae.target.closest("a,button")||w()};return n.jsx("li",{ref:g,children:n.jsxs("article",{onClick:K,className:`cursor-pointer rounded-md border p-2.5 text-sm transition-colors ${m?"border-sky-400 ring-2 ring-sky-400/60 dark:border-sky-500":R?"border-yellow-400 bg-yellow-50/40 dark:border-yellow-500/50 dark:bg-yellow-950/15":P?"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:[n.jsxs("div",{className:"flex items-center gap-2",children:[e.prId!=null&&n.jsx("button",{type:"button",onClick:ae=>{ae.stopPropagation(),y()},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:n.jsx(Jo,{size:13})}),n.jsx("span",{className:"shrink-0 text-[11px] text-gray-400",title:Ra(e.occurredAt),children:St(e.occurredAt)}),n.jsx(ht,{user:s,size:20}),n.jsx("span",{className:"truncate font-medium text-gray-800 dark:text-gray-100",children:S}),a&&n.jsxs("span",{className:"group/bot inline-flex shrink-0 items-center gap-1",children:[n.jsxs("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium",style:{color:a.color,background:`${a.color}1a`},title:`${a.label} — an automated reviewer Pierre triages`,children:[n.jsx("span",{"aria-hidden":!0,children:"🤖"}),a.label]}),a.userId!=null&&n.jsx("button",{type:"button",onClick:ae=>{ae.stopPropagation(),a.userId!=null&&o(a.userId)},disabled:i,className:"text-[9px] text-gray-400 underline underline-offset-2 opacity-0 transition-opacity hover:text-gray-600 disabled:opacity-40 group-hover/bot:opacity-100 dark:hover:text-gray-200",title:"Not a bot? Reclassify this reviewer as human",children:i?"saving…":"not a bot?"})]}),n.jsx("span",{className:"inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium",style:{color:j.color,background:j.color+"1a"},children:j.label}),N!=null&&n.jsx("span",{className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",style:{color:N.color,background:N.color+"1a"},children:N.label}),R&&n.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:"My Turn"}),R&&I!=null&&n.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(ae=>Mp[ae].title).join(" · "),children:Mp[I].label})]}),n.jsxs("div",{className:"mt-1 flex items-baseline gap-1.5 text-xs",children:[n.jsx("span",{className:"shrink-0 text-gray-400",children:e.repoFullName}),T!==""&&n.jsx("button",{type:"button",onClick:w,className:"min-w-0 truncate font-medium text-gray-700 hover:text-sky-600 hover:underline dark:text-gray-200",children:T}),e.path!=null&&n.jsxs("span",{className:"shrink-0 text-gray-400",children:["· ",e.path.split("/").pop()]})]}),q&&n.jsx(Y1,{item:e}),F&&!$&&n.jsxs("div",{className:"mt-1.5 rounded bg-gray-50 px-2 py-1.5 text-sm dark:bg-gray-900/50",children:[n.jsx("div",{ref:B,className:H?"":"overflow-hidden",style:H?void 0:{maxHeight:J1},children:n.jsx("div",{ref:O,children:n.jsx(cr,{children:e.content})})}),(ce||H)&&n.jsx("button",{type:"button",onClick:()=>ee(ae=>!ae),className:"mt-1 text-[11px] font-medium text-sky-600 hover:underline dark:text-sky-400",children:H?"Show less":"Show more"})]}),e.mergedComments.length>0&&n.jsx("div",{className:"mt-1.5 space-y-1.5",children:e.mergedComments.map(ae=>n.jsxs("div",{className:"rounded bg-gray-50 px-2 py-1.5 text-sm dark:bg-gray-900/50",children:[n.jsx("div",{className:"mb-0.5 text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"Also commented"}),n.jsx("div",{className:"max-h-72 overflow-auto",children:n.jsx(cr,{children:ae.content})})]},ae.commentId))}),b.length>0&&n.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[e.changeSummary!=null&&n.jsx("div",{className:"text-[11px] font-medium text-gray-500 dark:text-gray-400",children:e.changeSummary}),n.jsx("ul",{className:"space-y-1.5",children:b.map(ae=>n.jsx(X1,{thread:ae,author:ae.authorId!=null?p.get(ae.authorId):void 0,onOpen:()=>v(ae.threadId)},ae.threadId))})]}),(Y||X)&&n.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:[Y&&n.jsxs("span",{children:["Merged by ",n.jsx("span",{className:"font-medium",children:u})]}),X&&n.jsxs("span",{children:["Reviewed by ",n.jsx("span",{className:"font-medium",children:d.join(", ")})]})]}),$&&n.jsx("div",{className:"mt-1.5",onClick:ae=>ae.stopPropagation(),children:n.jsx(Q1,{item:e})}),L&&e.prId!=null&&n.jsx("div",{className:"mt-1.5",children:Q?n.jsx("div",{onClick:ae=>ae.stopPropagation(),children:n.jsx(Ku,{prId:e.prId,initialBody:ch(e.content,(s==null?void 0:s.githubLogin)??null),autoFocus:!0,onCancel:()=>_(!1),onDone:()=>_(!1)})}):n.jsx("button",{type:"button",onClick:ae=>{ae.stopPropagation(),_(!0)},className:"text-[11px] font-medium text-sky-600 hover:underline dark:text-sky-400",children:"Reply"})})]})})}function ek(e){return qe({queryKey:["team-insights"],queryFn:()=>ge.teamInsights(),enabled:e,refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4})}function tk(){const e=yn();return e.teamInsights||e.activityDigest||e.slackDigest||e.issueLinks}function h0(e){return qe({queryKey:["pro-settings"],queryFn:ge.proSettings,enabled:e,staleTime:6e4})}function nk(){const e=Be();return Ue({mutationFn:s=>ge.updateProSettings(s),onSuccess:(s,a)=>{e.setQueryData(["pro-settings"],s),a.issue&&(e.invalidateQueries({queryKey:["pr"]}),e.invalidateQueries({queryKey:["thread"]})),a.sprint&&(e.invalidateQueries({queryKey:["team-insights"]}),e.invalidateQueries({queryKey:["team-metrics-detail"]}),e.invalidateQueries({queryKey:["sprint-report"]}))}})}const rk=[{key:"rolling_7",label:"7d"},{key:"rolling_14",label:"14d"},{key:"rolling_30",label:"30d"},{key:"sprint",label:"Sprint"}],sk={keep:{label:"Keep",className:"bg-green-500/10 text-green-700 dark:text-green-300 border border-green-500/30",title:"Healthy signal-to-noise — worth keeping on."},tune:{label:"Tune",className:"bg-amber-500/10 text-amber-700 dark:text-amber-300 border border-amber-500/30",title:"A lot of comments go untouched — consider muting the noisy paths/severities."},kill:{label:"Kill",className:"bg-red-500/10 text-red-700 dark:text-red-300 border border-red-500/30",title:"High volume, low acted-on, high untouched — probably not paying for itself."}};function Su(e){return e==null?"—":`${Math.round(e)}%`}function ak(e){return e==null?"—":`$${e.toFixed(2)}`}function lk(e,s){return e.map(a=>{const o=s.get(a.kind)??null,i=o!=null&&a.actedOn>0?o/a.actedOn:null;return{...a,costMonthlyUsd:o,costPerActedOnUsd:i}})}function ok({vendors:e}){const{labels:s,series:a}=x.useMemo(()=>{const o=new Set;for(const d of e)for(const p of d.trend)o.add(p.weekStart);const i=Array.from(o).sort().slice(-12),u=e.filter(d=>d.trend.length>0).map(d=>{const p=new Map(d.trend.map(m=>[m.weekStart,m.threads]));return{key:d.kind,label:d.label,color:an(d.kind).color,values:i.map(m=>p.get(m)??null)}});return{labels:i,series:u}},[e]);return s.length<2||a.length===0?n.jsx(wt,{label:"Not enough weekly history yet"}):n.jsx(Os,{labels:s,series:a,height:140,curved:!0})}function ik({suggestions:e}){var a;const s=Uu();return e.length===0?null:n.jsxs("div",{className:"rounded-lg border border-amber-300/50 bg-amber-50/50 p-3 dark:border-amber-500/30 dark:bg-amber-950/20",children:[n.jsx("div",{className:"mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-amber-700 dark:text-amber-300",children:"Tuning suggestions"}),n.jsx("ul",{className:"space-y-1.5",children:e.map((o,i)=>{const u=an(o.vendorKind),d=s.isPending;return n.jsxs("li",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]",children:[n.jsxs("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium",style:{color:u.color,background:`${u.color}1a`},children:["🤖 ",u.label]}),n.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:o.rationale}),n.jsx("button",{type:"button",onClick:()=>s.mutate({vendorKind:o.vendorKind,pathGlob:o.pathGlob,severity:o.severity,action:"hide"}),disabled:d,className:"ml-auto shrink-0 rounded border border-amber-400 px-1.5 py-0.5 font-medium text-amber-700 hover:bg-amber-100 disabled:opacity-50 dark:border-amber-600 dark:text-amber-200 dark:hover:bg-amber-900/30",title:"Hide this vendor's matching threads from the feed",children:d?"Adding…":"Create mute rule"})]},`${o.vendorKind}:${o.pathGlob??"*"}:${o.severity??"*"}:${i}`)})}),s.isError&&n.jsx("div",{className:"mt-1 text-[11px] text-red-500",children:((a=s.error)==null?void 0:a.message)??"Couldn’t create the rule."})]})}function ck({vendors:e,onOpenVendor:s}){return n.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-200 dark:border-gray-800",children:n.jsxs("table",{className:"w-full min-w-[680px] border-collapse text-[11px]",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-gray-200 text-left text-gray-500 dark:border-gray-800 dark:text-gray-400",children:[n.jsx("th",{className:"px-2 py-1.5 font-medium",children:"Vendor"}),n.jsx("th",{className:"px-2 py-1.5 text-right font-medium",children:"Threads"}),n.jsx("th",{className:"px-2 py-1.5 text-right font-medium",children:"Comments"}),n.jsx("th",{className:"px-2 py-1.5 text-right font-medium",title:"A later commit likely addressed the thread, it was resolved, or a human replied/resolved after the bot",children:"Acted on"}),n.jsx("th",{className:"px-2 py-1.5 text-right font-medium",title:"Threads with no reply and no follow-up commit",children:"Untouched"}),n.jsx("th",{className:"px-2 py-1.5 text-right font-medium",title:"Untouched threads' oldest age",children:"Oldest"}),n.jsx("th",{className:"px-2 py-1.5 text-right font-medium",title:"Low-value / untouched share — the noise floor",children:"Noise"}),n.jsx("th",{className:"px-2 py-1.5 text-right font-medium",title:"Monthly vendor cost ÷ acted-on threads (from Pro settings)",children:"$/acted-on"}),n.jsx("th",{className:"px-2 py-1.5 text-center font-medium",children:"Verdict"})]})}),n.jsx("tbody",{children:e.map(a=>{const o=an(a.kind),i=sk[a.verdict];return n.jsxs("tr",{className:"border-b border-gray-100 last:border-0 dark:border-gray-800/60",children:[n.jsxs("td",{className:"px-2 py-1.5",children:[n.jsxs("button",{type:"button",onClick:()=>s(a.kind),title:"View this bot's PRs",className:"inline-flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 font-medium hover:underline",style:{color:o.color,background:`${o.color}1a`},children:["🤖 ",a.label]}),a.reviewers>1&&n.jsxs("span",{className:"ml-1 text-gray-400",children:["×",a.reviewers]})]}),n.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums",children:a.threads}),n.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums text-gray-500",children:a.comments}),n.jsxs("td",{className:"px-2 py-1.5 text-right tabular-nums",children:[n.jsx("span",{className:"text-gray-700 dark:text-gray-200",children:a.actedOn}),n.jsx("span",{className:"ml-1 text-gray-400",children:Su(a.actedOnPct)})]}),n.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums",children:n.jsx("span",{className:a.untouched>0?"text-amber-600 dark:text-amber-400":"text-gray-400",children:a.untouched})}),n.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums text-gray-500",children:a.oldestUntouchedDays!=null?`${a.oldestUntouchedDays}d`:"—"}),n.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums text-gray-500",children:Su(a.noiseRatioPct)}),n.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums text-gray-500",title:a.costMonthlyUsd!=null?`$${a.costMonthlyUsd}/mo`:"Set a monthly cost in Settings → Review bots",children:ak(a.costPerActedOnUsd)}),n.jsx("td",{className:"px-2 py-1.5 text-center",children:n.jsx("span",{className:`inline-block rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide ${i.className}`,title:i.title,children:i.label})})]},a.kind)})})]})})}function uk(){const e=te(v=>v.botAnalyticsWindow),s=te(v=>v.setBotAnalyticsWindow),a=te(v=>v.openBotPrsDetail),{data:o,isLoading:i,isError:u}=gh(e),{data:d}=h0(!0),p=x.useMemo(()=>new Map(((d==null?void 0:d.bots.cost)??[]).map(v=>[v.kind,v.monthlyUsd])),[d==null?void 0:d.bots.cost]),m=x.useMemo(()=>o?lk(o.vendors,p):[],[o,p]),g=n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("h3",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"Review-bot ROI"}),n.jsx("span",{className:"rounded bg-violet-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:"Pro"}),n.jsx("div",{className:"ml-auto inline-flex overflow-hidden rounded border border-gray-300 dark:border-gray-700",children:rk.map(v=>n.jsx("button",{type:"button",onClick:()=>s(v.key),className:`px-2 py-0.5 text-[11px] font-medium ${e===v.key?"bg-violet-500/15 text-violet-700 dark:text-violet-300":"text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800"}`,children:v.label},v.key))})]});let w;if(i)w=n.jsx("div",{className:"h-28 animate-pulse rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/40"});else if(u)w=n.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load bot analytics."});else if(!o||m.length===0)w=n.jsxs("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:["No automated-reviewer activity in this window.",n.jsx("div",{className:"mt-1 text-[11px]",children:"When review bots (CodeRabbit, Copilot, in-house AI…) comment on your PRs, their signal-to-noise lands here."})]});else{const v=o.totals;w=n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:[n.jsx("span",{className:"font-semibold tabular-nums text-gray-700 dark:text-gray-200",children:v.threads})," ","bot thread",v.threads===1?"":"s"," · ",v.comments," comment",v.comments===1?"":"s"," ·"," ",n.jsx("span",{className:"tabular-nums",children:Su(v.actedOnPct)})," acted on ·"," ",n.jsx("span",{className:"tabular-nums text-amber-600 dark:text-amber-400",children:v.untouched})," ","untouched ·"," ",n.jsxs("span",{title:"PRs whose only reviews/comments came from bots — no human review or comment since they opened",className:"cursor-help",children:[n.jsx("b",{className:"tabular-nums text-gray-700 dark:text-gray-200",children:v.botOnlyPrs})," ","bot-only PR",v.botOnlyPrs===1?"":"s"]})]}),n.jsx(ck,{vendors:m,onOpenVendor:a}),n.jsx(Et,{title:"Weekly thread volume",note:"last 12 weeks",children:n.jsx(ok,{vendors:m})}),n.jsx(ik,{suggestions:o.suggestions}),n.jsx("div",{className:"text-[11px] text-gray-400",children:"“Acted on” = a later commit likely addressed the thread, it was resolved, or a human replied/resolved after the bot (approximate). Verdicts + cost are deterministic — no AI. Set per-vendor monthly cost in Settings → Review bots to see $/acted-on."})]})}return n.jsxs("div",{className:"space-y-2","data-testid":"bot-roi-panel",children:[g,w]})}function dk(e){return qe({queryKey:["retro-report"],queryFn:ge.retroReport,enabled:e,staleTime:6e4})}const fk=5e3;function pk(){const e=Be(),[s,a]=x.useState(null);x.useEffect(()=>{if(s==null)return;const i=window.setTimeout(()=>a(null),fk);return()=>window.clearTimeout(i)},[s]);const o=Ue({mutationFn:ge.refreshRetroReport,onSuccess:i=>{var u;e.setQueryData(["retro-report"],i),e.invalidateQueries({queryKey:["ai-usage"]}),a(i.creditsExhausted?"Out of AI credits this month — summaries resume on the 1st.":i.throttled&&((u=i.report)!=null&&u.stale)?"Refreshed moments ago — showing the latest. Try again shortly.":null)}});return Object.assign(o,{notice:s})}function mk(e){return{id:e.prId,number:e.prNumber,title:e.title??`#${e.prNumber}`,repoFullName:e.repoFullName,authorLogin:e.authorLogin,authorDisplayName:null,authorAvatarUrl:null}}function Im(e){const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function hk(){return n.jsxs("div",{className:"space-y-1.5 py-0.5","aria-hidden":"true",children:[n.jsx("div",{className:"digest-skeleton-line h-3.5",style:{width:"52%"}}),["94%","88%","96%","72%","84%","68%","90%"].map((e,s)=>n.jsx("div",{className:"digest-skeleton-line h-3",style:{width:e}},s))]})}function gk(){var w,v;const{activityDigest:e}=yn(),s=De(y=>y.openPrDetailTab),{data:a,isLoading:o}=dk(e),i=pk(),u=ci(e),d=((w=u.data)==null?void 0:w.allowanceCredits)!=null&&(u.data.remainingCredits??0)<=0;if(!e)return null;const p=(a==null?void 0:a.report)??null,m=i.isPending,g=p!=null?`${Im(p.window.from)} – ${Im(p.window.to)}`:null;return n.jsx("div",{className:"mx-auto max-w-3xl p-4",children:n.jsxs("div",{className:"rounded-lg border border-violet-200 bg-violet-50/40 p-4 dark:border-violet-900/60 dark:bg-violet-950/20",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("span",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:[n.jsx("span",{"aria-hidden":"true",children:"✨"})," Retro"]}),n.jsx("span",{className:"shrink-0 rounded bg-violet-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:"Pro"}),g!=null&&n.jsxs("span",{className:"text-xs text-gray-400",children:["· ",g]}),n.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-gray-400",children:[p!=null&&n.jsxs("span",{title:p.model,children:["Haiku",p.stale?" · stale":""]}),p==null?n.jsx("button",{type:"button",onClick:()=>i.mutate(),disabled:m||d,className:"flex items-center gap-0.5 rounded border border-violet-300 px-1.5 py-0.5 font-medium text-violet-600 hover:border-violet-400 disabled:opacity-50 dark:border-violet-800 dark:text-violet-300 dark:hover:border-violet-600",title:d?"Out of AI credits — resets next month":"Generate a retrospective of the sprint window (runs the Haiku model)",children:d?"Out of credits":m?"Generating…":"Generate"}):p.stale&&n.jsxs("button",{type:"button",onClick:()=>i.mutate(),disabled:m||d,className:"flex items-center gap-0.5 rounded border border-violet-300 px-1.5 py-0.5 font-medium text-violet-600 hover:border-violet-400 disabled:opacity-50 dark:border-violet-800 dark:text-violet-300 dark:hover:border-violet-600",title:d?"Out of AI credits — resets next month":"Regenerate — the window has more activity since this was written (runs the Haiku model)",children:[n.jsx("span",{"aria-hidden":"true",children:"↻"}),d?"Out of credits":m?"Regenerating…":"Regenerate"]})]})]}),n.jsxs("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:["A retrospective of the period: what shipped and what it did, review-thread resolutions, CI failures & root causes, recurring themes, tone, and follow-ups. The window follows your ",n.jsx("span",{className:"font-medium",children:"Sprint"})," setting (sprint-to-date / 7 / 14 days)."]}),i.isError&&n.jsx("div",{className:"mt-2 text-[11px] text-red-500",children:((v=i.error)==null?void 0:v.message)??"Couldn’t generate the retro."}),!i.isError&&i.notice&&n.jsx("div",{className:"mt-2 text-[11px] text-gray-400",children:i.notice}),d&&n.jsx("div",{className:"mt-2 text-[11px] text-amber-600 dark:text-amber-400",children:"Out of AI credits this month — summaries resume on the 1st. Existing retros still show."}),n.jsx("div",{className:"mt-3",children:m?n.jsx(hk,{}):o?n.jsx("div",{className:"h-24 animate-pulse rounded bg-violet-500/5"}):p?n.jsxs("div",{className:"digest-fade-in",children:[n.jsx(Xu,{markdown:p.summary,prRefs:p.prRefs,onOpenPr:y=>s(mk(y),{fromActivity:!0})}),n.jsxs("div",{className:"mt-2 text-[10px] text-gray-400",children:["Generated ",new Date(p.generatedAt).toLocaleString()]})]},p.generatedAt):n.jsxs("div",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:["Tells the story of the past period — what merged, which review threads got resolved and how quickly, why CI failed, the themes that kept coming up, and what followed. Click ",n.jsx("span",{className:"font-medium",children:"Generate"})," above."]})})]})})}function xk(e){return qe({queryKey:["sprint-report"],queryFn:ge.sprintReport,enabled:e,staleTime:6e4})}const yk=5e3;function vk(){const e=Be(),[s,a]=x.useState(null);x.useEffect(()=>{if(s==null)return;const i=window.setTimeout(()=>a(null),yk);return()=>window.clearTimeout(i)},[s]);const o=Ue({mutationFn:ge.refreshSprintReport,onSuccess:i=>{var u;e.setQueryData(["sprint-report"],i),e.invalidateQueries({queryKey:["ai-usage"]}),a(i.creditsExhausted?"Out of AI credits this month — summaries resume on the 1st.":i.throttled&&((u=i.report)!=null&&u.stale)?"Refreshed moments ago — showing the latest. Try again shortly.":null)}});return Object.assign(o,{notice:s})}function bk({digests:e,isLoading:s,anyWatched:a,refreshingRepoIds:o,onRegenerateRepo:i,outOfCredits:u=!1,embedded:d=!1}){const{activityDigest:p}=yn(),{data:m}=Mr(),g=wm(R=>R.expanded),w=wm(R=>R.toggle),v=o0(),y=x.useMemo(()=>(m??[]).filter(R=>R.inboxWatch),[m]),j=x.useMemo(()=>new Map(e.map(R=>[R.repoId,R])),[e]);return p?n.jsxs("div",{className:"space-y-2",children:[!d&&n.jsx("div",{className:"flex items-center gap-2 px-0.5",children:n.jsxs("span",{className:"flex items-center gap-1 text-[11px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:[n.jsx("span",{"aria-hidden":"true",children:"✨"})," Repo summaries · watched repos"]})}),!a||y.length===0?n.jsx("p",{className:"px-0.5 text-xs text-gray-400",children:"No watched repos in view — Watch a repo (the eye toggle) to get a summary here."}):s&&e.length===0?n.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"}):n.jsx("div",{className:"space-y-2",children:y.map(R=>{const P=j.get(R.id);return n.jsx(f0,{digest:P,isLoading:!1,title:R.fullName,collapsed:!g.has(R.id),onToggle:()=>w(R.id),onRegenerate:(P==null||P.stale)&&i?()=>i(R.id):void 0,regenerating:o.has(R.id),onOpenPr:v,showProBadge:!1,outOfCredits:u},R.id)})})]}):null}function wk(e){return{id:e.prId,number:e.prNumber,title:e.title??`#${e.prNumber}`,repoFullName:e.repoFullName,authorLogin:e.authorLogin,authorDisplayName:null,authorAvatarUrl:null}}function kk({digests:e,digestsLoading:s=!1,anyWatched:a=!1,refreshingRepoIds:o,onRegenerateRepo:i,onRegenerateAllDigests:u,cascadeBusy:d=!1}){var L,q;const{activityDigest:p}=yn(),m=De(Q=>Q.openPrDetailTab),{data:g,isLoading:w}=xk(p),v=vk(),y=ci(p),j=((L=y.data)==null?void 0:L.allowanceCredits)!=null&&(y.data.remainingCredits??0)<=0,R=Io(Q=>Q.collapsed),P=Io(Q=>Q.setCollapsed),E=Io(Q=>Q.reposOpen),S=Io(Q=>Q.setReposOpen),T=e!==void 0&&a,N=(e==null?void 0:e.length)??0;if(!p)return null;const b=(g==null?void 0:g.report)??null,I=v.isPending||d,$=()=>{v.mutate(),u==null||u()};return n.jsxs("div",{className:"rounded-lg border border-violet-200 bg-violet-50/40 p-3 dark:border-violet-900/60 dark:bg-violet-950/20","data-testid":"sprint-report",children:[n.jsxs("div",{onClick:()=>P(!R),className:"-mx-1 flex cursor-pointer select-none items-center gap-2 rounded px-1 hover:bg-violet-500/5",children:[n.jsxs("button",{type:"button",onClick:Q=>{Q.stopPropagation(),P(!R)},"aria-expanded":!R,className:"flex items-center gap-1.5 text-sm font-semibold text-gray-700 hover:text-gray-900 dark:text-gray-200 dark:hover:text-white",children:[n.jsx("span",{className:"w-3 select-none text-gray-400",children:R?"▸":"▾"}),n.jsx("span",{"aria-hidden":"true",children:"✨"})," Sprint report"]}),n.jsx("span",{className:"shrink-0 rounded bg-violet-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:"Pro"}),n.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-gray-400",children:[b!=null&&n.jsxs("span",{title:b.model,children:["Haiku "," · ",St(b.generatedAt),b.stale?" · stale":""]}),b==null?n.jsx("button",{type:"button",onClick:Q=>{Q.stopPropagation(),$()},disabled:I||j,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:j?"Out of AI credits — resets next month":"Generate the first sprint report from the current Insights, and every watched repo’s summary (runs the Haiku model)",children:j?"Out of credits":I?"Generating…":"Generate"}):b.stale&&n.jsxs("button",{type:"button",onClick:Q=>{Q.stopPropagation(),$()},disabled:I||j,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:j?"Out of AI credits — resets next month":"Regenerate the sprint report and every changed repo summary — the Insights changed since it was written (runs the Haiku model)",children:[n.jsx("span",{"aria-hidden":"true",children:"↻"}),j?"Out of credits":I?"Regenerating…":"Regenerate"]})]})]}),v.isError&&n.jsx("div",{className:"mt-2 text-[11px] text-red-500",children:((q=v.error)==null?void 0:q.message)??"Couldn’t generate the report."}),!v.isError&&v.notice&&n.jsx("div",{className:"mt-2 text-[11px] text-gray-400",children:v.notice}),j&&n.jsx("div",{className:"mt-2 text-[11px] text-amber-600 dark:text-amber-400",children:"Out of AI credits this month — summaries resume on the 1st. Existing reports still show."}),!R&&n.jsx("div",{className:"mt-2",children:I?n.jsx(jk,{}):w?n.jsx("div",{className:"h-16 animate-pulse rounded bg-violet-500/5"}):b?n.jsxs("div",{className:"digest-fade-in",children:[n.jsx(Xu,{markdown:b.summary,prRefs:b.prRefs,onOpenPr:Q=>m(wk(Q),{fromActivity:!0})}),n.jsxs("div",{className:"mt-1.5 text-[10px] text-gray-400",children:["Generated ",new Date(b.generatedAt).toLocaleString()]})]},b.generatedAt):n.jsxs("div",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:["A prioritised, PR-linked summary of what needs attention this sprint — generated from the Insights below. Click"," ",n.jsx("span",{className:"font-medium",children:"Generate"})," above."]})}),!R&&T&&n.jsxs("div",{className:"mt-3 border-t border-violet-200/60 pt-2 dark:border-violet-900/40",children:[n.jsxs("button",{type:"button",onClick:()=>S(!E),className:"flex w-full items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:[n.jsx("span",{className:"w-3 select-none text-gray-400",children:E?"▾":"▸"}),n.jsx("span",{"aria-hidden":"true",children:"✨"})," Repo summaries",n.jsxs("span",{className:"font-normal text-gray-400",children:["· ",N]})]}),E&&n.jsx("div",{className:"mt-2",children:n.jsx(bk,{embedded:!0,digests:e??[],isLoading:s,anyWatched:a,refreshingRepoIds:o??new Set,onRegenerateRepo:i,outOfCredits:j})})]})]})}function jk(){return n.jsxs("div",{className:"space-y-1.5 py-0.5","aria-hidden":"true",children:[n.jsx("div",{className:"digest-skeleton-line h-3.5",style:{width:"58%"}}),["94%","88%","72%","80%","64%"].map((e,s)=>n.jsx("div",{className:"digest-skeleton-line h-3",style:{width:e}},s))]})}function ss({labels:e,series:s,mode:a="grouped",formatY:o=zs,formatValue:i=o,height:u=132,rotateLabels:d=!1}){const[p,m]=yl(),[g,w]=x.useState(null),v=30,y=8,j=8,R=d?40:16,P=e.length,E=Math.max(m-v-y,1),S=u-j-R,T=/^\d{4}-\d{2}-\d{2}T/.test(e[0]??""),N=B=>s.reduce((O,H)=>O+(H.values[B]??0),0),b=Ju(a==="stacked"?Math.max(1,...e.map((B,O)=>N(O))):Math.max(1,...s.flatMap(B=>B.values.map(O=>O??0)))),I=E/Math.max(P,1),$=B=>v+B*I+I*.15,L=I*.7,q=B=>j+S*(1-B/b),Q=j+S,_=B=>{const O=Math.floor((B.nativeEvent.offsetX-v)/I);w(Math.max(0,Math.min(P-1,O)))},Y=B=>{const O=e[B]??"";return T?_s(O):O},X=!T||P<=8;return n.jsxs("div",{children:[n.jsxs("div",{ref:p,className:"relative",style:{height:u},children:[m>0&&n.jsxs("svg",{width:m,height:u,className:"block",children:[[0,b].map(B=>n.jsxs("g",{children:[n.jsx("line",{x1:v,y1:q(B),x2:m-y,y2:q(B),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),n.jsx("text",{x:v-4,y:q(B)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:o(B)})]},B)),g!=null&&n.jsx("rect",{x:v+g*I,y:j,width:I,height:S,className:"text-gray-400/10 dark:text-gray-300/10",fill:"currentColor"}),e.map((B,O)=>{if(a==="stacked"){let ee=0;return s.map(ce=>{const C=ce.values[O]??0;if(C<=0)return null;const F=q(ee+C),K=q(ee)-F;return ee+=C,n.jsx("rect",{x:$(O),y:F,width:L,height:Math.max(K,0),fill:ce.color},`${O}-${ce.key}`)})}const H=L/Math.max(s.length,1);return s.map((ee,ce)=>{const C=ee.values[O]??0;return C<=0?null:n.jsx("rect",{x:$(O)+ce*H,y:q(C),width:Math.max(H-.5,.5),height:Q-q(C),fill:ee.color},`${O}-${ee.key}`)})}),e.map((B,O)=>{if(!(X||O===0||O===P-1))return null;const H=v+O*I+I/2;if(d){const ee=Q+9;return n.jsx("text",{x:H,y:ee,textAnchor:"end",transform:`rotate(-35 ${H} ${ee})`,className:"fill-gray-400 text-[8px]",children:Y(O)},`lbl-${O}`)}return n.jsx("text",{x:H,y:u-4,textAnchor:"middle",className:"fill-gray-400 text-[8px]",children:Y(O)},`lbl-${O}`)}),n.jsx("rect",{x:0,y:0,width:m,height:u,fill:"transparent",onMouseMove:_,onMouseLeave:()=>w(null)})]}),g!=null&&m>0&&n.jsxs(vl,{x:v+g*I+I/2,y:j,width:m,children:[n.jsx("div",{className:"font-medium",children:Y(g)}),s.map(B=>n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-[1px]",style:{background:B.color}}),B.label,": ",i(B.values[g]??0)]},B.key)),a==="stacked"&&s.length>1&&n.jsxs("div",{className:"mt-0.5 border-t border-gray-200 pt-0.5 dark:border-gray-700",children:["total: ",i(N(g))]})]})]}),s.length>1&&n.jsx(ui,{series:s})]})}const Tm=e=>`${Math.round(e)}%`,Nk=e=>String(Math.round(e));function al({label:e,stat:s,format:a,betterWhen:o,sub:i,onActivate:u}){const{value:d,previous:p,lowConfidence:m}=s,g=d!=null&&p!=null?d-p:null,w=g!=null&&g!==0&&g>0==(o==="up"),v=g!=null&&g!==0&&!m;return n.jsxs(Cu,{onActivate:u,children:[n.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wide text-gray-400",children:e}),n.jsx("div",{className:"text-lg font-semibold text-gray-800 dark:text-gray-100",children:d==null?"—":a(d)}),v?n.jsxs("div",{className:`text-[11px] ${w?"text-green-600 dark:text-green-400":"text-red-500 dark:text-red-400"}`,children:[g>0?"▲":"▼"," ",a(Math.abs(g))," ",n.jsx("span",{className:"text-gray-400",children:"vs last"})]}):m?n.jsx("div",{className:"text-[11px] text-gray-400",title:"Too few data points to read a trend yet (small sample)",children:p==null?"building baseline":`was ${a(p)}`}):n.jsx("div",{className:"text-[11px] text-gray-400",children:p==null?i:"no change"}),n.jsx("div",{className:"mt-0.5 text-[10px] text-gray-400",children:i})]})}function Cu({onActivate:e,children:s}){const a="block w-full rounded-lg border border-gray-200 bg-white p-2 text-left dark:border-gray-800 dark:bg-gray-900/40";return e?n.jsx("button",{type:"button",onClick:e,title:"Inspect the PRs behind this metric",className:`${a} cursor-pointer transition hover:border-gray-300 hover:bg-gray-50/70 focus:outline-none focus-visible:ring-2 focus-visible:ring-sky-400 dark:hover:border-gray-600 dark:hover:bg-gray-900/60`,children:s}):n.jsx("div",{className:a,children:s})}function Sk({metrics:e,onOpenMetric:s}){const[a,o]=x.useState(!1),i=e.weekBuckets,u=e.comparisonMode??"rolling_14",d=Math.max(1,Math.min(e.sprintDays,Math.ceil(e.elapsedDays??e.sprintDays))),p=u==="sprint"?`day ${d} of ${e.sprintDays} · vs same point last sprint`:`rolling ${e.sprintDays} days · vs prior ${e.sprintDays} days`,m=E=>E.reduce((S,T)=>S+T,0),g=E=>s?()=>s(E):void 0,w=[{key:"opened",label:"Opened",color:Ke.blue,values:e.throughput.opened},{key:"merged",label:"Merged",color:Ke.green,values:e.throughput.merged}],v=[{key:"lead",label:"Lead time",color:Ke.purple,values:e.leadTimeTrend}],y=[{key:"ci",label:"Merge CI success",color:Ke.green,values:e.ciSuccessTrend}],j=[{key:"recovery",label:"CI recovery",color:Ke.orange,values:e.ciRecoveryTrend}],R=[{key:"failures",label:"Failures",color:Ke.red,values:e.ciFailureReasons.map(E=>E.count)}],P=e.ciFailureReasons.map(E=>E.stage);return n.jsxs("div",{className:"space-y-3 rounded-lg border border-gray-200 bg-gray-50/50 p-3 dark:border-gray-800 dark:bg-gray-900/20","data-testid":"flow-metrics",children:[n.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[n.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-300",children:"Flow metrics"}),n.jsxs("span",{className:"text-[11px] text-gray-400",children:["DORA-ish · ",p,s?" · tap a tile to drill in":""]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-7",children:[n.jsxs(Cu,{onActivate:g("open_prs"),children:[n.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wide text-gray-400",children:"Open PRs"}),n.jsx("div",{className:"text-lg font-semibold text-gray-800 dark:text-gray-100",children:e.openPrs}),n.jsx("div",{className:"text-[11px] text-gray-400",children:"across all repos"}),n.jsx("div",{className:"mt-0.5 text-[10px] text-gray-400",children:"currently open"})]}),n.jsx(al,{label:"Merges",stat:e.merges,format:Nk,betterWhen:"up",sub:"deploy frequency",onActivate:g("merges")}),n.jsx(al,{label:"Lead time",stat:e.leadTimeHours,format:Pn,betterWhen:"down",sub:"open → merge",onActivate:g("lead_time")}),n.jsx(al,{label:"Review latency",stat:e.timeToFirstReviewHours,format:Pn,betterWhen:"down",sub:"to first review",onActivate:g("review_latency")}),n.jsx(al,{label:"Merge CI",stat:e.mergeCiSuccessPct,format:Tm,betterWhen:"up",sub:"green at merge",onActivate:g("merge_ci")}),n.jsx(al,{label:"CI recovery",stat:e.ciRecoveryHours,format:Pn,betterWhen:"down",sub:"red → green",onActivate:g("ci_recovery")}),n.jsxs(Cu,{onActivate:g("ci_red"),children:[n.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wide text-gray-400",children:"CI red now"}),n.jsx("div",{className:`text-lg font-semibold ${e.ciFailingNow>0?"text-red-500 dark:text-red-400":"text-gray-800 dark:text-gray-100"}`,children:e.ciFailingNow}),n.jsx("div",{className:"text-[11px] text-gray-400",children:e.ciFailingNow>0&&e.ciFailingMedianAgeHours!=null?`~${Pn(e.ciFailingMedianAgeHours)} unresolved`:"all green"}),n.jsx("div",{className:"mt-0.5 text-[10px] text-gray-400",children:"recovery pressure"})]})]}),n.jsx("h4",{className:"pt-1 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"12-week trend"}),n.jsxs("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-3",children:[n.jsx(Et,{title:"Throughput",note:"opened vs merged · weekly",children:m(e.throughput.opened)+m(e.throughput.merged)===0?n.jsx(wt,{}):n.jsx(ss,{labels:i,series:w,mode:"grouped"})}),n.jsx(Et,{title:"CI recovery time",note:"median red→green · weekly",children:e.ciRecoveryTrend.every(E=>E==null)?n.jsx(wt,{label:"No CI recoveries yet — accrues from sync"}):n.jsx(Os,{labels:i,series:j,area:!0,curved:!0,formatY:Pn})}),n.jsx(Et,{title:"CI failures by stage",note:"which checks fail · window",children:P.length===0?n.jsx(wt,{label:"No CI failures recorded yet"}):n.jsx(ss,{labels:P,series:R,rotateLabels:!0})})]}),n.jsxs("div",{children:[n.jsxs("button",{type:"button",onClick:()=>o(E=>!E),className:"text-[11px] font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:[a?"▾":"▸"," More charts — lead time · merge CI success"]}),a&&n.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-3 lg:grid-cols-2",children:[n.jsx(Et,{title:"Lead time for changes",note:"median open→merge · weekly",children:e.leadTimeTrend.every(E=>E==null)?n.jsx(wt,{}):n.jsx(Os,{labels:i,series:v,area:!0,curved:!0,formatY:Pn})}),n.jsx(Et,{title:"Merge CI success",note:"% green at merge · weekly",children:e.ciSuccessTrend.every(E=>E==null)?n.jsx(wt,{}):n.jsx(Os,{labels:i,series:y,curved:!0,formatY:Tm})})]})]})]})}function Em(e){const s=new Date(e);return new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth()+1,1)).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Pm({label:e,credits:s,hint:a}){return n.jsxs("div",{className:"flex items-baseline justify-between gap-3 py-1",children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-[12px] font-medium text-gray-700 dark:text-gray-200",children:e}),n.jsx("div",{className:"text-[10px] text-gray-400",children:a})]}),n.jsxs("div",{className:"whitespace-nowrap text-sm font-semibold tabular-nums text-gray-800 dark:text-gray-100",children:[s.toLocaleString()," ",n.jsx("span",{className:"text-[10px] font-normal text-gray-400",children:"cr"})]})]})}function Ck(){const{data:e,isLoading:s,isError:a}=ci(!0),o=e?new Date(e.monthStart).toLocaleDateString(void 0,{month:"long"}):"";return n.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white p-3 dark:border-gray-800 dark:bg-gray-900/40",children:[n.jsxs("div",{className:"mb-1 flex items-baseline gap-2",children:[n.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-300",children:"AI usage"}),n.jsx("span",{className:"text-[11px] text-gray-400",children:o?`${o} to date · credits`:"month to date · credits"})]}),s?n.jsx("div",{className:"h-16 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"}):a||!e?n.jsx("div",{className:"text-[11px] text-gray-400",children:"Usage isn’t available."}):(()=>{const i=e.allowanceCredits,u=i!=null,d=e.remainingCredits??0,p=u&&d<=0,m=u&&i>0?Math.min(100,Math.round(e.totalCredits/i*100)):0;return n.jsxs(n.Fragment,{children:[u&&n.jsxs("div",{className:"mb-2",children:[n.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[n.jsxs("div",{className:"text-[13px] font-semibold tabular-nums text-gray-800 dark:text-gray-100",children:[e.totalCredits.toLocaleString(),n.jsxs("span",{className:"text-gray-400",children:[" / ",i.toLocaleString()]})," ",n.jsx("span",{className:"text-[10px] font-normal text-gray-400",children:"cr"})]}),n.jsx("div",{className:`text-[11px] tabular-nums ${p?"font-medium text-amber-600 dark:text-amber-400":"text-gray-500 dark:text-gray-400"}`,children:p?"out of credits":`${d.toLocaleString()} left`})]}),n.jsx("div",{className:"mt-1 h-1.5 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",children:n.jsx("div",{className:`h-full rounded-full ${p?"bg-amber-500":"bg-violet-500"}`,style:{width:`${m}%`}})}),n.jsx("div",{className:"mt-1 text-[10px] text-gray-400",children:p?`Out of AI credits — resets ${Em(e.monthStart)}.`:`digest ≈ 9 cr · sprint ≈ 10 cr · resets ${Em(e.monthStart)}`})]}),n.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:[n.jsx(Pm,{label:"Summaries",credits:e.summaryCredits,hint:"digests · sprint report · analyses"}),n.jsx(Pm,{label:"Agentic tools",credits:e.agentCredits,hint:"Claude Review · AI Fix"})]}),!u&&n.jsxs("div",{className:"mt-1 flex items-baseline justify-between gap-3 border-t border-gray-200 pt-1.5 dark:border-gray-700",children:[n.jsx("div",{className:"text-[12px] font-semibold text-gray-700 dark:text-gray-200",children:"Total this month"}),n.jsxs("div",{className:"whitespace-nowrap text-base font-semibold tabular-nums text-violet-600 dark:text-violet-300",children:[e.totalCredits.toLocaleString()," ",n.jsx("span",{className:"text-[10px] font-normal text-gray-400",children:"cr"})]})]}),n.jsx("div",{className:"mt-1.5 text-[10px] text-gray-400",children:"An approximate measure of model usage across everything Pierre runs for you."})]})})()]})}const Rk={high:{border:"border-l-red-400 dark:border-l-red-500",dot:"bg-red-500"},warn:{border:"border-l-amber-400 dark:border-l-amber-500",dot:"bg-amber-500"},info:{border:"border-l-sky-400 dark:border-l-sky-500",dot:"bg-sky-500"}},Ik={bot_signal:"Review-bot signal",bot_only_review:"Only a bot reviewed",stalled_review:"Stalled review",untouched_thread:"Untouched thread",reviewer_load:"Review load",reviewer_routing:"Needs a reviewer"},Am=new Set(["bot_signal","bot_only_review"]),Tk=[{key:"overview",label:"Overview"},{key:"bots",label:"Bots"},{key:"retro",label:"Retro"}];function $m(e){return e<48?`${e}h`:`${Math.round(e/24)}d`}function ka(e,s){const a=e.authorId!=null?s.get(e.authorId):void 0;return{id:e.prId,number:e.prNumber,title:e.prTitle,repoFullName:e.repoFullName,authorLogin:(a==null?void 0:a.githubLogin)??null,authorDisplayName:(a==null?void 0:a.displayName)??null,authorAvatarUrl:(a==null?void 0:a.avatarUrl)??null}}function _o({id:e,usersById:s}){const a=s.get(e);return n.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-gray-500/10 px-1.5 py-0.5 text-[11px]",children:[n.jsx(ht,{user:a,size:13}),n.jsx(sn,{user:a,fallbackId:e})]})}function Ek({kind:e}){const s=an(e);return n.jsxs("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium",style:{color:s.color,background:`${s.color}1a`},title:"This thread was opened by an automated reviewer",children:["🤖 ",s.label]})}function au({pr:e}){const s=e.ciStatus?ur[e.ciStatus]:null;return n.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-gray-500 dark:text-gray-400",children:[n.jsxs("span",{className:"inline-flex items-center gap-1",title:(s==null?void 0:s.label)??"no checks",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:s?{background:s.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"},"aria-hidden":!0}),(s==null?void 0:s.label)??"no checks"]}),n.jsxs("span",{children:[e.changedFiles," file",e.changedFiles===1?"":"s"]}),n.jsxs("span",{className:"font-mono",children:[n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions]})," ",n.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions]})]})]})}function lu({prId:e}){const[s,a]=x.useState(!1);return n.jsxs("div",{className:"mt-2",children:[n.jsxs("button",{type:"button",onClick:()=>a(o=>!o),className:"text-[11px] font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:[s?"▾":"▸"," PR summary"]}),s&&n.jsx(Pk,{prId:e})]})}function Pk({prId:e}){const{data:s,isLoading:a}=Zo(e);if(a)return n.jsx("div",{className:"mt-1 text-[11px] text-gray-400",children:"Loading…"});if(!s)return n.jsx("div",{className:"mt-1 text-[11px] text-gray-400",children:"Couldn’t load this PR."});const o=s.body!=null&&s.body.trim()!=="";return n.jsxs("div",{className:"mt-1 space-y-2 rounded border border-gray-200 bg-gray-50 p-2 dark:border-gray-800 dark:bg-gray-900/40",children:[o?n.jsx("div",{className:"max-h-64 overflow-auto text-sm",children:n.jsx(cr,{children:s.body})}):n.jsx("div",{className:"text-[11px] italic text-gray-400",children:"No PR description."}),n.jsx(kh,{pr:s})]})}function Ak({card:e}){const{data:s,isLoading:a}=qu(e.threadId),{data:o}=$n(),i=x.useMemo(()=>ln(o),[o]),u=`https://github.com/${e.repoFullName}/pull/${e.prNumber}`;return a?n.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Loading conversation…"}):s?n.jsx(gl,{thread:s,usersById:i,prUrl:u,repoId:e.repoId}):n.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Couldn’t load this conversation."})}function $k({card:e,usersById:s}){var u;const a=hh(e.prId),o=e.suggestedReviewers.map(d=>d.userId),i=a.isSuccess;return n.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[n.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-gray-500",children:[n.jsx("span",{className:"font-medium",children:"Suggested reviewers"}),n.jsx("button",{type:"button",onClick:()=>a.mutate({userIds:o}),disabled:a.isPending||i||o.length===0,className:"rounded border border-violet-300 px-1.5 py-0.5 font-medium text-violet-700 hover:bg-violet-50 disabled:opacity-50 dark:border-violet-700 dark:text-violet-300 dark:hover:bg-violet-900/20",title:"Request these reviewers on GitHub",children:i?"✓ Requested":a.isPending?"Assigning…":`Assign${o.length>1?" all":""}`})]}),n.jsx("ul",{className:"space-y-1",children:e.suggestedReviewers.map(d=>n.jsxs("li",{className:"flex flex-wrap items-center gap-1.5 text-[11px] text-gray-500",children:[n.jsx(_o,{id:d.userId,usersById:s}),n.jsx("span",{className:"text-gray-400",children:d.reason})]},d.userId))}),a.isError&&n.jsx("div",{className:"text-[11px] text-red-500",children:((u=a.error)==null?void 0:u.message)??"Couldn’t request reviewers."})]})}function Sa({card:e,right:s,onActivate:a,children:o,innerRef:i,flash:u=!1}){const d=Rk[e.severity],p=a?m=>{m.target.closest("a,button,textarea,input,[data-noactivate]")||a()}:void 0;return n.jsxs("li",{ref:i,onClick:p,className:`rounded-lg border border-l-4 border-gray-200 bg-white p-3 dark:border-gray-800 dark:bg-gray-900/40 ${d.border}${u?" ring-2 ring-sky-400/70":""}${a?" cursor-pointer hover:bg-gray-50/70 dark:hover:bg-gray-900/60":""}`,children:[n.jsxs("div",{className:"mb-1.5 flex items-center gap-2 text-[11px]",children:[n.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${d.dot}`,"aria-hidden":!0}),n.jsx("span",{className:"font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:Ik[e.kind]}),n.jsx("span",{className:"ml-auto text-gray-400",children:s})]}),o]})}function ou({card:e,onOpen:s}){return n.jsxs("div",{className:"flex min-w-0 items-baseline gap-1.5 text-sm",children:[n.jsxs("button",{type:"button",onClick:s,className:"min-w-0 truncate text-left font-medium text-gray-800 hover:underline dark:text-gray-100",title:"Open this PR on its Overview tab",children:[n.jsxs("span",{className:"text-gray-400",children:[e.repoFullName," #",e.prNumber]})," ",e.prTitle]}),n.jsx("a",{href:e.githubUrl,target:"_blank",rel:"noreferrer noopener",onClick:a=>a.stopPropagation(),className:"shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",title:"Open on GitHub",children:"↗"})]})}function Mk({card:e,innerRef:s,flash:a,onOpen:o}){return n.jsxs(Sa,{card:e,innerRef:s,flash:a,right:`${e.prs.length} PR${e.prs.length===1?"":"s"}`,children:[n.jsxs("div",{className:"text-sm text-gray-800 dark:text-gray-100",children:["🤖 Only a bot reviewed"," ",n.jsx("span",{className:"font-semibold tabular-nums",children:e.prs.length})," PR",e.prs.length===1?"":"s"," — no human review"]}),n.jsx("ul",{className:"mt-1.5 space-y-1",children:e.prs.map(i=>n.jsxs("li",{className:"flex min-w-0 items-baseline gap-1.5 text-[11px]",children:[n.jsxs("button",{type:"button",onClick:()=>o({id:i.prId,number:i.number,title:i.title,repoFullName:i.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null},e.id),className:"min-w-0 truncate text-left text-gray-600 hover:underline dark:text-gray-300",title:"Open this PR on its Overview tab",children:[n.jsxs("span",{className:"text-gray-400",children:[i.repoFullName," #",i.number]})," ",i.title]}),n.jsx("span",{className:"shrink-0 rounded bg-gray-500/10 px-1 py-0.5 text-[10px] uppercase tracking-wide text-gray-500",children:i.state}),n.jsx("span",{className:"shrink-0 rounded px-1 py-0.5 text-[10px] font-medium text-amber-700 dark:text-amber-300",style:{background:"#f59e0b1a"},title:"The only review on this PR",children:i.botLabel}),n.jsx("a",{href:i.githubUrl,target:"_blank",rel:"noreferrer noopener",onClick:u=>u.stopPropagation(),className:"shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",title:"Open on GitHub",children:"↗"})]},i.prId))}),n.jsx("div",{className:"mt-2 text-[11px] text-gray-400",children:"A trust/safety hook — deterministic (no AI). Consider a human pass before these ship."})]})}function Mm({initialSubTab:e}={}){var H,ee,ce;const s=De(C=>C.openPrDetailTab),a=te(C=>C.showThreadInChanges),o=te(C=>C.openMetricsDetail),i=te(C=>C.openBotPrsDetail),{data:u,isLoading:d,isError:p}=ek(!0),m=x.useMemo(()=>ln(u==null?void 0:u.users),[u==null?void 0:u.users]),[g,w]=x.useState(e??"overview");x.useEffect(()=>{e&&w(e)},[e]);const v=De(C=>C.activityFlashItemId),y=De(C=>C.clearActivityFlashItem),j=x.useRef(new Map),[R,P]=x.useState(null);x.useEffect(()=>{if(v==null)return;const C=v,F=requestAnimationFrame(()=>{const K=j.current.get(C);K&&(K.scrollIntoView({block:"center",behavior:"smooth"}),P(C),window.setTimeout(()=>P(ae=>ae===C?null:ae),1800)),y()});return()=>cancelAnimationFrame(F)},[v,y]);const E=(C,F)=>{F?j.current.set(C,F):j.current.delete(C)},{activityDigest:S,teamInsights:T}=yn(),{data:N}=Mr(),b=x.useMemo(()=>(N??[]).filter(C=>C.inboxWatch).map(C=>C.id),[N]),I=x1(b,S&&b.length>0),$=l0(),[L,q]=x.useState(!1),Q=(C,F)=>s(C,{fromActivity:!0,returnItemId:F}),_=C=>{s(ka(C,m),{fromActivity:!0,returnItemId:C.id}),a(C.prId,C.threadId)},Y=(u==null?void 0:u.cards)??[],X=Y.filter(C=>!Am.has(C.kind)),B=Y.filter(C=>Am.has(C.kind)),O=C=>{switch(C.kind){case"stalled_review":return n.jsxs(Sa,{card:C,innerRef:F=>E(C.id,F),flash:R===C.id,right:`waiting ${$m(C.ageHours)}`,onActivate:()=>Q(ka(C,m),C.id),children:[n.jsx(ou,{card:C,onOpen:()=>Q(ka(C,m),C.id)}),n.jsx(au,{pr:C}),n.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5 text-[11px] text-gray-500",children:[n.jsx("span",{children:"waiting on"}),C.requestedReviewerIds.length>0?C.requestedReviewerIds.map(F=>n.jsx(_o,{id:F,usersById:m},F)):n.jsx("span",{className:"italic",children:"no reviewer requested"})]}),n.jsx(lu,{prId:C.prId})]},C.id);case"untouched_thread":return n.jsxs(Sa,{card:C,innerRef:F=>E(C.id,F),flash:R===C.id,right:`${$m(C.ageHours)} old`,children:[n.jsxs("div",{className:"-m-1 cursor-pointer rounded p-1 hover:bg-gray-50/70 dark:hover:bg-gray-900/60",onClick:F=>{F.target.closest("a,button")||_(C)},children:[n.jsx(ou,{card:C,onOpen:()=>Q(ka(C,m),C.id)}),n.jsx(au,{pr:C}),n.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5 text-[11px] text-gray-500",children:[n.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 font-mono",children:C.path}),n.jsx("span",{children:"· no reply since"}),C.originalCommenterId!=null&&n.jsx(_o,{id:C.originalCommenterId,usersById:m}),C.botKind!=null&&n.jsx(Ek,{kind:C.botKind})]})]}),n.jsx("div",{className:"mt-2",children:n.jsx(Ak,{card:C})}),n.jsx(lu,{prId:C.prId})]},C.id);case"reviewer_routing":return n.jsxs(Sa,{card:C,innerRef:F=>E(C.id,F),flash:R===C.id,right:"unassigned",onActivate:()=>Q(ka(C,m),C.id),children:[n.jsx(ou,{card:C,onOpen:()=>Q(ka(C,m),C.id)}),n.jsx(au,{pr:C}),C.topPaths.length>0&&n.jsxs("div",{className:"mt-1 truncate text-[11px] text-gray-400",children:["touches"," ",n.jsx("span",{className:"font-mono",children:C.topPaths.slice(0,3).join(", ")})]}),n.jsx($k,{card:C,usersById:m}),n.jsx(lu,{prId:C.prId})]},C.id);case"reviewer_load":return n.jsxs(Sa,{card:C,innerRef:F=>E(C.id,F),flash:R===C.id,right:`${C.reviewsThisSprint} review${C.reviewsThisSprint===1?"":"s"} this sprint`,children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[n.jsx(_o,{id:C.reviewerId,usersById:m}),n.jsxs("span",{className:"font-semibold text-gray-800 dark:text-gray-100",children:[C.pendingCount," pending review",C.pendingCount===1?"":"s"]})]}),C.pendingPrs.length>0&&n.jsx("ul",{className:"mt-1.5 space-y-0.5",children:C.pendingPrs.map(F=>n.jsx("li",{className:"truncate text-[11px]",children:n.jsxs("button",{type:"button",onClick:()=>Q({id:F.prId,number:F.prNumber,title:F.prTitle,repoFullName:F.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null},C.id),className:"text-left text-gray-500 hover:underline dark:text-gray-400",children:[n.jsxs("span",{className:"text-gray-400",children:[F.repoFullName," #",F.prNumber]})," ",F.prTitle]})},F.prId))})]},C.id);case"bot_signal":return n.jsxs(Sa,{card:C,innerRef:F=>E(C.id,F),flash:R===C.id,right:C.actedOnPct!=null?`${C.actedOnPct}% acted on`:void 0,children:[n.jsxs("div",{className:"text-sm text-gray-800 dark:text-gray-100",children:[n.jsx("span",{className:"font-semibold tabular-nums",children:C.totalThreads})," ","review-bot thread",C.totalThreads===1?"":"s"," this sprint ·"," ",n.jsx("span",{className:"tabular-nums",children:C.totalUntouched})," untouched",C.oldestUntouchedDays!=null&&C.totalUntouched>0&&n.jsxs(n.Fragment,{children:[", oldest"," ",n.jsx("span",{className:"tabular-nums",children:C.oldestUntouchedDays}),"d"]})]}),n.jsx("ul",{className:"mt-2 space-y-1",children:C.vendors.map(F=>{const K=an(F.kind),ae=F.threads>0?Math.round(F.actedOn/F.threads*100):0;return n.jsxs("li",{className:"flex flex-wrap items-center gap-x-2 text-[11px]",children:[n.jsxs("button",{type:"button",onClick:()=>i(F.kind),className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium hover:underline",style:{color:K.color,background:`${K.color}1a`},title:"View this bot's PRs",children:["🤖 ",K.label]}),n.jsxs("span",{className:"tabular-nums text-gray-500",children:[F.threads," thread",F.threads===1?"":"s"]}),n.jsx("span",{className:"text-gray-400",children:"·"}),n.jsxs("span",{className:"tabular-nums text-gray-500",children:[ae,"% acted on"]}),F.untouched>0&&n.jsxs("span",{className:"tabular-nums text-amber-600 dark:text-amber-400",children:["· ",F.untouched," untouched"]})]},F.kind)})}),n.jsx("div",{className:"mt-2 text-[11px] text-gray-400",children:"“Acted on” = a later commit touched the flagged file (approximate). Deterministic across every repo + bot — no AI."})]},C.id);case"bot_only_review":return n.jsx(Mk,{card:C,innerRef:F=>E(C.id,F),flash:R===C.id,onOpen:Q},C.id);default:return null}};return n.jsxs("div",{className:"space-y-3","data-testid":"insights-view",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("h2",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"Insights"}),n.jsx("span",{className:"rounded bg-violet-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:"Pro"}),(u==null?void 0:u.sprint)&&n.jsxs("span",{className:"text-[11px] text-gray-400",children:["sprint: last ",((H=u.metrics)==null?void 0:H.sprintDays)??14,"d · ",Y.length," item",Y.length===1?"":"s"]}),n.jsx("div",{className:"ml-auto flex items-center gap-1.5",children:n.jsxs("button",{type:"button",onClick:()=>q(C=>!C),className:`rounded border px-1.5 py-0.5 text-[11px] font-medium ${L?"border-violet-300 bg-violet-50 text-violet-700 dark:border-violet-700 dark:bg-violet-950/30 dark:text-violet-300":"border-gray-300 hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-500"}`,title:"Show your month-to-date AI usage (in credits)",children:[L?"▾":"▸"," Track usage"]})})]}),L&&n.jsx(Ck,{}),n.jsx("div",{role:"tablist",className:"flex flex-wrap gap-1 border-b border-gray-200 dark:border-gray-800",children:Tk.map(({key:C,label:F})=>{const K=C===g;return n.jsx("button",{type:"button",role:"tab","aria-selected":K,onClick:()=>w(C),className:`-mb-px rounded-t-md border border-b-0 px-3 py-1.5 text-xs font-medium ${K?"border-gray-300 bg-white text-violet-600 dark:border-gray-700 dark:bg-gray-950 dark:text-violet-300":"border-transparent text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-900/60"}`,children:F},C)})}),g==="overview"?n.jsxs("div",{className:"space-y-3",children:[(u==null?void 0:u.metrics)&&n.jsx(Sk,{metrics:u.metrics,onOpenMetric:o}),n.jsx(kk,{digests:((ee=I.data)==null?void 0:ee.digests)??[],digestsLoading:I.isLoading,anyWatched:b.length>0,refreshingRepoIds:$.refreshingRepoIds,onRegenerateRepo:C=>$.mutate(C),onRegenerateAllDigests:b.length>0?()=>$.mutate(b):void 0,cascadeBusy:$.isPending}),n.jsx(p0,{active:$.isPending&&(((ce=$.progress)==null?void 0:ce.total)??0)>0,label:"Regenerating summaries",...a0($.progress)}),d?n.jsx("div",{className:"space-y-3",children:[0,1,2].map(C=>n.jsx("div",{className:"h-20 animate-pulse rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/40"},C))}):p?n.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load insights."}):X.length===0?n.jsxs("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:["Nothing needs attention across your watched repos right now. 🎉",n.jsx("div",{className:"mt-1 text-[11px]",children:"Stalled reviews, untouched threads, reviewer load and un-assigned PRs will surface here."})]}):n.jsx("ul",{className:"space-y-2",children:X.map(C=>O(C))})]}):g==="bots"?n.jsxs("div",{className:"space-y-3",children:[T&&n.jsx(uk,{}),p?n.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load insights."}):B.length>0?n.jsx("ul",{className:"space-y-2",children:B.map(C=>O(C))}):null]}):n.jsx(gk,{})]})}function Fm({labels:e,series:s,formatValue:a=zs,height:o=132}){const[i,u]=yl(),[d,p]=x.useState(null),m=30,g=8,w=8,v=16,y=e.length,j=Math.max(u-m-g,1),R=o-w-v,P=(q,Q)=>q.values[Q]??0,E=q=>s.reduce((Q,_)=>Q+P(_,q),0),S=Ju(Math.max(1,...e.map((q,Q)=>E(Q)))),T=q=>m+(y<=1?j/2:q/(y-1)*j),N=q=>w+R*(1-q/S),b=w+R,I=[];{const q=e.map(()=>0);for(const Q of s)I.push([...q]),e.forEach((_,Y)=>q[Y]=(q[Y]??0)+P(Q,Y))}const $=(q,Q)=>{const _=I[Q],Y=e.map((B,O)=>[T(O),N(_[O]+P(q,O))]),X=e.map((B,O)=>[T(O),N(_[O])]).reverse();return`M ${Y.map(([B,O])=>`${B},${O}`).join(" L ")} L ${X.map(([B,O])=>`${B},${O}`).join(" L ")} Z`},L=q=>{const Q=y<=1?0:Math.round((q.nativeEvent.offsetX-m)/j*(y-1));p(Math.max(0,Math.min(y-1,Q)))};return n.jsxs("div",{children:[n.jsxs("div",{ref:i,className:"relative",style:{height:o},children:[u>0&&n.jsxs("svg",{width:u,height:o,className:"block",children:[[0,S].map(q=>n.jsxs("g",{children:[n.jsx("line",{x1:m,y1:N(q),x2:u-g,y2:N(q),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),n.jsx("text",{x:m-4,y:N(q)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:zs(q)})]},q)),s.map((q,Q)=>n.jsx("path",{d:$(q,Q),fill:q.color,opacity:.85},q.key)),d!=null&&n.jsx("line",{x1:T(d),y1:w,x2:T(d),y2:b,className:"text-gray-400 dark:text-gray-300",stroke:"currentColor",strokeWidth:1}),n.jsx("text",{x:m,y:o-4,className:"fill-gray-400 text-[8px]",children:e[0]?_s(e[0]):""}),n.jsx("text",{x:u-g,y:o-4,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:e[y-1]?_s(e[y-1]):""}),n.jsx("rect",{x:0,y:0,width:u,height:o,fill:"transparent",onMouseMove:L,onMouseLeave:()=>p(null)})]}),d!=null&&u>0&&n.jsxs(vl,{x:T(d),y:w,width:u,children:[n.jsx("div",{className:"font-medium",children:e[d]?_s(e[d]):""}),s.map(q=>n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-[1px]",style:{background:q.color}}),q.label,": ",a(P(q,d))]},q.key)),n.jsxs("div",{className:"mt-0.5 border-t border-gray-200 pt-0.5 dark:border-gray-700",children:["total: ",a(E(d))]})]})]}),s.length>1&&n.jsx(ui,{series:s})]})}function Fk({points:e,xLabel:s,yLabel:a,formatX:o=zs,formatY:i=zs,fit:u=!1,height:d=150}){const[p,m]=yl(),[g,w]=x.useState(null),v=32,y=8,j=8,R=18,P=Math.max(m-v-y,1),E=d-j-R,S=_=>Math.log10(1+Math.max(0,_)),T=S(Math.max(1,...e.map(_=>_.x))),N=S(Math.max(1,...e.map(_=>_.y))),b=_=>v+S(_)/(T||1)*P,I=_=>j+E*(1-S(_)/(N||1)),$=_=>[0,1,10,100,1e3,1e4].filter(Y=>S(Y)<=_+.01),L=(()=>{if(!u)return null;const _=e.filter(se=>se.x>0&&se.y>0);if(_.length<4)return null;const Y=_.map(se=>Math.log10(se.x)),X=_.map(se=>Math.log10(se.y)),B=_.length,O=Y.reduce((se,Z)=>se+Z,0)/B,H=X.reduce((se,Z)=>se+Z,0)/B;let ee=0,ce=0;for(let se=0;se<B;se++)ee+=(Y[se]-O)**2,ce+=(Y[se]-O)*(X[se]-H);if(ee===0)return null;const C=ce/ee,F=H-C*O,K=Math.min(...Y),ae=Math.max(...Y);if(ae<=K)return null;const ne=24;let Pe="";for(let se=0;se<=ne;se++){const Z=K+se/ne*(ae-K),je=10**Z,We=10**(F+C*Z);Pe+=`${se===0?"M":" L"} ${b(je).toFixed(1)} ${I(We).toFixed(1)}`}return{d:Pe,slope:C}})(),q=_=>{const Y=_.nativeEvent.offsetX,X=_.nativeEvent.offsetY;let B=-1,O=196;e.forEach((H,ee)=>{const ce=b(H.x)-Y,C=I(H.y)-X,F=ce*ce+C*C;F<O&&(O=F,B=ee)}),w(B>=0?B:null)},Q=g!=null?e[g]:null;return n.jsxs("div",{children:[n.jsxs("div",{ref:p,className:"relative",style:{height:d},children:[m>0&&n.jsxs("svg",{width:m,height:d,className:"block",children:[$(N).map(_=>n.jsxs("g",{children:[n.jsx("line",{x1:v,y1:I(_),x2:m-y,y2:I(_),className:"text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),n.jsx("text",{x:v-4,y:I(_)+3,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:i(_)})]},`y${_}`)),$(T).map(_=>n.jsx("text",{x:b(_),y:d-8,textAnchor:"middle",className:"fill-gray-400 text-[8px]",children:o(_)},`x${_}`)),e.map((_,Y)=>n.jsx("circle",{cx:b(_.x),cy:I(_.y),r:g===Y?4:2.2,fill:_.merged?Ke.green:Ke.gray,opacity:g==null||g===Y?.75:.3},Y)),L&&n.jsx("path",{d:L.d,fill:"none",stroke:Ke.amber,strokeWidth:1.5,strokeDasharray:"4 3",opacity:.95}),L&&n.jsxs("text",{x:v+5,y:j+9,fill:Ke.amber,className:"text-[8px] font-semibold",children:["≈ ",a," ∝ ",s,"^",L.slope.toFixed(1)]}),n.jsxs("text",{x:v,y:d-1,className:"fill-gray-400 text-[8px]",children:[s," →"]}),n.jsx("rect",{x:0,y:0,width:m,height:d,fill:"transparent",onMouseMove:q,onMouseLeave:()=>w(null)})]}),Q&&m>0&&n.jsxs(vl,{x:b(Q.x),y:I(Q.y),width:m,children:[n.jsx("div",{className:"font-medium",children:Q.label}),n.jsxs("div",{children:[s,": ",o(Q.x)]}),n.jsxs("div",{children:[a,": ",i(Q.y)]})]})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("span",{className:"text-[9px] text-gray-400",children:[a," (log) ↑"]}),n.jsx(ui,{series:[{label:"merged",color:Ke.green},{label:"closed",color:Ke.gray}]})]})]})}const iu=[1,2,3,4,5,6,0],Lk=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],_k=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Ok({cells:e,height:s}){const[a,o]=yl(),[i,u]=x.useState(null),d=26,p=2,m=14,w=Math.max(o-d-2,1)/24,v=s??p+7*m+14,y=Math.max(1,...e),j=P=>{const E=Math.floor((P.nativeEvent.offsetX-d)/w),S=Math.floor((P.nativeEvent.offsetY-p)/m);if(E<0||E>23||S<0||S>6){u(null);return}u({row:S,col:E})},R=(P,E)=>e[iu[P]*24+E]??0;return n.jsx("div",{children:n.jsxs("div",{ref:a,className:"relative",style:{height:v},children:[o>0&&n.jsxs("svg",{width:o,height:v,className:"block",children:[Lk.map((P,E)=>n.jsx("text",{x:d-4,y:p+E*m+m-4,textAnchor:"end",className:"fill-gray-400 text-[8px]",children:P},P)),iu.map((P,E)=>Array.from({length:24},(S,T)=>{const N=R(E,T),b=(i==null?void 0:i.row)===E&&(i==null?void 0:i.col)===T;return n.jsx("rect",{x:d+T*w,y:p+E*m,width:Math.max(w-1,1),height:m-1,rx:1.5,fill:N>0?Ke.blue:"currentColor",className:N>0?"":"text-gray-100 dark:text-gray-800",fillOpacity:N>0?.15+.85*(N/y):1,stroke:b?Ke.blue:"none",strokeWidth:b?1.5:0},`${E}-${T}`)})),[0,6,12,18].map(P=>n.jsxs("text",{x:d+P*w,y:v-3,className:"fill-gray-400 text-[8px]",children:[P,":00"]},P)),n.jsx("rect",{x:0,y:0,width:o,height:v,fill:"transparent",onMouseMove:j,onMouseLeave:()=>u(null)})]}),i&&o>0&&n.jsxs(vl,{x:d+i.col*w+w/2,y:p+i.row*m,width:o,children:[_k[iu[i.row]]," ",String(i.col).padStart(2,"0"),":00 ·"," ",R(i.row,i.col)," events"]})]})})}const ns=e=>e.reduce((s,a)=>s+a,0);function ll({title:e,children:s}){return n.jsxs("div",{children:[n.jsx("h3",{className:"mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:e}),n.jsx("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:s})]})}function Dk({data:e}){const{data:s}=$n(),a=ln(s),o=e.weekBuckets,i=`${e.windowDays/7}-wk · weekly`,u=[{key:"opened",label:"Opened",color:Ke.blue,values:e.throughput.opened},{key:"merged",label:"Merged",color:Ke.green,values:e.throughput.merged},{key:"closed",label:"Closed",color:Ke.gray,values:e.throughput.closed}],d=[{key:"open",label:"Open",color:Ke.blue,values:e.backlog.open},{key:"stalled",label:"Stalled",color:Ke.orange,values:e.backlog.stalled}],p=[{key:"median",label:"Median to 1st review",color:Ke.blue,values:e.reviewLatencyTrend.medianHours}],m=[{key:"ttfr",label:"Open → 1st review",color:Ke.amber,values:e.cycleBreakdown.toFirstReview},{key:"rtm",label:"1st review → close",color:Ke.blue,values:e.cycleBreakdown.reviewToMerge}],g=[{key:"count",label:"PRs",color:Ke.blue,values:e.reviewLatencyDist.map(N=>N.count)}],w=e.reviewLatencyDist.map(N=>N.label),v=[{key:"untouched",label:jt.untouched.label,color:jt.untouched.color,values:e.threadMix.untouched},{key:"replied",label:jt.replied_unresolved.label,color:jt.replied_unresolved.color,values:e.threadMix.replied_unresolved},{key:"likely",label:jt.likely_addressed.label,color:jt.likely_addressed.color,values:e.threadMix.likely_addressed},{key:"resolved",label:jt.resolved.label,color:jt.resolved.color,values:e.threadMix.resolved}],y=[{key:"approved",label:"Approved",color:Ke.green,values:e.reviewVerdicts.approved},{key:"changes",label:"Changes requested",color:Ke.orange,values:e.reviewVerdicts.changes_requested},{key:"commented",label:"Commented",color:Ke.gray,values:e.reviewVerdicts.commented},{key:"dismissed",label:"Dismissed",color:Ke.slate,values:e.reviewVerdicts.dismissed}],j=e.reviewerLoad.map((N,b)=>({key:String(N.userId),label:N.userId===-1?"Others":ft(a.get(N.userId),N.userId),color:Cm[b%Cm.length],values:N.weekly})),R=[{key:"count",label:"PRs",color:Ke.purple,values:e.sizeDist.map(N=>N.count)}],P=e.sizeDist.map(N=>N.label),E=e.sizeVsCycle.map(N=>({x:N.loc,y:N.hoursOpen,label:`#${N.prNumber}`,merged:N.merged})),S=e.sizeCycleByBucket.map(N=>N.label),T=[{key:"median",label:"Median time open",color:Ke.teal,values:e.sizeCycleByBucket.map(N=>N.medianHours??0)}];return n.jsxs("div",{className:"space-y-4",children:[n.jsxs(ll,{title:"Flow & throughput",children:[n.jsx(Et,{title:"PR throughput",note:i,children:ns(u.flatMap(N=>N.values))===0?n.jsx(wt,{}):n.jsx(ss,{labels:o,series:u,mode:"grouped"})}),n.jsx(Et,{title:"Open backlog & stalled",note:"weekly snapshot",children:Math.max(0,...e.backlog.open)===0?n.jsx(wt,{}):n.jsx(Os,{labels:o,series:d,curved:!0})})]}),n.jsxs(ll,{title:"Speed & latency",children:[n.jsx(Et,{title:"Time to first review",note:"weekly median",children:e.reviewLatencyTrend.medianHours.every(N=>N==null)?n.jsx(wt,{}):n.jsx(Os,{labels:o,series:p,area:!0,formatY:Pn,curved:!0})}),n.jsx(Et,{title:"Cycle-time breakdown",note:"by close week",children:ns(e.cycleBreakdown.count)===0?n.jsx(wt,{}):n.jsx(ss,{labels:o,series:m,mode:"stacked",formatY:Pn})}),n.jsx(Et,{title:"Review-latency distribution",note:"open → 1st review",children:ns(g[0].values)===0?n.jsx(wt,{}):n.jsx(ss,{labels:w,series:g})})]}),n.jsxs(ll,{title:"Review health",children:[n.jsx(Et,{title:"Thread-resolution mix",note:"by thread created week",children:ns(v.flatMap(N=>N.values))===0?n.jsx(wt,{}):n.jsx(Fm,{labels:o,series:v})}),n.jsx(Et,{title:"Review verdicts",note:i,children:ns(y.flatMap(N=>N.values))===0?n.jsx(wt,{}):n.jsx(ss,{labels:o,series:y,mode:"stacked"})}),n.jsx(Et,{title:"Reviews by reviewer",note:i,children:j.length===0?n.jsx(wt,{}):n.jsx(Fm,{labels:o,series:j})})]}),n.jsxs(ll,{title:"Size & risk",children:[n.jsx(Et,{title:"PR size distribution",note:"opened, by LOC",children:ns(R[0].values)===0?n.jsx(wt,{}):n.jsx(ss,{labels:P,series:R})}),n.jsx(Et,{title:"Median time open by size",note:"PRs closed in window",children:ns(e.sizeCycleByBucket.map(N=>N.count))===0?n.jsx(wt,{}):n.jsx(ss,{labels:S,series:T,formatY:Pn,formatValue:Pn})}),n.jsx(Et,{title:"Size vs. time open",note:"log–log · power-law fit",children:E.length===0?n.jsx(wt,{}):n.jsx(Fk,{points:E,xLabel:"LOC",yLabel:"time open",formatX:zs,formatY:Pn,fit:!0})})]}),n.jsx(ll,{title:"Cadence",children:n.jsx(Et,{title:"Activity heatmap",note:"by weekday × hour (UTC)",children:ns(e.activityHeatmap)===0?n.jsx(wt,{}):n.jsx(Ok,{cells:e.activityHeatmap})})})]})}function Bk({repoId:e,repoName:s,onClose:a}){const{data:o,isLoading:i,error:u}=ah(e);return x.useEffect(()=>{if(e==null)return;const d=p=>{p.key==="Escape"&&(p.stopImmediatePropagation(),a())};return window.addEventListener("keydown",d,!0),()=>window.removeEventListener("keydown",d,!0)},[e,a]),e==null?null:n.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4",onClick:a,role:"presentation",children:n.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:d=>d.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Repo analytics",children:[n.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("h2",{className:"truncate text-sm font-semibold",children:s??"Analytics"}),n.jsxs("p",{className:"text-[11px] text-gray-400",children:["Charts over the last ",o?o.windowDays/7:12," weeks"]})]}),n.jsx("button",{type:"button",onClick:a,className:"shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":"Close (Esc)",title:"Close (Esc)",children:"✕"})]}),n.jsxs("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-3",children:[i&&!o&&n.jsx("div",{className:"py-12 text-center text-sm text-gray-500",children:"Loading analytics…"}),u&&n.jsx("div",{className:"py-12 text-center text-sm text-red-500",children:"Failed to load analytics."}),o&&n.jsx(Dk,{data:o})]})]})})}let Ru=!1;function zk(){Ru=!0}function qk(e){return[...e].sort((s,a)=>a.attentionCount!==s.attentionCount?a.attentionCount-s.attentionCount:s.hasUnread!==a.hasUnread?s.hasUnread?-1:1:s.repoFullName.localeCompare(a.repoFullName))}function Uk(){const[,e]=x.useState(0);x.useEffect(()=>{const s=window.setInterval(()=>e(a=>a+1),3e4);return()=>window.clearInterval(s)},[])}function Kk({fullName:e,maintainerCount:s,hasUnread:a,attentionCount:o,openPrs:i,threadTotals:u,selected:d,onSelect:p}){const m=u!=null||a||o>0||i!=null;return n.jsxs("button",{type:"button",onClick:p,"aria-pressed":d,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 ${d?"border-sky-500 bg-sky-50 dark:bg-sky-950/30":"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800/50"}`,children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-gray-700 dark:text-gray-200",children:e}),s>0&&n.jsx(zu,{})]}),m&&n.jsxs("span",{className:"flex items-center gap-1.5 pl-0.5",children:[a&&n.jsx("span",{"aria-hidden":"true",title:"New activity",className:"inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-sky-500"}),u!=null&&n.jsx(Gu,{counts:u,compact:!0}),o>0&&n.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:["⚠",o]}),n.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-gray-400",children:i==null?"":i>0?`[${i}]`:"[—]"})]})]})}function Hk(){Uk();const e=te(N=>N.userIds),s=te(N=>N.activityRepoId),a=te(N=>N.setActivityRepo),{teamInsights:o}=yn(),{data:i,isFetching:u,isLoading:d}=$x(null,e),{data:p}=Mr(),[m,g]=x.useState(null),w=x.useMemo(()=>qk((i==null?void 0:i.repos)??[]),[i==null?void 0:i.repos]),v=typeof s=="number"?w.find(N=>N.repoId===s)??null:null,y=s==="feed"||s==null,j=s==="insights",R=s==="retro";x.useEffect(()=>{!Ru&&o&&(Ru=!0,te.getState().activityRepoId==="feed"&&a("insights"))},[o,a]);const P=(i==null?void 0:i.generatedAt)??null,E=i!=null?w.map(N=>({repoId:N.repoId,fullName:N.repoFullName,maintainerCount:N.maintainerIds.length,hasUnread:N.hasUnread,attentionCount:N.attentionCount,openPrs:N.stats.openPrs,threadTotals:N.threadTotals})):(p??[]).map(N=>({repoId:N.id,fullName:N.fullName,maintainerCount:0,hasUnread:!1,attentionCount:0,openPrs:null,threadTotals:null})),S=i!=null&&w.length===0,T=(p??[]).length>0;return n.jsxs("div",{className:"flex h-full min-h-0 flex-col md:flex-row",children:[n.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:[n.jsx("div",{className:"flex items-center gap-2 border-b border-gray-200 px-3 py-2 dark:border-gray-800",children:n.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"State of play"})}),P!=null&&n.jsx("div",{className:"px-3 py-1 text-[10px] text-gray-400",title:new Date(P).toLocaleString(),children:St(P)}),u&&i!=null&&n.jsx("div",{className:"h-0.5 w-full overflow-hidden bg-sky-100 dark:bg-sky-950",children:n.jsx("div",{className:"h-full w-1/3 animate-pulse bg-sky-500"})}),n.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 ${u&&i!=null?"opacity-60 transition-opacity":""}`,children:[o&&n.jsxs("button",{type:"button",onClick:()=>a("insights"),"aria-pressed":j,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 ${j?"border-sky-500 bg-sky-50 dark:bg-sky-950/30":"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800/50"}`,title:"Team review-intelligence across your watched repos (Pro)",children:[n.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-violet-500",children:"◈"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-semibold text-gray-700 dark:text-gray-200",children:"Insights"}),n.jsx("span",{className:"shrink-0 rounded bg-violet-500/10 px-1 text-[9px] font-semibold uppercase text-violet-600 dark:text-violet-300",children:"Pro"})]}),n.jsxs("button",{type:"button",onClick:()=>a("feed"),"aria-pressed":y,className:`flex w-56 shrink-0 items-center gap-1.5 rounded border-l-2 px-2 py-1.5 text-left text-xs md:w-full ${y?"border-sky-500 bg-sky-50 dark:bg-sky-950/30":"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800/50"}`,title:"A relevance-ranked stream across all your repos",children:[n.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-sky-500",children:"✦"}),n.jsx("span",{className:"min-w-0 flex-1 truncate font-semibold text-gray-700 dark:text-gray-200",children:"Feed"})]}),E.map(N=>n.jsx(Kk,{fullName:N.fullName,maintainerCount:N.maintainerCount,hasUnread:N.hasUnread,attentionCount:N.attentionCount,openPrs:N.openPrs,threadTotals:N.threadTotals,selected:s===N.repoId,onSelect:()=>a(N.repoId)},N.repoId)),n.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(N=>n.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-400",title:jt[N].description,children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{background:jt[N].color}}),jt[N].label.toLowerCase()]},N))})]})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-3",children:j?n.jsx(Mm,{}):R?n.jsx(Mm,{initialSubTab:"retro"}):S?n.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-gray-400",children:T?"No watched repos yet. Open the repos dropdown in the filter bar and toggle Watch on a repo to populate the Activity console.":"No repos yet. Add a repo from the filter bar to populate the Activity console."}):y?n.jsx(su,{}):d&&i==null?n.jsx("div",{className:"space-y-3",children:[0,1,2].map(N=>n.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"},N))}):v!=null?n.jsxs("div",{className:"space-y-3","data-testid":"repo-console",children:[n.jsx(L1,{repo:v}),n.jsx(_1,{repoId:v.repoId,onOpenCharts:()=>g({repoId:v.repoId,name:v.repoFullName})}),n.jsx(O1,{prs:v.prs,repoFullName:v.repoFullName}),n.jsx(su,{repoId:v.repoId})]}):n.jsx(su,{})}),n.jsx(Bk,{repoId:(m==null?void 0:m.repoId)??null,repoName:(m==null?void 0:m.name)??null,onClose:()=>g(null)})]})}function Wk(e){return qe({queryKey:["team-metrics-detail"],queryFn:()=>ge.teamMetricsDetail(),enabled:e,refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4})}function Vk({repos:e,selected:s,onChange:a}){const[o,i]=x.useState(!1),u=x.useRef(null);Yn(u,()=>i(!1),o),x.useEffect(()=>{if(!o)return;const y=j=>{j.key==="Escape"&&(j.stopPropagation(),i(!1))};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[o]);const d=e.map(y=>y.id),p=d.length,m=s==null,g=y=>m||s.includes(y),w=y=>{const j=m?d:s,R=j.includes(y)?j.filter(P=>P!==y):[...j,y];a(R.length===p?null:R)},v=m?p:s.length;return n.jsxs("div",{ref:u,className:"relative",children:[n.jsxs("span",{className:"inline-flex items-center whitespace-nowrap rounded-full border border-gray-300 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[n.jsxs("button",{type:"button",onClick:()=>i(y=>!y),"aria-haspopup":"true","aria-expanded":o,className:`inline-flex items-center gap-1 py-0.5 pl-2.5 ${m?"pr-2.5":"pr-1"}`,children:[m?"All team repos":`Repos (${v}/${p})`,n.jsx("span",{"aria-hidden":!0,className:"text-[9px]",children:"▾"})]}),!m&&n.jsx("button",{type:"button",onClick:()=>a(null),title:"Show all team repos","aria-label":"Show all team repos",className:"py-0.5 pl-0.5 pr-2 opacity-60 hover:opacity-100",children:"✕"})]}),o&&n.jsxs("div",{role:"dialog","aria-label":"Filter by repo",className:"absolute right-0 top-full z-[60] mt-1 w-64 rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[n.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs font-medium hover:bg-gray-100 dark:hover:bg-gray-800",children:[n.jsx("input",{type:"checkbox",checked:m,onChange:()=>a(null)}),n.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:"All team repos"})]}),n.jsx("div",{className:"my-1 border-t border-gray-200 dark:border-gray-700"}),n.jsx("div",{className:"max-h-72 overflow-y-auto",children:p===0?n.jsx("div",{className:"px-1 py-2 text-xs text-gray-500",children:"No repos with data."}):e.map(y=>{const j=s!=null&&s.length===1&&s[0]===y.id;return n.jsxs("div",{className:"group flex items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[n.jsxs("label",{className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2",children:[n.jsx("input",{type:"checkbox",checked:g(y.id),onChange:()=>w(y.id)}),n.jsx("span",{className:"min-w-0 truncate text-gray-800 dark:text-gray-100",title:y.fullName,children:y.fullName})]}),p>1&&!j&&n.jsx("button",{type:"button",onClick:()=>a([y.id]),title:`Show only ${y.fullName}`,"aria-label":`Show only ${y.fullName}`,className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-gray-400 opacity-0 hover:bg-gray-200 hover:text-gray-700 focus:opacity-100 group-hover:opacity-100 dark:hover:bg-gray-700 dark:hover:text-gray-200",children:"only"})]},y.id)})})]})]})}const Lm={open_prs:{label:"Open PRs",blurb:"All currently-open PRs · longest-open first"},merges:{label:"Merges",blurb:"Merged this sprint · newest first"},lead_time:{label:"Lead time",blurb:"Open → merge (merged + open) · longest first"},review_latency:{label:"Review latency",blurb:"Open → first review · longest first"},merge_ci:{label:"Merge CI",blurb:"Merged PRs · CI-failed-at-merge first"},ci_recovery:{label:"CI recovery",blurb:"Red → green · slowest first"},ci_red:{label:"CI red now",blurb:"Currently-failing branches · longest red first"}};function cu(e,s){if(!e)return[];switch(s){case"open_prs":return e.openPrs;case"merges":return e.merges;case"lead_time":return e.leadTime;case"review_latency":return e.reviewLatency;case"merge_ci":return e.mergeCi;case"ci_recovery":return e.ciRecovery;case"ci_red":return e.ciRed}}function Qk({ci:e}){const s=e?ur[e]:null;return n.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:s?{background:s.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"},"aria-hidden":!0}),(s==null?void 0:s.label)??"no checks"]})}function Gk({pr:e}){return n.jsxs("span",{className:"whitespace-nowrap text-[11px]",children:[n.jsxs("span",{className:"text-gray-400",children:[e.changedFiles,"f"]})," ",n.jsxs("span",{className:"font-mono text-green-600 dark:text-green-400",children:["+",e.additions]})," ",n.jsxs("span",{className:"font-mono text-red-500 dark:text-red-400",children:["−",e.deletions]})]})}function _m({id:e,usersById:s}){const a=e!=null?s.get(e):void 0;return n.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-600 dark:text-gray-300",children:[n.jsx(ht,{user:a,size:14}),n.jsx(sn,{user:a,fallbackId:e??0})]})}function Yk({ids:e,usersById:s}){return e.length===0?n.jsx("span",{className:"text-[11px] italic text-gray-400",children:"none"}):n.jsx("span",{className:"flex flex-wrap gap-1",children:e.map(a=>{const o=s.get(a);return n.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-gray-500/10 px-1 py-0.5 text-[10px]",children:[n.jsx(ht,{user:o,size:11}),n.jsx(sn,{user:o,fallbackId:a})]},a)})})}function Xk(e){switch(e){case"open_prs":return"Open for";case"merges":case"lead_time":return"Lead time";case"review_latency":return"Latency";case"merge_ci":return"CI @ merge";case"ci_recovery":return"Recovery";case"ci_red":return"Red for"}}function Jk({m:e,pr:s}){const a=o=>o==null?"—":Pn(o);switch(e){case"open_prs":case"merges":case"lead_time":return n.jsx("span",{className:"font-medium",children:a(s.leadTimeHours)});case"review_latency":return n.jsx("span",{className:"font-medium",children:a(s.reviewLatencyHours)});case"ci_recovery":return n.jsx("span",{className:"font-medium text-orange-600 dark:text-orange-400",children:a(s.recoveryHours)});case"ci_red":return n.jsx("span",{className:"font-medium text-red-500 dark:text-red-400",children:a(s.redAgeHours)});case"merge_ci":{const o=s.ciStatus==="failure"||s.ciStatus==="error";return n.jsx("span",{className:`font-medium ${o?"text-red-500 dark:text-red-400":"text-gray-500"}`,children:s.ciStatus??"—"})}}}function Zk({m:e,pr:s,usersById:a,onOpen:o}){const i=e==="review_latency",u=e==="merges"||e==="merge_ci";return n.jsxs("tr",{className:"border-t border-gray-100 align-top hover:bg-gray-50/70 dark:border-gray-800/60 dark:hover:bg-gray-900/40",children:[n.jsx("td",{className:"py-1.5 pr-3",children:n.jsxs("button",{type:"button",onClick:()=>o(s),className:"block max-w-md text-left hover:underline",title:`${s.repoFullName} #${s.prNumber} — ${s.prTitle}`,children:[n.jsxs("span",{className:"block truncate font-mono text-[11px] text-gray-400",children:[s.repoFullName," #",s.prNumber]}),n.jsx("span",{className:"block truncate text-sm font-medium text-gray-800 dark:text-gray-100",children:s.prTitle})]})}),n.jsx("td",{className:"py-1.5 pr-3",children:n.jsx(Jk,{m:e,pr:s})}),n.jsx("td",{className:"py-1.5 pr-3",children:n.jsx(Qk,{ci:s.ciStatus})}),n.jsx("td",{className:"py-1.5 pr-3",children:n.jsx(Gk,{pr:s})}),n.jsx("td",{className:"py-1.5 pr-3",children:n.jsx(_m,{id:s.authorId,usersById:a})}),n.jsx("td",{className:"py-1.5 pr-3 text-[11px] text-gray-500 dark:text-gray-400",children:i?n.jsx(Yk,{ids:s.reviewerIds,usersById:a}):u?n.jsx(_m,{id:s.mergedById,usersById:a}):St(s.openedAt)})]})}function ej({m:e,rows:s,usersById:a,onOpen:o}){const i=e==="review_latency"?"Reviewers":e==="merges"||e==="merge_ci"?"Merged by":"Opened";return n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full min-w-[720px] border-collapse text-sm",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"text-left text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:[n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Pull request"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:Xk(e)}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"CI"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Diff"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Author"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:i})]})}),n.jsx("tbody",{children:s.map(u=>n.jsx(Zk,{m:e,pr:u,usersById:a,onOpen:o},u.prId))})]})})}function tj(){const e=te(I=>I.metricsFocus),s=te(I=>I.consumeMetricsFocus),a=De(I=>I.openPrDetailTab),{data:o,isLoading:i,isError:u,refetch:d,isFetching:p}=Wk(!0),{data:m}=$n(),g=x.useMemo(()=>ln(m),[m]),[w,v]=x.useState(e??"merges");x.useEffect(()=>{e&&(v(e),s())},[e,s]);const y=(o==null?void 0:o.detail)??null,[j,R]=x.useState({}),P=j[w]??null,E=I=>R($=>({...$,[w]:I})),S=x.useMemo(()=>{const I=new Map;if(y)for(const $ of Np)for(const L of cu(y,$))I.set(L.repoId,L.repoFullName);return[...I.entries()].map(([$,L])=>({id:$,fullName:L})).sort(($,L)=>$.fullName.localeCompare(L.fullName))},[y]),T=cu(y,w),N=P==null?T:T.filter(I=>P.includes(I.repoId)),b=I=>{const $=I.authorId!=null?g.get(I.authorId):void 0,L={id:I.prId,number:I.prNumber,title:I.prTitle,repoFullName:I.repoFullName,authorLogin:($==null?void 0:$.githubLogin)??null,authorDisplayName:($==null?void 0:$.displayName)??null,authorAvatarUrl:($==null?void 0:$.avatarUrl)??null};a(L)};return n.jsxs("div",{className:"mx-auto max-w-6xl space-y-4 p-4",children:[n.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[n.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:"Flow metrics"}),n.jsx("span",{className:"rounded bg-violet-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:"Pro"}),y&&n.jsx("span",{className:"text-[11px] text-gray-400",children:"sprint: last 2 weeks · where issues cluster"}),n.jsxs("button",{type:"button",onClick:()=>void d(),disabled:p,className:"ml-auto rounded border border-gray-300 px-1.5 py-0.5 text-[11px] font-medium hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:[n.jsx("span",{"aria-hidden":!0,className:p?"animate-spin":"",children:"↻"})," ","Refresh"]})]}),n.jsx("div",{role:"tablist",className:"flex flex-wrap gap-1 border-b border-gray-200 dark:border-gray-800",children:Np.map(I=>{const $=I===w,L=cu(y,I).length;return n.jsxs("button",{type:"button",role:"tab","aria-selected":$,onClick:()=>v(I),className:`-mb-px rounded-t-md border border-b-0 px-3 py-1.5 text-xs font-medium ${$?"border-gray-300 bg-white text-violet-600 dark:border-gray-700 dark:bg-gray-950 dark:text-violet-300":"border-transparent text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-900/60"}`,children:[Lm[I].label,y?n.jsx("span",{className:"ml-1 text-gray-400",children:L}):null]},I)})}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("div",{className:"text-[11px] text-gray-400",children:Lm[w].blurb}),N.length!==T.length&&n.jsxs("span",{className:"text-[11px] text-gray-400",children:["· ",N.length," of ",T.length]}),n.jsx("div",{className:"ml-auto",children:n.jsx(Vk,{repos:S,selected:P,onChange:E})})]}),i?n.jsx("div",{className:"space-y-2",children:[0,1,2,3].map(I=>n.jsx("div",{className:"h-8 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"},I))}):u?n.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load the metric detail."}):N.length===0?n.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:T.length===0?"Nothing to show for this metric in the current sprint. 🎉":"No PRs for the selected repos — adjust the repo filter."}):n.jsx(ej,{m:w,rows:N,usersById:g,onOpen:b})]})}function nj(e,s,a=!0){return qe({queryKey:["bot-vendor-prs",e,s],queryFn:()=>ge.botVendorPrs(e,s),enabled:a&&e!=null,refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4})}const rj=[{key:"rolling_7",label:"7d"},{key:"rolling_14",label:"14d"},{key:"rolling_30",label:"30d"},{key:"sprint",label:"Sprint"}],sj=[];function aj({ci:e}){const s=e?ur[e]:null;return n.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:s?{background:s.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"},"aria-hidden":!0}),(s==null?void 0:s.label)??"no checks"]})}function lj({pr:e}){return n.jsxs("span",{className:"whitespace-nowrap text-[11px]",children:[n.jsxs("span",{className:"text-gray-400",children:[e.changedFiles,"f"]})," ",n.jsxs("span",{className:"font-mono text-green-600 dark:text-green-400",children:["+",e.additions]})," ",n.jsxs("span",{className:"font-mono text-red-500 dark:text-red-400",children:["−",e.deletions]})]})}function oj({id:e,usersById:s}){const a=e!=null?s.get(e):void 0;return n.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-600 dark:text-gray-300",children:[n.jsx(ht,{user:a,size:14}),n.jsx(sn,{user:a,fallbackId:e??0})]})}function ij({pr:e}){return n.jsxs("span",{className:"whitespace-nowrap text-[11px] tabular-nums",children:[n.jsx("span",{className:"text-gray-700 dark:text-gray-200",children:e.botThreads}),e.botUntouched>0&&n.jsxs("span",{className:"ml-1 text-amber-600 dark:text-amber-400",title:`${e.botUntouched} still untouched — no reply, no follow-up commit`,children:[e.botUntouched," untouched"]})]})}function cj({pr:e}){const s=e.botThreads>0?Math.round(e.botActedOn/e.botThreads*100):null;return n.jsxs("span",{className:"whitespace-nowrap text-[11px] tabular-nums",children:[n.jsx("span",{className:"text-gray-700 dark:text-gray-200",children:e.botActedOn}),s!=null&&n.jsxs("span",{className:"ml-1 text-gray-400",children:[s,"%"]})]})}function uj({pr:e,usersById:s,onOpen:a}){return n.jsxs("tr",{className:"border-t border-gray-100 align-top hover:bg-gray-50/70 dark:border-gray-800/60 dark:hover:bg-gray-900/40",children:[n.jsx("td",{className:"py-1.5 pr-3",children:n.jsxs("button",{type:"button",onClick:()=>a(e),className:"block max-w-md text-left hover:underline",title:`${e.repoFullName} #${e.prNumber} — ${e.prTitle}`,children:[n.jsxs("span",{className:"block truncate font-mono text-[11px] text-gray-400",children:[e.repoFullName," #",e.prNumber]}),n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-gray-800 dark:text-gray-100",children:e.prTitle}),e.botOnly&&n.jsx("span",{className:"shrink-0 rounded bg-amber-500/10 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-amber-700 dark:text-amber-300",title:"Only bots touched this PR — no human review or comment",children:"bot-only"})]})]})}),n.jsx("td",{className:"py-1.5 pr-3",children:n.jsx(ij,{pr:e})}),n.jsx("td",{className:"py-1.5 pr-3",children:n.jsx(cj,{pr:e})}),n.jsx("td",{className:"py-1.5 pr-3",children:n.jsx(aj,{ci:e.ciStatus})}),n.jsx("td",{className:"py-1.5 pr-3",children:n.jsx(lj,{pr:e})}),n.jsx("td",{className:"py-1.5 pr-3",children:n.jsx(oj,{id:e.authorId,usersById:s})}),n.jsx("td",{className:"py-1.5 pr-3 text-[11px] text-gray-500 dark:text-gray-400",children:e.lastBotActivityAt?St(e.lastBotActivityAt):"—"})]})}function dj({rows:e,usersById:s,onOpen:a}){return n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full min-w-[720px] border-collapse text-sm",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"text-left text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:[n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Pull request"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Bot threads"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Acted on"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"CI"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Diff"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Author"}),n.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Last activity"})]})}),n.jsx("tbody",{children:e.map(o=>n.jsx(uj,{pr:o,usersById:s,onOpen:a},o.prId))})]})})}function fj(){var S,T,N;const e=te(b=>b.botPrsFocus),s=te(b=>b.consumeBotPrsFocus),a=te(b=>b.botAnalyticsWindow),o=te(b=>b.setBotAnalyticsWindow),i=De(b=>b.openPrDetailTab),{data:u}=$n(),d=x.useMemo(()=>ln(u),[u]),p=gh(a),m=((S=p.data)==null?void 0:S.vendors)??sj,[g,w]=x.useState(e);x.useEffect(()=>{e&&(w(e),s())},[e,s]),x.useEffect(()=>{m.length!==0&&w(b=>b!=null&&m.some(I=>I.kind===b)?b:m[0].kind)},[m]);const v=nj(g,a),y=((T=v.data)==null?void 0:T.prs)??[],j=((N=p.data)==null?void 0:N.totals.botOnlyPrs)??0,R=b=>{const I=b.authorId!=null?d.get(b.authorId):void 0,$={id:b.prId,number:b.prNumber,title:b.prTitle,repoFullName:b.repoFullName,authorLogin:(I==null?void 0:I.githubLogin)??null,authorDisplayName:(I==null?void 0:I.displayName)??null,authorAvatarUrl:(I==null?void 0:I.avatarUrl)??null};i($)},P=p.isFetching||v.isFetching,E=()=>{p.refetch(),v.refetch()};return n.jsxs("div",{className:"mx-auto max-w-6xl space-y-4 p-4",children:[n.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[n.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:"Bot PRs"}),n.jsx("span",{className:"rounded bg-violet-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-violet-600 dark:text-violet-300",children:"Pro"}),n.jsxs("span",{className:"text-[11px] text-gray-400",children:["PRs an automated reviewer touched · most-recent activity first",j>0&&n.jsxs(n.Fragment,{children:[" · ",n.jsxs("span",{className:"text-amber-600 dark:text-amber-400",children:[j," bot-only"]})]})]}),n.jsx("div",{className:"ml-auto inline-flex overflow-hidden rounded border border-gray-300 dark:border-gray-700",children:rj.map(b=>n.jsx("button",{type:"button",onClick:()=>o(b.key),className:`px-2 py-0.5 text-[11px] font-medium ${a===b.key?"bg-violet-500/15 text-violet-700 dark:text-violet-300":"text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800"}`,children:b.label},b.key))}),n.jsxs("button",{type:"button",onClick:E,disabled:P,className:"rounded border border-gray-300 px-1.5 py-0.5 text-[11px] font-medium hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:[n.jsx("span",{"aria-hidden":!0,className:P?"animate-spin":"",children:"↻"})," ","Refresh"]})]}),p.isLoading?n.jsx("div",{className:"space-y-2",children:[0,1,2,3].map(b=>n.jsx("div",{className:"h-8 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"},b))}):p.isError?n.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load bot analytics."}):m.length===0?n.jsxs("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:["No automated-reviewer activity in this window.",n.jsx("div",{className:"mt-1 text-[11px]",children:"When review bots (CodeRabbit, Copilot, in-house AI…) comment on your PRs, the PRs they touched land here."})]}):n.jsxs(n.Fragment,{children:[n.jsx("div",{role:"tablist",className:"flex flex-wrap gap-1 border-b border-gray-200 dark:border-gray-800",children:m.map(b=>{const I=b.kind===g,$=an(b.kind);return n.jsxs("button",{type:"button",role:"tab","aria-selected":I,onClick:()=>w(b.kind),className:`-mb-px flex items-center gap-1 rounded-t-md border border-b-0 px-3 py-1.5 text-xs font-medium ${I?"border-gray-300 bg-white dark:border-gray-700 dark:bg-gray-950":"border-transparent text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-900/60"}`,style:I?{color:$.color}:void 0,children:[n.jsx("span",{"aria-hidden":!0,children:"🤖"}),b.label,n.jsx("span",{className:"ml-1 text-gray-400",children:b.threads})]},b.kind)})}),v.isLoading?n.jsx("div",{className:"space-y-2",children:[0,1,2,3].map(b=>n.jsx("div",{className:"h-8 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"},b))}):v.isError?n.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load the PR list."}):y.length===0?n.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:"No PRs for this bot in the window."}):n.jsx(dj,{rows:y,usersById:d,onOpen:R})]})]})}function pj(){const e=te(g=>g.selectedPrId),s=te(g=>g.selectedThreadId),a=te(g=>g.clearSelection),o=x.useDeferredValue(e),i=e??o,u=De(g=>g.activeTab),d=Au(u),p=(d==null?void 0:d.kind)==="pr-detail"?d.prId:null,m=i!=null&&i!==p;return n.jsxs("div",{className:"relative h-full","data-testid":"detail-pane",children:[e!=null&&n.jsx("div",{className:"absolute right-2 top-1.5 z-10 flex items-center gap-2",children:n.jsx("button",{type:"button","data-testid":"detail-clear",onClick:a,className:"rounded px-2 py-0.5 text-xs text-gray-400 hover:text-gray-600",title:"Clear selection (Esc)",children:"✕"})}),m?n.jsx(Nh,{prId:i,selectedThreadId:s},i):n.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."})]})}function FN(e){return qe({queryKey:["claude-review",e],queryFn:()=>ge.claudeReview(e),enabled:e!=null})}function LN(e){return qe({queryKey:["claude-review-by-id",e],queryFn:()=>ge.claudeReviewById(e),enabled:e!=null})}function _N(e,s){const a=Be(),[o,i]=x.useState(null);return x.useEffect(()=>{if(e==null||!s){i(null);return}const u=new AbortController;let d=!1;const p=()=>{d||(d=!0,a.invalidateQueries({queryKey:["claude-review",e]}))};return ti(`/api/prs/${e}/claude-review/stream`,{signal:u.signal,onEvent:m=>{m.type==="done"?(p(),i({status:m.status,reviewId:m.reviewId,progress:null})):i({status:m.status,reviewId:m.reviewId,progress:m.progress})}}).catch(()=>{}),()=>u.abort()},[e,s,a]),{status:o}}function ON(e){const s=Be();return Ue({mutationFn:a=>ge.generateClaudeReview(e,a.model,a.mode),onSuccess:()=>{te.getState().bumpClaudeReviewKickoff(),s.invalidateQueries({queryKey:["claude-review",e]}),s.invalidateQueries({queryKey:["claude-review-status",e]})}})}function DN(e){const s=Be();return Ue({mutationFn:a=>ge.postClaudeFinding(a.findingId),onSuccess:()=>void s.invalidateQueries({queryKey:["claude-review",e]})})}function BN(e){const s=Be();return Ue({mutationFn:()=>ge.cancelClaudeReview(e),onSuccess:()=>void s.invalidateQueries({queryKey:["claude-review",e]})})}function zN(e){const s=Be();return Ue({mutationFn:a=>ge.updateClaudeReview(a.reviewId,{userBody:a.userBody,userVerdict:a.userVerdict}),onSuccess:()=>void s.invalidateQueries({queryKey:["claude-review",e]})})}function qN(e){const s=Be();return Ue({mutationFn:a=>ge.updateClaudeFinding(a.findingId,{included:a.included,editedBody:a.editedBody}),onSuccess:()=>void s.invalidateQueries({queryKey:["claude-review",e]})})}function mj(e){return qe({queryKey:["claude-reviews-active"],queryFn:ge.activeClaudeReviews,enabled:e,refetchInterval:2500})}function UN(e){const s=Be();return Ue({mutationFn:a=>ge.setClaudeKey(a),onSuccess:()=>void s.invalidateQueries({queryKey:["claude-review",e]})})}function KN(e){const s=Be();return Ue({mutationFn:a=>ge.postClaudeReview(a.reviewId,a.userVerdict,a.dryRun??!1),onSuccess:(a,o)=>{o.dryRun||s.invalidateQueries({queryKey:["claude-review",e]})}})}const g0="pierre:notifications",uu="pierre:notif-pref";function Om(){try{return localStorage.getItem(g0)==="1"}catch{return!1}}function x0(){const[e,s]=x.useState(Om);x.useEffect(()=>{const o=()=>s(Om());return window.addEventListener(uu,o),window.addEventListener("storage",o),()=>{window.removeEventListener(uu,o),window.removeEventListener("storage",o)}},[]);const a=x.useCallback(o=>{try{localStorage.setItem(g0,o?"1":"0")}catch{}s(o),window.dispatchEvent(new Event(uu))},[]);return[e,a]}const hj="pierre:reviewSoundMuted";let To=null;function y0(){try{if(To!=null)return To;const e=window,s=window.AudioContext??e.webkitAudioContext;return s==null?null:(To=new s,To)}catch{return null}}function gj(){try{return localStorage.getItem(hj)==="true"}catch{return!1}}function HN(){try{const e=y0();e!=null&&e.state==="suspended"&&e.resume()}catch{}}function Dm(e,s,a,o){const i=e.createOscillator(),u=e.createGain();i.type="sine",i.frequency.value=s;const d=.12;u.gain.setValueAtTime(1e-4,a),u.gain.exponentialRampToValueAtTime(d,a+.02),u.gain.exponentialRampToValueAtTime(1e-4,a+o),i.connect(u),u.connect(e.destination),i.start(a),i.stop(a+o+.02)}function xj(){try{if(gj())return;const e=y0();if(e==null)return;e.state==="suspended"&&e.resume();const s=e.currentTime+.01;Dm(e,660,s,.15),Dm(e,990,s+.13,.18)}catch{}}function yj(e){if(e.length===0||typeof Notification>"u"||Notification.permission!=="granted")return;const s=e.length===1?"Claude review ready":`${e.length} Claude reviews ready`,a=e.length===1?`${e[0].repoFullName} #${e[0].prNumber}`:e.slice(0,3).map(o=>`${o.repoFullName} #${o.prNumber}`).join(" · ");try{const o=new Notification(s,{body:a,tag:"pierre-claude-review"});o.onclick=()=>{window.focus(),o.close()}}catch{}}const vj={cloning:"Cloning",fetching_diff:"Fetching diff",deciding:"Deciding scope",reviewing:"Reviewing",persisting:"Saving findings"};function bj(){const e=yn().claudeReview,s=te(b=>b.claudeReviewKickoff),a=te(b=>b.openClaudeReview),[o]=x0(),i=x.useRef(o);i.current=o;const[u,d]=x.useState(!1);x.useEffect(()=>{s>0&&d(!0)},[s]);const{data:p,dataUpdatedAt:m}=mj(e&&u);x.useEffect(()=>{u&&((p==null?void 0:p.reviews.length)??0)===0&&d(!1)},[m]);const[g,w]=x.useState({}),[v,y]=x.useState({}),j=x.useRef(null),R=((p==null?void 0:p.reviews)??[]).map(b=>`${b.reviewId}:${b.phase??""}`).join(",");x.useEffect(()=>{const b=(p==null?void 0:p.reviews)??[],I=new Set(b.map(L=>L.reviewId)),$=j.current;if($!=null){const L=[];for(const[q,Q]of $)I.has(q)||L.push(Q);L.length>0&&(xj(),i.current&&yj(L))}j.current=new Map(b.map(L=>[L.reviewId,{repoFullName:L.repoFullName,prNumber:L.prNumber,prTitle:L.prTitle}])),w(L=>{const q={...L};for(const Q of b)q[Q.reviewId]={reviewId:Q.reviewId,prId:Q.prId,repoFullName:Q.repoFullName,prNumber:Q.prNumber,prTitle:Q.prTitle,phase:Q.phase,done:!1};for(const Q of Object.values(q))!I.has(Q.reviewId)&&!Q.done&&(q[Q.reviewId]={...Q,done:!0});return q})},[R]);const P=Object.values(g).filter(b=>!v[b.reviewId]);if(!e||P.length===0)return null;const E=P.filter(b=>!b.done),S=E.length===0,T=()=>{y(b=>{const I={...b};for(const $ of P)I[$.reviewId]=!0;return I})},N=b=>y(I=>({...I,[b]:!0}));return n.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:n.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:[n.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 px-3 py-1.5 dark:border-gray-800",children:[n.jsxs("span",{className:"text-xs font-semibold",children:["Claude reviews",E.length>0&&n.jsxs("span",{className:"ml-1 font-normal text-gray-400",children:["· ",E.length," running"]})]}),S&&n.jsx("button",{type:"button",onClick:T,className:"text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:"Dismiss all"})]}),n.jsx("ul",{className:"max-h-64 divide-y divide-gray-100 overflow-auto dark:divide-gray-800",children:P.map(b=>n.jsxs("li",{className:"px-3 py-2 text-xs",children:[n.jsxs("button",{type:"button",onClick:()=>a({id:b.prId,number:b.prNumber,title:b.prTitle,repoFullName:b.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null}),className:"block w-full text-left",title:"Open this review",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[b.done?n.jsx("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full bg-green-500"}):n.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"}),n.jsxs("span",{className:"truncate font-medium text-blue-600 hover:underline dark:text-blue-400",children:[b.repoFullName," #",b.prNumber]})]}),n.jsx("div",{className:"mt-0.5 truncate text-gray-500",children:b.prTitle}),n.jsx("div",{className:"mt-0.5 text-gray-400",children:b.done?"Ready — click to view":`${b.phase!=null?vj[b.phase]??b.phase:"Starting"}…`})]}),b.done&&n.jsx("div",{className:"mt-1 text-right",children:n.jsx("button",{type:"button",onClick:()=>N(b.reviewId),className:"text-[11px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:"dismiss"})})]},b.reviewId))})]})})}function wj({repos:e,statuses:s,cancelling:a,onCancel:o}){const i=m=>s==null?void 0:s.find(g=>g.repoId===m),u=m=>{if(s===void 0)return!0;const g=i(m);return g===void 0||g.status==="running"},d=e.filter(m=>!u(m.id)).length,p=e.length>0&&d===e.length;return n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",role:"presentation",children:n.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:[n.jsx("div",{className:"mb-3 flex items-center justify-between",children:n.jsx("h2",{className:"text-sm font-semibold",children:a?"Cancelling…":e.length===0?"Starting sync…":p?"Sync complete":`Syncing ${e.length} repo${e.length===1?"":"s"}`})}),n.jsx("ul",{className:"space-y-3",children:e.map(m=>{var R,P;const g=i(m.id),w=u(m.id),v=(g==null?void 0:g.status)==="error",y=((R=g==null?void 0:g.progress)==null?void 0:R.prsProcessed)??0,j=w?Math.round((((P=g==null?void 0:g.progress)==null?void 0:P.percent)??0)*100):100;return n.jsxs("li",{children:[n.jsxs("div",{className:"mb-1 flex items-baseline justify-between gap-2 text-xs",children:[n.jsx("span",{className:"truncate font-medium",title:m.fullName,children:m.fullName}),n.jsx("span",{className:"shrink-0 text-gray-500",children:v?n.jsx("span",{className:"text-red-500",children:"error"}):w?`${j}%${y>0?` · ${y} PRs`:""}`:n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["✓ done",y>0?` · ${y} PRs`:""]})})]}),n.jsx("div",{className:"h-2 w-full overflow-hidden rounded bg-gray-200 dark:bg-gray-800",children:n.jsx("div",{className:`h-2 rounded transition-all duration-500 ${v?"bg-red-500":w?"bg-blue-500":"bg-green-500"}`,style:{width:`${v?100:j}%`}})})]},m.id)})}),n.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 text-xs text-gray-500",children:[n.jsxs("span",{children:[d," of ",e.length," repo",e.length===1?"":"s"," complete"]}),n.jsx("button",{type:"button",onClick:o,disabled:a,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:a?"Cancelling…":"Cancel"})]})]})})}function Bm({spinning:e=!1,size:s=14}){return n.jsxs("svg",{viewBox:"0 0 24 24",width:s,height:s,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:e?"animate-spin":void 0,children:[n.jsx("polyline",{points:"23 4 23 10 17 10"}),n.jsx("polyline",{points:"1 20 1 14 7 14"}),n.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function kj({size:e=14}){return n.jsxs("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[n.jsx("path",{d:"M12 3v12"}),n.jsx("polyline",{points:"7 10 12 15 17 10"}),n.jsx("line",{x1:"5",y1:"21",x2:"19",y2:"21"})]})}function jj(e){let s=null;for(const a of e){const o=a.lastIncrementalSyncAt??a.lastFullSyncAt;o&&(!s||o>s)&&(s=o)}return s}const Qo=5,Iu=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function v0(e){const s=new Date,a=new Date(s);return a.setSeconds(0,0),a.setMinutes(Math.floor(s.getMinutes()/e)*e+e),a}function Nj(e){const s=v0(Qo),a=Math.max(1,Math.round((s.getTime()-Date.now())/6e4)),o=e?[`Last synced ${Iu(new Date(e))}`]:[];return o.push(`Syncs automatically every ${Qo} minutes`),o.push(`Next sync ~${Iu(s)} (in ${a} min)`),o.join(`
49
+ `)}function Sj(){const e=Be(),[s,a]=x.useState(!1),[o,i]=x.useState(!1),[u,d]=x.useState(!1),[p,m]=x.useState(!1),[g,w]=x.useState([]),[v,y]=x.useState(!1),j=x.useRef(null),{data:R}=qe({queryKey:["repos"],queryFn:ge.listRepos,refetchInterval:s?3e3:3e4}),P=(R??[]).map(ne=>ne.id).join(","),{data:E}=qe({queryKey:["sync-status",P],enabled:s&&!!R&&R.length>0,queryFn:()=>Promise.all((R??[]).map(ne=>ge.syncStatus(ne.id))),refetchInterval:1500}),S=new Set(g),T=S.size===0?R??[]:(R??[]).filter(ne=>S.has(ne.id)),N=new Set(T.map(ne=>ne.id)),b=E==null?void 0:E.filter(ne=>N.has(ne.repoId)),I=(b??[]).filter(ne=>ne.status==="running"),$=I.length,L=$>0&&I.every(ne=>{var Pe;return((Pe=ne.progress)==null?void 0:Pe.foregroundComplete)===!0}),q=jj(R??[]),Q=x.useRef(q),_=x.useRef(!1),Y=x.useRef(null),X=()=>{Y.current!=null&&(clearTimeout(Y.current),Y.current=null)},B=()=>{d(!1),_.current=!1,X()};x.useEffect(()=>X,[]),Yn(j,()=>y(!1),v),x.useEffect(()=>{if(!v)return;const ne=Pe=>{Pe.key==="Escape"&&(Pe.stopPropagation(),y(!1))};return document.addEventListener("keydown",ne),()=>document.removeEventListener("keydown",ne)},[v]);const O=()=>{e.invalidateQueries({queryKey:["timeline"]}),e.invalidateQueries({queryKey:["open-prs"]}),e.invalidateQueries({queryKey:["users"]}),e.invalidateQueries({queryKey:["mergers"]}),e.invalidateQueries({queryKey:["my-turn"]}),e.invalidateQueries({queryKey:["me"]});for(const ne of Ou)e.invalidateQueries({queryKey:[ne]})};x.useEffect(()=>{Q.current!==q&&(Q.current=q,O())},[q]),x.useEffect(()=>{!s||!L||_.current||(_.current=!0,i(!1),O())},[s,L]),x.useEffect(()=>{$>0&&d(!0)},[$]),x.useEffect(()=>{s&&u&&E&&$===0&&(a(!1),d(!1),O(),X(),Y.current=setTimeout(()=>{i(!1),Y.current=null},1e3))},[s,u,E,$]);const H=te(ne=>ne.syncModalSignal),ee=te(ne=>ne.syncModalRepoId),ce=x.useRef(H);if(x.useEffect(()=>{H!==ce.current&&(ce.current=H,ee!=null&&(o?w(ne=>ne.includes(ee)?ne:[...ne,ee]):(w([ee]),i(!0),a(!0),B()),e.invalidateQueries({queryKey:["repos"]}),e.invalidateQueries({queryKey:["sync-status"]})))},[H,e]),!R||R.length===0)return null;const C=R.find(ne=>ne.lastSyncStatus==="error"),F=async(ne=!1)=>{a(!0),i(!0),w([]),B(),await Promise.allSettled(R.map(Pe=>ge.syncRepo(Pe.id,ne))),e.invalidateQueries({queryKey:["repos"]}),e.invalidateQueries({queryKey:["sync-status"]})},K=async()=>{m(!0),X();const ne=(b??[]).filter(se=>se.status==="running").map(se=>se.repoId),Pe=ne.length?ne:T.map(se=>se.id);await Promise.allSettled(Pe.map(se=>ge.cancelSync(se))),a(!1),d(!1),m(!1),i(!1),e.invalidateQueries({queryKey:["repos"]}),O()},ae=L?"loading older history…":$>0?`syncing ${$} repo${$===1?"":"s"}…`:"syncing…";return n.jsxs(n.Fragment,{children:[o&&n.jsx(wj,{repos:T,statuses:b,cancelling:p,onCancel:()=>void K()}),n.jsxs("div",{ref:j,className:"relative",children:[n.jsxs("button",{type:"button",onClick:()=>y(ne=>!ne),"aria-haspopup":"menu","aria-expanded":v,title:C?`Sync error: ${C.fullName}${C.lastSyncError?` — ${C.lastSyncError}`:""}`:Nj(q),className:`relative flex items-center gap-1 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 ${v?"bg-gray-100 dark:bg-gray-800":""}`,children:[n.jsx(Bm,{spinning:s}),n.jsx("span",{className:"hidden sm:inline",children:"Sync"}),C&&!s&&n.jsx("span",{"aria-hidden":!0,className:"absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-red-500 ring-1 ring-white dark:ring-gray-900"}),n.jsx("span",{"aria-hidden":!0,className:"text-[9px] text-gray-400",children:"▾"})]}),v&&n.jsxs("div",{role:"menu","aria-label":"Sync menu",className:"absolute right-0 top-full z-[60] mt-1 w-64 rounded-lg border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[n.jsx("div",{className:"px-3 py-1.5 text-[11px] leading-snug text-gray-500 dark:text-gray-400",children:C?n.jsxs("span",{className:"text-red-500",children:["Sync error: ",C.fullName]}):s?n.jsx("span",{children:ae}):q?n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"text-gray-600 dark:text-gray-300",children:["Synced ",St(q)]}),n.jsx("br",{}),n.jsxs("span",{children:["Auto-syncs every ",Qo," min · next ~",Iu(v0(Qo))]})]}):"Not synced yet"}),n.jsx("div",{className:"my-1 border-t border-gray-100 dark:border-gray-800"}),n.jsxs("button",{role:"menuitem",type:"button",disabled:s,onClick:()=>{y(!1),F(!1)},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-gray-700 hover:bg-gray-100 disabled:opacity-50 dark:text-gray-200 dark:hover:bg-gray-800",children:[n.jsx(Bm,{spinning:s}),"Sync now"]}),n.jsxs("button",{role:"menuitem",type:"button",disabled:s,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?")&&(y(!1),F(!0))},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-gray-700 hover:bg-gray-100 disabled:opacity-50 dark:text-gray-200 dark:hover:bg-gray-800",title:"Force a full backfill for all repos",children:[n.jsx(kj,{}),"Deep re-sync…"]})]})]})]})}function Cj(){const e=te(b=>b.searchQuery),s=te(b=>b.setSearchQuery),a=De(b=>b.openPrFocusTab),{data:o}=Fu(),{data:i}=Lu(),{data:u}=Mr(),{data:d}=$n(),[p,m]=x.useState(!1),[g,w]=x.useState(-1),v=x.useRef(null),y=x.useMemo(()=>{const b=new Map;for(const I of u??[])b.set(I.id,I.fullName);return b},[u]),j=x.useMemo(()=>ln(d),[d]),R=x.useMemo(()=>{const b=new Map;for(const I of(o==null?void 0:o.prs)??[])b.set(I.id,I);for(const I of(i==null?void 0:i.prs)??[])b.has(I.id)||b.set(I.id,I);return[...b.values()]},[o,i]),P=x.useMemo(()=>{const b=e.trim().toLowerCase();if(!b)return[];const I=b.replace(/^#/,""),$=I.length>0&&/^\d+$/.test(I),L=R.filter(q=>q.title.toLowerCase().includes(b)||$&&String(q.number).includes(I));if($){const q=Q=>{const _=String(Q.number);return _===I?0:_.startsWith(I)?1:_.includes(I)?2:3};L.sort((Q,_)=>q(Q)-q(_))}return L.slice(0,30)},[R,e]),E=p&&e.trim().length>0,S=g>=0&&g<P.length?P[g].id:null;Yn(v,()=>m(!1),E),x.useEffect(()=>{var b,I;S!=null&&((I=(b=v.current)==null?void 0:b.querySelector(`#pr-result-${S}`))==null||I.scrollIntoView({block:"nearest"}))},[S]);const T=b=>{if(!b)return;const I=b.authorId!=null?j.get(b.authorId):void 0;a({id:b.id,number:b.number,title:b.title,repoFullName:y.get(b.repoId)??`repo ${b.repoId}`,authorLogin:(I==null?void 0:I.githubLogin)??null,authorDisplayName:(I==null?void 0:I.displayName)??null,authorAvatarUrl:(I==null?void 0:I.avatarUrl)??null}),m(!1)},N=b=>{if(b.key==="Escape"){m(!1),b.target.blur();return}!E||P.length===0||(b.key==="ArrowDown"?(b.preventDefault(),w(I=>(I+1)%P.length)):b.key==="ArrowUp"?(b.preventDefault(),w(I=>I<=0?P.length-1:I-1)):b.key==="Enter"&&(b.preventDefault(),T(P[g>=0?g:0])))};return n.jsxs("div",{ref:v,className:"relative",children:[n.jsx("input",{type:"search",value:e,placeholder:"Search PRs (title or number)…",onChange:b=>{s(b.target.value),w(-1),m(!0)},onFocus:()=>m(!0),onKeyDown:N,role:"combobox","aria-expanded":E,"aria-controls":"pr-search-results","aria-autocomplete":"list","aria-activedescendant":S!=null?`pr-result-${S}`:void 0,"aria-label":"Search PRs by title or number",className:"w-56 rounded border border-gray-300 bg-transparent px-2 py-0.5 text-xs focus:border-blue-500 focus:outline-none dark:border-gray-700"}),E&&n.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:P.length===0?n.jsx("div",{className:"px-3 py-2 text-xs text-gray-500",children:"No matching PRs."}):P.map((b,I)=>{const $=b.authorId!=null?j.get(b.authorId):void 0;return n.jsxs("button",{id:`pr-result-${b.id}`,type:"button",role:"option","aria-selected":I===g,onMouseEnter:()=>w(I),onClick:()=>T(b),className:`flex w-full flex-col gap-0.5 px-3 py-1.5 text-left ${I===g?"bg-gray-100 dark:bg-gray-800":""} hover:bg-gray-100 dark:hover:bg-gray-800`,children:[n.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-400",children:[n.jsx(ht,{user:$,size:12}),n.jsx("span",{className:"truncate",title:ft($,b.authorId),children:ft($,b.authorId)}),n.jsx("span",{"aria-hidden":!0,children:"·"}),n.jsxs("span",{className:"shrink-0",children:[y.get(b.repoId)??`repo ${b.repoId}`," · #",b.number]})]}),n.jsx("span",{className:"truncate text-xs",title:b.title,children:b.title})]},b.id)})})]})}function Rj(){const{data:e}=_u(),s=De(w=>w.activeTab),a=De(w=>w.showActivity),o=te(w=>w.setActivityRepo),i=te(w=>w.setFeedMyTurnOnly),[u,d]=x.useState(!1);if(u||!(e!=null&&e.user)||s==="activity")return null;const p=e.newFeedItems??0;if(p<=0)return null;const m=e.feedLastSeenAt,g=()=>{zk(),o("feed"),i(!0),a(),d(!0)};return n.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:[n.jsxs("button",{type:"button",onClick:g,title:"Show your feed",className:"flex min-w-0 flex-1 items-center gap-2 text-left hover:underline",children:[n.jsx("span",{className:"font-medium",children:"Welcome back"}),n.jsxs("span",{className:"min-w-0 truncate text-amber-700/80 dark:text-amber-300/80",children:["· ",p," new item",p===1?"":"s"," in your feed",m?` since you were last here ${St(m)}`:""]})]}),n.jsx("button",{type:"button",onClick:g,className:"shrink-0 rounded border border-amber-400 px-2 py-0.5 font-medium hover:bg-amber-100 dark:border-amber-700 dark:hover:bg-amber-900/40",children:"Show feed"}),n.jsx("button",{type:"button",onClick:()=>d(!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 Ij({onClose:e}){return x.useEffect(()=>{const s=a=>{a.key==="Escape"&&(a.stopImmediatePropagation(),e())};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[e]),n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:e,role:"presentation",children:n.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:s=>s.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Pierre help",children:[n.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[n.jsx("h2",{className:"brand-title",children:"Pierre"}),n.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:"✕"})]}),n.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:[n.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."}),n.jsxs(rs,{title:"Track repositories",children:["Add repos in the filter bar’s ",n.jsx("em",{children:"add repo"})," box as ",n.jsx(Tj,{children:"owner/name"}),". Pierre syncs their PR activity every few minutes into a local file — nothing leaves your machine."]}),n.jsxs(rs,{title:"Read the timeline",children:["Rows are grouped ",n.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."]}),n.jsxs(rs,{title:"Focus mode",children:["To isolate one PR and just its contributors: double-click its bar, click"," ",n.jsx("strong",{children:"Focus"})," in the detail pane, or click a cross-person marker. Leave focus with the ",n.jsx("strong",{children:"✕"})," on the header"," ",n.jsx("strong",{children:"Focus mode"})," badge, ",n.jsx(ja,{children:"Esc"}),", or the browser"," ",n.jsx("strong",{children:"Back"})," button."]}),n.jsxs(rs,{title:"Detail pane",children:["Selecting a PR opens the bottom pane with ",n.jsx("strong",{children:"Overview"})," (checks, summary, comments), ",n.jsx("strong",{children:"Threads"}),", and ",n.jsx("strong",{children:"Activity"}),". The ",n.jsx("em",{children:"Show"})," links jump back to that moment on the timeline; drag the divider to resize the pane."]}),n.jsxs(rs,{title:"Filter",children:["Narrow by date range, members (auto-scoped to who’s active in view), event categories, and thread states. ",n.jsx("em",{children:"Exclude bots"})," hides renovate / dependabot / CI noise."]}),n.jsxs(rs,{title:"Open-PRs strip",children:["The collapsible strip up top lists currently-open PRs — toggle between"," ",n.jsx("strong",{children:"all"}),", ",n.jsx("strong",{children:"my turn"}),", and"," ",n.jsx("strong",{children:"needs attention"}),"."]}),n.jsxs(rs,{title:"Activity & Insights",children:["Clicking an item in the ",n.jsx("strong",{children:"Activity Feed"})," opens that PR's detail tab, where ",n.jsx("strong",{children:"Show"})," / ",n.jsx("strong",{children:"Focus"})," drive the timeline; the feed's ",n.jsx("strong",{children:"My Turn only"})," toggle narrows it to what needs you."," ",n.jsx("strong",{children:"Insights"})," opens a per-repo snapshot (open / merged / stalled, time-to-first-review, review load). Save filter combinations as named ",n.jsx("strong",{children:"Views"}),", and use the bell to get notified when something new lands in your queue."]}),n.jsxs(rs,{title:"Keyboard",children:[n.jsx(ja,{children:"/"})," focus the filter · ",n.jsx(ja,{children:"j"}),"/",n.jsx(ja,{children:"k"})," cycle PRs ·"," ",n.jsx(ja,{children:"i"})," Insights · ",n.jsx(ja,{children:"Esc"})," exit focus, else clear the selection."]})]})]})})}function rs({title:e,children:s}){return n.jsxs("section",{children:[n.jsx("h3",{className:"mb-1 font-semibold text-gray-800 dark:text-gray-100",children:e}),n.jsx("p",{children:s})]})}function Tj({children:e}){return n.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 ja({children:e}){return n.jsx("kbd",{className:"rounded border border-gray-300 bg-gray-100 px-1 text-[11px] font-medium text-gray-600 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",children:e})}function or({title:e,desc:s,children:a}){return n.jsxs("section",{className:"border-b border-gray-100 pb-4 last:border-b-0 dark:border-gray-800",children:[n.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:e}),s!=null&&n.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:s}),n.jsx("div",{className:"mt-2.5 space-y-2.5",children:a})]})}function Nt({label:e,htmlFor:s,hint:a,children:o}){return n.jsxs("label",{htmlFor:s,className:"flex flex-col gap-1 text-xs",children:[n.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:e}),o,a!=null&&n.jsx("span",{className:"text-[11px] text-gray-400",children:a})]})}const rt="w-full rounded border border-gray-300 bg-white px-2 py-1 text-xs text-gray-800 outline-none focus:border-sky-400 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100";function Pr({dirty:e,saving:s,onClick:a}){return n.jsx("button",{type:"button",onClick:a,disabled:!e||s,className:"self-start rounded bg-sky-600 px-3 py-1 text-xs font-medium text-white hover:bg-sky-700 disabled:cursor-not-allowed disabled:opacity-40",children:s?"Saving…":"Save"})}const Ej=[7,14,21,28],zm=[{value:"rolling_14",label:"Rolling 14 days (default)",hint:"Trailing 14 days vs the prior 14 — always a full window, no sprint needed. Best if you don’t run fixed sprints."},{value:"rolling_7",label:"Rolling 7 days",hint:"Trailing 7 days vs the prior 7 — a tighter, more responsive momentum read."},{value:"sprint",label:"Sprint position (like-for-like)",hint:"This sprint SO FAR vs the SAME point in the previous sprint (e.g. day 3 vs day 3). Needs a start date + cadence below."}];function Pj({settings:e,save:s,saving:a}){var b,I;const o=e.sprint.comparisonMode,i=e.sprint.cadenceDays??14,u=((b=e.sprint.startDate)==null?void 0:b.slice(0,10))??"",[d,p]=x.useState(o),[m,g]=x.useState(i),[w,v]=x.useState(!Ej.includes(i)),[y,j]=x.useState(u),R=d==="sprint",P=d!==o||R&&(m!==i||y!==u),E=u!==""||e.sprint.cadenceDays!=null,S=(I=zm.find($=>$.value===d))==null?void 0:I.hint,T=()=>s({sprint:R?{comparisonMode:d,cadenceDays:m,startDate:y===""?null:y}:{comparisonMode:d}}),N=()=>{const $=d==="sprint"?"rolling_14":d;p($),j(""),v(!1),g(14),s({sprint:{comparisonMode:$,cadenceDays:null,startDate:null}})};return n.jsxs(or,{title:"Sprint",desc:"How the Insights flow-metrics compare over time. Open PRs always count, regardless of the window.",children:[n.jsx(Nt,{label:"Comparison window",hint:S,children:n.jsx("select",{className:rt,value:d,onChange:$=>p($.target.value),children:zm.map($=>n.jsx("option",{value:$.value,children:$.label},$.value))})}),R&&n.jsxs(n.Fragment,{children:[n.jsx(Nt,{label:"Cadence",children:n.jsxs("select",{className:rt,value:w?"custom":String(m),onChange:$=>{$.target.value==="custom"?v(!0):(v(!1),g(Number($.target.value)))},children:[n.jsx("option",{value:"7",children:"1 week"}),n.jsx("option",{value:"14",children:"2 weeks"}),n.jsx("option",{value:"21",children:"3 weeks"}),n.jsx("option",{value:"28",children:"4 weeks"}),n.jsx("option",{value:"custom",children:"Custom…"})]})}),w&&n.jsx(Nt,{label:"Sprint length (days)",children:n.jsx("input",{type:"number",min:1,max:90,className:rt,value:m,onChange:$=>g(Math.max(1,Math.min(90,Number($.target.value)||1)))})}),n.jsx(Nt,{label:"Start date",hint:"The day your first/any sprint began — cadence rolls forward from here.",children:n.jsx("input",{type:"date",className:rt,value:y,onChange:$=>j($.target.value)})}),y===""&&n.jsx("p",{className:"text-[11px] text-amber-600 dark:text-amber-400",children:"Set a start date to use sprint-position comparison — until then the Insights fall back to a rolling 14-day window."})]}),n.jsx(Pr,{dirty:P,saving:a,onClick:T}),E&&n.jsx("div",{className:"mt-3 border-t border-gray-100 pt-3 dark:border-gray-800",children:n.jsx("button",{type:"button",onClick:N,disabled:a,className:"text-[11px] text-gray-400 underline hover:text-red-500 disabled:opacity-50",title:"Remove the sprint start date + cadence and use a rolling 14-day tracker",children:"Clear sprint dates (disable sprints)"})})]})}const qm=Array.from({length:24},(e,s)=>s),Um=e=>{const s=e<12;return`${e%12===0?12:e%12}:00 ${s?"AM":"PM"}`};function Aj({settings:e,save:s,saving:a}){const o=e.slack,[i,u]=x.useState(""),[d,p]=x.useState(o.cadence),[m,g]=x.useState(o.hour1),[w,v]=x.useState(o.hour2),[y,j]=x.useState({busy:!1,msg:null,ok:!1}),R=async()=>{j({busy:!0,msg:null,ok:!1});try{const E=await ge.testSlackDigest();j({busy:!1,ok:E.sent,msg:E.sent?"Sent — check Slack.":E.message??"Not sent."})}catch(E){j({busy:!1,ok:!1,msg:E.message})}},P=i.trim()!==""||d!==o.cadence||m!==o.hour1||w!==o.hour2;return n.jsxs(or,{title:"Slack digest",desc:"Deliver the sprint + repo digest to a Slack channel on a schedule. Report is generated fresh at send time.",children:[n.jsx(Nt,{label:"Incoming webhook URL",hint:o.configured?n.jsx("span",{className:"text-emerald-500",children:"A webhook is configured. Enter a new URL to replace it, or clear it to disable."}):"Create one at api.slack.com/apps → Incoming Webhooks.",children:n.jsx("input",{type:"url",className:rt,placeholder:o.configured?"•••••••• (unchanged)":"https://hooks.slack.com/services/…",value:i,onChange:E=>u(E.target.value)})}),n.jsx(Nt,{label:"Cadence",children:n.jsxs("select",{className:rt,value:d,onChange:E=>p(E.target.value),children:[n.jsx("option",{value:"off",children:"Off"}),n.jsx("option",{value:"daily",children:"Daily"}),n.jsx("option",{value:"twice_daily",children:"Twice daily"})]})}),d!=="off"&&n.jsxs("div",{className:"flex gap-2",children:[n.jsx(Nt,{label:"Send at",hint:e.slack.timezone??"server time",children:n.jsx("select",{className:rt,value:m,onChange:E=>g(Number(E.target.value)),children:qm.map(E=>n.jsx("option",{value:E,children:Um(E)},E))})}),d==="twice_daily"&&n.jsx(Nt,{label:"And at",children:n.jsx("select",{className:rt,value:w,onChange:E=>v(Number(E.target.value)),children:qm.map(E=>n.jsx("option",{value:E,children:Um(E)},E))})})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Pr,{dirty:P,saving:a,onClick:()=>{const E={cadence:d,hour1:m,hour2:w};i.trim()!==""&&(E.webhookUrl=i.trim()),s({slack:E}),u("")}}),o.configured&&n.jsx("button",{type:"button",onClick:R,disabled:y.busy,className:"rounded border border-gray-300 px-3 py-1 text-xs font-medium text-gray-600 hover:bg-gray-100 disabled:opacity-40 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:y.busy?"Sending…":"Send test"}),o.configured&&n.jsx("button",{type:"button",onClick:()=>{u(""),s({slack:{webhookUrl:""}})},disabled:a,className:"rounded px-2 py-1 text-xs font-medium text-red-500 hover:bg-red-50 disabled:opacity-40 dark:hover:bg-red-950",children:"Remove webhook"}),y.msg!=null&&n.jsx("span",{className:`text-[11px] ${y.ok?"text-emerald-500":"text-red-500"}`,children:y.msg})]})]})}const Eo=5,$j=[{value:"manual",label:"Manual",desc:"Only regenerate when you click Refresh."},{value:"interval",label:"Every N minutes",desc:"Regenerate on a timer (unchanged repos cost nothing)."},{value:"on_change",label:"When a change is detected",desc:"Regenerate after a sync that changed a watched repo."}];function Mj({settings:e,save:s,saving:a}){const o=e.aiUpdate,[i,u]=x.useState(o.mode),[d,p]=x.useState(o.intervalMinutes),m=i!==o.mode||i==="interval"&&d!==o.intervalMinutes;return n.jsxs(or,{title:"AI summary updates",desc:"Controls when the Pro Haiku digests / sprint report regenerate.",children:[n.jsx("div",{className:"space-y-1.5",children:$j.map(g=>n.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[n.jsx("input",{type:"radio",name:"ai-update-mode",className:"mt-0.5",checked:i===g.value,onChange:()=>u(g.value)}),n.jsxs("span",{children:[n.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:g.label}),n.jsx("span",{className:"block text-[11px] text-gray-400",children:g.desc})]})]},g.value))}),i==="interval"&&n.jsx(Nt,{label:"Interval (minutes)",hint:`Minimum ${Eo}.`,children:n.jsx("input",{type:"number",min:Eo,className:rt,value:d,onChange:g=>p(Math.max(Eo,Number(g.target.value)||Eo))})}),n.jsx(Pr,{dirty:m,saving:a,onClick:()=>s({aiUpdate:{mode:i,intervalMinutes:d}})})]})}const Fj={jira:"https://your-org.atlassian.net",linear:"https://linear.app/your-workspace"};function Lj({settings:e,save:s,saving:a}){const o=e.issue,[i,u]=x.useState(o.provider??""),[d,p]=x.useState(o.baseUrl??""),m=o.projectKeys.join(", "),[g,w]=x.useState(m),v=g.split(/[\s,]+/).map(j=>j.trim().toUpperCase()).filter(j=>j!==""),y=(i||null)!==o.provider||d.trim()!==(o.baseUrl??"")||v.join(",")!==o.projectKeys.join(",");return n.jsxs(or,{title:"Issue tracker",desc:"Link Jira/Linear tickets detected in a PR's title or branch into the PR details.",children:[n.jsx(Nt,{label:"Provider",children:n.jsxs("select",{className:rt,value:i,onChange:j=>u(j.target.value),children:[n.jsx("option",{value:"",children:"None"}),n.jsx("option",{value:"jira",children:"Jira"}),n.jsx("option",{value:"linear",children:"Linear"})]})}),i!==""&&n.jsxs(n.Fragment,{children:[n.jsx(Nt,{label:"Base URL",hint:i==="jira"?"Tickets link to {base}/browse/KEY-123.":"Tickets link to {base}/issue/KEY-123.",children:n.jsx("input",{type:"url",className:rt,placeholder:Fj[i],value:d,onChange:j=>p(j.target.value)})}),n.jsx(Nt,{label:"Project keys",hint:"Optional, comma-separated (e.g. ENG, PROJ). When set, ONLY these prefixes are detected (in the title AND branch) — the most reliable way to avoid false matches like GPT-4 or node-18. Leave blank to detect uppercase keys in the PR title only.",children:n.jsx("input",{type:"text",className:rt,placeholder:"ENG, PROJ",value:g,onChange:j=>w(j.target.value)})})]}),n.jsx(Pr,{dirty:y,saving:a,onClick:()=>s({issue:{provider:i===""?null:i,baseUrl:d.trim()===""?null:d.trim(),projectKeys:v}})})]})}const _j=Object.keys(qs),Oj=8;function Dj(){var E;const e=xh(),s=yh(),a=Uu(),[o,i]=x.useState({}),[u,d]=x.useState(""),p=S=>o[S.userId]??{kind:S.classification.kind??"in_house",label:S.classification.label},m=(S,T)=>i(N=>({...N,[S.userId]:{...p(S),...T}})),g=s.isPending,w=((E=e.data)==null?void 0:E.reviewers)??[],v=w.filter(S=>S.classification.automated===!0),y=w.filter(S=>S.classification.automated!==!0),j=u.trim().toLowerCase(),R=x.useMemo(()=>j===""?[]:y.filter(S=>`${S.login} ${S.displayName??""}`.toLowerCase().includes(j)).slice(0,Oj),[y,j]),P=S=>{s.mutate({userId:S.userId,body:{automated:!0,kind:"in_house"}}),d("")};return n.jsxs(or,{title:"Review bots",desc:"Reviewers we treat as an AI/automated reviewer. Override any row — a manual choice sticks. To mark a human reviewer as a bot, search below.",children:[e.isLoading?n.jsx("p",{className:"py-3 text-center text-[11px] text-gray-400",children:"Loading…"}):e.isError?n.jsx("p",{className:"py-3 text-center text-[11px] text-red-500",children:e.error.message}):w.length===0?n.jsx("p",{className:"py-3 text-center text-[11px] text-gray-400",children:"No reviewers detected yet — sync a repo first."}):n.jsxs(n.Fragment,{children:[v.length===0?n.jsx("p",{className:"py-2 text-center text-[11px] text-gray-400",children:"No automated reviewers yet — search below to mark one."}):n.jsx("ul",{className:"divide-y divide-gray-100 rounded border border-gray-200 dark:divide-gray-800 dark:border-gray-700",children:v.map(S=>{const T=S.classification,N=p(S),b=an(T.kind??"in_house");return n.jsxs("li",{className:"flex flex-col gap-1.5 px-2.5 py-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[S.avatarUrl!=null&&n.jsx("img",{src:S.avatarUrl,alt:"",className:"h-5 w-5 shrink-0 rounded-full"}),n.jsxs("span",{className:"truncate text-xs font-medium text-gray-800 dark:text-gray-100",title:S.sampleReviewBody??void 0,children:[S.login,S.displayName!=null&&S.displayName!==S.login&&n.jsx("span",{className:"ml-1 font-normal text-gray-400",children:S.displayName})]}),n.jsxs("span",{className:"ml-auto shrink-0 text-[10px] text-gray-400",children:[S.threadsLast90d," threads · 90d"]})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px] font-medium",style:{color:b.color,backgroundColor:`${b.color}1a`},children:[n.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:b.color}}),b.label]}),T.confidence!=="high"&&n.jsxs("span",{className:"text-[10px] text-amber-500",title:T.reasons.join(" · "),children:["likely (",T.confidence,")"]}),S.isManualOverride?n.jsx("span",{className:"rounded bg-sky-50 px-1 py-0.5 text-[9px] font-medium uppercase tracking-wide text-sky-600 dark:bg-sky-950 dark:text-sky-300",children:"manual"}):n.jsx("span",{className:"text-[9px] uppercase tracking-wide text-gray-300 dark:text-gray-600",title:T.reasons.join(" · "),children:T.source.replace(/_/g," ")})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsx("select",{className:`${rt} w-auto py-0.5`,value:N.kind,onChange:I=>m(S,{kind:I.target.value}),"aria-label":"Reviewer kind",children:_j.map(I=>n.jsx("option",{value:I,children:an(I).label},I))}),n.jsx("input",{className:`${rt} w-28 py-0.5`,value:N.label,placeholder:"Label",onChange:I=>m(S,{label:I.target.value}),"aria-label":"Reviewer label"}),n.jsx("button",{type:"button",disabled:g,onClick:()=>s.mutate({userId:S.userId,body:{automated:!0,kind:N.kind,label:N.label}}),className:"rounded bg-sky-600 px-2 py-0.5 text-[11px] font-medium text-white hover:bg-sky-700 disabled:opacity-40",children:"Apply"}),n.jsx("button",{type:"button",disabled:g,onClick:()=>s.mutate({userId:S.userId,body:{automated:!1,kind:null}}),className:"rounded border border-gray-300 px-2 py-0.5 text-[11px] font-medium text-gray-600 hover:bg-gray-100 disabled:opacity-40 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:"Not a bot"}),n.jsx("button",{type:"button",disabled:a.isPending,onClick:()=>a.mutate({vendorKind:T.kind??N.kind,action:"hide"}),title:"Hide this vendor's threads (adds a mute rule)",className:"rounded px-1.5 py-0.5 text-[11px] font-medium text-gray-500 hover:bg-gray-100 disabled:opacity-40 dark:text-gray-400 dark:hover:bg-gray-800",children:"Mute"})]})]},S.userId)})}),n.jsxs("div",{className:"mt-1 space-y-1.5",children:[n.jsxs("label",{className:"flex flex-col gap-1 text-xs",children:[n.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:"Add a review bot"}),n.jsx("input",{className:rt,value:u,placeholder:"Search reviewers by name or login…",onChange:S=>d(S.target.value),"aria-label":"Search reviewers to mark as a review bot"})]}),j===""?n.jsx("p",{className:"text-[10px] text-gray-400",children:"Type a reviewer's name to mark them as a bot. They default to In-house AI — set the exact vendor above once added."}):R.length===0?n.jsx("p",{className:"text-[10px] text-gray-400",children:"No matching reviewers."}):n.jsx("ul",{className:"divide-y divide-gray-100 rounded border border-gray-200 dark:divide-gray-800 dark:border-gray-700",children:R.map(S=>n.jsxs("li",{className:"flex items-center gap-2 px-2.5 py-1.5",children:[S.avatarUrl!=null&&n.jsx("img",{src:S.avatarUrl,alt:"",className:"h-5 w-5 shrink-0 rounded-full"}),n.jsxs("span",{className:"truncate text-xs font-medium text-gray-800 dark:text-gray-100",children:[S.login,S.displayName!=null&&S.displayName!==S.login&&n.jsx("span",{className:"ml-1 font-normal text-gray-400",children:S.displayName})]}),n.jsxs("span",{className:"ml-auto shrink-0 text-[10px] text-gray-400",children:[S.threadsLast90d," · 90d"]}),n.jsx("button",{type:"button",disabled:g,onClick:()=>P(S),className:"shrink-0 rounded bg-sky-600 px-2 py-0.5 text-[11px] font-medium text-white hover:bg-sky-700 disabled:opacity-40",children:"Treat as review bot"})]},S.userId))})]})]}),s.isError&&n.jsx("p",{className:"text-[11px] text-red-500",children:s.error.message})]})}const Bj=Object.keys(qs),zj=e=>e==null?"Any bot":an(e).label;function qj({settings:e,save:s,saving:a}){var q,Q;const o=My(),i=Uu(),u=Fy(),d=e.bots,[p,m]=x.useState(d.autoResolve),[g,w]=x.useState(d.autoResolveDays),v=p!==d.autoResolve||g!==d.autoResolveDays,[y,j]=x.useState("any"),[R,P]=x.useState(""),[E,S]=x.useState(""),[T,N]=x.useState("hide"),[b,I]=x.useState(7),$=()=>{i.mutate({vendorKind:y==="any"?null:y,pathGlob:R.trim()===""?null:R.trim(),severity:E.trim()===""?null:E.trim(),action:T,autoResolveDays:T==="auto_resolve"?Math.min(90,Math.max(1,b)):null},{onSuccess:()=>{P(""),S("")}})},L=((q=o.data)==null?void 0:q.rules)??[];return n.jsxs(or,{title:"Mute & auto-triage rules",desc:"Hide low-value bot threads, or (with auto-resolve on) let a background job resolve likely-addressed bot threads older than a threshold. Auto-resolve only ever touches likely-addressed threads and never merges.",children:[n.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[n.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[n.jsx("input",{type:"checkbox",checked:p,onChange:_=>m(_.target.checked)}),n.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:"Enable standing auto-resolve"})]}),n.jsx(Nt,{label:"Older than (days)",children:n.jsx("input",{type:"number",min:1,max:90,className:`${rt} w-20`,value:g,onChange:_=>w(Math.min(90,Math.max(1,Number(_.target.value)||1)))})}),n.jsx(Pr,{dirty:v,saving:a,onClick:()=>s({bots:{autoResolve:p,autoResolveDays:g}})})]}),n.jsx("div",{className:"mt-1 space-y-1",children:o.isLoading?n.jsx("p",{className:"py-2 text-center text-[11px] text-gray-400",children:"Loading rules…"}):L.length===0?n.jsx("p",{className:"py-2 text-center text-[11px] text-gray-400",children:"No rules yet."}):n.jsx("ul",{className:"divide-y divide-gray-100 rounded border border-gray-200 dark:divide-gray-800 dark:border-gray-700",children:L.map(_=>n.jsxs("li",{className:"flex items-center gap-2 px-2 py-1.5 text-[11px]",children:[n.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:zj(_.vendorKind)}),n.jsx("span",{className:"text-gray-400",children:_.pathGlob??"any path"}),n.jsx("span",{className:"text-gray-400",children:_.severity??"any severity"}),n.jsx("span",{className:`ml-auto rounded px-1.5 py-0.5 font-medium ${_.action==="auto_resolve"?"bg-amber-50 text-amber-600 dark:bg-amber-950 dark:text-amber-300":"bg-gray-100 text-gray-500 dark:bg-gray-800 dark:text-gray-300"}`,children:_.action==="auto_resolve"?`Auto-resolve · ${_.autoResolveDays??"?"}d`:"Hide"}),n.jsx("button",{type:"button",disabled:u.isPending,onClick:()=>u.mutate(_.id),className:"text-gray-400 hover:text-red-500 disabled:opacity-40","aria-label":"Delete rule",title:"Delete rule",children:"✕"})]},_.id))})}),n.jsxs("div",{className:"flex flex-wrap items-end gap-2 rounded border border-dashed border-gray-200 p-2 dark:border-gray-700",children:[n.jsx(Nt,{label:"Vendor",children:n.jsxs("select",{className:`${rt} w-auto`,value:y,onChange:_=>j(_.target.value),children:[n.jsx("option",{value:"any",children:"Any bot"}),Bj.map(_=>n.jsx("option",{value:_,children:an(_).label},_))]})}),n.jsx(Nt,{label:"Path glob",children:n.jsx("input",{className:`${rt} w-28`,value:R,placeholder:"e.g. tests/**",onChange:_=>P(_.target.value)})}),n.jsx(Nt,{label:"Severity",children:n.jsx("input",{className:`${rt} w-24`,value:E,placeholder:"e.g. nitpick",onChange:_=>S(_.target.value)})}),n.jsx(Nt,{label:"Action",children:n.jsxs("select",{className:`${rt} w-auto`,value:T,onChange:_=>N(_.target.value),children:[n.jsx("option",{value:"hide",children:"Hide"}),n.jsx("option",{value:"auto_resolve",children:"Auto-resolve"})]})}),T==="auto_resolve"&&n.jsx(Nt,{label:"Days",children:n.jsx("input",{type:"number",min:1,max:90,className:`${rt} w-16`,value:b,onChange:_=>I(Math.min(90,Math.max(1,Number(_.target.value)||1)))})}),n.jsx("button",{type:"button",disabled:i.isPending,onClick:$,className:"self-start rounded bg-sky-600 px-3 py-1 text-xs font-medium text-white hover:bg-sky-700 disabled:opacity-40",children:i.isPending?"Adding…":"Add rule"})]}),(i.isError||u.isError)&&n.jsx("p",{className:"text-[11px] text-red-500",children:(Q=i.error??u.error)==null?void 0:Q.message})]})}const Km=Object.keys(qs);function $s({label:e,hint:s,checked:a,onChange:o}){return n.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[n.jsx("input",{type:"checkbox",className:"mt-0.5",checked:a,onChange:i=>o(i.target.checked)}),n.jsxs("span",{children:[n.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:e}),s!=null&&n.jsx("span",{className:"block text-[11px] text-gray-400",children:s})]})]})}function Uj({settings:e,save:s,saving:a}){const o=yn(),i=e.bots,[u,d]=x.useState(i.inhouseDetect),[p,m]=x.useState(i.autoTagHighConfidence),[g,w]=x.useState(i.deepDetect),[v,y]=x.useState(i.aiTiebreak),[j,R]=x.useState(i.loginAllowlist.join(`
50
+ `)),P=j.split(/[\n,]/).map(B=>B.trim()).filter(Boolean),E=u!==i.inhouseDetect||p!==i.autoTagHighConfidence||g!==i.deepDetect||v!==i.aiTiebreak||P.join(`
51
51
  `)!==i.loginAllowlist.join(`
52
- `),[w,R]=x.useState(i.tagPierreReviews),[S,j]=x.useState(i.pierreFooter),T=w!==i.tagPierreReviews||S!==i.pierreFooter,[M,D]=x.useState(i.cost),U=JSON.stringify(M)!==JSON.stringify(i.cost),G=()=>Km.find(B=>!M.some(_=>_.kind===B))??"in_house",[L,Y]=x.useState(i.slackDigest),X=L!==i.slackDigest;return n.jsxs("div",{"data-testid":"bot-settings-section",className:"space-y-4",children:[n.jsx(Oj,{}),n.jsxs(or,{title:"Detection",desc:"How we recognise automated reviewers beyond the known vendors — your own in-house AI reviewer or CI service accounts.",children:[n.jsx($s,{label:"Detect in-house / service-account reviewers",hint:"Fingerprint branded review markers and behaviour to flag your own automation.",checked:u,onChange:d}),n.jsx($s,{label:"Auto-tag high-confidence matches",hint:"Badge a reviewer automatically when detection is high-confidence (medium always asks first).",checked:p,onChange:m}),n.jsx($s,{label:"Deep detect (app attribution)",hint:"Off by default — an extra REST lookup during sync to read GitHub App attribution.",checked:g,onChange:y}),n.jsx($s,{label:"AI tie-break (opt-in)",hint:"For medium-confidence cases only, one cheap model call per reviewer to decide. Costs a little; off by default.",checked:b,onChange:v}),n.jsx(Nt,{label:"Login allowlist",hint:"One login or glob per line (e.g. acme-ci, *-bot). Always treated as automated.",children:n.jsx("textarea",{className:`${rt} min-h-[3rem] font-mono`,value:N,placeholder:`acme-ci
53
- *-svc`,onChange:B=>I(B.target.value)})}),n.jsx(Pr,{dirty:E,saving:a,onClick:()=>s({bots:{inhouseDetect:u,autoTagHighConfidence:p,deepDetect:g,aiTiebreak:b,loginAllowlist:P}})})]}),n.jsxs(or,{title:"Pierre attribution",desc:"How Pierre's own Claude reviews are stamped when posted.",children:[n.jsx($s,{label:"Tag Pierre reviews",hint:"Append a hidden marker so Pierre-posted reviews are recognised as its own (verbatim vs curated).",checked:w,onChange:R}),n.jsx($s,{label:"Visible footer",hint:'Also append a visible "Reviewed with Pierre + Claude" footer to posted reviews.',checked:S,onChange:j}),n.jsx(Pr,{dirty:T,saving:a,onClick:()=>s({bots:{tagPierreReviews:w,pierreFooter:S}})})]}),n.jsx(zj,{settings:e,save:s,saving:a}),n.jsxs(or,{title:"Per-vendor cost",desc:"Optional monthly spend per reviewer, used to show cost-per-acted-on in the Bot ROI panel. Stays on your account.",children:[M.length===0?n.jsx("p",{className:"text-[11px] text-gray-400",children:"No costs entered."}):n.jsx("ul",{className:"space-y-1.5",children:M.map((B,_)=>n.jsxs("li",{className:"flex items-center gap-2",children:[n.jsx("select",{className:`${rt} w-auto`,value:B.kind,onChange:H=>D(ee=>ee.map((ce,C)=>C===_?{...ce,kind:H.target.value}:ce)),"aria-label":"Vendor",children:Km.map(H=>n.jsx("option",{value:H,children:an(H).label},H))}),n.jsx("span",{className:"text-[11px] text-gray-400",children:"$"}),n.jsx("input",{type:"number",min:0,className:`${rt} w-24`,value:B.monthlyUsd,onChange:H=>D(ee=>ee.map((ce,C)=>C===_?{...ce,monthlyUsd:Math.max(0,Number(H.target.value)||0)}:ce)),"aria-label":"Monthly USD"}),n.jsx("span",{className:"text-[11px] text-gray-400",children:"/mo"}),n.jsx("button",{type:"button",onClick:()=>D(H=>H.filter((ee,ce)=>ce!==_)),className:"ml-auto text-gray-400 hover:text-red-500","aria-label":"Remove",title:"Remove",children:"✕"})]},_))}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("button",{type:"button",onClick:()=>D(B=>[...B,{kind:G(),monthlyUsd:0}]),className:"rounded border border-gray-300 px-2 py-1 text-[11px] font-medium text-gray-600 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:"Add vendor cost"}),n.jsx(Pr,{dirty:U,saving:a,onClick:()=>s({bots:{cost:M}})})]})]}),o.slackDigest&&n.jsxs(or,{title:"Slack bot digest",desc:"Include a review-bot summary block in the Slack digest.",children:[n.jsx($s,{label:"Send the review-bot block",hint:"Adds a deterministic bots section (volume · acted-on · untouched) to the scheduled Slack digest.",checked:L,onChange:Y}),n.jsx(Pr,{dirty:X,saving:a,onClick:()=>s({bots:{slackDigest:L}})})]})]})}function Uj({onClose:e}){const s=yn(),a=h0(!0),o=tk(),i=d=>{o.mutate(d)};x.useEffect(()=>{const d=p=>{p.key==="Escape"&&(p.stopImmediatePropagation(),e())};return window.addEventListener("keydown",d,!0),()=>window.removeEventListener("keydown",d,!0)},[e]);const u=a.data;return n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:e,role:"presentation",children:n.jsxs("div",{className:"flex max-h-[85vh] w-[30rem] max-w-[92vw] flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-900",onClick:d=>d.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Settings",children:[n.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[n.jsx("h2",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:"Settings"}),n.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:"✕"})]}),n.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto px-4 py-3",children:[o.isError&&n.jsx("p",{className:"rounded bg-red-50 px-2 py-1 text-xs text-red-600 dark:bg-red-950 dark:text-red-300",children:o.error.message}),a.isLoading||u==null?n.jsx("p",{className:"py-6 text-center text-xs text-gray-400",children:a.isError?"Settings unavailable.":"Loading…"}):n.jsxs(n.Fragment,{children:[s.teamInsights&&n.jsx(Ej,{settings:u,save:i,saving:o.isPending}),s.teamInsights&&n.jsx(qj,{settings:u,save:i,saving:o.isPending}),s.slackDigest&&n.jsx(Pj,{settings:u,save:i,saving:o.isPending}),s.activityDigest&&n.jsx($j,{settings:u,save:i,saving:o.isPending}),s.issueLinks&&n.jsx(Fj,{settings:u,save:i,saving:o.isPending})]})]})]})})}const Kj={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.",unavailable:"That sign-in method isn’t enabled on this deployment."},Hm=()=>n.jsx("svg",{viewBox:"0 0 16 16",width:"18",height:"18",fill:"currentColor","aria-hidden":"true",children:n.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"})});function Hj(){const[e]=x.useState(()=>{const i=new URLSearchParams(window.location.search).get("auth");return i?Kj[i]??"We couldn’t complete sign-in. Please try again.":null});x.useEffect(()=>{if(!e)return;const i=new URL(window.location.href);i.searchParams.delete("auth"),window.history.replaceState({},"",i.pathname+i.search+i.hash)},[e]);const[s,a]=x.useState({oauth:!0,app:!1,appSlug:""});x.useEffect(()=>{let i=!0;return fetch("/api/auth/providers",{credentials:"include"}).then(u=>u.ok?u.json():null).then(u=>{i&&u&&a(u)}).catch(()=>{}),()=>{i=!1}},[]);const o=s.oauth&&s.app;return n.jsx("div",{className:"flex h-full min-h-screen w-full items-center justify-center bg-gray-950 px-4 text-gray-100",children:n.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:[n.jsx("span",{className:"brand-title text-4xl",title:"Pierre — a play on “PR”",children:"Pierre"}),n.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&&n.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}),n.jsxs("div",{className:"mt-7 flex w-full flex-col gap-3",children:[s.oauth&&n.jsxs("a",{href:"/api/auth/login/oauth",className:"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:[n.jsx(Hm,{}),"Sign in with GitHub"]}),s.app&&n.jsxs("div",{className:"flex w-full flex-col gap-1",children:[n.jsxs("a",{href:"/api/auth/login/app",className:`inline-flex w-full items-center justify-center gap-2 rounded-lg px-4 py-2.5 text-sm font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-sky-400 focus:ring-offset-2 focus:ring-offset-gray-950 ${o?"border border-gray-700 bg-transparent text-gray-100 hover:bg-gray-800":"bg-blue-600 text-white hover:bg-blue-700"}`,children:[n.jsx(Hm,{}),"Sign in with the Pierre GitHub App"]}),n.jsx("span",{className:"px-1 text-[11px] leading-snug text-amber-500/80",children:"Scope may be limited: private org repos only appear once an org admin installs the app on your org — until then you’ll see public repos."})]})]}),o&&n.jsxs("p",{className:"mt-4 text-[11px] leading-relaxed text-gray-500",children:[n.jsx("span",{className:"text-gray-400",children:"GitHub"})," = public repositories, instant, no install. ",n.jsx("span",{className:"text-gray-400",children:"GitHub App"})," = also private repos, but only in orgs that have installed the app."]}),n.jsxs("p",{className:"mt-4 text-xs leading-relaxed text-gray-500",children:["Public repositories work either way, with no install. To watch"," ",n.jsx("strong",{className:"font-semibold text-gray-400",children:"private"})," org repos, sign in with the GitHub App and"," ",s.app&&s.appSlug?n.jsx("a",{className:"underline decoration-gray-600 underline-offset-2 hover:text-gray-300",href:`https://github.com/apps/${s.appSlug}/installations/new`,target:"_blank",rel:"noreferrer",children:"install it"}):"install it"," ","on that org (an org owner may need to approve). Revoke anytime from your GitHub settings."]})]})})}function Wj({notices:e}){if(e.length===0)return null;const s=e.map(a=>a.org).join(", ");return n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-amber-400/50 bg-amber-400/10 px-4 py-2 text-xs text-amber-800 dark:text-amber-200",children:[n.jsxs("span",{className:"min-w-0",children:[n.jsxs("strong",{className:"font-semibold",children:["Your GitHub sign-in is no longer authorized for ",s,"."]})," ","Its pull requests, CI checks and comments can’t be synced until you re-authorize (SAML single sign-on)."]}),n.jsx("a",{href:"/api/auth/reconnect",className:"ml-auto whitespace-nowrap rounded border border-amber-500/60 px-2.5 py-0.5 font-medium hover:bg-amber-400/20",children:"Reconnect GitHub"}),n.jsx("span",{className:"w-full text-[11px] text-amber-700/80 dark:text-amber-300/70",children:"Reconnect signs you in again through SSO. If it doesn’t clear, your org may restrict third-party OAuth apps — an org owner has to approve Pierre once."})]})}function Vj({user:e,canSignOut:s,onSignOut:a,onOpenSettings:o}){const[i,u]=x.useState(!1),d=x.useRef(null),p=e.displayName??e.login;Yn(d,()=>u(!1),i),x.useEffect(()=>{if(!i)return;const g=y=>{y.key==="Escape"&&(y.stopPropagation(),u(!1))};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[i]);const m=e.avatarUrl!=null?n.jsx("img",{src:e.avatarUrl,alt:p,width:20,height:20,className:"shrink-0 rounded-full",style:{width:20,height:20}}):n.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:p.slice(0,2).toUpperCase()});return n.jsxs("div",{ref:d,className:"relative",children:[n.jsxs("button",{type:"button",onClick:()=>u(g=>!g),"aria-haspopup":"menu","aria-expanded":i,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 ${i?"bg-gray-100 dark:bg-gray-800":""}`,title:e.displayName!=null?`Signed in as ${e.displayName} (@${e.login})`:`Signed in as ${e.login}`,children:[m,n.jsx("span",{className:"max-w-[10rem] truncate",children:p}),n.jsx("span",{"aria-hidden":"true",className:"text-[9px] text-gray-400",children:"▾"})]}),i&&n.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:[o!=null&&n.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{u(!1),o()},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:[n.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:[n.jsx("circle",{cx:"12",cy:"12",r:"3"}),n.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),"Settings"]}),n.jsxs("a",{role:"menuitem",href:Du(e.login),target:"_blank",rel:"noreferrer noopener",onClick:()=>u(!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:[n.jsx(ph,{size:13}),"Open Profile on GitHub"]}),s&&n.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{u(!1),a()},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:[n.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:[n.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),n.jsx("polyline",{points:"16 17 21 12 16 7"}),n.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]}),"Sign Out"]})]})]})}const Qj=["7d","14d","30d","90d","custom"];function du(e,s){if(e.length!==s.length)return!1;const a=new Set(e);return s.every(o=>a.has(o))}function fu(e){if(!e)return null;const s=e.split(",").map(a=>Number.parseInt(a,10)).filter(Number.isFinite);return s.length?s:null}function Gj(){const e=new URLSearchParams(window.location.search),s={},a=e.get("preset");a&&Qj.includes(a)&&(s.preset=a),s.repoIds=fu(e.get("repos")),s.userIds=fu(e.get("users")),e.get("bots")!==null&&(s.excludeBots=e.get("bots")==="1");const o=fu(e.get("allowBots"));o&&(s.allowedBotIds=o);const i=e.get("stale");i==="0"?s.excludeStale=!1:i==="1"&&(s.excludeStale=!0),s.customFrom=e.get("from"),s.customTo=e.get("to");const u=e.get("cats");if(u){const N=new Set(cl);s.categories=u.split(",").filter(I=>N.has(I))}const d=e.get("status");if(d!==null){const N=new Set(ul);s.prStatuses=d.split(",").filter(I=>N.has(I))}const p=e.get("reviews");if(p!==null){const N=new Set(dl);s.reviewStates=p.split(",").filter(I=>N.has(I))}const m=e.get("states");if(m){const N=new Set(Pu);s.derivedStates=m.split(",").filter(I=>N.has(I))}const g=e.get("pr");g&&(s.selectedPrId=Number.parseInt(g,10));const y=e.get("thread");y&&(s.selectedThreadId=Number.parseInt(y,10));const b=e.get("strip");(b==="my_turn"||b==="needs_attention"||b==="all")&&(s.stripFilter=b);const v=e.get("activityRepo");if(v){const N=Number.parseInt(v,10);Number.isFinite(N)&&(s.activityRepoId=N)}return e.get("open")==="1"&&(s.stripCollapsed=!1),s}function Wm(e){var i,u;const s=new URLSearchParams;e.preset!=="14d"&&s.set("preset",e.preset),(i=e.repoIds)!=null&&i.length&&s.set("repos",e.repoIds.join(",")),(u=e.userIds)!=null&&u.length&&s.set("users",e.userIds.join(",")),e.excludeBots&&s.set("bots","1"),e.excludeBots&&e.allowedBotIds.length&&s.set("allowBots",e.allowedBotIds.join(",")),e.excludeStale||s.set("stale","0"),e.preset==="custom"&&e.customFrom&&s.set("from",e.customFrom),e.preset==="custom"&&e.customTo&&s.set("to",e.customTo),du(e.categories,_o)||s.set("cats",e.categories.join(",")),du(e.prStatuses,Do)||s.set("status",e.prStatuses.join(",")),du(e.reviewStates,Oo)||s.set("reviews",e.reviewStates.join(",")),e.derivedStates.length&&s.set("states",e.derivedStates.join(",")),e.selectedPrId&&s.set("pr",String(e.selectedPrId)),e.selectedThreadId&&s.set("thread",String(e.selectedThreadId)),e.stripFilter!=="all"&&s.set("strip",e.stripFilter),e.stripCollapsed||s.set("open","1"),Oe.getState().activeTab==="activity"&&(s.set("view","activity"),typeof e.activityRepoId=="number"&&s.set("activityRepo",String(e.activityRepoId)));const a=s.toString(),o=`${window.location.pathname}${a?`?${a}`:""}`;o!==window.location.pathname+window.location.search&&window.history.replaceState(null,"",o)}const b0="pierre:filterBarState";function Yj(){try{const e=localStorage.getItem(b0);if(!e)return null;const s=JSON.parse(e);return s&&typeof s=="object"?Go(s):null}catch{return null}}function Xj(e){try{localStorage.setItem(b0,JSON.stringify(gu(e)))}catch{}}function Jj(){const e=x.useRef(!1);x.useEffect(()=>{if(!e.current){if(window.location.search.length>1)te.getState().hydrate(Gj()),new URLSearchParams(window.location.search).get("view")==="activity"&&Oe.getState().setActiveTab("activity");else{const i=Gx(),u=i?Go(i.state):Yj();u&&te.getState().hydrate(u),Oe.getState().setActiveTab("activity")}e.current=!0}const s=te.subscribe(o=>{Wm(o),Xj(o)}),a=Oe.subscribe(()=>{Wm(te.getState())});return()=>{s(),a()}},[])}function Vm(e){if(!(e instanceof HTMLElement))return!1;const s=e.tagName;return s==="INPUT"||s==="TEXTAREA"||e.isContentEditable}function Zj(){const{data:e}=nh();x.useEffect(()=>{const s=a=>{var m;const{selectedPrId:o,selectPr:i,clearSelection:u}=te.getState(),d=Oe.getState(),p=d.activeTab==="timeline";if(a.key==="Escape"){Vm(a.target)?a.target.blur():p?u():d.showTimeline();return}if(!Vm(a.target)){if(a.key==="/"){a.preventDefault(),(m=document.getElementById("add-repo-input"))==null||m.focus();return}if(a.key==="i"){d.showActivity();return}if(p&&(a.key==="j"||a.key==="k")){const g=[...(e==null?void 0:e.prs)??[]].sort((N,I)=>I.openedAt.localeCompare(N.openedAt));if(g.length===0)return;const y=g.findIndex(N=>N.id===o);let b;y===-1?b=0:b=a.key==="j"?y+1:y-1,b=Math.max(0,Math.min(g.length-1,b));const v=g[b];v&&i(v.id)}}};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e])}function eN(){const e=Be();x.useEffect(()=>{let s=null;const a=()=>{const u=new Map,d=(p,m)=>{const g=u.get(p);(!g||m>g)&&u.set(p,m)};for(const[,p]of e.getQueriesData({queryKey:["timeline"]}))for(const m of(p==null?void 0:p.prs)??[])d(m.id,m.updatedAt);for(const[,p]of e.getQueriesData({queryKey:["open-prs"]}))for(const m of(p==null?void 0:p.prs)??[])d(m.id,m.updatedAt);for(const[p,m]of u){const g=e.getQueryData(["pr",p]);if(!g||g.updatedAt>=m)continue;const y=e.getQueryState(["pr",p]);if(!(y&&y.fetchStatus!=="idle")){e.invalidateQueries({queryKey:["pr",p]});for(const b of g.threads??[])e.invalidateQueries({queryKey:["thread",b.id]})}}},o=()=>{s||(s=setTimeout(()=>{s=null,a()},300))};o();const i=e.getQueryCache().subscribe(u=>{const d=u.query.queryKey[0];(d==="timeline"||d==="open-prs")&&o()});return()=>{s&&clearTimeout(s),i()}},[e])}function tN(e){const{data:s}=sh(),a=x.useRef(null);x.useEffect(()=>{if(!s)return;const o=new Set;for(const v of s.awaitingReview)o.add(`r:${v.prId}`);for(const v of s.yourPrs)o.add(`p:${v.prId}`);for(const v of s.approvedPrs??[])o.add(`a:${v.prId}`);for(const v of s.threadsAwaiting)o.add(`t:${v.threadId}`);for(const v of s.watchedRepoPrs)o.add(`w:${v.prId}`);const i=a.current;if(a.current=o,i==null||!e||typeof Notification>"u"||Notification.permission!=="granted")return;const u=[...o].filter(v=>!i.has(v));if(u.length===0)return;const d=u.filter(v=>v.startsWith("r:")).length,p=u.filter(v=>v.startsWith("t:")).length,m=u.filter(v=>v.startsWith("p:")).length,g=u.filter(v=>v.startsWith("a:")).length,y=u.filter(v=>v.startsWith("w:")).length,b=[];d&&b.push(`${d} review${d===1?"":"s"} requested`),p&&b.push(`${p} thread${p===1?"":"s"} awaiting you`),m&&b.push(`${m} of your PRs active`),g&&b.push(`${g} of your PRs approved`),y&&b.push(`${y} new in watched repos`);try{const v=new Notification(`Pierre — ${u.length} new in My Turn`,{body:b.join(" · "),tag:"pierre-my-turn"});v.onclick=()=>{window.focus(),v.close()}}catch{}},[s,e])}const pu="";function nN(e){return/^G-[A-Z0-9]{6,}$/i.test(e)&&e!=="G-XXXXXXXXXX"}let Tu=!1;function rN(){if(Tu||typeof window>"u"||!nN(pu))return;Tu=!0;const e=document.createElement("script");e.async=!0,e.src=`https://www.googletagmanager.com/gtag/js?id=${pu}`,document.head.appendChild(e),window.dataLayer=window.dataLayer||[],window.gtag=function(){window.dataLayer.push(arguments)},window.gtag("js",new Date),window.gtag("config",pu,{send_page_view:!1})}function sN(e=window.location.pathname){!Tu||!window.gtag||window.gtag("event","page_view",{page_path:e,page_location:`${window.location.origin}${e}`,page_title:document.title})}function aN(){const[e,s]=x.useState(()=>(localStorage.getItem("theme")??"dark")!=="light");return x.useEffect(()=>{document.documentElement.classList.toggle("dark",e),localStorage.setItem("theme",e?"dark":"light")},[e]),[e,()=>s(a=>!a)]}function lN(){var F,K,ae;const e=_u();Jj(),Zj(),eN();const[s,a]=aN(),[o,i]=x.useState(!1),[u,d]=x.useState(!1),p=ek(),[m,g]=x0(),y=typeof window<"u"&&"Notification"in window;tN(m&&y);const b=()=>{if(y){if(m){g(!1);return}Notification.permission==="granted"?g(!0):Notification.permission!=="denied"&&Notification.requestPermission().then(ne=>g(ne==="granted"))}},v=((F=e.data)==null?void 0:F.deploymentMode)==="cloud",N=((K=e.data)==null?void 0:K.user)??null,I=()=>{Oe.getState().clear(),ge.logout().finally(()=>window.location.assign("/"))},P=te(ne=>ne.selectedPrId),E=te(ne=>ne.selectedThreadId),w=Oe(ne=>ne.activeTab),R=Oe(ne=>ne.tabs),S=w!=="timeline"&&w!=="activity"?R.find(ne=>ne.key===w)??null:null,j=w==="activity",T=(S==null?void 0:S.kind)==="pr-detail"?S.prId:null,M=(S==null?void 0:S.kind)==="metrics-detail",D=(S==null?void 0:S.kind)==="bot-prs",U=(S==null?void 0:S.kind)==="pr-focus"?{kind:"isolate",prId:S.prId}:null,G=T!=null||j||M||D,L=P!=null&&!G,[Y,X]=s0("pierre:detailPaneHeight",384),B=x.useRef(null),_=x.useRef(null),H=x.useRef(null);x.useEffect(()=>{for(const ne of[_.current,B.current])ne&&(G?ne.setAttribute("inert",""):ne.removeAttribute("inert"))},[G]),x.useEffect(()=>{const ne=()=>Oe.getState().navigateBack();return window.addEventListener("popstate",ne),()=>window.removeEventListener("popstate",ne)},[]),x.useEffect(()=>{window.dispatchEvent(new Event("resize"))},[L]);const ee=ne=>{var Pe;H.current={startY:ne.clientY,startH:((Pe=B.current)==null?void 0:Pe.offsetHeight)??Y},ne.currentTarget.setPointerCapture(ne.pointerId)},ce=ne=>{const Pe=H.current;if(!Pe||!B.current)return;const se=window.innerHeight*.7,Z=Math.min(Math.max(Pe.startH+(Pe.startY-ne.clientY),160),se);B.current.style.height=`${Z}px`,window.dispatchEvent(new Event("resize"))},C=ne=>{!H.current||!B.current||(H.current=null,ne.currentTarget.releasePointerCapture(ne.pointerId),X(B.current.offsetHeight))};return x.useEffect(()=>{if(!v)return;const ne=()=>{ge.me().catch(()=>{})},Pe=window.setInterval(ne,180*1e3);return()=>window.clearInterval(Pe)},[v]),x.useEffect(()=>{v&&(rN(),sN())},[v]),e.error instanceof Gt&&e.error.status===401?n.jsx(Hj,{}):e.isLoading&&!e.data?n.jsx("div",{className:"flex h-full min-h-screen items-center justify-center bg-gray-950",children:n.jsx("span",{className:"brand-title text-4xl text-gray-100",children:"Pierre"})}):n.jsxs("div",{className:"flex h-full flex-col",children:[n.jsx(Wj,{notices:((ae=e.data)==null?void 0:ae.authNotices)??[]}),n.jsxs("header",{className:"flex items-center gap-3 border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[n.jsx("h1",{className:"brand-title",title:"Pierre — a play on “PR”",children:"Pierre"}),n.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[n.jsx(Sj,{}),n.jsx(Nj,{}),y&&n.jsx("button",{type:"button",onClick:b,"aria-pressed":m,className:`rounded border px-2 py-0.5 text-xs hover:border-gray-400 dark:hover:border-gray-500 ${m?"border-blue-400 text-blue-600 dark:border-blue-600 dark:text-blue-400":"border-gray-300 dark:border-gray-700"}`,title:m?"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:n.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:m?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[n.jsx("path",{d:"M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9"}),n.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}),n.jsx("button",{type:"button",onClick:()=>i(!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:"?"}),n.jsx("button",{type:"button",onClick:a,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:s?"☀":"☾"}),N!=null&&n.jsx(Vj,{user:N,canSignOut:v,onSignOut:I,onOpenSettings:p?()=>d(!0):null})]})]}),o&&n.jsx(Rj,{onClose:()=>i(!1)}),u&&n.jsx(Uj,{onClose:()=>d(!1)}),n.jsx(Cj,{}),n.jsx(iy,{}),n.jsx(py,{}),n.jsx(by,{}),n.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[n.jsx("section",{ref:_,className:"min-h-0 flex-1 overflow-hidden",children:U==null?n.jsx(vm,{},"board"):n.jsx(vm,{mode:U},`focus:${U.prId}`)}),L&&n.jsxs(n.Fragment,{children:[n.jsx("div",{role:"separator","aria-orientation":"horizontal","aria-label":"Resize detail pane",onPointerDown:ee,onPointerMove:ce,onPointerUp:C,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"}),n.jsx("section",{ref:B,style:{height:Y},className:"shrink-0 overflow-auto",children:n.jsx(fj,{})})]}),T!=null&&n.jsx("div",{"data-testid":"pinned-pr-overlay",className:"absolute inset-0 z-20 bg-white dark:bg-gray-950",children:n.jsx(Nh,{prId:T,selectedThreadId:P===T?E:null},T)}),j&&n.jsx("div",{"data-testid":"activity-overlay",className:"absolute inset-0 z-20 overflow-hidden bg-white dark:bg-gray-950",children:n.jsx(Kk,{})}),M&&n.jsx("div",{"data-testid":"metrics-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:n.jsx(ej,{})}),D&&n.jsx("div",{"data-testid":"bot-prs-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:n.jsx(dj,{})})]}),n.jsx(vj,{})]})}function di(e){return new Promise((s,a)=>{e.oncomplete=e.onsuccess=()=>s(e.result),e.onabort=e.onerror=()=>a(e.error)})}function oN(e,s){let a;const o=()=>{if(a)return a;const i=indexedDB.open(e);return i.onupgradeneeded=()=>i.result.createObjectStore(s),a=di(i),a.then(u=>{u.onclose=()=>a=void 0},()=>{}),a};return(i,u)=>o().then(d=>u(d.transaction(s,i).objectStore(s)))}let mu;function Zu(){return mu||(mu=oN("keyval-store","keyval")),mu}function iN(e,s=Zu()){return s("readonly",a=>di(a.get(e)))}function cN(e,s,a=Zu()){return a("readwrite",o=>(o.put(s,e),di(o.transaction)))}function uN(e,s=Zu()){return s("readwrite",a=>(a.delete(e),di(a.transaction)))}const dN=Zg({storage:{getItem:e=>iN(e).then(s=>s??null),setItem:(e,s)=>cN(e,s),removeItem:e=>uN(e)},key:"pierre-query-cache",throttleTime:1e3}),fN=new ex({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1,retry:1}}});var Eo,Qm;(Qm=(Eo=navigator.storage)==null?void 0:Eo.persist)==null||Qm.call(Eo);new URLSearchParams(window.location.search).has("perf")&&Eu(()=>import("./perfProbe-Da13EhTE.js"),[]).then(e=>e.startPerfProbe());const w0=document.getElementById("root");if(!w0)throw new Error("#root not found");const pN=1e3*60*60*24*7;mx.createRoot(w0).render(n.jsx(x.StrictMode,{children:n.jsx(tx,{client:fN,persistOptions:{persister:dN,maxAge:pN,buster:"pierre-detail-v3",dehydrateOptions:{shouldDehydrateQuery:e=>{const s=e.queryKey[0];return(s==="pr"||s==="thread"||s==="pr-files")&&e.state.status==="success"}}},children:n.jsx(lN,{})})}));export{kh as A,UN as B,yN as C,yn as D,CN as E,Pv as F,jN as G,qN as H,NN as I,IN as J,zN as K,BN as L,cr as M,p0 as R,Gt as a,vN as b,uv as c,dv as d,ei as e,ge as f,Wx as g,bN as h,wN as i,PN as j,AN as k,SN as l,EN as m,TN as n,DN as o,$N as p,kN as q,St as r,MN as s,FN as t,KN as u,LN as v,te as w,_N as x,RN as y,ON as z};
52
+ `),[S,T]=x.useState(i.tagPierreReviews),[N,b]=x.useState(i.pierreFooter),I=S!==i.tagPierreReviews||N!==i.pierreFooter,[$,L]=x.useState(i.cost),q=JSON.stringify($)!==JSON.stringify(i.cost),Q=()=>Km.find(B=>!$.some(O=>O.kind===B))??"in_house",[_,Y]=x.useState(i.slackDigest),X=_!==i.slackDigest;return n.jsxs("div",{"data-testid":"bot-settings-section",className:"space-y-4",children:[n.jsx(Dj,{}),n.jsxs(or,{title:"Detection",desc:"How we recognise automated reviewers beyond the known vendors — your own in-house AI reviewer or CI service accounts.",children:[n.jsx($s,{label:"Detect in-house / service-account reviewers",hint:"Fingerprint branded review markers and behaviour to flag your own automation.",checked:u,onChange:d}),n.jsx($s,{label:"Auto-tag high-confidence matches",hint:"Badge a reviewer automatically when detection is high-confidence (medium always asks first).",checked:p,onChange:m}),n.jsx($s,{label:"Deep detect (app attribution)",hint:"Off by default — an extra REST lookup during sync to read GitHub App attribution.",checked:g,onChange:w}),n.jsx($s,{label:"AI tie-break (opt-in)",hint:"For medium-confidence cases only, one cheap model call per reviewer to decide. Costs a little; off by default.",checked:v,onChange:y}),n.jsx(Nt,{label:"Login allowlist",hint:"One login or glob per line (e.g. acme-ci, *-bot). Always treated as automated.",children:n.jsx("textarea",{className:`${rt} min-h-[3rem] font-mono`,value:j,placeholder:`acme-ci
53
+ *-svc`,onChange:B=>R(B.target.value)})}),n.jsx(Pr,{dirty:E,saving:a,onClick:()=>s({bots:{inhouseDetect:u,autoTagHighConfidence:p,deepDetect:g,aiTiebreak:v,loginAllowlist:P}})})]}),n.jsxs(or,{title:"Pierre attribution",desc:"How Pierre's own Claude reviews are stamped when posted.",children:[n.jsx($s,{label:"Tag Pierre reviews",hint:"Append a hidden marker so Pierre-posted reviews are recognised as its own (verbatim vs curated).",checked:S,onChange:T}),n.jsx($s,{label:"Visible footer",hint:'Also append a visible "Reviewed with Pierre + Claude" footer to posted reviews.',checked:N,onChange:b}),n.jsx(Pr,{dirty:I,saving:a,onClick:()=>s({bots:{tagPierreReviews:S,pierreFooter:N}})})]}),n.jsx(qj,{settings:e,save:s,saving:a}),n.jsxs(or,{title:"Per-vendor cost",desc:"Optional monthly spend per reviewer, used to show cost-per-acted-on in the Bot ROI panel. Stays on your account.",children:[$.length===0?n.jsx("p",{className:"text-[11px] text-gray-400",children:"No costs entered."}):n.jsx("ul",{className:"space-y-1.5",children:$.map((B,O)=>n.jsxs("li",{className:"flex items-center gap-2",children:[n.jsx("select",{className:`${rt} w-auto`,value:B.kind,onChange:H=>L(ee=>ee.map((ce,C)=>C===O?{...ce,kind:H.target.value}:ce)),"aria-label":"Vendor",children:Km.map(H=>n.jsx("option",{value:H,children:an(H).label},H))}),n.jsx("span",{className:"text-[11px] text-gray-400",children:"$"}),n.jsx("input",{type:"number",min:0,className:`${rt} w-24`,value:B.monthlyUsd,onChange:H=>L(ee=>ee.map((ce,C)=>C===O?{...ce,monthlyUsd:Math.max(0,Number(H.target.value)||0)}:ce)),"aria-label":"Monthly USD"}),n.jsx("span",{className:"text-[11px] text-gray-400",children:"/mo"}),n.jsx("button",{type:"button",onClick:()=>L(H=>H.filter((ee,ce)=>ce!==O)),className:"ml-auto text-gray-400 hover:text-red-500","aria-label":"Remove",title:"Remove",children:"✕"})]},O))}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("button",{type:"button",onClick:()=>L(B=>[...B,{kind:Q(),monthlyUsd:0}]),className:"rounded border border-gray-300 px-2 py-1 text-[11px] font-medium text-gray-600 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:"Add vendor cost"}),n.jsx(Pr,{dirty:q,saving:a,onClick:()=>s({bots:{cost:$}})})]})]}),o.slackDigest&&n.jsxs(or,{title:"Slack bot digest",desc:"Include a review-bot summary block in the Slack digest.",children:[n.jsx($s,{label:"Send the review-bot block",hint:"Adds a deterministic bots section (volume · acted-on · untouched) to the scheduled Slack digest.",checked:_,onChange:Y}),n.jsx(Pr,{dirty:X,saving:a,onClick:()=>s({bots:{slackDigest:_}})})]})]})}function Kj({onClose:e}){const s=yn(),a=h0(!0),o=nk(),i=d=>{o.mutate(d)};x.useEffect(()=>{const d=p=>{p.key==="Escape"&&(p.stopImmediatePropagation(),e())};return window.addEventListener("keydown",d,!0),()=>window.removeEventListener("keydown",d,!0)},[e]);const u=a.data;return n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:e,role:"presentation",children:n.jsxs("div",{className:"flex max-h-[85vh] w-[30rem] max-w-[92vw] flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-900",onClick:d=>d.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Settings",children:[n.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[n.jsx("h2",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:"Settings"}),n.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:"✕"})]}),n.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto px-4 py-3",children:[o.isError&&n.jsx("p",{className:"rounded bg-red-50 px-2 py-1 text-xs text-red-600 dark:bg-red-950 dark:text-red-300",children:o.error.message}),a.isLoading||u==null?n.jsx("p",{className:"py-6 text-center text-xs text-gray-400",children:a.isError?"Settings unavailable.":"Loading…"}):n.jsxs(n.Fragment,{children:[s.teamInsights&&n.jsx(Pj,{settings:u,save:i,saving:o.isPending}),s.teamInsights&&n.jsx(Uj,{settings:u,save:i,saving:o.isPending}),s.slackDigest&&n.jsx(Aj,{settings:u,save:i,saving:o.isPending}),s.activityDigest&&n.jsx(Mj,{settings:u,save:i,saving:o.isPending}),s.issueLinks&&n.jsx(Lj,{settings:u,save:i,saving:o.isPending})]})]})]})})}const Hj={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.",unavailable:"That sign-in method isn’t enabled on this deployment."},Hm=()=>n.jsx("svg",{viewBox:"0 0 16 16",width:"18",height:"18",fill:"currentColor","aria-hidden":"true",children:n.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"})});function Wj(){const[e]=x.useState(()=>{const i=new URLSearchParams(window.location.search).get("auth");return i?Hj[i]??"We couldn’t complete sign-in. Please try again.":null});x.useEffect(()=>{if(!e)return;const i=new URL(window.location.href);i.searchParams.delete("auth"),window.history.replaceState({},"",i.pathname+i.search+i.hash)},[e]);const[s,a]=x.useState({oauth:!0,app:!1,appSlug:""});x.useEffect(()=>{let i=!0;return fetch("/api/auth/providers",{credentials:"include"}).then(u=>u.ok?u.json():null).then(u=>{i&&u&&a(u)}).catch(()=>{}),()=>{i=!1}},[]);const o=s.oauth&&s.app;return n.jsx("div",{className:"flex h-full min-h-screen w-full items-center justify-center bg-gray-950 px-4 text-gray-100",children:n.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:[n.jsx("span",{className:"brand-title text-4xl",title:"Pierre — a play on “PR”",children:"Pierre"}),n.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&&n.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}),n.jsxs("div",{className:"mt-7 flex w-full flex-col gap-3",children:[s.oauth&&n.jsxs("a",{href:"/api/auth/login/oauth",className:"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:[n.jsx(Hm,{}),"Sign in with GitHub"]}),s.app&&n.jsxs("div",{className:"flex w-full flex-col gap-1",children:[n.jsxs("a",{href:"/api/auth/login/app",className:`inline-flex w-full items-center justify-center gap-2 rounded-lg px-4 py-2.5 text-sm font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-sky-400 focus:ring-offset-2 focus:ring-offset-gray-950 ${o?"border border-gray-700 bg-transparent text-gray-100 hover:bg-gray-800":"bg-blue-600 text-white hover:bg-blue-700"}`,children:[n.jsx(Hm,{}),"Sign in with the Pierre GitHub App"]}),n.jsx("span",{className:"px-1 text-[11px] leading-snug text-amber-500/80",children:"Scope may be limited: private org repos only appear once an org admin installs the app on your org — until then you’ll see public repos."})]})]}),o&&n.jsxs("p",{className:"mt-4 text-[11px] leading-relaxed text-gray-500",children:[n.jsx("span",{className:"text-gray-400",children:"GitHub"})," = public repositories, instant, no install. ",n.jsx("span",{className:"text-gray-400",children:"GitHub App"})," = also private repos, but only in orgs that have installed the app."]}),n.jsxs("p",{className:"mt-4 text-xs leading-relaxed text-gray-500",children:["Public repositories work either way, with no install. To watch"," ",n.jsx("strong",{className:"font-semibold text-gray-400",children:"private"})," org repos, sign in with the GitHub App and"," ",s.app&&s.appSlug?n.jsx("a",{className:"underline decoration-gray-600 underline-offset-2 hover:text-gray-300",href:`https://github.com/apps/${s.appSlug}/installations/new`,target:"_blank",rel:"noreferrer",children:"install it"}):"install it"," ","on that org (an org owner may need to approve). Revoke anytime from your GitHub settings."]})]})})}function Vj({notices:e}){if(e.length===0)return null;const s=e.map(a=>a.org).join(", ");return n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-amber-400/50 bg-amber-400/10 px-4 py-2 text-xs text-amber-800 dark:text-amber-200",children:[n.jsxs("span",{className:"min-w-0",children:[n.jsxs("strong",{className:"font-semibold",children:["Your GitHub sign-in is no longer authorized for ",s,"."]})," ","Its pull requests, CI checks and comments can’t be synced until you re-authorize (SAML single sign-on)."]}),n.jsx("a",{href:"/api/auth/reconnect",className:"ml-auto whitespace-nowrap rounded border border-amber-500/60 px-2.5 py-0.5 font-medium hover:bg-amber-400/20",children:"Reconnect GitHub"}),n.jsx("span",{className:"w-full text-[11px] text-amber-700/80 dark:text-amber-300/70",children:"Reconnect signs you in again through SSO. If it doesn’t clear, your org may restrict third-party OAuth apps — an org owner has to approve Pierre once."})]})}function Qj({user:e,canSignOut:s,onSignOut:a,onOpenSettings:o}){const[i,u]=x.useState(!1),d=x.useRef(null),p=e.displayName??e.login;Yn(d,()=>u(!1),i),x.useEffect(()=>{if(!i)return;const g=w=>{w.key==="Escape"&&(w.stopPropagation(),u(!1))};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[i]);const m=e.avatarUrl!=null?n.jsx("img",{src:e.avatarUrl,alt:p,width:20,height:20,className:"shrink-0 rounded-full",style:{width:20,height:20}}):n.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:p.slice(0,2).toUpperCase()});return n.jsxs("div",{ref:d,className:"relative",children:[n.jsxs("button",{type:"button",onClick:()=>u(g=>!g),"aria-haspopup":"menu","aria-expanded":i,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 ${i?"bg-gray-100 dark:bg-gray-800":""}`,title:e.displayName!=null?`Signed in as ${e.displayName} (@${e.login})`:`Signed in as ${e.login}`,children:[m,n.jsx("span",{className:"max-w-[10rem] truncate",children:p}),n.jsx("span",{"aria-hidden":"true",className:"text-[9px] text-gray-400",children:"▾"})]}),i&&n.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:[o!=null&&n.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{u(!1),o()},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:[n.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:[n.jsx("circle",{cx:"12",cy:"12",r:"3"}),n.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),"Settings"]}),n.jsxs("a",{role:"menuitem",href:Du(e.login),target:"_blank",rel:"noreferrer noopener",onClick:()=>u(!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:[n.jsx(ph,{size:13}),"Open Profile on GitHub"]}),s&&n.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{u(!1),a()},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:[n.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:[n.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),n.jsx("polyline",{points:"16 17 21 12 16 7"}),n.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]}),"Sign Out"]})]})]})}const Gj=["7d","14d","30d","90d","custom"];function du(e,s){if(e.length!==s.length)return!1;const a=new Set(e);return s.every(o=>a.has(o))}function fu(e){if(!e)return null;const s=e.split(",").map(a=>Number.parseInt(a,10)).filter(Number.isFinite);return s.length?s:null}function Yj(){const e=new URLSearchParams(window.location.search),s={},a=e.get("preset");a&&Gj.includes(a)&&(s.preset=a),s.repoIds=fu(e.get("repos")),s.userIds=fu(e.get("users")),e.get("bots")!==null&&(s.excludeBots=e.get("bots")==="1");const o=fu(e.get("allowBots"));o&&(s.allowedBotIds=o);const i=e.get("stale");i==="0"?s.excludeStale=!1:i==="1"&&(s.excludeStale=!0),s.customFrom=e.get("from"),s.customTo=e.get("to");const u=e.get("cats");if(u){const j=new Set(cl);s.categories=u.split(",").filter(R=>j.has(R))}const d=e.get("status");if(d!==null){const j=new Set(ul);s.prStatuses=d.split(",").filter(R=>j.has(R))}const p=e.get("reviews");if(p!==null){const j=new Set(dl);s.reviewStates=p.split(",").filter(R=>j.has(R))}const m=e.get("states");if(m){const j=new Set(Pu);s.derivedStates=m.split(",").filter(R=>j.has(R))}const g=e.get("pr");g&&(s.selectedPrId=Number.parseInt(g,10));const w=e.get("thread");w&&(s.selectedThreadId=Number.parseInt(w,10));const v=e.get("strip");(v==="my_turn"||v==="needs_attention"||v==="all")&&(s.stripFilter=v);const y=e.get("activityRepo");if(y){const j=Number.parseInt(y,10);Number.isFinite(j)&&(s.activityRepoId=j)}return e.get("open")==="1"&&(s.stripCollapsed=!1),s}function Wm(e){var i,u;const s=new URLSearchParams;e.preset!=="14d"&&s.set("preset",e.preset),(i=e.repoIds)!=null&&i.length&&s.set("repos",e.repoIds.join(",")),(u=e.userIds)!=null&&u.length&&s.set("users",e.userIds.join(",")),e.excludeBots&&s.set("bots","1"),e.excludeBots&&e.allowedBotIds.length&&s.set("allowBots",e.allowedBotIds.join(",")),e.excludeStale||s.set("stale","0"),e.preset==="custom"&&e.customFrom&&s.set("from",e.customFrom),e.preset==="custom"&&e.customTo&&s.set("to",e.customTo),du(e.categories,Oo)||s.set("cats",e.categories.join(",")),du(e.prStatuses,Bo)||s.set("status",e.prStatuses.join(",")),du(e.reviewStates,Do)||s.set("reviews",e.reviewStates.join(",")),e.derivedStates.length&&s.set("states",e.derivedStates.join(",")),e.selectedPrId&&s.set("pr",String(e.selectedPrId)),e.selectedThreadId&&s.set("thread",String(e.selectedThreadId)),e.stripFilter!=="all"&&s.set("strip",e.stripFilter),e.stripCollapsed||s.set("open","1"),De.getState().activeTab==="activity"&&(s.set("view","activity"),typeof e.activityRepoId=="number"&&s.set("activityRepo",String(e.activityRepoId)));const a=s.toString(),o=`${window.location.pathname}${a?`?${a}`:""}`;o!==window.location.pathname+window.location.search&&window.history.replaceState(null,"",o)}const b0="pierre:filterBarState";function Xj(){try{const e=localStorage.getItem(b0);if(!e)return null;const s=JSON.parse(e);return s&&typeof s=="object"?Yo(s):null}catch{return null}}function Jj(e){try{localStorage.setItem(b0,JSON.stringify(gu(e)))}catch{}}function Zj(){const e=x.useRef(!1);x.useEffect(()=>{if(!e.current){if(window.location.search.length>1)te.getState().hydrate(Yj()),new URLSearchParams(window.location.search).get("view")==="activity"&&De.getState().setActiveTab("activity");else{const i=Gx(),u=i?Yo(i.state):Xj();u&&te.getState().hydrate(u),De.getState().setActiveTab("activity")}e.current=!0}const s=te.subscribe(o=>{Wm(o),Jj(o)}),a=De.subscribe(()=>{Wm(te.getState())});return()=>{s(),a()}},[])}function Vm(e){if(!(e instanceof HTMLElement))return!1;const s=e.tagName;return s==="INPUT"||s==="TEXTAREA"||e.isContentEditable}function eN(){const{data:e}=nh();x.useEffect(()=>{const s=a=>{var m;const{selectedPrId:o,selectPr:i,clearSelection:u}=te.getState(),d=De.getState(),p=d.activeTab==="timeline";if(a.key==="Escape"){Vm(a.target)?a.target.blur():p?u():d.showTimeline();return}if(!Vm(a.target)){if(a.key==="/"){a.preventDefault(),(m=document.getElementById("add-repo-input"))==null||m.focus();return}if(a.key==="i"){d.showActivity();return}if(p&&(a.key==="j"||a.key==="k")){const g=[...(e==null?void 0:e.prs)??[]].sort((j,R)=>R.openedAt.localeCompare(j.openedAt));if(g.length===0)return;const w=g.findIndex(j=>j.id===o);let v;w===-1?v=0:v=a.key==="j"?w+1:w-1,v=Math.max(0,Math.min(g.length-1,v));const y=g[v];y&&i(y.id)}}};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e])}function tN(){const e=Be();x.useEffect(()=>{let s=null;const a=()=>{const u=new Map,d=(p,m)=>{const g=u.get(p);(!g||m>g)&&u.set(p,m)};for(const[,p]of e.getQueriesData({queryKey:["timeline"]}))for(const m of(p==null?void 0:p.prs)??[])d(m.id,m.updatedAt);for(const[,p]of e.getQueriesData({queryKey:["open-prs"]}))for(const m of(p==null?void 0:p.prs)??[])d(m.id,m.updatedAt);for(const[p,m]of u){const g=e.getQueryData(["pr",p]);if(!g||g.updatedAt>=m)continue;const w=e.getQueryState(["pr",p]);if(!(w&&w.fetchStatus!=="idle")){e.invalidateQueries({queryKey:["pr",p]});for(const v of g.threads??[])e.invalidateQueries({queryKey:["thread",v.id]})}}},o=()=>{s||(s=setTimeout(()=>{s=null,a()},300))};o();const i=e.getQueryCache().subscribe(u=>{const d=u.query.queryKey[0];(d==="timeline"||d==="open-prs")&&o()});return()=>{s&&clearTimeout(s),i()}},[e])}function nN(e){const{data:s}=sh(),a=x.useRef(null);x.useEffect(()=>{if(!s)return;const o=new Set;for(const y of s.awaitingReview)o.add(`r:${y.prId}`);for(const y of s.yourPrs)o.add(`p:${y.prId}`);for(const y of s.approvedPrs??[])o.add(`a:${y.prId}`);for(const y of s.threadsAwaiting)o.add(`t:${y.threadId}`);for(const y of s.watchedRepoPrs)o.add(`w:${y.prId}`);const i=a.current;if(a.current=o,i==null||!e||typeof Notification>"u"||Notification.permission!=="granted")return;const u=[...o].filter(y=>!i.has(y));if(u.length===0)return;const d=u.filter(y=>y.startsWith("r:")).length,p=u.filter(y=>y.startsWith("t:")).length,m=u.filter(y=>y.startsWith("p:")).length,g=u.filter(y=>y.startsWith("a:")).length,w=u.filter(y=>y.startsWith("w:")).length,v=[];d&&v.push(`${d} review${d===1?"":"s"} requested`),p&&v.push(`${p} thread${p===1?"":"s"} awaiting you`),m&&v.push(`${m} of your PRs active`),g&&v.push(`${g} of your PRs approved`),w&&v.push(`${w} new in watched repos`);try{const y=new Notification(`Pierre — ${u.length} new in My Turn`,{body:v.join(" · "),tag:"pierre-my-turn"});y.onclick=()=>{window.focus(),y.close()}}catch{}},[s,e])}const pu="";function rN(e){return/^G-[A-Z0-9]{6,}$/i.test(e)&&e!=="G-XXXXXXXXXX"}let Tu=!1;function sN(){if(Tu||typeof window>"u"||!rN(pu))return;Tu=!0;const e=document.createElement("script");e.async=!0,e.src=`https://www.googletagmanager.com/gtag/js?id=${pu}`,document.head.appendChild(e),window.dataLayer=window.dataLayer||[],window.gtag=function(){window.dataLayer.push(arguments)},window.gtag("js",new Date),window.gtag("config",pu,{send_page_view:!1})}function aN(e=window.location.pathname){!Tu||!window.gtag||window.gtag("event","page_view",{page_path:e,page_location:`${window.location.origin}${e}`,page_title:document.title})}function lN(){const[e,s]=x.useState(()=>(localStorage.getItem("theme")??"dark")!=="light");return x.useEffect(()=>{document.documentElement.classList.toggle("dark",e),localStorage.setItem("theme",e?"dark":"light")},[e]),[e,()=>s(a=>!a)]}function oN(){var F,K,ae;const e=_u();Zj(),eN(),tN();const[s,a]=lN(),[o,i]=x.useState(!1),[u,d]=x.useState(!1),p=tk(),[m,g]=x0(),w=typeof window<"u"&&"Notification"in window;nN(m&&w);const v=()=>{if(w){if(m){g(!1);return}Notification.permission==="granted"?g(!0):Notification.permission!=="denied"&&Notification.requestPermission().then(ne=>g(ne==="granted"))}},y=((F=e.data)==null?void 0:F.deploymentMode)==="cloud",j=((K=e.data)==null?void 0:K.user)??null,R=()=>{De.getState().clear(),ge.logout().finally(()=>window.location.assign("/"))},P=te(ne=>ne.selectedPrId),E=te(ne=>ne.selectedThreadId),S=De(ne=>ne.activeTab),T=De(ne=>ne.tabs),N=S!=="timeline"&&S!=="activity"?T.find(ne=>ne.key===S)??null:null,b=S==="activity",I=(N==null?void 0:N.kind)==="pr-detail"?N.prId:null,$=(N==null?void 0:N.kind)==="metrics-detail",L=(N==null?void 0:N.kind)==="bot-prs",q=(N==null?void 0:N.kind)==="pr-focus"?{kind:"isolate",prId:N.prId}:null,Q=I!=null||b||$||L,_=P!=null&&!Q,[Y,X]=s0("pierre:detailPaneHeight",384),B=x.useRef(null),O=x.useRef(null),H=x.useRef(null);x.useEffect(()=>{for(const ne of[O.current,B.current])ne&&(Q?ne.setAttribute("inert",""):ne.removeAttribute("inert"))},[Q]),x.useEffect(()=>{const ne=()=>De.getState().navigateBack();return window.addEventListener("popstate",ne),()=>window.removeEventListener("popstate",ne)},[]),x.useEffect(()=>{window.dispatchEvent(new Event("resize"))},[_]);const ee=ne=>{var Pe;H.current={startY:ne.clientY,startH:((Pe=B.current)==null?void 0:Pe.offsetHeight)??Y},ne.currentTarget.setPointerCapture(ne.pointerId)},ce=ne=>{const Pe=H.current;if(!Pe||!B.current)return;const se=window.innerHeight*.7,Z=Math.min(Math.max(Pe.startH+(Pe.startY-ne.clientY),160),se);B.current.style.height=`${Z}px`,window.dispatchEvent(new Event("resize"))},C=ne=>{!H.current||!B.current||(H.current=null,ne.currentTarget.releasePointerCapture(ne.pointerId),X(B.current.offsetHeight))};return x.useEffect(()=>{if(!y)return;const ne=()=>{ge.me().catch(()=>{})},Pe=window.setInterval(ne,180*1e3);return()=>window.clearInterval(Pe)},[y]),x.useEffect(()=>{y&&(sN(),aN())},[y]),e.error instanceof Gt&&e.error.status===401?n.jsx(Wj,{}):e.isLoading&&!e.data?n.jsx("div",{className:"flex h-full min-h-screen items-center justify-center bg-gray-950",children:n.jsx("span",{className:"brand-title text-4xl text-gray-100",children:"Pierre"})}):n.jsxs("div",{className:"flex h-full flex-col",children:[n.jsx(Vj,{notices:((ae=e.data)==null?void 0:ae.authNotices)??[]}),n.jsxs("header",{className:"flex items-center gap-3 border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[n.jsx("h1",{className:"brand-title",title:"Pierre — a play on “PR”",children:"Pierre"}),n.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[n.jsx(Cj,{}),n.jsx(Sj,{}),w&&n.jsx("button",{type:"button",onClick:v,"aria-pressed":m,className:`rounded border px-2 py-0.5 text-xs hover:border-gray-400 dark:hover:border-gray-500 ${m?"border-blue-400 text-blue-600 dark:border-blue-600 dark:text-blue-400":"border-gray-300 dark:border-gray-700"}`,title:m?"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:n.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:m?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[n.jsx("path",{d:"M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9"}),n.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}),n.jsx("button",{type:"button",onClick:()=>i(!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:"?"}),n.jsx("button",{type:"button",onClick:a,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:s?"☀":"☾"}),j!=null&&n.jsx(Qj,{user:j,canSignOut:y,onSignOut:R,onOpenSettings:p?()=>d(!0):null})]})]}),o&&n.jsx(Ij,{onClose:()=>i(!1)}),u&&n.jsx(Kj,{onClose:()=>d(!1)}),n.jsx(Rj,{}),n.jsx(iy,{}),n.jsx(py,{}),n.jsx(by,{}),n.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[n.jsx("section",{ref:O,className:"min-h-0 flex-1 overflow-hidden",children:q==null?n.jsx(vm,{},"board"):n.jsx(vm,{mode:q},`focus:${q.prId}`)}),_&&n.jsxs(n.Fragment,{children:[n.jsx("div",{role:"separator","aria-orientation":"horizontal","aria-label":"Resize detail pane",onPointerDown:ee,onPointerMove:ce,onPointerUp:C,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"}),n.jsx("section",{ref:B,style:{height:Y},className:"shrink-0 overflow-auto",children:n.jsx(pj,{})})]}),I!=null&&n.jsx("div",{"data-testid":"pinned-pr-overlay",className:"absolute inset-0 z-20 bg-white dark:bg-gray-950",children:n.jsx(Nh,{prId:I,selectedThreadId:P===I?E:null},I)}),b&&n.jsx("div",{"data-testid":"activity-overlay",className:"absolute inset-0 z-20 overflow-hidden bg-white dark:bg-gray-950",children:n.jsx(Hk,{})}),$&&n.jsx("div",{"data-testid":"metrics-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:n.jsx(tj,{})}),L&&n.jsx("div",{"data-testid":"bot-prs-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:n.jsx(fj,{})})]}),n.jsx(bj,{})]})}function di(e){return new Promise((s,a)=>{e.oncomplete=e.onsuccess=()=>s(e.result),e.onabort=e.onerror=()=>a(e.error)})}function iN(e,s){let a;const o=()=>{if(a)return a;const i=indexedDB.open(e);return i.onupgradeneeded=()=>i.result.createObjectStore(s),a=di(i),a.then(u=>{u.onclose=()=>a=void 0},()=>{}),a};return(i,u)=>o().then(d=>u(d.transaction(s,i).objectStore(s)))}let mu;function Zu(){return mu||(mu=iN("keyval-store","keyval")),mu}function cN(e,s=Zu()){return s("readonly",a=>di(a.get(e)))}function uN(e,s,a=Zu()){return a("readwrite",o=>(o.put(s,e),di(o.transaction)))}function dN(e,s=Zu()){return s("readwrite",a=>(a.delete(e),di(a.transaction)))}const fN=Zg({storage:{getItem:e=>cN(e).then(s=>s??null),setItem:(e,s)=>uN(e,s),removeItem:e=>dN(e)},key:"pierre-query-cache",throttleTime:1e3}),pN=new ex({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1,retry:1}}});var Po,Qm;(Qm=(Po=navigator.storage)==null?void 0:Po.persist)==null||Qm.call(Po);new URLSearchParams(window.location.search).has("perf")&&Eu(()=>import("./perfProbe-Da13EhTE.js"),[]).then(e=>e.startPerfProbe());const w0=document.getElementById("root");if(!w0)throw new Error("#root not found");const mN=1e3*60*60*24*7;mx.createRoot(w0).render(n.jsx(x.StrictMode,{children:n.jsx(tx,{client:pN,persistOptions:{persister:fN,maxAge:mN,buster:"pierre-detail-v4",dehydrateOptions:{shouldDehydrateQuery:e=>{const s=e.queryKey[0];return(s==="pr"||s==="thread"||s==="pr-files")&&e.state.status==="success"}}},children:n.jsx(oN,{})})}));export{kh as A,KN as B,vN as C,yn as D,RN as E,Av as F,NN as G,UN as H,SN as I,TN as J,qN as K,zN as L,cr as M,p0 as R,Gt as a,bN as b,dv as c,fv as d,ei as e,ge as f,Wx as g,wN as h,kN as i,AN as j,$N as k,CN as l,PN as m,EN as n,BN as o,MN as p,jN as q,St as r,FN as s,LN as t,HN as u,_N as v,te as w,ON as x,IN as y,DN as z};