@devqubit/ui 0.1.11-beta.4 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/client.d.ts +5 -1
- package/dist/api/client.d.ts.map +1 -1
- package/dist/components/MetricChart/MetricChart.d.ts +6 -0
- package/dist/components/MetricChart/MetricChart.d.ts.map +1 -0
- package/dist/components/MetricChart/index.d.ts +3 -0
- package/dist/components/MetricChart/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/index.cjs +8 -8
- package/dist/index.js +1683 -1346
- package/dist/pages/RunDetailPage.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/api/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RunSummary, RunRecord, Project, Group, Capabilities, DiffReport, Artifact } from '../types';
|
|
1
|
+
import { RunSummary, RunRecord, Project, Group, Capabilities, DiffReport, Artifact, MetricSeries } from '../types';
|
|
2
2
|
export declare class ApiError extends Error {
|
|
3
3
|
status: number;
|
|
4
4
|
constructor(status: number, message: string);
|
|
@@ -89,6 +89,10 @@ export declare class ApiClient {
|
|
|
89
89
|
missing_objects: number;
|
|
90
90
|
}>;
|
|
91
91
|
getExportDownloadUrl(runId: string): string;
|
|
92
|
+
getMetricSeries(runId: string): Promise<{
|
|
93
|
+
run_id: string;
|
|
94
|
+
series: MetricSeries;
|
|
95
|
+
}>;
|
|
92
96
|
}
|
|
93
97
|
export declare const api: ApiClient;
|
|
94
98
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/api/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names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declare function MetricCharts({ series }: MetricChartsProps): import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
//# sourceMappingURL=MetricChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MetricChart.d.ts","sourceRoot":"","sources":["../../../src/components/MetricChart/MetricChart.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,aAAa,CAAC;AAmX7D,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,YAAY,CAAC;CACtB;AAED,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,EAAE,iBAAiB,kDA6CzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/MetricChart/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -15,4 +15,6 @@ export { GroupsTable } from './GroupsTable';
|
|
|
15
15
|
export type { GroupsTableProps } from './GroupsTable';
|
|
16
16
|
export { ExportRunButton } from './ExportRunButton';
|
|
17
17
|
export type { ExportRunButtonProps, ExportProgress } from './ExportRunButton';
|
|
18
|
+
export { MetricCharts } from './MetricChart';
|
|
19
|
+
export type { MetricChartsProps } from './MetricChart';
|
|
18
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC9C,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG7D,cAAc,MAAM,CAAC;AAGrB,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,SAAS,EAAE,W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 -136,6 +136,16 @@ export declare function useMutation<TArgs extends unknown[], TResult>(mutationFn
|
|
|
136
136
|
loading: boolean;
|
|
137
137
|
error: ApiError | null;
|
|
138
138
|
};
|
|
139
|
+
/**
|
|
140
|
+
* Fetch metric time-series for a run.
|
|
141
|
+
*
|
|
142
|
+
* Returns null when the run has no step-based metrics.
|
|
143
|
+
* Polls while the run is active so charts update in near-real-time.
|
|
144
|
+
* Does one final refetch when the run transitions to terminal state.
|
|
145
|
+
*/
|
|
146
|
+
export declare function useMetricSeries(runId: string, isRunning: boolean): AsyncState<import('../types').MetricSeries | null> & {
|
|
147
|
+
refetch: () => Promise<void>;
|
|
148
|
+
};
|
|
139
149
|
export type { AsyncState, AppContextValue, };
|
|
140
150
|
export { ThemeProvider, useTheme, useThemeOptional } from './useTheme';
|
|
141
151
|
export type { Theme, ThemeContextValue, ThemeProviderProps } from './useTheme';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,SAAS,EAAqB,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAExD,uDAAuD;AACvD,eAAO,MAAM,aAAa,OAAQ,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAQD,oCAAoC;AACpC,UAAU,UAAU,CAAC,CAAC;IACpB,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;CACxB;AAED,mCAAmC;A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AAC,OAAO,CAAC,CAAC;IAC7C,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;CACxB,CAoBA;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO;aAhPnC,MAAM,OAAO,CAAC,IAAI,CAAC;EA6QhD;AAED,YAAY,EACV,UAAU,EACV,eAAe,GAChB,CAAC;AAGF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACvE,YAAY,EAAE,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`+
|
|
3
|
-
`),
|
|
4
|
-
`),
|
|
5
|
-
`+
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react"),L=require("react-router-dom");var We={exports:{}},Pe={};var Dt;function Bs(){if(Dt)return Pe;Dt=1;var t=f,s=Symbol.for("react.element"),a=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,l=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function c(i,u,h){var m,g={},y=null,D=null;h!==void 0&&(y=""+h),u.key!==void 0&&(y=""+u.key),u.ref!==void 0&&(D=u.ref);for(m in u)n.call(u,m)&&!o.hasOwnProperty(m)&&(g[m]=u[m]);if(i&&i.defaultProps)for(m in u=i.defaultProps,u)g[m]===void 0&&(g[m]=u[m]);return{$$typeof:s,type:i,key:y,ref:D,props:g,_owner:l.current}}return Pe.Fragment=a,Pe.jsx=c,Pe.jsxs=c,Pe}var De={};var At;function Is(){return At||(At=1,process.env.NODE_ENV!=="production"&&(function(){var t=f,s=Symbol.for("react.element"),a=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),i=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),D=Symbol.for("react.offscreen"),v=Symbol.iterator,W="@@iterator";function E(r){if(r===null||typeof r!="object")return null;var x=v&&r[v]||r[W];return typeof x=="function"?x:null}var A=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function T(r){{for(var x=arguments.length,j=new Array(x>1?x-1:0),b=1;b<x;b++)j[b-1]=arguments[b];ce("error",r,j)}}function ce(r,x,j){{var b=A.ReactDebugCurrentFrame,k=b.getStackAddendum();k!==""&&(x+="%s",j=j.concat([k]));var P=j.map(function(S){return String(S)});P.unshift("Warning: "+x),Function.prototype.apply.call(console[r],console,P)}}var le=!1,te=!1,Q=!1,N=!1,V=!1,ue;ue=Symbol.for("react.module.reference");function K(r){return!!(typeof r=="string"||typeof r=="function"||r===n||r===o||V||r===l||r===h||r===m||N||r===D||le||te||Q||typeof r=="object"&&r!==null&&(r.$$typeof===y||r.$$typeof===g||r.$$typeof===c||r.$$typeof===i||r.$$typeof===u||r.$$typeof===ue||r.getModuleId!==void 0))}function se(r,x,j){var b=r.displayName;if(b)return b;var k=x.displayName||x.name||"";return k!==""?j+"("+k+")":j}function fe(r){return r.displayName||"Context"}function ne(r){if(r==null)return null;if(typeof r.tag=="number"&&T("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case n:return"Fragment";case a:return"Portal";case o:return"Profiler";case l:return"StrictMode";case h:return"Suspense";case m:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case i:var x=r;return fe(x)+".Consumer";case c:var j=r;return fe(j._context)+".Provider";case u:return se(r,r.render,"ForwardRef");case g:var b=r.displayName||null;return b!==null?b:ne(r.type)||"Memo";case y:{var k=r,P=k._payload,S=k._init;try{return ne(S(P))}catch{return null}}}return null}var re=Object.assign,oe=0,C,B,je,he,Oe,ye,Me;function jt(){}jt.__reactDisabledLog=!0;function hs(){{if(oe===0){C=console.log,B=console.info,je=console.warn,he=console.error,Oe=console.group,ye=console.groupCollapsed,Me=console.groupEnd;var r={configurable:!0,enumerable:!0,value:jt,writable:!0};Object.defineProperties(console,{info:r,log:r,warn:r,error:r,group:r,groupCollapsed:r,groupEnd:r})}oe++}}function xs(){{if(oe--,oe===0){var r={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:re({},r,{value:C}),info:re({},r,{value:B}),warn:re({},r,{value:je}),error:re({},r,{value:he}),group:re({},r,{value:Oe}),groupCollapsed:re({},r,{value:ye}),groupEnd:re({},r,{value:Me})})}oe<0&&T("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Ze=A.ReactCurrentDispatcher,et;function Be(r,x,j){{if(et===void 0)try{throw Error()}catch(k){var b=k.stack.trim().match(/\n( *(at )?)/);et=b&&b[1]||""}return`
|
|
2
|
+
`+et+r}}var tt=!1,Ie;{var ms=typeof WeakMap=="function"?WeakMap:Map;Ie=new ms}function pt(r,x){if(!r||tt)return"";{var j=Ie.get(r);if(j!==void 0)return j}var b;tt=!0;var k=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var P;P=Ze.current,Ze.current=null,hs();try{if(x){var S=function(){throw Error()};if(Object.defineProperty(S.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(S,[])}catch(Z){b=Z}Reflect.construct(r,[],S)}else{try{S.call()}catch(Z){b=Z}r.call(S.prototype)}}else{try{throw Error()}catch(Z){b=Z}r()}}catch(Z){if(Z&&b&&typeof Z.stack=="string"){for(var R=Z.stack.split(`
|
|
3
|
+
`),J=b.stack.split(`
|
|
4
|
+
`),O=R.length-1,M=J.length-1;O>=1&&M>=0&&R[O]!==J[M];)M--;for(;O>=1&&M>=0;O--,M--)if(R[O]!==J[M]){if(O!==1||M!==1)do if(O--,M--,M<0||R[O]!==J[M]){var ae=`
|
|
5
|
+
`+R[O].replace(" at new "," at ");return r.displayName&&ae.includes("<anonymous>")&&(ae=ae.replace("<anonymous>",r.displayName)),typeof r=="function"&&Ie.set(r,ae),ae}while(O>=1&&M>=0);break}}}finally{tt=!1,Ze.current=P,xs(),Error.prepareStackTrace=k}var we=r?r.displayName||r.name:"",Ne=we?Be(we):"";return typeof r=="function"&&Ie.set(r,Ne),Ne}function fs(r,x,j){return pt(r,!1)}function js(r){var x=r.prototype;return!!(x&&x.isReactComponent)}function qe(r,x,j){if(r==null)return"";if(typeof r=="function")return pt(r,js(r));if(typeof r=="string")return Be(r);switch(r){case h:return Be("Suspense");case m:return Be("SuspenseList")}if(typeof r=="object")switch(r.$$typeof){case u:return fs(r.render);case g:return qe(r.type,x,j);case y:{var b=r,k=b._payload,P=b._init;try{return qe(P(k),x,j)}catch{}}}return""}var Te=Object.prototype.hasOwnProperty,gt={},vt=A.ReactDebugCurrentFrame;function Ue(r){if(r){var x=r._owner,j=qe(r.type,r._source,x?x.type:null);vt.setExtraStackFrame(j)}else vt.setExtraStackFrame(null)}function ps(r,x,j,b,k){{var P=Function.call.bind(Te);for(var S in r)if(P(r,S)){var R=void 0;try{if(typeof r[S]!="function"){var J=Error((b||"React class")+": "+j+" type `"+S+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof r[S]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw J.name="Invariant Violation",J}R=r[S](x,S,b,j,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(O){R=O}R&&!(R instanceof Error)&&(Ue(k),T("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",b||"React class",j,S,typeof R),Ue(null)),R instanceof Error&&!(R.message in gt)&&(gt[R.message]=!0,Ue(k),T("Failed %s type: %s",j,R.message),Ue(null))}}}var gs=Array.isArray;function st(r){return gs(r)}function vs(r){{var x=typeof Symbol=="function"&&Symbol.toStringTag,j=x&&r[Symbol.toStringTag]||r.constructor.name||"Object";return j}}function bs(r){try{return bt(r),!1}catch{return!0}}function bt(r){return""+r}function yt(r){if(bs(r))return T("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",vs(r)),bt(r)}var Nt=A.ReactCurrentOwner,ys={key:!0,ref:!0,__self:!0,__source:!0},_t,wt;function Ns(r){if(Te.call(r,"ref")){var x=Object.getOwnPropertyDescriptor(r,"ref").get;if(x&&x.isReactWarning)return!1}return r.ref!==void 0}function _s(r){if(Te.call(r,"key")){var x=Object.getOwnPropertyDescriptor(r,"key").get;if(x&&x.isReactWarning)return!1}return r.key!==void 0}function ws(r,x){typeof r.ref=="string"&&Nt.current}function Rs(r,x){{var j=function(){_t||(_t=!0,T("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",x))};j.isReactWarning=!0,Object.defineProperty(r,"key",{get:j,configurable:!0})}}function Ss(r,x){{var j=function(){wt||(wt=!0,T("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",x))};j.isReactWarning=!0,Object.defineProperty(r,"ref",{get:j,configurable:!0})}}var Es=function(r,x,j,b,k,P,S){var R={$$typeof:s,type:r,key:x,ref:j,props:S,_owner:P};return R._store={},Object.defineProperty(R._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(R,"_self",{configurable:!1,enumerable:!1,writable:!1,value:b}),Object.defineProperty(R,"_source",{configurable:!1,enumerable:!1,writable:!1,value:k}),Object.freeze&&(Object.freeze(R.props),Object.freeze(R)),R};function ks(r,x,j,b,k){{var P,S={},R=null,J=null;j!==void 0&&(yt(j),R=""+j),_s(x)&&(yt(x.key),R=""+x.key),Ns(x)&&(J=x.ref,ws(x,k));for(P in x)Te.call(x,P)&&!ys.hasOwnProperty(P)&&(S[P]=x[P]);if(r&&r.defaultProps){var O=r.defaultProps;for(P in O)S[P]===void 0&&(S[P]=O[P])}if(R||J){var M=typeof r=="function"?r.displayName||r.name||"Unknown":r;R&&Rs(S,M),J&&Ss(S,M)}return Es(r,R,J,k,b,Nt.current,S)}}var rt=A.ReactCurrentOwner,Rt=A.ReactDebugCurrentFrame;function _e(r){if(r){var x=r._owner,j=qe(r.type,r._source,x?x.type:null);Rt.setExtraStackFrame(j)}else Rt.setExtraStackFrame(null)}var nt;nt=!1;function at(r){return typeof r=="object"&&r!==null&&r.$$typeof===s}function St(){{if(rt.current){var r=ne(rt.current.type);if(r)return`
|
|
6
6
|
|
|
7
|
-
Check the render method of \``+
|
|
7
|
+
Check the render method of \``+r+"`."}return""}}function Cs(r){return""}var Et={};function Ts(r){{var x=St();if(!x){var j=typeof r=="string"?r:r.displayName||r.name;j&&(x=`
|
|
8
8
|
|
|
9
|
-
Check the top-level render call using <`+
|
|
9
|
+
Check the top-level render call using <`+j+">.")}return x}}function kt(r,x){{if(!r._store||r._store.validated||r.key!=null)return;r._store.validated=!0;var j=Ts(x);if(Et[j])return;Et[j]=!0;var b="";r&&r._owner&&r._owner!==rt.current&&(b=" It was passed a child from "+ne(r._owner.type)+"."),_e(r),T('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',j,b),_e(null)}}function Ct(r,x){{if(typeof r!="object")return;if(st(r))for(var j=0;j<r.length;j++){var b=r[j];at(b)&&kt(b,x)}else if(at(r))r._store&&(r._store.validated=!0);else if(r){var k=E(r);if(typeof k=="function"&&k!==r.entries)for(var P=k.call(r),S;!(S=P.next()).done;)at(S.value)&&kt(S.value,x)}}}function Ps(r){{var x=r.type;if(x==null||typeof x=="string")return;var j;if(typeof x=="function")j=x.propTypes;else if(typeof x=="object"&&(x.$$typeof===u||x.$$typeof===g))j=x.propTypes;else return;if(j){var b=ne(x);ps(j,r.props,"prop",b,r)}else if(x.PropTypes!==void 0&&!nt){nt=!0;var k=ne(x);T("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",k||"Unknown")}typeof x.getDefaultProps=="function"&&!x.getDefaultProps.isReactClassApproved&&T("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ds(r){{for(var x=Object.keys(r.props),j=0;j<x.length;j++){var b=x[j];if(b!=="children"&&b!=="key"){_e(r),T("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",b),_e(null);break}}r.ref!==null&&(_e(r),T("Invalid attribute `ref` supplied to `React.Fragment`."),_e(null))}}var Tt={};function Pt(r,x,j,b,k,P){{var S=K(r);if(!S){var R="";(r===void 0||typeof r=="object"&&r!==null&&Object.keys(r).length===0)&&(R+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var J=Cs();J?R+=J:R+=St();var O;r===null?O="null":st(r)?O="array":r!==void 0&&r.$$typeof===s?(O="<"+(ne(r.type)||"Unknown")+" />",R=" Did you accidentally export a JSX literal instead of a component?"):O=typeof r,T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",O,R)}var M=ks(r,x,j,k,P);if(M==null)return M;if(S){var ae=x.children;if(ae!==void 0)if(b)if(st(ae)){for(var we=0;we<ae.length;we++)Ct(ae[we],r);Object.freeze&&Object.freeze(ae)}else T("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ct(ae,r)}if(Te.call(x,"key")){var Ne=ne(r),Z=Object.keys(x).filter(function(Ms){return Ms!=="key"}),it=Z.length>0?"{key: someKey, "+Z.join(": ..., ")+": ...}":"{key: someKey}";if(!Tt[Ne+it]){var Os=Z.length>0?"{"+Z.join(": ..., ")+": ...}":"{}";T(`A props object containing a "key" prop is being spread into JSX:
|
|
10
10
|
let props = %s;
|
|
11
11
|
<%s {...props} />
|
|
12
12
|
React keys must be passed directly to JSX without using spread:
|
|
13
13
|
let props = %s;
|
|
14
|
-
<%s key={someKey} {...props} />`,Ze,de,ks,de),Et[de+Ze]=!0}}return s===n?Es(F):Rs(F),F}}function Ss(s,l,f){return St(s,l,f,!0)}function Cs(s,l,f){return St(s,l,f,!1)}var Ts=Cs,Ps=Ss;we.Fragment=n,we.jsx=Ts,we.jsxs=Ps})()),we}var Pt;function Fs(){return Pt||(Pt=1,process.env.NODE_ENV==="production"?$e.exports=As():$e.exports=Ls()),$e.exports}var e=Fs();class je extends Error{constructor(r,a){super(a),this.status=r,this.name="ApiError"}}class Dt{baseUrl;headers;constructor(r={}){this.baseUrl=r.baseUrl??"",this.headers={"Content-Type":"application/json",...r.headers}}async request(r,a,n={}){let o=`${this.baseUrl}${a}`;if(n.params){const u=new URLSearchParams;Object.entries(n.params).forEach(([x,h])=>{h!=null&&h!==""&&u.set(x,String(h))});const i=u.toString();i&&(o+=`?${i}`)}const d=await fetch(o,{method:r,headers:{...this.headers,...n.headers},body:n.body?JSON.stringify(n.body):void 0,credentials:n.credentials,cache:"no-store"});if(!d.ok){const u=await d.json().catch(()=>({detail:"Unknown error"}));throw new je(d.status,u.detail||d.statusText)}if(!(d.status===204||d.headers.get("content-length")==="0"))return d.json()}async getCapabilities(){return this.request("GET","/api/v1/capabilities")}async listRuns(r){return this.request("GET","/api/runs",{params:r})}async getRun(r){return this.request("GET",`/api/runs/${r}`)}async deleteRun(r){await this.request("DELETE",`/api/runs/${r}`)}async setBaseline(r,a){return this.request("POST",`/api/projects/${r}/baseline/${a}`,{params:{redirect:"false"}})}async listProjects(r){return this.request("GET","/api/projects",{params:r})}async listGroups(r){return this.request("GET","/api/groups",{params:r})}async getGroup(r){return this.request("GET",`/api/groups/${r}`)}async getDiff(r,a){return this.request("GET","/api/diff",{params:{a:r,b:a}})}async getArtifact(r,a){return this.request("GET",`/api/runs/${r}/artifacts/${a}`)}getArtifactDownloadUrl(r,a){return`${this.baseUrl}/api/runs/${r}/artifacts/${a}/raw`}async createExport(r){return this.request("POST",`/api/runs/${r}/export`)}async getExportInfo(r){return this.request("GET",`/api/runs/${r}/export/info`)}getExportDownloadUrl(r){return`${this.baseUrl}/api/runs/${r}/export/download`}}const At=new Dt;function Q(t){return t?.slice(0,8)??""}function Ie(t){return t?.slice(0,12)??"N/A"}function Se(t){const r=new Date(t),n=Math.floor((new Date().getTime()-r.getTime())/1e3);if(n<60)return"just now";if(n<3600){const d=Math.floor(n/60);return`${d} minute${d!==1?"s":""} ago`}if(n<86400){const d=Math.floor(n/3600);return`${d} hour${d!==1?"s":""} ago`}if(n<2592e3){const d=Math.floor(n/86400);return`${d} day${d!==1?"s":""} ago`}if(n<31536e3){const d=Math.floor(n/2592e3);return`${d} month${d!==1?"s":""} ago`}const o=Math.floor(n/31536e3);return`${o} year${o!==1?"s":""} ago`}function Lt(t,r=6){return typeof t!="number"||isNaN(t)?String(t):Number(t.toPrecision(r)).toString()}function Ee(t){return t<1024?`${t} bytes`:t<1048576?`${(t/1024).toFixed(1)} KB`:`${(t/1048576).toFixed(1)} MB`}function Ft(t){return JSON.stringify(t,null,2)}function Ot(t,r=60){return t?t.length<=r?t:t.slice(0,r-3)+"...":""}function Os(t,r){const a=new URLSearchParams;Object.entries(r).forEach(([o,d])=>{d!=null&&d!==""&&a.set(o,String(d))});const n=a.toString();return n?`${t}?${n}`:t}function O(...t){return t.filter(Boolean).join(" ")}function tt(t,r){const a=new Date(t).getTime(),n=r?new Date(r).getTime():Date.now();return Math.max(0,Math.floor((n-a)/1e3))}function st(t){if(t<60)return`${t}s`;const r=Math.floor(t/86400),a=Math.floor(t%86400/3600),n=Math.floor(t%3600/60),o=t%60;return r>0?`${r}d ${a}h ${n}m`:a>0?`${a}h ${n}m ${o}s`:`${n}m ${o}s`}function Ce(t){return t==="FINISHED"||t==="FAILED"||t==="KILLED"}const $t=p.createContext(null);function $s({children:t}){const r={theme:"light",resolvedTheme:"light",setTheme:()=>{},toggleTheme:()=>{}};return e.jsx($t.Provider,{value:r,children:t})}function Bt(){const t=p.useContext($t);return t||{theme:"light",resolvedTheme:"light",setTheme:()=>{},toggleTheme:()=>{}}}function Bs(){return Bt()}const Be=1e3,Is={runsActive:Be,runsIdle:Be,runDetail:Be},It=p.createContext(null);function qt({children:t,api:r=At,initialWorkspace:a=null,pollingConfig:n}){const[o,d]=p.useState(null),[u,i]=p.useState(a),x={...Is,...n};return p.useEffect(()=>{r.getCapabilities().then(d).catch(console.error)},[r]),e.jsx(It.Provider,{value:{api:r,capabilities:o,currentWorkspace:u,setCurrentWorkspace:i,pollingConfig:x},children:t})}function V(){const t=p.useContext(It);if(!t)throw new Error("useApp must be used within AppProvider");return t}function ue(t,r=[]){const[a,n]=p.useState({data:null,loading:!0,error:null}),o=p.useRef(!0),d=p.useRef(t);d.current=t;const u=p.useCallback(async x=>{x||n(h=>({...h,loading:!0,error:null}));try{const h=await d.current();o.current&&n({data:h,loading:!1,error:null})}catch(h){if(o.current){const m=h instanceof je?h:new je(500,String(h));n(g=>({data:x?g.data:null,loading:!1,error:m}))}}},[]);p.useEffect(()=>(o.current=!0,u(!1),()=>{o.current=!1}),r);const i=p.useCallback(()=>u(!0),[u]);return{...a,refetch:i}}function rt(t,r,a){p.useEffect(()=>{if(!a)return;let n,o=!1;const d=()=>{if(o)return;const x=r*.1*(Math.random()*2-1);n=setTimeout(u,Math.max(500,r+x))},u=async()=>{if(!o&&document.visibilityState!=="hidden"){try{await t()}catch{}d()}};d();const i=()=>{o||document.visibilityState!=="visible"||(clearTimeout(n),Promise.resolve(t()).catch(()=>{}).finally(d))};return document.addEventListener("visibilitychange",i),()=>{o=!0,clearTimeout(n),document.removeEventListener("visibilitychange",i)}},[t,r,a])}function nt(t){const{api:r,currentWorkspace:a,pollingConfig:n}=V(),o=ue(()=>r.listRuns({...t,workspace:a?.id}),[r,a?.id,t?.project,t?.status,t?.q,t?.limit]),u=o.data?.runs.some(i=>!Ce(i.status))??!1?n.runsActive:n.runsIdle;return rt(o.refetch,u,!0),o}function at(t){const{api:r,pollingConfig:a}=V(),n=ue(async()=>{const{run:d}=await r.getRun(t);return d},[r,t]),o=n.data?!Ce(n.data.status):!1;return rt(n.refetch,a.runDetail,o),n}function Te(){const{api:t,currentWorkspace:r}=V();return ue(async()=>{const{projects:a}=await t.listProjects({workspace:r?.id});return a},[t,r?.id])}function Mt(t){const{api:r,currentWorkspace:a}=V();return ue(async()=>{const{groups:n}=await r.listGroups({...t,workspace:a?.id});return n},[r,a?.id,t?.project])}function Ut(t){const{api:r}=V();return ue(()=>r.getGroup(t),[r,t])}function Gt(t,r){const{api:a}=V();return ue(()=>a.getDiff(t,r),[a,t,r])}function Wt(t,r){const{api:a}=V();return ue(()=>a.getArtifact(t,r),[a,t,r])}function pe(t){const[r,a]=p.useState(!1),[n,o]=p.useState(null);return{mutate:p.useCallback(async(...u)=>{a(!0),o(null);try{return await t(...u)}catch(i){const x=i instanceof je?i:new je(500,String(i));throw o(x),x}finally{a(!1)}},[t]),loading:r,error:n}}const qs=[{href:"/runs",label:"Runs",matchPaths:["/runs"]},{href:"/projects",label:"Projects",matchPaths:["/projects"]},{href:"/groups",label:"Groups",matchPaths:["/groups"]},{href:"/diff",label:"Compare",matchPaths:["/diff"]},{href:"/search",label:"Search",matchPaths:["/search"]}],Vt=p.createContext(null);function Ms({config:t,children:r}){return e.jsx(Vt.Provider,{value:t,children:r})}function zt(){return p.useContext(Vt)}function W({children:t,config:r}){const a=k.useLocation(),o={...zt(),...r},d=o?.navLinks??qs,u=[...o?.prependNavLinks??[],...d,...o?.appendNavLinks??[]],i=o?.logo??{text:"devqubit",icon:"⚛"},x=h=>h.matchPaths?h.matchPaths.some(m=>a.pathname.startsWith(m)):a.pathname===h.href;return e.jsxs("div",{className:"dq-layout",children:[e.jsx("header",{className:"dq-header",children:e.jsxs("div",{className:"dq-header-inner",children:[e.jsxs("div",{className:"dq-header-left",children:[e.jsxs(k.Link,{to:"/",className:"dq-logo",children:[i.icon&&e.jsx("span",{className:"dq-logo-icon",children:i.icon}),i.text]}),e.jsx("nav",{className:"dq-nav",children:u.map(h=>e.jsx(k.Link,{to:h.href,className:O("dq-nav-link",x(h)&&"active"),children:h.label},h.href))})]}),e.jsx("div",{className:"dq-header-right",children:o?.headerRight})]})}),e.jsx("main",{className:"dq-main fade-in",children:t})]})}function ge({title:t,subtitle:r,actions:a}){return e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",children:t}),r&&e.jsx("p",{className:"text-sm text-muted mt-1",children:r})]}),a&&e.jsx("div",{className:"flex gap-2",children:a})]})}function H({variant:t="gray",className:r,children:a,...n}){return e.jsx("span",{className:O("badge",`badge-${t}`,r),...n,children:a})}const D=p.forwardRef(({variant:t="secondary",size:r="default",loading:a,className:n,children:o,disabled:d,...u},i)=>e.jsxs("button",{ref:i,className:O("btn",t==="ghost-danger"?"btn-ghost-danger":`btn-${t}`,r==="sm"&&"btn-sm",n),disabled:d||a,...u,children:[a&&e.jsx(I,{}),o]}));D.displayName="Button";function b({className:t,children:r,...a}){return e.jsx("div",{className:O("card",t),...a,children:r})}function U({className:t,children:r,...a}){return e.jsx("div",{className:O("card-header",t),...a,children:r})}function G({className:t,children:r,...a}){return e.jsx("h3",{className:O("card-title",t),...a,children:r})}function Us({variant:t="info",className:r,children:a,...n}){return e.jsx("div",{className:O("alert",`alert-${t}`,r),...n,children:a})}function I({className:t,...r}){return e.jsx("span",{className:O("spinner",t),...r})}function le({message:t,hint:r,className:a,...n}){return e.jsxs("div",{className:O("empty-state",a),...n,children:[e.jsx("p",{children:t}),r&&e.jsx("p",{className:"text-sm text-muted mt-2",children:r})]})}function qe({items:t,className:r,...a}){return e.jsx("dl",{className:O("kv-list",r),...a,children:t.map(({label:n,value:o})=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{children:n}),e.jsx("dd",{children:o})]},n))})}function Me({open:t,onClose:r,title:a,children:n,actions:o}){return t?e.jsx("div",{className:O("modal-backdrop",t&&"active"),onClick:d=>d.target===d.currentTarget&&r(),children:e.jsxs("div",{className:"modal",onClick:d=>d.stopPropagation(),children:[e.jsx("h3",{className:"modal-title",children:a}),e.jsx("div",{className:"modal-body",children:n}),o&&e.jsx("div",{className:"modal-actions",children:o})]})}):null}function ve({message:t,variant:r="info",visible:a,onClose:n}){if(!a)return null;const o={success:"✓",error:"✕",info:"i"}[r],d={success:"text-[#059669]",error:"text-[#DC4A4A]",info:"text-[#2563EB]"}[r];return e.jsxs("div",{className:"toast",onClick:n,children:[e.jsx("span",{className:O("mr-2 font-bold",d),children:o}),t]})}function Z({children:t,className:r}){return e.jsx("div",{className:O("form-group",r),children:t})}function ne({className:t,children:r,...a}){return e.jsx("label",{className:O("form-label",t),...a,children:r})}const Ue=p.forwardRef(({className:t,...r},a)=>e.jsx("input",{ref:a,className:O("form-input",t),...r}));Ue.displayName="Input";const ce=p.forwardRef(({className:t,children:r,...a},n)=>e.jsx("select",{ref:n,className:O("form-input",t),...a,children:r}));ce.displayName="Select";function it({children:t,className:r}){return e.jsx("div",{className:O("form-row",r),children:t})}function $({className:t,children:r,...a}){return e.jsx("table",{className:O("table",t),...a,children:r})}function se({className:t,children:r,...a}){return e.jsx("thead",{className:t,...a,children:r})}function B({className:t,children:r,...a}){return e.jsx("tbody",{className:t,...a,children:r})}function j({className:t,children:r,...a}){return e.jsx("tr",{className:t,...a,children:r})}function N({className:t,children:r,...a}){return e.jsx("th",{className:t,...a,children:r})}function c({className:t,children:r,...a}){return e.jsx("td",{className:t,...a,children:r})}function ct({status:t}){const r={FINISHED:"success",FAILED:"danger",KILLED:"gray",RUNNING:"warning",UNKNOWN:"gray"}[t];return e.jsx(H,{variant:r,children:t})}function Gs({createdAt:t,endedAt:r,status:a}){const n=!Ce(a),[o,d]=p.useState(Date.now());p.useEffect(()=>{if(!n)return;const h=setInterval(()=>d(Date.now()),1e3);return()=>clearInterval(h)},[n]);const i=tt(t,n?void 0:r),x=n?Math.max(0,Math.floor((o-new Date(t).getTime())/1e3)):i;return e.jsx("span",{className:n?"tabular-nums":void 0,children:st(x)})}function Ge({runs:t,onDelete:r,loading:a,emptyHint:n,baselineRunId:o}){const[d,u]=p.useState(null),i=()=>{d&&r&&(r(d.run_id),u(null))};return t.length?e.jsxs(e.Fragment,{children:[e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Run ID"}),e.jsx(N,{children:"Name"}),e.jsx(N,{children:"Project"}),e.jsx(N,{children:"Status"}),e.jsx(N,{children:"Duration"}),e.jsx(N,{children:"Created"}),e.jsx(N,{children:"Actions"})]})}),e.jsx(B,{children:t.map(x=>e.jsxs(j,{children:[e.jsxs(c,{children:[e.jsx(k.Link,{to:`/runs/${x.run_id}`,className:"font-mono",children:Q(x.run_id)}),x.run_id===o&&e.jsx(H,{variant:"info",className:"ml-2",children:"Baseline"})]}),e.jsx(c,{children:x.run_name||"—"}),e.jsx(c,{children:x.project}),e.jsx(c,{children:e.jsx(ct,{status:x.status})}),e.jsx(c,{className:"font-mono text-sm",children:e.jsx(Gs,{createdAt:x.created_at,endedAt:x.ended_at,status:x.status})}),e.jsx(c,{className:"text-muted",children:Se(x.created_at)}),e.jsx(c,{children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k.Link,{to:`/runs/${x.run_id}`,children:e.jsx(D,{variant:"secondary",size:"sm",children:"View"})}),r&&e.jsx(D,{variant:"ghost-danger",size:"sm",onClick:()=>u(x),disabled:a,children:"Delete"})]})})]},x.run_id))})]}),e.jsxs(Me,{open:!!d,onClose:()=>u(null),title:"Delete Run",actions:e.jsxs(e.Fragment,{children:[e.jsx(D,{variant:"secondary",onClick:()=>u(null),children:"Cancel"}),e.jsxs(D,{variant:"danger",onClick:i,disabled:a,children:[a&&e.jsx(I,{}),"Delete"]})]}),children:[e.jsx("p",{children:"Are you sure you want to delete this run?"}),d&&e.jsx("p",{className:"font-mono text-sm mt-2",children:Q(d.run_id)}),e.jsx("p",{className:"text-sm text-danger mt-2",children:"This action cannot be undone."})]})]}):e.jsx(le,{message:"No runs found",hint:n??"Try adjusting your filters"})}function Yt(){const[t,r]=k.useSearchParams(),{api:a}=V(),{data:n}=Te(),[o,d]=p.useState(null),[u,i]=p.useState({project:t.get("project")||"",status:t.get("status")||"",q:t.get("q")||"",limit:parseInt(t.get("limit")||"25",10)}),{data:x,loading:h,refetch:m}=nt(u),g=pe(w=>a.deleteRun(w));p.useEffect(()=>{if(o){const w=setTimeout(()=>d(null),3e3);return()=>clearTimeout(w)}},[o]);const _=p.useCallback((w,K)=>{i(q=>({...q,[w]:K}));const T=new URLSearchParams(t);K?T.set(w,String(K)):T.delete(w),r(T,{replace:!0})},[t,r]),z=p.useCallback(async w=>{try{await g.mutate(w),d({message:"Run deleted",variant:"success"}),m()}catch{d({message:"Failed to delete run",variant:"error"})}},[g,m]);return e.jsxs(W,{children:[e.jsx(ge,{title:"Runs"}),e.jsx(b,{className:"mb-4",children:e.jsxs(it,{children:[e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"project",children:"Project"}),e.jsxs(ce,{id:"project",value:u.project,onChange:w=>_("project",w.target.value),children:[e.jsx("option",{value:"",children:"All projects"}),n?.map(w=>e.jsx("option",{value:w.name,children:w.name},w.name))]})]}),e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"status",children:"Status"}),e.jsxs(ce,{id:"status",value:u.status,onChange:w=>_("status",w.target.value),children:[e.jsx("option",{value:"",children:"All"}),e.jsx("option",{value:"FINISHED",children:"Finished"}),e.jsx("option",{value:"FAILED",children:"Failed"}),e.jsx("option",{value:"RUNNING",children:"Running"})]})]}),e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"q",children:"Query"}),e.jsx(Ue,{id:"q",value:u.q,onChange:w=>_("q",w.target.value),placeholder:"metric.fidelity > 0.9"})]}),e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"limit",children:"Limit"}),e.jsxs(ce,{id:"limit",value:u.limit,onChange:w=>_("limit",parseInt(w.target.value,10)),children:[e.jsx("option",{value:"25",children:"25"}),e.jsx("option",{value:"50",children:"50"}),e.jsx("option",{value:"100",children:"100"})]})]}),e.jsxs(Z,{className:"flex items-end gap-2",children:[e.jsx(D,{variant:"primary",onClick:()=>m(),children:"Filter"}),h&&e.jsx(I,{})]})]})}),e.jsx(b,{children:h&&!x?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(I,{})}):e.jsx(Ge,{runs:x?.runs??[],onDelete:z,loading:g.loading,baselineRunId:u.project?n?.find(w=>w.name===u.project)?.baseline?.run_id:void 0})}),o&&e.jsx(ve,{message:o.message,variant:o.variant,visible:!!o,onClose:()=>d(null)})]})}function Ht({projects:t,currentWorkspace:r}){if(!t.length)return e.jsx(le,{message:"No projects yet",hint:"Projects are created automatically when you log runs"});const a=n=>{const o=new URLSearchParams({project:n});return r&&o.set("workspace",r.id),`/runs?${o}`};return e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Project"}),e.jsx(N,{children:"Runs"}),e.jsx(N,{children:"Baseline"}),e.jsx(N,{})]})}),e.jsx(B,{children:t.map(n=>e.jsxs(j,{children:[e.jsxs(c,{children:[e.jsx("span",{className:"font-medium",children:n.name}),n.description&&e.jsx("p",{className:"text-muted text-sm",children:Ot(n.description)})]}),e.jsx(c,{children:e.jsx(H,{variant:"gray",children:n.run_count??0})}),e.jsx(c,{children:n.baseline?e.jsxs(e.Fragment,{children:[e.jsx(k.Link,{to:`/runs/${n.baseline.run_id}`,className:"font-mono text-sm",children:Q(n.baseline.run_id)}),n.baseline.run_name&&e.jsx("p",{className:"text-muted text-sm",children:n.baseline.run_name})]}):e.jsx("span",{className:"text-muted",children:"—"})}),e.jsx(c,{className:"text-right",children:e.jsx(k.Link,{to:a(n.name),children:e.jsx(D,{variant:"secondary",size:"sm",children:"View Runs"})})})]},n.name))})]})}function Kt({groups:t}){return t.length?e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Group ID"}),e.jsx(N,{children:"Name"}),e.jsx(N,{children:"Project"}),e.jsx(N,{children:"Runs"}),e.jsx(N,{children:"Actions"})]})}),e.jsx(B,{children:t.map(r=>e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:Q(r.group_id)}),e.jsx(c,{children:r.group_name||"—"}),e.jsx(c,{children:r.project}),e.jsx(c,{children:e.jsx(H,{variant:"gray",children:r.run_count})}),e.jsx(c,{children:e.jsx(k.Link,{to:`/groups/${r.group_id}`,children:e.jsx(D,{variant:"secondary",size:"sm",children:"View Runs"})})})]},r.group_id))})]}):e.jsx(le,{message:"No groups found",hint:"Groups are created when runs have a group_id set"})}function Jt({runId:t,runName:r,variant:a="secondary",size:n="sm",className:o=""}){const{api:d}=V(),[u,i]=p.useState({status:"idle"}),[x,h]=p.useState(!1),[m,g]=p.useState(null),_=async()=>{i({status:"preparing",message:"Preparing bundle..."}),h(!0);try{const T=await d.createExport(t);i({status:"packing",message:"Creating bundle...",artifactCount:T.artifact_count,objectCount:T.object_count}),i(he=>({...he,status:"downloading",message:"Downloading bundle..."}));const q=d.getExportDownloadUrl(t),P=await fetch(q,{credentials:"same-origin"});if(!P.ok)throw new Error("Download failed");const re=await P.blob(),ae=r?`${r.replace(/[^a-zA-Z0-9_-]/g,"_")}_${t.slice(0,8)}.zip`:`run_${t.slice(0,8)}.zip`,J=URL.createObjectURL(re),ee=document.createElement("a");ee.href=J,ee.download=ae,document.body.appendChild(ee),ee.click(),document.body.removeChild(ee),URL.revokeObjectURL(J),i({status:"complete",message:"Export complete!",bundleSize:re.size,artifactCount:T.artifact_count,objectCount:T.object_count})}catch(T){const q=T instanceof Error?T.message:"Export failed";i({status:"error",message:q}),g({message:q,variant:"error"})}},z=()=>{u.status!=="preparing"&&u.status!=="packing"&&u.status!=="downloading"&&(h(!1),i({status:"idle"}))},w=T=>T<1024?`${T} B`:T<1024*1024?`${(T/1024).toFixed(1)} KB`:`${(T/(1024*1024)).toFixed(1)} MB`,K=["preparing","packing","downloading"].includes(u.status);return e.jsxs(e.Fragment,{children:[e.jsxs(D,{variant:a,size:n,onClick:_,disabled:K,className:o,children:[K&&e.jsx(I,{}),e.jsx(Ws,{}),"Export"]}),e.jsx(Me,{open:x,onClose:z,title:"Export Run",actions:u.status==="error"||u.status==="complete"?e.jsx(D,{variant:"secondary",onClick:z,children:"Close"}):void 0,children:e.jsxs("div",{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[u.status==="error"?e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--dq-danger-bg)] flex items-center justify-center",children:e.jsx(zs,{})}):u.status==="complete"?e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--dq-success-bg)] flex items-center justify-center",children:e.jsx(Vs,{})}):e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--dq-primary-bg)] flex items-center justify-center",children:e.jsx(I,{})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:u.message}),u.status==="error"&&e.jsx("p",{className:"text-sm text-[var(--dq-text-muted)]",children:"Please try again or contact support."})]})]}),(u.artifactCount!==void 0||u.objectCount!==void 0||u.bundleSize!==void 0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 mt-4",children:[u.artifactCount!==void 0&&e.jsxs(H,{variant:"gray",children:[u.artifactCount," artifacts"]}),u.objectCount!==void 0&&e.jsxs(H,{variant:"gray",children:[u.objectCount," objects"]}),u.bundleSize!==void 0&&e.jsx(H,{variant:"info",children:w(u.bundleSize)})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--dq-border-light)]",children:[e.jsxs("p",{className:"text-sm text-[var(--dq-text-muted)]",children:["Run ID: ",e.jsx("code",{className:"text-xs",children:t})]}),r&&e.jsxs("p",{className:"text-sm text-[var(--dq-text-muted)]",children:["Name: ",r]})]})]})}),m&&e.jsx(ve,{message:m.message,variant:m.variant,visible:!!m,onClose:()=>g(null)})]})}function Ws(){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function Vs(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--dq-success)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})}function zs(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--dq-danger)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}function Ys({createdAt:t,endedAt:r,status:a}){const n=!Ce(a),[o,d]=p.useState(Date.now());p.useEffect(()=>{if(!n)return;const i=setInterval(()=>d(Date.now()),1e3);return()=>clearInterval(i)},[n]);const u=n?Math.max(0,Math.floor((o-new Date(t).getTime())/1e3)):tt(t,r);return e.jsx("span",{className:n?"tabular-nums":void 0,children:st(u)})}function Xt(){const{runId:t}=k.useParams(),r=k.useNavigate(),{api:a}=V(),{data:n,loading:o,error:d,refetch:u}=at(t),{data:i,refetch:x}=Te(),[h,m]=p.useState(!1),[g,_]=p.useState(null),{mutate:z,loading:w}=pe(()=>a.setBaseline(n.project,n.run_id)),{mutate:K,loading:T}=pe(()=>a.deleteRun(t)),P=i?.find(R=>R.name===n?.project)?.baseline?.run_id===t;if(p.useEffect(()=>{if(g){const R=setTimeout(()=>_(null),3e3);return()=>clearTimeout(R)}},[g]),o)return e.jsx(W,{children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(I,{})})});if(d||!n)return e.jsx(W,{children:e.jsx(b,{children:e.jsx(le,{message:"Run not found",hint:d?.message||`Run ${t} does not exist`})})});const re=n.backend||{},ae=n.fingerprints||{},J=n.data?.params||{},ee=n.data?.metrics||{},he=n.data?.tags||{},xe=n.artifacts||[],be=n.errors||[],We=async()=>{try{await z(),await x(),u(),_({message:"Baseline updated",variant:"success"})}catch{_({message:"Failed to set baseline",variant:"error"})}},Ve=async()=>{try{await K(),m(!1),_({message:"Run deleted",variant:"success"}),setTimeout(()=>r("/runs"),1e3)}catch{_({message:"Failed to delete run",variant:"error"}),m(!1)}},Pe=async R=>{const A=xe[R];try{const ke=a.getArtifactDownloadUrl(n.run_id,R),Ne=await fetch(ke);if(!Ne.ok)throw new Error("Download failed");const De=await Ne.blob(),oe=document.createElement("a");oe.href=URL.createObjectURL(De),oe.download=A?.kind||`artifact-${R}`,oe.click(),URL.revokeObjectURL(oe.href),_({message:"Download complete",variant:"success"})}catch{_({message:"Download failed",variant:"error"})}},te=[{label:"Project",value:e.jsx(k.Link,{to:`/runs?project=${n.project}`,children:n.project})},{label:"Name",value:n.run_name||"—"},{label:"Adapter",value:n.adapter||"N/A"},{label:"Status",value:e.jsx(ct,{status:n.status})},{label:"Created",value:`${n.created_at} (${Se(n.created_at)})`},{label:"Duration",value:e.jsx(Ys,{createdAt:n.created_at,endedAt:n.ended_at,status:n.status})},...n.ended_at?[{label:"Ended",value:`${n.ended_at} (${Se(n.ended_at)})`}]:[],{label:"Backend",value:re.name||"N/A"},...n.group_id?[{label:"Group",value:e.jsx(k.Link,{to:`/groups/${n.group_id}`,children:n.group_name||Q(n.group_id)})}]:[]];return e.jsxs(W,{children:[P&&e.jsxs("div",{className:"mb-4 px-4 py-3 bg-[#EFF6FF] border border-[#2563EB]/20 rounded-md text-[#2563EB] text-sm font-medium",children:['This run is the current baseline for project "',n.project,'"']}),e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",children:n.run_name||"Unnamed Run"}),e.jsx("p",{className:"text-muted text-sm font-mono",children:n.run_id})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Jt,{runId:n.run_id,runName:n.run_name}),!P&&e.jsxs(D,{variant:"secondary",size:"sm",onClick:We,disabled:w,children:[w&&e.jsx(I,{}),"Set as Baseline"]}),e.jsx(D,{variant:"ghost-danger",size:"sm",onClick:()=>m(!0),children:"Delete"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Overview"})}),e.jsx(qe,{items:te})]}),e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Fingerprints"})}),e.jsx(qe,{items:[{label:"Run",value:e.jsx("span",{className:"font-mono text-sm truncate",children:ae.run||"N/A"})},{label:"Program",value:e.jsx("span",{className:"font-mono text-sm truncate",children:ae.program||"N/A"})}]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Parameters"})}),Object.keys(J).length?e.jsx($,{children:e.jsx(B,{children:Object.entries(J).map(([R,A])=>e.jsxs(j,{children:[e.jsx(c,{children:R}),e.jsx(c,{className:"font-mono",children:String(A)})]},R))})}):e.jsx("p",{className:"text-muted",children:"No parameters"})]}),e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Metrics"})}),Object.keys(ee).length?e.jsx($,{children:e.jsx(B,{children:Object.entries(ee).map(([R,A])=>e.jsxs(j,{children:[e.jsx(c,{children:R}),e.jsx(c,{className:"font-mono",children:typeof A=="number"?Lt(A):String(A)})]},R))})}):e.jsx("p",{className:"text-muted",children:"No metrics"})]}),e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Tags"})}),Object.keys(he).length?e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(he).map(([R,A])=>e.jsxs(H,{variant:"gray",children:[R,": ",String(A)]},R))}):e.jsx("p",{className:"text-muted",children:"No tags"})]})]}),e.jsxs(b,{className:"mb-4",children:[e.jsx(U,{children:e.jsxs(G,{children:["Artifacts (",xe.length,")"]})}),xe.length?e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"#"}),e.jsx(N,{children:"Kind"}),e.jsx(N,{children:"Role"}),e.jsx(N,{children:"Media Type"}),e.jsx(N,{children:"Digest"}),e.jsx(N,{children:"Actions"})]})}),e.jsx(B,{children:xe.map((R,A)=>e.jsxs(j,{children:[e.jsx(c,{children:A}),e.jsx(c,{className:"font-mono text-sm",children:R.kind}),e.jsx(c,{children:e.jsx(H,{variant:"gray",children:R.role})}),e.jsx(c,{className:"text-muted text-sm",children:R.media_type}),e.jsx(c,{className:"font-mono text-sm",children:Ie(R.digest)}),e.jsx(c,{children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k.Link,{to:`/runs/${n.run_id}/artifacts/${A}`,children:e.jsx(D,{variant:"secondary",size:"sm",children:"View"})}),e.jsx(D,{variant:"secondary",size:"sm",onClick:()=>Pe(A),children:"Download"})]})})]},A))})]}):e.jsx("p",{className:"text-muted",children:"No artifacts"})]}),be.length>0&&e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{className:"text-danger",children:"Errors"})}),be.map((R,A)=>e.jsxs("div",{className:"mb-2",children:[e.jsx("strong",{children:R.type}),": ",R.message,R.traceback&&e.jsx("pre",{className:"mt-2",children:R.traceback})]},A))]}),e.jsxs(Me,{open:h,onClose:()=>m(!1),title:"Delete Run",actions:e.jsxs(e.Fragment,{children:[e.jsx(D,{variant:"secondary",onClick:()=>m(!1),children:"Cancel"}),e.jsxs(D,{variant:"danger",onClick:Ve,disabled:T,children:[T&&e.jsx(I,{}),"Delete"]})]}),children:[e.jsx("p",{children:"Are you sure you want to delete this run?"}),e.jsx("p",{className:"font-mono text-sm mt-2",children:Q(n.run_id)}),e.jsx("p",{className:"text-sm text-danger mt-2",children:"This action cannot be undone."})]}),g&&e.jsx(ve,{message:g.message,variant:g.variant,visible:!!g,onClose:()=>_(null)})]})}function Qt(){const{currentWorkspace:t}=V(),{data:r,loading:a}=Te();return e.jsxs(W,{children:[e.jsx(ge,{title:"Projects"}),e.jsx(b,{children:a?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(I,{})}):e.jsx(Ht,{projects:r??[],currentWorkspace:t})})]})}function Zt(){const[t,r]=k.useSearchParams(),{data:a}=Te(),[n,o]=p.useState(t.get("project")||""),{data:d,loading:u,refetch:i}=Mt({project:n||void 0}),x=p.useCallback(h=>{o(h);const m=new URLSearchParams(t);h?m.set("project",h):m.delete("project"),r(m,{replace:!0})},[t,r]);return e.jsxs(W,{children:[e.jsx(ge,{title:"Run Groups"}),e.jsx(b,{className:"mb-4",children:e.jsxs(it,{children:[e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"project",children:"Project"}),e.jsxs(ce,{id:"project",value:n,onChange:h=>x(h.target.value),children:[e.jsx("option",{value:"",children:"All projects"}),a?.map(h=>e.jsx("option",{value:h.name,children:h.name},h.name))]})]}),e.jsxs(Z,{className:"flex items-end gap-2",children:[e.jsx(D,{variant:"primary",onClick:()=>i(),children:"Filter"}),u&&e.jsx(I,{})]})]})}),e.jsx(b,{children:u&&!d?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(I,{})}):e.jsx(Kt,{groups:d??[]})})]})}function es(){const{groupId:t}=k.useParams(),{api:r}=V(),{data:a,loading:n,error:o,refetch:d}=Ut(t),[u,i]=p.useState(null),x=pe(m=>r.deleteRun(m));p.useEffect(()=>{if(u){const m=setTimeout(()=>i(null),3e3);return()=>clearTimeout(m)}},[u]);const h=async m=>{try{await x.mutate(m),i({message:"Run deleted",variant:"success"}),d()}catch{i({message:"Failed to delete run",variant:"error"})}};return n?e.jsx(W,{children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(I,{})})}):o||!a?e.jsx(W,{children:e.jsx(b,{children:e.jsx(le,{message:"Group not found",hint:o?.message})})}):e.jsxs(W,{children:[e.jsx(ge,{title:e.jsxs(e.Fragment,{children:["Group ",e.jsx("span",{className:"font-mono",children:Q(t)})]}),subtitle:e.jsx("span",{className:"font-mono text-muted",children:t})}),e.jsxs(b,{children:[e.jsx(U,{children:e.jsxs(G,{children:["Runs in Group (",a.runs.length,")"]})}),e.jsx(Ge,{runs:a.runs,onDelete:h,loading:x.loading})]}),u&&e.jsx(ve,{message:u.message,variant:u.variant,visible:!!u,onClose:()=>i(null)})]})}function Hs({className:t=""}){return e.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})}function Ks({className:t=""}){return e.jsxs("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Js({className:t=""}){return e.jsxs("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}function et({className:t=""}){return e.jsxs("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}function Re({match:t}){return t?e.jsxs("span",{className:"diff-match inline-flex items-center gap-1.5",children:[e.jsx(Hs,{className:"flex-shrink-0"}),e.jsx("span",{className:"font-medium",children:"Match"})]}):e.jsxs("span",{className:"diff-mismatch inline-flex items-center gap-1.5",children:[e.jsx(Ks,{className:"flex-shrink-0"}),e.jsx("span",{className:"font-medium",children:"Different"})]})}function Xs({warnings:t}){return!t||t.length===0?null:e.jsx("div",{className:"alert alert-warning mb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Js,{className:"flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold mb-1",children:t.length===1?"Warning":`${t.length} Warnings`}),e.jsx("ul",{className:"space-y-1",children:t.map((r,a)=>e.jsx("li",{className:"text-sm",children:r},a))})]})]})})}function kt({label:t,run:r,variant:a}){return e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:`absolute top-0 left-0 w-1 h-full rounded-l ${a==="a"?"bg-info":"bg-primary"}`}),e.jsxs("div",{className:"pl-4",children:[e.jsx("p",{className:`text-xs font-semibold uppercase tracking-wider mb-2 ${a==="a"?"text-info":"text-primary"}`,children:t}),e.jsx(k.Link,{to:`/runs/${r.run_id}`,className:"text-base font-medium hover:underline",children:r.run_name||"Unnamed Run"}),e.jsx("p",{className:"font-mono text-xs mt-1 text-muted",children:Q(r.run_id)}),e.jsxs("p",{className:"text-sm mt-1 text-muted",children:[r.project," · ",Se(r.created_at)]})]})]})}function ie({children:t,badge:r}){return e.jsx(U,{children:e.jsx(G,{children:e.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[t,r&&e.jsx(H,{variant:r.variant,children:r.label})]})})})}function Qs({tvd:t,noiseContext:r}){if(t===0)return e.jsx("p",{className:"text-sm mt-4 text-success",children:"✓ Distributions are identical (TVD = 0)"});if(!r)return null;const{p_value:a,noise_ratio:n}=r;return a!=null?a>=.1?e.jsx("p",{className:"text-sm mt-4 text-success",children:"✓ Consistent with sampling noise — difference is not statistically significant"}):a>=.05?e.jsxs("p",{className:"text-sm mt-4 text-warning",children:["⚠ Borderline (p=",a.toFixed(2),") — consider increasing shots"]}):e.jsxs("p",{className:"text-sm mt-4 text-danger",children:["✗ Statistically significant difference (p=",a.toFixed(2),") — results show meaningful divergence"]}):n!=null?n<1.5?e.jsx("p",{className:"text-sm mt-4 text-success",children:"✓ TVD is within expected shot noise range"}):n<3?e.jsxs("p",{className:"text-sm mt-4 text-warning",children:["⚠ Ambiguous (",n.toFixed(1),"× expected noise) — consider increasing shots"]}):e.jsxs("p",{className:"text-sm mt-4 text-danger",children:["✗ TVD exceeds expected noise (",n.toFixed(1),"×) — results show meaningful differences"]}):null}function Zs(){const[t,r]=k.useSearchParams(),{data:a}=nt({limit:100}),n=a?.runs??[],[o,d]=p.useState(t.get("a")||""),[u,i]=p.useState(t.get("b")||""),[x,h]=p.useState(""),m=g=>{if(g.preventDefault(),!o||!u){h("Please select both runs to compare");return}if(o===u){h("Please select two different runs");return}h(""),r({a:o,b:u})};return e.jsxs(e.Fragment,{children:[e.jsx(b,{children:e.jsxs("form",{onSubmit:m,children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"a",children:"Run A (Baseline)"}),e.jsxs(ce,{id:"a",value:o,onChange:g=>{d(g.target.value),h("")},children:[e.jsx("option",{value:"",children:"Select run..."}),n.map(g=>e.jsxs("option",{value:g.run_id,children:[g.run_name||"Unnamed"," (",Q(g.run_id),") — ",g.project]},g.run_id))]})]}),e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"b",children:"Run B (Candidate)"}),e.jsxs(ce,{id:"b",value:u,onChange:g=>{i(g.target.value),h("")},children:[e.jsx("option",{value:"",children:"Select run..."}),n.map(g=>e.jsxs("option",{value:g.run_id,children:[g.run_name||"Unnamed"," (",Q(g.run_id),") — ",g.project]},g.run_id))]})]})]}),x&&e.jsx("p",{className:"text-sm mb-3 text-danger",children:x}),e.jsx(D,{type:"submit",variant:"primary",children:"Compare"})]})}),e.jsxs(b,{className:"mt-4",children:[e.jsx(U,{children:e.jsx(G,{children:"How it works"})}),e.jsxs("div",{className:"space-y-2 text-sm text-muted",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(et,{className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{children:"Select two runs to compare their parameters, metrics, and artifacts"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(et,{className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{children:"The diff shows changed values and computes TVD for result distributions"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(et,{className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{children:"You can also compare from the run detail page"})]})]})]})]})}function er({runIdA:t,runIdB:r}){const{data:a,loading:n,error:o}=Gt(t,r);if(n)return e.jsx(b,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-3",children:[e.jsx(I,{}),e.jsx("p",{className:"text-sm text-muted",children:"Comparing runs..."})]})});if(o||!a)return e.jsx(b,{children:e.jsx(le,{message:"Failed to load diff",hint:o?.message})});const{run_a:d,run_b:u,report:i}=a,x=i.device_drift?.significant_drift?{variant:"warning",label:"Drift Detected"}:i.device_drift?.has_calibration_data?{variant:"success",label:"Stable"}:{variant:"gray",label:"No Data"};return e.jsxs(e.Fragment,{children:[e.jsx(Xs,{warnings:i.warnings||[]}),e.jsx(b,{className:"mb-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsx(kt,{label:"Run A (Baseline)",run:d,variant:"a"}),e.jsx(kt,{label:"Run B (Candidate)",run:u,variant:"b"})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[e.jsxs(b,{children:[e.jsx(ie,{children:"Metadata"}),e.jsx($,{children:e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{children:"Project"}),e.jsx(c,{children:e.jsx(Re,{match:i.metadata.project_match})})]}),e.jsxs(j,{children:[e.jsx(c,{children:"Backend"}),e.jsx(c,{children:e.jsx(Re,{match:i.metadata.backend_match})})]}),!i.metadata.project_match&&e.jsxs(e.Fragment,{children:[e.jsxs(j,{children:[e.jsx(c,{className:"text-sm text-muted",children:"Project A"}),e.jsx(c,{className:"font-mono text-sm",children:i.metadata.project_a||"N/A"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"text-sm text-muted",children:"Project B"}),e.jsx(c,{className:"font-mono text-sm",children:i.metadata.project_b||"N/A"})]})]}),!i.metadata.backend_match&&e.jsxs(e.Fragment,{children:[e.jsxs(j,{children:[e.jsx(c,{className:"text-sm text-muted",children:"Backend A"}),e.jsx(c,{className:"font-mono text-sm",children:i.metadata.backend_a||"N/A"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"text-sm text-muted",children:"Backend B"}),e.jsx(c,{className:"font-mono text-sm",children:i.metadata.backend_b||"N/A"})]})]})]})})]}),e.jsxs(b,{children:[e.jsx(ie,{children:"Fingerprints"}),e.jsx($,{children:e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{children:"Run A"}),e.jsx(c,{className:"font-mono text-sm",children:Ie(i.fingerprints.a)})]}),e.jsxs(j,{children:[e.jsx(c,{children:"Run B"}),e.jsx(c,{className:"font-mono text-sm",children:Ie(i.fingerprints.b)})]}),e.jsxs(j,{children:[e.jsx(c,{children:"Match"}),e.jsx(c,{children:e.jsx(Re,{match:i.fingerprints.a===i.fingerprints.b})})]})]})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[e.jsxs(b,{children:[e.jsx(ie,{badge:{variant:i.program.exact_match?"success":i.program.structural_match?"info":"warning",label:i.program.exact_match?"Exact Match":i.program.structural_match?"Structural Match":"Different"},children:"Program"}),e.jsx($,{children:e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{children:"Exact Match"}),e.jsx(c,{children:e.jsx(Re,{match:i.program.exact_match})})]}),e.jsxs(j,{children:[e.jsx(c,{children:"Structural Match"}),e.jsx(c,{children:e.jsx(Re,{match:i.program.structural_match})})]})]})})]}),e.jsxs(b,{children:[e.jsx(ie,{badge:x,children:"Device Calibration"}),i.device_drift?.significant_drift?e.jsx("p",{className:"text-sm text-warning",children:"Significant calibration drift detected between runs"}):i.device_drift?.has_calibration_data?e.jsx("p",{className:"text-muted",children:"Calibration within acceptable thresholds"}):e.jsx("p",{className:"text-muted",children:"No calibration data available"})]})]}),e.jsxs(b,{className:"mb-4",children:[e.jsx(ie,{badge:{variant:i.params.match?"success":"warning",label:i.params.match?"Match":"Different"},children:"Parameters"}),i.params.match?e.jsx("p",{className:"text-muted",children:"All parameters match"}):e.jsx(e.Fragment,{children:i.params.changed&&Object.keys(i.params.changed).length>0&&e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Parameter"}),e.jsx(N,{children:"Run A"}),e.jsx(N,{children:"Run B"})]})}),e.jsx(B,{children:Object.entries(i.params.changed).map(([h,m])=>e.jsxs(j,{children:[e.jsx(c,{children:h}),e.jsx(c,{className:"font-mono",children:String(m.a)}),e.jsx(c,{className:"font-mono",children:String(m.b)})]},h))})]})})]}),e.jsxs(b,{className:"mb-4",children:[e.jsx(ie,{badge:{variant:i.metrics.match?"success":"warning",label:i.metrics.match?"Match":"Different"},children:"Metrics"}),i.metrics.match?e.jsx("p",{className:"text-muted",children:"All metrics match"}):e.jsx(e.Fragment,{children:i.metrics.changed&&Object.keys(i.metrics.changed).length>0&&e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Metric"}),e.jsx(N,{children:"Run A"}),e.jsx(N,{children:"Run B"})]})}),e.jsx(B,{children:Object.entries(i.metrics.changed).map(([h,m])=>e.jsxs(j,{children:[e.jsx(c,{children:h}),e.jsx(c,{className:"font-mono",children:m.a}),e.jsx(c,{className:"font-mono",children:m.b})]},h))})]})})]}),i.circuit_diff&&e.jsxs(b,{className:"mb-4",children:[e.jsx(ie,{badge:{variant:i.circuit_diff.match?"success":"warning",label:i.circuit_diff.match?"Match":"Different"},children:"Circuit"}),i.circuit_diff.match?e.jsx("p",{className:"text-muted",children:"Circuit structure matches"}):e.jsxs("div",{className:"space-y-4",children:[i.circuit_diff.changed&&Object.keys(i.circuit_diff.changed).length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2 text-muted",children:"Changed Properties"}),e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Property"}),e.jsx(N,{children:"Run A"}),e.jsx(N,{children:"Run B"}),e.jsx(N,{children:"Delta"})]})}),e.jsx(B,{children:Object.entries(i.circuit_diff.changed).map(([h,m])=>e.jsxs(j,{children:[e.jsx(c,{children:m.label||h}),e.jsx(c,{className:"font-mono",children:String(m.a)}),e.jsx(c,{className:"font-mono",children:String(m.b)}),e.jsx(c,{className:"font-mono",children:m.delta!=null&&e.jsxs("span",{className:m.delta>0?"text-danger":"text-success",children:[m.delta>0?"+":"",m.delta,m.pct!=null&&` (${m.pct>0?"+":""}${m.pct.toFixed(1)}%)`]})})]},h))})]})]}),i.circuit_diff.is_clifford_changed&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2 text-muted",children:"Clifford Status"}),e.jsx($,{children:e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{children:"Run A"}),e.jsx(c,{className:"font-mono",children:i.circuit_diff.is_clifford_a!=null?String(i.circuit_diff.is_clifford_a):"unknown"})]}),e.jsxs(j,{children:[e.jsx(c,{children:"Run B"}),e.jsx(c,{className:"font-mono",children:i.circuit_diff.is_clifford_b!=null?String(i.circuit_diff.is_clifford_b):"unknown"})]})]})})]}),i.circuit_diff.added_gates&&i.circuit_diff.added_gates.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2 text-muted",children:"New Gate Types (in B)"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.circuit_diff.added_gates.map(h=>e.jsx(H,{variant:"success",children:h},h))})]}),i.circuit_diff.removed_gates&&i.circuit_diff.removed_gates.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2 text-muted",children:"Removed Gate Types (from A)"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.circuit_diff.removed_gates.map(h=>e.jsx(H,{variant:"danger",children:h},h))})]})]})]}),i.tvd!=null&&e.jsxs(b,{className:"mb-4",children:[e.jsx(ie,{children:"Results Distribution"}),e.jsx($,{children:e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{children:"Total Variation Distance (TVD)"}),e.jsx(c,{className:"font-mono font-medium",children:i.tvd.toFixed(6)})]}),i.shots&&e.jsxs(j,{children:[e.jsx(c,{children:"Total Shots (A / B)"}),e.jsxs(c,{className:"font-mono",children:[i.shots.a," / ",i.shots.b]})]}),i.noise_context?.noise_p95&&e.jsxs(j,{children:[e.jsx(c,{children:"Noise Threshold (p95)"}),e.jsx(c,{className:"font-mono",children:i.noise_context.noise_p95.toFixed(6)})]}),i.noise_context?.p_value!=null&&e.jsxs(j,{children:[e.jsx(c,{children:"p-value"}),e.jsx(c,{className:"font-mono",children:i.noise_context.p_value.toFixed(4)})]})]})}),e.jsx(Qs,{tvd:i.tvd,noiseContext:i.noise_context})]})]})}function ts(){const[t]=k.useSearchParams(),r=t.get("a"),a=t.get("b"),n=r&&a;return e.jsxs(W,{children:[e.jsx("div",{className:"page-header",children:e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",children:"Compare Runs"}),n&&e.jsx("p",{className:"text-sm mt-1 text-muted",children:e.jsx(k.Link,{to:"/diff",children:"← Select different runs"})})]})}),n?e.jsx(er,{runIdA:r,runIdB:a}):e.jsx(Zs,{})]})}function ss(){const{api:t}=V(),[r,a]=p.useState(""),[n,o]=p.useState(null),[d,u]=p.useState(!1),[i,x]=p.useState(""),{mutate:h,loading:m}=pe(async()=>{const _=await t.listRuns({q:r,limit:100});return o(_.runs),u(!0),_}),g=_=>{if(_.preventDefault(),!r.trim()){x("Please enter a search query");return}x(""),h()};return e.jsxs(W,{children:[e.jsx("div",{className:"page-header",children:e.jsx("h1",{className:"page-title",children:"Search Runs"})}),e.jsx(b,{className:"mb-4",children:e.jsxs("form",{onSubmit:g,children:[e.jsxs(Z,{children:[e.jsx(ne,{htmlFor:"q",children:"Query"}),e.jsx(Ue,{id:"q",type:"text",value:r,onChange:_=>{a(_.target.value),x("")},placeholder:"metric.fidelity > 0.95 and params.shots = 1000",className:"font-mono"})]}),i&&e.jsx("p",{className:"text-sm text-[#DC4A4A] mb-3",children:i}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(D,{type:"submit",variant:"primary",disabled:m,children:[m&&e.jsx(I,{}),"Search"]}),m&&e.jsx("span",{className:"text-muted text-sm",children:"Searching..."})]})]})}),d&&n&&e.jsx(b,{className:"mb-4",children:n.length>0?e.jsx(Ge,{runs:n}):e.jsx("p",{className:"text-muted text-center py-8",children:"No runs match your query"})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Query Syntax"})}),e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Field"}),e.jsx(N,{children:"Description"})]})}),e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"params.X"}),e.jsx(c,{children:"Parameter value"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"metric.X"}),e.jsx(c,{children:"Metric value"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"tags.X"}),e.jsx(c,{children:"Tag value"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"status"}),e.jsx(c,{children:"Run status"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"project"}),e.jsx(c,{children:"Project name"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"backend"}),e.jsx(c,{children:"Backend name"})]})]})]})]}),e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Operators"})}),e.jsxs($,{children:[e.jsx(se,{children:e.jsxs(j,{children:[e.jsx(N,{children:"Operator"}),e.jsx(N,{children:"Description"})]})}),e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"="}),e.jsx(c,{children:"Equals"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"!="}),e.jsx(c,{children:"Not equals"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:">"}),e.jsx(c,{children:"Greater than"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:">="}),e.jsx(c,{children:"Greater or equal"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"<"}),e.jsx(c,{children:"Less than"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"<="}),e.jsx(c,{children:"Less or equal"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"~"}),e.jsx(c,{children:"Contains"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"and"}),e.jsx(c,{children:"Combine conditions"})]})]})]})]})]}),e.jsxs(b,{className:"mt-4",children:[e.jsx(U,{children:e.jsx(G,{children:"Examples"})}),e.jsx($,{children:e.jsxs(B,{children:[e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"metric.fidelity > 0.95"}),e.jsx(c,{children:"High fidelity runs"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"params.shots = 1000 and status = FINISHED"}),e.jsx(c,{children:"Finished runs with 1000 shots"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"tags.backend ~ ibm"}),e.jsx(c,{children:"Runs with IBM backends"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"metric.error < 0.01"}),e.jsx(c,{children:"Low error runs"})]}),e.jsxs(j,{children:[e.jsx(c,{className:"font-mono",children:"project = vqe and metric.energy < -2.0"}),e.jsx(c,{children:"VQE runs with low energy"})]})]})})]})]})}function rs(){const{runId:t,index:r}=k.useParams(),a=parseInt(r,10),{api:n}=V(),{data:o}=at(t),{data:d,loading:u,error:i}=Wt(t,a),[x,h]=p.useState(null);p.useEffect(()=>{if(x){const P=setTimeout(()=>h(null),3e3);return()=>clearTimeout(P)}},[x]);const m=async()=>{try{const P=n.getArtifactDownloadUrl(t,a),re=await fetch(P);if(!re.ok)throw new Error("Download failed");const ae=await re.blob(),J=document.createElement("a");J.href=URL.createObjectURL(ae),J.download=g?.kind||`artifact-${a}`,J.click(),URL.revokeObjectURL(J.href),h({message:"Download complete",variant:"success"})}catch{h({message:"Download failed",variant:"error"})}};if(u)return e.jsx(W,{children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(I,{})})});if(i||!d)return e.jsx(W,{children:e.jsx(b,{children:e.jsx(le,{message:"Artifact not found",hint:i?.message})})});const{artifact:g,size:_,content:z,content_json:w,preview_available:K,error:T}=d,q=10*1024*1024;return e.jsxs(W,{children:[e.jsx(ge,{title:g.kind,subtitle:e.jsxs(e.Fragment,{children:["← Back to run ",e.jsxs(k.Link,{to:`/runs/${t}`,children:[Q(t),o?.run_name&&` — ${o.run_name}`]})]}),actions:e.jsx(D,{variant:"primary",onClick:m,children:"Download"})}),e.jsx(b,{className:"mb-4",children:e.jsx(qe,{items:[{label:"Kind",value:e.jsx("span",{className:"font-mono",children:g.kind})},{label:"Role",value:e.jsx(H,{variant:"gray",children:g.role})},{label:"Media Type",value:g.media_type},{label:"Digest",value:e.jsx("span",{className:"font-mono text-sm",children:g.digest})},{label:"Size",value:Ee(_)}]})}),e.jsxs(b,{children:[e.jsx(U,{children:e.jsx(G,{children:"Content"})}),T?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-danger",children:["Error loading artifact: ",T]}),e.jsx("p",{className:"text-muted mt-2",children:e.jsx(D,{variant:"primary",onClick:m,children:"Download to view"})})]}):K?w?e.jsx("pre",{children:Ft(w)}):z?e.jsx("pre",{children:z}):e.jsxs("p",{className:"text-muted",children:["Binary content (",Ee(_),") — download to view"]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-muted",children:[e.jsx("strong",{children:"Artifact too large for preview"})," (",Ee(_)," exceeds ",Ee(q)," limit)"]}),e.jsx("p",{className:"text-sm text-muted mt-2",children:"Download the artifact to view its contents."}),e.jsx("p",{className:"mt-4",children:e.jsx(D,{variant:"primary",onClick:m,children:"Download"})})]})]}),x&&e.jsx(ve,{message:x.message,variant:x.variant,visible:!!x,onClose:()=>h(null)})]})}const ns=[{path:"/",element:e.jsx(k.Navigate,{to:"/runs",replace:!0})},{path:"/runs",element:e.jsx(Yt,{})},{path:"/runs/:runId",element:e.jsx(Xt,{})},{path:"/runs/:runId/artifacts/:index",element:e.jsx(rs,{})},{path:"/projects",element:e.jsx(Qt,{})},{path:"/groups",element:e.jsx(Zt,{})},{path:"/groups/:groupId",element:e.jsx(es,{})},{path:"/diff",element:e.jsx(ts,{})},{path:"/search",element:e.jsx(ss,{})}];function lt(t=[]){return k.createBrowserRouter([...ns,...t])}const as=lt();function tr({additionalRoutes:t,...r}){const a=t?.length?lt(t):as;return e.jsx(qt,{...r,children:e.jsx(k.RouterProvider,{router:a})})}exports.Alert=Us;exports.ApiClient=Dt;exports.ApiError=je;exports.App=tr;exports.AppProvider=qt;exports.ArtifactPage=rs;exports.Badge=H;exports.Button=D;exports.Card=b;exports.CardHeader=U;exports.CardTitle=G;exports.DiffPage=ts;exports.EmptyState=le;exports.ExportRunButton=Jt;exports.FormGroup=Z;exports.FormRow=it;exports.GroupDetailPage=es;exports.GroupsPage=Zt;exports.GroupsTable=Kt;exports.Input=Ue;exports.KVList=qe;exports.Label=ne;exports.Layout=W;exports.LayoutConfigProvider=Ms;exports.Modal=Me;exports.POLL_INTERVAL=Be;exports.PageHeader=ge;exports.ProjectsPage=Qt;exports.ProjectsTable=Ht;exports.RunDetailPage=Xt;exports.RunsPage=Yt;exports.RunsTable=Ge;exports.SearchPage=ss;exports.Select=ce;exports.Spinner=I;exports.StatusBadge=ct;exports.Table=$;exports.TableBody=B;exports.TableCell=c;exports.TableHead=se;exports.TableHeader=N;exports.TableRow=j;exports.ThemeProvider=$s;exports.Toast=ve;exports.api=At;exports.buildUrl=Os;exports.cn=O;exports.coreRoutes=ns;exports.createRouter=lt;exports.elapsedSeconds=tt;exports.formatBytes=Ee;exports.formatDuration=st;exports.formatNumber=Lt;exports.isTerminalStatus=Ce;exports.jsonPretty=Ft;exports.router=as;exports.shortDigest=Ie;exports.shortId=Q;exports.timeAgo=Se;exports.truncate=Ot;exports.useApp=V;exports.useArtifact=Wt;exports.useDiff=Gt;exports.useGroup=Ut;exports.useGroups=Mt;exports.useLayoutConfig=zt;exports.useMutation=pe;exports.usePolling=rt;exports.useProjects=Te;exports.useRun=at;exports.useRuns=nt;exports.useTheme=Bt;exports.useThemeOptional=Bs;
|
|
14
|
+
<%s key={someKey} {...props} />`,it,Ne,Os,Ne),Tt[Ne+it]=!0}}return r===n?Ds(M):Ps(M),M}}function As(r,x,j){return Pt(r,x,j,!0)}function Ls(r,x,j){return Pt(r,x,j,!1)}var Fs=Ls,$s=As;De.Fragment=n,De.jsx=Fs,De.jsxs=$s})()),De}var Lt;function qs(){return Lt||(Lt=1,process.env.NODE_ENV==="production"?We.exports=Bs():We.exports=Is()),We.exports}var e=qs();class Re extends Error{constructor(s,a){super(a),this.status=s,this.name="ApiError"}}class Bt{baseUrl;headers;constructor(s={}){this.baseUrl=s.baseUrl??"",this.headers={"Content-Type":"application/json",...s.headers}}async request(s,a,n={}){let l=`${this.baseUrl}${a}`;if(n.params){const c=new URLSearchParams;Object.entries(n.params).forEach(([u,h])=>{h!=null&&h!==""&&c.set(u,String(h))});const i=c.toString();i&&(l+=`?${i}`)}const o=await fetch(l,{method:s,headers:{...this.headers,...n.headers},body:n.body?JSON.stringify(n.body):void 0,credentials:n.credentials,cache:"no-store"});if(!o.ok){const c=await o.json().catch(()=>({detail:"Unknown error"}));throw new Re(o.status,c.detail||o.statusText)}if(!(o.status===204||o.headers.get("content-length")==="0"))return o.json()}async getCapabilities(){return this.request("GET","/api/v1/capabilities")}async listRuns(s){return this.request("GET","/api/runs",{params:s})}async getRun(s){return this.request("GET",`/api/runs/${s}`)}async deleteRun(s){await this.request("DELETE",`/api/runs/${s}`)}async setBaseline(s,a){return this.request("POST",`/api/projects/${s}/baseline/${a}`,{params:{redirect:"false"}})}async listProjects(s){return this.request("GET","/api/projects",{params:s})}async listGroups(s){return this.request("GET","/api/groups",{params:s})}async getGroup(s){return this.request("GET",`/api/groups/${s}`)}async getDiff(s,a){return this.request("GET","/api/diff",{params:{a:s,b:a}})}async getArtifact(s,a){return this.request("GET",`/api/runs/${s}/artifacts/${a}`)}getArtifactDownloadUrl(s,a){return`${this.baseUrl}/api/runs/${s}/artifacts/${a}/raw`}async createExport(s){return this.request("POST",`/api/runs/${s}/export`)}async getExportInfo(s){return this.request("GET",`/api/runs/${s}/export/info`)}getExportDownloadUrl(s){return`${this.baseUrl}/api/runs/${s}/export/download`}async getMetricSeries(s){return this.request("GET",`/api/runs/${s}/metric_series`)}}const It=new Bt;function ie(t){return t?.slice(0,8)??""}function ze(t){return t?.slice(0,12)??"N/A"}function Fe(t){const s=new Date(t),n=Math.floor((new Date().getTime()-s.getTime())/1e3);if(n<60)return"just now";if(n<3600){const o=Math.floor(n/60);return`${o} minute${o!==1?"s":""} ago`}if(n<86400){const o=Math.floor(n/3600);return`${o} hour${o!==1?"s":""} ago`}if(n<2592e3){const o=Math.floor(n/86400);return`${o} day${o!==1?"s":""} ago`}if(n<31536e3){const o=Math.floor(n/2592e3);return`${o} month${o!==1?"s":""} ago`}const l=Math.floor(n/31536e3);return`${l} year${l!==1?"s":""} ago`}function He(t,s=6){return typeof t!="number"||isNaN(t)?String(t):Number(t.toPrecision(s)).toString()}function Le(t){return t<1024?`${t} bytes`:t<1048576?`${(t/1024).toFixed(1)} KB`:`${(t/1048576).toFixed(1)} MB`}function qt(t){return JSON.stringify(t,null,2)}function Ut(t,s=60){return t?t.length<=s?t:t.slice(0,s-3)+"...":""}function Us(t,s){const a=new URLSearchParams;Object.entries(s).forEach(([l,o])=>{o!=null&&o!==""&&a.set(l,String(o))});const n=a.toString();return n?`${t}?${n}`:t}function I(...t){return t.filter(Boolean).join(" ")}function ot(t,s){const a=new Date(t).getTime(),n=s?new Date(s).getTime():Date.now();return Math.max(0,Math.floor((n-a)/1e3))}function dt(t){if(t<60)return`${t}s`;const s=Math.floor(t/86400),a=Math.floor(t%86400/3600),n=Math.floor(t%3600/60),l=t%60;return s>0?`${s}d ${a}h ${n}m`:a>0?`${a}h ${n}m ${l}s`:`${n}m ${l}s`}function Ee(t){return t==="FINISHED"||t==="FAILED"||t==="KILLED"}const Wt=f.createContext(null);function Ws({children:t}){const s={theme:"light",resolvedTheme:"light",setTheme:()=>{},toggleTheme:()=>{}};return e.jsx(Wt.Provider,{value:s,children:t})}function Gt(){const t=f.useContext(Wt);return t||{theme:"light",resolvedTheme:"light",setTheme:()=>{},toggleTheme:()=>{}}}function Gs(){return Gt()}const Ve=1e3,Vs={runsActive:Ve,runsIdle:Ve,runDetail:Ve},Vt=f.createContext(null);function zt({children:t,api:s=It,initialWorkspace:a=null,pollingConfig:n}){const[l,o]=f.useState(null),[c,i]=f.useState(a),u={...Vs,...n};return f.useEffect(()=>{s.getCapabilities().then(o).catch(console.error)},[s]),e.jsx(Vt.Provider,{value:{api:s,capabilities:l,currentWorkspace:c,setCurrentWorkspace:i,pollingConfig:u},children:t})}function Y(){const t=f.useContext(Vt);if(!t)throw new Error("useApp must be used within AppProvider");return t}function ve(t,s=[]){const[a,n]=f.useState({data:null,loading:!0,error:null}),l=f.useRef(!0),o=f.useRef(t);o.current=t;const c=f.useCallback(async u=>{u||n(h=>({...h,loading:!0,error:null}));try{const h=await o.current();l.current&&n({data:h,loading:!1,error:null})}catch(h){if(l.current){const m=h instanceof Re?h:new Re(500,String(h));n(g=>({data:u?g.data:null,loading:!1,error:m}))}}},[]);f.useEffect(()=>(l.current=!0,c(!1),()=>{l.current=!1}),s);const i=f.useCallback(()=>c(!0),[c]);return{...a,refetch:i}}function Ke(t,s,a){f.useEffect(()=>{if(!a)return;let n,l=!1;const o=()=>{if(l)return;const u=s*.1*(Math.random()*2-1);n=setTimeout(c,Math.max(500,s+u))},c=async()=>{if(!l&&document.visibilityState!=="hidden"){try{await t()}catch{}o()}};o();const i=()=>{l||document.visibilityState!=="visible"||(clearTimeout(n),Promise.resolve(t()).catch(()=>{}).finally(o))};return document.addEventListener("visibilitychange",i),()=>{l=!0,clearTimeout(n),document.removeEventListener("visibilitychange",i)}},[t,s,a])}function ut(t){const{api:s,currentWorkspace:a,pollingConfig:n}=Y(),l=ve(()=>s.listRuns({...t,workspace:a?.id}),[s,a?.id,t?.project,t?.status,t?.q,t?.limit]),c=l.data?.runs.some(i=>!Ee(i.status))??!1?n.runsActive:n.runsIdle;return Ke(l.refetch,c,!0),l}function ht(t){const{api:s,pollingConfig:a}=Y(),n=ve(async()=>{const{run:o}=await s.getRun(t);return o},[s,t]),l=n.data?!Ee(n.data.status):!1;return Ke(n.refetch,a.runDetail,l),n}function $e(){const{api:t,currentWorkspace:s}=Y();return ve(async()=>{const{projects:a}=await t.listProjects({workspace:s?.id});return a},[t,s?.id])}function Ht(t){const{api:s,currentWorkspace:a}=Y();return ve(async()=>{const{groups:n}=await s.listGroups({...t,workspace:a?.id});return n},[s,a?.id,t?.project])}function Yt(t){const{api:s}=Y();return ve(()=>s.getGroup(t),[s,t])}function Kt(t,s){const{api:a}=Y();return ve(()=>a.getDiff(t,s),[a,t,s])}function Jt(t,s){const{api:a}=Y();return ve(()=>a.getArtifact(t,s),[a,t,s])}function Se(t){const[s,a]=f.useState(!1),[n,l]=f.useState(null);return{mutate:f.useCallback(async(...c)=>{a(!0),l(null);try{return await t(...c)}catch(i){const u=i instanceof Re?i:new Re(500,String(i));throw l(u),u}finally{a(!1)}},[t]),loading:s,error:n}}function zs(t,s){const{api:a,pollingConfig:n}=Y(),l=ve(async()=>{try{const{series:c}=await a.getMetricSeries(t);return Object.values(c).some(u=>u.length>0)?c:null}catch{return null}},[a,t]),o=f.useRef(s);return f.useEffect(()=>{o.current&&!s&&l.refetch(),o.current=s},[s,l.refetch]),Ke(l.refetch,n.runDetail,s),l}const Hs=[{href:"/runs",label:"Runs",matchPaths:["/runs"]},{href:"/projects",label:"Projects",matchPaths:["/projects"]},{href:"/groups",label:"Groups",matchPaths:["/groups"]},{href:"/diff",label:"Compare",matchPaths:["/diff"]},{href:"/search",label:"Search",matchPaths:["/search"]}],Xt=f.createContext(null);function Ys({config:t,children:s}){return e.jsx(Xt.Provider,{value:t,children:s})}function Qt(){return f.useContext(Xt)}function X({children:t,config:s}){const a=L.useLocation(),l={...Qt(),...s},o=l?.navLinks??Hs,c=[...l?.prependNavLinks??[],...o,...l?.appendNavLinks??[]],i=l?.logo??{text:"devqubit",icon:"⚛"},u=h=>h.matchPaths?h.matchPaths.some(m=>a.pathname.startsWith(m)):a.pathname===h.href;return e.jsxs("div",{className:"dq-layout",children:[e.jsx("header",{className:"dq-header",children:e.jsxs("div",{className:"dq-header-inner",children:[e.jsxs("div",{className:"dq-header-left",children:[e.jsxs(L.Link,{to:"/",className:"dq-logo",children:[i.icon&&e.jsx("span",{className:"dq-logo-icon",children:i.icon}),i.text]}),e.jsx("nav",{className:"dq-nav",children:c.map(h=>e.jsx(L.Link,{to:h.href,className:I("dq-nav-link",u(h)&&"active"),children:h.label},h.href))})]}),e.jsx("div",{className:"dq-header-right",children:l?.headerRight})]})}),e.jsx("main",{className:"dq-main fade-in",children:t})]})}function ke({title:t,subtitle:s,actions:a}){return e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",children:t}),s&&e.jsx("p",{className:"text-sm text-muted mt-1",children:s})]}),a&&e.jsx("div",{className:"flex gap-2",children:a})]})}function ee({variant:t="gray",className:s,children:a,...n}){return e.jsx("span",{className:I("badge",`badge-${t}`,s),...n,children:a})}const $=f.forwardRef(({variant:t="secondary",size:s="default",loading:a,className:n,children:l,disabled:o,...c},i)=>e.jsxs("button",{ref:i,className:I("btn",t==="ghost-danger"?"btn-ghost-danger":`btn-${t}`,s==="sm"&&"btn-sm",n),disabled:o||a,...c,children:[a&&e.jsx(G,{}),l]}));$.displayName="Button";function _({className:t,children:s,...a}){return e.jsx("div",{className:I("card",t),...a,children:s})}function z({className:t,children:s,...a}){return e.jsx("div",{className:I("card-header",t),...a,children:s})}function H({className:t,children:s,...a}){return e.jsx("h3",{className:I("card-title",t),...a,children:s})}function Ks({variant:t="info",className:s,children:a,...n}){return e.jsx("div",{className:I("alert",`alert-${t}`,s),...n,children:a})}function G({className:t,...s}){return e.jsx("span",{className:I("spinner",t),...s})}function be({message:t,hint:s,className:a,...n}){return e.jsxs("div",{className:I("empty-state",a),...n,children:[e.jsx("p",{children:t}),s&&e.jsx("p",{className:"text-sm text-muted mt-2",children:s})]})}function Ye({items:t,className:s,...a}){return e.jsx("dl",{className:I("kv-list",s),...a,children:t.map(({label:n,value:l})=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{children:n}),e.jsx("dd",{children:l})]},n))})}function Je({open:t,onClose:s,title:a,children:n,actions:l}){return t?e.jsx("div",{className:I("modal-backdrop","active"),onClick:o=>o.target===o.currentTarget&&s(),children:e.jsxs("div",{className:"modal",onClick:o=>o.stopPropagation(),children:[e.jsx("h3",{className:"modal-title",children:a}),e.jsx("div",{className:"modal-body",children:n}),l&&e.jsx("div",{className:"modal-actions",children:l})]})}):null}function Ce({message:t,variant:s="info",visible:a,onClose:n}){if(!a)return null;const l={success:"✓",error:"✕",info:"i"}[s],o={success:"text-[#059669]",error:"text-[#DC4A4A]",info:"text-[#2563EB]"}[s];return e.jsxs("div",{className:"toast",onClick:n,children:[e.jsx("span",{className:I("mr-2 font-bold",o),children:l}),t]})}function de({children:t,className:s}){return e.jsx("div",{className:I("form-group",s),children:t})}function me({className:t,children:s,...a}){return e.jsx("label",{className:I("form-label",t),...a,children:s})}const Xe=f.forwardRef(({className:t,...s},a)=>e.jsx("input",{ref:a,className:I("form-input",t),...s}));Xe.displayName="Input";const ge=f.forwardRef(({className:t,children:s,...a},n)=>e.jsx("select",{ref:n,className:I("form-input",t),...a,children:s}));ge.displayName="Select";function xt({children:t,className:s}){return e.jsx("div",{className:I("form-row",s),children:t})}function q({className:t,children:s,...a}){return e.jsx("table",{className:I("table",t),...a,children:s})}function xe({className:t,children:s,...a}){return e.jsx("thead",{className:t,...a,children:s})}function U({className:t,children:s,...a}){return e.jsx("tbody",{className:t,...a,children:s})}function p({className:t,children:s,...a}){return e.jsx("tr",{className:t,...a,children:s})}function w({className:t,children:s,...a}){return e.jsx("th",{className:t,...a,children:s})}function d({className:t,children:s,...a}){return e.jsx("td",{className:t,...a,children:s})}function mt({status:t}){const s={FINISHED:"success",FAILED:"danger",KILLED:"gray",RUNNING:"warning",UNKNOWN:"gray"}[t];return e.jsx(ee,{variant:s,children:t})}function Js({createdAt:t,endedAt:s,status:a}){const n=!Ee(a),[l,o]=f.useState(Date.now());f.useEffect(()=>{if(!n)return;const h=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(h)},[n]);const i=ot(t,n?void 0:s),u=n?Math.max(0,Math.floor((l-new Date(t).getTime())/1e3)):i;return e.jsx("span",{className:n?"tabular-nums":void 0,children:dt(u)})}function Qe({runs:t,onDelete:s,loading:a,emptyHint:n,baselineRunId:l}){const[o,c]=f.useState(null),i=()=>{o&&s&&(s(o.run_id),c(null))};return t.length?e.jsxs(e.Fragment,{children:[e.jsxs(q,{children:[e.jsx(xe,{children:e.jsxs(p,{children:[e.jsx(w,{children:"Run ID"}),e.jsx(w,{children:"Name"}),e.jsx(w,{children:"Project"}),e.jsx(w,{children:"Status"}),e.jsx(w,{children:"Duration"}),e.jsx(w,{children:"Created"}),e.jsx(w,{children:"Actions"})]})}),e.jsx(U,{children:t.map(u=>e.jsxs(p,{children:[e.jsxs(d,{children:[e.jsx(L.Link,{to:`/runs/${u.run_id}`,className:"font-mono",children:ie(u.run_id)}),u.run_id===l&&e.jsx(ee,{variant:"info",className:"ml-2",children:"Baseline"})]}),e.jsx(d,{children:u.run_name||"—"}),e.jsx(d,{children:u.project}),e.jsx(d,{children:e.jsx(mt,{status:u.status})}),e.jsx(d,{className:"font-mono text-sm",children:e.jsx(Js,{createdAt:u.created_at,endedAt:u.ended_at,status:u.status})}),e.jsx(d,{className:"text-muted",children:Fe(u.created_at)}),e.jsx(d,{children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(L.Link,{to:`/runs/${u.run_id}`,children:e.jsx($,{variant:"secondary",size:"sm",children:"View"})}),s&&e.jsx($,{variant:"ghost-danger",size:"sm",onClick:()=>c(u),disabled:a,children:"Delete"})]})})]},u.run_id))})]}),e.jsxs(Je,{open:!!o,onClose:()=>c(null),title:"Delete Run",actions:e.jsxs(e.Fragment,{children:[e.jsx($,{variant:"secondary",onClick:()=>c(null),children:"Cancel"}),e.jsxs($,{variant:"danger",onClick:i,disabled:a,children:[a&&e.jsx(G,{}),"Delete"]})]}),children:[e.jsx("p",{children:"Are you sure you want to delete this run?"}),o&&e.jsx("p",{className:"font-mono text-sm mt-2",children:ie(o.run_id)}),e.jsx("p",{className:"text-sm text-danger mt-2",children:"This action cannot be undone."})]})]}):e.jsx(be,{message:"No runs found",hint:n??"Try adjusting your filters"})}function Zt(){const[t,s]=L.useSearchParams(),{api:a}=Y(),{data:n}=$e(),[l,o]=f.useState(null),[c,i]=f.useState({project:t.get("project")||"",status:t.get("status")||"",q:t.get("q")||"",limit:parseInt(t.get("limit")||"25",10)}),{data:u,loading:h,refetch:m}=ut(c),g=Se(v=>a.deleteRun(v));f.useEffect(()=>{if(l){const v=setTimeout(()=>o(null),3e3);return()=>clearTimeout(v)}},[l]);const y=f.useCallback((v,W)=>{i(A=>({...A,[v]:W}));const E=new URLSearchParams(t);W?E.set(v,String(W)):E.delete(v),s(E,{replace:!0})},[t,s]),D=f.useCallback(async v=>{try{await g.mutate(v),o({message:"Run deleted",variant:"success"}),m()}catch{o({message:"Failed to delete run",variant:"error"})}},[g,m]);return e.jsxs(X,{children:[e.jsx(ke,{title:"Runs"}),e.jsx(_,{className:"mb-4",children:e.jsxs(xt,{children:[e.jsxs(de,{children:[e.jsx(me,{htmlFor:"project",children:"Project"}),e.jsxs(ge,{id:"project",value:c.project,onChange:v=>y("project",v.target.value),children:[e.jsx("option",{value:"",children:"All projects"}),n?.map(v=>e.jsx("option",{value:v.name,children:v.name},v.name))]})]}),e.jsxs(de,{children:[e.jsx(me,{htmlFor:"status",children:"Status"}),e.jsxs(ge,{id:"status",value:c.status,onChange:v=>y("status",v.target.value),children:[e.jsx("option",{value:"",children:"All"}),e.jsx("option",{value:"FINISHED",children:"Finished"}),e.jsx("option",{value:"FAILED",children:"Failed"}),e.jsx("option",{value:"RUNNING",children:"Running"})]})]}),e.jsxs(de,{children:[e.jsx(me,{htmlFor:"q",children:"Query"}),e.jsx(Xe,{id:"q",value:c.q,onChange:v=>y("q",v.target.value),placeholder:"metric.fidelity > 0.9"})]}),e.jsxs(de,{children:[e.jsx(me,{htmlFor:"limit",children:"Limit"}),e.jsxs(ge,{id:"limit",value:c.limit,onChange:v=>y("limit",parseInt(v.target.value,10)),children:[e.jsx("option",{value:"25",children:"25"}),e.jsx("option",{value:"50",children:"50"}),e.jsx("option",{value:"100",children:"100"})]})]}),e.jsxs(de,{className:"flex items-end gap-2",children:[e.jsx($,{variant:"primary",onClick:()=>m(),children:"Filter"}),h&&e.jsx(G,{})]})]})}),e.jsx(_,{children:h&&!u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(G,{})}):e.jsx(Qe,{runs:u?.runs??[],onDelete:D,loading:g.loading,baselineRunId:c.project?n?.find(v=>v.name===c.project)?.baseline?.run_id:void 0})}),l&&e.jsx(Ce,{message:l.message,variant:l.variant,visible:!!l,onClose:()=>o(null)})]})}function es({projects:t,currentWorkspace:s}){if(!t.length)return e.jsx(be,{message:"No projects yet",hint:"Projects are created automatically when you log runs"});const a=n=>{const l=new URLSearchParams({project:n});return s&&l.set("workspace",s.id),`/runs?${l}`};return e.jsxs(q,{children:[e.jsx(xe,{children:e.jsxs(p,{children:[e.jsx(w,{children:"Project"}),e.jsx(w,{children:"Runs"}),e.jsx(w,{children:"Baseline"}),e.jsx(w,{})]})}),e.jsx(U,{children:t.map(n=>e.jsxs(p,{children:[e.jsxs(d,{children:[e.jsx("span",{className:"font-medium",children:n.name}),n.description&&e.jsx("p",{className:"text-muted text-sm",children:Ut(n.description)})]}),e.jsx(d,{children:e.jsx(ee,{variant:"gray",children:n.run_count??0})}),e.jsx(d,{children:n.baseline?e.jsxs(e.Fragment,{children:[e.jsx(L.Link,{to:`/runs/${n.baseline.run_id}`,className:"font-mono text-sm",children:ie(n.baseline.run_id)}),n.baseline.run_name&&e.jsx("p",{className:"text-muted text-sm",children:n.baseline.run_name})]}):e.jsx("span",{className:"text-muted",children:"—"})}),e.jsx(d,{className:"text-right",children:e.jsx(L.Link,{to:a(n.name),children:e.jsx($,{variant:"secondary",size:"sm",children:"View Runs"})})})]},n.name))})]})}function ts({groups:t}){return t.length?e.jsxs(q,{children:[e.jsx(xe,{children:e.jsxs(p,{children:[e.jsx(w,{children:"Group ID"}),e.jsx(w,{children:"Name"}),e.jsx(w,{children:"Project"}),e.jsx(w,{children:"Runs"}),e.jsx(w,{children:"Actions"})]})}),e.jsx(U,{children:t.map(s=>e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:ie(s.group_id)}),e.jsx(d,{children:s.group_name||"—"}),e.jsx(d,{children:s.project}),e.jsx(d,{children:e.jsx(ee,{variant:"gray",children:s.run_count})}),e.jsx(d,{children:e.jsx(L.Link,{to:`/groups/${s.group_id}`,children:e.jsx($,{variant:"secondary",size:"sm",children:"View Runs"})})})]},s.group_id))})]}):e.jsx(be,{message:"No groups found",hint:"Groups are created when runs have a group_id set"})}function ss({runId:t,runName:s,variant:a="secondary",size:n="sm",className:l=""}){const{api:o}=Y(),[c,i]=f.useState({status:"idle"}),[u,h]=f.useState(!1),[m,g]=f.useState(null),y=async()=>{i({status:"preparing",message:"Preparing bundle..."}),h(!0);try{const E=await o.createExport(t);i({status:"packing",message:"Creating bundle...",artifactCount:E.artifact_count,objectCount:E.object_count}),i(N=>({...N,status:"downloading",message:"Downloading bundle..."}));const A=o.getExportDownloadUrl(t),T=await fetch(A,{credentials:"same-origin"});if(!T.ok)throw new Error("Download failed");const ce=await T.blob(),le=s?`${s.replace(/[^a-zA-Z0-9_-]/g,"_")}_${t.slice(0,8)}.zip`:`run_${t.slice(0,8)}.zip`,te=URL.createObjectURL(ce),Q=document.createElement("a");Q.href=te,Q.download=le,document.body.appendChild(Q),Q.click(),document.body.removeChild(Q),URL.revokeObjectURL(te),i({status:"complete",message:"Export complete!",bundleSize:ce.size,artifactCount:E.artifact_count,objectCount:E.object_count})}catch(E){const A=E instanceof Error?E.message:"Export failed";i({status:"error",message:A}),g({message:A,variant:"error"})}},D=()=>{c.status!=="preparing"&&c.status!=="packing"&&c.status!=="downloading"&&(h(!1),i({status:"idle"}))},v=E=>E<1024?`${E} B`:E<1024*1024?`${(E/1024).toFixed(1)} KB`:`${(E/(1024*1024)).toFixed(1)} MB`,W=["preparing","packing","downloading"].includes(c.status);return e.jsxs(e.Fragment,{children:[e.jsxs($,{variant:a,size:n,onClick:y,disabled:W,className:l,children:[W&&e.jsx(G,{}),e.jsx(Xs,{}),"Export"]}),e.jsx(Je,{open:u,onClose:D,title:"Export Run",actions:c.status==="error"||c.status==="complete"?e.jsx($,{variant:"secondary",onClick:D,children:"Close"}):void 0,children:e.jsxs("div",{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[c.status==="error"?e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--dq-danger-bg)] flex items-center justify-center",children:e.jsx(Zs,{})}):c.status==="complete"?e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--dq-success-bg)] flex items-center justify-center",children:e.jsx(Qs,{})}):e.jsx("div",{className:"w-10 h-10 rounded-full bg-[var(--dq-primary-bg)] flex items-center justify-center",children:e.jsx(G,{})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:c.message}),c.status==="error"&&e.jsx("p",{className:"text-sm text-[var(--dq-text-muted)]",children:"Please try again or contact support."})]})]}),(c.artifactCount!==void 0||c.objectCount!==void 0||c.bundleSize!==void 0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 mt-4",children:[c.artifactCount!==void 0&&e.jsxs(ee,{variant:"gray",children:[c.artifactCount," artifacts"]}),c.objectCount!==void 0&&e.jsxs(ee,{variant:"gray",children:[c.objectCount," objects"]}),c.bundleSize!==void 0&&e.jsx(ee,{variant:"info",children:v(c.bundleSize)})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--dq-border-light)]",children:[e.jsxs("p",{className:"text-sm text-[var(--dq-text-muted)]",children:["Run ID: ",e.jsx("code",{className:"text-xs",children:t})]}),s&&e.jsxs("p",{className:"text-sm text-[var(--dq-text-muted)]",children:["Name: ",s]})]})]})}),m&&e.jsx(Ce,{message:m.message,variant:m.variant,visible:!!m,onClose:()=>g(null)})]})}function Xs(){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function Qs(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--dq-success)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})}function Zs(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--dq-danger)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}const F={top:12,right:16,bottom:28,left:56},ct=210,Ft=5,$t=["var(--dq-primary)","var(--dq-info)","var(--dq-warning)","var(--dq-danger)","#8B5CF6","#EC4899"];function er(t,s){const a=t/s,n=Math.pow(10,Math.floor(Math.log10(a))),l=a/n;return(l<1.5?1:l<3?2:l<7?5:10)*n}function Ot(t,s,a){if(t===s)return[t];const n=er(s-t,a),l=Math.floor(t/n)*n,o=[];for(let c=l;c<=s+n*.01;c+=n)o.push(c);return o}function tr(t){const s=Math.abs(t);return s===0?"0":s>=1e6?(t/1e6).toFixed(1)+"M":s>=1e3?(t/1e3).toFixed(1)+"k":s>=1?t.toFixed(s>=100?0:s>=10?1:2):t.toPrecision(3)}function sr(t,s){if(t.length<=s)return t;const a=t.length/s,n=[t[0]];for(let l=1;l<s-1;l++){const o=Math.floor(l*a),c=Math.min(Math.floor((l+1)*a),t.length);let i=t[o],u=t[o];for(let h=o;h<c;h++)t[h].value<i.value&&(i=t[h]),t[h].value>u.value&&(u=t[h]);i.step<=u.step?(n.push(i),i!==u&&n.push(u)):(n.push(u),i!==u&&n.push(i))}return n.push(t[t.length-1]),n}function rr(t){const[s,a]=f.useState(0);return f.useEffect(()=>{const n=t.current;if(!n)return;const l=new ResizeObserver(o=>{const c=o[0]?.contentRect.width;c&&c>0&&a(Math.floor(c))});return l.observe(n),a(Math.floor(n.getBoundingClientRect().width)||0),()=>l.disconnect()},[t]),s}function nr({x:t,y:s,value:a,step:n,chartWidth:l}){const c=`${a} step ${n}`.length*6.2+16,i=22,u=8;let h=s-i-u;h<2&&(h=s+u+4);let m=t-c/2;return m=Math.max(F.left,Math.min(m,l-F.right-c)),e.jsxs("g",{pointerEvents:"none",children:[e.jsx("rect",{x:m,y:h,width:c,height:i,rx:4,fill:"var(--dq-bg-primary)",stroke:"var(--dq-border-color)",strokeWidth:1}),e.jsxs("text",{x:m+8,y:h+i/2,dominantBaseline:"central",fontSize:11,className:"fill-[var(--dq-text-primary)]",fontFamily:"ui-monospace, monospace",children:[e.jsx("tspan",{children:a}),e.jsxs("tspan",{dx:8,className:"fill-[var(--dq-text-muted)]",children:["step ",n]})]})]})}function ar({metricKey:t,points:s,color:a}){const n=f.useRef(null),l=f.useRef(null),o=rr(n),[c,i]=f.useState(null),u=f.useMemo(()=>[...s].sort((N,V)=>N.step-V.step),[s]),h=o-F.left-F.right,m=ct-F.top-F.bottom,g=f.useMemo(()=>h>0?sr(u,h):u,[u,h]),{xMin:y,xMax:D,yMin:v,yMax:W}=f.useMemo(()=>{let N=1/0,V=-1/0;for(const K of u)K.value<N&&(N=K.value),K.value>V&&(V=K.value);const ue=(V-N)*.05||.1;return{xMin:u[0]?.step??0,xMax:u[u.length-1]?.step??1,yMin:N-ue,yMax:V+ue}},[u]),E=f.useCallback(N=>F.left+(N-y)/(D-y||1)*h,[y,D,h]),A=f.useCallback(N=>F.top+m-(N-v)/(W-v||1)*m,[v,W,m]),T=f.useMemo(()=>g.map((N,V)=>`${V===0?"M":"L"}${E(N.step).toFixed(1)},${A(N.value).toFixed(1)}`).join(" "),[g,E,A]),ce=f.useMemo(()=>Ot(v,W,Ft),[v,W]),le=f.useMemo(()=>Ot(y,D,Ft).map(Math.round),[y,D]),te=f.useCallback(N=>{const V=l.current?.getBoundingClientRect();if(!V||!u.length)return;const ue=N.clientX-V.left,K=y+(ue-F.left)/h*(D-y);let se=0,fe=u.length-1;for(;se<fe;){const oe=se+fe>>1;u[oe].step<K?se=oe+1:fe=oe}const ne=se>0&&Math.abs(u[se-1].step-K)<Math.abs(u[se].step-K)?se-1:se,re=u[ne];i({x:E(re.step),y:A(re.value),pt:re})},[u,y,D,h,E,A]),Q=u[u.length-1];return o<100?e.jsx("div",{ref:n,className:"metric-chart"}):e.jsxs("div",{ref:n,className:"metric-chart",children:[e.jsxs("div",{className:"metric-chart-header",children:[e.jsx("span",{className:"metric-chart-label",style:{color:a},children:t}),Q&&e.jsxs("span",{className:"metric-chart-latest",children:["latest: ",He(Q.value)," @ step ",Q.step]})]}),e.jsxs("svg",{ref:l,width:o,height:ct,className:"metric-chart-svg",onMouseMove:te,onMouseLeave:()=>i(null),children:[ce.map(N=>e.jsx("line",{x1:F.left,x2:o-F.right,y1:A(N),y2:A(N),stroke:"var(--dq-border-color)",strokeWidth:.5,strokeDasharray:"3,3"},`gy-${N}`)),le.map(N=>e.jsx("line",{x1:E(N),x2:E(N),y1:F.top,y2:F.top+m,stroke:"var(--dq-border-color)",strokeWidth:.5,strokeDasharray:"3,3"},`gx-${N}`)),e.jsx("line",{x1:F.left,y1:F.top,x2:F.left,y2:F.top+m,stroke:"var(--dq-border-color)",strokeWidth:1}),e.jsx("line",{x1:F.left,y1:F.top+m,x2:o-F.right,y2:F.top+m,stroke:"var(--dq-border-color)",strokeWidth:1}),ce.map(N=>e.jsx("text",{x:F.left-6,y:A(N),textAnchor:"end",dominantBaseline:"middle",className:"fill-[var(--dq-text-muted)]",fontSize:10,children:tr(N)},N)),le.map(N=>e.jsx("text",{x:E(N),y:ct-4,textAnchor:"middle",className:"fill-[var(--dq-text-muted)]",fontSize:10,children:N},N)),e.jsx("path",{d:T,fill:"none",stroke:a,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}),c&&e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:c.x,x2:c.x,y1:F.top,y2:F.top+m,stroke:"var(--dq-text-muted)",strokeWidth:1,strokeDasharray:"3,3",opacity:.4}),e.jsx("circle",{cx:c.x,cy:c.y,r:3.5,fill:a}),e.jsx(nr,{x:c.x,y:c.y,value:He(c.pt.value),step:c.pt.step,chartWidth:o})]})]})]})}const Ge=6;function ir({series:t}){const s=Object.keys(t).sort(),[a,n]=f.useState(0);if(!s.length)return null;const l=Math.ceil(s.length/Ge),o=s.slice(a*Ge,(a+1)*Ge);return e.jsxs("div",{children:[e.jsx("div",{className:"metric-charts-grid",children:o.map((c,i)=>e.jsx(ar,{metricKey:c,points:t[c],color:$t[(a*Ge+i)%$t.length]},c))}),l>1&&e.jsxs("div",{className:"metric-charts-pagination",children:[e.jsx("button",{className:"metric-charts-page-btn",onClick:()=>n(c=>c-1),disabled:a===0,children:"‹ Prev"}),e.jsxs("span",{className:"metric-charts-page-info",children:[a+1," / ",l]}),e.jsx("button",{className:"metric-charts-page-btn",onClick:()=>n(c=>c+1),disabled:a>=l-1,children:"Next ›"})]})]})}function cr({createdAt:t,endedAt:s,status:a}){const n=!Ee(a),[l,o]=f.useState(Date.now());f.useEffect(()=>{if(!n)return;const i=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(i)},[n]);const c=n?Math.max(0,Math.floor((l-new Date(t).getTime())/1e3)):ot(t,s);return e.jsx("span",{className:n?"tabular-nums":void 0,children:dt(c)})}function rs(){const{runId:t}=L.useParams(),s=L.useNavigate(),{api:a}=Y(),{data:n,loading:l,error:o,refetch:c}=ht(t),{data:i,refetch:u}=$e(),h=n?!Ee(n.status):!1,{data:m}=zs(t,h),[g,y]=f.useState(!1),[D,v]=f.useState(null),{mutate:W,loading:E}=Se(()=>a.setBaseline(n.project,n.run_id)),{mutate:A,loading:T}=Se(()=>a.deleteRun(t)),le=i?.find(C=>C.name===n?.project)?.baseline?.run_id===t;if(f.useEffect(()=>{if(D){const C=setTimeout(()=>v(null),3e3);return()=>clearTimeout(C)}},[D]),l)return e.jsx(X,{children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(G,{})})});if(o||!n)return e.jsx(X,{children:e.jsx(_,{children:e.jsx(be,{message:"Run not found",hint:o?.message||`Run ${t} does not exist`})})});const te=n.backend||{},Q=n.fingerprints||{},N=n.data?.params||{},V=n.data?.metrics||{},ue=n.data?.tags||{},K=n.artifacts||[],se=n.errors||[],fe=async()=>{try{await W(),await u(),c(),v({message:"Baseline updated",variant:"success"})}catch{v({message:"Failed to set baseline",variant:"error"})}},ne=async()=>{try{await A(),y(!1),v({message:"Run deleted",variant:"success"}),setTimeout(()=>s("/runs"),1e3)}catch{v({message:"Failed to delete run",variant:"error"}),y(!1)}},re=async C=>{const B=K[C];try{const je=a.getArtifactDownloadUrl(n.run_id,C),he=await fetch(je);if(!he.ok){const Me={404:"Artifact not found",403:"Permission denied"};throw new Error(Me[he.status]??(he.status>=500?"Server error":`Download failed (${he.status})`))}const Oe=await he.blob(),ye=document.createElement("a");ye.href=URL.createObjectURL(Oe),ye.download=B?.kind||`artifact-${C}`,ye.click(),URL.revokeObjectURL(ye.href),v({message:"Download complete",variant:"success"})}catch(je){const he=je instanceof Error&&je.message?je.message:"Download failed";v({message:he,variant:"error"})}},oe=[{label:"Project",value:e.jsx(L.Link,{to:`/runs?project=${n.project}`,children:n.project})},{label:"Name",value:n.run_name||"—"},{label:"Adapter",value:n.adapter||"N/A"},{label:"Status",value:e.jsx(mt,{status:n.status})},{label:"Created",value:`${n.created_at} (${Fe(n.created_at)})`},{label:"Duration",value:e.jsx(cr,{createdAt:n.created_at,endedAt:n.ended_at,status:n.status})},...n.ended_at?[{label:"Ended",value:`${n.ended_at} (${Fe(n.ended_at)})`}]:[],{label:"Backend",value:te.name||"N/A"},...n.group_id?[{label:"Group",value:e.jsx(L.Link,{to:`/groups/${n.group_id}`,children:n.group_name||ie(n.group_id)})}]:[]];return e.jsxs(X,{children:[le&&e.jsxs("div",{className:"mb-4 px-4 py-3 bg-[#EFF6FF] border border-[#2563EB]/20 rounded-md text-[#2563EB] text-sm font-medium",children:['This run is the current baseline for project "',n.project,'"']}),e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",children:n.run_name||"Unnamed Run"}),e.jsx("p",{className:"text-muted text-sm font-mono",children:n.run_id})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ss,{runId:n.run_id,runName:n.run_name}),!le&&e.jsxs($,{variant:"secondary",size:"sm",onClick:fe,disabled:E,children:[E&&e.jsx(G,{}),"Set as Baseline"]}),e.jsx($,{variant:"ghost-danger",size:"sm",onClick:()=>y(!0),children:"Delete"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[e.jsxs(_,{children:[e.jsx(z,{children:e.jsx(H,{children:"Overview"})}),e.jsx(Ye,{items:oe})]}),e.jsxs(_,{children:[e.jsx(z,{children:e.jsx(H,{children:"Fingerprints"})}),e.jsx(Ye,{items:[{label:"Run",value:e.jsx("span",{className:"font-mono text-sm truncate",children:Q.run||"N/A"})},{label:"Program",value:e.jsx("span",{className:"font-mono text-sm truncate",children:Q.program||"N/A"})}]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[e.jsxs(_,{children:[e.jsx(z,{children:e.jsx(H,{children:"Parameters"})}),Object.keys(N).length?e.jsx(q,{children:e.jsx(U,{children:Object.entries(N).map(([C,B])=>e.jsxs(p,{children:[e.jsx(d,{children:C}),e.jsx(d,{className:"font-mono",children:String(B)})]},C))})}):e.jsx("p",{className:"text-muted",children:"No parameters"})]}),e.jsxs(_,{children:[e.jsx(z,{children:e.jsx(H,{children:"Metrics"})}),Object.keys(V).length?e.jsx(q,{children:e.jsx(U,{children:Object.entries(V).map(([C,B])=>e.jsxs(p,{children:[e.jsx(d,{children:C}),e.jsx(d,{className:"font-mono",children:typeof B=="number"?He(B):String(B)})]},C))})}):e.jsx("p",{className:"text-muted",children:"No metrics"})]}),e.jsxs(_,{children:[e.jsx(z,{children:e.jsx(H,{children:"Tags"})}),Object.keys(ue).length?e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(ue).map(([C,B])=>e.jsxs(ee,{variant:"gray",children:[C,": ",String(B)]},C))}):e.jsx("p",{className:"text-muted",children:"No tags"})]})]}),m&&e.jsxs(_,{className:"mb-4",children:[e.jsx(z,{children:e.jsx(H,{children:"Metric History"})}),e.jsx("div",{className:"p-4",children:e.jsx(ir,{series:m})})]}),e.jsxs(_,{className:"mb-4",children:[e.jsx(z,{children:e.jsxs(H,{children:["Artifacts (",K.length,")"]})}),K.length?e.jsxs(q,{children:[e.jsx(xe,{children:e.jsxs(p,{children:[e.jsx(w,{children:"#"}),e.jsx(w,{children:"Kind"}),e.jsx(w,{children:"Role"}),e.jsx(w,{children:"Media Type"}),e.jsx(w,{children:"Digest"}),e.jsx(w,{children:"Actions"})]})}),e.jsx(U,{children:K.map((C,B)=>e.jsxs(p,{children:[e.jsx(d,{children:B}),e.jsx(d,{className:"font-mono text-sm",children:C.kind}),e.jsx(d,{children:e.jsx(ee,{variant:"gray",children:C.role})}),e.jsx(d,{className:"text-muted text-sm",children:C.media_type}),e.jsx(d,{className:"font-mono text-sm",children:ze(C.digest)}),e.jsx(d,{children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(L.Link,{to:`/runs/${n.run_id}/artifacts/${B}`,children:e.jsx($,{variant:"secondary",size:"sm",children:"View"})}),e.jsx($,{variant:"secondary",size:"sm",onClick:()=>re(B),children:"Download"})]})})]},B))})]}):e.jsx("p",{className:"text-muted",children:"No artifacts"})]}),se.length>0&&e.jsxs(_,{children:[e.jsx(z,{children:e.jsx(H,{className:"text-danger",children:"Errors"})}),se.map((C,B)=>e.jsxs("div",{className:"mb-2",children:[e.jsx("strong",{children:C.type}),": ",C.message,C.traceback&&e.jsx("pre",{className:"mt-2",children:C.traceback})]},B))]}),e.jsxs(Je,{open:g,onClose:()=>y(!1),title:"Delete Run",actions:e.jsxs(e.Fragment,{children:[e.jsx($,{variant:"secondary",onClick:()=>y(!1),children:"Cancel"}),e.jsxs($,{variant:"danger",onClick:ne,disabled:T,children:[T&&e.jsx(G,{}),"Delete"]})]}),children:[e.jsx("p",{children:"Are you sure you want to delete this run?"}),e.jsx("p",{className:"font-mono text-sm mt-2",children:ie(n.run_id)}),e.jsx("p",{className:"text-sm text-danger mt-2",children:"This action cannot be undone."})]}),D&&e.jsx(Ce,{message:D.message,variant:D.variant,visible:!!D,onClose:()=>v(null)})]})}function ns(){const{currentWorkspace:t}=Y(),{data:s,loading:a}=$e();return e.jsxs(X,{children:[e.jsx(ke,{title:"Projects"}),e.jsx(_,{children:a?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(G,{})}):e.jsx(es,{projects:s??[],currentWorkspace:t})})]})}function as(){const[t,s]=L.useSearchParams(),{data:a}=$e(),[n,l]=f.useState(t.get("project")||""),{data:o,loading:c,refetch:i}=Ht({project:n||void 0}),u=f.useCallback(h=>{l(h);const m=new URLSearchParams(t);h?m.set("project",h):m.delete("project"),s(m,{replace:!0})},[t,s]);return e.jsxs(X,{children:[e.jsx(ke,{title:"Run Groups"}),e.jsx(_,{className:"mb-4",children:e.jsxs(xt,{children:[e.jsxs(de,{children:[e.jsx(me,{htmlFor:"project",children:"Project"}),e.jsxs(ge,{id:"project",value:n,onChange:h=>u(h.target.value),children:[e.jsx("option",{value:"",children:"All projects"}),a?.map(h=>e.jsx("option",{value:h.name,children:h.name},h.name))]})]}),e.jsxs(de,{className:"flex items-end gap-2",children:[e.jsx($,{variant:"primary",onClick:()=>i(),children:"Filter"}),c&&e.jsx(G,{})]})]})}),e.jsx(_,{children:c&&!o?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(G,{})}):e.jsx(ts,{groups:o??[]})})]})}function is(){const{groupId:t}=L.useParams(),{api:s}=Y(),{data:a,loading:n,error:l,refetch:o}=Yt(t),[c,i]=f.useState(null),u=Se(m=>s.deleteRun(m));f.useEffect(()=>{if(c){const m=setTimeout(()=>i(null),3e3);return()=>clearTimeout(m)}},[c]);const h=async m=>{try{await u.mutate(m),i({message:"Run deleted",variant:"success"}),o()}catch{i({message:"Failed to delete run",variant:"error"})}};return n?e.jsx(X,{children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(G,{})})}):l||!a?e.jsx(X,{children:e.jsx(_,{children:e.jsx(be,{message:"Group not found",hint:l?.message})})}):e.jsxs(X,{children:[e.jsx(ke,{title:e.jsxs(e.Fragment,{children:["Group ",e.jsx("span",{className:"font-mono",children:ie(t)})]}),subtitle:e.jsx("span",{className:"font-mono text-muted",children:t})}),e.jsxs(_,{children:[e.jsx(z,{children:e.jsxs(H,{children:["Runs in Group (",a.runs.length,")"]})}),e.jsx(Qe,{runs:a.runs,onDelete:h,loading:u.loading})]}),c&&e.jsx(Ce,{message:c.message,variant:c.variant,visible:!!c,onClose:()=>i(null)})]})}function lr({className:t=""}){return e.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})}function or({className:t=""}){return e.jsxs("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function dr({className:t=""}){return e.jsxs("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}function lt({className:t=""}){return e.jsxs("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}function Ae({match:t}){return t?e.jsxs("span",{className:"diff-match inline-flex items-center gap-1.5",children:[e.jsx(lr,{className:"flex-shrink-0"}),e.jsx("span",{className:"font-medium",children:"Match"})]}):e.jsxs("span",{className:"diff-mismatch inline-flex items-center gap-1.5",children:[e.jsx(or,{className:"flex-shrink-0"}),e.jsx("span",{className:"font-medium",children:"Different"})]})}function ur({warnings:t}){return!t||t.length===0?null:e.jsx("div",{className:"alert alert-warning mb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(dr,{className:"flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold mb-1",children:t.length===1?"Warning":`${t.length} Warnings`}),e.jsx("ul",{className:"space-y-1",children:t.map((s,a)=>e.jsx("li",{className:"text-sm",children:s},a))})]})]})})}function Mt({label:t,run:s,variant:a}){return e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:`absolute top-0 left-0 w-1 h-full rounded-l ${a==="a"?"bg-info":"bg-primary"}`}),e.jsxs("div",{className:"pl-4",children:[e.jsx("p",{className:`text-xs font-semibold uppercase tracking-wider mb-2 ${a==="a"?"text-info":"text-primary"}`,children:t}),e.jsx(L.Link,{to:`/runs/${s.run_id}`,className:"text-base font-medium hover:underline",children:s.run_name||"Unnamed Run"}),e.jsx("p",{className:"font-mono text-xs mt-1 text-muted",children:ie(s.run_id)}),e.jsxs("p",{className:"text-sm mt-1 text-muted",children:[s.project," · ",Fe(s.created_at)]})]})]})}function pe({children:t,badge:s}){return e.jsx(z,{children:e.jsx(H,{children:e.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[t,s&&e.jsx(ee,{variant:s.variant,children:s.label})]})})})}function hr({tvd:t,noiseContext:s}){if(t===0)return e.jsx("p",{className:"text-sm mt-4 text-success",children:"✓ Distributions are identical (TVD = 0)"});if(!s)return null;const{p_value:a,noise_ratio:n}=s;return a!=null?a>=.1?e.jsx("p",{className:"text-sm mt-4 text-success",children:"✓ Consistent with sampling noise — difference is not statistically significant"}):a>=.05?e.jsxs("p",{className:"text-sm mt-4 text-warning",children:["⚠ Borderline (p=",a.toFixed(2),") — consider increasing shots"]}):e.jsxs("p",{className:"text-sm mt-4 text-danger",children:["✗ Statistically significant difference (p=",a.toFixed(2),") — results show meaningful divergence"]}):n!=null?n<1.5?e.jsx("p",{className:"text-sm mt-4 text-success",children:"✓ TVD is within expected shot noise range"}):n<3?e.jsxs("p",{className:"text-sm mt-4 text-warning",children:["⚠ Ambiguous (",n.toFixed(1),"× expected noise) — consider increasing shots"]}):e.jsxs("p",{className:"text-sm mt-4 text-danger",children:["✗ TVD exceeds expected noise (",n.toFixed(1),"×) — results show meaningful differences"]}):null}function xr(){const[t,s]=L.useSearchParams(),{data:a}=ut({limit:100}),n=a?.runs??[],[l,o]=f.useState(t.get("a")||""),[c,i]=f.useState(t.get("b")||""),[u,h]=f.useState(""),m=g=>{if(g.preventDefault(),!l||!c){h("Please select both runs to compare");return}if(l===c){h("Please select two different runs");return}h(""),s({a:l,b:c})};return e.jsxs(e.Fragment,{children:[e.jsx(_,{children:e.jsxs("form",{onSubmit:m,children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[e.jsxs(de,{children:[e.jsx(me,{htmlFor:"a",children:"Run A (Baseline)"}),e.jsxs(ge,{id:"a",value:l,onChange:g=>{o(g.target.value),h("")},children:[e.jsx("option",{value:"",children:"Select run..."}),n.map(g=>e.jsxs("option",{value:g.run_id,children:[g.run_name||"Unnamed"," (",ie(g.run_id),") — ",g.project]},g.run_id))]})]}),e.jsxs(de,{children:[e.jsx(me,{htmlFor:"b",children:"Run B (Candidate)"}),e.jsxs(ge,{id:"b",value:c,onChange:g=>{i(g.target.value),h("")},children:[e.jsx("option",{value:"",children:"Select run..."}),n.map(g=>e.jsxs("option",{value:g.run_id,children:[g.run_name||"Unnamed"," (",ie(g.run_id),") — ",g.project]},g.run_id))]})]})]}),u&&e.jsx("p",{className:"text-sm mb-3 text-danger",children:u}),e.jsx($,{type:"submit",variant:"primary",children:"Compare"})]})}),e.jsxs(_,{className:"mt-4",children:[e.jsx(z,{children:e.jsx(H,{children:"How it works"})}),e.jsxs("div",{className:"space-y-2 text-sm text-muted",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(lt,{className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{children:"Select two runs to compare their parameters, metrics, and artifacts"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(lt,{className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{children:"The diff shows changed values and computes TVD for result distributions"})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(lt,{className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{children:"You can also compare from the run detail page"})]})]})]})]})}function mr({runIdA:t,runIdB:s}){const{data:a,loading:n,error:l}=Kt(t,s);if(n)return e.jsx(_,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-3",children:[e.jsx(G,{}),e.jsx("p",{className:"text-sm text-muted",children:"Comparing runs..."})]})});if(l||!a)return e.jsx(_,{children:e.jsx(be,{message:"Failed to load diff",hint:l?.message})});const{run_a:o,run_b:c,report:i}=a,u=i.device_drift?.significant_drift?{variant:"warning",label:"Drift Detected"}:i.device_drift?.has_calibration_data?{variant:"success",label:"Stable"}:{variant:"gray",label:"No Data"};return e.jsxs(e.Fragment,{children:[e.jsx(ur,{warnings:i.warnings||[]}),e.jsx(_,{className:"mb-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsx(Mt,{label:"Run A (Baseline)",run:o,variant:"a"}),e.jsx(Mt,{label:"Run B (Candidate)",run:c,variant:"b"})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[e.jsxs(_,{children:[e.jsx(pe,{children:"Metadata"}),e.jsx(q,{children:e.jsxs(U,{children:[e.jsxs(p,{children:[e.jsx(d,{children:"Project"}),e.jsx(d,{children:e.jsx(Ae,{match:i.metadata.project_match})})]}),e.jsxs(p,{children:[e.jsx(d,{children:"Backend"}),e.jsx(d,{children:e.jsx(Ae,{match:i.metadata.backend_match})})]}),!i.metadata.project_match&&e.jsxs(e.Fragment,{children:[e.jsxs(p,{children:[e.jsx(d,{className:"text-sm text-muted",children:"Project A"}),e.jsx(d,{className:"font-mono text-sm",children:i.metadata.project_a||"N/A"})]}),e.jsxs(p,{children:[e.jsx(d,{className:"text-sm text-muted",children:"Project B"}),e.jsx(d,{className:"font-mono text-sm",children:i.metadata.project_b||"N/A"})]})]}),!i.metadata.backend_match&&e.jsxs(e.Fragment,{children:[e.jsxs(p,{children:[e.jsx(d,{className:"text-sm text-muted",children:"Backend A"}),e.jsx(d,{className:"font-mono text-sm",children:i.metadata.backend_a||"N/A"})]}),e.jsxs(p,{children:[e.jsx(d,{className:"text-sm text-muted",children:"Backend B"}),e.jsx(d,{className:"font-mono text-sm",children:i.metadata.backend_b||"N/A"})]})]})]})})]}),e.jsxs(_,{children:[e.jsx(pe,{children:"Fingerprints"}),e.jsx(q,{children:e.jsxs(U,{children:[e.jsxs(p,{children:[e.jsx(d,{children:"Run A"}),e.jsx(d,{className:"font-mono text-sm",children:ze(i.fingerprints.a)})]}),e.jsxs(p,{children:[e.jsx(d,{children:"Run B"}),e.jsx(d,{className:"font-mono text-sm",children:ze(i.fingerprints.b)})]}),e.jsxs(p,{children:[e.jsx(d,{children:"Match"}),e.jsx(d,{children:e.jsx(Ae,{match:i.fingerprints.a===i.fingerprints.b})})]})]})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[e.jsxs(_,{children:[e.jsx(pe,{badge:{variant:i.program.exact_match?"success":i.program.structural_match?"info":"warning",label:i.program.exact_match?"Exact Match":i.program.structural_match?"Structural Match":"Different"},children:"Program"}),e.jsx(q,{children:e.jsxs(U,{children:[e.jsxs(p,{children:[e.jsx(d,{children:"Exact Match"}),e.jsx(d,{children:e.jsx(Ae,{match:i.program.exact_match})})]}),e.jsxs(p,{children:[e.jsx(d,{children:"Structural Match"}),e.jsx(d,{children:e.jsx(Ae,{match:i.program.structural_match})})]})]})})]}),e.jsxs(_,{children:[e.jsx(pe,{badge:u,children:"Device Calibration"}),i.device_drift?.significant_drift?e.jsx("p",{className:"text-sm text-warning",children:"Significant calibration drift detected between runs"}):i.device_drift?.has_calibration_data?e.jsx("p",{className:"text-muted",children:"Calibration within acceptable thresholds"}):e.jsx("p",{className:"text-muted",children:"No calibration data available"})]})]}),e.jsxs(_,{className:"mb-4",children:[e.jsx(pe,{badge:{variant:i.params.match?"success":"warning",label:i.params.match?"Match":"Different"},children:"Parameters"}),i.params.match?e.jsx("p",{className:"text-muted",children:"All parameters match"}):e.jsx(e.Fragment,{children:i.params.changed&&Object.keys(i.params.changed).length>0&&e.jsxs(q,{children:[e.jsx(xe,{children:e.jsxs(p,{children:[e.jsx(w,{children:"Parameter"}),e.jsx(w,{children:"Run A"}),e.jsx(w,{children:"Run B"})]})}),e.jsx(U,{children:Object.entries(i.params.changed).map(([h,m])=>e.jsxs(p,{children:[e.jsx(d,{children:h}),e.jsx(d,{className:"font-mono",children:String(m.a)}),e.jsx(d,{className:"font-mono",children:String(m.b)})]},h))})]})})]}),e.jsxs(_,{className:"mb-4",children:[e.jsx(pe,{badge:{variant:i.metrics.match?"success":"warning",label:i.metrics.match?"Match":"Different"},children:"Metrics"}),i.metrics.match?e.jsx("p",{className:"text-muted",children:"All metrics match"}):e.jsx(e.Fragment,{children:i.metrics.changed&&Object.keys(i.metrics.changed).length>0&&e.jsxs(q,{children:[e.jsx(xe,{children:e.jsxs(p,{children:[e.jsx(w,{children:"Metric"}),e.jsx(w,{children:"Run A"}),e.jsx(w,{children:"Run B"})]})}),e.jsx(U,{children:Object.entries(i.metrics.changed).map(([h,m])=>e.jsxs(p,{children:[e.jsx(d,{children:h}),e.jsx(d,{className:"font-mono",children:m.a}),e.jsx(d,{className:"font-mono",children:m.b})]},h))})]})})]}),i.circuit_diff&&e.jsxs(_,{className:"mb-4",children:[e.jsx(pe,{badge:{variant:i.circuit_diff.match?"success":"warning",label:i.circuit_diff.match?"Match":"Different"},children:"Circuit"}),i.circuit_diff.match?e.jsx("p",{className:"text-muted",children:"Circuit structure matches"}):e.jsxs("div",{className:"space-y-4",children:[i.circuit_diff.changed&&Object.keys(i.circuit_diff.changed).length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2 text-muted",children:"Changed Properties"}),e.jsxs(q,{children:[e.jsx(xe,{children:e.jsxs(p,{children:[e.jsx(w,{children:"Property"}),e.jsx(w,{children:"Run A"}),e.jsx(w,{children:"Run B"}),e.jsx(w,{children:"Delta"})]})}),e.jsx(U,{children:Object.entries(i.circuit_diff.changed).map(([h,m])=>e.jsxs(p,{children:[e.jsx(d,{children:m.label||h}),e.jsx(d,{className:"font-mono",children:String(m.a)}),e.jsx(d,{className:"font-mono",children:String(m.b)}),e.jsx(d,{className:"font-mono",children:m.delta!=null&&e.jsxs("span",{className:m.delta>0?"text-danger":"text-success",children:[m.delta>0?"+":"",m.delta,m.pct!=null&&` (${m.pct>0?"+":""}${m.pct.toFixed(1)}%)`]})})]},h))})]})]}),i.circuit_diff.is_clifford_changed&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2 text-muted",children:"Clifford Status"}),e.jsx(q,{children:e.jsxs(U,{children:[e.jsxs(p,{children:[e.jsx(d,{children:"Run A"}),e.jsx(d,{className:"font-mono",children:i.circuit_diff.is_clifford_a!=null?String(i.circuit_diff.is_clifford_a):"unknown"})]}),e.jsxs(p,{children:[e.jsx(d,{children:"Run B"}),e.jsx(d,{className:"font-mono",children:i.circuit_diff.is_clifford_b!=null?String(i.circuit_diff.is_clifford_b):"unknown"})]})]})})]}),i.circuit_diff.added_gates&&i.circuit_diff.added_gates.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2 text-muted",children:"New Gate Types (in B)"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.circuit_diff.added_gates.map(h=>e.jsx(ee,{variant:"success",children:h},h))})]}),i.circuit_diff.removed_gates&&i.circuit_diff.removed_gates.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2 text-muted",children:"Removed Gate Types (from A)"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.circuit_diff.removed_gates.map(h=>e.jsx(ee,{variant:"danger",children:h},h))})]})]})]}),i.tvd!=null&&e.jsxs(_,{className:"mb-4",children:[e.jsx(pe,{children:"Results Distribution"}),e.jsx(q,{children:e.jsxs(U,{children:[e.jsxs(p,{children:[e.jsx(d,{children:"Total Variation Distance (TVD)"}),e.jsx(d,{className:"font-mono font-medium",children:i.tvd.toFixed(6)})]}),i.shots&&e.jsxs(p,{children:[e.jsx(d,{children:"Total Shots (A / B)"}),e.jsxs(d,{className:"font-mono",children:[i.shots.a," / ",i.shots.b]})]}),i.noise_context?.noise_p95&&e.jsxs(p,{children:[e.jsx(d,{children:"Noise Threshold (p95)"}),e.jsx(d,{className:"font-mono",children:i.noise_context.noise_p95.toFixed(6)})]}),i.noise_context?.p_value!=null&&e.jsxs(p,{children:[e.jsx(d,{children:"p-value"}),e.jsx(d,{className:"font-mono",children:i.noise_context.p_value.toFixed(4)})]})]})}),e.jsx(hr,{tvd:i.tvd,noiseContext:i.noise_context})]})]})}function cs(){const[t]=L.useSearchParams(),s=t.get("a"),a=t.get("b"),n=s&&a;return e.jsxs(X,{children:[e.jsx("div",{className:"page-header",children:e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",children:"Compare Runs"}),n&&e.jsx("p",{className:"text-sm mt-1 text-muted",children:e.jsx(L.Link,{to:"/diff",children:"← Select different runs"})})]})}),n?e.jsx(mr,{runIdA:s,runIdB:a}):e.jsx(xr,{})]})}function ls(){const{api:t}=Y(),[s,a]=f.useState(""),[n,l]=f.useState(null),[o,c]=f.useState(!1),[i,u]=f.useState(""),{mutate:h,loading:m}=Se(async()=>{const y=await t.listRuns({q:s,limit:100});return l(y.runs),c(!0),y}),g=y=>{if(y.preventDefault(),!s.trim()){u("Please enter a search query");return}u(""),h()};return e.jsxs(X,{children:[e.jsx("div",{className:"page-header",children:e.jsx("h1",{className:"page-title",children:"Search Runs"})}),e.jsx(_,{className:"mb-4",children:e.jsxs("form",{onSubmit:g,children:[e.jsxs(de,{children:[e.jsx(me,{htmlFor:"q",children:"Query"}),e.jsx(Xe,{id:"q",type:"text",value:s,onChange:y=>{a(y.target.value),u("")},placeholder:"metric.fidelity > 0.95 and params.shots = 1000",className:"font-mono"})]}),i&&e.jsx("p",{className:"text-sm text-[#DC4A4A] mb-3",children:i}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs($,{type:"submit",variant:"primary",disabled:m,children:[m&&e.jsx(G,{}),"Search"]}),m&&e.jsx("span",{className:"text-muted text-sm",children:"Searching..."})]})]})}),o&&n&&e.jsx(_,{className:"mb-4",children:n.length>0?e.jsx(Qe,{runs:n}):e.jsx("p",{className:"text-muted text-center py-8",children:"No runs match your query"})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(_,{children:[e.jsx(z,{children:e.jsx(H,{children:"Query Syntax"})}),e.jsxs(q,{children:[e.jsx(xe,{children:e.jsxs(p,{children:[e.jsx(w,{children:"Field"}),e.jsx(w,{children:"Description"})]})}),e.jsxs(U,{children:[e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:"params.X"}),e.jsx(d,{children:"Parameter value"})]}),e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:"metric.X"}),e.jsx(d,{children:"Metric value"})]}),e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:"tags.X"}),e.jsx(d,{children:"Tag value"})]}),e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:"status"}),e.jsx(d,{children:"Run status"})]}),e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:"project"}),e.jsx(d,{children:"Project name"})]}),e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:"backend"}),e.jsx(d,{children:"Backend name"})]})]})]})]}),e.jsxs(_,{children:[e.jsx(z,{children:e.jsx(H,{children:"Operators"})}),e.jsxs(q,{children:[e.jsx(xe,{children:e.jsxs(p,{children:[e.jsx(w,{children:"Operator"}),e.jsx(w,{children:"Description"})]})}),e.jsxs(U,{children:[e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:"="}),e.jsx(d,{children:"Equals"})]}),e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:"!="}),e.jsx(d,{children:"Not equals"})]}),e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:">"}),e.jsx(d,{children:"Greater than"})]}),e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:">="}),e.jsx(d,{children:"Greater or equal"})]}),e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:"<"}),e.jsx(d,{children:"Less than"})]}),e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:"<="}),e.jsx(d,{children:"Less or equal"})]}),e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:"~"}),e.jsx(d,{children:"Contains"})]}),e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:"and"}),e.jsx(d,{children:"Combine conditions"})]})]})]})]})]}),e.jsxs(_,{className:"mt-4",children:[e.jsx(z,{children:e.jsx(H,{children:"Examples"})}),e.jsx(q,{children:e.jsxs(U,{children:[e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:"metric.fidelity > 0.95"}),e.jsx(d,{children:"High fidelity runs"})]}),e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:"params.shots = 1000 and status = FINISHED"}),e.jsx(d,{children:"Finished runs with 1000 shots"})]}),e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:"tags.backend ~ ibm"}),e.jsx(d,{children:"Runs with IBM backends"})]}),e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:"metric.error < 0.01"}),e.jsx(d,{children:"Low error runs"})]}),e.jsxs(p,{children:[e.jsx(d,{className:"font-mono",children:"project = vqe and metric.energy < -2.0"}),e.jsx(d,{children:"VQE runs with low energy"})]})]})})]})]})}function os(){const{runId:t,index:s}=L.useParams(),a=parseInt(s,10),{api:n}=Y(),{data:l}=ht(t),{data:o,loading:c,error:i}=Jt(t,a),[u,h]=f.useState(null);f.useEffect(()=>{if(u){const T=setTimeout(()=>h(null),3e3);return()=>clearTimeout(T)}},[u]);const m=async()=>{try{const T=n.getArtifactDownloadUrl(t,a),ce=await fetch(T);if(!ce.ok)throw new Error("Download failed");const le=await ce.blob(),te=document.createElement("a");te.href=URL.createObjectURL(le),te.download=g?.kind||`artifact-${a}`,te.click(),URL.revokeObjectURL(te.href),h({message:"Download complete",variant:"success"})}catch{h({message:"Download failed",variant:"error"})}};if(c)return e.jsx(X,{children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(G,{})})});if(i||!o)return e.jsx(X,{children:e.jsx(_,{children:e.jsx(be,{message:"Artifact not found",hint:i?.message})})});const{artifact:g,size:y,content:D,content_json:v,preview_available:W,error:E}=o,A=10*1024*1024;return e.jsxs(X,{children:[e.jsx(ke,{title:g.kind,subtitle:e.jsxs(e.Fragment,{children:["← Back to run ",e.jsxs(L.Link,{to:`/runs/${t}`,children:[ie(t),l?.run_name&&` — ${l.run_name}`]})]}),actions:e.jsx($,{variant:"primary",onClick:m,children:"Download"})}),e.jsx(_,{className:"mb-4",children:e.jsx(Ye,{items:[{label:"Kind",value:e.jsx("span",{className:"font-mono",children:g.kind})},{label:"Role",value:e.jsx(ee,{variant:"gray",children:g.role})},{label:"Media Type",value:g.media_type},{label:"Digest",value:e.jsx("span",{className:"font-mono text-sm",children:g.digest})},{label:"Size",value:Le(y)}]})}),e.jsxs(_,{children:[e.jsx(z,{children:e.jsx(H,{children:"Content"})}),E?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-danger",children:["Error loading artifact: ",E]}),e.jsx("p",{className:"text-muted mt-2",children:e.jsx($,{variant:"primary",onClick:m,children:"Download to view"})})]}):W?v?e.jsx("pre",{children:qt(v)}):D?e.jsx("pre",{children:D}):e.jsxs("p",{className:"text-muted",children:["Binary content (",Le(y),") — download to view"]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-muted",children:[e.jsx("strong",{children:"Artifact too large for preview"})," (",Le(y)," exceeds ",Le(A)," limit)"]}),e.jsx("p",{className:"text-sm text-muted mt-2",children:"Download the artifact to view its contents."}),e.jsx("p",{className:"mt-4",children:e.jsx($,{variant:"primary",onClick:m,children:"Download"})})]})]}),u&&e.jsx(Ce,{message:u.message,variant:u.variant,visible:!!u,onClose:()=>h(null)})]})}const ds=[{path:"/",element:e.jsx(L.Navigate,{to:"/runs",replace:!0})},{path:"/runs",element:e.jsx(Zt,{})},{path:"/runs/:runId",element:e.jsx(rs,{})},{path:"/runs/:runId/artifacts/:index",element:e.jsx(os,{})},{path:"/projects",element:e.jsx(ns,{})},{path:"/groups",element:e.jsx(as,{})},{path:"/groups/:groupId",element:e.jsx(is,{})},{path:"/diff",element:e.jsx(cs,{})},{path:"/search",element:e.jsx(ls,{})}];function ft(t=[]){return L.createBrowserRouter([...ds,...t])}const us=ft();function fr({additionalRoutes:t,...s}){const a=t?.length?ft(t):us;return e.jsx(zt,{...s,children:e.jsx(L.RouterProvider,{router:a})})}exports.Alert=Ks;exports.ApiClient=Bt;exports.ApiError=Re;exports.App=fr;exports.AppProvider=zt;exports.ArtifactPage=os;exports.Badge=ee;exports.Button=$;exports.Card=_;exports.CardHeader=z;exports.CardTitle=H;exports.DiffPage=cs;exports.EmptyState=be;exports.ExportRunButton=ss;exports.FormGroup=de;exports.FormRow=xt;exports.GroupDetailPage=is;exports.GroupsPage=as;exports.GroupsTable=ts;exports.Input=Xe;exports.KVList=Ye;exports.Label=me;exports.Layout=X;exports.LayoutConfigProvider=Ys;exports.Modal=Je;exports.POLL_INTERVAL=Ve;exports.PageHeader=ke;exports.ProjectsPage=ns;exports.ProjectsTable=es;exports.RunDetailPage=rs;exports.RunsPage=Zt;exports.RunsTable=Qe;exports.SearchPage=ls;exports.Select=ge;exports.Spinner=G;exports.StatusBadge=mt;exports.Table=q;exports.TableBody=U;exports.TableCell=d;exports.TableHead=xe;exports.TableHeader=w;exports.TableRow=p;exports.ThemeProvider=Ws;exports.Toast=Ce;exports.api=It;exports.buildUrl=Us;exports.cn=I;exports.coreRoutes=ds;exports.createRouter=ft;exports.elapsedSeconds=ot;exports.formatBytes=Le;exports.formatDuration=dt;exports.formatNumber=He;exports.isTerminalStatus=Ee;exports.jsonPretty=qt;exports.router=us;exports.shortDigest=ze;exports.shortId=ie;exports.timeAgo=Fe;exports.truncate=Ut;exports.useApp=Y;exports.useArtifact=Jt;exports.useDiff=Kt;exports.useGroup=Yt;exports.useGroups=Ht;exports.useLayoutConfig=Qt;exports.useMutation=Se;exports.usePolling=Ke;exports.useProjects=$e;exports.useRun=ht;exports.useRuns=ut;exports.useTheme=Gt;exports.useThemeOptional=Gs;
|