diff --git a/dashboard/src/main.test.tsx b/dashboard/src/main.test.tsx index 4f647f4..2e58040 100644 --- a/dashboard/src/main.test.tsx +++ b/dashboard/src/main.test.tsx @@ -25,9 +25,11 @@ import { WebPushControl, WebhookHookDetailPage, WebhookPage, + api, buildJobQuery, buildKnowledgeQuery, changelogMarkdown, + createUnauthorizedHandler, formatRuntimeUsageSeconds, groupSessionEvents, groupTranscriptEntries, @@ -133,6 +135,30 @@ function sampleSloMetrics() { } describe("dashboard routing and API query helpers", () => { + it("starts only one OAuth login when concurrent API requests find an expired session", async () => { + const redirectToLogin = vi.fn(); + const handleUnauthorized = createUnauthorizedHandler(redirectToLogin); + const fetchMock = vi.fn().mockResolvedValue(new Response(null, { + status: 401, + statusText: "Unauthorized", + })); + vi.stubGlobal("fetch", fetchMock); + + const results = await Promise.allSettled([ + api("/api/me", undefined, handleUnauthorized), + api("/api/status", undefined, handleUnauthorized), + ]); + + expect(redirectToLogin).toHaveBeenCalledOnce(); + expect(redirectToLogin).toHaveBeenCalledWith("/auth/login"); + expect(fetchMock).toHaveBeenCalledTimes(2); + expect(results).toEqual([ + expect.objectContaining({ status: "rejected", reason: expect.objectContaining({ message: "401 Unauthorized" }) }), + expect.objectContaining({ status: "rejected", reason: expect.objectContaining({ message: "401 Unauthorized" }) }), + ]); + vi.unstubAllGlobals(); + }); + it("builds trimmed job queries and preserves the requested limit", () => { expect( buildJobQuery( diff --git a/dashboard/src/main.tsx b/dashboard/src/main.tsx index 156bb7d..c190704 100644 --- a/dashboard/src/main.tsx +++ b/dashboard/src/main.tsx @@ -763,10 +763,29 @@ function cn(...values: Array) { return twMerge(clsx(values)); } -async function api(path: string, init?: RequestInit): Promise { +function redirectToLogin(path: string) { + window.location.replace(path); +} + +function createUnauthorizedHandler(redirect = redirectToLogin) { + let redirectStarted = false; + return () => { + if (redirectStarted) return; + redirectStarted = true; + redirect("/auth/login"); + }; +} + +// Each login replaces the OAuth state cookie, so the page must start this flow only once. +const handleUnauthorized = createUnauthorizedHandler(); + +async function api(path: string, init?: RequestInit, onUnauthorized = handleUnauthorized): Promise { const headers = new Headers(init?.headers); headers.set("Accept", "application/json"); const response = await fetch(path, { ...init, headers }); + if (response.status === 401) { + onUnauthorized(); + } if (!response.ok) { throw new Error(`${response.status} ${response.statusText}`); } @@ -5541,6 +5560,8 @@ export { webhookTimeseriesPath, WebhookPage, WebhookHookDetailPage, + api, + createUnauthorizedHandler, }; const root = document.getElementById("root"); diff --git a/src/github_agent_bridge/dashboard_static/assets/index-j9YYBdoS.js b/src/github_agent_bridge/dashboard_static/assets/index-CCJFb6gR.js similarity index 96% rename from src/github_agent_bridge/dashboard_static/assets/index-j9YYBdoS.js rename to src/github_agent_bridge/dashboard_static/assets/index-CCJFb6gR.js index d0af7ce..42db534 100644 --- a/src/github_agent_bridge/dashboard_static/assets/index-j9YYBdoS.js +++ b/src/github_agent_bridge/dashboard_static/assets/index-CCJFb6gR.js @@ -174,8 +174,8 @@ var Ha=e=>{throw TypeError(e)};var Jr=(e,t,n)=>t.has(e)||Ha("Cannot "+n);var g=( `});++r0&&n.push({type:"text",value:` `}),n}function Lo(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Mo(e,t){const n=Jm(e,t),r=n.one(e,void 0),i=zm(n),a=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&a.children.push({type:"text",value:` -`},i),a}function tf(e,t){return e&&"run"in e?async function(n,r){const i=Mo(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Mo(n,{file:r,...e||t})}}function Do(e){if(e)throw e}var ss,Oo;function nf(){if(Oo)return ss;Oo=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):t.call(u)==="[object Array]"},a=function(u){if(!u||t.call(u)!=="[object Object]")return!1;var d=e.call(u,"constructor"),h=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!d&&!h)return!1;var m;for(m in u);return typeof m>"u"||e.call(u,m)},o=function(u,d){n&&d.name==="__proto__"?n(u,d.name,{enumerable:!0,configurable:!0,value:d.newValue,writable:!0}):u[d.name]=d.newValue},l=function(u,d){if(d==="__proto__")if(e.call(u,d)){if(r)return r(u,d).value}else return;return u[d]};return ss=function c(){var u,d,h,m,p,w,y=arguments[0],v=1,b=arguments.length,N=!1;for(typeof y=="boolean"&&(N=y,y=arguments[1]||{},v=2),(y==null||typeof y!="object"&&typeof y!="function")&&(y={});vo.length;let c;l&&o.push(i);try{c=e.apply(this,o)}catch(u){const d=u;if(l&&n)throw d;return i(d)}l||(c&&c.then&&typeof c.then=="function"?c.then(a,i):c instanceof Error?i(c):a(c))}function i(o,...l){n||(n=!0,t(o,...l))}function a(o){i(null,o)}}const pt={basename:of,dirname:lf,extname:cf,join:uf,sep:"/"};function of(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');yr(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,l=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),l>-1&&(e.codePointAt(i)===t.codePointAt(l--)?l<0&&(r=i):(l=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function lf(e){if(yr(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function cf(e){yr(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){const l=e.codePointAt(t);if(l===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),l===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function uf(...e){let t=-1,n;for(;++t0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function hf(e,t){let n="",r=0,i=-1,a=0,o=-1,l,c;for(;++o<=e.length;){if(o2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),i=o,a=0;continue}}else if(n.length>0){n="",r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else l===46&&a>-1?a++:a=-1}return n}function yr(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const pf={cwd:mf};function mf(){return"/"}function Hs(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function ff(e){if(typeof e=="string")e=new URL(e);else if(!Hs(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return xf(e)}function xf(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n0){let[p,...w]=d;const y=r[m][1];Us(y)&&Us(p)&&(p=is(!0,y,p)),r[m]=[u,p,...w]}}}}const wf=new vi().freeze();function cs(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function us(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function ds(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function zo(e){if(!Us(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function qo(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Pr(e){return vf(e)?e:new fc(e)}function vf(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function jf(e){return typeof e=="string"||kf(e)}function kf(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Nf="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Bo=[],$o={allowDangerousHtml:!0},Sf=/^(https?|ircs?|mailto|xmpp)$/i,_f=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Cf(e){const t=Pf(e),n=Ef(e);return Rf(t.runSync(t.parse(n),n),e)}function Pf(e){const t=e.rehypePlugins||Bo,n=e.remarkPlugins||Bo,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...$o}:$o;return wf().use(im).use(n).use(tf,r).use(t)}function Ef(e){const t=e.children||"",n=new fc;return typeof t=="string"&&(n.value=t),n}function Rf(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||If;for(const d of _f)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+Nf+d.id,void 0);return mc(e,u),Fd(e,{Fragment:s.Fragment,components:i,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function u(d,h,m){if(d.type==="raw"&&m&&typeof h=="number")return o?m.children.splice(h,1):m.children[h]={type:"text",value:d.value},h;if(d.type==="element"){let p;for(p in ts)if(Object.hasOwn(ts,p)&&Object.hasOwn(d.properties,p)){const w=d.properties[p],y=ts[p];(y===null||y.includes(d.tagName))&&(d.properties[p]=c(String(w||""),p,d))}}if(d.type==="element"){let p=n?!n.includes(d.tagName):a?a.includes(d.tagName):!1;if(!p&&r&&typeof h=="number"&&(p=!r(d,h,m)),p&&m&&typeof h=="number")return l&&d.children?m.children.splice(h,1,...d.children):m.children.splice(h,1),h}}}function If(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||Sf.test(e.slice(0,t))?e:""}const ji="-",Tf=e=>{const t=Lf(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{const l=o.split(ji);return l[0]===""&&l.length!==1&&l.shift(),xc(l,t)||Af(o)},getConflictingClassGroupIds:(o,l)=>{const c=n[o]||[];return l&&r[o]?[...c,...r[o]]:c}}},xc=(e,t)=>{var o;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),i=r?xc(e.slice(1),r):void 0;if(i)return i;if(t.validators.length===0)return;const a=e.join(ji);return(o=t.validators.find(({validator:l})=>l(a)))==null?void 0:o.classGroupId},Uo=/^\[(.+)\]$/,Af=e=>{if(Uo.test(e)){const t=Uo.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},Lf=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return Df(Object.entries(e.classGroups),n).forEach(([a,o])=>{Ks(o,r,a,t)}),r},Ks=(e,t,n,r)=>{e.forEach(i=>{if(typeof i=="string"){const a=i===""?t:Ho(t,i);a.classGroupId=n;return}if(typeof i=="function"){if(Mf(i)){Ks(i(r),t,n,r);return}t.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([a,o])=>{Ks(o,Ho(t,a),n,r)})})},Ho=(e,t)=>{let n=e;return t.split(ji).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},Mf=e=>e.isThemeGetter,Df=(e,t)=>t?e.map(([n,r])=>{const i=r.map(a=>typeof a=="string"?t+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([o,l])=>[t+o,l])):a);return[n,i]}):e,Of=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const i=(a,o)=>{n.set(a,o),t++,t>e&&(t=0,r=n,n=new Map)};return{get(a){let o=n.get(a);if(o!==void 0)return o;if((o=r.get(a))!==void 0)return i(a,o),o},set(a,o){n.has(a)?n.set(a,o):i(a,o)}}},gc="!",Ff=e=>{const{separator:t,experimentalParseClassName:n}=e,r=t.length===1,i=t[0],a=t.length,o=l=>{const c=[];let u=0,d=0,h;for(let v=0;vd?h-d:void 0;return{modifiers:c,hasImportantModifier:p,baseClassName:w,maybePostfixModifierPosition:y}};return n?l=>n({className:l,parseClassName:o}):o},zf=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(r=>{r[0]==="["?(t.push(...n.sort(),r),n=[]):n.push(r)}),t.push(...n.sort()),t},qf=e=>({cache:Of(e.cacheSize),parseClassName:Ff(e),...Tf(e)}),Bf=/\s+/,$f=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=t,a=[],o=e.trim().split(Bf);let l="";for(let c=o.length-1;c>=0;c-=1){const u=o[c],{modifiers:d,hasImportantModifier:h,baseClassName:m,maybePostfixModifierPosition:p}=n(u);let w=!!p,y=r(w?m.substring(0,p):m);if(!y){if(!w){l=u+(l.length>0?" "+l:l);continue}if(y=r(m),!y){l=u+(l.length>0?" "+l:l);continue}w=!1}const v=zf(d).join(":"),b=h?v+gc:v,N=b+y;if(a.includes(N))continue;a.push(N);const k=i(y,w);for(let _=0;_0?" "+l:l)}return l};function Uf(){let e=0,t,n,r="";for(;e{if(typeof e=="string")return e;let t,n="";for(let r=0;rh(d),e());return n=qf(u),r=n.cache.get,i=n.cache.set,a=l,l(c)}function l(c){const u=r(c);if(u)return u;const d=$f(c,n);return i(c,d),d}return function(){return a(Uf.apply(null,arguments))}}const ge=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},yc=/^\[(?:([a-z-]+):)?(.+)\]$/i,Kf=/^\d+\/\d+$/,Qf=new Set(["px","full","screen"]),Wf=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Vf=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Gf=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Jf=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Xf=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,kt=e=>yn(e)||Qf.has(e)||Kf.test(e),Rt=e=>$n(e,"length",ix),yn=e=>!!e&&!Number.isNaN(Number(e)),hs=e=>$n(e,"number",yn),Yn=e=>!!e&&Number.isInteger(Number(e)),Yf=e=>e.endsWith("%")&&yn(e.slice(0,-1)),Y=e=>yc.test(e),It=e=>Wf.test(e),Zf=new Set(["length","size","percentage"]),ex=e=>$n(e,Zf,wc),tx=e=>$n(e,"position",wc),nx=new Set(["image","url"]),rx=e=>$n(e,nx,ox),sx=e=>$n(e,"",ax),Zn=()=>!0,$n=(e,t,n)=>{const r=yc.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):n(r[2]):!1},ix=e=>Vf.test(e)&&!Gf.test(e),wc=()=>!1,ax=e=>Jf.test(e),ox=e=>Xf.test(e),lx=()=>{const e=ge("colors"),t=ge("spacing"),n=ge("blur"),r=ge("brightness"),i=ge("borderColor"),a=ge("borderRadius"),o=ge("borderSpacing"),l=ge("borderWidth"),c=ge("contrast"),u=ge("grayscale"),d=ge("hueRotate"),h=ge("invert"),m=ge("gap"),p=ge("gradientColorStops"),w=ge("gradientColorStopPositions"),y=ge("inset"),v=ge("margin"),b=ge("opacity"),N=ge("padding"),k=ge("saturate"),_=ge("scale"),D=ge("sepia"),j=ge("skew"),B=ge("space"),F=ge("translate"),C=()=>["auto","contain","none"],M=()=>["auto","hidden","clip","visible","scroll"],O=()=>["auto",Y,t],I=()=>[Y,t],X=()=>["",kt,Rt],q=()=>["auto",yn,Y],P=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],U=()=>["solid","dashed","dotted","double","none"],te=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],me=()=>["start","end","center","between","around","evenly","stretch"],ye=()=>["","0",Y],f=()=>["auto","avoid","all","avoid-page","page","left","right","column"],A=()=>[yn,Y];return{cacheSize:500,separator:":",theme:{colors:[Zn],spacing:[kt,Rt],blur:["none","",It,Y],brightness:A(),borderColor:[e],borderRadius:["none","","full",It,Y],borderSpacing:I(),borderWidth:X(),contrast:A(),grayscale:ye(),hueRotate:A(),invert:ye(),gap:I(),gradientColorStops:[e],gradientColorStopPositions:[Yf,Rt],inset:O(),margin:O(),opacity:A(),padding:I(),saturate:A(),scale:A(),sepia:ye(),skew:A(),space:I(),translate:I()},classGroups:{aspect:[{aspect:["auto","square","video",Y]}],container:["container"],columns:[{columns:[It]}],"break-after":[{"break-after":f()}],"break-before":[{"break-before":f()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...P(),Y]}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[y]}],"inset-x":[{"inset-x":[y]}],"inset-y":[{"inset-y":[y]}],start:[{start:[y]}],end:[{end:[y]}],top:[{top:[y]}],right:[{right:[y]}],bottom:[{bottom:[y]}],left:[{left:[y]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Yn,Y]}],basis:[{basis:O()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Y]}],grow:[{grow:ye()}],shrink:[{shrink:ye()}],order:[{order:["first","last","none",Yn,Y]}],"grid-cols":[{"grid-cols":[Zn]}],"col-start-end":[{col:["auto",{span:["full",Yn,Y]},Y]}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":[Zn]}],"row-start-end":[{row:["auto",{span:[Yn,Y]},Y]}],"row-start":[{"row-start":q()}],"row-end":[{"row-end":q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Y]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Y]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal",...me()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...me(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...me(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[N]}],px:[{px:[N]}],py:[{py:[N]}],ps:[{ps:[N]}],pe:[{pe:[N]}],pt:[{pt:[N]}],pr:[{pr:[N]}],pb:[{pb:[N]}],pl:[{pl:[N]}],m:[{m:[v]}],mx:[{mx:[v]}],my:[{my:[v]}],ms:[{ms:[v]}],me:[{me:[v]}],mt:[{mt:[v]}],mr:[{mr:[v]}],mb:[{mb:[v]}],ml:[{ml:[v]}],"space-x":[{"space-x":[B]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[B]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Y,t]}],"min-w":[{"min-w":[Y,t,"min","max","fit"]}],"max-w":[{"max-w":[Y,t,"none","full","min","max","fit","prose",{screen:[It]},It]}],h:[{h:[Y,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Y,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Y,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Y,t,"auto","min","max","fit"]}],"font-size":[{text:["base",It,Rt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",hs]}],"font-family":[{font:[Zn]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Y]}],"line-clamp":[{"line-clamp":["none",yn,hs]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",kt,Y]}],"list-image":[{"list-image":["none",Y]}],"list-style-type":[{list:["none","disc","decimal",Y]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[b]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[b]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...U(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",kt,Rt]}],"underline-offset":[{"underline-offset":["auto",kt,Y]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Y]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Y]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[b]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...P(),tx]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",ex]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},rx]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[w]}],"gradient-via-pos":[{via:[w]}],"gradient-to-pos":[{to:[w]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[b]}],"border-style":[{border:[...U(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[b]}],"divide-style":[{divide:U()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...U()]}],"outline-offset":[{"outline-offset":[kt,Y]}],"outline-w":[{outline:[kt,Rt]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:X()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[b]}],"ring-offset-w":[{"ring-offset":[kt,Rt]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",It,sx]}],"shadow-color":[{shadow:[Zn]}],opacity:[{opacity:[b]}],"mix-blend":[{"mix-blend":[...te(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":te()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",It,Y]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[h]}],saturate:[{saturate:[k]}],sepia:[{sepia:[D]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[b]}],"backdrop-saturate":[{"backdrop-saturate":[k]}],"backdrop-sepia":[{"backdrop-sepia":[D]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Y]}],duration:[{duration:A()}],ease:[{ease:["linear","in","out","in-out",Y]}],delay:[{delay:A()}],animate:[{animate:["none","spin","ping","pulse","bounce",Y]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[_]}],"scale-x":[{"scale-x":[_]}],"scale-y":[{"scale-y":[_]}],rotate:[{rotate:[Yn,Y]}],"translate-x":[{"translate-x":[F]}],"translate-y":[{"translate-y":[F]}],"skew-x":[{"skew-x":[j]}],"skew-y":[{"skew-y":[j]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Y]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Y]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Y]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[kt,Rt,hs]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},cx=Hf(lx),Qs={status:"",repo:"",thread:"",action:"",intent:"",actor:""},ux=new Uu({defaultOptions:{queries:{retry:1}}}),Ko=12,dx=12,hx=10080*60*1e3,px=1e3,Ws=Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC";function Q(...e){return cx(du(e))}async function ee(e,t){const n=new Headers(t==null?void 0:t.headers);n.set("Accept","application/json");const r=await fetch(e,{...t,headers:n});if(!r.ok)throw new Error(`${r.status} ${r.statusText}`);return r.json()}function Xe(e){if(e==null)return"n/a";const t=Math.max(0,Math.floor(e));if(t<60)return`${t}s`;const n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}const mx=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"short"}),fx=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});function wr(e){if(!e)return null;const t=new Date(e);return Number.isNaN(t.getTime())?null:t}function xx(e){const t=wr(e);return t?mx.format(t):e??""}function ir(e){const t=wr(e);return t?fx.format(t):e??""}function vc(e,t){const n=wr(e);if(!n)return e??"";const r=t-n.getTime(),i=Math.abs(r);if(i>hx)return ir(e);const a=r>=0?"ago":"from now",o=Math.round(i/1e3);if(o<45)return r>=0?"just now":"soon";if(o<90)return`1m ${a}`;const l=Math.round(o/60);if(l<60)return`${l}m ${a}`;if(l<90)return`1h ${a}`;const c=Math.round(l/60);return c<24?`${c}h ${a}`:c<36?`1d ${a}`:`${Math.round(c/24)}d ${a}`}function ue({value:e,compact:t=!1,relative:n=!1,now:r=Date.now()}){const i=wr(e);return i?s.jsx("time",{dateTime:i.toISOString(),title:`UTC: ${i.toISOString()}`,children:n?vc(e,r):t?ir(e):xx(e)}):s.jsx(s.Fragment,{children:e??""})}function jc(e,t){const n=wr(e);return n?Math.max(0,Math.floor((t-n.getTime())/1e3)):null}function ki(e,t){return e.status==="running"?jc(e.started_at,t)??e.runtime_seconds:e.runtime_seconds}function Ni(e,t){return e.status==="pending"?jc(e.created_at,t)??e.queue_wait_seconds:e.queue_wait_seconds}function gx(e){const[t,n]=R.useState(()=>Date.now());return R.useEffect(()=>{if(!e)return;n(Date.now());const r=window.setInterval(()=>n(Date.now()),px);return()=>window.clearInterval(r)},[e]),t}function bx(e){return(e??"").split(/\r?\n/).map(n=>n.trim()).find(Boolean)??""}function zr(e,t,n=1){const r=bx(t),i=n>1?` (${n})`:"";return r?`${e}${i}: ${r}`:`${e}${i}`}function qr(e){return e==="openclaw_stdout"||e==="openclaw_stderr"}function kc(e){return e.map(t=>t==null?void 0:t.trim()).filter(Boolean).join(` -`)}function yx(e){const t=[];for(const n of e){const r=t[t.length-1];if(r&&qr(n.event_type)&&r.eventType===n.event_type){r.count+=1,r.meta=n.ts,r.detail=kc([r.detail,n.detail]),r.summary=zr(n.summary,r.detail,r.count);continue}t.push({id:String(n.id),badge:n.event_type,meta:n.ts,summary:qr(n.event_type)?zr(n.summary,n.detail):n.summary,detail:n.detail,eventType:n.event_type,count:1})}return t}function wx(e){const t=[];return e.forEach((n,r)=>{const i=t[t.length-1];if(i&&qr(n.kind)&&i.kind===n.kind){i.count+=1,i.meta=n.timestamp,i.text=kc([i.text,n.text]),i.summary=zr(`${n.role} · ${n.kind}`,i.text,i.count);return}t.push({id:`${n.timestamp??"entry"}-${r}`,badge:n.title,meta:n.timestamp,summary:qr(n.kind)?zr(`${n.role} · ${n.kind}`,n.text):`${n.role} · ${n.kind}`,text:n.text,kind:n.kind,count:1})}),t}function Qo(e,t,n,r){return e==="openclaw_stdout"?!1:t||n>=r-2}function vx(e){return{pending:{badge:"border-amber-300 bg-amber-50 text-amber-800",dot:"bg-amber-500"},running:{badge:"border-blue-300 bg-blue-50 text-blue-700",dot:"bg-blue-600"},blocked:{badge:"border-red-300 bg-red-50 text-red-700",dot:"bg-red-600"},denied:{badge:"border-red-300 bg-red-50 text-red-700",dot:"bg-red-600"},done:{badge:"border-emerald-300 bg-emerald-50 text-emerald-700",dot:"bg-emerald-600"},waiting_approval:{badge:"border-slate-300 bg-slate-50 text-slate-700",dot:"bg-slate-500"}}[e]??{badge:"border-slate-300 bg-slate-50 text-slate-700",dot:"bg-slate-500"}}function jx(e,t){const n=new URLSearchParams;for(const[r,i]of Object.entries(e))i.trim()&&n.set(r,i.trim());return n.set("limit",String(t)),`/api/jobs?${n.toString()}`}function kx(e,t,n,r=50,i=0){const a=new URLSearchParams;return e.trim()&&a.set("repo",e.trim()),n==="proposals"&&t.trim()&&a.set("status",t.trim()),a.set("section",n),a.set("limit",String(r)),i>0&&a.set("offset",String(i)),`/api/knowledge?${a.toString()}`}function Nx(e){return{timeseries:e==="overview",hooks:e==="hooks",deliveries:e==="deliveries"}}function Sx(e,t,n="day"){return`/api/webhooks/github/timeseries?${new URLSearchParams({from:e,to:t,bucket:n}).toString()}`}function _x(e=50,t){const n=new URLSearchParams({limit:String(e)});return t&&n.set("cursor",t),`/api/webhooks/github/hooks?${n.toString()}`}function Cx(e=50,t,n){const r=new URLSearchParams({limit:String(e)});t&&r.set("cursor",t);for(const[i,a]of Object.entries(n??{}))a!=null&&a.trim()&&r.set(i,a.trim());return`/api/webhooks/github/deliveries?${r.toString()}`}function Er(e=new Date){return{from:new Date(e.getTime()-720*60*60*1e3).toISOString(),to:e.toISOString()}}function Px(e=Ws,t="7d",n="7d"){return`/api/metrics/summary?${new URLSearchParams({window:t,runtime_window:n,timezone:e}).toString()}`}function rt(e){try{const t=new URL(e);return t.protocol==="https:"||t.protocol==="http:"?t.href:"#"}catch{return"#"}}function Lr(){return"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window}function Ex(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="github-agent-bridge:push")}function Rx(e){const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),i=new Uint8Array(r.length);for(let a=0;an.id===t.id)?e:[...e,t]}function Tx(e,t){const n=Wo(t);return e.some(r=>Wo(r)===n)?e:[...e,t]}function Wo(e){return`${e.timestamp??""}:${e.role}:${e.kind}:${e.title}:${e.text}`}function Ax(e){return["claimed","dispatch_started","dispatch_finished","done","blocked","denied","waiting_approval"].includes(e)}function Vs(e){return e==="blocked"}function Gs(e){return["blocked","denied","waiting_approval"].includes(e)}function Js(e,t){return e.status!=="running"?!1:t!=null&&t.is_admin?!0:!!(t!=null&&t.login&&e.trigger_actor&&t.login.toLowerCase()===e.trigger_actor.toLowerCase())}function Lx(e=window.location.pathname){const t=e.match(/^\/jobs\/(\d+)\/?$/);return t?Number(t[1]):null}function Mx(e=window.location.pathname){return/^\/knowledge\/?$/.test(e)}function Dx(e=window.location.pathname){return/^\/mcp\/?$/.test(e)}function Ox(e=window.location.pathname){return/^\/system\/?$/.test(e)}function Fx(e=window.location.pathname){const t=e.match(/^\/webhooks\/hooks\/([^/]+)\/?$/);return t?decodeURIComponent(t[1]):null}function zx(e=window.location.pathname){const t=e.match(/^\/webhooks\/deliveries\/([^/]+)\/?$/);return t?decodeURIComponent(t[1]):null}function ps(e=window.location.pathname){return/^\/webhooks(?:\/(?:hooks|deliveries)\/[^/]+)?\/?$/.test(e)}function Nc(e){return e.startsWith("repo:")?e.slice(5):e}function Vo(e){return Object.values(e).some(t=>t.trim()!=="")}function qx(e){return[{key:"status",label:"Status",value:e.status},{key:"repo",label:"Repo",value:e.repo},{key:"thread",label:"Thread",value:e.thread},{key:"action",label:"Action",value:e.action},{key:"actor",label:"Actor",value:e.actor.trim()?`@${e.actor.trim().replace(/^@/,"")}`:""},{key:"intent",label:"Intent",value:e.intent}].filter(t=>t.value.trim()!=="")}function Bx(){var Ti,Ai,Li,Mi,Di,Oi,Fi,zi,qi,Bi,$i,Ui,Hi,Ki,Qi,Wi,Vi,Gi,Ji,Xi,Yi,Zi,ea,ta,na,ra,sa,ia,aa,oa,la,ca,ua,da,ha,pa,ma,fa,xa,ga,ba,ya,wa,va,ja,ka,Na,Sa,_a,Ca,Pa,Ea,Ra,Ia,Ta,Aa,La,Ma,Da,Oa,Fa,za,qa,Ba,$a;const e=Sl(),[t,n]=R.useState(Qs),[r,i]=R.useState(Ko),a=R.useRef(!1),[o,l]=R.useState(""),[c,u]=R.useState("proposed"),[d,h]=R.useState("proposals"),[m,p]=R.useState("overview"),[w,y]=R.useState({hook_id:"",event_name:"",repository:"",result:"",enqueue_status:""}),[v,b]=R.useState(()=>Er()),[N,k]=R.useState(null),[_,D]=R.useState(""),[j,B]=R.useState(!1),[F,C]=R.useState(""),[M,O]=R.useState(!1),[I,X]=R.useState(""),[q,P]=R.useState("7d"),[U,te]=R.useState("7d"),[me,ye]=R.useState(()=>window.location.pathname),[f,A]=R.useState(null),fe=Lx(me),x=fe!==null,Pe=Mx(me),He=Dx(me),de=Ox(me),lt=ps(me),Me=Fx(me),Ke=zx(me),st=!x&&!Pe&&!He&&!de&&!lt,oe=fe,ke=ve({queryKey:["metrics",Ws,q,U],queryFn:()=>ee(Px(Ws,q,U)),enabled:st||de}),Ne=ve({queryKey:["dashboard-status"],queryFn:()=>ee("/api/status"),refetchInterval:de?1e4:!1}),Ee=ve({queryKey:["me"],queryFn:()=>ee("/api/me"),refetchInterval:!1}),ct=lt&&!!((Ai=(Ti=Ee.data)==null?void 0:Ti.user)!=null&&Ai.is_admin&&((Li=Ne.data)!=null&&Li.webhook_configured)),Ht=Nx(m),yt=ve({queryKey:["web-push-config"],queryFn:()=>ee("/api/web-push/config"),enabled:!!((Mi=Ee.data)!=null&&Mi.user)}),Vr=ve({queryKey:["about"],queryFn:()=>ee("/api/about")}),vr=ve({queryKey:["job-actors"],queryFn:()=>ee("/api/jobs/actors"),enabled:st}),Qe=ve({queryKey:["jobs",t,r],queryFn:()=>ee(jx(t,r)),enabled:st,placeholderData:E=>E}),it=ve({queryKey:["processes"],queryFn:()=>ee("/api/processes"),enabled:de,refetchInterval:de?1e4:!1}),hn=ve({queryKey:["systemd"],queryFn:()=>ee("/api/systemd"),enabled:de}),pn=ve({queryKey:["alerts"],queryFn:()=>ee("/api/alerts"),enabled:de}),mn=ve({queryKey:["webhook-summary"],queryFn:()=>ee("/api/webhooks/github/summary"),enabled:ct}),Kn=ve({queryKey:["webhook-timeseries",v.from,v.to,"day"],queryFn:()=>ee(Sx(v.from,v.to)),enabled:ct&&Ht.timeseries}),S=ve({queryKey:["webhook-exceptions"],queryFn:()=>ee("/api/webhooks/github/exceptions"),enabled:ct&&Ht.timeseries}),L=Yr({queryKey:["webhook-hooks"],queryFn:({pageParam:E})=>ee(_x(50,E)),initialPageParam:null,getNextPageParam:E=>E.next_cursor??void 0,enabled:ct&&Ht.hooks&&Me===null&&Ke===null}),K=Yr({queryKey:["webhook-deliveries",w],queryFn:({pageParam:E})=>ee(Cx(50,E,w)),initialPageParam:null,getNextPageParam:E=>E.next_cursor??void 0,enabled:ct&&Ht.deliveries&&Me===null&&Ke===null}),G=ve({queryKey:["webhook-hook",Me],queryFn:()=>ee(`/api/webhooks/github/hooks/${encodeURIComponent(Me??"")}`),enabled:ct&&Me!==null}),le=R.useCallback(async E=>{const Z=await ee(`/api/webhooks/github/hooks/${encodeURIComponent(E)}/ping`,{method:"POST"});return G.refetch(),window.setTimeout(()=>void G.refetch(),1500),Z.detail},[G]),Re=ve({queryKey:["webhook-delivery",Ke],queryFn:()=>ee(`/api/webhooks/github/deliveries/${encodeURIComponent(Ke??"")}`),enabled:ct&&Ke!==null}),De=Yr({queryKey:["knowledge",d,o,d==="proposals"?c:""],queryFn:({pageParam:E})=>ee(kx(o,c,d,50,E)),initialPageParam:0,getNextPageParam:E=>E.next_offset??void 0,enabled:Pe}),Fe=ve({queryKey:["mcp-tokens"],queryFn:()=>ee("/api/mcp/tokens"),enabled:He&&!!((Di=Ee.data)!=null&&Di.user)}),Kt=ve({queryKey:["mcp-users"],queryFn:()=>ee("/api/mcp/users"),enabled:He&&!!((Oi=Ee.data)!=null&&Oi.user)}),ut=ve({queryKey:["job",oe],queryFn:()=>ee(`/api/jobs/${oe}`),enabled:oe!==null}),Ie=ve({queryKey:["job-session",oe],queryFn:()=>ee(`/api/jobs/${oe}/session`),enabled:oe!==null}),wt=ve({queryKey:["job-session-events",oe],queryFn:()=>ee(`/api/jobs/${oe}/session/events`),enabled:oe!==null}),Ye=ve({queryKey:["job-session-transcript",oe],queryFn:()=>ee(`/api/jobs/${oe}/session/transcript`),enabled:oe!==null}),Ci=R.useCallback(async E=>{const Z=await ee(`/api/jobs/${E}/retry`,{method:"POST"});e.setQueryData(["job",E],{job:Z.job}),e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["metrics"]})},[e]),Pi=R.useCallback(async E=>{const Z=await ee(`/api/jobs/${E}/dismiss`,{method:"POST"});e.setQueryData(["job",E],{job:Z.job}),e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["metrics"]})},[e]),Ei=R.useCallback(async(E,Z)=>{const ce=await ee(`/api/jobs/${E}/cancel`,{method:"POST",body:JSON.stringify({reason:Z||""})});e.setQueryData(["job",E],{job:ce.job}),e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["metrics"]}),e.invalidateQueries({queryKey:["dashboard-status"]})},[e]),Ri=R.useCallback(async(E,Z)=>{await ee(`/api/knowledge/proposals/${encodeURIComponent(E)}/${Z}`,{method:"POST"}),e.invalidateQueries({queryKey:["knowledge"]}),e.invalidateQueries({queryKey:["dashboard-status"]})},[e]),Fc=R.useCallback(async E=>{await ee(`/api/knowledge/rules/${encodeURIComponent(E)}`,{method:"DELETE"}),e.invalidateQueries({queryKey:["knowledge"]})},[e]),zc=R.useCallback(async(E,Z)=>{await ee(`/api/knowledge/rules/${encodeURIComponent(E)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:Z})}),e.invalidateQueries({queryKey:["knowledge"]})},[e]),qc=R.useCallback(async(E,Z)=>{const ce=await ee("/api/mcp/tokens",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:E,user_login:Z||void 0})});return e.invalidateQueries({queryKey:["mcp-tokens"]}),ce},[e]),Bc=R.useCallback(async(E,Z)=>{await ee(`/api/mcp/tokens/${encodeURIComponent(E)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({user_login:Z})}),e.invalidateQueries({queryKey:["mcp-tokens"]}),e.invalidateQueries({queryKey:["mcp-users"]})},[e]),$c=R.useCallback(async E=>{await ee(`/api/mcp/tokens/${encodeURIComponent(E)}`,{method:"DELETE"}),e.invalidateQueries({queryKey:["mcp-tokens"]})},[e]),Gr=R.useCallback(async E=>{const Z={refresh:"/api/autoupdate/refresh",apply:"/api/autoupdate/apply",complete:"/api/autoupdate/complete-pending"}[E];k(E),D("");try{await ee(Z,{method:"POST"}),e.invalidateQueries({queryKey:["dashboard-status"]})}catch(ce){e.invalidateQueries({queryKey:["dashboard-status"]}),D(ce instanceof Error?ce.message:String(ce))}finally{k(null)}},[e]),Uc=R.useCallback(async E=>{B(!0),C("");try{const Z=await ee(`/api/executor/${E?"pause":"resume"}`,{method:"POST"});e.setQueryData(["dashboard-status"],ce=>ce&&{...ce,executor_pause:Z.executor_pause}),await e.invalidateQueries({queryKey:["dashboard-status"]})}catch(Z){C(Z instanceof Error?Z.message:String(Z))}finally{B(!1)}},[e]),Hc=R.useCallback(async E=>{O(!0),X("");try{await ee("/api/executor/resize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workers:E})}),await Promise.all([e.invalidateQueries({queryKey:["dashboard-status"]}),e.invalidateQueries({queryKey:["processes"]})])}catch(Z){X(Z instanceof Error?Z.message:String(Z))}finally{O(!1)}},[e]),Kc=R.useCallback(async()=>{var Ua;const E=(Ua=yt.data)==null?void 0:Ua.public_key;if(!E)throw new Error("web_push_not_configured");if(!Lr())throw new Error("web_push_not_supported");if(await window.Notification.requestPermission()!=="granted")throw new Error("notification_permission_denied");const ce=await navigator.serviceWorker.register("/service-worker.js"),su=await ce.pushManager.getSubscription()??await ce.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Rx(E)});await ee("/api/web-push/subscriptions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(su.toJSON())}),e.invalidateQueries({queryKey:["web-push-config"]})},[e,(Fi=yt.data)==null?void 0:Fi.public_key]),Qc=R.useCallback(async()=>{if(!Lr())return;const Z=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!Z)return;const ce=Z.endpoint;await Z.unsubscribe(),await ee("/api/web-push/subscriptions",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({endpoint:ce})}),e.invalidateQueries({queryKey:["web-push-config"]})},[e]);R.useEffect(()=>{var E;!((E=yt.data)!=null&&E.status.enabled)||!Lr()||navigator.serviceWorker.register("/service-worker.js").catch(()=>{})},[(zi=yt.data)==null?void 0:zi.status.enabled]),R.useEffect(()=>{if(oe===null)return;const E=new EventSource(`/api/jobs/${oe}/session/stream`);return E.addEventListener("session_event",Z=>{const ce=Br(Z);ce&&(e.setQueryData(["job-session-events",oe],Pt=>({events:Ix((Pt==null?void 0:Pt.events)??[],ce)})),Ax(ce.event_type)&&(e.invalidateQueries({queryKey:["job",oe]}),e.invalidateQueries({queryKey:["jobs"]})))}),E.addEventListener("transcript_entry",Z=>{const ce=Br(Z);!ce||ce.job_id!==oe||e.setQueryData(["job-session-transcript",oe],Pt=>({entries:Tx((Pt==null?void 0:Pt.entries)??[],ce.entry)}))}),E.onerror=()=>{e.invalidateQueries({queryKey:["job",oe]}),e.invalidateQueries({queryKey:["job-session-events",oe]}),e.invalidateQueries({queryKey:["job-session-transcript",oe]})},()=>E.close()},[oe,e]),R.useEffect(()=>{const E=()=>{ps(window.location.pathname)&&b(Er()),ye(window.location.pathname)};return window.addEventListener("popstate",E),()=>window.removeEventListener("popstate",E)},[]),R.useEffect(()=>{if(!("serviceWorker"in navigator))return;const E=Z=>{if(!Ex(Z.data))return;const ce={...Z.data.payload,id:Date.now(),receivedAt:Date.now()};A(ce),ce.job_id&&(e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["job",ce.job_id]}),e.invalidateQueries({queryKey:["metrics"]}))};return navigator.serviceWorker.addEventListener("message",E),()=>navigator.serviceWorker.removeEventListener("message",E)},[e]),R.useEffect(()=>{if(!f)return;const E=window.setTimeout(()=>A(null),12e3);return()=>window.clearTimeout(E)},[f]);const Ii=R.useCallback(E=>{window.history.pushState({},"",Un(E)),ye(window.location.pathname)},[]),dt=R.useCallback(E=>{window.history.pushState({},"",E),ps(E)&&b(Er()),ye(window.location.pathname)},[]),Qt=((qi=ke.data)==null?void 0:qi.metrics.status_counts)??{},jr=((Bi=Qe.data)==null?void 0:Bi.jobs)??[],Wc=!!((Ui=($i=Ee.data)==null?void 0:$i.user)!=null&&Ui.is_admin&&Sc((Hi=Ne.data)==null?void 0:Hi.autoupdate)),Vc=R.useCallback(E=>{n(E),i(Ko),a.current=!1},[]);R.useEffect(()=>{Qe.isFetching||(a.current=!1)},[Qe.isFetching]);const Gc=R.useCallback(()=>{a.current||(a.current=!0,i(E=>E+dx))},[]),Ct=oe?((Ki=ut.data)==null?void 0:Ki.job)??null:null,Jc=jr.some(E=>E.status==="running"||E.status==="pending")||(Ct==null?void 0:Ct.status)==="running"||(Ct==null?void 0:Ct.status)==="pending"||!!((Qi=it.data)!=null&&Qi.running_jobs.length),Qn=gx(Jc),Xc=s.jsx(rg,{selectedJobId:oe,selectedJob:Ct,loading:ut.isLoading,error:ut.error,session:(Wi=Ie.data)==null?void 0:Wi.session,sessionEvents:(Vi=wt.data)==null?void 0:Vi.events,transcript:(Gi=Ye.data)==null?void 0:Gi.entries,now:Qn}),Yc=((Ji=L.data)==null?void 0:Ji.pages.flatMap(E=>E.hooks))??[],Zc=((Xi=K.data)==null?void 0:Xi.pages.flatMap(E=>E.deliveries))??[],vt=((Yi=De.data)==null?void 0:Yi.pages)??[],jt=vt[vt.length-1],eu=vt.length>0?{...vt[0],repositories:(jt==null?void 0:jt.repositories)??vt[0].repositories,summary:(jt==null?void 0:jt.summary)??vt[0].summary,proposals:vt.flatMap(E=>E.proposals),rules:vt.flatMap(E=>E.rules),events:vt.flatMap(E=>E.events),next_offset:(jt==null?void 0:jt.next_offset)??null}:void 0,tu=m==="overview"?Kn.isLoading:m==="hooks"?L.isLoading:K.isLoading,nu=m==="overview"?Kn.error:m==="hooks"?L.error:K.error,ru=()=>{mn.refetch(),m==="overview"&&S.refetch(),m==="overview"&&b(Er()),m==="hooks"&&L.refetch(),m==="deliveries"&&K.refetch()};return s.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[s.jsx("header",{className:"border-b border-slate-800 bg-slate-950 text-white",children:s.jsxs("div",{className:"mx-auto flex w-full max-w-[1440px] items-center justify-between gap-3 px-4 py-4 md:px-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h1",{className:"truncate text-xl font-semibold",children:"GitHub Agent Bridge"}),s.jsx($x,{about:Vr.data})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(fg,{config:yt.data,loading:yt.isLoading,onEnable:Kc,onDisable:Qc}),s.jsx(mg,{user:(Zi=Ee.data)==null?void 0:Zi.user,loading:Ee.isLoading})]})]})}),s.jsxs("main",{className:"mx-auto grid w-full max-w-[1440px] gap-4 px-3 py-4 sm:px-4 md:px-6 md:py-5",children:[s.jsx(Vx,{isDashboardRoute:st,isSystemRoute:de,isKnowledgeRoute:Pe,isMcpRoute:He,isWebhooksRoute:lt,showWebhooks:!!((ta=(ea=Ee.data)==null?void 0:ea.user)!=null&&ta.is_admin&&((na=Ne.data)!=null&&na.webhook_configured)),knowledgeBadgeCount:((ia=(sa=(ra=Ne.data)==null?void 0:ra.metrics)==null?void 0:sa.knowledge)==null?void 0:ia.proposed)??0,systemUpdateAvailable:Wc,onNavigate:dt}),s.jsx(xg,{notification:f,onDismiss:()=>A(null),onNavigate:dt}),fe!==null?s.jsx(ng,{jobId:fe,detail:Xc,selectedJob:Ct,user:(aa=Ee.data)==null?void 0:aa.user,onBackToDashboard:()=>dt("/"),onRetry:Ci,onDismiss:Pi,onCancel:Ei,onRefresh:()=>{ut.refetch(),Ie.refetch(),wt.refetch(),Ye.refetch()}}):Pe?s.jsx(sg,{data:eu,loading:De.isLoading,error:De.error,repo:o,status:c,activeTab:d,user:(oa=Ee.data)==null?void 0:oa.user,now:Qn,onRepoChange:l,onStatusChange:u,onTabChange:h,onApprove:E=>Ri(E,"approve"),onReject:E=>Ri(E,"reject"),onUpdateRuleScope:zc,onDeleteRule:Fc,onRefresh:()=>De.refetch(),hasMore:!!De.hasNextPage,loadingMore:De.isFetchingNextPage,onLoadMore:()=>De.fetchNextPage()}):He?s.jsx(ug,{tokens:(la=Fe.data)==null?void 0:la.tokens,loading:Fe.isLoading,error:Fe.error,user:(ca=Ee.data)==null?void 0:ca.user,ownerOptions:((ua=Kt.data)==null?void 0:ua.users)??[],dashboardUrl:(da=Ne.data)==null?void 0:da.dashboard_url,dashboardUrlSource:(ha=Ne.data)==null?void 0:ha.dashboard_url_source,now:Qn,onCreate:qc,onUpdateOwner:Bc,onRevoke:$c,onRefresh:()=>Fe.refetch()}):lt?Ke?s.jsx(Zx,{data:Re.data,loading:Re.isLoading,error:Re.error,onBack:()=>{p("deliveries"),dt("/webhooks")},onRefresh:()=>Re.refetch(),onViewHook:E=>dt(`/webhooks/hooks/${encodeURIComponent(E)}`),onViewJob:Ii}):Me?s.jsx(Yx,{data:G.data,loading:G.isLoading,error:G.error,onBack:()=>{p("hooks"),dt("/webhooks")},onRefresh:()=>G.refetch(),onViewHook:E=>dt(`/webhooks/hooks/${encodeURIComponent(E)}`),onViewDelivery:E=>dt(`/webhooks/deliveries/${encodeURIComponent(E)}`),onPing:le}):s.jsx(Gx,{summary:mn.data,timeseries:(pa=Kn.data)==null?void 0:pa.points,exceptions:(ma=S.data)==null?void 0:ma.exceptions,hooks:Yc,deliveries:Zc,section:m,summaryLoading:mn.isLoading,sectionLoading:tu,loadingMore:m==="hooks"?L.isFetchingNextPage:K.isFetchingNextPage,hasMore:m==="hooks"?L.hasNextPage:K.hasNextPage,deliveryFilters:w,error:mn.error??nu,onSectionChange:p,onLoadMore:()=>m==="hooks"?L.fetchNextPage():K.fetchNextPage(),onDeliveryFiltersChange:y,onViewHook:E=>dt(`/webhooks/hooks/${encodeURIComponent(E)}`),onViewDelivery:E=>dt(`/webhooks/deliveries/${encodeURIComponent(E)}`),onRefresh:ru}):de?s.jsxs(s.Fragment,{children:[s.jsx(Ux,{state:(fa=Ne.data)==null?void 0:fa.autoupdate,isAdmin:!!((ga=(xa=Ee.data)==null?void 0:xa.user)!=null&&ga.is_admin),runningAction:N,actionError:_,onRefresh:()=>Gr("refresh"),onApply:()=>Gr("apply"),onCompletePending:()=>Gr("complete")}),s.jsx(eg,{executorPause:(ba=Ne.data)==null?void 0:ba.executor_pause,executorPauseLoading:Ne.isLoading,executorPauseStatusError:Ne.error,executorPausePending:j,executorPauseError:F,executorCapacity:{desired:((ya=it.data)==null?void 0:ya.executor.expected_workers)??((va=(wa=Ne.data)==null?void 0:wa.metrics)==null?void 0:va.executor_worker_count)??0,live:((ja=it.data)==null?void 0:ja.executor.live_workers)??((Na=(ka=Ne.data)==null?void 0:ka.metrics)==null?void 0:Na.executor_worker_live_count)??0,busy:((Sa=it.data)==null?void 0:Sa.executor.busy_workers)??((Ca=(_a=Ne.data)==null?void 0:_a.metrics)==null?void 0:Ca.executor_worker_busy_count)??0,draining:((Pa=it.data)==null?void 0:Pa.executor.draining_workers)??((Ra=(Ea=Ne.data)==null?void 0:Ea.metrics)==null?void 0:Ra.executor_worker_draining_count)??0},executorResizePending:M,executorResizeError:I,isAdmin:!!((Ta=(Ia=Ee.data)==null?void 0:Ia.user)!=null&&Ta.is_admin),onExecutorPauseChange:Uc,onExecutorResize:Hc,processes:it.data,processesLoading:it.isLoading,processesError:it.error,systemd:hn.data,systemdLoading:hn.isLoading,systemdError:hn.error,alerts:(Aa=pn.data)==null?void 0:Aa.alerts,alertsLoading:pn.isLoading,alertsError:pn.error,sloSummary:(La=ke.data)==null?void 0:La.metrics,sloLoading:ke.isLoading,sloError:ke.error,sloWindow:q,now:Qn,onRefreshProcesses:()=>it.refetch(),onRefreshSystemd:()=>hn.refetch(),onRefreshAlerts:()=>pn.refetch(),onSloWindowChange:P,onRefreshSlo:()=>ke.refetch()})]}):s.jsxs(s.Fragment,{children:[ke.error?s.jsx(be,{tone:"error",text:ke.error.message}):null,Ne.error?s.jsx(be,{tone:"error",text:Ne.error.message}):null,s.jsxs("section",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4","aria-label":"Summary metrics",children:[s.jsx(Ae,{title:"Pending",value:Qt.pending??0,icon:s.jsx(Rl,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Running",value:Qt.running??0,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Blocked",value:Qt.blocked??0,icon:s.jsx(Hr,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Done",value:Qt.done??0,icon:s.jsx(On,{className:"h-5 w-5"})})]}),s.jsxs("section",{className:"grid gap-3",children:[s.jsx(gg,{count:jr.length,limit:r,loading:Qe.isLoading,onRefresh:()=>Qe.refetch()}),s.jsxs(se,{title:"Recent jobs",flushHeader:!0,children:[s.jsx(kg,{filters:t,actorOptions:((Ma=vr.data)==null?void 0:Ma.actors)??[],onChange:Vc}),Qe.error?s.jsx(be,{tone:"error",text:Qe.error.message}):null,s.jsx(Sg,{jobs:jr,loading:Qe.isLoading,loadingMore:Qe.isFetching&&!Qe.isLoading,hasMore:jr.length>=r,onLoadMore:Gc,onViewJob:Ii,now:Qn,user:(Da=Ee.data)==null?void 0:Da.user,onRetry:Ci,onDismiss:Pi,onCancel:Ei})]}),s.jsx(se,{title:"Runtime & jobs",action:s.jsx(nt,{onClick:()=>ke.refetch()}),children:s.jsx(Og,{usage:(Oa=ke.data)==null?void 0:Oa.metrics.runtime_usage,jobsByCreatedDay:(Fa=ke.data)==null?void 0:Fa.metrics.by_created_day,loading:ke.isLoading,totalJobs:gs(Qt)})}),s.jsx(se,{title:"Runtime by user",children:s.jsx(Bg,{usage:(za=ke.data)==null?void 0:za.metrics.runtime_usage_by_actor,loading:ke.isLoading,totalJobs:gs(Qt),window:U,onWindowChange:te})}),s.jsx(se,{title:"Runtime by repository",children:s.jsx($g,{usage:(qa=ke.data)==null?void 0:qa.metrics.runtime_usage_by_repo,loading:ke.isLoading,totalJobs:gs(Qt),window:U,onWindowChange:te})})]}),s.jsxs("section",{className:"grid gap-4 xl:grid-cols-2",children:[s.jsx(se,{title:"Runtime percentiles",children:s.jsx(Xo,{label:"runtime",values:(Ba=ke.data)==null?void 0:Ba.metrics.runtime_seconds})}),s.jsx(se,{title:"Queue wait percentiles",children:s.jsx(Xo,{label:"queue wait",values:($a=ke.data)==null?void 0:$a.metrics.queue_wait_seconds})})]})]})]})]})}function $x({about:e}){const t=e!=null&&e.version?`v${e.version}`:"version loading";return s.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-slate-300",children:[s.jsx("span",{children:"Operational dashboard"}),s.jsx("span",{className:"font-mono text-xs text-slate-400",children:t}),e!=null&&e.repository_url?s.jsxs("a",{className:"inline-flex items-center gap-1 text-xs font-semibold text-slate-200 hover:underline",href:rt(e.repository_url),rel:"noreferrer",target:"_blank",children:[s.jsx(on,{className:"h-3.5 w-3.5","aria-hidden":!0}),"GitHub"]}):null]})}function Sc(e){var t,n;return!!((n=(t=e==null?void 0:e.target)==null?void 0:t.tag_name)!=null&&n.trim()&&e.decision!=="noop")}function Ux({state:e,isAdmin:t,runningAction:n=null,actionError:r="",onRefresh:i,onApply:a,onCompletePending:o}){var v,b,N,k,_,D,j,B,F,C,M;if(!e||!Sc(e))return null;const l=(b=(v=e==null?void 0:e.target)==null?void 0:v.tag_name)==null?void 0:b.trim();if(!t||!l)return null;const c=Hx(e.decision),u=((N=e.queue)==null?void 0:N.active_total)??0,d=Kx((k=e.classification)==null?void 0:k.risk),h=Qx((_=e.target)==null?void 0:_.body),m=((j=(D=e.classification)==null?void 0:D.migration_files)==null?void 0:j.length)??0,p=((F=(B=e.classification)==null?void 0:B.risky_files)==null?void 0:F.length)??0,w=!!(e.executor_reload_pending&&e.dashboard_applied_at&&o),y=!!(a&&(m===0||u===0));return s.jsxs("section",{className:"rounded-md border border-amber-300 bg-amber-50 p-3 text-amber-950 shadow-sm","aria-label":"Update available",children:[s.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Hr,{className:"h-4 w-4 text-amber-700","aria-hidden":!0}),s.jsx("h2",{className:"text-sm font-semibold",children:"Update available"}),s.jsx("span",{className:"rounded-sm border border-amber-300 bg-white px-1.5 py-0.5 font-mono text-[11px] text-amber-800",children:l}),(C=e.target)!=null&&C.url?s.jsxs("a",{className:"inline-flex items-center gap-1 text-xs font-semibold text-amber-800 hover:underline",href:rt(e.target.url),rel:"noreferrer",target:"_blank",children:[s.jsx(on,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Release"]}):null]}),s.jsxs("p",{className:"mt-1 text-sm text-amber-900",children:[c,e.installed_tag?s.jsxs("span",{className:"font-mono",children:[" from ",e.installed_tag]}):null]}),s.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[i?s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-1.5 rounded-md border border-amber-300 bg-white px-2.5 text-xs font-semibold text-amber-900 hover:bg-amber-100 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:n!==null,onClick:i,children:[s.jsx(zn,{className:Q("h-3.5 w-3.5",n==="refresh"&&"animate-spin"),"aria-hidden":!0}),n==="refresh"?"Checking...":"Check now"]}):null,y?s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-1.5 rounded-md bg-amber-800 px-2.5 text-xs font-semibold text-white hover:bg-amber-900 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:n!==null,onClick:()=>{window.confirm(`Apply ${l}? This can restart bridge services according to the recorded safe plan.`)&&(a==null||a())},children:[s.jsx(On,{className:"h-3.5 w-3.5","aria-hidden":!0}),n==="apply"?"Applying...":"Apply update"]}):null,w?s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-1.5 rounded-md border border-amber-300 bg-white px-2.5 text-xs font-semibold text-amber-900 hover:bg-amber-100 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:n!==null,onClick:o,children:[s.jsx(cr,{className:"h-3.5 w-3.5","aria-hidden":!0}),n==="complete"?"Completing...":"Complete reload"]}):null]})]}),s.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-3 lg:min-w-[420px]",children:[s.jsx(ms,{label:"Impact",value:d}),s.jsx(ms,{label:"Active jobs",value:String(u)}),s.jsx(ms,{label:"Admin only",value:"autoupdate"})]})]}),e.blocked_reason||e.executor_reload_pending||m>0||p>0?s.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-xs",children:[e.executor_reload_pending?s.jsx("span",{className:"rounded-sm border border-amber-300 bg-white px-2 py-1 font-semibold",children:"executor reload pending"}):null,e.blocked_reason?s.jsx("span",{className:"rounded-sm border border-amber-300 bg-white px-2 py-1 font-mono",children:e.blocked_reason}):null,m>0?s.jsxs("span",{className:"rounded-sm border border-amber-300 bg-white px-2 py-1",children:[m," migration file",m===1?"":"s"]}):null,p>0?s.jsxs("span",{className:"rounded-sm border border-amber-300 bg-white px-2 py-1",children:[p," executor/shared file",p===1?"":"s"]}):null]}):null,h?s.jsxs("div",{className:"mt-3 rounded-md border border-amber-200 bg-white/70 p-2.5",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-amber-800",children:"Changelog preview"}),s.jsx(Wx,{markdown:h})]}):null,(M=e.warnings)!=null&&M.length?s.jsx("div",{className:"mt-2 font-mono text-xs text-amber-800",children:e.warnings[0]}):null,r?s.jsxs("div",{className:"mt-2 rounded-sm border border-amber-300 bg-white px-2 py-1 font-mono text-xs text-amber-900",children:["Action failed: ",r]}):null]})}function ms({label:e,value:t}){return s.jsxs("div",{className:"min-w-0 rounded-md border border-amber-200 bg-white/80 px-2 py-1.5",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-amber-700",children:e}),s.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-amber-950",children:t})]})}function Hx(e){return{stage_dashboard_reload:"Dashboard reload can be staged now",stage_defer_executor_reload:"Dashboard reload can be staged; executor reload waits for the queue",stage_full_reload:"Full reload can be staged now",defer_migration:"Migration release is waiting for a quiet queue"}[e??""]??"Update plan recorded"}function Kx(e){return{dashboard_only:"dashboard only",executor_or_queue:"executor or queue",executor_or_shared:"executor or shared",migration_required:"migration",none:"none"}[e??""]??"unknown"}function Qx(e){return(e??"").trim()}function Wx({markdown:e}){return s.jsx("div",{className:"mt-1 text-sm leading-relaxed text-amber-950",children:s.jsx(Cf,{allowedElements:["a","blockquote","code","em","h1","h2","h3","h4","li","ol","p","strong","ul"],components:{a:({href:t,children:n})=>s.jsx("a",{className:"font-semibold text-amber-800 underline underline-offset-2",href:rt(t??""),rel:"noreferrer",target:"_blank",children:n}),blockquote:({children:t})=>s.jsx("blockquote",{className:"mt-2 border-l-2 border-amber-300 pl-2 text-amber-900",children:t}),code:({children:t})=>s.jsx("code",{className:"rounded-sm bg-amber-100 px-1 py-0.5 font-mono text-[0.85em] text-amber-950",children:t}),h1:({children:t})=>s.jsx("h3",{className:"mt-2 text-sm font-semibold text-amber-950 first:mt-0",children:t}),h2:({children:t})=>s.jsx("h3",{className:"mt-2 text-sm font-semibold text-amber-950 first:mt-0",children:t}),h3:({children:t})=>s.jsx("h3",{className:"mt-2 text-sm font-semibold text-amber-950 first:mt-0",children:t}),h4:({children:t})=>s.jsx("h4",{className:"mt-2 text-xs font-semibold uppercase text-amber-800 first:mt-0",children:t}),li:({children:t})=>s.jsx("li",{className:"break-words pl-0.5 [overflow-wrap:anywhere]",children:t}),ol:({children:t})=>s.jsx("ol",{className:"mt-1 list-decimal space-y-1 pl-5 first:mt-0",children:t}),p:({children:t})=>s.jsx("p",{className:"mt-1 break-words [overflow-wrap:anywhere] first:mt-0",children:t}),strong:({children:t})=>s.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>s.jsx("em",{className:"italic",children:t}),ul:({children:t})=>s.jsx("ul",{className:"mt-1 list-disc space-y-1 pl-5 first:mt-0",children:t})},children:e})})}function Vx({isDashboardRoute:e,isSystemRoute:t=!1,isKnowledgeRoute:n,isMcpRoute:r=!1,isWebhooksRoute:i=!1,showWebhooks:a=!1,knowledgeBadgeCount:o=0,systemUpdateAvailable:l=!1,onNavigate:c}){return s.jsxs("nav",{className:"flex min-w-0 rounded-lg border border-border bg-panel p-1 shadow-sm","aria-label":"Dashboard sections",children:[s.jsxs(er,{href:"/",active:e,onNavigate:c,children:[s.jsx(Al,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"Jobs"})]}),s.jsxs(er,{href:"/system",active:t,onNavigate:c,children:[s.jsx(id,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"System"}),l?s.jsx("span",{className:Q("inline-flex h-5 min-w-5 items-center justify-center rounded-full border px-1 font-mono text-[11px] leading-none",t?"border-white/40 bg-white/15 text-white":"border-amber-200 bg-amber-100 text-amber-800"),"aria-label":"System update available",children:"!"}):null]}),a?s.jsxs(er,{href:"/webhooks",active:i,onNavigate:c,children:[s.jsx(an,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"Webhooks"})]}):null,s.jsxs(er,{href:"/knowledge",active:n,onNavigate:c,children:[s.jsx(oi,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"Knowledge"}),o>0?s.jsx("span",{className:Q("inline-flex h-5 min-w-5 items-center justify-center rounded-full border px-1 font-mono text-[11px] leading-none",n?"border-white/40 bg-white/15 text-white":"border-amber-200 bg-amber-100 text-amber-800"),"aria-label":`${o} proposed knowledge ${o===1?"item":"items"}`,children:o}):null]}),s.jsxs(er,{href:"/mcp",active:r,onNavigate:c,children:[s.jsx(Dr,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"MCP"})]})]})}function gn({text:e}){return s.jsxs("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-muted",children:[s.jsx(zn,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),e]})}function Gx({summary:e,timeseries:t,exceptions:n,hooks:r,deliveries:i,section:a,summaryLoading:o,sectionLoading:l,loadingMore:c,hasMore:u,deliveryFilters:d,error:h,onSectionChange:m,onLoadMore:p,onDeliveryFiltersChange:w,onViewHook:y,onViewDelivery:v=()=>{},onRefresh:b}){var B,F,C,M,O,I,X,q,P,U,te,me,ye,f;const N=Object.values((e==null?void 0:e.receipts)??{}).reduce((A,fe)=>A+fe,0),k=((B=e==null?void 0:e.coverage)==null?void 0:B.promotion_state)??((F=e==null?void 0:e.coverage)!=null&&F.promotion_ready?"ready":"blocked"),_=k==="insufficient_data"?"insufficient data":k,D=(e==null?void 0:e.mode)==="primary"?"Primary eligibility scope":(e==null?void 0:e.mode)==="canary"?"Canary rollout cohort":"Shadow rollout cohort",j=[{id:"overview",label:"Overview"},{id:"hooks",label:"Hooks",count:(C=e==null?void 0:e.totals)==null?void 0:C.hooks},{id:"deliveries",label:"Deliveries",count:(M=e==null?void 0:e.totals)==null?void 0:M.deliveries}];return s.jsxs("section",{className:"grid gap-4",children:[s.jsx(Cc,{icon:s.jsx(an,{className:"h-5 w-5 text-muted","aria-hidden":!0}),title:"GitHub webhooks",subtitle:(e==null?void 0:e.mode)==="primary"?"Primary webhook ingestion. IMAP remains active as an idempotent safety net.":(e==null?void 0:e.mode)==="canary"?"Canary ingestion health. Only the webhook canary allowlist may create jobs.":"Shadow ingestion health. Deliveries are observed but do not create jobs.",action:s.jsx(nt,{onClick:b})}),h?s.jsx(be,{tone:"error",text:h.message}):null,s.jsx("div",{className:"flex max-w-full flex-wrap rounded-md border border-border bg-white p-1",role:"tablist","aria-label":"Webhook dashboard section",children:j.map(A=>s.jsxs("button",{type:"button",role:"tab","aria-label":A.count===void 0?A.label:`${A.label} (${A.count} total)`,"aria-selected":a===A.id,className:Q("inline-flex h-8 items-center gap-2 rounded px-3 text-sm font-semibold",a===A.id?"bg-primary text-white":"text-muted hover:bg-slate-50 hover:text-foreground"),onClick:()=>m(A.id),children:[A.label,A.count!==void 0?s.jsx("span",{className:"rounded border border-current/30 px-1 font-mono text-[10px]",children:A.count}):null]},A.id))}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4","aria-label":"Webhook status",children:[s.jsx(Ae,{title:"Receipts",value:N,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Duplicates",value:(e==null?void 0:e.duplicate_deliveries)??0,icon:s.jsx(zn,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Cross-source matches",value:(e==null?void 0:e.cross_source_matches)??0,icon:s.jsx(Fn,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Mode",value:o?"…":(e==null?void 0:e.mode)??"unknown",icon:s.jsx(Il,{className:"h-5 w-5"})})]}),a==="overview"?s.jsxs(s.Fragment,{children:[s.jsx(se,{title:"Delivery activity",children:l?s.jsx(gn,{text:"Loading delivery activity…"}):t!=null&&t.length?s.jsx("div",{className:"h-72","aria-label":"Webhook deliveries over time",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(ei,{data:t,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"bucket"}),s.jsx(sn,{allowDecimals:!1}),s.jsx(cn,{}),s.jsx(Ur,{}),s.jsx(Bt,{dataKey:"observed",stackId:"deliveries",fill:"#2563eb"}),s.jsx(Bt,{dataKey:"duplicate",stackId:"deliveries",fill:"#f59e0b"}),s.jsx(Bt,{dataKey:"unsupported",stackId:"deliveries",fill:"#94a3b8"})]})})}):s.jsx(J,{text:"No webhook activity in the selected 30-day window."})}),s.jsx(se,{title:"Receipt states",children:o?s.jsx(gn,{text:"Loading webhook summary…"}):Object.keys((e==null?void 0:e.receipts)??{}).length?s.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:Object.entries((e==null?void 0:e.receipts)??{}).sort(([A],[fe])=>A.localeCompare(fe)).map(([A,fe])=>s.jsx($,{label:A,value:fe},A))}):s.jsx(J,{text:"No webhook deliveries observed yet."})}),s.jsxs(se,{title:"Cross-source coverage",children:[s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx($,{label:"Both sources",value:((O=e==null?void 0:e.coverage)==null?void 0:O.both)??0}),s.jsx($,{label:"IMAP only",value:((I=e==null?void 0:e.coverage)==null?void 0:I.imap_only)??0}),s.jsx($,{label:"Webhook only",value:((X=e==null?void 0:e.coverage)==null?void 0:X.webhook_only)??0}),s.jsx($,{label:"Coverage",value:((q=e==null?void 0:e.coverage)==null?void 0:q.ratio)==null?"not measurable":`${Math.round(e.coverage.ratio*100)}%`}),s.jsx($,{label:"Decision mismatches",value:((P=e==null?void 0:e.coverage)==null?void 0:P.decision_mismatches)??0}),s.jsx($,{label:"Incomplete decision traces",value:((U=e==null?void 0:e.coverage)==null?void 0:U.incomplete_decision_traces)??0}),s.jsx($,{label:"Split identities",value:((te=e==null?void 0:e.coverage)==null?void 0:te.split_identities)??0}),s.jsx($,{label:"Promotion gate",value:_}),s.jsx($,{label:"Outside scope IMAP",value:((me=e==null?void 0:e.coverage)==null?void 0:me.outside_scope_imap_eligible)??0}),s.jsx($,{label:"Outside scope webhook",value:((ye=e==null?void 0:e.coverage)==null?void 0:ye.outside_scope_webhook_eligible)??0})]}),(f=e==null?void 0:e.coverage)!=null&&f.window_start&&e.coverage.window_end?s.jsxs("p",{className:"mt-3 font-mono text-xs text-muted",children:["Actionable IMAP events and comparable webhook events from ",s.jsx(ue,{value:e.coverage.window_start})," to ",s.jsx(ue,{value:e.coverage.window_end}),"; ",e.coverage.observation_days??7," observation days required and newest ",e.coverage.grace_seconds??0,"s excluded. ",D,": ",e.coverage.scope_repositories==null?"all repositories":`${e.coverage.scope_repositories.length} configured repositories`,e.coverage.observation_started_at?s.jsxs(s.Fragment,{children:["; observation epoch ",s.jsx(ue,{value:e.coverage.observation_started_at})]}):null,"."]}):null]}),Object.keys((e==null?void 0:e.enqueue)??{}).length?s.jsx(se,{title:"Canary ingestion decisions",children:s.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:Object.entries((e==null?void 0:e.enqueue)??{}).sort(([A],[fe])=>A.localeCompare(fe)).map(([A,fe])=>s.jsx($,{label:A,value:fe},A))})}):null,s.jsx(se,{title:"Exceptions requiring review",children:n!=null&&n.length?s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[840px] text-left text-sm",children:[s.jsx("thead",{className:"border-b border-border text-xs text-muted",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-3 py-2",children:"Type"}),s.jsx("th",{className:"px-3 py-2",children:"Repository"}),s.jsx("th",{className:"px-3 py-2",children:"Event"}),s.jsx("th",{className:"px-3 py-2",children:"References"}),s.jsx("th",{className:"px-3 py-2",children:"Observed"})]})}),s.jsx("tbody",{children:n.map(A=>s.jsxs("tr",{className:"border-b border-border/70 last:border-0",children:[s.jsx("td",{className:"px-3 py-2 font-semibold",children:A.kind}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:A.repository??"unknown"}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:A.event_type?`${A.event_type}${A.event_action?`:${A.event_action}`:""}`:"unknown"}),s.jsxs("td",{className:"px-3 py-2 font-mono text-xs",children:[s.jsx("div",{children:A.reference}),A.related_reference?s.jsx("div",{children:A.related_reference}):null,A.event_key?s.jsxs("div",{className:"text-muted",children:[A.event_key,A.related_event_key?` ↔ ${A.related_event_key}`:""]}):null]}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs text-muted",children:s.jsx(ue,{value:A.created_at,compact:!0})})]},`${A.kind}:${A.reference}:${A.related_reference??""}`))})]})}):s.jsx(J,{text:"No cross-source exceptions in retained data."})})]}):null,a==="hooks"?s.jsx(se,{title:"Hook inventory",children:l?s.jsx(gn,{text:"Loading hook inventory…"}):r!=null&&r.length?s.jsx(Xs,{noun:"hooks",hasMore:u,loading:c,onLoadMore:p,children:s.jsxs("table",{className:"w-full min-w-[920px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"sticky top-0 z-10 border-b border-border bg-panel text-left text-xs text-muted",children:[s.jsx("th",{className:"px-3 py-2",children:"Target"}),s.jsx("th",{className:"px-3 py-2",children:"State"}),s.jsx("th",{className:"px-3 py-2",children:"Configuration"}),s.jsx("th",{className:"px-3 py-2",children:"Last delivery"}),s.jsx("th",{className:"px-3 py-2",children:"Last ping"})]})}),s.jsx("tbody",{children:r.map(A=>s.jsxs("tr",{className:"cursor-pointer border-b border-border/70 last:border-0 hover:bg-slate-50",onClick:()=>y(A.id),children:[s.jsxs("td",{className:"px-3 py-3",children:[s.jsx("button",{type:"button",className:"text-left font-semibold text-primary hover:underline",onClick:fe=>{fe.stopPropagation(),y(A.id)},children:A.target}),s.jsxs("div",{className:"font-mono text-xs text-muted",children:[A.target_type," · #",A.id]})]}),s.jsx("td",{className:"px-3 py-3",children:s.jsx("span",{className:Q("rounded border px-2 py-1 text-xs font-semibold",A.status==="receiving"?"border-emerald-200 bg-emerald-50 text-emerald-700":A.status==="inactive"?"border-red-200 bg-red-50 text-red-700":"border-slate-200 bg-slate-50 text-slate-600"),children:A.status})}),s.jsxs("td",{className:"max-w-sm px-3 py-3 text-xs",children:[s.jsx("div",{children:A.events.join(", ")||"No event snapshot"}),s.jsxs("div",{className:"mt-1 font-mono text-muted",children:[A.content_type??"content type unknown"," · SSL ",A.ssl_verify===null||A.ssl_verify===void 0?"unknown":A.ssl_verify?"verified":"disabled"]})]}),s.jsxs("td",{className:"px-3 py-3 text-xs",children:[s.jsxs("div",{className:"font-semibold",children:[A.last_event_name??"Never",A.last_action?` · ${A.last_action}`:""]}),s.jsxs("div",{className:"mt-1 font-mono text-muted",children:[A.last_repository??"No repository",A.last_event_at?s.jsxs(s.Fragment,{children:[" · ",s.jsx(ue,{value:A.last_event_at,compact:!0})]}):null]})]}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs text-muted",children:A.last_ping_at?s.jsx(ue,{value:A.last_ping_at,compact:!0}):"Never"})]},A.id))})]})}):s.jsx(J,{text:"No hook inventory is available. Redeliver a signed ping from GitHub to create the sanitized configuration snapshot."})}):null,a==="deliveries"?s.jsxs(se,{title:"Recent deliveries",children:[s.jsx(Jx,{filters:d,onChange:w}),l?s.jsx(gn,{text:"Loading deliveries…"}):i!=null&&i.length?s.jsx(Xs,{noun:"deliveries",hasMore:u,loading:c,onLoadMore:p,children:s.jsx(_c,{deliveries:i,onViewHook:y,onViewDelivery:v})}):s.jsx(J,{text:"No deliveries match the current filters."})]}):null]})}function Jx({filters:e,onChange:t}){const n=[{key:"hook_id",label:"Hook ID",placeholder:"690954530"},{key:"event_name",label:"Event",placeholder:"issue_comment"},{key:"repository",label:"Repository",placeholder:"gisce/repository"},{key:"result",label:"Result",placeholder:"observed"},{key:"enqueue_status",label:"Ingestion",placeholder:"enqueued"}];return s.jsx("div",{className:"grid gap-2 border-b border-border p-3 sm:grid-cols-2 xl:grid-cols-5",children:n.map(r=>s.jsxs("label",{className:"grid gap-1 text-xs font-semibold text-muted",children:[r.label,s.jsx("input",{className:"h-9 rounded-md border border-border bg-white px-2 font-mono text-xs text-foreground",value:e[r.key],placeholder:r.placeholder,onChange:i=>t({...e,[r.key]:i.target.value})})]},r.key))})}function _c({deliveries:e,onViewHook:t,onViewDelivery:n=()=>{}}){return s.jsxs("table",{className:"w-full min-w-[1120px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"sticky top-0 z-10 border-b border-border bg-panel text-left text-xs text-muted",children:[s.jsx("th",{className:"px-3 py-2",children:"Received"}),s.jsx("th",{className:"px-3 py-2",children:"Hook"}),s.jsx("th",{className:"px-3 py-2",children:"Event"}),s.jsx("th",{className:"px-3 py-2",children:"Repository"}),s.jsx("th",{className:"px-3 py-2",children:"Result"}),s.jsx("th",{className:"px-3 py-2",children:"Ingestion"}),s.jsx("th",{className:"px-3 py-2",children:"Delivery"})]})}),s.jsx("tbody",{children:e.map(r=>{var i;return s.jsxs("tr",{className:"border-b border-border/70 last:border-0 hover:bg-slate-50",children:[s.jsx("td",{className:"px-3 py-3 font-mono text-xs text-muted",children:s.jsx(ue,{value:r.created_at,compact:!0})}),s.jsx("td",{className:"px-3 py-3",children:r.hook_id?s.jsxs("button",{type:"button",className:"text-left text-primary hover:underline",onClick:()=>t(r.hook_id),children:[s.jsx("span",{className:"block font-semibold",children:((i=r.hook)==null?void 0:i.target)??`Hook #${r.hook_id}`}),s.jsxs("span",{className:"font-mono text-xs",children:["#",r.hook_id]})]}):s.jsx("span",{className:"text-xs text-muted",children:"Unknown (legacy)"})}),s.jsxs("td",{className:"px-3 py-3 font-semibold",children:[r.event_name,r.action?` · ${r.action}`:""]}),s.jsx("td",{className:"px-3 py-3",children:r.repository??"—"}),s.jsxs("td",{className:"px-3 py-3",children:[s.jsx("span",{className:"rounded border border-border bg-slate-50 px-2 py-1 text-xs font-semibold",children:r.status}),r.duplicate_count?s.jsxs("span",{className:"ml-2 font-mono text-xs text-muted",children:[r.duplicate_count," retries"]}):null]}),s.jsx("td",{className:"px-3 py-3",children:r.enqueue_status?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"rounded border border-border bg-slate-50 px-2 py-1 text-xs font-semibold",children:r.enqueue_status}),r.job_id?s.jsxs("a",{className:"ml-2 font-mono text-xs font-semibold text-primary hover:underline",href:`/jobs/${r.job_id}`,children:["Job #",r.job_id]}):null]}):s.jsx("span",{className:"text-xs text-muted",children:"shadow"})}),s.jsx("td",{className:"max-w-[14rem] px-3 py-3",children:s.jsx("button",{type:"button",className:"block max-w-full truncate font-mono text-xs font-semibold text-primary hover:underline",title:r.delivery_id,onClick:()=>n(r.delivery_id),children:r.delivery_id})})]},r.delivery_id)})})]})}function Xs({noun:e,hasMore:t,loading:n,onLoadMore:r,children:i,className:a}){return s.jsxs("div",{"data-testid":`lazy-scroll-${e}`,className:Q("max-h-[640px] overflow-auto rounded-md border border-border",a),children:[i,s.jsx(Xx,{noun:e,hasMore:t,loading:n,onLoadMore:r})]})}function Xx({noun:e,hasMore:t,loading:n,onLoadMore:r}){const i=R.useRef(null),a=R.useRef(!1);return R.useEffect(()=>{n||(a.current=!1)},[n]),R.useEffect(()=>{const o=i.current;if(!o||!t||n||!r)return;const l=()=>{a.current||(a.current=!0,r())};if(!("IntersectionObserver"in window)){l();return}const c=new IntersectionObserver(u=>{u.some(d=>d.isIntersecting)&&l()},{rootMargin:"240px 0px"});return c.observe(o),()=>c.disconnect()},[t,n,e,r]),!t&&!n?null:s.jsx("div",{ref:i,className:"flex min-h-10 items-center justify-center border-t border-border px-3 py-2 text-xs font-medium text-muted","aria-live":"polite",children:n?`Loading more ${e}...`:`Scroll for more ${e}`})}function Yx({data:e,loading:t,error:n,onBack:r,onRefresh:i,onViewHook:a,onViewDelivery:o=()=>{},onPing:l}){const[c,u]=R.useState(!1),[d,h]=R.useState(""),[m,p]=R.useState("");if(t)return s.jsx(gn,{text:"Loading hook detail…"});if(n)return s.jsxs("div",{className:"grid gap-3",children:[s.jsx(be,{tone:"error",text:n.message}),s.jsx("button",{type:"button",className:"w-fit rounded border border-border px-3 py-2 text-sm font-semibold",onClick:r,children:"Back to hooks"})]});if(!e)return s.jsx(J,{text:"Hook detail is not available."});const w=e.hook,y={...w,github_created_at:w.github_created_at?s.jsx(ue,{value:w.github_created_at}):"unknown",github_updated_at:w.github_updated_at?s.jsx(ue,{value:w.github_updated_at}):"unknown",last_ping_at:w.last_ping_at?s.jsx(ue,{value:w.last_ping_at}):"never",last_event_at:w.last_event_at?s.jsx(ue,{value:w.last_event_at}):"never"},v=async()=>{if(!(!l||c)){u(!0),h(""),p("");try{h(await l(y.id))}catch(N){p(N instanceof Error?N.message:String(N))}finally{u(!1)}}},b=(e.recent_actions??[]).map(N=>({...N,created_at:s.jsx(ue,{value:N.created_at,compact:!0})}));return s.jsxs("section",{className:"grid gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsxs("button",{type:"button",className:"mb-2 inline-flex items-center gap-2 text-sm font-semibold text-primary hover:underline",onClick:r,children:[s.jsx(ai,{className:"h-4 w-4","aria-hidden":!0}),"Back to hooks"]}),s.jsx("h2",{className:"text-xl font-semibold",children:y.target}),s.jsxs("p",{className:"font-mono text-xs text-muted",children:[y.target_type," webhook #",y.id]})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[y.ping_url&&l?s.jsxs("button",{type:"button",className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold hover:bg-slate-50 disabled:cursor-wait disabled:opacity-60",disabled:c,onClick:()=>void v(),children:[s.jsx(an,{className:Q("h-4 w-4",c&&"animate-pulse"),"aria-hidden":!0}),c?"Sending ping…":"Send ping"]}):null,s.jsx(nt,{onClick:i}),y.admin_url?s.jsxs("a",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold hover:bg-slate-50",href:rt(y.admin_url),target:"_blank",rel:"noreferrer",children:[s.jsx(on,{className:"h-4 w-4","aria-hidden":!0}),"Open in GitHub"]}):null]})]}),m?s.jsx(be,{tone:"error",text:m}):null,d?s.jsx("div",{className:"rounded-md border border-emerald-200 bg-emerald-50 p-3 text-sm text-emerald-700",children:d}):null,s.jsxs("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[s.jsx(Ae,{title:"State",value:y.status,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Deliveries",value:e.stats.deliveries,icon:s.jsx(Fn,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Retries",value:e.stats.duplicates,icon:s.jsx(zn,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Unsupported",value:e.stats.unsupported,icon:s.jsx(Hr,{className:"h-5 w-5"})})]}),s.jsxs(se,{title:"Sanitized configuration",children:[s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:[s.jsx($,{label:"Active",value:y.active?"yes":"no"}),s.jsx($,{label:"Content type",value:y.content_type??"unknown"}),s.jsx($,{label:"SSL verification",value:y.ssl_verify===null||y.ssl_verify===void 0?"unknown":y.ssl_verify?"enabled":"disabled"}),s.jsx($,{label:"Destination URL",value:y.delivery_url??"unknown"}),s.jsx($,{label:"GitHub created",value:y.github_created_at??"unknown"}),s.jsx($,{label:"GitHub updated",value:y.github_updated_at??"unknown"}),s.jsx($,{label:"Last ping",value:y.last_ping_at??"never"}),s.jsx($,{label:"Last delivery",value:y.last_event_at??"never"}),s.jsx($,{label:"Last result",value:y.last_result??"unknown"})]}),s.jsxs("div",{className:"mt-3 rounded-md border border-border p-3",children:[s.jsx("div",{className:"text-xs font-semibold text-muted",children:"Subscribed events"}),s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:y.events.length?y.events.map(N=>s.jsx("span",{className:"rounded border border-border bg-slate-50 px-2 py-1 font-mono text-xs",children:N},N)):s.jsx("span",{className:"text-sm text-muted",children:"No event snapshot; send a ping to refresh it."})})]})]}),s.jsx(se,{title:"Latest observed delivery",children:s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:[s.jsx($,{label:"Event",value:y.last_event_name?`${y.last_event_name}${y.last_action?` · ${y.last_action}`:""}`:"none"}),s.jsx($,{label:"Repository",value:y.last_repository??"none"}),s.jsx($,{label:"Delivery ID",value:y.last_delivery_id??"none"})]})}),s.jsx(se,{title:"Recent administrative actions",children:b.length?s.jsx("div",{className:"divide-y divide-border rounded-md border border-border",children:b.map(N=>s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"font-semibold",children:N.action}),s.jsxs("span",{className:"ml-2 text-muted",children:["by @",N.actor]})]}),s.jsxs("span",{className:"font-mono text-xs text-muted",children:[N.status," · ",N.created_at]})]},N.id))}):s.jsx(J,{text:"No administrative actions recorded for this hook."})}),s.jsx(se,{title:"Recent deliveries",children:e.recent_deliveries.length?s.jsx(_c,{deliveries:e.recent_deliveries,onViewHook:a,onViewDelivery:o}):s.jsx(J,{text:"This hook has no retained deliveries."})})]})}function Zx({data:e,loading:t,error:n,onBack:r,onRefresh:i,onViewHook:a,onViewJob:o}){if(t)return s.jsx(gn,{text:"Loading delivery detail…"});if(n)return s.jsxs("div",{className:"grid gap-3",children:[s.jsx(be,{tone:"error",text:n.message}),s.jsx("button",{type:"button",className:"w-fit rounded border border-border px-3 py-2 text-sm font-semibold",onClick:r,children:"Back to deliveries"})]});if(!e)return s.jsx(J,{text:"Delivery detail is not available."});const l={...e.delivery,created_at:s.jsx(ue,{value:e.delivery.created_at})};return s.jsxs("section",{className:"grid gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsxs("button",{type:"button",className:"mb-2 inline-flex items-center gap-2 text-sm font-semibold text-primary hover:underline",onClick:r,children:[s.jsx(ai,{className:"h-4 w-4","aria-hidden":!0}),"Back to deliveries"]}),s.jsxs("h2",{className:"text-xl font-semibold",children:[l.event_name,l.action?` · ${l.action}`:""]}),s.jsxs("p",{className:"font-mono text-xs text-muted",children:["Delivery ",l.delivery_id]})]}),s.jsx(nt,{onClick:i})]}),s.jsxs(se,{title:"Delivery",children:[s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:[s.jsx($,{label:"Received",value:l.created_at}),s.jsx($,{label:"Repository",value:l.repository??"unknown"}),s.jsx($,{label:"Result",value:l.status}),s.jsx($,{label:"Event key",value:l.event_key??"unmatchable"}),s.jsx($,{label:"Payload SHA-256",value:e.payload_hash}),s.jsx($,{label:"Retries",value:l.duplicate_count??0})]}),l.hook_id?s.jsxs("button",{type:"button",className:"mt-3 text-sm font-semibold text-primary hover:underline",onClick:()=>a(l.hook_id),children:["View hook #",l.hook_id]}):null]}),s.jsx(se,{title:"Generated job",children:e.job?s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"font-semibold",children:e.job.work_key}),s.jsxs("div",{className:"mt-1 font-mono text-xs text-muted",children:["Job #",e.job.id," · ",e.job.status," · ",e.job.action," · ",e.job.work_intent]})]}),s.jsx("button",{type:"button",className:"rounded-md border border-border px-3 py-2 text-sm font-semibold hover:bg-slate-50",onClick:()=>o(e.job.id),children:"Open job"})]}):s.jsx(J,{text:"This delivery did not generate or coalesce into a job."})}),s.jsx(se,{title:"Full payload",children:e.payload===null?s.jsx(J,{text:"Payload was not retained for this legacy delivery."}):s.jsx("pre",{className:"max-h-[640px] overflow-auto rounded-md border border-border bg-slate-950 p-4 font-mono text-xs leading-relaxed text-slate-100",children:JSON.stringify(e.payload,null,2)})})]})}function eg({executorPause:e,executorPauseLoading:t,executorPauseStatusError:n,executorPausePending:r,executorPauseError:i,executorCapacity:a,executorResizePending:o,executorResizeError:l,isAdmin:c,onExecutorPauseChange:u,onExecutorResize:d,processes:h,processesLoading:m,processesError:p,systemd:w,systemdLoading:y,systemdError:v,alerts:b,alertsLoading:N,alertsError:k,sloSummary:_,sloLoading:D,sloError:j,sloWindow:B,now:F,onRefreshProcesses:C,onRefreshSystemd:M,onRefreshAlerts:O,onSloWindowChange:I,onRefreshSlo:X}){return s.jsxs("section",{className:"grid gap-4","aria-label":"Bridge system",children:[s.jsx(tg,{state:e,loading:t,statusError:n,pending:r,actionError:i,capacity:a,resizePending:o,resizeError:l,isAdmin:c,onChange:u,onResize:d}),j?s.jsx(be,{tone:"error",text:j.message}):null,s.jsx(wg,{summary:_,loading:D,window:B,onWindowChange:I,onRefresh:X}),s.jsxs(se,{title:"Systemd",action:s.jsx(nt,{onClick:M}),children:[v?s.jsx(be,{tone:"error",text:v.message}):null,s.jsx(Vg,{data:w,loading:y})]}),s.jsxs(se,{title:"Process activity",action:s.jsx(nt,{onClick:C}),children:[p?s.jsx(be,{tone:"error",text:p.message}):null,s.jsx(Xg,{data:h,loading:m})]}),s.jsxs(se,{title:"Monitor alerts",action:s.jsx(nt,{onClick:O}),children:[k?s.jsx(be,{tone:"error",text:k.message}):null,s.jsx(Yg,{alerts:b,loading:N,now:F})]})]})}function tg({state:e,loading:t,statusError:n,pending:r,actionError:i,capacity:a,resizePending:o=!1,resizeError:l="",isAdmin:c,onChange:u,onResize:d}){const h=!!(e!=null&&e.paused),[m,p]=R.useState(()=>String((a==null?void 0:a.desired)||1));R.useEffect(()=>{a!=null&&a.desired&&p(String(a.desired))},[a==null?void 0:a.desired]);const w=Number(m),y=Number.isInteger(w)&&w>=1;return s.jsxs(se,{title:"Executor",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-semibold",children:e?h?"Paused":"Accepting jobs":t?"Loading state...":"State unavailable"}),h?s.jsx("p",{className:"text-xs text-muted",children:"New jobs remain pending; running jobs continue."}):null,e!=null&&e.reason?s.jsxs("p",{className:"mt-1 text-xs text-muted",children:["Reason: ",e.reason]}):null,c?null:s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Admin only"})]}),s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm font-medium",children:[s.jsx("span",{children:"Pause"}),s.jsx("input",{"aria-label":"Pause executor",role:"switch",type:"checkbox",checked:h,disabled:!c||!e||!!e.error||!!n||r,onChange:()=>{const v=!h,b=v?"Pause executor? New jobs will remain pending; running jobs will continue.":"Resume executor? Pending jobs may start running.";window.confirm(b)&&u(v)},className:"peer sr-only"}),s.jsx("span",{"aria-hidden":!0,className:"relative h-6 w-11 rounded-full bg-slate-300 transition-colors peer-checked:bg-primary peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-primary peer-disabled:opacity-50 after:absolute after:left-0.5 after:top-0.5 after:h-5 after:w-5 after:rounded-full after:bg-white after:shadow-sm after:transition-transform peer-checked:after:translate-x-5"})]})]}),a?s.jsxs("div",{className:"mt-3 grid gap-3 border-t border-border pt-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4","aria-label":"Executor capacity",children:[s.jsx($,{label:"Desired",value:a.desired}),s.jsx($,{label:"Live",value:a.live}),s.jsx($,{label:"Busy",value:a.busy}),s.jsx($,{label:"Draining",value:a.draining})]}),s.jsxs("form",{className:"flex flex-wrap items-end gap-2",onSubmit:v=>{v.preventDefault(),y&&d&&d(w)},children:[s.jsxs("label",{className:"grid gap-1 text-xs font-semibold text-muted",children:["Desired workers",s.jsx("input",{"aria-label":"Desired workers",className:"control w-28",type:"number",min:"1",step:"1",value:m,disabled:!c||o,onChange:v=>p(v.target.value)})]}),s.jsx("button",{type:"submit",className:"h-9 rounded-md bg-primary px-3 text-sm font-semibold text-white disabled:cursor-not-allowed disabled:opacity-60",disabled:!c||o||!y||w===a.desired,children:o?"Resizing…":"Resize"})]})]}):null,n?s.jsx(be,{tone:"error",text:n.message}):null,e!=null&&e.error?s.jsx(be,{tone:"error",text:e.error}):null,i?s.jsx(be,{tone:"error",text:`Action failed: ${i}`}):null,l?s.jsx(be,{tone:"error",text:`Resize failed: ${l}`}):null]})}function er({href:e,active:t,children:n,onNavigate:r}){return s.jsx("a",{className:Q("inline-flex h-8 min-w-0 flex-1 items-center justify-center gap-1 rounded-md px-1.5 text-xs font-semibold sm:flex-none sm:gap-1.5 sm:px-3 sm:text-sm [&>span]:truncate [&>svg]:shrink-0",t?"bg-primary text-white shadow-sm":"text-muted hover:bg-slate-50 hover:text-foreground"),href:e,onClick:i=>{!r||i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.altKey||i.shiftKey||(i.preventDefault(),r(e))},children:n})}function ng({jobId:e,detail:t,selectedJob:n,user:r,onBackToDashboard:i,onRetry:a,onDismiss:o,onCancel:l,onRefresh:c}){const[u,d]=R.useState(!1),[h,m]=R.useState(!1),[p,w]=R.useState(!1),y=!!(r!=null&&r.is_admin&&n&&Vs(n.status)&&n.decision==="auto_trusted"),v=!!(r!=null&&r.is_admin&&n&&Gs(n.status)),b=!!(n&&Js(n,r)),N=u?"Retrying...":"Retry",k=h?"Dismissing...":"Dismiss",_=p?"Cancelling...":"Cancel";return s.jsxs("div",{className:"grid min-w-0 gap-3 sm:gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("a",{className:"inline-flex h-9 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50",href:"/",onClick:D=>{D.defaultPrevented||D.button!==0||D.metaKey||D.ctrlKey||D.altKey||D.shiftKey||(D.preventDefault(),i())},children:[s.jsx(ai,{className:"h-4 w-4","aria-hidden":!0}),"Dashboard"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[y?s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary px-3 text-sm font-semibold text-white disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:u,onClick:async()=>{if(window.confirm(`Retry job #${e}?`)){d(!0);try{await a(e)}finally{d(!1)}}},children:[s.jsx(cr,{className:"h-4 w-4","aria-hidden":!0}),N]}):null,v?s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md border border-border bg-white px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:h,onClick:async()=>{if(window.confirm(`Dismiss job #${e}?`)){m(!0);try{await o(e)}finally{m(!1)}}},children:[s.jsx(On,{className:"h-4 w-4","aria-hidden":!0}),k]}):null,b?s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md border border-red-200 bg-red-50 px-3 text-sm font-semibold text-red-700 hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:p,onClick:async()=>{const D=window.prompt(`Cancel job #${e}? Optional reason:`);if(D!==null){w(!0);try{await l(e,D)}finally{w(!1)}}},children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),_]}):null,s.jsx(nt,{onClick:c})]})]}),s.jsx(se,{title:`Job #${e}`,className:"p-3 sm:p-4",children:t})]})}function rg({selectedJobId:e,selectedJob:t,loading:n,error:r,session:i,sessionEvents:a,transcript:o,now:l}){return t?s.jsx(Ag,{job:t,session:i,sessionEvents:a,transcript:o,now:l}):e!==null&&n?s.jsx(J,{text:"Loading selected job..."}):e!==null&&r?s.jsx(be,{tone:"error",text:`Job #${e}: ${r.message}`}):s.jsx(J,{text:"Select a job to inspect its timeline, worklog and GitHub links."})}function sg({data:e,loading:t,error:n,repo:r,status:i,activeTab:a,user:o,now:l,onRepoChange:c,onStatusChange:u,onTabChange:d,onApprove:h,onReject:m,onUpdateRuleScope:p,onDeleteRule:w,onRefresh:y,hasMore:v=!1,loadingMore:b=!1,onLoadMore:N=()=>{}}){const k=(e==null?void 0:e.summary)??{},[_,D]=R.useState("proposals"),j=a??_,B=M=>{D(M),d==null||d(M)},C=[{id:"proposals",label:"Proposals",count:k.proposals??(k.proposed??0)+(k.approved??0)+(k.rejected??0)+(k.errors??0)},{id:"rules",label:"Rules",count:k.rules??0},{id:"events",label:"Events",count:k.events??0}];return s.jsxs("div",{className:"grid min-w-0 gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("h2",{className:"flex items-center gap-2 text-base font-semibold",children:[s.jsx(oi,{className:"h-5 w-5 text-muted","aria-hidden":!0}),"Acquired knowledge"]}),s.jsx("p",{className:"text-xs text-muted",children:"Captured feedback, proposed rules and curated agent memory."})]}),s.jsx(nt,{onClick:y})]}),n?s.jsx(be,{tone:"error",text:n.message}):null,s.jsxs("section",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4","aria-label":"Knowledge metrics",children:[s.jsx(Ae,{title:"Proposed",value:k.proposed??0,icon:s.jsx(Rl,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Approved",value:k.approved??0,icon:s.jsx(On,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Rules",value:k.rules??0,icon:s.jsx(Tl,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Events",value:k.events??0,icon:s.jsx(an,{className:"h-5 w-5"})})]}),s.jsx(se,{title:"Filters",className:"p-3",children:s.jsxs("div",{className:Q("grid gap-3",j==="proposals"?"md:grid-cols-[minmax(0,1fr)_220px]":"md:grid-cols-[minmax(0,1fr)]"),children:[s.jsx(ot,{label:"Repository",children:s.jsxs("select",{className:"control",value:r,onChange:M=>c(M.target.value),children:[s.jsx("option",{value:"",children:"All repositories"}),((e==null?void 0:e.repositories)??[]).map(M=>s.jsx("option",{value:M,children:M},M))]})}),j==="proposals"?s.jsx(ot,{label:"Proposal status",children:s.jsxs("select",{className:"control",value:i,onChange:M=>u(M.target.value),children:[s.jsx("option",{value:"",children:"All statuses"}),s.jsx("option",{value:"proposed",children:"proposed"}),s.jsx("option",{value:"approved",children:"approved"}),s.jsx("option",{value:"rejected",children:"rejected"}),s.jsx("option",{value:"error",children:"error"})]})}):null]})}),s.jsxs(se,{title:"Knowledge records",action:s.jsx("div",{className:"flex max-w-full flex-wrap rounded-md border border-border bg-white p-0.5",role:"tablist","aria-label":"Knowledge record type",children:C.map(M=>s.jsxs("button",{className:Q("inline-flex h-8 items-center gap-1.5 rounded px-2.5 text-xs font-semibold",j===M.id?"bg-primary text-white":"text-muted hover:bg-slate-50 hover:text-foreground"),type:"button",role:"tab","aria-label":`${M.label} (${M.count})`,"aria-selected":j===M.id,onClick:()=>B(M.id),children:[s.jsx("span",{children:M.label}),s.jsx("span",{className:Q("rounded-sm border px-1 font-mono text-[10px]",j===M.id?"border-white/40 text-white":"border-border text-muted"),children:M.count})]},M.id))}),children:[j==="proposals"?s.jsx(ig,{proposals:(e==null?void 0:e.proposals)??[],loading:t,isAdmin:!!(o!=null&&o.is_admin),now:l,onApprove:h,onReject:m}):null,j==="rules"?s.jsx(lg,{rules:(e==null?void 0:e.rules)??[],loading:t,now:l,onUpdateRuleScope:p,onDeleteRule:w}):null,j==="events"?s.jsx(cg,{events:(e==null?void 0:e.events)??[],loading:t,now:l}):null,v?s.jsx("div",{className:"mt-3 flex justify-center border-t border-border pt-3",children:s.jsx("button",{className:"button-secondary",type:"button",disabled:b,onClick:N,children:b?"Loading more...":"Load more knowledge records"})}):null]})]})}function ig({proposals:e,loading:t,isAdmin:n,now:r,onApprove:i,onReject:a}){const[o,l]=R.useState(null);return t&&e.length===0?s.jsx(J,{text:"Loading proposals..."}):e.length===0?s.jsx(J,{text:"No proposals match the current filters."}):s.jsx("div",{className:"grid gap-2",children:e.map(c=>s.jsxs("article",{className:"grid min-w-0 gap-2 rounded-md border border-border bg-white p-3",children:[s.jsx(Ec,{scope:c.scope,type:c.type,confidence:c.confidence,status:c.status,timestamp:c.updated_at,now:r}),s.jsx("p",{className:"min-w-0 break-words text-sm font-medium [overflow-wrap:anywhere]",children:c.rule||c.reason||"No reusable rule proposed."}),c.reason?s.jsx("p",{className:"min-w-0 break-words text-xs text-muted [overflow-wrap:anywhere]",children:c.reason}):null,c.source_event?s.jsx(ag,{event:c.source_event}):s.jsxs("p",{className:"font-mono text-xs text-muted",children:["Source event ",c.event_id]}),c.error?s.jsx(be,{tone:"error",text:c.error}):null,n&&c.status==="proposed"?s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md bg-primary px-3 text-sm font-semibold text-white disabled:opacity-60",type:"button",disabled:o===c.id,onClick:async()=>{l(c.id);try{await i(c.id)}finally{l(null)}},children:[s.jsx(On,{className:"h-4 w-4","aria-hidden":!0}),"Approve"]}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:opacity-60",type:"button",disabled:o===c.id,onClick:async()=>{l(c.id);try{await a(c.id)}finally{l(null)}},children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),"Reject"]})]}):null]},c.id))})}function ag({event:e}){const t=e.trigger_actor||(e.actor!=="github"?e.actor:null);return s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 rounded-md border border-border bg-slate-50 px-2 py-1.5",children:[s.jsx(Hn,{actor:t,avatarUrl:e.trigger_actor_avatar_url,framed:!0}),e.source_job_id?s.jsxs("a",{className:"inline-flex h-7 items-center gap-1 rounded-md border border-border bg-white px-2 text-xs font-semibold text-foreground hover:bg-slate-50",href:Un(e.source_job_id),children:[s.jsx(Fn,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Job #",e.source_job_id]}):null,e.github_urls.length>0?s.jsx(dr,{urls:e.github_urls,compact:!0}):s.jsx("span",{className:"font-mono text-xs text-muted",children:"No GitHub link"})]})}function og(e){const t=[{value:"global",label:"global"}];if(e.startsWith("repo:")){const n=e.slice(5),[r,i]=n.split("/",2);r&&i&&(t.push({value:`org:${r}`,label:`org:${r}`}),t.push({value:`repo:${r}/${i}`,label:`repo:${r}/${i}`}))}else e.startsWith("org:")&&t.push({value:e,label:e});return t.some(n=>n.value===e)||t.push({value:e,label:e}),t}function lg({rules:e,loading:t,now:n,onUpdateRuleScope:r,onDeleteRule:i}){const[a,o]=R.useState(null),[l,c]=R.useState(null),[u,d]=R.useState("");return t&&e.length===0?s.jsx(J,{text:"Loading curated rules..."}):e.length===0?s.jsx(J,{text:"No curated rules match the current filters."}):s.jsx("div",{className:"grid gap-2",children:e.map(h=>{const m=h.source_event_details??[],p=m[0],w=p?p.trigger_actor||(p.actor!=="github"?p.actor:null):null,y=m.flatMap(_=>_.github_urls??[]),v=og(h.scope),b=l===h.id,N=a===h.id,k=!!h.can_manage;return s.jsxs("article",{className:"grid min-w-0 gap-2 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsx(Ec,{scope:h.scope,type:h.type,confidence:h.confidence,status:`${h.observations} observation${h.observations===1?"":"s"}`,timestamp:h.last_seen,now:n}),k?s.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[b?s.jsxs(s.Fragment,{children:[s.jsx(ot,{label:"Scope",children:s.jsx("select",{className:"control h-8 min-w-[180px] py-1 text-xs",value:u,disabled:N,onChange:_=>d(_.target.value),children:v.map(_=>s.jsx("option",{value:_.value,children:_.label},_.value))})}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:opacity-60",type:"button",disabled:N||u===h.scope,title:"Save scope",onClick:async()=>{if(u!==h.scope){o(h.id);try{await r(h.id,u),c(null)}finally{o(null)}}},children:[s.jsx(od,{className:"h-4 w-4","aria-hidden":!0}),"Save"]}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-muted hover:bg-slate-50 disabled:opacity-60",type:"button",disabled:N,title:"Cancel scope edit",onClick:()=>{c(null),d("")},children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),"Cancel"]})]}):s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:opacity-60",type:"button",disabled:N,title:"Edit scope",onClick:()=>{c(h.id),d(h.scope)},children:[s.jsx(ad,{className:"h-4 w-4","aria-hidden":!0}),"Edit"]}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-red-200 px-3 text-sm font-semibold text-red-700 hover:bg-red-50 disabled:opacity-60",type:"button",disabled:N,onClick:async()=>{if(window.confirm("Delete this curated rule?")){o(h.id);try{await i(h.id)}finally{o(null)}}},children:[s.jsx(Ls,{className:"h-4 w-4","aria-hidden":!0}),"Delete"]})]}):null]}),s.jsx("p",{className:"min-w-0 break-words text-sm font-medium [overflow-wrap:anywhere]",children:h.rule}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx(Hn,{actor:w,avatarUrl:p==null?void 0:p.trigger_actor_avatar_url,framed:!0}),p!=null&&p.source_job_id?s.jsxs("a",{className:"inline-flex h-7 items-center gap-1 rounded-md border border-border px-2 text-xs font-semibold text-foreground hover:bg-white",href:Un(p.source_job_id),children:[s.jsx(Fn,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Job #",p.source_job_id]}):null,y.length>0?s.jsx(dr,{urls:y,compact:!0}):s.jsx("span",{className:"font-mono text-xs text-muted",children:"No GitHub link"})]})]},h.id)})})}function cg({events:e,loading:t,now:n}){return t&&e.length===0?s.jsx(J,{text:"Loading captured events..."}):e.length===0?s.jsx(J,{text:"No captured feedback events match the current filters."}):s.jsx("div",{className:"grid gap-2",children:e.map(r=>{const i=r.trigger_actor||(r.actor!=="github"?r.actor:null);return s.jsxs("details",{className:"group rounded-md border border-border bg-white",children:[s.jsxs("summary",{className:"grid cursor-pointer list-none gap-2 px-3 py-2 marker:hidden hover:bg-slate-50",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2 font-mono text-xs font-semibold text-muted",children:[s.jsx(Dn,{className:"h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180","aria-hidden":!0}),s.jsx("span",{className:"truncate",children:Nc(r.scope)})]}),s.jsx("span",{className:"shrink-0 font-mono text-xs text-muted",children:s.jsx(ue,{value:r.occurred_at,relative:!0,now:n})})]}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx(Hn,{actor:i,avatarUrl:r.trigger_actor_avatar_url,framed:!0}),r.source_job_id?s.jsxs("a",{className:"inline-flex h-7 items-center gap-1 rounded-md border border-border px-2 text-xs font-semibold text-foreground hover:bg-white",href:Un(r.source_job_id),children:[s.jsx(Fn,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Job #",r.source_job_id]}):null,r.github_urls.length>0?s.jsx(dr,{urls:r.github_urls,compact:!0}):s.jsx("span",{className:"font-mono text-xs text-muted",children:"No GitHub link"})]}),s.jsx("p",{className:"line-clamp-2 break-words text-sm [overflow-wrap:anywhere]",children:r.comment})]}),s.jsxs("div",{className:"grid gap-2 border-t border-border px-3 py-2",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"mb-1 text-xs font-semibold text-muted",children:"GitHub links"}),r.github_urls.length>0?s.jsx(dr,{urls:r.github_urls}):s.jsx("p",{className:"text-xs text-muted",children:"No links recorded."})]}),s.jsx("pre",{className:"max-h-72 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs leading-relaxed text-slate-100",children:JSON.stringify(r.context,null,2)})]})]},r.id)})})}function ug({tokens:e,loading:t,error:n,user:r,ownerOptions:i,dashboardUrl:a,dashboardUrlSource:o,now:l,onCreate:c,onUpdateOwner:u,onRevoke:d,onRefresh:h}){const[m,p]=R.useState(""),[w,y]=R.useState(""),[v,b]=R.useState(!1),[N,k]=R.useState(null),[_,D]=R.useState(null),[j,B]=R.useState(null),[F,C]=R.useState(""),M=e??[],O=i.find(P=>P.login===w);R.useEffect(()=>{var P;r!=null&&r.is_admin&&(w&&i.some(U=>U.login===w)||y((r==null?void 0:r.login)||((P=i[0])==null?void 0:P.login)||""))},[i,r==null?void 0:r.is_admin,r==null?void 0:r.login,w]);const I=(a||(typeof window>"u"?"":window.location.origin)).replace(/\/$/,""),X=`${I}/mcp`,q=`${I}/api/mcp`;return s.jsxs("div",{className:"grid min-w-0 gap-4",children:[s.jsx(Cc,{icon:s.jsx(Dr,{className:"h-5 w-5 text-muted","aria-hidden":!0}),title:"MCP access",subtitle:r!=null&&r.is_admin?"Issue and revoke globally readable knowledge tokens for any dashboard user.":"Issue and revoke globally readable knowledge tokens linked to your user.",action:s.jsx(nt,{onClick:h})}),n?s.jsx(be,{tone:"error",text:n.message}):null,F?s.jsx(be,{tone:"error",text:F}):null,s.jsx(dg,{dashboardUrl:X,endpointUrl:q,dashboardUrlSource:o??"request"}),j?s.jsxs("section",{className:"rounded-md border border-emerald-300 bg-emerald-50 p-3 text-emerald-950","aria-label":"Created MCP token",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-sm font-semibold",children:"Token created"}),s.jsx("p",{className:"mt-1 text-xs text-emerald-800",children:"This secret is shown once. Store it in the local agent environment before leaving this page."})]}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-emerald-300 bg-white px-3 text-sm font-semibold text-emerald-900 hover:bg-emerald-100",type:"button",onClick:()=>B(null),children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),"Hide"]})]}),s.jsx("pre",{className:"mt-3 overflow-auto rounded bg-emerald-950 px-3 py-2 font-mono text-xs text-emerald-50",children:j.token})]}):null,s.jsx(se,{title:"Create token",children:s.jsxs("form",{className:r!=null&&r.is_admin?"grid gap-3 md:grid-cols-[minmax(0,1fr)_minmax(12rem,16rem)_auto]":"grid gap-3 md:grid-cols-[minmax(0,1fr)_auto]",onSubmit:async P=>{P.preventDefault();const U=m.trim();if(U){b(!0),C("");try{const te=await c(U,r!=null&&r.is_admin?w:void 0);B(te),p("")}catch(te){C(te instanceof Error?te.message:String(te))}finally{b(!1)}}},children:[s.jsx(ot,{label:"Token name",children:s.jsx("input",{className:"control",value:m,placeholder:"local agent",disabled:v,onChange:P=>p(P.target.value)})}),r!=null&&r.is_admin?s.jsxs(ot,{label:"Lifecycle owner",children:[s.jsx(Pc,{ariaLabel:"Lifecycle owner",value:w,ownerOptions:i,disabled:v||i.length===0,selectedSuffix:P=>P.login===(r==null?void 0:r.login)?" (you)":"",emptyLabel:"No known users",onChange:y}),O?s.jsxs("span",{className:"font-normal text-muted",children:["Token management will be linked to @",O.login,"; this does not restrict repository reads."]}):null]}):null,s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 self-end rounded-md bg-primary px-3 text-sm font-semibold text-white disabled:cursor-not-allowed disabled:opacity-60",type:"submit",disabled:v||!m.trim()||!!(r!=null&&r.is_admin&&!w),children:[s.jsx(Dr,{className:"h-4 w-4","aria-hidden":!0}),v?"Creating...":"Create token"]})]})}),s.jsx(se,{title:"Active tokens",children:s.jsx(hg,{tokens:M,loading:t,now:l,ownerOptions:i,canManageOwners:!!(r!=null&&r.is_admin),revokingId:N,updatingOwnerId:_,onUpdateOwner:async(P,U)=>{D(P),C("");try{await u(P,U)}catch(te){C(te instanceof Error?te.message:String(te))}finally{D(null)}},onRevoke:async P=>{if(window.confirm("Revoke this MCP token?")){k(P),C("");try{await d(P)}catch(U){C(U instanceof Error?U.message:String(U))}finally{k(null)}}}})})]})}function dg({dashboardUrl:e,endpointUrl:t,dashboardUrlSource:n}){const r=n==="configured"?"Configured public URL":n==="forwarded"?"Forwarded public URL":"Needs public URL",i=n==="request",a=i?"Set GITHUB_AGENT_BRIDGE_DASHBOARD_PUBLIC_URL or forward X-Forwarded-* headers":e,o=i?"Public dashboard URL required before connecting remote agents":t,c=`{ +`},i),a}function tf(e,t){return e&&"run"in e?async function(n,r){const i=Mo(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Mo(n,{file:r,...e||t})}}function Do(e){if(e)throw e}var ss,Oo;function nf(){if(Oo)return ss;Oo=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):t.call(u)==="[object Array]"},a=function(u){if(!u||t.call(u)!=="[object Object]")return!1;var d=e.call(u,"constructor"),h=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!d&&!h)return!1;var m;for(m in u);return typeof m>"u"||e.call(u,m)},o=function(u,d){n&&d.name==="__proto__"?n(u,d.name,{enumerable:!0,configurable:!0,value:d.newValue,writable:!0}):u[d.name]=d.newValue},l=function(u,d){if(d==="__proto__")if(e.call(u,d)){if(r)return r(u,d).value}else return;return u[d]};return ss=function c(){var u,d,h,m,p,w,y=arguments[0],v=1,b=arguments.length,N=!1;for(typeof y=="boolean"&&(N=y,y=arguments[1]||{},v=2),(y==null||typeof y!="object"&&typeof y!="function")&&(y={});vo.length;let c;l&&o.push(i);try{c=e.apply(this,o)}catch(u){const d=u;if(l&&n)throw d;return i(d)}l||(c&&c.then&&typeof c.then=="function"?c.then(a,i):c instanceof Error?i(c):a(c))}function i(o,...l){n||(n=!0,t(o,...l))}function a(o){i(null,o)}}const pt={basename:of,dirname:lf,extname:cf,join:uf,sep:"/"};function of(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');yr(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,l=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),l>-1&&(e.codePointAt(i)===t.codePointAt(l--)?l<0&&(r=i):(l=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function lf(e){if(yr(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function cf(e){yr(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){const l=e.codePointAt(t);if(l===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),l===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function uf(...e){let t=-1,n;for(;++t0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function hf(e,t){let n="",r=0,i=-1,a=0,o=-1,l,c;for(;++o<=e.length;){if(o2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),i=o,a=0;continue}}else if(n.length>0){n="",r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else l===46&&a>-1?a++:a=-1}return n}function yr(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const pf={cwd:mf};function mf(){return"/"}function Hs(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function ff(e){if(typeof e=="string")e=new URL(e);else if(!Hs(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return xf(e)}function xf(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n0){let[p,...w]=d;const y=r[m][1];Us(y)&&Us(p)&&(p=is(!0,y,p)),r[m]=[u,p,...w]}}}}const wf=new vi().freeze();function cs(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function us(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function ds(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function zo(e){if(!Us(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function qo(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Pr(e){return vf(e)?e:new fc(e)}function vf(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function jf(e){return typeof e=="string"||kf(e)}function kf(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Nf="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Bo=[],$o={allowDangerousHtml:!0},Sf=/^(https?|ircs?|mailto|xmpp)$/i,_f=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Cf(e){const t=Pf(e),n=Ef(e);return Rf(t.runSync(t.parse(n),n),e)}function Pf(e){const t=e.rehypePlugins||Bo,n=e.remarkPlugins||Bo,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...$o}:$o;return wf().use(im).use(n).use(tf,r).use(t)}function Ef(e){const t=e.children||"",n=new fc;return typeof t=="string"&&(n.value=t),n}function Rf(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||If;for(const d of _f)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+Nf+d.id,void 0);return mc(e,u),Fd(e,{Fragment:s.Fragment,components:i,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function u(d,h,m){if(d.type==="raw"&&m&&typeof h=="number")return o?m.children.splice(h,1):m.children[h]={type:"text",value:d.value},h;if(d.type==="element"){let p;for(p in ts)if(Object.hasOwn(ts,p)&&Object.hasOwn(d.properties,p)){const w=d.properties[p],y=ts[p];(y===null||y.includes(d.tagName))&&(d.properties[p]=c(String(w||""),p,d))}}if(d.type==="element"){let p=n?!n.includes(d.tagName):a?a.includes(d.tagName):!1;if(!p&&r&&typeof h=="number"&&(p=!r(d,h,m)),p&&m&&typeof h=="number")return l&&d.children?m.children.splice(h,1,...d.children):m.children.splice(h,1),h}}}function If(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||Sf.test(e.slice(0,t))?e:""}const ji="-",Tf=e=>{const t=Lf(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{const l=o.split(ji);return l[0]===""&&l.length!==1&&l.shift(),xc(l,t)||Af(o)},getConflictingClassGroupIds:(o,l)=>{const c=n[o]||[];return l&&r[o]?[...c,...r[o]]:c}}},xc=(e,t)=>{var o;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),i=r?xc(e.slice(1),r):void 0;if(i)return i;if(t.validators.length===0)return;const a=e.join(ji);return(o=t.validators.find(({validator:l})=>l(a)))==null?void 0:o.classGroupId},Uo=/^\[(.+)\]$/,Af=e=>{if(Uo.test(e)){const t=Uo.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},Lf=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return Df(Object.entries(e.classGroups),n).forEach(([a,o])=>{Ks(o,r,a,t)}),r},Ks=(e,t,n,r)=>{e.forEach(i=>{if(typeof i=="string"){const a=i===""?t:Ho(t,i);a.classGroupId=n;return}if(typeof i=="function"){if(Mf(i)){Ks(i(r),t,n,r);return}t.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([a,o])=>{Ks(o,Ho(t,a),n,r)})})},Ho=(e,t)=>{let n=e;return t.split(ji).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},Mf=e=>e.isThemeGetter,Df=(e,t)=>t?e.map(([n,r])=>{const i=r.map(a=>typeof a=="string"?t+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([o,l])=>[t+o,l])):a);return[n,i]}):e,Of=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const i=(a,o)=>{n.set(a,o),t++,t>e&&(t=0,r=n,n=new Map)};return{get(a){let o=n.get(a);if(o!==void 0)return o;if((o=r.get(a))!==void 0)return i(a,o),o},set(a,o){n.has(a)?n.set(a,o):i(a,o)}}},gc="!",Ff=e=>{const{separator:t,experimentalParseClassName:n}=e,r=t.length===1,i=t[0],a=t.length,o=l=>{const c=[];let u=0,d=0,h;for(let v=0;vd?h-d:void 0;return{modifiers:c,hasImportantModifier:p,baseClassName:w,maybePostfixModifierPosition:y}};return n?l=>n({className:l,parseClassName:o}):o},zf=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(r=>{r[0]==="["?(t.push(...n.sort(),r),n=[]):n.push(r)}),t.push(...n.sort()),t},qf=e=>({cache:Of(e.cacheSize),parseClassName:Ff(e),...Tf(e)}),Bf=/\s+/,$f=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=t,a=[],o=e.trim().split(Bf);let l="";for(let c=o.length-1;c>=0;c-=1){const u=o[c],{modifiers:d,hasImportantModifier:h,baseClassName:m,maybePostfixModifierPosition:p}=n(u);let w=!!p,y=r(w?m.substring(0,p):m);if(!y){if(!w){l=u+(l.length>0?" "+l:l);continue}if(y=r(m),!y){l=u+(l.length>0?" "+l:l);continue}w=!1}const v=zf(d).join(":"),b=h?v+gc:v,N=b+y;if(a.includes(N))continue;a.push(N);const k=i(y,w);for(let _=0;_0?" "+l:l)}return l};function Uf(){let e=0,t,n,r="";for(;e{if(typeof e=="string")return e;let t,n="";for(let r=0;rh(d),e());return n=qf(u),r=n.cache.get,i=n.cache.set,a=l,l(c)}function l(c){const u=r(c);if(u)return u;const d=$f(c,n);return i(c,d),d}return function(){return a(Uf.apply(null,arguments))}}const ge=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},yc=/^\[(?:([a-z-]+):)?(.+)\]$/i,Kf=/^\d+\/\d+$/,Qf=new Set(["px","full","screen"]),Wf=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Vf=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Gf=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Jf=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Xf=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,kt=e=>yn(e)||Qf.has(e)||Kf.test(e),Rt=e=>$n(e,"length",ix),yn=e=>!!e&&!Number.isNaN(Number(e)),hs=e=>$n(e,"number",yn),Yn=e=>!!e&&Number.isInteger(Number(e)),Yf=e=>e.endsWith("%")&&yn(e.slice(0,-1)),Y=e=>yc.test(e),It=e=>Wf.test(e),Zf=new Set(["length","size","percentage"]),ex=e=>$n(e,Zf,wc),tx=e=>$n(e,"position",wc),nx=new Set(["image","url"]),rx=e=>$n(e,nx,ox),sx=e=>$n(e,"",ax),Zn=()=>!0,$n=(e,t,n)=>{const r=yc.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):n(r[2]):!1},ix=e=>Vf.test(e)&&!Gf.test(e),wc=()=>!1,ax=e=>Jf.test(e),ox=e=>Xf.test(e),lx=()=>{const e=ge("colors"),t=ge("spacing"),n=ge("blur"),r=ge("brightness"),i=ge("borderColor"),a=ge("borderRadius"),o=ge("borderSpacing"),l=ge("borderWidth"),c=ge("contrast"),u=ge("grayscale"),d=ge("hueRotate"),h=ge("invert"),m=ge("gap"),p=ge("gradientColorStops"),w=ge("gradientColorStopPositions"),y=ge("inset"),v=ge("margin"),b=ge("opacity"),N=ge("padding"),k=ge("saturate"),_=ge("scale"),D=ge("sepia"),j=ge("skew"),B=ge("space"),F=ge("translate"),C=()=>["auto","contain","none"],M=()=>["auto","hidden","clip","visible","scroll"],O=()=>["auto",Y,t],I=()=>[Y,t],X=()=>["",kt,Rt],q=()=>["auto",yn,Y],P=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],U=()=>["solid","dashed","dotted","double","none"],te=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],me=()=>["start","end","center","between","around","evenly","stretch"],ye=()=>["","0",Y],f=()=>["auto","avoid","all","avoid-page","page","left","right","column"],A=()=>[yn,Y];return{cacheSize:500,separator:":",theme:{colors:[Zn],spacing:[kt,Rt],blur:["none","",It,Y],brightness:A(),borderColor:[e],borderRadius:["none","","full",It,Y],borderSpacing:I(),borderWidth:X(),contrast:A(),grayscale:ye(),hueRotate:A(),invert:ye(),gap:I(),gradientColorStops:[e],gradientColorStopPositions:[Yf,Rt],inset:O(),margin:O(),opacity:A(),padding:I(),saturate:A(),scale:A(),sepia:ye(),skew:A(),space:I(),translate:I()},classGroups:{aspect:[{aspect:["auto","square","video",Y]}],container:["container"],columns:[{columns:[It]}],"break-after":[{"break-after":f()}],"break-before":[{"break-before":f()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...P(),Y]}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[y]}],"inset-x":[{"inset-x":[y]}],"inset-y":[{"inset-y":[y]}],start:[{start:[y]}],end:[{end:[y]}],top:[{top:[y]}],right:[{right:[y]}],bottom:[{bottom:[y]}],left:[{left:[y]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Yn,Y]}],basis:[{basis:O()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Y]}],grow:[{grow:ye()}],shrink:[{shrink:ye()}],order:[{order:["first","last","none",Yn,Y]}],"grid-cols":[{"grid-cols":[Zn]}],"col-start-end":[{col:["auto",{span:["full",Yn,Y]},Y]}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":[Zn]}],"row-start-end":[{row:["auto",{span:[Yn,Y]},Y]}],"row-start":[{"row-start":q()}],"row-end":[{"row-end":q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Y]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Y]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal",...me()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...me(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...me(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[N]}],px:[{px:[N]}],py:[{py:[N]}],ps:[{ps:[N]}],pe:[{pe:[N]}],pt:[{pt:[N]}],pr:[{pr:[N]}],pb:[{pb:[N]}],pl:[{pl:[N]}],m:[{m:[v]}],mx:[{mx:[v]}],my:[{my:[v]}],ms:[{ms:[v]}],me:[{me:[v]}],mt:[{mt:[v]}],mr:[{mr:[v]}],mb:[{mb:[v]}],ml:[{ml:[v]}],"space-x":[{"space-x":[B]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[B]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Y,t]}],"min-w":[{"min-w":[Y,t,"min","max","fit"]}],"max-w":[{"max-w":[Y,t,"none","full","min","max","fit","prose",{screen:[It]},It]}],h:[{h:[Y,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Y,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Y,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Y,t,"auto","min","max","fit"]}],"font-size":[{text:["base",It,Rt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",hs]}],"font-family":[{font:[Zn]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Y]}],"line-clamp":[{"line-clamp":["none",yn,hs]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",kt,Y]}],"list-image":[{"list-image":["none",Y]}],"list-style-type":[{list:["none","disc","decimal",Y]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[b]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[b]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...U(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",kt,Rt]}],"underline-offset":[{"underline-offset":["auto",kt,Y]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Y]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Y]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[b]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...P(),tx]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",ex]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},rx]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[w]}],"gradient-via-pos":[{via:[w]}],"gradient-to-pos":[{to:[w]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[b]}],"border-style":[{border:[...U(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[b]}],"divide-style":[{divide:U()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...U()]}],"outline-offset":[{"outline-offset":[kt,Y]}],"outline-w":[{outline:[kt,Rt]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:X()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[b]}],"ring-offset-w":[{"ring-offset":[kt,Rt]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",It,sx]}],"shadow-color":[{shadow:[Zn]}],opacity:[{opacity:[b]}],"mix-blend":[{"mix-blend":[...te(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":te()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",It,Y]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[h]}],saturate:[{saturate:[k]}],sepia:[{sepia:[D]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[b]}],"backdrop-saturate":[{"backdrop-saturate":[k]}],"backdrop-sepia":[{"backdrop-sepia":[D]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Y]}],duration:[{duration:A()}],ease:[{ease:["linear","in","out","in-out",Y]}],delay:[{delay:A()}],animate:[{animate:["none","spin","ping","pulse","bounce",Y]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[_]}],"scale-x":[{"scale-x":[_]}],"scale-y":[{"scale-y":[_]}],rotate:[{rotate:[Yn,Y]}],"translate-x":[{"translate-x":[F]}],"translate-y":[{"translate-y":[F]}],"skew-x":[{"skew-x":[j]}],"skew-y":[{"skew-y":[j]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Y]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Y]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Y]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[kt,Rt,hs]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},cx=Hf(lx),Qs={status:"",repo:"",thread:"",action:"",intent:"",actor:""},ux=new Uu({defaultOptions:{queries:{retry:1}}}),Ko=12,dx=12,hx=10080*60*1e3,px=1e3,Ws=Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC";function Q(...e){return cx(du(e))}function mx(e){window.location.replace(e)}function fx(e=mx){let t=!1;return()=>{t||(t=!0,e("/auth/login"))}}const xx=fx();async function ee(e,t,n=xx){const r=new Headers(t==null?void 0:t.headers);r.set("Accept","application/json");const i=await fetch(e,{...t,headers:r});if(i.status===401&&n(),!i.ok)throw new Error(`${i.status} ${i.statusText}`);return i.json()}function Xe(e){if(e==null)return"n/a";const t=Math.max(0,Math.floor(e));if(t<60)return`${t}s`;const n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}const gx=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"short"}),bx=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});function wr(e){if(!e)return null;const t=new Date(e);return Number.isNaN(t.getTime())?null:t}function yx(e){const t=wr(e);return t?gx.format(t):e??""}function ir(e){const t=wr(e);return t?bx.format(t):e??""}function vc(e,t){const n=wr(e);if(!n)return e??"";const r=t-n.getTime(),i=Math.abs(r);if(i>hx)return ir(e);const a=r>=0?"ago":"from now",o=Math.round(i/1e3);if(o<45)return r>=0?"just now":"soon";if(o<90)return`1m ${a}`;const l=Math.round(o/60);if(l<60)return`${l}m ${a}`;if(l<90)return`1h ${a}`;const c=Math.round(l/60);return c<24?`${c}h ${a}`:c<36?`1d ${a}`:`${Math.round(c/24)}d ${a}`}function ue({value:e,compact:t=!1,relative:n=!1,now:r=Date.now()}){const i=wr(e);return i?s.jsx("time",{dateTime:i.toISOString(),title:`UTC: ${i.toISOString()}`,children:n?vc(e,r):t?ir(e):yx(e)}):s.jsx(s.Fragment,{children:e??""})}function jc(e,t){const n=wr(e);return n?Math.max(0,Math.floor((t-n.getTime())/1e3)):null}function ki(e,t){return e.status==="running"?jc(e.started_at,t)??e.runtime_seconds:e.runtime_seconds}function Ni(e,t){return e.status==="pending"?jc(e.created_at,t)??e.queue_wait_seconds:e.queue_wait_seconds}function wx(e){const[t,n]=R.useState(()=>Date.now());return R.useEffect(()=>{if(!e)return;n(Date.now());const r=window.setInterval(()=>n(Date.now()),px);return()=>window.clearInterval(r)},[e]),t}function vx(e){return(e??"").split(/\r?\n/).map(n=>n.trim()).find(Boolean)??""}function zr(e,t,n=1){const r=vx(t),i=n>1?` (${n})`:"";return r?`${e}${i}: ${r}`:`${e}${i}`}function qr(e){return e==="openclaw_stdout"||e==="openclaw_stderr"}function kc(e){return e.map(t=>t==null?void 0:t.trim()).filter(Boolean).join(` +`)}function jx(e){const t=[];for(const n of e){const r=t[t.length-1];if(r&&qr(n.event_type)&&r.eventType===n.event_type){r.count+=1,r.meta=n.ts,r.detail=kc([r.detail,n.detail]),r.summary=zr(n.summary,r.detail,r.count);continue}t.push({id:String(n.id),badge:n.event_type,meta:n.ts,summary:qr(n.event_type)?zr(n.summary,n.detail):n.summary,detail:n.detail,eventType:n.event_type,count:1})}return t}function kx(e){const t=[];return e.forEach((n,r)=>{const i=t[t.length-1];if(i&&qr(n.kind)&&i.kind===n.kind){i.count+=1,i.meta=n.timestamp,i.text=kc([i.text,n.text]),i.summary=zr(`${n.role} · ${n.kind}`,i.text,i.count);return}t.push({id:`${n.timestamp??"entry"}-${r}`,badge:n.title,meta:n.timestamp,summary:qr(n.kind)?zr(`${n.role} · ${n.kind}`,n.text):`${n.role} · ${n.kind}`,text:n.text,kind:n.kind,count:1})}),t}function Qo(e,t,n,r){return e==="openclaw_stdout"?!1:t||n>=r-2}function Nx(e){return{pending:{badge:"border-amber-300 bg-amber-50 text-amber-800",dot:"bg-amber-500"},running:{badge:"border-blue-300 bg-blue-50 text-blue-700",dot:"bg-blue-600"},blocked:{badge:"border-red-300 bg-red-50 text-red-700",dot:"bg-red-600"},denied:{badge:"border-red-300 bg-red-50 text-red-700",dot:"bg-red-600"},done:{badge:"border-emerald-300 bg-emerald-50 text-emerald-700",dot:"bg-emerald-600"},waiting_approval:{badge:"border-slate-300 bg-slate-50 text-slate-700",dot:"bg-slate-500"}}[e]??{badge:"border-slate-300 bg-slate-50 text-slate-700",dot:"bg-slate-500"}}function Sx(e,t){const n=new URLSearchParams;for(const[r,i]of Object.entries(e))i.trim()&&n.set(r,i.trim());return n.set("limit",String(t)),`/api/jobs?${n.toString()}`}function _x(e,t,n,r=50,i=0){const a=new URLSearchParams;return e.trim()&&a.set("repo",e.trim()),n==="proposals"&&t.trim()&&a.set("status",t.trim()),a.set("section",n),a.set("limit",String(r)),i>0&&a.set("offset",String(i)),`/api/knowledge?${a.toString()}`}function Cx(e){return{timeseries:e==="overview",hooks:e==="hooks",deliveries:e==="deliveries"}}function Px(e,t,n="day"){return`/api/webhooks/github/timeseries?${new URLSearchParams({from:e,to:t,bucket:n}).toString()}`}function Ex(e=50,t){const n=new URLSearchParams({limit:String(e)});return t&&n.set("cursor",t),`/api/webhooks/github/hooks?${n.toString()}`}function Rx(e=50,t,n){const r=new URLSearchParams({limit:String(e)});t&&r.set("cursor",t);for(const[i,a]of Object.entries(n??{}))a!=null&&a.trim()&&r.set(i,a.trim());return`/api/webhooks/github/deliveries?${r.toString()}`}function Er(e=new Date){return{from:new Date(e.getTime()-720*60*60*1e3).toISOString(),to:e.toISOString()}}function Ix(e=Ws,t="7d",n="7d"){return`/api/metrics/summary?${new URLSearchParams({window:t,runtime_window:n,timezone:e}).toString()}`}function rt(e){try{const t=new URL(e);return t.protocol==="https:"||t.protocol==="http:"?t.href:"#"}catch{return"#"}}function Lr(){return"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window}function Tx(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="github-agent-bridge:push")}function Ax(e){const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),i=new Uint8Array(r.length);for(let a=0;an.id===t.id)?e:[...e,t]}function Mx(e,t){const n=Wo(t);return e.some(r=>Wo(r)===n)?e:[...e,t]}function Wo(e){return`${e.timestamp??""}:${e.role}:${e.kind}:${e.title}:${e.text}`}function Dx(e){return["claimed","dispatch_started","dispatch_finished","done","blocked","denied","waiting_approval"].includes(e)}function Vs(e){return e==="blocked"}function Gs(e){return["blocked","denied","waiting_approval"].includes(e)}function Js(e,t){return e.status!=="running"?!1:t!=null&&t.is_admin?!0:!!(t!=null&&t.login&&e.trigger_actor&&t.login.toLowerCase()===e.trigger_actor.toLowerCase())}function Ox(e=window.location.pathname){const t=e.match(/^\/jobs\/(\d+)\/?$/);return t?Number(t[1]):null}function Fx(e=window.location.pathname){return/^\/knowledge\/?$/.test(e)}function zx(e=window.location.pathname){return/^\/mcp\/?$/.test(e)}function qx(e=window.location.pathname){return/^\/system\/?$/.test(e)}function Bx(e=window.location.pathname){const t=e.match(/^\/webhooks\/hooks\/([^/]+)\/?$/);return t?decodeURIComponent(t[1]):null}function $x(e=window.location.pathname){const t=e.match(/^\/webhooks\/deliveries\/([^/]+)\/?$/);return t?decodeURIComponent(t[1]):null}function ps(e=window.location.pathname){return/^\/webhooks(?:\/(?:hooks|deliveries)\/[^/]+)?\/?$/.test(e)}function Nc(e){return e.startsWith("repo:")?e.slice(5):e}function Vo(e){return Object.values(e).some(t=>t.trim()!=="")}function Ux(e){return[{key:"status",label:"Status",value:e.status},{key:"repo",label:"Repo",value:e.repo},{key:"thread",label:"Thread",value:e.thread},{key:"action",label:"Action",value:e.action},{key:"actor",label:"Actor",value:e.actor.trim()?`@${e.actor.trim().replace(/^@/,"")}`:""},{key:"intent",label:"Intent",value:e.intent}].filter(t=>t.value.trim()!=="")}function Hx(){var Ti,Ai,Li,Mi,Di,Oi,Fi,zi,qi,Bi,$i,Ui,Hi,Ki,Qi,Wi,Vi,Gi,Ji,Xi,Yi,Zi,ea,ta,na,ra,sa,ia,aa,oa,la,ca,ua,da,ha,pa,ma,fa,xa,ga,ba,ya,wa,va,ja,ka,Na,Sa,_a,Ca,Pa,Ea,Ra,Ia,Ta,Aa,La,Ma,Da,Oa,Fa,za,qa,Ba,$a;const e=Sl(),[t,n]=R.useState(Qs),[r,i]=R.useState(Ko),a=R.useRef(!1),[o,l]=R.useState(""),[c,u]=R.useState("proposed"),[d,h]=R.useState("proposals"),[m,p]=R.useState("overview"),[w,y]=R.useState({hook_id:"",event_name:"",repository:"",result:"",enqueue_status:""}),[v,b]=R.useState(()=>Er()),[N,k]=R.useState(null),[_,D]=R.useState(""),[j,B]=R.useState(!1),[F,C]=R.useState(""),[M,O]=R.useState(!1),[I,X]=R.useState(""),[q,P]=R.useState("7d"),[U,te]=R.useState("7d"),[me,ye]=R.useState(()=>window.location.pathname),[f,A]=R.useState(null),fe=Ox(me),x=fe!==null,Pe=Fx(me),He=zx(me),de=qx(me),lt=ps(me),Me=Bx(me),Ke=$x(me),st=!x&&!Pe&&!He&&!de&&!lt,oe=fe,ke=ve({queryKey:["metrics",Ws,q,U],queryFn:()=>ee(Ix(Ws,q,U)),enabled:st||de}),Ne=ve({queryKey:["dashboard-status"],queryFn:()=>ee("/api/status"),refetchInterval:de?1e4:!1}),Ee=ve({queryKey:["me"],queryFn:()=>ee("/api/me"),refetchInterval:!1}),ct=lt&&!!((Ai=(Ti=Ee.data)==null?void 0:Ti.user)!=null&&Ai.is_admin&&((Li=Ne.data)!=null&&Li.webhook_configured)),Ht=Cx(m),yt=ve({queryKey:["web-push-config"],queryFn:()=>ee("/api/web-push/config"),enabled:!!((Mi=Ee.data)!=null&&Mi.user)}),Vr=ve({queryKey:["about"],queryFn:()=>ee("/api/about")}),vr=ve({queryKey:["job-actors"],queryFn:()=>ee("/api/jobs/actors"),enabled:st}),Qe=ve({queryKey:["jobs",t,r],queryFn:()=>ee(Sx(t,r)),enabled:st,placeholderData:E=>E}),it=ve({queryKey:["processes"],queryFn:()=>ee("/api/processes"),enabled:de,refetchInterval:de?1e4:!1}),hn=ve({queryKey:["systemd"],queryFn:()=>ee("/api/systemd"),enabled:de}),pn=ve({queryKey:["alerts"],queryFn:()=>ee("/api/alerts"),enabled:de}),mn=ve({queryKey:["webhook-summary"],queryFn:()=>ee("/api/webhooks/github/summary"),enabled:ct}),Kn=ve({queryKey:["webhook-timeseries",v.from,v.to,"day"],queryFn:()=>ee(Px(v.from,v.to)),enabled:ct&&Ht.timeseries}),S=ve({queryKey:["webhook-exceptions"],queryFn:()=>ee("/api/webhooks/github/exceptions"),enabled:ct&&Ht.timeseries}),L=Yr({queryKey:["webhook-hooks"],queryFn:({pageParam:E})=>ee(Ex(50,E)),initialPageParam:null,getNextPageParam:E=>E.next_cursor??void 0,enabled:ct&&Ht.hooks&&Me===null&&Ke===null}),K=Yr({queryKey:["webhook-deliveries",w],queryFn:({pageParam:E})=>ee(Rx(50,E,w)),initialPageParam:null,getNextPageParam:E=>E.next_cursor??void 0,enabled:ct&&Ht.deliveries&&Me===null&&Ke===null}),G=ve({queryKey:["webhook-hook",Me],queryFn:()=>ee(`/api/webhooks/github/hooks/${encodeURIComponent(Me??"")}`),enabled:ct&&Me!==null}),le=R.useCallback(async E=>{const Z=await ee(`/api/webhooks/github/hooks/${encodeURIComponent(E)}/ping`,{method:"POST"});return G.refetch(),window.setTimeout(()=>void G.refetch(),1500),Z.detail},[G]),Re=ve({queryKey:["webhook-delivery",Ke],queryFn:()=>ee(`/api/webhooks/github/deliveries/${encodeURIComponent(Ke??"")}`),enabled:ct&&Ke!==null}),De=Yr({queryKey:["knowledge",d,o,d==="proposals"?c:""],queryFn:({pageParam:E})=>ee(_x(o,c,d,50,E)),initialPageParam:0,getNextPageParam:E=>E.next_offset??void 0,enabled:Pe}),Fe=ve({queryKey:["mcp-tokens"],queryFn:()=>ee("/api/mcp/tokens"),enabled:He&&!!((Di=Ee.data)!=null&&Di.user)}),Kt=ve({queryKey:["mcp-users"],queryFn:()=>ee("/api/mcp/users"),enabled:He&&!!((Oi=Ee.data)!=null&&Oi.user)}),ut=ve({queryKey:["job",oe],queryFn:()=>ee(`/api/jobs/${oe}`),enabled:oe!==null}),Ie=ve({queryKey:["job-session",oe],queryFn:()=>ee(`/api/jobs/${oe}/session`),enabled:oe!==null}),wt=ve({queryKey:["job-session-events",oe],queryFn:()=>ee(`/api/jobs/${oe}/session/events`),enabled:oe!==null}),Ye=ve({queryKey:["job-session-transcript",oe],queryFn:()=>ee(`/api/jobs/${oe}/session/transcript`),enabled:oe!==null}),Ci=R.useCallback(async E=>{const Z=await ee(`/api/jobs/${E}/retry`,{method:"POST"});e.setQueryData(["job",E],{job:Z.job}),e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["metrics"]})},[e]),Pi=R.useCallback(async E=>{const Z=await ee(`/api/jobs/${E}/dismiss`,{method:"POST"});e.setQueryData(["job",E],{job:Z.job}),e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["metrics"]})},[e]),Ei=R.useCallback(async(E,Z)=>{const ce=await ee(`/api/jobs/${E}/cancel`,{method:"POST",body:JSON.stringify({reason:Z||""})});e.setQueryData(["job",E],{job:ce.job}),e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["metrics"]}),e.invalidateQueries({queryKey:["dashboard-status"]})},[e]),Ri=R.useCallback(async(E,Z)=>{await ee(`/api/knowledge/proposals/${encodeURIComponent(E)}/${Z}`,{method:"POST"}),e.invalidateQueries({queryKey:["knowledge"]}),e.invalidateQueries({queryKey:["dashboard-status"]})},[e]),Fc=R.useCallback(async E=>{await ee(`/api/knowledge/rules/${encodeURIComponent(E)}`,{method:"DELETE"}),e.invalidateQueries({queryKey:["knowledge"]})},[e]),zc=R.useCallback(async(E,Z)=>{await ee(`/api/knowledge/rules/${encodeURIComponent(E)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:Z})}),e.invalidateQueries({queryKey:["knowledge"]})},[e]),qc=R.useCallback(async(E,Z)=>{const ce=await ee("/api/mcp/tokens",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:E,user_login:Z||void 0})});return e.invalidateQueries({queryKey:["mcp-tokens"]}),ce},[e]),Bc=R.useCallback(async(E,Z)=>{await ee(`/api/mcp/tokens/${encodeURIComponent(E)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({user_login:Z})}),e.invalidateQueries({queryKey:["mcp-tokens"]}),e.invalidateQueries({queryKey:["mcp-users"]})},[e]),$c=R.useCallback(async E=>{await ee(`/api/mcp/tokens/${encodeURIComponent(E)}`,{method:"DELETE"}),e.invalidateQueries({queryKey:["mcp-tokens"]})},[e]),Gr=R.useCallback(async E=>{const Z={refresh:"/api/autoupdate/refresh",apply:"/api/autoupdate/apply",complete:"/api/autoupdate/complete-pending"}[E];k(E),D("");try{await ee(Z,{method:"POST"}),e.invalidateQueries({queryKey:["dashboard-status"]})}catch(ce){e.invalidateQueries({queryKey:["dashboard-status"]}),D(ce instanceof Error?ce.message:String(ce))}finally{k(null)}},[e]),Uc=R.useCallback(async E=>{B(!0),C("");try{const Z=await ee(`/api/executor/${E?"pause":"resume"}`,{method:"POST"});e.setQueryData(["dashboard-status"],ce=>ce&&{...ce,executor_pause:Z.executor_pause}),await e.invalidateQueries({queryKey:["dashboard-status"]})}catch(Z){C(Z instanceof Error?Z.message:String(Z))}finally{B(!1)}},[e]),Hc=R.useCallback(async E=>{O(!0),X("");try{await ee("/api/executor/resize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workers:E})}),await Promise.all([e.invalidateQueries({queryKey:["dashboard-status"]}),e.invalidateQueries({queryKey:["processes"]})])}catch(Z){X(Z instanceof Error?Z.message:String(Z))}finally{O(!1)}},[e]),Kc=R.useCallback(async()=>{var Ua;const E=(Ua=yt.data)==null?void 0:Ua.public_key;if(!E)throw new Error("web_push_not_configured");if(!Lr())throw new Error("web_push_not_supported");if(await window.Notification.requestPermission()!=="granted")throw new Error("notification_permission_denied");const ce=await navigator.serviceWorker.register("/service-worker.js"),su=await ce.pushManager.getSubscription()??await ce.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Ax(E)});await ee("/api/web-push/subscriptions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(su.toJSON())}),e.invalidateQueries({queryKey:["web-push-config"]})},[e,(Fi=yt.data)==null?void 0:Fi.public_key]),Qc=R.useCallback(async()=>{if(!Lr())return;const Z=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!Z)return;const ce=Z.endpoint;await Z.unsubscribe(),await ee("/api/web-push/subscriptions",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({endpoint:ce})}),e.invalidateQueries({queryKey:["web-push-config"]})},[e]);R.useEffect(()=>{var E;!((E=yt.data)!=null&&E.status.enabled)||!Lr()||navigator.serviceWorker.register("/service-worker.js").catch(()=>{})},[(zi=yt.data)==null?void 0:zi.status.enabled]),R.useEffect(()=>{if(oe===null)return;const E=new EventSource(`/api/jobs/${oe}/session/stream`);return E.addEventListener("session_event",Z=>{const ce=Br(Z);ce&&(e.setQueryData(["job-session-events",oe],Pt=>({events:Lx((Pt==null?void 0:Pt.events)??[],ce)})),Dx(ce.event_type)&&(e.invalidateQueries({queryKey:["job",oe]}),e.invalidateQueries({queryKey:["jobs"]})))}),E.addEventListener("transcript_entry",Z=>{const ce=Br(Z);!ce||ce.job_id!==oe||e.setQueryData(["job-session-transcript",oe],Pt=>({entries:Mx((Pt==null?void 0:Pt.entries)??[],ce.entry)}))}),E.onerror=()=>{e.invalidateQueries({queryKey:["job",oe]}),e.invalidateQueries({queryKey:["job-session-events",oe]}),e.invalidateQueries({queryKey:["job-session-transcript",oe]})},()=>E.close()},[oe,e]),R.useEffect(()=>{const E=()=>{ps(window.location.pathname)&&b(Er()),ye(window.location.pathname)};return window.addEventListener("popstate",E),()=>window.removeEventListener("popstate",E)},[]),R.useEffect(()=>{if(!("serviceWorker"in navigator))return;const E=Z=>{if(!Tx(Z.data))return;const ce={...Z.data.payload,id:Date.now(),receivedAt:Date.now()};A(ce),ce.job_id&&(e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["job",ce.job_id]}),e.invalidateQueries({queryKey:["metrics"]}))};return navigator.serviceWorker.addEventListener("message",E),()=>navigator.serviceWorker.removeEventListener("message",E)},[e]),R.useEffect(()=>{if(!f)return;const E=window.setTimeout(()=>A(null),12e3);return()=>window.clearTimeout(E)},[f]);const Ii=R.useCallback(E=>{window.history.pushState({},"",Un(E)),ye(window.location.pathname)},[]),dt=R.useCallback(E=>{window.history.pushState({},"",E),ps(E)&&b(Er()),ye(window.location.pathname)},[]),Qt=((qi=ke.data)==null?void 0:qi.metrics.status_counts)??{},jr=((Bi=Qe.data)==null?void 0:Bi.jobs)??[],Wc=!!((Ui=($i=Ee.data)==null?void 0:$i.user)!=null&&Ui.is_admin&&Sc((Hi=Ne.data)==null?void 0:Hi.autoupdate)),Vc=R.useCallback(E=>{n(E),i(Ko),a.current=!1},[]);R.useEffect(()=>{Qe.isFetching||(a.current=!1)},[Qe.isFetching]);const Gc=R.useCallback(()=>{a.current||(a.current=!0,i(E=>E+dx))},[]),Ct=oe?((Ki=ut.data)==null?void 0:Ki.job)??null:null,Jc=jr.some(E=>E.status==="running"||E.status==="pending")||(Ct==null?void 0:Ct.status)==="running"||(Ct==null?void 0:Ct.status)==="pending"||!!((Qi=it.data)!=null&&Qi.running_jobs.length),Qn=wx(Jc),Xc=s.jsx(ag,{selectedJobId:oe,selectedJob:Ct,loading:ut.isLoading,error:ut.error,session:(Wi=Ie.data)==null?void 0:Wi.session,sessionEvents:(Vi=wt.data)==null?void 0:Vi.events,transcript:(Gi=Ye.data)==null?void 0:Gi.entries,now:Qn}),Yc=((Ji=L.data)==null?void 0:Ji.pages.flatMap(E=>E.hooks))??[],Zc=((Xi=K.data)==null?void 0:Xi.pages.flatMap(E=>E.deliveries))??[],vt=((Yi=De.data)==null?void 0:Yi.pages)??[],jt=vt[vt.length-1],eu=vt.length>0?{...vt[0],repositories:(jt==null?void 0:jt.repositories)??vt[0].repositories,summary:(jt==null?void 0:jt.summary)??vt[0].summary,proposals:vt.flatMap(E=>E.proposals),rules:vt.flatMap(E=>E.rules),events:vt.flatMap(E=>E.events),next_offset:(jt==null?void 0:jt.next_offset)??null}:void 0,tu=m==="overview"?Kn.isLoading:m==="hooks"?L.isLoading:K.isLoading,nu=m==="overview"?Kn.error:m==="hooks"?L.error:K.error,ru=()=>{mn.refetch(),m==="overview"&&S.refetch(),m==="overview"&&b(Er()),m==="hooks"&&L.refetch(),m==="deliveries"&&K.refetch()};return s.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[s.jsx("header",{className:"border-b border-slate-800 bg-slate-950 text-white",children:s.jsxs("div",{className:"mx-auto flex w-full max-w-[1440px] items-center justify-between gap-3 px-4 py-4 md:px-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h1",{className:"truncate text-xl font-semibold",children:"GitHub Agent Bridge"}),s.jsx(Kx,{about:Vr.data})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(bg,{config:yt.data,loading:yt.isLoading,onEnable:Kc,onDisable:Qc}),s.jsx(gg,{user:(Zi=Ee.data)==null?void 0:Zi.user,loading:Ee.isLoading})]})]})}),s.jsxs("main",{className:"mx-auto grid w-full max-w-[1440px] gap-4 px-3 py-4 sm:px-4 md:px-6 md:py-5",children:[s.jsx(Xx,{isDashboardRoute:st,isSystemRoute:de,isKnowledgeRoute:Pe,isMcpRoute:He,isWebhooksRoute:lt,showWebhooks:!!((ta=(ea=Ee.data)==null?void 0:ea.user)!=null&&ta.is_admin&&((na=Ne.data)!=null&&na.webhook_configured)),knowledgeBadgeCount:((ia=(sa=(ra=Ne.data)==null?void 0:ra.metrics)==null?void 0:sa.knowledge)==null?void 0:ia.proposed)??0,systemUpdateAvailable:Wc,onNavigate:dt}),s.jsx(yg,{notification:f,onDismiss:()=>A(null),onNavigate:dt}),fe!==null?s.jsx(ig,{jobId:fe,detail:Xc,selectedJob:Ct,user:(aa=Ee.data)==null?void 0:aa.user,onBackToDashboard:()=>dt("/"),onRetry:Ci,onDismiss:Pi,onCancel:Ei,onRefresh:()=>{ut.refetch(),Ie.refetch(),wt.refetch(),Ye.refetch()}}):Pe?s.jsx(og,{data:eu,loading:De.isLoading,error:De.error,repo:o,status:c,activeTab:d,user:(oa=Ee.data)==null?void 0:oa.user,now:Qn,onRepoChange:l,onStatusChange:u,onTabChange:h,onApprove:E=>Ri(E,"approve"),onReject:E=>Ri(E,"reject"),onUpdateRuleScope:zc,onDeleteRule:Fc,onRefresh:()=>De.refetch(),hasMore:!!De.hasNextPage,loadingMore:De.isFetchingNextPage,onLoadMore:()=>De.fetchNextPage()}):He?s.jsx(pg,{tokens:(la=Fe.data)==null?void 0:la.tokens,loading:Fe.isLoading,error:Fe.error,user:(ca=Ee.data)==null?void 0:ca.user,ownerOptions:((ua=Kt.data)==null?void 0:ua.users)??[],dashboardUrl:(da=Ne.data)==null?void 0:da.dashboard_url,dashboardUrlSource:(ha=Ne.data)==null?void 0:ha.dashboard_url_source,now:Qn,onCreate:qc,onUpdateOwner:Bc,onRevoke:$c,onRefresh:()=>Fe.refetch()}):lt?Ke?s.jsx(ng,{data:Re.data,loading:Re.isLoading,error:Re.error,onBack:()=>{p("deliveries"),dt("/webhooks")},onRefresh:()=>Re.refetch(),onViewHook:E=>dt(`/webhooks/hooks/${encodeURIComponent(E)}`),onViewJob:Ii}):Me?s.jsx(tg,{data:G.data,loading:G.isLoading,error:G.error,onBack:()=>{p("hooks"),dt("/webhooks")},onRefresh:()=>G.refetch(),onViewHook:E=>dt(`/webhooks/hooks/${encodeURIComponent(E)}`),onViewDelivery:E=>dt(`/webhooks/deliveries/${encodeURIComponent(E)}`),onPing:le}):s.jsx(Yx,{summary:mn.data,timeseries:(pa=Kn.data)==null?void 0:pa.points,exceptions:(ma=S.data)==null?void 0:ma.exceptions,hooks:Yc,deliveries:Zc,section:m,summaryLoading:mn.isLoading,sectionLoading:tu,loadingMore:m==="hooks"?L.isFetchingNextPage:K.isFetchingNextPage,hasMore:m==="hooks"?L.hasNextPage:K.hasNextPage,deliveryFilters:w,error:mn.error??nu,onSectionChange:p,onLoadMore:()=>m==="hooks"?L.fetchNextPage():K.fetchNextPage(),onDeliveryFiltersChange:y,onViewHook:E=>dt(`/webhooks/hooks/${encodeURIComponent(E)}`),onViewDelivery:E=>dt(`/webhooks/deliveries/${encodeURIComponent(E)}`),onRefresh:ru}):de?s.jsxs(s.Fragment,{children:[s.jsx(Qx,{state:(fa=Ne.data)==null?void 0:fa.autoupdate,isAdmin:!!((ga=(xa=Ee.data)==null?void 0:xa.user)!=null&&ga.is_admin),runningAction:N,actionError:_,onRefresh:()=>Gr("refresh"),onApply:()=>Gr("apply"),onCompletePending:()=>Gr("complete")}),s.jsx(rg,{executorPause:(ba=Ne.data)==null?void 0:ba.executor_pause,executorPauseLoading:Ne.isLoading,executorPauseStatusError:Ne.error,executorPausePending:j,executorPauseError:F,executorCapacity:{desired:((ya=it.data)==null?void 0:ya.executor.expected_workers)??((va=(wa=Ne.data)==null?void 0:wa.metrics)==null?void 0:va.executor_worker_count)??0,live:((ja=it.data)==null?void 0:ja.executor.live_workers)??((Na=(ka=Ne.data)==null?void 0:ka.metrics)==null?void 0:Na.executor_worker_live_count)??0,busy:((Sa=it.data)==null?void 0:Sa.executor.busy_workers)??((Ca=(_a=Ne.data)==null?void 0:_a.metrics)==null?void 0:Ca.executor_worker_busy_count)??0,draining:((Pa=it.data)==null?void 0:Pa.executor.draining_workers)??((Ra=(Ea=Ne.data)==null?void 0:Ea.metrics)==null?void 0:Ra.executor_worker_draining_count)??0},executorResizePending:M,executorResizeError:I,isAdmin:!!((Ta=(Ia=Ee.data)==null?void 0:Ia.user)!=null&&Ta.is_admin),onExecutorPauseChange:Uc,onExecutorResize:Hc,processes:it.data,processesLoading:it.isLoading,processesError:it.error,systemd:hn.data,systemdLoading:hn.isLoading,systemdError:hn.error,alerts:(Aa=pn.data)==null?void 0:Aa.alerts,alertsLoading:pn.isLoading,alertsError:pn.error,sloSummary:(La=ke.data)==null?void 0:La.metrics,sloLoading:ke.isLoading,sloError:ke.error,sloWindow:q,now:Qn,onRefreshProcesses:()=>it.refetch(),onRefreshSystemd:()=>hn.refetch(),onRefreshAlerts:()=>pn.refetch(),onSloWindowChange:P,onRefreshSlo:()=>ke.refetch()})]}):s.jsxs(s.Fragment,{children:[ke.error?s.jsx(be,{tone:"error",text:ke.error.message}):null,Ne.error?s.jsx(be,{tone:"error",text:Ne.error.message}):null,s.jsxs("section",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4","aria-label":"Summary metrics",children:[s.jsx(Ae,{title:"Pending",value:Qt.pending??0,icon:s.jsx(Rl,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Running",value:Qt.running??0,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Blocked",value:Qt.blocked??0,icon:s.jsx(Hr,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Done",value:Qt.done??0,icon:s.jsx(On,{className:"h-5 w-5"})})]}),s.jsxs("section",{className:"grid gap-3",children:[s.jsx(wg,{count:jr.length,limit:r,loading:Qe.isLoading,onRefresh:()=>Qe.refetch()}),s.jsxs(se,{title:"Recent jobs",flushHeader:!0,children:[s.jsx(_g,{filters:t,actorOptions:((Ma=vr.data)==null?void 0:Ma.actors)??[],onChange:Vc}),Qe.error?s.jsx(be,{tone:"error",text:Qe.error.message}):null,s.jsx(Pg,{jobs:jr,loading:Qe.isLoading,loadingMore:Qe.isFetching&&!Qe.isLoading,hasMore:jr.length>=r,onLoadMore:Gc,onViewJob:Ii,now:Qn,user:(Da=Ee.data)==null?void 0:Da.user,onRetry:Ci,onDismiss:Pi,onCancel:Ei})]}),s.jsx(se,{title:"Runtime & jobs",action:s.jsx(nt,{onClick:()=>ke.refetch()}),children:s.jsx(qg,{usage:(Oa=ke.data)==null?void 0:Oa.metrics.runtime_usage,jobsByCreatedDay:(Fa=ke.data)==null?void 0:Fa.metrics.by_created_day,loading:ke.isLoading,totalJobs:gs(Qt)})}),s.jsx(se,{title:"Runtime by user",children:s.jsx(Hg,{usage:(za=ke.data)==null?void 0:za.metrics.runtime_usage_by_actor,loading:ke.isLoading,totalJobs:gs(Qt),window:U,onWindowChange:te})}),s.jsx(se,{title:"Runtime by repository",children:s.jsx(Kg,{usage:(qa=ke.data)==null?void 0:qa.metrics.runtime_usage_by_repo,loading:ke.isLoading,totalJobs:gs(Qt),window:U,onWindowChange:te})})]}),s.jsxs("section",{className:"grid gap-4 xl:grid-cols-2",children:[s.jsx(se,{title:"Runtime percentiles",children:s.jsx(Xo,{label:"runtime",values:(Ba=ke.data)==null?void 0:Ba.metrics.runtime_seconds})}),s.jsx(se,{title:"Queue wait percentiles",children:s.jsx(Xo,{label:"queue wait",values:($a=ke.data)==null?void 0:$a.metrics.queue_wait_seconds})})]})]})]})]})}function Kx({about:e}){const t=e!=null&&e.version?`v${e.version}`:"version loading";return s.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-slate-300",children:[s.jsx("span",{children:"Operational dashboard"}),s.jsx("span",{className:"font-mono text-xs text-slate-400",children:t}),e!=null&&e.repository_url?s.jsxs("a",{className:"inline-flex items-center gap-1 text-xs font-semibold text-slate-200 hover:underline",href:rt(e.repository_url),rel:"noreferrer",target:"_blank",children:[s.jsx(on,{className:"h-3.5 w-3.5","aria-hidden":!0}),"GitHub"]}):null]})}function Sc(e){var t,n;return!!((n=(t=e==null?void 0:e.target)==null?void 0:t.tag_name)!=null&&n.trim()&&e.decision!=="noop")}function Qx({state:e,isAdmin:t,runningAction:n=null,actionError:r="",onRefresh:i,onApply:a,onCompletePending:o}){var v,b,N,k,_,D,j,B,F,C,M;if(!e||!Sc(e))return null;const l=(b=(v=e==null?void 0:e.target)==null?void 0:v.tag_name)==null?void 0:b.trim();if(!t||!l)return null;const c=Wx(e.decision),u=((N=e.queue)==null?void 0:N.active_total)??0,d=Vx((k=e.classification)==null?void 0:k.risk),h=Gx((_=e.target)==null?void 0:_.body),m=((j=(D=e.classification)==null?void 0:D.migration_files)==null?void 0:j.length)??0,p=((F=(B=e.classification)==null?void 0:B.risky_files)==null?void 0:F.length)??0,w=!!(e.executor_reload_pending&&e.dashboard_applied_at&&o),y=!!(a&&(m===0||u===0));return s.jsxs("section",{className:"rounded-md border border-amber-300 bg-amber-50 p-3 text-amber-950 shadow-sm","aria-label":"Update available",children:[s.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Hr,{className:"h-4 w-4 text-amber-700","aria-hidden":!0}),s.jsx("h2",{className:"text-sm font-semibold",children:"Update available"}),s.jsx("span",{className:"rounded-sm border border-amber-300 bg-white px-1.5 py-0.5 font-mono text-[11px] text-amber-800",children:l}),(C=e.target)!=null&&C.url?s.jsxs("a",{className:"inline-flex items-center gap-1 text-xs font-semibold text-amber-800 hover:underline",href:rt(e.target.url),rel:"noreferrer",target:"_blank",children:[s.jsx(on,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Release"]}):null]}),s.jsxs("p",{className:"mt-1 text-sm text-amber-900",children:[c,e.installed_tag?s.jsxs("span",{className:"font-mono",children:[" from ",e.installed_tag]}):null]}),s.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[i?s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-1.5 rounded-md border border-amber-300 bg-white px-2.5 text-xs font-semibold text-amber-900 hover:bg-amber-100 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:n!==null,onClick:i,children:[s.jsx(zn,{className:Q("h-3.5 w-3.5",n==="refresh"&&"animate-spin"),"aria-hidden":!0}),n==="refresh"?"Checking...":"Check now"]}):null,y?s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-1.5 rounded-md bg-amber-800 px-2.5 text-xs font-semibold text-white hover:bg-amber-900 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:n!==null,onClick:()=>{window.confirm(`Apply ${l}? This can restart bridge services according to the recorded safe plan.`)&&(a==null||a())},children:[s.jsx(On,{className:"h-3.5 w-3.5","aria-hidden":!0}),n==="apply"?"Applying...":"Apply update"]}):null,w?s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-1.5 rounded-md border border-amber-300 bg-white px-2.5 text-xs font-semibold text-amber-900 hover:bg-amber-100 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:n!==null,onClick:o,children:[s.jsx(cr,{className:"h-3.5 w-3.5","aria-hidden":!0}),n==="complete"?"Completing...":"Complete reload"]}):null]})]}),s.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-3 lg:min-w-[420px]",children:[s.jsx(ms,{label:"Impact",value:d}),s.jsx(ms,{label:"Active jobs",value:String(u)}),s.jsx(ms,{label:"Admin only",value:"autoupdate"})]})]}),e.blocked_reason||e.executor_reload_pending||m>0||p>0?s.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-xs",children:[e.executor_reload_pending?s.jsx("span",{className:"rounded-sm border border-amber-300 bg-white px-2 py-1 font-semibold",children:"executor reload pending"}):null,e.blocked_reason?s.jsx("span",{className:"rounded-sm border border-amber-300 bg-white px-2 py-1 font-mono",children:e.blocked_reason}):null,m>0?s.jsxs("span",{className:"rounded-sm border border-amber-300 bg-white px-2 py-1",children:[m," migration file",m===1?"":"s"]}):null,p>0?s.jsxs("span",{className:"rounded-sm border border-amber-300 bg-white px-2 py-1",children:[p," executor/shared file",p===1?"":"s"]}):null]}):null,h?s.jsxs("div",{className:"mt-3 rounded-md border border-amber-200 bg-white/70 p-2.5",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-amber-800",children:"Changelog preview"}),s.jsx(Jx,{markdown:h})]}):null,(M=e.warnings)!=null&&M.length?s.jsx("div",{className:"mt-2 font-mono text-xs text-amber-800",children:e.warnings[0]}):null,r?s.jsxs("div",{className:"mt-2 rounded-sm border border-amber-300 bg-white px-2 py-1 font-mono text-xs text-amber-900",children:["Action failed: ",r]}):null]})}function ms({label:e,value:t}){return s.jsxs("div",{className:"min-w-0 rounded-md border border-amber-200 bg-white/80 px-2 py-1.5",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-amber-700",children:e}),s.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-amber-950",children:t})]})}function Wx(e){return{stage_dashboard_reload:"Dashboard reload can be staged now",stage_defer_executor_reload:"Dashboard reload can be staged; executor reload waits for the queue",stage_full_reload:"Full reload can be staged now",defer_migration:"Migration release is waiting for a quiet queue"}[e??""]??"Update plan recorded"}function Vx(e){return{dashboard_only:"dashboard only",executor_or_queue:"executor or queue",executor_or_shared:"executor or shared",migration_required:"migration",none:"none"}[e??""]??"unknown"}function Gx(e){return(e??"").trim()}function Jx({markdown:e}){return s.jsx("div",{className:"mt-1 text-sm leading-relaxed text-amber-950",children:s.jsx(Cf,{allowedElements:["a","blockquote","code","em","h1","h2","h3","h4","li","ol","p","strong","ul"],components:{a:({href:t,children:n})=>s.jsx("a",{className:"font-semibold text-amber-800 underline underline-offset-2",href:rt(t??""),rel:"noreferrer",target:"_blank",children:n}),blockquote:({children:t})=>s.jsx("blockquote",{className:"mt-2 border-l-2 border-amber-300 pl-2 text-amber-900",children:t}),code:({children:t})=>s.jsx("code",{className:"rounded-sm bg-amber-100 px-1 py-0.5 font-mono text-[0.85em] text-amber-950",children:t}),h1:({children:t})=>s.jsx("h3",{className:"mt-2 text-sm font-semibold text-amber-950 first:mt-0",children:t}),h2:({children:t})=>s.jsx("h3",{className:"mt-2 text-sm font-semibold text-amber-950 first:mt-0",children:t}),h3:({children:t})=>s.jsx("h3",{className:"mt-2 text-sm font-semibold text-amber-950 first:mt-0",children:t}),h4:({children:t})=>s.jsx("h4",{className:"mt-2 text-xs font-semibold uppercase text-amber-800 first:mt-0",children:t}),li:({children:t})=>s.jsx("li",{className:"break-words pl-0.5 [overflow-wrap:anywhere]",children:t}),ol:({children:t})=>s.jsx("ol",{className:"mt-1 list-decimal space-y-1 pl-5 first:mt-0",children:t}),p:({children:t})=>s.jsx("p",{className:"mt-1 break-words [overflow-wrap:anywhere] first:mt-0",children:t}),strong:({children:t})=>s.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>s.jsx("em",{className:"italic",children:t}),ul:({children:t})=>s.jsx("ul",{className:"mt-1 list-disc space-y-1 pl-5 first:mt-0",children:t})},children:e})})}function Xx({isDashboardRoute:e,isSystemRoute:t=!1,isKnowledgeRoute:n,isMcpRoute:r=!1,isWebhooksRoute:i=!1,showWebhooks:a=!1,knowledgeBadgeCount:o=0,systemUpdateAvailable:l=!1,onNavigate:c}){return s.jsxs("nav",{className:"flex min-w-0 rounded-lg border border-border bg-panel p-1 shadow-sm","aria-label":"Dashboard sections",children:[s.jsxs(er,{href:"/",active:e,onNavigate:c,children:[s.jsx(Al,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"Jobs"})]}),s.jsxs(er,{href:"/system",active:t,onNavigate:c,children:[s.jsx(id,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"System"}),l?s.jsx("span",{className:Q("inline-flex h-5 min-w-5 items-center justify-center rounded-full border px-1 font-mono text-[11px] leading-none",t?"border-white/40 bg-white/15 text-white":"border-amber-200 bg-amber-100 text-amber-800"),"aria-label":"System update available",children:"!"}):null]}),a?s.jsxs(er,{href:"/webhooks",active:i,onNavigate:c,children:[s.jsx(an,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"Webhooks"})]}):null,s.jsxs(er,{href:"/knowledge",active:n,onNavigate:c,children:[s.jsx(oi,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"Knowledge"}),o>0?s.jsx("span",{className:Q("inline-flex h-5 min-w-5 items-center justify-center rounded-full border px-1 font-mono text-[11px] leading-none",n?"border-white/40 bg-white/15 text-white":"border-amber-200 bg-amber-100 text-amber-800"),"aria-label":`${o} proposed knowledge ${o===1?"item":"items"}`,children:o}):null]}),s.jsxs(er,{href:"/mcp",active:r,onNavigate:c,children:[s.jsx(Dr,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"MCP"})]})]})}function gn({text:e}){return s.jsxs("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-muted",children:[s.jsx(zn,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),e]})}function Yx({summary:e,timeseries:t,exceptions:n,hooks:r,deliveries:i,section:a,summaryLoading:o,sectionLoading:l,loadingMore:c,hasMore:u,deliveryFilters:d,error:h,onSectionChange:m,onLoadMore:p,onDeliveryFiltersChange:w,onViewHook:y,onViewDelivery:v=()=>{},onRefresh:b}){var B,F,C,M,O,I,X,q,P,U,te,me,ye,f;const N=Object.values((e==null?void 0:e.receipts)??{}).reduce((A,fe)=>A+fe,0),k=((B=e==null?void 0:e.coverage)==null?void 0:B.promotion_state)??((F=e==null?void 0:e.coverage)!=null&&F.promotion_ready?"ready":"blocked"),_=k==="insufficient_data"?"insufficient data":k,D=(e==null?void 0:e.mode)==="primary"?"Primary eligibility scope":(e==null?void 0:e.mode)==="canary"?"Canary rollout cohort":"Shadow rollout cohort",j=[{id:"overview",label:"Overview"},{id:"hooks",label:"Hooks",count:(C=e==null?void 0:e.totals)==null?void 0:C.hooks},{id:"deliveries",label:"Deliveries",count:(M=e==null?void 0:e.totals)==null?void 0:M.deliveries}];return s.jsxs("section",{className:"grid gap-4",children:[s.jsx(Cc,{icon:s.jsx(an,{className:"h-5 w-5 text-muted","aria-hidden":!0}),title:"GitHub webhooks",subtitle:(e==null?void 0:e.mode)==="primary"?"Primary webhook ingestion. IMAP remains active as an idempotent safety net.":(e==null?void 0:e.mode)==="canary"?"Canary ingestion health. Only the webhook canary allowlist may create jobs.":"Shadow ingestion health. Deliveries are observed but do not create jobs.",action:s.jsx(nt,{onClick:b})}),h?s.jsx(be,{tone:"error",text:h.message}):null,s.jsx("div",{className:"flex max-w-full flex-wrap rounded-md border border-border bg-white p-1",role:"tablist","aria-label":"Webhook dashboard section",children:j.map(A=>s.jsxs("button",{type:"button",role:"tab","aria-label":A.count===void 0?A.label:`${A.label} (${A.count} total)`,"aria-selected":a===A.id,className:Q("inline-flex h-8 items-center gap-2 rounded px-3 text-sm font-semibold",a===A.id?"bg-primary text-white":"text-muted hover:bg-slate-50 hover:text-foreground"),onClick:()=>m(A.id),children:[A.label,A.count!==void 0?s.jsx("span",{className:"rounded border border-current/30 px-1 font-mono text-[10px]",children:A.count}):null]},A.id))}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4","aria-label":"Webhook status",children:[s.jsx(Ae,{title:"Receipts",value:N,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Duplicates",value:(e==null?void 0:e.duplicate_deliveries)??0,icon:s.jsx(zn,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Cross-source matches",value:(e==null?void 0:e.cross_source_matches)??0,icon:s.jsx(Fn,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Mode",value:o?"…":(e==null?void 0:e.mode)??"unknown",icon:s.jsx(Il,{className:"h-5 w-5"})})]}),a==="overview"?s.jsxs(s.Fragment,{children:[s.jsx(se,{title:"Delivery activity",children:l?s.jsx(gn,{text:"Loading delivery activity…"}):t!=null&&t.length?s.jsx("div",{className:"h-72","aria-label":"Webhook deliveries over time",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(ei,{data:t,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"bucket"}),s.jsx(sn,{allowDecimals:!1}),s.jsx(cn,{}),s.jsx(Ur,{}),s.jsx(Bt,{dataKey:"observed",stackId:"deliveries",fill:"#2563eb"}),s.jsx(Bt,{dataKey:"duplicate",stackId:"deliveries",fill:"#f59e0b"}),s.jsx(Bt,{dataKey:"unsupported",stackId:"deliveries",fill:"#94a3b8"})]})})}):s.jsx(J,{text:"No webhook activity in the selected 30-day window."})}),s.jsx(se,{title:"Receipt states",children:o?s.jsx(gn,{text:"Loading webhook summary…"}):Object.keys((e==null?void 0:e.receipts)??{}).length?s.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:Object.entries((e==null?void 0:e.receipts)??{}).sort(([A],[fe])=>A.localeCompare(fe)).map(([A,fe])=>s.jsx($,{label:A,value:fe},A))}):s.jsx(J,{text:"No webhook deliveries observed yet."})}),s.jsxs(se,{title:"Cross-source coverage",children:[s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx($,{label:"Both sources",value:((O=e==null?void 0:e.coverage)==null?void 0:O.both)??0}),s.jsx($,{label:"IMAP only",value:((I=e==null?void 0:e.coverage)==null?void 0:I.imap_only)??0}),s.jsx($,{label:"Webhook only",value:((X=e==null?void 0:e.coverage)==null?void 0:X.webhook_only)??0}),s.jsx($,{label:"Coverage",value:((q=e==null?void 0:e.coverage)==null?void 0:q.ratio)==null?"not measurable":`${Math.round(e.coverage.ratio*100)}%`}),s.jsx($,{label:"Decision mismatches",value:((P=e==null?void 0:e.coverage)==null?void 0:P.decision_mismatches)??0}),s.jsx($,{label:"Incomplete decision traces",value:((U=e==null?void 0:e.coverage)==null?void 0:U.incomplete_decision_traces)??0}),s.jsx($,{label:"Split identities",value:((te=e==null?void 0:e.coverage)==null?void 0:te.split_identities)??0}),s.jsx($,{label:"Promotion gate",value:_}),s.jsx($,{label:"Outside scope IMAP",value:((me=e==null?void 0:e.coverage)==null?void 0:me.outside_scope_imap_eligible)??0}),s.jsx($,{label:"Outside scope webhook",value:((ye=e==null?void 0:e.coverage)==null?void 0:ye.outside_scope_webhook_eligible)??0})]}),(f=e==null?void 0:e.coverage)!=null&&f.window_start&&e.coverage.window_end?s.jsxs("p",{className:"mt-3 font-mono text-xs text-muted",children:["Actionable IMAP events and comparable webhook events from ",s.jsx(ue,{value:e.coverage.window_start})," to ",s.jsx(ue,{value:e.coverage.window_end}),"; ",e.coverage.observation_days??7," observation days required and newest ",e.coverage.grace_seconds??0,"s excluded. ",D,": ",e.coverage.scope_repositories==null?"all repositories":`${e.coverage.scope_repositories.length} configured repositories`,e.coverage.observation_started_at?s.jsxs(s.Fragment,{children:["; observation epoch ",s.jsx(ue,{value:e.coverage.observation_started_at})]}):null,"."]}):null]}),Object.keys((e==null?void 0:e.enqueue)??{}).length?s.jsx(se,{title:"Canary ingestion decisions",children:s.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:Object.entries((e==null?void 0:e.enqueue)??{}).sort(([A],[fe])=>A.localeCompare(fe)).map(([A,fe])=>s.jsx($,{label:A,value:fe},A))})}):null,s.jsx(se,{title:"Exceptions requiring review",children:n!=null&&n.length?s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[840px] text-left text-sm",children:[s.jsx("thead",{className:"border-b border-border text-xs text-muted",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-3 py-2",children:"Type"}),s.jsx("th",{className:"px-3 py-2",children:"Repository"}),s.jsx("th",{className:"px-3 py-2",children:"Event"}),s.jsx("th",{className:"px-3 py-2",children:"References"}),s.jsx("th",{className:"px-3 py-2",children:"Observed"})]})}),s.jsx("tbody",{children:n.map(A=>s.jsxs("tr",{className:"border-b border-border/70 last:border-0",children:[s.jsx("td",{className:"px-3 py-2 font-semibold",children:A.kind}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:A.repository??"unknown"}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:A.event_type?`${A.event_type}${A.event_action?`:${A.event_action}`:""}`:"unknown"}),s.jsxs("td",{className:"px-3 py-2 font-mono text-xs",children:[s.jsx("div",{children:A.reference}),A.related_reference?s.jsx("div",{children:A.related_reference}):null,A.event_key?s.jsxs("div",{className:"text-muted",children:[A.event_key,A.related_event_key?` ↔ ${A.related_event_key}`:""]}):null]}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs text-muted",children:s.jsx(ue,{value:A.created_at,compact:!0})})]},`${A.kind}:${A.reference}:${A.related_reference??""}`))})]})}):s.jsx(J,{text:"No cross-source exceptions in retained data."})})]}):null,a==="hooks"?s.jsx(se,{title:"Hook inventory",children:l?s.jsx(gn,{text:"Loading hook inventory…"}):r!=null&&r.length?s.jsx(Xs,{noun:"hooks",hasMore:u,loading:c,onLoadMore:p,children:s.jsxs("table",{className:"w-full min-w-[920px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"sticky top-0 z-10 border-b border-border bg-panel text-left text-xs text-muted",children:[s.jsx("th",{className:"px-3 py-2",children:"Target"}),s.jsx("th",{className:"px-3 py-2",children:"State"}),s.jsx("th",{className:"px-3 py-2",children:"Configuration"}),s.jsx("th",{className:"px-3 py-2",children:"Last delivery"}),s.jsx("th",{className:"px-3 py-2",children:"Last ping"})]})}),s.jsx("tbody",{children:r.map(A=>s.jsxs("tr",{className:"cursor-pointer border-b border-border/70 last:border-0 hover:bg-slate-50",onClick:()=>y(A.id),children:[s.jsxs("td",{className:"px-3 py-3",children:[s.jsx("button",{type:"button",className:"text-left font-semibold text-primary hover:underline",onClick:fe=>{fe.stopPropagation(),y(A.id)},children:A.target}),s.jsxs("div",{className:"font-mono text-xs text-muted",children:[A.target_type," · #",A.id]})]}),s.jsx("td",{className:"px-3 py-3",children:s.jsx("span",{className:Q("rounded border px-2 py-1 text-xs font-semibold",A.status==="receiving"?"border-emerald-200 bg-emerald-50 text-emerald-700":A.status==="inactive"?"border-red-200 bg-red-50 text-red-700":"border-slate-200 bg-slate-50 text-slate-600"),children:A.status})}),s.jsxs("td",{className:"max-w-sm px-3 py-3 text-xs",children:[s.jsx("div",{children:A.events.join(", ")||"No event snapshot"}),s.jsxs("div",{className:"mt-1 font-mono text-muted",children:[A.content_type??"content type unknown"," · SSL ",A.ssl_verify===null||A.ssl_verify===void 0?"unknown":A.ssl_verify?"verified":"disabled"]})]}),s.jsxs("td",{className:"px-3 py-3 text-xs",children:[s.jsxs("div",{className:"font-semibold",children:[A.last_event_name??"Never",A.last_action?` · ${A.last_action}`:""]}),s.jsxs("div",{className:"mt-1 font-mono text-muted",children:[A.last_repository??"No repository",A.last_event_at?s.jsxs(s.Fragment,{children:[" · ",s.jsx(ue,{value:A.last_event_at,compact:!0})]}):null]})]}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs text-muted",children:A.last_ping_at?s.jsx(ue,{value:A.last_ping_at,compact:!0}):"Never"})]},A.id))})]})}):s.jsx(J,{text:"No hook inventory is available. Redeliver a signed ping from GitHub to create the sanitized configuration snapshot."})}):null,a==="deliveries"?s.jsxs(se,{title:"Recent deliveries",children:[s.jsx(Zx,{filters:d,onChange:w}),l?s.jsx(gn,{text:"Loading deliveries…"}):i!=null&&i.length?s.jsx(Xs,{noun:"deliveries",hasMore:u,loading:c,onLoadMore:p,children:s.jsx(_c,{deliveries:i,onViewHook:y,onViewDelivery:v})}):s.jsx(J,{text:"No deliveries match the current filters."})]}):null]})}function Zx({filters:e,onChange:t}){const n=[{key:"hook_id",label:"Hook ID",placeholder:"690954530"},{key:"event_name",label:"Event",placeholder:"issue_comment"},{key:"repository",label:"Repository",placeholder:"gisce/repository"},{key:"result",label:"Result",placeholder:"observed"},{key:"enqueue_status",label:"Ingestion",placeholder:"enqueued"}];return s.jsx("div",{className:"grid gap-2 border-b border-border p-3 sm:grid-cols-2 xl:grid-cols-5",children:n.map(r=>s.jsxs("label",{className:"grid gap-1 text-xs font-semibold text-muted",children:[r.label,s.jsx("input",{className:"h-9 rounded-md border border-border bg-white px-2 font-mono text-xs text-foreground",value:e[r.key],placeholder:r.placeholder,onChange:i=>t({...e,[r.key]:i.target.value})})]},r.key))})}function _c({deliveries:e,onViewHook:t,onViewDelivery:n=()=>{}}){return s.jsxs("table",{className:"w-full min-w-[1120px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"sticky top-0 z-10 border-b border-border bg-panel text-left text-xs text-muted",children:[s.jsx("th",{className:"px-3 py-2",children:"Received"}),s.jsx("th",{className:"px-3 py-2",children:"Hook"}),s.jsx("th",{className:"px-3 py-2",children:"Event"}),s.jsx("th",{className:"px-3 py-2",children:"Repository"}),s.jsx("th",{className:"px-3 py-2",children:"Result"}),s.jsx("th",{className:"px-3 py-2",children:"Ingestion"}),s.jsx("th",{className:"px-3 py-2",children:"Delivery"})]})}),s.jsx("tbody",{children:e.map(r=>{var i;return s.jsxs("tr",{className:"border-b border-border/70 last:border-0 hover:bg-slate-50",children:[s.jsx("td",{className:"px-3 py-3 font-mono text-xs text-muted",children:s.jsx(ue,{value:r.created_at,compact:!0})}),s.jsx("td",{className:"px-3 py-3",children:r.hook_id?s.jsxs("button",{type:"button",className:"text-left text-primary hover:underline",onClick:()=>t(r.hook_id),children:[s.jsx("span",{className:"block font-semibold",children:((i=r.hook)==null?void 0:i.target)??`Hook #${r.hook_id}`}),s.jsxs("span",{className:"font-mono text-xs",children:["#",r.hook_id]})]}):s.jsx("span",{className:"text-xs text-muted",children:"Unknown (legacy)"})}),s.jsxs("td",{className:"px-3 py-3 font-semibold",children:[r.event_name,r.action?` · ${r.action}`:""]}),s.jsx("td",{className:"px-3 py-3",children:r.repository??"—"}),s.jsxs("td",{className:"px-3 py-3",children:[s.jsx("span",{className:"rounded border border-border bg-slate-50 px-2 py-1 text-xs font-semibold",children:r.status}),r.duplicate_count?s.jsxs("span",{className:"ml-2 font-mono text-xs text-muted",children:[r.duplicate_count," retries"]}):null]}),s.jsx("td",{className:"px-3 py-3",children:r.enqueue_status?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"rounded border border-border bg-slate-50 px-2 py-1 text-xs font-semibold",children:r.enqueue_status}),r.job_id?s.jsxs("a",{className:"ml-2 font-mono text-xs font-semibold text-primary hover:underline",href:`/jobs/${r.job_id}`,children:["Job #",r.job_id]}):null]}):s.jsx("span",{className:"text-xs text-muted",children:"shadow"})}),s.jsx("td",{className:"max-w-[14rem] px-3 py-3",children:s.jsx("button",{type:"button",className:"block max-w-full truncate font-mono text-xs font-semibold text-primary hover:underline",title:r.delivery_id,onClick:()=>n(r.delivery_id),children:r.delivery_id})})]},r.delivery_id)})})]})}function Xs({noun:e,hasMore:t,loading:n,onLoadMore:r,children:i,className:a}){return s.jsxs("div",{"data-testid":`lazy-scroll-${e}`,className:Q("max-h-[640px] overflow-auto rounded-md border border-border",a),children:[i,s.jsx(eg,{noun:e,hasMore:t,loading:n,onLoadMore:r})]})}function eg({noun:e,hasMore:t,loading:n,onLoadMore:r}){const i=R.useRef(null),a=R.useRef(!1);return R.useEffect(()=>{n||(a.current=!1)},[n]),R.useEffect(()=>{const o=i.current;if(!o||!t||n||!r)return;const l=()=>{a.current||(a.current=!0,r())};if(!("IntersectionObserver"in window)){l();return}const c=new IntersectionObserver(u=>{u.some(d=>d.isIntersecting)&&l()},{rootMargin:"240px 0px"});return c.observe(o),()=>c.disconnect()},[t,n,e,r]),!t&&!n?null:s.jsx("div",{ref:i,className:"flex min-h-10 items-center justify-center border-t border-border px-3 py-2 text-xs font-medium text-muted","aria-live":"polite",children:n?`Loading more ${e}...`:`Scroll for more ${e}`})}function tg({data:e,loading:t,error:n,onBack:r,onRefresh:i,onViewHook:a,onViewDelivery:o=()=>{},onPing:l}){const[c,u]=R.useState(!1),[d,h]=R.useState(""),[m,p]=R.useState("");if(t)return s.jsx(gn,{text:"Loading hook detail…"});if(n)return s.jsxs("div",{className:"grid gap-3",children:[s.jsx(be,{tone:"error",text:n.message}),s.jsx("button",{type:"button",className:"w-fit rounded border border-border px-3 py-2 text-sm font-semibold",onClick:r,children:"Back to hooks"})]});if(!e)return s.jsx(J,{text:"Hook detail is not available."});const w=e.hook,y={...w,github_created_at:w.github_created_at?s.jsx(ue,{value:w.github_created_at}):"unknown",github_updated_at:w.github_updated_at?s.jsx(ue,{value:w.github_updated_at}):"unknown",last_ping_at:w.last_ping_at?s.jsx(ue,{value:w.last_ping_at}):"never",last_event_at:w.last_event_at?s.jsx(ue,{value:w.last_event_at}):"never"},v=async()=>{if(!(!l||c)){u(!0),h(""),p("");try{h(await l(y.id))}catch(N){p(N instanceof Error?N.message:String(N))}finally{u(!1)}}},b=(e.recent_actions??[]).map(N=>({...N,created_at:s.jsx(ue,{value:N.created_at,compact:!0})}));return s.jsxs("section",{className:"grid gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsxs("button",{type:"button",className:"mb-2 inline-flex items-center gap-2 text-sm font-semibold text-primary hover:underline",onClick:r,children:[s.jsx(ai,{className:"h-4 w-4","aria-hidden":!0}),"Back to hooks"]}),s.jsx("h2",{className:"text-xl font-semibold",children:y.target}),s.jsxs("p",{className:"font-mono text-xs text-muted",children:[y.target_type," webhook #",y.id]})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[y.ping_url&&l?s.jsxs("button",{type:"button",className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold hover:bg-slate-50 disabled:cursor-wait disabled:opacity-60",disabled:c,onClick:()=>void v(),children:[s.jsx(an,{className:Q("h-4 w-4",c&&"animate-pulse"),"aria-hidden":!0}),c?"Sending ping…":"Send ping"]}):null,s.jsx(nt,{onClick:i}),y.admin_url?s.jsxs("a",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold hover:bg-slate-50",href:rt(y.admin_url),target:"_blank",rel:"noreferrer",children:[s.jsx(on,{className:"h-4 w-4","aria-hidden":!0}),"Open in GitHub"]}):null]})]}),m?s.jsx(be,{tone:"error",text:m}):null,d?s.jsx("div",{className:"rounded-md border border-emerald-200 bg-emerald-50 p-3 text-sm text-emerald-700",children:d}):null,s.jsxs("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[s.jsx(Ae,{title:"State",value:y.status,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Deliveries",value:e.stats.deliveries,icon:s.jsx(Fn,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Retries",value:e.stats.duplicates,icon:s.jsx(zn,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Unsupported",value:e.stats.unsupported,icon:s.jsx(Hr,{className:"h-5 w-5"})})]}),s.jsxs(se,{title:"Sanitized configuration",children:[s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:[s.jsx($,{label:"Active",value:y.active?"yes":"no"}),s.jsx($,{label:"Content type",value:y.content_type??"unknown"}),s.jsx($,{label:"SSL verification",value:y.ssl_verify===null||y.ssl_verify===void 0?"unknown":y.ssl_verify?"enabled":"disabled"}),s.jsx($,{label:"Destination URL",value:y.delivery_url??"unknown"}),s.jsx($,{label:"GitHub created",value:y.github_created_at??"unknown"}),s.jsx($,{label:"GitHub updated",value:y.github_updated_at??"unknown"}),s.jsx($,{label:"Last ping",value:y.last_ping_at??"never"}),s.jsx($,{label:"Last delivery",value:y.last_event_at??"never"}),s.jsx($,{label:"Last result",value:y.last_result??"unknown"})]}),s.jsxs("div",{className:"mt-3 rounded-md border border-border p-3",children:[s.jsx("div",{className:"text-xs font-semibold text-muted",children:"Subscribed events"}),s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:y.events.length?y.events.map(N=>s.jsx("span",{className:"rounded border border-border bg-slate-50 px-2 py-1 font-mono text-xs",children:N},N)):s.jsx("span",{className:"text-sm text-muted",children:"No event snapshot; send a ping to refresh it."})})]})]}),s.jsx(se,{title:"Latest observed delivery",children:s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:[s.jsx($,{label:"Event",value:y.last_event_name?`${y.last_event_name}${y.last_action?` · ${y.last_action}`:""}`:"none"}),s.jsx($,{label:"Repository",value:y.last_repository??"none"}),s.jsx($,{label:"Delivery ID",value:y.last_delivery_id??"none"})]})}),s.jsx(se,{title:"Recent administrative actions",children:b.length?s.jsx("div",{className:"divide-y divide-border rounded-md border border-border",children:b.map(N=>s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"font-semibold",children:N.action}),s.jsxs("span",{className:"ml-2 text-muted",children:["by @",N.actor]})]}),s.jsxs("span",{className:"font-mono text-xs text-muted",children:[N.status," · ",N.created_at]})]},N.id))}):s.jsx(J,{text:"No administrative actions recorded for this hook."})}),s.jsx(se,{title:"Recent deliveries",children:e.recent_deliveries.length?s.jsx(_c,{deliveries:e.recent_deliveries,onViewHook:a,onViewDelivery:o}):s.jsx(J,{text:"This hook has no retained deliveries."})})]})}function ng({data:e,loading:t,error:n,onBack:r,onRefresh:i,onViewHook:a,onViewJob:o}){if(t)return s.jsx(gn,{text:"Loading delivery detail…"});if(n)return s.jsxs("div",{className:"grid gap-3",children:[s.jsx(be,{tone:"error",text:n.message}),s.jsx("button",{type:"button",className:"w-fit rounded border border-border px-3 py-2 text-sm font-semibold",onClick:r,children:"Back to deliveries"})]});if(!e)return s.jsx(J,{text:"Delivery detail is not available."});const l={...e.delivery,created_at:s.jsx(ue,{value:e.delivery.created_at})};return s.jsxs("section",{className:"grid gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsxs("button",{type:"button",className:"mb-2 inline-flex items-center gap-2 text-sm font-semibold text-primary hover:underline",onClick:r,children:[s.jsx(ai,{className:"h-4 w-4","aria-hidden":!0}),"Back to deliveries"]}),s.jsxs("h2",{className:"text-xl font-semibold",children:[l.event_name,l.action?` · ${l.action}`:""]}),s.jsxs("p",{className:"font-mono text-xs text-muted",children:["Delivery ",l.delivery_id]})]}),s.jsx(nt,{onClick:i})]}),s.jsxs(se,{title:"Delivery",children:[s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:[s.jsx($,{label:"Received",value:l.created_at}),s.jsx($,{label:"Repository",value:l.repository??"unknown"}),s.jsx($,{label:"Result",value:l.status}),s.jsx($,{label:"Event key",value:l.event_key??"unmatchable"}),s.jsx($,{label:"Payload SHA-256",value:e.payload_hash}),s.jsx($,{label:"Retries",value:l.duplicate_count??0})]}),l.hook_id?s.jsxs("button",{type:"button",className:"mt-3 text-sm font-semibold text-primary hover:underline",onClick:()=>a(l.hook_id),children:["View hook #",l.hook_id]}):null]}),s.jsx(se,{title:"Generated job",children:e.job?s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"font-semibold",children:e.job.work_key}),s.jsxs("div",{className:"mt-1 font-mono text-xs text-muted",children:["Job #",e.job.id," · ",e.job.status," · ",e.job.action," · ",e.job.work_intent]})]}),s.jsx("button",{type:"button",className:"rounded-md border border-border px-3 py-2 text-sm font-semibold hover:bg-slate-50",onClick:()=>o(e.job.id),children:"Open job"})]}):s.jsx(J,{text:"This delivery did not generate or coalesce into a job."})}),s.jsx(se,{title:"Full payload",children:e.payload===null?s.jsx(J,{text:"Payload was not retained for this legacy delivery."}):s.jsx("pre",{className:"max-h-[640px] overflow-auto rounded-md border border-border bg-slate-950 p-4 font-mono text-xs leading-relaxed text-slate-100",children:JSON.stringify(e.payload,null,2)})})]})}function rg({executorPause:e,executorPauseLoading:t,executorPauseStatusError:n,executorPausePending:r,executorPauseError:i,executorCapacity:a,executorResizePending:o,executorResizeError:l,isAdmin:c,onExecutorPauseChange:u,onExecutorResize:d,processes:h,processesLoading:m,processesError:p,systemd:w,systemdLoading:y,systemdError:v,alerts:b,alertsLoading:N,alertsError:k,sloSummary:_,sloLoading:D,sloError:j,sloWindow:B,now:F,onRefreshProcesses:C,onRefreshSystemd:M,onRefreshAlerts:O,onSloWindowChange:I,onRefreshSlo:X}){return s.jsxs("section",{className:"grid gap-4","aria-label":"Bridge system",children:[s.jsx(sg,{state:e,loading:t,statusError:n,pending:r,actionError:i,capacity:a,resizePending:o,resizeError:l,isAdmin:c,onChange:u,onResize:d}),j?s.jsx(be,{tone:"error",text:j.message}):null,s.jsx(kg,{summary:_,loading:D,window:B,onWindowChange:I,onRefresh:X}),s.jsxs(se,{title:"Systemd",action:s.jsx(nt,{onClick:M}),children:[v?s.jsx(be,{tone:"error",text:v.message}):null,s.jsx(Xg,{data:w,loading:y})]}),s.jsxs(se,{title:"Process activity",action:s.jsx(nt,{onClick:C}),children:[p?s.jsx(be,{tone:"error",text:p.message}):null,s.jsx(eb,{data:h,loading:m})]}),s.jsxs(se,{title:"Monitor alerts",action:s.jsx(nt,{onClick:O}),children:[k?s.jsx(be,{tone:"error",text:k.message}):null,s.jsx(tb,{alerts:b,loading:N,now:F})]})]})}function sg({state:e,loading:t,statusError:n,pending:r,actionError:i,capacity:a,resizePending:o=!1,resizeError:l="",isAdmin:c,onChange:u,onResize:d}){const h=!!(e!=null&&e.paused),[m,p]=R.useState(()=>String((a==null?void 0:a.desired)||1));R.useEffect(()=>{a!=null&&a.desired&&p(String(a.desired))},[a==null?void 0:a.desired]);const w=Number(m),y=Number.isInteger(w)&&w>=1;return s.jsxs(se,{title:"Executor",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-semibold",children:e?h?"Paused":"Accepting jobs":t?"Loading state...":"State unavailable"}),h?s.jsx("p",{className:"text-xs text-muted",children:"New jobs remain pending; running jobs continue."}):null,e!=null&&e.reason?s.jsxs("p",{className:"mt-1 text-xs text-muted",children:["Reason: ",e.reason]}):null,c?null:s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Admin only"})]}),s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm font-medium",children:[s.jsx("span",{children:"Pause"}),s.jsx("input",{"aria-label":"Pause executor",role:"switch",type:"checkbox",checked:h,disabled:!c||!e||!!e.error||!!n||r,onChange:()=>{const v=!h,b=v?"Pause executor? New jobs will remain pending; running jobs will continue.":"Resume executor? Pending jobs may start running.";window.confirm(b)&&u(v)},className:"peer sr-only"}),s.jsx("span",{"aria-hidden":!0,className:"relative h-6 w-11 rounded-full bg-slate-300 transition-colors peer-checked:bg-primary peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-primary peer-disabled:opacity-50 after:absolute after:left-0.5 after:top-0.5 after:h-5 after:w-5 after:rounded-full after:bg-white after:shadow-sm after:transition-transform peer-checked:after:translate-x-5"})]})]}),a?s.jsxs("div",{className:"mt-3 grid gap-3 border-t border-border pt-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4","aria-label":"Executor capacity",children:[s.jsx($,{label:"Desired",value:a.desired}),s.jsx($,{label:"Live",value:a.live}),s.jsx($,{label:"Busy",value:a.busy}),s.jsx($,{label:"Draining",value:a.draining})]}),s.jsxs("form",{className:"flex flex-wrap items-end gap-2",onSubmit:v=>{v.preventDefault(),y&&d&&d(w)},children:[s.jsxs("label",{className:"grid gap-1 text-xs font-semibold text-muted",children:["Desired workers",s.jsx("input",{"aria-label":"Desired workers",className:"control w-28",type:"number",min:"1",step:"1",value:m,disabled:!c||o,onChange:v=>p(v.target.value)})]}),s.jsx("button",{type:"submit",className:"h-9 rounded-md bg-primary px-3 text-sm font-semibold text-white disabled:cursor-not-allowed disabled:opacity-60",disabled:!c||o||!y||w===a.desired,children:o?"Resizing…":"Resize"})]})]}):null,n?s.jsx(be,{tone:"error",text:n.message}):null,e!=null&&e.error?s.jsx(be,{tone:"error",text:e.error}):null,i?s.jsx(be,{tone:"error",text:`Action failed: ${i}`}):null,l?s.jsx(be,{tone:"error",text:`Resize failed: ${l}`}):null]})}function er({href:e,active:t,children:n,onNavigate:r}){return s.jsx("a",{className:Q("inline-flex h-8 min-w-0 flex-1 items-center justify-center gap-1 rounded-md px-1.5 text-xs font-semibold sm:flex-none sm:gap-1.5 sm:px-3 sm:text-sm [&>span]:truncate [&>svg]:shrink-0",t?"bg-primary text-white shadow-sm":"text-muted hover:bg-slate-50 hover:text-foreground"),href:e,onClick:i=>{!r||i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.altKey||i.shiftKey||(i.preventDefault(),r(e))},children:n})}function ig({jobId:e,detail:t,selectedJob:n,user:r,onBackToDashboard:i,onRetry:a,onDismiss:o,onCancel:l,onRefresh:c}){const[u,d]=R.useState(!1),[h,m]=R.useState(!1),[p,w]=R.useState(!1),y=!!(r!=null&&r.is_admin&&n&&Vs(n.status)&&n.decision==="auto_trusted"),v=!!(r!=null&&r.is_admin&&n&&Gs(n.status)),b=!!(n&&Js(n,r)),N=u?"Retrying...":"Retry",k=h?"Dismissing...":"Dismiss",_=p?"Cancelling...":"Cancel";return s.jsxs("div",{className:"grid min-w-0 gap-3 sm:gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("a",{className:"inline-flex h-9 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50",href:"/",onClick:D=>{D.defaultPrevented||D.button!==0||D.metaKey||D.ctrlKey||D.altKey||D.shiftKey||(D.preventDefault(),i())},children:[s.jsx(ai,{className:"h-4 w-4","aria-hidden":!0}),"Dashboard"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[y?s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary px-3 text-sm font-semibold text-white disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:u,onClick:async()=>{if(window.confirm(`Retry job #${e}?`)){d(!0);try{await a(e)}finally{d(!1)}}},children:[s.jsx(cr,{className:"h-4 w-4","aria-hidden":!0}),N]}):null,v?s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md border border-border bg-white px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:h,onClick:async()=>{if(window.confirm(`Dismiss job #${e}?`)){m(!0);try{await o(e)}finally{m(!1)}}},children:[s.jsx(On,{className:"h-4 w-4","aria-hidden":!0}),k]}):null,b?s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md border border-red-200 bg-red-50 px-3 text-sm font-semibold text-red-700 hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:p,onClick:async()=>{const D=window.prompt(`Cancel job #${e}? Optional reason:`);if(D!==null){w(!0);try{await l(e,D)}finally{w(!1)}}},children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),_]}):null,s.jsx(nt,{onClick:c})]})]}),s.jsx(se,{title:`Job #${e}`,className:"p-3 sm:p-4",children:t})]})}function ag({selectedJobId:e,selectedJob:t,loading:n,error:r,session:i,sessionEvents:a,transcript:o,now:l}){return t?s.jsx(Dg,{job:t,session:i,sessionEvents:a,transcript:o,now:l}):e!==null&&n?s.jsx(J,{text:"Loading selected job..."}):e!==null&&r?s.jsx(be,{tone:"error",text:`Job #${e}: ${r.message}`}):s.jsx(J,{text:"Select a job to inspect its timeline, worklog and GitHub links."})}function og({data:e,loading:t,error:n,repo:r,status:i,activeTab:a,user:o,now:l,onRepoChange:c,onStatusChange:u,onTabChange:d,onApprove:h,onReject:m,onUpdateRuleScope:p,onDeleteRule:w,onRefresh:y,hasMore:v=!1,loadingMore:b=!1,onLoadMore:N=()=>{}}){const k=(e==null?void 0:e.summary)??{},[_,D]=R.useState("proposals"),j=a??_,B=M=>{D(M),d==null||d(M)},C=[{id:"proposals",label:"Proposals",count:k.proposals??(k.proposed??0)+(k.approved??0)+(k.rejected??0)+(k.errors??0)},{id:"rules",label:"Rules",count:k.rules??0},{id:"events",label:"Events",count:k.events??0}];return s.jsxs("div",{className:"grid min-w-0 gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("h2",{className:"flex items-center gap-2 text-base font-semibold",children:[s.jsx(oi,{className:"h-5 w-5 text-muted","aria-hidden":!0}),"Acquired knowledge"]}),s.jsx("p",{className:"text-xs text-muted",children:"Captured feedback, proposed rules and curated agent memory."})]}),s.jsx(nt,{onClick:y})]}),n?s.jsx(be,{tone:"error",text:n.message}):null,s.jsxs("section",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4","aria-label":"Knowledge metrics",children:[s.jsx(Ae,{title:"Proposed",value:k.proposed??0,icon:s.jsx(Rl,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Approved",value:k.approved??0,icon:s.jsx(On,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Rules",value:k.rules??0,icon:s.jsx(Tl,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Events",value:k.events??0,icon:s.jsx(an,{className:"h-5 w-5"})})]}),s.jsx(se,{title:"Filters",className:"p-3",children:s.jsxs("div",{className:Q("grid gap-3",j==="proposals"?"md:grid-cols-[minmax(0,1fr)_220px]":"md:grid-cols-[minmax(0,1fr)]"),children:[s.jsx(ot,{label:"Repository",children:s.jsxs("select",{className:"control",value:r,onChange:M=>c(M.target.value),children:[s.jsx("option",{value:"",children:"All repositories"}),((e==null?void 0:e.repositories)??[]).map(M=>s.jsx("option",{value:M,children:M},M))]})}),j==="proposals"?s.jsx(ot,{label:"Proposal status",children:s.jsxs("select",{className:"control",value:i,onChange:M=>u(M.target.value),children:[s.jsx("option",{value:"",children:"All statuses"}),s.jsx("option",{value:"proposed",children:"proposed"}),s.jsx("option",{value:"approved",children:"approved"}),s.jsx("option",{value:"rejected",children:"rejected"}),s.jsx("option",{value:"error",children:"error"})]})}):null]})}),s.jsxs(se,{title:"Knowledge records",action:s.jsx("div",{className:"flex max-w-full flex-wrap rounded-md border border-border bg-white p-0.5",role:"tablist","aria-label":"Knowledge record type",children:C.map(M=>s.jsxs("button",{className:Q("inline-flex h-8 items-center gap-1.5 rounded px-2.5 text-xs font-semibold",j===M.id?"bg-primary text-white":"text-muted hover:bg-slate-50 hover:text-foreground"),type:"button",role:"tab","aria-label":`${M.label} (${M.count})`,"aria-selected":j===M.id,onClick:()=>B(M.id),children:[s.jsx("span",{children:M.label}),s.jsx("span",{className:Q("rounded-sm border px-1 font-mono text-[10px]",j===M.id?"border-white/40 text-white":"border-border text-muted"),children:M.count})]},M.id))}),children:[j==="proposals"?s.jsx(lg,{proposals:(e==null?void 0:e.proposals)??[],loading:t,isAdmin:!!(o!=null&&o.is_admin),now:l,onApprove:h,onReject:m}):null,j==="rules"?s.jsx(dg,{rules:(e==null?void 0:e.rules)??[],loading:t,now:l,onUpdateRuleScope:p,onDeleteRule:w}):null,j==="events"?s.jsx(hg,{events:(e==null?void 0:e.events)??[],loading:t,now:l}):null,v?s.jsx("div",{className:"mt-3 flex justify-center border-t border-border pt-3",children:s.jsx("button",{className:"button-secondary",type:"button",disabled:b,onClick:N,children:b?"Loading more...":"Load more knowledge records"})}):null]})]})}function lg({proposals:e,loading:t,isAdmin:n,now:r,onApprove:i,onReject:a}){const[o,l]=R.useState(null);return t&&e.length===0?s.jsx(J,{text:"Loading proposals..."}):e.length===0?s.jsx(J,{text:"No proposals match the current filters."}):s.jsx("div",{className:"grid gap-2",children:e.map(c=>s.jsxs("article",{className:"grid min-w-0 gap-2 rounded-md border border-border bg-white p-3",children:[s.jsx(Ec,{scope:c.scope,type:c.type,confidence:c.confidence,status:c.status,timestamp:c.updated_at,now:r}),s.jsx("p",{className:"min-w-0 break-words text-sm font-medium [overflow-wrap:anywhere]",children:c.rule||c.reason||"No reusable rule proposed."}),c.reason?s.jsx("p",{className:"min-w-0 break-words text-xs text-muted [overflow-wrap:anywhere]",children:c.reason}):null,c.source_event?s.jsx(cg,{event:c.source_event}):s.jsxs("p",{className:"font-mono text-xs text-muted",children:["Source event ",c.event_id]}),c.error?s.jsx(be,{tone:"error",text:c.error}):null,n&&c.status==="proposed"?s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md bg-primary px-3 text-sm font-semibold text-white disabled:opacity-60",type:"button",disabled:o===c.id,onClick:async()=>{l(c.id);try{await i(c.id)}finally{l(null)}},children:[s.jsx(On,{className:"h-4 w-4","aria-hidden":!0}),"Approve"]}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:opacity-60",type:"button",disabled:o===c.id,onClick:async()=>{l(c.id);try{await a(c.id)}finally{l(null)}},children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),"Reject"]})]}):null]},c.id))})}function cg({event:e}){const t=e.trigger_actor||(e.actor!=="github"?e.actor:null);return s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 rounded-md border border-border bg-slate-50 px-2 py-1.5",children:[s.jsx(Hn,{actor:t,avatarUrl:e.trigger_actor_avatar_url,framed:!0}),e.source_job_id?s.jsxs("a",{className:"inline-flex h-7 items-center gap-1 rounded-md border border-border bg-white px-2 text-xs font-semibold text-foreground hover:bg-slate-50",href:Un(e.source_job_id),children:[s.jsx(Fn,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Job #",e.source_job_id]}):null,e.github_urls.length>0?s.jsx(dr,{urls:e.github_urls,compact:!0}):s.jsx("span",{className:"font-mono text-xs text-muted",children:"No GitHub link"})]})}function ug(e){const t=[{value:"global",label:"global"}];if(e.startsWith("repo:")){const n=e.slice(5),[r,i]=n.split("/",2);r&&i&&(t.push({value:`org:${r}`,label:`org:${r}`}),t.push({value:`repo:${r}/${i}`,label:`repo:${r}/${i}`}))}else e.startsWith("org:")&&t.push({value:e,label:e});return t.some(n=>n.value===e)||t.push({value:e,label:e}),t}function dg({rules:e,loading:t,now:n,onUpdateRuleScope:r,onDeleteRule:i}){const[a,o]=R.useState(null),[l,c]=R.useState(null),[u,d]=R.useState("");return t&&e.length===0?s.jsx(J,{text:"Loading curated rules..."}):e.length===0?s.jsx(J,{text:"No curated rules match the current filters."}):s.jsx("div",{className:"grid gap-2",children:e.map(h=>{const m=h.source_event_details??[],p=m[0],w=p?p.trigger_actor||(p.actor!=="github"?p.actor:null):null,y=m.flatMap(_=>_.github_urls??[]),v=ug(h.scope),b=l===h.id,N=a===h.id,k=!!h.can_manage;return s.jsxs("article",{className:"grid min-w-0 gap-2 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsx(Ec,{scope:h.scope,type:h.type,confidence:h.confidence,status:`${h.observations} observation${h.observations===1?"":"s"}`,timestamp:h.last_seen,now:n}),k?s.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[b?s.jsxs(s.Fragment,{children:[s.jsx(ot,{label:"Scope",children:s.jsx("select",{className:"control h-8 min-w-[180px] py-1 text-xs",value:u,disabled:N,onChange:_=>d(_.target.value),children:v.map(_=>s.jsx("option",{value:_.value,children:_.label},_.value))})}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:opacity-60",type:"button",disabled:N||u===h.scope,title:"Save scope",onClick:async()=>{if(u!==h.scope){o(h.id);try{await r(h.id,u),c(null)}finally{o(null)}}},children:[s.jsx(od,{className:"h-4 w-4","aria-hidden":!0}),"Save"]}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-muted hover:bg-slate-50 disabled:opacity-60",type:"button",disabled:N,title:"Cancel scope edit",onClick:()=>{c(null),d("")},children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),"Cancel"]})]}):s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:opacity-60",type:"button",disabled:N,title:"Edit scope",onClick:()=>{c(h.id),d(h.scope)},children:[s.jsx(ad,{className:"h-4 w-4","aria-hidden":!0}),"Edit"]}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-red-200 px-3 text-sm font-semibold text-red-700 hover:bg-red-50 disabled:opacity-60",type:"button",disabled:N,onClick:async()=>{if(window.confirm("Delete this curated rule?")){o(h.id);try{await i(h.id)}finally{o(null)}}},children:[s.jsx(Ls,{className:"h-4 w-4","aria-hidden":!0}),"Delete"]})]}):null]}),s.jsx("p",{className:"min-w-0 break-words text-sm font-medium [overflow-wrap:anywhere]",children:h.rule}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx(Hn,{actor:w,avatarUrl:p==null?void 0:p.trigger_actor_avatar_url,framed:!0}),p!=null&&p.source_job_id?s.jsxs("a",{className:"inline-flex h-7 items-center gap-1 rounded-md border border-border px-2 text-xs font-semibold text-foreground hover:bg-white",href:Un(p.source_job_id),children:[s.jsx(Fn,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Job #",p.source_job_id]}):null,y.length>0?s.jsx(dr,{urls:y,compact:!0}):s.jsx("span",{className:"font-mono text-xs text-muted",children:"No GitHub link"})]})]},h.id)})})}function hg({events:e,loading:t,now:n}){return t&&e.length===0?s.jsx(J,{text:"Loading captured events..."}):e.length===0?s.jsx(J,{text:"No captured feedback events match the current filters."}):s.jsx("div",{className:"grid gap-2",children:e.map(r=>{const i=r.trigger_actor||(r.actor!=="github"?r.actor:null);return s.jsxs("details",{className:"group rounded-md border border-border bg-white",children:[s.jsxs("summary",{className:"grid cursor-pointer list-none gap-2 px-3 py-2 marker:hidden hover:bg-slate-50",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2 font-mono text-xs font-semibold text-muted",children:[s.jsx(Dn,{className:"h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180","aria-hidden":!0}),s.jsx("span",{className:"truncate",children:Nc(r.scope)})]}),s.jsx("span",{className:"shrink-0 font-mono text-xs text-muted",children:s.jsx(ue,{value:r.occurred_at,relative:!0,now:n})})]}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx(Hn,{actor:i,avatarUrl:r.trigger_actor_avatar_url,framed:!0}),r.source_job_id?s.jsxs("a",{className:"inline-flex h-7 items-center gap-1 rounded-md border border-border px-2 text-xs font-semibold text-foreground hover:bg-white",href:Un(r.source_job_id),children:[s.jsx(Fn,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Job #",r.source_job_id]}):null,r.github_urls.length>0?s.jsx(dr,{urls:r.github_urls,compact:!0}):s.jsx("span",{className:"font-mono text-xs text-muted",children:"No GitHub link"})]}),s.jsx("p",{className:"line-clamp-2 break-words text-sm [overflow-wrap:anywhere]",children:r.comment})]}),s.jsxs("div",{className:"grid gap-2 border-t border-border px-3 py-2",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"mb-1 text-xs font-semibold text-muted",children:"GitHub links"}),r.github_urls.length>0?s.jsx(dr,{urls:r.github_urls}):s.jsx("p",{className:"text-xs text-muted",children:"No links recorded."})]}),s.jsx("pre",{className:"max-h-72 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs leading-relaxed text-slate-100",children:JSON.stringify(r.context,null,2)})]})]},r.id)})})}function pg({tokens:e,loading:t,error:n,user:r,ownerOptions:i,dashboardUrl:a,dashboardUrlSource:o,now:l,onCreate:c,onUpdateOwner:u,onRevoke:d,onRefresh:h}){const[m,p]=R.useState(""),[w,y]=R.useState(""),[v,b]=R.useState(!1),[N,k]=R.useState(null),[_,D]=R.useState(null),[j,B]=R.useState(null),[F,C]=R.useState(""),M=e??[],O=i.find(P=>P.login===w);R.useEffect(()=>{var P;r!=null&&r.is_admin&&(w&&i.some(U=>U.login===w)||y((r==null?void 0:r.login)||((P=i[0])==null?void 0:P.login)||""))},[i,r==null?void 0:r.is_admin,r==null?void 0:r.login,w]);const I=(a||(typeof window>"u"?"":window.location.origin)).replace(/\/$/,""),X=`${I}/mcp`,q=`${I}/api/mcp`;return s.jsxs("div",{className:"grid min-w-0 gap-4",children:[s.jsx(Cc,{icon:s.jsx(Dr,{className:"h-5 w-5 text-muted","aria-hidden":!0}),title:"MCP access",subtitle:r!=null&&r.is_admin?"Issue and revoke globally readable knowledge tokens for any dashboard user.":"Issue and revoke globally readable knowledge tokens linked to your user.",action:s.jsx(nt,{onClick:h})}),n?s.jsx(be,{tone:"error",text:n.message}):null,F?s.jsx(be,{tone:"error",text:F}):null,s.jsx(mg,{dashboardUrl:X,endpointUrl:q,dashboardUrlSource:o??"request"}),j?s.jsxs("section",{className:"rounded-md border border-emerald-300 bg-emerald-50 p-3 text-emerald-950","aria-label":"Created MCP token",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-sm font-semibold",children:"Token created"}),s.jsx("p",{className:"mt-1 text-xs text-emerald-800",children:"This secret is shown once. Store it in the local agent environment before leaving this page."})]}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-emerald-300 bg-white px-3 text-sm font-semibold text-emerald-900 hover:bg-emerald-100",type:"button",onClick:()=>B(null),children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),"Hide"]})]}),s.jsx("pre",{className:"mt-3 overflow-auto rounded bg-emerald-950 px-3 py-2 font-mono text-xs text-emerald-50",children:j.token})]}):null,s.jsx(se,{title:"Create token",children:s.jsxs("form",{className:r!=null&&r.is_admin?"grid gap-3 md:grid-cols-[minmax(0,1fr)_minmax(12rem,16rem)_auto]":"grid gap-3 md:grid-cols-[minmax(0,1fr)_auto]",onSubmit:async P=>{P.preventDefault();const U=m.trim();if(U){b(!0),C("");try{const te=await c(U,r!=null&&r.is_admin?w:void 0);B(te),p("")}catch(te){C(te instanceof Error?te.message:String(te))}finally{b(!1)}}},children:[s.jsx(ot,{label:"Token name",children:s.jsx("input",{className:"control",value:m,placeholder:"local agent",disabled:v,onChange:P=>p(P.target.value)})}),r!=null&&r.is_admin?s.jsxs(ot,{label:"Lifecycle owner",children:[s.jsx(Pc,{ariaLabel:"Lifecycle owner",value:w,ownerOptions:i,disabled:v||i.length===0,selectedSuffix:P=>P.login===(r==null?void 0:r.login)?" (you)":"",emptyLabel:"No known users",onChange:y}),O?s.jsxs("span",{className:"font-normal text-muted",children:["Token management will be linked to @",O.login,"; this does not restrict repository reads."]}):null]}):null,s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 self-end rounded-md bg-primary px-3 text-sm font-semibold text-white disabled:cursor-not-allowed disabled:opacity-60",type:"submit",disabled:v||!m.trim()||!!(r!=null&&r.is_admin&&!w),children:[s.jsx(Dr,{className:"h-4 w-4","aria-hidden":!0}),v?"Creating...":"Create token"]})]})}),s.jsx(se,{title:"Active tokens",children:s.jsx(fg,{tokens:M,loading:t,now:l,ownerOptions:i,canManageOwners:!!(r!=null&&r.is_admin),revokingId:N,updatingOwnerId:_,onUpdateOwner:async(P,U)=>{D(P),C("");try{await u(P,U)}catch(te){C(te instanceof Error?te.message:String(te))}finally{D(null)}},onRevoke:async P=>{if(window.confirm("Revoke this MCP token?")){k(P),C("");try{await d(P)}catch(U){C(U instanceof Error?U.message:String(U))}finally{k(null)}}}})})]})}function mg({dashboardUrl:e,endpointUrl:t,dashboardUrlSource:n}){const r=n==="configured"?"Configured public URL":n==="forwarded"?"Forwarded public URL":"Needs public URL",i=n==="request",a=i?"Set GITHUB_AGENT_BRIDGE_DASHBOARD_PUBLIC_URL or forward X-Forwarded-* headers":e,o=i?"Public dashboard URL required before connecting remote agents":t,c=`{ "mcpServers": { "github-agent-bridge": { "url": "${i?"https://bridge.example.com/api/mcp":t}", @@ -184,4 +184,4 @@ var Ha=e=>{throw TypeError(e)};var Jr=(e,t,n)=>t.has(e)||Ha("Cannot "+n);var g=( } } } -}`;return s.jsxs(se,{title:"Connect an agent",children:[i?s.jsx(be,{tone:"warning",text:"Set GITHUB_AGENT_BRIDGE_DASHBOARD_PUBLIC_URL, or forward X-Forwarded-* headers from the proxy, before connecting remote agents."}):null,s.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[s.jsxs("div",{className:"grid min-w-0 gap-3",children:[s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm font-semibold",children:[s.jsx(on,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"Public dashboard URL",s.jsx("span",{className:"rounded-sm border border-border bg-slate-50 px-1.5 py-0.5 font-mono text-[11px] font-normal text-muted",children:r})]}),s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Share this page URL with bridge admins only after it resolves to the external dashboard origin."}),s.jsx("pre",{className:"mt-3 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs text-slate-100",children:a})]}),s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(on,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"HTTP MCP endpoint"]}),s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Remote agents connect directly with a bearer token; no local `gab` binary is required on the agent host."}),s.jsx("pre",{className:"mt-3 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs text-slate-100",children:o})]})]}),s.jsxs("div",{className:"grid min-w-0 gap-3",children:[s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(Dr,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"Agent config"]}),s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Create a token below, then store the one-time secret as `GITHUB_AGENT_BRIDGE_MCP_TOKEN` for the agent."}),s.jsx("pre",{className:"mt-3 max-h-64 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs leading-relaxed text-slate-100",children:c})]}),s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(oi,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"Agent prompt"]}),s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Ask the agent to use the read-only bridge knowledge server before acting on repository work."}),s.jsx("pre",{className:"mt-3 max-h-40 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs leading-relaxed text-slate-100",children:"Use the github-agent-bridge MCP server for repository knowledge. Query list_repositories and list_knowledge before making repository decisions."})]})]})]})]})}function Cc({icon:e,title:t,subtitle:n,action:r}){return s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("h2",{className:"flex items-center gap-2 text-base font-semibold",children:[e,t]}),s.jsx("p",{className:"text-xs text-muted",children:n})]}),r]})}function hg({tokens:e,loading:t,now:n,ownerOptions:r,canManageOwners:i,revokingId:a,updatingOwnerId:o,onUpdateOwner:l,onRevoke:c}){return t&&e.length===0?s.jsx(J,{text:"Loading MCP tokens..."}):e.length===0?s.jsx(J,{text:"No active MCP tokens."}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"grid gap-2 md:hidden",children:e.map(u=>s.jsxs("article",{className:"grid min-w-0 gap-3 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"break-words text-sm font-semibold [overflow-wrap:anywhere]",children:u.name}),s.jsx("div",{className:"mt-1 break-all font-mono text-xs text-muted",children:u.id}),i?s.jsx(Go,{token:u,ownerOptions:r,disabled:o===u.id,onUpdateOwner:l}):u.user_login?s.jsxs("div",{className:"mt-1 text-xs text-muted",children:["Lifecycle owner: @",u.user_login]}):null]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[s.jsx($,{label:"Created",value:s.jsx(ue,{value:u.created_at,relative:!0,now:n})}),s.jsx($,{label:"Last used",value:u.last_used_at?s.jsx(ue,{value:u.last_used_at,relative:!0,now:n}):"never"})]}),s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-2 rounded-md border border-red-200 px-3 text-sm font-semibold text-red-700 hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:a===u.id,onClick:()=>c(u.id),children:[s.jsx(Ls,{className:"h-4 w-4","aria-hidden":!0}),a===u.id?"Revoking...":"Revoke"]})]},u.id))}),s.jsx("div",{className:"hidden overflow-auto rounded-md border border-border md:block",children:s.jsxs("table",{className:"min-w-full border-collapse text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border bg-slate-50 text-left text-xs text-muted",children:[s.jsx("th",{className:"px-3 py-2 font-semibold",children:"Name"}),s.jsx("th",{className:"px-3 py-2 font-semibold",children:"Lifecycle owner"}),s.jsx("th",{className:"px-3 py-2 font-semibold",children:"Created"}),s.jsx("th",{className:"px-3 py-2 font-semibold",children:"Last used"}),s.jsx("th",{className:"px-3 py-2 font-semibold",children:"ID"}),s.jsx("th",{className:"px-3 py-2 text-right font-semibold",children:"Actions"})]})}),s.jsx("tbody",{children:e.map(u=>s.jsxs("tr",{className:"border-b border-border last:border-b-0",children:[s.jsx("td",{className:"px-3 py-3 font-semibold",children:u.name}),s.jsx("td",{className:"px-3 py-3 text-xs text-muted",children:i?s.jsx(Go,{token:u,ownerOptions:r,disabled:o===u.id,onUpdateOwner:l}):u.user_login?`@${u.user_login}`:"unassigned"}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs",children:s.jsx(ue,{value:u.created_at,relative:!0,now:n})}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs",children:u.last_used_at?s.jsx(ue,{value:u.last_used_at,relative:!0,now:n}):"never"}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs text-muted",children:u.id}),s.jsx("td",{className:"px-3 py-3 text-right",children:s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-red-200 px-3 text-sm font-semibold text-red-700 hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:a===u.id,onClick:()=>c(u.id),children:[s.jsx(Ls,{className:"h-4 w-4","aria-hidden":!0}),a===u.id?"Revoking...":"Revoke"]})})]},u.id))})]})})]})}function Go({token:e,ownerOptions:t,disabled:n,onUpdateOwner:r}){const i=e.user_login??"";return s.jsx(Pc,{ariaLabel:`Lifecycle owner for ${e.name}`,value:i,ownerOptions:t,disabled:n||t.length===0,emptyLabel:"Select owner",size:"compact",onChange:a=>{!a||a===e.user_login||r(e.id,a)}})}function Pc({value:e,ownerOptions:t,disabled:n,onChange:r,ariaLabel:i,selectedSuffix:a,emptyLabel:o,size:l="default"}){const c=t.find(d=>d.login===e),u=c?`@${c.login}${(a==null?void 0:a(c))??""}`:o;return s.jsxs("div",{className:Q("relative flex min-w-0 items-center gap-2 rounded-md border border-border bg-panel text-foreground focus-within:border-primary focus-within:ring-1 focus-within:ring-primary",n?"opacity-60":"",l==="compact"?"h-8 w-44 max-w-full px-2":"h-9 w-full px-2.5"),children:[s.jsx("span",{className:Q("pointer-events-none flex shrink-0 items-center justify-center",l==="compact"?"h-5 w-5":"h-6 w-6"),children:c!=null&&c.avatar_url?s.jsx("img",{className:"h-full w-full rounded-full bg-slate-100",src:rt(c.avatar_url),alt:"",referrerPolicy:"no-referrer"}):s.jsx(An,{className:Q("text-muted",l==="compact"?"h-4 w-4":"h-5 w-5"),"aria-hidden":!0})}),s.jsx("span",{className:Q("pointer-events-none min-w-0 flex-1 truncate font-mono",c?"text-foreground":"text-muted",l==="compact"?"text-xs":"text-sm"),children:u}),s.jsxs("select",{className:"absolute inset-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed","aria-label":i,value:e,disabled:n,onChange:d=>r(d.target.value),children:[t.length===0||!e?s.jsx("option",{value:"",children:o}):null,t.map(d=>s.jsxs("option",{value:d.login,children:["@",d.login,(a==null?void 0:a(d))??""]},d.login))]}),s.jsx(Dn,{className:Q("pointer-events-none shrink-0 text-muted",l==="compact"?"h-3.5 w-3.5":"h-4 w-4"),"aria-hidden":!0})]})}function dr({urls:e,compact:t=!1}){const n=t?e.slice(0,2):e,r=e.length-n.length;return s.jsxs("div",{className:"flex min-w-0 max-w-full flex-wrap gap-1.5",children:[n.map(i=>s.jsxs("a",{className:Q("inline-flex max-w-full items-center gap-1 rounded-md border border-border font-semibold text-primary hover:bg-white hover:underline",t?"h-7 px-2 text-xs":"min-h-7 px-2 py-1 text-xs"),href:rt(i),"aria-label":i,rel:"noreferrer",target:"_blank",children:[s.jsx(on,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),s.jsx("span",{className:"truncate",children:t?pg(i):i})]},i)),r>0?s.jsxs("span",{className:"inline-flex h-7 items-center rounded-md border border-border px-2 font-mono text-xs text-muted",children:["+",r]}):null]})}function pg(e){try{const t=new URL(e);return t.pathname.replace(/^\//,"")+t.hash}catch{return e}}function Ec({scope:e,type:t,confidence:n,status:r,timestamp:i,now:a}){return s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-xs text-muted",children:[s.jsx("span",{className:"truncate font-mono font-semibold text-foreground",children:Nc(e)}),s.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 font-mono",children:t}),s.jsxs("span",{className:"rounded-sm border border-border px-1.5 py-0.5 font-mono",children:[Math.round(n*100),"%"]}),s.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 font-mono",children:r}),s.jsx("span",{className:"font-mono",children:s.jsx(ue,{value:i,relative:!0,now:a})})]})}function mg({user:e,loading:t}){const n=e!=null&&e.login?`@${e.login}`:t?"Loading profile...":"GitHub OAuth",r=e!=null&&e.is_admin?"admin":"read-only",i=e!=null&&e.avatar_url?s.jsx("img",{className:"h-10 w-10 rounded-full border border-slate-700 bg-slate-800",src:e.avatar_url,alt:e.login?`${e.login} avatar`:"",referrerPolicy:"no-referrer"}):s.jsx("span",{className:"inline-flex h-10 w-10 items-center justify-center rounded-full border border-slate-700 bg-slate-900",children:s.jsx(An,{className:"h-5 w-5","aria-hidden":!0})}),a=e!=null&&e.html_url?s.jsx("a",{className:"truncate font-semibold text-white hover:underline",href:rt(e.html_url),rel:"noreferrer",target:"_blank",children:n}):s.jsx("div",{className:"truncate font-semibold text-white",children:n});return s.jsxs("div",{className:"flex max-w-full shrink-0 items-center gap-3 text-sm text-slate-300","aria-label":e!=null&&e.login?`Signed in as ${e.login}`:"Dashboard account",children:[s.jsx(Tl,{className:"hidden h-4 w-4 shrink-0 sm:block","aria-hidden":!0}),s.jsxs("div",{className:"hidden min-w-0 text-right sm:block",children:[a,s.jsxs("div",{className:"text-xs text-slate-400",children:["Signed in · ",r]})]}),i,e!=null&&e.login?s.jsx("form",{action:"/auth/logout",method:"post",children:s.jsx("button",{className:"rounded-md border border-slate-700 px-2 py-1 text-xs font-semibold text-slate-300 hover:bg-slate-800 hover:text-white",type:"submit",children:"Sign out"})}):null]})}function fg({config:e,loading:t,onEnable:n,onDisable:r}){const[i,a]=R.useState(!1),[o,l]=R.useState(""),c=!!(e!=null&&e.status.enabled),u=typeof navigator<"u"&&typeof window<"u"&&Lr(),d=t||i||!(e!=null&&e.configured)||!u,h=u?e!=null&&e.configured?c?"Disable notifications":"Enable notifications":"Notifications not configured":"Notifications unavailable";return s.jsx("div",{className:"relative",children:s.jsx("button",{className:Q("inline-flex h-9 w-9 items-center justify-center rounded-md border text-sm font-semibold",c?"border-emerald-400 bg-emerald-50 text-emerald-700":"border-slate-700 bg-slate-900 text-slate-200",d&&"cursor-not-allowed opacity-60"),type:"button","aria-label":h,title:o||h,disabled:d,onClick:async()=>{a(!0),l("");try{c?await r():await n()}catch(m){l(m instanceof Error?m.message:String(m))}finally{a(!1)}},children:s.jsx(El,{className:Q("h-4 w-4",i&&"animate-live-pulse"),"aria-hidden":!0})})})}function xg({notification:e,onDismiss:t,onNavigate:n}){if(!e)return null;const r=e.title||"GitHub Agent Bridge",i=e.body||e.summary||"Bridge job finished",a=e.url||e.job_url||(e.job_id?Un(e.job_id):"/"),o=a.startsWith("/");return s.jsx("aside",{className:"fixed right-3 top-20 z-50 w-[min(calc(100vw-1.5rem),28rem)] rounded-md border border-emerald-300 bg-white shadow-xl shadow-slate-950/15","aria-live":"assertive","aria-label":"Bridge notification",children:s.jsxs("div",{className:"flex items-start gap-3 p-3",children:[s.jsx("div",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-emerald-50 text-emerald-700",children:s.jsx(El,{className:"h-4 w-4","aria-hidden":!0})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("h2",{className:"min-w-0 break-words text-sm font-semibold text-foreground",children:r}),s.jsx("button",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted hover:bg-slate-100 hover:text-foreground",type:"button","aria-label":"Dismiss notification",onClick:t,children:s.jsx(un,{className:"h-4 w-4","aria-hidden":!0})})]}),s.jsx("p",{className:"mt-1 min-w-0 break-words text-sm text-muted",children:i}),e.detail?s.jsx("p",{className:"mt-1 line-clamp-2 min-w-0 break-words text-xs text-muted",children:e.detail}):null,s.jsxs("button",{className:"mt-3 inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-2.5 text-xs font-semibold text-foreground hover:bg-slate-50",type:"button",onClick:()=>{t(),o?n(a):window.open(rt(a),"_blank","noopener,noreferrer")},children:[s.jsx(on,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Open"]})]})]})})}function gg({count:e,limit:t,loading:n,onRefresh:r}){return s.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3 rounded-lg border border-border bg-white px-3 py-3 shadow-sm md:px-4",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h2",{className:"text-base font-semibold",children:"Jobs"}),s.jsx("p",{className:"text-xs text-muted",children:n?"Refreshing latest jobs...":`Showing ${e} of the latest ${t} requested jobs`})]}),s.jsx(nt,{onClick:r,compactOnMobile:!0})]})}function se({title:e,action:t,children:n,className:r,flushHeader:i=!1}){return s.jsxs("section",{className:Q("min-w-0 rounded-lg border border-border bg-panel p-4 shadow-sm",r),children:[s.jsxs("div",{className:Q("flex flex-wrap items-center justify-between gap-3",!i&&"mb-4"),children:[s.jsx("h2",{className:"text-sm font-semibold",children:e}),t]}),n]})}function Ae({title:e,value:t,icon:n}){return s.jsxs("div",{className:"rounded-lg border border-border bg-panel p-3 shadow-sm md:p-4",children:[s.jsxs("div",{className:"flex items-center justify-between text-muted",children:[s.jsx("span",{className:"text-sm font-medium",children:e}),n]}),s.jsx("strong",{className:"mt-3 block text-2xl leading-none md:mt-4 md:text-3xl",children:t})]})}const bg=[{value:"24h",label:"24 hours"},{value:"7d",label:"7 days"},{value:"30d",label:"30 days"}],fs=[{key:"blocked",label:"Blocked",detail:"finished service jobs",color:"#dc2626"},{key:"no_op",label:"No-op",detail:"finished service jobs",color:"#7c3aed"},{key:"retry",label:"Retried",detail:"claimed service jobs",color:"#d97706"},{key:"coalescing",label:"Coalesced",detail:"ingested notifications",color:"#0284c7"}],yg=[{key:"source_received_to_queued",label:"Source → queue"},{key:"queued_to_claimed",label:"Queue → claim"},{key:"claimed_to_first_output",label:"Claim → first output"},{key:"claimed_to_done",label:"Claim → done"}];function wg({summary:e,loading:t,window:n,onWindowChange:r,onRefresh:i}){const a=s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("div",{className:"inline-flex h-8 rounded-md border border-border bg-white p-0.5",role:"group","aria-label":"SLO window",children:bg.map(c=>s.jsx("button",{className:Q("rounded px-2.5 text-xs font-semibold",n===c.value?"bg-primary text-white":"text-muted hover:bg-slate-50"),type:"button","aria-label":c.label,"aria-pressed":n===c.value,onClick:()=>r(c.value),children:c.value},c.value))}),s.jsx(nt,{onClick:i,compactOnMobile:!0})]});if(t&&!(e!=null&&e.slo))return s.jsx(se,{title:"Service SLOs",action:a,children:s.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 rounded-md border border-dashed border-border text-sm text-muted",children:[s.jsx(zn,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),"Loading SLO metrics…"]})});if((e==null?void 0:e.schema_ok)===!1)return s.jsx(se,{title:"Service SLOs",action:a,children:s.jsx(be,{tone:"warning",text:`SLO metrics are unavailable until the database schema is migrated${e.schema_error?`: ${e.schema_error}`:"."}`})});if(!(e!=null&&e.slo))return s.jsx(se,{title:"Service SLOs",action:a,children:s.jsx(J,{text:"No SLO read model is available."})});const o=e.slo,l=o.trends.daily.map(c=>({bucket:c.bucket,blocked:c.rates.blocked.percent,no_op:c.rates.no_op.percent,retry:c.rates.retry.percent,coalescing:c.rates.coalescing.percent}));return s.jsx(se,{title:"Service SLOs",action:a,children:s.jsxs("div",{className:"grid gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-1 text-xs text-muted",children:[s.jsxs("span",{children:[s.jsx("strong",{className:"text-foreground",children:o.cohort.sample_count})," finished auto-trusted service job",o.cohort.sample_count===1?"":"s",o.cohort.missing_count>0?` · ${o.cohort.missing_count} missing outcome`:"",o.cohort.excluded_count>0?` · ${o.cohort.excluded_count} excluded`:""]}),s.jsx("span",{className:"font-mono",children:o.window.timezone})]}),s.jsx("section",{className:"grid gap-2 sm:grid-cols-2 xl:grid-cols-4","aria-label":"SLO reliability rates",children:fs.map(c=>s.jsx(vg,{definition:c,rate:o.rates[c.key]},c.key))}),s.jsxs("section",{"aria-labelledby":"slo-latency-heading",children:[s.jsx("h3",{id:"slo-latency-heading",className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted",children:"Latency percentiles"}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2 xl:grid-cols-4",children:yg.map(c=>s.jsx(jg,{label:c.label,latency:o.latencies[c.key]},c.key))})]}),s.jsxs("section",{"aria-labelledby":"slo-trend-heading",children:[s.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[s.jsx("h3",{id:"slo-trend-heading",className:"text-xs font-semibold uppercase tracking-wide text-muted",children:"Daily reliability trend"}),s.jsx("span",{className:"text-xs text-muted",children:"Percent of each daily cohort"})]}),s.jsx("div",{className:"h-64",role:"img","aria-label":"Daily SLO reliability rates chart",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(dl,{data:l,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"bucket",minTickGap:20,tick:{fontSize:11}}),s.jsx(sn,{domain:[0,100],tickFormatter:c=>`${c}%`,width:44}),s.jsx(Ur,{}),s.jsx(cn,{formatter:(c,u)=>{var d;return[c==null?"n/a":`${Number(c).toLocaleString(void 0,{maximumFractionDigits:2})}%`,((d=fs.find(h=>h.key===u))==null?void 0:d.label)??u]}}),fs.map(c=>s.jsx(ti,{type:"monotone",dataKey:c.key,name:c.label,stroke:c.color,strokeWidth:2,dot:{r:2},activeDot:{r:4},connectNulls:!1,isAnimationActive:!1},c.key))]})})})]})]})})}function vg({definition:e,rate:t}){const n=t.percent===null?"n/a":`${t.percent.toLocaleString(void 0,{maximumFractionDigits:2})}%`;return s.jsxs("div",{className:"rounded-md border border-border bg-slate-50/70 p-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-xs font-semibold text-muted",children:e.label}),s.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:e.color},"aria-hidden":!0})]}),s.jsx("strong",{className:"mt-2 block text-2xl leading-none",children:n}),s.jsxs("p",{className:"mt-2 text-xs text-muted",children:[t.numerator," / ",t.denominator," ",e.detail]}),t.missing_count>0?s.jsxs("p",{className:"mt-1 text-xs text-amber-700",children:[t.missing_count," missing sample",t.missing_count===1?"":"s"]}):null,e.key==="retry"&&t.requeued_runs?s.jsxs("p",{className:"mt-1 text-xs text-muted",children:[t.requeued_runs," requeued run",t.requeued_runs===1?"":"s"]}):null]})}function jg({label:e,latency:t}){return s.jsxs("div",{className:"rounded-md border border-border p-3",children:[s.jsx("h4",{className:"text-xs font-semibold text-muted",children:e}),s.jsxs("div",{className:"mt-3 grid grid-cols-3 gap-2 text-center",children:[s.jsx(xs,{label:"p50",value:t.p50}),s.jsx(xs,{label:"p90",value:t.p90}),s.jsx(xs,{label:"p99",value:t.p99})]}),s.jsxs("p",{className:"mt-3 text-xs text-muted",children:[t.sample_count," sample",t.sample_count===1?"":"s",t.missing_count>0?` · ${t.missing_count} missing`:""]})]})}function xs({label:e,value:t}){return s.jsxs("div",{children:[s.jsx("div",{className:"font-mono text-sm font-semibold",children:Xe(t)}),s.jsx("div",{className:"mt-0.5 text-[10px] font-semibold uppercase text-muted",children:e})]})}function kg({filters:e,actorOptions:t,onChange:n}){const[r,i]=R.useState(e);R.useEffect(()=>i(e),[e]);const a=qx(e),o=Vo(e)||Vo(r),l=()=>{i(Qs),n(Qs)};return s.jsxs("details",{className:"my-3 rounded-md border border-border bg-slate-50/70",children:[s.jsxs("summary",{className:"grid cursor-pointer list-none grid-cols-[minmax(0,1fr)_auto] items-center gap-3 px-3 py-2 text-sm font-semibold marker:hidden",children:[s.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-2",children:[s.jsx(sd,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"Filters"]}),a.length>0?s.jsx("span",{className:"flex min-w-0 flex-wrap items-center gap-1.5","aria-label":"Applied filters",children:a.map(c=>s.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full border border-blue-200 bg-blue-50 px-2 py-0.5 text-xs font-semibold text-blue-700",children:[s.jsx("span",{className:"text-blue-700/70",children:c.label}),s.jsx("span",{className:"max-w-40 truncate font-mono",children:c.value.trim()})]},c.key))}):null]}),s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-2",children:[o?s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-1.5 rounded-md border border-border bg-white px-2.5 text-xs font-semibold text-foreground hover:bg-slate-50",type:"button",onClick:c=>{c.preventDefault(),c.stopPropagation(),l()},children:[s.jsx(cr,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Clear filters"]}):null,s.jsx(Dn,{className:"h-4 w-4 text-muted","aria-hidden":!0})]})]}),s.jsxs("form",{className:"grid gap-3 border-t border-border bg-white p-3 md:grid-cols-3 xl:grid-cols-9",onSubmit:c=>{c.preventDefault(),n(r)},children:[s.jsx(ot,{label:"Status",children:s.jsxs("select",{className:"control",value:r.status,onChange:c=>i({...r,status:c.target.value}),children:[s.jsx("option",{value:"",children:"All"}),s.jsx("option",{value:"pending",children:"pending"}),s.jsx("option",{value:"running",children:"running"}),s.jsx("option",{value:"blocked",children:"blocked"}),s.jsx("option",{value:"done",children:"done"}),s.jsx("option",{value:"denied",children:"denied"}),s.jsx("option",{value:"waiting_approval",children:"waiting_approval"})]})}),s.jsx(ot,{label:"Repository",children:s.jsx("input",{className:"control",value:r.repo,placeholder:"owner/repo",onChange:c=>i({...r,repo:c.target.value})})}),s.jsx(ot,{label:"Thread",children:s.jsx("input",{className:"control",value:r.thread,inputMode:"numeric",placeholder:"issue or PR",onChange:c=>i({...r,thread:c.target.value})})}),s.jsx(ot,{label:"Action",children:s.jsx("input",{className:"control",value:r.action,placeholder:"reply_comment",onChange:c=>i({...r,action:c.target.value})})}),s.jsx(ot,{label:"Actor",className:"xl:col-span-2",children:s.jsx(Ng,{value:r.actor,options:t,onChange:c=>i({...r,actor:c})})}),s.jsx(ot,{label:"Intent",children:s.jsxs("select",{className:"control",value:r.intent,onChange:c=>i({...r,intent:c.target.value}),children:[s.jsx("option",{value:"",children:"All"}),s.jsx("option",{value:"review_only",children:"review_only"}),s.jsx("option",{value:"work_allowed",children:"work_allowed"})]})}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 self-end xl:col-span-2",children:[s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-white",type:"button",disabled:!o,onClick:l,children:[s.jsx(cr,{className:"h-4 w-4","aria-hidden":!0}),"Clear"]}),s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary px-3 text-sm font-semibold text-white",type:"submit",children:[s.jsx(ld,{className:"h-4 w-4","aria-hidden":!0}),"Apply"]})]})]})]})}function Ng({value:e,options:t,onChange:n}){const[r,i]=R.useState(!1),a=e.trim().replace(/^@/,"").toLowerCase(),o=t.filter(c=>!a||c.login.toLowerCase().includes(a)).slice(0,8),l=t.find(c=>c.login.toLowerCase()===a);return s.jsxs("div",{className:"relative min-w-0",children:[s.jsxs("div",{className:"control flex items-center gap-2 px-2",children:[l?s.jsx("img",{className:"h-5 w-5 shrink-0 rounded-full bg-slate-100",src:rt(l.avatar_url??""),alt:`${l.login} avatar`,referrerPolicy:"no-referrer"}):s.jsx(An,{className:"h-4 w-4 shrink-0 text-muted","aria-hidden":!0}),s.jsx("input",{className:"min-w-0 flex-1 bg-transparent font-mono text-sm outline-none",value:e,placeholder:"@login",onChange:c=>{n(c.target.value),i(!0)},onFocus:()=>i(!0),onBlur:()=>window.setTimeout(()=>i(!1),100)}),e?s.jsx("button",{className:"rounded-sm p-1 text-muted hover:bg-slate-100",type:"button","aria-label":"Clear actor filter",onClick:()=>n(""),children:s.jsx(un,{className:"h-3.5 w-3.5","aria-hidden":!0})}):null]}),r&&o.length>0?s.jsx("div",{className:"absolute left-0 right-0 z-20 mt-1 max-h-72 overflow-auto rounded-md border border-border bg-white p-1 shadow-lg",children:o.map(c=>s.jsxs("button",{className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-left hover:bg-slate-50",type:"button",onMouseDown:u=>u.preventDefault(),onClick:()=>{n(c.login),i(!1)},children:[c.avatar_url?s.jsx("img",{className:"h-6 w-6 shrink-0 rounded-full bg-slate-100",src:rt(c.avatar_url),alt:`${c.login} avatar`,referrerPolicy:"no-referrer"}):s.jsx(An,{className:"h-5 w-5 shrink-0 text-muted","aria-hidden":!0}),s.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",children:["@",c.login]}),s.jsx("span",{className:"shrink-0 rounded-full bg-slate-100 px-1.5 py-0.5 text-[10px] font-semibold text-muted",children:c.job_count})]},c.login))}):null]})}function ot({label:e,children:t,className:n}){return s.jsxs("label",{className:Q("grid min-w-0 gap-1 text-xs font-semibold text-muted",n),children:[e,t]})}function Sg({jobs:e,loading:t,loadingMore:n=!1,hasMore:r=!1,onLoadMore:i,onViewJob:a,now:o,user:l,onRetry:c,onDismiss:u,onCancel:d}){const[h,m]=R.useState(null),[p,w]=R.useState(null),[y,v]=R.useState(null),b=R.useRef(!1),N=R.useRef(n),k=!!(l!=null&&l.is_admin&&c),_=!!(l!=null&&l.is_admin&&u);R.useEffect(()=>{N.current&&!n&&(b.current=!1),N.current=n},[n]);const D=R.useCallback(()=>{b.current||(b.current=!0,i==null||i())},[i]),j=R.useCallback(async C=>{if(c){m(C);try{await c(C)}finally{m(null)}}},[c]),B=R.useCallback(async C=>{if(u){w(C);try{await u(C)}finally{w(null)}}},[u]),F=R.useCallback(async(C,M)=>{if(d){v(C);try{await d(C,M)}finally{v(null)}}},[d]);return t&&e.length===0?s.jsx(J,{text:"Loading jobs..."}):e.length===0?s.jsx(J,{text:"No jobs match the current filters."}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid gap-2 md:hidden",children:[e.map(C=>s.jsx(Pg,{job:C,onViewJob:a,now:o,canRetry:k&&Vs(C.status)&&C.decision==="auto_trusted",retrying:h===C.id,onRetry:j,canDismiss:_&&Gs(C.status),dismissing:p===C.id,onDismiss:B,canCancel:!!(d&&Js(C,l)),cancelling:y===C.id,onCancel:F},C.id)),s.jsx(Cg,{hasMore:r,loading:n,onLoadMore:D})]}),s.jsx(Xs,{noun:"jobs",hasMore:r,loading:n,onLoadMore:D,className:"hidden md:block",children:s.jsxs("table",{className:"min-w-[1080px] table-fixed border-collapse text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"sticky top-0 z-10 border-b border-border bg-panel text-left text-xs text-muted",children:[s.jsx("th",{className:"w-[42%] px-3 py-2 font-semibold",children:"Job"}),s.jsx("th",{className:"w-32 px-3 py-2 font-semibold",children:"Status"}),s.jsx("th",{className:"w-40 px-3 py-2 font-semibold",children:"Action"}),s.jsx("th",{className:"w-36 px-3 py-2 font-semibold",children:"Actor"}),s.jsx("th",{className:"w-36 px-3 py-2 font-semibold",children:"Timing"}),s.jsx("th",{className:"w-28 px-3 py-2 font-semibold",children:"Updated"}),s.jsx("th",{className:"w-24 px-3 py-2 text-right font-semibold",children:"Actions"})]})}),s.jsx("tbody",{children:e.map(C=>s.jsx(_g,{job:C,now:o,onViewJob:a,canRetry:k&&Vs(C.status)&&C.decision==="auto_trusted",retrying:h===C.id,onRetry:j,canDismiss:_&&Gs(C.status),dismissing:p===C.id,onDismiss:B,canCancel:!!(d&&Js(C,l)),cancelling:y===C.id,onCancel:F},C.id))})]})})]})}function _g({job:e,now:t,onViewJob:n,canRetry:r,retrying:i,onRetry:a,canDismiss:o,dismissing:l,onDismiss:c,canCancel:u,cancelling:d,onCancel:h}){return s.jsxs("tr",{className:"cursor-pointer border-b border-border align-top hover:bg-slate-50",onClick:()=>n(e.id),children:[s.jsx("td",{className:"min-w-0 px-3 py-3",children:s.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[s.jsxs("span",{className:"mt-0.5 shrink-0 font-mono text-xs font-semibold text-muted",children:["#",e.id]}),s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("div",{className:"line-clamp-2 text-sm font-semibold leading-snug text-foreground [overflow-wrap:anywhere]",title:e.subject,children:e.subject}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted",children:[s.jsx("span",{className:"min-w-0 max-w-full truncate font-mono",children:e.repo??e.work_key}),s.jsxs("span",{className:"shrink-0",children:["thread ",e.thread??"n/a"]})]})]})]})}),s.jsx("td",{className:"px-3 py-3",children:s.jsx(_i,{status:e.status})}),s.jsxs("td",{className:"px-3 py-3",children:[s.jsx("div",{className:"min-w-0 truncate text-sm text-foreground",title:e.action,children:e.action}),s.jsx("div",{className:"mt-1",children:s.jsx(Si,{intent:e.intent,actionMode:e.action_mode,display:"intent",compact:!0})})]}),s.jsx("td",{className:"px-3 py-3",children:s.jsx(Hn,{actor:e.trigger_actor,avatarUrl:e.trigger_actor_avatar_url})}),s.jsxs("td",{className:"px-3 py-3 text-xs text-muted",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{children:"wait"}),s.jsx("span",{className:"font-mono text-foreground",children:Xe(Ni(e,t))})]}),s.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[s.jsx("span",{children:"run"}),s.jsx("span",{className:"font-mono text-foreground",children:Xe(ki(e,t))})]}),s.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[s.jsx("span",{children:"tries"}),s.jsx("span",{className:"font-mono text-foreground",children:e.attempts})]})]}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs",children:s.jsx(ue,{value:e.updated_at,compact:!0,relative:!0,now:t})}),s.jsx("td",{className:"px-3 py-3 text-right",children:s.jsxs("div",{className:"inline-flex items-center gap-1",children:[s.jsx(Rc,{jobId:e.id,canRetry:r,retrying:i,onRetry:a,compact:!0}),s.jsx(Ic,{jobId:e.id,canDismiss:o,dismissing:l,onDismiss:c,compact:!0}),s.jsx(Tc,{jobId:e.id,canCancel:u,cancelling:d,onCancel:h,compact:!0})]})})]})}function Cg({hasMore:e,loading:t,onLoadMore:n}){return!e&&!t?null:s.jsxs("button",{className:"inline-flex min-h-10 w-full items-center justify-center gap-2 rounded-md border border-border px-3 py-2 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60 md:hidden",type:"button",disabled:t||!e,onClick:()=>n==null?void 0:n(),children:[s.jsx(Dn,{className:"h-4 w-4","aria-hidden":!0}),t?"Loading more jobs...":"Load more jobs"]})}function Pg({job:e,onViewJob:t,now:n,canRetry:r,retrying:i,onRetry:a,canDismiss:o,dismissing:l,onDismiss:c,canCancel:u,cancelling:d,onCancel:h}){return s.jsxs("article",{className:"rounded-md border border-border bg-white shadow-[0_1px_0_rgba(15,23,42,0.03)]",children:[s.jsxs("button",{className:"grid w-full gap-2 p-3 text-left hover:bg-slate-50",type:"button",onClick:()=>t(e.id),children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsxs("div",{className:"grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-2",children:[s.jsxs("span",{className:"shrink-0 font-mono text-xs font-semibold text-muted",children:["#",e.id]}),s.jsx("span",{className:"truncate font-mono text-sm",children:e.repo??e.work_key})]}),s.jsx("div",{className:"line-clamp-2 text-sm leading-snug text-foreground",children:e.subject}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted",children:[s.jsxs("span",{children:["thread ",e.thread??"n/a"," · ",e.action]}),s.jsx(Si,{intent:e.intent,actionMode:e.action_mode,compact:!0,display:"intent"}),s.jsx(Hn,{actor:e.trigger_actor,avatarUrl:e.trigger_actor_avatar_url})]})]}),s.jsx(_i,{status:e.status})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[s.jsx($,{label:"Wait",value:Xe(Ni(e,n))}),s.jsx($,{label:"Runtime",value:Xe(ki(e,n))}),s.jsx($,{label:"Updated",value:s.jsx(ue,{value:e.updated_at,compact:!0,relative:!0,now:n})})]})]}),r||o||u?s.jsxs("div",{className:"flex flex-wrap gap-2 border-t border-border px-3 py-2",children:[s.jsx(Rc,{jobId:e.id,canRetry:r,retrying:i,onRetry:a}),s.jsx(Ic,{jobId:e.id,canDismiss:o,dismissing:l,onDismiss:c}),s.jsx(Tc,{jobId:e.id,canCancel:u,cancelling:d,onCancel:h})]}):null]})}function Rc({jobId:e,canRetry:t,retrying:n,onRetry:r,compact:i=!1}){if(!t)return null;const a=n?"Retrying...":"Retry";return s.jsxs("button",{className:Q("inline-flex h-8 items-center justify-center gap-2 rounded-md border border-border text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60",i?"w-8 px-0":"px-3"),type:"button",disabled:n,"aria-label":`Retry job #${e}`,title:`Retry job #${e}`,onClick:async o=>{o.stopPropagation(),window.confirm(`Retry job #${e}?`)&&await r(e)},children:[s.jsx(cr,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{className:Q(i&&"sr-only"),children:a})]})}function Ic({jobId:e,canDismiss:t,dismissing:n,onDismiss:r,compact:i=!1}){if(!t)return null;const a=n?"Dismissing...":"Dismiss";return s.jsxs("button",{className:Q("inline-flex h-8 items-center justify-center gap-2 rounded-md border border-border text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60",i?"w-8 px-0":"px-3"),type:"button",disabled:n,"aria-label":`Dismiss job #${e}`,title:`Dismiss job #${e}`,onClick:async o=>{o.stopPropagation(),window.confirm(`Dismiss job #${e}?`)&&await r(e)},children:[s.jsx(On,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{className:Q(i&&"sr-only"),children:a})]})}function Tc({jobId:e,canCancel:t,cancelling:n,onCancel:r,compact:i=!1}){if(!t)return null;const a=n?"Cancelling...":"Cancel";return s.jsxs("button",{className:Q("inline-flex h-8 items-center justify-center gap-2 rounded-md border border-red-200 bg-red-50 text-sm font-semibold text-red-700 hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-60",i?"w-8 px-0":"px-3"),type:"button",disabled:n,"aria-label":`Cancel job #${e}`,title:`Cancel job #${e}`,onClick:async o=>{o.stopPropagation();const l=window.prompt(`Cancel job #${e}? Optional reason:`);l!==null&&await r(e,l)},children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{className:Q(i&&"sr-only"),children:a})]})}function Hn({actor:e,avatarUrl:t,framed:n=!1}){const r=t?s.jsx("img",{className:"h-4 w-4 shrink-0 rounded-full bg-slate-100",src:rt(t),alt:e?`${e} avatar`:"",referrerPolicy:"no-referrer"}):s.jsx(An,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),i=s.jsxs(s.Fragment,{children:[r,s.jsx("span",{className:"min-w-0 truncate",children:e?`@${e}`:"unknown actor"})]});return n?s.jsx("span",{className:"inline-flex h-7 max-w-full items-center gap-1 rounded-md border border-border px-2 text-xs font-semibold text-muted",children:i}):s.jsx("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1 font-mono text-xs text-muted",children:i})}function Eg(e){return(e==null?void 0:e.model)??"OpenClaw default"}function Rg(e){return(e==null?void 0:e.thinking)??"OpenClaw default"}function Ig(e){return e?e.configured?"configured":e.summary:"n/a"}function Tg(e,t){const n=t||(e==="work_allowed"?"fix_allowed":"review_only");return n==="fix_allowed"||!t&&e==="work_allowed"?{mode:n,intentLabel:"work_allowed",title:"Work allowed"}:{mode:n,intentLabel:"review_only",title:"Review only"}}function Si({intent:e,actionMode:t,compact:n=!1,display:r="mode"}){const i=Tg(e,t),a=i.intentLabel==="work_allowed"?cd:Il,o=r==="intent"?i.intentLabel:i.mode;return s.jsxs("span",{className:Q("inline-flex min-h-6 max-w-full items-center gap-1.5 rounded-md border px-2 text-xs font-semibold",i.intentLabel==="work_allowed"?"border-blue-200 bg-blue-50 text-blue-700":"border-violet-200 bg-violet-50 text-violet-700",n&&"min-h-5 px-1.5 text-[11px]"),title:`${i.title}: ${i.mode}`,"aria-label":`${i.title}: ${o}`,children:[s.jsx(a,{className:Q("h-3.5 w-3.5 shrink-0",n&&"h-3 w-3"),"aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono",children:o})]})}function Ag({job:e,session:t,sessionEvents:n,transcript:r,now:i,compact:a=!1}){var p;const o=Un(e.id),l=n??[],c=r??[],u=yx(l),d=wx(c),h=ki(e,i),m=Ni(e,i);return s.jsxs("div",{className:"grid min-w-0 gap-4",children:[s.jsxs("div",{className:"sticky top-0 z-20 -mx-3 -mt-3 grid gap-2 border-b border-border bg-panel/95 px-3 py-2 shadow-sm backdrop-blur sm:-mx-4 sm:-mt-4 sm:px-4","aria-label":"Sticky job header",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx(_i,{status:e.status}),s.jsxs("a",{className:"inline-flex h-7 items-center gap-1 rounded-md border border-border bg-white px-2 text-xs font-semibold text-foreground hover:bg-slate-50",href:o,children:[s.jsx(Fn,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Job #",e.id]}),s.jsx(Hn,{actor:e.trigger_actor,avatarUrl:e.trigger_actor_avatar_url,framed:!0}),s.jsx("span",{className:"min-w-0 break-words font-mono text-xs text-muted [overflow-wrap:anywhere]",children:e.work_key})]}),s.jsxs("div",{className:"grid min-w-0 gap-2 lg:grid-cols-[minmax(0,1fr)_minmax(280px,auto)] lg:items-start",children:[s.jsx("p",{className:"min-w-0 break-words text-sm text-muted [overflow-wrap:anywhere]",children:e.subject}),s.jsxs("div",{className:"grid min-w-0 gap-1",children:[s.jsx("h3",{className:"text-xs font-semibold text-muted",children:"GitHub links"}),e.github_urls.length>0?s.jsx(dr,{urls:e.github_urls,compact:!0}):s.jsx("p",{className:"text-xs text-muted",children:"No links recorded."})]})]})]}),s.jsxs("div",{className:Q("grid gap-2 text-sm sm:gap-3",a?"grid-cols-1":"grid-cols-3"),children:[s.jsx($,{label:"Queue wait",value:Xe(m)}),s.jsx($,{label:e.status==="running"?"Running for":"Runtime",value:Xe(h)}),s.jsx($,{label:"Coalesced",value:String(e.coalesced_count)})]}),e.queue_state==="serialized_by_work_key"?s.jsxs("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900",children:["Serialized behind running job #",e.blocked_by_job_id," for this work key."]}):null,s.jsxs("div",{className:Q("grid gap-2 text-sm sm:gap-3",a?"grid-cols-1":"grid-cols-3"),children:[s.jsx($,{label:"Model",value:Eg(e.model_route)}),s.jsx($,{label:"Reasoning",value:Rg(e.model_route)}),s.jsx($,{label:"Route",value:Ig(e.model_route)})]}),s.jsx(Lg,{job:e,compact:a}),s.jsxs("div",{className:Q("grid gap-2 text-sm sm:gap-3",a?"grid-cols-1":"grid-cols-2 xl:grid-cols-4"),children:[s.jsx($,{label:"Created",value:s.jsx(ue,{value:e.created_at,compact:!0,relative:!0,now:i})}),s.jsx($,{label:"Started",value:e.started_at?s.jsx(ue,{value:e.started_at,compact:!0,relative:!0,now:i}):"n/a"}),s.jsx($,{label:"Updated",value:s.jsx(ue,{value:e.updated_at,compact:!0,relative:!0,now:i})}),s.jsx($,{label:"Finished",value:e.finished_at?s.jsx(ue,{value:e.finished_at,compact:!0,relative:!0,now:i}):"n/a"})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"mb-2 text-sm font-semibold",children:"Timeline"}),s.jsx("div",{className:"grid min-w-0 gap-3",children:(e.worklog??[]).length>0?(p=e.worklog)==null?void 0:p.map(w=>s.jsxs("div",{className:"min-w-0 border-l-2 border-primary pl-3",children:[s.jsx("div",{className:"text-sm font-semibold",children:w.phase}),s.jsx("div",{className:"font-mono text-xs text-muted",children:s.jsx(ue,{value:w.ts,relative:!0,now:i})}),s.jsx("div",{className:"break-words text-sm [overflow-wrap:anywhere]",children:w.summary}),w.detail?s.jsx("div",{className:"mt-1 break-words font-mono text-xs text-muted [overflow-wrap:anywhere]",children:w.detail}):null]},w.id)):s.jsx(J,{text:"No worklog entries."})})]}),s.jsxs("div",{children:[s.jsxs("h3",{className:"mb-2 flex items-center gap-2 text-sm font-semibold",children:[s.jsx(Al,{className:"h-4 w-4","aria-hidden":!0}),"OpenClaw session"]}),t?s.jsxs("div",{className:"grid gap-3",children:[s.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[s.jsx($,{label:"Session ID",value:t.id}),s.jsx($,{label:"Source",value:t.source})]}),s.jsx("p",{className:"break-words text-xs text-muted [overflow-wrap:anywhere]",children:t.detail})]}):s.jsx(J,{text:"Session correlation is loading."})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"mb-2 text-sm font-semibold",children:"Agent activity"}),s.jsx("div",{className:"grid max-h-[460px] min-w-0 gap-2 overflow-auto pr-1",children:u.length>0?u.map((w,y)=>s.jsx(Dg,{event:w,defaultOpen:Qo(w.eventType,e.status==="running",y,u.length),now:i},w.id)):s.jsx(J,{text:e.status==="running"?"Waiting for live agent output...":"No agent activity has been recorded for this session."})})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"mb-2 text-sm font-semibold",children:"Session transcript"}),s.jsx("div",{className:"grid max-h-[620px] min-w-0 gap-2 overflow-auto pr-1",children:d.length>0?d.map((w,y)=>s.jsx(Mg,{entry:w,defaultOpen:Qo(w.kind,e.status==="running",y,d.length),now:i},w.id)):s.jsx(J,{text:e.status==="running"?"Waiting for live transcript entries...":"No OpenClaw transcript entries are available for this session."})})]})]})}function Lg({job:e,compact:t=!1}){const n=e.intent_classifier??null,r=(n==null?void 0:n.llm)??{},i=(n==null?void 0:n.parser)??{},a=typeof r.confidence=="number"?`${Math.round(r.confidence*100)}%`:"n/a";return s.jsxs("div",{className:"grid gap-2",children:[s.jsx("h3",{className:"text-sm font-semibold",children:"Action mode"}),s.jsxs("div",{className:Q("grid gap-2 text-sm sm:gap-3",t?"grid-cols-1":"grid-cols-2 xl:grid-cols-4"),children:[s.jsx($,{label:"Mode",value:s.jsx(Si,{intent:e.intent,actionMode:e.action_mode})}),s.jsx($,{label:"Intent",value:e.intent}),s.jsx($,{label:"Addressed",value:n?Jo(r.addressed_to_agent):"n/a"}),s.jsx($,{label:"Write",value:n?r.write_permission??"none":e.intent==="work_allowed"?"allowed":"none"})]}),n?s.jsxs("div",{className:"grid gap-2 rounded-md border border-border bg-panel p-3 text-xs",children:[s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(ht,{label:"Classifier",value:n.enabled?"enabled":"disabled"}),s.jsx(ht,{label:"Applied",value:Jo(r.applied)}),s.jsx(ht,{label:"Confidence",value:a}),s.jsx(ht,{label:"Parser",value:`${i.action??"n/a"} / ${i.work_intent??"n/a"}`})]}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[s.jsx(ht,{label:"LLM",value:`${r.action??"n/a"} / ${r.work_intent??"n/a"}`}),s.jsx(ht,{label:"Scope",value:r.scope||"n/a"})]}),r.main_request?s.jsx(ht,{label:"Main request",value:r.main_request}):null,r.subordinate_reason?s.jsx(ht,{label:"Subordinate reason",value:r.subordinate_reason}):null,r.reason?s.jsx(ht,{label:"Reason",value:r.reason}):null,n.error?s.jsx(ht,{label:"Error",value:n.error,tone:"danger"}):null]}):s.jsx("p",{className:"text-xs text-muted",children:"No intent classifier metadata recorded for this job."})]})}function Jo(e){return e===!0?"yes":e===!1?"no":"n/a"}function ht({label:e,value:t,tone:n="neutral"}){return s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted",children:e}),s.jsx("div",{className:Q("mt-0.5 min-w-0 break-words font-mono text-xs [overflow-wrap:anywhere]",n==="danger"?"text-red-700":"text-foreground"),children:t})]})}function Mg({entry:e,defaultOpen:t,now:n}){return s.jsx(Ac,{badge:e.badge,meta:s.jsx(ue,{value:e.meta,relative:!0,now:n}),count:e.count,summary:e.summary,defaultOpen:t,children:s.jsx("pre",{className:"max-h-72 max-w-full overflow-auto whitespace-pre-wrap break-words rounded bg-slate-950 px-2 py-1.5 font-mono text-xs leading-relaxed text-slate-100 [overflow-wrap:anywhere]",children:e.text})})}function Dg({event:e,defaultOpen:t,now:n}){return s.jsx(Ac,{badge:e.badge,meta:s.jsx(ue,{value:e.meta,relative:!0,now:n}),count:e.count,summary:e.summary,defaultOpen:t,children:e.detail?s.jsx("pre",{className:"max-h-56 max-w-full overflow-auto whitespace-pre-wrap break-words rounded bg-slate-950 px-2 py-1.5 font-mono text-xs leading-relaxed text-slate-100 [overflow-wrap:anywhere]",children:e.detail}):null})}function Ac({badge:e,meta:t,count:n,summary:r,defaultOpen:i,children:a}){const[o,l]=R.useState(!!i);return s.jsxs("details",{className:"group min-w-0 rounded border border-border bg-slate-50/60",open:o,onToggle:c=>l(c.currentTarget.open),children:[s.jsxs("summary",{className:"grid cursor-pointer list-none gap-1 px-2 py-1.5 marker:hidden hover:bg-white",children:[s.jsxs("div",{className:"grid min-w-0 gap-1 sm:flex sm:items-center sm:justify-between sm:gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(Dn,{className:"h-3.5 w-3.5 shrink-0 text-muted transition-transform group-open:rotate-180","aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono text-[11px] font-semibold text-muted",children:e}),n&&n>1?s.jsx("span",{className:"rounded-sm border border-border px-1 font-mono text-[10px] text-muted",children:n}):null]}),s.jsx("span",{className:"min-w-0 truncate pl-5 font-mono text-[11px] text-muted sm:shrink-0 sm:pl-0",children:t})]}),s.jsx("div",{className:"min-w-0 break-words pl-5 text-xs text-foreground [overflow-wrap:anywhere] sm:truncate",children:r})]}),s.jsx("div",{className:"min-w-0 border-t border-border bg-white px-2 py-2",children:a})]})}function Xo({label:e,values:t}){const n=[{name:"median",seconds:(t==null?void 0:t.median)??0},{name:"p90",seconds:(t==null?void 0:t.p90)??0},{name:"p99",seconds:(t==null?void 0:t.p99)??0}];return s.jsx("div",{className:"h-56",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(ei,{data:n,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"name"}),s.jsx(sn,{tickFormatter:Xe}),s.jsx(cn,{formatter:r=>[Xe(Number(r)),e]}),s.jsx(Bt,{dataKey:"seconds",fill:"#0969da",radius:[4,4,0,0]})]})})})}function Og({usage:e,jobsByCreatedDay:t,loading:n,totalJobs:r}){const[i,a]=R.useState("day"),o=(e==null?void 0:e[i])??[],l=Fg(e,t,i),c=o.reduce((d,h)=>d+h.seconds,0),u=o.reduce((d,h)=>d+(h.runs??h.jobs),0);return n&&l.length===0?s.jsx(J,{text:"Loading runtime and job history..."}):l.length===0?s.jsx(J,{text:r>0?"No jobs have valid runtime or creation dates.":"No job history available."}):s.jsxs("div",{className:"grid gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted",children:[s.jsx(Ll,{className:"h-4 w-4","aria-hidden":!0}),s.jsxs("span",{children:[tt(c)," consumed across ",u," run",u===1?"":"s"]})]}),s.jsx("div",{className:"inline-flex h-8 rounded-md border border-border bg-white p-0.5","aria-label":"Runtime grouping",children:["day","month"].map(d=>s.jsx("button",{className:Q("rounded px-2.5 text-xs font-semibold capitalize",i===d?"bg-primary text-white":"text-muted hover:bg-slate-50"),type:"button",onClick:()=>a(d),children:d},d))})]}),s.jsx("div",{className:"h-64",role:"img","aria-label":"Runtime and jobs activity chart",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(ou,{data:l,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"label",minTickGap:16,tick:{fontSize:11}}),s.jsx(sn,{yAxisId:"runtime",tickFormatter:d=>tt(Number(d))}),s.jsx(sn,{yAxisId:"jobs",orientation:"right",allowDecimals:!1}),s.jsx(Ur,{}),s.jsx(cn,{formatter:(d,h)=>h==="Work"?[tt(Number(d)),"work"]:h==="Review"?[tt(Number(d)),"review"]:h==="Jobs"?[Number(d),"jobs"]:[Number(d),String(h)],labelFormatter:d=>String(d)}),s.jsx(Bt,{yAxisId:"runtime",dataKey:"work_seconds",name:"Work",stackId:"runtime",fill:"#0969da",isAnimationActive:!1}),s.jsx(Bt,{yAxisId:"runtime",dataKey:"review_seconds",name:"Review",stackId:"runtime",fill:"#8250df",radius:[4,4,0,0],isAnimationActive:!1}),s.jsx(ti,{yAxisId:"jobs",type:"monotone",dataKey:"jobs",name:"Jobs",stroke:"#16a34a",strokeWidth:2,dot:{r:3},activeDot:{r:5},isAnimationActive:!1})]})})})]})}function Fg(e,t,n){const r=new Map;for(const a of(e==null?void 0:e[n])??[])r.set(a.bucket,{...a});const i=new Map;for(const[a,o]of Object.entries(t??{})){const l=n==="month"?a.slice(0,7):a;i.set(l,(i.get(l)??0)+o)}for(const a of i.keys())r.has(a)||r.set(a,zg(a));return[...r.values()].sort((a,o)=>a.bucket.localeCompare(o.bucket)).map(a=>({...a,jobs:i.get(a.bucket)??0,label:Wg(a.bucket,n)}))}function zg(e){return{bucket:e,seconds:0,minutes:0,runs:0,jobs:0,work_seconds:0,review_seconds:0,work_runs:0,review_runs:0,work_jobs:0,review_jobs:0}}const Lc=[{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"},{value:"all",label:"All time"}],qg=2,Rr=["#0969da","#8250df","#1a7f37","#bf8700","#cf222e","#0550ae","#6e40c9","#0a7f68"];function Bg({usage:e,loading:t,totalJobs:n,window:r,onWindowChange:i}){const a=e??[],o=a.reduce((l,c)=>l+c.seconds,0);return s.jsxs("div",{className:"grid gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[a.length>0?s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted",children:[s.jsx(An,{className:"h-4 w-4","aria-hidden":!0}),s.jsxs("span",{children:[tt(o)," consumed across ",a.length," user",a.length===1?"":"s"]})]}):s.jsx("span",{}),s.jsx("div",{className:"inline-flex h-8 rounded-md border border-border bg-white p-0.5",role:"group","aria-label":"Runtime by user window",children:Lc.map(l=>s.jsx("button",{className:Q("rounded px-2.5 text-xs font-semibold",r===l.value?"bg-primary text-white":"text-muted hover:bg-slate-50"),type:"button","aria-label":l.label,"aria-pressed":r===l.value,onClick:()=>i(l.value),children:l.value==="all"?"All":l.value},l.value))})]}),t&&a.length===0?s.jsx(J,{text:"Loading runtime by user..."}):a.length===0?s.jsx(J,{text:n>0?"No jobs have recorded user runtime in this window.":"No job history available."}):s.jsx("div",{className:"overflow-x-auto",role:"img","aria-label":"Runtime usage by user chart",children:s.jsx("div",{className:"h-64",style:{minWidth:`${Math.max(720,a.length*112)}px`},children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(ei,{data:a,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"actor",interval:0,height:68,tick:s.jsx(Kg,{usage:a}),tickLine:!1}),s.jsx(sn,{tickFormatter:l=>tt(Number(l))}),s.jsx(Ur,{}),s.jsx(cn,{formatter:(l,c)=>[tt(Number(l)),String(c).toLowerCase()],labelFormatter:l=>l==="unknown"?"unknown":`@${String(l)}`}),s.jsx(Bt,{dataKey:"work_seconds",name:"Work",stackId:"runtime",fill:"#0969da",isAnimationActive:!1}),s.jsx(Bt,{dataKey:"review_seconds",name:"Review",stackId:"runtime",fill:"#8250df",radius:[4,4,0,0],isAnimationActive:!1})]})})})})]})}function $g({usage:e,loading:t,totalJobs:n,window:r,onWindowChange:i}){const a=e??[],o=a.reduce((c,u)=>c+u.seconds,0),l=Ug(a);return s.jsxs("div",{className:"grid gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[a.length>0?s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted",children:[s.jsx(Ll,{className:"h-4 w-4","aria-hidden":!0}),s.jsxs("span",{children:[tt(o)," consumed across ",a.length," repositor",a.length===1?"y":"ies"]})]}):s.jsx("span",{}),s.jsx("div",{className:"inline-flex h-8 rounded-md border border-border bg-white p-0.5",role:"group","aria-label":"Runtime by repository window",children:Lc.map(c=>s.jsx("button",{className:Q("rounded px-2.5 text-xs font-semibold",r===c.value?"bg-primary text-white":"text-muted hover:bg-slate-50"),type:"button","aria-label":c.label,"aria-pressed":r===c.value,onClick:()=>i(c.value),children:c.value==="all"?"All":c.value},c.value))})]}),t&&a.length===0?s.jsx(J,{text:"Loading runtime by repository..."}):a.length===0?s.jsx(J,{text:n>0?"No jobs have recorded repository runtime in this window.":"No job history available."}):s.jsxs("div",{className:"grid items-center gap-4 md:grid-cols-[minmax(0,1fr)_minmax(240px,0.8fr)]",role:"img","aria-label":"Runtime usage by repository chart",children:[s.jsx("div",{className:"h-72 min-w-0",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(lu,{children:[s.jsx(cu,{data:l,dataKey:"seconds",nameKey:"repo",innerRadius:"54%",outerRadius:"86%",paddingAngle:1,stroke:"#ffffff",strokeWidth:2,labelLine:!1,label:({percent:c})=>$r((c??0)*100),isAnimationActive:!1,children:l.map((c,u)=>s.jsx(uu,{fill:c.repo==="Other"?"#94a3b8":Rr[u%Rr.length]},c.repo))}),s.jsx(cn,{content:s.jsx(Hg,{totalSeconds:o})})]})})}),s.jsx("ul",{className:"grid min-w-0 gap-2","aria-label":"Repository runtime percentages",children:l.map((c,u)=>s.jsxs("li",{className:"grid min-w-0 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 text-sm",children:[s.jsx("span",{className:"h-3 w-3 rounded-sm",style:{backgroundColor:c.repo==="Other"?"#94a3b8":Rr[u%Rr.length]},"aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono text-xs",title:c.repo,children:c.repo==="Other"?`Other (${c.repositories.length})`:c.repo}),s.jsx("span",{className:"font-semibold tabular-nums",children:$r(c.percentage)})]},c.repo))})]})]})}function Ug(e){const t=e.filter(a=>a.seconds>0).sort((a,o)=>o.seconds-a.seconds),n=t.reduce((a,o)=>a+o.seconds,0);if(n<=0)return[];const r=[],i=[];for(const a of t){const o=a.seconds/n*100;o0){const a=i.reduce((o,l)=>({repo:"Other",seconds:o.seconds+l.seconds,minutes:o.minutes+l.minutes,runs:o.runs+l.runs,work_seconds:o.work_seconds+l.work_seconds,review_seconds:o.review_seconds+l.review_seconds,work_runs:o.work_runs+l.work_runs,review_runs:o.review_runs+l.review_runs}),{repo:"Other",seconds:0,minutes:0,runs:0,work_seconds:0,review_seconds:0,work_runs:0,review_runs:0});r.push({...a,percentage:a.seconds/n*100,repositories:i})}return r}function Hg({active:e,payload:t,totalSeconds:n}){var i;const r=(i=t==null?void 0:t[0])==null?void 0:i.payload;return!e||!r?null:s.jsxs("div",{className:"min-w-56 rounded-md border border-border bg-white p-3 text-xs shadow-lg",children:[s.jsx("div",{className:"font-mono font-semibold text-foreground",children:r.repo==="Other"?`Other (${r.repositories.length} repositor${r.repositories.length===1?"y":"ies"})`:r.repo}),s.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-x-4 gap-y-1 text-muted",children:[s.jsx("span",{children:"Total"}),s.jsxs("span",{className:"text-right font-semibold text-foreground",children:[tt(r.seconds)," · ",$r(r.seconds/n*100)]}),s.jsx("span",{children:"Work"}),s.jsx("span",{className:"text-right text-foreground",children:tt(r.work_seconds)}),s.jsx("span",{children:"Review"}),s.jsx("span",{className:"text-right text-foreground",children:tt(r.review_seconds)}),s.jsx("span",{children:"Runs"}),s.jsx("span",{className:"text-right text-foreground",children:r.runs})]}),r.repo==="Other"?s.jsx("div",{className:"mt-2 max-h-40 overflow-auto border-t border-border pt-2",children:r.repositories.map(a=>s.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-3 py-0.5",children:[s.jsx("span",{className:"truncate font-mono",title:a.repo,children:a.repo}),s.jsxs("span",{className:"tabular-nums text-muted",children:[$r(a.seconds/n*100)," · ",tt(a.seconds)]})]},a.repo))}):null]})}function $r(e){return`${e.toFixed(1)}%`}function Kg({x:e=0,y:t=0,payload:n,usage:r}){const i=String((n==null?void 0:n.value)??"unknown"),a=r.find(h=>h.actor===i),o=Qg(a),l=i==="unknown"?"unknown user":`@${i}`,c=i==="unknown"?"unknown":`@${i}`,u=c.length>18?`${c.slice(0,17)}…`:c,d=R.useId().replace(/:/g,"");return s.jsxs("g",{transform:`translate(${e},${t})`,children:[s.jsx("title",{children:l}),s.jsx("defs",{children:s.jsx("clipPath",{id:d,children:s.jsx("circle",{cx:"0",cy:"18",r:"14"})})}),s.jsx("circle",{cx:"0",cy:"18",r:"14",fill:"#f1f5f9",stroke:"#cbd5e1"}),o?s.jsx("image",{x:"-14",y:"4",width:"28",height:"28",href:o,clipPath:`url(#${d})`,preserveAspectRatio:"xMidYMid slice",role:"img","aria-label":`${l} avatar`}):s.jsx("text",{x:"0",y:"22",textAnchor:"middle",fontSize:"12",fill:"#64748b","aria-label":l,children:"?"}),s.jsx("text",{x:"0",y:"49",textAnchor:"middle",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"11",fontWeight:"600",fill:"#475569",children:u})]})}function Qg(e){if(!e)return null;const t=rt(e.avatar_url??"");return t!=="#"?t:!e.actor||e.actor==="unknown"?null:`https://github.com/${encodeURIComponent(e.actor)}.png?size=80`}function Wg(e,t){if(t==="month"){const[a,o]=e.split("-").map(Number);return!a||!o?e:new Intl.DateTimeFormat(void 0,{month:"short",year:"numeric"}).format(new Date(a,o-1,1))}const[n,r,i]=e.split("-").map(Number);return!n||!r||!i?e:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(n,r-1,i))}function tt(e){const t=Math.max(0,Math.round(e));if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const r=Math.floor(n/60),i=n%60;return i===0?`${r}h`:`${r}h ${i}m`}function gs(e){return Object.values(e).reduce((t,n)=>t+n,0)}function Vg({data:e,loading:t}){if(t&&!e)return s.jsx(J,{text:"Loading systemd units..."});if(!e)return s.jsx(J,{text:"No systemd snapshot available."});const n=e.units??[],r=n.filter(o=>o.active_state==="active").length,i=n.filter(o=>o.active_state==="failed"||o.result==="failed").length,a=n.filter(o=>o.kind==="timer").length;return s.jsxs("div",{className:"grid min-w-0 gap-3",children:[e.errors.length>0?s.jsx(be,{tone:"error",text:e.errors[0]}):null,n.length===0?s.jsx(J,{text:"No configured bridge units found."}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[s.jsx(Ir,{label:"Units",value:String(n.length)}),s.jsx(Ir,{label:"Active",value:String(r)}),s.jsx(Ir,{label:"Failed",value:String(i),tone:i>0?"bad":"neutral"}),s.jsx(Ir,{label:"Timers",value:String(a)})]}),s.jsxs("div",{className:"overflow-hidden rounded-md border border-border bg-white",children:[s.jsxs("div",{className:"hidden grid-cols-[minmax(0,1.35fr)_90px_120px_90px_minmax(0,1fr)] gap-3 border-b border-border bg-slate-50 px-3 py-2 text-[11px] font-semibold uppercase text-muted md:grid",children:[s.jsx("span",{children:"Unit"}),s.jsx("span",{children:"Status"}),s.jsx("span",{children:"State"}),s.jsx("span",{children:"PID"}),s.jsx("span",{children:"Schedule"})]}),s.jsx("div",{className:"divide-y divide-border",children:n.map(o=>s.jsx(Gg,{unit:o},o.unit))})]})]})]})}function Ir({label:e,value:t,tone:n="neutral"}){return s.jsxs("div",{className:Q("min-w-0 rounded-md border bg-white px-3 py-2",n==="bad"?"border-red-200":"border-border"),children:[s.jsx("div",{className:Q("font-mono text-lg font-semibold",n==="bad"?"text-red-700":"text-foreground"),children:t}),s.jsx("div",{className:"mt-0.5 text-[11px] font-semibold uppercase text-muted",children:e})]})}function Gg({unit:e}){const[t,n]=R.useState(!1),r=e.active_state==="active",i=e.active_state==="failed"||e.result==="failed",a=e.next_elapse||e.last_trigger||"n/a";return s.jsxs("details",{className:"group min-w-0",open:t,onToggle:o=>n(o.currentTarget.open),children:[s.jsxs("summary",{className:"grid min-w-0 cursor-pointer list-none grid-cols-2 gap-2 px-3 py-3 text-sm marker:hidden hover:bg-slate-50 md:grid-cols-[minmax(0,1.35fr)_90px_120px_90px_minmax(0,1fr)] md:items-center md:gap-3",children:[s.jsxs("div",{className:"col-span-2 min-w-0 md:col-span-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(Dn,{className:"h-3.5 w-3.5 shrink-0 text-muted transition-transform group-open:rotate-180","aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono text-xs font-semibold text-foreground",children:e.unit})]}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 pl-5 text-[11px] font-semibold uppercase text-muted",children:[s.jsx("span",{children:e.role}),s.jsx("span",{children:e.kind}),s.jsx("span",{children:e.load_state}),s.jsx("span",{children:t?"following log":"expand log"})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 md:block",children:[s.jsx("span",{className:"text-[11px] font-semibold uppercase text-muted md:hidden",children:"Status"}),s.jsx("span",{className:Q("inline-flex h-6 items-center rounded-full border px-2 text-xs font-semibold",i?"border-red-300 bg-red-50 text-red-700":r?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-slate-300 bg-slate-50 text-slate-700"),children:e.active_state})]}),s.jsx(Yo,{label:"State",value:e.sub_state,detail:e.result||"unknown"}),s.jsx(Yo,{label:"PID",value:e.main_pid?String(e.main_pid):"n/a",detail:Xe(e.uptime_seconds)}),s.jsxs("div",{className:"col-span-2 min-w-0 md:col-span-1",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted md:hidden",children:"Schedule"}),s.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",title:a,children:e.next_elapse?`next ${e.next_elapse}`:a})]})]}),s.jsx("div",{className:"border-t border-border bg-slate-50 px-3 pb-3 pt-2",children:s.jsx(Jg,{unit:e.unit,active:t})})]})}function Yo({label:e,value:t,detail:n}){return s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted md:hidden",children:e}),s.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",children:t}),n?s.jsx("div",{className:"truncate font-mono text-[11px] text-muted",children:n}):null]})}function Jg({unit:e,active:t}){const[n,r]=R.useState([]),[i,a]=R.useState(""),o=R.useRef(null);return R.useEffect(()=>{if(!t){r([]),a("");return}r([]),a("");const l=new EventSource(`/api/systemd/journal/stream?unit=${encodeURIComponent(e)}`);return l.addEventListener("journal_line",c=>{const u=Br(c);u&&r(d=>[...d.slice(-199),u])}),l.addEventListener("journal_error",c=>{const u=Br(c);a((u==null?void 0:u.error)??"journal stream failed")}),l.onerror=()=>{},()=>l.close()},[t,e]),R.useEffect(()=>{const l=o.current;l&&(l.scrollTop=l.scrollHeight)},[n]),s.jsxs("div",{className:"grid min-w-0 gap-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted",children:"Live journal"}),s.jsx("div",{className:"mt-0.5 truncate font-mono text-[11px] text-muted",children:n.length>0?`${n.length} lines streamed`:"waiting for journal output"})]}),s.jsx("div",{className:"font-mono text-[11px] text-muted",children:"journalctl -f"})]}),i?s.jsx(be,{tone:"error",text:i}):null,s.jsx("div",{ref:o,className:"h-72 overflow-auto rounded-md border border-slate-800 bg-slate-950 p-3 font-mono text-xs leading-relaxed text-slate-100",children:n.length>0?n.map((l,c)=>s.jsx("div",{className:"break-words [overflow-wrap:anywhere]",children:l.line},`${l.unit}-${c}`)):s.jsx("div",{className:"text-slate-400",children:"No journal lines received yet."})})]})}function Xg({data:e,loading:t}){var h,m,p,w,y,v;if(t&&!e)return s.jsx(J,{text:"Loading process activity..."});if(!e)return s.jsx(J,{text:"No process snapshot available."});const n=e.executor.children??[],r=n.flatMap(b=>Dc(b)),i=r.reduce((b,N)=>b+N.cpu_ticks,0),a=r.reduce((b,N)=>b+Zg(N),0),o=e.executor.service==="active",l=r.slice(0,8).map(b=>({label:`pid ${b.pid}`,ticks:b.cpu_ticks})),c=(e.samples??[]).map(b=>({label:ir(b.ts),ticks:b.cpu_ticks,io:b.io_bytes,active:b.active_since_last_sample?"active":"quiet"})),u=c.length>0?c:l,d=(h=e.samples)==null?void 0:h[e.samples.length-1];return s.jsxs("div",{className:"grid gap-4",children:[s.jsx("div",{className:"rounded-md border border-slate-200 bg-slate-50 p-3",children:s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:Q("inline-flex h-6 items-center rounded-full border px-2 text-xs font-semibold",o?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-slate-300 bg-white text-slate-600"),children:o?"active":"idle"}),s.jsxs("span",{className:"font-mono text-xs text-muted",children:["service ",e.executor.service]})]}),s.jsx("div",{className:"mt-2 text-sm font-semibold text-foreground",children:e.running_jobs.length>0?`${e.running_jobs.length} running job${e.running_jobs.length===1?"":"s"}`:"No running jobs"}),e.running_jobs.length>0?s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:e.running_jobs.slice(0,4).map(b=>s.jsxs("span",{className:"inline-flex min-h-6 items-center gap-1.5 rounded-full border border-blue-200 bg-white px-2 font-mono text-[11px] font-semibold text-blue-700",children:[s.jsx("span",{className:"h-2 w-2 rounded-full bg-blue-600 animate-live-pulse","aria-hidden":!0}),"#",b.id," ",Xe(b.age_seconds)]},b.id))}):null,d?s.jsxs("p",{className:"mt-1 text-xs text-muted",children:["Last persisted sample ",ir(d.ts)," · ",d.active_since_last_sample?"activity observed":`quiet ${Xe(d.idle_seconds)}`]}):null,s.jsx("p",{className:"mt-1 text-xs text-muted",children:e.detail})]}),s.jsxs("div",{className:"grid min-w-[190px] grid-cols-3 gap-2 text-center text-xs",children:[s.jsx(bs,{label:"PID",value:e.executor.pid?String(e.executor.pid):"n/a"}),s.jsx(bs,{label:"Children",value:String(r.length)}),s.jsx(bs,{label:"CPU ticks",value:String(i)})]})]})}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[s.jsx(Tr,{label:"Live process",value:((m=e.signals)==null?void 0:m.live_process.state)??(r.length>0?"live":"no_child_process"),detail:`${((p=e.signals)==null?void 0:p.live_process.child_count)??r.length} children`}),s.jsx(Tr,{label:"Process activity",value:((w=e.signals)==null?void 0:w.process_activity.state)??(d!=null&&d.active_since_last_sample?"active":"quiet"),detail:d?`sample ${ir(d.ts)}`:"no sample"}),s.jsx(Tr,{label:"Semantic progress",value:(y=e.signals)!=null&&y.semantic_progress.length?"recent":"none",detail:Zo(e.running_jobs,"semantic_progress")}),s.jsx(Tr,{label:"Visible progress",value:(v=e.signals)!=null&&v.visible_progress.length?"streaming":"none",detail:Zo(e.running_jobs,"visible_progress")})]}),e.alerts.length>0?s.jsx(be,{tone:"error",text:e.alerts[0]}):null,s.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[s.jsxs("div",{className:"min-w-0 rounded-md border border-border p-3",children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[s.jsxs("h3",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(ro,{className:"h-4 w-4","aria-hidden":!0}),c.length>0?"CPU history":"CPU ticks"]}),s.jsxs("span",{className:"font-mono text-xs text-muted",children:[Oc(a)," I/O"]})]}),u.length>0?s.jsx("div",{className:"h-40",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(dl,{data:u,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"label",tick:!1}),s.jsx(sn,{allowDecimals:!1,tick:{fontSize:11}}),s.jsx(cn,{formatter:b=>[Number(b),"cpu ticks"]}),s.jsx(ti,{type:"monotone",dataKey:"ticks",stroke:"#0f766e",strokeWidth:2,dot:{r:3},activeDot:{r:5},isAnimationActive:!1})]})})}):s.jsx(J,{text:"No executor CPU samples available."})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("h3",{className:"mb-2 flex items-center gap-2 text-sm font-semibold",children:[s.jsx(ro,{className:"h-4 w-4","aria-hidden":!0}),"Executor children"]}),n.length>0?s.jsx("div",{className:"grid gap-2",children:n.map(b=>s.jsx(Mc,{process:b},b.pid))}):s.jsx(J,{text:"No child process detected for the executor."})]})]})]})}function Yg({alerts:e,loading:t,now:n}){if(t&&!e)return s.jsx(J,{text:"Loading monitor alerts..."});const r=e??[];return r.length===0?s.jsx(J,{text:"No active monitor alerts."}):s.jsx("div",{className:"grid gap-2",children:r.slice(0,5).map(i=>s.jsxs("div",{className:"rounded-md border border-red-200 bg-red-50 p-2.5",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs font-semibold text-red-700",children:[s.jsx(Hr,{className:"h-3.5 w-3.5","aria-hidden":!0}),s.jsx("span",{children:i.severity}),s.jsx("span",{className:"font-normal text-red-600",children:vc(i.last_seen,n)}),i.observations>1?s.jsxs("span",{className:"rounded-full border border-red-200 bg-white px-1.5",children:[i.observations,"x"]}):null]}),s.jsx("p",{className:"mt-1 break-words text-sm font-medium text-red-950 [overflow-wrap:anywhere]",children:i.message})]},i.fingerprint))})}function Mc({process:e}){var r,i;const t=((r=e.io_bytes)==null?void 0:r.read_bytes)??0,n=((i=e.io_bytes)==null?void 0:i.write_bytes)??0;return s.jsxs("div",{className:"rounded-md border border-border bg-white p-2.5",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[s.jsxs("span",{className:"font-mono",children:["pid ",e.pid]}),s.jsxs("span",{className:"rounded-full border border-border px-2 text-xs text-muted",children:["state ",e.state]}),s.jsxs("span",{className:"rounded-full border border-border px-2 text-xs text-muted",children:["cpu ",e.cpu_ticks]}),s.jsxs("span",{className:"rounded-full border border-border px-2 text-xs text-muted",children:["I/O ",Oc(t+n)]})]}),s.jsx("div",{className:"mt-2 break-words font-mono text-xs text-muted",children:e.cmd||"unknown command"}),e.children&&e.children.length>0?s.jsx("div",{className:"mt-3 border-l-2 border-border pl-3",children:e.children.map(a=>s.jsx(Mc,{process:a},a.pid))}):null]})}function bs({label:e,value:t}){return s.jsxs("div",{className:"rounded-md border border-border bg-white px-2 py-2",children:[s.jsx("div",{className:"font-mono text-sm font-semibold text-foreground",children:t}),s.jsx("div",{className:"mt-0.5 text-[11px] font-semibold uppercase text-muted",children:e})]})}function Tr({label:e,value:t,detail:n}){return s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-2.5",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted",children:e}),s.jsx("div",{className:"mt-1 truncate text-sm font-semibold text-foreground",children:t}),s.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-muted",children:n})]})}function Zo(e,t){const n=e.find(i=>i[t]),r=n==null?void 0:n[t];return!n||!r?"no running heartbeat":`#${n.id} ${r.phase} ${Xe(r.age_seconds??null)}`}function Dc(e){return[e,...(e.children??[]).flatMap(t=>Dc(t))]}function Zg(e){var t,n;return(((t=e.io_bytes)==null?void 0:t.read_bytes)??0)+(((n=e.io_bytes)==null?void 0:n.write_bytes)??0)}function Oc(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(1)} MiB`}function $({label:e,value:t}){return s.jsxs("div",{className:"min-w-0 rounded-md border border-border p-3",children:[s.jsx("div",{className:"text-xs font-semibold text-muted",children:e}),s.jsx("div",{className:"mt-1 min-w-0 break-words text-sm [overflow-wrap:anywhere]",children:t})]})}function _i({status:e}){const t=vx(e),n=e==="running"||e==="pending";return s.jsxs("span",{className:Q("inline-flex min-h-6 items-center gap-1.5 rounded-full border px-2 text-xs font-semibold",t.badge),children:[s.jsx("span",{className:Q("h-2.5 w-2.5 rounded-full",t.dot,n&&"animate-live-pulse"),"aria-hidden":!0}),e]})}function J({text:e}){return s.jsx("div",{className:"rounded-md border border-dashed border-border p-6 text-center text-sm text-muted",children:e})}function be({tone:e,text:t}){return s.jsx("div",{className:Q("rounded-md border p-3 text-sm",e==="error"&&"border-red-300 bg-red-50 text-red-700",e==="warning"&&"border-amber-300 bg-amber-50 text-amber-800"),children:t})}function nt({onClick:e,compactOnMobile:t=!1}){return s.jsxs("button",{className:Q("inline-flex h-8 items-center justify-center gap-2 rounded-md border border-border text-sm font-semibold text-foreground hover:bg-slate-50",t?"w-8 px-0 sm:w-auto sm:px-3":"px-3"),onClick:e,type:"button","aria-label":"Refresh",children:[s.jsx(zn,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{className:Q(t&&"hidden sm:inline"),children:"Refresh"})]})}const el=document.getElementById("root");el&&xu.createRoot(el).render(s.jsx(R.StrictMode,{children:s.jsx(Hu,{client:ux,children:s.jsx(Bx,{})})})); +}`;return s.jsxs(se,{title:"Connect an agent",children:[i?s.jsx(be,{tone:"warning",text:"Set GITHUB_AGENT_BRIDGE_DASHBOARD_PUBLIC_URL, or forward X-Forwarded-* headers from the proxy, before connecting remote agents."}):null,s.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[s.jsxs("div",{className:"grid min-w-0 gap-3",children:[s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm font-semibold",children:[s.jsx(on,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"Public dashboard URL",s.jsx("span",{className:"rounded-sm border border-border bg-slate-50 px-1.5 py-0.5 font-mono text-[11px] font-normal text-muted",children:r})]}),s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Share this page URL with bridge admins only after it resolves to the external dashboard origin."}),s.jsx("pre",{className:"mt-3 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs text-slate-100",children:a})]}),s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(on,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"HTTP MCP endpoint"]}),s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Remote agents connect directly with a bearer token; no local `gab` binary is required on the agent host."}),s.jsx("pre",{className:"mt-3 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs text-slate-100",children:o})]})]}),s.jsxs("div",{className:"grid min-w-0 gap-3",children:[s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(Dr,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"Agent config"]}),s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Create a token below, then store the one-time secret as `GITHUB_AGENT_BRIDGE_MCP_TOKEN` for the agent."}),s.jsx("pre",{className:"mt-3 max-h-64 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs leading-relaxed text-slate-100",children:c})]}),s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(oi,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"Agent prompt"]}),s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Ask the agent to use the read-only bridge knowledge server before acting on repository work."}),s.jsx("pre",{className:"mt-3 max-h-40 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs leading-relaxed text-slate-100",children:"Use the github-agent-bridge MCP server for repository knowledge. Query list_repositories and list_knowledge before making repository decisions."})]})]})]})]})}function Cc({icon:e,title:t,subtitle:n,action:r}){return s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("h2",{className:"flex items-center gap-2 text-base font-semibold",children:[e,t]}),s.jsx("p",{className:"text-xs text-muted",children:n})]}),r]})}function fg({tokens:e,loading:t,now:n,ownerOptions:r,canManageOwners:i,revokingId:a,updatingOwnerId:o,onUpdateOwner:l,onRevoke:c}){return t&&e.length===0?s.jsx(J,{text:"Loading MCP tokens..."}):e.length===0?s.jsx(J,{text:"No active MCP tokens."}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"grid gap-2 md:hidden",children:e.map(u=>s.jsxs("article",{className:"grid min-w-0 gap-3 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"break-words text-sm font-semibold [overflow-wrap:anywhere]",children:u.name}),s.jsx("div",{className:"mt-1 break-all font-mono text-xs text-muted",children:u.id}),i?s.jsx(Go,{token:u,ownerOptions:r,disabled:o===u.id,onUpdateOwner:l}):u.user_login?s.jsxs("div",{className:"mt-1 text-xs text-muted",children:["Lifecycle owner: @",u.user_login]}):null]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[s.jsx($,{label:"Created",value:s.jsx(ue,{value:u.created_at,relative:!0,now:n})}),s.jsx($,{label:"Last used",value:u.last_used_at?s.jsx(ue,{value:u.last_used_at,relative:!0,now:n}):"never"})]}),s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-2 rounded-md border border-red-200 px-3 text-sm font-semibold text-red-700 hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:a===u.id,onClick:()=>c(u.id),children:[s.jsx(Ls,{className:"h-4 w-4","aria-hidden":!0}),a===u.id?"Revoking...":"Revoke"]})]},u.id))}),s.jsx("div",{className:"hidden overflow-auto rounded-md border border-border md:block",children:s.jsxs("table",{className:"min-w-full border-collapse text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border bg-slate-50 text-left text-xs text-muted",children:[s.jsx("th",{className:"px-3 py-2 font-semibold",children:"Name"}),s.jsx("th",{className:"px-3 py-2 font-semibold",children:"Lifecycle owner"}),s.jsx("th",{className:"px-3 py-2 font-semibold",children:"Created"}),s.jsx("th",{className:"px-3 py-2 font-semibold",children:"Last used"}),s.jsx("th",{className:"px-3 py-2 font-semibold",children:"ID"}),s.jsx("th",{className:"px-3 py-2 text-right font-semibold",children:"Actions"})]})}),s.jsx("tbody",{children:e.map(u=>s.jsxs("tr",{className:"border-b border-border last:border-b-0",children:[s.jsx("td",{className:"px-3 py-3 font-semibold",children:u.name}),s.jsx("td",{className:"px-3 py-3 text-xs text-muted",children:i?s.jsx(Go,{token:u,ownerOptions:r,disabled:o===u.id,onUpdateOwner:l}):u.user_login?`@${u.user_login}`:"unassigned"}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs",children:s.jsx(ue,{value:u.created_at,relative:!0,now:n})}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs",children:u.last_used_at?s.jsx(ue,{value:u.last_used_at,relative:!0,now:n}):"never"}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs text-muted",children:u.id}),s.jsx("td",{className:"px-3 py-3 text-right",children:s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-red-200 px-3 text-sm font-semibold text-red-700 hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:a===u.id,onClick:()=>c(u.id),children:[s.jsx(Ls,{className:"h-4 w-4","aria-hidden":!0}),a===u.id?"Revoking...":"Revoke"]})})]},u.id))})]})})]})}function Go({token:e,ownerOptions:t,disabled:n,onUpdateOwner:r}){const i=e.user_login??"";return s.jsx(Pc,{ariaLabel:`Lifecycle owner for ${e.name}`,value:i,ownerOptions:t,disabled:n||t.length===0,emptyLabel:"Select owner",size:"compact",onChange:a=>{!a||a===e.user_login||r(e.id,a)}})}function Pc({value:e,ownerOptions:t,disabled:n,onChange:r,ariaLabel:i,selectedSuffix:a,emptyLabel:o,size:l="default"}){const c=t.find(d=>d.login===e),u=c?`@${c.login}${(a==null?void 0:a(c))??""}`:o;return s.jsxs("div",{className:Q("relative flex min-w-0 items-center gap-2 rounded-md border border-border bg-panel text-foreground focus-within:border-primary focus-within:ring-1 focus-within:ring-primary",n?"opacity-60":"",l==="compact"?"h-8 w-44 max-w-full px-2":"h-9 w-full px-2.5"),children:[s.jsx("span",{className:Q("pointer-events-none flex shrink-0 items-center justify-center",l==="compact"?"h-5 w-5":"h-6 w-6"),children:c!=null&&c.avatar_url?s.jsx("img",{className:"h-full w-full rounded-full bg-slate-100",src:rt(c.avatar_url),alt:"",referrerPolicy:"no-referrer"}):s.jsx(An,{className:Q("text-muted",l==="compact"?"h-4 w-4":"h-5 w-5"),"aria-hidden":!0})}),s.jsx("span",{className:Q("pointer-events-none min-w-0 flex-1 truncate font-mono",c?"text-foreground":"text-muted",l==="compact"?"text-xs":"text-sm"),children:u}),s.jsxs("select",{className:"absolute inset-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed","aria-label":i,value:e,disabled:n,onChange:d=>r(d.target.value),children:[t.length===0||!e?s.jsx("option",{value:"",children:o}):null,t.map(d=>s.jsxs("option",{value:d.login,children:["@",d.login,(a==null?void 0:a(d))??""]},d.login))]}),s.jsx(Dn,{className:Q("pointer-events-none shrink-0 text-muted",l==="compact"?"h-3.5 w-3.5":"h-4 w-4"),"aria-hidden":!0})]})}function dr({urls:e,compact:t=!1}){const n=t?e.slice(0,2):e,r=e.length-n.length;return s.jsxs("div",{className:"flex min-w-0 max-w-full flex-wrap gap-1.5",children:[n.map(i=>s.jsxs("a",{className:Q("inline-flex max-w-full items-center gap-1 rounded-md border border-border font-semibold text-primary hover:bg-white hover:underline",t?"h-7 px-2 text-xs":"min-h-7 px-2 py-1 text-xs"),href:rt(i),"aria-label":i,rel:"noreferrer",target:"_blank",children:[s.jsx(on,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),s.jsx("span",{className:"truncate",children:t?xg(i):i})]},i)),r>0?s.jsxs("span",{className:"inline-flex h-7 items-center rounded-md border border-border px-2 font-mono text-xs text-muted",children:["+",r]}):null]})}function xg(e){try{const t=new URL(e);return t.pathname.replace(/^\//,"")+t.hash}catch{return e}}function Ec({scope:e,type:t,confidence:n,status:r,timestamp:i,now:a}){return s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-xs text-muted",children:[s.jsx("span",{className:"truncate font-mono font-semibold text-foreground",children:Nc(e)}),s.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 font-mono",children:t}),s.jsxs("span",{className:"rounded-sm border border-border px-1.5 py-0.5 font-mono",children:[Math.round(n*100),"%"]}),s.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 font-mono",children:r}),s.jsx("span",{className:"font-mono",children:s.jsx(ue,{value:i,relative:!0,now:a})})]})}function gg({user:e,loading:t}){const n=e!=null&&e.login?`@${e.login}`:t?"Loading profile...":"GitHub OAuth",r=e!=null&&e.is_admin?"admin":"read-only",i=e!=null&&e.avatar_url?s.jsx("img",{className:"h-10 w-10 rounded-full border border-slate-700 bg-slate-800",src:e.avatar_url,alt:e.login?`${e.login} avatar`:"",referrerPolicy:"no-referrer"}):s.jsx("span",{className:"inline-flex h-10 w-10 items-center justify-center rounded-full border border-slate-700 bg-slate-900",children:s.jsx(An,{className:"h-5 w-5","aria-hidden":!0})}),a=e!=null&&e.html_url?s.jsx("a",{className:"truncate font-semibold text-white hover:underline",href:rt(e.html_url),rel:"noreferrer",target:"_blank",children:n}):s.jsx("div",{className:"truncate font-semibold text-white",children:n});return s.jsxs("div",{className:"flex max-w-full shrink-0 items-center gap-3 text-sm text-slate-300","aria-label":e!=null&&e.login?`Signed in as ${e.login}`:"Dashboard account",children:[s.jsx(Tl,{className:"hidden h-4 w-4 shrink-0 sm:block","aria-hidden":!0}),s.jsxs("div",{className:"hidden min-w-0 text-right sm:block",children:[a,s.jsxs("div",{className:"text-xs text-slate-400",children:["Signed in · ",r]})]}),i,e!=null&&e.login?s.jsx("form",{action:"/auth/logout",method:"post",children:s.jsx("button",{className:"rounded-md border border-slate-700 px-2 py-1 text-xs font-semibold text-slate-300 hover:bg-slate-800 hover:text-white",type:"submit",children:"Sign out"})}):null]})}function bg({config:e,loading:t,onEnable:n,onDisable:r}){const[i,a]=R.useState(!1),[o,l]=R.useState(""),c=!!(e!=null&&e.status.enabled),u=typeof navigator<"u"&&typeof window<"u"&&Lr(),d=t||i||!(e!=null&&e.configured)||!u,h=u?e!=null&&e.configured?c?"Disable notifications":"Enable notifications":"Notifications not configured":"Notifications unavailable";return s.jsx("div",{className:"relative",children:s.jsx("button",{className:Q("inline-flex h-9 w-9 items-center justify-center rounded-md border text-sm font-semibold",c?"border-emerald-400 bg-emerald-50 text-emerald-700":"border-slate-700 bg-slate-900 text-slate-200",d&&"cursor-not-allowed opacity-60"),type:"button","aria-label":h,title:o||h,disabled:d,onClick:async()=>{a(!0),l("");try{c?await r():await n()}catch(m){l(m instanceof Error?m.message:String(m))}finally{a(!1)}},children:s.jsx(El,{className:Q("h-4 w-4",i&&"animate-live-pulse"),"aria-hidden":!0})})})}function yg({notification:e,onDismiss:t,onNavigate:n}){if(!e)return null;const r=e.title||"GitHub Agent Bridge",i=e.body||e.summary||"Bridge job finished",a=e.url||e.job_url||(e.job_id?Un(e.job_id):"/"),o=a.startsWith("/");return s.jsx("aside",{className:"fixed right-3 top-20 z-50 w-[min(calc(100vw-1.5rem),28rem)] rounded-md border border-emerald-300 bg-white shadow-xl shadow-slate-950/15","aria-live":"assertive","aria-label":"Bridge notification",children:s.jsxs("div",{className:"flex items-start gap-3 p-3",children:[s.jsx("div",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-emerald-50 text-emerald-700",children:s.jsx(El,{className:"h-4 w-4","aria-hidden":!0})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("h2",{className:"min-w-0 break-words text-sm font-semibold text-foreground",children:r}),s.jsx("button",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted hover:bg-slate-100 hover:text-foreground",type:"button","aria-label":"Dismiss notification",onClick:t,children:s.jsx(un,{className:"h-4 w-4","aria-hidden":!0})})]}),s.jsx("p",{className:"mt-1 min-w-0 break-words text-sm text-muted",children:i}),e.detail?s.jsx("p",{className:"mt-1 line-clamp-2 min-w-0 break-words text-xs text-muted",children:e.detail}):null,s.jsxs("button",{className:"mt-3 inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-2.5 text-xs font-semibold text-foreground hover:bg-slate-50",type:"button",onClick:()=>{t(),o?n(a):window.open(rt(a),"_blank","noopener,noreferrer")},children:[s.jsx(on,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Open"]})]})]})})}function wg({count:e,limit:t,loading:n,onRefresh:r}){return s.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3 rounded-lg border border-border bg-white px-3 py-3 shadow-sm md:px-4",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h2",{className:"text-base font-semibold",children:"Jobs"}),s.jsx("p",{className:"text-xs text-muted",children:n?"Refreshing latest jobs...":`Showing ${e} of the latest ${t} requested jobs`})]}),s.jsx(nt,{onClick:r,compactOnMobile:!0})]})}function se({title:e,action:t,children:n,className:r,flushHeader:i=!1}){return s.jsxs("section",{className:Q("min-w-0 rounded-lg border border-border bg-panel p-4 shadow-sm",r),children:[s.jsxs("div",{className:Q("flex flex-wrap items-center justify-between gap-3",!i&&"mb-4"),children:[s.jsx("h2",{className:"text-sm font-semibold",children:e}),t]}),n]})}function Ae({title:e,value:t,icon:n}){return s.jsxs("div",{className:"rounded-lg border border-border bg-panel p-3 shadow-sm md:p-4",children:[s.jsxs("div",{className:"flex items-center justify-between text-muted",children:[s.jsx("span",{className:"text-sm font-medium",children:e}),n]}),s.jsx("strong",{className:"mt-3 block text-2xl leading-none md:mt-4 md:text-3xl",children:t})]})}const vg=[{value:"24h",label:"24 hours"},{value:"7d",label:"7 days"},{value:"30d",label:"30 days"}],fs=[{key:"blocked",label:"Blocked",detail:"finished service jobs",color:"#dc2626"},{key:"no_op",label:"No-op",detail:"finished service jobs",color:"#7c3aed"},{key:"retry",label:"Retried",detail:"claimed service jobs",color:"#d97706"},{key:"coalescing",label:"Coalesced",detail:"ingested notifications",color:"#0284c7"}],jg=[{key:"source_received_to_queued",label:"Source → queue"},{key:"queued_to_claimed",label:"Queue → claim"},{key:"claimed_to_first_output",label:"Claim → first output"},{key:"claimed_to_done",label:"Claim → done"}];function kg({summary:e,loading:t,window:n,onWindowChange:r,onRefresh:i}){const a=s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("div",{className:"inline-flex h-8 rounded-md border border-border bg-white p-0.5",role:"group","aria-label":"SLO window",children:vg.map(c=>s.jsx("button",{className:Q("rounded px-2.5 text-xs font-semibold",n===c.value?"bg-primary text-white":"text-muted hover:bg-slate-50"),type:"button","aria-label":c.label,"aria-pressed":n===c.value,onClick:()=>r(c.value),children:c.value},c.value))}),s.jsx(nt,{onClick:i,compactOnMobile:!0})]});if(t&&!(e!=null&&e.slo))return s.jsx(se,{title:"Service SLOs",action:a,children:s.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 rounded-md border border-dashed border-border text-sm text-muted",children:[s.jsx(zn,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),"Loading SLO metrics…"]})});if((e==null?void 0:e.schema_ok)===!1)return s.jsx(se,{title:"Service SLOs",action:a,children:s.jsx(be,{tone:"warning",text:`SLO metrics are unavailable until the database schema is migrated${e.schema_error?`: ${e.schema_error}`:"."}`})});if(!(e!=null&&e.slo))return s.jsx(se,{title:"Service SLOs",action:a,children:s.jsx(J,{text:"No SLO read model is available."})});const o=e.slo,l=o.trends.daily.map(c=>({bucket:c.bucket,blocked:c.rates.blocked.percent,no_op:c.rates.no_op.percent,retry:c.rates.retry.percent,coalescing:c.rates.coalescing.percent}));return s.jsx(se,{title:"Service SLOs",action:a,children:s.jsxs("div",{className:"grid gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-1 text-xs text-muted",children:[s.jsxs("span",{children:[s.jsx("strong",{className:"text-foreground",children:o.cohort.sample_count})," finished auto-trusted service job",o.cohort.sample_count===1?"":"s",o.cohort.missing_count>0?` · ${o.cohort.missing_count} missing outcome`:"",o.cohort.excluded_count>0?` · ${o.cohort.excluded_count} excluded`:""]}),s.jsx("span",{className:"font-mono",children:o.window.timezone})]}),s.jsx("section",{className:"grid gap-2 sm:grid-cols-2 xl:grid-cols-4","aria-label":"SLO reliability rates",children:fs.map(c=>s.jsx(Ng,{definition:c,rate:o.rates[c.key]},c.key))}),s.jsxs("section",{"aria-labelledby":"slo-latency-heading",children:[s.jsx("h3",{id:"slo-latency-heading",className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted",children:"Latency percentiles"}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2 xl:grid-cols-4",children:jg.map(c=>s.jsx(Sg,{label:c.label,latency:o.latencies[c.key]},c.key))})]}),s.jsxs("section",{"aria-labelledby":"slo-trend-heading",children:[s.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[s.jsx("h3",{id:"slo-trend-heading",className:"text-xs font-semibold uppercase tracking-wide text-muted",children:"Daily reliability trend"}),s.jsx("span",{className:"text-xs text-muted",children:"Percent of each daily cohort"})]}),s.jsx("div",{className:"h-64",role:"img","aria-label":"Daily SLO reliability rates chart",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(dl,{data:l,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"bucket",minTickGap:20,tick:{fontSize:11}}),s.jsx(sn,{domain:[0,100],tickFormatter:c=>`${c}%`,width:44}),s.jsx(Ur,{}),s.jsx(cn,{formatter:(c,u)=>{var d;return[c==null?"n/a":`${Number(c).toLocaleString(void 0,{maximumFractionDigits:2})}%`,((d=fs.find(h=>h.key===u))==null?void 0:d.label)??u]}}),fs.map(c=>s.jsx(ti,{type:"monotone",dataKey:c.key,name:c.label,stroke:c.color,strokeWidth:2,dot:{r:2},activeDot:{r:4},connectNulls:!1,isAnimationActive:!1},c.key))]})})})]})]})})}function Ng({definition:e,rate:t}){const n=t.percent===null?"n/a":`${t.percent.toLocaleString(void 0,{maximumFractionDigits:2})}%`;return s.jsxs("div",{className:"rounded-md border border-border bg-slate-50/70 p-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-xs font-semibold text-muted",children:e.label}),s.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:e.color},"aria-hidden":!0})]}),s.jsx("strong",{className:"mt-2 block text-2xl leading-none",children:n}),s.jsxs("p",{className:"mt-2 text-xs text-muted",children:[t.numerator," / ",t.denominator," ",e.detail]}),t.missing_count>0?s.jsxs("p",{className:"mt-1 text-xs text-amber-700",children:[t.missing_count," missing sample",t.missing_count===1?"":"s"]}):null,e.key==="retry"&&t.requeued_runs?s.jsxs("p",{className:"mt-1 text-xs text-muted",children:[t.requeued_runs," requeued run",t.requeued_runs===1?"":"s"]}):null]})}function Sg({label:e,latency:t}){return s.jsxs("div",{className:"rounded-md border border-border p-3",children:[s.jsx("h4",{className:"text-xs font-semibold text-muted",children:e}),s.jsxs("div",{className:"mt-3 grid grid-cols-3 gap-2 text-center",children:[s.jsx(xs,{label:"p50",value:t.p50}),s.jsx(xs,{label:"p90",value:t.p90}),s.jsx(xs,{label:"p99",value:t.p99})]}),s.jsxs("p",{className:"mt-3 text-xs text-muted",children:[t.sample_count," sample",t.sample_count===1?"":"s",t.missing_count>0?` · ${t.missing_count} missing`:""]})]})}function xs({label:e,value:t}){return s.jsxs("div",{children:[s.jsx("div",{className:"font-mono text-sm font-semibold",children:Xe(t)}),s.jsx("div",{className:"mt-0.5 text-[10px] font-semibold uppercase text-muted",children:e})]})}function _g({filters:e,actorOptions:t,onChange:n}){const[r,i]=R.useState(e);R.useEffect(()=>i(e),[e]);const a=Ux(e),o=Vo(e)||Vo(r),l=()=>{i(Qs),n(Qs)};return s.jsxs("details",{className:"my-3 rounded-md border border-border bg-slate-50/70",children:[s.jsxs("summary",{className:"grid cursor-pointer list-none grid-cols-[minmax(0,1fr)_auto] items-center gap-3 px-3 py-2 text-sm font-semibold marker:hidden",children:[s.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-2",children:[s.jsx(sd,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"Filters"]}),a.length>0?s.jsx("span",{className:"flex min-w-0 flex-wrap items-center gap-1.5","aria-label":"Applied filters",children:a.map(c=>s.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full border border-blue-200 bg-blue-50 px-2 py-0.5 text-xs font-semibold text-blue-700",children:[s.jsx("span",{className:"text-blue-700/70",children:c.label}),s.jsx("span",{className:"max-w-40 truncate font-mono",children:c.value.trim()})]},c.key))}):null]}),s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-2",children:[o?s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-1.5 rounded-md border border-border bg-white px-2.5 text-xs font-semibold text-foreground hover:bg-slate-50",type:"button",onClick:c=>{c.preventDefault(),c.stopPropagation(),l()},children:[s.jsx(cr,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Clear filters"]}):null,s.jsx(Dn,{className:"h-4 w-4 text-muted","aria-hidden":!0})]})]}),s.jsxs("form",{className:"grid gap-3 border-t border-border bg-white p-3 md:grid-cols-3 xl:grid-cols-9",onSubmit:c=>{c.preventDefault(),n(r)},children:[s.jsx(ot,{label:"Status",children:s.jsxs("select",{className:"control",value:r.status,onChange:c=>i({...r,status:c.target.value}),children:[s.jsx("option",{value:"",children:"All"}),s.jsx("option",{value:"pending",children:"pending"}),s.jsx("option",{value:"running",children:"running"}),s.jsx("option",{value:"blocked",children:"blocked"}),s.jsx("option",{value:"done",children:"done"}),s.jsx("option",{value:"denied",children:"denied"}),s.jsx("option",{value:"waiting_approval",children:"waiting_approval"})]})}),s.jsx(ot,{label:"Repository",children:s.jsx("input",{className:"control",value:r.repo,placeholder:"owner/repo",onChange:c=>i({...r,repo:c.target.value})})}),s.jsx(ot,{label:"Thread",children:s.jsx("input",{className:"control",value:r.thread,inputMode:"numeric",placeholder:"issue or PR",onChange:c=>i({...r,thread:c.target.value})})}),s.jsx(ot,{label:"Action",children:s.jsx("input",{className:"control",value:r.action,placeholder:"reply_comment",onChange:c=>i({...r,action:c.target.value})})}),s.jsx(ot,{label:"Actor",className:"xl:col-span-2",children:s.jsx(Cg,{value:r.actor,options:t,onChange:c=>i({...r,actor:c})})}),s.jsx(ot,{label:"Intent",children:s.jsxs("select",{className:"control",value:r.intent,onChange:c=>i({...r,intent:c.target.value}),children:[s.jsx("option",{value:"",children:"All"}),s.jsx("option",{value:"review_only",children:"review_only"}),s.jsx("option",{value:"work_allowed",children:"work_allowed"})]})}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 self-end xl:col-span-2",children:[s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-white",type:"button",disabled:!o,onClick:l,children:[s.jsx(cr,{className:"h-4 w-4","aria-hidden":!0}),"Clear"]}),s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary px-3 text-sm font-semibold text-white",type:"submit",children:[s.jsx(ld,{className:"h-4 w-4","aria-hidden":!0}),"Apply"]})]})]})]})}function Cg({value:e,options:t,onChange:n}){const[r,i]=R.useState(!1),a=e.trim().replace(/^@/,"").toLowerCase(),o=t.filter(c=>!a||c.login.toLowerCase().includes(a)).slice(0,8),l=t.find(c=>c.login.toLowerCase()===a);return s.jsxs("div",{className:"relative min-w-0",children:[s.jsxs("div",{className:"control flex items-center gap-2 px-2",children:[l?s.jsx("img",{className:"h-5 w-5 shrink-0 rounded-full bg-slate-100",src:rt(l.avatar_url??""),alt:`${l.login} avatar`,referrerPolicy:"no-referrer"}):s.jsx(An,{className:"h-4 w-4 shrink-0 text-muted","aria-hidden":!0}),s.jsx("input",{className:"min-w-0 flex-1 bg-transparent font-mono text-sm outline-none",value:e,placeholder:"@login",onChange:c=>{n(c.target.value),i(!0)},onFocus:()=>i(!0),onBlur:()=>window.setTimeout(()=>i(!1),100)}),e?s.jsx("button",{className:"rounded-sm p-1 text-muted hover:bg-slate-100",type:"button","aria-label":"Clear actor filter",onClick:()=>n(""),children:s.jsx(un,{className:"h-3.5 w-3.5","aria-hidden":!0})}):null]}),r&&o.length>0?s.jsx("div",{className:"absolute left-0 right-0 z-20 mt-1 max-h-72 overflow-auto rounded-md border border-border bg-white p-1 shadow-lg",children:o.map(c=>s.jsxs("button",{className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-left hover:bg-slate-50",type:"button",onMouseDown:u=>u.preventDefault(),onClick:()=>{n(c.login),i(!1)},children:[c.avatar_url?s.jsx("img",{className:"h-6 w-6 shrink-0 rounded-full bg-slate-100",src:rt(c.avatar_url),alt:`${c.login} avatar`,referrerPolicy:"no-referrer"}):s.jsx(An,{className:"h-5 w-5 shrink-0 text-muted","aria-hidden":!0}),s.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",children:["@",c.login]}),s.jsx("span",{className:"shrink-0 rounded-full bg-slate-100 px-1.5 py-0.5 text-[10px] font-semibold text-muted",children:c.job_count})]},c.login))}):null]})}function ot({label:e,children:t,className:n}){return s.jsxs("label",{className:Q("grid min-w-0 gap-1 text-xs font-semibold text-muted",n),children:[e,t]})}function Pg({jobs:e,loading:t,loadingMore:n=!1,hasMore:r=!1,onLoadMore:i,onViewJob:a,now:o,user:l,onRetry:c,onDismiss:u,onCancel:d}){const[h,m]=R.useState(null),[p,w]=R.useState(null),[y,v]=R.useState(null),b=R.useRef(!1),N=R.useRef(n),k=!!(l!=null&&l.is_admin&&c),_=!!(l!=null&&l.is_admin&&u);R.useEffect(()=>{N.current&&!n&&(b.current=!1),N.current=n},[n]);const D=R.useCallback(()=>{b.current||(b.current=!0,i==null||i())},[i]),j=R.useCallback(async C=>{if(c){m(C);try{await c(C)}finally{m(null)}}},[c]),B=R.useCallback(async C=>{if(u){w(C);try{await u(C)}finally{w(null)}}},[u]),F=R.useCallback(async(C,M)=>{if(d){v(C);try{await d(C,M)}finally{v(null)}}},[d]);return t&&e.length===0?s.jsx(J,{text:"Loading jobs..."}):e.length===0?s.jsx(J,{text:"No jobs match the current filters."}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid gap-2 md:hidden",children:[e.map(C=>s.jsx(Ig,{job:C,onViewJob:a,now:o,canRetry:k&&Vs(C.status)&&C.decision==="auto_trusted",retrying:h===C.id,onRetry:j,canDismiss:_&&Gs(C.status),dismissing:p===C.id,onDismiss:B,canCancel:!!(d&&Js(C,l)),cancelling:y===C.id,onCancel:F},C.id)),s.jsx(Rg,{hasMore:r,loading:n,onLoadMore:D})]}),s.jsx(Xs,{noun:"jobs",hasMore:r,loading:n,onLoadMore:D,className:"hidden md:block",children:s.jsxs("table",{className:"min-w-[1080px] table-fixed border-collapse text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"sticky top-0 z-10 border-b border-border bg-panel text-left text-xs text-muted",children:[s.jsx("th",{className:"w-[42%] px-3 py-2 font-semibold",children:"Job"}),s.jsx("th",{className:"w-32 px-3 py-2 font-semibold",children:"Status"}),s.jsx("th",{className:"w-40 px-3 py-2 font-semibold",children:"Action"}),s.jsx("th",{className:"w-36 px-3 py-2 font-semibold",children:"Actor"}),s.jsx("th",{className:"w-36 px-3 py-2 font-semibold",children:"Timing"}),s.jsx("th",{className:"w-28 px-3 py-2 font-semibold",children:"Updated"}),s.jsx("th",{className:"w-24 px-3 py-2 text-right font-semibold",children:"Actions"})]})}),s.jsx("tbody",{children:e.map(C=>s.jsx(Eg,{job:C,now:o,onViewJob:a,canRetry:k&&Vs(C.status)&&C.decision==="auto_trusted",retrying:h===C.id,onRetry:j,canDismiss:_&&Gs(C.status),dismissing:p===C.id,onDismiss:B,canCancel:!!(d&&Js(C,l)),cancelling:y===C.id,onCancel:F},C.id))})]})})]})}function Eg({job:e,now:t,onViewJob:n,canRetry:r,retrying:i,onRetry:a,canDismiss:o,dismissing:l,onDismiss:c,canCancel:u,cancelling:d,onCancel:h}){return s.jsxs("tr",{className:"cursor-pointer border-b border-border align-top hover:bg-slate-50",onClick:()=>n(e.id),children:[s.jsx("td",{className:"min-w-0 px-3 py-3",children:s.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[s.jsxs("span",{className:"mt-0.5 shrink-0 font-mono text-xs font-semibold text-muted",children:["#",e.id]}),s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("div",{className:"line-clamp-2 text-sm font-semibold leading-snug text-foreground [overflow-wrap:anywhere]",title:e.subject,children:e.subject}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted",children:[s.jsx("span",{className:"min-w-0 max-w-full truncate font-mono",children:e.repo??e.work_key}),s.jsxs("span",{className:"shrink-0",children:["thread ",e.thread??"n/a"]})]})]})]})}),s.jsx("td",{className:"px-3 py-3",children:s.jsx(_i,{status:e.status})}),s.jsxs("td",{className:"px-3 py-3",children:[s.jsx("div",{className:"min-w-0 truncate text-sm text-foreground",title:e.action,children:e.action}),s.jsx("div",{className:"mt-1",children:s.jsx(Si,{intent:e.intent,actionMode:e.action_mode,display:"intent",compact:!0})})]}),s.jsx("td",{className:"px-3 py-3",children:s.jsx(Hn,{actor:e.trigger_actor,avatarUrl:e.trigger_actor_avatar_url})}),s.jsxs("td",{className:"px-3 py-3 text-xs text-muted",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{children:"wait"}),s.jsx("span",{className:"font-mono text-foreground",children:Xe(Ni(e,t))})]}),s.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[s.jsx("span",{children:"run"}),s.jsx("span",{className:"font-mono text-foreground",children:Xe(ki(e,t))})]}),s.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[s.jsx("span",{children:"tries"}),s.jsx("span",{className:"font-mono text-foreground",children:e.attempts})]})]}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs",children:s.jsx(ue,{value:e.updated_at,compact:!0,relative:!0,now:t})}),s.jsx("td",{className:"px-3 py-3 text-right",children:s.jsxs("div",{className:"inline-flex items-center gap-1",children:[s.jsx(Rc,{jobId:e.id,canRetry:r,retrying:i,onRetry:a,compact:!0}),s.jsx(Ic,{jobId:e.id,canDismiss:o,dismissing:l,onDismiss:c,compact:!0}),s.jsx(Tc,{jobId:e.id,canCancel:u,cancelling:d,onCancel:h,compact:!0})]})})]})}function Rg({hasMore:e,loading:t,onLoadMore:n}){return!e&&!t?null:s.jsxs("button",{className:"inline-flex min-h-10 w-full items-center justify-center gap-2 rounded-md border border-border px-3 py-2 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60 md:hidden",type:"button",disabled:t||!e,onClick:()=>n==null?void 0:n(),children:[s.jsx(Dn,{className:"h-4 w-4","aria-hidden":!0}),t?"Loading more jobs...":"Load more jobs"]})}function Ig({job:e,onViewJob:t,now:n,canRetry:r,retrying:i,onRetry:a,canDismiss:o,dismissing:l,onDismiss:c,canCancel:u,cancelling:d,onCancel:h}){return s.jsxs("article",{className:"rounded-md border border-border bg-white shadow-[0_1px_0_rgba(15,23,42,0.03)]",children:[s.jsxs("button",{className:"grid w-full gap-2 p-3 text-left hover:bg-slate-50",type:"button",onClick:()=>t(e.id),children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsxs("div",{className:"grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-2",children:[s.jsxs("span",{className:"shrink-0 font-mono text-xs font-semibold text-muted",children:["#",e.id]}),s.jsx("span",{className:"truncate font-mono text-sm",children:e.repo??e.work_key})]}),s.jsx("div",{className:"line-clamp-2 text-sm leading-snug text-foreground",children:e.subject}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted",children:[s.jsxs("span",{children:["thread ",e.thread??"n/a"," · ",e.action]}),s.jsx(Si,{intent:e.intent,actionMode:e.action_mode,compact:!0,display:"intent"}),s.jsx(Hn,{actor:e.trigger_actor,avatarUrl:e.trigger_actor_avatar_url})]})]}),s.jsx(_i,{status:e.status})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[s.jsx($,{label:"Wait",value:Xe(Ni(e,n))}),s.jsx($,{label:"Runtime",value:Xe(ki(e,n))}),s.jsx($,{label:"Updated",value:s.jsx(ue,{value:e.updated_at,compact:!0,relative:!0,now:n})})]})]}),r||o||u?s.jsxs("div",{className:"flex flex-wrap gap-2 border-t border-border px-3 py-2",children:[s.jsx(Rc,{jobId:e.id,canRetry:r,retrying:i,onRetry:a}),s.jsx(Ic,{jobId:e.id,canDismiss:o,dismissing:l,onDismiss:c}),s.jsx(Tc,{jobId:e.id,canCancel:u,cancelling:d,onCancel:h})]}):null]})}function Rc({jobId:e,canRetry:t,retrying:n,onRetry:r,compact:i=!1}){if(!t)return null;const a=n?"Retrying...":"Retry";return s.jsxs("button",{className:Q("inline-flex h-8 items-center justify-center gap-2 rounded-md border border-border text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60",i?"w-8 px-0":"px-3"),type:"button",disabled:n,"aria-label":`Retry job #${e}`,title:`Retry job #${e}`,onClick:async o=>{o.stopPropagation(),window.confirm(`Retry job #${e}?`)&&await r(e)},children:[s.jsx(cr,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{className:Q(i&&"sr-only"),children:a})]})}function Ic({jobId:e,canDismiss:t,dismissing:n,onDismiss:r,compact:i=!1}){if(!t)return null;const a=n?"Dismissing...":"Dismiss";return s.jsxs("button",{className:Q("inline-flex h-8 items-center justify-center gap-2 rounded-md border border-border text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60",i?"w-8 px-0":"px-3"),type:"button",disabled:n,"aria-label":`Dismiss job #${e}`,title:`Dismiss job #${e}`,onClick:async o=>{o.stopPropagation(),window.confirm(`Dismiss job #${e}?`)&&await r(e)},children:[s.jsx(On,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{className:Q(i&&"sr-only"),children:a})]})}function Tc({jobId:e,canCancel:t,cancelling:n,onCancel:r,compact:i=!1}){if(!t)return null;const a=n?"Cancelling...":"Cancel";return s.jsxs("button",{className:Q("inline-flex h-8 items-center justify-center gap-2 rounded-md border border-red-200 bg-red-50 text-sm font-semibold text-red-700 hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-60",i?"w-8 px-0":"px-3"),type:"button",disabled:n,"aria-label":`Cancel job #${e}`,title:`Cancel job #${e}`,onClick:async o=>{o.stopPropagation();const l=window.prompt(`Cancel job #${e}? Optional reason:`);l!==null&&await r(e,l)},children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{className:Q(i&&"sr-only"),children:a})]})}function Hn({actor:e,avatarUrl:t,framed:n=!1}){const r=t?s.jsx("img",{className:"h-4 w-4 shrink-0 rounded-full bg-slate-100",src:rt(t),alt:e?`${e} avatar`:"",referrerPolicy:"no-referrer"}):s.jsx(An,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),i=s.jsxs(s.Fragment,{children:[r,s.jsx("span",{className:"min-w-0 truncate",children:e?`@${e}`:"unknown actor"})]});return n?s.jsx("span",{className:"inline-flex h-7 max-w-full items-center gap-1 rounded-md border border-border px-2 text-xs font-semibold text-muted",children:i}):s.jsx("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1 font-mono text-xs text-muted",children:i})}function Tg(e){return(e==null?void 0:e.model)??"OpenClaw default"}function Ag(e){return(e==null?void 0:e.thinking)??"OpenClaw default"}function Lg(e){return e?e.configured?"configured":e.summary:"n/a"}function Mg(e,t){const n=t||(e==="work_allowed"?"fix_allowed":"review_only");return n==="fix_allowed"||!t&&e==="work_allowed"?{mode:n,intentLabel:"work_allowed",title:"Work allowed"}:{mode:n,intentLabel:"review_only",title:"Review only"}}function Si({intent:e,actionMode:t,compact:n=!1,display:r="mode"}){const i=Mg(e,t),a=i.intentLabel==="work_allowed"?cd:Il,o=r==="intent"?i.intentLabel:i.mode;return s.jsxs("span",{className:Q("inline-flex min-h-6 max-w-full items-center gap-1.5 rounded-md border px-2 text-xs font-semibold",i.intentLabel==="work_allowed"?"border-blue-200 bg-blue-50 text-blue-700":"border-violet-200 bg-violet-50 text-violet-700",n&&"min-h-5 px-1.5 text-[11px]"),title:`${i.title}: ${i.mode}`,"aria-label":`${i.title}: ${o}`,children:[s.jsx(a,{className:Q("h-3.5 w-3.5 shrink-0",n&&"h-3 w-3"),"aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono",children:o})]})}function Dg({job:e,session:t,sessionEvents:n,transcript:r,now:i,compact:a=!1}){var p;const o=Un(e.id),l=n??[],c=r??[],u=jx(l),d=kx(c),h=ki(e,i),m=Ni(e,i);return s.jsxs("div",{className:"grid min-w-0 gap-4",children:[s.jsxs("div",{className:"sticky top-0 z-20 -mx-3 -mt-3 grid gap-2 border-b border-border bg-panel/95 px-3 py-2 shadow-sm backdrop-blur sm:-mx-4 sm:-mt-4 sm:px-4","aria-label":"Sticky job header",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx(_i,{status:e.status}),s.jsxs("a",{className:"inline-flex h-7 items-center gap-1 rounded-md border border-border bg-white px-2 text-xs font-semibold text-foreground hover:bg-slate-50",href:o,children:[s.jsx(Fn,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Job #",e.id]}),s.jsx(Hn,{actor:e.trigger_actor,avatarUrl:e.trigger_actor_avatar_url,framed:!0}),s.jsx("span",{className:"min-w-0 break-words font-mono text-xs text-muted [overflow-wrap:anywhere]",children:e.work_key})]}),s.jsxs("div",{className:"grid min-w-0 gap-2 lg:grid-cols-[minmax(0,1fr)_minmax(280px,auto)] lg:items-start",children:[s.jsx("p",{className:"min-w-0 break-words text-sm text-muted [overflow-wrap:anywhere]",children:e.subject}),s.jsxs("div",{className:"grid min-w-0 gap-1",children:[s.jsx("h3",{className:"text-xs font-semibold text-muted",children:"GitHub links"}),e.github_urls.length>0?s.jsx(dr,{urls:e.github_urls,compact:!0}):s.jsx("p",{className:"text-xs text-muted",children:"No links recorded."})]})]})]}),s.jsxs("div",{className:Q("grid gap-2 text-sm sm:gap-3",a?"grid-cols-1":"grid-cols-3"),children:[s.jsx($,{label:"Queue wait",value:Xe(m)}),s.jsx($,{label:e.status==="running"?"Running for":"Runtime",value:Xe(h)}),s.jsx($,{label:"Coalesced",value:String(e.coalesced_count)})]}),e.queue_state==="serialized_by_work_key"?s.jsxs("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900",children:["Serialized behind running job #",e.blocked_by_job_id," for this work key."]}):null,s.jsxs("div",{className:Q("grid gap-2 text-sm sm:gap-3",a?"grid-cols-1":"grid-cols-3"),children:[s.jsx($,{label:"Model",value:Tg(e.model_route)}),s.jsx($,{label:"Reasoning",value:Ag(e.model_route)}),s.jsx($,{label:"Route",value:Lg(e.model_route)})]}),s.jsx(Og,{job:e,compact:a}),s.jsxs("div",{className:Q("grid gap-2 text-sm sm:gap-3",a?"grid-cols-1":"grid-cols-2 xl:grid-cols-4"),children:[s.jsx($,{label:"Created",value:s.jsx(ue,{value:e.created_at,compact:!0,relative:!0,now:i})}),s.jsx($,{label:"Started",value:e.started_at?s.jsx(ue,{value:e.started_at,compact:!0,relative:!0,now:i}):"n/a"}),s.jsx($,{label:"Updated",value:s.jsx(ue,{value:e.updated_at,compact:!0,relative:!0,now:i})}),s.jsx($,{label:"Finished",value:e.finished_at?s.jsx(ue,{value:e.finished_at,compact:!0,relative:!0,now:i}):"n/a"})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"mb-2 text-sm font-semibold",children:"Timeline"}),s.jsx("div",{className:"grid min-w-0 gap-3",children:(e.worklog??[]).length>0?(p=e.worklog)==null?void 0:p.map(w=>s.jsxs("div",{className:"min-w-0 border-l-2 border-primary pl-3",children:[s.jsx("div",{className:"text-sm font-semibold",children:w.phase}),s.jsx("div",{className:"font-mono text-xs text-muted",children:s.jsx(ue,{value:w.ts,relative:!0,now:i})}),s.jsx("div",{className:"break-words text-sm [overflow-wrap:anywhere]",children:w.summary}),w.detail?s.jsx("div",{className:"mt-1 break-words font-mono text-xs text-muted [overflow-wrap:anywhere]",children:w.detail}):null]},w.id)):s.jsx(J,{text:"No worklog entries."})})]}),s.jsxs("div",{children:[s.jsxs("h3",{className:"mb-2 flex items-center gap-2 text-sm font-semibold",children:[s.jsx(Al,{className:"h-4 w-4","aria-hidden":!0}),"OpenClaw session"]}),t?s.jsxs("div",{className:"grid gap-3",children:[s.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[s.jsx($,{label:"Session ID",value:t.id}),s.jsx($,{label:"Source",value:t.source})]}),s.jsx("p",{className:"break-words text-xs text-muted [overflow-wrap:anywhere]",children:t.detail})]}):s.jsx(J,{text:"Session correlation is loading."})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"mb-2 text-sm font-semibold",children:"Agent activity"}),s.jsx("div",{className:"grid max-h-[460px] min-w-0 gap-2 overflow-auto pr-1",children:u.length>0?u.map((w,y)=>s.jsx(zg,{event:w,defaultOpen:Qo(w.eventType,e.status==="running",y,u.length),now:i},w.id)):s.jsx(J,{text:e.status==="running"?"Waiting for live agent output...":"No agent activity has been recorded for this session."})})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"mb-2 text-sm font-semibold",children:"Session transcript"}),s.jsx("div",{className:"grid max-h-[620px] min-w-0 gap-2 overflow-auto pr-1",children:d.length>0?d.map((w,y)=>s.jsx(Fg,{entry:w,defaultOpen:Qo(w.kind,e.status==="running",y,d.length),now:i},w.id)):s.jsx(J,{text:e.status==="running"?"Waiting for live transcript entries...":"No OpenClaw transcript entries are available for this session."})})]})]})}function Og({job:e,compact:t=!1}){const n=e.intent_classifier??null,r=(n==null?void 0:n.llm)??{},i=(n==null?void 0:n.parser)??{},a=typeof r.confidence=="number"?`${Math.round(r.confidence*100)}%`:"n/a";return s.jsxs("div",{className:"grid gap-2",children:[s.jsx("h3",{className:"text-sm font-semibold",children:"Action mode"}),s.jsxs("div",{className:Q("grid gap-2 text-sm sm:gap-3",t?"grid-cols-1":"grid-cols-2 xl:grid-cols-4"),children:[s.jsx($,{label:"Mode",value:s.jsx(Si,{intent:e.intent,actionMode:e.action_mode})}),s.jsx($,{label:"Intent",value:e.intent}),s.jsx($,{label:"Addressed",value:n?Jo(r.addressed_to_agent):"n/a"}),s.jsx($,{label:"Write",value:n?r.write_permission??"none":e.intent==="work_allowed"?"allowed":"none"})]}),n?s.jsxs("div",{className:"grid gap-2 rounded-md border border-border bg-panel p-3 text-xs",children:[s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(ht,{label:"Classifier",value:n.enabled?"enabled":"disabled"}),s.jsx(ht,{label:"Applied",value:Jo(r.applied)}),s.jsx(ht,{label:"Confidence",value:a}),s.jsx(ht,{label:"Parser",value:`${i.action??"n/a"} / ${i.work_intent??"n/a"}`})]}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[s.jsx(ht,{label:"LLM",value:`${r.action??"n/a"} / ${r.work_intent??"n/a"}`}),s.jsx(ht,{label:"Scope",value:r.scope||"n/a"})]}),r.main_request?s.jsx(ht,{label:"Main request",value:r.main_request}):null,r.subordinate_reason?s.jsx(ht,{label:"Subordinate reason",value:r.subordinate_reason}):null,r.reason?s.jsx(ht,{label:"Reason",value:r.reason}):null,n.error?s.jsx(ht,{label:"Error",value:n.error,tone:"danger"}):null]}):s.jsx("p",{className:"text-xs text-muted",children:"No intent classifier metadata recorded for this job."})]})}function Jo(e){return e===!0?"yes":e===!1?"no":"n/a"}function ht({label:e,value:t,tone:n="neutral"}){return s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted",children:e}),s.jsx("div",{className:Q("mt-0.5 min-w-0 break-words font-mono text-xs [overflow-wrap:anywhere]",n==="danger"?"text-red-700":"text-foreground"),children:t})]})}function Fg({entry:e,defaultOpen:t,now:n}){return s.jsx(Ac,{badge:e.badge,meta:s.jsx(ue,{value:e.meta,relative:!0,now:n}),count:e.count,summary:e.summary,defaultOpen:t,children:s.jsx("pre",{className:"max-h-72 max-w-full overflow-auto whitespace-pre-wrap break-words rounded bg-slate-950 px-2 py-1.5 font-mono text-xs leading-relaxed text-slate-100 [overflow-wrap:anywhere]",children:e.text})})}function zg({event:e,defaultOpen:t,now:n}){return s.jsx(Ac,{badge:e.badge,meta:s.jsx(ue,{value:e.meta,relative:!0,now:n}),count:e.count,summary:e.summary,defaultOpen:t,children:e.detail?s.jsx("pre",{className:"max-h-56 max-w-full overflow-auto whitespace-pre-wrap break-words rounded bg-slate-950 px-2 py-1.5 font-mono text-xs leading-relaxed text-slate-100 [overflow-wrap:anywhere]",children:e.detail}):null})}function Ac({badge:e,meta:t,count:n,summary:r,defaultOpen:i,children:a}){const[o,l]=R.useState(!!i);return s.jsxs("details",{className:"group min-w-0 rounded border border-border bg-slate-50/60",open:o,onToggle:c=>l(c.currentTarget.open),children:[s.jsxs("summary",{className:"grid cursor-pointer list-none gap-1 px-2 py-1.5 marker:hidden hover:bg-white",children:[s.jsxs("div",{className:"grid min-w-0 gap-1 sm:flex sm:items-center sm:justify-between sm:gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(Dn,{className:"h-3.5 w-3.5 shrink-0 text-muted transition-transform group-open:rotate-180","aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono text-[11px] font-semibold text-muted",children:e}),n&&n>1?s.jsx("span",{className:"rounded-sm border border-border px-1 font-mono text-[10px] text-muted",children:n}):null]}),s.jsx("span",{className:"min-w-0 truncate pl-5 font-mono text-[11px] text-muted sm:shrink-0 sm:pl-0",children:t})]}),s.jsx("div",{className:"min-w-0 break-words pl-5 text-xs text-foreground [overflow-wrap:anywhere] sm:truncate",children:r})]}),s.jsx("div",{className:"min-w-0 border-t border-border bg-white px-2 py-2",children:a})]})}function Xo({label:e,values:t}){const n=[{name:"median",seconds:(t==null?void 0:t.median)??0},{name:"p90",seconds:(t==null?void 0:t.p90)??0},{name:"p99",seconds:(t==null?void 0:t.p99)??0}];return s.jsx("div",{className:"h-56",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(ei,{data:n,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"name"}),s.jsx(sn,{tickFormatter:Xe}),s.jsx(cn,{formatter:r=>[Xe(Number(r)),e]}),s.jsx(Bt,{dataKey:"seconds",fill:"#0969da",radius:[4,4,0,0]})]})})})}function qg({usage:e,jobsByCreatedDay:t,loading:n,totalJobs:r}){const[i,a]=R.useState("day"),o=(e==null?void 0:e[i])??[],l=Bg(e,t,i),c=o.reduce((d,h)=>d+h.seconds,0),u=o.reduce((d,h)=>d+(h.runs??h.jobs),0);return n&&l.length===0?s.jsx(J,{text:"Loading runtime and job history..."}):l.length===0?s.jsx(J,{text:r>0?"No jobs have valid runtime or creation dates.":"No job history available."}):s.jsxs("div",{className:"grid gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted",children:[s.jsx(Ll,{className:"h-4 w-4","aria-hidden":!0}),s.jsxs("span",{children:[tt(c)," consumed across ",u," run",u===1?"":"s"]})]}),s.jsx("div",{className:"inline-flex h-8 rounded-md border border-border bg-white p-0.5","aria-label":"Runtime grouping",children:["day","month"].map(d=>s.jsx("button",{className:Q("rounded px-2.5 text-xs font-semibold capitalize",i===d?"bg-primary text-white":"text-muted hover:bg-slate-50"),type:"button",onClick:()=>a(d),children:d},d))})]}),s.jsx("div",{className:"h-64",role:"img","aria-label":"Runtime and jobs activity chart",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(ou,{data:l,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"label",minTickGap:16,tick:{fontSize:11}}),s.jsx(sn,{yAxisId:"runtime",tickFormatter:d=>tt(Number(d))}),s.jsx(sn,{yAxisId:"jobs",orientation:"right",allowDecimals:!1}),s.jsx(Ur,{}),s.jsx(cn,{formatter:(d,h)=>h==="Work"?[tt(Number(d)),"work"]:h==="Review"?[tt(Number(d)),"review"]:h==="Jobs"?[Number(d),"jobs"]:[Number(d),String(h)],labelFormatter:d=>String(d)}),s.jsx(Bt,{yAxisId:"runtime",dataKey:"work_seconds",name:"Work",stackId:"runtime",fill:"#0969da",isAnimationActive:!1}),s.jsx(Bt,{yAxisId:"runtime",dataKey:"review_seconds",name:"Review",stackId:"runtime",fill:"#8250df",radius:[4,4,0,0],isAnimationActive:!1}),s.jsx(ti,{yAxisId:"jobs",type:"monotone",dataKey:"jobs",name:"Jobs",stroke:"#16a34a",strokeWidth:2,dot:{r:3},activeDot:{r:5},isAnimationActive:!1})]})})})]})}function Bg(e,t,n){const r=new Map;for(const a of(e==null?void 0:e[n])??[])r.set(a.bucket,{...a});const i=new Map;for(const[a,o]of Object.entries(t??{})){const l=n==="month"?a.slice(0,7):a;i.set(l,(i.get(l)??0)+o)}for(const a of i.keys())r.has(a)||r.set(a,$g(a));return[...r.values()].sort((a,o)=>a.bucket.localeCompare(o.bucket)).map(a=>({...a,jobs:i.get(a.bucket)??0,label:Jg(a.bucket,n)}))}function $g(e){return{bucket:e,seconds:0,minutes:0,runs:0,jobs:0,work_seconds:0,review_seconds:0,work_runs:0,review_runs:0,work_jobs:0,review_jobs:0}}const Lc=[{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"},{value:"all",label:"All time"}],Ug=2,Rr=["#0969da","#8250df","#1a7f37","#bf8700","#cf222e","#0550ae","#6e40c9","#0a7f68"];function Hg({usage:e,loading:t,totalJobs:n,window:r,onWindowChange:i}){const a=e??[],o=a.reduce((l,c)=>l+c.seconds,0);return s.jsxs("div",{className:"grid gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[a.length>0?s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted",children:[s.jsx(An,{className:"h-4 w-4","aria-hidden":!0}),s.jsxs("span",{children:[tt(o)," consumed across ",a.length," user",a.length===1?"":"s"]})]}):s.jsx("span",{}),s.jsx("div",{className:"inline-flex h-8 rounded-md border border-border bg-white p-0.5",role:"group","aria-label":"Runtime by user window",children:Lc.map(l=>s.jsx("button",{className:Q("rounded px-2.5 text-xs font-semibold",r===l.value?"bg-primary text-white":"text-muted hover:bg-slate-50"),type:"button","aria-label":l.label,"aria-pressed":r===l.value,onClick:()=>i(l.value),children:l.value==="all"?"All":l.value},l.value))})]}),t&&a.length===0?s.jsx(J,{text:"Loading runtime by user..."}):a.length===0?s.jsx(J,{text:n>0?"No jobs have recorded user runtime in this window.":"No job history available."}):s.jsx("div",{className:"overflow-x-auto",role:"img","aria-label":"Runtime usage by user chart",children:s.jsx("div",{className:"h-64",style:{minWidth:`${Math.max(720,a.length*112)}px`},children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(ei,{data:a,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"actor",interval:0,height:68,tick:s.jsx(Vg,{usage:a}),tickLine:!1}),s.jsx(sn,{tickFormatter:l=>tt(Number(l))}),s.jsx(Ur,{}),s.jsx(cn,{formatter:(l,c)=>[tt(Number(l)),String(c).toLowerCase()],labelFormatter:l=>l==="unknown"?"unknown":`@${String(l)}`}),s.jsx(Bt,{dataKey:"work_seconds",name:"Work",stackId:"runtime",fill:"#0969da",isAnimationActive:!1}),s.jsx(Bt,{dataKey:"review_seconds",name:"Review",stackId:"runtime",fill:"#8250df",radius:[4,4,0,0],isAnimationActive:!1})]})})})})]})}function Kg({usage:e,loading:t,totalJobs:n,window:r,onWindowChange:i}){const a=e??[],o=a.reduce((c,u)=>c+u.seconds,0),l=Qg(a);return s.jsxs("div",{className:"grid gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[a.length>0?s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted",children:[s.jsx(Ll,{className:"h-4 w-4","aria-hidden":!0}),s.jsxs("span",{children:[tt(o)," consumed across ",a.length," repositor",a.length===1?"y":"ies"]})]}):s.jsx("span",{}),s.jsx("div",{className:"inline-flex h-8 rounded-md border border-border bg-white p-0.5",role:"group","aria-label":"Runtime by repository window",children:Lc.map(c=>s.jsx("button",{className:Q("rounded px-2.5 text-xs font-semibold",r===c.value?"bg-primary text-white":"text-muted hover:bg-slate-50"),type:"button","aria-label":c.label,"aria-pressed":r===c.value,onClick:()=>i(c.value),children:c.value==="all"?"All":c.value},c.value))})]}),t&&a.length===0?s.jsx(J,{text:"Loading runtime by repository..."}):a.length===0?s.jsx(J,{text:n>0?"No jobs have recorded repository runtime in this window.":"No job history available."}):s.jsxs("div",{className:"grid items-center gap-4 md:grid-cols-[minmax(0,1fr)_minmax(240px,0.8fr)]",role:"img","aria-label":"Runtime usage by repository chart",children:[s.jsx("div",{className:"h-72 min-w-0",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(lu,{children:[s.jsx(cu,{data:l,dataKey:"seconds",nameKey:"repo",innerRadius:"54%",outerRadius:"86%",paddingAngle:1,stroke:"#ffffff",strokeWidth:2,labelLine:!1,label:({percent:c})=>$r((c??0)*100),isAnimationActive:!1,children:l.map((c,u)=>s.jsx(uu,{fill:c.repo==="Other"?"#94a3b8":Rr[u%Rr.length]},c.repo))}),s.jsx(cn,{content:s.jsx(Wg,{totalSeconds:o})})]})})}),s.jsx("ul",{className:"grid min-w-0 gap-2","aria-label":"Repository runtime percentages",children:l.map((c,u)=>s.jsxs("li",{className:"grid min-w-0 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 text-sm",children:[s.jsx("span",{className:"h-3 w-3 rounded-sm",style:{backgroundColor:c.repo==="Other"?"#94a3b8":Rr[u%Rr.length]},"aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono text-xs",title:c.repo,children:c.repo==="Other"?`Other (${c.repositories.length})`:c.repo}),s.jsx("span",{className:"font-semibold tabular-nums",children:$r(c.percentage)})]},c.repo))})]})]})}function Qg(e){const t=e.filter(a=>a.seconds>0).sort((a,o)=>o.seconds-a.seconds),n=t.reduce((a,o)=>a+o.seconds,0);if(n<=0)return[];const r=[],i=[];for(const a of t){const o=a.seconds/n*100;o0){const a=i.reduce((o,l)=>({repo:"Other",seconds:o.seconds+l.seconds,minutes:o.minutes+l.minutes,runs:o.runs+l.runs,work_seconds:o.work_seconds+l.work_seconds,review_seconds:o.review_seconds+l.review_seconds,work_runs:o.work_runs+l.work_runs,review_runs:o.review_runs+l.review_runs}),{repo:"Other",seconds:0,minutes:0,runs:0,work_seconds:0,review_seconds:0,work_runs:0,review_runs:0});r.push({...a,percentage:a.seconds/n*100,repositories:i})}return r}function Wg({active:e,payload:t,totalSeconds:n}){var i;const r=(i=t==null?void 0:t[0])==null?void 0:i.payload;return!e||!r?null:s.jsxs("div",{className:"min-w-56 rounded-md border border-border bg-white p-3 text-xs shadow-lg",children:[s.jsx("div",{className:"font-mono font-semibold text-foreground",children:r.repo==="Other"?`Other (${r.repositories.length} repositor${r.repositories.length===1?"y":"ies"})`:r.repo}),s.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-x-4 gap-y-1 text-muted",children:[s.jsx("span",{children:"Total"}),s.jsxs("span",{className:"text-right font-semibold text-foreground",children:[tt(r.seconds)," · ",$r(r.seconds/n*100)]}),s.jsx("span",{children:"Work"}),s.jsx("span",{className:"text-right text-foreground",children:tt(r.work_seconds)}),s.jsx("span",{children:"Review"}),s.jsx("span",{className:"text-right text-foreground",children:tt(r.review_seconds)}),s.jsx("span",{children:"Runs"}),s.jsx("span",{className:"text-right text-foreground",children:r.runs})]}),r.repo==="Other"?s.jsx("div",{className:"mt-2 max-h-40 overflow-auto border-t border-border pt-2",children:r.repositories.map(a=>s.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-3 py-0.5",children:[s.jsx("span",{className:"truncate font-mono",title:a.repo,children:a.repo}),s.jsxs("span",{className:"tabular-nums text-muted",children:[$r(a.seconds/n*100)," · ",tt(a.seconds)]})]},a.repo))}):null]})}function $r(e){return`${e.toFixed(1)}%`}function Vg({x:e=0,y:t=0,payload:n,usage:r}){const i=String((n==null?void 0:n.value)??"unknown"),a=r.find(h=>h.actor===i),o=Gg(a),l=i==="unknown"?"unknown user":`@${i}`,c=i==="unknown"?"unknown":`@${i}`,u=c.length>18?`${c.slice(0,17)}…`:c,d=R.useId().replace(/:/g,"");return s.jsxs("g",{transform:`translate(${e},${t})`,children:[s.jsx("title",{children:l}),s.jsx("defs",{children:s.jsx("clipPath",{id:d,children:s.jsx("circle",{cx:"0",cy:"18",r:"14"})})}),s.jsx("circle",{cx:"0",cy:"18",r:"14",fill:"#f1f5f9",stroke:"#cbd5e1"}),o?s.jsx("image",{x:"-14",y:"4",width:"28",height:"28",href:o,clipPath:`url(#${d})`,preserveAspectRatio:"xMidYMid slice",role:"img","aria-label":`${l} avatar`}):s.jsx("text",{x:"0",y:"22",textAnchor:"middle",fontSize:"12",fill:"#64748b","aria-label":l,children:"?"}),s.jsx("text",{x:"0",y:"49",textAnchor:"middle",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"11",fontWeight:"600",fill:"#475569",children:u})]})}function Gg(e){if(!e)return null;const t=rt(e.avatar_url??"");return t!=="#"?t:!e.actor||e.actor==="unknown"?null:`https://github.com/${encodeURIComponent(e.actor)}.png?size=80`}function Jg(e,t){if(t==="month"){const[a,o]=e.split("-").map(Number);return!a||!o?e:new Intl.DateTimeFormat(void 0,{month:"short",year:"numeric"}).format(new Date(a,o-1,1))}const[n,r,i]=e.split("-").map(Number);return!n||!r||!i?e:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(n,r-1,i))}function tt(e){const t=Math.max(0,Math.round(e));if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const r=Math.floor(n/60),i=n%60;return i===0?`${r}h`:`${r}h ${i}m`}function gs(e){return Object.values(e).reduce((t,n)=>t+n,0)}function Xg({data:e,loading:t}){if(t&&!e)return s.jsx(J,{text:"Loading systemd units..."});if(!e)return s.jsx(J,{text:"No systemd snapshot available."});const n=e.units??[],r=n.filter(o=>o.active_state==="active").length,i=n.filter(o=>o.active_state==="failed"||o.result==="failed").length,a=n.filter(o=>o.kind==="timer").length;return s.jsxs("div",{className:"grid min-w-0 gap-3",children:[e.errors.length>0?s.jsx(be,{tone:"error",text:e.errors[0]}):null,n.length===0?s.jsx(J,{text:"No configured bridge units found."}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[s.jsx(Ir,{label:"Units",value:String(n.length)}),s.jsx(Ir,{label:"Active",value:String(r)}),s.jsx(Ir,{label:"Failed",value:String(i),tone:i>0?"bad":"neutral"}),s.jsx(Ir,{label:"Timers",value:String(a)})]}),s.jsxs("div",{className:"overflow-hidden rounded-md border border-border bg-white",children:[s.jsxs("div",{className:"hidden grid-cols-[minmax(0,1.35fr)_90px_120px_90px_minmax(0,1fr)] gap-3 border-b border-border bg-slate-50 px-3 py-2 text-[11px] font-semibold uppercase text-muted md:grid",children:[s.jsx("span",{children:"Unit"}),s.jsx("span",{children:"Status"}),s.jsx("span",{children:"State"}),s.jsx("span",{children:"PID"}),s.jsx("span",{children:"Schedule"})]}),s.jsx("div",{className:"divide-y divide-border",children:n.map(o=>s.jsx(Yg,{unit:o},o.unit))})]})]})]})}function Ir({label:e,value:t,tone:n="neutral"}){return s.jsxs("div",{className:Q("min-w-0 rounded-md border bg-white px-3 py-2",n==="bad"?"border-red-200":"border-border"),children:[s.jsx("div",{className:Q("font-mono text-lg font-semibold",n==="bad"?"text-red-700":"text-foreground"),children:t}),s.jsx("div",{className:"mt-0.5 text-[11px] font-semibold uppercase text-muted",children:e})]})}function Yg({unit:e}){const[t,n]=R.useState(!1),r=e.active_state==="active",i=e.active_state==="failed"||e.result==="failed",a=e.next_elapse||e.last_trigger||"n/a";return s.jsxs("details",{className:"group min-w-0",open:t,onToggle:o=>n(o.currentTarget.open),children:[s.jsxs("summary",{className:"grid min-w-0 cursor-pointer list-none grid-cols-2 gap-2 px-3 py-3 text-sm marker:hidden hover:bg-slate-50 md:grid-cols-[minmax(0,1.35fr)_90px_120px_90px_minmax(0,1fr)] md:items-center md:gap-3",children:[s.jsxs("div",{className:"col-span-2 min-w-0 md:col-span-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(Dn,{className:"h-3.5 w-3.5 shrink-0 text-muted transition-transform group-open:rotate-180","aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono text-xs font-semibold text-foreground",children:e.unit})]}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 pl-5 text-[11px] font-semibold uppercase text-muted",children:[s.jsx("span",{children:e.role}),s.jsx("span",{children:e.kind}),s.jsx("span",{children:e.load_state}),s.jsx("span",{children:t?"following log":"expand log"})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 md:block",children:[s.jsx("span",{className:"text-[11px] font-semibold uppercase text-muted md:hidden",children:"Status"}),s.jsx("span",{className:Q("inline-flex h-6 items-center rounded-full border px-2 text-xs font-semibold",i?"border-red-300 bg-red-50 text-red-700":r?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-slate-300 bg-slate-50 text-slate-700"),children:e.active_state})]}),s.jsx(Yo,{label:"State",value:e.sub_state,detail:e.result||"unknown"}),s.jsx(Yo,{label:"PID",value:e.main_pid?String(e.main_pid):"n/a",detail:Xe(e.uptime_seconds)}),s.jsxs("div",{className:"col-span-2 min-w-0 md:col-span-1",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted md:hidden",children:"Schedule"}),s.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",title:a,children:e.next_elapse?`next ${e.next_elapse}`:a})]})]}),s.jsx("div",{className:"border-t border-border bg-slate-50 px-3 pb-3 pt-2",children:s.jsx(Zg,{unit:e.unit,active:t})})]})}function Yo({label:e,value:t,detail:n}){return s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted md:hidden",children:e}),s.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",children:t}),n?s.jsx("div",{className:"truncate font-mono text-[11px] text-muted",children:n}):null]})}function Zg({unit:e,active:t}){const[n,r]=R.useState([]),[i,a]=R.useState(""),o=R.useRef(null);return R.useEffect(()=>{if(!t){r([]),a("");return}r([]),a("");const l=new EventSource(`/api/systemd/journal/stream?unit=${encodeURIComponent(e)}`);return l.addEventListener("journal_line",c=>{const u=Br(c);u&&r(d=>[...d.slice(-199),u])}),l.addEventListener("journal_error",c=>{const u=Br(c);a((u==null?void 0:u.error)??"journal stream failed")}),l.onerror=()=>{},()=>l.close()},[t,e]),R.useEffect(()=>{const l=o.current;l&&(l.scrollTop=l.scrollHeight)},[n]),s.jsxs("div",{className:"grid min-w-0 gap-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted",children:"Live journal"}),s.jsx("div",{className:"mt-0.5 truncate font-mono text-[11px] text-muted",children:n.length>0?`${n.length} lines streamed`:"waiting for journal output"})]}),s.jsx("div",{className:"font-mono text-[11px] text-muted",children:"journalctl -f"})]}),i?s.jsx(be,{tone:"error",text:i}):null,s.jsx("div",{ref:o,className:"h-72 overflow-auto rounded-md border border-slate-800 bg-slate-950 p-3 font-mono text-xs leading-relaxed text-slate-100",children:n.length>0?n.map((l,c)=>s.jsx("div",{className:"break-words [overflow-wrap:anywhere]",children:l.line},`${l.unit}-${c}`)):s.jsx("div",{className:"text-slate-400",children:"No journal lines received yet."})})]})}function eb({data:e,loading:t}){var h,m,p,w,y,v;if(t&&!e)return s.jsx(J,{text:"Loading process activity..."});if(!e)return s.jsx(J,{text:"No process snapshot available."});const n=e.executor.children??[],r=n.flatMap(b=>Dc(b)),i=r.reduce((b,N)=>b+N.cpu_ticks,0),a=r.reduce((b,N)=>b+nb(N),0),o=e.executor.service==="active",l=r.slice(0,8).map(b=>({label:`pid ${b.pid}`,ticks:b.cpu_ticks})),c=(e.samples??[]).map(b=>({label:ir(b.ts),ticks:b.cpu_ticks,io:b.io_bytes,active:b.active_since_last_sample?"active":"quiet"})),u=c.length>0?c:l,d=(h=e.samples)==null?void 0:h[e.samples.length-1];return s.jsxs("div",{className:"grid gap-4",children:[s.jsx("div",{className:"rounded-md border border-slate-200 bg-slate-50 p-3",children:s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:Q("inline-flex h-6 items-center rounded-full border px-2 text-xs font-semibold",o?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-slate-300 bg-white text-slate-600"),children:o?"active":"idle"}),s.jsxs("span",{className:"font-mono text-xs text-muted",children:["service ",e.executor.service]})]}),s.jsx("div",{className:"mt-2 text-sm font-semibold text-foreground",children:e.running_jobs.length>0?`${e.running_jobs.length} running job${e.running_jobs.length===1?"":"s"}`:"No running jobs"}),e.running_jobs.length>0?s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:e.running_jobs.slice(0,4).map(b=>s.jsxs("span",{className:"inline-flex min-h-6 items-center gap-1.5 rounded-full border border-blue-200 bg-white px-2 font-mono text-[11px] font-semibold text-blue-700",children:[s.jsx("span",{className:"h-2 w-2 rounded-full bg-blue-600 animate-live-pulse","aria-hidden":!0}),"#",b.id," ",Xe(b.age_seconds)]},b.id))}):null,d?s.jsxs("p",{className:"mt-1 text-xs text-muted",children:["Last persisted sample ",ir(d.ts)," · ",d.active_since_last_sample?"activity observed":`quiet ${Xe(d.idle_seconds)}`]}):null,s.jsx("p",{className:"mt-1 text-xs text-muted",children:e.detail})]}),s.jsxs("div",{className:"grid min-w-[190px] grid-cols-3 gap-2 text-center text-xs",children:[s.jsx(bs,{label:"PID",value:e.executor.pid?String(e.executor.pid):"n/a"}),s.jsx(bs,{label:"Children",value:String(r.length)}),s.jsx(bs,{label:"CPU ticks",value:String(i)})]})]})}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[s.jsx(Tr,{label:"Live process",value:((m=e.signals)==null?void 0:m.live_process.state)??(r.length>0?"live":"no_child_process"),detail:`${((p=e.signals)==null?void 0:p.live_process.child_count)??r.length} children`}),s.jsx(Tr,{label:"Process activity",value:((w=e.signals)==null?void 0:w.process_activity.state)??(d!=null&&d.active_since_last_sample?"active":"quiet"),detail:d?`sample ${ir(d.ts)}`:"no sample"}),s.jsx(Tr,{label:"Semantic progress",value:(y=e.signals)!=null&&y.semantic_progress.length?"recent":"none",detail:Zo(e.running_jobs,"semantic_progress")}),s.jsx(Tr,{label:"Visible progress",value:(v=e.signals)!=null&&v.visible_progress.length?"streaming":"none",detail:Zo(e.running_jobs,"visible_progress")})]}),e.alerts.length>0?s.jsx(be,{tone:"error",text:e.alerts[0]}):null,s.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[s.jsxs("div",{className:"min-w-0 rounded-md border border-border p-3",children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[s.jsxs("h3",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(ro,{className:"h-4 w-4","aria-hidden":!0}),c.length>0?"CPU history":"CPU ticks"]}),s.jsxs("span",{className:"font-mono text-xs text-muted",children:[Oc(a)," I/O"]})]}),u.length>0?s.jsx("div",{className:"h-40",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(dl,{data:u,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"label",tick:!1}),s.jsx(sn,{allowDecimals:!1,tick:{fontSize:11}}),s.jsx(cn,{formatter:b=>[Number(b),"cpu ticks"]}),s.jsx(ti,{type:"monotone",dataKey:"ticks",stroke:"#0f766e",strokeWidth:2,dot:{r:3},activeDot:{r:5},isAnimationActive:!1})]})})}):s.jsx(J,{text:"No executor CPU samples available."})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("h3",{className:"mb-2 flex items-center gap-2 text-sm font-semibold",children:[s.jsx(ro,{className:"h-4 w-4","aria-hidden":!0}),"Executor children"]}),n.length>0?s.jsx("div",{className:"grid gap-2",children:n.map(b=>s.jsx(Mc,{process:b},b.pid))}):s.jsx(J,{text:"No child process detected for the executor."})]})]})]})}function tb({alerts:e,loading:t,now:n}){if(t&&!e)return s.jsx(J,{text:"Loading monitor alerts..."});const r=e??[];return r.length===0?s.jsx(J,{text:"No active monitor alerts."}):s.jsx("div",{className:"grid gap-2",children:r.slice(0,5).map(i=>s.jsxs("div",{className:"rounded-md border border-red-200 bg-red-50 p-2.5",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs font-semibold text-red-700",children:[s.jsx(Hr,{className:"h-3.5 w-3.5","aria-hidden":!0}),s.jsx("span",{children:i.severity}),s.jsx("span",{className:"font-normal text-red-600",children:vc(i.last_seen,n)}),i.observations>1?s.jsxs("span",{className:"rounded-full border border-red-200 bg-white px-1.5",children:[i.observations,"x"]}):null]}),s.jsx("p",{className:"mt-1 break-words text-sm font-medium text-red-950 [overflow-wrap:anywhere]",children:i.message})]},i.fingerprint))})}function Mc({process:e}){var r,i;const t=((r=e.io_bytes)==null?void 0:r.read_bytes)??0,n=((i=e.io_bytes)==null?void 0:i.write_bytes)??0;return s.jsxs("div",{className:"rounded-md border border-border bg-white p-2.5",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[s.jsxs("span",{className:"font-mono",children:["pid ",e.pid]}),s.jsxs("span",{className:"rounded-full border border-border px-2 text-xs text-muted",children:["state ",e.state]}),s.jsxs("span",{className:"rounded-full border border-border px-2 text-xs text-muted",children:["cpu ",e.cpu_ticks]}),s.jsxs("span",{className:"rounded-full border border-border px-2 text-xs text-muted",children:["I/O ",Oc(t+n)]})]}),s.jsx("div",{className:"mt-2 break-words font-mono text-xs text-muted",children:e.cmd||"unknown command"}),e.children&&e.children.length>0?s.jsx("div",{className:"mt-3 border-l-2 border-border pl-3",children:e.children.map(a=>s.jsx(Mc,{process:a},a.pid))}):null]})}function bs({label:e,value:t}){return s.jsxs("div",{className:"rounded-md border border-border bg-white px-2 py-2",children:[s.jsx("div",{className:"font-mono text-sm font-semibold text-foreground",children:t}),s.jsx("div",{className:"mt-0.5 text-[11px] font-semibold uppercase text-muted",children:e})]})}function Tr({label:e,value:t,detail:n}){return s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-2.5",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted",children:e}),s.jsx("div",{className:"mt-1 truncate text-sm font-semibold text-foreground",children:t}),s.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-muted",children:n})]})}function Zo(e,t){const n=e.find(i=>i[t]),r=n==null?void 0:n[t];return!n||!r?"no running heartbeat":`#${n.id} ${r.phase} ${Xe(r.age_seconds??null)}`}function Dc(e){return[e,...(e.children??[]).flatMap(t=>Dc(t))]}function nb(e){var t,n;return(((t=e.io_bytes)==null?void 0:t.read_bytes)??0)+(((n=e.io_bytes)==null?void 0:n.write_bytes)??0)}function Oc(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(1)} MiB`}function $({label:e,value:t}){return s.jsxs("div",{className:"min-w-0 rounded-md border border-border p-3",children:[s.jsx("div",{className:"text-xs font-semibold text-muted",children:e}),s.jsx("div",{className:"mt-1 min-w-0 break-words text-sm [overflow-wrap:anywhere]",children:t})]})}function _i({status:e}){const t=Nx(e),n=e==="running"||e==="pending";return s.jsxs("span",{className:Q("inline-flex min-h-6 items-center gap-1.5 rounded-full border px-2 text-xs font-semibold",t.badge),children:[s.jsx("span",{className:Q("h-2.5 w-2.5 rounded-full",t.dot,n&&"animate-live-pulse"),"aria-hidden":!0}),e]})}function J({text:e}){return s.jsx("div",{className:"rounded-md border border-dashed border-border p-6 text-center text-sm text-muted",children:e})}function be({tone:e,text:t}){return s.jsx("div",{className:Q("rounded-md border p-3 text-sm",e==="error"&&"border-red-300 bg-red-50 text-red-700",e==="warning"&&"border-amber-300 bg-amber-50 text-amber-800"),children:t})}function nt({onClick:e,compactOnMobile:t=!1}){return s.jsxs("button",{className:Q("inline-flex h-8 items-center justify-center gap-2 rounded-md border border-border text-sm font-semibold text-foreground hover:bg-slate-50",t?"w-8 px-0 sm:w-auto sm:px-3":"px-3"),onClick:e,type:"button","aria-label":"Refresh",children:[s.jsx(zn,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{className:Q(t&&"hidden sm:inline"),children:"Refresh"})]})}const el=document.getElementById("root");el&&xu.createRoot(el).render(s.jsx(R.StrictMode,{children:s.jsx(Hu,{client:ux,children:s.jsx(Hx,{})})})); diff --git a/src/github_agent_bridge/dashboard_static/index.html b/src/github_agent_bridge/dashboard_static/index.html index 5d2e2ae..0f27a5f 100644 --- a/src/github_agent_bridge/dashboard_static/index.html +++ b/src/github_agent_bridge/dashboard_static/index.html @@ -4,7 +4,7 @@ GitHub Agent Bridge Dashboard - +