hammerkit 2.2.0-next.2 → 2.2.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dashboard/assets/{graph-canvas-D6GMgkoe.js → graph-canvas-D2f3lNda.js} +1 -1
- package/dist/dashboard/assets/{index-BNq9j5Jo.js → index-DE3NTbjw.js} +4 -4
- package/dist/dashboard/index.html +1 -1
- package/dist/executer/deadline.js +2 -3
- package/dist/executer/docker-task.js +19 -2
- package/dist/executer/execution-steps.js +36 -1
- package/dist/executer/get-container-binds.js +2 -1
- package/dist/remote/remote-status.js +2 -3
- package/dist/remote/remote-work-commands.js +16 -6
- package/dist/server/proposal-store.js +94 -0
- package/dist/server/proposals-api.js +3 -0
- package/dist/server/proposals.js +168 -19
- package/dist/server/runs.js +23 -18
- package/dist/server/server-config.js +6 -2
- package/dist/server/server.js +17 -2
- package/dist/utils/long-timer.js +33 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-canvas-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-canvas-D2f3lNda.js","assets/graph-canvas-DLioOiRN.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function ee(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function te(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function ne(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,ne(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),ne(o,r,i,``,function(e){return e})):o!=null&&(ee(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=ne(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=ne(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ne(te(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function re(e,t,n){if(e==null)return e;var r=[],i=0;return ne(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ie(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var ae=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function oe(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,ae)}catch(e){ae(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function se(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else oe(se.bind(null,e))}var ce={map:re,forEach:function(e,t,n){re(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return re(e,function(){t++}),t},toArray:function(e){return re(e,function(e){return e})||[]},only:function(e){if(!ee(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=ce,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=se,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=ee,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ie}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=oe,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),u=o(((e,t)=>{t.exports=l()})),d=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&A(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&A(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var ee=new MessageChannel,k=ee.port2;ee.port1.onmessage=D,O=function(){k.postMessage(null)}}else O=function(){_(D,0)};function A(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,A(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{var t=u();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=d(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=d(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.1`})),m=o(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=p()})),h=o((e=>{var t=f(),n=u(),r=m();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function d(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}function h(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&h(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function g(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function _(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function v(e){var t=[null,null],n=g(e);return n===null||y(t,e,n.child,{foundSelf:!1}),t}function y(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&y(e,t,n.child,r))return!0;n=n.sibling}return!1}function b(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var x=null,S=null;function C(e,t,n){return e===n||e===t&&(x=e,!0)}function w(e,t,n){return e===n?(S=e,!1):e===t&&(S!==null&&(x=e),!0)}function T(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function E(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var D=Object.assign,O=Symbol.for(`react.element`),ee=Symbol.for(`react.transitional.element`),k=Symbol.for(`react.portal`),A=Symbol.for(`react.fragment`),j=Symbol.for(`react.strict_mode`),te=Symbol.for(`react.profiler`),ne=Symbol.for(`react.consumer`),re=Symbol.for(`react.context`),ie=Symbol.for(`react.forward_ref`),ae=Symbol.for(`react.suspense`),oe=Symbol.for(`react.suspense_list`),se=Symbol.for(`react.memo`),ce=Symbol.for(`react.lazy`),le=Symbol.for(`react.activity`),ue=Symbol.for(`react.legacy_hidden`),de=Symbol.for(`react.memo_cache_sentinel`),fe=Symbol.for(`react.view_transition`),pe=Symbol.for(`react.recoverable`),me=Symbol.iterator;function he(e){return typeof e!=`object`||!e?null:(e=me&&e[me]||e[`@@iterator`],typeof e==`function`?e:null)}var M=Symbol.for(`react.client.reference`);function ge(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===M?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case A:return`Fragment`;case te:return`Profiler`;case j:return`StrictMode`;case ae:return`Suspense`;case oe:return`SuspenseList`;case le:return`Activity`;case fe:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case k:return`Portal`;case re:return e.displayName||`Context`;case ne:return(e._context.displayName||`Context`)+`.Consumer`;case ie:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case se:return t=e.displayName||null,t===null?ge(e.type)||`Memo`:t;case ce:t=e._payload,e=e._init;try{return ge(e(t))}catch{}}return null}var _e=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ve={pending:!1,data:null,method:null,action:null},ye=[],be=-1;function xe(e){return{current:e}}function Se(e){0>be||(e.current=ye[be],ye[be]=null,be--)}function F(e,t){be++,ye[be]=e.current,e.current=t}var Ce=xe(null),we=xe(null),Te=xe(null),Ee=xe(null);function De(e,t){switch(F(Te,t),F(we,e),F(Ce,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Se(Ce),F(Ce,e)}function Oe(){Se(Ce),Se(we),Se(Te)}function ke(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,F(Ee,e)),t=Ce.current;var n=dp(t,e.type);t!==n&&(F(we,e),F(Ce,n))}function Ae(e){we.current===e&&(Se(Ce),Se(we)),Ee.current===e&&(Se(Ee),sh._currentValue=ve)}var je,Me;function Ne(e){if(je===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);je=t&&t[1]||``,Me=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+je+e+Me}var Pe=!1;function Fe(e,t){if(!e||Pe)return``;Pe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -11,13 +11,13 @@ Error generating stack: `+e.message+`
|
|
|
11
11
|
`))t+=Zo(n.codePointAt(0)??0)?`?`:n;return t}function Qo(e){return U(e).replace(/\n/g,`?`)}function $o(e,t){return e.length>t?`${e.slice(0,t)}…`:e}function es(e){return e===void 0?``:Go(e)}function ts(e,t){let n=Date.parse(e??``);if(!Number.isFinite(n))return``;let r=n-t;if(Math.abs(r)<1e3)return`now`;let i=Go(Math.abs(r));return r>0?`in ${i}`:`${i} ago`}function ns(e=5e3){let[t,n]=(0,j.useState)(()=>Date.now());return(0,j.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function W({children:e}){return(0,L.jsx)(L.Fragment,{children:U(e??``)})}function G({children:e,className:t=``}){return(0,L.jsx)(`code`,{className:`font-mono text-[0.85em] break-all ${t}`,children:(0,L.jsx)(W,{children:e})})}function K({children:e}){return(0,L.jsx)(`span`,{className:`text-stone-500 dark:text-stone-400`,children:e})}function q({children:e,note:t}){return(0,j.useEffect)(()=>{document.title=`${U(e)} · hammerkit`},[e]),(0,L.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,L.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight break-all`,children:(0,L.jsx)(W,{children:e})}),t?(0,L.jsx)(`p`,{className:`text-sm text-stone-500 dark:text-stone-400`,children:t}):null]})}function rs({title:e,note:t,children:n,id:r}){return(0,L.jsxs)(`section`,{className:`mb-8`,id:r,children:[(0,L.jsxs)(`h2`,{className:`mb-3 flex flex-wrap items-baseline gap-x-2 text-base font-semibold`,children:[e,t?(0,L.jsx)(`span`,{className:`text-sm font-normal text-stone-500 dark:text-stone-400`,children:t}):null]}),n]})}function is({children:e,className:t=``}){return(0,L.jsx)(`div`,{className:`rounded-lg border border-stone-200 bg-white p-4 shadow-xs dark:border-stone-800 dark:bg-stone-900 ${t}`,children:e})}function as({children:e}){return(0,L.jsx)(`p`,{className:`text-sm text-stone-500 dark:text-stone-400`,children:e})}function os({items:e,columns:t=`grid-cols-[max-content_1fr]`}){return(0,L.jsx)(`dl`,{className:`grid ${t} gap-x-4 gap-y-1.5 text-sm`,children:e.map(([e,t],n)=>(0,L.jsxs)(`div`,{className:`contents`,children:[(0,L.jsx)(`dt`,{className:`text-stone-500 dark:text-stone-400`,children:e}),(0,L.jsx)(`dd`,{className:`min-w-0 break-words`,children:t})]},n))})}var ss={up:`text-emerald-700 border-emerald-600/40 bg-emerald-50 dark:text-emerald-300 dark:bg-emerald-950`,succeeded:`text-emerald-700 border-emerald-600/40 bg-emerald-50 dark:text-emerald-300 dark:bg-emerald-950`,approved:`text-emerald-700 border-emerald-600/40 bg-emerald-50 dark:text-emerald-300 dark:bg-emerald-950`,published:`text-emerald-700 border-emerald-600/40 bg-emerald-50 dark:text-emerald-300 dark:bg-emerald-950`,cached:`text-emerald-700 border-emerald-600/40 bg-emerald-50 dark:text-emerald-300 dark:bg-emerald-950`,failed:`text-red-700 border-red-600/40 bg-red-50 dark:text-red-300 dark:bg-red-950`,rejected:`text-red-700 border-red-600/40 bg-red-50 dark:text-red-300 dark:bg-red-950`,running:`text-sky-700 border-sky-600/40 bg-sky-50 dark:text-sky-300 dark:bg-sky-950`,queued:`text-sky-700 border-sky-600/40 bg-sky-50 dark:text-sky-300 dark:bg-sky-950`,asleep:`text-amber-700 border-amber-600/40 bg-amber-50 dark:text-amber-300 dark:bg-amber-950`,"awaiting-approval":`text-amber-700 border-amber-600/40 bg-amber-50 dark:text-amber-300 dark:bg-amber-950`,waiting:`text-amber-700 border-amber-600/40 bg-amber-50 dark:text-amber-300 dark:bg-amber-950`},cs=(0,L.jsx)(`path`,{d:`M4.75 8.25l2.25 2.25 4.25-4.5`}),ls=(0,L.jsx)(`path`,{d:`M5.5 5.5l5 5M10.5 5.5l-5 5`}),us=(0,L.jsx)(`path`,{d:`M6.5 5.5v5M9.5 5.5v5`}),ds={succeeded:cs,approved:cs,cached:(0,L.jsx)(`path`,{d:`M8.75 3.75L5.25 8.75h3l-1 3.5 3.5-5h-3z`,className:`fill-current`,strokeWidth:`1`}),failed:ls,rejected:ls,cancelled:(0,L.jsx)(`path`,{d:`M5 8h6`}),published:cs,yanked:(0,L.jsx)(`path`,{d:`M5 8h6`}),skipped:(0,L.jsx)(`path`,{d:`M5.5 5.25L8.5 8l-3 2.75M10.5 5.25v5.5`}),running:(0,L.jsx)(`path`,{d:`M8 4a4 4 0 0 1 4 4`,className:`origin-center animate-spin`}),up:(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:`2.25`,className:`fill-current stroke-none`}),queued:(0,L.jsxs)(`g`,{className:`fill-current stroke-none`,children:[(0,L.jsx)(`circle`,{cx:`5`,cy:`8`,r:`1`}),(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1`}),(0,L.jsx)(`circle`,{cx:`11`,cy:`8`,r:`1`})]}),asleep:(0,L.jsx)(`path`,{d:`M10.75 9.5A3.5 3.5 0 0 1 6.5 5.25a3.5 3.5 0 1 0 4.25 4.25z`}),"awaiting-approval":us,waiting:us,expired:(0,L.jsx)(`path`,{d:`M8 5v3l2 1.5`})};function fs({state:e}){return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full border align-middle ${ss[e]??`border-stone-300 text-stone-600 dark:border-stone-700 dark:text-stone-300`}`,children:(0,L.jsx)(`svg`,{viewBox:`0 0 16 16`,className:`h-4 w-4 fill-none stroke-current`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,children:ds[e]??(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1.25`,className:`fill-current stroke-none`})})})}function ps({state:e,detail:t}){let n=t?`${e}, ${t}`:e;return(0,L.jsx)(`span`,{role:`img`,"aria-label":n,title:n,className:`inline-flex align-middle`,children:(0,L.jsx)(fs,{state:e})})}function ms({state:e}){return(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 align-middle whitespace-nowrap`,children:[(0,L.jsx)(fs,{state:e}),e]})}function hs({tip:e,children:t}){let n=(0,j.useId)(),[r,i]=(0,j.useState)(null);(0,j.useEffect)(()=>{if(!r)return;let e=()=>i(null);return window.addEventListener(`scroll`,e,!0),()=>window.removeEventListener(`scroll`,e,!0)},[r]);let a=e=>i(e.currentTarget.getBoundingClientRect());return(0,L.jsxs)(`span`,{tabIndex:0,"aria-describedby":r?n:void 0,onMouseEnter:a,onFocus:a,onMouseLeave:()=>i(null),onBlur:()=>i(null),className:`cursor-default underline decoration-stone-400/70 decoration-dotted underline-offset-4 outline-none focus-visible:rounded-sm focus-visible:ring-2 focus-visible:ring-emerald-500 dark:decoration-stone-500/70`,children:[t,r?(0,qi.createPortal)((0,L.jsx)(`div`,{id:n,role:`tooltip`,style:{top:r.bottom+6,left:r.right},className:`pointer-events-none fixed z-50 -translate-x-full rounded-md border border-stone-200 bg-white px-2.5 py-1.5 text-left text-xs whitespace-nowrap text-stone-700 shadow-lg dark:border-stone-700 dark:bg-stone-800 dark:text-stone-200`,children:e}),document.body):null]})}function gs({iso:e,now:t}){if(!e||!Number.isFinite(Date.parse(e)))return null;let n=new Date(e),r=n.toLocaleString(void 0,{month:`short`,day:`numeric`,...n.getFullYear()===new Date(t).getFullYear()?{}:{year:`numeric`},hour:`numeric`,minute:`2-digit`,second:`2-digit`});return(0,L.jsx)(`time`,{dateTime:e,title:ts(e,t),children:r})}function _s({value:e,max:t,also:n,full:r}){let i=e=>t&&e!==void 0?Math.min(100,e/t*100):0;return(0,L.jsxs)(`div`,{className:`relative h-2 overflow-hidden rounded-full bg-stone-200 dark:bg-stone-800`,children:[n===void 0?null:(0,L.jsx)(`div`,{className:`absolute inset-y-0 left-0 rounded-full bg-emerald-600/30 dark:bg-emerald-400/30`,style:{width:`${i(n)}%`}}),(0,L.jsx)(`div`,{className:`absolute inset-y-0 left-0 rounded-full ${r?`bg-amber-500`:`bg-emerald-600 dark:bg-emerald-500`}`,style:{width:`${i(e)}%`}})]})}function vs({id:e,children:t}){return(0,L.jsx)(Li,{to:`/runs/${encodeURIComponent(e)}`,className:`link font-mono text-[0.85em]`,children:t??U(e)})}function ys({who:e}){return(0,L.jsx)(`span`,{title:e.name?`${e.sub}${e.iss?` at ${e.iss}`:``}`:e.iss,children:(0,L.jsx)(W,{children:e.name??e.sub})})}function bs({run:e}){return e.owner?(0,L.jsxs)(`span`,{className:`ml-1 text-xs text-stone-500 dark:text-stone-400`,children:[`of `,(0,L.jsx)(ys,{who:e.owner})]}):null}function xs({run:e}){return e.up?(0,L.jsxs)(`span`,{children:[(0,L.jsx)(G,{children:e.up.name}),`: up `,(0,L.jsx)(W,{children:e.up.services.join(`, `)})]}):e.tasks.length>0?(0,L.jsx)(W,{children:e.tasks.join(`, `)}):(0,L.jsx)(K,{children:`by labels`})}function Ss({href:e,children:t}){return e?(0,L.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`underline decoration-stone-400/40 underline-offset-2 hover:decoration-current dark:decoration-stone-500/50`,children:t}):(0,L.jsx)(L.Fragment,{children:t})}function Cs({repo:e,gitRef:t,commit:n}){let r=V(e);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Ss,{href:r?.repo,children:(0,L.jsx)(W,{children:e})}),t||n?(0,L.jsx)(`br`,{}):null,(0,L.jsxs)(`span`,{className:`text-xs`,children:[t?(0,L.jsx)(Ss,{href:r?.ref?.(t),children:(0,L.jsx)(G,{children:t})}):null,t&&n?` at `:null,n?(0,L.jsx)(Ss,{href:r?.commit?.(n),children:(0,L.jsx)(G,{children:n.slice(0,12)})}):null]})]})}function ws({run:e}){let t=e.source;if(t.type===`ref`)return(0,L.jsx)(`span`,{children:(0,L.jsx)(Cs,{repo:t.repo,gitRef:t.ref,commit:t.commit})});if(t.type===`sandbox`){let e=V(t.repo);return(0,L.jsxs)(`span`,{children:[`sandbox `,(0,L.jsx)(G,{children:t.id}),(0,L.jsx)(`br`,{}),(0,L.jsxs)(`span`,{className:`text-xs`,children:[(0,L.jsx)(Ss,{href:e?.repo,children:(0,L.jsx)(W,{children:t.repo})}),` `,`at`,` `,(0,L.jsx)(Ss,{href:e?.commit?.(t.commit),children:(0,L.jsx)(G,{children:t.commit.slice(0,12)})}),t.clean===!1?` with changes`:``]})]})}return(0,L.jsx)(`span`,{children:`an upload`})}function Ts({query:e,children:t,missing:n}){if(e.isPending)return(0,L.jsx)(as,{children:`Loading…`});if(e.isError){let t=e.error;return t instanceof Do&&t.status===404&&n?(0,L.jsx)(L.Fragment,{children:n}):(0,L.jsx)(Es,{error:t})}return(0,L.jsx)(L.Fragment,{children:t(e.data)})}function Es({error:e,then:t=`to decide`}){return e instanceof Do&&e.signInAgain?(0,L.jsxs)(`p`,{className:`text-sm text-red-700 dark:text-red-400`,children:[U(e.message),`.`,` `,(0,L.jsx)(`a`,{className:`link`,href:Oo(),children:`Sign in again`}),` `,t,`.`]}):(0,L.jsx)(`p`,{className:`text-sm text-red-700 dark:text-red-400`,children:U(e instanceof Error?e.message:String(e))})}function Ds({children:e,tone:t=`plain`,...n}){let r={plain:`border-stone-300 bg-white hover:bg-stone-50 dark:border-stone-700 dark:bg-stone-900 dark:hover:bg-stone-800`,good:`border-emerald-700 bg-emerald-600 text-white hover:bg-emerald-700`,danger:`border-red-300 bg-white text-red-700 hover:bg-red-50 dark:border-red-900 dark:bg-stone-900 dark:text-red-400 dark:hover:bg-red-950`};return(0,L.jsx)(`button`,{...n,className:`rounded-md border px-3 py-1 text-sm font-medium disabled:opacity-50 ${r[t]} ${n.className??``}`,children:e})}var Os=`-mx-3 bg-emerald-500/15 px-3 text-emerald-300`,ks=`-mx-3 bg-red-500/15 px-3 text-red-300`,As=`rounded-md border border-stone-300 bg-white px-2 py-1 text-sm dark:border-stone-700 dark:bg-stone-900`,js=[`1h`,`8h`,`24h`,`72h`],Ms=`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border align-middle disabled:opacity-50`;function Ns({run:e}){let t=Ro(()=>Po(`/v1/runs/${encodeURIComponent(e.id)}/cancel`));return e.may?.stop?(0,L.jsxs)(`span`,{className:`inline-flex flex-col items-start gap-1`,children:[(0,L.jsx)(`button`,{type:`button`,title:`Stop`,"aria-label":`Stop ${e.id}`,disabled:t.isPending,onClick:()=>{window.confirm(`Stop ${e.id}?`)&&t.mutate()},className:`${Ms} border-red-300 text-red-700 hover:bg-red-50 dark:border-red-900 dark:text-red-400 dark:hover:bg-red-950`,children:(0,L.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-3.5 w-3.5 fill-current`,children:(0,L.jsx)(`rect`,{x:`3.5`,y:`3.5`,width:`9`,height:`9`,rx:`1.5`})})}),t.error?(0,L.jsx)(Es,{error:t.error}):null]}):null}function Ps({run:e}){let t=vr(),n=Ro(()=>Po(`/v1/runs/${encodeURIComponent(e.id)}/retry`));return e.may?.retry?(0,L.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,L.jsx)(`button`,{type:`button`,title:`Retry: start it again as a new run`,"aria-label":`Retry ${e.id}`,disabled:n.isPending,onClick:()=>n.mutate(void 0,{onSuccess:e=>t(`/runs/${encodeURIComponent(e.id)}`)}),className:`${Ms} border-stone-300 hover:bg-stone-50 dark:border-stone-700 dark:hover:bg-stone-800`,children:(0,L.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4 fill-none stroke-current`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,L.jsx)(`path`,{d:`M13 8a5 5 0 1 1-1.46-3.54M13 2.5v3h-3`})})}),n.error?(0,L.jsx)(`div`,{role:`alert`,title:`Close`,onClick:()=>n.reset(),className:`absolute top-full cursor-pointer right-0 z-10 mt-1 w-80 rounded-md border border-red-200 bg-white p-2 text-left shadow-sm [overflow-wrap:anywhere] dark:border-red-900 dark:bg-stone-900`,children:(0,L.jsx)(Es,{error:n.error,then:`to retry it`})}):null]}):null}function Fs({run:e}){let t=Ro(()=>Po(`/v1/runs/${encodeURIComponent(e.id)}/wake`));return e.may?.wake?(0,L.jsxs)(`span`,{className:`inline-flex flex-col items-start gap-1`,children:[(0,L.jsx)(`button`,{type:`button`,title:`Start`,"aria-label":`Start ${e.id}`,disabled:t.isPending,onClick:()=>t.mutate(),className:`${Ms} border-emerald-600/50 text-emerald-700 hover:bg-emerald-50 dark:border-emerald-700 dark:text-emerald-400 dark:hover:bg-emerald-950`,children:(0,L.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-3.5 w-3.5 fill-current`,children:(0,L.jsx)(`path`,{d:`M5 3.25v9.5a.75.75 0 0 0 1.14.64l7.5-4.75a.75.75 0 0 0 0-1.28l-7.5-4.75A.75.75 0 0 0 5 3.25z`})})}),t.error?(0,L.jsx)(Es,{error:t.error}):null]}):null}function Is({run:e}){let t=Ro(t=>Po(`/v1/runs/${encodeURIComponent(e.id)}/extend`,{ttl:t})),[n,r]=(0,j.useState)(null),i=(0,j.useId)();return(0,j.useEffect)(()=>{if(!n)return;let e=e=>{(e instanceof KeyboardEvent?e.key===`Escape`:!e.target.closest?.(`[data-menu="${i}"]`))&&r(null)},t=()=>r(null);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,e),window.addEventListener(`scroll`,t,!0),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,e),window.removeEventListener(`scroll`,t,!0)}},[n,i]),e.may?.extend?(0,L.jsxs)(`span`,{className:`inline-flex flex-col items-start gap-1`,children:[(0,L.jsx)(`button`,{type:`button`,"data-menu":i,title:`Extend`,"aria-label":`Extend ${e.id}`,"aria-haspopup":`menu`,"aria-expanded":!!n,disabled:t.isPending,onClick:e=>r(n?null:e.currentTarget.getBoundingClientRect()),className:`${Ms} border-stone-300 hover:bg-stone-50 dark:border-stone-700 dark:hover:bg-stone-800`,children:(0,L.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4 fill-none stroke-current`,strokeWidth:`1.5`,strokeLinecap:`round`,children:(0,L.jsx)(`path`,{d:`M12.5 8.5a5 5 0 1 1-4-4.9M7.5 6v3l2 1.25M12.5 1.5v4M10.5 3.5h4`})})}),n?(0,qi.createPortal)((0,L.jsxs)(`div`,{role:`menu`,"data-menu":i,"aria-label":`Keep it up for`,style:{top:n.bottom+4,left:n.left},className:`fixed z-50 flex flex-col rounded-md border border-stone-200 bg-white py-1 text-sm shadow-lg dark:border-stone-700 dark:bg-stone-800`,children:[(0,L.jsx)(`span`,{className:`px-3 py-1 text-xs text-stone-500 dark:text-stone-400`,children:`Keep it up for`}),js.map(e=>(0,L.jsx)(`button`,{type:`button`,role:`menuitem`,className:`px-3 py-1 text-left hover:bg-stone-100 dark:hover:bg-stone-700`,onClick:()=>{r(null),t.mutate(e)},children:e},e))]}),document.body):null,t.error?(0,L.jsx)(Es,{error:t.error}):null]}):null}function Ls({path:e,yes:t,why:n=!0,onDone:r}){let i=Lo(),a=ns(),[o,s]=(0,j.useState)(``),c=Ro(t=>Po(`${e}/${t}`,t===`reject`&&o.trim()?{reason:o.trim().slice(0,500)}:{})),l=i.data?.decideUntil;if(l&&Date.parse(l)<a)return(0,L.jsxs)(`p`,{className:`text-sm text-stone-500 dark:text-stone-400`,children:[`Your sign-in is older than `,i.data?.decideWithinMinutes,` minutes.`,` `,(0,L.jsx)(`a`,{className:`link`,href:Oo(),children:`Sign in again`}),` `,`to decide.`]});if(c.isSuccess)return(0,L.jsx)(as,{children:`Done.`});let u=e=>c.mutate(e,{onSuccess:()=>r?.()});return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(Ds,{tone:`good`,onClick:()=>u(`approve`),disabled:c.isPending,children:t}),n?(0,L.jsx)(`input`,{className:`${As} min-w-0 flex-1 sm:max-w-xs`,value:o,maxLength:500,onChange:e=>s(e.target.value),placeholder:`why not (optional)`,"aria-label":`Why not`}):null,(0,L.jsx)(Ds,{tone:`danger`,onClick:()=>u(`reject`),disabled:c.isPending,children:`Reject`})]}),c.error?(0,L.jsx)(Es,{error:c.error}):null]})}function Rs({args:e}){return Array.isArray(e)&&e.length>0?(0,L.jsxs)(`p`,{className:`text-sm`,children:[`Arguments:`,` `,e.map((e,t)=>(0,L.jsx)(G,{className:`mr-1`,children:JSON.stringify(e)},t))]}):null}function zs({name:e,entry:t,relations:n=!0}){return(0,L.jsxs)(`div`,{className:`text-sm`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[e?(0,L.jsx)(`strong`,{children:(0,L.jsx)(G,{children:e})}):null,(0,L.jsxs)(K,{children:[t.kind,`, `,t.runtime]}),t.image?(0,L.jsx)(G,{className:`text-stone-500`,children:t.image}):null]}),t.description?(0,L.jsx)(`div`,{className:`text-xs`,children:(0,L.jsx)(W,{children:t.description})}):null,t.cmds.length>0?(0,L.jsx)(`pre`,{className:`log my-1`,children:t.cmds.map(e=>`$ ${U(e)}`).join(`
|
|
12
12
|
`)}):null,(0,L.jsx)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:[n&&t.deps.length>0?`after ${t.deps.join(`, `)}`:``,n&&t.needs.length>0?`needs ${t.needs.join(`, `)}`:``,...t.secrets.map(e=>`secret ${e.from}${e.account?` as ${e.account}`:``} → ${e.target}`),t.mounts.length>0?`mounts ${t.mounts.join(`, `)}`:``,t.ports.length>0?`ports ${t.ports.join(`, `)}`:``,t.capAdd?.length?`capAdd ${t.capAdd.join(`, `)}`:``].filter(Boolean).map(U).join(` · `)})]})}function Bs({run:e}){let t=e.up?.endpoints??[];if(t.length===0)return(0,L.jsx)(K,{children:`none`});let n=e=>t.filter(t=>t.service===e.service).length>1?`${e.service}:${e.port}`:e.service;return(0,L.jsx)(`span`,{className:`flex flex-col`,children:t.map(e=>e.url&&/^https?:\/\//.test(e.url)?(0,L.jsx)(`a`,{className:`link`,href:e.url,rel:`noreferrer`,title:`${e.service}:${e.port}`,children:(0,L.jsx)(W,{children:n(e)})},e.url):(0,L.jsx)(`span`,{title:`${e.service}:${e.port}`,children:(0,L.jsx)(W,{children:n(e)})},`${e.service}:${e.port}`))})}function Vs({run:e,now:t}){return e.state===`up`&&e.sleepsAt?(0,L.jsx)(gs,{iso:e.sleepsAt,now:t}):e.up?.sleepTtl?(0,L.jsxs)(`span`,{children:[`after `,Xo(e.up.sleepTtl)]}):(0,L.jsx)(K,{children:`never`})}function Hs({head:e,children:t,sort:n,right:r}){return(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-stone-200 bg-white dark:border-stone-800 dark:bg-stone-900`,children:(0,L.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,L.jsx)(`thead`,{className:`border-b border-stone-200 text-xs text-stone-500 dark:border-stone-800 dark:text-stone-400`,children:(0,L.jsx)(`tr`,{children:e.map((e,t)=>{let i=n?.keys[t],a=!!n&&i!==void 0&&n.state.key===i,o=!!r?.[t],s=(0,L.jsx)(`span`,{"aria-hidden":`true`,className:a?``:`invisible`,children:a&&n?.state.dir===`asc`?`↑`:`↓`});return(0,L.jsx)(`th`,{className:`px-3 py-2 font-medium whitespace-nowrap ${o?`text-right`:``}`,"aria-sort":a?n.state.dir===`asc`?`ascending`:`descending`:void 0,children:n&&i!==void 0?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>n.onSort(i),className:`inline-flex cursor-pointer items-center gap-1 hover:text-stone-900 dark:hover:text-white ${a?`text-stone-900 dark:text-white`:``}`,children:[o?s:null,e,o?null:s]}):e},t)})})}),(0,L.jsx)(`tbody`,{className:`divide-y divide-stone-100 dark:divide-stone-800`,children:t})]})})}function Us(e,t,n){let[r,i]=(0,j.useState)(n),a=t[r.key];return{rows:[...e].sort((e,t)=>{let n=a(e),i=a(t);if(n===void 0||i===void 0)return n===i?0:n===void 0?1:-1;let o=typeof n==`number`&&typeof i==`number`?n-i:String(n).localeCompare(String(i));return r.dir===`asc`?o:-o}),state:r,onSort:n=>i(r=>r.key===n?{key:n,dir:r.dir===`asc`?`desc`:`asc`}:{key:n,dir:e.some(e=>typeof t[n](e)==`number`)?`desc`:`asc`})}}function J({children:e,num:t,className:n=``}){return(0,L.jsx)(`td`,{className:`px-3 py-2 align-top ${t?`text-right whitespace-nowrap tabular-nums`:``} ${n}`,children:e})}function Ws({label:e,tabs:t,current:n,onChange:r}){return(0,L.jsx)(`div`,{role:`tablist`,"aria-label":e,className:`mb-4 flex gap-1 overflow-x-auto overflow-y-hidden border-b border-stone-200 text-sm [scrollbar-width:none] dark:border-stone-800`,children:t.map(e=>{let t=e.key===n;return(0,L.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,onClick:()=>r(e.key),className:`flex cursor-pointer items-baseline gap-1.5 border-b-2 px-3 py-2 whitespace-nowrap ${t?`border-emerald-500 font-medium text-stone-900 dark:text-white`:`border-transparent text-stone-600 hover:border-stone-300 hover:text-stone-900 dark:text-stone-300 dark:hover:border-stone-600 dark:hover:text-white`}`,children:[e.name,e.note===void 0?null:(0,L.jsx)(`span`,{className:`text-xs font-normal text-stone-500 tabular-nums dark:text-stone-400`,children:e.note})]},e.key)})})}var Gs=e=>`${Ko(e)} ${e===1?`core`:`cores`}`;function Ks({capacity:e}){let{machines:t,runs:n}=e,r=e.backend===`kubernetes`,i=(i,a)=>{let o=a===`cpu`?Gs:Jo,s=t?.allocatable[a],c=n.used?.[a],l=n.requested[a],u=t?.used?.[a],d=r?l??c:c??u,f=[l!==void 0&&r?`runs requested ${o(l)}`:``,c===void 0?``:`runs use ${o(c)}`,u===void 0?``:`${r?`the nodes use`:`the machine uses`} ${o(u)}`].filter(Boolean),p=e=>e?` (${e})`:``,m=[s===void 0?`total${p(e.unknown?.total)}`:``,c===void 0&&u===void 0?`use${p(e.unknown?.used)}`:``].filter(Boolean);return(0,L.jsxs)(is,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,L.jsx)(`strong`,{className:`text-sm`,children:i}),s===void 0?null:(0,L.jsxs)(`span`,{className:`text-sm tabular-nums`,title:f.join(` · `)||void 0,children:[d===void 0?``:`${a===`cpu`?Ko(d):Jo(d)} `,(0,L.jsxs)(K,{children:[`of `,o(s)]})]})]}),s===void 0?null:(0,L.jsx)(_s,{value:d,max:s,also:u}),m.length>0?(0,L.jsx)(`div`,{className:`text-xs`,children:(0,L.jsxs)(K,{children:[`not known: `,m.join(` · `)]})}):null]})};return(0,L.jsxs)(L.Fragment,{children:[i(`CPU`,`cpu`),i(`Memory`,`memory`),t?.load?(0,L.jsxs)(is,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(`strong`,{className:`text-sm`,children:`Load`}),(0,L.jsxs)(`div`,{className:`text-sm tabular-nums`,children:[t.load.map(e=>e.toFixed(2)).join(` · `),` `,(0,L.jsx)(K,{children:`(1, 5, 15 min)`})]})]}):null]})}function qs(e){return e?`${Ko(e.cpu)} CPU · ${Jo(e.memory)}`:(0,L.jsx)(K,{children:`?`})}function Js(){let e=B(`/capacity`),t=Lo(),n=ns(),r=e=>e.owner?e.owner.iss===t.data?.iss&&e.owner.sub===t.data?.sub?`yours`:(0,L.jsx)(ys,{who:e.owner}):(0,L.jsx)(K,{children:`somebody else`}),i=e=>e.run?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(vs,{id:e.run}),` `,e.up?(0,L.jsxs)(`span`,{children:[(0,L.jsx)(G,{children:e.up.name}),`: up `,(0,L.jsx)(W,{children:e.up.services.join(`, `)})]}):(0,L.jsx)(W,{children:(e.tasks??[]).join(`, `)}),e.repo?(0,L.jsx)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:(0,L.jsx)(W,{children:e.repo})}):null]}):e.kind===`run`?(0,L.jsx)(K,{children:`a run of somebody else`}):e.kind===`sandbox`?`a sandbox: its files and commands`:(0,L.jsx)(K,{children:`pods of no run the server keeps`}),a=e.data?.uses??[],o=e.data;return o?(0,L.jsxs)(rs,{title:`Capacity`,note:(0,L.jsxs)(L.Fragment,{children:[o.backend===`kubernetes`?`on Kubernetes`:`on a host`,`, read `,(0,L.jsx)(gs,{iso:o.at,now:n})]}),children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,L.jsx)(Ks,{capacity:o}),(0,L.jsxs)(is,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(`strong`,{className:`text-sm`,children:`Runs`}),(0,L.jsxs)(`div`,{className:`text-xs`,children:[o.runs.pods===void 0?``:`${qo(o.runs.pods,`pod`)} · `,o.runs.containers===void 0?``:`${qo(o.runs.containers,`container`)} · `,`requested `,qs(o.runs.requested),o.runs.used?(0,L.jsxs)(L.Fragment,{children:[` · in use `,qs(o.runs.used)]}):null]})]})]}),a.length>0?(0,L.jsxs)(`div`,{className:`mt-4`,children:[(0,L.jsx)(`h3`,{className:`mb-2 text-sm font-medium`,children:`Active resources`}),(0,L.jsx)(Hs,{head:[`What`,`Whose`,`Requested`,`In use`],children:a.map((e,t)=>(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(J,{children:i(e)}),(0,L.jsx)(J,{children:r(e)}),(0,L.jsx)(J,{className:`whitespace-nowrap`,children:qs(e.requested)}),(0,L.jsx)(J,{className:`whitespace-nowrap`,children:qs(e.used)})]},e.run??t))})]}):null]}):null}function Ys(){let e=B(`/overview`),t=ns();return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{children:`Overview`}),(0,L.jsx)(Ts,{query:e,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Xs,{overview:e,now:t}),(0,L.jsx)(Js,{})]})})]})}function Xs({overview:e,now:t}){return e.queue.length===0?null:(0,L.jsx)(rs,{title:`Queue`,note:`in the order runs start`,children:(0,L.jsx)(`ol`,{className:`flex flex-col gap-2`,children:e.queue.map(e=>(0,L.jsxs)(`li`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1 rounded-lg border p-3 text-sm ${e.mine?`border-emerald-600/40 bg-emerald-50 dark:bg-emerald-950`:`border-stone-200 bg-white dark:border-stone-800 dark:bg-stone-900`}`,children:[(0,L.jsxs)(`span`,{className:`flex-1`,children:[(0,L.jsxs)(K,{children:[e.position,`. `]}),e.run?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(vs,{id:e.run.id}),` `,(0,L.jsx)(xs,{run:e.run}),(0,L.jsx)(bs,{run:e.run})]}):`a run of somebody else`]}),(0,L.jsxs)(`span`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:[e.run?`waiting ${es(Uo(e.run,t))} · `:``,`waits:`,` `,Yo(e.waitsFor,e.mine,!1)]})]},e.position))})})}function Zs(e,t,n){let[r,i=``]=e.split(`?`,2),a=new URLSearchParams(i);return a.set(`limit`,String(t)),n&&a.set(`cursor`,n),`${r}?${a}`}function Qs(e,t={}){let{limit:n=50,refresh:r=!0,enabled:i=!0}=t;return To({queryKey:[`api`,e,`pages`,n],queryFn:({pageParam:t})=>No(`/v1${Zs(e,n,t)}`),initialPageParam:void 0,getNextPageParam:e=>e.next,placeholderData:ba,refetchInterval:r?Io:!1,enabled:i,retry:(e,t)=>!(t instanceof Do&&t.status<500)&&e<2})}function $s(e,t,n){let r=new Map;for(let i of e.data?.pages??[])for(let e of t(i))r.has(n(e))||r.set(n(e),e);return[...r.values()]}function ec({query:e,root:t,compact:n}){let r=(0,j.useRef)(null),{hasNextPage:i,isFetchingNextPage:a,isFetchNextPageError:o,fetchNextPage:s}=e;return(0,j.useEffect)(()=>{let e=r.current;if(!e||!i||o||typeof IntersectionObserver>`u`)return;let n=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&!a&&s()},{root:t?.current??null,rootMargin:`200px`});return n.observe(e),()=>n.disconnect()},[i,a,o,s,t]),i?(0,L.jsxs)(`div`,{ref:r,className:`flex flex-col items-center gap-1 ${n?`py-1`:`mt-3`}`,children:[o?(0,L.jsx)(Es,{error:e.error}):null,(0,L.jsx)(`button`,{type:`button`,onClick:()=>void s(),disabled:a,className:`text-emerald-700 hover:underline disabled:text-stone-500 disabled:no-underline dark:text-emerald-400 ${n?`text-xs`:`text-sm`}`,children:a?`Loading…`:`Load more`})]}):null}function tc(e,t=250){let[n,r]=(0,j.useState)(e);return(0,j.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function nc(e,t){let n=new URLSearchParams(e);for(let[e,r]of Object.entries(t))for(let t of r)n.append(e,t);return n}var rc=30;function ic({name:e,options:t,values:n,label:r,chosen:i,onChange:a}){let[o,s]=(0,j.useState)(!1),[c,l]=(0,j.useState)(``),u=(0,j.useRef)(null);(0,j.useEffect)(()=>{if(!o)return;let e=e=>{(e instanceof KeyboardEvent?e.key===`Escape`:!u.current?.contains(e.target))&&s(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,e)}},[o]);let d=e=>U(r?.(e)??e.name??e.value),f=e=>a(i.includes(e)?i.filter(t=>t!==e):[...i,e]),p=i.length>0;return(0,L.jsxs)(`div`,{ref:u,className:`relative`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>s(!o),"aria-haspopup":`true`,"aria-expanded":o,className:`inline-flex max-w-72 items-center gap-1.5 rounded-full border px-3 py-0.5 text-sm ${p?`border-emerald-600 bg-emerald-50 text-emerald-800 dark:border-emerald-500 dark:bg-emerald-950 dark:text-emerald-200`:`border-stone-300 text-stone-600 hover:border-stone-400 dark:border-stone-700 dark:text-stone-300 dark:hover:border-stone-500`}`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:e}),p?(0,L.jsx)(`span`,{className:`truncate`,children:i.length===1?d({value:i[0]}):`${i.length} chosen`}):null,(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs opacity-60`,children:`▾`})]}),o?(0,L.jsxs)(`div`,{role:`group`,"aria-label":e,className:`absolute left-0 z-20 mt-1 flex w-64 max-w-[calc(100vw-2rem)] flex-col rounded-lg border border-stone-200 bg-white py-1 text-sm shadow-lg dark:border-stone-700 dark:bg-stone-900`,children:[(0,L.jsx)(`div`,{className:`px-2 pt-1 pb-1.5`,children:(0,L.jsx)(`input`,{className:`${As} w-full`,value:c,onChange:e=>l(e.target.value),placeholder:`Search`,"aria-label":`Search ${e}`,autoFocus:!0})}),n===void 0?(0,L.jsx)(sc,{options:(t??[]).filter(e=>ac(e,d(e),c)),chosen:i,search:c,nameOf:d,toggle:f}):(0,L.jsx)(oc,{path:n,search:c,chosen:i,nameOf:d,toggle:f}),p?(0,L.jsx)(`button`,{type:`button`,onClick:()=>a([]),className:`mx-3 mt-1 border-t border-stone-200 pt-1.5 pb-0.5 text-left text-xs text-emerald-700 hover:underline dark:border-stone-700 dark:text-emerald-400`,children:`Clear`}):null]}):null]})}function ac(e,t,n){let r=n.trim().toLowerCase();return!r||e.value.toLowerCase().includes(r)||t.toLowerCase().includes(r)}function oc({path:e,search:t,chosen:n,nameOf:r,toggle:i}){let a=tc(t.trim()),o=(0,j.useRef)(null),s=Qs(`${e}${a?`&search=${encodeURIComponent(a)}`:``}`,{limit:rc,refresh:!1}),c=$s(s,e=>e.values,e=>e.value);return s.isPending?(0,L.jsx)(`p`,{className:`px-3 py-1.5 text-stone-500 dark:text-stone-400`,children:`Loading…`}):s.isError&&!s.data?(0,L.jsx)(`p`,{className:`px-3 py-1.5 text-red-700 dark:text-red-400`,children:U(s.error.message)}):(0,L.jsx)(sc,{options:c,chosen:n,search:t,nameOf:r,toggle:i,list:o,children:(0,L.jsx)(ec,{query:s,root:o,compact:!0})})}function sc({options:e,chosen:t,search:n,nameOf:r,toggle:i,list:a,children:o}){let s=[...t.filter(t=>!e.some(e=>e.value===t)).map(e=>({value:e})).filter(e=>ac(e,r(e),n)),...e];return(0,L.jsxs)(`div`,{ref:a,className:`flex max-h-72 flex-col overflow-y-auto`,children:[s.length===0?(0,L.jsx)(`p`,{className:`px-3 py-1.5 text-stone-500 dark:text-stone-400`,children:n.trim()?`Nothing is like that.`:`Nothing to choose.`}):s.map(e=>(0,L.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 px-3 py-1 hover:bg-stone-100 dark:hover:bg-stone-800`,children:[(0,L.jsx)(`input`,{type:`checkbox`,className:`accent-emerald-600`,checked:t.includes(e.value),onChange:()=>i(e.value)}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.value,children:r(e)}),e.count===void 0?null:(0,L.jsx)(`span`,{className:`text-xs text-stone-500 tabular-nums dark:text-stone-400`,children:e.count})]},e.value)),o]})}function cc(e,t){return(e.get(t)??``).split(`,`).filter(Boolean)}function lc(e,t,n){let r=new URLSearchParams(e);return n.length>0?r.set(t,n.join(`,`)):r.delete(t),r}function uc(e,t,n){let r=new Map;for(let n of e)for(let e of new Set(t(n)))r.set(e,(r.get(e)??0)+1);return[...r].sort(([e,t],[r,i])=>n?n.indexOf(e)-n.indexOf(r):i-t||e.localeCompare(r)).map(([e,t])=>({value:e,count:t}))}function dc(e){let t={name:``,dirs:new Map,files:[]};for(let n of e){let e=t;for(let t of n.path.split(`/`).slice(0,-1)){let n=e.dirs.get(t);n||(n={name:t,dirs:new Map,files:[]},e.dirs.set(t,n)),e=n}e.files.push(n)}let n=e=>{for(let[t,r]of e.dirs){let i=r;for(;i.files.length===0&&i.dirs.size===1;){let[e]=i.dirs.values();i={...e,name:`${i.name}/${e.name}`}}e.dirs.set(t,n(i))}return e};return n(t)}function fc({items:e,open:t,onOpen:n,className:r,extra:i}){let a=(e,o)=>(0,L.jsxs)(L.Fragment,{children:[[...e.dirs.values()].sort((e,t)=>e.name.localeCompare(t.name)).map(e=>(0,L.jsxs)(j.Fragment,{children:[(0,L.jsxs)(`li`,{className:`truncate py-0.5 text-stone-500 dark:text-stone-400`,style:{paddingLeft:`${o*.75}rem`},title:e.name,children:[e.name,`/`]}),a(e,o+1)]},`d:${e.name}`)),[...e.files].sort((e,t)=>e.path.localeCompare(t.path)).map(e=>{let a=e.path===t;return(0,L.jsx)(`li`,{style:{paddingLeft:`${o*.75}rem`},children:(0,L.jsxs)(`button`,{type:`button`,"aria-current":a?`true`:void 0,onClick:()=>n(e.path),title:e.path,className:`flex w-full cursor-pointer items-baseline gap-2 rounded px-1.5 py-0.5 text-left ${a?`bg-emerald-50 font-medium text-stone-900 dark:bg-emerald-950 dark:text-white`:`hover:bg-stone-100 dark:hover:bg-stone-800`}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate ${r?.(e)??``}`,children:U(e.path.split(`/`).pop()??e.path)}),i?(0,L.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums`,children:i(e)}):null]})},e.path)})]});return(0,L.jsx)(`nav`,{"aria-label":`Files`,className:`md:sticky md:top-4 md:max-h-[80vh] md:overflow-y-auto`,children:(0,L.jsx)(`ul`,{className:`font-mono text-[0.8rem]`,children:a(dc(e),0)})})}function pc({tree:e,children:t}){return(0,L.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-[minmax(12rem,18rem)_minmax(0,1fr)]`,children:[e,(0,L.jsx)(`div`,{className:`min-w-0`,children:t})]})}function mc(e,t=`file`){let[n,r]=Vi(),i=n.get(t);return[i!==null&&e.includes(i)?i:[...e].sort()[0],e=>{let i=new URLSearchParams(n);i.set(t,e),r(i,{replace:!0})}]}function hc({files:e}){let t=Object.keys(e),[n,r]=mc(t);if(!n)return(0,L.jsx)(K,{children:`No files.`});let i=e[n];return(0,L.jsxs)(pc,{tree:(0,L.jsx)(fc,{items:t.map(e=>({path:e})),open:n,onOpen:r,extra:({path:t})=>(0,L.jsx)(K,{children:e[t].split(`
|
|
13
13
|
`).length})}),children:[(0,L.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-baseline gap-2 text-sm`,children:[(0,L.jsx)(G,{children:n}),(0,L.jsxs)(K,{children:[i.split(`
|
|
14
|
-
`).length,` lines`]})]}),(0,L.jsx)(`pre`,{className:`log`,children:U(i)})]})}var gc=`modulepreload`,_c=function(e){return`/`+e},vc={},yc=function(e){return e.pathname.endsWith(`.css`)},bc=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},xc=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=_c(t,n);let r=s(t),i=yc(r);return bc(vc,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:gc,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Sc=(0,j.lazy)(()=>xc(()=>import(`./graph-canvas-
|
|
15
|
-
`)})]}):null,(0,L.jsxs)(`dl`,{className:`grid grid-cols-[7rem_1fr] gap-x-3 gap-y-1.5`,children:[n?.[e]?(0,L.jsx)(Pc,{name:`Sources`,children:(0,L.jsx)(Lc,{items:n[e].src})}):null,(0,L.jsx)(Pc,{name:`Generates`,children:(0,L.jsx)(Lc,{items:a.generates.map(Fc)})}),(0,L.jsx)(Pc,{name:`Secrets`,children:a.secrets.length>0?(0,L.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:a.secrets.map((e,t)=>(0,L.jsxs)(`li`,{children:[(0,L.jsx)(G,{children:e.target}),` `,(0,L.jsx)(K,{children:`from`}),` `,(0,L.jsx)(G,{children:e.from}),e.account?(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(K,{children:`as`}),` `,(0,L.jsx)(G,{children:e.account})]}):null]},t))}):(0,L.jsx)(K,{children:`none`})}),a.accounts.length>0?(0,L.jsx)(Pc,{name:`Accounts`,children:(0,L.jsx)(W,{children:a.accounts.join(`, `)})}):null,a.serverEnvs?.length?(0,L.jsx)(Pc,{name:`Server variables`,children:(0,L.jsx)(Lc,{items:a.serverEnvs})}):null,s?(0,L.jsx)(Pc,{name:`Network`,children:typeof s==`string`?s:(0,L.jsxs)(L.Fragment,{children:[`only `,(0,L.jsx)(W,{children:s.allow.join(`, `)})]})}):null,a.mounts.length>0?(0,L.jsx)(Pc,{name:`Mounts`,children:(0,L.jsx)(Lc,{items:a.mounts})}):null,a.ports.length>0?(0,L.jsx)(Pc,{name:`Ports`,children:(0,L.jsx)(Lc,{items:a.ports})}):null,a.capAdd?.length?(0,L.jsx)(Pc,{name:`Capabilities`,children:(0,L.jsx)(Lc,{items:a.capAdd})}):null,a.args===void 0?null:(0,L.jsx)(Pc,{name:`Arguments`,children:a.args?`taken`:`refused`})]})]})}function zc({title:e,status:t,tabs:n,onClose:r}){let[i,a]=(0,j.useState)(n[0]?.name),o=n.find(e=>e.name===i)??n[0];return(0,j.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,L.jsxs)(`aside`,{"aria-label":e,className:`fixed inset-y-0 right-0 z-40 flex w-full max-w-lg flex-col border-l border-stone-200 bg-white shadow-2xl dark:border-stone-800 dark:bg-stone-900`,children:[(0,L.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-stone-200 px-4 py-3 dark:border-stone-800`,children:[(0,L.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-mono text-sm font-semibold`,children:U(e)}),t,(0,L.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`Close`,className:`cursor-pointer rounded-md px-2 py-0.5 text-lg leading-none text-stone-500 hover:bg-stone-100 hover:text-stone-900 dark:hover:bg-stone-800 dark:hover:text-white`,children:`×`})]}),n.length>1?(0,L.jsx)(`div`,{role:`tablist`,"aria-label":`What ${e} shows`,className:`flex gap-1 px-4 pt-3 text-sm`,children:n.map(e=>(0,L.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===o,onClick:()=>a(e.name),className:`cursor-pointer rounded-md px-2.5 py-0.5 ${e===o?`bg-stone-200 font-medium text-stone-900 dark:bg-stone-700 dark:text-white`:`text-stone-600 hover:bg-stone-100 dark:text-stone-300 dark:hover:bg-stone-800`}`,children:e.name},e.name))}):null,(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:o?.content})]})}function Bc(e){return`/build-files/${zo(e)}`}function Vc({hash:e,entry:t}){return(0,L.jsx)(Li,{className:`link font-mono text-[0.85em]`,to:Bc(e),title:e,children:t?U(t):`${e.slice(0,19)}…`})}var Hc=`7d`,Uc=`last 7 days`,Wc=[`info`,`graph`,`files`];function Gc(){let e=Sr().hash??``,t=ns(),[n,r]=Vi(),i=n.get(`tab`),a=Wc.includes(i)?i:`info`,o=e=>{let t=new URLSearchParams(n);e===`info`?t.delete(`tab`):t.set(`tab`,e),r(t,{replace:!0})},[s,c]=(0,j.useState)(null),l=B(`/definitions/${zo(e)}`,{refresh:!1}),u=B(`/definitions/${zo(e)}/files`,{refresh:!1}),d=l.data?.annotations?.repo,f=B(`/tasks?since=${Hc}`,{enabled:!!d});return(0,L.jsx)(Ts,{query:l,missing:(0,L.jsx)(as,{children:`There is no such build file you may see.`}),children:e=>{let n=e.plan&&Tc(e.plan),r=Object.fromEntries((f.data?.tasks??[]).filter(e=>e.repo===d&&n?.[e.task]).map(e=>[e.task,e])),i=[qo(e.tasks.length,`task`),...e.services.length>0?[qo(e.services.length,`service`)]:[]].join(`, `),l=(0,L.jsx)(as,{children:`This version was published before the server kept what it runs.`}),p=u.data?Object.keys(u.data.files).length:void 0;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{children:e.entry}),(0,L.jsx)(Ws,{label:`What the build file shows`,tabs:[{key:`info`,name:`Info`},{key:`graph`,name:`Graph`,note:n?Object.keys(n).length:void 0},{key:`files`,name:`Files`,note:p}],current:a,onChange:o}),a===`info`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(is,{className:`mb-6`,children:(0,L.jsx)(os,{items:Kc(e,t)})}),d&&n?(0,L.jsx)(qc,{stats:Object.values(r),loading:f.isLoading}):null,(0,L.jsx)(rs,{title:`Tasks and services`,note:`${i}, a click on one opens it`,children:n?(0,L.jsx)(Xc,{plan:n,stats:d?r:void 0,onSelect:c}):l})]}):null,a===`graph`?n?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{className:`mb-2 text-sm text-stone-500 dark:text-stone-400`,children:[i,`, a click on one opens it`,d?`; each box says how often it came from the cache in the ${Uc}`:``,`.`]}),(0,L.jsx)(Mc,{plan:n}),(0,L.jsx)(Ec,{plan:n,notes:Object.fromEntries(Object.entries(r).map(([e,t])=>[e,Ac(t)])),selected:s,onSelect:c})]}):l:null,a===`files`?(0,L.jsx)(Ts,{query:u,missing:(0,L.jsx)(as,{children:`The server keeps no files of this version.`}),children:e=>(0,L.jsx)(hc,{files:e.files})}):null,s&&n?(0,L.jsx)(Nc,{name:s,plan:n,inputs:e.inputs,stats:d?{of:r,period:Uc}:void 0,onSelect:c}):null]})}})}function Kc(e,t){let n=e.annotations?.repo,r=e.annotations?.commit,i=[[`Hash`,(0,L.jsx)(G,{className:`break-all`,children:e.hash})],[`Published by`,(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(G,{children:e.publishedBy.sub}),` `,(0,L.jsx)(gs,{iso:e.publishedAt,now:t})]})]];e.approvedBy&&i.push([`Approved by`,(0,L.jsx)(G,{children:e.approvedBy.sub})]),e.yanked&&i.push([`Yanked`,(0,L.jsxs)(L.Fragment,{children:[`by `,(0,L.jsx)(G,{children:e.yanked.by.sub}),` `,(0,L.jsx)(gs,{iso:e.yanked.at,now:t}),e.yanked.reason?(0,L.jsxs)(L.Fragment,{children:[`: `,(0,L.jsx)(W,{children:e.yanked.reason})]}):null]})]),n&&i.push([`Repository`,(0,L.jsx)(Cs,{repo:n,gitRef:e.annotations?.branch,commit:r})]);let a=Object.entries(e.annotations??{}).filter(([e])=>![`repo`,`branch`,`commit`].includes(e));return a.length>0&&i.push([`Annotations`,(0,L.jsx)(`span`,{className:`flex flex-wrap gap-2`,children:a.map(([e,t])=>(0,L.jsx)(G,{children:`${e}=${String(t)}`},e))})]),e.accounts&&e.accounts.length>0&&i.push([`Accounts`,(0,L.jsx)(W,{children:e.accounts.join(`, `)})]),i}function qc({stats:e,loading:t}){let n=e.reduce((e,t)=>e+t.runs,0),r=e.reduce((e,t)=>e+t.cached,0),i=e.reduce((e,t)=>e+t.failed,0),a=e.reduce((e,t)=>e+(t.totalMs??0),0),o=[[`Task runs`,String(n),`of its tasks in the ${Uc}`],[`From the cache`,n?kc(r/n):`–`,`${r} of ${n}`],[`Passed`,n?kc((n-i)/n):`–`,i?`${i} failed`:`none failed`],[`Time run`,a?es(a):`–`,`what ran, not the cache`]];return(0,L.jsx)(`section`,{"aria-label":`The ${Uc}`,className:`mb-6`,children:(0,L.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:o.map(([e,n,r])=>(0,L.jsxs)(is,{className:`p-3!`,children:[(0,L.jsx)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:e}),(0,L.jsx)(`div`,{className:`text-xl font-semibold tabular-nums`,children:t?`…`:n}),(0,L.jsx)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:t?``:r})]},e))})})}var Jc={name:e=>e.name,file:e=>e.file,deps:e=>e.entry.deps.length+e.entry.needs.length,runs:e=>e.stats?.runs,cache:e=>e.stats?Dc(e.stats):void 0,success:e=>e.stats?Oc(e.stats):void 0,median:e=>e.stats?.medianMs},Yc=[`name`,`file`,`deps`,`runs`,`cache`,`success`,`median`];function Xc({plan:e,stats:t,marks:n,onSelect:r}){let i=Us(Object.entries(e).map(([e,n])=>({name:e,entry:n,file:wc(e,n),...t?.[e]?{stats:t[e]}:{}})),Jc,{key:`name`,dir:`asc`}),a=[`Name`,`Build file`,`Waits for`,...t?[`Runs`,`Cached`,`Passed`,`Median`]:[]];return(0,L.jsx)(Hs,{head:a,right:a.map((e,t)=>t>=3),sort:{keys:Yc.slice(0,a.length),state:i.state,onSort:i.onSort},children:i.rows.map(({name:e,entry:i,file:a,stats:o})=>(0,L.jsxs)(`tr`,{className:`hover:bg-stone-50 dark:hover:bg-stone-800/40`,children:[(0,L.jsxs)(J,{children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:`cursor-pointer text-left font-mono text-[0.85em] font-medium hover:underline`,children:U(e)}),n?.[e]?(0,L.jsxs)(L.Fragment,{children:[` `,n[e]]}):null,(0,L.jsxs)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:[i.kind===`service`?(0,L.jsx)(`span`,{className:`mr-1 rounded-full border border-violet-400 px-1.5 text-violet-700 dark:border-violet-500 dark:text-violet-300`,children:`service`}):null,i.runtime===`none`?i.kind===`service`?``:`groups its dependencies`:i.image?U(i.image):i.runtime]})]}),(0,L.jsx)(J,{className:`whitespace-nowrap`,children:(0,L.jsx)(G,{children:a})}),(0,L.jsx)(J,{children:i.deps.length+i.needs.length>0?(0,L.jsx)(`span`,{className:`text-xs`,children:U([...i.deps,...i.needs].join(`, `))}):(0,L.jsx)(K,{children:`nothing`})}),t?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(J,{num:!0,children:o?o.runs:(0,L.jsx)(K,{children:`–`})}),(0,L.jsx)(J,{num:!0,children:o?(0,L.jsx)(`span`,{title:`${o.cached} of ${o.runs} from the cache`,children:kc(Dc(o))}):null}),(0,L.jsx)(J,{num:!0,className:o&&o.failed>0?(Oc(o)??1)<.5?`text-red-600 dark:text-red-400`:`text-amber-600 dark:text-amber-400`:``,children:o?(0,L.jsx)(`span`,{title:`${o.failed} of ${o.runs} failed`,children:kc(Oc(o))}):null}),(0,L.jsx)(J,{num:!0,children:o?es(o.medianMs):null})]}):null]},e))})}function Zc(e){return`/build-files/proposed/${zo(e)}`}var Qc=864e5,$c=`no repository given`;function el(e,t,n){let r=new Set(e.map(e=>e.hash));return[...e.map(e=>({hash:e.hash,path:e.annotations.path??e.entry,href:Bc(e.hash),state:e.yanked?`yanked`:`published`,annotations:e.annotations,tasks:e.tasks,services:e.services,by:e.publishedBy.sub,...e.approvedBy?{decidedBy:`approved by ${e.approvedBy.sub}`}:{},at:e.publishedAt})),...t.filter(e=>!r.has(e.hash)&&(e.state===`waiting`||n-Date.parse(e.decidedAt??``)<Qc)).map(e=>({hash:e.hash,path:e.annotations?.path??e.entry,href:Zc(e.hash),state:e.state,annotations:e.annotations??{},tasks:e.tasks,services:e.services,by:`proposed by ${e.proposedBy.sub}`,...e.decidedBy?{decidedBy:`${e.state} by ${e.decidedBy.sub}`}:{},at:e.createdAt,canDecide:e.canDecide}))]}function tl(e){let t=new Map,n=[...e].sort((e,t)=>Number(t.state===`waiting`)-Number(e.state===`waiting`)||Date.parse(t.at)-Date.parse(e.at));for(let e of n){let n=e.annotations.repo??$c;t.set(n,[...t.get(n)??[],e])}return[...t].sort(([e],[t])=>e===$c?1:t===$c?-1:e.localeCompare(t))}function nl(e,t){let n=t.toLowerCase();return[e.hash,e.path,e.by,...Object.values(e.annotations),...e.tasks,...e.services].some(e=>e.toLowerCase().includes(n))}function rl(){let[e,t]=Vi(),n=(e.get(`q`)??``).slice(0,100),r=tc(n.trim()),i=cc(e,`repo`),a=nc(new URLSearchParams,{repo:i}),o=new URLSearchParams(a);r&&o.set(`q`,r);let s=Qs(`/definitions?${o}`),c=$s(s,e=>e.definitions,e=>e.hash),l=B(`/proposals`),u=ns(),d=n=>{let r=new URLSearchParams(e);n?r.set(`q`,n):r.delete(`q`),t(r,{replace:!0})},f=!!r||i.length>0;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{children:`Build files`}),(0,L.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:(0,L.jsx)(`input`,{className:`${As} min-w-48 flex-1 sm:max-w-xs`,value:n,onChange:e=>d(e.target.value),placeholder:`path, task, commit, hash, person`,"aria-label":`Search`})}),(0,L.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:(0,L.jsx)(ic,{name:`Repository`,values:`/definitions?${o}&values=repo`,chosen:i,onChange:n=>t(lc(e,`repo`,n),{replace:!0})})}),(0,L.jsx)(Ts,{query:s,missing:(0,L.jsx)(as,{children:`You may not see the build files of this server.`}),children:()=>{let e=el(c,l.data?.proposals??[],u).filter(e=>e.href===Bc(e.hash)||(i.length===0||i.includes(e.annotations.repo??``))&&(!r||nl(e,r)));return e.length===0?(0,L.jsx)(as,{children:f?`No build file is like that.`:`No build file is published or proposed.`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Hs,{head:[`Build file`,`Commit`,`Tasks`,`Published`],right:il,children:tl(e).map(([e,t])=>(0,L.jsxs)(j.Fragment,{children:[(0,L.jsx)(`tr`,{className:`bg-stone-50 dark:bg-stone-950/40`,children:(0,L.jsx)(`th`,{colSpan:4,scope:`colgroup`,className:`px-3 py-1.5 text-left text-xs font-medium text-stone-600 dark:text-stone-300`,children:(0,L.jsx)(Ss,{href:V(e)?.repo,children:(0,L.jsx)(W,{children:e})})})}),t.map(e=>(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(J,{className:`whitespace-nowrap`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(fs,{state:e.state}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(Li,{className:`link font-mono text-[0.85em]`,to:e.href,title:e.hash,children:U(e.path)}),(0,L.jsxs)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:[(0,L.jsx)(`span`,{className:`font-mono`,title:e.hash,children:e.hash.slice(7,19)}),` `,e.canDecide?(0,L.jsx)(Li,{to:e.href,className:`rounded-full bg-amber-500 px-1.5 font-medium whitespace-nowrap text-white hover:bg-amber-600`,children:`your approval`}):e.state]})]})]})}),(0,L.jsxs)(J,{className:`whitespace-nowrap`,children:[e.annotations.commit?(0,L.jsx)(Ss,{href:e.annotations.repo?V(e.annotations.repo)?.commit?.(e.annotations.commit):void 0,children:(0,L.jsx)(G,{children:e.annotations.commit.slice(0,12)})}):(0,L.jsx)(K,{children:`not known`}),e.annotations.dirty?(0,L.jsx)(`div`,{className:`text-xs text-amber-600`,children:`with changes`}):null]}),(0,L.jsx)(J,{className:`whitespace-nowrap`,children:(0,L.jsxs)(hs,{tip:(0,L.jsxs)(`dl`,{className:`grid max-w-80 grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 whitespace-normal`,children:[(0,L.jsx)(`dt`,{className:`text-stone-500 dark:text-stone-400`,children:`Tasks`}),(0,L.jsx)(`dd`,{children:U(e.tasks.join(`, `))||`none`}),(0,L.jsx)(`dt`,{className:`text-stone-500 dark:text-stone-400`,children:`Services`}),(0,L.jsx)(`dd`,{children:U(e.services.join(`, `))||`none`})]}),children:[qo(e.tasks.length,`task`),e.services.length>0?`, ${qo(e.services.length,`service`)}`:``]})}),(0,L.jsxs)(J,{num:!0,children:[(0,L.jsx)(gs,{iso:e.at,now:u}),(0,L.jsx)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:(0,L.jsx)(W,{children:e.by})}),e.decidedBy?(0,L.jsx)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:(0,L.jsx)(W,{children:e.decidedBy})}):null]})]},e.hash))]},e))}),(0,L.jsx)(ec,{query:s})]})}})]})}var il=[!1,!1,!1,!0],al=864e5,ol=[`succeeded`,`failed`,`cancelled`,`rejected`],sl=e=>[`awaiting-approval`,`queued`,`running`].includes(e.state)?`starting`:e.state===`succeeded`?`ended`:e.state,cl=[`starting`,`up`,`asleep`,`ended`,`failed`,`cancelled`,`rejected`],ll=[[`state`,`State`,e=>[sl(e)],cl],[`source`,`Source`,e=>[pl(e)]],[`user`,`User`,e=>[e.owner?e.owner.name??e.owner.sub:`you`]]];function ul(e,t){return[e.id,e.owner?.sub??``,e.owner?.name??``,...e.up?[e.up.name,...e.up.services]:[],pl(e),e.source.type===`ref`?e.source.ref:``,e.entry??``].some(e=>e.toLowerCase().includes(t))}function dl(){let[e,t]=Vi(),n=(e.get(`q`)??``).slice(0,100),r=B(`/runs?scope=visible&kind=services`),i=ns(),a=Object.fromEntries(ll.map(([t])=>[t,cc(e,t)])),o=n=>{let r=new URLSearchParams(e);n?r.set(`q`,n):r.delete(`q`),t(r,{replace:!0})},s=(r.data?.runs??[]).filter(e=>!ol.includes(e.state)||i-Date.parse(e.finishedAt??e.createdAt)<al).map((e,t)=>({run:e,index:t})).sort((e,t)=>cl.indexOf(sl(e.run))-cl.indexOf(sl(t.run))||e.index-t.index).map(({run:e})=>e),c=n.trim().toLowerCase(),l=s.filter(e=>(!c||ul(e,c))&&ll.every(([t,,n])=>a[t].length===0||n(e).some(e=>a[t].includes(e))));return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{children:`Services`}),(0,L.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:(0,L.jsx)(`input`,{className:`${As} min-w-48 flex-1 sm:max-w-xs`,value:n,onChange:e=>o(e.target.value),placeholder:`service, ref, build file, person`,"aria-label":`Search`})}),(0,L.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:ll.map(([n,r,i,o])=>(0,L.jsx)(ic,{name:r,options:uc(s,i,o),chosen:a[n],onChange:r=>t(lc(e,n,r),{replace:!0})},n))}),(0,L.jsx)(Ts,{query:r,children:()=>{if(l.length===0){let e=c||ll.some(([e])=>a[e].length>0);return(0,L.jsx)(as,{children:e?`No service run is like that.`:`No service run is starting, up or asleep, or ended in the last day.`})}return(0,L.jsx)(hl,{runs:l,now:i})}})]})}var fl=[`Name`,`Source`,`Started`,``],pl=e=>e.source.type===`upload`?`an upload`:e.source.repo;function ml(e){let t=new Map;for(let n of e)t.set(pl(n),[...t.get(pl(n))??[],n]);return[...t].sort(([e],[t])=>e.localeCompare(t))}function hl({runs:e,now:t}){return(0,L.jsx)(Hs,{head:fl,children:ml(e).map(([e,n])=>(0,L.jsxs)(j.Fragment,{children:[(0,L.jsx)(`tr`,{className:`bg-stone-50 dark:bg-stone-950/40`,children:(0,L.jsx)(`th`,{colSpan:fl.length,scope:`colgroup`,className:`px-3 py-1.5 text-left text-xs font-medium text-stone-600 dark:text-stone-300`,children:(0,L.jsx)(Ss,{href:V(e)?.repo,children:(0,L.jsx)(W,{children:e})})})}),n.map(e=>(0,L.jsx)(yl,{run:e,now:t},e.id))]},e))})}function gl({run:e}){let t=e.source;if(t.type===`upload`)return(0,L.jsx)(K,{children:`an upload`});let n=V(t.repo),r=(0,L.jsx)(Ss,{href:n?.commit?.(t.commit),children:(0,L.jsx)(G,{children:t.commit.slice(0,12)})});return t.type===`sandbox`?(0,L.jsxs)(`span`,{children:[`sandbox `,(0,L.jsx)(G,{children:t.id}),` at `,r,t.clean===!1?` with changes`:``]}):(0,L.jsxs)(`span`,{children:[(0,L.jsx)(Ss,{href:n?.ref?.(t.ref),children:(0,L.jsx)(G,{children:t.ref})}),` `,`at `,r]})}function _l({run:e,now:t}){let n=e.startedAt??e.createdAt;return(0,L.jsx)(hs,{tip:(0,L.jsxs)(`dl`,{className:`grid grid-cols-[auto_auto] gap-x-4 gap-y-0.5`,children:[(0,L.jsx)(`dt`,{className:`text-stone-500 dark:text-stone-400`,children:`Started`}),(0,L.jsx)(`dd`,{children:(0,L.jsx)(gs,{iso:n,now:t})}),(0,L.jsx)(`dt`,{className:`text-stone-500 dark:text-stone-400`,children:`Sleeps`}),(0,L.jsx)(`dd`,{children:(0,L.jsx)(Vs,{run:e,now:t})}),(0,L.jsx)(`dt`,{className:`text-stone-500 dark:text-stone-400`,children:`Ends`}),(0,L.jsx)(`dd`,{children:e.expiresAt?(0,L.jsx)(gs,{iso:e.expiresAt,now:t}):`once up`})]}),children:ts(n,t)})}function vl({run:e}){let t=e.up?.endpoints??[];return(e.up?.services??[...new Set(t.map(e=>e.service))]).map((e,n)=>{let r=t.filter(t=>t.service===e),i=r.find(e=>e.url&&/^https?:\/\//.test(e.url))?.url,a=r.map(t=>`${e}:${t.port}`).join(`, `)||void 0;return(0,L.jsxs)(j.Fragment,{children:[n>0?`, `:null,i?(0,L.jsx)(`a`,{className:`link`,href:i,rel:`noreferrer`,title:a,children:(0,L.jsx)(W,{children:e})}):(0,L.jsx)(`span`,{title:a,children:(0,L.jsx)(W,{children:e})})]},e)})}function yl({run:e,now:t}){return(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(J,{children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(vs,{id:e.id,children:(0,L.jsx)(ps,{state:e.state,detail:e.wakes?`woken ${e.wakes}×`:void 0})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(vl,{run:e}),(0,L.jsxs)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:[sl(e),e.wakes?`, woken ${e.wakes}×`:null]})]})]})}),(0,L.jsxs)(J,{children:[(0,L.jsx)(gl,{run:e}),(0,L.jsx)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:(0,L.jsx)(Vc,{hash:e.definition,entry:e.entry})})]}),(0,L.jsxs)(J,{className:`whitespace-nowrap`,children:[(0,L.jsx)(_l,{run:e,now:t}),e.owner?(0,L.jsxs)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:[`by `,(0,L.jsx)(ys,{who:e.owner})]}):null]}),(0,L.jsx)(J,{children:(0,L.jsxs)(`span`,{className:`inline-flex items-start gap-2`,children:[(0,L.jsx)(Is,{run:e}),(0,L.jsx)(Fs,{run:e}),(0,L.jsx)(Ns,{run:e})]})})]})}var bl=[[`1h`,`Last hour`],[`24h`,`Last 24 hours`],[`7d`,`Last 7 days`],[`30d`,`Last 30 days`]],xl={m:6e4,h:36e5,d:864e5};function Sl(e){let t=/^(\d+)([mhd])$/.exec(e);return t?Number(t[1])*xl[t[2]]:void 0}function Cl(e,t){let n=e.get(`from`),r=e.get(`to`);if(n!==null||r!==null)return{type:`between`,...n?{from:n}:{},...r?{to:r}:{}};let i=e.get(`since`);return i===``?{type:`all`}:{type:`last`,period:i??t}}function wl(e,t,n){let r=new URLSearchParams(e);return r.delete(`since`),r.delete(`from`),r.delete(`to`),t.type===`all`?r.set(`since`,``):t.type===`last`&&t.period!==n?r.set(`since`,t.period):t.type===`between`&&(t.from&&r.set(`from`,t.from),t.to&&r.set(`to`,t.to)),r}function Tl(e){let t=new URLSearchParams;return e.type===`last`?t.set(`since`,e.period):e.type===`between`&&(e.from&&t.set(`since`,e.from),e.to&&t.set(`until`,e.to)),t}var El=e=>new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`});function Dl(e){if(e===void 0||!Number.isFinite(e))return``;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function Ol(e,t){return e.type===`last`?bl.find(([t])=>t===e.period)?.[1]??`Last ${e.period}`:e.type===`all`?t?`All the server keeps, since ${El(t)}`:`All the server keeps`:`${e.from?El(e.from):`the oldest run`} → ${e.to?El(e.to):`now`}`}function kl(){return(0,L.jsxs)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4 shrink-0 fill-none stroke-current`,strokeWidth:`1.5`,children:[(0,L.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`11`,rx:`1.5`}),(0,L.jsx)(`path`,{d:`M2 6.5h12M5.5 1.5v3M10.5 1.5v3`,strokeLinecap:`round`})]})}function Al({value:e,onChange:t,oldest:n}){let[r,i]=(0,j.useState)(!1),[a,o]=(0,j.useState)(``),[s,c]=(0,j.useState)(``),l=(0,j.useRef)(null);(0,j.useEffect)(()=>{if(!r)return;let e=e=>{(e instanceof KeyboardEvent?e.key===`Escape`:!l.current?.contains(e.target))&&i(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,e)}},[r]);let u=()=>{if(!r){let t=Date.now(),r=e.type===`between`?Date.parse(e.from??``):e.type===`last`?t-(Sl(e.period)??0):Date.parse(n??``);o(Dl(Number.isFinite(r)?r:void 0)),c(e.type===`between`&&e.to?Dl(Date.parse(e.to)):``)}i(!r)},d=e=>{t(e),i(!1)},f=a?new Date(a).getTime():void 0,p=s?new Date(s).getTime()+59999:void 0,m=f!==void 0&&p!==void 0&&p<f,h=()=>d(f===void 0&&p===void 0?{type:`all`}:{type:`between`,...f===void 0?{}:{from:new Date(f).toISOString()},...p===void 0?{}:{to:new Date(p).toISOString()}}),g=e=>`rounded-md px-2 py-1 text-left text-sm ${e?`bg-emerald-600 text-white dark:bg-emerald-500 dark:text-stone-950`:`hover:bg-stone-100 dark:hover:bg-stone-800`}`;return(0,L.jsxs)(`div`,{ref:l,className:`relative`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:u,"aria-haspopup":`dialog`,"aria-expanded":r,"aria-label":`Time range`,className:`${As} flex max-w-full items-center gap-2 text-left hover:border-stone-400 dark:hover:border-stone-500`,children:[(0,L.jsx)(kl,{}),(0,L.jsx)(`span`,{className:`truncate`,children:Ol(e,n)}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`ml-1 text-stone-400`,children:`▾`})]}),r?(0,L.jsxs)(`div`,{role:`dialog`,"aria-label":`Choose the time range`,className:`absolute right-0 z-20 mt-1 w-80 max-w-[calc(100vw-2rem)] rounded-lg border border-stone-200 bg-white p-3 shadow-lg dark:border-stone-700 dark:bg-stone-900`,children:[(0,L.jsx)(`p`,{className:`mb-1 text-xs font-medium text-stone-500 dark:text-stone-400`,children:`Commonly used`}),(0,L.jsxs)(`div`,{className:`mb-3 grid grid-cols-2 gap-1`,children:[bl.map(([t,n])=>(0,L.jsx)(`button`,{type:`button`,className:g(e.type===`last`&&e.period===t),onClick:()=>d({type:`last`,period:t}),children:n},t)),(0,L.jsx)(`button`,{type:`button`,className:`${g(e.type===`all`)} col-span-2`,onClick:()=>d({type:`all`}),children:`All the server keeps`})]}),(0,L.jsx)(`p`,{className:`mb-1 text-xs font-medium text-stone-500 dark:text-stone-400`,children:`From and to`}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`label`,{className:`flex items-center justify-between gap-2 text-sm`,children:[(0,L.jsx)(`span`,{className:`w-10 text-stone-500 dark:text-stone-400`,children:`From`}),(0,L.jsx)(`input`,{type:`datetime-local`,className:`${As} flex-1`,value:a,onChange:e=>o(e.target.value)})]}),(0,L.jsxs)(`label`,{className:`flex items-center justify-between gap-2 text-sm`,children:[(0,L.jsx)(`span`,{className:`w-10 text-stone-500 dark:text-stone-400`,children:`To`}),(0,L.jsx)(`input`,{type:`datetime-local`,className:`${As} flex-1`,value:s,onChange:e=>c(e.target.value),title:`empty: up to now`})]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsx)(`span`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:m?`The end is before the start.`:`An empty end is now.`}),(0,L.jsx)(`button`,{type:`button`,disabled:m,onClick:h,className:`rounded-md bg-emerald-600 px-3 py-1 text-sm font-medium text-white hover:bg-emerald-700 disabled:opacity-50 dark:bg-emerald-500 dark:text-stone-950 dark:hover:bg-emerald-400`,children:`Apply`})]})]})]}):null]})}var jl=`7d`,Ml=[`Run`,`Source`,`Tasks`,`Total`,`Created`],Nl=Ml.map((e,t)=>t>=3);function Pl({run:e,now:t}){let n=Uo(e,t),r=Wo(e,t);if(n===void 0&&r===void 0)return null;let i=[];return n!==void 0&&i.push([`Waited for a place`,n]),r!==void 0&&i.push([`Ran`,r]),(0,L.jsx)(hs,{tip:(0,L.jsx)(`dl`,{className:`grid grid-cols-[auto_auto] gap-x-4 gap-y-0.5`,children:i.map(([e,t])=>(0,L.jsxs)(`div`,{className:`contents`,children:[(0,L.jsx)(`dt`,{className:`text-stone-500 dark:text-stone-400`,children:e}),(0,L.jsx)(`dd`,{className:`text-right tabular-nums`,children:es(t)})]},e))}),children:es((n??0)+(r??0))})}var Fl=[[`state`,`State`],[`source`,`Source`],[`task`,`Task`]],Il=e=>e.value===`upload`?`an upload`:void 0;function Ll(){let[e,t]=Vi(),n=(e.get(`q`)??``).slice(0,100),r=tc(n.trim()),i=Cl(e,jl),a=Object.fromEntries(Fl.map(([t])=>[t,cc(e,t)])),o=Tl(i);o.set(`scope`,`visible`);let s=nc(o,a);r&&s.set(`q`,r);let c=Qs(`/runs?${s}`),l=$s(c,e=>e.runs,e=>e.id),u=ns(),d=n=>{let r=new URLSearchParams(e);n?r.set(`q`,n):r.delete(`q`),t(r,{replace:!0})},f=i.type===`all`?c.data?.pages[0]?.oldest:void 0;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{children:`Runs`}),(0,L.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,L.jsx)(`input`,{className:`${As} min-w-48 flex-1 sm:max-w-xs`,value:n,onChange:e=>d(e.target.value),placeholder:`task, service, ref, person, id`,"aria-label":`Search`}),(0,L.jsx)(`div`,{className:`sm:ml-auto`,children:(0,L.jsx)(Al,{value:i,oldest:f,onChange:n=>t(wl(e,n,jl),{replace:!0})})})]}),(0,L.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:Fl.map(([n,r])=>(0,L.jsx)(ic,{name:r,values:`/runs?${s}&values=${n}`,label:n===`source`?Il:void 0,chosen:a[n],onChange:r=>t(lc(e,n,r),{replace:!0})},n))}),(0,L.jsx)(Ts,{query:c,children:()=>{if(l.length===0){let e=r||Fl.some(([e])=>a[e].length>0);return(0,L.jsx)(as,{children:e?`No run of this period is like that.`:`No run in this period.`})}return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Hs,{head:Ml,right:Nl,children:l.map(e=>(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(J,{children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(fs,{state:e.state}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(vs,{id:e.id}),(0,L.jsxs)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:[e.may?.decide?(0,L.jsx)(Li,{to:`/runs/${encodeURIComponent(e.id)}`,className:`rounded-full bg-amber-500 px-1.5 font-medium whitespace-nowrap text-white hover:bg-amber-600`,children:`your approval`}):e.state,e.queue?`, ${e.queue.position}. in the queue`:null]})]})]})}),(0,L.jsx)(J,{children:(0,L.jsx)(ws,{run:e})}),(0,L.jsxs)(J,{children:[(0,L.jsx)(xs,{run:e}),e.error?(0,L.jsx)(`div`,{className:`text-xs whitespace-pre-wrap text-red-700 dark:text-red-400`,children:U($o(e.error,200))}):null]}),(0,L.jsx)(J,{num:!0,children:(0,L.jsx)(Pl,{run:e,now:u})}),(0,L.jsxs)(J,{num:!0,children:[(0,L.jsx)(gs,{iso:e.createdAt,now:u}),(0,L.jsx)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:e.owner?(0,L.jsx)(ys,{who:e.owner}):`you`})]})]},e.id))}),(0,L.jsx)(ec,{query:c})]})}})]})}var Rl=200;function zl(){let e=Sr().id??``,t=B(`/runs?scope=visible&id=${encodeURIComponent(e)}`,{refresh:e=>!Bl(e?.runs[0])}),n=Bl(t.data?.runs[0]),r=B(`/runs/${encodeURIComponent(e)}`,{enabled:n});return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{children:e}),n?(0,L.jsx)(Ts,{query:r,children:e=>(0,L.jsx)(Vl,{run:e,full:!0})}):(0,L.jsx)(Ts,{query:t,children:({runs:e})=>e[0]?(0,L.jsx)(Vl,{run:e[0]}):(0,L.jsx)(as,{children:`There is no such run you may see.`})})]})}function Bl(e){return!!e&&(!e.owner||!!e.readable)}function Vl({run:e,full:t=!1}){let n=ns(),r=!e.owner,i=e=>(0,L.jsx)(gs,{iso:e,now:n}),a=[[`Source`,(0,L.jsx)(ws,{run:e})],[`Build file`,(0,L.jsx)(Li,{className:`link font-mono text-[0.85em] break-all`,to:Bc(e.definition),children:e.definition})],[e.up?`Services`:`Tasks`,(0,L.jsx)(xs,{run:e})]];e.up&&a.push([`Endpoints`,(0,L.jsx)(Bs,{run:e})]),e.accounts.length>0&&a.push([`Accounts`,e.accounts.join(`, `)]);let o=[[`Owner`,e.owner?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(ys,{who:e.owner}),e.owner.name?null:(0,L.jsxs)(K,{children:[` at `,e.owner.iss]})]}):`you`],[`Created`,i(e.createdAt)]];e.retryOf&&o.push([`Retry of`,(0,L.jsx)(Li,{className:`link font-mono text-[0.85em]`,to:`/runs/${encodeURIComponent(e.retryOf)}`,children:e.retryOf})]);for(let t of e.approvals??[])o.push([(0,L.jsxs)(L.Fragment,{children:[`Approval of `,(0,L.jsx)(G,{children:t.account})]}),t.approvedBy?(0,L.jsxs)(L.Fragment,{children:[`approved by `,(0,L.jsx)(G,{children:t.approvedBy.sub})]}):(0,L.jsxs)(L.Fragment,{children:[`waits until `,i(t.expiresAt)]})]);let s=[],c=Uo(e,n);c!==void 0&&s.push([`Waited for a place`,`${es(c)}${e.state===`queued`?` so far`:``}`]),e.queue&&s.push([`Queue`,`${e.queue.position}. waits: ${Yo(e.queue.waitsFor,r,!1)}`]),e.startedAt&&s.push([`Started`,i(e.startedAt)]);let l=Wo(e,n);l!==void 0&&s.push([e.up?`Took to be up`:`Ran`,`${es(l)}${e.finishedAt||e.upAt?``:` so far`}`]),e.finishedAt&&s.push([`Finished`,i(e.finishedAt)]),e.up&&(e.upAt&&s.push([`Up since`,i(e.upAt)]),e.expiresAt&&s.push([`Ends`,(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[i(e.expiresAt),(0,L.jsx)(Is,{run:e})]})]),e.up.sleepTtl&&s.push([`Sleeps`,(0,L.jsxs)(L.Fragment,{children:[`after `,Xo(e.up.sleepTtl),` without a request`,e.state===`up`&&e.sleepsAt?(0,L.jsxs)(L.Fragment,{children:[`, next `,i(e.sleepsAt)]}):null,e.wakes?`, woken ${e.wakes}×`:``]})]));let u=[[`Source`,a],[`Owner`,o],[`Timing`,s]];return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(is,{className:`mb-6 flex flex-col gap-5`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-3 text-sm`,children:[(0,L.jsx)(ms,{state:e.state}),e.error?(0,L.jsx)(`span`,{className:`whitespace-pre-wrap text-red-700 dark:text-red-400`,children:U($o(e.error,2e3))}):null,(0,L.jsxs)(`span`,{className:`ml-auto inline-flex items-start gap-2`,children:[t?(0,L.jsxs)(`span`,{className:`self-center text-xs whitespace-nowrap text-stone-500 dark:text-stone-400`,children:[(0,L.jsx)(Li,{className:`link`,to:`/runs/${encodeURIComponent(e.id)}/log`,children:`log`}),` `,`·`,` `,(0,L.jsx)(`a`,{className:`link`,href:`/api/runs/${encodeURIComponent(e.id)}/log.txt`,download:!0,children:`download`})]}):null,(0,L.jsx)(Fs,{run:e}),(0,L.jsx)(Ns,{run:e}),(0,L.jsx)(Ps,{run:e})]})]}),e.may?.decide?(0,L.jsx)(Hl,{run:e,now:n}):null,(0,L.jsx)(`div`,{className:`grid gap-5 lg:grid-cols-3`,children:u.filter(([,e])=>e.length>0).map(([e,t])=>(0,L.jsxs)(`section`,{"aria-label":e,children:[(0,L.jsx)(`h2`,{className:`mb-2 text-xs font-medium tracking-wide text-stone-500 uppercase dark:text-stone-400`,children:e}),(0,L.jsx)(os,{items:t,columns:`grid-cols-[9rem_1fr] lg:grid-cols-[max-content_1fr]`})]},e))})]}),(0,L.jsx)(ql,{run:e,full:t,now:n})]})}function Hl({run:e,now:t}){let n=(e.approvals??[]).filter(e=>!e.approvedBy);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-md border border-amber-500/50 bg-amber-50 p-3 text-sm dark:bg-amber-950/30`,children:[(0,L.jsxs)(`p`,{children:[`Waits for your approval`,n.length>0?(0,L.jsxs)(L.Fragment,{children:[` `,`of `,(0,L.jsx)(W,{children:n.map(e=>e.account).join(`, `)}),`, until`,` `,(0,L.jsx)(gs,{iso:n[0]?.expiresAt,now:t})]}):null,`.`]}),(0,L.jsx)(Ls,{path:`/v1/approvals/${encodeURIComponent(e.id)}`,yes:`Approve`})]})}function Ul(e,t){if(!t)return[];let n=[],r=new Set,i=e=>{let a=t[e];if(!r.has(e)&&a){r.add(e);for(let e of[...a.deps,...a.needs])i(e);n.push(e)}},a=[...e.tasks,...e.up?.services??[]];for(let e of a.length>0?a:Object.keys(t))i(e);return n}function Wl(e){return e===`awaiting-approval`?`waiting`:e===`queued`?`queued`:Gl(e)?`skipped`:`pending`}var Gl=e=>[`succeeded`,`failed`,`cancelled`,`rejected`].includes(e);function Kl({name:e,shown:t,onClick:n}){return(0,L.jsx)(`button`,{type:`button`,onClick:n,"aria-expanded":t,"aria-controls":`does-${e}`,"aria-label":`${t?`Hide`:`Show`} ${e}`,className:`-ml-1 inline-flex h-5 w-5 items-center justify-center rounded text-stone-500 hover:bg-stone-100 dark:text-stone-400 dark:hover:bg-stone-800`,children:(0,L.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-3.5 w-3.5 fill-none stroke-current transition-transform ${t?`rotate-90`:``}`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,L.jsx)(`path`,{d:`M6 4l4 4-4 4`})})})}function ql({run:e,full:t,now:n}){let r=`plan`in e?e.plan:void 0,i=B(`/definitions/${zo(e.definition)}`,{enabled:!r,refresh:!1}),a=r??i.data?.plan,o=(0,j.useMemo)(()=>a&&Tc(a),[a]),[s,c]=(0,j.useState)(null),l=new Map(`results`in e&&e.results?Object.entries(e.results).map(([e,t])=>[e,{status:t.status,startedAt:t.startedAt,finishedAt:t.finishedAt,durationMs:t.durationMs,error:t.error,cache:t.cache?.hit?`hit`:t.cache?.causes?.map(e=>$o(e,200)).join(`
|
|
14
|
+
`).length,` lines`]})]}),(0,L.jsx)(`pre`,{className:`log`,children:U(i)})]})}var gc=`modulepreload`,_c=function(e){return`/`+e},vc={},yc=function(e){return e.pathname.endsWith(`.css`)},bc=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},xc=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=_c(t,n);let r=s(t),i=yc(r);return bc(vc,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:gc,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Sc=(0,j.lazy)(()=>xc(()=>import(`./graph-canvas-D2f3lNda.js`),__vite__mapDeps([0,1]))),Cc={added:`bg-emerald-100 dark:bg-emerald-900/50`,changed:`bg-amber-100 dark:bg-amber-900/50`};function wc(e,t){if(t?.file)return t.file;let n=e.indexOf(`:`);return n>0?`${e.slice(0,n)}:*`:`top level`}function Tc(e){let t=Object.keys(e).filter(t=>e[t].kind===`service`),n=(e,t)=>{let n=0;for(;n<e.length&&e[n]===t[n];)n++;return n},r=(r,i)=>e[i]?i:t.filter(e=>e.endsWith(`:${i}`)).sort((e,t)=>n(t,r)-n(e,r))[0]??i;return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,n.needs.every(t=>e[t])?n:{...n,needs:n.needs.map(e=>r(t,e))}]))}function Ec(e){let{plan:t,names:n=Object.keys(t)}=e,[r,i]=(0,j.useState)(new Set),a=new Map;for(let e of n){let n=wc(e,t[e]);a.set(n,(a.get(n)??0)+1)}let o=n.filter(e=>!r.has(wc(e,t[e]))),s=e=>{let t=new Set(r);t.delete(e)||t.add(e),i(t)};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(j.Suspense,{fallback:(0,L.jsx)(`div`,{className:`flex h-40 items-center justify-center rounded-lg border border-stone-200 bg-stone-50 text-sm text-stone-500 dark:border-stone-800 dark:bg-stone-950`,children:`drawing the graph…`}),children:o.length>0?(0,L.jsx)(Sc,{...e,names:o}):(0,L.jsx)(`div`,{className:`flex h-40 items-center justify-center rounded-lg border border-stone-200 bg-stone-50 text-sm text-stone-500 dark:border-stone-800 dark:bg-stone-950`,children:`Every build file is hidden.`})}),a.size>1?(0,L.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-xs`,role:`group`,"aria-label":`Build files shown`,children:[(0,L.jsx)(`span`,{className:`mr-1 text-stone-500 dark:text-stone-400`,children:`Build files`}),[...a].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>{let n=!r.has(e);return(0,L.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:n?`hide the ${t} of ${e}`:`show the ${t} of ${e}`,onClick:()=>s(e),className:`inline-flex cursor-pointer items-center gap-1.5 rounded-full border px-2 py-0.5 font-mono ${n?`border-stone-300 bg-white text-stone-800 hover:bg-stone-100 dark:border-stone-600 dark:bg-stone-900 dark:text-stone-100 dark:hover:bg-stone-800`:`border-dashed border-stone-300 text-stone-400 line-through hover:text-stone-600 dark:border-stone-700 dark:text-stone-500 dark:hover:text-stone-300`}`,children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`border border-stone-400 dark:border-stone-500`}`}),U(e),(0,L.jsx)(`span`,{className:`text-stone-500 tabular-nums no-underline dark:text-stone-400`,children:t})]},e)}),r.size>0?(0,L.jsx)(`button`,{type:`button`,className:`link ml-1 cursor-pointer`,onClick:()=>i(new Set),children:`show all`}):null]}):null]})}var Dc=e=>e.runs?e.cached/e.runs:void 0,Oc=e=>e.runs?(e.runs-e.failed)/e.runs:void 0,kc=e=>e===void 0?``:`${Math.round(e*100)}%`;function Ac(e){return[`${kc(Dc(e))} cached`,e.medianMs===void 0?``:es(e.medianMs)].filter(Boolean).join(` · `)}function jc({stats:e,period:t}){return e?(0,L.jsxs)(`dl`,{className:`grid grid-cols-[7rem_1fr] gap-x-3 gap-y-1.5 text-sm`,children:[(0,L.jsx)(Pc,{name:`Runs`,children:e.runs}),(0,L.jsxs)(Pc,{name:`From the cache`,children:[kc(Dc(e)),` `,(0,L.jsxs)(K,{children:[`(`,e.cached,` of `,e.runs,`)`]})]}),(0,L.jsxs)(Pc,{name:`Passed`,children:[kc(Oc(e)),e.failed>0?(0,L.jsxs)(K,{children:[` (`,e.failed,` failed)`]}):null]}),e.medianMs===void 0?null:(0,L.jsxs)(Pc,{name:`Took`,children:[es(e.medianMs),` `,(0,L.jsx)(K,{children:`median`}),e.p90Ms===void 0?null:(0,L.jsxs)(L.Fragment,{children:[`, `,es(e.p90Ms),` `,(0,L.jsx)(K,{children:`90%`})]})]})]}):(0,L.jsxs)(K,{children:[`It did not run in the `,t,`.`]})}function Mc({run:e=!1,plan:t,names:n=Object.keys(t),marks:r}){let i=new Set(n.filter(e=>t[e])),a=[...i].map(e=>t[e]),o=[[a.some(e=>e.kind!==`service`),(0,L.jsx)(`span`,{"aria-hidden":!0,className:`inline-block h-3 w-4 rounded-sm border-2 border-stone-400`}),`task`],[a.some(e=>e.kind===`service`),(0,L.jsx)(`span`,{"aria-hidden":!0,className:`inline-block h-3 w-4 rounded-full border-2 border-violet-400`}),`service`],[!e&&a.some(e=>e.kind!==`service`&&e.runtime===`none`),(0,L.jsx)(`span`,{"aria-hidden":!0,className:`inline-block h-3 w-4 rounded-sm border-2 border-dashed border-stone-400`}),`groups its dependencies`],[a.some(e=>e.deps.some(e=>i.has(e))),(0,L.jsx)(`span`,{"aria-hidden":!0,className:`inline-block h-0 w-5 border-t-2 border-stone-400`}),`runs after`],[a.some(e=>e.kind!==`service`&&e.needs.some(e=>i.has(e))),(0,L.jsx)(`span`,{"aria-hidden":!0,className:`inline-block h-0 w-5 border-t-2 border-dashed border-violet-500`}),`needs the service, on hover`],[n.some(e=>r?.[e]===`added`),(0,L.jsx)(`span`,{"aria-hidden":!0,className:`inline-block h-3 w-4 rounded-sm border-2 border-stone-400 ${Cc.added}`}),`added`],[n.some(e=>r?.[e]===`changed`),(0,L.jsx)(`span`,{"aria-hidden":!0,className:`inline-block h-3 w-4 rounded-sm border-2 border-stone-400 ${Cc.changed}`}),`changed`]];return(0,L.jsx)(`ul`,{className:`mb-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-stone-600 dark:text-stone-300`,children:o.filter(([e])=>e).map(([,e,t])=>(0,L.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[e,t]},t))})}function Nc({name:e,plan:t,inputs:n,stats:r,onSelect:i}){return(0,L.jsx)(zc,{title:e,tabs:[{name:`Task`,content:(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsx)(Rc,{name:e,plan:t,inputs:n,onSelect:i}),r?(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-stone-500 uppercase dark:text-stone-400`,children:[`The `,r.period]}),(0,L.jsx)(jc,{stats:r.of[e],period:r.period})]}):null]})}],onClose:()=>i(null)})}function Pc({name:e,children:t}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{className:`text-stone-500 dark:text-stone-400`,children:e}),(0,L.jsx)(`dd`,{className:`min-w-0 break-words`,children:t})]})}function Fc(e){return e.replace(/^.*[\\/]hammerkit-definition-[^\\/]+[\\/]/,``)}function Ic({names:e,onSelect:t}){return e.length===0?(0,L.jsx)(K,{children:`none`}):(0,L.jsx)(`span`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,L.jsx)(`button`,{type:`button`,onClick:()=>t(e),className:`cursor-pointer rounded bg-stone-100 px-1.5 font-mono text-[0.8rem] hover:bg-stone-200 dark:bg-stone-800 dark:hover:bg-stone-700`,children:U(e)},e))})}function Lc({items:e}){return e.length===0?(0,L.jsx)(K,{children:`none`}):(0,L.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.map((e,t)=>(0,L.jsx)(`li`,{children:(0,L.jsx)(G,{children:e})},t))})}function Rc({name:e,plan:t,inputs:n,args:r,onSelect:i}){let a=t[e];if(!a)return(0,L.jsxs)(K,{children:[`The build file says nothing of `,e,`.`]});let o=Object.entries(t).filter(([,t])=>t.deps.includes(e)||t.needs.includes(e)).map(([e])=>e),s=a.network;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 text-sm`,children:[a.description?(0,L.jsx)(`p`,{children:(0,L.jsx)(W,{children:a.description})}):null,(0,L.jsxs)(`dl`,{className:`grid grid-cols-[7rem_1fr] gap-x-3 gap-y-1.5`,children:[a.file?(0,L.jsx)(Pc,{name:`Build file`,children:(0,L.jsx)(G,{children:a.file})}):null,(0,L.jsxs)(Pc,{name:`Kind`,children:[a.kind,`, `,a.runtime===`none`?`runs nothing`:a.runtime]}),a.image?(0,L.jsx)(Pc,{name:`Image`,children:(0,L.jsx)(G,{children:a.image})}):null,(0,L.jsx)(Pc,{name:`Runs after`,children:(0,L.jsx)(Ic,{names:a.deps,onSelect:i})}),(0,L.jsx)(Pc,{name:`Needs`,children:(0,L.jsx)(Ic,{names:a.needs,onSelect:i})}),(0,L.jsx)(Pc,{name:a.kind===`service`?`Needed by`:`Before`,children:(0,L.jsx)(Ic,{names:o,onSelect:i})})]}),a.cmds.length>0?(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-stone-500 uppercase dark:text-stone-400`,children:a.kind===`service`?`Command`:`Commands`}),(0,L.jsx)(Rs,{args:r}),(0,L.jsx)(`pre`,{className:`log whitespace-pre-wrap`,children:a.cmds.map(e=>`$ ${U(e)}`).join(`
|
|
15
|
+
`)})]}):null,(0,L.jsxs)(`dl`,{className:`grid grid-cols-[7rem_1fr] gap-x-3 gap-y-1.5`,children:[n?.[e]?(0,L.jsx)(Pc,{name:`Sources`,children:(0,L.jsx)(Lc,{items:n[e].src})}):null,(0,L.jsx)(Pc,{name:`Generates`,children:(0,L.jsx)(Lc,{items:a.generates.map(Fc)})}),(0,L.jsx)(Pc,{name:`Secrets`,children:a.secrets.length>0?(0,L.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:a.secrets.map((e,t)=>(0,L.jsxs)(`li`,{children:[(0,L.jsx)(G,{children:e.target}),` `,(0,L.jsx)(K,{children:`from`}),` `,(0,L.jsx)(G,{children:e.from}),e.account?(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(K,{children:`as`}),` `,(0,L.jsx)(G,{children:e.account})]}):null]},t))}):(0,L.jsx)(K,{children:`none`})}),a.accounts.length>0?(0,L.jsx)(Pc,{name:`Accounts`,children:(0,L.jsx)(W,{children:a.accounts.join(`, `)})}):null,a.serverEnvs?.length?(0,L.jsx)(Pc,{name:`Server variables`,children:(0,L.jsx)(Lc,{items:a.serverEnvs})}):null,s?(0,L.jsx)(Pc,{name:`Network`,children:typeof s==`string`?s:(0,L.jsxs)(L.Fragment,{children:[`only `,(0,L.jsx)(W,{children:s.allow.join(`, `)})]})}):null,a.mounts.length>0?(0,L.jsx)(Pc,{name:`Mounts`,children:(0,L.jsx)(Lc,{items:a.mounts})}):null,a.ports.length>0?(0,L.jsx)(Pc,{name:`Ports`,children:(0,L.jsx)(Lc,{items:a.ports})}):null,a.capAdd?.length?(0,L.jsx)(Pc,{name:`Capabilities`,children:(0,L.jsx)(Lc,{items:a.capAdd})}):null,a.args===void 0?null:(0,L.jsx)(Pc,{name:`Arguments`,children:a.args?`taken`:`refused`})]})]})}function zc({title:e,status:t,tabs:n,onClose:r}){let[i,a]=(0,j.useState)(n[0]?.name),o=n.find(e=>e.name===i)??n[0];return(0,j.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,L.jsxs)(`aside`,{"aria-label":e,className:`fixed inset-y-0 right-0 z-40 flex w-full max-w-lg flex-col border-l border-stone-200 bg-white shadow-2xl dark:border-stone-800 dark:bg-stone-900`,children:[(0,L.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-stone-200 px-4 py-3 dark:border-stone-800`,children:[(0,L.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-mono text-sm font-semibold`,children:U(e)}),t,(0,L.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`Close`,className:`cursor-pointer rounded-md px-2 py-0.5 text-lg leading-none text-stone-500 hover:bg-stone-100 hover:text-stone-900 dark:hover:bg-stone-800 dark:hover:text-white`,children:`×`})]}),n.length>1?(0,L.jsx)(`div`,{role:`tablist`,"aria-label":`What ${e} shows`,className:`flex gap-1 px-4 pt-3 text-sm`,children:n.map(e=>(0,L.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===o,onClick:()=>a(e.name),className:`cursor-pointer rounded-md px-2.5 py-0.5 ${e===o?`bg-stone-200 font-medium text-stone-900 dark:bg-stone-700 dark:text-white`:`text-stone-600 hover:bg-stone-100 dark:text-stone-300 dark:hover:bg-stone-800`}`,children:e.name},e.name))}):null,(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:o?.content})]})}function Bc(e){return`/build-files/${zo(e)}`}function Vc({hash:e,entry:t}){return(0,L.jsx)(Li,{className:`link font-mono text-[0.85em]`,to:Bc(e),title:e,children:t?U(t):`${e.slice(0,19)}…`})}var Hc=`7d`,Uc=`last 7 days`,Wc=[`info`,`graph`,`files`];function Gc(){let e=Sr().hash??``,t=ns(),[n,r]=Vi(),i=n.get(`tab`),a=Wc.includes(i)?i:`info`,o=e=>{let t=new URLSearchParams(n);e===`info`?t.delete(`tab`):t.set(`tab`,e),r(t,{replace:!0})},[s,c]=(0,j.useState)(null),l=B(`/definitions/${zo(e)}`,{refresh:!1}),u=B(`/definitions/${zo(e)}/files`,{refresh:!1}),d=l.data?.annotations?.repo,f=B(`/tasks?since=${Hc}`,{enabled:!!d});return(0,L.jsx)(Ts,{query:l,missing:(0,L.jsx)(as,{children:`There is no such build file you may see.`}),children:e=>{let n=e.plan&&Tc(e.plan),r=Object.fromEntries((f.data?.tasks??[]).filter(e=>e.repo===d&&n?.[e.task]).map(e=>[e.task,e])),i=[qo(e.tasks.length,`task`),...e.services.length>0?[qo(e.services.length,`service`)]:[]].join(`, `),l=(0,L.jsx)(as,{children:`This version was published before the server kept what it runs.`}),p=u.data?Object.keys(u.data.files).length:void 0;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{children:e.entry}),(0,L.jsx)(Ws,{label:`What the build file shows`,tabs:[{key:`info`,name:`Info`},{key:`graph`,name:`Graph`,note:n?Object.keys(n).length:void 0},{key:`files`,name:`Files`,note:p}],current:a,onChange:o}),a===`info`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(is,{className:`mb-6`,children:(0,L.jsx)(os,{items:Kc(e,t)})}),d&&n?(0,L.jsx)(qc,{stats:Object.values(r),loading:f.isLoading}):null,(0,L.jsx)(rs,{title:`Tasks and services`,note:`${i}, a click on one opens it`,children:n?(0,L.jsx)(Xc,{plan:n,stats:d?r:void 0,onSelect:c}):l})]}):null,a===`graph`?n?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{className:`mb-2 text-sm text-stone-500 dark:text-stone-400`,children:[i,`, a click on one opens it`,d?`; each box says how often it came from the cache in the ${Uc}`:``,`.`]}),(0,L.jsx)(Mc,{plan:n}),(0,L.jsx)(Ec,{plan:n,notes:Object.fromEntries(Object.entries(r).map(([e,t])=>[e,Ac(t)])),selected:s,onSelect:c})]}):l:null,a===`files`?(0,L.jsx)(Ts,{query:u,missing:(0,L.jsx)(as,{children:`The server keeps no files of this version.`}),children:e=>(0,L.jsx)(hc,{files:e.files})}):null,s&&n?(0,L.jsx)(Nc,{name:s,plan:n,inputs:e.inputs,stats:d?{of:r,period:Uc}:void 0,onSelect:c}):null]})}})}function Kc(e,t){let n=e.annotations?.repo,r=e.annotations?.commit,i=[[`Hash`,(0,L.jsx)(G,{className:`break-all`,children:e.hash})],[`Published by`,(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(G,{children:e.publishedBy.sub}),` `,(0,L.jsx)(gs,{iso:e.publishedAt,now:t})]})]];e.approvedBy&&i.push([`Approved by`,(0,L.jsx)(G,{children:e.approvedBy.sub})]),e.yanked&&i.push([`Yanked`,(0,L.jsxs)(L.Fragment,{children:[`by `,(0,L.jsx)(G,{children:e.yanked.by.sub}),` `,(0,L.jsx)(gs,{iso:e.yanked.at,now:t}),e.yanked.reason?(0,L.jsxs)(L.Fragment,{children:[`: `,(0,L.jsx)(W,{children:e.yanked.reason})]}):null]})]),n&&i.push([`Repository`,(0,L.jsx)(Cs,{repo:n,gitRef:e.annotations?.branch,commit:r})]);let a=Object.entries(e.annotations??{}).filter(([e])=>![`repo`,`branch`,`commit`].includes(e));return a.length>0&&i.push([`Annotations`,(0,L.jsx)(`span`,{className:`flex flex-wrap gap-2`,children:a.map(([e,t])=>(0,L.jsx)(G,{children:`${e}=${String(t)}`},e))})]),e.accounts&&e.accounts.length>0&&i.push([`Accounts`,(0,L.jsx)(W,{children:e.accounts.join(`, `)})]),i}function qc({stats:e,loading:t}){let n=e.reduce((e,t)=>e+t.runs,0),r=e.reduce((e,t)=>e+t.cached,0),i=e.reduce((e,t)=>e+t.failed,0),a=e.reduce((e,t)=>e+(t.totalMs??0),0),o=[[`Task runs`,String(n),`of its tasks in the ${Uc}`],[`From the cache`,n?kc(r/n):`–`,`${r} of ${n}`],[`Passed`,n?kc((n-i)/n):`–`,i?`${i} failed`:`none failed`],[`Time run`,a?es(a):`–`,`what ran, not the cache`]];return(0,L.jsx)(`section`,{"aria-label":`The ${Uc}`,className:`mb-6`,children:(0,L.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:o.map(([e,n,r])=>(0,L.jsxs)(is,{className:`p-3!`,children:[(0,L.jsx)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:e}),(0,L.jsx)(`div`,{className:`text-xl font-semibold tabular-nums`,children:t?`…`:n}),(0,L.jsx)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:t?``:r})]},e))})})}var Jc={name:e=>e.name,file:e=>e.file,deps:e=>e.entry.deps.length+e.entry.needs.length,runs:e=>e.stats?.runs,cache:e=>e.stats?Dc(e.stats):void 0,success:e=>e.stats?Oc(e.stats):void 0,median:e=>e.stats?.medianMs},Yc=[`name`,`file`,`deps`,`runs`,`cache`,`success`,`median`];function Xc({plan:e,stats:t,marks:n,onSelect:r}){let i=Us(Object.entries(e).map(([e,n])=>({name:e,entry:n,file:wc(e,n),...t?.[e]?{stats:t[e]}:{}})),Jc,{key:`name`,dir:`asc`}),a=[`Name`,`Build file`,`Waits for`,...t?[`Runs`,`Cached`,`Passed`,`Median`]:[]];return(0,L.jsx)(Hs,{head:a,right:a.map((e,t)=>t>=3),sort:{keys:Yc.slice(0,a.length),state:i.state,onSort:i.onSort},children:i.rows.map(({name:e,entry:i,file:a,stats:o})=>(0,L.jsxs)(`tr`,{className:`hover:bg-stone-50 dark:hover:bg-stone-800/40`,children:[(0,L.jsxs)(J,{children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:`cursor-pointer text-left font-mono text-[0.85em] font-medium hover:underline`,children:U(e)}),n?.[e]?(0,L.jsxs)(L.Fragment,{children:[` `,n[e]]}):null,(0,L.jsxs)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:[i.kind===`service`?(0,L.jsx)(`span`,{className:`mr-1 rounded-full border border-violet-400 px-1.5 text-violet-700 dark:border-violet-500 dark:text-violet-300`,children:`service`}):null,i.runtime===`none`?i.kind===`service`?``:`groups its dependencies`:i.image?U(i.image):i.runtime]})]}),(0,L.jsx)(J,{className:`whitespace-nowrap`,children:(0,L.jsx)(G,{children:a})}),(0,L.jsx)(J,{children:i.deps.length+i.needs.length>0?(0,L.jsx)(`span`,{className:`text-xs`,children:U([...i.deps,...i.needs].join(`, `))}):(0,L.jsx)(K,{children:`nothing`})}),t?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(J,{num:!0,children:o?o.runs:(0,L.jsx)(K,{children:`–`})}),(0,L.jsx)(J,{num:!0,children:o?(0,L.jsx)(`span`,{title:`${o.cached} of ${o.runs} from the cache`,children:kc(Dc(o))}):null}),(0,L.jsx)(J,{num:!0,className:o&&o.failed>0?(Oc(o)??1)<.5?`text-red-600 dark:text-red-400`:`text-amber-600 dark:text-amber-400`:``,children:o?(0,L.jsx)(`span`,{title:`${o.failed} of ${o.runs} failed`,children:kc(Oc(o))}):null}),(0,L.jsx)(J,{num:!0,children:o?es(o.medianMs):null})]}):null]},e))})}function Zc(e){return`/build-files/proposed/${zo(e)}`}var Qc=864e5,$c=`no repository given`;function el(e,t,n){let r=new Set(e.map(e=>e.hash));return[...e.map(e=>({hash:e.hash,path:e.annotations.path??e.entry,href:Bc(e.hash),state:e.yanked?`yanked`:`published`,annotations:e.annotations,tasks:e.tasks,services:e.services,by:e.publishedBy.sub,...e.approvedBy?{decidedBy:`approved by ${e.approvedBy.sub}`}:{},at:e.publishedAt})),...t.filter(e=>!r.has(e.hash)&&(e.state===`waiting`||n-Date.parse(e.decidedAt??``)<Qc)).map(e=>({hash:e.hash,path:e.annotations?.path??e.entry,href:Zc(e.hash),state:e.state,annotations:e.annotations??{},tasks:e.tasks,services:e.services,by:`proposed by ${e.proposedBy.sub}`,...e.decidedBy?{decidedBy:`${e.state} by ${e.decidedBy.sub}`}:{},at:e.createdAt,canDecide:e.canDecide}))]}function tl(e){let t=new Map,n=[...e].sort((e,t)=>Number(t.state===`waiting`)-Number(e.state===`waiting`)||Date.parse(t.at)-Date.parse(e.at));for(let e of n){let n=e.annotations.repo??$c;t.set(n,[...t.get(n)??[],e])}return[...t].sort(([e],[t])=>e===$c?1:t===$c?-1:e.localeCompare(t))}function nl(e,t){let n=t.toLowerCase();return[e.hash,e.path,e.by,...Object.values(e.annotations),...e.tasks,...e.services].some(e=>e.toLowerCase().includes(n))}function rl(){let[e,t]=Vi(),n=(e.get(`q`)??``).slice(0,100),r=tc(n.trim()),i=cc(e,`repo`),a=nc(new URLSearchParams,{repo:i}),o=new URLSearchParams(a);r&&o.set(`q`,r);let s=Qs(`/definitions?${o}`),c=$s(s,e=>e.definitions,e=>e.hash),l=B(`/proposals`),u=ns(),d=n=>{let r=new URLSearchParams(e);n?r.set(`q`,n):r.delete(`q`),t(r,{replace:!0})},f=!!r||i.length>0;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{children:`Build files`}),(0,L.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:(0,L.jsx)(`input`,{className:`${As} min-w-48 flex-1 sm:max-w-xs`,value:n,onChange:e=>d(e.target.value),placeholder:`path, task, commit, hash, person`,"aria-label":`Search`})}),(0,L.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:(0,L.jsx)(ic,{name:`Repository`,values:`/definitions?${o}&values=repo`,chosen:i,onChange:n=>t(lc(e,`repo`,n),{replace:!0})})}),(0,L.jsx)(Ts,{query:s,missing:(0,L.jsx)(as,{children:`You may not see the build files of this server.`}),children:()=>{let e=el(c,l.data?.proposals??[],u).filter(e=>e.href===Bc(e.hash)||(i.length===0||i.includes(e.annotations.repo??``))&&(!r||nl(e,r)));return e.length===0?(0,L.jsx)(as,{children:f?`No build file is like that.`:`No build file is published or proposed.`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Hs,{head:[`Build file`,`Commit`,`Tasks`,`Published`],right:il,children:tl(e).map(([e,t])=>(0,L.jsxs)(j.Fragment,{children:[(0,L.jsx)(`tr`,{className:`bg-stone-50 dark:bg-stone-950/40`,children:(0,L.jsx)(`th`,{colSpan:4,scope:`colgroup`,className:`px-3 py-1.5 text-left text-xs font-medium text-stone-600 dark:text-stone-300`,children:(0,L.jsx)(Ss,{href:V(e)?.repo,children:(0,L.jsx)(W,{children:e})})})}),t.map(e=>(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(J,{className:`whitespace-nowrap`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(fs,{state:e.state}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(Li,{className:`link font-mono text-[0.85em]`,to:e.href,title:e.hash,children:U(e.path)}),(0,L.jsxs)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:[(0,L.jsx)(`span`,{className:`font-mono`,title:e.hash,children:e.hash.slice(7,19)}),` `,e.canDecide?(0,L.jsx)(Li,{to:e.href,className:`rounded-full bg-amber-500 px-1.5 font-medium whitespace-nowrap text-white hover:bg-amber-600`,children:`your approval`}):e.state]})]})]})}),(0,L.jsxs)(J,{className:`whitespace-nowrap`,children:[e.annotations.commit?(0,L.jsx)(Ss,{href:e.annotations.repo?V(e.annotations.repo)?.commit?.(e.annotations.commit):void 0,children:(0,L.jsx)(G,{children:e.annotations.commit.slice(0,12)})}):(0,L.jsx)(K,{children:`not known`}),e.annotations.dirty?(0,L.jsx)(`div`,{className:`text-xs text-amber-600`,children:`with changes`}):null]}),(0,L.jsx)(J,{className:`whitespace-nowrap`,children:(0,L.jsxs)(hs,{tip:(0,L.jsxs)(`dl`,{className:`grid max-w-80 grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 whitespace-normal`,children:[(0,L.jsx)(`dt`,{className:`text-stone-500 dark:text-stone-400`,children:`Tasks`}),(0,L.jsx)(`dd`,{children:U(e.tasks.join(`, `))||`none`}),(0,L.jsx)(`dt`,{className:`text-stone-500 dark:text-stone-400`,children:`Services`}),(0,L.jsx)(`dd`,{children:U(e.services.join(`, `))||`none`})]}),children:[qo(e.tasks.length,`task`),e.services.length>0?`, ${qo(e.services.length,`service`)}`:``]})}),(0,L.jsxs)(J,{num:!0,children:[(0,L.jsx)(gs,{iso:e.at,now:u}),(0,L.jsx)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:(0,L.jsx)(W,{children:e.by})}),e.decidedBy?(0,L.jsx)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:(0,L.jsx)(W,{children:e.decidedBy})}):null]})]},e.hash))]},e))}),(0,L.jsx)(ec,{query:s})]})}})]})}var il=[!1,!1,!1,!0],al=864e5,ol=[`succeeded`,`failed`,`cancelled`,`rejected`],sl=e=>[`awaiting-approval`,`queued`,`running`].includes(e.state)?`starting`:e.state===`succeeded`?`ended`:e.state,cl=[`starting`,`up`,`asleep`,`ended`,`failed`,`cancelled`,`rejected`],ll=[[`state`,`State`,e=>[sl(e)],cl],[`source`,`Source`,e=>[pl(e)]],[`user`,`User`,e=>[e.owner?e.owner.name??e.owner.sub:`you`]]];function ul(e,t){return[e.id,e.owner?.sub??``,e.owner?.name??``,...e.up?[e.up.name,...e.up.services]:[],pl(e),e.source.type===`ref`?e.source.ref:``,e.entry??``].some(e=>e.toLowerCase().includes(t))}function dl(){let[e,t]=Vi(),n=(e.get(`q`)??``).slice(0,100),r=B(`/runs?scope=visible&kind=services`),i=ns(),a=Object.fromEntries(ll.map(([t])=>[t,cc(e,t)])),o=n=>{let r=new URLSearchParams(e);n?r.set(`q`,n):r.delete(`q`),t(r,{replace:!0})},s=(r.data?.runs??[]).filter(e=>!ol.includes(e.state)||i-Date.parse(e.finishedAt??e.createdAt)<al).map((e,t)=>({run:e,index:t})).sort((e,t)=>cl.indexOf(sl(e.run))-cl.indexOf(sl(t.run))||e.index-t.index).map(({run:e})=>e),c=n.trim().toLowerCase(),l=s.filter(e=>(!c||ul(e,c))&&ll.every(([t,,n])=>a[t].length===0||n(e).some(e=>a[t].includes(e))));return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{children:`Services`}),(0,L.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:(0,L.jsx)(`input`,{className:`${As} min-w-48 flex-1 sm:max-w-xs`,value:n,onChange:e=>o(e.target.value),placeholder:`service, ref, build file, person`,"aria-label":`Search`})}),(0,L.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:ll.map(([n,r,i,o])=>(0,L.jsx)(ic,{name:r,options:uc(s,i,o),chosen:a[n],onChange:r=>t(lc(e,n,r),{replace:!0})},n))}),(0,L.jsx)(Ts,{query:r,children:()=>{if(l.length===0){let e=c||ll.some(([e])=>a[e].length>0);return(0,L.jsx)(as,{children:e?`No service run is like that.`:`No service run is starting, up or asleep, or ended in the last day.`})}return(0,L.jsx)(hl,{runs:l,now:i})}})]})}var fl=[`Name`,`Source`,`Started`,``],pl=e=>e.source.type===`upload`?`an upload`:e.source.repo;function ml(e){let t=new Map;for(let n of e)t.set(pl(n),[...t.get(pl(n))??[],n]);return[...t].sort(([e],[t])=>e.localeCompare(t))}function hl({runs:e,now:t}){return(0,L.jsx)(Hs,{head:fl,children:ml(e).map(([e,n])=>(0,L.jsxs)(j.Fragment,{children:[(0,L.jsx)(`tr`,{className:`bg-stone-50 dark:bg-stone-950/40`,children:(0,L.jsx)(`th`,{colSpan:fl.length,scope:`colgroup`,className:`px-3 py-1.5 text-left text-xs font-medium text-stone-600 dark:text-stone-300`,children:(0,L.jsx)(Ss,{href:V(e)?.repo,children:(0,L.jsx)(W,{children:e})})})}),n.map(e=>(0,L.jsx)(yl,{run:e,now:t},e.id))]},e))})}function gl({run:e}){let t=e.source;if(t.type===`upload`)return(0,L.jsx)(K,{children:`an upload`});let n=V(t.repo),r=(0,L.jsx)(Ss,{href:n?.commit?.(t.commit),children:(0,L.jsx)(G,{children:t.commit.slice(0,12)})});return t.type===`sandbox`?(0,L.jsxs)(`span`,{children:[`sandbox `,(0,L.jsx)(G,{children:t.id}),` at `,r,t.clean===!1?` with changes`:``]}):(0,L.jsxs)(`span`,{children:[(0,L.jsx)(Ss,{href:n?.ref?.(t.ref),children:(0,L.jsx)(G,{children:t.ref})}),` `,`at `,r]})}function _l({run:e,now:t}){let n=e.startedAt??e.createdAt;return(0,L.jsx)(hs,{tip:(0,L.jsxs)(`dl`,{className:`grid grid-cols-[auto_auto] gap-x-4 gap-y-0.5`,children:[(0,L.jsx)(`dt`,{className:`text-stone-500 dark:text-stone-400`,children:`Started`}),(0,L.jsx)(`dd`,{children:(0,L.jsx)(gs,{iso:n,now:t})}),(0,L.jsx)(`dt`,{className:`text-stone-500 dark:text-stone-400`,children:`Sleeps`}),(0,L.jsx)(`dd`,{children:(0,L.jsx)(Vs,{run:e,now:t})}),(0,L.jsx)(`dt`,{className:`text-stone-500 dark:text-stone-400`,children:`Ends`}),(0,L.jsx)(`dd`,{children:e.expiresAt?(0,L.jsx)(gs,{iso:e.expiresAt,now:t}):`once up`})]}),children:ts(n,t)})}function vl({run:e}){let t=e.up?.endpoints??[];return(e.up?.services??[...new Set(t.map(e=>e.service))]).map((e,n)=>{let r=t.filter(t=>t.service===e),i=r.find(e=>e.url&&/^https?:\/\//.test(e.url))?.url,a=r.map(t=>`${e}:${t.port}`).join(`, `)||void 0;return(0,L.jsxs)(j.Fragment,{children:[n>0?`, `:null,i?(0,L.jsx)(`a`,{className:`link`,href:i,rel:`noreferrer`,title:a,children:(0,L.jsx)(W,{children:e})}):(0,L.jsx)(`span`,{title:a,children:(0,L.jsx)(W,{children:e})})]},e)})}function yl({run:e,now:t}){return(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(J,{children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(vs,{id:e.id,children:(0,L.jsx)(ps,{state:e.state,detail:e.wakes?`woken ${e.wakes}×`:void 0})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(vl,{run:e}),(0,L.jsxs)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:[sl(e),e.wakes?`, woken ${e.wakes}×`:null]})]})]})}),(0,L.jsxs)(J,{children:[(0,L.jsx)(gl,{run:e}),(0,L.jsx)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:(0,L.jsx)(Vc,{hash:e.definition,entry:e.entry})})]}),(0,L.jsxs)(J,{className:`whitespace-nowrap`,children:[(0,L.jsx)(_l,{run:e,now:t}),e.owner?(0,L.jsxs)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:[`by `,(0,L.jsx)(ys,{who:e.owner})]}):null]}),(0,L.jsx)(J,{children:(0,L.jsxs)(`span`,{className:`inline-flex items-start gap-2`,children:[(0,L.jsx)(Is,{run:e}),(0,L.jsx)(Fs,{run:e}),(0,L.jsx)(Ns,{run:e})]})})]})}var bl=[[`1h`,`Last hour`],[`24h`,`Last 24 hours`],[`7d`,`Last 7 days`],[`30d`,`Last 30 days`]],xl={m:6e4,h:36e5,d:864e5};function Sl(e){let t=/^(\d+)([mhd])$/.exec(e);return t?Number(t[1])*xl[t[2]]:void 0}function Cl(e,t){let n=e.get(`from`),r=e.get(`to`);if(n!==null||r!==null)return{type:`between`,...n?{from:n}:{},...r?{to:r}:{}};let i=e.get(`since`);return i===``?{type:`all`}:{type:`last`,period:i??t}}function wl(e,t,n){let r=new URLSearchParams(e);return r.delete(`since`),r.delete(`from`),r.delete(`to`),t.type===`all`?r.set(`since`,``):t.type===`last`&&t.period!==n?r.set(`since`,t.period):t.type===`between`&&(t.from&&r.set(`from`,t.from),t.to&&r.set(`to`,t.to)),r}function Tl(e){let t=new URLSearchParams;return e.type===`last`?t.set(`since`,e.period):e.type===`between`&&(e.from&&t.set(`since`,e.from),e.to&&t.set(`until`,e.to)),t}var El=e=>new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`});function Dl(e){if(e===void 0||!Number.isFinite(e))return``;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function Ol(e,t){return e.type===`last`?bl.find(([t])=>t===e.period)?.[1]??`Last ${e.period}`:e.type===`all`?t?`All the server keeps, since ${El(t)}`:`All the server keeps`:`${e.from?El(e.from):`the oldest run`} → ${e.to?El(e.to):`now`}`}function kl(){return(0,L.jsxs)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4 shrink-0 fill-none stroke-current`,strokeWidth:`1.5`,children:[(0,L.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`11`,rx:`1.5`}),(0,L.jsx)(`path`,{d:`M2 6.5h12M5.5 1.5v3M10.5 1.5v3`,strokeLinecap:`round`})]})}function Al({value:e,onChange:t,oldest:n}){let[r,i]=(0,j.useState)(!1),[a,o]=(0,j.useState)(``),[s,c]=(0,j.useState)(``),l=(0,j.useRef)(null);(0,j.useEffect)(()=>{if(!r)return;let e=e=>{(e instanceof KeyboardEvent?e.key===`Escape`:!l.current?.contains(e.target))&&i(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,e)}},[r]);let u=()=>{if(!r){let t=Date.now(),r=e.type===`between`?Date.parse(e.from??``):e.type===`last`?t-(Sl(e.period)??0):Date.parse(n??``);o(Dl(Number.isFinite(r)?r:void 0)),c(e.type===`between`&&e.to?Dl(Date.parse(e.to)):``)}i(!r)},d=e=>{t(e),i(!1)},f=a?new Date(a).getTime():void 0,p=s?new Date(s).getTime()+59999:void 0,m=f!==void 0&&p!==void 0&&p<f,h=()=>d(f===void 0&&p===void 0?{type:`all`}:{type:`between`,...f===void 0?{}:{from:new Date(f).toISOString()},...p===void 0?{}:{to:new Date(p).toISOString()}}),g=e=>`rounded-md px-2 py-1 text-left text-sm ${e?`bg-emerald-600 text-white dark:bg-emerald-500 dark:text-stone-950`:`hover:bg-stone-100 dark:hover:bg-stone-800`}`;return(0,L.jsxs)(`div`,{ref:l,className:`relative`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:u,"aria-haspopup":`dialog`,"aria-expanded":r,"aria-label":`Time range`,className:`${As} flex max-w-full items-center gap-2 text-left hover:border-stone-400 dark:hover:border-stone-500`,children:[(0,L.jsx)(kl,{}),(0,L.jsx)(`span`,{className:`truncate`,children:Ol(e,n)}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`ml-1 text-stone-400`,children:`▾`})]}),r?(0,L.jsxs)(`div`,{role:`dialog`,"aria-label":`Choose the time range`,className:`absolute right-0 z-20 mt-1 w-80 max-w-[calc(100vw-2rem)] rounded-lg border border-stone-200 bg-white p-3 shadow-lg dark:border-stone-700 dark:bg-stone-900`,children:[(0,L.jsx)(`p`,{className:`mb-1 text-xs font-medium text-stone-500 dark:text-stone-400`,children:`Commonly used`}),(0,L.jsxs)(`div`,{className:`mb-3 grid grid-cols-2 gap-1`,children:[bl.map(([t,n])=>(0,L.jsx)(`button`,{type:`button`,className:g(e.type===`last`&&e.period===t),onClick:()=>d({type:`last`,period:t}),children:n},t)),(0,L.jsx)(`button`,{type:`button`,className:`${g(e.type===`all`)} col-span-2`,onClick:()=>d({type:`all`}),children:`All the server keeps`})]}),(0,L.jsx)(`p`,{className:`mb-1 text-xs font-medium text-stone-500 dark:text-stone-400`,children:`From and to`}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`label`,{className:`flex items-center justify-between gap-2 text-sm`,children:[(0,L.jsx)(`span`,{className:`w-10 text-stone-500 dark:text-stone-400`,children:`From`}),(0,L.jsx)(`input`,{type:`datetime-local`,className:`${As} flex-1`,value:a,onChange:e=>o(e.target.value)})]}),(0,L.jsxs)(`label`,{className:`flex items-center justify-between gap-2 text-sm`,children:[(0,L.jsx)(`span`,{className:`w-10 text-stone-500 dark:text-stone-400`,children:`To`}),(0,L.jsx)(`input`,{type:`datetime-local`,className:`${As} flex-1`,value:s,onChange:e=>c(e.target.value),title:`empty: up to now`})]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsx)(`span`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:m?`The end is before the start.`:`An empty end is now.`}),(0,L.jsx)(`button`,{type:`button`,disabled:m,onClick:h,className:`rounded-md bg-emerald-600 px-3 py-1 text-sm font-medium text-white hover:bg-emerald-700 disabled:opacity-50 dark:bg-emerald-500 dark:text-stone-950 dark:hover:bg-emerald-400`,children:`Apply`})]})]})]}):null]})}var jl=`7d`,Ml=[`Run`,`Source`,`Tasks`,`Total`,`Created`],Nl=Ml.map((e,t)=>t>=3);function Pl({run:e,now:t}){let n=Uo(e,t),r=Wo(e,t);if(n===void 0&&r===void 0)return null;let i=[];return n!==void 0&&i.push([`Waited for a place`,n]),r!==void 0&&i.push([`Ran`,r]),(0,L.jsx)(hs,{tip:(0,L.jsx)(`dl`,{className:`grid grid-cols-[auto_auto] gap-x-4 gap-y-0.5`,children:i.map(([e,t])=>(0,L.jsxs)(`div`,{className:`contents`,children:[(0,L.jsx)(`dt`,{className:`text-stone-500 dark:text-stone-400`,children:e}),(0,L.jsx)(`dd`,{className:`text-right tabular-nums`,children:es(t)})]},e))}),children:es((n??0)+(r??0))})}var Fl=[[`state`,`State`],[`source`,`Source`],[`task`,`Task`]],Il=e=>e.value===`upload`?`an upload`:void 0;function Ll(){let[e,t]=Vi(),n=(e.get(`q`)??``).slice(0,100),r=tc(n.trim()),i=Cl(e,jl),a=Object.fromEntries(Fl.map(([t])=>[t,cc(e,t)])),o=Tl(i);o.set(`scope`,`visible`);let s=nc(o,a);r&&s.set(`q`,r);let c=Qs(`/runs?${s}`),l=$s(c,e=>e.runs,e=>e.id),u=ns(),d=n=>{let r=new URLSearchParams(e);n?r.set(`q`,n):r.delete(`q`),t(r,{replace:!0})},f=i.type===`all`?c.data?.pages[0]?.oldest:void 0;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{children:`Runs`}),(0,L.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,L.jsx)(`input`,{className:`${As} min-w-48 flex-1 sm:max-w-xs`,value:n,onChange:e=>d(e.target.value),placeholder:`task, service, ref, person, id`,"aria-label":`Search`}),(0,L.jsx)(`div`,{className:`sm:ml-auto`,children:(0,L.jsx)(Al,{value:i,oldest:f,onChange:n=>t(wl(e,n,jl),{replace:!0})})})]}),(0,L.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:Fl.map(([n,r])=>(0,L.jsx)(ic,{name:r,values:`/runs?${s}&values=${n}`,label:n===`source`?Il:void 0,chosen:a[n],onChange:r=>t(lc(e,n,r),{replace:!0})},n))}),(0,L.jsx)(Ts,{query:c,children:()=>{if(l.length===0){let e=r||Fl.some(([e])=>a[e].length>0);return(0,L.jsx)(as,{children:e?`No run of this period is like that.`:`No run in this period.`})}return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Hs,{head:Ml,right:Nl,children:l.map(e=>(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(J,{children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(fs,{state:e.state}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(vs,{id:e.id}),(0,L.jsxs)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:[e.may?.decide?(0,L.jsx)(Li,{to:`/runs/${encodeURIComponent(e.id)}`,className:`rounded-full bg-amber-500 px-1.5 font-medium whitespace-nowrap text-white hover:bg-amber-600`,children:`your approval`}):e.state,e.queue?`, ${e.queue.position}. in the queue`:null]})]})]})}),(0,L.jsx)(J,{children:(0,L.jsx)(ws,{run:e})}),(0,L.jsxs)(J,{children:[(0,L.jsx)(xs,{run:e}),e.error?(0,L.jsx)(`div`,{className:`text-xs whitespace-pre-wrap text-red-700 dark:text-red-400`,children:U($o(e.error,200))}):null]}),(0,L.jsx)(J,{num:!0,children:(0,L.jsx)(Pl,{run:e,now:u})}),(0,L.jsxs)(J,{num:!0,children:[(0,L.jsx)(gs,{iso:e.createdAt,now:u}),(0,L.jsx)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:e.owner?(0,L.jsx)(ys,{who:e.owner}):`you`})]})]},e.id))}),(0,L.jsx)(ec,{query:c})]})}})]})}var Rl=200;function zl(){let e=Sr().id??``,t=B(`/runs?scope=visible&id=${encodeURIComponent(e)}`,{refresh:e=>!Bl(e?.runs[0])}),n=Bl(t.data?.runs[0]),r=B(`/runs/${encodeURIComponent(e)}`,{enabled:n});return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{children:e}),n?(0,L.jsx)(Ts,{query:r,children:e=>(0,L.jsx)(Vl,{run:e,full:!0})}):(0,L.jsx)(Ts,{query:t,children:({runs:e})=>e[0]?(0,L.jsx)(Vl,{run:e[0]}):(0,L.jsx)(as,{children:`There is no such run you may see.`})})]})}function Bl(e){return!!e&&(!e.owner||!!e.readable)}function Vl({run:e,full:t=!1}){let n=ns(),r=!e.owner,i=e=>(0,L.jsx)(gs,{iso:e,now:n}),a=[[`Source`,(0,L.jsx)(ws,{run:e})],[`Build file`,(0,L.jsx)(Li,{className:`link font-mono text-[0.85em] break-all`,to:Bc(e.definition),children:e.definition})],[e.up?`Services`:`Tasks`,(0,L.jsx)(xs,{run:e})]];e.up&&a.push([`Endpoints`,(0,L.jsx)(Bs,{run:e})]),e.accounts.length>0&&a.push([`Accounts`,e.accounts.join(`, `)]);let o=[[`Owner`,e.owner?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(ys,{who:e.owner}),e.owner.name?null:(0,L.jsxs)(K,{children:[` at `,e.owner.iss]})]}):`you`],[`Created`,i(e.createdAt)]];e.retryOf&&o.push([`Retry of`,(0,L.jsx)(Li,{className:`link font-mono text-[0.85em]`,to:`/runs/${encodeURIComponent(e.retryOf)}`,children:e.retryOf})]);for(let t of e.approvals??[])o.push([(0,L.jsxs)(L.Fragment,{children:[`Approval of `,(0,L.jsx)(G,{children:t.account})]}),t.approvedBy?(0,L.jsxs)(L.Fragment,{children:[`approved by `,(0,L.jsx)(G,{children:t.approvedBy.sub})]}):t.expiresAt?(0,L.jsxs)(L.Fragment,{children:[`waits until `,i(t.expiresAt)]}):(0,L.jsx)(L.Fragment,{children:`waits until somebody decides`})]);let s=[],c=Uo(e,n);c!==void 0&&s.push([`Waited for a place`,`${es(c)}${e.state===`queued`?` so far`:``}`]),e.queue&&s.push([`Queue`,`${e.queue.position}. waits: ${Yo(e.queue.waitsFor,r,!1)}`]),e.startedAt&&s.push([`Started`,i(e.startedAt)]);let l=Wo(e,n);l!==void 0&&s.push([e.up?`Took to be up`:`Ran`,`${es(l)}${e.finishedAt||e.upAt?``:` so far`}`]),e.finishedAt&&s.push([`Finished`,i(e.finishedAt)]),e.up&&(e.upAt&&s.push([`Up since`,i(e.upAt)]),e.expiresAt&&s.push([`Ends`,(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[i(e.expiresAt),(0,L.jsx)(Is,{run:e})]})]),e.up.sleepTtl&&s.push([`Sleeps`,(0,L.jsxs)(L.Fragment,{children:[`after `,Xo(e.up.sleepTtl),` without a request`,e.state===`up`&&e.sleepsAt?(0,L.jsxs)(L.Fragment,{children:[`, next `,i(e.sleepsAt)]}):null,e.wakes?`, woken ${e.wakes}×`:``]})]));let u=[[`Source`,a],[`Owner`,o],[`Timing`,s]];return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(is,{className:`mb-6 flex flex-col gap-5`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-3 text-sm`,children:[(0,L.jsx)(ms,{state:e.state}),e.error?(0,L.jsx)(`span`,{className:`whitespace-pre-wrap text-red-700 dark:text-red-400`,children:U($o(e.error,2e3))}):null,(0,L.jsxs)(`span`,{className:`ml-auto inline-flex items-start gap-2`,children:[t?(0,L.jsxs)(`span`,{className:`self-center text-xs whitespace-nowrap text-stone-500 dark:text-stone-400`,children:[(0,L.jsx)(Li,{className:`link`,to:`/runs/${encodeURIComponent(e.id)}/log`,children:`log`}),` `,`·`,` `,(0,L.jsx)(`a`,{className:`link`,href:`/api/runs/${encodeURIComponent(e.id)}/log.txt`,download:!0,children:`download`})]}):null,(0,L.jsx)(Fs,{run:e}),(0,L.jsx)(Ns,{run:e}),(0,L.jsx)(Ps,{run:e})]})]}),e.may?.decide?(0,L.jsx)(Hl,{run:e,now:n}):null,(0,L.jsx)(`div`,{className:`grid gap-5 lg:grid-cols-3`,children:u.filter(([,e])=>e.length>0).map(([e,t])=>(0,L.jsxs)(`section`,{"aria-label":e,children:[(0,L.jsx)(`h2`,{className:`mb-2 text-xs font-medium tracking-wide text-stone-500 uppercase dark:text-stone-400`,children:e}),(0,L.jsx)(os,{items:t,columns:`grid-cols-[9rem_1fr] lg:grid-cols-[max-content_1fr]`})]},e))})]}),(0,L.jsx)(ql,{run:e,full:t,now:n})]})}function Hl({run:e,now:t}){let n=(e.approvals??[]).filter(e=>!e.approvedBy);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-md border border-amber-500/50 bg-amber-50 p-3 text-sm dark:bg-amber-950/30`,children:[(0,L.jsxs)(`p`,{children:[`Waits for your approval`,n.length>0?(0,L.jsxs)(L.Fragment,{children:[` `,`of `,(0,L.jsx)(W,{children:n.map(e=>e.account).join(`, `)}),n[0]?.expiresAt?(0,L.jsxs)(L.Fragment,{children:[`, until `,(0,L.jsx)(gs,{iso:n[0].expiresAt,now:t})]}):`, with no time limit`]}):null,`.`]}),(0,L.jsx)(Ls,{path:`/v1/approvals/${encodeURIComponent(e.id)}`,yes:`Approve`})]})}function Ul(e,t){if(!t)return[];let n=[],r=new Set,i=e=>{let a=t[e];if(!r.has(e)&&a){r.add(e);for(let e of[...a.deps,...a.needs])i(e);n.push(e)}},a=[...e.tasks,...e.up?.services??[]];for(let e of a.length>0?a:Object.keys(t))i(e);return n}function Wl(e){return e===`awaiting-approval`?`waiting`:e===`queued`?`queued`:Gl(e)?`skipped`:`pending`}var Gl=e=>[`succeeded`,`failed`,`cancelled`,`rejected`].includes(e);function Kl({name:e,shown:t,onClick:n}){return(0,L.jsx)(`button`,{type:`button`,onClick:n,"aria-expanded":t,"aria-controls":`does-${e}`,"aria-label":`${t?`Hide`:`Show`} ${e}`,className:`-ml-1 inline-flex h-5 w-5 items-center justify-center rounded text-stone-500 hover:bg-stone-100 dark:text-stone-400 dark:hover:bg-stone-800`,children:(0,L.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-3.5 w-3.5 fill-none stroke-current transition-transform ${t?`rotate-90`:``}`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,L.jsx)(`path`,{d:`M6 4l4 4-4 4`})})})}function ql({run:e,full:t,now:n}){let r=`plan`in e?e.plan:void 0,i=B(`/definitions/${zo(e.definition)}`,{enabled:!r,refresh:!1}),a=r??i.data?.plan,o=(0,j.useMemo)(()=>a&&Tc(a),[a]),[s,c]=(0,j.useState)(null),l=new Map(`results`in e&&e.results?Object.entries(e.results).map(([e,t])=>[e,{status:t.status,startedAt:t.startedAt,finishedAt:t.finishedAt,durationMs:t.durationMs,error:t.error,cache:t.cache?.hit?`hit`:t.cache?.causes?.map(e=>$o(e,200)).join(`
|
|
16
16
|
`),exitCode:t.exitCode,commands:t.commands}]):Object.entries((`timings`in e?e.timings:void 0)??{}).map(([e,t])=>[e,{status:t.status,startedAt:t.startedAt,finishedAt:t.finishedAt,durationMs:t.durationMs,cache:t.cached?`hit`:void 0}])),[u,d]=(0,j.useState)(()=>e.may?.decide?`all`:new Set(t?[...l].filter(([,e])=>e.status===`failed`).map(([e])=>e):[])),f=Ul(e,o),p=[...l.keys(),...e.up?.services??[],...e.tasks],m=[...new Set([...f,...p])];if(m.length===0)return null;let h=t=>o?.[t]?.kind===`service`||!!e.up?.services.includes(t),g=m.filter(h),_=m.filter(e=>!h(e)),v=e=>u===`all`||u.has(e),y=e=>{let t=new Set(u===`all`?m:u);t.has(e)?t.delete(e):t.add(e),d(t)},b=e=>t&&l.has(e),x=e=>!!o?.[e]||b(e),S=e=>{if(!e.some(x))return;let t=e.every(e=>!x(e)||v(e));return(0,L.jsx)(`button`,{type:`button`,className:`link text-sm font-normal`,onClick:()=>{let n=new Set(u===`all`?m:u);for(let r of e)t?n.delete(r):n.add(r);d(n)},children:t?`close all`:`open all`})},C=(t,n)=>x(t)&&v(t)?(0,L.jsx)(`tr`,{id:`does-${t}`,className:`bg-stone-50/60 dark:bg-stone-950/30`,children:(0,L.jsx)(`td`,{colSpan:n,className:`px-3 pt-1 pb-3 pl-9`,children:(0,L.jsx)(eu,{run:e,name:t,entry:o?.[t],log:b(t)})})}):null,w=e=>(0,L.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:x(e)?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Kl,{name:e,shown:v(e),onClick:()=>y(e)}),(0,L.jsx)(`button`,{type:`button`,className:`cursor-pointer`,onClick:()=>y(e),tabIndex:-1,children:(0,L.jsx)(G,{className:`break-normal`,children:e})})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`w-4`}),(0,L.jsx)(G,{className:`break-normal`,children:e})]})}),T=t=>{let n=l.get(t)?.status;if(n)return n;let r=[`awaiting-approval`,`queued`].includes(e.state);return e.up?.services.includes(t)&&!r&&e.state!==`running`?e.state:r||e.up||!h(t)?Wl(e.state):void 0},E=Object.fromEntries(m.flatMap(e=>{let t=T(e),n=l.get(e),r=n?.durationMs!==void 0&&t!==`cached`?es(n.durationMs):void 0;return t?[[e,{state:t,...r?{note:r}:{}}]]:[]})),D=_.filter(e=>[`succeeded`,`failed`,`cached`].includes(l.get(e)?.status??``)),O=D.filter(e=>l.get(e)?.status===`cached`).length,ee=D.reduce((e,t)=>e+(l.get(t)?.status===`cached`?0:l.get(t)?.durationMs??0),0),k=[D.length>0?`${O} of ${D.length} tasks from the cache (${Math.round(O/D.length*100)}%)${ee?`, ${es(ee)} run`:``}`:``,`a click on a task opens it`].filter(Boolean).join(` · `),A=[`Service`,`Status`,`Took`],te=[`Task`,`Status`,`Took`,`Deps`,`Cache`,...t?[`Exit`]:[]];return(0,L.jsxs)(L.Fragment,{children:[o?(0,L.jsxs)(rs,{title:`Graph`,note:k,children:[(0,L.jsx)(Mc,{run:!0,plan:o,names:m}),(0,L.jsx)(Ec,{plan:o,names:m.filter(e=>o[e]),states:E,selected:s,onSelect:c})]}):null,s?(0,L.jsx)(zc,{title:s,status:(0,L.jsx)(ms,{state:T(s)??Wl(e.state)}),tabs:[{name:`Task`,content:(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsx)(Y,{row:l.get(s),full:t}),o?(0,L.jsx)(Rc,{name:s,plan:o,inputs:i.data?.inputs,args:t?e.options?.args:void 0,onSelect:c}):null]})},...b(s)?[{name:`Log`,content:(0,L.jsx)(tu,{run:e,name:s})}]:[]],onClose:()=>c(null)}):null,(0,L.jsx)($l,{run:e,names:m,ran:l,plan:o,now:n}),g.length>0?(0,L.jsx)(rs,{title:`Services`,note:S(g),children:(0,L.jsx)(Hs,{head:A,right:[!1,!1,!0],children:g.map(e=>{let t=T(e);return(0,L.jsxs)(j.Fragment,{children:[(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(J,{className:`whitespace-nowrap`,children:w(e)}),(0,L.jsx)(J,{children:t?(0,L.jsx)(ps,{state:t}):(0,L.jsx)(K,{children:`–`})}),(0,L.jsx)(J,{num:!0,children:es(l.get(e)?.durationMs)})]}),C(e,A.length)]},e)})})}):null,_.length>0?(0,L.jsxs)(rs,{title:`Tasks`,note:S(_),children:[t?(0,L.jsx)(Rs,{args:e.options?.args}):null,(0,L.jsx)(Hs,{head:te,right:te.map((e,t)=>t===2||t===5),children:_.map(n=>{let r=l.get(n),i=o?.[n];return(0,L.jsxs)(j.Fragment,{children:[(0,L.jsxs)(`tr`,{children:[(0,L.jsxs)(J,{className:`whitespace-nowrap`,children:[w(n),t&&r?.error?(0,L.jsx)(`div`,{className:`pl-5 text-xs whitespace-pre-wrap text-red-700 dark:text-red-400`,children:U($o(r.error,500))}):null]}),(0,L.jsx)(J,{children:(0,L.jsx)(ps,{state:T(n)??Wl(e.state)})}),(0,L.jsx)(J,{num:!0,children:es(r?.durationMs)}),(0,L.jsx)(J,{children:i&&i.deps.length+i.needs.length>0?(0,L.jsxs)(`span`,{className:`font-mono text-[0.85em]`,children:[U(i.deps.join(`, `)),i.needs.length>0?(0,L.jsxs)(`span`,{className:`text-stone-500 dark:text-stone-400`,children:[i.deps.length>0?` · `:``,U(i.needs.join(`, `))]}):null]}):null}),(0,L.jsx)(J,{className:`text-xs whitespace-pre-wrap`,children:r?.cache?U(r.cache):null}),t?(0,L.jsx)(J,{num:!0,children:r?.exitCode??``}):null]}),C(n,te.length)]},n)})})]}):null]})}var Jl={succeeded:`bg-emerald-500 dark:bg-emerald-400`,cached:`bg-emerald-300 dark:bg-emerald-700`,failed:`bg-red-500 dark:bg-red-400`,running:`bg-sky-500 dark:bg-sky-400`},Yl={waiting:`bg-amber-400 dark:bg-amber-500`,prepare:`bg-violet-400 dark:bg-violet-500`,setup:`bg-stone-300 dark:bg-stone-600`,tasks:`bg-stone-400 dark:bg-stone-500`,other:`border border-stone-300 dark:border-stone-600`},Xl=[{phase:`source`,label:`checkout`,style:`bg-indigo-500 dark:bg-indigo-400`,tip:`the files of the run: a checkout of the commit, or those of the sandbox`},{phase:`namespace`,label:`namespace`,style:`bg-fuchsia-400 dark:bg-fuchsia-600`,tip:`the place of the run on the cluster prepared: its namespace, quota and claims`},{phase:`plan`,label:`plan`,style:`bg-teal-600 dark:bg-teal-600`,tip:`the process of the run started and read the build files`}];function Zl(e){let t=0,n=-1/0;for(let[r,i]of[...e].sort((e,t)=>e[0]-t[0]))i>n&&(t+=i-Math.max(r,n),n=i);return t}function Ql({tip:e,took:t,children:n}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`flex min-w-0 items-center gap-1.5 truncate text-stone-600 dark:text-stone-300`,children:`run`}),(0,L.jsx)(`div`,{role:`img`,"aria-label":`run: ${e}`,title:e,className:`relative h-3 rounded-sm bg-stone-100 dark:bg-stone-800/60`,children:n}),(0,L.jsx)(`span`,{className:`text-right text-xs text-stone-500 tabular-nums dark:text-stone-400`,children:t})]})}function $l({run:e,names:t,ran:n,plan:r,now:i}){let a=Date.parse(e.createdAt),o=e.finishedAt?Date.parse(e.finishedAt):i,s=e.startedAt?Date.parse(e.startedAt):void 0,c=[],l=Xl.flatMap(t=>{let n=e.phases?.find(e=>e.phase===t.phase),r=n?[Date.parse(n.startedAt),Date.parse(n.finishedAt)]:void 0;return r&&Number.isFinite(r[0])&&Number.isFinite(r[1])&&r[1]>=r[0]?[{...t,interval:r}]:[]});for(let e of t){let t=n.get(e),r=t?.status===`cached`,a=r?t.finishedAt??t.startedAt:t?.startedAt;if(!t||!a||!Number.isFinite(Date.parse(a)))continue;let o=Date.parse(a),s=r?o:t.finishedAt?Date.parse(t.finishedAt):t.status===`running`?i:o+(t.durationMs??0),l=t.commands?.map(({startedAt:e,finishedAt:t})=>[Math.max(o,Date.parse(e)),Math.min(s,Date.parse(t))]).filter(([e,t])=>Number.isFinite(e)&&Number.isFinite(t)&&t>=e);c.push({name:e,status:t.status,start:o,end:s,waiting:[],...r?{marker:!0}:{},...l?.length?{commands:l}:{}})}let u=new Map(c.map(e=>[e.name,e])),d=Math.min(...c.map(e=>e.start));for(let e of c){if(e.marker)continue;let t=(r?.[e.name]?.deps??[]).map(e=>u.get(e)).filter(t=>!!t&&t.end<=e.start).sort((e,t)=>t.end-e.end)[0];if(t)e.waiting=[[t.end,e.start]],e.waitedFor=t.name;else{let t=Math.min(s??d,d);e.waiting=[[a,t],[d,e.start]],e.prepare=[t,d]}}let f=Math.max(o-a,...c.map(e=>e.end-a),1);if(!c.length)return null;let p=e=>[e.start,e.end],m=s===void 0?f:Math.max(0,s-a),h=Zl(c.flatMap(e=>e.commands??[])),g=Zl(c.filter(e=>e.commands).map(p)),_=Zl(c.map(p)),v=Zl(l.map(e=>e.interval)),y=c.filter(e=>e.marker),b=Math.min(...c.filter(e=>!e.marker).map(e=>e.start)),x=Math.min(b,Math.max(d,...y.filter(e=>e.end<=b).map(e=>e.end))),S=l.length?Math.max(...l.map(e=>e.interval[1])):s??a,C=x>S?[S,x]:void 0,w=C?C[1]-C[0]:0,T=l.length?`cache check`:`prepare`,E=l.length?`the keys of the tasks computed from their files, each taken from the cache a marker, until a first task started`:`the run before its first tasks: the checkout, the namespace, the plan, the cache check`,D=[{label:`waiting`,ms:m,style:Yl.waiting,tip:`for a place in the queue or an approval; on a line, also for the dependencies of the task`},...l.map(e=>({label:e.label,ms:e.interval[1]-e.interval[0],style:e.style,tip:e.tip})),{label:T,ms:w,style:Yl.prepare,tip:E},{label:`setup`,ms:g-h,style:Yl.setup,tip:`a task, but no command: the pod scheduled, the image pulled, caches restored and stored`},{label:`commands`,ms:h,style:Jl.succeeded,tip:`a command ran, in the color of how its task ended`},{label:`tasks`,ms:_-g,style:Yl.tasks,tip:`a task that does not say when its commands ran: cached, still running`},{label:`other`,ms:Math.max(0,f-m-v-w-_),style:Yl.other,tip:`no task: between tasks, the end of the run`}].filter(e=>e.ms>=500),O=e=>Math.min(100,Math.max(0,e/f*100)),ee=([e,t])=>({left:`${O(e-a)}%`,width:`${O(t-e)}%`}),k=(e,t,n,r)=>t&&t[1]>t[0]?(0,L.jsx)(`div`,{title:r,className:`absolute inset-y-0 rounded-sm ${n}`,style:ee(t)},e):null,A=e=>es(e[1]-e[0])||`0s`;return(0,L.jsx)(rs,{title:`Timeline`,note:`${es(f)} since submitted${e.finishedAt?` until finished`:``}`,children:(0,L.jsxs)(is,{children:[(0,L.jsxs)(`ul`,{className:`mb-3 flex flex-wrap gap-x-4 gap-y-1 text-xs text-stone-600 dark:text-stone-300`,children:[D.map(e=>(0,L.jsxs)(`li`,{className:`flex cursor-help items-center gap-1.5`,title:`${e.label}: ${e.tip}`,children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:`inline-block h-2.5 w-2.5 rounded-sm ${e.style}`}),e.label,(0,L.jsxs)(`span`,{className:`text-stone-500 tabular-nums dark:text-stone-400`,children:[es(e.ms)||`0s`,` · `,Math.round(O(e.ms)),`%`]})]},e.label)),y.length?(0,L.jsxs)(`li`,{className:`flex cursor-help items-center gap-1.5`,title:`cached: a task taken from the cache, when it was`,children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:`inline-block h-2.5 w-1 rounded-sm ${Jl.cached}`}),`cached`,(0,L.jsxs)(`span`,{className:`text-stone-500 tabular-nums dark:text-stone-400`,children:[y.length,` `,y.length===1?`task`:`tasks`]})]}):null]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-[minmax(6rem,max-content)_1fr_3.5rem] items-center gap-x-3 gap-y-1.5 text-sm`,children:[l.length||C?(0,L.jsxs)(Ql,{tip:[s!==void 0&&s>a?`waited ${A([a,s])} in the queue`:``,...l.map(e=>`${e.label} ${A(e.interval)}`),C?`${T} ${A(C)}`:``].filter(Boolean).join(`, `),took:A([a,C?.[1]??d]),children:[k(`queue`,s===void 0?void 0:[a,s],Yl.waiting,`in the queue`),l.map(e=>k(e.phase,e.interval,e.style,`${e.label}: ${A(e.interval)}, ${e.tip}`)),k(`checking`,C,Yl.prepare,C?`${T}: ${A(C)}, ${E}`:``)]}):null,c.map(e=>{let t=[e.start,e.end],n=e.commands?Zl(e.commands):void 0,r=e.waitedFor?`for ${e.waitedFor}`:`in the queue, for a place`,i=e.waiting.reduce((e,[t,n])=>e+Math.max(0,n-t),0),o=[i>0?`waited ${es(i)||`0s`} ${r}`:``,e.prepare&&e.prepare[1]>e.prepare[0]?`prepare ${A(e.prepare)}`:``,n===void 0?``:`setup ${es(e.end-e.start-n)||`0s`}, commands ${es(n)||`0s`}`].filter(Boolean),s=e.marker?`${e.name}: ${e.status}, at ${es(e.end-a)||`0s`}${i>0?`, after ${e.waitedFor??`the run prepared`}`:``}`:`${e.name}: ${e.status}, ${A(t)}${o.length?` (${o.join(`, `)})`:``}`,c=Jl[e.status]??Yl.tasks;return(0,L.jsxs)(j.Fragment,{children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 truncate`,children:[(0,L.jsx)(ps,{state:e.status}),(0,L.jsx)(G,{className:`break-normal`,children:e.name})]}),(0,L.jsxs)(`div`,{role:`img`,"aria-label":s,title:s,className:`relative h-3 rounded-sm bg-stone-100 dark:bg-stone-800/60`,children:[e.waiting.map((e,t)=>k(`waiting-${t}`,e,Yl.waiting,`waited ${A(e)} ${r}`)),k(`prepare`,e.prepare,Yl.prepare,`the run prepared: checkout, namespace, plan`),e.marker?(0,L.jsx)(`div`,{title:s,className:`absolute -inset-y-0.5 w-1 -translate-x-1/2 rounded-sm ring-2 ring-white dark:ring-stone-900 ${c}`,style:{left:`${O(e.end-a)}%`}}):(0,L.jsx)(`div`,{title:s,className:`absolute inset-y-0 min-w-0.5 rounded-sm ${e.commands?Yl.setup:c}`,style:ee(t)}),e.commands?.map((t,n)=>(0,L.jsx)(`div`,{title:`${e.name}, command ${n+1}: ${A(t)}`,className:`absolute inset-y-0 min-w-0.5 rounded-sm ${c}`,style:ee(t)},n))]}),(0,L.jsx)(`span`,{className:`text-right text-xs text-stone-500 tabular-nums dark:text-stone-400`,children:e.marker?`cached`:A(t)})]},e.name)}),(0,L.jsx)(`span`,{}),(0,L.jsx)(`div`,{className:`relative h-4 text-[0.7rem] text-stone-400 tabular-nums dark:text-stone-500`,children:[0,.25,.5,.75,1].map(e=>(0,L.jsx)(`span`,{className:`absolute top-0 whitespace-nowrap ${e===0?``:e===1?`-translate-x-full`:`-translate-x-1/2`}`,style:{left:`${e*100}%`},children:e===0?`0`:es(f*e)},e))}),(0,L.jsx)(`span`,{})]})]})})}function eu({run:e,name:t,entry:n,log:r}){let[i,a]=(0,j.useState)(r?`log`:`command`),o=[...n?[`command`]:[],...r?[`log`]:[]],s=o.includes(i)?i:o[0];return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o.length>1?(0,L.jsx)(`div`,{role:`tablist`,"aria-label":`What ${t} shows`,className:`flex gap-1 text-sm`,children:o.map(e=>(0,L.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===s,onClick:()=>a(e),className:`cursor-pointer rounded-md px-2.5 py-0.5 ${e===s?`bg-stone-200 font-medium text-stone-900 dark:bg-stone-700 dark:text-white`:`text-stone-600 hover:bg-stone-100 dark:text-stone-300 dark:hover:bg-stone-800`}`,children:e===`command`?`Command`:`Log`},e))}):null,(0,L.jsx)(`div`,{role:o.length>1?`tabpanel`:void 0,children:s===`log`?(0,L.jsx)(tu,{run:e,name:t}):n?(0,L.jsx)(zs,{entry:n,relations:!1}):null})]})}function Y({row:e,full:t}){return e?(0,L.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,L.jsx)(os,{items:[...e.durationMs===void 0?[]:[[`Took`,es(e.durationMs)||`0s`]],...e.cache?[[`Cache`,e.cache===`hit`?`taken from the cache`:(0,L.jsx)(`span`,{className:`text-xs whitespace-pre-wrap`,children:U(e.cache)})]]:[],...t&&e.exitCode!==void 0?[[`Exit code`,String(e.exitCode)]]:[]],columns:`grid-cols-[7rem_1fr]`}),t&&e.error?(0,L.jsx)(`p`,{className:`text-xs whitespace-pre-wrap text-red-700 dark:text-red-400`,children:U($o(e.error,2e3))}):null]}):null}function tu({run:e,name:t}){let n=encodeURIComponent(e.id),r=encodeURIComponent(t),i=B(`/runs/${n}/logs?tail=${Rl}&task=${r}`,{refresh:!Gl(e.state)}),a=(0,j.useRef)(null),o=(0,j.useRef)(!0);(0,j.useEffect)(()=>{a.current&&o.current&&(a.current.scrollTop=a.current.scrollHeight)},[i.data]);let s=()=>{let e=a.current;e&&(o.current=e.scrollHeight-e.scrollTop-e.clientHeight<8)};return(0,L.jsx)(Ts,{query:i,children:e=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{ref:a,onScroll:s,className:`max-h-96 overflow-y-auto rounded-lg`,children:(0,L.jsx)(ru,{page:e,named:!1})}),(0,L.jsxs)(`div`,{className:`mt-1 text-xs text-stone-500 dark:text-stone-400`,children:[e.total>e.lines.length?`the last ${e.lines.length} of ${e.total} lines · `:``,e.truncated?`cut off at runs.maxLogBytes · `:``,(0,L.jsx)(Li,{className:`link`,to:`/runs/${n}/log?task=${r}`,children:`all of it`}),` `,`·`,` `,(0,L.jsx)(`a`,{className:`link`,href:`/api/runs/${n}/log.txt?task=${r}`,download:!0,children:`download`})]})]})})}function nu({run:e,names:t,chosen:n,base:r,anchor:i=``}){let a=new Set(e.up?.services??Object.entries(e.plan??{}).filter(([,e])=>e.kind===`service`).map(([e])=>e)),o=(e,t)=>(0,L.jsx)(Li,{to:`${r}${e?`?task=${encodeURIComponent(e)}`:``}${i}`,className:e===n?`font-medium text-stone-900 dark:text-white`:`text-emerald-700 hover:underline dark:text-emerald-400`,"aria-current":e===n?`page`:void 0,children:t},e??``);return(0,L.jsxs)(`nav`,{className:`mb-2 flex flex-wrap gap-x-3 gap-y-1 text-sm`,children:[o(void 0,`all`),t.map(e=>o(e,(0,L.jsxs)(L.Fragment,{children:[U(e),e===`hammerkit`?(0,L.jsx)(K,{children:` (server)`}):a.has(e)?(0,L.jsx)(K,{children:` (service)`}):null]})))]})}function ru({page:e,named:t}){return e.lines.length===0?(0,L.jsx)(`pre`,{className:`log text-stone-500`,children:`nothing yet`}):(0,L.jsx)(`pre`,{className:`log`,children:e.lines.map(e=>(0,L.jsxs)(`span`,{className:e.stream===`stderr`?`text-red-300`:void 0,children:[t?(0,L.jsxs)(`span`,{className:`text-stone-500`,children:[`[`,U(e.task),`] `]}):null,e.match?(0,L.jsx)(`mark`,{className:`bg-amber-700 text-white`,children:Qo(e.text)}):Qo(e.text),`
|
|
17
17
|
`]},e.line))})}var iu=1e3;function au(){let e=Sr().id??``,[t,n]=Vi(),r=t.get(`task`)??void 0,i=(t.get(`grep`)??``).replace(/[\r\n]/g,` `).slice(0,200)||void 0,a=Number(t.get(`from`)),o=Number.isInteger(a)&&a>=1?a:void 0,[s,c]=(0,j.useState)(i??``),l=B(`/runs/${encodeURIComponent(e)}`,{refresh:!1}),u=new URLSearchParams({limit:String(iu)});r&&u.set(`task`,r),i&&(u.set(`grep`,i),u.set(`i`,`true`),u.set(`context`,`2`)),o===void 0?i||u.set(`tail`,String(iu)):u.set(`from`,String(o));let d=B(`/runs/${encodeURIComponent(e)}/logs?${u}`,{refresh:o===void 0}),f=t=>{let n=new URLSearchParams({...r?{task:r}:{},...i?{grep:i}:{},...t});return`/runs/${encodeURIComponent(e)}/log?${n}`},p=e=>{e.preventDefault();let t=new URLSearchParams(r?{task:r}:{});s.trim()&&t.set(`grep`,s.trim()),n(t)},m=r?`?task=${encodeURIComponent(r)}`:``;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{children:`Log of ${e}`}),(0,L.jsxs)(`p`,{className:`mb-3 text-sm`,children:[(0,L.jsx)(Li,{className:`link`,to:`/runs/${encodeURIComponent(e)}`,children:`back to the run`}),` `,`·`,` `,(0,L.jsx)(`a`,{className:`link`,href:`/api/runs/${encodeURIComponent(e)}/log.txt${m}`,download:!0,children:`download`})]}),l.data?(0,L.jsx)(nu,{run:l.data,names:d.data?.names??[],chosen:r,base:`/runs/${encodeURIComponent(e)}/log`}):null,(0,L.jsxs)(`form`,{className:`mb-3 flex flex-wrap items-center gap-2`,onSubmit:p,children:[(0,L.jsx)(`input`,{className:`${As} min-w-0 flex-1 sm:max-w-sm`,value:s,maxLength:200,onChange:e=>c(e.target.value),placeholder:`look for a text`,"aria-label":`Look for`}),(0,L.jsx)(Ds,{type:`submit`,children:`Look`}),i?(0,L.jsx)(Li,{className:`link text-sm`,to:`/runs/${encodeURIComponent(e)}/log${m}`,children:`show all`}):null]}),(0,L.jsx)(Ts,{query:d,missing:(0,L.jsx)(as,{children:`The log of this run is for its owner and who decides about it.`}),children:e=>{let t=e.lines[0]?.line,n=e.lines[e.lines.length-1]?.line,a=(0,L.jsxs)(`div`,{className:`my-2 flex gap-4 text-sm`,children:[!i&&t!==void 0&&t>1?(0,L.jsx)(Li,{className:`link`,to:f({from:String(Math.max(1,t-iu))}),children:`earlier`}):null,e.next===void 0?null:(0,L.jsx)(Li,{className:`link`,to:f({from:String(e.next)}),children:`later`})]});return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`text-sm`,children:(0,L.jsxs)(K,{children:[t===void 0?`${e.total} lines`:`lines ${t} to ${n} of ${e.total}`,i?`, with “${i}” and two lines around`:``,e.truncated?`, cut off at runs.maxLogBytes`:``]})}),a,(0,L.jsx)(ru,{page:e,named:!r}),a]})}})]})}var ou=`7d`,su=e=>e.value===`upload`?`an upload`:void 0,cu=[`Task`,`Last`,`Runs`,`Cache hits`,`Success`,`Median`,`90%`,`Total`],lu=cu.map((e,t)=>t>=1),uu=[`task`,`last`,`runs`,`cache`,`success`,`median`,`p90`,`total`];function du(e){let t=new Map;for(let n of e)t.set(n.repo,[...t.get(n.repo)??[],n]);return[...t].sort(([e],[t])=>e.localeCompare(t))}function fu({entry:e,now:t}){let n=Oc(e),{definition:r,entry:i}=e.last;return(0,L.jsxs)(`tr`,{children:[(0,L.jsxs)(J,{className:`whitespace-nowrap`,children:[(0,L.jsx)(G,{className:`break-normal`,children:e.task}),r?(0,L.jsxs)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:[(0,L.jsx)(Vc,{hash:r,entry:i}),` `,(0,L.jsx)(`span`,{className:`font-mono text-[0.85em]`,title:r,children:r.slice(7,19)})]}):null]}),(0,L.jsx)(J,{num:!0,children:(0,L.jsx)(gs,{iso:e.last.at,now:t})}),(0,L.jsx)(J,{num:!0,children:e.runs}),(0,L.jsx)(J,{num:!0,children:(0,L.jsx)(`span`,{title:`${e.cached} of ${e.runs} from the cache`,children:kc(Dc(e))})}),(0,L.jsx)(J,{num:!0,className:n===void 0||n===1?``:n<.5?`text-red-600 dark:text-red-400`:`text-amber-600 dark:text-amber-400`,children:(0,L.jsx)(`span`,{title:`${e.failed} of ${e.runs} failed`,children:kc(n)})}),(0,L.jsx)(J,{num:!0,children:es(e.medianMs)}),(0,L.jsx)(J,{num:!0,children:es(e.p90Ms)}),(0,L.jsx)(J,{num:!0,children:es(e.totalMs)})]})}function pu(){let[e,t]=Vi(),n=Cl(e,ou),r=Tl(n),[i,a]=(0,j.useState)(``),o=tc(i.trim()),s=cc(e,`source`),[c,l]=(0,j.useState)({key:`last`,dir:`desc`}),u=nc(r,{source:s});o&&u.set(`q`,o);let d=Qs(`/tasks?${u}&sort=${c.key}&order=${c.dir}`),f=$s(d,e=>e.tasks,e=>`${e.repo}\0${e.task}`),p=ns(),m=e=>l(t=>t.key===e?{key:e,dir:t.dir===`asc`?`desc`:`asc`}:{key:e,dir:e===`task`?`asc`:`desc`}),h=d.data?.pages[0]?.oldest;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{children:`Tasks`}),(0,L.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,L.jsx)(`input`,{className:`${As} min-w-48 flex-1 sm:max-w-xs`,value:i,onChange:e=>a(e.target.value),placeholder:`task, build file or repository`,"aria-label":`Search`}),(0,L.jsx)(`div`,{className:`sm:ml-auto`,children:(0,L.jsx)(Al,{value:n,oldest:h,onChange:n=>t(wl(e,n,ou),{replace:!0})})})]}),(0,L.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:(0,L.jsx)(ic,{name:`Source`,values:`/tasks?${u}&values=source`,label:su,chosen:s,onChange:n=>t(lc(e,`source`,n),{replace:!0})})}),(0,L.jsx)(Ts,{query:d,children:()=>f.length===0?(0,L.jsx)(as,{children:o||s.length>0?`No task of this period is like that.`:`No task ran in this period.`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Hs,{head:cu,right:lu,sort:{keys:uu,state:c,onSort:m},children:du(f).map(([e,t])=>(0,L.jsxs)(j.Fragment,{children:[(0,L.jsx)(`tr`,{className:`bg-stone-50 dark:bg-stone-950/40`,children:(0,L.jsx)(`th`,{colSpan:cu.length,scope:`colgroup`,className:`px-3 py-1.5 text-left text-xs font-medium text-stone-600 dark:text-stone-300`,children:(0,L.jsx)(Ss,{href:V(e)?.repo,children:(0,L.jsx)(W,{children:e})})})}),t.map(e=>(0,L.jsx)(fu,{entry:e,now:p},e.task))]},e))}),(0,L.jsx)(ec,{query:d})]})})]})}function mu(e,t,n,r){let i=e.filter(e=>e.hash!==t&&!e.yanked).sort((e,t)=>Date.parse(t.publishedAt)-Date.parse(e.publishedAt)),a=e=>e.annotations.path??e.entry;return(i.find(e=>e.annotations.repo===n&&a(e)===r)??i.find(e=>e.annotations.repo===n)??i[0])?.hash}var hu=e=>e.replace(/^sha256:/,``).slice(0,12);function gu(e,t,n){let[r,i]=Vi(),a=B(`/definitions`,{refresh:!1}),o=a.data?.definitions??[],s=o.filter(t=>t.hash!==e).sort((e,t)=>Date.parse(t.publishedAt)-Date.parse(e.publishedAt)),c=r.get(`base`);return{list:a,choices:s,base:s.some(e=>e.hash===c)?c:mu(o,e,t,n),setBase:e=>{let t=new URLSearchParams(r);t.set(`base`,e),i(t,{replace:!0})}}}function _u({choices:e,base:t,onChange:n}){return e.length===0?(0,L.jsx)(K,{children:`No other version is published to compare with.`}):(0,L.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-sm`,children:[(0,L.jsx)(`span`,{className:`shrink-0 text-stone-600 dark:text-stone-300`,children:`Compared with`}),(0,L.jsx)(`select`,{className:`${As} w-full min-w-0 sm:w-80`,value:t??``,onChange:e=>n(e.target.value),children:e.map(e=>(0,L.jsx)(`option`,{value:e.hash,children:[e.annotations.repo,e.annotations.path??e.entry,e.annotations.branch,e.annotations.commit?`at ${e.annotations.commit.slice(0,12)}`:``,hu(e.hash),new Date(e.publishedAt).toLocaleString(),e.yanked?`(yanked)`:``].filter(Boolean).join(` · `)},e.hash))})]})}var vu=new Set([`file`,`flags`]);function yu(e){let t=/^([^:]+):\/(?:[^:]*\/)?hammerkit-definition-[^/:]+(?:\/([^:]*))?(:ro)?$/.exec(e);return t&&(t[2]??`.`)===t[1].replace(/^\.\//,``)?`${t[1]}${t[3]??``}`:e}function bu(e){return e?{...e,mounts:e.mounts.map(yu)}:void 0}function xu(e,t){let n={};for(let[r,i]of Object.entries(t)){let t=bu(e[r]),a=bu(i);n[r]=t?[...new Set([...Object.keys(t),...Object.keys(a)])].some(e=>!vu.has(e)&&JSON.stringify(t[e])!==JSON.stringify(a[e]))?`changed`:`unchanged`:`added`}return{status:n,removed:Object.keys(e).filter(e=>!(e in t)).sort()}}function Su({before:e,after:t}){let n=[...new Set([...Object.keys(e??t),...Object.keys(t)])].sort().map(n=>{let r=e?e[n]===void 0?`added`:t[n]===void 0?`removed`:e[n]===t[n]?`same`:`changed`:`same`;return{path:n,status:r,lines:r===`same`?void 0:Du(e?.[n]??``,t[n]??``)}}),r=n.find(e=>e.status!==`same`)?.path,[i,a]=mc(n.map(e=>e.path)),[o]=Vi(),s=o.get(`file`)===null?r??i:i,c=o.get(`at`),l=n.find(e=>e.path===s);if(!l)return(0,L.jsx)(K,{children:`No files.`});let u=n.filter(e=>e.status!==`same`).length,d=t[l.path]??e?.[l.path]??``;return(0,L.jsxs)(L.Fragment,{children:[e?(0,L.jsx)(`p`,{className:`mb-2 text-sm text-stone-500 dark:text-stone-400`,children:u===0?`No file changed.`:`${qo(u,`file`)} changed.`}):null,(0,L.jsxs)(pc,{tree:(0,L.jsx)(fc,{items:n,open:s,onOpen:a,className:e=>wu[e.status]??``,extra:e=>e.lines?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:[`+`,e.lines.filter(e=>e.kind===`+`).length]}),` `,(0,L.jsxs)(`span`,{className:`text-red-700 dark:text-red-400`,children:[`−`,e.lines.filter(e=>e.kind===`-`).length]})]}):e.status===`same`?null:(0,L.jsx)(K,{children:`large`})}),children:[(0,L.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-baseline gap-2 text-sm`,children:[(0,L.jsx)(G,{children:l.path}),l.status===`same`?(0,L.jsxs)(K,{children:[e?`unchanged, `:``,d.split(`
|
|
18
18
|
`).length,` lines`]}):(0,L.jsx)(`span`,{className:wu[l.status]??``,children:l.status})]}),(0,L.jsx)(Ou,{lines:l.lines??d.split(`
|
|
19
19
|
`).map(e=>({kind:` `,text:e})),whole:l.status===`same`,focus:c?Cu(c):void 0},`${l.path}:${c??``}`)]})]})}function Cu(e){let t=e.split(`:`).pop()??e;return e=>{let n=e.trim();return/^\s/.test(e)&&(n===`${t}:`||n===`'${t}':`||n===`"${t}":`)}}var wu={added:`text-emerald-700 dark:text-emerald-400`,removed:`text-red-700 dark:text-red-400`,changed:`text-amber-700 dark:text-amber-400`},Tu=4e6,Eu=3;function Du(e,t){let n=e===``?[]:e.split(`
|
|
20
20
|
`),r=t===``?[]:t.split(`
|
|
21
|
-
`);if(n.length*r.length>Tu)return;let i=r.length+1,a=new Uint32Array((n.length+1)*i);for(let e=n.length-1;e>=0;e--)for(let t=r.length-1;t>=0;t--)a[e*i+t]=n[e]===r[t]?a[(e+1)*i+t+1]+1:Math.max(a[(e+1)*i+t],a[e*i+t+1]);let o=[],s=0,c=0;for(;s<n.length||c<r.length;)s<n.length&&c<r.length&&n[s]===r[c]?(o.push({kind:` `,text:n[s]}),s++,c++):c<r.length&&(s===n.length||a[s*i+c+1]>=a[(s+1)*i+c])?o.push({kind:`+`,text:r[c++]}):o.push({kind:`-`,text:n[s++]});return o}function Ou({lines:e,whole:t=!1,focus:n}){let r=(0,j.useRef)(null);if((0,j.useEffect)(()=>{r.current?.scrollIntoView({block:`center`})},[]),!e)return(0,L.jsx)(as,{children:`Too large to compare line by line.`});let i=n?e.findIndex(e=>e.kind!==`-`&&n(e.text)):-1,a=new Set;e.forEach((n,r)=>{if(t||n.kind!==` `||r===i)for(let t=Math.max(0,r-Eu);t<=Math.min(e.length-1,r+Eu);t++)a.add(t)});let o=[],s=!1;return e.forEach((e,n)=>{if(!a.has(n)){s=!0;return}s&&o.length>0&&o.push((0,L.jsx)(`div`,{className:`text-sky-400`,children:`⋯`},`gap${n}`)),s=!1;let c=e.kind===`+`?Os:e.kind===`-`?ks:``;o.push((0,L.jsxs)(`div`,{ref:n===i?r:void 0,className:n===i?`${c} outline-1 outline-amber-400`:c,children:[t?``:`${e.kind} `,U(e.text)||` `]},n))}),(0,L.jsx)(`pre`,{className:`log whitespace-pre-wrap`,children:o})}var ku=[`info`,`graph`,`files`];function Au(){let e=Sr().hash??``,t=vr(),n=ns(),[r,i]=Vi(),a=r.get(`tab`),o=ku.includes(a)?a:`info`,s=e=>{let t=new URLSearchParams(r);e===`info`?t.delete(`tab`):t.set(`tab`,e),i(t,{replace:!0})},[c,l]=(0,j.useState)(null),u=B(`/proposals/${zo(e)}`),d=u.data?.state===`waiting`,f=B(`/proposals/${zo(e)}/files`,{enabled:d,refresh:!1}),p=(0,j.useMemo)(()=>u.data&&Tc(u.data.plan),[u.data]),m=gu(e,u.data?.annotations?.repo,u.data?.annotations?.path??u.data?.entry),h=m.base,g=B(`/definitions/${zo(h??``)}`,{enabled:!!h,refresh:!1}),_=B(`/definitions/${zo(h??``)}/files`,{enabled:!!h&&d,refresh:!1}),v=(0,j.useMemo)(()=>p&&g.data?.plan?xu(Tc(g.data.plan),p):void 0,[p,g.data]),y=r.has(`change`)?cc(r,`change`):[`changed`],b=p&&v&&y.length>0?Object.fromEntries(Object.entries(p).filter(([e])=>y.includes(v.status[e]===`unchanged`?`unchanged`:`changed`))):p,x=e=>{let t=p?wc(e,p[e]):void 0;if(!t||f.data?.files[t]===void 0){l(e);return}let n=new URLSearchParams(r);n.set(`tab`,`files`),n.set(`file`,t),n.set(`at`,e),i(n)};return(0,L.jsx)(Ts,{query:u,missing:(0,L.jsx)(as,{children:`There is no such version you may see.`}),children:e=>{let a=[qo(e.tasks.length,`task`),...e.services.length>0?[qo(e.services.length,`service`)]:[]].join(`, `),u=f.data?Object.keys(f.data.files).length:void 0;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{note:`proposed`,children:e.entry}),(0,L.jsxs)(is,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1 text-sm`,children:[(0,L.jsx)(ms,{state:e.state}),e.reason?(0,L.jsx)(W,{children:e.reason}):null,d?(0,L.jsxs)(K,{children:[e.canDecide?`Waits for your approval`:`Waits for somebody who may publish`,`, until`,` `,(0,L.jsx)(gs,{iso:e.expiresAt,now:n})]}):null]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:ml-auto`,children:[d||m.choices.length>0?(0,L.jsx)(Ts,{query:m.list,children:()=>(0,L.jsx)(_u,{choices:m.choices,base:h,onChange:m.setBase})}):null,e.canDecide?(0,L.jsx)(Ls,{path:`/v1/proposals/${zo(e.hash)}`,yes:`Approve`,why:!1,onDone:()=>t(`/build-files`)}):null]})]}),(0,L.jsx)(Ws,{label:`What the proposed version shows`,tabs:[{key:`info`,name:`Info`},{key:`graph`,name:`Graph`,note:Object.keys(e.plan).length},{key:`files`,name:`Files`,note:u}],current:o,onChange:s}),o===`info`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(is,{className:`mb-6`,children:(0,L.jsx)(os,{items:Pu(e,n)})}),(0,L.jsxs)(rs,{title:`Tasks and services`,note:`${a}, a click on one opens where it is declared`,children:[v?(0,L.jsx)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:(0,L.jsx)(ic,{name:`Compared`,options:[`changed`,`unchanged`].map(e=>({value:e,count:Object.values(v.status).filter(t=>(t===`unchanged`?`unchanged`:`changed`)===e).length})),chosen:y,onChange:e=>{let t=lc(r,`change`,e);e.length===0&&t.set(`change`,``),i(t,{replace:!0})}})}):null,b&&Object.keys(b).length>0?(0,L.jsx)(Xc,{plan:b,marks:v?Nu(v.status):void 0,onSelect:x}):(0,L.jsx)(as,{children:`Every task and service is the same as in the version it is compared with.`}),v&&v.removed.length>0?(0,L.jsxs)(`p`,{className:`mt-3 text-sm text-red-700 dark:text-red-400`,children:[`Removed:`,` `,v.removed.map(e=>(0,L.jsx)(G,{className:`mr-2`,children:e},e))]}):null]})]}):null,o===`graph`&&p?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{className:`mb-2 text-sm text-stone-500 dark:text-stone-400`,children:[a,`, a click on one opens it.`]}),(0,L.jsx)(Mc,{plan:p,marks:v?Mu(v.status):void 0}),(0,L.jsx)(Ec,{plan:p,marks:v?Mu(v.status):void 0,selected:c,onSelect:l})]}):null,o===`files`?d?(0,L.jsx)(Ts,{query:f,children:e=>h?(0,L.jsx)(Ts,{query:_,missing:(0,L.jsx)(Su,{before:void 0,after:e.files}),children:t=>(0,L.jsx)(Su,{before:t.files,after:e.files})}):(0,L.jsx)(Su,{before:void 0,after:e.files})}):(0,L.jsx)(as,{children:`The files are kept only while the version waits.`}):null,c&&p?(0,L.jsx)(Nc,{name:c,plan:p,onSelect:l}):null]})}})}var ju={added:`border-emerald-500 text-emerald-700 dark:text-emerald-400`,changed:`border-amber-500 text-amber-700 dark:text-amber-400`,unchanged:``};function Mu(e){return Object.fromEntries(Object.entries(e).flatMap(([e,t])=>t===`unchanged`?[]:[[e,t]]))}function Nu(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==`unchanged`).map(([e,t])=>[e,(0,L.jsx)(`span`,{className:`rounded-full border px-1.5 text-xs ${ju[t]}`,children:t})]))}function Pu(e,t){let n=e.annotations?.repo,r=[[`Hash`,(0,L.jsx)(G,{className:`break-all`,children:e.hash})],[`Proposed by`,(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(G,{children:e.proposedBy.sub}),` `,(0,L.jsx)(gs,{iso:e.createdAt,now:t})]})]];e.decidedBy&&r.push([e.state===`approved`?`Approved by`:`Decided by`,(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(G,{children:e.decidedBy.sub}),e.decidedAt?(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(gs,{iso:e.decidedAt,now:t})]}):null]})]),n&&r.push([`Repository`,(0,L.jsx)(Cs,{repo:n,gitRef:e.annotations?.branch,commit:e.annotations?.commit})]);let i=Object.entries(e.annotations??{}).filter(([e])=>![`repo`,`branch`,`commit`].includes(e));return i.length>0&&r.push([`Annotations`,(0,L.jsx)(`span`,{className:`flex flex-wrap gap-2`,children:i.map(([e,t])=>(0,L.jsx)(G,{children:`${e}=${String(t)}`},e))})]),e.accounts.length>0&&r.push([`Accounts`,(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(W,{children:e.accounts.join(`, `)}),e.missing.length>0?(0,L.jsxs)(`span`,{className:`text-stone-500 dark:text-stone-400`,children:[` (who publishes uses `,e.missing.join(`, `),`)`]}):null]})]),r}function Fu(e){return`/sandboxes/${encodeURIComponent(e)}`}function Iu(e){let t=new Map;for(let n of[...e].sort((e,t)=>Date.parse(t.lastUsedAt)-Date.parse(e.lastUsedAt)))t.set(n.repo,[...t.get(n.repo)??[],n]);return[...t].sort(([e],[t])=>e.localeCompare(t))}function Lu({sandbox:e}){let t=V(e.repo),n=e.pushed?.[e.ref]===e.commit,r=Object.entries(e.pushed??{}).filter(([t,n])=>t!==e.ref||n!==e.commit);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Ss,{href:t?.ref?.(e.ref),children:(0,L.jsx)(G,{className:`break-normal`,children:e.ref})}),(0,L.jsxs)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:[`at`,` `,(0,L.jsx)(Ss,{href:t?.commit?.(e.commit),children:(0,L.jsx)(G,{className:`break-normal`,children:e.commit.slice(0,12)})}),n?`, pushed`:null]}),r.length>0?(0,L.jsxs)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:[`pushed`,` `,r.map(([n,r],i)=>(0,L.jsxs)(j.Fragment,{children:[i>0?`, `:``,n===e.ref?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Ss,{href:t?.ref?.(n),children:(0,L.jsx)(G,{children:n})}),` `]}),(0,L.jsx)(K,{children:`at`}),` `,(0,L.jsx)(Ss,{href:t?.commit?.(r),children:(0,L.jsx)(G,{children:r.slice(0,12)})})]},n))]}):null]})}function Ru({sandbox:e,onDone:t}){let n=Ro(()=>Fo(`/v1/sandboxes/${encodeURIComponent(e.id)}`)),r=e.run?`Delete ${e.id}? The run ${e.run} that works on it stops, and what was not pushed is gone.`:`Delete ${e.id}? What was not pushed is gone.`;return(0,L.jsxs)(`span`,{className:`inline-flex flex-col items-end gap-1`,children:[(0,L.jsx)(`button`,{type:`button`,title:`Delete`,"aria-label":`Delete ${e.id}`,disabled:n.isPending,onClick:()=>{window.confirm(r)&&n.mutate(void 0,{onSuccess:()=>t?.()})},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-red-300 text-red-700 hover:bg-red-50 disabled:opacity-50 dark:border-red-900 dark:text-red-400 dark:hover:bg-red-950`,children:(0,L.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4 fill-none stroke-current`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,L.jsx)(`path`,{d:`M2.5 4.5h11M6.5 4.5V3h3v1.5M4 4.5l.75 8.5h6.5L12 4.5M6.75 7v4M9.25 7v4`})})}),n.error?(0,L.jsx)(Es,{error:n.error}):null]})}var zu=[[`owner`,`Owner`],[`repo`,`Repository`],[`ref`,`Branch`]];function Bu(){let[e,t]=Vi(),n=Lo().data,r=n?.observe??!1,i=zu.filter(([e])=>r||e!==`owner`),a=Object.fromEntries(i.map(([t])=>[t,cc(e,t)])),o=nc(new URLSearchParams(r?`scope=all`:``),a),s=Qs(`/sandboxes?${o}`),c=$s(s,e=>e.sandboxes,e=>e.id),l=ns(),u=i.some(([e])=>a[e].length>0),d=e=>e.value===n?.sub?`you`:c.find(t=>t.owner?.sub===e.value)?.owner?.name,f=r?7:6;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{children:`Sandboxes`}),u||c.length>0?(0,L.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:i.map(([n,r])=>(0,L.jsx)(ic,{name:r,values:`/sandboxes?${o}&values=${n}`,label:n===`owner`?d:void 0,chosen:a[n],onChange:r=>t(lc(e,n,r),{replace:!0})},n))}):null,(0,L.jsx)(Ts,{query:s,missing:(0,L.jsx)(as,{children:`This server keeps no sandboxes.`}),children:()=>(0,L.jsxs)(L.Fragment,{children:[c.length===0?(0,L.jsx)(as,{children:u?`No sandbox is like that.`:r?`There is no sandbox on this server.`:`You have no sandbox on this server.`}):(0,L.jsx)(Hs,{head:[`Sandbox`,`Branch`,...r?[`Owner`]:[],`Size`,`Last used`,`Created`,``],right:[!1,!1,...r?[!1]:[],!0,!0,!0,!0],children:Iu(c).map(([e,t])=>(0,L.jsxs)(j.Fragment,{children:[(0,L.jsx)(`tr`,{className:`bg-stone-50 dark:bg-stone-950/40`,children:(0,L.jsx)(`th`,{colSpan:f,scope:`colgroup`,className:`px-3 py-1.5 text-left text-xs font-medium text-stone-600 dark:text-stone-300`,children:(0,L.jsx)(Ss,{href:V(e)?.repo,children:(0,L.jsx)(W,{children:e})})})}),t.map(e=>(0,L.jsxs)(`tr`,{children:[(0,L.jsxs)(J,{className:`whitespace-nowrap`,children:[(0,L.jsx)(Li,{className:`link font-mono text-[0.85em]`,to:Fu(e.id),children:e.id}),(0,L.jsx)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:e.run?(0,L.jsxs)(L.Fragment,{children:[`busy with `,(0,L.jsx)(vs,{id:e.run})]}):`free`})]}),(0,L.jsx)(J,{className:`whitespace-nowrap`,children:(0,L.jsx)(Lu,{sandbox:e})}),r?(0,L.jsx)(J,{className:`whitespace-nowrap`,children:e.owner?(0,L.jsx)(ys,{who:e.owner}):(0,L.jsx)(K,{children:`you`})}):null,(0,L.jsx)(J,{num:!0,children:Jo(e.bytes)}),(0,L.jsx)(J,{num:!0,children:(0,L.jsx)(gs,{iso:e.lastUsedAt,now:l})}),(0,L.jsx)(J,{num:!0,children:(0,L.jsx)(gs,{iso:e.createdAt,now:l})}),(0,L.jsx)(J,{className:`text-right`,children:e.owner?null:(0,L.jsx)(Ru,{sandbox:e})})]},e.id))]},e))}),(0,L.jsx)(ec,{query:s})]})})]})}var Vu={added:`text-emerald-700 dark:text-emerald-400`,deleted:`text-red-700 dark:text-red-400`};function Hu(){let e=Sr().id??``,t=vr(),[n,r]=Vi(),i=n.get(`tab`)===`runs`?`runs`:`changes`,a=e=>{let t=new URLSearchParams(n);e===`changes`?t.delete(`tab`):t.set(`tab`,e),r(t,{replace:!0})},o=ns(),s=Lo().data?.observe??!1,c=B(`/sandboxes/${encodeURIComponent(e)}`),l=c.data!==void 0&&!c.data.busy,u=B(`/sandboxes/${encodeURIComponent(e)}/changes`,{enabled:l}),d=u.data?.files??[],f=d.find(e=>e.path===n.get(`file`))??d[0],p=new URLSearchParams({format:`diff`});for(let e of f?[f.path,...f.from?[f.from]:[]]:[])p.append(`path`,e);let m=Mo(`/sandboxes/${encodeURIComponent(e)}/changes?${p}`,{enabled:l&&f!==void 0}),h=B(`/runs?${new URLSearchParams({scope:s?`all`:`mine`,sandbox:e})}`);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{children:e}),(0,L.jsx)(Ts,{query:c,missing:(0,L.jsx)(as,{children:s?`There is no such sandbox.`:`There is no such sandbox of yours.`}),children:e=>{let s=[[`Repository`,(0,L.jsx)(Ss,{href:V(e.repo)?.repo,children:(0,L.jsx)(W,{children:e.repo})})],[`Branch`,(0,L.jsx)(Lu,{sandbox:e})],...e.owner?[[`Owner`,(0,L.jsx)(ys,{who:e.owner})]]:[],[`Size`,Jo(e.bytes)],[`Created`,(0,L.jsx)(gs,{iso:e.createdAt,now:o})],[`Last used`,(0,L.jsx)(gs,{iso:e.lastUsedAt,now:o})],[`Run`,e.run?(0,L.jsx)(vs,{id:e.run}):(0,L.jsx)(K,{children:`none works on it`})]];return(0,L.jsxs)(L.Fragment,{children:[e.owner?(0,L.jsxs)(`p`,{className:`mb-4 rounded-lg border border-sky-200 bg-sky-50 px-4 py-2 text-sm text-sky-900 dark:border-sky-900 dark:bg-sky-950 dark:text-sky-200`,children:[`A sandbox of `,(0,L.jsx)(ys,{who:e.owner}),`. You see it because you observe this server: you can read it, but not change or delete it.`]}):null,(0,L.jsxs)(is,{className:`mb-6 flex items-start gap-4`,children:[(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,L.jsx)(os,{items:s})}),e.owner?null:(0,L.jsx)(Ru,{sandbox:e,onDone:()=>t(`/sandboxes`)})]}),(0,L.jsx)(Ws,{label:`What the sandbox shows`,tabs:[{key:`changes`,name:`Changes`,note:u.data?u.data.files.length:void 0},{key:`runs`,name:`Runs`,note:h.data?h.data.runs.length:void 0}],current:i,onChange:a}),i===`runs`?(0,L.jsx)(L.Fragment,{children:(0,L.jsx)(Ts,{query:h,children:({runs:e})=>e.length===0?(0,L.jsx)(as,{children:`No run worked on it.`}):(0,L.jsx)(Hs,{head:[`Run`,`Tasks`,`Created`],right:[!1,!1,!0],children:e.map(e=>(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(J,{className:`whitespace-nowrap`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(fs,{state:e.state}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(vs,{id:e.id}),(0,L.jsx)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:e.state})]})]})}),(0,L.jsx)(J,{children:(0,L.jsx)(xs,{run:e})}),(0,L.jsx)(J,{num:!0,children:(0,L.jsx)(gs,{iso:e.createdAt,now:o})})]},e.id))})})}):(0,L.jsx)(L.Fragment,{children:e.busy?(0,L.jsx)(as,{children:`A run works on it: the changes show once it is over.`}):(0,L.jsx)(Ts,{query:u,children:({files:t})=>t.length===0||!f?(0,L.jsxs)(as,{children:[`Nothing changed since `,e.commit.slice(0,12),`.`]}):(0,L.jsxs)(pc,{tree:(0,L.jsx)(fc,{items:t,open:f.path,onOpen:e=>{let t=new URLSearchParams(n);t.set(`file`,e),r(t,{replace:!0})},className:e=>Vu[e.status]??``,extra:e=>(0,L.jsxs)(L.Fragment,{children:[e.additions===null?null:(0,L.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:[`+`,e.additions]}),` `,e.deletions===null?null:(0,L.jsxs)(`span`,{className:`text-red-700 dark:text-red-400`,children:[`−`,e.deletions]})]})}),children:[(0,L.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-baseline gap-2 text-sm`,children:[(0,L.jsx)(G,{children:f.path}),f.from?(0,L.jsxs)(K,{children:[`from `,(0,L.jsx)(G,{children:f.from})]}):null,(0,L.jsx)(`span`,{className:Vu[f.status]??``,children:f.status})]}),(0,L.jsx)(Ts,{query:m,children:e=>e?(0,L.jsx)(Wu,{text:Uu(e,f.path)}):(0,L.jsx)(as,{children:`No lines to show: its mode or kind changed.`})})]})})})]})}})]})}function Uu(e,t){let n=e.split(/^(?=diff --git )/m).filter(e=>e.split(`
|
|
21
|
+
`);if(n.length*r.length>Tu)return;let i=r.length+1,a=new Uint32Array((n.length+1)*i);for(let e=n.length-1;e>=0;e--)for(let t=r.length-1;t>=0;t--)a[e*i+t]=n[e]===r[t]?a[(e+1)*i+t+1]+1:Math.max(a[(e+1)*i+t],a[e*i+t+1]);let o=[],s=0,c=0;for(;s<n.length||c<r.length;)s<n.length&&c<r.length&&n[s]===r[c]?(o.push({kind:` `,text:n[s]}),s++,c++):c<r.length&&(s===n.length||a[s*i+c+1]>=a[(s+1)*i+c])?o.push({kind:`+`,text:r[c++]}):o.push({kind:`-`,text:n[s++]});return o}function Ou({lines:e,whole:t=!1,focus:n}){let r=(0,j.useRef)(null);if((0,j.useEffect)(()=>{r.current?.scrollIntoView({block:`center`})},[]),!e)return(0,L.jsx)(as,{children:`Too large to compare line by line.`});let i=n?e.findIndex(e=>e.kind!==`-`&&n(e.text)):-1,a=new Set;e.forEach((n,r)=>{if(t||n.kind!==` `||r===i)for(let t=Math.max(0,r-Eu);t<=Math.min(e.length-1,r+Eu);t++)a.add(t)});let o=[],s=!1;return e.forEach((e,n)=>{if(!a.has(n)){s=!0;return}s&&o.length>0&&o.push((0,L.jsx)(`div`,{className:`text-sky-400`,children:`⋯`},`gap${n}`)),s=!1;let c=e.kind===`+`?Os:e.kind===`-`?ks:``;o.push((0,L.jsxs)(`div`,{ref:n===i?r:void 0,className:n===i?`${c} outline-1 outline-amber-400`:c,children:[t?``:`${e.kind} `,U(e.text)||` `]},n))}),(0,L.jsx)(`pre`,{className:`log whitespace-pre-wrap`,children:o})}var ku=[`info`,`graph`,`files`];function Au(){let e=Sr().hash??``,t=vr(),n=ns(),[r,i]=Vi(),a=r.get(`tab`),o=ku.includes(a)?a:`info`,s=e=>{let t=new URLSearchParams(r);e===`info`?t.delete(`tab`):t.set(`tab`,e),i(t,{replace:!0})},[c,l]=(0,j.useState)(null),u=B(`/proposals/${zo(e)}`),d=u.data?.state===`waiting`,f=B(`/proposals/${zo(e)}/files`,{enabled:d,refresh:!1}),p=(0,j.useMemo)(()=>u.data&&Tc(u.data.plan),[u.data]),m=gu(e,u.data?.annotations?.repo,u.data?.annotations?.path??u.data?.entry),h=m.base,g=B(`/definitions/${zo(h??``)}`,{enabled:!!h,refresh:!1}),_=B(`/definitions/${zo(h??``)}/files`,{enabled:!!h&&d,refresh:!1}),v=(0,j.useMemo)(()=>p&&g.data?.plan?xu(Tc(g.data.plan),p):void 0,[p,g.data]),y=r.has(`change`)?cc(r,`change`):[`changed`],b=p&&v&&y.length>0?Object.fromEntries(Object.entries(p).filter(([e])=>y.includes(v.status[e]===`unchanged`?`unchanged`:`changed`))):p,x=e=>{let t=p?wc(e,p[e]):void 0;if(!t||f.data?.files[t]===void 0){l(e);return}let n=new URLSearchParams(r);n.set(`tab`,`files`),n.set(`file`,t),n.set(`at`,e),i(n)};return(0,L.jsx)(Ts,{query:u,missing:(0,L.jsx)(as,{children:`There is no such version you may see.`}),children:e=>{let a=[qo(e.tasks.length,`task`),...e.services.length>0?[qo(e.services.length,`service`)]:[]].join(`, `),u=f.data?Object.keys(f.data.files).length:void 0;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{note:`proposed`,children:e.entry}),(0,L.jsxs)(is,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1 text-sm`,children:[(0,L.jsx)(ms,{state:e.state}),e.reason?(0,L.jsx)(W,{children:e.reason}):null,d?(0,L.jsxs)(K,{children:[e.canDecide?`Waits for your approval`:`Waits for somebody who may publish`,e.expiresAt?(0,L.jsxs)(L.Fragment,{children:[`, until `,(0,L.jsx)(gs,{iso:e.expiresAt,now:n})]}):`, with no time limit`]}):null]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:ml-auto`,children:[d||m.choices.length>0?(0,L.jsx)(Ts,{query:m.list,children:()=>(0,L.jsx)(_u,{choices:m.choices,base:h,onChange:m.setBase})}):null,e.canDecide?(0,L.jsx)(Ls,{path:`/v1/proposals/${zo(e.hash)}`,yes:`Approve`,why:!1,onDone:()=>t(`/build-files`)}):null]})]}),(0,L.jsx)(Ws,{label:`What the proposed version shows`,tabs:[{key:`info`,name:`Info`},{key:`graph`,name:`Graph`,note:Object.keys(e.plan).length},{key:`files`,name:`Files`,note:u}],current:o,onChange:s}),o===`info`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(is,{className:`mb-6`,children:(0,L.jsx)(os,{items:Pu(e,n)})}),(0,L.jsxs)(rs,{title:`Tasks and services`,note:`${a}, a click on one opens where it is declared`,children:[v?(0,L.jsx)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:(0,L.jsx)(ic,{name:`Compared`,options:[`changed`,`unchanged`].map(e=>({value:e,count:Object.values(v.status).filter(t=>(t===`unchanged`?`unchanged`:`changed`)===e).length})),chosen:y,onChange:e=>{let t=lc(r,`change`,e);e.length===0&&t.set(`change`,``),i(t,{replace:!0})}})}):null,b&&Object.keys(b).length>0?(0,L.jsx)(Xc,{plan:b,marks:v?Nu(v.status):void 0,onSelect:x}):(0,L.jsx)(as,{children:`Every task and service is the same as in the version it is compared with.`}),v&&v.removed.length>0?(0,L.jsxs)(`p`,{className:`mt-3 text-sm text-red-700 dark:text-red-400`,children:[`Removed:`,` `,v.removed.map(e=>(0,L.jsx)(G,{className:`mr-2`,children:e},e))]}):null]})]}):null,o===`graph`&&p?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{className:`mb-2 text-sm text-stone-500 dark:text-stone-400`,children:[a,`, a click on one opens it.`]}),(0,L.jsx)(Mc,{plan:p,marks:v?Mu(v.status):void 0}),(0,L.jsx)(Ec,{plan:p,marks:v?Mu(v.status):void 0,selected:c,onSelect:l})]}):null,o===`files`?d?(0,L.jsx)(Ts,{query:f,children:e=>h?(0,L.jsx)(Ts,{query:_,missing:(0,L.jsx)(Su,{before:void 0,after:e.files}),children:t=>(0,L.jsx)(Su,{before:t.files,after:e.files})}):(0,L.jsx)(Su,{before:void 0,after:e.files})}):(0,L.jsx)(as,{children:`The files are kept only while the version waits.`}):null,c&&p?(0,L.jsx)(Nc,{name:c,plan:p,onSelect:l}):null]})}})}var ju={added:`border-emerald-500 text-emerald-700 dark:text-emerald-400`,changed:`border-amber-500 text-amber-700 dark:text-amber-400`,unchanged:``};function Mu(e){return Object.fromEntries(Object.entries(e).flatMap(([e,t])=>t===`unchanged`?[]:[[e,t]]))}function Nu(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==`unchanged`).map(([e,t])=>[e,(0,L.jsx)(`span`,{className:`rounded-full border px-1.5 text-xs ${ju[t]}`,children:t})]))}function Pu(e,t){let n=e.annotations?.repo,r=[[`Hash`,(0,L.jsx)(G,{className:`break-all`,children:e.hash})],[`Proposed by`,(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(G,{children:e.proposedBy.sub}),` `,(0,L.jsx)(gs,{iso:e.createdAt,now:t})]})]];e.decidedBy&&r.push([e.state===`approved`?`Approved by`:`Decided by`,(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(G,{children:e.decidedBy.sub}),e.decidedAt?(0,L.jsxs)(L.Fragment,{children:[` `,(0,L.jsx)(gs,{iso:e.decidedAt,now:t})]}):null]})]),n&&r.push([`Repository`,(0,L.jsx)(Cs,{repo:n,gitRef:e.annotations?.branch,commit:e.annotations?.commit})]);let i=Object.entries(e.annotations??{}).filter(([e])=>![`repo`,`branch`,`commit`].includes(e));return i.length>0&&r.push([`Annotations`,(0,L.jsx)(`span`,{className:`flex flex-wrap gap-2`,children:i.map(([e,t])=>(0,L.jsx)(G,{children:`${e}=${String(t)}`},e))})]),e.accounts.length>0&&r.push([`Accounts`,(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(W,{children:e.accounts.join(`, `)}),e.missing.length>0?(0,L.jsxs)(`span`,{className:`text-stone-500 dark:text-stone-400`,children:[` (who publishes uses `,e.missing.join(`, `),`)`]}):null]})]),r}function Fu(e){return`/sandboxes/${encodeURIComponent(e)}`}function Iu(e){let t=new Map;for(let n of[...e].sort((e,t)=>Date.parse(t.lastUsedAt)-Date.parse(e.lastUsedAt)))t.set(n.repo,[...t.get(n.repo)??[],n]);return[...t].sort(([e],[t])=>e.localeCompare(t))}function Lu({sandbox:e}){let t=V(e.repo),n=e.pushed?.[e.ref]===e.commit,r=Object.entries(e.pushed??{}).filter(([t,n])=>t!==e.ref||n!==e.commit);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Ss,{href:t?.ref?.(e.ref),children:(0,L.jsx)(G,{className:`break-normal`,children:e.ref})}),(0,L.jsxs)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:[`at`,` `,(0,L.jsx)(Ss,{href:t?.commit?.(e.commit),children:(0,L.jsx)(G,{className:`break-normal`,children:e.commit.slice(0,12)})}),n?`, pushed`:null]}),r.length>0?(0,L.jsxs)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:[`pushed`,` `,r.map(([n,r],i)=>(0,L.jsxs)(j.Fragment,{children:[i>0?`, `:``,n===e.ref?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Ss,{href:t?.ref?.(n),children:(0,L.jsx)(G,{children:n})}),` `]}),(0,L.jsx)(K,{children:`at`}),` `,(0,L.jsx)(Ss,{href:t?.commit?.(r),children:(0,L.jsx)(G,{children:r.slice(0,12)})})]},n))]}):null]})}function Ru({sandbox:e,onDone:t}){let n=Ro(()=>Fo(`/v1/sandboxes/${encodeURIComponent(e.id)}`)),r=e.run?`Delete ${e.id}? The run ${e.run} that works on it stops, and what was not pushed is gone.`:`Delete ${e.id}? What was not pushed is gone.`;return(0,L.jsxs)(`span`,{className:`inline-flex flex-col items-end gap-1`,children:[(0,L.jsx)(`button`,{type:`button`,title:`Delete`,"aria-label":`Delete ${e.id}`,disabled:n.isPending,onClick:()=>{window.confirm(r)&&n.mutate(void 0,{onSuccess:()=>t?.()})},className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-red-300 text-red-700 hover:bg-red-50 disabled:opacity-50 dark:border-red-900 dark:text-red-400 dark:hover:bg-red-950`,children:(0,L.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`h-4 w-4 fill-none stroke-current`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,L.jsx)(`path`,{d:`M2.5 4.5h11M6.5 4.5V3h3v1.5M4 4.5l.75 8.5h6.5L12 4.5M6.75 7v4M9.25 7v4`})})}),n.error?(0,L.jsx)(Es,{error:n.error}):null]})}var zu=[[`owner`,`Owner`],[`repo`,`Repository`],[`ref`,`Branch`]];function Bu(){let[e,t]=Vi(),n=Lo().data,r=n?.observe??!1,i=zu.filter(([e])=>r||e!==`owner`),a=Object.fromEntries(i.map(([t])=>[t,cc(e,t)])),o=nc(new URLSearchParams(r?`scope=all`:``),a),s=Qs(`/sandboxes?${o}`),c=$s(s,e=>e.sandboxes,e=>e.id),l=ns(),u=i.some(([e])=>a[e].length>0),d=e=>e.value===n?.sub?`you`:c.find(t=>t.owner?.sub===e.value)?.owner?.name,f=r?7:6;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{children:`Sandboxes`}),u||c.length>0?(0,L.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:i.map(([n,r])=>(0,L.jsx)(ic,{name:r,values:`/sandboxes?${o}&values=${n}`,label:n===`owner`?d:void 0,chosen:a[n],onChange:r=>t(lc(e,n,r),{replace:!0})},n))}):null,(0,L.jsx)(Ts,{query:s,missing:(0,L.jsx)(as,{children:`This server keeps no sandboxes.`}),children:()=>(0,L.jsxs)(L.Fragment,{children:[c.length===0?(0,L.jsx)(as,{children:u?`No sandbox is like that.`:r?`There is no sandbox on this server.`:`You have no sandbox on this server.`}):(0,L.jsx)(Hs,{head:[`Sandbox`,`Branch`,...r?[`Owner`]:[],`Size`,`Last used`,`Created`,``],right:[!1,!1,...r?[!1]:[],!0,!0,!0,!0],children:Iu(c).map(([e,t])=>(0,L.jsxs)(j.Fragment,{children:[(0,L.jsx)(`tr`,{className:`bg-stone-50 dark:bg-stone-950/40`,children:(0,L.jsx)(`th`,{colSpan:f,scope:`colgroup`,className:`px-3 py-1.5 text-left text-xs font-medium text-stone-600 dark:text-stone-300`,children:(0,L.jsx)(Ss,{href:V(e)?.repo,children:(0,L.jsx)(W,{children:e})})})}),t.map(e=>(0,L.jsxs)(`tr`,{children:[(0,L.jsxs)(J,{className:`whitespace-nowrap`,children:[(0,L.jsx)(Li,{className:`link font-mono text-[0.85em]`,to:Fu(e.id),children:e.id}),(0,L.jsx)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:e.run?(0,L.jsxs)(L.Fragment,{children:[`busy with `,(0,L.jsx)(vs,{id:e.run})]}):`free`})]}),(0,L.jsx)(J,{className:`whitespace-nowrap`,children:(0,L.jsx)(Lu,{sandbox:e})}),r?(0,L.jsx)(J,{className:`whitespace-nowrap`,children:e.owner?(0,L.jsx)(ys,{who:e.owner}):(0,L.jsx)(K,{children:`you`})}):null,(0,L.jsx)(J,{num:!0,children:Jo(e.bytes)}),(0,L.jsx)(J,{num:!0,children:(0,L.jsx)(gs,{iso:e.lastUsedAt,now:l})}),(0,L.jsx)(J,{num:!0,children:(0,L.jsx)(gs,{iso:e.createdAt,now:l})}),(0,L.jsx)(J,{className:`text-right`,children:e.owner?null:(0,L.jsx)(Ru,{sandbox:e})})]},e.id))]},e))}),(0,L.jsx)(ec,{query:s})]})})]})}var Vu={added:`text-emerald-700 dark:text-emerald-400`,deleted:`text-red-700 dark:text-red-400`};function Hu(){let e=Sr().id??``,t=vr(),[n,r]=Vi(),i=n.get(`tab`)===`runs`?`runs`:`changes`,a=e=>{let t=new URLSearchParams(n);e===`changes`?t.delete(`tab`):t.set(`tab`,e),r(t,{replace:!0})},o=ns(),s=Lo().data?.observe??!1,c=B(`/sandboxes/${encodeURIComponent(e)}`),l=c.data!==void 0&&!c.data.busy,u=B(`/sandboxes/${encodeURIComponent(e)}/changes`,{enabled:l}),d=u.data?.files??[],f=d.find(e=>e.path===n.get(`file`))??d[0],p=new URLSearchParams({format:`diff`});for(let e of f?[f.path,...f.from?[f.from]:[]]:[])p.append(`path`,e);let m=Mo(`/sandboxes/${encodeURIComponent(e)}/changes?${p}`,{enabled:l&&f!==void 0}),h=B(`/runs?${new URLSearchParams({scope:s?`all`:`mine`,sandbox:e})}`);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{children:e}),(0,L.jsx)(Ts,{query:c,missing:(0,L.jsx)(as,{children:s?`There is no such sandbox.`:`There is no such sandbox of yours.`}),children:e=>{let s=[[`Repository`,(0,L.jsx)(Ss,{href:V(e.repo)?.repo,children:(0,L.jsx)(W,{children:e.repo})})],[`Branch`,(0,L.jsx)(Lu,{sandbox:e})],...e.owner?[[`Owner`,(0,L.jsx)(ys,{who:e.owner})]]:[],[`Size`,Jo(e.bytes)],[`Created`,(0,L.jsx)(gs,{iso:e.createdAt,now:o})],[`Last used`,(0,L.jsx)(gs,{iso:e.lastUsedAt,now:o})],[`Run`,e.run?(0,L.jsx)(vs,{id:e.run}):(0,L.jsx)(K,{children:`none works on it`})]];return(0,L.jsxs)(L.Fragment,{children:[e.owner?(0,L.jsxs)(`p`,{className:`mb-4 rounded-lg border border-sky-200 bg-sky-50 px-4 py-2 text-sm text-sky-900 dark:border-sky-900 dark:bg-sky-950 dark:text-sky-200`,children:[`A sandbox of `,(0,L.jsx)(ys,{who:e.owner}),`. You see it because you observe this server: you can read it, but not change or delete it.`]}):null,(0,L.jsxs)(is,{className:`mb-6 flex items-start gap-4`,children:[(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,L.jsx)(os,{items:s})}),e.owner?null:(0,L.jsx)(Ru,{sandbox:e,onDone:()=>t(`/sandboxes`)})]}),(0,L.jsx)(Ws,{label:`What the sandbox shows`,tabs:[{key:`changes`,name:`Changes`,note:u.data?u.data.files.length:void 0},{key:`runs`,name:`Runs`,note:h.data?h.data.runs.length:void 0}],current:i,onChange:a}),i===`runs`?(0,L.jsx)(L.Fragment,{children:(0,L.jsx)(Ts,{query:h,children:({runs:e})=>e.length===0?(0,L.jsx)(as,{children:`No run worked on it.`}):(0,L.jsx)(Hs,{head:[`Run`,`Tasks`,`Created`],right:[!1,!1,!0],children:e.map(e=>(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(J,{className:`whitespace-nowrap`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(fs,{state:e.state}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(vs,{id:e.id}),(0,L.jsx)(`div`,{className:`text-xs text-stone-500 dark:text-stone-400`,children:e.state})]})]})}),(0,L.jsx)(J,{children:(0,L.jsx)(xs,{run:e})}),(0,L.jsx)(J,{num:!0,children:(0,L.jsx)(gs,{iso:e.createdAt,now:o})})]},e.id))})})}):(0,L.jsx)(L.Fragment,{children:e.busy?(0,L.jsx)(as,{children:`A run works on it: the changes show once it is over.`}):(0,L.jsx)(Ts,{query:u,children:({files:t})=>t.length===0||!f?(0,L.jsxs)(as,{children:[`Nothing changed since `,e.commit.slice(0,12),`.`]}):(0,L.jsxs)(pc,{tree:(0,L.jsx)(fc,{items:t,open:f.path,onOpen:e=>{let t=new URLSearchParams(n);t.set(`file`,e),r(t,{replace:!0})},className:e=>Vu[e.status]??``,extra:e=>(0,L.jsxs)(L.Fragment,{children:[e.additions===null?null:(0,L.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:[`+`,e.additions]}),` `,e.deletions===null?null:(0,L.jsxs)(`span`,{className:`text-red-700 dark:text-red-400`,children:[`−`,e.deletions]})]})}),children:[(0,L.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-baseline gap-2 text-sm`,children:[(0,L.jsx)(G,{children:f.path}),f.from?(0,L.jsxs)(K,{children:[`from `,(0,L.jsx)(G,{children:f.from})]}):null,(0,L.jsx)(`span`,{className:Vu[f.status]??``,children:f.status})]}),(0,L.jsx)(Ts,{query:m,children:e=>e?(0,L.jsx)(Wu,{text:Uu(e,f.path)}):(0,L.jsx)(as,{children:`No lines to show: its mode or kind changed.`})})]})})})]})}})]})}function Uu(e,t){let n=e.split(/^(?=diff --git )/m).filter(e=>e.split(`
|
|
22
22
|
`,1)[0].endsWith(` b/${t}`));return n.length>0?n.join(``):e}function Wu({text:e}){return(0,L.jsx)(`pre`,{className:`log whitespace-pre-wrap`,children:e.split(`
|
|
23
23
|
`).map((e,t)=>(0,L.jsx)(`div`,{className:e.startsWith(`+`)&&!e.startsWith(`+++`)?Os:e.startsWith(`-`)&&!e.startsWith(`---`)?ks:e.startsWith(`@@`)?`text-sky-400`:``,children:U(e)||` `},t))})}var Gu=[[`/`,`Overview`],[`/services`,`Services`],[`/tasks`,`Tasks`],[`/runs`,`Runs`],[`/build-files`,`Build files`],[`/sandboxes`,`Sandboxes`]];function Ku(){let e=B(`/approvals`),t=B(`/proposals`);return{"/runs":e.data?.approvals.length??0,"/build-files":t.data?.proposals.filter(e=>e.canDecide).length??0}}function qu(){return(0,L.jsx)(gi,{to:Zc(Sr().hash??``),replace:!0})}function Ju(){let e=Lo(),t=Ku();return(0,L.jsxs)(`div`,{className:`min-h-screen`,children:[(0,L.jsx)(`header`,{className:`border-b border-stone-200 bg-white dark:border-stone-800 dark:bg-stone-900`,children:(0,L.jsxs)(`div`,{className:`mx-auto flex max-w-6xl flex-wrap items-center gap-x-6 gap-y-2 px-4 py-3`,children:[(0,L.jsxs)(`strong`,{className:`flex items-center gap-2 font-semibold`,children:[(0,L.jsx)(`img`,{src:`/logo.png`,alt:``,className:`h-6 w-6`}),`hammerkit`]}),(0,L.jsx)(`nav`,{className:`order-last flex w-full flex-wrap gap-x-4 gap-y-1 text-sm md:order-none md:w-auto md:flex-1`,children:Gu.map(([e,n])=>(0,L.jsxs)(Ri,{to:e,end:e===`/`,className:({isActive:e})=>`border-b-2 py-1 ${e?`border-emerald-600 font-medium text-stone-900 dark:text-white`:`border-transparent text-stone-600 hover:text-stone-900 dark:text-stone-400 dark:hover:text-white`}`,children:[n,t[e]?(0,L.jsx)(`span`,{className:`ml-1 rounded-full bg-amber-500 px-1.5 text-xs font-medium text-white`,title:`waiting for you to decide`,children:t[e]}):null]},e))}),(0,L.jsxs)(`span`,{className:`ml-auto flex flex-col items-end text-sm leading-tight text-stone-500 dark:text-stone-400`,children:[e.data?(0,L.jsx)(ys,{who:e.data}):null,(0,L.jsx)(`a`,{className:`link text-xs`,href:`/.hammerkit/logout`,children:`Sign out`})]})]})}),(0,L.jsx)(`main`,{className:`mx-auto max-w-6xl px-4 py-6`,children:e.isError?(0,L.jsx)(Es,{error:e.error}):e.data?(0,L.jsx)(_i,{}):null})]})}function Yu(){return(0,L.jsx)(`p`,{className:`text-sm text-stone-500`,children:`There is no such page.`})}var X=Pi([{element:(0,L.jsx)(Ju,{}),children:[{path:`/`,element:(0,L.jsx)(Ys,{})},{path:`/services`,element:(0,L.jsx)(dl,{})},{path:`/runs`,element:(0,L.jsx)(Ll,{})},{path:`/runs/:id`,element:(0,L.jsx)(zl,{})},{path:`/runs/:id/log`,element:(0,L.jsx)(au,{})},{path:`/tasks`,element:(0,L.jsx)(pu,{})},{path:`/sandboxes`,element:(0,L.jsx)(Bu,{})},{path:`/sandboxes/:id`,element:(0,L.jsx)(Hu,{})},{path:`/build-files`,element:(0,L.jsx)(rl,{})},{path:`/build-files/proposed/:hash`,element:(0,L.jsx)(Au,{})},{path:`/build-files/:hash`,element:(0,L.jsx)(Gc,{})},{path:`/approvals`,element:(0,L.jsx)(gi,{to:`/runs`,replace:!0})},{path:`/approvals/versions/:hash`,element:(0,L.jsx)(qu,{})},{path:`/capacity`,element:(0,L.jsx)(gi,{to:`/`,replace:!0})},{path:`*`,element:(0,L.jsx)(Yu,{})}]}]),Xu=new lo({defaultOptions:{queries:{refetchOnWindowFocus:!0,staleTime:2e3}}});(0,Eo.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(j.StrictMode,{children:(0,L.jsx)($i,{client:Xu,children:(0,L.jsx)(Ji,{router:X})})}));export{m as a,c,Xi as i,fs as n,u as o,U as r,o as s,Cc as t};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta name="robots" content="noindex" />
|
|
7
7
|
<link rel="icon" href="/logo.png" type="image/png" />
|
|
8
8
|
<title>hammerkit</title>
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-DE3NTbjw.js"></script>
|
|
10
10
|
<link rel="stylesheet" crossorigin href="/assets/index-DP3_hKOe.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withDeadline = exports.getTaskTimeout = void 0;
|
|
4
4
|
const abort_event_1 = require("../utils/abort-event");
|
|
5
|
+
const long_timer_1 = require("../utils/long-timer");
|
|
5
6
|
// How long a task may run: its own `timeout`, else the run's default (`--timeout`), and
|
|
6
7
|
// never longer than the run's cap (`--max-timeout`), which also covers tasks with a
|
|
7
8
|
// longer timeout of their own. A caller can shorten a task this way, never extend it.
|
|
@@ -13,8 +14,6 @@ function getTaskTimeout(own, run) {
|
|
|
13
14
|
return timeout === null ? run.maxTimeout : Math.min(timeout, run.maxTimeout);
|
|
14
15
|
}
|
|
15
16
|
exports.getTaskTimeout = getTaskTimeout;
|
|
16
|
-
// the longest delay of setTimeout: Node fires a longer one after 1 ms
|
|
17
|
-
const MAX_TIMER_MS = 2 ** 31 - 1;
|
|
18
17
|
// An abort signal that follows `parent` and additionally fires after `timeout`
|
|
19
18
|
// ms, so a task deadline reuses the runtimes' existing abort/cleanup path. A
|
|
20
19
|
// timeout beyond what a timer can wait (about 24.8 days) sets no deadline.
|
|
@@ -24,7 +23,7 @@ const MAX_TIMER_MS = 2 ** 31 - 1;
|
|
|
24
23
|
function withDeadline(parent, timeout) {
|
|
25
24
|
const controller = new AbortController();
|
|
26
25
|
const parentListener = (0, abort_event_1.listenOnAbort)(parent, () => controller.abort());
|
|
27
|
-
const limit = timeout !== null && timeout <= MAX_TIMER_MS ? timeout : null;
|
|
26
|
+
const limit = timeout !== null && timeout <= long_timer_1.MAX_TIMER_MS ? timeout : null;
|
|
28
27
|
// what is left of the time to run, and of the time to wait in pauses
|
|
29
28
|
let left = limit ?? 0;
|
|
30
29
|
let pauseLeft = limit ?? 0;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dockerTask = exports.getCapabilityHostConfig = exports.buildCreateOptions = void 0;
|
|
3
|
+
exports.exportGenerates = exports.dockerTask = exports.getCapabilityHostConfig = exports.buildCreateOptions = void 0;
|
|
4
4
|
const work_item_executions_1 = require("../planner/work-item-executions");
|
|
5
5
|
const run_labels_1 = require("../docker/run-labels");
|
|
6
6
|
const execute_docker_1 = require("./execute-docker");
|
|
@@ -197,15 +197,32 @@ async function exportGenerates(environment, container, generates) {
|
|
|
197
197
|
});
|
|
198
198
|
await environment.file.createDirectory(generate.path);
|
|
199
199
|
await new Promise((resolve, reject) => {
|
|
200
|
+
// tar reports an entry it cannot write as a warning and goes on, which would leave the
|
|
201
|
+
// output short without a failure: a warning fails the export. Its info (such as
|
|
202
|
+
// stripping the / of an absolute path) does not.
|
|
203
|
+
const warnings = [];
|
|
200
204
|
readable
|
|
201
205
|
.pipe((0, tar_1.extract)({
|
|
202
206
|
cwd: generate.path,
|
|
203
207
|
newer: true,
|
|
204
208
|
stripComponents: 1,
|
|
209
|
+
onwarn: (code, message) => {
|
|
210
|
+
if (code !== 'TAR_ENTRY_INFO') {
|
|
211
|
+
warnings.push(`${code} ${message}`);
|
|
212
|
+
}
|
|
213
|
+
},
|
|
205
214
|
}))
|
|
206
|
-
.on('close', () =>
|
|
215
|
+
.on('close', () => {
|
|
216
|
+
if (warnings.length > 0) {
|
|
217
|
+
reject(new Error(`export of ${generate.path} failed: ${warnings.join('; ')}`));
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
resolve();
|
|
221
|
+
}
|
|
222
|
+
})
|
|
207
223
|
.on('error', (err) => reject(err));
|
|
208
224
|
});
|
|
209
225
|
}
|
|
210
226
|
}
|
|
227
|
+
exports.exportGenerates = exportGenerates;
|
|
211
228
|
//# sourceMappingURL=docker-task.js.map
|