@mastra/deployer-cloud 1.48.0-alpha.8 → 1.48.0-alpha.9
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/CHANGELOG.md +8 -0
- package/dist/studio/assets/{core-Ba801SMK.js → core-BzGcCrGa.js} +1 -1
- package/dist/studio/assets/{index-BawNxU7y.js → index-KcUhH_gd.js} +2 -2
- package/dist/studio/assets/{main-CryxgaV0.js → main-CAn3F9Cx.js} +4 -4
- package/dist/studio/index.html +1 -1
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./core-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./core-BzGcCrGa.js","./engine-compile-BkERmzkH.js","./preload-helper-PPVm8Dsz.js","./engine-javascript-CSIo_1eZ.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{_ as Eo}from"./preload-helper-PPVm8Dsz.js";function Zzt(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in e)){const a=Object.getOwnPropertyDescriptor(r,s);a&&Object.defineProperty(e,s,a.get?a:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var Pj=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Cc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var YQ={exports:{}},fA={};var vRe;function Gzt(){if(vRe)return fA;vRe=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,s,a){var i=null;if(a!==void 0&&(i=""+a),s.key!==void 0&&(i=""+s.key),"key"in s){a={};for(var l in s)l!=="key"&&(a[l]=s[l])}else a=s;return s=a.ref,{$$typeof:e,type:r,key:i,ref:s!==void 0?s:null,props:a}}return fA.Fragment=t,fA.jsx=n,fA.jsxs=n,fA}var yRe;function Qzt(){return yRe||(yRe=1,YQ.exports=Gzt()),YQ.exports}var o=Qzt(),XQ={exports:{}},Br={},bRe;function Yzt(){if(bRe)return Br;bRe=1;var e={env:{}};var t=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),h=Symbol.iterator;function m(U){return U===null||typeof U!="object"?null:(U=h&&U[h]||U["@@iterator"],typeof U=="function"?U:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,b={};function w(U,P,q){this.props=U,this.context=P,this.refs=b,this.updater=q||g}w.prototype.isReactComponent={},w.prototype.setState=function(U,P){if(typeof U!="object"&&typeof U!="function"&&U!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,U,P,"setState")},w.prototype.forceUpdate=function(U){this.updater.enqueueForceUpdate(this,U,"forceUpdate")};function S(){}S.prototype=w.prototype;function k(U,P,q){this.props=U,this.context=P,this.refs=b,this.updater=q||g}var _=k.prototype=new S;_.constructor=k,y(_,w.prototype),_.isPureReactComponent=!0;var C=Array.isArray;function E(){}var j={H:null,A:null,T:null,S:null},N=Object.prototype.hasOwnProperty;function I(U,P,q){var Z=q.ref;return{$$typeof:t,type:U,key:P,ref:Z!==void 0?Z:null,props:q}}function R(U,P){return I(U.type,P,U.props)}function $(U){return typeof U=="object"&&U!==null&&U.$$typeof===t}function F(U){var P={"=":"=0",":":"=2"};return"$"+U.replace(/[=:]/g,function(q){return P[q]})}var D=/\/+/g;function V(U,P){return typeof U=="object"&&U!==null&&U.key!=null?F(""+U.key):P.toString(36)}function W(U){switch(U.status){case"fulfilled":return U.value;case"rejected":throw U.reason;default:switch(typeof U.status=="string"?U.then(E,E):(U.status="pending",U.then(function(P){U.status==="pending"&&(U.status="fulfilled",U.value=P)},function(P){U.status==="pending"&&(U.status="rejected",U.reason=P)})),U.status){case"fulfilled":return U.value;case"rejected":throw U.reason}}throw U}function L(U,P,q,Z,X){var te=typeof U;(te==="undefined"||te==="boolean")&&(U=null);var J=!1;if(U===null)J=!0;else switch(te){case"bigint":case"string":case"number":J=!0;break;case"object":switch(U.$$typeof){case t:case n:J=!0;break;case f:return J=U._init,L(J(U._payload),P,q,Z,X)}}if(J)return X=X(U),J=Z===""?"."+V(U,0):Z,C(X)?(q="",J!=null&&(q=J.replace(D,"$&/")+"/"),L(X,P,q,"",function(de){return de})):X!=null&&($(X)&&(X=R(X,q+(X.key==null||U&&U.key===X.key?"":(""+X.key).replace(D,"$&/")+"/")+J)),P.push(X)),1;J=0;var ee=Z===""?".":Z+":";if(C(U))for(var ae=0;ae<U.length;ae++)Z=U[ae],te=ee+V(Z,ae),J+=L(Z,P,q,te,X);else if(ae=m(U),typeof ae=="function")for(U=ae.call(U),ae=0;!(Z=U.next()).done;)Z=Z.value,te=ee+V(Z,ae++),J+=L(Z,P,q,te,X);else if(te==="object"){if(typeof U.then=="function")return L(W(U),P,q,Z,X);throw P=String(U),Error("Objects are not valid as a React child (found: "+(P==="[object Object]"?"object with keys {"+Object.keys(U).join(", ")+"}":P)+"). If you meant to render a collection of children, use an array instead.")}return J}function z(U,P,q){if(U==null)return U;var Z=[],X=0;return L(U,Z,"","",function(te){return P.call(q,te,X++)}),Z}function B(U){if(U._status===-1){var P=U._result;P=P(),P.then(function(q){(U._status===0||U._status===-1)&&(U._status=1,U._result=q)},function(q){(U._status===0||U._status===-1)&&(U._status=2,U._result=q)}),U._status===-1&&(U._status=0,U._result=P)}if(U._status===1)return U._result.default;throw U._result}var M=typeof reportError=="function"?reportError:function(U){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var P=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof U=="object"&&U!==null&&typeof U.message=="string"?String(U.message):String(U),error:U});if(!window.dispatchEvent(P))return}else if(typeof e=="object"&&typeof e.emit=="function"){e.emit("uncaughtException",U);return}console.error(U)},G={map:z,forEach:function(U,P,q){z(U,function(){P.apply(this,arguments)},q)},count:function(U){var P=0;return z(U,function(){P++}),P},toArray:function(U){return z(U,function(P){return P})||[]},only:function(U){if(!$(U))throw Error("React.Children.only expected to receive a single React element child.");return U}};return Br.Activity=p,Br.Children=G,Br.Component=w,Br.Fragment=r,Br.Profiler=a,Br.PureComponent=k,Br.StrictMode=s,Br.Suspense=u,Br.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=j,Br.__COMPILER_RUNTIME={__proto__:null,c:function(U){return j.H.useMemoCache(U)}},Br.cache=function(U){return function(){return U.apply(null,arguments)}},Br.cacheSignal=function(){return null},Br.cloneElement=function(U,P,q){if(U==null)throw Error("The argument must be a React element, but you passed "+U+".");var Z=y({},U.props),X=U.key;if(P!=null)for(te in P.key!==void 0&&(X=""+P.key),P)!N.call(P,te)||te==="key"||te==="__self"||te==="__source"||te==="ref"&&P.ref===void 0||(Z[te]=P[te]);var te=arguments.length-2;if(te===1)Z.children=q;else if(1<te){for(var J=Array(te),ee=0;ee<te;ee++)J[ee]=arguments[ee+2];Z.children=J}return I(U.type,X,Z)},Br.createContext=function(U){return U={$$typeof:l,_currentValue:U,_currentValue2:U,_threadCount:0,Provider:null,Consumer:null},U.Provider=U,U.Consumer={$$typeof:i,_context:U},U},Br.createElement=function(U,P,q){var Z,X={},te=null;if(P!=null)for(Z in P.key!==void 0&&(te=""+P.key),P)N.call(P,Z)&&Z!=="key"&&Z!=="__self"&&Z!=="__source"&&(X[Z]=P[Z]);var J=arguments.length-2;if(J===1)X.children=q;else if(1<J){for(var ee=Array(J),ae=0;ae<J;ae++)ee[ae]=arguments[ae+2];X.children=ee}if(U&&U.defaultProps)for(Z in J=U.defaultProps,J)X[Z]===void 0&&(X[Z]=J[Z]);return I(U,te,X)},Br.createRef=function(){return{current:null}},Br.forwardRef=function(U){return{$$typeof:c,render:U}},Br.isValidElement=$,Br.lazy=function(U){return{$$typeof:f,_payload:{_status:-1,_result:U},_init:B}},Br.memo=function(U,P){return{$$typeof:d,type:U,compare:P===void 0?null:P}},Br.startTransition=function(U){var P=j.T,q={};j.T=q;try{var Z=U(),X=j.S;X!==null&&X(q,Z),typeof Z=="object"&&Z!==null&&typeof Z.then=="function"&&Z.then(E,M)}catch(te){M(te)}finally{P!==null&&q.types!==null&&(P.types=q.types),j.T=P}},Br.unstable_useCacheRefresh=function(){return j.H.useCacheRefresh()},Br.use=function(U){return j.H.use(U)},Br.useActionState=function(U,P,q){return j.H.useActionState(U,P,q)},Br.useCallback=function(U,P){return j.H.useCallback(U,P)},Br.useContext=function(U){return j.H.useContext(U)},Br.useDebugValue=function(){},Br.useDeferredValue=function(U,P){return j.H.useDeferredValue(U,P)},Br.useEffect=function(U,P){return j.H.useEffect(U,P)},Br.useEffectEvent=function(U){return j.H.useEffectEvent(U)},Br.useId=function(){return j.H.useId()},Br.useImperativeHandle=function(U,P,q){return j.H.useImperativeHandle(U,P,q)},Br.useInsertionEffect=function(U,P){return j.H.useInsertionEffect(U,P)},Br.useLayoutEffect=function(U,P){return j.H.useLayoutEffect(U,P)},Br.useMemo=function(U,P){return j.H.useMemo(U,P)},Br.useOptimistic=function(U,P){return j.H.useOptimistic(U,P)},Br.useReducer=function(U,P,q){return j.H.useReducer(U,P,q)},Br.useRef=function(U){return j.H.useRef(U)},Br.useState=function(U){return j.H.useState(U)},Br.useSyncExternalStore=function(U,P,q){return j.H.useSyncExternalStore(U,P,q)},Br.useTransition=function(){return j.H.useTransition()},Br.version="19.2.6",Br}var xRe;function iN(){return xRe||(xRe=1,XQ.exports=Yzt()),XQ.exports}var v=iN();const Le=Cc(v),oN=Zzt({__proto__:null,default:Le},[v]);var KQ={exports:{}},pA={},JQ={exports:{}},eY={};var wRe;function Xzt(){return wRe||(wRe=1,(function(e){function t(W,L){var z=W.length;W.push(L);e:for(;0<z;){var B=z-1>>>1,M=W[B];if(0<s(M,L))W[B]=L,W[z]=M,z=B;else break e}}function n(W){return W.length===0?null:W[0]}function r(W){if(W.length===0)return null;var L=W[0],z=W.pop();if(z!==L){W[0]=z;e:for(var B=0,M=W.length,G=M>>>1;B<G;){var U=2*(B+1)-1,P=W[U],q=U+1,Z=W[q];if(0>s(P,z))q<M&&0>s(Z,P)?(W[B]=Z,W[q]=z,B=q):(W[B]=P,W[U]=z,B=U);else if(q<M&&0>s(Z,z))W[B]=Z,W[q]=z,B=q;else break e}}return L}function s(W,L){var z=W.sortIndex-L.sortIndex;return z!==0?z:W.id-L.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var i=Date,l=i.now();e.unstable_now=function(){return i.now()-l}}var c=[],u=[],d=1,f=null,p=3,h=!1,m=!1,g=!1,y=!1,b=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function k(W){for(var L=n(u);L!==null;){if(L.callback===null)r(u);else if(L.startTime<=W)r(u),L.sortIndex=L.expirationTime,t(c,L);else break;L=n(u)}}function _(W){if(g=!1,k(W),!m)if(n(c)!==null)m=!0,C||(C=!0,$());else{var L=n(u);L!==null&&V(_,L.startTime-W)}}var C=!1,E=-1,j=5,N=-1;function I(){return y?!0:!(e.unstable_now()-N<j)}function R(){if(y=!1,C){var W=e.unstable_now();N=W;var L=!0;try{e:{m=!1,g&&(g=!1,w(E),E=-1),h=!0;var z=p;try{t:{for(k(W),f=n(c);f!==null&&!(f.expirationTime>W&&I());){var B=f.callback;if(typeof B=="function"){f.callback=null,p=f.priorityLevel;var M=B(f.expirationTime<=W);if(W=e.unstable_now(),typeof M=="function"){f.callback=M,k(W),L=!0;break t}f===n(c)&&r(c),k(W)}else r(c);f=n(c)}if(f!==null)L=!0;else{var G=n(u);G!==null&&V(_,G.startTime-W),L=!1}}break e}finally{f=null,p=z,h=!1}L=void 0}}finally{L?$():C=!1}}}var $;if(typeof S=="function")$=function(){S(R)};else if(typeof MessageChannel<"u"){var F=new MessageChannel,D=F.port2;F.port1.onmessage=R,$=function(){D.postMessage(null)}}else $=function(){b(R,0)};function V(W,L){E=b(function(){W(e.unstable_now())},L)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(W){W.callback=null},e.unstable_forceFrameRate=function(W){0>W||125<W?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):j=0<W?Math.floor(1e3/W):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_next=function(W){switch(p){case 1:case 2:case 3:var L=3;break;default:L=p}var z=p;p=L;try{return W()}finally{p=z}},e.unstable_requestPaint=function(){y=!0},e.unstable_runWithPriority=function(W,L){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var z=p;p=W;try{return L()}finally{p=z}},e.unstable_scheduleCallback=function(W,L,z){var B=e.unstable_now();switch(typeof z=="object"&&z!==null?(z=z.delay,z=typeof z=="number"&&0<z?B+z:B):z=B,W){case 1:var M=-1;break;case 2:M=250;break;case 5:M=1073741823;break;case 4:M=1e4;break;default:M=5e3}return M=z+M,W={id:d++,callback:L,priorityLevel:W,startTime:z,expirationTime:M,sortIndex:-1},z>B?(W.sortIndex=z,t(u,W),n(c)===null&&W===n(u)&&(g?(w(E),E=-1):g=!0,V(_,z-B))):(W.sortIndex=M,t(c,W),m||h||(m=!0,C||(C=!0,$()))),W},e.unstable_shouldYield=I,e.unstable_wrapCallback=function(W){var L=p;return function(){var z=p;p=L;try{return W.apply(this,arguments)}finally{p=z}}}})(eY)),eY}var SRe;function Kzt(){return SRe||(SRe=1,JQ.exports=Xzt()),JQ.exports}var tY={exports:{}},cu={};var kRe;function Jzt(){if(kRe)return cu;kRe=1;var e=iN();function t(c){var u="https://react.dev/errors/"+c;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)u+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},s=Symbol.for("react.portal");function a(c,u,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:s,key:f==null?null:""+f,children:c,containerInfo:u,implementation:d}}var i=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(c,u){if(c==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return cu.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,cu.createPortal=function(c,u){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(t(299));return a(c,u,null,d)},cu.flushSync=function(c){var u=i.T,d=r.p;try{if(i.T=null,r.p=2,c)return c()}finally{i.T=u,r.p=d,r.d.f()}},cu.preconnect=function(c,u){typeof c=="string"&&(u?(u=u.crossOrigin,u=typeof u=="string"?u==="use-credentials"?u:"":void 0):u=null,r.d.C(c,u))},cu.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},cu.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin),p=typeof u.integrity=="string"?u.integrity:void 0,h=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:p,fetchPriority:h}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:p,fetchPriority:h,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},cu.preinitModule=function(c,u){if(typeof c=="string")if(typeof u=="object"&&u!==null){if(u.as==null||u.as==="script"){var d=l(u.as,u.crossOrigin);r.d.M(c,{crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0})}}else u==null&&r.d.M(c)},cu.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin);r.d.L(c,d,{crossOrigin:f,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0,type:typeof u.type=="string"?u.type:void 0,fetchPriority:typeof u.fetchPriority=="string"?u.fetchPriority:void 0,referrerPolicy:typeof u.referrerPolicy=="string"?u.referrerPolicy:void 0,imageSrcSet:typeof u.imageSrcSet=="string"?u.imageSrcSet:void 0,imageSizes:typeof u.imageSizes=="string"?u.imageSizes:void 0,media:typeof u.media=="string"?u.media:void 0})}},cu.preloadModule=function(c,u){if(typeof c=="string")if(u){var d=l(u.as,u.crossOrigin);r.d.m(c,{as:typeof u.as=="string"&&u.as!=="script"?u.as:void 0,crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0})}else r.d.m(c)},cu.requestFormReset=function(c){r.d.r(c)},cu.unstable_batchedUpdates=function(c,u){return c(u)},cu.useFormState=function(c,u,d){return i.H.useFormState(c,u,d)},cu.useFormStatus=function(){return i.H.useHostTransitionStatus()},cu.version="19.2.6",cu}var ORe;function Wnt(){if(ORe)return tY.exports;ORe=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),tY.exports=Jzt(),tY.exports}var _Re;function e7t(){if(_Re)return pA;_Re=1;var e={env:{}};var t=Kzt(),n=iN(),r=Wnt();function s(x){var O="https://react.dev/errors/"+x;if(1<arguments.length){O+="?args[]="+encodeURIComponent(arguments[1]);for(var T=2;T<arguments.length;T++)O+="&args[]="+encodeURIComponent(arguments[T])}return"Minified React error #"+x+"; visit "+O+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(x){return!(!x||x.nodeType!==1&&x.nodeType!==9&&x.nodeType!==11)}function i(x){var O=x,T=x;if(x.alternate)for(;O.return;)O=O.return;else{x=O;do O=x,(O.flags&4098)!==0&&(T=O.return),x=O.return;while(x)}return O.tag===3?T:null}function l(x){if(x.tag===13){var O=x.memoizedState;if(O===null&&(x=x.alternate,x!==null&&(O=x.memoizedState)),O!==null)return O.dehydrated}return null}function c(x){if(x.tag===31){var O=x.memoizedState;if(O===null&&(x=x.alternate,x!==null&&(O=x.memoizedState)),O!==null)return O.dehydrated}return null}function u(x){if(i(x)!==x)throw Error(s(188))}function d(x){var O=x.alternate;if(!O){if(O=i(x),O===null)throw Error(s(188));return O!==x?null:x}for(var T=x,A=O;;){var H=T.return;if(H===null)break;var Q=H.alternate;if(Q===null){if(A=H.return,A!==null){T=A;continue}break}if(H.child===Q.child){for(Q=H.child;Q;){if(Q===T)return u(H),x;if(Q===A)return u(H),O;Q=Q.sibling}throw Error(s(188))}if(T.return!==A.return)T=H,A=Q;else{for(var ie=!1,we=H.child;we;){if(we===T){ie=!0,T=H,A=Q;break}if(we===A){ie=!0,A=H,T=Q;break}we=we.sibling}if(!ie){for(we=Q.child;we;){if(we===T){ie=!0,T=Q,A=H;break}if(we===A){ie=!0,A=Q,T=H;break}we=we.sibling}if(!ie)throw Error(s(189))}}if(T.alternate!==A)throw Error(s(190))}if(T.tag!==3)throw Error(s(188));return T.stateNode.current===T?x:O}function f(x){var O=x.tag;if(O===5||O===26||O===27||O===6)return x;for(x=x.child;x!==null;){if(O=f(x),O!==null)return O;x=x.sibling}return null}var p=Object.assign,h=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),k=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),N=Symbol.for("react.lazy"),I=Symbol.for("react.activity"),R=Symbol.for("react.memo_cache_sentinel"),$=Symbol.iterator;function F(x){return x===null||typeof x!="object"?null:(x=$&&x[$]||x["@@iterator"],typeof x=="function"?x:null)}var D=Symbol.for("react.client.reference");function V(x){if(x==null)return null;if(typeof x=="function")return x.$$typeof===D?null:x.displayName||x.name||null;if(typeof x=="string")return x;switch(x){case y:return"Fragment";case w:return"Profiler";case b:return"StrictMode";case C:return"Suspense";case E:return"SuspenseList";case I:return"Activity"}if(typeof x=="object")switch(x.$$typeof){case g:return"Portal";case k:return x.displayName||"Context";case S:return(x._context.displayName||"Context")+".Consumer";case _:var O=x.render;return x=x.displayName,x||(x=O.displayName||O.name||"",x=x!==""?"ForwardRef("+x+")":"ForwardRef"),x;case j:return O=x.displayName||null,O!==null?O:V(x.type)||"Memo";case N:O=x._payload,x=x._init;try{return V(x(O))}catch{}}return null}var W=Array.isArray,L=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B={pending:!1,data:null,method:null,action:null},M=[],G=-1;function U(x){return{current:x}}function P(x){0>G||(x.current=M[G],M[G]=null,G--)}function q(x,O){G++,M[G]=x.current,x.current=O}var Z=U(null),X=U(null),te=U(null),J=U(null);function ee(x,O){switch(q(te,O),q(X,x),q(Z,null),O.nodeType){case 9:case 11:x=(x=O.documentElement)&&(x=x.namespaceURI)?zAe(x):0;break;default:if(x=O.tagName,O=O.namespaceURI)O=zAe(O),x=BAe(O,x);else switch(x){case"svg":x=1;break;case"math":x=2;break;default:x=0}}P(Z),q(Z,x)}function ae(){P(Z),P(X),P(te)}function de(x){x.memoizedState!==null&&q(J,x);var O=Z.current,T=BAe(O,x.type);O!==T&&(q(X,x),q(Z,T))}function Y(x){X.current===x&&(P(Z),P(X)),J.current===x&&(P(J),lA._currentValue=B)}var ne,ce;function pe(x){if(ne===void 0)try{throw Error()}catch(T){var O=T.stack.trim().match(/\n( *(at )?)/);ne=O&&O[1]||"",ce=-1<T.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<T.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
4
|
`+ne+x+ce}var le=!1;function ve(x,O){if(!x||le)return"";le=!0;var T=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var A={DetermineComponentFrameRoot:function(){try{if(O){var Ct=function(){throw Error()};if(Object.defineProperty(Ct.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ct,[])}catch(dt){var lt=dt}Reflect.construct(x,[],Ct)}else{try{Ct.call()}catch(dt){lt=dt}x.call(Ct.prototype)}}else{try{throw Error()}catch(dt){lt=dt}(Ct=x())&&typeof Ct.catch=="function"&&Ct.catch(function(){})}}catch(dt){if(dt&<&&typeof dt.stack=="string")return[dt.stack,lt.stack]}return[null,null]}};A.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var H=Object.getOwnPropertyDescriptor(A.DetermineComponentFrameRoot,"name");H&&H.configurable&&Object.defineProperty(A.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var Q=A.DetermineComponentFrameRoot(),ie=Q[0],we=Q[1];if(ie&&we){var Be=ie.split(`
|
|
@@ -7,7 +7,7 @@ import{_ as Eo}from"./preload-helper-PPVm8Dsz.js";function Zzt(e,t){for(var n=0;
|
|
|
7
7
|
`+Be[A].replace(" at new "," at ");return x.displayName&&xt.includes("<anonymous>")&&(xt=xt.replace("<anonymous>",x.displayName)),xt}while(1<=A&&0<=H);break}}}finally{le=!1,Error.prepareStackTrace=T}return(T=x?x.displayName||x.name:"")?pe(T):""}function ye(x,O){switch(x.tag){case 26:case 27:case 5:return pe(x.type);case 16:return pe("Lazy");case 13:return x.child!==O&&O!==null?pe("Suspense Fallback"):pe("Suspense");case 19:return pe("SuspenseList");case 0:case 15:return ve(x.type,!1);case 11:return ve(x.type.render,!1);case 1:return ve(x.type,!0);case 31:return pe("Activity");default:return""}}function Se(x){try{var O="",T=null;do O+=ye(x,T),T=x,x=x.return;while(x);return O}catch(A){return`
|
|
8
8
|
Error generating stack: `+A.message+`
|
|
9
9
|
`+A.stack}}var Ne=Object.prototype.hasOwnProperty,ke=t.unstable_scheduleCallback,Ie=t.unstable_cancelCallback,ze=t.unstable_shouldYield,oe=t.unstable_requestPaint,se=t.unstable_now,re=t.unstable_getCurrentPriorityLevel,he=t.unstable_ImmediatePriority,xe=t.unstable_UserBlockingPriority,Ee=t.unstable_NormalPriority,Pe=t.unstable_LowPriority,Qe=t.unstable_IdlePriority,Ze=t.log,Ce=t.unstable_setDisableYieldValue,je=null,_e=null;function Oe(x){if(typeof Ze=="function"&&Ce(x),_e&&typeof _e.setStrictMode=="function")try{_e.setStrictMode(je,x)}catch{}}var Re=Math.clz32?Math.clz32:Ge,qe=Math.log,Ke=Math.LN2;function Ge(x){return x>>>=0,x===0?32:31-(qe(x)/Ke|0)|0}var Ot=256,yt=262144,rn=4194304;function bt(x){var O=x&42;if(O!==0)return O;switch(x&-x){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return x&261888;case 262144:case 524288:case 1048576:case 2097152:return x&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return x&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return x}}function Pt(x,O,T){var A=x.pendingLanes;if(A===0)return 0;var H=0,Q=x.suspendedLanes,ie=x.pingedLanes;x=x.warmLanes;var we=A&134217727;return we!==0?(A=we&~Q,A!==0?H=bt(A):(ie&=we,ie!==0?H=bt(ie):T||(T=we&~x,T!==0&&(H=bt(T))))):(we=A&~Q,we!==0?H=bt(we):ie!==0?H=bt(ie):T||(T=A&~x,T!==0&&(H=bt(T)))),H===0?0:O!==0&&O!==H&&(O&Q)===0&&(Q=H&-H,T=O&-O,Q>=T||Q===32&&(T&4194048)!==0)?O:H}function en(x,O){return(x.pendingLanes&~(x.suspendedLanes&~x.pingedLanes)&O)===0}function Ye(x,O){switch(x){case 1:case 2:case 4:case 8:case 64:return O+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return O+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ot(){var x=rn;return rn<<=1,(rn&62914560)===0&&(rn=4194304),x}function it(x){for(var O=[],T=0;31>T;T++)O.push(x);return O}function Yt(x,O){x.pendingLanes|=O,O!==268435456&&(x.suspendedLanes=0,x.pingedLanes=0,x.warmLanes=0)}function Wt(x,O,T,A,H,Q){var ie=x.pendingLanes;x.pendingLanes=T,x.suspendedLanes=0,x.pingedLanes=0,x.warmLanes=0,x.expiredLanes&=T,x.entangledLanes&=T,x.errorRecoveryDisabledLanes&=T,x.shellSuspendCounter=0;var we=x.entanglements,Be=x.expirationTimes,st=x.hiddenUpdates;for(T=ie&~T;0<T;){var xt=31-Re(T),Ct=1<<xt;we[xt]=0,Be[xt]=-1;var lt=st[xt];if(lt!==null)for(st[xt]=null,xt=0;xt<lt.length;xt++){var dt=lt[xt];dt!==null&&(dt.lane&=-536870913)}T&=~Ct}A!==0&&_n(x,A,0),Q!==0&&H===0&&x.tag!==0&&(x.suspendedLanes|=Q&~(ie&~O))}function _n(x,O,T){x.pendingLanes|=O,x.suspendedLanes&=~O;var A=31-Re(O);x.entangledLanes|=O,x.entanglements[A]=x.entanglements[A]|1073741824|T&261930}function Te(x,O){var T=x.entangledLanes|=O;for(x=x.entanglements;T;){var A=31-Re(T),H=1<<A;H&O|x[A]&O&&(x[A]|=O),T&=~H}}function Fe(x,O){var T=O&-O;return T=(T&42)!==0?1:Me(T),(T&(x.suspendedLanes|O))!==0?0:T}function Me(x){switch(x){case 2:x=1;break;case 8:x=4;break;case 32:x=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:x=128;break;case 268435456:x=134217728;break;default:x=0}return x}function Je(x){return x&=-x,2<x?8<x?(x&134217727)!==0?32:268435456:8:2}function nt(){var x=z.p;return x!==0?x:(x=window.event,x===void 0?32:uRe(x.type))}function Dt(x,O){var T=z.p;try{return z.p=x,O()}finally{z.p=T}}var _t=Math.random().toString(36).slice(2),Ft="__reactFiber$"+_t,$t="__reactProps$"+_t,jt="__reactContainer$"+_t,xn="__reactEvents$"+_t,sr="__reactListeners$"+_t,Zn="__reactHandles$"+_t,Er="__reactResources$"+_t,hr="__reactMarker$"+_t;function xs(x){delete x[Ft],delete x[$t],delete x[xn],delete x[sr],delete x[Zn]}function Mr(x){var O=x[Ft];if(O)return O;for(var T=x.parentNode;T;){if(O=T[jt]||T[Ft]){if(T=O.alternate,O.child!==null||T!==null&&T.child!==null)for(x=GAe(x);x!==null;){if(T=x[Ft])return T;x=GAe(x)}return O}x=T,T=x.parentNode}return null}function fr(x){if(x=x[Ft]||x[jt]){var O=x.tag;if(O===5||O===6||O===13||O===31||O===26||O===27||O===3)return x}return null}function Hs(x){var O=x.tag;if(O===5||O===26||O===27||O===6)return x.stateNode;throw Error(s(33))}function fa(x){var O=x[Er];return O||(O=x[Er]={hoistableStyles:new Map,hoistableScripts:new Map}),O}function _a(x){x[hr]=!0}var Ma=new Set,Bo={};function gl(x,O){il(x,O),il(x+"Capture",O)}function il(x,O){for(Bo[x]=O,x=0;x<O.length;x++)Ma.add(O[x])}var Em=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Uu={},Rf={};function jm(x){return Ne.call(Rf,x)?!0:Ne.call(Uu,x)?!1:Em.test(x)?Rf[x]=!0:(Uu[x]=!0,!1)}function qu(x,O,T){if(jm(O))if(T===null)x.removeAttribute(O);else{switch(typeof T){case"undefined":case"function":case"symbol":x.removeAttribute(O);return;case"boolean":var A=O.toLowerCase().slice(0,5);if(A!=="data-"&&A!=="aria-"){x.removeAttribute(O);return}}x.setAttribute(O,""+T)}}function Zr(x,O,T){if(T===null)x.removeAttribute(O);else{switch(typeof T){case"undefined":case"function":case"symbol":case"boolean":x.removeAttribute(O);return}x.setAttribute(O,""+T)}}function Ca(x,O,T,A){if(A===null)x.removeAttribute(T);else{switch(typeof A){case"undefined":case"function":case"symbol":case"boolean":x.removeAttribute(T);return}x.setAttributeNS(O,T,""+A)}}function hi(x){switch(typeof x){case"bigint":case"boolean":case"number":case"string":case"undefined":return x;case"object":return x;default:return""}}function Ii(x){var O=x.type;return(x=x.nodeName)&&x.toLowerCase()==="input"&&(O==="checkbox"||O==="radio")}function $l(x,O,T){var A=Object.getOwnPropertyDescriptor(x.constructor.prototype,O);if(!x.hasOwnProperty(O)&&typeof A<"u"&&typeof A.get=="function"&&typeof A.set=="function"){var H=A.get,Q=A.set;return Object.defineProperty(x,O,{configurable:!0,get:function(){return H.call(this)},set:function(ie){T=""+ie,Q.call(this,ie)}}),Object.defineProperty(x,O,{enumerable:A.enumerable}),{getValue:function(){return T},setValue:function(ie){T=""+ie},stopTracking:function(){x._valueTracker=null,delete x[O]}}}}function Vu(x){if(!x._valueTracker){var O=Ii(x)?"checked":"value";x._valueTracker=$l(x,O,""+x[O])}}function Ws(x){if(!x)return!1;var O=x._valueTracker;if(!O)return!0;var T=O.getValue(),A="";return x&&(A=Ii(x)?x.checked?"true":"false":x.value),x=A,x!==T?(O.setValue(x),!0):!1}function lu(x){if(x=x||(typeof document<"u"?document:void 0),typeof x>"u")return null;try{return x.activeElement||x.body}catch{return x.body}}var Wg=/[\n"\\]/g;function Uo(x){return x.replace(Wg,function(O){return"\\"+O.charCodeAt(0).toString(16)+" "})}function Y1(x,O,T,A,H,Q,ie,we){x.name="",ie!=null&&typeof ie!="function"&&typeof ie!="symbol"&&typeof ie!="boolean"?x.type=ie:x.removeAttribute("type"),O!=null?ie==="number"?(O===0&&x.value===""||x.value!=O)&&(x.value=""+hi(O)):x.value!==""+hi(O)&&(x.value=""+hi(O)):ie!=="submit"&&ie!=="reset"||x.removeAttribute("value"),O!=null?Zg(x,ie,hi(O)):T!=null?Zg(x,ie,hi(T)):A!=null&&x.removeAttribute("value"),H==null&&Q!=null&&(x.defaultChecked=!!Q),H!=null&&(x.checked=H&&typeof H!="function"&&typeof H!="symbol"),we!=null&&typeof we!="function"&&typeof we!="symbol"&&typeof we!="boolean"?x.name=""+hi(we):x.removeAttribute("name")}function qy(x,O,T,A,H,Q,ie,we){if(Q!=null&&typeof Q!="function"&&typeof Q!="symbol"&&typeof Q!="boolean"&&(x.type=Q),O!=null||T!=null){if(!(Q!=="submit"&&Q!=="reset"||O!=null)){Vu(x);return}T=T!=null?""+hi(T):"",O=O!=null?""+hi(O):T,we||O===x.value||(x.value=O),x.defaultValue=O}A=A??H,A=typeof A!="function"&&typeof A!="symbol"&&!!A,x.checked=we?x.checked:!!A,x.defaultChecked=!!A,ie!=null&&typeof ie!="function"&&typeof ie!="symbol"&&typeof ie!="boolean"&&(x.name=ie),Vu(x)}function Zg(x,O,T){O==="number"&&lu(x.ownerDocument)===x||x.defaultValue===""+T||(x.defaultValue=""+T)}function Gg(x,O,T,A){if(x=x.options,O){O={};for(var H=0;H<T.length;H++)O["$"+T[H]]=!0;for(T=0;T<x.length;T++)H=O.hasOwnProperty("$"+x[T].value),x[T].selected!==H&&(x[T].selected=H),H&&A&&(x[T].defaultSelected=!0)}else{for(T=""+hi(T),O=null,H=0;H<x.length;H++){if(x[H].value===T){x[H].selected=!0,A&&(x[H].defaultSelected=!0);return}O!==null||x[H].disabled||(O=x[H])}O!==null&&(O.selected=!0)}}function X1(x,O,T){if(O!=null&&(O=""+hi(O),O!==x.value&&(x.value=O),T==null)){x.defaultValue!==O&&(x.defaultValue=O);return}x.defaultValue=T!=null?""+hi(T):""}function kI(x,O,T,A){if(O==null){if(A!=null){if(T!=null)throw Error(s(92));if(W(A)){if(1<A.length)throw Error(s(93));A=A[0]}T=A}T==null&&(T=""),O=T}T=hi(O),x.defaultValue=T,A=x.textContent,A===T&&A!==""&&A!==null&&(x.value=A),Vu(x)}function Tm(x,O){if(O){var T=x.firstChild;if(T&&T===x.lastChild&&T.nodeType===3){T.nodeValue=O;return}}x.textContent=O}var a0=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function G_(x,O,T){var A=O.indexOf("--")===0;T==null||typeof T=="boolean"||T===""?A?x.setProperty(O,""):O==="float"?x.cssFloat="":x[O]="":A?x.setProperty(O,T):typeof T!="number"||T===0||a0.has(O)?O==="float"?x.cssFloat=T:x[O]=(""+T).trim():x[O]=T+"px"}function Q_(x,O,T){if(O!=null&&typeof O!="object")throw Error(s(62));if(x=x.style,T!=null){for(var A in T)!T.hasOwnProperty(A)||O!=null&&O.hasOwnProperty(A)||(A.indexOf("--")===0?x.setProperty(A,""):A==="float"?x.cssFloat="":x[A]="");for(var H in O)A=O[H],O.hasOwnProperty(H)&&T[H]!==A&&G_(x,H,A)}else for(var Q in O)O.hasOwnProperty(Q)&&G_(x,Q,O[Q])}function K1(x){if(x.indexOf("-")===-1)return!1;switch(x){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var YZ=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),XZ=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Y_(x){return XZ.test(""+x)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":x}function Nm(){}var J1=null;function OI(x){return x=x.target||x.srcElement||window,x.correspondingUseElement&&(x=x.correspondingUseElement),x.nodeType===3?x.parentNode:x}var i0=null,un=null;function Qn(x){var O=fr(x);if(O&&(x=O.stateNode)){var T=x[$t]||null;e:switch(x=O.stateNode,O.type){case"input":if(Y1(x,T.value,T.defaultValue,T.defaultValue,T.checked,T.defaultChecked,T.type,T.name),O=T.name,T.type==="radio"&&O!=null){for(T=x;T.parentNode;)T=T.parentNode;for(T=T.querySelectorAll('input[name="'+Uo(""+O)+'"][type="radio"]'),O=0;O<T.length;O++){var A=T[O];if(A!==x&&A.form===x.form){var H=A[$t]||null;if(!H)throw Error(s(90));Y1(A,H.value,H.defaultValue,H.defaultValue,H.checked,H.defaultChecked,H.type,H.name)}}for(O=0;O<T.length;O++)A=T[O],A.form===x.form&&Ws(A)}break e;case"textarea":X1(x,T.value,T.defaultValue);break e;case"select":O=T.value,O!=null&&Gg(x,!!T.multiple,O,!1)}}}var Cs=!1;function Ea(x,O,T){if(Cs)return x(O,T);Cs=!0;try{var A=x(O);return A}finally{if(Cs=!1,(i0!==null||un!==null)&&(A5(),i0&&(O=i0,x=un,un=i0=null,Qn(O),x)))for(O=0;O<x.length;O++)Qn(x[O])}}function so(x,O){var T=x.stateNode;if(T===null)return null;var A=T[$t]||null;if(A===null)return null;T=A[O];e:switch(O){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(A=!A.disabled)||(x=x.type,A=!(x==="button"||x==="input"||x==="select"||x==="textarea")),x=!A;break e;default:x=!1}if(x)return null;if(T&&typeof T!="function")throw Error(s(231,O,typeof T));return T}var Ba=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Im=!1;if(Ba)try{var jd={};Object.defineProperty(jd,"passive",{get:function(){Im=!0}}),window.addEventListener("test",jd,jd),window.removeEventListener("test",jd,jd)}catch{Im=!1}var Pf=null,_I=null,CI=null;function BTe(){if(CI)return CI;var x,O=_I,T=O.length,A,H="value"in Pf?Pf.value:Pf.textContent,Q=H.length;for(x=0;x<T&&O[x]===H[x];x++);var ie=T-x;for(A=1;A<=ie&&O[T-A]===H[Q-A];A++);return CI=H.slice(x,1<A?1-A:void 0)}function Z4(x){var O=x.keyCode;return"charCode"in x?(x=x.charCode,x===0&&O===13&&(x=13)):x=O,x===10&&(x=13),32<=x||x===13?x:0}function G4(){return!0}function UTe(){return!1}function Td(x){function O(T,A,H,Q,ie){this._reactName=T,this._targetInst=H,this.type=A,this.nativeEvent=Q,this.target=ie,this.currentTarget=null;for(var we in x)x.hasOwnProperty(we)&&(T=x[we],this[we]=T?T(Q):Q[we]);return this.isDefaultPrevented=(Q.defaultPrevented!=null?Q.defaultPrevented:Q.returnValue===!1)?G4:UTe,this.isPropagationStopped=UTe,this}return p(O.prototype,{preventDefault:function(){this.defaultPrevented=!0;var T=this.nativeEvent;T&&(T.preventDefault?T.preventDefault():typeof T.returnValue!="unknown"&&(T.returnValue=!1),this.isDefaultPrevented=G4)},stopPropagation:function(){var T=this.nativeEvent;T&&(T.stopPropagation?T.stopPropagation():typeof T.cancelBubble!="unknown"&&(T.cancelBubble=!0),this.isPropagationStopped=G4)},persist:function(){},isPersistent:G4}),O}var eS={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(x){return x.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Q4=Td(eS),EI=p({},eS,{view:0,detail:0}),H9t=Td(EI),KZ,JZ,jI,Y4=p({},EI,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:tG,button:0,buttons:0,relatedTarget:function(x){return x.relatedTarget===void 0?x.fromElement===x.srcElement?x.toElement:x.fromElement:x.relatedTarget},movementX:function(x){return"movementX"in x?x.movementX:(x!==jI&&(jI&&x.type==="mousemove"?(KZ=x.screenX-jI.screenX,JZ=x.screenY-jI.screenY):JZ=KZ=0,jI=x),KZ)},movementY:function(x){return"movementY"in x?x.movementY:JZ}}),qTe=Td(Y4),W9t=p({},Y4,{dataTransfer:0}),Z9t=Td(W9t),G9t=p({},EI,{relatedTarget:0}),eG=Td(G9t),Q9t=p({},eS,{animationName:0,elapsedTime:0,pseudoElement:0}),Y9t=Td(Q9t),X9t=p({},eS,{clipboardData:function(x){return"clipboardData"in x?x.clipboardData:window.clipboardData}}),K9t=Td(X9t),J9t=p({},eS,{data:0}),VTe=Td(J9t),eFt={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},tFt={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},nFt={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function rFt(x){var O=this.nativeEvent;return O.getModifierState?O.getModifierState(x):(x=nFt[x])?!!O[x]:!1}function tG(){return rFt}var sFt=p({},EI,{key:function(x){if(x.key){var O=eFt[x.key]||x.key;if(O!=="Unidentified")return O}return x.type==="keypress"?(x=Z4(x),x===13?"Enter":String.fromCharCode(x)):x.type==="keydown"||x.type==="keyup"?tFt[x.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:tG,charCode:function(x){return x.type==="keypress"?Z4(x):0},keyCode:function(x){return x.type==="keydown"||x.type==="keyup"?x.keyCode:0},which:function(x){return x.type==="keypress"?Z4(x):x.type==="keydown"||x.type==="keyup"?x.keyCode:0}}),aFt=Td(sFt),iFt=p({},Y4,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),HTe=Td(iFt),oFt=p({},EI,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:tG}),lFt=Td(oFt),cFt=p({},eS,{propertyName:0,elapsedTime:0,pseudoElement:0}),uFt=Td(cFt),dFt=p({},Y4,{deltaX:function(x){return"deltaX"in x?x.deltaX:"wheelDeltaX"in x?-x.wheelDeltaX:0},deltaY:function(x){return"deltaY"in x?x.deltaY:"wheelDeltaY"in x?-x.wheelDeltaY:"wheelDelta"in x?-x.wheelDelta:0},deltaZ:0,deltaMode:0}),fFt=Td(dFt),pFt=p({},eS,{newState:0,oldState:0}),hFt=Td(pFt),mFt=[9,13,27,32],nG=Ba&&"CompositionEvent"in window,TI=null;Ba&&"documentMode"in document&&(TI=document.documentMode);var gFt=Ba&&"TextEvent"in window&&!TI,WTe=Ba&&(!nG||TI&&8<TI&&11>=TI),ZTe=" ",GTe=!1;function QTe(x,O){switch(x){case"keyup":return mFt.indexOf(O.keyCode)!==-1;case"keydown":return O.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function YTe(x){return x=x.detail,typeof x=="object"&&"data"in x?x.data:null}var X_=!1;function vFt(x,O){switch(x){case"compositionend":return YTe(O);case"keypress":return O.which!==32?null:(GTe=!0,ZTe);case"textInput":return x=O.data,x===ZTe&>e?null:x;default:return null}}function yFt(x,O){if(X_)return x==="compositionend"||!nG&&QTe(x,O)?(x=BTe(),CI=_I=Pf=null,X_=!1,x):null;switch(x){case"paste":return null;case"keypress":if(!(O.ctrlKey||O.altKey||O.metaKey)||O.ctrlKey&&O.altKey){if(O.char&&1<O.char.length)return O.char;if(O.which)return String.fromCharCode(O.which)}return null;case"compositionend":return WTe&&O.locale!=="ko"?null:O.data;default:return null}}var bFt={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function XTe(x){var O=x&&x.nodeName&&x.nodeName.toLowerCase();return O==="input"?!!bFt[x.type]:O==="textarea"}function KTe(x,O,T,A){i0?un?un.push(A):un=[A]:i0=A,O=F5(O,"onChange"),0<O.length&&(T=new Q4("onChange","change",null,T,A),x.push({event:T,listeners:O}))}var NI=null,II=null;function xFt(x){PAe(x,0)}function X4(x){var O=Hs(x);if(Ws(O))return x}function JTe(x,O){if(x==="change")return O}var eNe=!1;if(Ba){var rG;if(Ba){var sG="oninput"in document;if(!sG){var tNe=document.createElement("div");tNe.setAttribute("oninput","return;"),sG=typeof tNe.oninput=="function"}rG=sG}else rG=!1;eNe=rG&&(!document.documentMode||9<document.documentMode)}function nNe(){NI&&(NI.detachEvent("onpropertychange",rNe),II=NI=null)}function rNe(x){if(x.propertyName==="value"&&X4(II)){var O=[];KTe(O,II,x,OI(x)),Ea(xFt,O)}}function wFt(x,O,T){x==="focusin"?(nNe(),NI=O,II=T,NI.attachEvent("onpropertychange",rNe)):x==="focusout"&&nNe()}function SFt(x){if(x==="selectionchange"||x==="keyup"||x==="keydown")return X4(II)}function kFt(x,O){if(x==="click")return X4(O)}function OFt(x,O){if(x==="input"||x==="change")return X4(O)}function _Ft(x,O){return x===O&&(x!==0||1/x===1/O)||x!==x&&O!==O}var $f=typeof Object.is=="function"?Object.is:_Ft;function AI(x,O){if($f(x,O))return!0;if(typeof x!="object"||x===null||typeof O!="object"||O===null)return!1;var T=Object.keys(x),A=Object.keys(O);if(T.length!==A.length)return!1;for(A=0;A<T.length;A++){var H=T[A];if(!Ne.call(O,H)||!$f(x[H],O[H]))return!1}return!0}function sNe(x){for(;x&&x.firstChild;)x=x.firstChild;return x}function aNe(x,O){var T=sNe(x);x=0;for(var A;T;){if(T.nodeType===3){if(A=x+T.textContent.length,x<=O&&A>=O)return{node:T,offset:O-x};x=A}e:{for(;T;){if(T.nextSibling){T=T.nextSibling;break e}T=T.parentNode}T=void 0}T=sNe(T)}}function iNe(x,O){return x&&O?x===O?!0:x&&x.nodeType===3?!1:O&&O.nodeType===3?iNe(x,O.parentNode):"contains"in x?x.contains(O):x.compareDocumentPosition?!!(x.compareDocumentPosition(O)&16):!1:!1}function oNe(x){x=x!=null&&x.ownerDocument!=null&&x.ownerDocument.defaultView!=null?x.ownerDocument.defaultView:window;for(var O=lu(x.document);O instanceof x.HTMLIFrameElement;){try{var T=typeof O.contentWindow.location.href=="string"}catch{T=!1}if(T)x=O.contentWindow;else break;O=lu(x.document)}return O}function aG(x){var O=x&&x.nodeName&&x.nodeName.toLowerCase();return O&&(O==="input"&&(x.type==="text"||x.type==="search"||x.type==="tel"||x.type==="url"||x.type==="password")||O==="textarea"||x.contentEditable==="true")}var CFt=Ba&&"documentMode"in document&&11>=document.documentMode,K_=null,iG=null,RI=null,oG=!1;function lNe(x,O,T){var A=T.window===T?T.document:T.nodeType===9?T:T.ownerDocument;oG||K_==null||K_!==lu(A)||(A=K_,"selectionStart"in A&&aG(A)?A={start:A.selectionStart,end:A.selectionEnd}:(A=(A.ownerDocument&&A.ownerDocument.defaultView||window).getSelection(),A={anchorNode:A.anchorNode,anchorOffset:A.anchorOffset,focusNode:A.focusNode,focusOffset:A.focusOffset}),RI&&AI(RI,A)||(RI=A,A=F5(iG,"onSelect"),0<A.length&&(O=new Q4("onSelect","select",null,O,T),x.push({event:O,listeners:A}),O.target=K_)))}function tS(x,O){var T={};return T[x.toLowerCase()]=O.toLowerCase(),T["Webkit"+x]="webkit"+O,T["Moz"+x]="moz"+O,T}var J_={animationend:tS("Animation","AnimationEnd"),animationiteration:tS("Animation","AnimationIteration"),animationstart:tS("Animation","AnimationStart"),transitionrun:tS("Transition","TransitionRun"),transitionstart:tS("Transition","TransitionStart"),transitioncancel:tS("Transition","TransitionCancel"),transitionend:tS("Transition","TransitionEnd")},lG={},cNe={};Ba&&(cNe=document.createElement("div").style,"AnimationEvent"in window||(delete J_.animationend.animation,delete J_.animationiteration.animation,delete J_.animationstart.animation),"TransitionEvent"in window||delete J_.transitionend.transition);function nS(x){if(lG[x])return lG[x];if(!J_[x])return x;var O=J_[x],T;for(T in O)if(O.hasOwnProperty(T)&&T in cNe)return lG[x]=O[T];return x}var uNe=nS("animationend"),dNe=nS("animationiteration"),fNe=nS("animationstart"),EFt=nS("transitionrun"),jFt=nS("transitionstart"),TFt=nS("transitioncancel"),pNe=nS("transitionend"),hNe=new Map,cG="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");cG.push("scrollEnd");function Am(x,O){hNe.set(x,O),gl(O,[x])}var K4=typeof reportError=="function"?reportError:function(x){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var O=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof x=="object"&&x!==null&&typeof x.message=="string"?String(x.message):String(x),error:x});if(!window.dispatchEvent(O))return}else if(typeof e=="object"&&typeof e.emit=="function"){e.emit("uncaughtException",x);return}console.error(x)},th=[],eC=0,uG=0;function J4(){for(var x=eC,O=uG=eC=0;O<x;){var T=th[O];th[O++]=null;var A=th[O];th[O++]=null;var H=th[O];th[O++]=null;var Q=th[O];if(th[O++]=null,A!==null&&H!==null){var ie=A.pending;ie===null?H.next=H:(H.next=ie.next,ie.next=H),A.pending=H}Q!==0&&mNe(T,H,Q)}}function e5(x,O,T,A){th[eC++]=x,th[eC++]=O,th[eC++]=T,th[eC++]=A,uG|=A,x.lanes|=A,x=x.alternate,x!==null&&(x.lanes|=A)}function dG(x,O,T,A){return e5(x,O,T,A),t5(x)}function rS(x,O){return e5(x,null,null,O),t5(x)}function mNe(x,O,T){x.lanes|=T;var A=x.alternate;A!==null&&(A.lanes|=T);for(var H=!1,Q=x.return;Q!==null;)Q.childLanes|=T,A=Q.alternate,A!==null&&(A.childLanes|=T),Q.tag===22&&(x=Q.stateNode,x===null||x._visibility&1||(H=!0)),x=Q,Q=Q.return;return x.tag===3?(Q=x.stateNode,H&&O!==null&&(H=31-Re(T),x=Q.hiddenUpdates,A=x[H],A===null?x[H]=[O]:A.push(O),O.lane=T|536870912),Q):null}function t5(x){if(50<tA)throw tA=0,xQ=null,Error(s(185));for(var O=x.return;O!==null;)x=O,O=x.return;return x.tag===3?x.stateNode:null}var tC={};function NFt(x,O,T,A){this.tag=x,this.key=T,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=O,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=A,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Mf(x,O,T,A){return new NFt(x,O,T,A)}function fG(x){return x=x.prototype,!(!x||!x.isReactComponent)}function Vy(x,O){var T=x.alternate;return T===null?(T=Mf(x.tag,O,x.key,x.mode),T.elementType=x.elementType,T.type=x.type,T.stateNode=x.stateNode,T.alternate=x,x.alternate=T):(T.pendingProps=O,T.type=x.type,T.flags=0,T.subtreeFlags=0,T.deletions=null),T.flags=x.flags&65011712,T.childLanes=x.childLanes,T.lanes=x.lanes,T.child=x.child,T.memoizedProps=x.memoizedProps,T.memoizedState=x.memoizedState,T.updateQueue=x.updateQueue,O=x.dependencies,T.dependencies=O===null?null:{lanes:O.lanes,firstContext:O.firstContext},T.sibling=x.sibling,T.index=x.index,T.ref=x.ref,T.refCleanup=x.refCleanup,T}function gNe(x,O){x.flags&=65011714;var T=x.alternate;return T===null?(x.childLanes=0,x.lanes=O,x.child=null,x.subtreeFlags=0,x.memoizedProps=null,x.memoizedState=null,x.updateQueue=null,x.dependencies=null,x.stateNode=null):(x.childLanes=T.childLanes,x.lanes=T.lanes,x.child=T.child,x.subtreeFlags=0,x.deletions=null,x.memoizedProps=T.memoizedProps,x.memoizedState=T.memoizedState,x.updateQueue=T.updateQueue,x.type=T.type,O=T.dependencies,x.dependencies=O===null?null:{lanes:O.lanes,firstContext:O.firstContext}),x}function n5(x,O,T,A,H,Q){var ie=0;if(A=x,typeof x=="function")fG(x)&&(ie=1);else if(typeof x=="string")ie=$zt(x,T,Z.current)?26:x==="html"||x==="head"||x==="body"?27:5;else e:switch(x){case I:return x=Mf(31,T,O,H),x.elementType=I,x.lanes=Q,x;case y:return sS(T.children,H,Q,O);case b:ie=8,H|=24;break;case w:return x=Mf(12,T,O,H|2),x.elementType=w,x.lanes=Q,x;case C:return x=Mf(13,T,O,H),x.elementType=C,x.lanes=Q,x;case E:return x=Mf(19,T,O,H),x.elementType=E,x.lanes=Q,x;default:if(typeof x=="object"&&x!==null)switch(x.$$typeof){case k:ie=10;break e;case S:ie=9;break e;case _:ie=11;break e;case j:ie=14;break e;case N:ie=16,A=null;break e}ie=29,T=Error(s(130,x===null?"null":typeof x,"")),A=null}return O=Mf(ie,T,O,H),O.elementType=x,O.type=A,O.lanes=Q,O}function sS(x,O,T,A){return x=Mf(7,x,A,O),x.lanes=T,x}function pG(x,O,T){return x=Mf(6,x,null,O),x.lanes=T,x}function vNe(x){var O=Mf(18,null,null,0);return O.stateNode=x,O}function hG(x,O,T){return O=Mf(4,x.children!==null?x.children:[],x.key,O),O.lanes=T,O.stateNode={containerInfo:x.containerInfo,pendingChildren:null,implementation:x.implementation},O}var yNe=new WeakMap;function nh(x,O){if(typeof x=="object"&&x!==null){var T=yNe.get(x);return T!==void 0?T:(O={value:x,source:O,stack:Se(O)},yNe.set(x,O),O)}return{value:x,source:O,stack:Se(O)}}var nC=[],rC=0,r5=null,PI=0,rh=[],sh=0,o0=null,Qg=1,Yg="";function Hy(x,O){nC[rC++]=PI,nC[rC++]=r5,r5=x,PI=O}function bNe(x,O,T){rh[sh++]=Qg,rh[sh++]=Yg,rh[sh++]=o0,o0=x;var A=Qg;x=Yg;var H=32-Re(A)-1;A&=~(1<<H),T+=1;var Q=32-Re(O)+H;if(30<Q){var ie=H-H%5;Q=(A&(1<<ie)-1).toString(32),A>>=ie,H-=ie,Qg=1<<32-Re(O)+H|T<<H|A,Yg=Q+x}else Qg=1<<Q|T<<H|A,Yg=x}function mG(x){x.return!==null&&(Hy(x,1),bNe(x,1,0))}function gG(x){for(;x===r5;)r5=nC[--rC],nC[rC]=null,PI=nC[--rC],nC[rC]=null;for(;x===o0;)o0=rh[--sh],rh[sh]=null,Yg=rh[--sh],rh[sh]=null,Qg=rh[--sh],rh[sh]=null}function xNe(x,O){rh[sh++]=Qg,rh[sh++]=Yg,rh[sh++]=o0,Qg=O.id,Yg=O.overflow,o0=x}var Ic=null,Ui=null,Zs=!1,l0=null,ah=!1,vG=Error(s(519));function c0(x){var O=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw $I(nh(O,x)),vG}function wNe(x){var O=x.stateNode,T=x.type,A=x.memoizedProps;switch(O[Ft]=x,O[$t]=A,T){case"dialog":js("cancel",O),js("close",O);break;case"iframe":case"object":case"embed":js("load",O);break;case"video":case"audio":for(T=0;T<rA.length;T++)js(rA[T],O);break;case"source":js("error",O);break;case"img":case"image":case"link":js("error",O),js("load",O);break;case"details":js("toggle",O);break;case"input":js("invalid",O),qy(O,A.value,A.defaultValue,A.checked,A.defaultChecked,A.type,A.name,!0);break;case"select":js("invalid",O);break;case"textarea":js("invalid",O),kI(O,A.value,A.defaultValue,A.children)}T=A.children,typeof T!="string"&&typeof T!="number"&&typeof T!="bigint"||O.textContent===""+T||A.suppressHydrationWarning===!0||LAe(O.textContent,T)?(A.popover!=null&&(js("beforetoggle",O),js("toggle",O)),A.onScroll!=null&&js("scroll",O),A.onScrollEnd!=null&&js("scrollend",O),A.onClick!=null&&(O.onclick=Nm),O=!0):O=!1,O||c0(x,!0)}function SNe(x){for(Ic=x.return;Ic;)switch(Ic.tag){case 5:case 31:case 13:ah=!1;return;case 27:case 3:ah=!0;return;default:Ic=Ic.return}}function sC(x){if(x!==Ic)return!1;if(!Zs)return SNe(x),Zs=!0,!1;var O=x.tag,T;if((T=O!==3&&O!==27)&&((T=O===5)&&(T=x.type,T=!(T!=="form"&&T!=="button")||$Q(x.type,x.memoizedProps)),T=!T),T&&Ui&&c0(x),SNe(x),O===13){if(x=x.memoizedState,x=x!==null?x.dehydrated:null,!x)throw Error(s(317));Ui=ZAe(x)}else if(O===31){if(x=x.memoizedState,x=x!==null?x.dehydrated:null,!x)throw Error(s(317));Ui=ZAe(x)}else O===27?(O=Ui,k0(x.type)?(x=zQ,zQ=null,Ui=x):Ui=O):Ui=Ic?oh(x.stateNode.nextSibling):null;return!0}function aS(){Ui=Ic=null,Zs=!1}function yG(){var x=l0;return x!==null&&(Rd===null?Rd=x:Rd.push.apply(Rd,x),l0=null),x}function $I(x){l0===null?l0=[x]:l0.push(x)}var bG=U(null),iS=null,Wy=null;function u0(x,O,T){q(bG,O._currentValue),O._currentValue=T}function Zy(x){x._currentValue=bG.current,P(bG)}function xG(x,O,T){for(;x!==null;){var A=x.alternate;if((x.childLanes&O)!==O?(x.childLanes|=O,A!==null&&(A.childLanes|=O)):A!==null&&(A.childLanes&O)!==O&&(A.childLanes|=O),x===T)break;x=x.return}}function wG(x,O,T,A){var H=x.child;for(H!==null&&(H.return=x);H!==null;){var Q=H.dependencies;if(Q!==null){var ie=H.child;Q=Q.firstContext;e:for(;Q!==null;){var we=Q;Q=H;for(var Be=0;Be<O.length;Be++)if(we.context===O[Be]){Q.lanes|=T,we=Q.alternate,we!==null&&(we.lanes|=T),xG(Q.return,T,x),A||(ie=null);break e}Q=we.next}}else if(H.tag===18){if(ie=H.return,ie===null)throw Error(s(341));ie.lanes|=T,Q=ie.alternate,Q!==null&&(Q.lanes|=T),xG(ie,T,x),ie=null}else ie=H.child;if(ie!==null)ie.return=H;else for(ie=H;ie!==null;){if(ie===x){ie=null;break}if(H=ie.sibling,H!==null){H.return=ie.return,ie=H;break}ie=ie.return}H=ie}}function aC(x,O,T,A){x=null;for(var H=O,Q=!1;H!==null;){if(!Q){if((H.flags&524288)!==0)Q=!0;else if((H.flags&262144)!==0)break}if(H.tag===10){var ie=H.alternate;if(ie===null)throw Error(s(387));if(ie=ie.memoizedProps,ie!==null){var we=H.type;$f(H.pendingProps.value,ie.value)||(x!==null?x.push(we):x=[we])}}else if(H===J.current){if(ie=H.alternate,ie===null)throw Error(s(387));ie.memoizedState.memoizedState!==H.memoizedState.memoizedState&&(x!==null?x.push(lA):x=[lA])}H=H.return}x!==null&&wG(O,x,T,A),O.flags|=262144}function s5(x){for(x=x.firstContext;x!==null;){if(!$f(x.context._currentValue,x.memoizedValue))return!0;x=x.next}return!1}function oS(x){iS=x,Wy=null,x=x.dependencies,x!==null&&(x.firstContext=null)}function Ac(x){return kNe(iS,x)}function a5(x,O){return iS===null&&oS(x),kNe(x,O)}function kNe(x,O){var T=O._currentValue;if(O={context:O,memoizedValue:T,next:null},Wy===null){if(x===null)throw Error(s(308));Wy=O,x.dependencies={lanes:0,firstContext:O},x.flags|=524288}else Wy=Wy.next=O;return T}var IFt=typeof AbortController<"u"?AbortController:function(){var x=[],O=this.signal={aborted:!1,addEventListener:function(T,A){x.push(A)}};this.abort=function(){O.aborted=!0,x.forEach(function(T){return T()})}},AFt=t.unstable_scheduleCallback,RFt=t.unstable_NormalPriority,vl={$$typeof:k,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function SG(){return{controller:new IFt,data:new Map,refCount:0}}function MI(x){x.refCount--,x.refCount===0&&AFt(RFt,function(){x.controller.abort()})}var DI=null,kG=0,iC=0,oC=null;function PFt(x,O){if(DI===null){var T=DI=[];kG=0,iC=CQ(),oC={status:"pending",value:void 0,then:function(A){T.push(A)}}}return kG++,O.then(ONe,ONe),O}function ONe(){if(--kG===0&&DI!==null){oC!==null&&(oC.status="fulfilled");var x=DI;DI=null,iC=0,oC=null;for(var O=0;O<x.length;O++)(0,x[O])()}}function $Ft(x,O){var T=[],A={status:"pending",value:null,reason:null,then:function(H){T.push(H)}};return x.then(function(){A.status="fulfilled",A.value=O;for(var H=0;H<T.length;H++)(0,T[H])(O)},function(H){for(A.status="rejected",A.reason=H,H=0;H<T.length;H++)(0,T[H])(void 0)}),A}var _Ne=L.S;L.S=function(x,O){lAe=se(),typeof O=="object"&&O!==null&&typeof O.then=="function"&&PFt(x,O),_Ne!==null&&_Ne(x,O)};var lS=U(null);function OG(){var x=lS.current;return x!==null?x:mi.pooledCache}function i5(x,O){O===null?q(lS,lS.current):q(lS,O.pool)}function CNe(){var x=OG();return x===null?null:{parent:vl._currentValue,pool:x}}var lC=Error(s(460)),_G=Error(s(474)),o5=Error(s(542)),l5={then:function(){}};function ENe(x){return x=x.status,x==="fulfilled"||x==="rejected"}function jNe(x,O,T){switch(T=x[T],T===void 0?x.push(O):T!==O&&(O.then(Nm,Nm),O=T),O.status){case"fulfilled":return O.value;case"rejected":throw x=O.reason,NNe(x),x;default:if(typeof O.status=="string")O.then(Nm,Nm);else{if(x=mi,x!==null&&100<x.shellSuspendCounter)throw Error(s(482));x=O,x.status="pending",x.then(function(A){if(O.status==="pending"){var H=O;H.status="fulfilled",H.value=A}},function(A){if(O.status==="pending"){var H=O;H.status="rejected",H.reason=A}})}switch(O.status){case"fulfilled":return O.value;case"rejected":throw x=O.reason,NNe(x),x}throw uS=O,lC}}function cS(x){try{var O=x._init;return O(x._payload)}catch(T){throw T!==null&&typeof T=="object"&&typeof T.then=="function"?(uS=T,lC):T}}var uS=null;function TNe(){if(uS===null)throw Error(s(459));var x=uS;return uS=null,x}function NNe(x){if(x===lC||x===o5)throw Error(s(483))}var cC=null,LI=0;function c5(x){var O=LI;return LI+=1,cC===null&&(cC=[]),jNe(cC,x,O)}function FI(x,O){O=O.props.ref,x.ref=O!==void 0?O:null}function u5(x,O){throw O.$$typeof===h?Error(s(525)):(x=Object.prototype.toString.call(O),Error(s(31,x==="[object Object]"?"object with keys {"+Object.keys(O).join(", ")+"}":x)))}function INe(x){function O(et,He){if(x){var rt=et.deletions;rt===null?(et.deletions=[He],et.flags|=16):rt.push(He)}}function T(et,He){if(!x)return null;for(;He!==null;)O(et,He),He=He.sibling;return null}function A(et){for(var He=new Map;et!==null;)et.key!==null?He.set(et.key,et):He.set(et.index,et),et=et.sibling;return He}function H(et,He){return et=Vy(et,He),et.index=0,et.sibling=null,et}function Q(et,He,rt){return et.index=rt,x?(rt=et.alternate,rt!==null?(rt=rt.index,rt<He?(et.flags|=67108866,He):rt):(et.flags|=67108866,He)):(et.flags|=1048576,He)}function ie(et){return x&&et.alternate===null&&(et.flags|=67108866),et}function we(et,He,rt,kt){return He===null||He.tag!==6?(He=pG(rt,et.mode,kt),He.return=et,He):(He=H(He,rt),He.return=et,He)}function Be(et,He,rt,kt){var cr=rt.type;return cr===y?xt(et,He,rt.props.children,kt,rt.key):He!==null&&(He.elementType===cr||typeof cr=="object"&&cr!==null&&cr.$$typeof===N&&cS(cr)===He.type)?(He=H(He,rt.props),FI(He,rt),He.return=et,He):(He=n5(rt.type,rt.key,rt.props,null,et.mode,kt),FI(He,rt),He.return=et,He)}function st(et,He,rt,kt){return He===null||He.tag!==4||He.stateNode.containerInfo!==rt.containerInfo||He.stateNode.implementation!==rt.implementation?(He=hG(rt,et.mode,kt),He.return=et,He):(He=H(He,rt.children||[]),He.return=et,He)}function xt(et,He,rt,kt,cr){return He===null||He.tag!==7?(He=sS(rt,et.mode,kt,cr),He.return=et,He):(He=H(He,rt),He.return=et,He)}function Ct(et,He,rt){if(typeof He=="string"&&He!==""||typeof He=="number"||typeof He=="bigint")return He=pG(""+He,et.mode,rt),He.return=et,He;if(typeof He=="object"&&He!==null){switch(He.$$typeof){case m:return rt=n5(He.type,He.key,He.props,null,et.mode,rt),FI(rt,He),rt.return=et,rt;case g:return He=hG(He,et.mode,rt),He.return=et,He;case N:return He=cS(He),Ct(et,He,rt)}if(W(He)||F(He))return He=sS(He,et.mode,rt,null),He.return=et,He;if(typeof He.then=="function")return Ct(et,c5(He),rt);if(He.$$typeof===k)return Ct(et,a5(et,He),rt);u5(et,He)}return null}function lt(et,He,rt,kt){var cr=He!==null?He.key:null;if(typeof rt=="string"&&rt!==""||typeof rt=="number"||typeof rt=="bigint")return cr!==null?null:we(et,He,""+rt,kt);if(typeof rt=="object"&&rt!==null){switch(rt.$$typeof){case m:return rt.key===cr?Be(et,He,rt,kt):null;case g:return rt.key===cr?st(et,He,rt,kt):null;case N:return rt=cS(rt),lt(et,He,rt,kt)}if(W(rt)||F(rt))return cr!==null?null:xt(et,He,rt,kt,null);if(typeof rt.then=="function")return lt(et,He,c5(rt),kt);if(rt.$$typeof===k)return lt(et,He,a5(et,rt),kt);u5(et,rt)}return null}function dt(et,He,rt,kt,cr){if(typeof kt=="string"&&kt!==""||typeof kt=="number"||typeof kt=="bigint")return et=et.get(rt)||null,we(He,et,""+kt,cr);if(typeof kt=="object"&&kt!==null){switch(kt.$$typeof){case m:return et=et.get(kt.key===null?rt:kt.key)||null,Be(He,et,kt,cr);case g:return et=et.get(kt.key===null?rt:kt.key)||null,st(He,et,kt,cr);case N:return kt=cS(kt),dt(et,He,rt,kt,cr)}if(W(kt)||F(kt))return et=et.get(rt)||null,xt(He,et,kt,cr,null);if(typeof kt.then=="function")return dt(et,He,rt,c5(kt),cr);if(kt.$$typeof===k)return dt(et,He,rt,a5(He,kt),cr);u5(He,kt)}return null}function Mn(et,He,rt,kt){for(var cr=null,pa=null,Gn=He,rs=He=0,Fs=null;Gn!==null&&rs<rt.length;rs++){Gn.index>rs?(Fs=Gn,Gn=null):Fs=Gn.sibling;var ha=lt(et,Gn,rt[rs],kt);if(ha===null){Gn===null&&(Gn=Fs);break}x&&Gn&&ha.alternate===null&&O(et,Gn),He=Q(ha,He,rs),pa===null?cr=ha:pa.sibling=ha,pa=ha,Gn=Fs}if(rs===rt.length)return T(et,Gn),Zs&&Hy(et,rs),cr;if(Gn===null){for(;rs<rt.length;rs++)Gn=Ct(et,rt[rs],kt),Gn!==null&&(He=Q(Gn,He,rs),pa===null?cr=Gn:pa.sibling=Gn,pa=Gn);return Zs&&Hy(et,rs),cr}for(Gn=A(Gn);rs<rt.length;rs++)Fs=dt(Gn,et,rs,rt[rs],kt),Fs!==null&&(x&&Fs.alternate!==null&&Gn.delete(Fs.key===null?rs:Fs.key),He=Q(Fs,He,rs),pa===null?cr=Fs:pa.sibling=Fs,pa=Fs);return x&&Gn.forEach(function(j0){return O(et,j0)}),Zs&&Hy(et,rs),cr}function yr(et,He,rt,kt){if(rt==null)throw Error(s(151));for(var cr=null,pa=null,Gn=He,rs=He=0,Fs=null,ha=rt.next();Gn!==null&&!ha.done;rs++,ha=rt.next()){Gn.index>rs?(Fs=Gn,Gn=null):Fs=Gn.sibling;var j0=lt(et,Gn,ha.value,kt);if(j0===null){Gn===null&&(Gn=Fs);break}x&&Gn&&j0.alternate===null&&O(et,Gn),He=Q(j0,He,rs),pa===null?cr=j0:pa.sibling=j0,pa=j0,Gn=Fs}if(ha.done)return T(et,Gn),Zs&&Hy(et,rs),cr;if(Gn===null){for(;!ha.done;rs++,ha=rt.next())ha=Ct(et,ha.value,kt),ha!==null&&(He=Q(ha,He,rs),pa===null?cr=ha:pa.sibling=ha,pa=ha);return Zs&&Hy(et,rs),cr}for(Gn=A(Gn);!ha.done;rs++,ha=rt.next())ha=dt(Gn,et,rs,ha.value,kt),ha!==null&&(x&&ha.alternate!==null&&Gn.delete(ha.key===null?rs:ha.key),He=Q(ha,He,rs),pa===null?cr=ha:pa.sibling=ha,pa=ha);return x&&Gn.forEach(function(Wzt){return O(et,Wzt)}),Zs&&Hy(et,rs),cr}function ti(et,He,rt,kt){if(typeof rt=="object"&&rt!==null&&rt.type===y&&rt.key===null&&(rt=rt.props.children),typeof rt=="object"&&rt!==null){switch(rt.$$typeof){case m:e:{for(var cr=rt.key;He!==null;){if(He.key===cr){if(cr=rt.type,cr===y){if(He.tag===7){T(et,He.sibling),kt=H(He,rt.props.children),kt.return=et,et=kt;break e}}else if(He.elementType===cr||typeof cr=="object"&&cr!==null&&cr.$$typeof===N&&cS(cr)===He.type){T(et,He.sibling),kt=H(He,rt.props),FI(kt,rt),kt.return=et,et=kt;break e}T(et,He);break}else O(et,He);He=He.sibling}rt.type===y?(kt=sS(rt.props.children,et.mode,kt,rt.key),kt.return=et,et=kt):(kt=n5(rt.type,rt.key,rt.props,null,et.mode,kt),FI(kt,rt),kt.return=et,et=kt)}return ie(et);case g:e:{for(cr=rt.key;He!==null;){if(He.key===cr)if(He.tag===4&&He.stateNode.containerInfo===rt.containerInfo&&He.stateNode.implementation===rt.implementation){T(et,He.sibling),kt=H(He,rt.children||[]),kt.return=et,et=kt;break e}else{T(et,He);break}else O(et,He);He=He.sibling}kt=hG(rt,et.mode,kt),kt.return=et,et=kt}return ie(et);case N:return rt=cS(rt),ti(et,He,rt,kt)}if(W(rt))return Mn(et,He,rt,kt);if(F(rt)){if(cr=F(rt),typeof cr!="function")throw Error(s(150));return rt=cr.call(rt),yr(et,He,rt,kt)}if(typeof rt.then=="function")return ti(et,He,c5(rt),kt);if(rt.$$typeof===k)return ti(et,He,a5(et,rt),kt);u5(et,rt)}return typeof rt=="string"&&rt!==""||typeof rt=="number"||typeof rt=="bigint"?(rt=""+rt,He!==null&&He.tag===6?(T(et,He.sibling),kt=H(He,rt),kt.return=et,et=kt):(T(et,He),kt=pG(rt,et.mode,kt),kt.return=et,et=kt),ie(et)):T(et,He)}return function(et,He,rt,kt){try{LI=0;var cr=ti(et,He,rt,kt);return cC=null,cr}catch(Gn){if(Gn===lC||Gn===o5)throw Gn;var pa=Mf(29,Gn,null,et.mode);return pa.lanes=kt,pa.return=et,pa}}}var dS=INe(!0),ANe=INe(!1),d0=!1;function CG(x){x.updateQueue={baseState:x.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function EG(x,O){x=x.updateQueue,O.updateQueue===x&&(O.updateQueue={baseState:x.baseState,firstBaseUpdate:x.firstBaseUpdate,lastBaseUpdate:x.lastBaseUpdate,shared:x.shared,callbacks:null})}function f0(x){return{lane:x,tag:0,payload:null,callback:null,next:null}}function p0(x,O,T){var A=x.updateQueue;if(A===null)return null;if(A=A.shared,(ja&2)!==0){var H=A.pending;return H===null?O.next=O:(O.next=H.next,H.next=O),A.pending=O,O=t5(x),mNe(x,null,T),O}return e5(x,A,O,T),t5(x)}function zI(x,O,T){if(O=O.updateQueue,O!==null&&(O=O.shared,(T&4194048)!==0)){var A=O.lanes;A&=x.pendingLanes,T|=A,O.lanes=T,Te(x,T)}}function jG(x,O){var T=x.updateQueue,A=x.alternate;if(A!==null&&(A=A.updateQueue,T===A)){var H=null,Q=null;if(T=T.firstBaseUpdate,T!==null){do{var ie={lane:T.lane,tag:T.tag,payload:T.payload,callback:null,next:null};Q===null?H=Q=ie:Q=Q.next=ie,T=T.next}while(T!==null);Q===null?H=Q=O:Q=Q.next=O}else H=Q=O;T={baseState:A.baseState,firstBaseUpdate:H,lastBaseUpdate:Q,shared:A.shared,callbacks:A.callbacks},x.updateQueue=T;return}x=T.lastBaseUpdate,x===null?T.firstBaseUpdate=O:x.next=O,T.lastBaseUpdate=O}var TG=!1;function BI(){if(TG){var x=oC;if(x!==null)throw x}}function UI(x,O,T,A){TG=!1;var H=x.updateQueue;d0=!1;var Q=H.firstBaseUpdate,ie=H.lastBaseUpdate,we=H.shared.pending;if(we!==null){H.shared.pending=null;var Be=we,st=Be.next;Be.next=null,ie===null?Q=st:ie.next=st,ie=Be;var xt=x.alternate;xt!==null&&(xt=xt.updateQueue,we=xt.lastBaseUpdate,we!==ie&&(we===null?xt.firstBaseUpdate=st:we.next=st,xt.lastBaseUpdate=Be))}if(Q!==null){var Ct=H.baseState;ie=0,xt=st=Be=null,we=Q;do{var lt=we.lane&-536870913,dt=lt!==we.lane;if(dt?(Ls<)===lt:(A<)===lt){lt!==0&<===iC&&(TG=!0),xt!==null&&(xt=xt.next={lane:0,tag:we.tag,payload:we.payload,callback:null,next:null});e:{var Mn=x,yr=we;lt=O;var ti=T;switch(yr.tag){case 1:if(Mn=yr.payload,typeof Mn=="function"){Ct=Mn.call(ti,Ct,lt);break e}Ct=Mn;break e;case 3:Mn.flags=Mn.flags&-65537|128;case 0:if(Mn=yr.payload,lt=typeof Mn=="function"?Mn.call(ti,Ct,lt):Mn,lt==null)break e;Ct=p({},Ct,lt);break e;case 2:d0=!0}}lt=we.callback,lt!==null&&(x.flags|=64,dt&&(x.flags|=8192),dt=H.callbacks,dt===null?H.callbacks=[lt]:dt.push(lt))}else dt={lane:lt,tag:we.tag,payload:we.payload,callback:we.callback,next:null},xt===null?(st=xt=dt,Be=Ct):xt=xt.next=dt,ie|=lt;if(we=we.next,we===null){if(we=H.shared.pending,we===null)break;dt=we,we=dt.next,dt.next=null,H.lastBaseUpdate=dt,H.shared.pending=null}}while(!0);xt===null&&(Be=Ct),H.baseState=Be,H.firstBaseUpdate=st,H.lastBaseUpdate=xt,Q===null&&(H.shared.lanes=0),y0|=ie,x.lanes=ie,x.memoizedState=Ct}}function RNe(x,O){if(typeof x!="function")throw Error(s(191,x));x.call(O)}function PNe(x,O){var T=x.callbacks;if(T!==null)for(x.callbacks=null,x=0;x<T.length;x++)RNe(T[x],O)}var uC=U(null),d5=U(0);function $Ne(x,O){x=nb,q(d5,x),q(uC,O),nb=x|O.baseLanes}function NG(){q(d5,nb),q(uC,uC.current)}function IG(){nb=d5.current,P(uC),P(d5)}var Df=U(null),ih=null;function h0(x){var O=x.alternate;q(ol,ol.current&1),q(Df,x),ih===null&&(O===null||uC.current!==null||O.memoizedState!==null)&&(ih=x)}function AG(x){q(ol,ol.current),q(Df,x),ih===null&&(ih=x)}function MNe(x){x.tag===22?(q(ol,ol.current),q(Df,x),ih===null&&(ih=x)):m0()}function m0(){q(ol,ol.current),q(Df,Df.current)}function Lf(x){P(Df),ih===x&&(ih=null),P(ol)}var ol=U(0);function f5(x){for(var O=x;O!==null;){if(O.tag===13){var T=O.memoizedState;if(T!==null&&(T=T.dehydrated,T===null||LQ(T)||FQ(T)))return O}else if(O.tag===19&&(O.memoizedProps.revealOrder==="forwards"||O.memoizedProps.revealOrder==="backwards"||O.memoizedProps.revealOrder==="unstable_legacy-backwards"||O.memoizedProps.revealOrder==="together")){if((O.flags&128)!==0)return O}else if(O.child!==null){O.child.return=O,O=O.child;continue}if(O===x)break;for(;O.sibling===null;){if(O.return===null||O.return===x)return null;O=O.return}O.sibling.return=O.return,O=O.sibling}return null}var Gy=0,Xr=null,Ja=null,yl=null,p5=!1,dC=!1,fS=!1,h5=0,qI=0,fC=null,MFt=0;function qo(){throw Error(s(321))}function RG(x,O){if(O===null)return!1;for(var T=0;T<O.length&&T<x.length;T++)if(!$f(x[T],O[T]))return!1;return!0}function PG(x,O,T,A,H,Q){return Gy=Q,Xr=O,O.memoizedState=null,O.updateQueue=null,O.lanes=0,L.H=x===null||x.memoizedState===null?bIe:QG,fS=!1,Q=T(A,H),fS=!1,dC&&(Q=LNe(O,T,A,H)),DNe(x),Q}function DNe(x){L.H=WI;var O=Ja!==null&&Ja.next!==null;if(Gy=0,yl=Ja=Xr=null,p5=!1,qI=0,fC=null,O)throw Error(s(300));x===null||bl||(x=x.dependencies,x!==null&&s5(x)&&(bl=!0))}function LNe(x,O,T,A){Xr=x;var H=0;do{if(dC&&(fC=null),qI=0,dC=!1,25<=H)throw Error(s(301));if(H+=1,yl=Ja=null,x.updateQueue!=null){var Q=x.updateQueue;Q.lastEffect=null,Q.events=null,Q.stores=null,Q.memoCache!=null&&(Q.memoCache.index=0)}L.H=xIe,Q=O(T,A)}while(dC);return Q}function DFt(){var x=L.H,O=x.useState()[0];return O=typeof O.then=="function"?VI(O):O,x=x.useState()[0],(Ja!==null?Ja.memoizedState:null)!==x&&(Xr.flags|=1024),O}function $G(){var x=h5!==0;return h5=0,x}function MG(x,O,T){O.updateQueue=x.updateQueue,O.flags&=-2053,x.lanes&=~T}function DG(x){if(p5){for(x=x.memoizedState;x!==null;){var O=x.queue;O!==null&&(O.pending=null),x=x.next}p5=!1}Gy=0,yl=Ja=Xr=null,dC=!1,qI=h5=0,fC=null}function Hu(){var x={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return yl===null?Xr.memoizedState=yl=x:yl=yl.next=x,yl}function ll(){if(Ja===null){var x=Xr.alternate;x=x!==null?x.memoizedState:null}else x=Ja.next;var O=yl===null?Xr.memoizedState:yl.next;if(O!==null)yl=O,Ja=x;else{if(x===null)throw Xr.alternate===null?Error(s(467)):Error(s(310));Ja=x,x={memoizedState:Ja.memoizedState,baseState:Ja.baseState,baseQueue:Ja.baseQueue,queue:Ja.queue,next:null},yl===null?Xr.memoizedState=yl=x:yl=yl.next=x}return yl}function m5(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function VI(x){var O=qI;return qI+=1,fC===null&&(fC=[]),x=jNe(fC,x,O),O=Xr,(yl===null?O.memoizedState:yl.next)===null&&(O=O.alternate,L.H=O===null||O.memoizedState===null?bIe:QG),x}function g5(x){if(x!==null&&typeof x=="object"){if(typeof x.then=="function")return VI(x);if(x.$$typeof===k)return Ac(x)}throw Error(s(438,String(x)))}function LG(x){var O=null,T=Xr.updateQueue;if(T!==null&&(O=T.memoCache),O==null){var A=Xr.alternate;A!==null&&(A=A.updateQueue,A!==null&&(A=A.memoCache,A!=null&&(O={data:A.data.map(function(H){return H.slice()}),index:0})))}if(O==null&&(O={data:[],index:0}),T===null&&(T=m5(),Xr.updateQueue=T),T.memoCache=O,T=O.data[O.index],T===void 0)for(T=O.data[O.index]=Array(x),A=0;A<x;A++)T[A]=R;return O.index++,T}function Qy(x,O){return typeof O=="function"?O(x):O}function v5(x){var O=ll();return FG(O,Ja,x)}function FG(x,O,T){var A=x.queue;if(A===null)throw Error(s(311));A.lastRenderedReducer=T;var H=x.baseQueue,Q=A.pending;if(Q!==null){if(H!==null){var ie=H.next;H.next=Q.next,Q.next=ie}O.baseQueue=H=Q,A.pending=null}if(Q=x.baseState,H===null)x.memoizedState=Q;else{O=H.next;var we=ie=null,Be=null,st=O,xt=!1;do{var Ct=st.lane&-536870913;if(Ct!==st.lane?(Ls&Ct)===Ct:(Gy&Ct)===Ct){var lt=st.revertLane;if(lt===0)Be!==null&&(Be=Be.next={lane:0,revertLane:0,gesture:null,action:st.action,hasEagerState:st.hasEagerState,eagerState:st.eagerState,next:null}),Ct===iC&&(xt=!0);else if((Gy<)===lt){st=st.next,lt===iC&&(xt=!0);continue}else Ct={lane:0,revertLane:st.revertLane,gesture:null,action:st.action,hasEagerState:st.hasEagerState,eagerState:st.eagerState,next:null},Be===null?(we=Be=Ct,ie=Q):Be=Be.next=Ct,Xr.lanes|=lt,y0|=lt;Ct=st.action,fS&&T(Q,Ct),Q=st.hasEagerState?st.eagerState:T(Q,Ct)}else lt={lane:Ct,revertLane:st.revertLane,gesture:st.gesture,action:st.action,hasEagerState:st.hasEagerState,eagerState:st.eagerState,next:null},Be===null?(we=Be=lt,ie=Q):Be=Be.next=lt,Xr.lanes|=Ct,y0|=Ct;st=st.next}while(st!==null&&st!==O);if(Be===null?ie=Q:Be.next=we,!$f(Q,x.memoizedState)&&(bl=!0,xt&&(T=oC,T!==null)))throw T;x.memoizedState=Q,x.baseState=ie,x.baseQueue=Be,A.lastRenderedState=Q}return H===null&&(A.lanes=0),[x.memoizedState,A.dispatch]}function zG(x){var O=ll(),T=O.queue;if(T===null)throw Error(s(311));T.lastRenderedReducer=x;var A=T.dispatch,H=T.pending,Q=O.memoizedState;if(H!==null){T.pending=null;var ie=H=H.next;do Q=x(Q,ie.action),ie=ie.next;while(ie!==H);$f(Q,O.memoizedState)||(bl=!0),O.memoizedState=Q,O.baseQueue===null&&(O.baseState=Q),T.lastRenderedState=Q}return[Q,A]}function FNe(x,O,T){var A=Xr,H=ll(),Q=Zs;if(Q){if(T===void 0)throw Error(s(407));T=T()}else T=O();var ie=!$f((Ja||H).memoizedState,T);if(ie&&(H.memoizedState=T,bl=!0),H=H.queue,qG(UNe.bind(null,A,H,x),[x]),H.getSnapshot!==O||ie||yl!==null&&yl.memoizedState.tag&1){if(A.flags|=2048,pC(9,{destroy:void 0},BNe.bind(null,A,H,T,O),null),mi===null)throw Error(s(349));Q||(Gy&127)!==0||zNe(A,O,T)}return T}function zNe(x,O,T){x.flags|=16384,x={getSnapshot:O,value:T},O=Xr.updateQueue,O===null?(O=m5(),Xr.updateQueue=O,O.stores=[x]):(T=O.stores,T===null?O.stores=[x]:T.push(x))}function BNe(x,O,T,A){O.value=T,O.getSnapshot=A,qNe(O)&&VNe(x)}function UNe(x,O,T){return T(function(){qNe(O)&&VNe(x)})}function qNe(x){var O=x.getSnapshot;x=x.value;try{var T=O();return!$f(x,T)}catch{return!0}}function VNe(x){var O=rS(x,2);O!==null&&Pd(O,x,2)}function BG(x){var O=Hu();if(typeof x=="function"){var T=x;if(x=T(),fS){Oe(!0);try{T()}finally{Oe(!1)}}}return O.memoizedState=O.baseState=x,O.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qy,lastRenderedState:x},O}function HNe(x,O,T,A){return x.baseState=T,FG(x,Ja,typeof A=="function"?A:Qy)}function LFt(x,O,T,A,H){if(x5(x))throw Error(s(485));if(x=O.action,x!==null){var Q={payload:H,action:x,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(ie){Q.listeners.push(ie)}};L.T!==null?T(!0):Q.isTransition=!1,A(Q),T=O.pending,T===null?(Q.next=O.pending=Q,WNe(O,Q)):(Q.next=T.next,O.pending=T.next=Q)}}function WNe(x,O){var T=O.action,A=O.payload,H=x.state;if(O.isTransition){var Q=L.T,ie={};L.T=ie;try{var we=T(H,A),Be=L.S;Be!==null&&Be(ie,we),ZNe(x,O,we)}catch(st){UG(x,O,st)}finally{Q!==null&&ie.types!==null&&(Q.types=ie.types),L.T=Q}}else try{Q=T(H,A),ZNe(x,O,Q)}catch(st){UG(x,O,st)}}function ZNe(x,O,T){T!==null&&typeof T=="object"&&typeof T.then=="function"?T.then(function(A){GNe(x,O,A)},function(A){return UG(x,O,A)}):GNe(x,O,T)}function GNe(x,O,T){O.status="fulfilled",O.value=T,QNe(O),x.state=T,O=x.pending,O!==null&&(T=O.next,T===O?x.pending=null:(T=T.next,O.next=T,WNe(x,T)))}function UG(x,O,T){var A=x.pending;if(x.pending=null,A!==null){A=A.next;do O.status="rejected",O.reason=T,QNe(O),O=O.next;while(O!==A)}x.action=null}function QNe(x){x=x.listeners;for(var O=0;O<x.length;O++)(0,x[O])()}function YNe(x,O){return O}function XNe(x,O){if(Zs){var T=mi.formState;if(T!==null){e:{var A=Xr;if(Zs){if(Ui){t:{for(var H=Ui,Q=ah;H.nodeType!==8;){if(!Q){H=null;break t}if(H=oh(H.nextSibling),H===null){H=null;break t}}Q=H.data,H=Q==="F!"||Q==="F"?H:null}if(H){Ui=oh(H.nextSibling),A=H.data==="F!";break e}}c0(A)}A=!1}A&&(O=T[0])}}return T=Hu(),T.memoizedState=T.baseState=O,A={pending:null,lanes:0,dispatch:null,lastRenderedReducer:YNe,lastRenderedState:O},T.queue=A,T=gIe.bind(null,Xr,A),A.dispatch=T,A=BG(!1),Q=GG.bind(null,Xr,!1,A.queue),A=Hu(),H={state:O,dispatch:null,action:x,pending:null},A.queue=H,T=LFt.bind(null,Xr,H,Q,T),H.dispatch=T,A.memoizedState=x,[O,T,!1]}function KNe(x){var O=ll();return JNe(O,Ja,x)}function JNe(x,O,T){if(O=FG(x,O,YNe)[0],x=v5(Qy)[0],typeof O=="object"&&O!==null&&typeof O.then=="function")try{var A=VI(O)}catch(ie){throw ie===lC?o5:ie}else A=O;O=ll();var H=O.queue,Q=H.dispatch;return T!==O.memoizedState&&(Xr.flags|=2048,pC(9,{destroy:void 0},FFt.bind(null,H,T),null)),[A,Q,x]}function FFt(x,O){x.action=O}function eIe(x){var O=ll(),T=Ja;if(T!==null)return JNe(O,T,x);ll(),O=O.memoizedState,T=ll();var A=T.queue.dispatch;return T.memoizedState=x,[O,A,!1]}function pC(x,O,T,A){return x={tag:x,create:T,deps:A,inst:O,next:null},O=Xr.updateQueue,O===null&&(O=m5(),Xr.updateQueue=O),T=O.lastEffect,T===null?O.lastEffect=x.next=x:(A=T.next,T.next=x,x.next=A,O.lastEffect=x),x}function tIe(){return ll().memoizedState}function y5(x,O,T,A){var H=Hu();Xr.flags|=x,H.memoizedState=pC(1|O,{destroy:void 0},T,A===void 0?null:A)}function b5(x,O,T,A){var H=ll();A=A===void 0?null:A;var Q=H.memoizedState.inst;Ja!==null&&A!==null&&RG(A,Ja.memoizedState.deps)?H.memoizedState=pC(O,Q,T,A):(Xr.flags|=x,H.memoizedState=pC(1|O,Q,T,A))}function nIe(x,O){y5(8390656,8,x,O)}function qG(x,O){b5(2048,8,x,O)}function zFt(x){Xr.flags|=4;var O=Xr.updateQueue;if(O===null)O=m5(),Xr.updateQueue=O,O.events=[x];else{var T=O.events;T===null?O.events=[x]:T.push(x)}}function rIe(x){var O=ll().memoizedState;return zFt({ref:O,nextImpl:x}),function(){if((ja&2)!==0)throw Error(s(440));return O.impl.apply(void 0,arguments)}}function sIe(x,O){return b5(4,2,x,O)}function aIe(x,O){return b5(4,4,x,O)}function iIe(x,O){if(typeof O=="function"){x=x();var T=O(x);return function(){typeof T=="function"?T():O(null)}}if(O!=null)return x=x(),O.current=x,function(){O.current=null}}function oIe(x,O,T){T=T!=null?T.concat([x]):null,b5(4,4,iIe.bind(null,O,x),T)}function VG(){}function lIe(x,O){var T=ll();O=O===void 0?null:O;var A=T.memoizedState;return O!==null&&RG(O,A[1])?A[0]:(T.memoizedState=[x,O],x)}function cIe(x,O){var T=ll();O=O===void 0?null:O;var A=T.memoizedState;if(O!==null&&RG(O,A[1]))return A[0];if(A=x(),fS){Oe(!0);try{x()}finally{Oe(!1)}}return T.memoizedState=[A,O],A}function HG(x,O,T){return T===void 0||(Gy&1073741824)!==0&&(Ls&261930)===0?x.memoizedState=O:(x.memoizedState=T,x=uAe(),Xr.lanes|=x,y0|=x,T)}function uIe(x,O,T,A){return $f(T,O)?T:uC.current!==null?(x=HG(x,T,A),$f(x,O)||(bl=!0),x):(Gy&42)===0||(Gy&1073741824)!==0&&(Ls&261930)===0?(bl=!0,x.memoizedState=T):(x=uAe(),Xr.lanes|=x,y0|=x,O)}function dIe(x,O,T,A,H){var Q=z.p;z.p=Q!==0&&8>Q?Q:8;var ie=L.T,we={};L.T=we,GG(x,!1,O,T);try{var Be=H(),st=L.S;if(st!==null&&st(we,Be),Be!==null&&typeof Be=="object"&&typeof Be.then=="function"){var xt=$Ft(Be,A);HI(x,O,xt,Bf(x))}else HI(x,O,A,Bf(x))}catch(Ct){HI(x,O,{then:function(){},status:"rejected",reason:Ct},Bf())}finally{z.p=Q,ie!==null&&we.types!==null&&(ie.types=we.types),L.T=ie}}function BFt(){}function WG(x,O,T,A){if(x.tag!==5)throw Error(s(476));var H=fIe(x).queue;dIe(x,H,O,B,T===null?BFt:function(){return pIe(x),T(A)})}function fIe(x){var O=x.memoizedState;if(O!==null)return O;O={memoizedState:B,baseState:B,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qy,lastRenderedState:B},next:null};var T={};return O.next={memoizedState:T,baseState:T,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qy,lastRenderedState:T},next:null},x.memoizedState=O,x=x.alternate,x!==null&&(x.memoizedState=O),O}function pIe(x){var O=fIe(x);O.next===null&&(O=x.alternate.memoizedState),HI(x,O.next.queue,{},Bf())}function ZG(){return Ac(lA)}function hIe(){return ll().memoizedState}function mIe(){return ll().memoizedState}function UFt(x){for(var O=x.return;O!==null;){switch(O.tag){case 24:case 3:var T=Bf();x=f0(T);var A=p0(O,x,T);A!==null&&(Pd(A,O,T),zI(A,O,T)),O={cache:SG()},x.payload=O;return}O=O.return}}function qFt(x,O,T){var A=Bf();T={lane:A,revertLane:0,gesture:null,action:T,hasEagerState:!1,eagerState:null,next:null},x5(x)?vIe(O,T):(T=dG(x,O,T,A),T!==null&&(Pd(T,x,A),yIe(T,O,A)))}function gIe(x,O,T){var A=Bf();HI(x,O,T,A)}function HI(x,O,T,A){var H={lane:A,revertLane:0,gesture:null,action:T,hasEagerState:!1,eagerState:null,next:null};if(x5(x))vIe(O,H);else{var Q=x.alternate;if(x.lanes===0&&(Q===null||Q.lanes===0)&&(Q=O.lastRenderedReducer,Q!==null))try{var ie=O.lastRenderedState,we=Q(ie,T);if(H.hasEagerState=!0,H.eagerState=we,$f(we,ie))return e5(x,O,H,0),mi===null&&J4(),!1}catch{}if(T=dG(x,O,H,A),T!==null)return Pd(T,x,A),yIe(T,O,A),!0}return!1}function GG(x,O,T,A){if(A={lane:2,revertLane:CQ(),gesture:null,action:A,hasEagerState:!1,eagerState:null,next:null},x5(x)){if(O)throw Error(s(479))}else O=dG(x,T,A,2),O!==null&&Pd(O,x,2)}function x5(x){var O=x.alternate;return x===Xr||O!==null&&O===Xr}function vIe(x,O){dC=p5=!0;var T=x.pending;T===null?O.next=O:(O.next=T.next,T.next=O),x.pending=O}function yIe(x,O,T){if((T&4194048)!==0){var A=O.lanes;A&=x.pendingLanes,T|=A,O.lanes=T,Te(x,T)}}var WI={readContext:Ac,use:g5,useCallback:qo,useContext:qo,useEffect:qo,useImperativeHandle:qo,useLayoutEffect:qo,useInsertionEffect:qo,useMemo:qo,useReducer:qo,useRef:qo,useState:qo,useDebugValue:qo,useDeferredValue:qo,useTransition:qo,useSyncExternalStore:qo,useId:qo,useHostTransitionStatus:qo,useFormState:qo,useActionState:qo,useOptimistic:qo,useMemoCache:qo,useCacheRefresh:qo};WI.useEffectEvent=qo;var bIe={readContext:Ac,use:g5,useCallback:function(x,O){return Hu().memoizedState=[x,O===void 0?null:O],x},useContext:Ac,useEffect:nIe,useImperativeHandle:function(x,O,T){T=T!=null?T.concat([x]):null,y5(4194308,4,iIe.bind(null,O,x),T)},useLayoutEffect:function(x,O){return y5(4194308,4,x,O)},useInsertionEffect:function(x,O){y5(4,2,x,O)},useMemo:function(x,O){var T=Hu();O=O===void 0?null:O;var A=x();if(fS){Oe(!0);try{x()}finally{Oe(!1)}}return T.memoizedState=[A,O],A},useReducer:function(x,O,T){var A=Hu();if(T!==void 0){var H=T(O);if(fS){Oe(!0);try{T(O)}finally{Oe(!1)}}}else H=O;return A.memoizedState=A.baseState=H,x={pending:null,lanes:0,dispatch:null,lastRenderedReducer:x,lastRenderedState:H},A.queue=x,x=x.dispatch=qFt.bind(null,Xr,x),[A.memoizedState,x]},useRef:function(x){var O=Hu();return x={current:x},O.memoizedState=x},useState:function(x){x=BG(x);var O=x.queue,T=gIe.bind(null,Xr,O);return O.dispatch=T,[x.memoizedState,T]},useDebugValue:VG,useDeferredValue:function(x,O){var T=Hu();return HG(T,x,O)},useTransition:function(){var x=BG(!1);return x=dIe.bind(null,Xr,x.queue,!0,!1),Hu().memoizedState=x,[!1,x]},useSyncExternalStore:function(x,O,T){var A=Xr,H=Hu();if(Zs){if(T===void 0)throw Error(s(407));T=T()}else{if(T=O(),mi===null)throw Error(s(349));(Ls&127)!==0||zNe(A,O,T)}H.memoizedState=T;var Q={value:T,getSnapshot:O};return H.queue=Q,nIe(UNe.bind(null,A,Q,x),[x]),A.flags|=2048,pC(9,{destroy:void 0},BNe.bind(null,A,Q,T,O),null),T},useId:function(){var x=Hu(),O=mi.identifierPrefix;if(Zs){var T=Yg,A=Qg;T=(A&~(1<<32-Re(A)-1)).toString(32)+T,O="_"+O+"R_"+T,T=h5++,0<T&&(O+="H"+T.toString(32)),O+="_"}else T=MFt++,O="_"+O+"r_"+T.toString(32)+"_";return x.memoizedState=O},useHostTransitionStatus:ZG,useFormState:XNe,useActionState:XNe,useOptimistic:function(x){var O=Hu();O.memoizedState=O.baseState=x;var T={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return O.queue=T,O=GG.bind(null,Xr,!0,T),T.dispatch=O,[x,O]},useMemoCache:LG,useCacheRefresh:function(){return Hu().memoizedState=UFt.bind(null,Xr)},useEffectEvent:function(x){var O=Hu(),T={impl:x};return O.memoizedState=T,function(){if((ja&2)!==0)throw Error(s(440));return T.impl.apply(void 0,arguments)}}},QG={readContext:Ac,use:g5,useCallback:lIe,useContext:Ac,useEffect:qG,useImperativeHandle:oIe,useInsertionEffect:sIe,useLayoutEffect:aIe,useMemo:cIe,useReducer:v5,useRef:tIe,useState:function(){return v5(Qy)},useDebugValue:VG,useDeferredValue:function(x,O){var T=ll();return uIe(T,Ja.memoizedState,x,O)},useTransition:function(){var x=v5(Qy)[0],O=ll().memoizedState;return[typeof x=="boolean"?x:VI(x),O]},useSyncExternalStore:FNe,useId:hIe,useHostTransitionStatus:ZG,useFormState:KNe,useActionState:KNe,useOptimistic:function(x,O){var T=ll();return HNe(T,Ja,x,O)},useMemoCache:LG,useCacheRefresh:mIe};QG.useEffectEvent=rIe;var xIe={readContext:Ac,use:g5,useCallback:lIe,useContext:Ac,useEffect:qG,useImperativeHandle:oIe,useInsertionEffect:sIe,useLayoutEffect:aIe,useMemo:cIe,useReducer:zG,useRef:tIe,useState:function(){return zG(Qy)},useDebugValue:VG,useDeferredValue:function(x,O){var T=ll();return Ja===null?HG(T,x,O):uIe(T,Ja.memoizedState,x,O)},useTransition:function(){var x=zG(Qy)[0],O=ll().memoizedState;return[typeof x=="boolean"?x:VI(x),O]},useSyncExternalStore:FNe,useId:hIe,useHostTransitionStatus:ZG,useFormState:eIe,useActionState:eIe,useOptimistic:function(x,O){var T=ll();return Ja!==null?HNe(T,Ja,x,O):(T.baseState=x,[x,T.queue.dispatch])},useMemoCache:LG,useCacheRefresh:mIe};xIe.useEffectEvent=rIe;function YG(x,O,T,A){O=x.memoizedState,T=T(A,O),T=T==null?O:p({},O,T),x.memoizedState=T,x.lanes===0&&(x.updateQueue.baseState=T)}var XG={enqueueSetState:function(x,O,T){x=x._reactInternals;var A=Bf(),H=f0(A);H.payload=O,T!=null&&(H.callback=T),O=p0(x,H,A),O!==null&&(Pd(O,x,A),zI(O,x,A))},enqueueReplaceState:function(x,O,T){x=x._reactInternals;var A=Bf(),H=f0(A);H.tag=1,H.payload=O,T!=null&&(H.callback=T),O=p0(x,H,A),O!==null&&(Pd(O,x,A),zI(O,x,A))},enqueueForceUpdate:function(x,O){x=x._reactInternals;var T=Bf(),A=f0(T);A.tag=2,O!=null&&(A.callback=O),O=p0(x,A,T),O!==null&&(Pd(O,x,T),zI(O,x,T))}};function wIe(x,O,T,A,H,Q,ie){return x=x.stateNode,typeof x.shouldComponentUpdate=="function"?x.shouldComponentUpdate(A,Q,ie):O.prototype&&O.prototype.isPureReactComponent?!AI(T,A)||!AI(H,Q):!0}function SIe(x,O,T,A){x=O.state,typeof O.componentWillReceiveProps=="function"&&O.componentWillReceiveProps(T,A),typeof O.UNSAFE_componentWillReceiveProps=="function"&&O.UNSAFE_componentWillReceiveProps(T,A),O.state!==x&&XG.enqueueReplaceState(O,O.state,null)}function pS(x,O){var T=O;if("ref"in O){T={};for(var A in O)A!=="ref"&&(T[A]=O[A])}if(x=x.defaultProps){T===O&&(T=p({},T));for(var H in x)T[H]===void 0&&(T[H]=x[H])}return T}function kIe(x){K4(x)}function OIe(x){console.error(x)}function _Ie(x){K4(x)}function w5(x,O){try{var T=x.onUncaughtError;T(O.value,{componentStack:O.stack})}catch(A){setTimeout(function(){throw A})}}function CIe(x,O,T){try{var A=x.onCaughtError;A(T.value,{componentStack:T.stack,errorBoundary:O.tag===1?O.stateNode:null})}catch(H){setTimeout(function(){throw H})}}function KG(x,O,T){return T=f0(T),T.tag=3,T.payload={element:null},T.callback=function(){w5(x,O)},T}function EIe(x){return x=f0(x),x.tag=3,x}function jIe(x,O,T,A){var H=T.type.getDerivedStateFromError;if(typeof H=="function"){var Q=A.value;x.payload=function(){return H(Q)},x.callback=function(){CIe(O,T,A)}}var ie=T.stateNode;ie!==null&&typeof ie.componentDidCatch=="function"&&(x.callback=function(){CIe(O,T,A),typeof H!="function"&&(b0===null?b0=new Set([this]):b0.add(this));var we=A.stack;this.componentDidCatch(A.value,{componentStack:we!==null?we:""})})}function VFt(x,O,T,A,H){if(T.flags|=32768,A!==null&&typeof A=="object"&&typeof A.then=="function"){if(O=T.alternate,O!==null&&aC(O,T,H,!0),T=Df.current,T!==null){switch(T.tag){case 31:case 13:return ih===null?R5():T.alternate===null&&Vo===0&&(Vo=3),T.flags&=-257,T.flags|=65536,T.lanes=H,A===l5?T.flags|=16384:(O=T.updateQueue,O===null?T.updateQueue=new Set([A]):O.add(A),kQ(x,A,H)),!1;case 22:return T.flags|=65536,A===l5?T.flags|=16384:(O=T.updateQueue,O===null?(O={transitions:null,markerInstances:null,retryQueue:new Set([A])},T.updateQueue=O):(T=O.retryQueue,T===null?O.retryQueue=new Set([A]):T.add(A)),kQ(x,A,H)),!1}throw Error(s(435,T.tag))}return kQ(x,A,H),R5(),!1}if(Zs)return O=Df.current,O!==null?((O.flags&65536)===0&&(O.flags|=256),O.flags|=65536,O.lanes=H,A!==vG&&(x=Error(s(422),{cause:A}),$I(nh(x,T)))):(A!==vG&&(O=Error(s(423),{cause:A}),$I(nh(O,T))),x=x.current.alternate,x.flags|=65536,H&=-H,x.lanes|=H,A=nh(A,T),H=KG(x.stateNode,A,H),jG(x,H),Vo!==4&&(Vo=2)),!1;var Q=Error(s(520),{cause:A});if(Q=nh(Q,T),eA===null?eA=[Q]:eA.push(Q),Vo!==4&&(Vo=2),O===null)return!0;A=nh(A,T),T=O;do{switch(T.tag){case 3:return T.flags|=65536,x=H&-H,T.lanes|=x,x=KG(T.stateNode,A,x),jG(T,x),!1;case 1:if(O=T.type,Q=T.stateNode,(T.flags&128)===0&&(typeof O.getDerivedStateFromError=="function"||Q!==null&&typeof Q.componentDidCatch=="function"&&(b0===null||!b0.has(Q))))return T.flags|=65536,H&=-H,T.lanes|=H,H=EIe(H),jIe(H,x,T,A),jG(T,H),!1}T=T.return}while(T!==null);return!1}var JG=Error(s(461)),bl=!1;function Rc(x,O,T,A){O.child=x===null?ANe(O,null,T,A):dS(O,x.child,T,A)}function TIe(x,O,T,A,H){T=T.render;var Q=O.ref;if("ref"in A){var ie={};for(var we in A)we!=="ref"&&(ie[we]=A[we])}else ie=A;return oS(O),A=PG(x,O,T,ie,Q,H),we=$G(),x!==null&&!bl?(MG(x,O,H),Yy(x,O,H)):(Zs&&we&&mG(O),O.flags|=1,Rc(x,O,A,H),O.child)}function NIe(x,O,T,A,H){if(x===null){var Q=T.type;return typeof Q=="function"&&!fG(Q)&&Q.defaultProps===void 0&&T.compare===null?(O.tag=15,O.type=Q,IIe(x,O,Q,A,H)):(x=n5(T.type,null,A,O,O.mode,H),x.ref=O.ref,x.return=O,O.child=x)}if(Q=x.child,!oQ(x,H)){var ie=Q.memoizedProps;if(T=T.compare,T=T!==null?T:AI,T(ie,A)&&x.ref===O.ref)return Yy(x,O,H)}return O.flags|=1,x=Vy(Q,A),x.ref=O.ref,x.return=O,O.child=x}function IIe(x,O,T,A,H){if(x!==null){var Q=x.memoizedProps;if(AI(Q,A)&&x.ref===O.ref)if(bl=!1,O.pendingProps=A=Q,oQ(x,H))(x.flags&131072)!==0&&(bl=!0);else return O.lanes=x.lanes,Yy(x,O,H)}return eQ(x,O,T,A,H)}function AIe(x,O,T,A){var H=A.children,Q=x!==null?x.memoizedState:null;if(x===null&&O.stateNode===null&&(O.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),A.mode==="hidden"){if((O.flags&128)!==0){if(Q=Q!==null?Q.baseLanes|T:T,x!==null){for(A=O.child=x.child,H=0;A!==null;)H=H|A.lanes|A.childLanes,A=A.sibling;A=H&~Q}else A=0,O.child=null;return RIe(x,O,Q,T,A)}if((T&536870912)!==0)O.memoizedState={baseLanes:0,cachePool:null},x!==null&&i5(O,Q!==null?Q.cachePool:null),Q!==null?$Ne(O,Q):NG(),MNe(O);else return A=O.lanes=536870912,RIe(x,O,Q!==null?Q.baseLanes|T:T,T,A)}else Q!==null?(i5(O,Q.cachePool),$Ne(O,Q),m0(),O.memoizedState=null):(x!==null&&i5(O,null),NG(),m0());return Rc(x,O,H,T),O.child}function ZI(x,O){return x!==null&&x.tag===22||O.stateNode!==null||(O.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),O.sibling}function RIe(x,O,T,A,H){var Q=OG();return Q=Q===null?null:{parent:vl._currentValue,pool:Q},O.memoizedState={baseLanes:T,cachePool:Q},x!==null&&i5(O,null),NG(),MNe(O),x!==null&&aC(x,O,A,!0),O.childLanes=H,null}function S5(x,O){return O=O5({mode:O.mode,children:O.children},x.mode),O.ref=x.ref,x.child=O,O.return=x,O}function PIe(x,O,T){return dS(O,x.child,null,T),x=S5(O,O.pendingProps),x.flags|=2,Lf(O),O.memoizedState=null,x}function HFt(x,O,T){var A=O.pendingProps,H=(O.flags&128)!==0;if(O.flags&=-129,x===null){if(Zs){if(A.mode==="hidden")return x=S5(O,A),O.lanes=536870912,ZI(null,x);if(AG(O),(x=Ui)?(x=WAe(x,ah),x=x!==null&&x.data==="&"?x:null,x!==null&&(O.memoizedState={dehydrated:x,treeContext:o0!==null?{id:Qg,overflow:Yg}:null,retryLane:536870912,hydrationErrors:null},T=vNe(x),T.return=O,O.child=T,Ic=O,Ui=null)):x=null,x===null)throw c0(O);return O.lanes=536870912,null}return S5(O,A)}var Q=x.memoizedState;if(Q!==null){var ie=Q.dehydrated;if(AG(O),H)if(O.flags&256)O.flags&=-257,O=PIe(x,O,T);else if(O.memoizedState!==null)O.child=x.child,O.flags|=128,O=null;else throw Error(s(558));else if(bl||aC(x,O,T,!1),H=(T&x.childLanes)!==0,bl||H){if(A=mi,A!==null&&(ie=Fe(A,T),ie!==0&&ie!==Q.retryLane))throw Q.retryLane=ie,rS(x,ie),Pd(A,x,ie),JG;R5(),O=PIe(x,O,T)}else x=Q.treeContext,Ui=oh(ie.nextSibling),Ic=O,Zs=!0,l0=null,ah=!1,x!==null&&xNe(O,x),O=S5(O,A),O.flags|=4096;return O}return x=Vy(x.child,{mode:A.mode,children:A.children}),x.ref=O.ref,O.child=x,x.return=O,x}function k5(x,O){var T=O.ref;if(T===null)x!==null&&x.ref!==null&&(O.flags|=4194816);else{if(typeof T!="function"&&typeof T!="object")throw Error(s(284));(x===null||x.ref!==T)&&(O.flags|=4194816)}}function eQ(x,O,T,A,H){return oS(O),T=PG(x,O,T,A,void 0,H),A=$G(),x!==null&&!bl?(MG(x,O,H),Yy(x,O,H)):(Zs&&A&&mG(O),O.flags|=1,Rc(x,O,T,H),O.child)}function $Ie(x,O,T,A,H,Q){return oS(O),O.updateQueue=null,T=LNe(O,A,T,H),DNe(x),A=$G(),x!==null&&!bl?(MG(x,O,Q),Yy(x,O,Q)):(Zs&&A&&mG(O),O.flags|=1,Rc(x,O,T,Q),O.child)}function MIe(x,O,T,A,H){if(oS(O),O.stateNode===null){var Q=tC,ie=T.contextType;typeof ie=="object"&&ie!==null&&(Q=Ac(ie)),Q=new T(A,Q),O.memoizedState=Q.state!==null&&Q.state!==void 0?Q.state:null,Q.updater=XG,O.stateNode=Q,Q._reactInternals=O,Q=O.stateNode,Q.props=A,Q.state=O.memoizedState,Q.refs={},CG(O),ie=T.contextType,Q.context=typeof ie=="object"&&ie!==null?Ac(ie):tC,Q.state=O.memoizedState,ie=T.getDerivedStateFromProps,typeof ie=="function"&&(YG(O,T,ie,A),Q.state=O.memoizedState),typeof T.getDerivedStateFromProps=="function"||typeof Q.getSnapshotBeforeUpdate=="function"||typeof Q.UNSAFE_componentWillMount!="function"&&typeof Q.componentWillMount!="function"||(ie=Q.state,typeof Q.componentWillMount=="function"&&Q.componentWillMount(),typeof Q.UNSAFE_componentWillMount=="function"&&Q.UNSAFE_componentWillMount(),ie!==Q.state&&XG.enqueueReplaceState(Q,Q.state,null),UI(O,A,Q,H),BI(),Q.state=O.memoizedState),typeof Q.componentDidMount=="function"&&(O.flags|=4194308),A=!0}else if(x===null){Q=O.stateNode;var we=O.memoizedProps,Be=pS(T,we);Q.props=Be;var st=Q.context,xt=T.contextType;ie=tC,typeof xt=="object"&&xt!==null&&(ie=Ac(xt));var Ct=T.getDerivedStateFromProps;xt=typeof Ct=="function"||typeof Q.getSnapshotBeforeUpdate=="function",we=O.pendingProps!==we,xt||typeof Q.UNSAFE_componentWillReceiveProps!="function"&&typeof Q.componentWillReceiveProps!="function"||(we||st!==ie)&&SIe(O,Q,A,ie),d0=!1;var lt=O.memoizedState;Q.state=lt,UI(O,A,Q,H),BI(),st=O.memoizedState,we||lt!==st||d0?(typeof Ct=="function"&&(YG(O,T,Ct,A),st=O.memoizedState),(Be=d0||wIe(O,T,Be,A,lt,st,ie))?(xt||typeof Q.UNSAFE_componentWillMount!="function"&&typeof Q.componentWillMount!="function"||(typeof Q.componentWillMount=="function"&&Q.componentWillMount(),typeof Q.UNSAFE_componentWillMount=="function"&&Q.UNSAFE_componentWillMount()),typeof Q.componentDidMount=="function"&&(O.flags|=4194308)):(typeof Q.componentDidMount=="function"&&(O.flags|=4194308),O.memoizedProps=A,O.memoizedState=st),Q.props=A,Q.state=st,Q.context=ie,A=Be):(typeof Q.componentDidMount=="function"&&(O.flags|=4194308),A=!1)}else{Q=O.stateNode,EG(x,O),ie=O.memoizedProps,xt=pS(T,ie),Q.props=xt,Ct=O.pendingProps,lt=Q.context,st=T.contextType,Be=tC,typeof st=="object"&&st!==null&&(Be=Ac(st)),we=T.getDerivedStateFromProps,(st=typeof we=="function"||typeof Q.getSnapshotBeforeUpdate=="function")||typeof Q.UNSAFE_componentWillReceiveProps!="function"&&typeof Q.componentWillReceiveProps!="function"||(ie!==Ct||lt!==Be)&&SIe(O,Q,A,Be),d0=!1,lt=O.memoizedState,Q.state=lt,UI(O,A,Q,H),BI();var dt=O.memoizedState;ie!==Ct||lt!==dt||d0||x!==null&&x.dependencies!==null&&s5(x.dependencies)?(typeof we=="function"&&(YG(O,T,we,A),dt=O.memoizedState),(xt=d0||wIe(O,T,xt,A,lt,dt,Be)||x!==null&&x.dependencies!==null&&s5(x.dependencies))?(st||typeof Q.UNSAFE_componentWillUpdate!="function"&&typeof Q.componentWillUpdate!="function"||(typeof Q.componentWillUpdate=="function"&&Q.componentWillUpdate(A,dt,Be),typeof Q.UNSAFE_componentWillUpdate=="function"&&Q.UNSAFE_componentWillUpdate(A,dt,Be)),typeof Q.componentDidUpdate=="function"&&(O.flags|=4),typeof Q.getSnapshotBeforeUpdate=="function"&&(O.flags|=1024)):(typeof Q.componentDidUpdate!="function"||ie===x.memoizedProps&<===x.memoizedState||(O.flags|=4),typeof Q.getSnapshotBeforeUpdate!="function"||ie===x.memoizedProps&<===x.memoizedState||(O.flags|=1024),O.memoizedProps=A,O.memoizedState=dt),Q.props=A,Q.state=dt,Q.context=Be,A=xt):(typeof Q.componentDidUpdate!="function"||ie===x.memoizedProps&<===x.memoizedState||(O.flags|=4),typeof Q.getSnapshotBeforeUpdate!="function"||ie===x.memoizedProps&<===x.memoizedState||(O.flags|=1024),A=!1)}return Q=A,k5(x,O),A=(O.flags&128)!==0,Q||A?(Q=O.stateNode,T=A&&typeof T.getDerivedStateFromError!="function"?null:Q.render(),O.flags|=1,x!==null&&A?(O.child=dS(O,x.child,null,H),O.child=dS(O,null,T,H)):Rc(x,O,T,H),O.memoizedState=Q.state,x=O.child):x=Yy(x,O,H),x}function DIe(x,O,T,A){return aS(),O.flags|=256,Rc(x,O,T,A),O.child}var tQ={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function nQ(x){return{baseLanes:x,cachePool:CNe()}}function rQ(x,O,T){return x=x!==null?x.childLanes&~T:0,O&&(x|=zf),x}function LIe(x,O,T){var A=O.pendingProps,H=!1,Q=(O.flags&128)!==0,ie;if((ie=Q)||(ie=x!==null&&x.memoizedState===null?!1:(ol.current&2)!==0),ie&&(H=!0,O.flags&=-129),ie=(O.flags&32)!==0,O.flags&=-33,x===null){if(Zs){if(H?h0(O):m0(),(x=Ui)?(x=WAe(x,ah),x=x!==null&&x.data!=="&"?x:null,x!==null&&(O.memoizedState={dehydrated:x,treeContext:o0!==null?{id:Qg,overflow:Yg}:null,retryLane:536870912,hydrationErrors:null},T=vNe(x),T.return=O,O.child=T,Ic=O,Ui=null)):x=null,x===null)throw c0(O);return FQ(x)?O.lanes=32:O.lanes=536870912,null}var we=A.children;return A=A.fallback,H?(m0(),H=O.mode,we=O5({mode:"hidden",children:we},H),A=sS(A,H,T,null),we.return=O,A.return=O,we.sibling=A,O.child=we,A=O.child,A.memoizedState=nQ(T),A.childLanes=rQ(x,ie,T),O.memoizedState=tQ,ZI(null,A)):(h0(O),sQ(O,we))}var Be=x.memoizedState;if(Be!==null&&(we=Be.dehydrated,we!==null)){if(Q)O.flags&256?(h0(O),O.flags&=-257,O=aQ(x,O,T)):O.memoizedState!==null?(m0(),O.child=x.child,O.flags|=128,O=null):(m0(),we=A.fallback,H=O.mode,A=O5({mode:"visible",children:A.children},H),we=sS(we,H,T,null),we.flags|=2,A.return=O,we.return=O,A.sibling=we,O.child=A,dS(O,x.child,null,T),A=O.child,A.memoizedState=nQ(T),A.childLanes=rQ(x,ie,T),O.memoizedState=tQ,O=ZI(null,A));else if(h0(O),FQ(we)){if(ie=we.nextSibling&&we.nextSibling.dataset,ie)var st=ie.dgst;ie=st,A=Error(s(419)),A.stack="",A.digest=ie,$I({value:A,source:null,stack:null}),O=aQ(x,O,T)}else if(bl||aC(x,O,T,!1),ie=(T&x.childLanes)!==0,bl||ie){if(ie=mi,ie!==null&&(A=Fe(ie,T),A!==0&&A!==Be.retryLane))throw Be.retryLane=A,rS(x,A),Pd(ie,x,A),JG;LQ(we)||R5(),O=aQ(x,O,T)}else LQ(we)?(O.flags|=192,O.child=x.child,O=null):(x=Be.treeContext,Ui=oh(we.nextSibling),Ic=O,Zs=!0,l0=null,ah=!1,x!==null&&xNe(O,x),O=sQ(O,A.children),O.flags|=4096);return O}return H?(m0(),we=A.fallback,H=O.mode,Be=x.child,st=Be.sibling,A=Vy(Be,{mode:"hidden",children:A.children}),A.subtreeFlags=Be.subtreeFlags&65011712,st!==null?we=Vy(st,we):(we=sS(we,H,T,null),we.flags|=2),we.return=O,A.return=O,A.sibling=we,O.child=A,ZI(null,A),A=O.child,we=x.child.memoizedState,we===null?we=nQ(T):(H=we.cachePool,H!==null?(Be=vl._currentValue,H=H.parent!==Be?{parent:Be,pool:Be}:H):H=CNe(),we={baseLanes:we.baseLanes|T,cachePool:H}),A.memoizedState=we,A.childLanes=rQ(x,ie,T),O.memoizedState=tQ,ZI(x.child,A)):(h0(O),T=x.child,x=T.sibling,T=Vy(T,{mode:"visible",children:A.children}),T.return=O,T.sibling=null,x!==null&&(ie=O.deletions,ie===null?(O.deletions=[x],O.flags|=16):ie.push(x)),O.child=T,O.memoizedState=null,T)}function sQ(x,O){return O=O5({mode:"visible",children:O},x.mode),O.return=x,x.child=O}function O5(x,O){return x=Mf(22,x,null,O),x.lanes=0,x}function aQ(x,O,T){return dS(O,x.child,null,T),x=sQ(O,O.pendingProps.children),x.flags|=2,O.memoizedState=null,x}function FIe(x,O,T){x.lanes|=O;var A=x.alternate;A!==null&&(A.lanes|=O),xG(x.return,O,T)}function iQ(x,O,T,A,H,Q){var ie=x.memoizedState;ie===null?x.memoizedState={isBackwards:O,rendering:null,renderingStartTime:0,last:A,tail:T,tailMode:H,treeForkCount:Q}:(ie.isBackwards=O,ie.rendering=null,ie.renderingStartTime=0,ie.last=A,ie.tail=T,ie.tailMode=H,ie.treeForkCount=Q)}function zIe(x,O,T){var A=O.pendingProps,H=A.revealOrder,Q=A.tail;A=A.children;var ie=ol.current,we=(ie&2)!==0;if(we?(ie=ie&1|2,O.flags|=128):ie&=1,q(ol,ie),Rc(x,O,A,T),A=Zs?PI:0,!we&&x!==null&&(x.flags&128)!==0)e:for(x=O.child;x!==null;){if(x.tag===13)x.memoizedState!==null&&FIe(x,T,O);else if(x.tag===19)FIe(x,T,O);else if(x.child!==null){x.child.return=x,x=x.child;continue}if(x===O)break e;for(;x.sibling===null;){if(x.return===null||x.return===O)break e;x=x.return}x.sibling.return=x.return,x=x.sibling}switch(H){case"forwards":for(T=O.child,H=null;T!==null;)x=T.alternate,x!==null&&f5(x)===null&&(H=T),T=T.sibling;T=H,T===null?(H=O.child,O.child=null):(H=T.sibling,T.sibling=null),iQ(O,!1,H,T,Q,A);break;case"backwards":case"unstable_legacy-backwards":for(T=null,H=O.child,O.child=null;H!==null;){if(x=H.alternate,x!==null&&f5(x)===null){O.child=H;break}x=H.sibling,H.sibling=T,T=H,H=x}iQ(O,!0,T,null,Q,A);break;case"together":iQ(O,!1,null,null,void 0,A);break;default:O.memoizedState=null}return O.child}function Yy(x,O,T){if(x!==null&&(O.dependencies=x.dependencies),y0|=O.lanes,(T&O.childLanes)===0)if(x!==null){if(aC(x,O,T,!1),(T&O.childLanes)===0)return null}else return null;if(x!==null&&O.child!==x.child)throw Error(s(153));if(O.child!==null){for(x=O.child,T=Vy(x,x.pendingProps),O.child=T,T.return=O;x.sibling!==null;)x=x.sibling,T=T.sibling=Vy(x,x.pendingProps),T.return=O;T.sibling=null}return O.child}function oQ(x,O){return(x.lanes&O)!==0?!0:(x=x.dependencies,!!(x!==null&&s5(x)))}function WFt(x,O,T){switch(O.tag){case 3:ee(O,O.stateNode.containerInfo),u0(O,vl,x.memoizedState.cache),aS();break;case 27:case 5:de(O);break;case 4:ee(O,O.stateNode.containerInfo);break;case 10:u0(O,O.type,O.memoizedProps.value);break;case 31:if(O.memoizedState!==null)return O.flags|=128,AG(O),null;break;case 13:var A=O.memoizedState;if(A!==null)return A.dehydrated!==null?(h0(O),O.flags|=128,null):(T&O.child.childLanes)!==0?LIe(x,O,T):(h0(O),x=Yy(x,O,T),x!==null?x.sibling:null);h0(O);break;case 19:var H=(x.flags&128)!==0;if(A=(T&O.childLanes)!==0,A||(aC(x,O,T,!1),A=(T&O.childLanes)!==0),H){if(A)return zIe(x,O,T);O.flags|=128}if(H=O.memoizedState,H!==null&&(H.rendering=null,H.tail=null,H.lastEffect=null),q(ol,ol.current),A)break;return null;case 22:return O.lanes=0,AIe(x,O,T,O.pendingProps);case 24:u0(O,vl,x.memoizedState.cache)}return Yy(x,O,T)}function BIe(x,O,T){if(x!==null)if(x.memoizedProps!==O.pendingProps)bl=!0;else{if(!oQ(x,T)&&(O.flags&128)===0)return bl=!1,WFt(x,O,T);bl=(x.flags&131072)!==0}else bl=!1,Zs&&(O.flags&1048576)!==0&&bNe(O,PI,O.index);switch(O.lanes=0,O.tag){case 16:e:{var A=O.pendingProps;if(x=cS(O.elementType),O.type=x,typeof x=="function")fG(x)?(A=pS(x,A),O.tag=1,O=MIe(null,O,x,A,T)):(O.tag=0,O=eQ(null,O,x,A,T));else{if(x!=null){var H=x.$$typeof;if(H===_){O.tag=11,O=TIe(null,O,x,A,T);break e}else if(H===j){O.tag=14,O=NIe(null,O,x,A,T);break e}}throw O=V(x)||x,Error(s(306,O,""))}}return O;case 0:return eQ(x,O,O.type,O.pendingProps,T);case 1:return A=O.type,H=pS(A,O.pendingProps),MIe(x,O,A,H,T);case 3:e:{if(ee(O,O.stateNode.containerInfo),x===null)throw Error(s(387));A=O.pendingProps;var Q=O.memoizedState;H=Q.element,EG(x,O),UI(O,A,null,T);var ie=O.memoizedState;if(A=ie.cache,u0(O,vl,A),A!==Q.cache&&wG(O,[vl],T,!0),BI(),A=ie.element,Q.isDehydrated)if(Q={element:A,isDehydrated:!1,cache:ie.cache},O.updateQueue.baseState=Q,O.memoizedState=Q,O.flags&256){O=DIe(x,O,A,T);break e}else if(A!==H){H=nh(Error(s(424)),O),$I(H),O=DIe(x,O,A,T);break e}else for(x=O.stateNode.containerInfo,x.nodeType===9?x=x.body:x=x.nodeName==="HTML"?x.ownerDocument.body:x,Ui=oh(x.firstChild),Ic=O,Zs=!0,l0=null,ah=!0,T=ANe(O,null,A,T),O.child=T;T;)T.flags=T.flags&-3|4096,T=T.sibling;else{if(aS(),A===H){O=Yy(x,O,T);break e}Rc(x,O,A,T)}O=O.child}return O;case 26:return k5(x,O),x===null?(T=KAe(O.type,null,O.pendingProps,null))?O.memoizedState=T:Zs||(T=O.type,x=O.pendingProps,A=z5(te.current).createElement(T),A[Ft]=O,A[$t]=x,Pc(A,T,x),_a(A),O.stateNode=A):O.memoizedState=KAe(O.type,x.memoizedProps,O.pendingProps,x.memoizedState),null;case 27:return de(O),x===null&&Zs&&(A=O.stateNode=QAe(O.type,O.pendingProps,te.current),Ic=O,ah=!0,H=Ui,k0(O.type)?(zQ=H,Ui=oh(A.firstChild)):Ui=H),Rc(x,O,O.pendingProps.children,T),k5(x,O),x===null&&(O.flags|=4194304),O.child;case 5:return x===null&&Zs&&((H=A=Ui)&&(A=Szt(A,O.type,O.pendingProps,ah),A!==null?(O.stateNode=A,Ic=O,Ui=oh(A.firstChild),ah=!1,H=!0):H=!1),H||c0(O)),de(O),H=O.type,Q=O.pendingProps,ie=x!==null?x.memoizedProps:null,A=Q.children,$Q(H,Q)?A=null:ie!==null&&$Q(H,ie)&&(O.flags|=32),O.memoizedState!==null&&(H=PG(x,O,DFt,null,null,T),lA._currentValue=H),k5(x,O),Rc(x,O,A,T),O.child;case 6:return x===null&&Zs&&((x=T=Ui)&&(T=kzt(T,O.pendingProps,ah),T!==null?(O.stateNode=T,Ic=O,Ui=null,x=!0):x=!1),x||c0(O)),null;case 13:return LIe(x,O,T);case 4:return ee(O,O.stateNode.containerInfo),A=O.pendingProps,x===null?O.child=dS(O,null,A,T):Rc(x,O,A,T),O.child;case 11:return TIe(x,O,O.type,O.pendingProps,T);case 7:return Rc(x,O,O.pendingProps,T),O.child;case 8:return Rc(x,O,O.pendingProps.children,T),O.child;case 12:return Rc(x,O,O.pendingProps.children,T),O.child;case 10:return A=O.pendingProps,u0(O,O.type,A.value),Rc(x,O,A.children,T),O.child;case 9:return H=O.type._context,A=O.pendingProps.children,oS(O),H=Ac(H),A=A(H),O.flags|=1,Rc(x,O,A,T),O.child;case 14:return NIe(x,O,O.type,O.pendingProps,T);case 15:return IIe(x,O,O.type,O.pendingProps,T);case 19:return zIe(x,O,T);case 31:return HFt(x,O,T);case 22:return AIe(x,O,T,O.pendingProps);case 24:return oS(O),A=Ac(vl),x===null?(H=OG(),H===null&&(H=mi,Q=SG(),H.pooledCache=Q,Q.refCount++,Q!==null&&(H.pooledCacheLanes|=T),H=Q),O.memoizedState={parent:A,cache:H},CG(O),u0(O,vl,H)):((x.lanes&T)!==0&&(EG(x,O),UI(O,null,null,T),BI()),H=x.memoizedState,Q=O.memoizedState,H.parent!==A?(H={parent:A,cache:A},O.memoizedState=H,O.lanes===0&&(O.memoizedState=O.updateQueue.baseState=H),u0(O,vl,A)):(A=Q.cache,u0(O,vl,A),A!==H.cache&&wG(O,[vl],T,!0))),Rc(x,O,O.pendingProps.children,T),O.child;case 29:throw O.pendingProps}throw Error(s(156,O.tag))}function Xy(x){x.flags|=4}function lQ(x,O,T,A,H){if((O=(x.mode&32)!==0)&&(O=!1),O){if(x.flags|=16777216,(H&335544128)===H)if(x.stateNode.complete)x.flags|=8192;else if(hAe())x.flags|=8192;else throw uS=l5,_G}else x.flags&=-16777217}function UIe(x,O){if(O.type!=="stylesheet"||(O.state.loading&4)!==0)x.flags&=-16777217;else if(x.flags|=16777216,!rRe(O))if(hAe())x.flags|=8192;else throw uS=l5,_G}function _5(x,O){O!==null&&(x.flags|=4),x.flags&16384&&(O=x.tag!==22?ot():536870912,x.lanes|=O,vC|=O)}function GI(x,O){if(!Zs)switch(x.tailMode){case"hidden":O=x.tail;for(var T=null;O!==null;)O.alternate!==null&&(T=O),O=O.sibling;T===null?x.tail=null:T.sibling=null;break;case"collapsed":T=x.tail;for(var A=null;T!==null;)T.alternate!==null&&(A=T),T=T.sibling;A===null?O||x.tail===null?x.tail=null:x.tail.sibling=null:A.sibling=null}}function qi(x){var O=x.alternate!==null&&x.alternate.child===x.child,T=0,A=0;if(O)for(var H=x.child;H!==null;)T|=H.lanes|H.childLanes,A|=H.subtreeFlags&65011712,A|=H.flags&65011712,H.return=x,H=H.sibling;else for(H=x.child;H!==null;)T|=H.lanes|H.childLanes,A|=H.subtreeFlags,A|=H.flags,H.return=x,H=H.sibling;return x.subtreeFlags|=A,x.childLanes=T,O}function ZFt(x,O,T){var A=O.pendingProps;switch(gG(O),O.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return qi(O),null;case 1:return qi(O),null;case 3:return T=O.stateNode,A=null,x!==null&&(A=x.memoizedState.cache),O.memoizedState.cache!==A&&(O.flags|=2048),Zy(vl),ae(),T.pendingContext&&(T.context=T.pendingContext,T.pendingContext=null),(x===null||x.child===null)&&(sC(O)?Xy(O):x===null||x.memoizedState.isDehydrated&&(O.flags&256)===0||(O.flags|=1024,yG())),qi(O),null;case 26:var H=O.type,Q=O.memoizedState;return x===null?(Xy(O),Q!==null?(qi(O),UIe(O,Q)):(qi(O),lQ(O,H,null,A,T))):Q?Q!==x.memoizedState?(Xy(O),qi(O),UIe(O,Q)):(qi(O),O.flags&=-16777217):(x=x.memoizedProps,x!==A&&Xy(O),qi(O),lQ(O,H,x,A,T)),null;case 27:if(Y(O),T=te.current,H=O.type,x!==null&&O.stateNode!=null)x.memoizedProps!==A&&Xy(O);else{if(!A){if(O.stateNode===null)throw Error(s(166));return qi(O),null}x=Z.current,sC(O)?wNe(O):(x=QAe(H,A,T),O.stateNode=x,Xy(O))}return qi(O),null;case 5:if(Y(O),H=O.type,x!==null&&O.stateNode!=null)x.memoizedProps!==A&&Xy(O);else{if(!A){if(O.stateNode===null)throw Error(s(166));return qi(O),null}if(Q=Z.current,sC(O))wNe(O);else{var ie=z5(te.current);switch(Q){case 1:Q=ie.createElementNS("http://www.w3.org/2000/svg",H);break;case 2:Q=ie.createElementNS("http://www.w3.org/1998/Math/MathML",H);break;default:switch(H){case"svg":Q=ie.createElementNS("http://www.w3.org/2000/svg",H);break;case"math":Q=ie.createElementNS("http://www.w3.org/1998/Math/MathML",H);break;case"script":Q=ie.createElement("div"),Q.innerHTML="<script><\/script>",Q=Q.removeChild(Q.firstChild);break;case"select":Q=typeof A.is=="string"?ie.createElement("select",{is:A.is}):ie.createElement("select"),A.multiple?Q.multiple=!0:A.size&&(Q.size=A.size);break;default:Q=typeof A.is=="string"?ie.createElement(H,{is:A.is}):ie.createElement(H)}}Q[Ft]=O,Q[$t]=A;e:for(ie=O.child;ie!==null;){if(ie.tag===5||ie.tag===6)Q.appendChild(ie.stateNode);else if(ie.tag!==4&&ie.tag!==27&&ie.child!==null){ie.child.return=ie,ie=ie.child;continue}if(ie===O)break e;for(;ie.sibling===null;){if(ie.return===null||ie.return===O)break e;ie=ie.return}ie.sibling.return=ie.return,ie=ie.sibling}O.stateNode=Q;e:switch(Pc(Q,H,A),H){case"button":case"input":case"select":case"textarea":A=!!A.autoFocus;break e;case"img":A=!0;break e;default:A=!1}A&&Xy(O)}}return qi(O),lQ(O,O.type,x===null?null:x.memoizedProps,O.pendingProps,T),null;case 6:if(x&&O.stateNode!=null)x.memoizedProps!==A&&Xy(O);else{if(typeof A!="string"&&O.stateNode===null)throw Error(s(166));if(x=te.current,sC(O)){if(x=O.stateNode,T=O.memoizedProps,A=null,H=Ic,H!==null)switch(H.tag){case 27:case 5:A=H.memoizedProps}x[Ft]=O,x=!!(x.nodeValue===T||A!==null&&A.suppressHydrationWarning===!0||LAe(x.nodeValue,T)),x||c0(O,!0)}else x=z5(x).createTextNode(A),x[Ft]=O,O.stateNode=x}return qi(O),null;case 31:if(T=O.memoizedState,x===null||x.memoizedState!==null){if(A=sC(O),T!==null){if(x===null){if(!A)throw Error(s(318));if(x=O.memoizedState,x=x!==null?x.dehydrated:null,!x)throw Error(s(557));x[Ft]=O}else aS(),(O.flags&128)===0&&(O.memoizedState=null),O.flags|=4;qi(O),x=!1}else T=yG(),x!==null&&x.memoizedState!==null&&(x.memoizedState.hydrationErrors=T),x=!0;if(!x)return O.flags&256?(Lf(O),O):(Lf(O),null);if((O.flags&128)!==0)throw Error(s(558))}return qi(O),null;case 13:if(A=O.memoizedState,x===null||x.memoizedState!==null&&x.memoizedState.dehydrated!==null){if(H=sC(O),A!==null&&A.dehydrated!==null){if(x===null){if(!H)throw Error(s(318));if(H=O.memoizedState,H=H!==null?H.dehydrated:null,!H)throw Error(s(317));H[Ft]=O}else aS(),(O.flags&128)===0&&(O.memoizedState=null),O.flags|=4;qi(O),H=!1}else H=yG(),x!==null&&x.memoizedState!==null&&(x.memoizedState.hydrationErrors=H),H=!0;if(!H)return O.flags&256?(Lf(O),O):(Lf(O),null)}return Lf(O),(O.flags&128)!==0?(O.lanes=T,O):(T=A!==null,x=x!==null&&x.memoizedState!==null,T&&(A=O.child,H=null,A.alternate!==null&&A.alternate.memoizedState!==null&&A.alternate.memoizedState.cachePool!==null&&(H=A.alternate.memoizedState.cachePool.pool),Q=null,A.memoizedState!==null&&A.memoizedState.cachePool!==null&&(Q=A.memoizedState.cachePool.pool),Q!==H&&(A.flags|=2048)),T!==x&&T&&(O.child.flags|=8192),_5(O,O.updateQueue),qi(O),null);case 4:return ae(),x===null&&NQ(O.stateNode.containerInfo),qi(O),null;case 10:return Zy(O.type),qi(O),null;case 19:if(P(ol),A=O.memoizedState,A===null)return qi(O),null;if(H=(O.flags&128)!==0,Q=A.rendering,Q===null)if(H)GI(A,!1);else{if(Vo!==0||x!==null&&(x.flags&128)!==0)for(x=O.child;x!==null;){if(Q=f5(x),Q!==null){for(O.flags|=128,GI(A,!1),x=Q.updateQueue,O.updateQueue=x,_5(O,x),O.subtreeFlags=0,x=T,T=O.child;T!==null;)gNe(T,x),T=T.sibling;return q(ol,ol.current&1|2),Zs&&Hy(O,A.treeForkCount),O.child}x=x.sibling}A.tail!==null&&se()>N5&&(O.flags|=128,H=!0,GI(A,!1),O.lanes=4194304)}else{if(!H)if(x=f5(Q),x!==null){if(O.flags|=128,H=!0,x=x.updateQueue,O.updateQueue=x,_5(O,x),GI(A,!0),A.tail===null&&A.tailMode==="hidden"&&!Q.alternate&&!Zs)return qi(O),null}else 2*se()-A.renderingStartTime>N5&&T!==536870912&&(O.flags|=128,H=!0,GI(A,!1),O.lanes=4194304);A.isBackwards?(Q.sibling=O.child,O.child=Q):(x=A.last,x!==null?x.sibling=Q:O.child=Q,A.last=Q)}return A.tail!==null?(x=A.tail,A.rendering=x,A.tail=x.sibling,A.renderingStartTime=se(),x.sibling=null,T=ol.current,q(ol,H?T&1|2:T&1),Zs&&Hy(O,A.treeForkCount),x):(qi(O),null);case 22:case 23:return Lf(O),IG(),A=O.memoizedState!==null,x!==null?x.memoizedState!==null!==A&&(O.flags|=8192):A&&(O.flags|=8192),A?(T&536870912)!==0&&(O.flags&128)===0&&(qi(O),O.subtreeFlags&6&&(O.flags|=8192)):qi(O),T=O.updateQueue,T!==null&&_5(O,T.retryQueue),T=null,x!==null&&x.memoizedState!==null&&x.memoizedState.cachePool!==null&&(T=x.memoizedState.cachePool.pool),A=null,O.memoizedState!==null&&O.memoizedState.cachePool!==null&&(A=O.memoizedState.cachePool.pool),A!==T&&(O.flags|=2048),x!==null&&P(lS),null;case 24:return T=null,x!==null&&(T=x.memoizedState.cache),O.memoizedState.cache!==T&&(O.flags|=2048),Zy(vl),qi(O),null;case 25:return null;case 30:return null}throw Error(s(156,O.tag))}function GFt(x,O){switch(gG(O),O.tag){case 1:return x=O.flags,x&65536?(O.flags=x&-65537|128,O):null;case 3:return Zy(vl),ae(),x=O.flags,(x&65536)!==0&&(x&128)===0?(O.flags=x&-65537|128,O):null;case 26:case 27:case 5:return Y(O),null;case 31:if(O.memoizedState!==null){if(Lf(O),O.alternate===null)throw Error(s(340));aS()}return x=O.flags,x&65536?(O.flags=x&-65537|128,O):null;case 13:if(Lf(O),x=O.memoizedState,x!==null&&x.dehydrated!==null){if(O.alternate===null)throw Error(s(340));aS()}return x=O.flags,x&65536?(O.flags=x&-65537|128,O):null;case 19:return P(ol),null;case 4:return ae(),null;case 10:return Zy(O.type),null;case 22:case 23:return Lf(O),IG(),x!==null&&P(lS),x=O.flags,x&65536?(O.flags=x&-65537|128,O):null;case 24:return Zy(vl),null;case 25:return null;default:return null}}function qIe(x,O){switch(gG(O),O.tag){case 3:Zy(vl),ae();break;case 26:case 27:case 5:Y(O);break;case 4:ae();break;case 31:O.memoizedState!==null&&Lf(O);break;case 13:Lf(O);break;case 19:P(ol);break;case 10:Zy(O.type);break;case 22:case 23:Lf(O),IG(),x!==null&&P(lS);break;case 24:Zy(vl)}}function QI(x,O){try{var T=O.updateQueue,A=T!==null?T.lastEffect:null;if(A!==null){var H=A.next;T=H;do{if((T.tag&x)===x){A=void 0;var Q=T.create,ie=T.inst;A=Q(),ie.destroy=A}T=T.next}while(T!==H)}}catch(we){qa(O,O.return,we)}}function g0(x,O,T){try{var A=O.updateQueue,H=A!==null?A.lastEffect:null;if(H!==null){var Q=H.next;A=Q;do{if((A.tag&x)===x){var ie=A.inst,we=ie.destroy;if(we!==void 0){ie.destroy=void 0,H=O;var Be=T,st=we;try{st()}catch(xt){qa(H,Be,xt)}}}A=A.next}while(A!==Q)}}catch(xt){qa(O,O.return,xt)}}function VIe(x){var O=x.updateQueue;if(O!==null){var T=x.stateNode;try{PNe(O,T)}catch(A){qa(x,x.return,A)}}}function HIe(x,O,T){T.props=pS(x.type,x.memoizedProps),T.state=x.memoizedState;try{T.componentWillUnmount()}catch(A){qa(x,O,A)}}function YI(x,O){try{var T=x.ref;if(T!==null){switch(x.tag){case 26:case 27:case 5:var A=x.stateNode;break;case 30:A=x.stateNode;break;default:A=x.stateNode}typeof T=="function"?x.refCleanup=T(A):T.current=A}}catch(H){qa(x,O,H)}}function Xg(x,O){var T=x.ref,A=x.refCleanup;if(T!==null)if(typeof A=="function")try{A()}catch(H){qa(x,O,H)}finally{x.refCleanup=null,x=x.alternate,x!=null&&(x.refCleanup=null)}else if(typeof T=="function")try{T(null)}catch(H){qa(x,O,H)}else T.current=null}function WIe(x){var O=x.type,T=x.memoizedProps,A=x.stateNode;try{e:switch(O){case"button":case"input":case"select":case"textarea":T.autoFocus&&A.focus();break e;case"img":T.src?A.src=T.src:T.srcSet&&(A.srcset=T.srcSet)}}catch(H){qa(x,x.return,H)}}function cQ(x,O,T){try{var A=x.stateNode;gzt(A,x.type,T,O),A[$t]=O}catch(H){qa(x,x.return,H)}}function ZIe(x){return x.tag===5||x.tag===3||x.tag===26||x.tag===27&&k0(x.type)||x.tag===4}function uQ(x){e:for(;;){for(;x.sibling===null;){if(x.return===null||ZIe(x.return))return null;x=x.return}for(x.sibling.return=x.return,x=x.sibling;x.tag!==5&&x.tag!==6&&x.tag!==18;){if(x.tag===27&&k0(x.type)||x.flags&2||x.child===null||x.tag===4)continue e;x.child.return=x,x=x.child}if(!(x.flags&2))return x.stateNode}}function dQ(x,O,T){var A=x.tag;if(A===5||A===6)x=x.stateNode,O?(T.nodeType===9?T.body:T.nodeName==="HTML"?T.ownerDocument.body:T).insertBefore(x,O):(O=T.nodeType===9?T.body:T.nodeName==="HTML"?T.ownerDocument.body:T,O.appendChild(x),T=T._reactRootContainer,T!=null||O.onclick!==null||(O.onclick=Nm));else if(A!==4&&(A===27&&k0(x.type)&&(T=x.stateNode,O=null),x=x.child,x!==null))for(dQ(x,O,T),x=x.sibling;x!==null;)dQ(x,O,T),x=x.sibling}function C5(x,O,T){var A=x.tag;if(A===5||A===6)x=x.stateNode,O?T.insertBefore(x,O):T.appendChild(x);else if(A!==4&&(A===27&&k0(x.type)&&(T=x.stateNode),x=x.child,x!==null))for(C5(x,O,T),x=x.sibling;x!==null;)C5(x,O,T),x=x.sibling}function GIe(x){var O=x.stateNode,T=x.memoizedProps;try{for(var A=x.type,H=O.attributes;H.length;)O.removeAttributeNode(H[0]);Pc(O,A,T),O[Ft]=x,O[$t]=T}catch(Q){qa(x,x.return,Q)}}var Ky=!1,xl=!1,fQ=!1,QIe=typeof WeakSet=="function"?WeakSet:Set,lc=null;function QFt(x,O){if(x=x.containerInfo,RQ=Z5,x=oNe(x),aG(x)){if("selectionStart"in x)var T={start:x.selectionStart,end:x.selectionEnd};else e:{T=(T=x.ownerDocument)&&T.defaultView||window;var A=T.getSelection&&T.getSelection();if(A&&A.rangeCount!==0){T=A.anchorNode;var H=A.anchorOffset,Q=A.focusNode;A=A.focusOffset;try{T.nodeType,Q.nodeType}catch{T=null;break e}var ie=0,we=-1,Be=-1,st=0,xt=0,Ct=x,lt=null;t:for(;;){for(var dt;Ct!==T||H!==0&&Ct.nodeType!==3||(we=ie+H),Ct!==Q||A!==0&&Ct.nodeType!==3||(Be=ie+A),Ct.nodeType===3&&(ie+=Ct.nodeValue.length),(dt=Ct.firstChild)!==null;)lt=Ct,Ct=dt;for(;;){if(Ct===x)break t;if(lt===T&&++st===H&&(we=ie),lt===Q&&++xt===A&&(Be=ie),(dt=Ct.nextSibling)!==null)break;Ct=lt,lt=Ct.parentNode}Ct=dt}T=we===-1||Be===-1?null:{start:we,end:Be}}else T=null}T=T||{start:0,end:0}}else T=null;for(PQ={focusedElem:x,selectionRange:T},Z5=!1,lc=O;lc!==null;)if(O=lc,x=O.child,(O.subtreeFlags&1028)!==0&&x!==null)x.return=O,lc=x;else for(;lc!==null;){switch(O=lc,Q=O.alternate,x=O.flags,O.tag){case 0:if((x&4)!==0&&(x=O.updateQueue,x=x!==null?x.events:null,x!==null))for(T=0;T<x.length;T++)H=x[T],H.ref.impl=H.nextImpl;break;case 11:case 15:break;case 1:if((x&1024)!==0&&Q!==null){x=void 0,T=O,H=Q.memoizedProps,Q=Q.memoizedState,A=T.stateNode;try{var Mn=pS(T.type,H);x=A.getSnapshotBeforeUpdate(Mn,Q),A.__reactInternalSnapshotBeforeUpdate=x}catch(yr){qa(T,T.return,yr)}}break;case 3:if((x&1024)!==0){if(x=O.stateNode.containerInfo,T=x.nodeType,T===9)DQ(x);else if(T===1)switch(x.nodeName){case"HEAD":case"HTML":case"BODY":DQ(x);break;default:x.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((x&1024)!==0)throw Error(s(163))}if(x=O.sibling,x!==null){x.return=O.return,lc=x;break}lc=O.return}}function YIe(x,O,T){var A=T.flags;switch(T.tag){case 0:case 11:case 15:eb(x,T),A&4&&QI(5,T);break;case 1:if(eb(x,T),A&4)if(x=T.stateNode,O===null)try{x.componentDidMount()}catch(ie){qa(T,T.return,ie)}else{var H=pS(T.type,O.memoizedProps);O=O.memoizedState;try{x.componentDidUpdate(H,O,x.__reactInternalSnapshotBeforeUpdate)}catch(ie){qa(T,T.return,ie)}}A&64&&VIe(T),A&512&&YI(T,T.return);break;case 3:if(eb(x,T),A&64&&(x=T.updateQueue,x!==null)){if(O=null,T.child!==null)switch(T.child.tag){case 27:case 5:O=T.child.stateNode;break;case 1:O=T.child.stateNode}try{PNe(x,O)}catch(ie){qa(T,T.return,ie)}}break;case 27:O===null&&A&4&&GIe(T);case 26:case 5:eb(x,T),O===null&&A&4&&WIe(T),A&512&&YI(T,T.return);break;case 12:eb(x,T);break;case 31:eb(x,T),A&4&&JIe(x,T);break;case 13:eb(x,T),A&4&&eAe(x,T),A&64&&(x=T.memoizedState,x!==null&&(x=x.dehydrated,x!==null&&(T=szt.bind(null,T),Ozt(x,T))));break;case 22:if(A=T.memoizedState!==null||Ky,!A){O=O!==null&&O.memoizedState!==null||xl,H=Ky;var Q=xl;Ky=A,(xl=O)&&!Q?tb(x,T,(T.subtreeFlags&8772)!==0):eb(x,T),Ky=H,xl=Q}break;case 30:break;default:eb(x,T)}}function XIe(x){var O=x.alternate;O!==null&&(x.alternate=null,XIe(O)),x.child=null,x.deletions=null,x.sibling=null,x.tag===5&&(O=x.stateNode,O!==null&&xs(O)),x.stateNode=null,x.return=null,x.dependencies=null,x.memoizedProps=null,x.memoizedState=null,x.pendingProps=null,x.stateNode=null,x.updateQueue=null}var ao=null,Nd=!1;function Jy(x,O,T){for(T=T.child;T!==null;)KIe(x,O,T),T=T.sibling}function KIe(x,O,T){if(_e&&typeof _e.onCommitFiberUnmount=="function")try{_e.onCommitFiberUnmount(je,T)}catch{}switch(T.tag){case 26:xl||Xg(T,O),Jy(x,O,T),T.memoizedState?T.memoizedState.count--:T.stateNode&&(T=T.stateNode,T.parentNode.removeChild(T));break;case 27:xl||Xg(T,O);var A=ao,H=Nd;k0(T.type)&&(ao=T.stateNode,Nd=!1),Jy(x,O,T),aA(T.stateNode),ao=A,Nd=H;break;case 5:xl||Xg(T,O);case 6:if(A=ao,H=Nd,ao=null,Jy(x,O,T),ao=A,Nd=H,ao!==null)if(Nd)try{(ao.nodeType===9?ao.body:ao.nodeName==="HTML"?ao.ownerDocument.body:ao).removeChild(T.stateNode)}catch(Q){qa(T,O,Q)}else try{ao.removeChild(T.stateNode)}catch(Q){qa(T,O,Q)}break;case 18:ao!==null&&(Nd?(x=ao,VAe(x.nodeType===9?x.body:x.nodeName==="HTML"?x.ownerDocument.body:x,T.stateNode),_C(x)):VAe(ao,T.stateNode));break;case 4:A=ao,H=Nd,ao=T.stateNode.containerInfo,Nd=!0,Jy(x,O,T),ao=A,Nd=H;break;case 0:case 11:case 14:case 15:g0(2,T,O),xl||g0(4,T,O),Jy(x,O,T);break;case 1:xl||(Xg(T,O),A=T.stateNode,typeof A.componentWillUnmount=="function"&&HIe(T,O,A)),Jy(x,O,T);break;case 21:Jy(x,O,T);break;case 22:xl=(A=xl)||T.memoizedState!==null,Jy(x,O,T),xl=A;break;default:Jy(x,O,T)}}function JIe(x,O){if(O.memoizedState===null&&(x=O.alternate,x!==null&&(x=x.memoizedState,x!==null))){x=x.dehydrated;try{_C(x)}catch(T){qa(O,O.return,T)}}}function eAe(x,O){if(O.memoizedState===null&&(x=O.alternate,x!==null&&(x=x.memoizedState,x!==null&&(x=x.dehydrated,x!==null))))try{_C(x)}catch(T){qa(O,O.return,T)}}function YFt(x){switch(x.tag){case 31:case 13:case 19:var O=x.stateNode;return O===null&&(O=x.stateNode=new QIe),O;case 22:return x=x.stateNode,O=x._retryCache,O===null&&(O=x._retryCache=new QIe),O;default:throw Error(s(435,x.tag))}}function E5(x,O){var T=YFt(x);O.forEach(function(A){if(!T.has(A)){T.add(A);var H=azt.bind(null,x,A);A.then(H,H)}})}function Id(x,O){var T=O.deletions;if(T!==null)for(var A=0;A<T.length;A++){var H=T[A],Q=x,ie=O,we=ie;e:for(;we!==null;){switch(we.tag){case 27:if(k0(we.type)){ao=we.stateNode,Nd=!1;break e}break;case 5:ao=we.stateNode,Nd=!1;break e;case 3:case 4:ao=we.stateNode.containerInfo,Nd=!0;break e}we=we.return}if(ao===null)throw Error(s(160));KIe(Q,ie,H),ao=null,Nd=!1,Q=H.alternate,Q!==null&&(Q.return=null),H.return=null}if(O.subtreeFlags&13886)for(O=O.child;O!==null;)tAe(O,x),O=O.sibling}var Rm=null;function tAe(x,O){var T=x.alternate,A=x.flags;switch(x.tag){case 0:case 11:case 14:case 15:Id(O,x),Ad(x),A&4&&(g0(3,x,x.return),QI(3,x),g0(5,x,x.return));break;case 1:Id(O,x),Ad(x),A&512&&(xl||T===null||Xg(T,T.return)),A&64&&Ky&&(x=x.updateQueue,x!==null&&(A=x.callbacks,A!==null&&(T=x.shared.hiddenCallbacks,x.shared.hiddenCallbacks=T===null?A:T.concat(A))));break;case 26:var H=Rm;if(Id(O,x),Ad(x),A&512&&(xl||T===null||Xg(T,T.return)),A&4){var Q=T!==null?T.memoizedState:null;if(A=x.memoizedState,T===null)if(A===null)if(x.stateNode===null){e:{A=x.type,T=x.memoizedProps,H=H.ownerDocument||H;t:switch(A){case"title":Q=H.getElementsByTagName("title")[0],(!Q||Q[hr]||Q[Ft]||Q.namespaceURI==="http://www.w3.org/2000/svg"||Q.hasAttribute("itemprop"))&&(Q=H.createElement(A),H.head.insertBefore(Q,H.querySelector("head > title"))),Pc(Q,A,T),Q[Ft]=x,_a(Q),A=Q;break e;case"link":var ie=tRe("link","href",H).get(A+(T.href||""));if(ie){for(var we=0;we<ie.length;we++)if(Q=ie[we],Q.getAttribute("href")===(T.href==null||T.href===""?null:T.href)&&Q.getAttribute("rel")===(T.rel==null?null:T.rel)&&Q.getAttribute("title")===(T.title==null?null:T.title)&&Q.getAttribute("crossorigin")===(T.crossOrigin==null?null:T.crossOrigin)){ie.splice(we,1);break t}}Q=H.createElement(A),Pc(Q,A,T),H.head.appendChild(Q);break;case"meta":if(ie=tRe("meta","content",H).get(A+(T.content||""))){for(we=0;we<ie.length;we++)if(Q=ie[we],Q.getAttribute("content")===(T.content==null?null:""+T.content)&&Q.getAttribute("name")===(T.name==null?null:T.name)&&Q.getAttribute("property")===(T.property==null?null:T.property)&&Q.getAttribute("http-equiv")===(T.httpEquiv==null?null:T.httpEquiv)&&Q.getAttribute("charset")===(T.charSet==null?null:T.charSet)){ie.splice(we,1);break t}}Q=H.createElement(A),Pc(Q,A,T),H.head.appendChild(Q);break;default:throw Error(s(468,A))}Q[Ft]=x,_a(Q),A=Q}x.stateNode=A}else nRe(H,x.type,x.stateNode);else x.stateNode=eRe(H,A,x.memoizedProps);else Q!==A?(Q===null?T.stateNode!==null&&(T=T.stateNode,T.parentNode.removeChild(T)):Q.count--,A===null?nRe(H,x.type,x.stateNode):eRe(H,A,x.memoizedProps)):A===null&&x.stateNode!==null&&cQ(x,x.memoizedProps,T.memoizedProps)}break;case 27:Id(O,x),Ad(x),A&512&&(xl||T===null||Xg(T,T.return)),T!==null&&A&4&&cQ(x,x.memoizedProps,T.memoizedProps);break;case 5:if(Id(O,x),Ad(x),A&512&&(xl||T===null||Xg(T,T.return)),x.flags&32){H=x.stateNode;try{Tm(H,"")}catch(Mn){qa(x,x.return,Mn)}}A&4&&x.stateNode!=null&&(H=x.memoizedProps,cQ(x,H,T!==null?T.memoizedProps:H)),A&1024&&(fQ=!0);break;case 6:if(Id(O,x),Ad(x),A&4){if(x.stateNode===null)throw Error(s(162));A=x.memoizedProps,T=x.stateNode;try{T.nodeValue=A}catch(Mn){qa(x,x.return,Mn)}}break;case 3:if(q5=null,H=Rm,Rm=B5(O.containerInfo),Id(O,x),Rm=H,Ad(x),A&4&&T!==null&&T.memoizedState.isDehydrated)try{_C(O.containerInfo)}catch(Mn){qa(x,x.return,Mn)}fQ&&(fQ=!1,nAe(x));break;case 4:A=Rm,Rm=B5(x.stateNode.containerInfo),Id(O,x),Ad(x),Rm=A;break;case 12:Id(O,x),Ad(x);break;case 31:Id(O,x),Ad(x),A&4&&(A=x.updateQueue,A!==null&&(x.updateQueue=null,E5(x,A)));break;case 13:Id(O,x),Ad(x),x.child.flags&8192&&x.memoizedState!==null!=(T!==null&&T.memoizedState!==null)&&(T5=se()),A&4&&(A=x.updateQueue,A!==null&&(x.updateQueue=null,E5(x,A)));break;case 22:H=x.memoizedState!==null;var Be=T!==null&&T.memoizedState!==null,st=Ky,xt=xl;if(Ky=st||H,xl=xt||Be,Id(O,x),xl=xt,Ky=st,Ad(x),A&8192)e:for(O=x.stateNode,O._visibility=H?O._visibility&-2:O._visibility|1,H&&(T===null||Be||Ky||xl||hS(x)),T=null,O=x;;){if(O.tag===5||O.tag===26){if(T===null){Be=T=O;try{if(Q=Be.stateNode,H)ie=Q.style,typeof ie.setProperty=="function"?ie.setProperty("display","none","important"):ie.display="none";else{we=Be.stateNode;var Ct=Be.memoizedProps.style,lt=Ct!=null&&Ct.hasOwnProperty("display")?Ct.display:null;we.style.display=lt==null||typeof lt=="boolean"?"":(""+lt).trim()}}catch(Mn){qa(Be,Be.return,Mn)}}}else if(O.tag===6){if(T===null){Be=O;try{Be.stateNode.nodeValue=H?"":Be.memoizedProps}catch(Mn){qa(Be,Be.return,Mn)}}}else if(O.tag===18){if(T===null){Be=O;try{var dt=Be.stateNode;H?HAe(dt,!0):HAe(Be.stateNode,!1)}catch(Mn){qa(Be,Be.return,Mn)}}}else if((O.tag!==22&&O.tag!==23||O.memoizedState===null||O===x)&&O.child!==null){O.child.return=O,O=O.child;continue}if(O===x)break e;for(;O.sibling===null;){if(O.return===null||O.return===x)break e;T===O&&(T=null),O=O.return}T===O&&(T=null),O.sibling.return=O.return,O=O.sibling}A&4&&(A=x.updateQueue,A!==null&&(T=A.retryQueue,T!==null&&(A.retryQueue=null,E5(x,T))));break;case 19:Id(O,x),Ad(x),A&4&&(A=x.updateQueue,A!==null&&(x.updateQueue=null,E5(x,A)));break;case 30:break;case 21:break;default:Id(O,x),Ad(x)}}function Ad(x){var O=x.flags;if(O&2){try{for(var T,A=x.return;A!==null;){if(ZIe(A)){T=A;break}A=A.return}if(T==null)throw Error(s(160));switch(T.tag){case 27:var H=T.stateNode,Q=uQ(x);C5(x,Q,H);break;case 5:var ie=T.stateNode;T.flags&32&&(Tm(ie,""),T.flags&=-33);var we=uQ(x);C5(x,we,ie);break;case 3:case 4:var Be=T.stateNode.containerInfo,st=uQ(x);dQ(x,st,Be);break;default:throw Error(s(161))}}catch(xt){qa(x,x.return,xt)}x.flags&=-3}O&4096&&(x.flags&=-4097)}function nAe(x){if(x.subtreeFlags&1024)for(x=x.child;x!==null;){var O=x;nAe(O),O.tag===5&&O.flags&1024&&O.stateNode.reset(),x=x.sibling}}function eb(x,O){if(O.subtreeFlags&8772)for(O=O.child;O!==null;)YIe(x,O.alternate,O),O=O.sibling}function hS(x){for(x=x.child;x!==null;){var O=x;switch(O.tag){case 0:case 11:case 14:case 15:g0(4,O,O.return),hS(O);break;case 1:Xg(O,O.return);var T=O.stateNode;typeof T.componentWillUnmount=="function"&&HIe(O,O.return,T),hS(O);break;case 27:aA(O.stateNode);case 26:case 5:Xg(O,O.return),hS(O);break;case 22:O.memoizedState===null&&hS(O);break;case 30:hS(O);break;default:hS(O)}x=x.sibling}}function tb(x,O,T){for(T=T&&(O.subtreeFlags&8772)!==0,O=O.child;O!==null;){var A=O.alternate,H=x,Q=O,ie=Q.flags;switch(Q.tag){case 0:case 11:case 15:tb(H,Q,T),QI(4,Q);break;case 1:if(tb(H,Q,T),A=Q,H=A.stateNode,typeof H.componentDidMount=="function")try{H.componentDidMount()}catch(st){qa(A,A.return,st)}if(A=Q,H=A.updateQueue,H!==null){var we=A.stateNode;try{var Be=H.shared.hiddenCallbacks;if(Be!==null)for(H.shared.hiddenCallbacks=null,H=0;H<Be.length;H++)RNe(Be[H],we)}catch(st){qa(A,A.return,st)}}T&&ie&64&&VIe(Q),YI(Q,Q.return);break;case 27:GIe(Q);case 26:case 5:tb(H,Q,T),T&&A===null&&ie&4&&WIe(Q),YI(Q,Q.return);break;case 12:tb(H,Q,T);break;case 31:tb(H,Q,T),T&&ie&4&&JIe(H,Q);break;case 13:tb(H,Q,T),T&&ie&4&&eAe(H,Q);break;case 22:Q.memoizedState===null&&tb(H,Q,T),YI(Q,Q.return);break;case 30:break;default:tb(H,Q,T)}O=O.sibling}}function pQ(x,O){var T=null;x!==null&&x.memoizedState!==null&&x.memoizedState.cachePool!==null&&(T=x.memoizedState.cachePool.pool),x=null,O.memoizedState!==null&&O.memoizedState.cachePool!==null&&(x=O.memoizedState.cachePool.pool),x!==T&&(x!=null&&x.refCount++,T!=null&&MI(T))}function hQ(x,O){x=null,O.alternate!==null&&(x=O.alternate.memoizedState.cache),O=O.memoizedState.cache,O!==x&&(O.refCount++,x!=null&&MI(x))}function Pm(x,O,T,A){if(O.subtreeFlags&10256)for(O=O.child;O!==null;)rAe(x,O,T,A),O=O.sibling}function rAe(x,O,T,A){var H=O.flags;switch(O.tag){case 0:case 11:case 15:Pm(x,O,T,A),H&2048&&QI(9,O);break;case 1:Pm(x,O,T,A);break;case 3:Pm(x,O,T,A),H&2048&&(x=null,O.alternate!==null&&(x=O.alternate.memoizedState.cache),O=O.memoizedState.cache,O!==x&&(O.refCount++,x!=null&&MI(x)));break;case 12:if(H&2048){Pm(x,O,T,A),x=O.stateNode;try{var Q=O.memoizedProps,ie=Q.id,we=Q.onPostCommit;typeof we=="function"&&we(ie,O.alternate===null?"mount":"update",x.passiveEffectDuration,-0)}catch(Be){qa(O,O.return,Be)}}else Pm(x,O,T,A);break;case 31:Pm(x,O,T,A);break;case 13:Pm(x,O,T,A);break;case 23:break;case 22:Q=O.stateNode,ie=O.alternate,O.memoizedState!==null?Q._visibility&2?Pm(x,O,T,A):XI(x,O):Q._visibility&2?Pm(x,O,T,A):(Q._visibility|=2,hC(x,O,T,A,(O.subtreeFlags&10256)!==0||!1)),H&2048&&pQ(ie,O);break;case 24:Pm(x,O,T,A),H&2048&&hQ(O.alternate,O);break;default:Pm(x,O,T,A)}}function hC(x,O,T,A,H){for(H=H&&((O.subtreeFlags&10256)!==0||!1),O=O.child;O!==null;){var Q=x,ie=O,we=T,Be=A,st=ie.flags;switch(ie.tag){case 0:case 11:case 15:hC(Q,ie,we,Be,H),QI(8,ie);break;case 23:break;case 22:var xt=ie.stateNode;ie.memoizedState!==null?xt._visibility&2?hC(Q,ie,we,Be,H):XI(Q,ie):(xt._visibility|=2,hC(Q,ie,we,Be,H)),H&&st&2048&&pQ(ie.alternate,ie);break;case 24:hC(Q,ie,we,Be,H),H&&st&2048&&hQ(ie.alternate,ie);break;default:hC(Q,ie,we,Be,H)}O=O.sibling}}function XI(x,O){if(O.subtreeFlags&10256)for(O=O.child;O!==null;){var T=x,A=O,H=A.flags;switch(A.tag){case 22:XI(T,A),H&2048&&pQ(A.alternate,A);break;case 24:XI(T,A),H&2048&&hQ(A.alternate,A);break;default:XI(T,A)}O=O.sibling}}var KI=8192;function mC(x,O,T){if(x.subtreeFlags&KI)for(x=x.child;x!==null;)sAe(x,O,T),x=x.sibling}function sAe(x,O,T){switch(x.tag){case 26:mC(x,O,T),x.flags&KI&&x.memoizedState!==null&&Mzt(T,Rm,x.memoizedState,x.memoizedProps);break;case 5:mC(x,O,T);break;case 3:case 4:var A=Rm;Rm=B5(x.stateNode.containerInfo),mC(x,O,T),Rm=A;break;case 22:x.memoizedState===null&&(A=x.alternate,A!==null&&A.memoizedState!==null?(A=KI,KI=16777216,mC(x,O,T),KI=A):mC(x,O,T));break;default:mC(x,O,T)}}function aAe(x){var O=x.alternate;if(O!==null&&(x=O.child,x!==null)){O.child=null;do O=x.sibling,x.sibling=null,x=O;while(x!==null)}}function JI(x){var O=x.deletions;if((x.flags&16)!==0){if(O!==null)for(var T=0;T<O.length;T++){var A=O[T];lc=A,oAe(A,x)}aAe(x)}if(x.subtreeFlags&10256)for(x=x.child;x!==null;)iAe(x),x=x.sibling}function iAe(x){switch(x.tag){case 0:case 11:case 15:JI(x),x.flags&2048&&g0(9,x,x.return);break;case 3:JI(x);break;case 12:JI(x);break;case 22:var O=x.stateNode;x.memoizedState!==null&&O._visibility&2&&(x.return===null||x.return.tag!==13)?(O._visibility&=-3,j5(x)):JI(x);break;default:JI(x)}}function j5(x){var O=x.deletions;if((x.flags&16)!==0){if(O!==null)for(var T=0;T<O.length;T++){var A=O[T];lc=A,oAe(A,x)}aAe(x)}for(x=x.child;x!==null;){switch(O=x,O.tag){case 0:case 11:case 15:g0(8,O,O.return),j5(O);break;case 22:T=O.stateNode,T._visibility&2&&(T._visibility&=-3,j5(O));break;default:j5(O)}x=x.sibling}}function oAe(x,O){for(;lc!==null;){var T=lc;switch(T.tag){case 0:case 11:case 15:g0(8,T,O);break;case 23:case 22:if(T.memoizedState!==null&&T.memoizedState.cachePool!==null){var A=T.memoizedState.cachePool.pool;A!=null&&A.refCount++}break;case 24:MI(T.memoizedState.cache)}if(A=T.child,A!==null)A.return=T,lc=A;else e:for(T=x;lc!==null;){A=lc;var H=A.sibling,Q=A.return;if(XIe(A),A===T){lc=null;break e}if(H!==null){H.return=Q,lc=H;break e}lc=Q}}}var XFt={getCacheForType:function(x){var O=Ac(vl),T=O.data.get(x);return T===void 0&&(T=x(),O.data.set(x,T)),T},cacheSignal:function(){return Ac(vl).controller.signal}},KFt=typeof WeakMap=="function"?WeakMap:Map,ja=0,mi=null,Es=null,Ls=0,Ua=0,Ff=null,v0=!1,gC=!1,mQ=!1,nb=0,Vo=0,y0=0,mS=0,gQ=0,zf=0,vC=0,eA=null,Rd=null,vQ=!1,T5=0,lAe=0,N5=1/0,I5=null,b0=null,Ml=0,x0=null,yC=null,rb=0,yQ=0,bQ=null,cAe=null,tA=0,xQ=null;function Bf(){return(ja&2)!==0&&Ls!==0?Ls&-Ls:L.T!==null?CQ():nt()}function uAe(){if(zf===0)if((Ls&536870912)===0||Zs){var x=yt;yt<<=1,(yt&3932160)===0&&(yt=262144),zf=x}else zf=536870912;return x=Df.current,x!==null&&(x.flags|=32),zf}function Pd(x,O,T){(x===mi&&(Ua===2||Ua===9)||x.cancelPendingCommit!==null)&&(bC(x,0),w0(x,Ls,zf,!1)),Yt(x,T),((ja&2)===0||x!==mi)&&(x===mi&&((ja&2)===0&&(mS|=T),Vo===4&&w0(x,Ls,zf,!1)),Kg(x))}function dAe(x,O,T){if((ja&6)!==0)throw Error(s(327));var A=!T&&(O&127)===0&&(O&x.expiredLanes)===0||en(x,O),H=A?tzt(x,O):SQ(x,O,!0),Q=A;do{if(H===0){gC&&!A&&w0(x,O,0,!1);break}else{if(T=x.current.alternate,Q&&!JFt(T)){H=SQ(x,O,!1),Q=!1;continue}if(H===2){if(Q=O,x.errorRecoveryDisabledLanes&Q)var ie=0;else ie=x.pendingLanes&-536870913,ie=ie!==0?ie:ie&536870912?536870912:0;if(ie!==0){O=ie;e:{var we=x;H=eA;var Be=we.current.memoizedState.isDehydrated;if(Be&&(bC(we,ie).flags|=256),ie=SQ(we,ie,!1),ie!==2){if(mQ&&!Be){we.errorRecoveryDisabledLanes|=Q,mS|=Q,H=4;break e}Q=Rd,Rd=H,Q!==null&&(Rd===null?Rd=Q:Rd.push.apply(Rd,Q))}H=ie}if(Q=!1,H!==2)continue}}if(H===1){bC(x,0),w0(x,O,0,!0);break}e:{switch(A=x,Q=H,Q){case 0:case 1:throw Error(s(345));case 4:if((O&4194048)!==O)break;case 6:w0(A,O,zf,!v0);break e;case 2:Rd=null;break;case 3:case 5:break;default:throw Error(s(329))}if((O&62914560)===O&&(H=T5+300-se(),10<H)){if(w0(A,O,zf,!v0),Pt(A,0,!0)!==0)break e;rb=O,A.timeoutHandle=UAe(fAe.bind(null,A,T,Rd,I5,vQ,O,zf,mS,vC,v0,Q,"Throttled",-0,0),H);break e}fAe(A,T,Rd,I5,vQ,O,zf,mS,vC,v0,Q,null,-0,0)}}break}while(!0);Kg(x)}function fAe(x,O,T,A,H,Q,ie,we,Be,st,xt,Ct,lt,dt){if(x.timeoutHandle=-1,Ct=O.subtreeFlags,Ct&8192||(Ct&16785408)===16785408){Ct={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Nm},sAe(O,Q,Ct);var Mn=(Q&62914560)===Q?T5-se():(Q&4194048)===Q?lAe-se():0;if(Mn=Dzt(Ct,Mn),Mn!==null){rb=Q,x.cancelPendingCommit=Mn(xAe.bind(null,x,O,Q,T,A,H,ie,we,Be,xt,Ct,null,lt,dt)),w0(x,Q,ie,!st);return}}xAe(x,O,Q,T,A,H,ie,we,Be)}function JFt(x){for(var O=x;;){var T=O.tag;if((T===0||T===11||T===15)&&O.flags&16384&&(T=O.updateQueue,T!==null&&(T=T.stores,T!==null)))for(var A=0;A<T.length;A++){var H=T[A],Q=H.getSnapshot;H=H.value;try{if(!$f(Q(),H))return!1}catch{return!1}}if(T=O.child,O.subtreeFlags&16384&&T!==null)T.return=O,O=T;else{if(O===x)break;for(;O.sibling===null;){if(O.return===null||O.return===x)return!0;O=O.return}O.sibling.return=O.return,O=O.sibling}}return!0}function w0(x,O,T,A){O&=~gQ,O&=~mS,x.suspendedLanes|=O,x.pingedLanes&=~O,A&&(x.warmLanes|=O),A=x.expirationTimes;for(var H=O;0<H;){var Q=31-Re(H),ie=1<<Q;A[Q]=-1,H&=~ie}T!==0&&_n(x,T,O)}function A5(){return(ja&6)===0?(nA(0),!1):!0}function wQ(){if(Es!==null){if(Ua===0)var x=Es.return;else x=Es,Wy=iS=null,DG(x),cC=null,LI=0,x=Es;for(;x!==null;)qIe(x.alternate,x),x=x.return;Es=null}}function bC(x,O){var T=x.timeoutHandle;T!==-1&&(x.timeoutHandle=-1,bzt(T)),T=x.cancelPendingCommit,T!==null&&(x.cancelPendingCommit=null,T()),rb=0,wQ(),mi=x,Es=T=Vy(x.current,null),Ls=O,Ua=0,Ff=null,v0=!1,gC=en(x,O),mQ=!1,vC=zf=gQ=mS=y0=Vo=0,Rd=eA=null,vQ=!1,(O&8)!==0&&(O|=O&32);var A=x.entangledLanes;if(A!==0)for(x=x.entanglements,A&=O;0<A;){var H=31-Re(A),Q=1<<H;O|=x[H],A&=~Q}return nb=O,J4(),T}function pAe(x,O){Xr=null,L.H=WI,O===lC||O===o5?(O=TNe(),Ua=3):O===_G?(O=TNe(),Ua=4):Ua=O===JG?8:O!==null&&typeof O=="object"&&typeof O.then=="function"?6:1,Ff=O,Es===null&&(Vo=1,w5(x,nh(O,x.current)))}function hAe(){var x=Df.current;return x===null?!0:(Ls&4194048)===Ls?ih===null:(Ls&62914560)===Ls||(Ls&536870912)!==0?x===ih:!1}function mAe(){var x=L.H;return L.H=WI,x===null?WI:x}function gAe(){var x=L.A;return L.A=XFt,x}function R5(){Vo=4,v0||(Ls&4194048)!==Ls&&Df.current!==null||(gC=!0),(y0&134217727)===0&&(mS&134217727)===0||mi===null||w0(mi,Ls,zf,!1)}function SQ(x,O,T){var A=ja;ja|=2;var H=mAe(),Q=gAe();(mi!==x||Ls!==O)&&(I5=null,bC(x,O)),O=!1;var ie=Vo;e:do try{if(Ua!==0&&Es!==null){var we=Es,Be=Ff;switch(Ua){case 8:wQ(),ie=6;break e;case 3:case 2:case 9:case 6:Df.current===null&&(O=!0);var st=Ua;if(Ua=0,Ff=null,xC(x,we,Be,st),T&&gC){ie=0;break e}break;default:st=Ua,Ua=0,Ff=null,xC(x,we,Be,st)}}ezt(),ie=Vo;break}catch(xt){pAe(x,xt)}while(!0);return O&&x.shellSuspendCounter++,Wy=iS=null,ja=A,L.H=H,L.A=Q,Es===null&&(mi=null,Ls=0,J4()),ie}function ezt(){for(;Es!==null;)vAe(Es)}function tzt(x,O){var T=ja;ja|=2;var A=mAe(),H=gAe();mi!==x||Ls!==O?(I5=null,N5=se()+500,bC(x,O)):gC=en(x,O);e:do try{if(Ua!==0&&Es!==null){O=Es;var Q=Ff;t:switch(Ua){case 1:Ua=0,Ff=null,xC(x,O,Q,1);break;case 2:case 9:if(ENe(Q)){Ua=0,Ff=null,yAe(O);break}O=function(){Ua!==2&&Ua!==9||mi!==x||(Ua=7),Kg(x)},Q.then(O,O);break e;case 3:Ua=7;break e;case 4:Ua=5;break e;case 7:ENe(Q)?(Ua=0,Ff=null,yAe(O)):(Ua=0,Ff=null,xC(x,O,Q,7));break;case 5:var ie=null;switch(Es.tag){case 26:ie=Es.memoizedState;case 5:case 27:var we=Es;if(ie?rRe(ie):we.stateNode.complete){Ua=0,Ff=null;var Be=we.sibling;if(Be!==null)Es=Be;else{var st=we.return;st!==null?(Es=st,P5(st)):Es=null}break t}}Ua=0,Ff=null,xC(x,O,Q,5);break;case 6:Ua=0,Ff=null,xC(x,O,Q,6);break;case 8:wQ(),Vo=6;break e;default:throw Error(s(462))}}nzt();break}catch(xt){pAe(x,xt)}while(!0);return Wy=iS=null,L.H=A,L.A=H,ja=T,Es!==null?0:(mi=null,Ls=0,J4(),Vo)}function nzt(){for(;Es!==null&&!ze();)vAe(Es)}function vAe(x){var O=BIe(x.alternate,x,nb);x.memoizedProps=x.pendingProps,O===null?P5(x):Es=O}function yAe(x){var O=x,T=O.alternate;switch(O.tag){case 15:case 0:O=$Ie(T,O,O.pendingProps,O.type,void 0,Ls);break;case 11:O=$Ie(T,O,O.pendingProps,O.type.render,O.ref,Ls);break;case 5:DG(O);default:qIe(T,O),O=Es=gNe(O,nb),O=BIe(T,O,nb)}x.memoizedProps=x.pendingProps,O===null?P5(x):Es=O}function xC(x,O,T,A){Wy=iS=null,DG(O),cC=null,LI=0;var H=O.return;try{if(VFt(x,H,O,T,Ls)){Vo=1,w5(x,nh(T,x.current)),Es=null;return}}catch(Q){if(H!==null)throw Es=H,Q;Vo=1,w5(x,nh(T,x.current)),Es=null;return}O.flags&32768?(Zs||A===1?x=!0:gC||(Ls&536870912)!==0?x=!1:(v0=x=!0,(A===2||A===9||A===3||A===6)&&(A=Df.current,A!==null&&A.tag===13&&(A.flags|=16384))),bAe(O,x)):P5(O)}function P5(x){var O=x;do{if((O.flags&32768)!==0){bAe(O,v0);return}x=O.return;var T=ZFt(O.alternate,O,nb);if(T!==null){Es=T;return}if(O=O.sibling,O!==null){Es=O;return}Es=O=x}while(O!==null);Vo===0&&(Vo=5)}function bAe(x,O){do{var T=GFt(x.alternate,x);if(T!==null){T.flags&=32767,Es=T;return}if(T=x.return,T!==null&&(T.flags|=32768,T.subtreeFlags=0,T.deletions=null),!O&&(x=x.sibling,x!==null)){Es=x;return}Es=x=T}while(x!==null);Vo=6,Es=null}function xAe(x,O,T,A,H,Q,ie,we,Be){x.cancelPendingCommit=null;do $5();while(Ml!==0);if((ja&6)!==0)throw Error(s(327));if(O!==null){if(O===x.current)throw Error(s(177));if(Q=O.lanes|O.childLanes,Q|=uG,Wt(x,T,Q,ie,we,Be),x===mi&&(Es=mi=null,Ls=0),yC=O,x0=x,rb=T,yQ=Q,bQ=H,cAe=A,(O.subtreeFlags&10256)!==0||(O.flags&10256)!==0?(x.callbackNode=null,x.callbackPriority=0,izt(Ee,function(){return _Ae(),null})):(x.callbackNode=null,x.callbackPriority=0),A=(O.flags&13878)!==0,(O.subtreeFlags&13878)!==0||A){A=L.T,L.T=null,H=z.p,z.p=2,ie=ja,ja|=4;try{QFt(x,O,T)}finally{ja=ie,z.p=H,L.T=A}}Ml=1,wAe(),SAe(),kAe()}}function wAe(){if(Ml===1){Ml=0;var x=x0,O=yC,T=(O.flags&13878)!==0;if((O.subtreeFlags&13878)!==0||T){T=L.T,L.T=null;var A=z.p;z.p=2;var H=ja;ja|=4;try{tAe(O,x);var Q=PQ,ie=oNe(x.containerInfo),we=Q.focusedElem,Be=Q.selectionRange;if(ie!==we&&we&&we.ownerDocument&&iNe(we.ownerDocument.documentElement,we)){if(Be!==null&&aG(we)){var st=Be.start,xt=Be.end;if(xt===void 0&&(xt=st),"selectionStart"in we)we.selectionStart=st,we.selectionEnd=Math.min(xt,we.value.length);else{var Ct=we.ownerDocument||document,lt=Ct&&Ct.defaultView||window;if(lt.getSelection){var dt=lt.getSelection(),Mn=we.textContent.length,yr=Math.min(Be.start,Mn),ti=Be.end===void 0?yr:Math.min(Be.end,Mn);!dt.extend&&yr>ti&&(ie=ti,ti=yr,yr=ie);var et=aNe(we,yr),He=aNe(we,ti);if(et&&He&&(dt.rangeCount!==1||dt.anchorNode!==et.node||dt.anchorOffset!==et.offset||dt.focusNode!==He.node||dt.focusOffset!==He.offset)){var rt=Ct.createRange();rt.setStart(et.node,et.offset),dt.removeAllRanges(),yr>ti?(dt.addRange(rt),dt.extend(He.node,He.offset)):(rt.setEnd(He.node,He.offset),dt.addRange(rt))}}}}for(Ct=[],dt=we;dt=dt.parentNode;)dt.nodeType===1&&Ct.push({element:dt,left:dt.scrollLeft,top:dt.scrollTop});for(typeof we.focus=="function"&&we.focus(),we=0;we<Ct.length;we++){var kt=Ct[we];kt.element.scrollLeft=kt.left,kt.element.scrollTop=kt.top}}Z5=!!RQ,PQ=RQ=null}finally{ja=H,z.p=A,L.T=T}}x.current=O,Ml=2}}function SAe(){if(Ml===2){Ml=0;var x=x0,O=yC,T=(O.flags&8772)!==0;if((O.subtreeFlags&8772)!==0||T){T=L.T,L.T=null;var A=z.p;z.p=2;var H=ja;ja|=4;try{YIe(x,O.alternate,O)}finally{ja=H,z.p=A,L.T=T}}Ml=3}}function kAe(){if(Ml===4||Ml===3){Ml=0,oe();var x=x0,O=yC,T=rb,A=cAe;(O.subtreeFlags&10256)!==0||(O.flags&10256)!==0?Ml=5:(Ml=0,yC=x0=null,OAe(x,x.pendingLanes));var H=x.pendingLanes;if(H===0&&(b0=null),Je(T),O=O.stateNode,_e&&typeof _e.onCommitFiberRoot=="function")try{_e.onCommitFiberRoot(je,O,void 0,(O.current.flags&128)===128)}catch{}if(A!==null){O=L.T,H=z.p,z.p=2,L.T=null;try{for(var Q=x.onRecoverableError,ie=0;ie<A.length;ie++){var we=A[ie];Q(we.value,{componentStack:we.stack})}}finally{L.T=O,z.p=H}}(rb&3)!==0&&$5(),Kg(x),H=x.pendingLanes,(T&261930)!==0&&(H&42)!==0?x===xQ?tA++:(tA=0,xQ=x):tA=0,nA(0)}}function OAe(x,O){(x.pooledCacheLanes&=O)===0&&(O=x.pooledCache,O!=null&&(x.pooledCache=null,MI(O)))}function $5(){return wAe(),SAe(),kAe(),_Ae()}function _Ae(){if(Ml!==5)return!1;var x=x0,O=yQ;yQ=0;var T=Je(rb),A=L.T,H=z.p;try{z.p=32>T?32:T,L.T=null,T=bQ,bQ=null;var Q=x0,ie=rb;if(Ml=0,yC=x0=null,rb=0,(ja&6)!==0)throw Error(s(331));var we=ja;if(ja|=4,iAe(Q.current),rAe(Q,Q.current,ie,T),ja=we,nA(0,!1),_e&&typeof _e.onPostCommitFiberRoot=="function")try{_e.onPostCommitFiberRoot(je,Q)}catch{}return!0}finally{z.p=H,L.T=A,OAe(x,O)}}function CAe(x,O,T){O=nh(T,O),O=KG(x.stateNode,O,2),x=p0(x,O,2),x!==null&&(Yt(x,2),Kg(x))}function qa(x,O,T){if(x.tag===3)CAe(x,x,T);else for(;O!==null;){if(O.tag===3){CAe(O,x,T);break}else if(O.tag===1){var A=O.stateNode;if(typeof O.type.getDerivedStateFromError=="function"||typeof A.componentDidCatch=="function"&&(b0===null||!b0.has(A))){x=nh(T,x),T=EIe(2),A=p0(O,T,2),A!==null&&(jIe(T,A,O,x),Yt(A,2),Kg(A));break}}O=O.return}}function kQ(x,O,T){var A=x.pingCache;if(A===null){A=x.pingCache=new KFt;var H=new Set;A.set(O,H)}else H=A.get(O),H===void 0&&(H=new Set,A.set(O,H));H.has(T)||(mQ=!0,H.add(T),x=rzt.bind(null,x,O,T),O.then(x,x))}function rzt(x,O,T){var A=x.pingCache;A!==null&&A.delete(O),x.pingedLanes|=x.suspendedLanes&T,x.warmLanes&=~T,mi===x&&(Ls&T)===T&&(Vo===4||Vo===3&&(Ls&62914560)===Ls&&300>se()-T5?(ja&2)===0&&bC(x,0):gQ|=T,vC===Ls&&(vC=0)),Kg(x)}function EAe(x,O){O===0&&(O=ot()),x=rS(x,O),x!==null&&(Yt(x,O),Kg(x))}function szt(x){var O=x.memoizedState,T=0;O!==null&&(T=O.retryLane),EAe(x,T)}function azt(x,O){var T=0;switch(x.tag){case 31:case 13:var A=x.stateNode,H=x.memoizedState;H!==null&&(T=H.retryLane);break;case 19:A=x.stateNode;break;case 22:A=x.stateNode._retryCache;break;default:throw Error(s(314))}A!==null&&A.delete(O),EAe(x,T)}function izt(x,O){return ke(x,O)}var M5=null,wC=null,OQ=!1,D5=!1,_Q=!1,S0=0;function Kg(x){x!==wC&&x.next===null&&(wC===null?M5=wC=x:wC=wC.next=x),D5=!0,OQ||(OQ=!0,lzt())}function nA(x,O){if(!_Q&&D5){_Q=!0;do for(var T=!1,A=M5;A!==null;){if(x!==0){var H=A.pendingLanes;if(H===0)var Q=0;else{var ie=A.suspendedLanes,we=A.pingedLanes;Q=(1<<31-Re(42|x)+1)-1,Q&=H&~(ie&~we),Q=Q&201326741?Q&201326741|1:Q?Q|2:0}Q!==0&&(T=!0,IAe(A,Q))}else Q=Ls,Q=Pt(A,A===mi?Q:0,A.cancelPendingCommit!==null||A.timeoutHandle!==-1),(Q&3)===0||en(A,Q)||(T=!0,IAe(A,Q));A=A.next}while(T);_Q=!1}}function ozt(){jAe()}function jAe(){D5=OQ=!1;var x=0;S0!==0&&yzt()&&(x=S0);for(var O=se(),T=null,A=M5;A!==null;){var H=A.next,Q=TAe(A,O);Q===0?(A.next=null,T===null?M5=H:T.next=H,H===null&&(wC=T)):(T=A,(x!==0||(Q&3)!==0)&&(D5=!0)),A=H}Ml!==0&&Ml!==5||nA(x),S0!==0&&(S0=0)}function TAe(x,O){for(var T=x.suspendedLanes,A=x.pingedLanes,H=x.expirationTimes,Q=x.pendingLanes&-62914561;0<Q;){var ie=31-Re(Q),we=1<<ie,Be=H[ie];Be===-1?((we&T)===0||(we&A)!==0)&&(H[ie]=Ye(we,O)):Be<=O&&(x.expiredLanes|=we),Q&=~we}if(O=mi,T=Ls,T=Pt(x,x===O?T:0,x.cancelPendingCommit!==null||x.timeoutHandle!==-1),A=x.callbackNode,T===0||x===O&&(Ua===2||Ua===9)||x.cancelPendingCommit!==null)return A!==null&&A!==null&&Ie(A),x.callbackNode=null,x.callbackPriority=0;if((T&3)===0||en(x,T)){if(O=T&-T,O===x.callbackPriority)return O;switch(A!==null&&Ie(A),Je(T)){case 2:case 8:T=xe;break;case 32:T=Ee;break;case 268435456:T=Qe;break;default:T=Ee}return A=NAe.bind(null,x),T=ke(T,A),x.callbackPriority=O,x.callbackNode=T,O}return A!==null&&A!==null&&Ie(A),x.callbackPriority=2,x.callbackNode=null,2}function NAe(x,O){if(Ml!==0&&Ml!==5)return x.callbackNode=null,x.callbackPriority=0,null;var T=x.callbackNode;if($5()&&x.callbackNode!==T)return null;var A=Ls;return A=Pt(x,x===mi?A:0,x.cancelPendingCommit!==null||x.timeoutHandle!==-1),A===0?null:(dAe(x,A,O),TAe(x,se()),x.callbackNode!=null&&x.callbackNode===T?NAe.bind(null,x):null)}function IAe(x,O){if($5())return null;dAe(x,O,!0)}function lzt(){xzt(function(){(ja&6)!==0?ke(he,ozt):jAe()})}function CQ(){if(S0===0){var x=iC;x===0&&(x=Ot,Ot<<=1,(Ot&261888)===0&&(Ot=256)),S0=x}return S0}function AAe(x){return x==null||typeof x=="symbol"||typeof x=="boolean"?null:typeof x=="function"?x:Y_(""+x)}function RAe(x,O){var T=O.ownerDocument.createElement("input");return T.name=O.name,T.value=O.value,x.id&&T.setAttribute("form",x.id),O.parentNode.insertBefore(T,O),x=new FormData(x),T.parentNode.removeChild(T),x}function czt(x,O,T,A,H){if(O==="submit"&&T&&T.stateNode===H){var Q=AAe((H[$t]||null).action),ie=A.submitter;ie&&(O=(O=ie[$t]||null)?AAe(O.formAction):ie.getAttribute("formAction"),O!==null&&(Q=O,ie=null));var we=new Q4("action","action",null,A,H);x.push({event:we,listeners:[{instance:null,listener:function(){if(A.defaultPrevented){if(S0!==0){var Be=ie?RAe(H,ie):new FormData(H);WG(T,{pending:!0,data:Be,method:H.method,action:Q},null,Be)}}else typeof Q=="function"&&(we.preventDefault(),Be=ie?RAe(H,ie):new FormData(H),WG(T,{pending:!0,data:Be,method:H.method,action:Q},Q,Be))},currentTarget:H}]})}}for(var EQ=0;EQ<cG.length;EQ++){var jQ=cG[EQ],uzt=jQ.toLowerCase(),dzt=jQ[0].toUpperCase()+jQ.slice(1);Am(uzt,"on"+dzt)}Am(uNe,"onAnimationEnd"),Am(dNe,"onAnimationIteration"),Am(fNe,"onAnimationStart"),Am("dblclick","onDoubleClick"),Am("focusin","onFocus"),Am("focusout","onBlur"),Am(EFt,"onTransitionRun"),Am(jFt,"onTransitionStart"),Am(TFt,"onTransitionCancel"),Am(pNe,"onTransitionEnd"),il("onMouseEnter",["mouseout","mouseover"]),il("onMouseLeave",["mouseout","mouseover"]),il("onPointerEnter",["pointerout","pointerover"]),il("onPointerLeave",["pointerout","pointerover"]),gl("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),gl("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),gl("onBeforeInput",["compositionend","keypress","textInput","paste"]),gl("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),gl("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),gl("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var rA="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),fzt=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(rA));function PAe(x,O){O=(O&4)!==0;for(var T=0;T<x.length;T++){var A=x[T],H=A.event;A=A.listeners;e:{var Q=void 0;if(O)for(var ie=A.length-1;0<=ie;ie--){var we=A[ie],Be=we.instance,st=we.currentTarget;if(we=we.listener,Be!==Q&&H.isPropagationStopped())break e;Q=we,H.currentTarget=st;try{Q(H)}catch(xt){K4(xt)}H.currentTarget=null,Q=Be}else for(ie=0;ie<A.length;ie++){if(we=A[ie],Be=we.instance,st=we.currentTarget,we=we.listener,Be!==Q&&H.isPropagationStopped())break e;Q=we,H.currentTarget=st;try{Q(H)}catch(xt){K4(xt)}H.currentTarget=null,Q=Be}}}}function js(x,O){var T=O[xn];T===void 0&&(T=O[xn]=new Set);var A=x+"__bubble";T.has(A)||($Ae(O,x,2,!1),T.add(A))}function TQ(x,O,T){var A=0;O&&(A|=4),$Ae(T,x,A,O)}var L5="_reactListening"+Math.random().toString(36).slice(2);function NQ(x){if(!x[L5]){x[L5]=!0,Ma.forEach(function(T){T!=="selectionchange"&&(fzt.has(T)||TQ(T,!1,x),TQ(T,!0,x))});var O=x.nodeType===9?x:x.ownerDocument;O===null||O[L5]||(O[L5]=!0,TQ("selectionchange",!1,O))}}function $Ae(x,O,T,A){switch(uRe(O)){case 2:var H=zzt;break;case 8:H=Bzt;break;default:H=HQ}T=H.bind(null,O,T,x),H=void 0,!Im||O!=="touchstart"&&O!=="touchmove"&&O!=="wheel"||(H=!0),A?H!==void 0?x.addEventListener(O,T,{capture:!0,passive:H}):x.addEventListener(O,T,!0):H!==void 0?x.addEventListener(O,T,{passive:H}):x.addEventListener(O,T,!1)}function IQ(x,O,T,A,H){var Q=A;if((O&1)===0&&(O&2)===0&&A!==null)e:for(;;){if(A===null)return;var ie=A.tag;if(ie===3||ie===4){var we=A.stateNode.containerInfo;if(we===H)break;if(ie===4)for(ie=A.return;ie!==null;){var Be=ie.tag;if((Be===3||Be===4)&&ie.stateNode.containerInfo===H)return;ie=ie.return}for(;we!==null;){if(ie=Mr(we),ie===null)return;if(Be=ie.tag,Be===5||Be===6||Be===26||Be===27){A=Q=ie;continue e}we=we.parentNode}}A=A.return}Ea(function(){var st=Q,xt=OI(T),Ct=[];e:{var lt=hNe.get(x);if(lt!==void 0){var dt=Q4,Mn=x;switch(x){case"keypress":if(Z4(T)===0)break e;case"keydown":case"keyup":dt=aFt;break;case"focusin":Mn="focus",dt=eG;break;case"focusout":Mn="blur",dt=eG;break;case"beforeblur":case"afterblur":dt=eG;break;case"click":if(T.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":dt=qTe;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":dt=Z9t;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":dt=lFt;break;case uNe:case dNe:case fNe:dt=Y9t;break;case pNe:dt=uFt;break;case"scroll":case"scrollend":dt=H9t;break;case"wheel":dt=fFt;break;case"copy":case"cut":case"paste":dt=K9t;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":dt=HTe;break;case"toggle":case"beforetoggle":dt=hFt}var yr=(O&4)!==0,ti=!yr&&(x==="scroll"||x==="scrollend"),et=yr?lt!==null?lt+"Capture":null:lt;yr=[];for(var He=st,rt;He!==null;){var kt=He;if(rt=kt.stateNode,kt=kt.tag,kt!==5&&kt!==26&&kt!==27||rt===null||et===null||(kt=so(He,et),kt!=null&&yr.push(sA(He,kt,rt))),ti)break;He=He.return}0<yr.length&&(lt=new dt(lt,Mn,null,T,xt),Ct.push({event:lt,listeners:yr}))}}if((O&7)===0){e:{if(lt=x==="mouseover"||x==="pointerover",dt=x==="mouseout"||x==="pointerout",lt&&T!==J1&&(Mn=T.relatedTarget||T.fromElement)&&(Mr(Mn)||Mn[jt]))break e;if((dt||lt)&&(lt=xt.window===xt?xt:(lt=xt.ownerDocument)?lt.defaultView||lt.parentWindow:window,dt?(Mn=T.relatedTarget||T.toElement,dt=st,Mn=Mn?Mr(Mn):null,Mn!==null&&(ti=i(Mn),yr=Mn.tag,Mn!==ti||yr!==5&&yr!==27&&yr!==6)&&(Mn=null)):(dt=null,Mn=st),dt!==Mn)){if(yr=qTe,kt="onMouseLeave",et="onMouseEnter",He="mouse",(x==="pointerout"||x==="pointerover")&&(yr=HTe,kt="onPointerLeave",et="onPointerEnter",He="pointer"),ti=dt==null?lt:Hs(dt),rt=Mn==null?lt:Hs(Mn),lt=new yr(kt,He+"leave",dt,T,xt),lt.target=ti,lt.relatedTarget=rt,kt=null,Mr(xt)===st&&(yr=new yr(et,He+"enter",Mn,T,xt),yr.target=rt,yr.relatedTarget=ti,kt=yr),ti=kt,dt&&Mn)t:{for(yr=pzt,et=dt,He=Mn,rt=0,kt=et;kt;kt=yr(kt))rt++;kt=0;for(var cr=He;cr;cr=yr(cr))kt++;for(;0<rt-kt;)et=yr(et),rt--;for(;0<kt-rt;)He=yr(He),kt--;for(;rt--;){if(et===He||He!==null&&et===He.alternate){yr=et;break t}et=yr(et),He=yr(He)}yr=null}else yr=null;dt!==null&&MAe(Ct,lt,dt,yr,!1),Mn!==null&&ti!==null&&MAe(Ct,ti,Mn,yr,!0)}}e:{if(lt=st?Hs(st):window,dt=lt.nodeName&<.nodeName.toLowerCase(),dt==="select"||dt==="input"&<.type==="file")var pa=JTe;else if(XTe(lt))if(eNe)pa=OFt;else{pa=SFt;var Gn=wFt}else dt=lt.nodeName,!dt||dt.toLowerCase()!=="input"||lt.type!=="checkbox"&<.type!=="radio"?st&&K1(st.elementType)&&(pa=JTe):pa=kFt;if(pa&&(pa=pa(x,st))){KTe(Ct,pa,T,xt);break e}Gn&&Gn(x,lt,st),x==="focusout"&&st&<.type==="number"&&st.memoizedProps.value!=null&&Zg(lt,"number",lt.value)}switch(Gn=st?Hs(st):window,x){case"focusin":(XTe(Gn)||Gn.contentEditable==="true")&&(K_=Gn,iG=st,RI=null);break;case"focusout":RI=iG=K_=null;break;case"mousedown":oG=!0;break;case"contextmenu":case"mouseup":case"dragend":oG=!1,lNe(Ct,T,xt);break;case"selectionchange":if(CFt)break;case"keydown":case"keyup":lNe(Ct,T,xt)}var rs;if(nG)e:{switch(x){case"compositionstart":var Fs="onCompositionStart";break e;case"compositionend":Fs="onCompositionEnd";break e;case"compositionupdate":Fs="onCompositionUpdate";break e}Fs=void 0}else X_?QTe(x,T)&&(Fs="onCompositionEnd"):x==="keydown"&&T.keyCode===229&&(Fs="onCompositionStart");Fs&&(WTe&&T.locale!=="ko"&&(X_||Fs!=="onCompositionStart"?Fs==="onCompositionEnd"&&X_&&(rs=BTe()):(Pf=xt,_I="value"in Pf?Pf.value:Pf.textContent,X_=!0)),Gn=F5(st,Fs),0<Gn.length&&(Fs=new VTe(Fs,x,null,T,xt),Ct.push({event:Fs,listeners:Gn}),rs?Fs.data=rs:(rs=YTe(T),rs!==null&&(Fs.data=rs)))),(rs=gFt?vFt(x,T):yFt(x,T))&&(Fs=F5(st,"onBeforeInput"),0<Fs.length&&(Gn=new VTe("onBeforeInput","beforeinput",null,T,xt),Ct.push({event:Gn,listeners:Fs}),Gn.data=rs)),czt(Ct,x,st,T,xt)}PAe(Ct,O)})}function sA(x,O,T){return{instance:x,listener:O,currentTarget:T}}function F5(x,O){for(var T=O+"Capture",A=[];x!==null;){var H=x,Q=H.stateNode;if(H=H.tag,H!==5&&H!==26&&H!==27||Q===null||(H=so(x,T),H!=null&&A.unshift(sA(x,H,Q)),H=so(x,O),H!=null&&A.push(sA(x,H,Q))),x.tag===3)return A;x=x.return}return[]}function pzt(x){if(x===null)return null;do x=x.return;while(x&&x.tag!==5&&x.tag!==27);return x||null}function MAe(x,O,T,A,H){for(var Q=O._reactName,ie=[];T!==null&&T!==A;){var we=T,Be=we.alternate,st=we.stateNode;if(we=we.tag,Be!==null&&Be===A)break;we!==5&&we!==26&&we!==27||st===null||(Be=st,H?(st=so(T,Q),st!=null&&ie.unshift(sA(T,st,Be))):H||(st=so(T,Q),st!=null&&ie.push(sA(T,st,Be)))),T=T.return}ie.length!==0&&x.push({event:O,listeners:ie})}var hzt=/\r\n?/g,mzt=/\u0000|\uFFFD/g;function DAe(x){return(typeof x=="string"?x:""+x).replace(hzt,`
|
|
10
|
-
`).replace(mzt,"")}function LAe(x,O){return O=DAe(O),DAe(x)===O}function ei(x,O,T,A,H,Q){switch(T){case"children":typeof A=="string"?O==="body"||O==="textarea"&&A===""||Tm(x,A):(typeof A=="number"||typeof A=="bigint")&&O!=="body"&&Tm(x,""+A);break;case"className":Zr(x,"class",A);break;case"tabIndex":Zr(x,"tabindex",A);break;case"dir":case"role":case"viewBox":case"width":case"height":Zr(x,T,A);break;case"style":Q_(x,A,Q);break;case"data":if(O!=="object"){Zr(x,"data",A);break}case"src":case"href":if(A===""&&(O!=="a"||T!=="href")){x.removeAttribute(T);break}if(A==null||typeof A=="function"||typeof A=="symbol"||typeof A=="boolean"){x.removeAttribute(T);break}A=Y_(""+A),x.setAttribute(T,A);break;case"action":case"formAction":if(typeof A=="function"){x.setAttribute(T,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof Q=="function"&&(T==="formAction"?(O!=="input"&&ei(x,O,"name",H.name,H,null),ei(x,O,"formEncType",H.formEncType,H,null),ei(x,O,"formMethod",H.formMethod,H,null),ei(x,O,"formTarget",H.formTarget,H,null)):(ei(x,O,"encType",H.encType,H,null),ei(x,O,"method",H.method,H,null),ei(x,O,"target",H.target,H,null)));if(A==null||typeof A=="symbol"||typeof A=="boolean"){x.removeAttribute(T);break}A=Y_(""+A),x.setAttribute(T,A);break;case"onClick":A!=null&&(x.onclick=Nm);break;case"onScroll":A!=null&&js("scroll",x);break;case"onScrollEnd":A!=null&&js("scrollend",x);break;case"dangerouslySetInnerHTML":if(A!=null){if(typeof A!="object"||!("__html"in A))throw Error(s(61));if(T=A.__html,T!=null){if(H.children!=null)throw Error(s(60));x.innerHTML=T}}break;case"multiple":x.multiple=A&&typeof A!="function"&&typeof A!="symbol";break;case"muted":x.muted=A&&typeof A!="function"&&typeof A!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(A==null||typeof A=="function"||typeof A=="boolean"||typeof A=="symbol"){x.removeAttribute("xlink:href");break}T=Y_(""+A),x.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",T);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":A!=null&&typeof A!="function"&&typeof A!="symbol"?x.setAttribute(T,""+A):x.removeAttribute(T);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":A&&typeof A!="function"&&typeof A!="symbol"?x.setAttribute(T,""):x.removeAttribute(T);break;case"capture":case"download":A===!0?x.setAttribute(T,""):A!==!1&&A!=null&&typeof A!="function"&&typeof A!="symbol"?x.setAttribute(T,A):x.removeAttribute(T);break;case"cols":case"rows":case"size":case"span":A!=null&&typeof A!="function"&&typeof A!="symbol"&&!isNaN(A)&&1<=A?x.setAttribute(T,A):x.removeAttribute(T);break;case"rowSpan":case"start":A==null||typeof A=="function"||typeof A=="symbol"||isNaN(A)?x.removeAttribute(T):x.setAttribute(T,A);break;case"popover":js("beforetoggle",x),js("toggle",x),qu(x,"popover",A);break;case"xlinkActuate":Ca(x,"http://www.w3.org/1999/xlink","xlink:actuate",A);break;case"xlinkArcrole":Ca(x,"http://www.w3.org/1999/xlink","xlink:arcrole",A);break;case"xlinkRole":Ca(x,"http://www.w3.org/1999/xlink","xlink:role",A);break;case"xlinkShow":Ca(x,"http://www.w3.org/1999/xlink","xlink:show",A);break;case"xlinkTitle":Ca(x,"http://www.w3.org/1999/xlink","xlink:title",A);break;case"xlinkType":Ca(x,"http://www.w3.org/1999/xlink","xlink:type",A);break;case"xmlBase":Ca(x,"http://www.w3.org/XML/1998/namespace","xml:base",A);break;case"xmlLang":Ca(x,"http://www.w3.org/XML/1998/namespace","xml:lang",A);break;case"xmlSpace":Ca(x,"http://www.w3.org/XML/1998/namespace","xml:space",A);break;case"is":qu(x,"is",A);break;case"innerText":case"textContent":break;default:(!(2<T.length)||T[0]!=="o"&&T[0]!=="O"||T[1]!=="n"&&T[1]!=="N")&&(T=YZ.get(T)||T,qu(x,T,A))}}function AQ(x,O,T,A,H,Q){switch(T){case"style":Q_(x,A,Q);break;case"dangerouslySetInnerHTML":if(A!=null){if(typeof A!="object"||!("__html"in A))throw Error(s(61));if(T=A.__html,T!=null){if(H.children!=null)throw Error(s(60));x.innerHTML=T}}break;case"children":typeof A=="string"?Tm(x,A):(typeof A=="number"||typeof A=="bigint")&&Tm(x,""+A);break;case"onScroll":A!=null&&js("scroll",x);break;case"onScrollEnd":A!=null&&js("scrollend",x);break;case"onClick":A!=null&&(x.onclick=Nm);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Bo.hasOwnProperty(T))e:{if(T[0]==="o"&&T[1]==="n"&&(H=T.endsWith("Capture"),O=T.slice(2,H?T.length-7:void 0),Q=x[$t]||null,Q=Q!=null?Q[T]:null,typeof Q=="function"&&x.removeEventListener(O,Q,H),typeof A=="function")){typeof Q!="function"&&Q!==null&&(T in x?x[T]=null:x.hasAttribute(T)&&x.removeAttribute(T)),x.addEventListener(O,A,H);break e}T in x?x[T]=A:A===!0?x.setAttribute(T,""):qu(x,T,A)}}}function Pc(x,O,T){switch(O){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":js("error",x),js("load",x);var A=!1,H=!1,Q;for(Q in T)if(T.hasOwnProperty(Q)){var ie=T[Q];if(ie!=null)switch(Q){case"src":A=!0;break;case"srcSet":H=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,O));default:ei(x,O,Q,ie,T,null)}}H&&ei(x,O,"srcSet",T.srcSet,T,null),A&&ei(x,O,"src",T.src,T,null);return;case"input":js("invalid",x);var we=Q=ie=H=null,Be=null,st=null;for(A in T)if(T.hasOwnProperty(A)){var xt=T[A];if(xt!=null)switch(A){case"name":H=xt;break;case"type":ie=xt;break;case"checked":Be=xt;break;case"defaultChecked":st=xt;break;case"value":Q=xt;break;case"defaultValue":we=xt;break;case"children":case"dangerouslySetInnerHTML":if(xt!=null)throw Error(s(137,O));break;default:ei(x,O,A,xt,T,null)}}qy(x,Q,we,Be,st,ie,H,!1);return;case"select":js("invalid",x),A=ie=Q=null;for(H in T)if(T.hasOwnProperty(H)&&(we=T[H],we!=null))switch(H){case"value":Q=we;break;case"defaultValue":ie=we;break;case"multiple":A=we;default:ei(x,O,H,we,T,null)}O=Q,T=ie,x.multiple=!!A,O!=null?Gg(x,!!A,O,!1):T!=null&&Gg(x,!!A,T,!0);return;case"textarea":js("invalid",x),Q=H=A=null;for(ie in T)if(T.hasOwnProperty(ie)&&(we=T[ie],we!=null))switch(ie){case"value":A=we;break;case"defaultValue":H=we;break;case"children":Q=we;break;case"dangerouslySetInnerHTML":if(we!=null)throw Error(s(91));break;default:ei(x,O,ie,we,T,null)}kI(x,A,H,Q);return;case"option":for(Be in T)T.hasOwnProperty(Be)&&(A=T[Be],A!=null)&&(Be==="selected"?x.selected=A&&typeof A!="function"&&typeof A!="symbol":ei(x,O,Be,A,T,null));return;case"dialog":js("beforetoggle",x),js("toggle",x),js("cancel",x),js("close",x);break;case"iframe":case"object":js("load",x);break;case"video":case"audio":for(A=0;A<rA.length;A++)js(rA[A],x);break;case"image":js("error",x),js("load",x);break;case"details":js("toggle",x);break;case"embed":case"source":case"link":js("error",x),js("load",x);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(st in T)if(T.hasOwnProperty(st)&&(A=T[st],A!=null))switch(st){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,O));default:ei(x,O,st,A,T,null)}return;default:if(K1(O)){for(xt in T)T.hasOwnProperty(xt)&&(A=T[xt],A!==void 0&&AQ(x,O,xt,A,T,void 0));return}}for(we in T)T.hasOwnProperty(we)&&(A=T[we],A!=null&&ei(x,O,we,A,T,null))}function gzt(x,O,T,A){switch(O){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var H=null,Q=null,ie=null,we=null,Be=null,st=null,xt=null;for(dt in T){var Ct=T[dt];if(T.hasOwnProperty(dt)&&Ct!=null)switch(dt){case"checked":break;case"value":break;case"defaultValue":Be=Ct;default:A.hasOwnProperty(dt)||ei(x,O,dt,null,A,Ct)}}for(var lt in A){var dt=A[lt];if(Ct=T[lt],A.hasOwnProperty(lt)&&(dt!=null||Ct!=null))switch(lt){case"type":Q=dt;break;case"name":H=dt;break;case"checked":st=dt;break;case"defaultChecked":xt=dt;break;case"value":ie=dt;break;case"defaultValue":we=dt;break;case"children":case"dangerouslySetInnerHTML":if(dt!=null)throw Error(s(137,O));break;default:dt!==Ct&&ei(x,O,lt,dt,A,Ct)}}Y1(x,ie,we,Be,st,xt,Q,H);return;case"select":dt=ie=we=lt=null;for(Q in T)if(Be=T[Q],T.hasOwnProperty(Q)&&Be!=null)switch(Q){case"value":break;case"multiple":dt=Be;default:A.hasOwnProperty(Q)||ei(x,O,Q,null,A,Be)}for(H in A)if(Q=A[H],Be=T[H],A.hasOwnProperty(H)&&(Q!=null||Be!=null))switch(H){case"value":lt=Q;break;case"defaultValue":we=Q;break;case"multiple":ie=Q;default:Q!==Be&&ei(x,O,H,Q,A,Be)}O=we,T=ie,A=dt,lt!=null?Gg(x,!!T,lt,!1):!!A!=!!T&&(O!=null?Gg(x,!!T,O,!0):Gg(x,!!T,T?[]:"",!1));return;case"textarea":dt=lt=null;for(we in T)if(H=T[we],T.hasOwnProperty(we)&&H!=null&&!A.hasOwnProperty(we))switch(we){case"value":break;case"children":break;default:ei(x,O,we,null,A,H)}for(ie in A)if(H=A[ie],Q=T[ie],A.hasOwnProperty(ie)&&(H!=null||Q!=null))switch(ie){case"value":lt=H;break;case"defaultValue":dt=H;break;case"children":break;case"dangerouslySetInnerHTML":if(H!=null)throw Error(s(91));break;default:H!==Q&&ei(x,O,ie,H,A,Q)}X1(x,lt,dt);return;case"option":for(var Mn in T)lt=T[Mn],T.hasOwnProperty(Mn)&<!=null&&!A.hasOwnProperty(Mn)&&(Mn==="selected"?x.selected=!1:ei(x,O,Mn,null,A,lt));for(Be in A)lt=A[Be],dt=T[Be],A.hasOwnProperty(Be)&<!==dt&&(lt!=null||dt!=null)&&(Be==="selected"?x.selected=lt&&typeof lt!="function"&&typeof lt!="symbol":ei(x,O,Be,lt,A,dt));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var yr in T)lt=T[yr],T.hasOwnProperty(yr)&<!=null&&!A.hasOwnProperty(yr)&&ei(x,O,yr,null,A,lt);for(st in A)if(lt=A[st],dt=T[st],A.hasOwnProperty(st)&<!==dt&&(lt!=null||dt!=null))switch(st){case"children":case"dangerouslySetInnerHTML":if(lt!=null)throw Error(s(137,O));break;default:ei(x,O,st,lt,A,dt)}return;default:if(K1(O)){for(var ti in T)lt=T[ti],T.hasOwnProperty(ti)&<!==void 0&&!A.hasOwnProperty(ti)&&AQ(x,O,ti,void 0,A,lt);for(xt in A)lt=A[xt],dt=T[xt],!A.hasOwnProperty(xt)||lt===dt||lt===void 0&&dt===void 0||AQ(x,O,xt,lt,A,dt);return}}for(var et in T)lt=T[et],T.hasOwnProperty(et)&<!=null&&!A.hasOwnProperty(et)&&ei(x,O,et,null,A,lt);for(Ct in A)lt=A[Ct],dt=T[Ct],!A.hasOwnProperty(Ct)||lt===dt||lt==null&&dt==null||ei(x,O,Ct,lt,A,dt)}function FAe(x){switch(x){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function vzt(){if(typeof performance.getEntriesByType=="function"){for(var x=0,O=0,T=performance.getEntriesByType("resource"),A=0;A<T.length;A++){var H=T[A],Q=H.transferSize,ie=H.initiatorType,we=H.duration;if(Q&&we&&FAe(ie)){for(ie=0,we=H.responseEnd,A+=1;A<T.length;A++){var Be=T[A],st=Be.startTime;if(st>we)break;var xt=Be.transferSize,Ct=Be.initiatorType;xt&&FAe(Ct)&&(Be=Be.responseEnd,ie+=xt*(Be<we?1:(we-st)/(Be-st)))}if(--A,O+=8*(Q+ie)/(H.duration/1e3),x++,10<x)break}}if(0<x)return O/x/1e6}return navigator.connection&&(x=navigator.connection.downlink,typeof x=="number")?x:5}var RQ=null,PQ=null;function z5(x){return x.nodeType===9?x:x.ownerDocument}function zAe(x){switch(x){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function BAe(x,O){if(x===0)switch(O){case"svg":return 1;case"math":return 2;default:return 0}return x===1&&O==="foreignObject"?0:x}function $Q(x,O){return x==="textarea"||x==="noscript"||typeof O.children=="string"||typeof O.children=="number"||typeof O.children=="bigint"||typeof O.dangerouslySetInnerHTML=="object"&&O.dangerouslySetInnerHTML!==null&&O.dangerouslySetInnerHTML.__html!=null}var MQ=null;function yzt(){var x=window.event;return x&&x.type==="popstate"?x===MQ?!1:(MQ=x,!0):(MQ=null,!1)}var UAe=typeof setTimeout=="function"?setTimeout:void 0,bzt=typeof clearTimeout=="function"?clearTimeout:void 0,qAe=typeof Promise=="function"?Promise:void 0,xzt=typeof queueMicrotask=="function"?queueMicrotask:typeof qAe<"u"?function(x){return qAe.resolve(null).then(x).catch(wzt)}:UAe;function wzt(x){setTimeout(function(){throw x})}function k0(x){return x==="head"}function VAe(x,O){var T=O,A=0;do{var H=T.nextSibling;if(x.removeChild(T),H&&H.nodeType===8)if(T=H.data,T==="/$"||T==="/&"){if(A===0){x.removeChild(H),_C(O);return}A--}else if(T==="$"||T==="$?"||T==="$~"||T==="$!"||T==="&")A++;else if(T==="html")aA(x.ownerDocument.documentElement);else if(T==="head"){T=x.ownerDocument.head,aA(T);for(var Q=T.firstChild;Q;){var ie=Q.nextSibling,we=Q.nodeName;Q[hr]||we==="SCRIPT"||we==="STYLE"||we==="LINK"&&Q.rel.toLowerCase()==="stylesheet"||T.removeChild(Q),Q=ie}}else T==="body"&&aA(x.ownerDocument.body);T=H}while(T);_C(O)}function HAe(x,O){var T=x;x=0;do{var A=T.nextSibling;if(T.nodeType===1?O?(T._stashedDisplay=T.style.display,T.style.display="none"):(T.style.display=T._stashedDisplay||"",T.getAttribute("style")===""&&T.removeAttribute("style")):T.nodeType===3&&(O?(T._stashedText=T.nodeValue,T.nodeValue=""):T.nodeValue=T._stashedText||""),A&&A.nodeType===8)if(T=A.data,T==="/$"){if(x===0)break;x--}else T!=="$"&&T!=="$?"&&T!=="$~"&&T!=="$!"||x++;T=A}while(T)}function DQ(x){var O=x.firstChild;for(O&&O.nodeType===10&&(O=O.nextSibling);O;){var T=O;switch(O=O.nextSibling,T.nodeName){case"HTML":case"HEAD":case"BODY":DQ(T),xs(T);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(T.rel.toLowerCase()==="stylesheet")continue}x.removeChild(T)}}function Szt(x,O,T,A){for(;x.nodeType===1;){var H=T;if(x.nodeName.toLowerCase()!==O.toLowerCase()){if(!A&&(x.nodeName!=="INPUT"||x.type!=="hidden"))break}else if(A){if(!x[hr])switch(O){case"meta":if(!x.hasAttribute("itemprop"))break;return x;case"link":if(Q=x.getAttribute("rel"),Q==="stylesheet"&&x.hasAttribute("data-precedence"))break;if(Q!==H.rel||x.getAttribute("href")!==(H.href==null||H.href===""?null:H.href)||x.getAttribute("crossorigin")!==(H.crossOrigin==null?null:H.crossOrigin)||x.getAttribute("title")!==(H.title==null?null:H.title))break;return x;case"style":if(x.hasAttribute("data-precedence"))break;return x;case"script":if(Q=x.getAttribute("src"),(Q!==(H.src==null?null:H.src)||x.getAttribute("type")!==(H.type==null?null:H.type)||x.getAttribute("crossorigin")!==(H.crossOrigin==null?null:H.crossOrigin))&&Q&&x.hasAttribute("async")&&!x.hasAttribute("itemprop"))break;return x;default:return x}}else if(O==="input"&&x.type==="hidden"){var Q=H.name==null?null:""+H.name;if(H.type==="hidden"&&x.getAttribute("name")===Q)return x}else return x;if(x=oh(x.nextSibling),x===null)break}return null}function kzt(x,O,T){if(O==="")return null;for(;x.nodeType!==3;)if((x.nodeType!==1||x.nodeName!=="INPUT"||x.type!=="hidden")&&!T||(x=oh(x.nextSibling),x===null))return null;return x}function WAe(x,O){for(;x.nodeType!==8;)if((x.nodeType!==1||x.nodeName!=="INPUT"||x.type!=="hidden")&&!O||(x=oh(x.nextSibling),x===null))return null;return x}function LQ(x){return x.data==="$?"||x.data==="$~"}function FQ(x){return x.data==="$!"||x.data==="$?"&&x.ownerDocument.readyState!=="loading"}function Ozt(x,O){var T=x.ownerDocument;if(x.data==="$~")x._reactRetry=O;else if(x.data!=="$?"||T.readyState!=="loading")O();else{var A=function(){O(),T.removeEventListener("DOMContentLoaded",A)};T.addEventListener("DOMContentLoaded",A),x._reactRetry=A}}function oh(x){for(;x!=null;x=x.nextSibling){var O=x.nodeType;if(O===1||O===3)break;if(O===8){if(O=x.data,O==="$"||O==="$!"||O==="$?"||O==="$~"||O==="&"||O==="F!"||O==="F")break;if(O==="/$"||O==="/&")return null}}return x}var zQ=null;function ZAe(x){x=x.nextSibling;for(var O=0;x;){if(x.nodeType===8){var T=x.data;if(T==="/$"||T==="/&"){if(O===0)return oh(x.nextSibling);O--}else T!=="$"&&T!=="$!"&&T!=="$?"&&T!=="$~"&&T!=="&"||O++}x=x.nextSibling}return null}function GAe(x){x=x.previousSibling;for(var O=0;x;){if(x.nodeType===8){var T=x.data;if(T==="$"||T==="$!"||T==="$?"||T==="$~"||T==="&"){if(O===0)return x;O--}else T!=="/$"&&T!=="/&"||O++}x=x.previousSibling}return null}function QAe(x,O,T){switch(O=z5(T),x){case"html":if(x=O.documentElement,!x)throw Error(s(452));return x;case"head":if(x=O.head,!x)throw Error(s(453));return x;case"body":if(x=O.body,!x)throw Error(s(454));return x;default:throw Error(s(451))}}function aA(x){for(var O=x.attributes;O.length;)x.removeAttributeNode(O[0]);xs(x)}var lh=new Map,YAe=new Set;function B5(x){return typeof x.getRootNode=="function"?x.getRootNode():x.nodeType===9?x:x.ownerDocument}var sb=z.d;z.d={f:_zt,r:Czt,D:Ezt,C:jzt,L:Tzt,m:Nzt,X:Azt,S:Izt,M:Rzt};function _zt(){var x=sb.f(),O=A5();return x||O}function Czt(x){var O=fr(x);O!==null&&O.tag===5&&O.type==="form"?pIe(O):sb.r(x)}var SC=typeof document>"u"?null:document;function XAe(x,O,T){var A=SC;if(A&&typeof O=="string"&&O){var H=Uo(O);H='link[rel="'+x+'"][href="'+H+'"]',typeof T=="string"&&(H+='[crossorigin="'+T+'"]'),YAe.has(H)||(YAe.add(H),x={rel:x,crossOrigin:T,href:O},A.querySelector(H)===null&&(O=A.createElement("link"),Pc(O,"link",x),_a(O),A.head.appendChild(O)))}}function Ezt(x){sb.D(x),XAe("dns-prefetch",x,null)}function jzt(x,O){sb.C(x,O),XAe("preconnect",x,O)}function Tzt(x,O,T){sb.L(x,O,T);var A=SC;if(A&&x&&O){var H='link[rel="preload"][as="'+Uo(O)+'"]';O==="image"&&T&&T.imageSrcSet?(H+='[imagesrcset="'+Uo(T.imageSrcSet)+'"]',typeof T.imageSizes=="string"&&(H+='[imagesizes="'+Uo(T.imageSizes)+'"]')):H+='[href="'+Uo(x)+'"]';var Q=H;switch(O){case"style":Q=kC(x);break;case"script":Q=OC(x)}lh.has(Q)||(x=p({rel:"preload",href:O==="image"&&T&&T.imageSrcSet?void 0:x,as:O},T),lh.set(Q,x),A.querySelector(H)!==null||O==="style"&&A.querySelector(iA(Q))||O==="script"&&A.querySelector(oA(Q))||(O=A.createElement("link"),Pc(O,"link",x),_a(O),A.head.appendChild(O)))}}function Nzt(x,O){sb.m(x,O);var T=SC;if(T&&x){var A=O&&typeof O.as=="string"?O.as:"script",H='link[rel="modulepreload"][as="'+Uo(A)+'"][href="'+Uo(x)+'"]',Q=H;switch(A){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":Q=OC(x)}if(!lh.has(Q)&&(x=p({rel:"modulepreload",href:x},O),lh.set(Q,x),T.querySelector(H)===null)){switch(A){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(T.querySelector(oA(Q)))return}A=T.createElement("link"),Pc(A,"link",x),_a(A),T.head.appendChild(A)}}}function Izt(x,O,T){sb.S(x,O,T);var A=SC;if(A&&x){var H=fa(A).hoistableStyles,Q=kC(x);O=O||"default";var ie=H.get(Q);if(!ie){var we={loading:0,preload:null};if(ie=A.querySelector(iA(Q)))we.loading=5;else{x=p({rel:"stylesheet",href:x,"data-precedence":O},T),(T=lh.get(Q))&&BQ(x,T);var Be=ie=A.createElement("link");_a(Be),Pc(Be,"link",x),Be._p=new Promise(function(st,xt){Be.onload=st,Be.onerror=xt}),Be.addEventListener("load",function(){we.loading|=1}),Be.addEventListener("error",function(){we.loading|=2}),we.loading|=4,U5(ie,O,A)}ie={type:"stylesheet",instance:ie,count:1,state:we},H.set(Q,ie)}}}function Azt(x,O){sb.X(x,O);var T=SC;if(T&&x){var A=fa(T).hoistableScripts,H=OC(x),Q=A.get(H);Q||(Q=T.querySelector(oA(H)),Q||(x=p({src:x,async:!0},O),(O=lh.get(H))&&UQ(x,O),Q=T.createElement("script"),_a(Q),Pc(Q,"link",x),T.head.appendChild(Q)),Q={type:"script",instance:Q,count:1,state:null},A.set(H,Q))}}function Rzt(x,O){sb.M(x,O);var T=SC;if(T&&x){var A=fa(T).hoistableScripts,H=OC(x),Q=A.get(H);Q||(Q=T.querySelector(oA(H)),Q||(x=p({src:x,async:!0,type:"module"},O),(O=lh.get(H))&&UQ(x,O),Q=T.createElement("script"),_a(Q),Pc(Q,"link",x),T.head.appendChild(Q)),Q={type:"script",instance:Q,count:1,state:null},A.set(H,Q))}}function KAe(x,O,T,A){var H=(H=te.current)?B5(H):null;if(!H)throw Error(s(446));switch(x){case"meta":case"title":return null;case"style":return typeof T.precedence=="string"&&typeof T.href=="string"?(O=kC(T.href),T=fa(H).hoistableStyles,A=T.get(O),A||(A={type:"style",instance:null,count:0,state:null},T.set(O,A)),A):{type:"void",instance:null,count:0,state:null};case"link":if(T.rel==="stylesheet"&&typeof T.href=="string"&&typeof T.precedence=="string"){x=kC(T.href);var Q=fa(H).hoistableStyles,ie=Q.get(x);if(ie||(H=H.ownerDocument||H,ie={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},Q.set(x,ie),(Q=H.querySelector(iA(x)))&&!Q._p&&(ie.instance=Q,ie.state.loading=5),lh.has(x)||(T={rel:"preload",as:"style",href:T.href,crossOrigin:T.crossOrigin,integrity:T.integrity,media:T.media,hrefLang:T.hrefLang,referrerPolicy:T.referrerPolicy},lh.set(x,T),Q||Pzt(H,x,T,ie.state))),O&&A===null)throw Error(s(528,""));return ie}if(O&&A!==null)throw Error(s(529,""));return null;case"script":return O=T.async,T=T.src,typeof T=="string"&&O&&typeof O!="function"&&typeof O!="symbol"?(O=OC(T),T=fa(H).hoistableScripts,A=T.get(O),A||(A={type:"script",instance:null,count:0,state:null},T.set(O,A)),A):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,x))}}function kC(x){return'href="'+Uo(x)+'"'}function iA(x){return'link[rel="stylesheet"]['+x+"]"}function JAe(x){return p({},x,{"data-precedence":x.precedence,precedence:null})}function Pzt(x,O,T,A){x.querySelector('link[rel="preload"][as="style"]['+O+"]")?A.loading=1:(O=x.createElement("link"),A.preload=O,O.addEventListener("load",function(){return A.loading|=1}),O.addEventListener("error",function(){return A.loading|=2}),Pc(O,"link",T),_a(O),x.head.appendChild(O))}function OC(x){return'[src="'+Uo(x)+'"]'}function oA(x){return"script[async]"+x}function eRe(x,O,T){if(O.count++,O.instance===null)switch(O.type){case"style":var A=x.querySelector('style[data-href~="'+Uo(T.href)+'"]');if(A)return O.instance=A,_a(A),A;var H=p({},T,{"data-href":T.href,"data-precedence":T.precedence,href:null,precedence:null});return A=(x.ownerDocument||x).createElement("style"),_a(A),Pc(A,"style",H),U5(A,T.precedence,x),O.instance=A;case"stylesheet":H=kC(T.href);var Q=x.querySelector(iA(H));if(Q)return O.state.loading|=4,O.instance=Q,_a(Q),Q;A=JAe(T),(H=lh.get(H))&&BQ(A,H),Q=(x.ownerDocument||x).createElement("link"),_a(Q);var ie=Q;return ie._p=new Promise(function(we,Be){ie.onload=we,ie.onerror=Be}),Pc(Q,"link",A),O.state.loading|=4,U5(Q,T.precedence,x),O.instance=Q;case"script":return Q=OC(T.src),(H=x.querySelector(oA(Q)))?(O.instance=H,_a(H),H):(A=T,(H=lh.get(Q))&&(A=p({},T),UQ(A,H)),x=x.ownerDocument||x,H=x.createElement("script"),_a(H),Pc(H,"link",A),x.head.appendChild(H),O.instance=H);case"void":return null;default:throw Error(s(443,O.type))}else O.type==="stylesheet"&&(O.state.loading&4)===0&&(A=O.instance,O.state.loading|=4,U5(A,T.precedence,x));return O.instance}function U5(x,O,T){for(var A=T.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),H=A.length?A[A.length-1]:null,Q=H,ie=0;ie<A.length;ie++){var we=A[ie];if(we.dataset.precedence===O)Q=we;else if(Q!==H)break}Q?Q.parentNode.insertBefore(x,Q.nextSibling):(O=T.nodeType===9?T.head:T,O.insertBefore(x,O.firstChild))}function BQ(x,O){x.crossOrigin==null&&(x.crossOrigin=O.crossOrigin),x.referrerPolicy==null&&(x.referrerPolicy=O.referrerPolicy),x.title==null&&(x.title=O.title)}function UQ(x,O){x.crossOrigin==null&&(x.crossOrigin=O.crossOrigin),x.referrerPolicy==null&&(x.referrerPolicy=O.referrerPolicy),x.integrity==null&&(x.integrity=O.integrity)}var q5=null;function tRe(x,O,T){if(q5===null){var A=new Map,H=q5=new Map;H.set(T,A)}else H=q5,A=H.get(T),A||(A=new Map,H.set(T,A));if(A.has(x))return A;for(A.set(x,null),T=T.getElementsByTagName(x),H=0;H<T.length;H++){var Q=T[H];if(!(Q[hr]||Q[Ft]||x==="link"&&Q.getAttribute("rel")==="stylesheet")&&Q.namespaceURI!=="http://www.w3.org/2000/svg"){var ie=Q.getAttribute(O)||"";ie=x+ie;var we=A.get(ie);we?we.push(Q):A.set(ie,[Q])}}return A}function nRe(x,O,T){x=x.ownerDocument||x,x.head.insertBefore(T,O==="title"?x.querySelector("head > title"):null)}function $zt(x,O,T){if(T===1||O.itemProp!=null)return!1;switch(x){case"meta":case"title":return!0;case"style":if(typeof O.precedence!="string"||typeof O.href!="string"||O.href==="")break;return!0;case"link":if(typeof O.rel!="string"||typeof O.href!="string"||O.href===""||O.onLoad||O.onError)break;return O.rel==="stylesheet"?(x=O.disabled,typeof O.precedence=="string"&&x==null):!0;case"script":if(O.async&&typeof O.async!="function"&&typeof O.async!="symbol"&&!O.onLoad&&!O.onError&&O.src&&typeof O.src=="string")return!0}return!1}function rRe(x){return!(x.type==="stylesheet"&&(x.state.loading&3)===0)}function Mzt(x,O,T,A){if(T.type==="stylesheet"&&(typeof A.media!="string"||matchMedia(A.media).matches!==!1)&&(T.state.loading&4)===0){if(T.instance===null){var H=kC(A.href),Q=O.querySelector(iA(H));if(Q){O=Q._p,O!==null&&typeof O=="object"&&typeof O.then=="function"&&(x.count++,x=V5.bind(x),O.then(x,x)),T.state.loading|=4,T.instance=Q,_a(Q);return}Q=O.ownerDocument||O,A=JAe(A),(H=lh.get(H))&&BQ(A,H),Q=Q.createElement("link"),_a(Q);var ie=Q;ie._p=new Promise(function(we,Be){ie.onload=we,ie.onerror=Be}),Pc(Q,"link",A),T.instance=Q}x.stylesheets===null&&(x.stylesheets=new Map),x.stylesheets.set(T,O),(O=T.state.preload)&&(T.state.loading&3)===0&&(x.count++,T=V5.bind(x),O.addEventListener("load",T),O.addEventListener("error",T))}}var qQ=0;function Dzt(x,O){return x.stylesheets&&x.count===0&&W5(x,x.stylesheets),0<x.count||0<x.imgCount?function(T){var A=setTimeout(function(){if(x.stylesheets&&W5(x,x.stylesheets),x.unsuspend){var Q=x.unsuspend;x.unsuspend=null,Q()}},6e4+O);0<x.imgBytes&&qQ===0&&(qQ=62500*vzt());var H=setTimeout(function(){if(x.waitingForImages=!1,x.count===0&&(x.stylesheets&&W5(x,x.stylesheets),x.unsuspend)){var Q=x.unsuspend;x.unsuspend=null,Q()}},(x.imgBytes>qQ?50:800)+O);return x.unsuspend=T,function(){x.unsuspend=null,clearTimeout(A),clearTimeout(H)}}:null}function V5(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)W5(this,this.stylesheets);else if(this.unsuspend){var x=this.unsuspend;this.unsuspend=null,x()}}}var H5=null;function W5(x,O){x.stylesheets=null,x.unsuspend!==null&&(x.count++,H5=new Map,O.forEach(Lzt,x),H5=null,V5.call(x))}function Lzt(x,O){if(!(O.state.loading&4)){var T=H5.get(x);if(T)var A=T.get(null);else{T=new Map,H5.set(x,T);for(var H=x.querySelectorAll("link[data-precedence],style[data-precedence]"),Q=0;Q<H.length;Q++){var ie=H[Q];(ie.nodeName==="LINK"||ie.getAttribute("media")!=="not all")&&(T.set(ie.dataset.precedence,ie),A=ie)}A&&T.set(null,A)}H=O.instance,ie=H.getAttribute("data-precedence"),Q=T.get(ie)||A,Q===A&&T.set(null,H),T.set(ie,H),this.count++,A=V5.bind(this),H.addEventListener("load",A),H.addEventListener("error",A),Q?Q.parentNode.insertBefore(H,Q.nextSibling):(x=x.nodeType===9?x.head:x,x.insertBefore(H,x.firstChild)),O.state.loading|=4}}var lA={$$typeof:k,Provider:null,Consumer:null,_currentValue:B,_currentValue2:B,_threadCount:0};function Fzt(x,O,T,A,H,Q,ie,we,Be){this.tag=1,this.containerInfo=x,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=it(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=it(0),this.hiddenUpdates=it(null),this.identifierPrefix=A,this.onUncaughtError=H,this.onCaughtError=Q,this.onRecoverableError=ie,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Be,this.incompleteTransitions=new Map}function sRe(x,O,T,A,H,Q,ie,we,Be,st,xt,Ct){return x=new Fzt(x,O,T,ie,Be,st,xt,Ct,we),O=1,Q===!0&&(O|=24),Q=Mf(3,null,null,O),x.current=Q,Q.stateNode=x,O=SG(),O.refCount++,x.pooledCache=O,O.refCount++,Q.memoizedState={element:A,isDehydrated:T,cache:O},CG(Q),x}function aRe(x){return x?(x=tC,x):tC}function iRe(x,O,T,A,H,Q){H=aRe(H),A.context===null?A.context=H:A.pendingContext=H,A=f0(O),A.payload={element:T},Q=Q===void 0?null:Q,Q!==null&&(A.callback=Q),T=p0(x,A,O),T!==null&&(Pd(T,x,O),zI(T,x,O))}function oRe(x,O){if(x=x.memoizedState,x!==null&&x.dehydrated!==null){var T=x.retryLane;x.retryLane=T!==0&&T<O?T:O}}function VQ(x,O){oRe(x,O),(x=x.alternate)&&oRe(x,O)}function lRe(x){if(x.tag===13||x.tag===31){var O=rS(x,67108864);O!==null&&Pd(O,x,67108864),VQ(x,67108864)}}function cRe(x){if(x.tag===13||x.tag===31){var O=Bf();O=Me(O);var T=rS(x,O);T!==null&&Pd(T,x,O),VQ(x,O)}}var Z5=!0;function zzt(x,O,T,A){var H=L.T;L.T=null;var Q=z.p;try{z.p=2,HQ(x,O,T,A)}finally{z.p=Q,L.T=H}}function Bzt(x,O,T,A){var H=L.T;L.T=null;var Q=z.p;try{z.p=8,HQ(x,O,T,A)}finally{z.p=Q,L.T=H}}function HQ(x,O,T,A){if(Z5){var H=WQ(A);if(H===null)IQ(x,O,A,G5,T),dRe(x,A);else if(qzt(H,x,O,T,A))A.stopPropagation();else if(dRe(x,A),O&4&&-1<Uzt.indexOf(x)){for(;H!==null;){var Q=fr(H);if(Q!==null)switch(Q.tag){case 3:if(Q=Q.stateNode,Q.current.memoizedState.isDehydrated){var ie=bt(Q.pendingLanes);if(ie!==0){var we=Q;for(we.pendingLanes|=2,we.entangledLanes|=2;ie;){var Be=1<<31-Re(ie);we.entanglements[1]|=Be,ie&=~Be}Kg(Q),(ja&6)===0&&(N5=se()+500,nA(0))}}break;case 31:case 13:we=rS(Q,2),we!==null&&Pd(we,Q,2),A5(),VQ(Q,2)}if(Q=WQ(A),Q===null&&IQ(x,O,A,G5,T),Q===H)break;H=Q}H!==null&&A.stopPropagation()}else IQ(x,O,A,null,T)}}function WQ(x){return x=OI(x),ZQ(x)}var G5=null;function ZQ(x){if(G5=null,x=Mr(x),x!==null){var O=i(x);if(O===null)x=null;else{var T=O.tag;if(T===13){if(x=l(O),x!==null)return x;x=null}else if(T===31){if(x=c(O),x!==null)return x;x=null}else if(T===3){if(O.stateNode.current.memoizedState.isDehydrated)return O.tag===3?O.stateNode.containerInfo:null;x=null}else O!==x&&(x=null)}}return G5=x,null}function uRe(x){switch(x){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(re()){case he:return 2;case xe:return 8;case Ee:case Pe:return 32;case Qe:return 268435456;default:return 32}default:return 32}}var GQ=!1,O0=null,_0=null,C0=null,cA=new Map,uA=new Map,E0=[],Uzt="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function dRe(x,O){switch(x){case"focusin":case"focusout":O0=null;break;case"dragenter":case"dragleave":_0=null;break;case"mouseover":case"mouseout":C0=null;break;case"pointerover":case"pointerout":cA.delete(O.pointerId);break;case"gotpointercapture":case"lostpointercapture":uA.delete(O.pointerId)}}function dA(x,O,T,A,H,Q){return x===null||x.nativeEvent!==Q?(x={blockedOn:O,domEventName:T,eventSystemFlags:A,nativeEvent:Q,targetContainers:[H]},O!==null&&(O=fr(O),O!==null&&lRe(O)),x):(x.eventSystemFlags|=A,O=x.targetContainers,H!==null&&O.indexOf(H)===-1&&O.push(H),x)}function qzt(x,O,T,A,H){switch(O){case"focusin":return O0=dA(O0,x,O,T,A,H),!0;case"dragenter":return _0=dA(_0,x,O,T,A,H),!0;case"mouseover":return C0=dA(C0,x,O,T,A,H),!0;case"pointerover":var Q=H.pointerId;return cA.set(Q,dA(cA.get(Q)||null,x,O,T,A,H)),!0;case"gotpointercapture":return Q=H.pointerId,uA.set(Q,dA(uA.get(Q)||null,x,O,T,A,H)),!0}return!1}function fRe(x){var O=Mr(x.target);if(O!==null){var T=i(O);if(T!==null){if(O=T.tag,O===13){if(O=l(T),O!==null){x.blockedOn=O,Dt(x.priority,function(){cRe(T)});return}}else if(O===31){if(O=c(T),O!==null){x.blockedOn=O,Dt(x.priority,function(){cRe(T)});return}}else if(O===3&&T.stateNode.current.memoizedState.isDehydrated){x.blockedOn=T.tag===3?T.stateNode.containerInfo:null;return}}}x.blockedOn=null}function Q5(x){if(x.blockedOn!==null)return!1;for(var O=x.targetContainers;0<O.length;){var T=WQ(x.nativeEvent);if(T===null){T=x.nativeEvent;var A=new T.constructor(T.type,T);J1=A,T.target.dispatchEvent(A),J1=null}else return O=fr(T),O!==null&&lRe(O),x.blockedOn=T,!1;O.shift()}return!0}function pRe(x,O,T){Q5(x)&&T.delete(O)}function Vzt(){GQ=!1,O0!==null&&Q5(O0)&&(O0=null),_0!==null&&Q5(_0)&&(_0=null),C0!==null&&Q5(C0)&&(C0=null),cA.forEach(pRe),uA.forEach(pRe)}function Y5(x,O){x.blockedOn===O&&(x.blockedOn=null,GQ||(GQ=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Vzt)))}var X5=null;function hRe(x){X5!==x&&(X5=x,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){X5===x&&(X5=null);for(var O=0;O<x.length;O+=3){var T=x[O],A=x[O+1],H=x[O+2];if(typeof A!="function"){if(ZQ(A||T)===null)continue;break}var Q=fr(T);Q!==null&&(x.splice(O,3),O-=3,WG(Q,{pending:!0,data:H,method:T.method,action:A},A,H))}}))}function _C(x){function O(Be){return Y5(Be,x)}O0!==null&&Y5(O0,x),_0!==null&&Y5(_0,x),C0!==null&&Y5(C0,x),cA.forEach(O),uA.forEach(O);for(var T=0;T<E0.length;T++){var A=E0[T];A.blockedOn===x&&(A.blockedOn=null)}for(;0<E0.length&&(T=E0[0],T.blockedOn===null);)fRe(T),T.blockedOn===null&&E0.shift();if(T=(x.ownerDocument||x).$$reactFormReplay,T!=null)for(A=0;A<T.length;A+=3){var H=T[A],Q=T[A+1],ie=H[$t]||null;if(typeof Q=="function")ie||hRe(T);else if(ie){var we=null;if(Q&&Q.hasAttribute("formAction")){if(H=Q,ie=Q[$t]||null)we=ie.formAction;else if(ZQ(H)!==null)continue}else we=ie.action;typeof we=="function"?T[A+1]=we:(T.splice(A,3),A-=3),hRe(T)}}}function mRe(){function x(Q){Q.canIntercept&&Q.info==="react-transition"&&Q.intercept({handler:function(){return new Promise(function(ie){return H=ie})},focusReset:"manual",scroll:"manual"})}function O(){H!==null&&(H(),H=null),A||setTimeout(T,20)}function T(){if(!A&&!navigation.transition){var Q=navigation.currentEntry;Q&&Q.url!=null&&navigation.navigate(Q.url,{state:Q.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var A=!1,H=null;return navigation.addEventListener("navigate",x),navigation.addEventListener("navigatesuccess",O),navigation.addEventListener("navigateerror",O),setTimeout(T,100),function(){A=!0,navigation.removeEventListener("navigate",x),navigation.removeEventListener("navigatesuccess",O),navigation.removeEventListener("navigateerror",O),H!==null&&(H(),H=null)}}}function QQ(x){this._internalRoot=x}K5.prototype.render=QQ.prototype.render=function(x){var O=this._internalRoot;if(O===null)throw Error(s(409));var T=O.current,A=Bf();iRe(T,A,x,O,null,null)},K5.prototype.unmount=QQ.prototype.unmount=function(){var x=this._internalRoot;if(x!==null){this._internalRoot=null;var O=x.containerInfo;iRe(x.current,2,null,x,null,null),A5(),O[jt]=null}};function K5(x){this._internalRoot=x}K5.prototype.unstable_scheduleHydration=function(x){if(x){var O=nt();x={blockedOn:null,target:x,priority:O};for(var T=0;T<E0.length&&O!==0&&O<E0[T].priority;T++);E0.splice(T,0,x),T===0&&fRe(x)}};var gRe=n.version;if(gRe!=="19.2.6")throw Error(s(527,gRe,"19.2.6"));z.findDOMNode=function(x){var O=x._reactInternals;if(O===void 0)throw typeof x.render=="function"?Error(s(188)):(x=Object.keys(x).join(","),Error(s(268,x)));return x=d(O),x=x!==null?f(x):null,x=x===null?null:x.stateNode,x};var Hzt={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:L,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var J5=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!J5.isDisabled&&J5.supportsFiber)try{je=J5.inject(Hzt),_e=J5}catch{}}return pA.createRoot=function(x,O){if(!a(x))throw Error(s(299));var T=!1,A="",H=kIe,Q=OIe,ie=_Ie;return O!=null&&(O.unstable_strictMode===!0&&(T=!0),O.identifierPrefix!==void 0&&(A=O.identifierPrefix),O.onUncaughtError!==void 0&&(H=O.onUncaughtError),O.onCaughtError!==void 0&&(Q=O.onCaughtError),O.onRecoverableError!==void 0&&(ie=O.onRecoverableError)),O=sRe(x,1,!1,null,null,T,A,null,H,Q,ie,mRe),x[jt]=O.current,NQ(x),new QQ(O)},pA.hydrateRoot=function(x,O,T){if(!a(x))throw Error(s(299));var A=!1,H="",Q=kIe,ie=OIe,we=_Ie,Be=null;return T!=null&&(T.unstable_strictMode===!0&&(A=!0),T.identifierPrefix!==void 0&&(H=T.identifierPrefix),T.onUncaughtError!==void 0&&(Q=T.onUncaughtError),T.onCaughtError!==void 0&&(ie=T.onCaughtError),T.onRecoverableError!==void 0&&(we=T.onRecoverableError),T.formState!==void 0&&(Be=T.formState)),O=sRe(x,1,!0,O,T??null,A,H,Be,Q,ie,we,mRe),O.context=aRe(null),T=O.current,A=Bf(),A=Me(A),H=f0(A),H.callback=null,p0(T,H,A),T=A,O.current.lanes=T,Yt(O,T),Kg(O),x[jt]=O.current,NQ(x),new K5(O)},pA.version="19.2.6",pA}var CRe;function t7t(){if(CRe)return KQ.exports;CRe=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),KQ.exports=e7t(),KQ.exports}var n7t=t7t(),dk=256,i9=[],eL;for(;dk--;)i9[dk]=(dk+256).toString(16).substring(1);function uo(){var e=0,t,n="";if(!eL||dk+16>256){for(eL=Array(e=256);e--;)eL[e]=256*Math.random()|0;e=dk=0}for(;e<16;e++)t=eL[dk+e],e==6?n+=i9[t&15|64]:e==8?n+=i9[t&63|128]:n+=i9[t],e&1&&e>1&&e<11&&(n+="-");return dk++,n}var zve=new Set(["observationalMemory","asyncBuffering","request-response-id-rotation","workspaces-v1","datasets","observability:v1.13.2","observability-delta-polling","channels","deploy-diagnosis","model-inference-span","internal-usage-rollup"]),Znt="vercel.ai.error",r7t=Symbol.for(Znt),Gnt,s7t=class Qnt extends Error{constructor({name:t,message:n,cause:r}){super(n),this[Gnt]=!0,this.name=t,this.cause=r}static isInstance(t){return Qnt.hasMarker(t,Znt)}static hasMarker(t,n){const r=Symbol.for(n);return t!=null&&typeof t=="object"&&r in t&&typeof t[r]=="boolean"&&t[r]===!0}};Gnt=r7t;var $j=s7t;function Ynt(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var Xnt="AI_InvalidArgumentError",Knt=`vercel.ai.error.${Xnt}`,a7t=Symbol.for(Knt),Jnt,i7t=class extends $j{constructor({message:t,cause:n,argument:r}){super({name:Xnt,message:t,cause:n}),this[Jnt]=!0,this.argument=r}static isInstance(t){return $j.hasMarker(t,Knt)}};Jnt=a7t;var ert="AI_JSONParseError",trt=`vercel.ai.error.${ert}`,o7t=Symbol.for(trt),nrt,ERe=class extends $j{constructor({text:t,cause:n}){super({name:ert,message:`JSON parsing failed: Text: ${t}.
|
|
10
|
+
`).replace(mzt,"")}function LAe(x,O){return O=DAe(O),DAe(x)===O}function ei(x,O,T,A,H,Q){switch(T){case"children":typeof A=="string"?O==="body"||O==="textarea"&&A===""||Tm(x,A):(typeof A=="number"||typeof A=="bigint")&&O!=="body"&&Tm(x,""+A);break;case"className":Zr(x,"class",A);break;case"tabIndex":Zr(x,"tabindex",A);break;case"dir":case"role":case"viewBox":case"width":case"height":Zr(x,T,A);break;case"style":Q_(x,A,Q);break;case"data":if(O!=="object"){Zr(x,"data",A);break}case"src":case"href":if(A===""&&(O!=="a"||T!=="href")){x.removeAttribute(T);break}if(A==null||typeof A=="function"||typeof A=="symbol"||typeof A=="boolean"){x.removeAttribute(T);break}A=Y_(""+A),x.setAttribute(T,A);break;case"action":case"formAction":if(typeof A=="function"){x.setAttribute(T,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof Q=="function"&&(T==="formAction"?(O!=="input"&&ei(x,O,"name",H.name,H,null),ei(x,O,"formEncType",H.formEncType,H,null),ei(x,O,"formMethod",H.formMethod,H,null),ei(x,O,"formTarget",H.formTarget,H,null)):(ei(x,O,"encType",H.encType,H,null),ei(x,O,"method",H.method,H,null),ei(x,O,"target",H.target,H,null)));if(A==null||typeof A=="symbol"||typeof A=="boolean"){x.removeAttribute(T);break}A=Y_(""+A),x.setAttribute(T,A);break;case"onClick":A!=null&&(x.onclick=Nm);break;case"onScroll":A!=null&&js("scroll",x);break;case"onScrollEnd":A!=null&&js("scrollend",x);break;case"dangerouslySetInnerHTML":if(A!=null){if(typeof A!="object"||!("__html"in A))throw Error(s(61));if(T=A.__html,T!=null){if(H.children!=null)throw Error(s(60));x.innerHTML=T}}break;case"multiple":x.multiple=A&&typeof A!="function"&&typeof A!="symbol";break;case"muted":x.muted=A&&typeof A!="function"&&typeof A!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(A==null||typeof A=="function"||typeof A=="boolean"||typeof A=="symbol"){x.removeAttribute("xlink:href");break}T=Y_(""+A),x.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",T);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":A!=null&&typeof A!="function"&&typeof A!="symbol"?x.setAttribute(T,""+A):x.removeAttribute(T);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":A&&typeof A!="function"&&typeof A!="symbol"?x.setAttribute(T,""):x.removeAttribute(T);break;case"capture":case"download":A===!0?x.setAttribute(T,""):A!==!1&&A!=null&&typeof A!="function"&&typeof A!="symbol"?x.setAttribute(T,A):x.removeAttribute(T);break;case"cols":case"rows":case"size":case"span":A!=null&&typeof A!="function"&&typeof A!="symbol"&&!isNaN(A)&&1<=A?x.setAttribute(T,A):x.removeAttribute(T);break;case"rowSpan":case"start":A==null||typeof A=="function"||typeof A=="symbol"||isNaN(A)?x.removeAttribute(T):x.setAttribute(T,A);break;case"popover":js("beforetoggle",x),js("toggle",x),qu(x,"popover",A);break;case"xlinkActuate":Ca(x,"http://www.w3.org/1999/xlink","xlink:actuate",A);break;case"xlinkArcrole":Ca(x,"http://www.w3.org/1999/xlink","xlink:arcrole",A);break;case"xlinkRole":Ca(x,"http://www.w3.org/1999/xlink","xlink:role",A);break;case"xlinkShow":Ca(x,"http://www.w3.org/1999/xlink","xlink:show",A);break;case"xlinkTitle":Ca(x,"http://www.w3.org/1999/xlink","xlink:title",A);break;case"xlinkType":Ca(x,"http://www.w3.org/1999/xlink","xlink:type",A);break;case"xmlBase":Ca(x,"http://www.w3.org/XML/1998/namespace","xml:base",A);break;case"xmlLang":Ca(x,"http://www.w3.org/XML/1998/namespace","xml:lang",A);break;case"xmlSpace":Ca(x,"http://www.w3.org/XML/1998/namespace","xml:space",A);break;case"is":qu(x,"is",A);break;case"innerText":case"textContent":break;default:(!(2<T.length)||T[0]!=="o"&&T[0]!=="O"||T[1]!=="n"&&T[1]!=="N")&&(T=YZ.get(T)||T,qu(x,T,A))}}function AQ(x,O,T,A,H,Q){switch(T){case"style":Q_(x,A,Q);break;case"dangerouslySetInnerHTML":if(A!=null){if(typeof A!="object"||!("__html"in A))throw Error(s(61));if(T=A.__html,T!=null){if(H.children!=null)throw Error(s(60));x.innerHTML=T}}break;case"children":typeof A=="string"?Tm(x,A):(typeof A=="number"||typeof A=="bigint")&&Tm(x,""+A);break;case"onScroll":A!=null&&js("scroll",x);break;case"onScrollEnd":A!=null&&js("scrollend",x);break;case"onClick":A!=null&&(x.onclick=Nm);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Bo.hasOwnProperty(T))e:{if(T[0]==="o"&&T[1]==="n"&&(H=T.endsWith("Capture"),O=T.slice(2,H?T.length-7:void 0),Q=x[$t]||null,Q=Q!=null?Q[T]:null,typeof Q=="function"&&x.removeEventListener(O,Q,H),typeof A=="function")){typeof Q!="function"&&Q!==null&&(T in x?x[T]=null:x.hasAttribute(T)&&x.removeAttribute(T)),x.addEventListener(O,A,H);break e}T in x?x[T]=A:A===!0?x.setAttribute(T,""):qu(x,T,A)}}}function Pc(x,O,T){switch(O){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":js("error",x),js("load",x);var A=!1,H=!1,Q;for(Q in T)if(T.hasOwnProperty(Q)){var ie=T[Q];if(ie!=null)switch(Q){case"src":A=!0;break;case"srcSet":H=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,O));default:ei(x,O,Q,ie,T,null)}}H&&ei(x,O,"srcSet",T.srcSet,T,null),A&&ei(x,O,"src",T.src,T,null);return;case"input":js("invalid",x);var we=Q=ie=H=null,Be=null,st=null;for(A in T)if(T.hasOwnProperty(A)){var xt=T[A];if(xt!=null)switch(A){case"name":H=xt;break;case"type":ie=xt;break;case"checked":Be=xt;break;case"defaultChecked":st=xt;break;case"value":Q=xt;break;case"defaultValue":we=xt;break;case"children":case"dangerouslySetInnerHTML":if(xt!=null)throw Error(s(137,O));break;default:ei(x,O,A,xt,T,null)}}qy(x,Q,we,Be,st,ie,H,!1);return;case"select":js("invalid",x),A=ie=Q=null;for(H in T)if(T.hasOwnProperty(H)&&(we=T[H],we!=null))switch(H){case"value":Q=we;break;case"defaultValue":ie=we;break;case"multiple":A=we;default:ei(x,O,H,we,T,null)}O=Q,T=ie,x.multiple=!!A,O!=null?Gg(x,!!A,O,!1):T!=null&&Gg(x,!!A,T,!0);return;case"textarea":js("invalid",x),Q=H=A=null;for(ie in T)if(T.hasOwnProperty(ie)&&(we=T[ie],we!=null))switch(ie){case"value":A=we;break;case"defaultValue":H=we;break;case"children":Q=we;break;case"dangerouslySetInnerHTML":if(we!=null)throw Error(s(91));break;default:ei(x,O,ie,we,T,null)}kI(x,A,H,Q);return;case"option":for(Be in T)T.hasOwnProperty(Be)&&(A=T[Be],A!=null)&&(Be==="selected"?x.selected=A&&typeof A!="function"&&typeof A!="symbol":ei(x,O,Be,A,T,null));return;case"dialog":js("beforetoggle",x),js("toggle",x),js("cancel",x),js("close",x);break;case"iframe":case"object":js("load",x);break;case"video":case"audio":for(A=0;A<rA.length;A++)js(rA[A],x);break;case"image":js("error",x),js("load",x);break;case"details":js("toggle",x);break;case"embed":case"source":case"link":js("error",x),js("load",x);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(st in T)if(T.hasOwnProperty(st)&&(A=T[st],A!=null))switch(st){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,O));default:ei(x,O,st,A,T,null)}return;default:if(K1(O)){for(xt in T)T.hasOwnProperty(xt)&&(A=T[xt],A!==void 0&&AQ(x,O,xt,A,T,void 0));return}}for(we in T)T.hasOwnProperty(we)&&(A=T[we],A!=null&&ei(x,O,we,A,T,null))}function gzt(x,O,T,A){switch(O){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var H=null,Q=null,ie=null,we=null,Be=null,st=null,xt=null;for(dt in T){var Ct=T[dt];if(T.hasOwnProperty(dt)&&Ct!=null)switch(dt){case"checked":break;case"value":break;case"defaultValue":Be=Ct;default:A.hasOwnProperty(dt)||ei(x,O,dt,null,A,Ct)}}for(var lt in A){var dt=A[lt];if(Ct=T[lt],A.hasOwnProperty(lt)&&(dt!=null||Ct!=null))switch(lt){case"type":Q=dt;break;case"name":H=dt;break;case"checked":st=dt;break;case"defaultChecked":xt=dt;break;case"value":ie=dt;break;case"defaultValue":we=dt;break;case"children":case"dangerouslySetInnerHTML":if(dt!=null)throw Error(s(137,O));break;default:dt!==Ct&&ei(x,O,lt,dt,A,Ct)}}Y1(x,ie,we,Be,st,xt,Q,H);return;case"select":dt=ie=we=lt=null;for(Q in T)if(Be=T[Q],T.hasOwnProperty(Q)&&Be!=null)switch(Q){case"value":break;case"multiple":dt=Be;default:A.hasOwnProperty(Q)||ei(x,O,Q,null,A,Be)}for(H in A)if(Q=A[H],Be=T[H],A.hasOwnProperty(H)&&(Q!=null||Be!=null))switch(H){case"value":lt=Q;break;case"defaultValue":we=Q;break;case"multiple":ie=Q;default:Q!==Be&&ei(x,O,H,Q,A,Be)}O=we,T=ie,A=dt,lt!=null?Gg(x,!!T,lt,!1):!!A!=!!T&&(O!=null?Gg(x,!!T,O,!0):Gg(x,!!T,T?[]:"",!1));return;case"textarea":dt=lt=null;for(we in T)if(H=T[we],T.hasOwnProperty(we)&&H!=null&&!A.hasOwnProperty(we))switch(we){case"value":break;case"children":break;default:ei(x,O,we,null,A,H)}for(ie in A)if(H=A[ie],Q=T[ie],A.hasOwnProperty(ie)&&(H!=null||Q!=null))switch(ie){case"value":lt=H;break;case"defaultValue":dt=H;break;case"children":break;case"dangerouslySetInnerHTML":if(H!=null)throw Error(s(91));break;default:H!==Q&&ei(x,O,ie,H,A,Q)}X1(x,lt,dt);return;case"option":for(var Mn in T)lt=T[Mn],T.hasOwnProperty(Mn)&<!=null&&!A.hasOwnProperty(Mn)&&(Mn==="selected"?x.selected=!1:ei(x,O,Mn,null,A,lt));for(Be in A)lt=A[Be],dt=T[Be],A.hasOwnProperty(Be)&<!==dt&&(lt!=null||dt!=null)&&(Be==="selected"?x.selected=lt&&typeof lt!="function"&&typeof lt!="symbol":ei(x,O,Be,lt,A,dt));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var yr in T)lt=T[yr],T.hasOwnProperty(yr)&<!=null&&!A.hasOwnProperty(yr)&&ei(x,O,yr,null,A,lt);for(st in A)if(lt=A[st],dt=T[st],A.hasOwnProperty(st)&<!==dt&&(lt!=null||dt!=null))switch(st){case"children":case"dangerouslySetInnerHTML":if(lt!=null)throw Error(s(137,O));break;default:ei(x,O,st,lt,A,dt)}return;default:if(K1(O)){for(var ti in T)lt=T[ti],T.hasOwnProperty(ti)&<!==void 0&&!A.hasOwnProperty(ti)&&AQ(x,O,ti,void 0,A,lt);for(xt in A)lt=A[xt],dt=T[xt],!A.hasOwnProperty(xt)||lt===dt||lt===void 0&&dt===void 0||AQ(x,O,xt,lt,A,dt);return}}for(var et in T)lt=T[et],T.hasOwnProperty(et)&<!=null&&!A.hasOwnProperty(et)&&ei(x,O,et,null,A,lt);for(Ct in A)lt=A[Ct],dt=T[Ct],!A.hasOwnProperty(Ct)||lt===dt||lt==null&&dt==null||ei(x,O,Ct,lt,A,dt)}function FAe(x){switch(x){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function vzt(){if(typeof performance.getEntriesByType=="function"){for(var x=0,O=0,T=performance.getEntriesByType("resource"),A=0;A<T.length;A++){var H=T[A],Q=H.transferSize,ie=H.initiatorType,we=H.duration;if(Q&&we&&FAe(ie)){for(ie=0,we=H.responseEnd,A+=1;A<T.length;A++){var Be=T[A],st=Be.startTime;if(st>we)break;var xt=Be.transferSize,Ct=Be.initiatorType;xt&&FAe(Ct)&&(Be=Be.responseEnd,ie+=xt*(Be<we?1:(we-st)/(Be-st)))}if(--A,O+=8*(Q+ie)/(H.duration/1e3),x++,10<x)break}}if(0<x)return O/x/1e6}return navigator.connection&&(x=navigator.connection.downlink,typeof x=="number")?x:5}var RQ=null,PQ=null;function z5(x){return x.nodeType===9?x:x.ownerDocument}function zAe(x){switch(x){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function BAe(x,O){if(x===0)switch(O){case"svg":return 1;case"math":return 2;default:return 0}return x===1&&O==="foreignObject"?0:x}function $Q(x,O){return x==="textarea"||x==="noscript"||typeof O.children=="string"||typeof O.children=="number"||typeof O.children=="bigint"||typeof O.dangerouslySetInnerHTML=="object"&&O.dangerouslySetInnerHTML!==null&&O.dangerouslySetInnerHTML.__html!=null}var MQ=null;function yzt(){var x=window.event;return x&&x.type==="popstate"?x===MQ?!1:(MQ=x,!0):(MQ=null,!1)}var UAe=typeof setTimeout=="function"?setTimeout:void 0,bzt=typeof clearTimeout=="function"?clearTimeout:void 0,qAe=typeof Promise=="function"?Promise:void 0,xzt=typeof queueMicrotask=="function"?queueMicrotask:typeof qAe<"u"?function(x){return qAe.resolve(null).then(x).catch(wzt)}:UAe;function wzt(x){setTimeout(function(){throw x})}function k0(x){return x==="head"}function VAe(x,O){var T=O,A=0;do{var H=T.nextSibling;if(x.removeChild(T),H&&H.nodeType===8)if(T=H.data,T==="/$"||T==="/&"){if(A===0){x.removeChild(H),_C(O);return}A--}else if(T==="$"||T==="$?"||T==="$~"||T==="$!"||T==="&")A++;else if(T==="html")aA(x.ownerDocument.documentElement);else if(T==="head"){T=x.ownerDocument.head,aA(T);for(var Q=T.firstChild;Q;){var ie=Q.nextSibling,we=Q.nodeName;Q[hr]||we==="SCRIPT"||we==="STYLE"||we==="LINK"&&Q.rel.toLowerCase()==="stylesheet"||T.removeChild(Q),Q=ie}}else T==="body"&&aA(x.ownerDocument.body);T=H}while(T);_C(O)}function HAe(x,O){var T=x;x=0;do{var A=T.nextSibling;if(T.nodeType===1?O?(T._stashedDisplay=T.style.display,T.style.display="none"):(T.style.display=T._stashedDisplay||"",T.getAttribute("style")===""&&T.removeAttribute("style")):T.nodeType===3&&(O?(T._stashedText=T.nodeValue,T.nodeValue=""):T.nodeValue=T._stashedText||""),A&&A.nodeType===8)if(T=A.data,T==="/$"){if(x===0)break;x--}else T!=="$"&&T!=="$?"&&T!=="$~"&&T!=="$!"||x++;T=A}while(T)}function DQ(x){var O=x.firstChild;for(O&&O.nodeType===10&&(O=O.nextSibling);O;){var T=O;switch(O=O.nextSibling,T.nodeName){case"HTML":case"HEAD":case"BODY":DQ(T),xs(T);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(T.rel.toLowerCase()==="stylesheet")continue}x.removeChild(T)}}function Szt(x,O,T,A){for(;x.nodeType===1;){var H=T;if(x.nodeName.toLowerCase()!==O.toLowerCase()){if(!A&&(x.nodeName!=="INPUT"||x.type!=="hidden"))break}else if(A){if(!x[hr])switch(O){case"meta":if(!x.hasAttribute("itemprop"))break;return x;case"link":if(Q=x.getAttribute("rel"),Q==="stylesheet"&&x.hasAttribute("data-precedence"))break;if(Q!==H.rel||x.getAttribute("href")!==(H.href==null||H.href===""?null:H.href)||x.getAttribute("crossorigin")!==(H.crossOrigin==null?null:H.crossOrigin)||x.getAttribute("title")!==(H.title==null?null:H.title))break;return x;case"style":if(x.hasAttribute("data-precedence"))break;return x;case"script":if(Q=x.getAttribute("src"),(Q!==(H.src==null?null:H.src)||x.getAttribute("type")!==(H.type==null?null:H.type)||x.getAttribute("crossorigin")!==(H.crossOrigin==null?null:H.crossOrigin))&&Q&&x.hasAttribute("async")&&!x.hasAttribute("itemprop"))break;return x;default:return x}}else if(O==="input"&&x.type==="hidden"){var Q=H.name==null?null:""+H.name;if(H.type==="hidden"&&x.getAttribute("name")===Q)return x}else return x;if(x=oh(x.nextSibling),x===null)break}return null}function kzt(x,O,T){if(O==="")return null;for(;x.nodeType!==3;)if((x.nodeType!==1||x.nodeName!=="INPUT"||x.type!=="hidden")&&!T||(x=oh(x.nextSibling),x===null))return null;return x}function WAe(x,O){for(;x.nodeType!==8;)if((x.nodeType!==1||x.nodeName!=="INPUT"||x.type!=="hidden")&&!O||(x=oh(x.nextSibling),x===null))return null;return x}function LQ(x){return x.data==="$?"||x.data==="$~"}function FQ(x){return x.data==="$!"||x.data==="$?"&&x.ownerDocument.readyState!=="loading"}function Ozt(x,O){var T=x.ownerDocument;if(x.data==="$~")x._reactRetry=O;else if(x.data!=="$?"||T.readyState!=="loading")O();else{var A=function(){O(),T.removeEventListener("DOMContentLoaded",A)};T.addEventListener("DOMContentLoaded",A),x._reactRetry=A}}function oh(x){for(;x!=null;x=x.nextSibling){var O=x.nodeType;if(O===1||O===3)break;if(O===8){if(O=x.data,O==="$"||O==="$!"||O==="$?"||O==="$~"||O==="&"||O==="F!"||O==="F")break;if(O==="/$"||O==="/&")return null}}return x}var zQ=null;function ZAe(x){x=x.nextSibling;for(var O=0;x;){if(x.nodeType===8){var T=x.data;if(T==="/$"||T==="/&"){if(O===0)return oh(x.nextSibling);O--}else T!=="$"&&T!=="$!"&&T!=="$?"&&T!=="$~"&&T!=="&"||O++}x=x.nextSibling}return null}function GAe(x){x=x.previousSibling;for(var O=0;x;){if(x.nodeType===8){var T=x.data;if(T==="$"||T==="$!"||T==="$?"||T==="$~"||T==="&"){if(O===0)return x;O--}else T!=="/$"&&T!=="/&"||O++}x=x.previousSibling}return null}function QAe(x,O,T){switch(O=z5(T),x){case"html":if(x=O.documentElement,!x)throw Error(s(452));return x;case"head":if(x=O.head,!x)throw Error(s(453));return x;case"body":if(x=O.body,!x)throw Error(s(454));return x;default:throw Error(s(451))}}function aA(x){for(var O=x.attributes;O.length;)x.removeAttributeNode(O[0]);xs(x)}var lh=new Map,YAe=new Set;function B5(x){return typeof x.getRootNode=="function"?x.getRootNode():x.nodeType===9?x:x.ownerDocument}var sb=z.d;z.d={f:_zt,r:Czt,D:Ezt,C:jzt,L:Tzt,m:Nzt,X:Azt,S:Izt,M:Rzt};function _zt(){var x=sb.f(),O=A5();return x||O}function Czt(x){var O=fr(x);O!==null&&O.tag===5&&O.type==="form"?pIe(O):sb.r(x)}var SC=typeof document>"u"?null:document;function XAe(x,O,T){var A=SC;if(A&&typeof O=="string"&&O){var H=Uo(O);H='link[rel="'+x+'"][href="'+H+'"]',typeof T=="string"&&(H+='[crossorigin="'+T+'"]'),YAe.has(H)||(YAe.add(H),x={rel:x,crossOrigin:T,href:O},A.querySelector(H)===null&&(O=A.createElement("link"),Pc(O,"link",x),_a(O),A.head.appendChild(O)))}}function Ezt(x){sb.D(x),XAe("dns-prefetch",x,null)}function jzt(x,O){sb.C(x,O),XAe("preconnect",x,O)}function Tzt(x,O,T){sb.L(x,O,T);var A=SC;if(A&&x&&O){var H='link[rel="preload"][as="'+Uo(O)+'"]';O==="image"&&T&&T.imageSrcSet?(H+='[imagesrcset="'+Uo(T.imageSrcSet)+'"]',typeof T.imageSizes=="string"&&(H+='[imagesizes="'+Uo(T.imageSizes)+'"]')):H+='[href="'+Uo(x)+'"]';var Q=H;switch(O){case"style":Q=kC(x);break;case"script":Q=OC(x)}lh.has(Q)||(x=p({rel:"preload",href:O==="image"&&T&&T.imageSrcSet?void 0:x,as:O},T),lh.set(Q,x),A.querySelector(H)!==null||O==="style"&&A.querySelector(iA(Q))||O==="script"&&A.querySelector(oA(Q))||(O=A.createElement("link"),Pc(O,"link",x),_a(O),A.head.appendChild(O)))}}function Nzt(x,O){sb.m(x,O);var T=SC;if(T&&x){var A=O&&typeof O.as=="string"?O.as:"script",H='link[rel="modulepreload"][as="'+Uo(A)+'"][href="'+Uo(x)+'"]',Q=H;switch(A){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":Q=OC(x)}if(!lh.has(Q)&&(x=p({rel:"modulepreload",href:x},O),lh.set(Q,x),T.querySelector(H)===null)){switch(A){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(T.querySelector(oA(Q)))return}A=T.createElement("link"),Pc(A,"link",x),_a(A),T.head.appendChild(A)}}}function Izt(x,O,T){sb.S(x,O,T);var A=SC;if(A&&x){var H=fa(A).hoistableStyles,Q=kC(x);O=O||"default";var ie=H.get(Q);if(!ie){var we={loading:0,preload:null};if(ie=A.querySelector(iA(Q)))we.loading=5;else{x=p({rel:"stylesheet",href:x,"data-precedence":O},T),(T=lh.get(Q))&&BQ(x,T);var Be=ie=A.createElement("link");_a(Be),Pc(Be,"link",x),Be._p=new Promise(function(st,xt){Be.onload=st,Be.onerror=xt}),Be.addEventListener("load",function(){we.loading|=1}),Be.addEventListener("error",function(){we.loading|=2}),we.loading|=4,U5(ie,O,A)}ie={type:"stylesheet",instance:ie,count:1,state:we},H.set(Q,ie)}}}function Azt(x,O){sb.X(x,O);var T=SC;if(T&&x){var A=fa(T).hoistableScripts,H=OC(x),Q=A.get(H);Q||(Q=T.querySelector(oA(H)),Q||(x=p({src:x,async:!0},O),(O=lh.get(H))&&UQ(x,O),Q=T.createElement("script"),_a(Q),Pc(Q,"link",x),T.head.appendChild(Q)),Q={type:"script",instance:Q,count:1,state:null},A.set(H,Q))}}function Rzt(x,O){sb.M(x,O);var T=SC;if(T&&x){var A=fa(T).hoistableScripts,H=OC(x),Q=A.get(H);Q||(Q=T.querySelector(oA(H)),Q||(x=p({src:x,async:!0,type:"module"},O),(O=lh.get(H))&&UQ(x,O),Q=T.createElement("script"),_a(Q),Pc(Q,"link",x),T.head.appendChild(Q)),Q={type:"script",instance:Q,count:1,state:null},A.set(H,Q))}}function KAe(x,O,T,A){var H=(H=te.current)?B5(H):null;if(!H)throw Error(s(446));switch(x){case"meta":case"title":return null;case"style":return typeof T.precedence=="string"&&typeof T.href=="string"?(O=kC(T.href),T=fa(H).hoistableStyles,A=T.get(O),A||(A={type:"style",instance:null,count:0,state:null},T.set(O,A)),A):{type:"void",instance:null,count:0,state:null};case"link":if(T.rel==="stylesheet"&&typeof T.href=="string"&&typeof T.precedence=="string"){x=kC(T.href);var Q=fa(H).hoistableStyles,ie=Q.get(x);if(ie||(H=H.ownerDocument||H,ie={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},Q.set(x,ie),(Q=H.querySelector(iA(x)))&&!Q._p&&(ie.instance=Q,ie.state.loading=5),lh.has(x)||(T={rel:"preload",as:"style",href:T.href,crossOrigin:T.crossOrigin,integrity:T.integrity,media:T.media,hrefLang:T.hrefLang,referrerPolicy:T.referrerPolicy},lh.set(x,T),Q||Pzt(H,x,T,ie.state))),O&&A===null)throw Error(s(528,""));return ie}if(O&&A!==null)throw Error(s(529,""));return null;case"script":return O=T.async,T=T.src,typeof T=="string"&&O&&typeof O!="function"&&typeof O!="symbol"?(O=OC(T),T=fa(H).hoistableScripts,A=T.get(O),A||(A={type:"script",instance:null,count:0,state:null},T.set(O,A)),A):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,x))}}function kC(x){return'href="'+Uo(x)+'"'}function iA(x){return'link[rel="stylesheet"]['+x+"]"}function JAe(x){return p({},x,{"data-precedence":x.precedence,precedence:null})}function Pzt(x,O,T,A){x.querySelector('link[rel="preload"][as="style"]['+O+"]")?A.loading=1:(O=x.createElement("link"),A.preload=O,O.addEventListener("load",function(){return A.loading|=1}),O.addEventListener("error",function(){return A.loading|=2}),Pc(O,"link",T),_a(O),x.head.appendChild(O))}function OC(x){return'[src="'+Uo(x)+'"]'}function oA(x){return"script[async]"+x}function eRe(x,O,T){if(O.count++,O.instance===null)switch(O.type){case"style":var A=x.querySelector('style[data-href~="'+Uo(T.href)+'"]');if(A)return O.instance=A,_a(A),A;var H=p({},T,{"data-href":T.href,"data-precedence":T.precedence,href:null,precedence:null});return A=(x.ownerDocument||x).createElement("style"),_a(A),Pc(A,"style",H),U5(A,T.precedence,x),O.instance=A;case"stylesheet":H=kC(T.href);var Q=x.querySelector(iA(H));if(Q)return O.state.loading|=4,O.instance=Q,_a(Q),Q;A=JAe(T),(H=lh.get(H))&&BQ(A,H),Q=(x.ownerDocument||x).createElement("link"),_a(Q);var ie=Q;return ie._p=new Promise(function(we,Be){ie.onload=we,ie.onerror=Be}),Pc(Q,"link",A),O.state.loading|=4,U5(Q,T.precedence,x),O.instance=Q;case"script":return Q=OC(T.src),(H=x.querySelector(oA(Q)))?(O.instance=H,_a(H),H):(A=T,(H=lh.get(Q))&&(A=p({},T),UQ(A,H)),x=x.ownerDocument||x,H=x.createElement("script"),_a(H),Pc(H,"link",A),x.head.appendChild(H),O.instance=H);case"void":return null;default:throw Error(s(443,O.type))}else O.type==="stylesheet"&&(O.state.loading&4)===0&&(A=O.instance,O.state.loading|=4,U5(A,T.precedence,x));return O.instance}function U5(x,O,T){for(var A=T.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),H=A.length?A[A.length-1]:null,Q=H,ie=0;ie<A.length;ie++){var we=A[ie];if(we.dataset.precedence===O)Q=we;else if(Q!==H)break}Q?Q.parentNode.insertBefore(x,Q.nextSibling):(O=T.nodeType===9?T.head:T,O.insertBefore(x,O.firstChild))}function BQ(x,O){x.crossOrigin==null&&(x.crossOrigin=O.crossOrigin),x.referrerPolicy==null&&(x.referrerPolicy=O.referrerPolicy),x.title==null&&(x.title=O.title)}function UQ(x,O){x.crossOrigin==null&&(x.crossOrigin=O.crossOrigin),x.referrerPolicy==null&&(x.referrerPolicy=O.referrerPolicy),x.integrity==null&&(x.integrity=O.integrity)}var q5=null;function tRe(x,O,T){if(q5===null){var A=new Map,H=q5=new Map;H.set(T,A)}else H=q5,A=H.get(T),A||(A=new Map,H.set(T,A));if(A.has(x))return A;for(A.set(x,null),T=T.getElementsByTagName(x),H=0;H<T.length;H++){var Q=T[H];if(!(Q[hr]||Q[Ft]||x==="link"&&Q.getAttribute("rel")==="stylesheet")&&Q.namespaceURI!=="http://www.w3.org/2000/svg"){var ie=Q.getAttribute(O)||"";ie=x+ie;var we=A.get(ie);we?we.push(Q):A.set(ie,[Q])}}return A}function nRe(x,O,T){x=x.ownerDocument||x,x.head.insertBefore(T,O==="title"?x.querySelector("head > title"):null)}function $zt(x,O,T){if(T===1||O.itemProp!=null)return!1;switch(x){case"meta":case"title":return!0;case"style":if(typeof O.precedence!="string"||typeof O.href!="string"||O.href==="")break;return!0;case"link":if(typeof O.rel!="string"||typeof O.href!="string"||O.href===""||O.onLoad||O.onError)break;return O.rel==="stylesheet"?(x=O.disabled,typeof O.precedence=="string"&&x==null):!0;case"script":if(O.async&&typeof O.async!="function"&&typeof O.async!="symbol"&&!O.onLoad&&!O.onError&&O.src&&typeof O.src=="string")return!0}return!1}function rRe(x){return!(x.type==="stylesheet"&&(x.state.loading&3)===0)}function Mzt(x,O,T,A){if(T.type==="stylesheet"&&(typeof A.media!="string"||matchMedia(A.media).matches!==!1)&&(T.state.loading&4)===0){if(T.instance===null){var H=kC(A.href),Q=O.querySelector(iA(H));if(Q){O=Q._p,O!==null&&typeof O=="object"&&typeof O.then=="function"&&(x.count++,x=V5.bind(x),O.then(x,x)),T.state.loading|=4,T.instance=Q,_a(Q);return}Q=O.ownerDocument||O,A=JAe(A),(H=lh.get(H))&&BQ(A,H),Q=Q.createElement("link"),_a(Q);var ie=Q;ie._p=new Promise(function(we,Be){ie.onload=we,ie.onerror=Be}),Pc(Q,"link",A),T.instance=Q}x.stylesheets===null&&(x.stylesheets=new Map),x.stylesheets.set(T,O),(O=T.state.preload)&&(T.state.loading&3)===0&&(x.count++,T=V5.bind(x),O.addEventListener("load",T),O.addEventListener("error",T))}}var qQ=0;function Dzt(x,O){return x.stylesheets&&x.count===0&&W5(x,x.stylesheets),0<x.count||0<x.imgCount?function(T){var A=setTimeout(function(){if(x.stylesheets&&W5(x,x.stylesheets),x.unsuspend){var Q=x.unsuspend;x.unsuspend=null,Q()}},6e4+O);0<x.imgBytes&&qQ===0&&(qQ=62500*vzt());var H=setTimeout(function(){if(x.waitingForImages=!1,x.count===0&&(x.stylesheets&&W5(x,x.stylesheets),x.unsuspend)){var Q=x.unsuspend;x.unsuspend=null,Q()}},(x.imgBytes>qQ?50:800)+O);return x.unsuspend=T,function(){x.unsuspend=null,clearTimeout(A),clearTimeout(H)}}:null}function V5(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)W5(this,this.stylesheets);else if(this.unsuspend){var x=this.unsuspend;this.unsuspend=null,x()}}}var H5=null;function W5(x,O){x.stylesheets=null,x.unsuspend!==null&&(x.count++,H5=new Map,O.forEach(Lzt,x),H5=null,V5.call(x))}function Lzt(x,O){if(!(O.state.loading&4)){var T=H5.get(x);if(T)var A=T.get(null);else{T=new Map,H5.set(x,T);for(var H=x.querySelectorAll("link[data-precedence],style[data-precedence]"),Q=0;Q<H.length;Q++){var ie=H[Q];(ie.nodeName==="LINK"||ie.getAttribute("media")!=="not all")&&(T.set(ie.dataset.precedence,ie),A=ie)}A&&T.set(null,A)}H=O.instance,ie=H.getAttribute("data-precedence"),Q=T.get(ie)||A,Q===A&&T.set(null,H),T.set(ie,H),this.count++,A=V5.bind(this),H.addEventListener("load",A),H.addEventListener("error",A),Q?Q.parentNode.insertBefore(H,Q.nextSibling):(x=x.nodeType===9?x.head:x,x.insertBefore(H,x.firstChild)),O.state.loading|=4}}var lA={$$typeof:k,Provider:null,Consumer:null,_currentValue:B,_currentValue2:B,_threadCount:0};function Fzt(x,O,T,A,H,Q,ie,we,Be){this.tag=1,this.containerInfo=x,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=it(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=it(0),this.hiddenUpdates=it(null),this.identifierPrefix=A,this.onUncaughtError=H,this.onCaughtError=Q,this.onRecoverableError=ie,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Be,this.incompleteTransitions=new Map}function sRe(x,O,T,A,H,Q,ie,we,Be,st,xt,Ct){return x=new Fzt(x,O,T,ie,Be,st,xt,Ct,we),O=1,Q===!0&&(O|=24),Q=Mf(3,null,null,O),x.current=Q,Q.stateNode=x,O=SG(),O.refCount++,x.pooledCache=O,O.refCount++,Q.memoizedState={element:A,isDehydrated:T,cache:O},CG(Q),x}function aRe(x){return x?(x=tC,x):tC}function iRe(x,O,T,A,H,Q){H=aRe(H),A.context===null?A.context=H:A.pendingContext=H,A=f0(O),A.payload={element:T},Q=Q===void 0?null:Q,Q!==null&&(A.callback=Q),T=p0(x,A,O),T!==null&&(Pd(T,x,O),zI(T,x,O))}function oRe(x,O){if(x=x.memoizedState,x!==null&&x.dehydrated!==null){var T=x.retryLane;x.retryLane=T!==0&&T<O?T:O}}function VQ(x,O){oRe(x,O),(x=x.alternate)&&oRe(x,O)}function lRe(x){if(x.tag===13||x.tag===31){var O=rS(x,67108864);O!==null&&Pd(O,x,67108864),VQ(x,67108864)}}function cRe(x){if(x.tag===13||x.tag===31){var O=Bf();O=Me(O);var T=rS(x,O);T!==null&&Pd(T,x,O),VQ(x,O)}}var Z5=!0;function zzt(x,O,T,A){var H=L.T;L.T=null;var Q=z.p;try{z.p=2,HQ(x,O,T,A)}finally{z.p=Q,L.T=H}}function Bzt(x,O,T,A){var H=L.T;L.T=null;var Q=z.p;try{z.p=8,HQ(x,O,T,A)}finally{z.p=Q,L.T=H}}function HQ(x,O,T,A){if(Z5){var H=WQ(A);if(H===null)IQ(x,O,A,G5,T),dRe(x,A);else if(qzt(H,x,O,T,A))A.stopPropagation();else if(dRe(x,A),O&4&&-1<Uzt.indexOf(x)){for(;H!==null;){var Q=fr(H);if(Q!==null)switch(Q.tag){case 3:if(Q=Q.stateNode,Q.current.memoizedState.isDehydrated){var ie=bt(Q.pendingLanes);if(ie!==0){var we=Q;for(we.pendingLanes|=2,we.entangledLanes|=2;ie;){var Be=1<<31-Re(ie);we.entanglements[1]|=Be,ie&=~Be}Kg(Q),(ja&6)===0&&(N5=se()+500,nA(0))}}break;case 31:case 13:we=rS(Q,2),we!==null&&Pd(we,Q,2),A5(),VQ(Q,2)}if(Q=WQ(A),Q===null&&IQ(x,O,A,G5,T),Q===H)break;H=Q}H!==null&&A.stopPropagation()}else IQ(x,O,A,null,T)}}function WQ(x){return x=OI(x),ZQ(x)}var G5=null;function ZQ(x){if(G5=null,x=Mr(x),x!==null){var O=i(x);if(O===null)x=null;else{var T=O.tag;if(T===13){if(x=l(O),x!==null)return x;x=null}else if(T===31){if(x=c(O),x!==null)return x;x=null}else if(T===3){if(O.stateNode.current.memoizedState.isDehydrated)return O.tag===3?O.stateNode.containerInfo:null;x=null}else O!==x&&(x=null)}}return G5=x,null}function uRe(x){switch(x){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(re()){case he:return 2;case xe:return 8;case Ee:case Pe:return 32;case Qe:return 268435456;default:return 32}default:return 32}}var GQ=!1,O0=null,_0=null,C0=null,cA=new Map,uA=new Map,E0=[],Uzt="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function dRe(x,O){switch(x){case"focusin":case"focusout":O0=null;break;case"dragenter":case"dragleave":_0=null;break;case"mouseover":case"mouseout":C0=null;break;case"pointerover":case"pointerout":cA.delete(O.pointerId);break;case"gotpointercapture":case"lostpointercapture":uA.delete(O.pointerId)}}function dA(x,O,T,A,H,Q){return x===null||x.nativeEvent!==Q?(x={blockedOn:O,domEventName:T,eventSystemFlags:A,nativeEvent:Q,targetContainers:[H]},O!==null&&(O=fr(O),O!==null&&lRe(O)),x):(x.eventSystemFlags|=A,O=x.targetContainers,H!==null&&O.indexOf(H)===-1&&O.push(H),x)}function qzt(x,O,T,A,H){switch(O){case"focusin":return O0=dA(O0,x,O,T,A,H),!0;case"dragenter":return _0=dA(_0,x,O,T,A,H),!0;case"mouseover":return C0=dA(C0,x,O,T,A,H),!0;case"pointerover":var Q=H.pointerId;return cA.set(Q,dA(cA.get(Q)||null,x,O,T,A,H)),!0;case"gotpointercapture":return Q=H.pointerId,uA.set(Q,dA(uA.get(Q)||null,x,O,T,A,H)),!0}return!1}function fRe(x){var O=Mr(x.target);if(O!==null){var T=i(O);if(T!==null){if(O=T.tag,O===13){if(O=l(T),O!==null){x.blockedOn=O,Dt(x.priority,function(){cRe(T)});return}}else if(O===31){if(O=c(T),O!==null){x.blockedOn=O,Dt(x.priority,function(){cRe(T)});return}}else if(O===3&&T.stateNode.current.memoizedState.isDehydrated){x.blockedOn=T.tag===3?T.stateNode.containerInfo:null;return}}}x.blockedOn=null}function Q5(x){if(x.blockedOn!==null)return!1;for(var O=x.targetContainers;0<O.length;){var T=WQ(x.nativeEvent);if(T===null){T=x.nativeEvent;var A=new T.constructor(T.type,T);J1=A,T.target.dispatchEvent(A),J1=null}else return O=fr(T),O!==null&&lRe(O),x.blockedOn=T,!1;O.shift()}return!0}function pRe(x,O,T){Q5(x)&&T.delete(O)}function Vzt(){GQ=!1,O0!==null&&Q5(O0)&&(O0=null),_0!==null&&Q5(_0)&&(_0=null),C0!==null&&Q5(C0)&&(C0=null),cA.forEach(pRe),uA.forEach(pRe)}function Y5(x,O){x.blockedOn===O&&(x.blockedOn=null,GQ||(GQ=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Vzt)))}var X5=null;function hRe(x){X5!==x&&(X5=x,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){X5===x&&(X5=null);for(var O=0;O<x.length;O+=3){var T=x[O],A=x[O+1],H=x[O+2];if(typeof A!="function"){if(ZQ(A||T)===null)continue;break}var Q=fr(T);Q!==null&&(x.splice(O,3),O-=3,WG(Q,{pending:!0,data:H,method:T.method,action:A},A,H))}}))}function _C(x){function O(Be){return Y5(Be,x)}O0!==null&&Y5(O0,x),_0!==null&&Y5(_0,x),C0!==null&&Y5(C0,x),cA.forEach(O),uA.forEach(O);for(var T=0;T<E0.length;T++){var A=E0[T];A.blockedOn===x&&(A.blockedOn=null)}for(;0<E0.length&&(T=E0[0],T.blockedOn===null);)fRe(T),T.blockedOn===null&&E0.shift();if(T=(x.ownerDocument||x).$$reactFormReplay,T!=null)for(A=0;A<T.length;A+=3){var H=T[A],Q=T[A+1],ie=H[$t]||null;if(typeof Q=="function")ie||hRe(T);else if(ie){var we=null;if(Q&&Q.hasAttribute("formAction")){if(H=Q,ie=Q[$t]||null)we=ie.formAction;else if(ZQ(H)!==null)continue}else we=ie.action;typeof we=="function"?T[A+1]=we:(T.splice(A,3),A-=3),hRe(T)}}}function mRe(){function x(Q){Q.canIntercept&&Q.info==="react-transition"&&Q.intercept({handler:function(){return new Promise(function(ie){return H=ie})},focusReset:"manual",scroll:"manual"})}function O(){H!==null&&(H(),H=null),A||setTimeout(T,20)}function T(){if(!A&&!navigation.transition){var Q=navigation.currentEntry;Q&&Q.url!=null&&navigation.navigate(Q.url,{state:Q.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var A=!1,H=null;return navigation.addEventListener("navigate",x),navigation.addEventListener("navigatesuccess",O),navigation.addEventListener("navigateerror",O),setTimeout(T,100),function(){A=!0,navigation.removeEventListener("navigate",x),navigation.removeEventListener("navigatesuccess",O),navigation.removeEventListener("navigateerror",O),H!==null&&(H(),H=null)}}}function QQ(x){this._internalRoot=x}K5.prototype.render=QQ.prototype.render=function(x){var O=this._internalRoot;if(O===null)throw Error(s(409));var T=O.current,A=Bf();iRe(T,A,x,O,null,null)},K5.prototype.unmount=QQ.prototype.unmount=function(){var x=this._internalRoot;if(x!==null){this._internalRoot=null;var O=x.containerInfo;iRe(x.current,2,null,x,null,null),A5(),O[jt]=null}};function K5(x){this._internalRoot=x}K5.prototype.unstable_scheduleHydration=function(x){if(x){var O=nt();x={blockedOn:null,target:x,priority:O};for(var T=0;T<E0.length&&O!==0&&O<E0[T].priority;T++);E0.splice(T,0,x),T===0&&fRe(x)}};var gRe=n.version;if(gRe!=="19.2.6")throw Error(s(527,gRe,"19.2.6"));z.findDOMNode=function(x){var O=x._reactInternals;if(O===void 0)throw typeof x.render=="function"?Error(s(188)):(x=Object.keys(x).join(","),Error(s(268,x)));return x=d(O),x=x!==null?f(x):null,x=x===null?null:x.stateNode,x};var Hzt={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:L,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var J5=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!J5.isDisabled&&J5.supportsFiber)try{je=J5.inject(Hzt),_e=J5}catch{}}return pA.createRoot=function(x,O){if(!a(x))throw Error(s(299));var T=!1,A="",H=kIe,Q=OIe,ie=_Ie;return O!=null&&(O.unstable_strictMode===!0&&(T=!0),O.identifierPrefix!==void 0&&(A=O.identifierPrefix),O.onUncaughtError!==void 0&&(H=O.onUncaughtError),O.onCaughtError!==void 0&&(Q=O.onCaughtError),O.onRecoverableError!==void 0&&(ie=O.onRecoverableError)),O=sRe(x,1,!1,null,null,T,A,null,H,Q,ie,mRe),x[jt]=O.current,NQ(x),new QQ(O)},pA.hydrateRoot=function(x,O,T){if(!a(x))throw Error(s(299));var A=!1,H="",Q=kIe,ie=OIe,we=_Ie,Be=null;return T!=null&&(T.unstable_strictMode===!0&&(A=!0),T.identifierPrefix!==void 0&&(H=T.identifierPrefix),T.onUncaughtError!==void 0&&(Q=T.onUncaughtError),T.onCaughtError!==void 0&&(ie=T.onCaughtError),T.onRecoverableError!==void 0&&(we=T.onRecoverableError),T.formState!==void 0&&(Be=T.formState)),O=sRe(x,1,!0,O,T??null,A,H,Be,Q,ie,we,mRe),O.context=aRe(null),T=O.current,A=Bf(),A=Me(A),H=f0(A),H.callback=null,p0(T,H,A),T=A,O.current.lanes=T,Yt(O,T),Kg(O),x[jt]=O.current,NQ(x),new K5(O)},pA.version="19.2.6",pA}var CRe;function t7t(){if(CRe)return KQ.exports;CRe=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),KQ.exports=e7t(),KQ.exports}var n7t=t7t(),dk=256,i9=[],eL;for(;dk--;)i9[dk]=(dk+256).toString(16).substring(1);function uo(){var e=0,t,n="";if(!eL||dk+16>256){for(eL=Array(e=256);e--;)eL[e]=256*Math.random()|0;e=dk=0}for(;e<16;e++)t=eL[dk+e],e==6?n+=i9[t&15|64]:e==8?n+=i9[t&63|128]:n+=i9[t],e&1&&e>1&&e<11&&(n+="-");return dk++,n}var zve=new Set(["observationalMemory","asyncBuffering","request-response-id-rotation","workspaces-v1","datasets","observability:v1.13.2","observability-delta-polling","channels","deploy-diagnosis","model-inference-span","internal-usage-rollup","json-prompt-injection:inline"]),Znt="vercel.ai.error",r7t=Symbol.for(Znt),Gnt,s7t=class Qnt extends Error{constructor({name:t,message:n,cause:r}){super(n),this[Gnt]=!0,this.name=t,this.cause=r}static isInstance(t){return Qnt.hasMarker(t,Znt)}static hasMarker(t,n){const r=Symbol.for(n);return t!=null&&typeof t=="object"&&r in t&&typeof t[r]=="boolean"&&t[r]===!0}};Gnt=r7t;var $j=s7t;function Ynt(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var Xnt="AI_InvalidArgumentError",Knt=`vercel.ai.error.${Xnt}`,a7t=Symbol.for(Knt),Jnt,i7t=class extends $j{constructor({message:t,cause:n,argument:r}){super({name:Xnt,message:t,cause:n}),this[Jnt]=!0,this.argument=r}static isInstance(t){return $j.hasMarker(t,Knt)}};Jnt=a7t;var ert="AI_JSONParseError",trt=`vercel.ai.error.${ert}`,o7t=Symbol.for(trt),nrt,ERe=class extends $j{constructor({text:t,cause:n}){super({name:ert,message:`JSON parsing failed: Text: ${t}.
|
|
11
11
|
Error message: ${Ynt(n)}`,cause:n}),this[nrt]=!0,this.text=t}static isInstance(t){return $j.hasMarker(t,trt)}};nrt=o7t;var rrt="AI_TypeValidationError",srt=`vercel.ai.error.${rrt}`,l7t=Symbol.for(srt),art,c7t=class Fue extends $j{constructor({value:t,cause:n}){super({name:rrt,message:`Type validation failed: Value: ${JSON.stringify(t)}.
|
|
12
12
|
Error message: ${Ynt(n)}`,cause:n}),this[art]=!0,this.value=t}static isInstance(t){return $j.hasMarker(t,srt)}static wrap({value:t,cause:n}){return Fue.isInstance(n)&&n.value===t?n:new Fue({value:t,cause:n})}};art=l7t;var jRe=c7t;let u7t=(e,t=21)=>(n=t)=>{let r="",s=n|0;for(;s--;)r+=e[Math.random()*e.length|0];return r};var gS={exports:{}},TRe;function d7t(){if(TRe)return gS.exports;TRe=1;const e=typeof Buffer<"u",t=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,n=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function r(l,c,u){u==null&&c!==null&&typeof c=="object"&&(u=c,c=void 0),e&&Buffer.isBuffer(l)&&(l=l.toString()),l&&l.charCodeAt(0)===65279&&(l=l.slice(1));const d=JSON.parse(l,c);if(d===null||typeof d!="object")return d;const f=u&&u.protoAction||"error",p=u&&u.constructorAction||"error";if(f==="ignore"&&p==="ignore")return d;if(f!=="ignore"&&p!=="ignore"){if(t.test(l)===!1&&n.test(l)===!1)return d}else if(f!=="ignore"&&p==="ignore"){if(t.test(l)===!1)return d}else if(n.test(l)===!1)return d;return s(d,{protoAction:f,constructorAction:p,safe:u&&u.safe})}function s(l,{protoAction:c="error",constructorAction:u="error",safe:d}={}){let f=[l];for(;f.length;){const p=f;f=[];for(const h of p){if(c!=="ignore"&&Object.prototype.hasOwnProperty.call(h,"__proto__")){if(d===!0)return null;if(c==="error")throw new SyntaxError("Object contains forbidden prototype property");delete h.__proto__}if(u!=="ignore"&&Object.prototype.hasOwnProperty.call(h,"constructor")&&Object.prototype.hasOwnProperty.call(h.constructor,"prototype")){if(d===!0)return null;if(u==="error")throw new SyntaxError("Object contains forbidden prototype property");delete h.constructor}for(const m in h){const g=h[m];g&&typeof g=="object"&&f.push(g)}}}return l}function a(l,c,u){const d=Error.stackTraceLimit;Error.stackTraceLimit=0;try{return r(l,c,u)}finally{Error.stackTraceLimit=d}}function i(l,c){const u=Error.stackTraceLimit;Error.stackTraceLimit=0;try{return r(l,c,{safe:!0})}catch{return null}finally{Error.stackTraceLimit=u}}return gS.exports=a,gS.exports.default=a,gS.exports.parse=a,gS.exports.safeParse=i,gS.exports.scan=s,gS.exports}var f7t=d7t();const p7t=Cc(f7t);var h7t=({prefix:e,size:t=16,alphabet:n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:r="-"}={})=>{const s=u7t(n,t);if(e==null)return s;if(n.includes(r))throw new i7t({argument:"separator",message:`The separator "${r}" must not be part of the alphabet "${n}".`});return a=>`${e}${r}${s(a)}`};h7t();var zue=Symbol.for("vercel.ai.validator");function m7t(e){return{[zue]:!0,validate:e}}function g7t(e){return typeof e=="object"&&e!==null&&zue in e&&e[zue]===!0&&"validate"in e}function v7t(e){return g7t(e)?e:y7t(e)}function y7t(e){return m7t(t=>{const n=e.safeParse(t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}})}function b7t({value:e,schema:t}){const n=v7t(t);try{if(n.validate==null)return{success:!0,value:e};const r=n.validate(e);return r.success?r:{success:!1,error:jRe.wrap({value:e,cause:r.error})}}catch(r){return{success:!1,error:jRe.wrap({value:e,cause:r})}}}function NRe({text:e,schema:t}){try{const n=p7t.parse(e);if(t==null)return{success:!0,value:n,rawValue:n};const r=b7t({value:n,schema:t});return r.success?{...r,rawValue:n}:r}catch(n){return{success:!1,error:ERe.isInstance(n)?n:new ERe({text:e,cause:n})}}}const irt=Symbol("Let zodToJsonSchema decide on which parser to use"),IRe={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},x7t=e=>typeof e=="string"?{...IRe,name:e}:{...IRe,...e},w7t=e=>{const t=x7t(e),n=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([r,s])=>[s._def,{def:s._def,path:[...t.basePath,t.definitionPath,r],jsonSchema:void 0}]))}};function ort(e,t,n,r){r?.errorMessages&&n&&(e.errorMessage={...e.errorMessage,[t]:n})}function Za(e,t,n,r,s){e[t]=n,ort(e,t,r,s)}const lrt=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join("/")};var ca;(function(e){e.assertEqual=s=>{};function t(s){}e.assertIs=t;function n(s){throw new Error}e.assertNever=n,e.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},e.getValidEnumValues=s=>{const a=e.objectKeys(s).filter(l=>typeof s[s[l]]!="number"),i={};for(const l of a)i[l]=s[l];return e.objectValues(i)},e.objectValues=s=>e.objectKeys(s).map(function(a){return s[a]}),e.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},e.find=(s,a)=>{for(const i of s)if(a(i))return i},e.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}e.joinValues=r,e.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(ca||(ca={}));var Bue;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Bue||(Bue={}));const Vn=ca.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ib=e=>{switch(typeof e){case"undefined":return Vn.undefined;case"string":return Vn.string;case"number":return Number.isNaN(e)?Vn.nan:Vn.number;case"boolean":return Vn.boolean;case"function":return Vn.function;case"bigint":return Vn.bigint;case"symbol":return Vn.symbol;case"object":return Array.isArray(e)?Vn.array:e===null?Vn.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Vn.promise:typeof Map<"u"&&e instanceof Map?Vn.map:typeof Set<"u"&&e instanceof Set?Vn.set:typeof Date<"u"&&e instanceof Date?Vn.date:Vn.object;default:return Vn.unknown}},Jt=ca.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);let zw=class crt extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(a){return a.message},r={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)r._errors.push(n(i));else{let l=r,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(l[u]=l[u]||{_errors:[]},l[u]._errors.push(n(i))):l[u]=l[u]||{_errors:[]},l=l[u],c++}}};return s(this),r}static assert(t){if(!(t instanceof crt))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ca.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n=Object.create(null),r=[];for(const s of this.issues)if(s.path.length>0){const a=s.path[0];n[a]=n[a]||[],n[a].push(t(s))}else r.push(t(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};zw.create=e=>new zw(e);const vF=(e,t)=>{let n;switch(e.code){case Jt.invalid_type:e.received===Vn.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Jt.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,ca.jsonStringifyReplacer)}`;break;case Jt.unrecognized_keys:n=`Unrecognized key(s) in object: ${ca.joinValues(e.keys,", ")}`;break;case Jt.invalid_union:n="Invalid input";break;case Jt.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${ca.joinValues(e.options)}`;break;case Jt.invalid_enum_value:n=`Invalid enum value. Expected ${ca.joinValues(e.options)}, received '${e.received}'`;break;case Jt.invalid_arguments:n="Invalid function arguments";break;case Jt.invalid_return_type:n="Invalid function return type";break;case Jt.invalid_date:n="Invalid date";break;case Jt.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:ca.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case Jt.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case Jt.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case Jt.custom:n="Invalid input";break;case Jt.invalid_intersection_types:n="Intersection results could not be merged";break;case Jt.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Jt.not_finite:n="Number must be finite";break;default:n=t.defaultError,ca.assertNever(e)}return{message:n}};let S7t=vF;function urt(){return S7t}const drt=e=>{const{data:t,path:n,errorMaps:r,issueData:s}=e,a=[...n,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let l="";const c=r.filter(u=>!!u).slice().reverse();for(const u of c)l=u(i,{data:t,defaultError:l}).message;return{...s,path:a,message:l}};function jn(e,t){const n=urt(),r=drt({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===vF?void 0:vF].filter(s=>!!s)});e.common.issues.push(r)}let Qh=class frt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const s of n){if(s.status==="aborted")return Dr;s.status==="dirty"&&t.dirty(),r.push(s.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const s of n){const a=await s.key,i=await s.value;r.push({key:a,value:i})}return frt.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const s of n){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return Dr;a.status==="dirty"&&t.dirty(),i.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(r[a.value]=i.value)}return{status:t.value,value:r}}};const Dr=Object.freeze({status:"aborted"}),_E=e=>({status:"dirty",value:e}),Bp=e=>({status:"valid",value:e}),Uue=e=>e.status==="aborted",que=e=>e.status==="dirty",Gk=e=>e.status==="valid",aP=e=>typeof Promise<"u"&&e instanceof Promise;var Yn;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(Yn||(Yn={}));let Bw=class{constructor(t,n,r,s){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const ARe=(e,t)=>{if(Gk(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new zw(e.common.issues);return this._error=n,this._error}}};function ks(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:s}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:s}:{errorMap:(i,l)=>{const{message:c}=e;return i.code==="invalid_enum_value"?{message:c??l.defaultError}:typeof l.data>"u"?{message:c??r??l.defaultError}:i.code!=="invalid_type"?{message:l.defaultError}:{message:c??n??l.defaultError}},description:s}}let Bs=class{get description(){return this._def.description}_getType(t){return Ib(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Ib(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Qh,ctx:{common:t.parent.common,data:t.data,parsedType:Ib(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(aP(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){const r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ib(t)},s=this._parseSync({data:t,path:r.path,parent:r});return ARe(r,s)}"~validate"(t){const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ib(t)};if(!this["~standard"].async)try{const r=this._parseSync({data:t,path:[],parent:n});return Gk(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(r=>Gk(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ib(t)},s=this._parse({data:t,path:r.path,parent:r}),a=await(aP(s)?s:Promise.resolve(s));return ARe(r,a)}refine(t,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,a)=>{const i=t(s),l=()=>a.addIssue({code:Jt.custom,...r(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(l(),!1)):i?!0:(l(),!1)})}refinement(t,n){return this._refinement((r,s)=>t(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(t){return new Uw({schema:this,typeName:Ve.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Yb.create(this,this._def)}nullable(){return Yk.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Qk.create(this)}promise(){return lP.create(this,this._def)}or(t){return iP.create([this,t],this._def)}and(t){return oP.create(this,t,this._def)}transform(t){return new Uw({...ks(this._def),schema:this,typeName:Ve.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new yF({...ks(this._def),innerType:this,defaultValue:n,typeName:Ve.ZodDefault})}brand(){return new brt({typeName:Ve.ZodBranded,type:this,...ks(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new bF({...ks(this._def),innerType:this,catchValue:n,typeName:Ve.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return xrt.create(this,t)}readonly(){return xF.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const k7t=/^c[^\s-]{8,}$/i,O7t=/^[0-9a-z]+$/,_7t=/^[0-9A-HJKMNP-TV-Z]{26}$/i,C7t=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,E7t=/^[a-z0-9_-]{21}$/i,j7t=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,T7t=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,N7t=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,I7t="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let nY;const A7t=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,R7t=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,P7t=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,$7t=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,M7t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,D7t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,prt="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",L7t=new RegExp(`^${prt}$`);function hrt(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function F7t(e){return new RegExp(`^${hrt(e)}$`)}function mrt(e){let t=`${prt}T${hrt(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function z7t(e,t){return!!((t==="v4"||!t)&&A7t.test(e)||(t==="v6"||!t)&&P7t.test(e))}function B7t(e,t){if(!j7t.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||t&&s.alg!==t)}catch{return!1}}function U7t(e,t){return!!((t==="v4"||!t)&&R7t.test(e)||(t==="v6"||!t)&&$7t.test(e))}let Vue=class $R extends Bs{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Vn.string){const a=this._getOrReturnCtx(t);return jn(a,{code:Jt.invalid_type,expected:Vn.string,received:a.parsedType}),Dr}const r=new Qh;let s;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(s=this._getOrReturnCtx(t,s),jn(s,{code:Jt.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")t.data.length>a.value&&(s=this._getOrReturnCtx(t,s),jn(s,{code:Jt.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const i=t.data.length>a.value,l=t.data.length<a.value;(i||l)&&(s=this._getOrReturnCtx(t,s),i?jn(s,{code:Jt.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):l&&jn(s,{code:Jt.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")N7t.test(t.data)||(s=this._getOrReturnCtx(t,s),jn(s,{validation:"email",code:Jt.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")nY||(nY=new RegExp(I7t,"u")),nY.test(t.data)||(s=this._getOrReturnCtx(t,s),jn(s,{validation:"emoji",code:Jt.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")C7t.test(t.data)||(s=this._getOrReturnCtx(t,s),jn(s,{validation:"uuid",code:Jt.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")E7t.test(t.data)||(s=this._getOrReturnCtx(t,s),jn(s,{validation:"nanoid",code:Jt.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")k7t.test(t.data)||(s=this._getOrReturnCtx(t,s),jn(s,{validation:"cuid",code:Jt.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")O7t.test(t.data)||(s=this._getOrReturnCtx(t,s),jn(s,{validation:"cuid2",code:Jt.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")_7t.test(t.data)||(s=this._getOrReturnCtx(t,s),jn(s,{validation:"ulid",code:Jt.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{s=this._getOrReturnCtx(t,s),jn(s,{validation:"url",code:Jt.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(s=this._getOrReturnCtx(t,s),jn(s,{validation:"regex",code:Jt.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(t,s),jn(s,{code:Jt.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(s=this._getOrReturnCtx(t,s),jn(s,{code:Jt.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(s=this._getOrReturnCtx(t,s),jn(s,{code:Jt.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?mrt(a).test(t.data)||(s=this._getOrReturnCtx(t,s),jn(s,{code:Jt.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?L7t.test(t.data)||(s=this._getOrReturnCtx(t,s),jn(s,{code:Jt.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?F7t(a).test(t.data)||(s=this._getOrReturnCtx(t,s),jn(s,{code:Jt.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?T7t.test(t.data)||(s=this._getOrReturnCtx(t,s),jn(s,{validation:"duration",code:Jt.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?z7t(t.data,a.version)||(s=this._getOrReturnCtx(t,s),jn(s,{validation:"ip",code:Jt.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?B7t(t.data,a.alg)||(s=this._getOrReturnCtx(t,s),jn(s,{validation:"jwt",code:Jt.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?U7t(t.data,a.version)||(s=this._getOrReturnCtx(t,s),jn(s,{validation:"cidr",code:Jt.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?M7t.test(t.data)||(s=this._getOrReturnCtx(t,s),jn(s,{validation:"base64",code:Jt.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?D7t.test(t.data)||(s=this._getOrReturnCtx(t,s),jn(s,{validation:"base64url",code:Jt.invalid_string,message:a.message}),r.dirty()):ca.assertNever(a);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(s=>t.test(s),{validation:n,code:Jt.invalid_string,...Yn.errToObj(r)})}_addCheck(t){return new $R({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Yn.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Yn.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Yn.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Yn.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Yn.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Yn.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Yn.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Yn.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Yn.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Yn.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Yn.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Yn.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Yn.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...Yn.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...Yn.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...Yn.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...Yn.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...Yn.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...Yn.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...Yn.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...Yn.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...Yn.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...Yn.errToObj(n)})}nonempty(t){return this.min(1,Yn.errToObj(t))}trim(){return new $R({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new $R({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new $R({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};Vue.create=e=>new Vue({checks:[],typeName:Ve.ZodString,coerce:e?.coerce??!1,...ks(e)});function q7t(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,s=n>r?n:r,a=Number.parseInt(e.toFixed(s).replace(".","")),i=Number.parseInt(t.toFixed(s).replace(".",""));return a%i/10**s}let Hue=class Wue extends Bs{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Vn.number){const a=this._getOrReturnCtx(t);return jn(a,{code:Jt.invalid_type,expected:Vn.number,received:a.parsedType}),Dr}let r;const s=new Qh;for(const a of this._def.checks)a.kind==="int"?ca.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),jn(r,{code:Jt.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),jn(r,{code:Jt.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),jn(r,{code:Jt.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?q7t(t.data,a.value)!==0&&(r=this._getOrReturnCtx(t,r),jn(r,{code:Jt.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),jn(r,{code:Jt.not_finite,message:a.message}),s.dirty()):ca.assertNever(a);return{status:s.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,Yn.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Yn.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Yn.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Yn.toString(n))}setLimit(t,n,r,s){return new Wue({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Yn.toString(s)}]})}_addCheck(t){return new Wue({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Yn.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Yn.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Yn.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Yn.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Yn.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Yn.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:Yn.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Yn.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Yn.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&ca.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}};Hue.create=e=>new Hue({checks:[],typeName:Ve.ZodNumber,coerce:e?.coerce||!1,...ks(e)});let Zue=class Gue extends Bs{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Vn.bigint)return this._getInvalidInput(t);let r;const s=new Qh;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),jn(r,{code:Jt.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),jn(r,{code:Jt.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),jn(r,{code:Jt.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):ca.assertNever(a);return{status:s.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return jn(n,{code:Jt.invalid_type,expected:Vn.bigint,received:n.parsedType}),Dr}gte(t,n){return this.setLimit("min",t,!0,Yn.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Yn.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Yn.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Yn.toString(n))}setLimit(t,n,r,s){return new Gue({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Yn.toString(s)}]})}_addCheck(t){return new Gue({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Yn.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Yn.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Yn.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Yn.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Yn.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};Zue.create=e=>new Zue({checks:[],typeName:Ve.ZodBigInt,coerce:e?.coerce??!1,...ks(e)});let Que=class extends Bs{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Vn.boolean){const r=this._getOrReturnCtx(t);return jn(r,{code:Jt.invalid_type,expected:Vn.boolean,received:r.parsedType}),Dr}return Bp(t.data)}};Que.create=e=>new Que({typeName:Ve.ZodBoolean,coerce:e?.coerce||!1,...ks(e)});let Yue=class grt extends Bs{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Vn.date){const a=this._getOrReturnCtx(t);return jn(a,{code:Jt.invalid_type,expected:Vn.date,received:a.parsedType}),Dr}if(Number.isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return jn(a,{code:Jt.invalid_date}),Dr}const r=new Qh;let s;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(s=this._getOrReturnCtx(t,s),jn(s,{code:Jt.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(s=this._getOrReturnCtx(t,s),jn(s,{code:Jt.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):ca.assertNever(a);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new grt({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:Yn.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:Yn.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}};Yue.create=e=>new Yue({checks:[],coerce:e?.coerce||!1,typeName:Ve.ZodDate,...ks(e)});let Xue=class extends Bs{_parse(t){if(this._getType(t)!==Vn.symbol){const r=this._getOrReturnCtx(t);return jn(r,{code:Jt.invalid_type,expected:Vn.symbol,received:r.parsedType}),Dr}return Bp(t.data)}};Xue.create=e=>new Xue({typeName:Ve.ZodSymbol,...ks(e)});let Kue=class extends Bs{_parse(t){if(this._getType(t)!==Vn.undefined){const r=this._getOrReturnCtx(t);return jn(r,{code:Jt.invalid_type,expected:Vn.undefined,received:r.parsedType}),Dr}return Bp(t.data)}};Kue.create=e=>new Kue({typeName:Ve.ZodUndefined,...ks(e)});let Jue=class extends Bs{_parse(t){if(this._getType(t)!==Vn.null){const r=this._getOrReturnCtx(t);return jn(r,{code:Jt.invalid_type,expected:Vn.null,received:r.parsedType}),Dr}return Bp(t.data)}};Jue.create=e=>new Jue({typeName:Ve.ZodNull,...ks(e)});let ede=class extends Bs{constructor(){super(...arguments),this._any=!0}_parse(t){return Bp(t.data)}};ede.create=e=>new ede({typeName:Ve.ZodAny,...ks(e)});let tde=class extends Bs{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Bp(t.data)}};tde.create=e=>new tde({typeName:Ve.ZodUnknown,...ks(e)});let lx=class extends Bs{_parse(t){const n=this._getOrReturnCtx(t);return jn(n,{code:Jt.invalid_type,expected:Vn.never,received:n.parsedType}),Dr}};lx.create=e=>new lx({typeName:Ve.ZodNever,...ks(e)});let nde=class extends Bs{_parse(t){if(this._getType(t)!==Vn.undefined){const r=this._getOrReturnCtx(t);return jn(r,{code:Jt.invalid_type,expected:Vn.void,received:r.parsedType}),Dr}return Bp(t.data)}};nde.create=e=>new nde({typeName:Ve.ZodVoid,...ks(e)});let Qk=class o9 extends Bs{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),s=this._def;if(n.parsedType!==Vn.array)return jn(n,{code:Jt.invalid_type,expected:Vn.array,received:n.parsedType}),Dr;if(s.exactLength!==null){const i=n.data.length>s.exactLength.value,l=n.data.length<s.exactLength.value;(i||l)&&(jn(n,{code:i?Jt.too_big:Jt.too_small,minimum:l?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(jn(n,{code:Jt.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(jn(n,{code:Jt.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((i,l)=>s.type._parseAsync(new Bw(n,i,n.path,l)))).then(i=>Qh.mergeArray(r,i));const a=[...n.data].map((i,l)=>s.type._parseSync(new Bw(n,i,n.path,l)));return Qh.mergeArray(r,a)}get element(){return this._def.type}min(t,n){return new o9({...this._def,minLength:{value:t,message:Yn.toString(n)}})}max(t,n){return new o9({...this._def,maxLength:{value:t,message:Yn.toString(n)}})}length(t,n){return new o9({...this._def,exactLength:{value:t,message:Yn.toString(n)}})}nonempty(t){return this.min(1,t)}};Qk.create=(e,t)=>new Qk({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ve.ZodArray,...ks(t)});function lE(e){if(e instanceof cx){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Yb.create(lE(r))}return new cx({...e._def,shape:()=>t})}else return e instanceof Qk?new Qk({...e._def,type:lE(e.element)}):e instanceof Yb?Yb.create(lE(e.unwrap())):e instanceof Yk?Yk.create(lE(e.unwrap())):e instanceof Mj?Mj.create(e.items.map(t=>lE(t))):e}let cx=class Hm extends Bs{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=ca.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==Vn.object){const u=this._getOrReturnCtx(t);return jn(u,{code:Jt.invalid_type,expected:Vn.object,received:u.parsedType}),Dr}const{status:r,ctx:s}=this._processInputParams(t),{shape:a,keys:i}=this._getCached(),l=[];if(!(this._def.catchall instanceof lx&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||l.push(u);const c=[];for(const u of i){const d=a[u],f=s.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new Bw(s,f,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof lx){const u=this._def.unknownKeys;if(u==="passthrough")for(const d of l)c.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(u==="strict")l.length>0&&(jn(s,{code:Jt.unrecognized_keys,keys:l}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const d of l){const f=s.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new Bw(s,f,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const d of c){const f=await d.key,p=await d.value;u.push({key:f,value:p,alwaysSet:d.alwaysSet})}return u}).then(u=>Qh.mergeObjectSync(r,u)):Qh.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(t){return Yn.errToObj,new Hm({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{const s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:Yn.errToObj(t).message??s}:{message:s}}}:{}})}strip(){return new Hm({...this._def,unknownKeys:"strip"})}passthrough(){return new Hm({...this._def,unknownKeys:"passthrough"})}extend(t){return new Hm({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Hm({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Ve.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Hm({...this._def,catchall:t})}pick(t){const n={};for(const r of ca.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new Hm({...this._def,shape:()=>n})}omit(t){const n={};for(const r of ca.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new Hm({...this._def,shape:()=>n})}deepPartial(){return lE(this)}partial(t){const n={};for(const r of ca.objectKeys(this.shape)){const s=this.shape[r];t&&!t[r]?n[r]=s:n[r]=s.optional()}return new Hm({...this._def,shape:()=>n})}required(t){const n={};for(const r of ca.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof Yb;)a=a._def.innerType;n[r]=a}return new Hm({...this._def,shape:()=>n})}keyof(){return yrt(ca.objectKeys(this.shape))}};cx.create=(e,t)=>new cx({shape:()=>e,unknownKeys:"strip",catchall:lx.create(),typeName:Ve.ZodObject,...ks(t)});cx.strictCreate=(e,t)=>new cx({shape:()=>e,unknownKeys:"strict",catchall:lx.create(),typeName:Ve.ZodObject,...ks(t)});cx.lazycreate=(e,t)=>new cx({shape:e,unknownKeys:"strip",catchall:lx.create(),typeName:Ve.ZodObject,...ks(t)});let iP=class extends Bs{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function s(a){for(const l of a)if(l.result.status==="valid")return l.result;for(const l of a)if(l.result.status==="dirty")return n.common.issues.push(...l.ctx.common.issues),l.result;const i=a.map(l=>new zw(l.ctx.common.issues));return jn(n,{code:Jt.invalid_union,unionErrors:i}),Dr}if(n.common.async)return Promise.all(r.map(async a=>{const i={...n,common:{...n.common,issues:[]},parent:null};return{result:await a._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const c of r){const u={...n,common:{...n.common,issues:[]},parent:null},d=c._parseSync({data:n.data,path:n.path,parent:u});if(d.status==="valid")return d;d.status==="dirty"&&!a&&(a={result:d,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return n.common.issues.push(...a.ctx.common.issues),a.result;const l=i.map(c=>new zw(c));return jn(n,{code:Jt.invalid_union,unionErrors:l}),Dr}}get options(){return this._def.options}};iP.create=(e,t)=>new iP({options:e,typeName:Ve.ZodUnion,...ks(t)});function rde(e,t){const n=Ib(e),r=Ib(t);if(e===t)return{valid:!0,data:e};if(n===Vn.object&&r===Vn.object){const s=ca.objectKeys(t),a=ca.objectKeys(e).filter(l=>s.indexOf(l)!==-1),i={...e,...t};for(const l of a){const c=rde(e[l],t[l]);if(!c.valid)return{valid:!1};i[l]=c.data}return{valid:!0,data:i}}else if(n===Vn.array&&r===Vn.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let a=0;a<e.length;a++){const i=e[a],l=t[a],c=rde(i,l);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===Vn.date&&r===Vn.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}let oP=class extends Bs{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=(a,i)=>{if(Uue(a)||Uue(i))return Dr;const l=rde(a.value,i.value);return l.valid?((que(a)||que(i))&&n.dirty(),{status:n.value,value:l.data}):(jn(r,{code:Jt.invalid_intersection_types}),Dr)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};oP.create=(e,t,n)=>new oP({left:e,right:t,typeName:Ve.ZodIntersection,...ks(n)});let Mj=class vrt extends Bs{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Vn.array)return jn(r,{code:Jt.invalid_type,expected:Vn.array,received:r.parsedType}),Dr;if(r.data.length<this._def.items.length)return jn(r,{code:Jt.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Dr;!this._def.rest&&r.data.length>this._def.items.length&&(jn(r,{code:Jt.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const a=[...r.data].map((i,l)=>{const c=this._def.items[l]||this._def.rest;return c?c._parse(new Bw(r,i,r.path,l)):null}).filter(i=>!!i);return r.common.async?Promise.all(a).then(i=>Qh.mergeArray(n,i)):Qh.mergeArray(n,a)}get items(){return this._def.items}rest(t){return new vrt({...this._def,rest:t})}};Mj.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Mj({items:e,typeName:Ve.ZodTuple,rest:null,...ks(t)})};let sde=class extends Bs{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Vn.map)return jn(r,{code:Jt.invalid_type,expected:Vn.map,received:r.parsedType}),Dr;const s=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([l,c],u)=>({key:s._parse(new Bw(r,l,r.path,[u,"key"])),value:a._parse(new Bw(r,c,r.path,[u,"value"]))}));if(r.common.async){const l=new Map;return Promise.resolve().then(async()=>{for(const c of i){const u=await c.key,d=await c.value;if(u.status==="aborted"||d.status==="aborted")return Dr;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),l.set(u.value,d.value)}return{status:n.value,value:l}})}else{const l=new Map;for(const c of i){const u=c.key,d=c.value;if(u.status==="aborted"||d.status==="aborted")return Dr;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),l.set(u.value,d.value)}return{status:n.value,value:l}}}};sde.create=(e,t,n)=>new sde({valueType:t,keyType:e,typeName:Ve.ZodMap,...ks(n)});let ade=class ide extends Bs{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==Vn.set)return jn(r,{code:Jt.invalid_type,expected:Vn.set,received:r.parsedType}),Dr;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(jn(r,{code:Jt.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(jn(r,{code:Jt.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const a=this._def.valueType;function i(c){const u=new Set;for(const d of c){if(d.status==="aborted")return Dr;d.status==="dirty"&&n.dirty(),u.add(d.value)}return{status:n.value,value:u}}const l=[...r.data.values()].map((c,u)=>a._parse(new Bw(r,c,r.path,u)));return r.common.async?Promise.all(l).then(c=>i(c)):i(l)}min(t,n){return new ide({...this._def,minSize:{value:t,message:Yn.toString(n)}})}max(t,n){return new ide({...this._def,maxSize:{value:t,message:Yn.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}};ade.create=(e,t)=>new ade({valueType:e,minSize:null,maxSize:null,typeName:Ve.ZodSet,...ks(t)});let ode=class extends Bs{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};ode.create=(e,t)=>new ode({getter:e,typeName:Ve.ZodLazy,...ks(t)});let lde=class extends Bs{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return jn(n,{received:n.data,code:Jt.invalid_literal,expected:this._def.value}),Dr}return{status:"valid",value:t.data}}get value(){return this._def.value}};lde.create=(e,t)=>new lde({value:e,typeName:Ve.ZodLiteral,...ks(t)});function yrt(e,t){return new TU({values:e,typeName:Ve.ZodEnum,...ks(t)})}let TU=class cde extends Bs{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return jn(n,{expected:ca.joinValues(r),received:n.parsedType,code:Jt.invalid_type}),Dr}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return jn(n,{received:n.data,code:Jt.invalid_enum_value,options:r}),Dr}return Bp(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return cde.create(t,{...this._def,...n})}exclude(t,n=this._def){return cde.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}};TU.create=yrt;let ude=class extends Bs{_parse(t){const n=ca.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==Vn.string&&r.parsedType!==Vn.number){const s=ca.objectValues(n);return jn(r,{expected:ca.joinValues(s),received:r.parsedType,code:Jt.invalid_type}),Dr}if(this._cache||(this._cache=new Set(ca.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const s=ca.objectValues(n);return jn(r,{received:r.data,code:Jt.invalid_enum_value,options:s}),Dr}return Bp(t.data)}get enum(){return this._def.values}};ude.create=(e,t)=>new ude({values:e,typeName:Ve.ZodNativeEnum,...ks(t)});let lP=class extends Bs{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Vn.promise&&n.common.async===!1)return jn(n,{code:Jt.invalid_type,expected:Vn.promise,received:n.parsedType}),Dr;const r=n.parsedType===Vn.promise?n.data:Promise.resolve(n.data);return Bp(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};lP.create=(e,t)=>new lP({type:e,typeName:Ve.ZodPromise,...ks(t)});let Uw=class extends Bs{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ve.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),s=this._def.effect||null,a={addIssue:i=>{jn(r,i),i.fatal?n.abort():n.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(r.data,a);if(r.common.async)return Promise.resolve(i).then(async l=>{if(n.value==="aborted")return Dr;const c=await this._def.schema._parseAsync({data:l,path:r.path,parent:r});return c.status==="aborted"?Dr:c.status==="dirty"||n.value==="dirty"?_E(c.value):c});{if(n.value==="aborted")return Dr;const l=this._def.schema._parseSync({data:i,path:r.path,parent:r});return l.status==="aborted"?Dr:l.status==="dirty"||n.value==="dirty"?_E(l.value):l}}if(s.type==="refinement"){const i=l=>{const c=s.refinement(l,a);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l};if(r.common.async===!1){const l=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return l.status==="aborted"?Dr:(l.status==="dirty"&&n.dirty(),i(l.value),{status:n.value,value:l.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(l=>l.status==="aborted"?Dr:(l.status==="dirty"&&n.dirty(),i(l.value).then(()=>({status:n.value,value:l.value}))))}if(s.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Gk(i))return Dr;const l=s.transform(i.value,a);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:l}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>Gk(i)?Promise.resolve(s.transform(i.value,a)).then(l=>({status:n.value,value:l})):Dr);ca.assertNever(s)}};Uw.create=(e,t,n)=>new Uw({schema:e,typeName:Ve.ZodEffects,effect:t,...ks(n)});Uw.createWithPreprocess=(e,t,n)=>new Uw({schema:t,effect:{type:"preprocess",transform:e},typeName:Ve.ZodEffects,...ks(n)});let Yb=class extends Bs{_parse(t){return this._getType(t)===Vn.undefined?Bp(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Yb.create=(e,t)=>new Yb({innerType:e,typeName:Ve.ZodOptional,...ks(t)});let Yk=class extends Bs{_parse(t){return this._getType(t)===Vn.null?Bp(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Yk.create=(e,t)=>new Yk({innerType:e,typeName:Ve.ZodNullable,...ks(t)});let yF=class extends Bs{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===Vn.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};yF.create=(e,t)=>new yF({innerType:e,typeName:Ve.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ks(t)});let bF=class extends Bs{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return aP(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new zw(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new zw(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};bF.create=(e,t)=>new bF({innerType:e,typeName:Ve.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ks(t)});let dde=class extends Bs{_parse(t){if(this._getType(t)!==Vn.nan){const r=this._getOrReturnCtx(t);return jn(r,{code:Jt.invalid_type,expected:Vn.nan,received:r.parsedType}),Dr}return{status:"valid",value:t.data}}};dde.create=e=>new dde({typeName:Ve.ZodNaN,...ks(e)});let brt=class extends Bs{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},xrt=class wrt extends Bs{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Dr:a.status==="dirty"?(n.dirty(),_E(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Dr:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(t,n){return new wrt({in:t,out:n,typeName:Ve.ZodPipeline})}},xF=class extends Bs{_parse(t){const n=this._def.innerType._parse(t),r=s=>(Gk(s)&&(s.value=Object.freeze(s.value)),s);return aP(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};xF.create=(e,t)=>new xF({innerType:e,typeName:Ve.ZodReadonly,...ks(t)});var Ve;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Ve||(Ve={}));lx.create;Qk.create;iP.create;oP.create;Mj.create;TU.create;lP.create;Yb.create;Yk.create;const V7t=Object.freeze(Object.defineProperty({__proto__:null,DIRTY:_E,INVALID:Dr,OK:Bp,ParseStatus:Qh,Schema:Bs,ZodAny:ede,ZodArray:Qk,ZodBigInt:Zue,ZodBoolean:Que,ZodBranded:brt,ZodCatch:bF,ZodDate:Yue,ZodDefault:yF,ZodEffects:Uw,ZodEnum:TU,ZodError:zw,get ZodFirstPartyTypeKind(){return Ve},ZodIntersection:oP,ZodIssueCode:Jt,ZodLazy:ode,ZodLiteral:lde,ZodMap:sde,ZodNaN:dde,ZodNativeEnum:ude,ZodNever:lx,ZodNull:Jue,ZodNullable:Yk,ZodNumber:Hue,ZodObject:cx,ZodOptional:Yb,ZodParsedType:Vn,ZodPipeline:xrt,ZodPromise:lP,ZodReadonly:xF,ZodSchema:Bs,ZodSet:ade,ZodString:Vue,ZodSymbol:Xue,ZodTransformer:Uw,ZodTuple:Mj,ZodType:Bs,ZodUndefined:Kue,ZodUnion:iP,ZodUnknown:tde,ZodVoid:nde,addIssueToContext:jn,datetimeRegex:mrt,defaultErrorMap:vF,getErrorMap:urt,getParsedType:Ib,isAborted:Uue,isAsync:aP,isDirty:que,isValid:Gk,makeIssue:drt,get objectUtil(){return Bue},get util(){return ca}},Symbol.toStringTag,{value:"Module"}));function uf(e){if(e.target!=="openAi")return{};const t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?lrt(t,e.currentPath):t.join("/")}}function H7t(e,t){const n={type:"array"};return e.type?._def&&e.type?._def?.typeName!==Ve.ZodAny&&(n.items=Aa(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&Za(n,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Za(n,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Za(n,"minItems",e.exactLength.value,e.exactLength.message,t),Za(n,"maxItems",e.exactLength.value,e.exactLength.message,t)),n}function W7t(e,t){const n={type:"integer",format:"int64"};if(!e.checks)return n;for(const r of e.checks)switch(r.kind){case"min":t.target==="jsonSchema7"?r.inclusive?Za(n,"minimum",r.value,r.message,t):Za(n,"exclusiveMinimum",r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),Za(n,"minimum",r.value,r.message,t));break;case"max":t.target==="jsonSchema7"?r.inclusive?Za(n,"maximum",r.value,r.message,t):Za(n,"exclusiveMaximum",r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),Za(n,"maximum",r.value,r.message,t));break;case"multipleOf":Za(n,"multipleOf",r.value,r.message,t);break}return n}function Z7t(){return{type:"boolean"}}function Srt(e,t){return Aa(e.type._def,t)}const G7t=(e,t)=>Aa(e.innerType._def,t);function krt(e,t,n){const r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((s,a)=>krt(e,t,s))};switch(r){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Q7t(e,t)}}const Q7t=(e,t)=>{const n={type:"integer",format:"unix-time"};if(t.target==="openApi3")return n;for(const r of e.checks)switch(r.kind){case"min":Za(n,"minimum",r.value,r.message,t);break;case"max":Za(n,"maximum",r.value,r.message,t);break}return n};function Y7t(e,t){return{...Aa(e.innerType._def,t),default:e.defaultValue()}}function X7t(e,t){return t.effectStrategy==="input"?Aa(e.schema._def,t):uf(t)}function K7t(e){return{type:"string",enum:Array.from(e.values)}}const J7t=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function eBt(e,t){const n=[Aa(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),Aa(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(a=>!!a);let r=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0;const s=[];return n.forEach(a=>{if(J7t(a))s.push(...a.allOf),a.unevaluatedProperties===void 0&&(r=void 0);else{let i=a;if("additionalProperties"in a&&a.additionalProperties===!1){const{additionalProperties:l,...c}=a;i=c}else r=void 0;s.push(i)}}),s.length?{allOf:s,...r}:void 0}function tBt(e,t){const n=typeof e.value;return n!=="bigint"&&n!=="number"&&n!=="boolean"&&n!=="string"?{type:Array.isArray(e.value)?"array":"object"}:t.target==="openApi3"?{type:n==="bigint"?"integer":n,enum:[e.value]}:{type:n==="bigint"?"integer":n,const:e.value}}let rY;const $m={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(rY===void 0&&(rY=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),rY),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Ort(e,t){const n={type:"string"};if(e.checks)for(const r of e.checks)switch(r.kind){case"min":Za(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,r.message,t);break;case"max":Za(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case"email":switch(t.emailStrategy){case"format:email":Mm(n,"email",r.message,t);break;case"format:idn-email":Mm(n,"idn-email",r.message,t);break;case"pattern:zod":Wu(n,$m.email,r.message,t);break}break;case"url":Mm(n,"uri",r.message,t);break;case"uuid":Mm(n,"uuid",r.message,t);break;case"regex":Wu(n,r.regex,r.message,t);break;case"cuid":Wu(n,$m.cuid,r.message,t);break;case"cuid2":Wu(n,$m.cuid2,r.message,t);break;case"startsWith":Wu(n,RegExp(`^${sY(r.value,t)}`),r.message,t);break;case"endsWith":Wu(n,RegExp(`${sY(r.value,t)}$`),r.message,t);break;case"datetime":Mm(n,"date-time",r.message,t);break;case"date":Mm(n,"date",r.message,t);break;case"time":Mm(n,"time",r.message,t);break;case"duration":Mm(n,"duration",r.message,t);break;case"length":Za(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,r.value):r.value,r.message,t),Za(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case"includes":{Wu(n,RegExp(sY(r.value,t)),r.message,t);break}case"ip":{r.version!=="v6"&&Mm(n,"ipv4",r.message,t),r.version!=="v4"&&Mm(n,"ipv6",r.message,t);break}case"base64url":Wu(n,$m.base64url,r.message,t);break;case"jwt":Wu(n,$m.jwt,r.message,t);break;case"cidr":{r.version!=="v6"&&Wu(n,$m.ipv4Cidr,r.message,t),r.version!=="v4"&&Wu(n,$m.ipv6Cidr,r.message,t);break}case"emoji":Wu(n,$m.emoji(),r.message,t);break;case"ulid":{Wu(n,$m.ulid,r.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{Mm(n,"binary",r.message,t);break}case"contentEncoding:base64":{Za(n,"contentEncoding","base64",r.message,t);break}case"pattern:zod":{Wu(n,$m.base64,r.message,t);break}}break}case"nanoid":Wu(n,$m.nanoid,r.message,t)}return n}function sY(e,t){return t.patternStrategy==="escape"?rBt(e):e}const nBt=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function rBt(e){let t="";for(let n=0;n<e.length;n++)nBt.has(e[n])||(t+="\\"),t+=e[n];return t}function Mm(e,t,n,r){e.format||e.anyOf?.some(s=>s.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&r.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):Za(e,"format",t,n,r)}function Wu(e,t,n,r){e.pattern||e.allOf?.some(s=>s.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&r.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:RRe(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):Za(e,"pattern",RRe(t,r),n,r)}function RRe(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;const n={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},r=n.i?e.source.toLowerCase():e.source;let s="",a=!1,i=!1,l=!1;for(let c=0;c<r.length;c++){if(a){s+=r[c],a=!1;continue}if(n.i){if(i){if(r[c].match(/[a-z]/)){l?(s+=r[c],s+=`${r[c-2]}-${r[c]}`.toUpperCase(),l=!1):r[c+1]==="-"&&r[c+2]?.match(/[a-z]/)?(s+=r[c],l=!0):s+=`${r[c]}${r[c].toUpperCase()}`;continue}}else if(r[c].match(/[a-z]/)){s+=`[${r[c]}${r[c].toUpperCase()}]`;continue}}if(n.m){if(r[c]==="^"){s+=`(^|(?<=[\r
|
|
13
13
|
]))`;continue}else if(r[c]==="$"){s+=`($|(?=[\r
|
|
@@ -333,7 +333,7 @@ attempted value: ${i}
|
|
|
333
333
|
\${}
|
|
334
334
|
}
|
|
335
335
|
}`,{label:"class",detail:"definition",type:"keyword"}),Md('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Md('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],Myt=$we.concat([Md("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Md("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Md("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),LLe=new zmt,Dyt=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function zA(e){return(t,n)=>{let r=t.node.getChild("VariableDefinition");return r&&n(r,e),!0}}const G6n=["FunctionDeclaration"],Q6n={FunctionDeclaration:zA("function"),ClassDeclaration:zA("class"),ClassExpression:()=>!0,EnumDeclaration:zA("constant"),TypeAliasDeclaration:zA("type"),NamespaceDeclaration:zA("namespace"),VariableDefinition(e,t){e.matchContext(G6n)||t(e,"variable")},TypeDefinition(e,t){t(e,"type")},__proto__:null};function Lyt(e,t){let n=LLe.get(t);if(n)return n;let r=[],s=!0;function a(i,l){let c=e.sliceString(i.from,i.to);r.push({label:c,type:l})}return t.cursor(La.IncludeAnonymous).iterate(i=>{if(s)s=!1;else if(i.name){let l=Q6n[i.name];if(l&&l(i,a)||Dyt.has(i.name))return!1}else if(i.to-i.from>8192){for(let l of Lyt(e,i.node))r.push(l);return!1}}),LLe.set(t,r),r}const i7=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,Mwe=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function Fyt(e){let t=fi(e.state).resolveInner(e.pos,-1);if(Mwe.indexOf(t.name)>-1)return null;let n=t.name=="VariableName"||t.to-t.from<20&&i7.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let r=[];for(let s=t;s;s=s.parent)Dyt.has(s.name)&&(r=r.concat(Lyt(e.state.doc,s)));return{options:r,from:n?t.from:e.pos,validFor:i7}}function SK(e,t,n){var r;let s=[];for(;;){let a=t.firstChild,i;if(a?.name=="VariableName")return s.push(e(a)),{path:s.reverse(),name:n};if(a?.name=="MemberExpression"&&((r=i=a.lastChild)===null||r===void 0?void 0:r.name)=="PropertyName")s.push(e(i)),t=a;else return null}}function zyt(e){let t=r=>e.state.doc.sliceString(r.from,r.to),n=fi(e.state).resolveInner(e.pos,-1);return n.name=="PropertyName"?SK(t,n.parent,t(n)):(n.name=="."||n.name=="?.")&&n.parent.name=="MemberExpression"?SK(t,n.parent,""):Mwe.indexOf(n.name)>-1?null:n.name=="VariableName"||n.to-n.from<20&&i7.test(t(n))?{path:[],name:t(n)}:n.name=="MemberExpression"?SK(t,n,""):e.explicit?{path:[],name:""}:null}function Y6n(e,t){let n=e,r=[],s=new Set;for(let a=0;;a++){for(let l of(Object.getOwnPropertyNames||Object.keys)(e)){if(!/^[a-zA-Z_$\xaa-\uffdc][\w$\xaa-\uffdc]*$/.test(l)||s.has(l))continue;s.add(l);let c;try{c=n[l]}catch{continue}r.push({label:l,type:typeof c=="function"?/^[A-Z]/.test(l)?"class":t?"function":"method":t?"variable":"property",boost:-a})}let i=Object.getPrototypeOf(e);if(!i)return r;e=i}}function X6n(e){let t=new Map;return n=>{let r=zyt(n);if(!r)return null;let s=e;for(let i of r.path)if(s=s[i],!s)return null;let a=t.get(s);return a||t.set(s,a=Y6n(s,!r.path.length)),{from:n.pos-r.name.length,options:a,validFor:i7}}}const qh=wO.define({name:"javascript",parser:Z6n.configure({props:[k_.add({IfStatement:gj({except:/^\s*({|else\b)/}),TryStatement:gj({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:HDn,SwitchBody:e=>{let t=e.textAfter,n=/^\s*\}/.test(t),r=/^\s*(case|default)\b/.test(t);return e.baseIndent+(n?0:r?1:2)*e.unit},Block:VDn({closing:"}"}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":gj({except:/^\s*{/}),JSXElement(e){let t=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},JSXEscape(e){let t=/\s*\}/.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},"JSXOpenTag JSXSelfClosingTag"(e){return e.column(e.node.from)+e.unit}}),O_.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":mwe,BlockComment(e){return{from:e.from+2,to:e.to-2}},JSXElement(e){let t=e.firstChild;if(!t||t.name=="JSXSelfClosingTag")return null;let n=e.lastChild;return{from:t.to,to:n.type.isError?e.to:n.from}},"JSXSelfClosingTag JSXOpenTag"(e){var t;let n=(t=e.firstChild)===null||t===void 0?void 0:t.nextSibling,r=e.lastChild;return!n||n.type.isError?null:{from:n.to,to:r.type.isError?e.to:r.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),Byt={test:e=>/^JSX/.test(e.name),facet:iV({commentTokens:{block:{open:"{/*",close:"*/}"}}})},Dwe=qh.configure({dialect:"ts"},"typescript"),Lwe=qh.configure({dialect:"jsx",props:[fwe.add(e=>e.isTop?[Byt]:void 0)]}),Fwe=qh.configure({dialect:"jsx ts",props:[fwe.add(e=>e.isTop?[Byt]:void 0)]},"typescript");let Uyt=e=>({label:e,type:"keyword"});const qyt="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(Uyt),K6n=qyt.concat(["declare","implements","private","protected","public"].map(Uyt));function o7(e={}){let t=e.jsx?e.typescript?Fwe:Lwe:e.typescript?Dwe:qh,n=e.typescript?Myt.concat(K6n):$we.concat(qyt);return new kO(t,[qh.data.of({autocomplete:N4n(Mwe,Bvt(n))}),qh.data.of({autocomplete:Fyt}),e.jsx?Vyt:[]])}function J6n(e){for(;;){if(e.name=="JSXOpenTag"||e.name=="JSXSelfClosingTag"||e.name=="JSXFragmentTag")return e;if(e.name=="JSXEscape"||!e.parent)return null;e=e.parent}}function FLe(e,t,n=e.length){for(let r=t?.firstChild;r;r=r.nextSibling)if(r.name=="JSXIdentifier"||r.name=="JSXBuiltin"||r.name=="JSXNamespacedName"||r.name=="JSXMemberExpression")return e.sliceString(r.from,Math.min(r.to,n));return""}const e8n=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Vyt=It.inputHandler.of((e,t,n,r,s)=>{if((e8n?e.composing:e.compositionStarted)||e.state.readOnly||t!=n||r!=">"&&r!="/"||!qh.isActiveAt(e.state,t,-1))return!1;let a=s(),{state:i}=a,l=i.changeByRange(c=>{var u;let{head:d}=c,f=fi(i).resolveInner(d-1,-1),p;if(f.name=="JSXStartTag"&&(f=f.parent),!(i.doc.sliceString(d-1,d)!=r||f.name=="JSXAttributeValue"&&f.to>d)){if(r==">"&&f.name=="JSXFragmentTag")return{range:c,changes:{from:d,insert:"</>"}};if(r=="/"&&f.name=="JSXStartCloseTag"){let h=f.parent,m=h.parent;if(m&&h.from==d-2&&((p=FLe(i.doc,m.firstChild,d))||((u=m.firstChild)===null||u===void 0?void 0:u.name)=="JSXFragmentTag")){let g=`${p}>`;return{range:vt.cursor(d+g.length,-1),changes:{from:d,insert:g}}}}else if(r==">"){let h=J6n(f);if(h&&h.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(i.doc.sliceString(d,d+2))&&(p=FLe(i.doc,h,d)))return{range:c,changes:{from:d,insert:`</${p}>`}}}}return{range:c}});return l.changes.empty?!1:(e.dispatch([a,i.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});function t8n(e,t){return t||(t={parserOptions:{ecmaVersion:2019,sourceType:"module"},env:{browser:!0,node:!0,es6:!0,es2015:!0,es2017:!0,es2020:!0},rules:{}},e.getRules().forEach((n,r)=>{var s;!((s=n.meta.docs)===null||s===void 0)&&s.recommended&&(t.rules[r]=2)})),n=>{let{state:r}=n,s=[];for(let{from:a,to:i}of qh.findRegions(r)){let l=r.doc.lineAt(a),c={line:l.number-1,col:a-l.from,pos:a};for(let u of e.verify(r.sliceDoc(a,i),t))s.push(n8n(u,r.doc,c))}return s}}function zLe(e,t,n,r){return n.line(e+r.line).from+t+(e==1?r.col-1:-1)}function n8n(e,t,n){let r=zLe(e.line,e.column,t,n),s={from:r,to:e.endLine!=null&&e.endColumn!=1?zLe(e.endLine,e.endColumn,t,n):r,message:e.message,source:e.ruleId?"eslint:"+e.ruleId:"eslint",severity:e.severity==1?"warning":"error"};if(e.fix){let{range:a,text:i}=e.fix,l=a[0]+n.pos-r,c=a[1]+n.pos-r;s.actions=[{name:"fix",apply(u,d){u.dispatch({changes:{from:d+l,to:d+c,insert:i},scrollIntoView:!0})}}]}return s}const c6=Object.freeze(Object.defineProperty({__proto__:null,autoCloseTags:Vyt,completionPath:zyt,esLint:t8n,javascript:o7,javascriptLanguage:qh,jsxLanguage:Lwe,localCompletionSource:Fyt,scopeCompletionSource:X6n,snippets:$we,tsxLanguage:Fwe,typescriptLanguage:Dwe,typescriptSnippets:Myt},Symbol.toStringTag,{value:"Module"})),BA=["_blank","_self","_top","_parent"],kK=["ascii","utf-8","utf-16","latin1","latin1"],OK=["get","post","put","delete"],_K=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],Vf=["true","false"],Jn={},r8n={a:{attrs:{href:null,ping:null,type:null,media:null,target:BA,hreflang:null}},abbr:Jn,address:Jn,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:Jn,aside:Jn,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:Jn,base:{attrs:{href:null,target:BA}},bdi:Jn,bdo:Jn,blockquote:{attrs:{cite:null}},body:Jn,br:Jn,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:_K,formmethod:OK,formnovalidate:["novalidate"],formtarget:BA,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:Jn,center:Jn,cite:Jn,code:Jn,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:Jn,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:Jn,div:Jn,dl:Jn,dt:Jn,em:Jn,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:Jn,figure:Jn,footer:Jn,form:{attrs:{action:null,name:null,"accept-charset":kK,autocomplete:["on","off"],enctype:_K,method:OK,novalidate:["novalidate"],target:BA}},h1:Jn,h2:Jn,h3:Jn,h4:Jn,h5:Jn,h6:Jn,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:Jn,hgroup:Jn,hr:Jn,html:{attrs:{manifest:null}},i:Jn,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:_K,formmethod:OK,formnovalidate:["novalidate"],formtarget:BA,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:Jn,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:Jn,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:Jn,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:kK,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:Jn,noscript:Jn,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:Jn,param:{attrs:{name:null,value:null}},pre:Jn,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:Jn,rt:Jn,ruby:Jn,samp:Jn,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:kK}},section:Jn,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:Jn,source:{attrs:{src:null,type:null,media:null}},span:Jn,strong:Jn,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:Jn,summary:Jn,sup:Jn,table:Jn,tbody:Jn,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:Jn,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:Jn,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:Jn,time:{attrs:{datetime:null}},title:Jn,tr:Jn,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:Jn,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:Jn},Hyt={accesskey:null,class:null,contenteditable:Vf,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:Vf,autocorrect:Vf,autocapitalize:Vf,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":Vf,"aria-autocomplete":["inline","list","both","none"],"aria-busy":Vf,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":Vf,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":Vf,"aria-hidden":Vf,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":Vf,"aria-multiselectable":Vf,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":Vf,"aria-relevant":null,"aria-required":Vf,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},Wyt="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(e=>"on"+e);for(let e of Wyt)Hyt[e]=null;class q${constructor(t,n){this.tags={...r8n,...t},this.globalAttrs={...Hyt,...n},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}}q$.default=new q$;function dT(e,t,n=e.length){if(!t)return"";let r=t.firstChild,s=r&&r.getChild("TagName");return s?e.sliceString(s.from,Math.min(s.to,n)):""}function fT(e,t=!1){for(;e;e=e.parent)if(e.name=="Element")if(t)t=!1;else return e;return null}function Zyt(e,t,n){let r=n.tags[dT(e,fT(t))];return r?.children||n.allTags}function zwe(e,t){let n=[];for(let r=fT(t);r&&!r.type.isTop;r=fT(r.parent)){let s=dT(e,r);if(s&&r.lastChild.name=="CloseTag")break;s&&n.indexOf(s)<0&&(t.name=="EndTag"||t.from>=r.firstChild.to)&&n.push(s)}return n}const Gyt=/^[:\-\.\w\u00b7-\uffff]*$/;function BLe(e,t,n,r,s){let a=/\s*>/.test(e.sliceDoc(s,s+5))?"":">",i=fT(n,n.name=="StartTag"||n.name=="TagName");return{from:r,to:s,options:Zyt(e.doc,i,t).map(l=>({label:l,type:"type"})).concat(zwe(e.doc,n).map((l,c)=>({label:"/"+l,apply:"/"+l+a,type:"type",boost:99-c}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function ULe(e,t,n,r){let s=/\s*>/.test(e.sliceDoc(r,r+5))?"":">";return{from:n,to:r,options:zwe(e.doc,t).map((a,i)=>({label:a,apply:a+s,type:"type",boost:99-i})),validFor:Gyt}}function s8n(e,t,n,r){let s=[],a=0;for(let i of Zyt(e.doc,n,t))s.push({label:"<"+i,type:"type"});for(let i of zwe(e.doc,n))s.push({label:"</"+i+">",type:"type",boost:99-a++});return{from:r,to:r,options:s,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function a8n(e,t,n,r,s){let a=fT(n),i=a?t.tags[dT(e.doc,a)]:null,l=i&&i.attrs?Object.keys(i.attrs):[],c=i&&i.globalAttrs===!1?l:l.length?l.concat(t.globalAttrNames):t.globalAttrNames;return{from:r,to:s,options:c.map(u=>({label:u,type:"property"})),validFor:Gyt}}function i8n(e,t,n,r,s){var a;let i=(a=n.parent)===null||a===void 0?void 0:a.getChild("AttributeName"),l=[],c;if(i){let u=e.sliceDoc(i.from,i.to),d=t.globalAttrs[u];if(!d){let f=fT(n),p=f?t.tags[dT(e.doc,f)]:null;d=p?.attrs&&p.attrs[u]}if(d){let f=e.sliceDoc(r,s).toLowerCase(),p='"',h='"';/^['"]/.test(f)?(c=f[0]=='"'?/^[^"]*$/:/^[^']*$/,p="",h=e.sliceDoc(s,s+1)==f[0]?"":f[0],f=f.slice(1),r++):c=/^[^\s<>='"]*$/;for(let m of d)l.push({label:m,apply:p+m+h,type:"constant"})}}return{from:r,to:s,options:l,validFor:c}}function Qyt(e,t){let{state:n,pos:r}=t,s=fi(n).resolveInner(r,-1),a=s.resolve(r);for(let i=r,l;a==s&&(l=s.childBefore(i));){let c=l.lastChild;if(!c||!c.type.isError||c.from<c.to)break;a=s=l,i=c.from}return s.name=="TagName"?s.parent&&/CloseTag$/.test(s.parent.name)?ULe(n,s,s.from,r):BLe(n,e,s,s.from,r):s.name=="StartTag"||s.name=="IncompleteTag"?BLe(n,e,s,r,r):s.name=="StartCloseTag"||s.name=="IncompleteCloseTag"?ULe(n,s,r,r):s.name=="OpenTag"||s.name=="SelfClosingTag"||s.name=="AttributeName"?a8n(n,e,s,s.name=="AttributeName"?s.from:r,r):s.name=="Is"||s.name=="AttributeValue"||s.name=="UnquotedAttributeValue"?i8n(n,e,s,s.name=="Is"?r:s.from,r):t.explicit&&(a.name=="Element"||a.name=="Text"||a.name=="Document")?s8n(n,e,s,r):null}function o8n(e){return Qyt(q$.default,e)}function l8n(e){let{extraTags:t,extraGlobalAttributes:n}=e,r=n||t?new q$(t,n):q$.default;return s=>Qyt(r,s)}const c8n=qh.parser.configure({top:"SingleExpression"}),Yyt=[{tag:"script",attrs:e=>e.type=="text/typescript"||e.lang=="ts",parser:Dwe.parser},{tag:"script",attrs:e=>e.type=="text/babel"||e.type=="text/jsx",parser:Lwe.parser},{tag:"script",attrs:e=>e.type=="text/typescript-jsx",parser:Fwe.parser},{tag:"script",attrs(e){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(e.type)},parser:c8n},{tag:"script",attrs(e){return!e.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(e.type)},parser:qh.parser},{tag:"style",attrs(e){return(!e.lang||e.lang=="css")&&(!e.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(e.type))},parser:a7.parser}],Xyt=[{name:"style",parser:a7.parser.configure({top:"Styles"})}].concat(Wyt.map(e=>({name:e,parser:qh.parser}))),Kyt=wO.define({name:"html",parser:PLn.configure({props:[k_.add({Element(e){let t=/^(\s*)(<\/)?/.exec(e.textAfter);return e.node.to<=e.pos+t[0].length?e.continue():e.lineIndent(e.node.from)+(t[2]?0:e.unit)},"OpenTag CloseTag SelfClosingTag"(e){return e.column(e.node.from)+e.unit},Document(e){if(e.pos+/\s*/.exec(e.textAfter)[0].length<e.node.to)return e.continue();let t=null,n;for(let r=e.node;;){let s=r.lastChild;if(!s||s.name!="Element"||s.to!=r.to)break;t=r=s}return t&&!((n=t.lastChild)&&(n.name=="CloseTag"||n.name=="SelfClosingTag"))?e.lineIndent(t.from)+e.unit:null}}),O_.add({Element(e){let t=e.firstChild,n=e.lastChild;return!t||t.name!="OpenTag"?null:{from:t.to,to:n.name=="CloseTag"?n.from:e.to}}}),Pvt.add({"OpenTag CloseTag":e=>e.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),$9=Kyt.configure({wrap:Tyt(Yyt,Xyt)});function u8n(e={}){let t="",n;e.matchClosingTags===!1&&(t="noMatch"),e.selfClosingTags===!0&&(t=(t?t+" ":"")+"selfClosing"),(e.nestedLanguages&&e.nestedLanguages.length||e.nestedAttributes&&e.nestedAttributes.length)&&(n=Tyt((e.nestedLanguages||[]).concat(Yyt),(e.nestedAttributes||[]).concat(Xyt)));let r=n?Kyt.configure({wrap:n,dialect:t}):t?$9.configure({dialect:t}):$9;return new kO(r,[$9.data.of({autocomplete:l8n(e)}),e.autoCloseTags!==!1?d8n:[],o7().support,g6n().support])}const qLe=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),d8n=It.inputHandler.of((e,t,n,r,s)=>{if(e.composing||e.state.readOnly||t!=n||r!=">"&&r!="/"||!$9.isActiveAt(e.state,t,-1))return!1;let a=s(),{state:i}=a,l=i.changeByRange(c=>{var u,d,f;let p=i.doc.sliceString(c.from-1,c.to)==r,{head:h}=c,m=fi(i).resolveInner(h,-1),g;if(p&&r==">"&&m.name=="EndTag"){let y=m.parent;if(((d=(u=y.parent)===null||u===void 0?void 0:u.lastChild)===null||d===void 0?void 0:d.name)!="CloseTag"&&(g=dT(i.doc,y.parent,h))&&!qLe.has(g)){let b=h+(i.doc.sliceString(h,h+1)===">"?1:0),w=`</${g}>`;return{range:c,changes:{from:h,to:b,insert:w}}}}else if(p&&r=="/"&&m.name=="IncompleteCloseTag"){let y=m.parent;if(m.from==h-2&&((f=y.lastChild)===null||f===void 0?void 0:f.name)!="CloseTag"&&(g=dT(i.doc,y,h))&&!qLe.has(g)){let b=h+(i.doc.sliceString(h,h+1)===">"?1:0),w=`${g}>`;return{range:vt.cursor(h+w.length,-1),changes:{from:h,to:b,insert:w}}}}return{range:c}});return l.changes.empty?!1:(e.dispatch([a,i.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),Jyt=iV({commentTokens:{block:{open:"<!--",close:"-->"}}}),ebt=new Rr,tbt=M5n.configure({props:[O_.add(e=>!e.is("Block")||e.is("Document")||ehe(e)!=null||f8n(e)?void 0:(t,n)=>({from:n.doc.lineAt(t.from).to,to:t.to})),ebt.add(ehe),k_.add({Document:()=>null}),mw.add({Document:Jyt})]});function ehe(e){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(e.name);return t?+t[1]:void 0}function f8n(e){return e.name=="OrderedList"||e.name=="BulletList"}function p8n(e,t){let n=e;for(;;){let r=n.nextSibling,s;if(!r||(s=ehe(r.type))!=null&&s<=t)break;n=r}return n.to}const h8n=Svt.of((e,t,n)=>{for(let r=fi(e).resolveInner(n,-1);r&&!(r.from<t);r=r.parent){let s=r.type.prop(ebt);if(s==null)continue;let a=p8n(r,s);if(a>n)return{from:n,to:a}}return null});function Bwe(e){return new mp(Jyt,e,[],"markdown")}const nbt=Bwe(tbt),m8n=tbt.configure([Z5n,Q5n,G5n,Y5n,{props:[O_.add({Table:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}]),CO=Bwe(m8n);function g8n(e,t){return n=>{if(n&&e){let r=null;if(n=/\S*/.exec(n)[0],typeof e=="function"?r=e(n):r=Ym.matchLanguageName(e,n,!0),r instanceof Ym)return r.support?r.support.language.parser:SO.getSkippingParser(r.load());if(r)return r.parser}return t?t.parser:null}}class CK{constructor(t,n,r,s,a,i,l){this.node=t,this.from=n,this.to=r,this.spaceBefore=s,this.spaceAfter=a,this.type=i,this.item=l}blank(t,n=!0){let r=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(t!=null){for(;r.length<t;)r+=" ";return r}else{for(let s=this.to-this.from-r.length-this.spaceAfter.length;s>0;s--)r+=" ";return r+(n?this.spaceAfter:"")}}marker(t,n){let r=this.node.name=="OrderedList"?String(+sbt(this.item,t)[2]+n):"";return this.spaceBefore+r+this.type+this.spaceAfter}}function rbt(e,t){let n=[],r=[];for(let s=e;s;s=s.parent){if(s.name=="FencedCode")return r;(s.name=="ListItem"||s.name=="Blockquote")&&n.push(s)}for(let s=n.length-1;s>=0;s--){let a=n[s],i,l=t.lineAt(a.from),c=a.from-l.from;if(a.name=="Blockquote"&&(i=/^ *>( ?)/.exec(l.text.slice(c))))r.push(new CK(a,c,c+i[0].length,"",i[1],">",null));else if(a.name=="ListItem"&&a.parent.name=="OrderedList"&&(i=/^( *)\d+([.)])( *)/.exec(l.text.slice(c)))){let u=i[3],d=i[0].length;u.length>=4&&(u=u.slice(0,u.length-4),d-=4),r.push(new CK(a.parent,c,c+d,i[1],u,i[2],a))}else if(a.name=="ListItem"&&a.parent.name=="BulletList"&&(i=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(l.text.slice(c)))){let u=i[4],d=i[0].length;u.length>4&&(u=u.slice(0,u.length-4),d-=4);let f=i[2];i[3]&&(f+=i[3].replace(/[xX]/," ")),r.push(new CK(a.parent,c,c+d,i[1],u,f,a))}}return r}function sbt(e,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from,e.from+10))}function EK(e,t,n,r=0){for(let s=-1,a=e;;){if(a.name=="ListItem"){let l=sbt(a,t),c=+l[2];if(s>=0){if(c!=s+1)return;n.push({from:a.from+l[1].length,to:a.from+l[0].length,insert:String(s+2+r)})}s=c}let i=a.nextSibling;if(!i)break;a=i}}function Uwe(e,t){let n=/^[ \t]*/.exec(e)[0].length;if(!n||t.facet(RN)!=" ")return e;let r=_g(e,4,n),s="";for(let a=r;a>0;)a>=4?(s+=" ",a-=4):(s+=" ",a--);return s+e.slice(n)}const abt=(e={})=>({state:t,dispatch:n})=>{let r=fi(t),{doc:s}=t,a=null,i=t.changeByRange(l=>{if(!l.empty||!CO.isActiveAt(t,l.from,-1)&&!CO.isActiveAt(t,l.from,1))return a={range:l};let c=l.from,u=s.lineAt(c),d=rbt(r.resolveInner(c,-1),s);for(;d.length&&d[d.length-1].from>c-u.from;)d.pop();if(!d.length)return a={range:l};let f=d[d.length-1];if(f.to-f.spaceAfter.length>c-u.from)return a={range:l};let p=c>=f.to-f.spaceAfter.length&&!/\S/.test(u.text.slice(f.to));if(f.item&&p){let b=f.node.firstChild,w=f.node.getChild("ListItem","ListItem");if(b.to>=c||w&&w.to<c||u.from>0&&!/[^\s>]/.test(s.lineAt(u.from-1).text)||e.nonTightLists===!1){let S=d.length>1?d[d.length-2]:null,k,_="";S&&S.item?(k=u.from+S.from,_=S.marker(s,1)):k=u.from+(S?S.to:0);let C=[{from:k,to:c,insert:_}];return f.node.name=="OrderedList"&&EK(f.item,s,C,-2),S&&S.node.name=="OrderedList"&&EK(S.item,s,C),{range:vt.cursor(k+_.length),changes:C}}else{let S=HLe(d,t,u);return{range:vt.cursor(c+S.length+1),changes:{from:u.from,insert:S+t.lineBreak}}}}if(f.node.name=="Blockquote"&&p&&u.from){let b=s.lineAt(u.from-1),w=/>\s*$/.exec(b.text);if(w&&w.index==f.from){let S=t.changes([{from:b.from+w.index,to:b.to},{from:u.from+f.from,to:u.to}]);return{range:l.map(S),changes:S}}}let h=[];f.node.name=="OrderedList"&&EK(f.item,s,h);let m=f.item&&f.item.from<u.from,g="";if(!m||/^[\s\d.)\-+*>]*/.exec(u.text)[0].length>=f.to)for(let b=0,w=d.length-1;b<=w;b++)g+=b==w&&!m?d[b].marker(s,1):d[b].blank(b<w?_g(u.text,4,d[b+1].from)-g.length:null);let y=c;for(;y>u.from&&/\s/.test(u.text.charAt(y-u.from-1));)y--;return g=Uwe(g,t),v8n(f.node,t.doc)&&(g=HLe(d,t,u)+t.lineBreak+g),h.push({from:y,to:c,insert:t.lineBreak+g}),{range:vt.cursor(y+g.length+1),changes:h}});return a?!1:(n(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0)},ibt=abt();function VLe(e){return e.name=="QuoteMark"||e.name=="ListMark"}function v8n(e,t){if(e.name!="OrderedList"&&e.name!="BulletList")return!1;let n=e.firstChild,r=e.getChild("ListItem","ListItem");if(!r)return!1;let s=t.lineAt(n.to),a=t.lineAt(r.from),i=/^[\s>]*$/.test(s.text);return s.number+(i?0:1)<a.number}function HLe(e,t,n){let r="";for(let s=0,a=e.length-2;s<=a;s++)r+=e[s].blank(s<a?_g(n.text,4,e[s+1].from)-r.length:null,s<a);return Uwe(r,t)}function y8n(e,t){let n=e.resolveInner(t,-1),r=t;VLe(n)&&(r=n.from,n=n.parent);for(let s;s=n.childBefore(r);)if(VLe(s))r=s.from;else if(s.name=="OrderedList"||s.name=="BulletList")n=s.lastChild,r=n.to;else break;return n}const obt=({state:e,dispatch:t})=>{let n=fi(e),r=null,s=e.changeByRange(a=>{let i=a.from,{doc:l}=e;if(a.empty&&CO.isActiveAt(e,a.from)){let c=l.lineAt(i),u=rbt(y8n(n,i),l);if(u.length){let d=u[u.length-1],f=d.to-d.spaceAfter.length+(d.spaceAfter?1:0);if(i-c.from>f&&!/\S/.test(c.text.slice(f,i-c.from)))return{range:vt.cursor(c.from+f),changes:{from:c.from+f,to:i}};if(i-c.from==f&&(!d.item||c.from<=d.item.from||!/\S/.test(c.text.slice(0,d.to)))){let p=c.from+d.from;if(d.item&&d.node.from<d.item.from&&/\S/.test(c.text.slice(d.from,d.to))){let h=d.blank(_g(c.text,4,d.to)-_g(c.text,4,d.from));return p==c.from&&(h=Uwe(h,e)),{range:vt.cursor(p+h.length),changes:{from:p,to:c.from+d.to,insert:h}}}if(p<i)return{range:vt.cursor(p),changes:{from:p,to:i}}}}}return r={range:a}});return r?!1:(t(e.update(s,{scrollIntoView:!0,userEvent:"delete"})),!0)},lbt=[{key:"Enter",run:ibt},{key:"Backspace",run:obt}],cbt=u8n({matchClosingTags:!1});function qwe(e={}){let{codeLanguages:t,defaultCodeLanguage:n,addKeymap:r=!0,base:{parser:s}=nbt,completeHTMLTags:a=!0,pasteURLAsLink:i=!0,htmlTagLanguage:l=cbt}=e;if(!(s instanceof uV))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let c=e.extensions?[e.extensions]:[],u=[l.support,h8n],d;i&&u.push(ubt),n instanceof kO?(u.push(n.support),d=n.language):n&&(d=n);let f=t||d?g8n(t,d):void 0;c.push(L5n({codeParser:f,htmlParser:l.language.parser})),r&&u.push(Pg.high(AN.of(lbt)));let p=Bwe(s.configure(c));return a&&u.push(p.data.of({autocomplete:b8n})),new kO(p,u)}function b8n(e){let{state:t,pos:n}=e,r=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(n-25,n));if(!r)return null;let s=fi(t).resolveInner(n,-1);for(;s&&!s.type.isTop;){if(s.name=="CodeBlock"||s.name=="FencedCode"||s.name=="ProcessingInstructionBlock"||s.name=="CommentBlock"||s.name=="Link"||s.name=="Image")return null;s=s.parent}return{from:n-r[0].length,to:n,options:x8n(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}let jK=null;function x8n(){if(jK)return jK;let e=o8n(new bwe(os.create({extensions:cbt}),0,!0));return jK=e?e.options:[]}const w8n=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,ubt=It.domEventHandlers({paste:(e,t)=>{var n;let{main:r}=t.state.selection;if(r.empty)return!1;let s=(n=e.clipboardData)===null||n===void 0?void 0:n.getData("text/plain");if(!s||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(s)||(/^www\./.test(s)&&(s="https://"+s),!CO.isActiveAt(t.state,r.from,1)))return!1;let a=fi(t.state),i=!1;return a.iterate({from:r.from,to:r.to,enter:l=>{(l.from>r.from||w8n.test(l.name))&&(i=!0)},leave:l=>{l.to<r.to&&(i=!0)}}),i?!1:(t.dispatch({changes:[{from:r.from,insert:"["},{from:r.to,insert:`](${s})`}],userEvent:"input.paste",scrollIntoView:!0}),!0)}}),S8n=Object.freeze(Object.defineProperty({__proto__:null,commonmarkLanguage:nbt,deleteMarkupBackward:obt,insertNewlineContinueMarkup:ibt,insertNewlineContinueMarkupCommand:abt,markdown:qwe,markdownKeymap:lbt,markdownLanguage:CO,pasteURLAsLink:ubt},Symbol.toStringTag,{value:"Module"}));function EO(){return EO=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},EO.apply(null,arguments)}var k8n=e=>{var t=e.theme,n=e.settings,r=n===void 0?{}:n,s=e.styles,a=s===void 0?[]:s,i={".cm-gutters":{}},l={};r.background&&(l.backgroundColor=r.background),r.backgroundImage&&(l.backgroundImage=r.backgroundImage),r.foreground&&(l.color=r.foreground),r.fontSize&&(l.fontSize=r.fontSize),(r.background||r.foreground)&&(i["&"]=l),r.fontFamily&&(i["&.cm-editor .cm-scroller"]={fontFamily:r.fontFamily}),r.gutterBackground&&(i[".cm-gutters"].backgroundColor=r.gutterBackground),r.gutterForeground&&(i[".cm-gutters"].color=r.gutterForeground),r.gutterBorder&&(i[".cm-gutters"].borderRightColor=r.gutterBorder),r.caret&&(i[".cm-content"]={caretColor:r.caret},i[".cm-cursor, .cm-dropCursor"]={borderLeftColor:r.caret});var c={};r.gutterActiveForeground&&(c.color=r.gutterActiveForeground),r.lineHighlight&&(i[".cm-activeLine"]={backgroundColor:r.lineHighlight},c.backgroundColor=r.lineHighlight),i[".cm-activeLineGutter"]=c,r.selection&&(i["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:r.selection+" !important"}),r.selectionMatch&&(i["& .cm-selectionMatch"]={backgroundColor:r.selectionMatch});var u=It.theme(i,{dark:t==="dark"}),d=$g.define(a),f=[u,F1(d)];return f},O8n={background:"#282a36",foreground:"#f8f8f2",caret:"#f8f8f0",selection:"rgba(255, 255, 255, 0.1)",selectionMatch:"rgba(255, 255, 255, 0.2)",gutterBackground:"#282a36",gutterForeground:"#6D8A88",gutterBorder:"transparent",lineHighlight:"rgba(255, 255, 255, 0.1)"},_8n=[{tag:fe.comment,color:"#6272a4"},{tag:fe.string,color:"#f1fa8c"},{tag:fe.atom,color:"#bd93f9"},{tag:fe.meta,color:"#f8f8f2"},{tag:[fe.keyword,fe.operator,fe.tagName],color:"#ff79c6"},{tag:[fe.function(fe.propertyName),fe.propertyName],color:"#66d9ef"},{tag:[fe.definition(fe.variableName),fe.function(fe.variableName),fe.className,fe.attributeName],color:"#50fa7b"},{tag:fe.atom,color:"#bd93f9"}],$N=e=>{var t=e||{},n=t.theme,r=n===void 0?"dark":n,s=t.settings,a=s===void 0?{}:s,i=t.styles,l=i===void 0?[]:i;return k8n({theme:r,settings:EO({},O8n,a),styles:[..._8n,...l]})};$N();function dbt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}const C8n=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Hwe(e.state,n.from);return r.line?E8n(e):r.block?T8n(e):!1};function Vwe(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=e(t,n);return s?(r(n.update(s)),!0):!1}}const E8n=Vwe(A8n,0),j8n=Vwe(fbt,0),T8n=Vwe((e,t)=>fbt(e,t,I8n(t)),0);function Hwe(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const UA=50;function N8n(e,{open:t,close:n},r,s){let a=e.sliceDoc(r-UA,r),i=e.sliceDoc(s,s+UA),l=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(i)[0].length,u=a.length-l;if(a.slice(u-t.length,u)==t&&i.slice(c,c+n.length)==n)return{open:{pos:r-l,margin:l&&1},close:{pos:s+c,margin:c&&1}};let d,f;s-r<=2*UA?d=f=e.sliceDoc(r,s):(d=e.sliceDoc(r,r+UA),f=e.sliceDoc(s-UA,s));let p=/^\s*/.exec(d)[0].length,h=/\s*$/.exec(f)[0].length,m=f.length-h-n.length;return d.slice(p,p+t.length)==t&&f.slice(m,m+n.length)==n?{open:{pos:r+p+t.length,margin:/\s/.test(d.charAt(p+t.length))?1:0},close:{pos:s-h-n.length,margin:/\s/.test(f.charAt(m-1))?1:0}}:null}function I8n(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),s=n.to<=r.to?r:e.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=s.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return t}function fbt(e,t,n=t.selection.ranges){let r=n.map(a=>Hwe(t,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,i)=>N8n(t,r[i],a.from,a.to));if(e!=2&&!s.every(a=>a))return{changes:t.changes(n.map((a,i)=>s[i]?[]:[{from:a.from,insert:r[i].open+" "},{from:a.to,insert:" "+r[i].close}]))};if(e!=1&&s.some(a=>a)){let a=[];for(let i=0,l;i<s.length;i++)if(l=s[i]){let c=r[i],{open:u,close:d}=l;a.push({from:u.pos-c.open.length,to:u.pos+u.margin},{from:d.pos-d.margin,to:d.pos+c.close.length})}return{changes:a}}return null}function A8n(e,t,n=t.selection.ranges){let r=[],s=-1;e:for(let{from:a,to:i}of n){let l=r.length,c=1e9,u;for(let d=a;d<=i;){let f=t.doc.lineAt(d);if(u==null&&(u=Hwe(t,f.from).line,!u))continue e;if(f.from>s&&(a==i||i>f.from)){s=f.from;let p=/^\s*/.exec(f.text)[0].length,h=p==f.length,m=f.text.slice(p,p+u.length)==u?p:-1;p<f.text.length&&p<c&&(c=p),r.push({line:f,comment:m,token:u,indent:p,empty:h,single:!1})}d=f.to+1}if(c<1e9)for(let d=l;d<r.length;d++)r[d].indent<r[d].line.text.length&&(r[d].indent=c);r.length==l+1&&(r[l].single=!0)}if(e!=2&&r.some(a=>a.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:l,token:c,indent:u,empty:d,single:f}of r)(f||!d)&&a.push({from:l.from+u,insert:c+" "});let i=t.changes(a);return{changes:i,selection:t.selection.map(i,1)}}else if(e!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:i,comment:l,token:c}of r)if(l>=0){let u=i.from+l,d=u+c.length;i.text[d-i.from]==" "&&d++,a.push({from:u,to:d})}return{changes:a}}return null}const the=Ay.define(),R8n=Ay.define(),P8n=On.define(),pbt=On.define({combine(e){return Ry(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,n)=>(r,s)=>t(r,s)||n(r,s)})}}),hbt=ml.define({create(){return Lv.empty},update(e,t){let n=t.state.facet(pbt),r=t.annotation(the);if(r){let c=Yd.fromTransaction(t,r.selection),u=r.side,d=u==0?e.undone:e.done;return c?d=l7(d,d.length,n.minDepth,c):d=vbt(d,t.startState.selection),new Lv(u==0?r.rest:d,u==0?d:r.rest)}let s=t.annotation(R8n);if((s=="full"||s=="before")&&(e=e.isolate()),t.annotation(El.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=Yd.fromTransaction(t),i=t.annotation(El.time),l=t.annotation(El.userEvent);return a?e=e.addChanges(a,i,l,n,t):t.selection&&(e=e.addSelection(t.startState.selection,i,l,n.newGroupDelay)),(s=="full"||s=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new Lv(e.done.map(Yd.fromJSON),e.undone.map(Yd.fromJSON))}});function $8n(e={}){return[hbt,pbt.of(e),It.domEventHandlers({beforeinput(t,n){let r=t.inputType=="historyUndo"?mbt:t.inputType=="historyRedo"?nhe:null;return r?(t.preventDefault(),r(n)):!1}})]}function dV(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let s=n.field(hbt,!1);if(!s)return!1;let a=s.pop(e,n,t);return a?(r(a),!0):!1}}const mbt=dV(0,!1),nhe=dV(1,!1),M8n=dV(0,!0),D8n=dV(1,!0);class Yd{constructor(t,n,r,s,a){this.changes=t,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(t){return new Yd(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,n,r;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(t){return new Yd(t.changes&&_l.fromJSON(t.changes),[],t.mapped&&Yv.fromJSON(t.mapped),t.startSelection&&vt.fromJSON(t.startSelection),t.selectionsAfter.map(vt.fromJSON))}static fromTransaction(t,n){let r=Ph;for(let s of t.startState.facet(P8n)){let a=s(t);a.length&&(r=r.concat(a))}return!r.length&&t.changes.empty?null:new Yd(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,Ph)}static selection(t){return new Yd(void 0,Ph,void 0,void 0,t)}}function l7(e,t,n,r){let s=t+1>n+20?t-n-1:0,a=e.slice(s,t);return a.push(r),a}function L8n(e,t){let n=[],r=!1;return e.iterChangedRanges((s,a)=>n.push(s,a)),t.iterChangedRanges((s,a,i,l)=>{for(let c=0;c<n.length;){let u=n[c++],d=n[c++];l>=u&&i<=d&&(r=!0)}}),r}function F8n(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function gbt(e,t){return e.length?t.length?e.concat(t):e:t}const Ph=[],z8n=200;function vbt(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-z8n));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),l7(e,e.length-1,1e9,n.setSelAfter(r)))}else return[Yd.selection([t])]}function B8n(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function TK(e,t){if(!e.length)return e;let n=e.length,r=Ph;for(;n;){let s=U8n(e[n-1],t,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=e.slice(0,n);return a[n-1]=s,a}else t=s.mapped,n--,r=s.selectionsAfter}return r.length?[Yd.selection(r)]:Ph}function U8n(e,t,n){let r=gbt(e.selectionsAfter.length?e.selectionsAfter.map(l=>l.map(t)):Ph,n);if(!e.changes)return Yd.selection(r);let s=e.changes.map(t),a=t.mapDesc(e.changes,!0),i=e.mapped?e.mapped.composeDesc(a):a;return new Yd(s,vr.mapEffects(e.effects,t),i,e.startSelection.map(a),r)}const q8n=/^(input\.type|delete)($|\.)/;class Lv{constructor(t,n,r=0,s=void 0){this.done=t,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Lv(this.done,this.undone):this}addChanges(t,n,r,s,a){let i=this.done,l=i[i.length-1];return l&&l.changes&&!l.changes.empty&&t.changes&&(!r||q8n.test(r))&&(!l.selectionsAfter.length&&n-this.prevTime<s.newGroupDelay&&s.joinToEvent(a,L8n(l.changes,t.changes))||r=="input.type.compose")?i=l7(i,i.length-1,s.minDepth,new Yd(t.changes.compose(l.changes),gbt(vr.mapEffects(t.effects,l.changes),l.effects),l.mapped,l.startSelection,Ph)):i=l7(i,i.length,s.minDepth,t),new Lv(i,Ph,n,r)}addSelection(t,n,r,s){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:Ph;return a.length>0&&n-this.prevTime<s&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&F8n(a[a.length-1],t)?this:new Lv(vbt(this.done,t),this.undone,n,r)}addMapping(t){return new Lv(TK(this.done,t),TK(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,n,r){let s=t==0?this.done:this.undone;if(s.length==0)return null;let a=s[s.length-1],i=a.selectionsAfter[0]||(a.startSelection?a.startSelection.map(a.changes.invertedDesc,1):n.selection);if(r&&a.selectionsAfter.length)return n.update({selection:a.selectionsAfter[a.selectionsAfter.length-1],annotations:the.of({side:t,rest:B8n(s),selection:i}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(a.changes){let l=s.length==1?Ph:s.slice(0,s.length-1);return a.mapped&&(l=TK(l,a.mapped)),n.update({changes:a.changes,selection:a.startSelection,effects:a.effects,annotations:the.of({side:t,rest:l,selection:i}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}Lv.empty=new Lv(Ph,Ph);const V8n=[{key:"Mod-z",run:mbt,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:nhe,preventDefault:!0},{linux:"Ctrl-Shift-z",run:nhe,preventDefault:!0},{key:"Mod-u",run:M8n,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:D8n,preventDefault:!0}];function MN(e,t){return vt.create(e.ranges.map(t),e.mainIndex)}function Mg(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function Dg({state:e,dispatch:t},n){let r=MN(e.selection,n);return r.eq(e.selection,!0)?!1:(t(Mg(e,r)),!0)}function fV(e,t){return vt.cursor(t?e.to:e.from)}function ybt(e,t){return Dg(e,n=>n.empty?e.moveByChar(n,t):fV(n,t))}function Fu(e){return e.textDirectionAt(e.state.selection.main.head)==xi.LTR}const bbt=e=>ybt(e,!Fu(e)),xbt=e=>ybt(e,Fu(e));function wbt(e,t){return Dg(e,n=>n.empty?e.moveByGroup(n,t):fV(n,t))}const H8n=e=>wbt(e,!Fu(e)),W8n=e=>wbt(e,Fu(e));function Z8n(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function pV(e,t,n){let r=fi(e).resolveInner(t.head),s=n?Rr.closedBy:Rr.openedBy;for(let c=t.head;;){let u=n?r.childAfter(c):r.childBefore(c);if(!u)break;Z8n(e,u,s)?r=u:c=n?u.to:u.from}let a=r.type.prop(s),i,l;return a&&(i=n?Dv(e,r.from,1):Dv(e,r.to,-1))&&i.matched?l=n?i.end.to:i.end.from:l=n?r.to:r.from,vt.cursor(l,n?-1:1)}const G8n=e=>Dg(e,t=>pV(e.state,t,!Fu(e))),Q8n=e=>Dg(e,t=>pV(e.state,t,Fu(e)));function Sbt(e,t){return Dg(e,n=>{if(!n.empty)return fV(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}const kbt=e=>Sbt(e,!1),Obt=e=>Sbt(e,!0);function _bt(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,s;if(t){for(let a of e.state.facet(It.scrollMargins)){let i=a(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}s=e.scrollDOM.clientHeight-n-r}else s=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,s-5)}}function Cbt(e,t){let n=_bt(e),{state:r}=e,s=MN(r.selection,i=>i.empty?e.moveVertically(i,t,n.height):fV(i,t));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let i=e.coordsAtPos(r.selection.main.head),l=e.scrollDOM.getBoundingClientRect(),c=l.top+n.marginTop,u=l.bottom-n.marginBottom;i&&i.top>c&&i.bottom<u&&(a=It.scrollIntoView(s.main.head,{y:"start",yMargin:i.top-c}))}return e.dispatch(Mg(r,s),{effects:a}),!0}const WLe=e=>Cbt(e,!1),rhe=e=>Cbt(e,!0);function z1(e,t,n){let r=e.lineBlockAt(t.head),s=e.moveToLineBoundary(t,n);if(s.head==t.head&&s.head!=(n?r.to:r.from)&&(s=e.moveToLineBoundary(t,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&t.head!=r.from+a&&(s=vt.cursor(r.from+a))}return s}const Y8n=e=>Dg(e,t=>z1(e,t,!0)),X8n=e=>Dg(e,t=>z1(e,t,!1)),K8n=e=>Dg(e,t=>z1(e,t,!Fu(e))),J8n=e=>Dg(e,t=>z1(e,t,Fu(e))),e9n=e=>Dg(e,t=>vt.cursor(e.lineBlockAt(t.head).from,1)),t9n=e=>Dg(e,t=>vt.cursor(e.lineBlockAt(t.head).to,-1));function n9n(e,t,n){let r=!1,s=MN(e.selection,a=>{let i=Dv(e,a.head,-1)||Dv(e,a.head,1)||a.head>0&&Dv(e,a.head-1,1)||a.head<e.doc.length&&Dv(e,a.head+1,-1);if(!i||!i.end)return a;r=!0;let l=i.start.from==a.head?i.end.to:i.end.from;return vt.cursor(l)});return r?(t(Mg(e,s)),!0):!1}const r9n=({state:e,dispatch:t})=>n9n(e,t);function bm(e,t){let n=MN(e.state.selection,r=>{let s=t(r);return vt.range(r.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(Mg(e.state,n)),!0)}function Ebt(e,t){return bm(e,n=>e.moveByChar(n,t))}const jbt=e=>Ebt(e,!Fu(e)),Tbt=e=>Ebt(e,Fu(e));function Nbt(e,t){return bm(e,n=>e.moveByGroup(n,t))}const s9n=e=>Nbt(e,!Fu(e)),a9n=e=>Nbt(e,Fu(e)),i9n=e=>bm(e,t=>pV(e.state,t,!Fu(e))),o9n=e=>bm(e,t=>pV(e.state,t,Fu(e)));function Ibt(e,t){return bm(e,n=>e.moveVertically(n,t))}const Abt=e=>Ibt(e,!1),Rbt=e=>Ibt(e,!0);function Pbt(e,t){return bm(e,n=>e.moveVertically(n,t,_bt(e).height))}const ZLe=e=>Pbt(e,!1),GLe=e=>Pbt(e,!0),l9n=e=>bm(e,t=>z1(e,t,!0)),c9n=e=>bm(e,t=>z1(e,t,!1)),u9n=e=>bm(e,t=>z1(e,t,!Fu(e))),d9n=e=>bm(e,t=>z1(e,t,Fu(e))),f9n=e=>bm(e,t=>vt.cursor(e.lineBlockAt(t.head).from)),p9n=e=>bm(e,t=>vt.cursor(e.lineBlockAt(t.head).to)),QLe=({state:e,dispatch:t})=>(t(Mg(e,{anchor:0})),!0),YLe=({state:e,dispatch:t})=>(t(Mg(e,{anchor:e.doc.length})),!0),XLe=({state:e,dispatch:t})=>(t(Mg(e,{anchor:e.selection.main.anchor,head:0})),!0),KLe=({state:e,dispatch:t})=>(t(Mg(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),h9n=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),m9n=({state:e,dispatch:t})=>{let n=hV(e).map(({from:r,to:s})=>vt.range(r,Math.min(s+1,e.doc.length)));return t(e.update({selection:vt.create(n),userEvent:"select"})),!0},g9n=({state:e,dispatch:t})=>{let n=MN(e.selection,r=>{let s=fi(e),a=s.resolveStack(r.from,1);if(r.empty){let i=s.resolveStack(r.from,-1);i.node.from>=a.node.from&&i.node.to<=a.node.to&&(a=i)}for(let i=a;i;i=i.next){let{node:l}=i;if((l.from<r.from&&l.to>=r.to||l.to>r.to&&l.from<=r.from)&&i.next)return vt.range(l.to,l.from)}return r});return n.eq(e.selection)?!1:(t(Mg(e,n)),!0)};function $bt(e,t){let{state:n}=e,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let i=n.doc.lineAt(a.head);if(t?i.to<e.state.doc.length:i.from>0)for(let l=a;;){let c=e.moveVertically(l,t);if(c.head<i.from||c.head>i.to){s.some(u=>u.head==c.head)||s.push(c);break}else{if(c.head==l.head)break;l=c}}}return s.length==r.ranges.length?!1:(e.dispatch(Mg(n,vt.create(s,s.length-1))),!0)}const v9n=e=>$bt(e,!1),y9n=e=>$bt(e,!0),b9n=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=vt.create([n.main]):n.main.empty||(r=vt.create([vt.cursor(n.main.head)])),r?(t(Mg(e,r)),!0):!1};function rD(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,s=r.changeByRange(a=>{let{from:i,to:l}=a;if(i==l){let c=t(a);c<i?(n="delete.backward",c=u6(e,c,!1)):c>i&&(n="delete.forward",c=u6(e,c,!0)),i=Math.min(i,c),l=Math.max(l,c)}else i=u6(e,i,!1),l=u6(e,l,!0);return i==l?{range:a}:{changes:{from:i,to:l},range:vt.cursor(i,i<a.head?-1:1)}});return s.changes.empty?!1:(e.dispatch(r.update(s,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?It.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function u6(e,t,n){if(e instanceof It)for(let r of e.state.facet(It.atomicRanges).map(s=>s(e)))r.between(t,t,(s,a)=>{s<t&&a>t&&(t=n?a:s)});return t}const Mbt=(e,t,n)=>rD(e,r=>{let s=r.from,{state:a}=e,i=a.doc.lineAt(s),l,c;if(n&&!t&&s>i.from&&s<i.from+200&&!/[^ \t]/.test(l=i.text.slice(0,s-i.from))){if(l[l.length-1]==" ")return s-1;let u=_g(l,a.tabSize),d=u%OO(a)||OO(a);for(let f=0;f<d&&l[l.length-1-f]==" ";f++)s--;c=s}else c=vc(i.text,s-i.from,t,t)+i.from,c==s&&i.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(i.text.slice(c-i.from,s-i.from))&&(c=vc(i.text,c-i.from,!1,!1)+i.from);return c}),she=e=>Mbt(e,!1,!0),Dbt=e=>Mbt(e,!0,!1),Lbt=(e,t)=>rD(e,n=>{let r=n.head,{state:s}=e,a=s.doc.lineAt(r),i=s.charCategorizer(r);for(let l=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?s.doc.lines:1)&&(r+=t?1:-1);break}let c=vc(a.text,r-a.from,t)+a.from,u=a.text.slice(Math.min(r,c)-a.from,Math.max(r,c)-a.from),d=i(u);if(l!=null&&d!=l)break;(u!=" "||r!=n.head)&&(l=d),r=c}return r}),Fbt=e=>Lbt(e,!1),x9n=e=>Lbt(e,!0),w9n=e=>rD(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),S9n=e=>rD(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),k9n=e=>rD(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),O9n=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:va.of(["",""])},range:vt.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},_9n=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>{if(!r.empty||r.from==0||r.from==e.doc.length)return{range:r};let s=r.from,a=e.doc.lineAt(s),i=s==a.from?s-1:vc(a.text,s-a.from,!1)+a.from,l=s==a.to?s+1:vc(a.text,s-a.from,!0)+a.from;return{changes:{from:i,to:l,insert:e.doc.slice(s,l).append(e.doc.slice(i,s))},range:vt.cursor(l)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function hV(e){let t=[],n=-1;for(let r of e.selection.ranges){let s=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=s.number){let i=t[t.length-1];i.to=a.to,i.ranges.push(r)}else t.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return t}function zbt(e,t,n){if(e.readOnly)return!1;let r=[],s=[];for(let a of hV(e)){if(n?a.to==e.doc.length:a.from==0)continue;let i=e.doc.lineAt(n?a.to+1:a.from-1),l=i.length+1;if(n){r.push({from:a.to,to:i.to},{from:a.from,insert:i.text+e.lineBreak});for(let c of a.ranges)s.push(vt.range(Math.min(e.doc.length,c.anchor+l),Math.min(e.doc.length,c.head+l)))}else{r.push({from:i.from,to:a.from},{from:a.to,insert:e.lineBreak+i.text});for(let c of a.ranges)s.push(vt.range(c.anchor-l,c.head-l))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:vt.create(s,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}const C9n=({state:e,dispatch:t})=>zbt(e,t,!1),E9n=({state:e,dispatch:t})=>zbt(e,t,!0);function Bbt(e,t,n){if(e.readOnly)return!1;let r=[];for(let a of hV(e))n?r.push({from:a.from,insert:e.doc.slice(a.from,a.to)+e.lineBreak}):r.push({from:a.to,insert:e.lineBreak+e.doc.slice(a.from,a.to)});let s=e.changes(r);return t(e.update({changes:s,selection:e.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const j9n=({state:e,dispatch:t})=>Bbt(e,t,!1),T9n=({state:e,dispatch:t})=>Bbt(e,t,!0),N9n=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(hV(t).map(({from:s,to:a})=>(s>0?s--:a<t.doc.length&&a++,{from:s,to:a}))),r=MN(t.selection,s=>{let a;if(e.lineWrapping){let i=e.lineBlockAt(s.head),l=e.coordsAtPos(s.head,s.assoc||1);l&&(a=i.bottom+e.documentTop-l.bottom+e.defaultLineHeight/2)}return e.moveVertically(s,!0,a)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function I9n(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=fi(e).resolveInner(t),r=n.childBefore(t),s=n.childAfter(t),a;return r&&s&&r.to<=t&&s.from>=t&&(a=r.type.prop(Rr.closedBy))&&a.indexOf(s.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(s.from).from&&!/\S/.test(e.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const JLe=Ubt(!1),A9n=Ubt(!0);function Ubt(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(s=>{let{from:a,to:i}=s,l=t.doc.lineAt(a),c=!e&&a==i&&I9n(t,a);e&&(a=i=(i<=l.to?l:t.doc.lineAt(i)).to);let u=new oV(t,{simulateBreak:a,simulateDoubleBreak:!!c}),d=pwe(u,a);for(d==null&&(d=_g(/^\s*/.exec(t.doc.lineAt(a).text)[0],t.tabSize));i<l.to&&/\s/.test(l.text[i-l.from]);)i++;c?{from:a,to:i}=c:a>l.from&&a<l.from+100&&!/\S/.test(l.text.slice(0,a))&&(a=l.from);let f=["",$$(t,d)];return c&&f.push($$(t,u.lineIndent(l.from,-1))),{changes:{from:a,to:i,insert:va.of(f)},range:vt.cursor(a+1+f[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function Wwe(e,t){let n=-1;return e.changeByRange(r=>{let s=[];for(let i=r.from;i<=r.to;){let l=e.doc.lineAt(i);l.number>n&&(r.empty||r.to>l.from)&&(t(l,s,r),n=l.number),i=l.to+1}let a=e.changes(s);return{changes:s,range:vt.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const R9n=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new oV(e,{overrideIndentation:a=>{let i=n[a];return i??-1}}),s=Wwe(e,(a,i,l)=>{let c=pwe(r,a.from);if(c==null)return;/\S/.test(a.text)||(c=0);let u=/^\s*/.exec(a.text)[0],d=$$(e,c);(u!=d||l.from<a.from+u.length)&&(n[a.from]=c,i.push({from:a.from,to:a.from+u.length,insert:d}))});return s.changes.empty||t(e.update(s,{userEvent:"indent"})),!0},qbt=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Wwe(e,(n,r)=>{r.push({from:n.from,insert:e.facet(RN)})}),{userEvent:"input.indent"})),!0),Vbt=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Wwe(e,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=_g(s,e.tabSize),i=0,l=$$(e,Math.max(0,a-OO(e)));for(;i<s.length&&i<l.length&&s.charCodeAt(i)==l.charCodeAt(i);)i++;r.push({from:n.from+i,to:n.from+s.length,insert:l.slice(i)})}),{userEvent:"delete.dedent"})),!0),P9n=e=>(e.setTabFocusMode(),!0),$9n=[{key:"Ctrl-b",run:bbt,shift:jbt,preventDefault:!0},{key:"Ctrl-f",run:xbt,shift:Tbt},{key:"Ctrl-p",run:kbt,shift:Abt},{key:"Ctrl-n",run:Obt,shift:Rbt},{key:"Ctrl-a",run:e9n,shift:f9n},{key:"Ctrl-e",run:t9n,shift:p9n},{key:"Ctrl-d",run:Dbt},{key:"Ctrl-h",run:she},{key:"Ctrl-k",run:w9n},{key:"Ctrl-Alt-h",run:Fbt},{key:"Ctrl-o",run:O9n},{key:"Ctrl-t",run:_9n},{key:"Ctrl-v",run:rhe}],M9n=[{key:"ArrowLeft",run:bbt,shift:jbt,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:H8n,shift:s9n,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:K8n,shift:u9n,preventDefault:!0},{key:"ArrowRight",run:xbt,shift:Tbt,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:W8n,shift:a9n,preventDefault:!0},{mac:"Cmd-ArrowRight",run:J8n,shift:d9n,preventDefault:!0},{key:"ArrowUp",run:kbt,shift:Abt,preventDefault:!0},{mac:"Cmd-ArrowUp",run:QLe,shift:XLe},{mac:"Ctrl-ArrowUp",run:WLe,shift:ZLe},{key:"ArrowDown",run:Obt,shift:Rbt,preventDefault:!0},{mac:"Cmd-ArrowDown",run:YLe,shift:KLe},{mac:"Ctrl-ArrowDown",run:rhe,shift:GLe},{key:"PageUp",run:WLe,shift:ZLe},{key:"PageDown",run:rhe,shift:GLe},{key:"Home",run:X8n,shift:c9n,preventDefault:!0},{key:"Mod-Home",run:QLe,shift:XLe},{key:"End",run:Y8n,shift:l9n,preventDefault:!0},{key:"Mod-End",run:YLe,shift:KLe},{key:"Enter",run:JLe,shift:JLe},{key:"Mod-a",run:h9n},{key:"Backspace",run:she,shift:she,preventDefault:!0},{key:"Delete",run:Dbt,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Fbt,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:x9n,preventDefault:!0},{mac:"Mod-Backspace",run:S9n,preventDefault:!0},{mac:"Mod-Delete",run:k9n,preventDefault:!0}].concat($9n.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),D9n=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:G8n,shift:i9n},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Q8n,shift:o9n},{key:"Alt-ArrowUp",run:C9n},{key:"Shift-Alt-ArrowUp",run:j9n},{key:"Alt-ArrowDown",run:E9n},{key:"Shift-Alt-ArrowDown",run:T9n},{key:"Mod-Alt-ArrowUp",run:v9n},{key:"Mod-Alt-ArrowDown",run:y9n},{key:"Escape",run:b9n},{key:"Mod-Enter",run:A9n},{key:"Alt-l",mac:"Ctrl-l",run:m9n},{key:"Mod-i",run:g9n,preventDefault:!0},{key:"Mod-[",run:Vbt},{key:"Mod-]",run:qbt},{key:"Mod-Alt-\\",run:R9n},{key:"Shift-Mod-k",run:N9n},{key:"Shift-Mod-\\",run:r9n},{key:"Mod-/",run:C8n},{key:"Alt-A",run:j8n},{key:"Ctrl-m",mac:"Shift-Alt-m",run:P9n}].concat(M9n),L9n={key:"Tab",run:qbt,shift:Vbt},e6e=typeof String.prototype.normalize=="function"?e=>e.normalize("NFKD"):e=>e;class Sx{constructor(t,n,r=0,s=t.length,a,i){this.test=i,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(r,s),this.bufferStart=r,this.normalize=a?l=>a(e6e(l)):e6e,this.query=this.normalize(n)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Ud(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let n=G0e(t),r=this.bufferStart+this.bufferPos;this.bufferPos+=_v(t);let s=this.normalize(n);if(s.length)for(let a=0,i=r,l=!0;;a++){let c=s.charCodeAt(a),u=this.match(c,i,l,this.bufferPos+this.bufferStart,a==s.length-1);if(u)return this.value=u,this;if(a==s.length-1)break;l&&a<n.length&&n.charCodeAt(a)==c?i++:l=!1}}}match(t,n,r,s,a){let i=null;for(let l=0;l<this.matches.length;){let c=this.matches[l],u=!1;this.query.charCodeAt(c.index)==t&&(c.index==this.query.length-1?i={from:c.from,to:s,precise:a&&c.precise}:(c.index++,u=!0)),u?l++:this.matches.splice(l,1)}return this.query.charCodeAt(0)==t&&(this.query.length==1?i={from:n,to:s,precise:r&&a}:this.matches.push({from:n,index:1,precise:r})),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}typeof Symbol<"u"&&(Sx.prototype[Symbol.iterator]=function(){return this});const Hbt={from:-1,to:-1,match:/.*/.exec(""),precise:!0},Zwe="gm"+(/x/.unicode==null?"":"u");class Wbt{constructor(t,n,r,s=0,a=t.length){if(this.text=t,this.to=a,this.curLine="",this.done=!1,this.value=Hbt,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new Zbt(t,n,r,s,a);this.re=new RegExp(n,Zwe+(r?.ignoreCase?"i":"")),this.test=r?.test,this.iter=t.iter();let i=t.lineAt(s);this.curLineStart=i.from,this.matchPos=c7(t,s),this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let r=this.curLineStart+n.index,s=r+n[0].length;if(this.matchPos=c7(this.text,s+(r==s?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<s||r>this.value.to)&&(!this.test||this.test(r,s,n)))return this.value={from:r,to:s,precise:!0,match:n},this;t=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),t=0;else return this.done=!0,this}}}const NK=new WeakMap;class yj{constructor(t,n){this.from=t,this.text=n}get to(){return this.from+this.text.length}static get(t,n,r){let s=NK.get(t);if(!s||s.from>=r||s.to<=n){let l=new yj(n,t.sliceString(n,r));return NK.set(t,l),l}if(s.from==n&&s.to==r)return s;let{text:a,from:i}=s;return i>n&&(a=t.sliceString(n,i)+a,i=n),s.to<r&&(a+=t.sliceString(s.to,r)),NK.set(t,new yj(i,a)),new yj(n,a.slice(n-i,r-i))}}class Zbt{constructor(t,n,r,s,a){this.text=t,this.to=a,this.done=!1,this.value=Hbt,this.matchPos=c7(t,s),this.re=new RegExp(n,Zwe+(r?.ignoreCase?"i":"")),this.test=r?.test,this.flat=yj.get(t,s,this.chunkEnd(s+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==t&&(this.re.lastIndex=t+1,n=this.re.exec(this.flat.text)),n){let r=this.flat.from+n.index,s=r+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,s,n)))return this.value={from:r,to:s,precise:!0,match:n},this.matchPos=c7(this.text,s+(r==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=yj.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(Wbt.prototype[Symbol.iterator]=Zbt.prototype[Symbol.iterator]=function(){return this});function F9n(e){try{return new RegExp(e,Zwe),!0}catch{return!1}}function c7(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}const z9n=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:s}=wDn(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return s.then(a=>{let i=a&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(a.elements.line.value);if(!i){e.dispatch({effects:r});return}let l=t.doc.lineAt(t.selection.main.head),[,c,u,d,f]=i,p=d?+d.slice(1):0,h=u?+u:l.number;if(u&&f){let y=h/100;c&&(y=y*(c=="-"?-1:1)+l.number/t.doc.lines),h=Math.round(t.doc.lines*y)}else u&&c&&(h=h*(c=="-"?-1:1)+l.number);let m=t.doc.line(Math.max(1,Math.min(t.doc.lines,h))),g=vt.cursor(m.from+Math.max(0,Math.min(p,m.length)));e.dispatch({effects:[r,It.scrollIntoView(g.from,{y:"center"})],selection:g})}),!0},B9n={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},U9n=On.define({combine(e){return Ry(e,B9n,{highlightWordAroundCursor:(t,n)=>t||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function q9n(e){return[G9n,Z9n]}const V9n=Cn.mark({class:"cm-selectionMatch"}),H9n=Cn.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function t6e(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=fo.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=fo.Word)}function W9n(e,t,n,r){return e(t.sliceDoc(n,n+1))==fo.Word&&e(t.sliceDoc(r-1,r))==fo.Word}const Z9n=yo.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(U9n),{state:n}=e,r=n.selection;if(r.ranges.length>1)return Cn.none;let s=r.main,a,i=null;if(s.empty){if(!t.highlightWordAroundCursor)return Cn.none;let c=n.wordAt(s.head);if(!c)return Cn.none;i=n.charCategorizer(s.head),a=n.sliceDoc(c.from,c.to)}else{let c=s.to-s.from;if(c<t.minSelectionLength||c>200)return Cn.none;if(t.wholeWords){if(a=n.sliceDoc(s.from,s.to),i=n.charCategorizer(s.head),!(t6e(i,n,s.from,s.to)&&W9n(i,n,s.from,s.to)))return Cn.none}else if(a=n.sliceDoc(s.from,s.to),!a)return Cn.none}let l=[];for(let c of e.visibleRanges){let u=new Sx(n.doc,a,c.from,c.to);for(;!u.next().done;){let{from:d,to:f}=u.value;if((!i||t6e(i,n,d,f))&&(s.empty&&d<=s.from&&f>=s.to?l.push(H9n.range(d,f)):(d>=s.to||f<=s.from)&&l.push(V9n.range(d,f)),l.length>t.maxMatches))return Cn.none}}return Cn.set(l)}},{decorations:e=>e.decorations}),G9n=It.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Q9n=({state:e,dispatch:t})=>{let{selection:n}=e,r=vt.create(n.ranges.map(s=>e.wordAt(s.head)||vt.cursor(s.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function Y9n(e,t){let{main:n,ranges:r}=e.selection,s=e.wordAt(n.head),a=s&&s.from==n.from&&s.to==n.to;for(let i=!1,l=new Sx(e.doc,t,r[r.length-1].to);;)if(l.next(),l.done){if(i)return null;l=new Sx(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),i=!0}else{if(i&&r.some(c=>c.from==l.value.from))continue;if(a){let c=e.wordAt(l.value.from);if(!c||c.from!=l.value.from||c.to!=l.value.to)continue}return l.value}}const X9n=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(a=>a.from===a.to))return Q9n({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(a=>e.sliceDoc(a.from,a.to)!=r))return!1;let s=Y9n(e,r);return s?(t(e.update({selection:e.selection.addRange(vt.range(s.from,s.to),!1),effects:It.scrollIntoView(s.to)})),!0):!1},DN=On.define({combine(e){return Ry(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new dFn(t),scrollToMatch:t=>It.scrollIntoView(t)})}});class Gbt{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||F9n(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord,this.test=t.test}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,(n,r)=>r=="n"?`
|
|
336
|
-
`:r=="r"?"\r":r=="t"?" ":"\\")}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord&&this.test==t.test}create(){return this.regexp?new rFn(this):new eFn(this)}getCursor(t,n=0,r){let s=t.doc?t:os.create({doc:t});return r==null&&(r=s.doc.length),this.regexp?vE(this,s,n,r):gE(this,s,n,r)}}class Qbt{constructor(t){this.spec=t}}function K9n(e,t,n){return(r,s,a,i)=>{if(n&&!n(r,s,a,i))return!1;let l=r>=i&&s<=i+a.length?a.slice(r-i,s-i):t.doc.sliceString(r,s);return e(l,t,r,s)}}function gE(e,t,n,r){let s;return e.wholeWord&&(s=J9n(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(s=K9n(e.test,t,s)),new Sx(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:a=>a.toLowerCase(),s)}function J9n(e,t){return(n,r,s,a)=>((a>n||a+s.length<r)&&(a=Math.max(0,n-2),s=e.sliceString(a,Math.min(e.length,r+2))),(t(u7(s,n-a))!=fo.Word||t(d7(s,n-a))!=fo.Word)&&(t(d7(s,r-a))!=fo.Word||t(u7(s,r-a))!=fo.Word))}class eFn extends Qbt{constructor(t){super(t)}nextMatch(t,n,r){let s=gE(this.spec,t,r,t.doc.length).nextOverlapping();if(s.done){let a=Math.min(t.doc.length,n+this.spec.unquoted.length);s=gE(this.spec,t,0,a).nextOverlapping()}return s.done||s.value.from==n&&s.value.to==r?null:s.value}prevMatchInRange(t,n,r){for(let s=r;;){let a=Math.max(n,s-1e4-this.spec.unquoted.length),i=gE(this.spec,t,a,s),l=null;for(;!i.nextOverlapping().done;)l=i.value;if(l)return l;if(a==n)return null;s-=1e4}}prevMatch(t,n,r){let s=this.prevMatchInRange(t,0,n);return s||(s=this.prevMatchInRange(t,Math.max(0,r-this.spec.unquoted.length),t.doc.length)),s&&(s.from!=n||s.to!=r)?s:null}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,n){let r=gE(this.spec,t,0,t.doc.length),s=[];for(;!r.next().done;){if(s.length>=n)return null;s.push(r.value)}return s}highlight(t,n,r,s){let a=gE(this.spec,t,Math.max(0,n-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,t.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}function tFn(e,t,n){return(r,s,a)=>(!n||n(r,s,a))&&e(a[0],t,r,s)}function vE(e,t,n,r){let s;return e.wholeWord&&(s=nFn(t.charCategorizer(t.selection.main.head))),e.test&&(s=tFn(e.test,t,s)),new Wbt(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:s},n,r)}function u7(e,t){return e.slice(vc(e,t,!1),t)}function d7(e,t){return e.slice(t,vc(e,t))}function nFn(e){return(t,n,r)=>!r[0].length||(e(u7(r.input,r.index))!=fo.Word||e(d7(r.input,r.index))!=fo.Word)&&(e(d7(r.input,r.index+r[0].length))!=fo.Word||e(u7(r.input,r.index+r[0].length))!=fo.Word)}class rFn extends Qbt{nextMatch(t,n,r){let s=vE(this.spec,t,r,t.doc.length).next();return s.done&&(s=vE(this.spec,t,0,n).next()),s.done?null:s.value}prevMatchInRange(t,n,r){for(let s=1;;s++){let a=Math.max(n,r-s*1e4),i=vE(this.spec,t,a,r),l=null;for(;!i.next().done;)l=i.value;if(l&&(a==n||l.from>a+10))return l;if(a==n)return null}}prevMatch(t,n,r){return this.prevMatchInRange(t,0,n)||this.prevMatchInRange(t,r,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,r)=>{if(r=="&")return t.match[0];if(r=="$")return"$";for(let s=r.length;s>0;s--){let a=+r.slice(0,s);if(a>0&&a<t.match.length)return t.match[a]+r.slice(s)}return n})}matchAll(t,n){let r=vE(this.spec,t,0,t.doc.length),s=[];for(;!r.next().done;){if(s.length>=n)return null;s.push(r.value)}return s}highlight(t,n,r,s){let a=vE(this.spec,t,Math.max(0,n-250),Math.min(r+250,t.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}const V$=vr.define(),Gwe=vr.define(),Rw=ml.define({create(e){return new IK(ahe(e).create(),null)},update(e,t){for(let n of t.effects)n.is(V$)?e=new IK(n.value.create(),e.panel):n.is(Gwe)&&(e=new IK(e.query,n.value?Qwe:null));return e},provide:e=>P$.from(e,t=>t.panel)});class IK{constructor(t,n){this.query=t,this.panel=n}}const sFn=Cn.mark({class:"cm-searchMatch"}),aFn=Cn.mark({class:"cm-searchMatch cm-searchMatch-selected"}),iFn=yo.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(Rw))}update(e){let t=e.state.field(Rw);(t!=e.startState.field(Rw)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return Cn.none;let{view:n}=this,r=new xd;for(let s=0,a=n.visibleRanges,i=a.length;s<i;s++){let{from:l,to:c}=a[s];for(;s<i-1&&c>a[s+1].from-500;)c=a[++s].to;e.highlight(n.state,l,c,(u,d)=>{let f=n.state.selection.ranges.some(p=>p.from==u&&p.to==d);r.add(u,d,f?aFn:sFn)})}return r.finish()}},{decorations:e=>e.decorations});function sD(e){return t=>{let n=t.state.field(Rw,!1);return n&&n.query.spec.valid?e(t,n):Kbt(t)}}const f7=sD((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let s=vt.single(r.from,r.to),a=e.state.facet(DN);return e.dispatch({selection:s,effects:[Ywe(e,r),a.scrollToMatch(s.main,e)],userEvent:"select.search"}),Xbt(e),!0}),p7=sD((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,s=t.prevMatch(n,r,r);if(!s)return!1;let a=vt.single(s.from,s.to),i=e.state.facet(DN);return e.dispatch({selection:a,effects:[Ywe(e,s),i.scrollToMatch(a.main,e)],userEvent:"select.search"}),Xbt(e),!0}),oFn=sD((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:vt.create(n.map(r=>vt.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),lFn=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:s}=n.main,a=[],i=0;for(let l=new Sx(e.doc,e.sliceDoc(r,s));!l.next().done;){if(a.length>1e3)return!1;l.value.from==r&&(i=a.length),a.push(vt.range(l.value.from,l.value.to))}return t(e.update({selection:vt.create(a,i),userEvent:"select.search.matches"})),!0},n6e=sD((e,{query:t})=>{let{state:n}=e,{from:r,to:s}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let i=a,l=[],c,u,d=[];i.precise?i.from==r&&i.to==s&&(u=n.toText(t.getReplacement(i)),l.push({from:i.from,to:i.to,insert:u}),d.push(It.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."))):i=t.nextMatch(n,i.from,i.to);let f=e.state.changes(l);return i&&(c=vt.single(i.from,i.to).map(f),d.push(Ywe(e,i)),d.push(n.facet(DN).scrollToMatch(c.main,e))),e.dispatch({changes:f,selection:c,effects:d,userEvent:"input.replace"}),!0}),cFn=sD((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let s of t.matchAll(e.state,1e9)){let{from:a,to:i,precise:l}=s;l&&n.push({from:a,to:i,insert:t.getReplacement(s)})}if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:It.announce.of(r),userEvent:"input.replace.all"}),!0});function Qwe(e){return e.state.facet(DN).createPanel(e)}function ahe(e,t){var n,r,s,a,i;let l=e.selection.main,c=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!c)return t;let u=e.facet(DN);return new Gbt({search:((n=t?.literal)!==null&&n!==void 0?n:u.literal)?c:c.replace(/\n/g,"\\n"),caseSensitive:(r=t?.caseSensitive)!==null&&r!==void 0?r:u.caseSensitive,literal:(s=t?.literal)!==null&&s!==void 0?s:u.literal,regexp:(a=t?.regexp)!==null&&a!==void 0?a:u.regexp,wholeWord:(i=t?.wholeWord)!==null&&i!==void 0?i:u.wholeWord})}function Ybt(e){let t=dwe(e,Qwe);return t&&t.dom.querySelector("[main-field]")}function Xbt(e){let t=Ybt(e);t&&t==e.root.activeElement&&t.select()}const Kbt=e=>{let t=e.state.field(Rw,!1);if(t&&t.panel){let n=Ybt(e);if(n&&n!=e.root.activeElement){let r=ahe(e.state,t.query.spec);r.valid&&e.dispatch({effects:V$.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[Gwe.of(!0),t?V$.of(ahe(e.state,t.query.spec)):vr.appendConfig.of(pFn)]});return!0},Jbt=e=>{let t=e.state.field(Rw,!1);if(!t||!t.panel)return!1;let n=dwe(e,Qwe);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:Gwe.of(!1)}),!0},uFn=[{key:"Mod-f",run:Kbt,scope:"editor search-panel"},{key:"F3",run:f7,shift:p7,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:f7,shift:p7,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Jbt,scope:"editor search-panel"},{key:"Mod-Shift-l",run:lFn},{key:"Mod-Alt-g",run:z9n},{key:"Mod-d",run:X9n,preventDefault:!0}];class dFn{constructor(t){this.view=t;let n=this.query=t.state.field(Rw).query.spec;this.commit=this.commit.bind(this),this.searchField=ii("input",{value:n.search,placeholder:Hf(t,"Find"),"aria-label":Hf(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ii("input",{value:n.replace,placeholder:Hf(t,"Replace"),"aria-label":Hf(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=ii("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=ii("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=ii("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(s,a,i){return ii("button",{class:"cm-button",name:s,onclick:a,type:"button"},i)}this.dom=ii("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,r("next",()=>f7(t),[Hf(t,"next")]),r("prev",()=>p7(t),[Hf(t,"previous")]),r("select",()=>oFn(t),[Hf(t,"all")]),ii("label",null,[this.caseField,Hf(t,"match case")]),ii("label",null,[this.reField,Hf(t,"regexp")]),ii("label",null,[this.wordField,Hf(t,"by word")]),...t.state.readOnly?[]:[ii("br"),this.replaceField,r("replace",()=>n6e(t),[Hf(t,"replace")]),r("replaceAll",()=>cFn(t),[Hf(t,"replace all")])],ii("button",{name:"close",onclick:()=>Jbt(t),"aria-label":Hf(t,"close"),type:"button"},["×"])])}commit(){let t=new Gbt({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:V$.of(t)}))}keydown(t){I3n(this.view,t,"search-panel")?t.preventDefault():t.keyCode==13&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?p7:f7)(this.view)):t.keyCode==13&&t.target==this.replaceField&&(t.preventDefault(),n6e(this.view))}update(t){for(let n of t.transactions)for(let r of n.effects)r.is(V$)&&!r.value.eq(this.query)&&this.setQuery(r.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(DN).top}}function Hf(e,t){return e.state.phrase(t)}const d6=30,f6=/[\s\.,:;?!]/;function Ywe(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),s=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-d6),i=Math.min(s,n+d6),l=e.state.sliceDoc(a,i);if(a!=r.from){for(let c=0;c<d6;c++)if(!f6.test(l[c+1])&&f6.test(l[c])){l=l.slice(c);break}}if(i!=s){for(let c=l.length-1;c>l.length-d6;c--)if(!f6.test(l[c-1])&&f6.test(l[c])){l=l.slice(0,c);break}}return It.announce.of(`${e.state.phrase("current match")}. ${l} ${e.state.phrase("on line")} ${r.number}.`)}const fFn=It.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),pFn=[Rw,Pg.low(iFn),fFn];class r6e{constructor(t,n,r){this.from=t,this.to=n,this.diagnostic=r}}class ck{constructor(t,n,r){this.diagnostics=t,this.panel=n,this.selected=r}static init(t,n,r){let s=r.facet(H$).markerFilter;s&&(t=s(t,r));let a=t.slice().sort((d,f)=>d.from-f.from||d.to-f.to),i=new xd,l=[],c=0;for(let d=0;;){let f=d==a.length?null:a[d];if(!f&&!l.length)break;let p,h;for(l.length?(p=c,h=l.reduce((g,y)=>Math.min(g,y.to),f&&f.from>p?f.from:1e8)):(p=f.from,h=f.to,l.push(f),d++);d<a.length;){let g=a[d];if(g.from==p&&(g.to>g.from||g.to==p))l.push(g),d++,h=Math.min(g.to,h);else{h=Math.min(g.from,h);break}}let m=CFn(l);if(l.some(g=>g.from==g.to||g.from==g.to-1&&r.doc.lineAt(g.from).to==g.from))i.add(p,p,Cn.widget({widget:new SFn(m),diagnostics:l.slice()}));else{let g=l.reduce((y,b)=>b.markClass?y+" "+b.markClass:y,"");i.add(p,h,Cn.mark({class:"cm-lintRange cm-lintRange-"+m+g,diagnostics:l.slice(),inclusiveEnd:l.some(y=>y.to>h)}))}c=h;for(let g=0;g<l.length;g++)l[g].to<=c&&l.splice(g--,1)}let u=i.finish();return new ck(u,n,pT(u))}}function pT(e,t=null,n=0){let r=null;return e.between(n,1e9,(s,a,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new r6e(s,a,t||i.diagnostics[0]);else{if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new r6e(r.from,a,r.diagnostic)}}),r}function hFn(e,t){let n=t.pos,r=t.end||n,s=e.state.facet(H$).hideOn(e,n,r);if(s!=null)return s;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(i=>i.is(ext))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function mFn(e,t){return e.field(gp,!1)?t:t.concat(vr.appendConfig.of(EFn))}const ext=vr.define(),Xwe=vr.define(),txt=vr.define(),gp=ml.define({create(){return new ck(Cn.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,s=e.panel;if(e.selected){let a=t.changes.mapPos(e.selected.from,1);r=pT(n,e.selected.diagnostic,a)||pT(n,null,a)}!n.size&&s&&t.state.facet(H$).autoPanel&&(s=null),e=new ck(n,s,r)}for(let n of t.effects)if(n.is(ext)){let r=t.state.facet(H$).autoPanel?n.value.length?W$.open:null:e.panel;e=ck.init(n.value,r,t.state)}else n.is(Xwe)?e=new ck(e.diagnostics,n.value?W$.open:null,e.selected):n.is(txt)&&(e=new ck(e.diagnostics,e.panel,n.value));return e},provide:e=>[P$.from(e,t=>t.panel),It.decorations.from(e,t=>t.diagnostics)]}),gFn=Cn.mark({class:"cm-lintRange cm-lintRange-active"});function vFn(e,t,n){let{diagnostics:r}=e.state.field(gp),s,a=-1,i=-1;r.between(t-(n<0?1:0),t+(n>0?1:0),(c,u,{spec:d})=>{if(t>=c&&t<=u&&(c==u||(t>c||n>0)&&(t<u||n<0)))return s=d.diagnostics,a=c,i=u,!1});let l=e.state.facet(H$).tooltipFilter;return s&&l&&(s=l(s,e.state)),s?{pos:a,end:i,above:e.state.doc.lineAt(a).to<i,create(){return{dom:yFn(e,s)}}}:null}function yFn(e,t){return ii("ul",{class:"cm-tooltip-lint"},t.map(n=>rxt(e,n,!1)))}const bFn=e=>{let t=e.state.field(gp,!1);(!t||!t.panel)&&e.dispatch({effects:mFn(e.state,[Xwe.of(!0)])});let n=dwe(e,W$.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},s6e=e=>{let t=e.state.field(gp,!1);return!t||!t.panel?!1:(e.dispatch({effects:Xwe.of(!1)}),!0)},xFn=e=>{let t=e.state.field(gp,!1);if(!t)return!1;let n=e.state.selection.main,r=t.diagnostics.iter(n.to+1);return!r.value&&(r=t.diagnostics.iter(0),!r.value||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)},wFn=[{key:"Mod-Shift-m",run:bFn,preventDefault:!0},{key:"F8",run:xFn}],H$=On.define({combine(e){return{sources:e.map(t=>t.source).filter(t=>t!=null),...Ry(e.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:a6e,tooltipFilter:a6e,needsRefresh:(t,n)=>t?n?r=>t(r)||n(r):t:n,hideOn:(t,n)=>t?n?(r,s,a)=>t(r,s,a)||n(r,s,a):t:n,autoPanel:(t,n)=>t||n})}}});function a6e(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function nxt(e){let t=[];if(e)e:for(let{name:n}of e){for(let r=0;r<n.length;r++){let s=n[r];if(/[a-zA-Z]/.test(s)&&!t.some(a=>a.toLowerCase()==s.toLowerCase())){t.push(s);continue e}}t.push("")}return t}function rxt(e,t,n){var r;let s=n?nxt(t.actions):[];return ii("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},ii("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),(r=t.actions)===null||r===void 0?void 0:r.map((a,i)=>{let l=!1,c=h=>{if(h.preventDefault(),l)return;l=!0;let m=pT(e.state.field(gp).diagnostics,t);m&&a.apply(e,m.from,m.to)},{name:u}=a,d=s[i]?u.indexOf(s[i]):-1,f=d<0?u:[u.slice(0,d),ii("u",u.slice(d,d+1)),u.slice(d+1)],p=a.markClass?" "+a.markClass:"";return ii("button",{type:"button",class:"cm-diagnosticAction"+p,onclick:c,onmousedown:c,"aria-label":` Action: ${u}${d<0?"":` (access key "${s[i]})"`}.`},f)}),t.source&&ii("div",{class:"cm-diagnosticSource"},t.source))}class SFn extends Wp{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return ii("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class i6e{constructor(t,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=rxt(t,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class W${constructor(t){this.view=t,this.items=[];let n=s=>{if(s.keyCode==27)s6e(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:a}=this.items[this.selectedIndex],i=nxt(a.actions);for(let l=0;l<i.length;l++)if(i[l].toUpperCase().charCodeAt(0)==s.keyCode){let c=pT(this.view.state.field(gp).diagnostics,a);c&&a.actions[l].apply(t,c.from,c.to)}}else return;s.preventDefault()},r=s=>{for(let a=0;a<this.items.length;a++)this.items[a].dom.contains(s.target)&&this.moveSelection(a)};this.list=ii("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=ii("div",{class:"cm-panel-lint"},this.list,ii("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>s6e(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(gp).selected;if(!t)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==t.diagnostic)return n;return-1}update(){let{diagnostics:t,selected:n}=this.view.state.field(gp),r=0,s=!1,a=null,i=new Set;for(t.between(0,this.view.state.doc.length,(l,c,{spec:u})=>{for(let d of u.diagnostics){if(i.has(d))continue;i.add(d);let f=-1,p;for(let h=r;h<this.items.length;h++)if(this.items[h].diagnostic==d){f=h;break}f<0?(p=new i6e(this.view,d),this.items.splice(r,0,p),s=!0):(p=this.items[f],f>r&&(this.items.splice(r,f-r),s=!0)),n&&p.diagnostic==n.diagnostic?p.dom.hasAttribute("aria-selected")||(p.dom.setAttribute("aria-selected","true"),a=p):p.dom.hasAttribute("aria-selected")&&p.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new i6e(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),a?(this.list.setAttribute("aria-activedescendant",a.id),this.view.requestMeasure({key:this,read:()=>({sel:a.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:c})=>{let u=c.height/this.list.offsetHeight;l.top<c.top?this.list.scrollTop-=(c.top-l.top)/u:l.bottom>c.bottom&&(this.list.scrollTop+=(l.bottom-c.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let t=this.list.firstChild;function n(){let r=t;t=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;t!=r.dom;)n();t=r.dom.nextSibling}else this.list.insertBefore(r.dom,t);for(;t;)n()}moveSelection(t){if(this.selectedIndex<0)return;let n=this.view.state.field(gp),r=pT(n.diagnostics,this.items[t].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:txt.of(r)})}static open(t){return new W$(t)}}function kFn(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function p6(e){return kFn(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const OFn=It.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:p6("#d11")},".cm-lintRange-warning":{backgroundImage:p6("orange")},".cm-lintRange-info":{backgroundImage:p6("#999")},".cm-lintRange-hint":{backgroundImage:p6("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function _Fn(e){return e=="error"?4:e=="warning"?3:e=="info"?2:1}function CFn(e){let t="hint",n=1;for(let r of e){let s=_Fn(r.severity);s>n&&(n=s,t=r.severity)}return t}const EFn=[gp,It.decorations.compute([gp],e=>{let{selected:t,panel:n}=e.field(gp);return!t||!n||t.from==t.to?Cn.none:Cn.set([gFn.range(t.from,t.to)])}),bDn(vFn,{hideOn:hFn}),OFn];var o6e=function(t){t===void 0&&(t={});var n=t,r=n.crosshairCursor,s=r===void 0?!1:r,a=[];t.closeBracketsKeymap!==!1&&(a=a.concat(g5n)),t.defaultKeymap!==!1&&(a=a.concat(D9n)),t.searchKeymap!==!1&&(a=a.concat(uFn)),t.historyKeymap!==!1&&(a=a.concat(V8n)),t.foldKeymap!==!1&&(a=a.concat(t4n)),t.completionKeymap!==!1&&(a=a.concat(Xvt)),t.lintKeymap!==!1&&(a=a.concat(wFn));var i=[];return t.lineNumbers!==!1&&i.push(IDn()),t.highlightActiveLineGutter!==!1&&i.push(PDn()),t.highlightSpecialChars!==!1&&i.push(Z3n()),t.history!==!1&&i.push($8n()),t.foldGutter!==!1&&i.push(a4n()),t.drawSelection!==!1&&i.push(D3n()),t.dropCursor!==!1&&i.push(U3n()),t.allowMultipleSelections!==!1&&i.push(os.allowMultipleSelections.of(!0)),t.indentOnInput!==!1&&i.push(ZDn()),t.syntaxHighlighting!==!1&&i.push(F1(c4n,{fallback:!0})),t.bracketMatching!==!1&&i.push(g4n()),t.closeBrackets!==!1&&i.push(f5n()),t.autocompletion!==!1&&i.push(Yvt()),t.rectangularSelection!==!1&&i.push(oDn()),s!==!1&&i.push(uDn()),t.highlightActiveLine!==!1&&i.push(J3n()),t.highlightSelectionMatches!==!1&&i.push(q9n()),t.tabSize&&typeof t.tabSize=="number"&&i.push(RN.of(" ".repeat(t.tabSize))),i.concat([AN.of(a.flat())]).filter(Boolean)};const jFn="#e5c07b",l6e="#e06c75",TFn="#56b6c2",NFn="#ffffff",M9="#abb2bf",ihe="#7d8799",IFn="#61afef",AFn="#98c379",c6e="#d19a66",RFn="#c678dd",PFn="#21252b",u6e="#2c313a",d6e="#282c34",AK="#353a42",$Fn="#3E4451",f6e="#528bff",MFn=It.theme({"&":{color:M9,backgroundColor:d6e},".cm-content":{caretColor:f6e},".cm-cursor, .cm-dropCursor":{borderLeftColor:f6e},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:$Fn},".cm-panels":{backgroundColor:PFn,color:M9},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:d6e,color:ihe,border:"none"},".cm-activeLineGutter":{backgroundColor:u6e},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:AK},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:AK,borderBottomColor:AK},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:u6e,color:M9}}},{dark:!0}),DFn=$g.define([{tag:fe.keyword,color:RFn},{tag:[fe.name,fe.deleted,fe.character,fe.propertyName,fe.macroName],color:l6e},{tag:[fe.function(fe.variableName),fe.labelName],color:IFn},{tag:[fe.color,fe.constant(fe.name),fe.standard(fe.name)],color:c6e},{tag:[fe.definition(fe.name),fe.separator],color:M9},{tag:[fe.typeName,fe.className,fe.number,fe.changed,fe.annotation,fe.modifier,fe.self,fe.namespace],color:jFn},{tag:[fe.operator,fe.operatorKeyword,fe.url,fe.escape,fe.regexp,fe.link,fe.special(fe.string)],color:TFn},{tag:[fe.meta,fe.comment],color:ihe},{tag:fe.strong,fontWeight:"bold"},{tag:fe.emphasis,fontStyle:"italic"},{tag:fe.strikethrough,textDecoration:"line-through"},{tag:fe.link,color:ihe,textDecoration:"underline"},{tag:fe.heading,fontWeight:"bold",color:l6e},{tag:[fe.atom,fe.bool,fe.special(fe.variableName)],color:c6e},{tag:[fe.processingInstruction,fe.string,fe.inserted],color:AFn},{tag:fe.invalid,color:NFn}]),LFn=[MFn,F1(DFn)];var FFn=It.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),zFn=function(t){t===void 0&&(t={});var n=t,r=n.indentWithTab,s=r===void 0?!0:r,a=n.editable,i=a===void 0?!0:a,l=n.readOnly,c=l===void 0?!1:l,u=n.theme,d=u===void 0?"light":u,f=n.placeholder,p=f===void 0?"":f,h=n.basicSetup,m=h===void 0?!0:h,g=[];switch(s&&g.unshift(AN.of([L9n])),m&&(typeof m=="boolean"?g.unshift(o6e()):g.unshift(o6e(m))),p&&g.unshift(rDn(p)),d){case"light":g.push(FFn);break;case"dark":g.push(LFn);break;case"none":break;default:g.push(d);break}return i===!1&&g.push(It.editable.of(!1)),c&&g.push(os.readOnly.of(!0)),[...g]},BFn=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(t=>!t.empty)});class UFn{constructor(t,n){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=n,this.timeoutMS=n,this.callbacks.push(t)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var t=this.callbacks.slice();this.callbacks.length=0,t.forEach(n=>{try{n()}catch(r){console.error("TimeoutLatch callback error:",r)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class p6e{constructor(){this.interval=null,this.latches=new Set}add(t){this.latches.add(t),this.start()}remove(t){this.latches.delete(t),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(t=>{t.tick(),t.isDone&&this.remove(t)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var RK=null,qFn=()=>typeof window>"u"?new p6e:(RK||(RK=new p6e),RK),h6e=Ay.define(),VFn=200,HFn=[];function WFn(e){var t=e.value,n=e.selection,r=e.onChange,s=e.onStatistics,a=e.onCreateEditor,i=e.onUpdate,l=e.extensions,c=l===void 0?HFn:l,u=e.autoFocus,d=e.theme,f=d===void 0?"light":d,p=e.height,h=p===void 0?null:p,m=e.minHeight,g=m===void 0?null:m,y=e.maxHeight,b=y===void 0?null:y,w=e.width,S=w===void 0?null:w,k=e.minWidth,_=k===void 0?null:k,C=e.maxWidth,E=C===void 0?null:C,j=e.placeholder,N=j===void 0?"":j,I=e.editable,R=I===void 0?!0:I,$=e.readOnly,F=$===void 0?!1:$,D=e.indentWithTab,V=D===void 0?!0:D,W=e.basicSetup,L=W===void 0?!0:W,z=e.root,B=e.initialState,M=v.useState(),G=M[0],U=M[1],P=v.useState(),q=P[0],Z=P[1],X=v.useState(),te=X[0],J=X[1],ee=v.useState(()=>({current:null}))[0],ae=v.useState(()=>({current:null}))[0],de=It.theme({"&":{height:h,minHeight:g,maxHeight:b,width:S,minWidth:_,maxWidth:E},"& .cm-scroller":{height:"100% !important"}}),Y=It.updateListener.of(pe=>{if(pe.docChanged&&typeof r=="function"&&!pe.transactions.some(ye=>ye.annotation(h6e))){ee.current?ee.current.reset():(ee.current=new UFn(()=>{if(ae.current){var ye=ae.current;ae.current=null,ye()}ee.current=null},VFn),qFn().add(ee.current));var le=pe.state.doc,ve=le.toString();r(ve,pe)}s&&s(BFn(pe))}),ne=zFn({theme:f,editable:R,readOnly:F,placeholder:N,indentWithTab:V,basicSetup:L}),ce=[Y,de,...ne];return i&&typeof i=="function"&&ce.push(It.updateListener.of(i)),ce=ce.concat(c),v.useLayoutEffect(()=>{if(G&&!te){var pe={doc:t,selection:n,extensions:ce},le=B?os.fromJSON(B.json,pe,B.fields):os.create(pe);if(J(le),!q){var ve=new It({state:le,parent:G,root:z});Z(ve),a&&a(ve,le)}}return()=>{q&&(J(void 0),Z(void 0))}},[G,te]),v.useEffect(()=>{e.container&&U(e.container)},[e.container]),v.useEffect(()=>()=>{q&&(q.destroy(),Z(void 0)),ee.current&&(ee.current.cancel(),ee.current=null)},[q]),v.useEffect(()=>{u&&q&&q.focus()},[u,q]),v.useEffect(()=>{q&&q.dispatch({effects:vr.reconfigure.of(ce)})},[f,c,h,g,b,S,_,E,N,R,F,V,L,r,i]),v.useEffect(()=>{if(t!==void 0){var pe=q?q.state.doc.toString():"";if(q&&t!==pe){var le=ee.current&&!ee.current.isDone,ve=()=>{q&&t!==q.state.doc.toString()&&q.dispatch({changes:{from:0,to:q.state.doc.toString().length,insert:t||""},annotations:[h6e.of(!0)]})};le?ae.current=ve:ve()}}},[t,q]),{state:te,setState:J,view:q,setView:Z,container:G,setContainer:U}}var ZFn=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Xc=v.forwardRef((e,t)=>{var n=e.className,r=e.value,s=r===void 0?"":r,a=e.selection,i=e.extensions,l=i===void 0?[]:i,c=e.onChange,u=e.onStatistics,d=e.onCreateEditor,f=e.onUpdate,p=e.autoFocus,h=e.theme,m=h===void 0?"light":h,g=e.height,y=e.minHeight,b=e.maxHeight,w=e.width,S=e.minWidth,k=e.maxWidth,_=e.basicSetup,C=e.placeholder,E=e.indentWithTab,j=e.editable,N=e.readOnly,I=e.root,R=e.initialState,$=dbt(e,ZFn),F=v.useRef(null),D=WFn({root:I,value:s,autoFocus:p,theme:m,height:g,minHeight:y,maxHeight:b,width:w,minWidth:S,maxWidth:k,basicSetup:_,placeholder:C,indentWithTab:E,editable:j,readOnly:N,selection:a,onChange:c,onStatistics:u,onCreateEditor:d,onUpdate:f,extensions:l,initialState:R}),V=D.state,W=D.view,L=D.container,z=D.setContainer;v.useImperativeHandle(t,()=>({editor:F.current,state:V,view:W}),[F,L,V,W]);var B=v.useCallback(G=>{F.current=G,z(G)},[z]);if(typeof s!="string")throw new Error("value must be typeof string but got "+typeof s);var M=typeof m=="string"?"cm-theme-"+m:"cm-theme";return o.jsx("div",EO({ref:B,className:""+M+(n?" "+n:"")},$))});Xc.displayName="CodeMirror";function GFn(e){return new kO(gwe.define(e))}const sxt=[Ym.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return Eo(()=>Promise.resolve().then(()=>c6),[],import.meta.url).then(e=>e.javascript())}}),Ym.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return Eo(()=>Promise.resolve().then(()=>j4n),void 0,import.meta.url).then(e=>e.json())}}),Ym.of({name:"JSX",extensions:["jsx"],load(){return Eo(()=>Promise.resolve().then(()=>c6),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),Ym.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return Eo(()=>Promise.resolve().then(()=>S8n),void 0,import.meta.url).then(e=>e.markdown())}}),Ym.of({name:"TSX",extensions:["tsx"],load(){return Eo(()=>Promise.resolve().then(()=>c6),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Ym.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return Eo(()=>Promise.resolve().then(()=>c6),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),Ym.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return Eo(()=>import("./shell-CjFT_Tl9.js"),[],import.meta.url).then(e=>GFn(e.shell))}})];function QFn(e,t=5){if(!e?.properties)return[];const n=[];function r(s,a,i){if(i>t)return;const l=Array.isArray(s.type)?s.type.join(" | "):s.type;if(n.push({path:a,label:a,description:s.description??s.title,type:l}),s.properties)for(const[c,u]of Object.entries(s.properties))r(u,`${a}.${c}`,i+1);if(s.items?.properties)for(const[c,u]of Object.entries(s.items.properties))r(u,`${a}[].${c}`,i+1)}for(const[s,a]of Object.entries(e.properties))r(a,s,1);return n}function YFn(e){const t=QFn(e);return Yvt({override:[XFn(t)],defaultKeymap:!0,closeOnBlur:!0,icons:!1})}function XFn(e){return t=>{const r=t.state.sliceDoc(Math.max(0,t.pos-50),t.pos).match(/\{\{([a-zA-Z0-9_.\[\]]*)?$/);if(!r)return null;const s=r[1]??"",a=t.pos-s.length,i=s?e.filter(c=>c.path.toLowerCase().startsWith(s.toLowerCase())):e;if(i.length===0)return null;const l=i.map(c=>({label:c.path,displayLabel:c.path,detail:c.type,info:c.description,apply:(u,d,f,p)=>{const g=u.state.sliceDoc(p,p+2)==="}}"?d.label:`${d.label}}}`;u.dispatch({changes:{from:f,to:p,insert:g},selection:{anchor:f+g.length}})}}));return{from:a,options:l,validFor:/^[a-zA-Z0-9_.\[\]]*$/}}}const KFn=/\{\{([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)\}\}/g,JFn=Cn.mark({class:"cm-variable-highlight"}),m6e=new uvt({regexp:KFn,decoration:()=>JFn}),ezn=yo.fromClass(class{decorations;constructor(e){this.decorations=m6e.createDeco(e)}update(e){this.decorations=m6e.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}),tzn=ezn;function nzn(){const e=$N({settings:{fontFamily:"var(--font-mono)",fontSize:"0.8rem",lineHighlight:"transparent",gutterBackground:"transparent",gutterForeground:"var(--neutral2)",background:"transparent",foreground:"var(--neutral6)",caret:"var(--neutral6)"},styles:[{tag:[fe.className,fe.propertyName],color:"var(--neutral6)"},{tag:fe.heading,color:"var(--accent3)",fontWeight:"bold"},{tag:[fe.heading1,fe.heading2,fe.heading3,fe.heading4,fe.heading5,fe.heading6],color:"var(--accent3)",fontWeight:"bold"},{tag:fe.emphasis,fontStyle:"italic",color:"var(--neutral6)"},{tag:fe.strong,fontWeight:"bold",color:"var(--neutral6)"},{tag:fe.link,color:"var(--accent3)",textDecoration:"underline"},{tag:fe.url,color:"var(--accent3)"},{tag:fe.monospace,color:"var(--neutral6)"},{tag:fe.strikethrough,textDecoration:"line-through"},{tag:fe.quote,fontStyle:"italic",color:"var(--neutral2)"}]}),t=It.theme({".cm-editor":{backgroundColor:"transparent"},".cm-content":{color:"var(--neutral6)",caretColor:"var(--neutral6)"},".cm-lineNumbers .cm-gutterElement":{color:"var(--neutral2)"},".cm-activeLineGutter":{color:"var(--neutral3)"},".cm-cursor":{borderLeftColor:"var(--neutral6)"},".cm-selectionBackground, .cm-content ::selection":{backgroundColor:"color-mix(in srgb, var(--accent3) 22%, transparent)"},".cm-tooltip-autocomplete":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",borderRadius:"6px",boxShadow:"0 8px 16px rgba(0, 0, 0, 0.2)"},".cm-tooltip-autocomplete > ul":{fontFamily:"var(--font-mono)"},".cm-completionLabel":{color:"var(--neutral6)"},".cm-completionDetail":{color:"var(--neutral3)",fontSize:"0.7rem",marginLeft:"auto",paddingLeft:"12px"},".cm-completionInfo":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",color:"var(--neutral3)",padding:"8px 12px"},".cm-completionIcon":{display:"none"},"ul.cm-completionList li[aria-selected]":{backgroundColor:"var(--surface4)",color:"var(--neutral6)"},".cm-line .cm-variable-highlight":{color:"var(--accent6) !important",fontWeight:"500"}});return[e,t]}function rzn(){const e=It.theme({"&":{backgroundColor:"transparent",color:"var(--neutral6)",fontSize:"0.8rem"},"&.cm-editor .cm-scroller":{fontFamily:"var(--font-mono)"},".cm-gutters":{backgroundColor:"transparent",color:"var(--neutral2)",borderRight:"none"},".cm-content":{color:"var(--neutral6)",caretColor:"var(--neutral6)"},".cm-activeLine":{backgroundColor:"transparent"},".cm-lineNumbers .cm-gutterElement":{color:"var(--neutral2)"},".cm-activeLineGutter":{backgroundColor:"transparent",color:"var(--neutral3)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--neutral6)"},"&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection":{background:"color-mix(in srgb, var(--accent3) 22%, transparent) !important"},".cm-tooltip-autocomplete":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",borderRadius:"6px",boxShadow:"0 8px 16px rgba(0, 0, 0, 0.2)"},".cm-tooltip-autocomplete > ul":{fontFamily:"var(--font-mono)"},".cm-completionLabel":{color:"var(--neutral6)"},".cm-completionDetail":{color:"var(--neutral3)",fontSize:"0.7rem",marginLeft:"auto",paddingLeft:"12px"},".cm-completionInfo":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",color:"var(--neutral3)",padding:"8px 12px"},".cm-completionIcon":{display:"none"},"ul.cm-completionList li[aria-selected]":{backgroundColor:"var(--surface4)",color:"var(--neutral6)"},".cm-line .cm-variable-highlight":{color:"var(--accent6) !important",fontWeight:"500"}}),t=$g.define([{tag:[fe.comment,fe.bracket],color:"var(--neutral2)"},{tag:[fe.string,fe.meta,fe.regexp],color:"var(--accent1)"},{tag:[fe.atom,fe.bool,fe.special(fe.variableName)],color:"var(--accent6)"},{tag:[fe.keyword,fe.operator,fe.tagName],color:"var(--accent2)"},{tag:[fe.function(fe.propertyName),fe.propertyName],color:"var(--accent5)"},{tag:[fe.definition(fe.variableName),fe.function(fe.variableName),fe.className,fe.attributeName],color:"var(--accent3)"},{tag:[fe.variableName,fe.number],color:"var(--accent5)"},{tag:[fe.name,fe.quote],color:"var(--accent1)"},{tag:fe.heading,color:"var(--accent3)",fontWeight:"bold"},{tag:[fe.heading1,fe.heading2,fe.heading3,fe.heading4,fe.heading5,fe.heading6],color:"var(--accent3)",fontWeight:"bold"},{tag:[fe.emphasis],fontStyle:"italic",color:"var(--neutral6)"},{tag:[fe.strong],fontWeight:"bold",color:"var(--neutral6)"},{tag:fe.link,color:"var(--accent3)",textDecoration:"underline"},{tag:fe.url,color:"var(--accent3)"},{tag:fe.monospace,color:"var(--neutral6)"},{tag:fe.strikethrough,textDecoration:"line-through"},{tag:[fe.deleted],color:"var(--accent2)"},{tag:fe.invalid,color:"var(--error)"},{tag:[fe.standard(fe.tagName)],color:"var(--accent1)"}]);return[e,F1(t)]}const Py=()=>{const e=EN().resolvedTheme==="dark";return v.useMemo(()=>e?nzn():rzn(),[e])},Qr=v.forwardRef(({data:e,value:t,onChange:n,showCopyButton:r=!0,className:s,language:a="json",highlightVariables:i=!1,placeholder:l,schema:c,autoFocus:u,lineNumbers:d=!0,lineWrapping:f=!0,editable:p,...h},m)=>{const g=Py(),y=e?JSON.stringify(e,null,2):t??"",b=v.useMemo(()=>{const w=[];return f&&w.push(It.lineWrapping),a==="json"?w.push(of):a==="markdown"&&w.push(qwe({base:CO,codeLanguages:sxt})),i&&a==="markdown"&&w.push(tzn),c&&a==="markdown"&&w.push(YFn(c)),p===!1&&w.push(os.readOnly.of(!0)),w},[a,i,c,p,f]);return o.jsxs("div",{className:K("rounded-md bg-surface3 p-1 font-mono relative border border-border1 overflow-hidden",s),...h,children:[r&&o.jsx(ya,{content:y,className:"absolute top-2 right-2 z-20"}),o.jsx(Xc,{ref:m,value:y,theme:g,extensions:b,onChange:n,editable:p,"aria-label":"Code editor",placeholder:l,height:"100%",style:{height:"100%"},autoFocus:u,basicSetup:{lineNumbers:d}})]})}),szn={js:"javascript",javascript:"javascript",mjs:"javascript",cjs:"javascript",node:"javascript",ts:"typescript",typescript:"typescript",mts:"typescript",cts:"typescript",tsx:"tsx",jsx:"jsx",json:"json",json5:"json",md:"markdown",markdown:"markdown",py:"python",python:"python",sh:"bash",bash:"bash",shell:"bash",zsh:"bash"};let PK=null;function azn(){return PK||(PK=(async()=>{const[{createHighlighterCore:e},{createJavaScriptRegexEngine:t}]=await Promise.all([Eo(()=>import("./core-Ba801SMK.js"),__vite__mapDeps([0,1,2]),import.meta.url),Eo(()=>import("./engine-javascript-CSIo_1eZ.js"),__vite__mapDeps([3,1]),import.meta.url)]);return e({themes:[Eo(()=>import("./github-light-DAi9KRSo.js"),[],import.meta.url),Eo(()=>import("./github-dark-DHJKELXO.js"),[],import.meta.url)],langs:[Eo(()=>import("./javascript-ySlJ1b_l.js"),[],import.meta.url),Eo(()=>import("./typescript-Dj6nwHGl.js"),[],import.meta.url),Eo(()=>import("./tsx-B6W0miNI.js"),[],import.meta.url),Eo(()=>import("./jsx-BAng5TT0.js"),[],import.meta.url),Eo(()=>import("./json-BQoSv7ci.js"),[],import.meta.url),Eo(()=>import("./bash-atvbtKCR.js"),[],import.meta.url),Eo(()=>import("./markdown-UIAJJxZW.js"),[],import.meta.url),Eo(()=>import("./python-DhUJRlN_.js"),[],import.meta.url)],engine:t()})})()),PK}async function izn(e,t){const n=szn[t?.toLowerCase()];if(!n)return null;const r=await azn(),{tokens:s}=r.codeToTokens(e,{lang:n,defaultColor:!1,themes:{light:"github-light",dark:"github-dark"}});return s}const ozn=e=>{try{return JSON.stringify(e??{},null,2)}catch{return"{}"}},lzn=({editorClassName:e="h-[240px] max-h-[40vh]",onSaved:t})=>{const n=Py(),{settings:r,setSettings:s}=Bq(),a=r?.tracingOptions,i=v.useMemo(()=>ozn(a),[a]),[l,c]=v.useState(()=>i),u=v.useRef(!1);v.useEffect(()=>{u.current||c(i)},[i]);const d=p=>{u.current=!0,c(p)},f=()=>{if(!l){s({...r,tracingOptions:void 0}),t?.();return}try{const p=JSON.parse(l);typeof p=="object"&&p!==null&&s({...r,tracingOptions:p})}catch{return}t?.()};return o.jsxs("div",{className:"space-y-2 px-5 py-2",children:[o.jsx(ge,{as:"h3",variant:"ui-md",className:"text-neutral3",children:"Tracing Options"}),o.jsx(Xc,{value:l,onChange:d,theme:n,extensions:[of],className:K("overflow-y-scroll bg-surface3 rounded-lg overflow-hidden p-3",e)}),o.jsx("div",{className:"flex items-center justify-end",children:o.jsx(ue,{type:"button",onClick:f,children:"Save"})})]})},czn=()=>{const[e,t]=v.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx(ue,{type:"button",variant:"ghost",size:"icon-md","aria-label":"Run Options",onClick:()=>t(!0),children:o.jsx(Ue,{children:o.jsx(Yye,{})})})}),o.jsx(Bn,{children:"Run Options"})]}),o.jsx(br,{open:e,onOpenChange:t,children:o.jsxs(xr,{children:[o.jsxs(wr,{children:[o.jsx(gr,{children:"Run Options"}),o.jsx(Qs,{children:"Configure tracing and debug options for this workflow run"})]}),o.jsx(Ar,{children:o.jsx(lzn,{onSaved:()=>t(!1)})})]})})]})};function uzn({status:e}){switch(e){case"running":return o.jsx(Gt,{});case"failed":return o.jsx(vs,{className:"text-accent2"});case"canceled":return o.jsx(xf,{className:"text-neutral3"});case"pending":case"waiting":return o.jsx(sO,{className:"text-neutral3"});case"suspended":return o.jsx(ZU,{className:"text-accent3"});case"success":return o.jsx(Js,{className:"text-accent1"});default:return o.jsx(sO,{className:"text-neutral3"})}}function axt({status:e}){return o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx(Ue,{"aria-label":e,className:"shrink-0",children:o.jsx(uzn,{status:e})})}),o.jsx(Bn,{children:e})]})}var $K,g6e;function Kwe(){if(g6e)return $K;g6e=1;var e="\0",t="\0",n="";class r{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>{};_defaultEdgeLabelFn=()=>{};_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(d){d&&(this._isDirected=Object.hasOwn(d,"directed")?d.directed:!0,this._isMultigraph=Object.hasOwn(d,"multigraph")?d.multigraph:!1,this._isCompound=Object.hasOwn(d,"compound")?d.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(d){return this._label=d,this}graph(){return this._label}setDefaultNodeLabel(d){return this._defaultNodeLabelFn=d,typeof d!="function"&&(this._defaultNodeLabelFn=()=>d),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var d=this;return this.nodes().filter(f=>Object.keys(d._in[f]).length===0)}sinks(){var d=this;return this.nodes().filter(f=>Object.keys(d._out[f]).length===0)}setNodes(d,f){var p=arguments,h=this;return d.forEach(function(m){p.length>1?h.setNode(m,f):h.setNode(m)}),this}setNode(d,f){return Object.hasOwn(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=f),this):(this._nodes[d]=arguments.length>1?f:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=t,this._children[d]={},this._children[t][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)}node(d){return this._nodes[d]}hasNode(d){return Object.hasOwn(this._nodes,d)}removeNode(d){var f=this;if(Object.hasOwn(this._nodes,d)){var p=h=>f.removeEdge(f._edgeObjs[h]);delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],this.children(d).forEach(function(h){f.setParent(h)}),delete this._children[d]),Object.keys(this._in[d]).forEach(p),delete this._in[d],delete this._preds[d],Object.keys(this._out[d]).forEach(p),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this}setParent(d,f){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(f===void 0)f=t;else{f+="";for(var p=f;p!==void 0;p=this.parent(p))if(p===d)throw new Error("Setting "+f+" as parent of "+d+" would create a cycle");this.setNode(f)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=f,this._children[f][d]=!0,this}_removeFromParentsChildList(d){delete this._children[this._parent[d]][d]}parent(d){if(this._isCompound){var f=this._parent[d];if(f!==t)return f}}children(d=t){if(this._isCompound){var f=this._children[d];if(f)return Object.keys(f)}else{if(d===t)return this.nodes();if(this.hasNode(d))return[]}}predecessors(d){var f=this._preds[d];if(f)return Object.keys(f)}successors(d){var f=this._sucs[d];if(f)return Object.keys(f)}neighbors(d){var f=this.predecessors(d);if(f){const h=new Set(f);for(var p of this.successors(d))h.add(p);return Array.from(h.values())}}isLeaf(d){var f;return this.isDirected()?f=this.successors(d):f=this.neighbors(d),f.length===0}filterNodes(d){var f=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});f.setGraph(this.graph());var p=this;Object.entries(this._nodes).forEach(function([g,y]){d(g)&&f.setNode(g,y)}),Object.values(this._edgeObjs).forEach(function(g){f.hasNode(g.v)&&f.hasNode(g.w)&&f.setEdge(g,p.edge(g))});var h={};function m(g){var y=p.parent(g);return y===void 0||f.hasNode(y)?(h[g]=y,y):y in h?h[y]:m(y)}return this._isCompound&&f.nodes().forEach(g=>f.setParent(g,m(g))),f}setDefaultEdgeLabel(d){return this._defaultEdgeLabelFn=d,typeof d!="function"&&(this._defaultEdgeLabelFn=()=>d),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(d,f){var p=this,h=arguments;return d.reduce(function(m,g){return h.length>1?p.setEdge(m,g,f):p.setEdge(m,g),g}),this}setEdge(){var d,f,p,h,m=!1,g=arguments[0];typeof g=="object"&&g!==null&&"v"in g?(d=g.v,f=g.w,p=g.name,arguments.length===2&&(h=arguments[1],m=!0)):(d=g,f=arguments[1],p=arguments[3],arguments.length>2&&(h=arguments[2],m=!0)),d=""+d,f=""+f,p!==void 0&&(p=""+p);var y=i(this._isDirected,d,f,p);if(Object.hasOwn(this._edgeLabels,y))return m&&(this._edgeLabels[y]=h),this;if(p!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(f),this._edgeLabels[y]=m?h:this._defaultEdgeLabelFn(d,f,p);var b=l(this._isDirected,d,f,p);return d=b.v,f=b.w,Object.freeze(b),this._edgeObjs[y]=b,s(this._preds[f],d),s(this._sucs[d],f),this._in[f][y]=b,this._out[d][y]=b,this._edgeCount++,this}edge(d,f,p){var h=arguments.length===1?c(this._isDirected,arguments[0]):i(this._isDirected,d,f,p);return this._edgeLabels[h]}edgeAsObj(){const d=this.edge(...arguments);return typeof d!="object"?{label:d}:d}hasEdge(d,f,p){var h=arguments.length===1?c(this._isDirected,arguments[0]):i(this._isDirected,d,f,p);return Object.hasOwn(this._edgeLabels,h)}removeEdge(d,f,p){var h=arguments.length===1?c(this._isDirected,arguments[0]):i(this._isDirected,d,f,p),m=this._edgeObjs[h];return m&&(d=m.v,f=m.w,delete this._edgeLabels[h],delete this._edgeObjs[h],a(this._preds[f],d),a(this._sucs[d],f),delete this._in[f][h],delete this._out[d][h],this._edgeCount--),this}inEdges(d,f){var p=this._in[d];if(p){var h=Object.values(p);return f?h.filter(m=>m.v===f):h}}outEdges(d,f){var p=this._out[d];if(p){var h=Object.values(p);return f?h.filter(m=>m.w===f):h}}nodeEdges(d,f){var p=this.inEdges(d,f);if(p)return p.concat(this.outEdges(d,f))}}function s(u,d){u[d]?u[d]++:u[d]=1}function a(u,d){--u[d]||delete u[d]}function i(u,d,f,p){var h=""+d,m=""+f;if(!u&&h>m){var g=h;h=m,m=g}return h+n+m+n+(p===void 0?e:p)}function l(u,d,f,p){var h=""+d,m=""+f;if(!u&&h>m){var g=h;h=m,m=g}var y={v:h,w:m};return p&&(y.name=p),y}function c(u,d){return i(u,d.v,d.w,d.name)}return $K=r,$K}var MK,v6e;function dzn(){return v6e||(v6e=1,MK="2.2.4"),MK}var DK,y6e;function fzn(){return y6e||(y6e=1,DK={Graph:Kwe(),version:dzn()}),DK}var LK,b6e;function pzn(){if(b6e)return LK;b6e=1;var e=Kwe();LK={write:t,read:s};function t(a){var i={options:{directed:a.isDirected(),multigraph:a.isMultigraph(),compound:a.isCompound()},nodes:n(a),edges:r(a)};return a.graph()!==void 0&&(i.value=structuredClone(a.graph())),i}function n(a){return a.nodes().map(function(i){var l=a.node(i),c=a.parent(i),u={v:i};return l!==void 0&&(u.value=l),c!==void 0&&(u.parent=c),u})}function r(a){return a.edges().map(function(i){var l=a.edge(i),c={v:i.v,w:i.w};return i.name!==void 0&&(c.name=i.name),l!==void 0&&(c.value=l),c})}function s(a){var i=new e(a.options).setGraph(a.value);return a.nodes.forEach(function(l){i.setNode(l.v,l.value),l.parent&&i.setParent(l.v,l.parent)}),a.edges.forEach(function(l){i.setEdge({v:l.v,w:l.w,name:l.name},l.value)}),i}return LK}var FK,x6e;function hzn(){if(x6e)return FK;x6e=1,FK=e;function e(t){var n={},r=[],s;function a(i){Object.hasOwn(n,i)||(n[i]=!0,s.push(i),t.successors(i).forEach(a),t.predecessors(i).forEach(a))}return t.nodes().forEach(function(i){s=[],a(i),s.length&&r.push(s)}),r}return FK}var zK,w6e;function ixt(){if(w6e)return zK;w6e=1;class e{_arr=[];_keyIndices={};size(){return this._arr.length}keys(){return this._arr.map(function(n){return n.key})}has(n){return Object.hasOwn(this._keyIndices,n)}priority(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(n,r){var s=this._keyIndices;if(n=String(n),!Object.hasOwn(s,n)){var a=this._arr,i=a.length;return s[n]=i,a.push({key:n,priority:r}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key}decrease(n,r){var s=this._keyIndices[n];if(r>this._arr[s].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[s].priority+" New: "+r);this._arr[s].priority=r,this._decrease(s)}_heapify(n){var r=this._arr,s=2*n,a=s+1,i=n;s<r.length&&(i=r[s].priority<r[i].priority?s:i,a<r.length&&(i=r[a].priority<r[i].priority?a:i),i!==n&&(this._swap(n,i),this._heapify(i)))}_decrease(n){for(var r=this._arr,s=r[n].priority,a;n!==0&&(a=n>>1,!(r[a].priority<s));)this._swap(n,a),n=a}_swap(n,r){var s=this._arr,a=this._keyIndices,i=s[n],l=s[r];s[n]=l,s[r]=i,a[l.key]=n,a[i.key]=r}}return zK=e,zK}var BK,S6e;function oxt(){if(S6e)return BK;S6e=1;var e=ixt();BK=n;var t=()=>1;function n(s,a,i,l){return r(s,String(a),i||t,l||function(c){return s.outEdges(c)})}function r(s,a,i,l){var c={},u=new e,d,f,p=function(h){var m=h.v!==d?h.v:h.w,g=c[m],y=i(h),b=f.distance+y;if(y<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+h+" Weight: "+y);b<g.distance&&(g.distance=b,g.predecessor=d,u.decrease(m,b))};for(s.nodes().forEach(function(h){var m=h===a?0:Number.POSITIVE_INFINITY;c[h]={distance:m},u.add(h,m)});u.size()>0&&(d=u.removeMin(),f=c[d],f.distance!==Number.POSITIVE_INFINITY);)l(d).forEach(p);return c}return BK}var UK,k6e;function mzn(){if(k6e)return UK;k6e=1;var e=oxt();UK=t;function t(n,r,s){return n.nodes().reduce(function(a,i){return a[i]=e(n,i,r,s),a},{})}return UK}var qK,O6e;function lxt(){if(O6e)return qK;O6e=1,qK=e;function e(t){var n=0,r=[],s={},a=[];function i(l){var c=s[l]={onStack:!0,lowlink:n,index:n++};if(r.push(l),t.successors(l).forEach(function(f){Object.hasOwn(s,f)?s[f].onStack&&(c.lowlink=Math.min(c.lowlink,s[f].index)):(i(f),c.lowlink=Math.min(c.lowlink,s[f].lowlink))}),c.lowlink===c.index){var u=[],d;do d=r.pop(),s[d].onStack=!1,u.push(d);while(l!==d);a.push(u)}}return t.nodes().forEach(function(l){Object.hasOwn(s,l)||i(l)}),a}return qK}var VK,_6e;function gzn(){if(_6e)return VK;_6e=1;var e=lxt();VK=t;function t(n){return e(n).filter(function(r){return r.length>1||r.length===1&&n.hasEdge(r[0],r[0])})}return VK}var HK,C6e;function vzn(){if(C6e)return HK;C6e=1,HK=t;var e=()=>1;function t(r,s,a){return n(r,s||e,a||function(i){return r.outEdges(i)})}function n(r,s,a){var i={},l=r.nodes();return l.forEach(function(c){i[c]={},i[c][c]={distance:0},l.forEach(function(u){c!==u&&(i[c][u]={distance:Number.POSITIVE_INFINITY})}),a(c).forEach(function(u){var d=u.v===c?u.w:u.v,f=s(u);i[c][d]={distance:f,predecessor:c}})}),l.forEach(function(c){var u=i[c];l.forEach(function(d){var f=i[d];l.forEach(function(p){var h=f[c],m=u[p],g=f[p],y=h.distance+m.distance;y<g.distance&&(g.distance=y,g.predecessor=m.predecessor)})})}),i}return HK}var WK,E6e;function cxt(){if(E6e)return WK;E6e=1;function e(n){var r={},s={},a=[];function i(l){if(Object.hasOwn(s,l))throw new t;Object.hasOwn(r,l)||(s[l]=!0,r[l]=!0,n.predecessors(l).forEach(i),delete s[l],a.push(l))}if(n.sinks().forEach(i),Object.keys(r).length!==n.nodeCount())throw new t;return a}class t extends Error{constructor(){super(...arguments)}}return WK=e,e.CycleException=t,WK}var ZK,j6e;function yzn(){if(j6e)return ZK;j6e=1;var e=cxt();ZK=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return ZK}var GK,T6e;function uxt(){if(T6e)return GK;T6e=1,GK=e;function e(s,a,i){Array.isArray(a)||(a=[a]);var l=s.isDirected()?f=>s.successors(f):f=>s.neighbors(f),c=i==="post"?t:n,u=[],d={};return a.forEach(f=>{if(!s.hasNode(f))throw new Error("Graph does not have node: "+f);c(f,l,d,u)}),u}function t(s,a,i,l){for(var c=[[s,!1]];c.length>0;){var u=c.pop();u[1]?l.push(u[0]):Object.hasOwn(i,u[0])||(i[u[0]]=!0,c.push([u[0],!0]),r(a(u[0]),d=>c.push([d,!1])))}}function n(s,a,i,l){for(var c=[s];c.length>0;){var u=c.pop();Object.hasOwn(i,u)||(i[u]=!0,l.push(u),r(a(u),d=>c.push(d)))}}function r(s,a){for(var i=s.length;i--;)a(s[i],i,s);return s}return GK}var QK,N6e;function bzn(){if(N6e)return QK;N6e=1;var e=uxt();QK=t;function t(n,r){return e(n,r,"post")}return QK}var YK,I6e;function xzn(){if(I6e)return YK;I6e=1;var e=uxt();YK=t;function t(n,r){return e(n,r,"pre")}return YK}var XK,A6e;function wzn(){if(A6e)return XK;A6e=1;var e=Kwe(),t=ixt();XK=n;function n(r,s){var a=new e,i={},l=new t,c;function u(f){var p=f.v===c?f.w:f.v,h=l.priority(p);if(h!==void 0){var m=s(f);m<h&&(i[p]=c,l.decrease(p,m))}}if(r.nodeCount()===0)return a;r.nodes().forEach(function(f){l.add(f,Number.POSITIVE_INFINITY),a.setNode(f)}),l.decrease(r.nodes()[0],0);for(var d=!1;l.size()>0;){if(c=l.removeMin(),Object.hasOwn(i,c))a.setEdge(c,i[c]);else{if(d)throw new Error("Input graph is not connected: "+r);d=!0}r.nodeEdges(c).forEach(u)}return a}return XK}var KK,R6e;function Szn(){return R6e||(R6e=1,KK={components:hzn(),dijkstra:oxt(),dijkstraAll:mzn(),findCycles:gzn(),floydWarshall:vzn(),isAcyclic:yzn(),postorder:bzn(),preorder:xzn(),prim:wzn(),tarjan:lxt(),topsort:cxt()}),KK}var JK,P6e;function Eg(){if(P6e)return JK;P6e=1;var e=fzn();return JK={Graph:e.Graph,json:pzn(),alg:Szn(),version:e.version},JK}var eJ,$6e;function kzn(){if($6e)return eJ;$6e=1;class e{constructor(){let s={};s._next=s._prev=s,this._sentinel=s}dequeue(){let s=this._sentinel,a=s._prev;if(a!==s)return t(a),a}enqueue(s){let a=this._sentinel;s._prev&&s._next&&t(s),s._next=a._next,a._next._prev=s,a._next=s,s._prev=a}toString(){let s=[],a=this._sentinel,i=a._prev;for(;i!==a;)s.push(JSON.stringify(i,n)),i=i._prev;return"["+s.join(", ")+"]"}}function t(r){r._prev._next=r._next,r._next._prev=r._prev,delete r._next,delete r._prev}function n(r,s){if(r!=="_next"&&r!=="_prev")return s}return eJ=e,eJ}var tJ,M6e;function Ozn(){if(M6e)return tJ;M6e=1;let e=Eg().Graph,t=kzn();tJ=r;let n=()=>1;function r(u,d){if(u.nodeCount()<=1)return[];let f=i(u,d||n);return s(f.graph,f.buckets,f.zeroIdx).flatMap(h=>u.outEdges(h.v,h.w))}function s(u,d,f){let p=[],h=d[d.length-1],m=d[0],g;for(;u.nodeCount();){for(;g=m.dequeue();)a(u,d,f,g);for(;g=h.dequeue();)a(u,d,f,g);if(u.nodeCount()){for(let y=d.length-2;y>0;--y)if(g=d[y].dequeue(),g){p=p.concat(a(u,d,f,g,!0));break}}}return p}function a(u,d,f,p,h){let m=h?[]:void 0;return u.inEdges(p.v).forEach(g=>{let y=u.edge(g),b=u.node(g.v);h&&m.push({v:g.v,w:g.w}),b.out-=y,l(d,f,b)}),u.outEdges(p.v).forEach(g=>{let y=u.edge(g),b=g.w,w=u.node(b);w.in-=y,l(d,f,w)}),u.removeNode(p.v),m}function i(u,d){let f=new e,p=0,h=0;u.nodes().forEach(y=>{f.setNode(y,{v:y,in:0,out:0})}),u.edges().forEach(y=>{let b=f.edge(y.v,y.w)||0,w=d(y),S=b+w;f.setEdge(y.v,y.w,S),h=Math.max(h,f.node(y.v).out+=w),p=Math.max(p,f.node(y.w).in+=w)});let m=c(h+p+3).map(()=>new t),g=p+1;return f.nodes().forEach(y=>{l(m,g,f.node(y))}),{graph:f,buckets:m,zeroIdx:g}}function l(u,d,f){f.out?f.in?u[f.out-f.in+d].enqueue(f):u[u.length-1].enqueue(f):u[0].enqueue(f)}function c(u){const d=[];for(let f=0;f<u;f++)d.push(f);return d}return tJ}var nJ,D6e;function jl(){if(D6e)return nJ;D6e=1;let e=Eg().Graph;nJ={addBorderNode:d,addDummyNode:t,applyWithChunking:h,asNonCompoundGraph:r,buildLayerMatrix:l,intersectRect:i,mapValues:C,maxRank:m,normalizeRanks:c,notime:b,partition:g,pick:_,predecessorWeights:a,range:k,removeEmptyRanks:u,simplify:n,successorWeights:s,time:y,uniqueId:S,zipObject:E};function t(j,N,I,R){for(var $=R;j.hasNode($);)$=S(R);return I.dummy=N,j.setNode($,I),$}function n(j){let N=new e().setGraph(j.graph());return j.nodes().forEach(I=>N.setNode(I,j.node(I))),j.edges().forEach(I=>{let R=N.edge(I.v,I.w)||{weight:0,minlen:1},$=j.edge(I);N.setEdge(I.v,I.w,{weight:R.weight+$.weight,minlen:Math.max(R.minlen,$.minlen)})}),N}function r(j){let N=new e({multigraph:j.isMultigraph()}).setGraph(j.graph());return j.nodes().forEach(I=>{j.children(I).length||N.setNode(I,j.node(I))}),j.edges().forEach(I=>{N.setEdge(I,j.edge(I))}),N}function s(j){let N=j.nodes().map(I=>{let R={};return j.outEdges(I).forEach($=>{R[$.w]=(R[$.w]||0)+j.edge($).weight}),R});return E(j.nodes(),N)}function a(j){let N=j.nodes().map(I=>{let R={};return j.inEdges(I).forEach($=>{R[$.v]=(R[$.v]||0)+j.edge($).weight}),R});return E(j.nodes(),N)}function i(j,N){let I=j.x,R=j.y,$=N.x-I,F=N.y-R,D=j.width/2,V=j.height/2;if(!$&&!F)throw new Error("Not possible to find intersection inside of the rectangle");let W,L;return Math.abs(F)*D>Math.abs($)*V?(F<0&&(V=-V),W=V*$/F,L=V):($<0&&(D=-D),W=D,L=D*F/$),{x:I+W,y:R+L}}function l(j){let N=k(m(j)+1).map(()=>[]);return j.nodes().forEach(I=>{let R=j.node(I),$=R.rank;$!==void 0&&(N[$][R.order]=I)}),N}function c(j){let N=j.nodes().map(R=>{let $=j.node(R).rank;return $===void 0?Number.MAX_VALUE:$}),I=h(Math.min,N);j.nodes().forEach(R=>{let $=j.node(R);Object.hasOwn($,"rank")&&($.rank-=I)})}function u(j){let N=j.nodes().map(D=>j.node(D).rank),I=h(Math.min,N),R=[];j.nodes().forEach(D=>{let V=j.node(D).rank-I;R[V]||(R[V]=[]),R[V].push(D)});let $=0,F=j.graph().nodeRankFactor;Array.from(R).forEach((D,V)=>{D===void 0&&V%F!==0?--$:D!==void 0&&$&&D.forEach(W=>j.node(W).rank+=$)})}function d(j,N,I,R){let $={width:0,height:0};return arguments.length>=4&&($.rank=I,$.order=R),t(j,"border",$,N)}function f(j,N=p){const I=[];for(let R=0;R<j.length;R+=N){const $=j.slice(R,R+N);I.push($)}return I}const p=65535;function h(j,N){if(N.length>p){const I=f(N);return j.apply(null,I.map(R=>j.apply(null,R)))}else return j.apply(null,N)}function m(j){const I=j.nodes().map(R=>{let $=j.node(R).rank;return $===void 0?Number.MIN_VALUE:$});return h(Math.max,I)}function g(j,N){let I={lhs:[],rhs:[]};return j.forEach(R=>{N(R)?I.lhs.push(R):I.rhs.push(R)}),I}function y(j,N){let I=Date.now();try{return N()}finally{console.log(j+" time: "+(Date.now()-I)+"ms")}}function b(j,N){return N()}let w=0;function S(j){var N=++w;return j+(""+N)}function k(j,N,I=1){N==null&&(N=j,j=0);let R=F=>F<N;I<0&&(R=F=>N<F);const $=[];for(let F=j;R(F);F+=I)$.push(F);return $}function _(j,N){const I={};for(const R of N)j[R]!==void 0&&(I[R]=j[R]);return I}function C(j,N){let I=N;return typeof N=="string"&&(I=R=>R[N]),Object.entries(j).reduce((R,[$,F])=>(R[$]=I(F,$),R),{})}function E(j,N){return j.reduce((I,R,$)=>(I[R]=N[$],I),{})}return nJ}var rJ,L6e;function _zn(){if(L6e)return rJ;L6e=1;let e=Ozn(),t=jl().uniqueId;rJ={run:n,undo:s};function n(a){(a.graph().acyclicer==="greedy"?e(a,l(a)):r(a)).forEach(c=>{let u=a.edge(c);a.removeEdge(c),u.forwardName=c.name,u.reversed=!0,a.setEdge(c.w,c.v,u,t("rev"))});function l(c){return u=>c.edge(u).weight}}function r(a){let i=[],l={},c={};function u(d){Object.hasOwn(c,d)||(c[d]=!0,l[d]=!0,a.outEdges(d).forEach(f=>{Object.hasOwn(l,f.w)?i.push(f):u(f.w)}),delete l[d])}return a.nodes().forEach(u),i}function s(a){a.edges().forEach(i=>{let l=a.edge(i);if(l.reversed){a.removeEdge(i);let c=l.forwardName;delete l.reversed,delete l.forwardName,a.setEdge(i.w,i.v,l,c)}})}return rJ}var sJ,F6e;function Czn(){if(F6e)return sJ;F6e=1;let e=jl();sJ={run:t,undo:r};function t(s){s.graph().dummyChains=[],s.edges().forEach(a=>n(s,a))}function n(s,a){let i=a.v,l=s.node(i).rank,c=a.w,u=s.node(c).rank,d=a.name,f=s.edge(a),p=f.labelRank;if(u===l+1)return;s.removeEdge(a);let h,m,g;for(g=0,++l;l<u;++g,++l)f.points=[],m={width:0,height:0,edgeLabel:f,edgeObj:a,rank:l},h=e.addDummyNode(s,"edge",m,"_d"),l===p&&(m.width=f.width,m.height=f.height,m.dummy="edge-label",m.labelpos=f.labelpos),s.setEdge(i,h,{weight:f.weight},d),g===0&&s.graph().dummyChains.push(h),i=h;s.setEdge(i,c,{weight:f.weight},d)}function r(s){s.graph().dummyChains.forEach(a=>{let i=s.node(a),l=i.edgeLabel,c;for(s.setEdge(i.edgeObj,l);i.dummy;)c=s.successors(a)[0],s.removeNode(a),l.points.push({x:i.x,y:i.y}),i.dummy==="edge-label"&&(l.x=i.x,l.y=i.y,l.width=i.width,l.height=i.height),a=c,i=s.node(a)})}return sJ}var aJ,z6e;function h7(){if(z6e)return aJ;z6e=1;const{applyWithChunking:e}=jl();aJ={longestPath:t,slack:n};function t(r){var s={};function a(i){var l=r.node(i);if(Object.hasOwn(s,i))return l.rank;s[i]=!0;let c=r.outEdges(i).map(d=>d==null?Number.POSITIVE_INFINITY:a(d.w)-r.edge(d).minlen);var u=e(Math.min,c);return u===Number.POSITIVE_INFINITY&&(u=0),l.rank=u}r.sources().forEach(a)}function n(r,s){return r.node(s.w).rank-r.node(s.v).rank-r.edge(s).minlen}return aJ}var iJ,B6e;function dxt(){if(B6e)return iJ;B6e=1;var e=Eg().Graph,t=h7().slack;iJ=n;function n(i){var l=new e({directed:!1}),c=i.nodes()[0],u=i.nodeCount();l.setNode(c,{});for(var d,f;r(l,i)<u;)d=s(l,i),f=l.hasNode(d.v)?t(i,d):-t(i,d),a(l,i,f);return l}function r(i,l){function c(u){l.nodeEdges(u).forEach(d=>{var f=d.v,p=u===f?d.w:f;!i.hasNode(p)&&!t(l,d)&&(i.setNode(p,{}),i.setEdge(u,p,{}),c(p))})}return i.nodes().forEach(c),i.nodeCount()}function s(i,l){return l.edges().reduce((u,d)=>{let f=Number.POSITIVE_INFINITY;return i.hasNode(d.v)!==i.hasNode(d.w)&&(f=t(l,d)),f<u[0]?[f,d]:u},[Number.POSITIVE_INFINITY,null])[1]}function a(i,l,c){i.nodes().forEach(u=>l.node(u).rank+=c)}return iJ}var oJ,U6e;function Ezn(){if(U6e)return oJ;U6e=1;var e=dxt(),t=h7().slack,n=h7().longestPath,r=Eg().alg.preorder,s=Eg().alg.postorder,a=jl().simplify;oJ=i,i.initLowLimValues=d,i.initCutValues=l,i.calcCutValue=u,i.leaveEdge=p,i.enterEdge=h,i.exchangeEdges=m;function i(w){w=a(w),n(w);var S=e(w);d(S),l(S,w);for(var k,_;k=p(S);)_=h(S,w,k),m(S,w,k,_)}function l(w,S){var k=s(w,w.nodes());k=k.slice(0,k.length-1),k.forEach(_=>c(w,S,_))}function c(w,S,k){var _=w.node(k),C=_.parent;w.edge(k,C).cutvalue=u(w,S,k)}function u(w,S,k){var _=w.node(k),C=_.parent,E=!0,j=S.edge(k,C),N=0;return j||(E=!1,j=S.edge(C,k)),N=j.weight,S.nodeEdges(k).forEach(I=>{var R=I.v===k,$=R?I.w:I.v;if($!==C){var F=R===E,D=S.edge(I).weight;if(N+=F?D:-D,y(w,k,$)){var V=w.edge(k,$).cutvalue;N+=F?-V:V}}}),N}function d(w,S){arguments.length<2&&(S=w.nodes()[0]),f(w,{},1,S)}function f(w,S,k,_,C){var E=k,j=w.node(_);return S[_]=!0,w.neighbors(_).forEach(N=>{Object.hasOwn(S,N)||(k=f(w,S,k,N,_))}),j.low=E,j.lim=k++,C?j.parent=C:delete j.parent,k}function p(w){return w.edges().find(S=>w.edge(S).cutvalue<0)}function h(w,S,k){var _=k.v,C=k.w;S.hasEdge(_,C)||(_=k.w,C=k.v);var E=w.node(_),j=w.node(C),N=E,I=!1;E.lim>j.lim&&(N=j,I=!0);var R=S.edges().filter($=>I===b(w,w.node($.v),N)&&I!==b(w,w.node($.w),N));return R.reduce(($,F)=>t(S,F)<t(S,$)?F:$)}function m(w,S,k,_){var C=k.v,E=k.w;w.removeEdge(C,E),w.setEdge(_.v,_.w,{}),d(w),l(w,S),g(w,S)}function g(w,S){var k=w.nodes().find(C=>!S.node(C).parent),_=r(w,k);_=_.slice(1),_.forEach(C=>{var E=w.node(C).parent,j=S.edge(C,E),N=!1;j||(j=S.edge(E,C),N=!0),S.node(C).rank=S.node(E).rank+(N?j.minlen:-j.minlen)})}function y(w,S,k){return w.hasEdge(S,k)}function b(w,S,k){return k.low<=S.lim&&S.lim<=k.lim}return oJ}var lJ,q6e;function jzn(){if(q6e)return lJ;q6e=1;var e=h7(),t=e.longestPath,n=dxt(),r=Ezn();lJ=s;function s(c){var u=c.graph().ranker;if(u instanceof Function)return u(c);switch(c.graph().ranker){case"network-simplex":l(c);break;case"tight-tree":i(c);break;case"longest-path":a(c);break;case"none":break;default:l(c)}}var a=t;function i(c){t(c),n(c)}function l(c){r(c)}return lJ}var cJ,V6e;function Tzn(){if(V6e)return cJ;V6e=1,cJ=e;function e(r){let s=n(r);r.graph().dummyChains.forEach(a=>{let i=r.node(a),l=i.edgeObj,c=t(r,s,l.v,l.w),u=c.path,d=c.lca,f=0,p=u[f],h=!0;for(;a!==l.w;){if(i=r.node(a),h){for(;(p=u[f])!==d&&r.node(p).maxRank<i.rank;)f++;p===d&&(h=!1)}if(!h){for(;f<u.length-1&&r.node(p=u[f+1]).minRank<=i.rank;)f++;p=u[f]}r.setParent(a,p),a=r.successors(a)[0]}})}function t(r,s,a,i){let l=[],c=[],u=Math.min(s[a].low,s[i].low),d=Math.max(s[a].lim,s[i].lim),f,p;f=a;do f=r.parent(f),l.push(f);while(f&&(s[f].low>u||d>s[f].lim));for(p=f,f=i;(f=r.parent(f))!==p;)c.push(f);return{path:l.concat(c.reverse()),lca:p}}function n(r){let s={},a=0;function i(l){let c=a;r.children(l).forEach(i),s[l]={low:c,lim:a++}}return r.children().forEach(i),s}return cJ}var uJ,H6e;function Nzn(){if(H6e)return uJ;H6e=1;let e=jl();uJ={run:t,cleanup:a};function t(i){let l=e.addDummyNode(i,"root",{},"_root"),c=r(i),u=Object.values(c),d=e.applyWithChunking(Math.max,u)-1,f=2*d+1;i.graph().nestingRoot=l,i.edges().forEach(h=>i.edge(h).minlen*=f);let p=s(i)+1;i.children().forEach(h=>n(i,l,f,p,d,c,h)),i.graph().nodeRankFactor=f}function n(i,l,c,u,d,f,p){let h=i.children(p);if(!h.length){p!==l&&i.setEdge(l,p,{weight:0,minlen:c});return}let m=e.addBorderNode(i,"_bt"),g=e.addBorderNode(i,"_bb"),y=i.node(p);i.setParent(m,p),y.borderTop=m,i.setParent(g,p),y.borderBottom=g,h.forEach(b=>{n(i,l,c,u,d,f,b);let w=i.node(b),S=w.borderTop?w.borderTop:b,k=w.borderBottom?w.borderBottom:b,_=w.borderTop?u:2*u,C=S!==k?1:d-f[p]+1;i.setEdge(m,S,{weight:_,minlen:C,nestingEdge:!0}),i.setEdge(k,g,{weight:_,minlen:C,nestingEdge:!0})}),i.parent(p)||i.setEdge(l,m,{weight:0,minlen:d+f[p]})}function r(i){var l={};function c(u,d){var f=i.children(u);f&&f.length&&f.forEach(p=>c(p,d+1)),l[u]=d}return i.children().forEach(u=>c(u,1)),l}function s(i){return i.edges().reduce((l,c)=>l+i.edge(c).weight,0)}function a(i){var l=i.graph();i.removeNode(l.nestingRoot),delete l.nestingRoot,i.edges().forEach(c=>{var u=i.edge(c);u.nestingEdge&&i.removeEdge(c)})}return uJ}var dJ,W6e;function Izn(){if(W6e)return dJ;W6e=1;let e=jl();dJ=t;function t(r){function s(a){let i=r.children(a),l=r.node(a);if(i.length&&i.forEach(s),Object.hasOwn(l,"minRank")){l.borderLeft=[],l.borderRight=[];for(let c=l.minRank,u=l.maxRank+1;c<u;++c)n(r,"borderLeft","_bl",a,l,c),n(r,"borderRight","_br",a,l,c)}}r.children().forEach(s)}function n(r,s,a,i,l,c){let u={width:0,height:0,rank:c,borderType:s},d=l[s][c-1],f=e.addDummyNode(r,"border",u,a);l[s][c]=f,r.setParent(f,i),d&&r.setEdge(d,f,{weight:1})}return dJ}var fJ,Z6e;function Azn(){if(Z6e)return fJ;Z6e=1,fJ={adjust:e,undo:t};function e(c){let u=c.graph().rankdir.toLowerCase();(u==="lr"||u==="rl")&&n(c)}function t(c){let u=c.graph().rankdir.toLowerCase();(u==="bt"||u==="rl")&&s(c),(u==="lr"||u==="rl")&&(i(c),n(c))}function n(c){c.nodes().forEach(u=>r(c.node(u))),c.edges().forEach(u=>r(c.edge(u)))}function r(c){let u=c.width;c.width=c.height,c.height=u}function s(c){c.nodes().forEach(u=>a(c.node(u))),c.edges().forEach(u=>{let d=c.edge(u);d.points.forEach(a),Object.hasOwn(d,"y")&&a(d)})}function a(c){c.y=-c.y}function i(c){c.nodes().forEach(u=>l(c.node(u))),c.edges().forEach(u=>{let d=c.edge(u);d.points.forEach(l),Object.hasOwn(d,"x")&&l(d)})}function l(c){let u=c.x;c.x=c.y,c.y=u}return fJ}var pJ,G6e;function Rzn(){if(G6e)return pJ;G6e=1;let e=jl();pJ=t;function t(n){let r={},s=n.nodes().filter(d=>!n.children(d).length),a=s.map(d=>n.node(d).rank),i=e.applyWithChunking(Math.max,a),l=e.range(i+1).map(()=>[]);function c(d){if(r[d])return;r[d]=!0;let f=n.node(d);l[f.rank].push(d),n.successors(d).forEach(c)}return s.sort((d,f)=>n.node(d).rank-n.node(f).rank).forEach(c),l}return pJ}var hJ,Q6e;function Pzn(){if(Q6e)return hJ;Q6e=1;let e=jl().zipObject;hJ=t;function t(r,s){let a=0;for(let i=1;i<s.length;++i)a+=n(r,s[i-1],s[i]);return a}function n(r,s,a){let i=e(a,a.map((p,h)=>h)),l=s.flatMap(p=>r.outEdges(p).map(h=>({pos:i[h.w],weight:r.edge(h).weight})).sort((h,m)=>h.pos-m.pos)),c=1;for(;c<a.length;)c<<=1;let u=2*c-1;c-=1;let d=new Array(u).fill(0),f=0;return l.forEach(p=>{let h=p.pos+c;d[h]+=p.weight;let m=0;for(;h>0;)h%2&&(m+=d[h+1]),h=h-1>>1,d[h]+=p.weight;f+=p.weight*m}),f}return hJ}var mJ,Y6e;function $zn(){if(Y6e)return mJ;Y6e=1,mJ=e;function e(t,n=[]){return n.map(r=>{let s=t.inEdges(r);if(s.length){let a=s.reduce((i,l)=>{let c=t.edge(l),u=t.node(l.v);return{sum:i.sum+c.weight*u.order,weight:i.weight+c.weight}},{sum:0,weight:0});return{v:r,barycenter:a.sum/a.weight,weight:a.weight}}else return{v:r}})}return mJ}var gJ,X6e;function Mzn(){if(X6e)return gJ;X6e=1;let e=jl();gJ=t;function t(s,a){let i={};s.forEach((c,u)=>{let d=i[c.v]={indegree:0,in:[],out:[],vs:[c.v],i:u};c.barycenter!==void 0&&(d.barycenter=c.barycenter,d.weight=c.weight)}),a.edges().forEach(c=>{let u=i[c.v],d=i[c.w];u!==void 0&&d!==void 0&&(d.indegree++,u.out.push(i[c.w]))});let l=Object.values(i).filter(c=>!c.indegree);return n(l)}function n(s){let a=[];function i(c){return u=>{u.merged||(u.barycenter===void 0||c.barycenter===void 0||u.barycenter>=c.barycenter)&&r(c,u)}}function l(c){return u=>{u.in.push(c),--u.indegree===0&&s.push(u)}}for(;s.length;){let c=s.pop();a.push(c),c.in.reverse().forEach(i(c)),c.out.forEach(l(c))}return a.filter(c=>!c.merged).map(c=>e.pick(c,["vs","i","barycenter","weight"]))}function r(s,a){let i=0,l=0;s.weight&&(i+=s.barycenter*s.weight,l+=s.weight),a.weight&&(i+=a.barycenter*a.weight,l+=a.weight),s.vs=a.vs.concat(s.vs),s.barycenter=i/l,s.weight=l,s.i=Math.min(a.i,s.i),a.merged=!0}return gJ}var vJ,K6e;function Dzn(){if(K6e)return vJ;K6e=1;let e=jl();vJ=t;function t(s,a){let i=e.partition(s,m=>Object.hasOwn(m,"barycenter")),l=i.lhs,c=i.rhs.sort((m,g)=>g.i-m.i),u=[],d=0,f=0,p=0;l.sort(r(!!a)),p=n(u,c,p),l.forEach(m=>{p+=m.vs.length,u.push(m.vs),d+=m.barycenter*m.weight,f+=m.weight,p=n(u,c,p)});let h={vs:u.flat(!0)};return f&&(h.barycenter=d/f,h.weight=f),h}function n(s,a,i){let l;for(;a.length&&(l=a[a.length-1]).i<=i;)a.pop(),s.push(l.vs),i++;return i}function r(s){return(a,i)=>a.barycenter<i.barycenter?-1:a.barycenter>i.barycenter?1:s?i.i-a.i:a.i-i.i}return vJ}var yJ,J6e;function Lzn(){if(J6e)return yJ;J6e=1;let e=$zn(),t=Mzn(),n=Dzn();yJ=r;function r(i,l,c,u){let d=i.children(l),f=i.node(l),p=f?f.borderLeft:void 0,h=f?f.borderRight:void 0,m={};p&&(d=d.filter(w=>w!==p&&w!==h));let g=e(i,d);g.forEach(w=>{if(i.children(w.v).length){let S=r(i,w.v,c,u);m[w.v]=S,Object.hasOwn(S,"barycenter")&&a(w,S)}});let y=t(g,c);s(y,m);let b=n(y,u);if(p&&(b.vs=[p,b.vs,h].flat(!0),i.predecessors(p).length)){let w=i.node(i.predecessors(p)[0]),S=i.node(i.predecessors(h)[0]);Object.hasOwn(b,"barycenter")||(b.barycenter=0,b.weight=0),b.barycenter=(b.barycenter*b.weight+w.order+S.order)/(b.weight+2),b.weight+=2}return b}function s(i,l){i.forEach(c=>{c.vs=c.vs.flatMap(u=>l[u]?l[u].vs:u)})}function a(i,l){i.barycenter!==void 0?(i.barycenter=(i.barycenter*i.weight+l.barycenter*l.weight)/(i.weight+l.weight),i.weight+=l.weight):(i.barycenter=l.barycenter,i.weight=l.weight)}return yJ}var bJ,e8e;function Fzn(){if(e8e)return bJ;e8e=1;let e=Eg().Graph,t=jl();bJ=n;function n(s,a,i,l){l||(l=s.nodes());let c=r(s),u=new e({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(d=>s.node(d));return l.forEach(d=>{let f=s.node(d),p=s.parent(d);(f.rank===a||f.minRank<=a&&a<=f.maxRank)&&(u.setNode(d),u.setParent(d,p||c),s[i](d).forEach(h=>{let m=h.v===d?h.w:h.v,g=u.edge(m,d),y=g!==void 0?g.weight:0;u.setEdge(m,d,{weight:s.edge(h).weight+y})}),Object.hasOwn(f,"minRank")&&u.setNode(d,{borderLeft:f.borderLeft[a],borderRight:f.borderRight[a]}))}),u}function r(s){for(var a;s.hasNode(a=t.uniqueId("_root")););return a}return bJ}var xJ,t8e;function zzn(){if(t8e)return xJ;t8e=1,xJ=e;function e(t,n,r){let s={},a;r.forEach(i=>{let l=t.parent(i),c,u;for(;l;){if(c=t.parent(l),c?(u=s[c],s[c]=l):(u=a,a=l),u&&u!==l){n.setEdge(u,l);return}l=c}})}return xJ}var wJ,n8e;function Bzn(){if(n8e)return wJ;n8e=1;let e=Rzn(),t=Pzn(),n=Lzn(),r=Fzn(),s=zzn(),a=Eg().Graph,i=jl();wJ=l;function l(f,p){if(p&&typeof p.customOrder=="function"){p.customOrder(f,l);return}let h=i.maxRank(f),m=c(f,i.range(1,h+1),"inEdges"),g=c(f,i.range(h-1,-1,-1),"outEdges"),y=e(f);if(d(f,y),p&&p.disableOptimalOrderHeuristic)return;let b=Number.POSITIVE_INFINITY,w;for(let S=0,k=0;k<4;++S,++k){u(S%2?m:g,S%4>=2),y=i.buildLayerMatrix(f);let _=t(f,y);_<b&&(k=0,w=Object.assign({},y),b=_)}d(f,w)}function c(f,p,h){const m=new Map,g=(y,b)=>{m.has(y)||m.set(y,[]),m.get(y).push(b)};for(const y of f.nodes()){const b=f.node(y);if(typeof b.rank=="number"&&g(b.rank,y),typeof b.minRank=="number"&&typeof b.maxRank=="number")for(let w=b.minRank;w<=b.maxRank;w++)w!==b.rank&&g(w,y)}return p.map(function(y){return r(f,y,h,m.get(y)||[])})}function u(f,p){let h=new a;f.forEach(function(m){let g=m.graph().root,y=n(m,g,h,p);y.vs.forEach((b,w)=>m.node(b).order=w),s(m,h,y.vs)})}function d(f,p){Object.values(p).forEach(h=>h.forEach((m,g)=>f.node(m).order=g))}return wJ}var SJ,r8e;function Uzn(){if(r8e)return SJ;r8e=1;let e=Eg().Graph,t=jl();SJ={positionX:h,findType1Conflicts:n,findType2Conflicts:r,addConflict:a,hasConflict:i,verticalAlignment:l,horizontalCompaction:c,alignCoordinates:f,findSmallestWidthAlignment:d,balance:p};function n(y,b){let w={};function S(k,_){let C=0,E=0,j=k.length,N=_[_.length-1];return _.forEach((I,R)=>{let $=s(y,I),F=$?y.node($).order:j;($||I===N)&&(_.slice(E,R+1).forEach(D=>{y.predecessors(D).forEach(V=>{let W=y.node(V),L=W.order;(L<C||F<L)&&!(W.dummy&&y.node(D).dummy)&&a(w,V,D)})}),E=R+1,C=F)}),_}return b.length&&b.reduce(S),w}function r(y,b){let w={};function S(_,C,E,j,N){let I;t.range(C,E).forEach(R=>{I=_[R],y.node(I).dummy&&y.predecessors(I).forEach($=>{let F=y.node($);F.dummy&&(F.order<j||F.order>N)&&a(w,$,I)})})}function k(_,C){let E=-1,j,N=0;return C.forEach((I,R)=>{if(y.node(I).dummy==="border"){let $=y.predecessors(I);$.length&&(j=y.node($[0]).order,S(C,N,R,E,j),N=R,E=j)}S(C,N,C.length,j,_.length)}),C}return b.length&&b.reduce(k),w}function s(y,b){if(y.node(b).dummy)return y.predecessors(b).find(w=>y.node(w).dummy)}function a(y,b,w){if(b>w){let k=b;b=w,w=k}let S=y[b];S||(y[b]=S={}),S[w]=!0}function i(y,b,w){if(b>w){let S=b;b=w,w=S}return!!y[b]&&Object.hasOwn(y[b],w)}function l(y,b,w,S){let k={},_={},C={};return b.forEach(E=>{E.forEach((j,N)=>{k[j]=j,_[j]=j,C[j]=N})}),b.forEach(E=>{let j=-1;E.forEach(N=>{let I=S(N);if(I.length){I=I.sort(($,F)=>C[$]-C[F]);let R=(I.length-1)/2;for(let $=Math.floor(R),F=Math.ceil(R);$<=F;++$){let D=I[$];_[N]===N&&j<C[D]&&!i(w,N,D)&&(_[D]=N,_[N]=k[N]=k[D],j=C[D])}}})}),{root:k,align:_}}function c(y,b,w,S,k){let _={},C=u(y,b,w,k),E=k?"borderLeft":"borderRight";function j(R,$){let F=C.nodes(),D=F.pop(),V={};for(;D;)V[D]?R(D):(V[D]=!0,F.push(D),F=F.concat($(D))),D=F.pop()}function N(R){_[R]=C.inEdges(R).reduce(($,F)=>Math.max($,_[F.v]+C.edge(F)),0)}function I(R){let $=C.outEdges(R).reduce((D,V)=>Math.min(D,_[V.w]-C.edge(V)),Number.POSITIVE_INFINITY),F=y.node(R);$!==Number.POSITIVE_INFINITY&&F.borderType!==E&&(_[R]=Math.max(_[R],$))}return j(N,C.predecessors.bind(C)),j(I,C.successors.bind(C)),Object.keys(S).forEach(R=>_[R]=_[w[R]]),_}function u(y,b,w,S){let k=new e,_=y.graph(),C=m(_.nodesep,_.edgesep,S);return b.forEach(E=>{let j;E.forEach(N=>{let I=w[N];if(k.setNode(I),j){var R=w[j],$=k.edge(R,I);k.setEdge(R,I,Math.max(C(y,N,j),$||0))}j=N})}),k}function d(y,b){return Object.values(b).reduce((w,S)=>{let k=Number.NEGATIVE_INFINITY,_=Number.POSITIVE_INFINITY;Object.entries(S).forEach(([E,j])=>{let N=g(y,E)/2;k=Math.max(j+N,k),_=Math.min(j-N,_)});const C=k-_;return C<w[0]&&(w=[C,S]),w},[Number.POSITIVE_INFINITY,null])[1]}function f(y,b){let w=Object.values(b),S=t.applyWithChunking(Math.min,w),k=t.applyWithChunking(Math.max,w);["u","d"].forEach(_=>{["l","r"].forEach(C=>{let E=_+C,j=y[E];if(j===b)return;let N=Object.values(j),I=S-t.applyWithChunking(Math.min,N);C!=="l"&&(I=k-t.applyWithChunking(Math.max,N)),I&&(y[E]=t.mapValues(j,R=>R+I))})})}function p(y,b){return t.mapValues(y.ul,(w,S)=>{if(b)return y[b.toLowerCase()][S];{let k=Object.values(y).map(_=>_[S]).sort((_,C)=>_-C);return(k[1]+k[2])/2}})}function h(y){let b=t.buildLayerMatrix(y),w=Object.assign(n(y,b),r(y,b)),S={},k;["u","d"].forEach(C=>{k=C==="u"?b:Object.values(b).reverse(),["l","r"].forEach(E=>{E==="r"&&(k=k.map(R=>Object.values(R).reverse()));let j=(C==="u"?y.predecessors:y.successors).bind(y),N=l(y,k,w,j),I=c(y,k,N.root,N.align,E==="r");E==="r"&&(I=t.mapValues(I,R=>-R)),S[C+E]=I})});let _=d(y,S);return f(S,_),p(S,y.graph().align)}function m(y,b,w){return(S,k,_)=>{let C=S.node(k),E=S.node(_),j=0,N;if(j+=C.width/2,Object.hasOwn(C,"labelpos"))switch(C.labelpos.toLowerCase()){case"l":N=-C.width/2;break;case"r":N=C.width/2;break}if(N&&(j+=w?N:-N),N=0,j+=(C.dummy?b:y)/2,j+=(E.dummy?b:y)/2,j+=E.width/2,Object.hasOwn(E,"labelpos"))switch(E.labelpos.toLowerCase()){case"l":N=E.width/2;break;case"r":N=-E.width/2;break}return N&&(j+=w?N:-N),N=0,j}}function g(y,b){return y.node(b).width}return SJ}var kJ,s8e;function qzn(){if(s8e)return kJ;s8e=1;let e=jl(),t=Uzn().positionX;kJ=n;function n(s){s=e.asNonCompoundGraph(s),r(s),Object.entries(t(s)).forEach(([a,i])=>s.node(a).x=i)}function r(s){let a=e.buildLayerMatrix(s),i=s.graph().ranksep,l=0;a.forEach(c=>{const u=c.reduce((d,f)=>{const p=s.node(f).height;return d>p?d:p},0);c.forEach(d=>s.node(d).y=l+u/2),l+=u+i})}return kJ}var OJ,a8e;function Vzn(){if(a8e)return OJ;a8e=1;let e=_zn(),t=Czn(),n=jzn(),r=jl().normalizeRanks,s=Tzn(),a=jl().removeEmptyRanks,i=Nzn(),l=Izn(),c=Azn(),u=Bzn(),d=qzn(),f=jl(),p=Eg().Graph;OJ=h;function h(P,q){let Z=q&&q.debugTiming?f.time:f.notime;Z("layout",()=>{let X=Z(" buildLayoutGraph",()=>j(P));Z(" runLayout",()=>m(X,Z,q)),Z(" updateInputGraph",()=>g(P,X))})}function m(P,q,Z){q(" makeSpaceForEdgeLabels",()=>N(P)),q(" removeSelfEdges",()=>z(P)),q(" acyclic",()=>e.run(P)),q(" nestingGraph.run",()=>i.run(P)),q(" rank",()=>n(f.asNonCompoundGraph(P))),q(" injectEdgeLabelProxies",()=>I(P)),q(" removeEmptyRanks",()=>a(P)),q(" nestingGraph.cleanup",()=>i.cleanup(P)),q(" normalizeRanks",()=>r(P)),q(" assignRankMinMax",()=>R(P)),q(" removeEdgeLabelProxies",()=>$(P)),q(" normalize.run",()=>t.run(P)),q(" parentDummyChains",()=>s(P)),q(" addBorderSegments",()=>l(P)),q(" order",()=>u(P,Z)),q(" insertSelfEdges",()=>B(P)),q(" adjustCoordinateSystem",()=>c.adjust(P)),q(" position",()=>d(P)),q(" positionSelfEdges",()=>M(P)),q(" removeBorderNodes",()=>L(P)),q(" normalize.undo",()=>t.undo(P)),q(" fixupEdgeLabelCoords",()=>V(P)),q(" undoCoordinateSystem",()=>c.undo(P)),q(" translateGraph",()=>F(P)),q(" assignNodeIntersects",()=>D(P)),q(" reversePoints",()=>W(P)),q(" acyclic.undo",()=>e.undo(P))}function g(P,q){P.nodes().forEach(Z=>{let X=P.node(Z),te=q.node(Z);X&&(X.x=te.x,X.y=te.y,X.rank=te.rank,q.children(Z).length&&(X.width=te.width,X.height=te.height))}),P.edges().forEach(Z=>{let X=P.edge(Z),te=q.edge(Z);X.points=te.points,Object.hasOwn(te,"x")&&(X.x=te.x,X.y=te.y)}),P.graph().width=q.graph().width,P.graph().height=q.graph().height}let y=["nodesep","edgesep","ranksep","marginx","marginy"],b={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},w=["acyclicer","ranker","rankdir","align"],S=["width","height","rank"],k={width:0,height:0},_=["minlen","weight","width","height","labeloffset"],C={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},E=["labelpos"];function j(P){let q=new p({multigraph:!0,compound:!0}),Z=U(P.graph());return q.setGraph(Object.assign({},b,G(Z,y),f.pick(Z,w))),P.nodes().forEach(X=>{let te=U(P.node(X));const J=G(te,S);Object.keys(k).forEach(ee=>{J[ee]===void 0&&(J[ee]=k[ee])}),q.setNode(X,J),q.setParent(X,P.parent(X))}),P.edges().forEach(X=>{let te=U(P.edge(X));q.setEdge(X,Object.assign({},C,G(te,_),f.pick(te,E)))}),q}function N(P){let q=P.graph();q.ranksep/=2,P.edges().forEach(Z=>{let X=P.edge(Z);X.minlen*=2,X.labelpos.toLowerCase()!=="c"&&(q.rankdir==="TB"||q.rankdir==="BT"?X.width+=X.labeloffset:X.height+=X.labeloffset)})}function I(P){P.edges().forEach(q=>{let Z=P.edge(q);if(Z.width&&Z.height){let X=P.node(q.v),J={rank:(P.node(q.w).rank-X.rank)/2+X.rank,e:q};f.addDummyNode(P,"edge-proxy",J,"_ep")}})}function R(P){let q=0;P.nodes().forEach(Z=>{let X=P.node(Z);X.borderTop&&(X.minRank=P.node(X.borderTop).rank,X.maxRank=P.node(X.borderBottom).rank,q=Math.max(q,X.maxRank))}),P.graph().maxRank=q}function $(P){P.nodes().forEach(q=>{let Z=P.node(q);Z.dummy==="edge-proxy"&&(P.edge(Z.e).labelRank=Z.rank,P.removeNode(q))})}function F(P){let q=Number.POSITIVE_INFINITY,Z=0,X=Number.POSITIVE_INFINITY,te=0,J=P.graph(),ee=J.marginx||0,ae=J.marginy||0;function de(Y){let ne=Y.x,ce=Y.y,pe=Y.width,le=Y.height;q=Math.min(q,ne-pe/2),Z=Math.max(Z,ne+pe/2),X=Math.min(X,ce-le/2),te=Math.max(te,ce+le/2)}P.nodes().forEach(Y=>de(P.node(Y))),P.edges().forEach(Y=>{let ne=P.edge(Y);Object.hasOwn(ne,"x")&&de(ne)}),q-=ee,X-=ae,P.nodes().forEach(Y=>{let ne=P.node(Y);ne.x-=q,ne.y-=X}),P.edges().forEach(Y=>{let ne=P.edge(Y);ne.points.forEach(ce=>{ce.x-=q,ce.y-=X}),Object.hasOwn(ne,"x")&&(ne.x-=q),Object.hasOwn(ne,"y")&&(ne.y-=X)}),J.width=Z-q+ee,J.height=te-X+ae}function D(P){P.edges().forEach(q=>{let Z=P.edge(q),X=P.node(q.v),te=P.node(q.w),J,ee;Z.points?(J=Z.points[0],ee=Z.points[Z.points.length-1]):(Z.points=[],J=te,ee=X),Z.points.unshift(f.intersectRect(X,J)),Z.points.push(f.intersectRect(te,ee))})}function V(P){P.edges().forEach(q=>{let Z=P.edge(q);if(Object.hasOwn(Z,"x"))switch((Z.labelpos==="l"||Z.labelpos==="r")&&(Z.width-=Z.labeloffset),Z.labelpos){case"l":Z.x-=Z.width/2+Z.labeloffset;break;case"r":Z.x+=Z.width/2+Z.labeloffset;break}})}function W(P){P.edges().forEach(q=>{let Z=P.edge(q);Z.reversed&&Z.points.reverse()})}function L(P){P.nodes().forEach(q=>{if(P.children(q).length){let Z=P.node(q),X=P.node(Z.borderTop),te=P.node(Z.borderBottom),J=P.node(Z.borderLeft[Z.borderLeft.length-1]),ee=P.node(Z.borderRight[Z.borderRight.length-1]);Z.width=Math.abs(ee.x-J.x),Z.height=Math.abs(te.y-X.y),Z.x=J.x+Z.width/2,Z.y=X.y+Z.height/2}}),P.nodes().forEach(q=>{P.node(q).dummy==="border"&&P.removeNode(q)})}function z(P){P.edges().forEach(q=>{if(q.v===q.w){var Z=P.node(q.v);Z.selfEdges||(Z.selfEdges=[]),Z.selfEdges.push({e:q,label:P.edge(q)}),P.removeEdge(q)}})}function B(P){var q=f.buildLayerMatrix(P);q.forEach(Z=>{var X=0;Z.forEach((te,J)=>{var ee=P.node(te);ee.order=J+X,(ee.selfEdges||[]).forEach(ae=>{f.addDummyNode(P,"selfedge",{width:ae.label.width,height:ae.label.height,rank:ee.rank,order:J+ ++X,e:ae.e,label:ae.label},"_se")}),delete ee.selfEdges})})}function M(P){P.nodes().forEach(q=>{var Z=P.node(q);if(Z.dummy==="selfedge"){var X=P.node(Z.e.v),te=X.x+X.width/2,J=X.y,ee=Z.x-te,ae=X.height/2;P.setEdge(Z.e,Z.label),P.removeNode(q),Z.label.points=[{x:te+2*ee/3,y:J-ae},{x:te+5*ee/6,y:J-ae},{x:te+ee,y:J},{x:te+5*ee/6,y:J+ae},{x:te+2*ee/3,y:J+ae}],Z.label.x=Z.x,Z.label.y=Z.y}})}function G(P,q){return f.mapValues(f.pick(P,q),Number)}function U(P){var q={};return P&&Object.entries(P).forEach(([Z,X])=>{typeof Z=="string"&&(Z=Z.toLowerCase()),q[Z]=X}),q}return OJ}var _J,i8e;function Hzn(){if(i8e)return _J;i8e=1;let e=jl(),t=Eg().Graph;_J={debugOrdering:n};function n(r){let s=e.buildLayerMatrix(r),a=new t({compound:!0,multigraph:!0}).setGraph({});return r.nodes().forEach(i=>{a.setNode(i,{label:i}),a.setParent(i,"layer"+r.node(i).rank)}),r.edges().forEach(i=>a.setEdge(i.v,i.w,{},i.name)),s.forEach((i,l)=>{let c="layer"+l;a.setNode(c,{rank:"same"}),i.reduce((u,d)=>(a.setEdge(u,d,{style:"invis"}),d))}),a}return _J}var CJ,o8e;function Wzn(){return o8e||(o8e=1,CJ="1.1.8"),CJ}var EJ,l8e;function Zzn(){return l8e||(l8e=1,EJ={graphlib:Eg(),layout:Vzn(),debug:Hzn(),util:{time:jl().time,notime:jl().notime},version:Wzn()}),EJ}var Gzn=Zzn();const c8e=Cc(Gzn);function Pl(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=Pl(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Qzn={value:()=>{}};function mV(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new D9(n)}function D9(e){this._=e}function Yzn(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",s=n.indexOf(".");if(s>=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}D9.prototype=mV.prototype={constructor:D9,on:function(e,t){var n=this._,r=Yzn(e+"",n),s,a=-1,i=r.length;if(arguments.length<2){for(;++a<i;)if((s=(e=r[a]).type)&&(s=Xzn(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++a<i;)if(s=(e=r[a]).type)n[s]=u8e(n[s],e.name,t);else if(t==null)for(s in n)n[s]=u8e(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new D9(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,a;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],r=0,s=a.length;r<s;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],s=0,a=r.length;s<a;++s)r[s].value.apply(t,n)}};function Xzn(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function u8e(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=Qzn,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var ohe="http://www.w3.org/1999/xhtml";const d8e={svg:"http://www.w3.org/2000/svg",xhtml:ohe,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function gV(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),d8e.hasOwnProperty(t)?{space:d8e[t],local:e}:e}function Kzn(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===ohe&&t.documentElement.namespaceURI===ohe?t.createElement(e):t.createElementNS(n,e)}}function Jzn(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function fxt(e){var t=gV(e);return(t.local?Jzn:Kzn)(t)}function e7n(){}function Jwe(e){return e==null?e7n:function(){return this.querySelector(e)}}function t7n(e){typeof e!="function"&&(e=Jwe(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=r[s]=new Array(i),c,u,d=0;d<i;++d)(c=a[d])&&(u=e.call(c,c.__data__,d,a))&&("__data__"in c&&(u.__data__=c.__data__),l[d]=u);return new Dp(r,this._parents)}function n7n(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function r7n(){return[]}function pxt(e){return e==null?r7n:function(){return this.querySelectorAll(e)}}function s7n(e){return function(){return n7n(e.apply(this,arguments))}}function a7n(e){typeof e=="function"?e=s7n(e):e=pxt(e);for(var t=this._groups,n=t.length,r=[],s=[],a=0;a<n;++a)for(var i=t[a],l=i.length,c,u=0;u<l;++u)(c=i[u])&&(r.push(e.call(c,c.__data__,u,i)),s.push(c));return new Dp(r,s)}function hxt(e){return function(){return this.matches(e)}}function mxt(e){return function(t){return t.matches(e)}}var i7n=Array.prototype.find;function o7n(e){return function(){return i7n.call(this.children,e)}}function l7n(){return this.firstElementChild}function c7n(e){return this.select(e==null?l7n:o7n(typeof e=="function"?e:mxt(e)))}var u7n=Array.prototype.filter;function d7n(){return Array.from(this.children)}function f7n(e){return function(){return u7n.call(this.children,e)}}function p7n(e){return this.selectAll(e==null?d7n:f7n(typeof e=="function"?e:mxt(e)))}function h7n(e){typeof e!="function"&&(e=hxt(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=r[s]=[],c,u=0;u<i;++u)(c=a[u])&&e.call(c,c.__data__,u,a)&&l.push(c);return new Dp(r,this._parents)}function gxt(e){return new Array(e.length)}function m7n(){return new Dp(this._enter||this._groups.map(gxt),this._parents)}function m7(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}m7.prototype={constructor:m7,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function g7n(e){return function(){return e}}function v7n(e,t,n,r,s,a){for(var i=0,l,c=t.length,u=a.length;i<u;++i)(l=t[i])?(l.__data__=a[i],r[i]=l):n[i]=new m7(e,a[i]);for(;i<c;++i)(l=t[i])&&(s[i]=l)}function y7n(e,t,n,r,s,a,i){var l,c,u=new Map,d=t.length,f=a.length,p=new Array(d),h;for(l=0;l<d;++l)(c=t[l])&&(p[l]=h=i.call(c,c.__data__,l,t)+"",u.has(h)?s[l]=c:u.set(h,c));for(l=0;l<f;++l)h=i.call(e,a[l],l,a)+"",(c=u.get(h))?(r[l]=c,c.__data__=a[l],u.delete(h)):n[l]=new m7(e,a[l]);for(l=0;l<d;++l)(c=t[l])&&u.get(p[l])===c&&(s[l]=c)}function b7n(e){return e.__data__}function x7n(e,t){if(!arguments.length)return Array.from(this,b7n);var n=t?y7n:v7n,r=this._parents,s=this._groups;typeof e!="function"&&(e=g7n(e));for(var a=s.length,i=new Array(a),l=new Array(a),c=new Array(a),u=0;u<a;++u){var d=r[u],f=s[u],p=f.length,h=w7n(e.call(d,d&&d.__data__,u,r)),m=h.length,g=l[u]=new Array(m),y=i[u]=new Array(m),b=c[u]=new Array(p);n(d,f,g,y,b,h,t);for(var w=0,S=0,k,_;w<m;++w)if(k=g[w]){for(w>=S&&(S=w+1);!(_=y[S])&&++S<m;);k._next=_||null}}return i=new Dp(i,r),i._enter=l,i._exit=c,i}function w7n(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function S7n(){return new Dp(this._exit||this._groups.map(gxt),this._parents)}function k7n(e,t,n){var r=this.enter(),s=this,a=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?a.remove():n(a),r&&s?r.merge(s).order():s}function O7n(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,a=r.length,i=Math.min(s,a),l=new Array(s),c=0;c<i;++c)for(var u=n[c],d=r[c],f=u.length,p=l[c]=new Array(f),h,m=0;m<f;++m)(h=u[m]||d[m])&&(p[m]=h);for(;c<s;++c)l[c]=n[c];return new Dp(l,this._parents)}function _7n(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],s=r.length-1,a=r[s],i;--s>=0;)(i=r[s])&&(a&&i.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(i,a),a=i);return this}function C7n(e){e||(e=E7n);function t(f,p){return f&&p?e(f.__data__,p.__data__):!f-!p}for(var n=this._groups,r=n.length,s=new Array(r),a=0;a<r;++a){for(var i=n[a],l=i.length,c=s[a]=new Array(l),u,d=0;d<l;++d)(u=i[d])&&(c[d]=u);c.sort(t)}return new Dp(s,this._parents).order()}function E7n(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function j7n(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function T7n(){return Array.from(this)}function N7n(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,a=r.length;s<a;++s){var i=r[s];if(i)return i}return null}function I7n(){let e=0;for(const t of this)++e;return e}function A7n(){return!this.node()}function R7n(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var s=t[n],a=0,i=s.length,l;a<i;++a)(l=s[a])&&e.call(l,l.__data__,a,s);return this}function P7n(e){return function(){this.removeAttribute(e)}}function $7n(e){return function(){this.removeAttributeNS(e.space,e.local)}}function M7n(e,t){return function(){this.setAttribute(e,t)}}function D7n(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function L7n(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function F7n(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function z7n(e,t){var n=gV(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?$7n:P7n:typeof t=="function"?n.local?F7n:L7n:n.local?D7n:M7n)(n,t))}function vxt(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function B7n(e){return function(){this.style.removeProperty(e)}}function U7n(e,t,n){return function(){this.style.setProperty(e,t,n)}}function q7n(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function V7n(e,t,n){return arguments.length>1?this.each((t==null?B7n:typeof t=="function"?q7n:U7n)(e,t,n??"")):hT(this.node(),e)}function hT(e,t){return e.style.getPropertyValue(t)||vxt(e).getComputedStyle(e,null).getPropertyValue(t)}function H7n(e){return function(){delete this[e]}}function W7n(e,t){return function(){this[e]=t}}function Z7n(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function G7n(e,t){return arguments.length>1?this.each((t==null?H7n:typeof t=="function"?Z7n:W7n)(e,t)):this.node()[e]}function yxt(e){return e.trim().split(/^|\s+/)}function e1e(e){return e.classList||new bxt(e)}function bxt(e){this._node=e,this._names=yxt(e.getAttribute("class")||"")}bxt.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function xxt(e,t){for(var n=e1e(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function wxt(e,t){for(var n=e1e(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function Q7n(e){return function(){xxt(this,e)}}function Y7n(e){return function(){wxt(this,e)}}function X7n(e,t){return function(){(t.apply(this,arguments)?xxt:wxt)(this,e)}}function K7n(e,t){var n=yxt(e+"");if(arguments.length<2){for(var r=e1e(this.node()),s=-1,a=n.length;++s<a;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?X7n:t?Q7n:Y7n)(n,t))}function J7n(){this.textContent=""}function eBn(e){return function(){this.textContent=e}}function tBn(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function nBn(e){return arguments.length?this.each(e==null?J7n:(typeof e=="function"?tBn:eBn)(e)):this.node().textContent}function rBn(){this.innerHTML=""}function sBn(e){return function(){this.innerHTML=e}}function aBn(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function iBn(e){return arguments.length?this.each(e==null?rBn:(typeof e=="function"?aBn:sBn)(e)):this.node().innerHTML}function oBn(){this.nextSibling&&this.parentNode.appendChild(this)}function lBn(){return this.each(oBn)}function cBn(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function uBn(){return this.each(cBn)}function dBn(e){var t=typeof e=="function"?e:fxt(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function fBn(){return null}function pBn(e,t){var n=typeof e=="function"?e:fxt(e),r=t==null?fBn:typeof t=="function"?t:Jwe(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function hBn(){var e=this.parentNode;e&&e.removeChild(this)}function mBn(){return this.each(hBn)}function gBn(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function vBn(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function yBn(e){return this.select(e?vBn:gBn)}function bBn(e){return arguments.length?this.property("__data__",e):this.node().__data__}function xBn(e){return function(t){e.call(this,t,this.__data__)}}function wBn(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function SBn(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,a;n<s;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function kBn(e,t,n){return function(){var r=this.__on,s,a=xBn(t);if(r){for(var i=0,l=r.length;i<l;++i)if((s=r[i]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=a,s.options=n),s.value=t;return}}this.addEventListener(e.type,a,n),s={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(s):this.__on=[s]}}function OBn(e,t,n){var r=wBn(e+""),s,a=r.length,i;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,u=l.length,d;c<u;++c)for(s=0,d=l[c];s<a;++s)if((i=r[s]).type===d.type&&i.name===d.name)return d.value}return}for(l=t?kBn:SBn,s=0;s<a;++s)this.each(l(r[s],t,n));return this}function Sxt(e,t,n){var r=vxt(e),s=r.CustomEvent;typeof s=="function"?s=new s(t,n):(s=r.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function _Bn(e,t){return function(){return Sxt(this,e,t)}}function CBn(e,t){return function(){return Sxt(this,e,t.apply(this,arguments))}}function EBn(e,t){return this.each((typeof t=="function"?CBn:_Bn)(e,t))}function*jBn(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,a=r.length,i;s<a;++s)(i=r[s])&&(yield i)}var kxt=[null];function Dp(e,t){this._groups=e,this._parents=t}function aD(){return new Dp([[document.documentElement]],kxt)}function TBn(){return this}Dp.prototype=aD.prototype={constructor:Dp,select:t7n,selectAll:a7n,selectChild:c7n,selectChildren:p7n,filter:h7n,data:x7n,enter:m7n,exit:S7n,join:k7n,merge:O7n,selection:TBn,order:_7n,sort:C7n,call:j7n,nodes:T7n,node:N7n,size:I7n,empty:A7n,each:R7n,attr:z7n,style:V7n,property:G7n,classed:K7n,text:nBn,html:iBn,raise:lBn,lower:uBn,append:dBn,insert:pBn,remove:mBn,clone:yBn,datum:bBn,on:OBn,dispatch:EBn,[Symbol.iterator]:jBn};function fp(e){return typeof e=="string"?new Dp([[document.querySelector(e)]],[document.documentElement]):new Dp([[e]],kxt)}function NBn(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Xm(e,t){if(e=NBn(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const IBn={passive:!1},Z$={capture:!0,passive:!1};function jJ(e){e.stopImmediatePropagation()}function bj(e){e.preventDefault(),e.stopImmediatePropagation()}function Oxt(e){var t=e.document.documentElement,n=fp(e).on("dragstart.drag",bj,Z$);"onselectstart"in t?n.on("selectstart.drag",bj,Z$):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function _xt(e,t){var n=e.document.documentElement,r=fp(e).on("dragstart.drag",null);t&&(r.on("click.drag",bj,Z$),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const h6=e=>()=>e;function lhe(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:a,x:i,y:l,dx:c,dy:u,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}lhe.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function ABn(e){return!e.ctrlKey&&!e.button}function RBn(){return this.parentNode}function PBn(e,t){return t??{x:e.x,y:e.y}}function $Bn(){return navigator.maxTouchPoints||"ontouchstart"in this}function Cxt(){var e=ABn,t=RBn,n=PBn,r=$Bn,s={},a=mV("start","drag","end"),i=0,l,c,u,d,f=0;function p(k){k.on("mousedown.drag",h).filter(r).on("touchstart.drag",y).on("touchmove.drag",b,IBn).on("touchend.drag touchcancel.drag",w).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(k,_){if(!(d||!e.call(this,k,_))){var C=S(this,t.call(this,k,_),k,_,"mouse");C&&(fp(k.view).on("mousemove.drag",m,Z$).on("mouseup.drag",g,Z$),Oxt(k.view),jJ(k),u=!1,l=k.clientX,c=k.clientY,C("start",k))}}function m(k){if(bj(k),!u){var _=k.clientX-l,C=k.clientY-c;u=_*_+C*C>f}s.mouse("drag",k)}function g(k){fp(k.view).on("mousemove.drag mouseup.drag",null),_xt(k.view,u),bj(k),s.mouse("end",k)}function y(k,_){if(e.call(this,k,_)){var C=k.changedTouches,E=t.call(this,k,_),j=C.length,N,I;for(N=0;N<j;++N)(I=S(this,E,k,_,C[N].identifier,C[N]))&&(jJ(k),I("start",k,C[N]))}}function b(k){var _=k.changedTouches,C=_.length,E,j;for(E=0;E<C;++E)(j=s[_[E].identifier])&&(bj(k),j("drag",k,_[E]))}function w(k){var _=k.changedTouches,C=_.length,E,j;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),E=0;E<C;++E)(j=s[_[E].identifier])&&(jJ(k),j("end",k,_[E]))}function S(k,_,C,E,j,N){var I=a.copy(),R=Xm(N||C,_),$,F,D;if((D=n.call(k,new lhe("beforestart",{sourceEvent:C,target:p,identifier:j,active:i,x:R[0],y:R[1],dx:0,dy:0,dispatch:I}),E))!=null)return $=D.x-R[0]||0,F=D.y-R[1]||0,function V(W,L,z){var B=R,M;switch(W){case"start":s[j]=V,M=i++;break;case"end":delete s[j],--i;case"drag":R=Xm(z||L,_),M=i;break}I.call(W,k,new lhe(W,{sourceEvent:L,subject:D,target:p,identifier:j,active:M,x:R[0]+$,y:R[1]+F,dx:R[0]-B[0],dy:R[1]-B[1],dispatch:I}),E)}}return p.filter=function(k){return arguments.length?(e=typeof k=="function"?k:h6(!!k),p):e},p.container=function(k){return arguments.length?(t=typeof k=="function"?k:h6(k),p):t},p.subject=function(k){return arguments.length?(n=typeof k=="function"?k:h6(k),p):n},p.touchable=function(k){return arguments.length?(r=typeof k=="function"?k:h6(!!k),p):r},p.on=function(){var k=a.on.apply(a,arguments);return k===a?p:k},p.clickDistance=function(k){return arguments.length?(f=(k=+k)*k,p):Math.sqrt(f)},p}function t1e(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Ext(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function iD(){}var G$=.7,g7=1/G$,xj="\\s*([+-]?\\d+)\\s*",Q$="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Xv="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",MBn=/^#([0-9a-f]{3,8})$/,DBn=new RegExp(`^rgb\\(${xj},${xj},${xj}\\)$`),LBn=new RegExp(`^rgb\\(${Xv},${Xv},${Xv}\\)$`),FBn=new RegExp(`^rgba\\(${xj},${xj},${xj},${Q$}\\)$`),zBn=new RegExp(`^rgba\\(${Xv},${Xv},${Xv},${Q$}\\)$`),BBn=new RegExp(`^hsl\\(${Q$},${Xv},${Xv}\\)$`),UBn=new RegExp(`^hsla\\(${Q$},${Xv},${Xv},${Q$}\\)$`),f8e={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};t1e(iD,jO,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:p8e,formatHex:p8e,formatHex8:qBn,formatHsl:VBn,formatRgb:h8e,toString:h8e});function p8e(){return this.rgb().formatHex()}function qBn(){return this.rgb().formatHex8()}function VBn(){return jxt(this).formatHsl()}function h8e(){return this.rgb().formatRgb()}function jO(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=MBn.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?m8e(t):n===3?new Xd(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?m6(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?m6(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=DBn.exec(e))?new Xd(t[1],t[2],t[3],1):(t=LBn.exec(e))?new Xd(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=FBn.exec(e))?m6(t[1],t[2],t[3],t[4]):(t=zBn.exec(e))?m6(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=BBn.exec(e))?y8e(t[1],t[2]/100,t[3]/100,1):(t=UBn.exec(e))?y8e(t[1],t[2]/100,t[3]/100,t[4]):f8e.hasOwnProperty(e)?m8e(f8e[e]):e==="transparent"?new Xd(NaN,NaN,NaN,0):null}function m8e(e){return new Xd(e>>16&255,e>>8&255,e&255,1)}function m6(e,t,n,r){return r<=0&&(e=t=n=NaN),new Xd(e,t,n,r)}function HBn(e){return e instanceof iD||(e=jO(e)),e?(e=e.rgb(),new Xd(e.r,e.g,e.b,e.opacity)):new Xd}function che(e,t,n,r){return arguments.length===1?HBn(e):new Xd(e,t,n,r??1)}function Xd(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}t1e(Xd,che,Ext(iD,{brighter(e){return e=e==null?g7:Math.pow(g7,e),new Xd(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?G$:Math.pow(G$,e),new Xd(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Xd(zk(this.r),zk(this.g),zk(this.b),v7(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:g8e,formatHex:g8e,formatHex8:WBn,formatRgb:v8e,toString:v8e}));function g8e(){return`#${_k(this.r)}${_k(this.g)}${_k(this.b)}`}function WBn(){return`#${_k(this.r)}${_k(this.g)}${_k(this.b)}${_k((isNaN(this.opacity)?1:this.opacity)*255)}`}function v8e(){const e=v7(this.opacity);return`${e===1?"rgb(":"rgba("}${zk(this.r)}, ${zk(this.g)}, ${zk(this.b)}${e===1?")":`, ${e})`}`}function v7(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function zk(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function _k(e){return e=zk(e),(e<16?"0":"")+e.toString(16)}function y8e(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new rg(e,t,n,r)}function jxt(e){if(e instanceof rg)return new rg(e.h,e.s,e.l,e.opacity);if(e instanceof iD||(e=jO(e)),!e)return new rg;if(e instanceof rg)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),a=Math.max(t,n,r),i=NaN,l=a-s,c=(a+s)/2;return l?(t===a?i=(n-r)/l+(n<r)*6:n===a?i=(r-t)/l+2:i=(t-n)/l+4,l/=c<.5?a+s:2-a-s,i*=60):l=c>0&&c<1?0:i,new rg(i,l,c,e.opacity)}function ZBn(e,t,n,r){return arguments.length===1?jxt(e):new rg(e,t,n,r??1)}function rg(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}t1e(rg,ZBn,Ext(iD,{brighter(e){return e=e==null?g7:Math.pow(g7,e),new rg(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?G$:Math.pow(G$,e),new rg(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,s=2*n-r;return new Xd(TJ(e>=240?e-240:e+120,s,r),TJ(e,s,r),TJ(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new rg(b8e(this.h),g6(this.s),g6(this.l),v7(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=v7(this.opacity);return`${e===1?"hsl(":"hsla("}${b8e(this.h)}, ${g6(this.s)*100}%, ${g6(this.l)*100}%${e===1?")":`, ${e})`}`}}));function b8e(e){return e=(e||0)%360,e<0?e+360:e}function g6(e){return Math.max(0,Math.min(1,e||0))}function TJ(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const n1e=e=>()=>e;function GBn(e,t){return function(n){return e+n*t}}function QBn(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function YBn(e){return(e=+e)==1?Txt:function(t,n){return n-t?QBn(t,n,e):n1e(isNaN(t)?n:t)}}function Txt(e,t){var n=t-e;return n?GBn(e,n):n1e(isNaN(e)?t:e)}const y7=(function e(t){var n=YBn(t);function r(s,a){var i=n((s=che(s)).r,(a=che(a)).r),l=n(s.g,a.g),c=n(s.b,a.b),u=Txt(s.opacity,a.opacity);return function(d){return s.r=i(d),s.g=l(d),s.b=c(d),s.opacity=u(d),s+""}}return r.gamma=e,r})(1);function XBn(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),s;return function(a){for(s=0;s<n;++s)r[s]=e[s]*(1-a)+t[s]*a;return r}}function KBn(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function JBn(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,s=new Array(r),a=new Array(n),i;for(i=0;i<r;++i)s[i]=rx(e[i],t[i]);for(;i<n;++i)a[i]=t[i];return function(l){for(i=0;i<r;++i)a[i]=s[i](l);return a}}function eUn(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Jm(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function tUn(e,t){var n={},r={},s;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in e?n[s]=rx(e[s],t[s]):r[s]=t[s];return function(a){for(s in n)r[s]=n[s](a);return r}}var uhe=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,NJ=new RegExp(uhe.source,"g");function nUn(e){return function(){return e}}function rUn(e){return function(t){return e(t)+""}}function Nxt(e,t){var n=uhe.lastIndex=NJ.lastIndex=0,r,s,a,i=-1,l=[],c=[];for(e=e+"",t=t+"";(r=uhe.exec(e))&&(s=NJ.exec(t));)(a=s.index)>n&&(a=t.slice(n,a),l[i]?l[i]+=a:l[++i]=a),(r=r[0])===(s=s[0])?l[i]?l[i]+=s:l[++i]=s:(l[++i]=null,c.push({i,x:Jm(r,s)})),n=NJ.lastIndex;return n<t.length&&(a=t.slice(n),l[i]?l[i]+=a:l[++i]=a),l.length<2?c[0]?rUn(c[0].x):nUn(t):(t=c.length,function(u){for(var d=0,f;d<t;++d)l[(f=c[d]).i]=f.x(u);return l.join("")})}function rx(e,t){var n=typeof t,r;return t==null||n==="boolean"?n1e(t):(n==="number"?Jm:n==="string"?(r=jO(t))?(t=r,y7):Nxt:t instanceof jO?y7:t instanceof Date?eUn:KBn(t)?XBn:Array.isArray(t)?JBn:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?tUn:Jm)(e,t)}function r1e(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var x8e=180/Math.PI,dhe={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ixt(e,t,n,r,s,a){var i,l,c;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(l=Math.sqrt(n*n+r*r))&&(n/=l,r/=l,c/=l),e*r<t*n&&(e=-e,t=-t,c=-c,i=-i),{translateX:s,translateY:a,rotate:Math.atan2(t,e)*x8e,skewX:Math.atan(c)*x8e,scaleX:i,scaleY:l}}var v6;function sUn(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?dhe:Ixt(t.a,t.b,t.c,t.d,t.e,t.f)}function aUn(e){return e==null||(v6||(v6=document.createElementNS("http://www.w3.org/2000/svg","g")),v6.setAttribute("transform",e),!(e=v6.transform.baseVal.consolidate()))?dhe:(e=e.matrix,Ixt(e.a,e.b,e.c,e.d,e.e,e.f))}function Axt(e,t,n,r){function s(u){return u.length?u.pop()+" ":""}function a(u,d,f,p,h,m){if(u!==f||d!==p){var g=h.push("translate(",null,t,null,n);m.push({i:g-4,x:Jm(u,f)},{i:g-2,x:Jm(d,p)})}else(f||p)&&h.push("translate("+f+t+p+n)}function i(u,d,f,p){u!==d?(u-d>180?d+=360:d-u>180&&(u+=360),p.push({i:f.push(s(f)+"rotate(",null,r)-2,x:Jm(u,d)})):d&&f.push(s(f)+"rotate("+d+r)}function l(u,d,f,p){u!==d?p.push({i:f.push(s(f)+"skewX(",null,r)-2,x:Jm(u,d)}):d&&f.push(s(f)+"skewX("+d+r)}function c(u,d,f,p,h,m){if(u!==f||d!==p){var g=h.push(s(h)+"scale(",null,",",null,")");m.push({i:g-4,x:Jm(u,f)},{i:g-2,x:Jm(d,p)})}else(f!==1||p!==1)&&h.push(s(h)+"scale("+f+","+p+")")}return function(u,d){var f=[],p=[];return u=e(u),d=e(d),a(u.translateX,u.translateY,d.translateX,d.translateY,f,p),i(u.rotate,d.rotate,f,p),l(u.skewX,d.skewX,f,p),c(u.scaleX,u.scaleY,d.scaleX,d.scaleY,f,p),u=d=null,function(h){for(var m=-1,g=p.length,y;++m<g;)f[(y=p[m]).i]=y.x(h);return f.join("")}}}var iUn=Axt(sUn,"px, ","px)","deg)"),oUn=Axt(aUn,", ",")",")"),lUn=1e-12;function w8e(e){return((e=Math.exp(e))+1/e)/2}function cUn(e){return((e=Math.exp(e))-1/e)/2}function uUn(e){return((e=Math.exp(2*e))-1)/(e+1)}const L9=(function e(t,n,r){function s(a,i){var l=a[0],c=a[1],u=a[2],d=i[0],f=i[1],p=i[2],h=d-l,m=f-c,g=h*h+m*m,y,b;if(g<lUn)b=Math.log(p/u)/t,y=function(E){return[l+E*h,c+E*m,u*Math.exp(t*E*b)]};else{var w=Math.sqrt(g),S=(p*p-u*u+r*g)/(2*u*n*w),k=(p*p-u*u-r*g)/(2*p*n*w),_=Math.log(Math.sqrt(S*S+1)-S),C=Math.log(Math.sqrt(k*k+1)-k);b=(C-_)/t,y=function(E){var j=E*b,N=w8e(_),I=u/(n*w)*(N*uUn(t*j+_)-cUn(_));return[l+I*h,c+I*m,u*N/w8e(t*j+_)]}}return y.duration=b*1e3*t/Math.SQRT2,y}return s.rho=function(a){var i=Math.max(.001,+a),l=i*i,c=l*l;return e(i,l,c)},s})(Math.SQRT2,2,4);function dUn(e,t){t===void 0&&(t=e,e=rx);for(var n=0,r=t.length-1,s=t[0],a=new Array(r<0?0:r);n<r;)a[n]=e(s,s=t[++n]);return function(i){var l=Math.max(0,Math.min(r-1,Math.floor(i*=r)));return a[l](i-l)}}var mT=0,r2=0,qA=0,Rxt=1e3,b7,s2,x7=0,TO=0,vV=0,Y$=typeof performance=="object"&&performance.now?performance:Date,Pxt=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function s1e(){return TO||(Pxt(fUn),TO=Y$.now()+vV)}function fUn(){TO=0}function w7(){this._call=this._time=this._next=null}w7.prototype=$xt.prototype={constructor:w7,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?s1e():+n)+(t==null?0:+t),!this._next&&s2!==this&&(s2?s2._next=this:b7=this,s2=this),this._call=e,this._time=n,fhe()},stop:function(){this._call&&(this._call=null,this._time=1/0,fhe())}};function $xt(e,t,n){var r=new w7;return r.restart(e,t,n),r}function pUn(){s1e(),++mT;for(var e=b7,t;e;)(t=TO-e._time)>=0&&e._call.call(void 0,t),e=e._next;--mT}function S8e(){TO=(x7=Y$.now())+vV,mT=r2=0;try{pUn()}finally{mT=0,mUn(),TO=0}}function hUn(){var e=Y$.now(),t=e-x7;t>Rxt&&(vV-=t,x7=e)}function mUn(){for(var e,t=b7,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:b7=n);s2=e,fhe(r)}function fhe(e){if(!mT){r2&&(r2=clearTimeout(r2));var t=e-TO;t>24?(e<1/0&&(r2=setTimeout(S8e,e-Y$.now()-vV)),qA&&(qA=clearInterval(qA))):(qA||(x7=Y$.now(),qA=setInterval(hUn,Rxt)),mT=1,Pxt(S8e))}}function k8e(e,t,n){var r=new w7;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var gUn=mV("start","end","cancel","interrupt"),vUn=[],Mxt=0,O8e=1,phe=2,F9=3,_8e=4,hhe=5,z9=6;function yV(e,t,n,r,s,a){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;yUn(e,n,{name:t,index:r,group:s,on:gUn,tween:vUn,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:Mxt})}function a1e(e,t){var n=Lg(e,t);if(n.state>Mxt)throw new Error("too late; already scheduled");return n}function $y(e,t){var n=Lg(e,t);if(n.state>F9)throw new Error("too late; already running");return n}function Lg(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function yUn(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=$xt(a,0,n.time);function a(u){n.state=O8e,n.timer.restart(i,n.delay,n.time),n.delay<=u&&i(u-n.delay)}function i(u){var d,f,p,h;if(n.state!==O8e)return c();for(d in r)if(h=r[d],h.name===n.name){if(h.state===F9)return k8e(i);h.state===_8e?(h.state=z9,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[d]):+d<t&&(h.state=z9,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[d])}if(k8e(function(){n.state===F9&&(n.state=_8e,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=phe,n.on.call("start",e,e.__data__,n.index,n.group),n.state===phe){for(n.state=F9,s=new Array(p=n.tween.length),d=0,f=-1;d<p;++d)(h=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(s[++f]=h);s.length=f+1}}function l(u){for(var d=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=hhe,1),f=-1,p=s.length;++f<p;)s[f].call(e,d);n.state===hhe&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=z9,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function B9(e,t){var n=e.__transition,r,s,a=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((r=n[i]).name!==t){a=!1;continue}s=r.state>phe&&r.state<hhe,r.state=z9,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[i]}a&&delete e.__transition}}function bUn(e){return this.each(function(){B9(this,e)})}function xUn(e,t){var n,r;return function(){var s=$y(this,e),a=s.tween;if(a!==n){r=n=a;for(var i=0,l=r.length;i<l;++i)if(r[i].name===t){r=r.slice(),r.splice(i,1);break}}s.tween=r}}function wUn(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var a=$y(this,e),i=a.tween;if(i!==r){s=(r=i).slice();for(var l={name:t,value:n},c=0,u=s.length;c<u;++c)if(s[c].name===t){s[c]=l;break}c===u&&s.push(l)}a.tween=s}}function SUn(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Lg(this.node(),n).tween,s=0,a=r.length,i;s<a;++s)if((i=r[s]).name===e)return i.value;return null}return this.each((t==null?xUn:wUn)(n,e,t))}function i1e(e,t,n){var r=e._id;return e.each(function(){var s=$y(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return Lg(s,r).value[t]}}function Dxt(e,t){var n;return(typeof t=="number"?Jm:t instanceof jO?y7:(n=jO(t))?(t=n,y7):Nxt)(e,t)}function kUn(e){return function(){this.removeAttribute(e)}}function OUn(e){return function(){this.removeAttributeNS(e.space,e.local)}}function _Un(e,t,n){var r,s=n+"",a;return function(){var i=this.getAttribute(e);return i===s?null:i===r?a:a=t(r=i,n)}}function CUn(e,t,n){var r,s=n+"",a;return function(){var i=this.getAttributeNS(e.space,e.local);return i===s?null:i===r?a:a=t(r=i,n)}}function EUn(e,t,n){var r,s,a;return function(){var i,l=n(this),c;return l==null?void this.removeAttribute(e):(i=this.getAttribute(e),c=l+"",i===c?null:i===r&&c===s?a:(s=c,a=t(r=i,l)))}}function jUn(e,t,n){var r,s,a;return function(){var i,l=n(this),c;return l==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),c=l+"",i===c?null:i===r&&c===s?a:(s=c,a=t(r=i,l)))}}function TUn(e,t){var n=gV(e),r=n==="transform"?oUn:Dxt;return this.attrTween(e,typeof t=="function"?(n.local?jUn:EUn)(n,r,i1e(this,"attr."+e,t)):t==null?(n.local?OUn:kUn)(n):(n.local?CUn:_Un)(n,r,t))}function NUn(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function IUn(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function AUn(e,t){var n,r;function s(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&IUn(e,a)),n}return s._value=t,s}function RUn(e,t){var n,r;function s(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&NUn(e,a)),n}return s._value=t,s}function PUn(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=gV(e);return this.tween(n,(r.local?AUn:RUn)(r,t))}function $Un(e,t){return function(){a1e(this,e).delay=+t.apply(this,arguments)}}function MUn(e,t){return t=+t,function(){a1e(this,e).delay=t}}function DUn(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?$Un:MUn)(t,e)):Lg(this.node(),t).delay}function LUn(e,t){return function(){$y(this,e).duration=+t.apply(this,arguments)}}function FUn(e,t){return t=+t,function(){$y(this,e).duration=t}}function zUn(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?LUn:FUn)(t,e)):Lg(this.node(),t).duration}function BUn(e,t){if(typeof t!="function")throw new Error;return function(){$y(this,e).ease=t}}function UUn(e){var t=this._id;return arguments.length?this.each(BUn(t,e)):Lg(this.node(),t).ease}function qUn(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;$y(this,e).ease=n}}function VUn(e){if(typeof e!="function")throw new Error;return this.each(qUn(this._id,e))}function HUn(e){typeof e!="function"&&(e=hxt(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=r[s]=[],c,u=0;u<i;++u)(c=a[u])&&e.call(c,c.__data__,u,a)&&l.push(c);return new kx(r,this._parents,this._name,this._id)}function WUn(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,a=Math.min(r,s),i=new Array(r),l=0;l<a;++l)for(var c=t[l],u=n[l],d=c.length,f=i[l]=new Array(d),p,h=0;h<d;++h)(p=c[h]||u[h])&&(f[h]=p);for(;l<r;++l)i[l]=t[l];return new kx(i,this._parents,this._name,this._id)}function ZUn(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function GUn(e,t,n){var r,s,a=ZUn(t)?a1e:$y;return function(){var i=a(this,e),l=i.on;l!==r&&(s=(r=l).copy()).on(t,n),i.on=s}}function QUn(e,t){var n=this._id;return arguments.length<2?Lg(this.node(),n).on.on(e):this.each(GUn(n,e,t))}function YUn(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function XUn(){return this.on("end.remove",YUn(this._id))}function KUn(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Jwe(e));for(var r=this._groups,s=r.length,a=new Array(s),i=0;i<s;++i)for(var l=r[i],c=l.length,u=a[i]=new Array(c),d,f,p=0;p<c;++p)(d=l[p])&&(f=e.call(d,d.__data__,p,l))&&("__data__"in d&&(f.__data__=d.__data__),u[p]=f,yV(u[p],t,n,p,u,Lg(d,n)));return new kx(a,this._parents,t,n)}function JUn(e){var t=this._name,n=this._id;typeof e!="function"&&(e=pxt(e));for(var r=this._groups,s=r.length,a=[],i=[],l=0;l<s;++l)for(var c=r[l],u=c.length,d,f=0;f<u;++f)if(d=c[f]){for(var p=e.call(d,d.__data__,f,c),h,m=Lg(d,n),g=0,y=p.length;g<y;++g)(h=p[g])&&yV(h,t,n,g,p,m);a.push(p),i.push(d)}return new kx(a,i,t,n)}var eqn=aD.prototype.constructor;function tqn(){return new eqn(this._groups,this._parents)}function nqn(e,t){var n,r,s;return function(){var a=hT(this,e),i=(this.style.removeProperty(e),hT(this,e));return a===i?null:a===n&&i===r?s:s=t(n=a,r=i)}}function Lxt(e){return function(){this.style.removeProperty(e)}}function rqn(e,t,n){var r,s=n+"",a;return function(){var i=hT(this,e);return i===s?null:i===r?a:a=t(r=i,n)}}function sqn(e,t,n){var r,s,a;return function(){var i=hT(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),hT(this,e))),i===c?null:i===r&&c===s?a:(s=c,a=t(r=i,l))}}function aqn(e,t){var n,r,s,a="style."+t,i="end."+a,l;return function(){var c=$y(this,e),u=c.on,d=c.value[a]==null?l||(l=Lxt(t)):void 0;(u!==n||s!==d)&&(r=(n=u).copy()).on(i,s=d),c.on=r}}function iqn(e,t,n){var r=(e+="")=="transform"?iUn:Dxt;return t==null?this.styleTween(e,nqn(e,r)).on("end.style."+e,Lxt(e)):typeof t=="function"?this.styleTween(e,sqn(e,r,i1e(this,"style."+e,t))).each(aqn(this._id,e)):this.styleTween(e,rqn(e,r,t),n).on("end.style."+e,null)}function oqn(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function lqn(e,t,n){var r,s;function a(){var i=t.apply(this,arguments);return i!==s&&(r=(s=i)&&oqn(e,i,n)),r}return a._value=t,a}function cqn(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,lqn(e,t,n??""))}function uqn(e){return function(){this.textContent=e}}function dqn(e){return function(){var t=e(this);this.textContent=t??""}}function fqn(e){return this.tween("text",typeof e=="function"?dqn(i1e(this,"text",e)):uqn(e==null?"":e+""))}function pqn(e){return function(t){this.textContent=e.call(this,t)}}function hqn(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&pqn(s)),t}return r._value=e,r}function mqn(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,hqn(e))}function gqn(){for(var e=this._name,t=this._id,n=Fxt(),r=this._groups,s=r.length,a=0;a<s;++a)for(var i=r[a],l=i.length,c,u=0;u<l;++u)if(c=i[u]){var d=Lg(c,t);yV(c,e,n,u,i,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new kx(r,this._parents,e,n)}function vqn(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(a,i){var l={value:i},c={value:function(){--s===0&&a()}};n.each(function(){var u=$y(this,r),d=u.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),u.on=t}),s===0&&a()})}var yqn=0;function kx(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Fxt(){return++yqn}var pb=aD.prototype;kx.prototype={constructor:kx,select:KUn,selectAll:JUn,selectChild:pb.selectChild,selectChildren:pb.selectChildren,filter:HUn,merge:WUn,selection:tqn,transition:gqn,call:pb.call,nodes:pb.nodes,node:pb.node,size:pb.size,empty:pb.empty,each:pb.each,on:QUn,attr:TUn,attrTween:PUn,style:iqn,styleTween:cqn,text:fqn,textTween:mqn,remove:XUn,tween:SUn,delay:DUn,duration:zUn,ease:UUn,easeVarying:VUn,end:vqn,[Symbol.iterator]:pb[Symbol.iterator]};function bqn(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var xqn={time:null,delay:0,duration:250,ease:bqn};function wqn(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Sqn(e){var t,n;e instanceof kx?(t=e._id,e=e._name):(t=Fxt(),(n=xqn).time=s1e(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,a=0;a<s;++a)for(var i=r[a],l=i.length,c,u=0;u<l;++u)(c=i[u])&&yV(c,e,t,u,i,n||wqn(c,t));return new kx(r,this._parents,e,t)}aD.prototype.interrupt=bUn;aD.prototype.transition=Sqn;const y6=e=>()=>e;function kqn(e,{sourceEvent:t,target:n,transform:r,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:s}})}function Vb(e,t,n){this.k=e,this.x=t,this.y=n}Vb.prototype={constructor:Vb,scale:function(e){return e===1?this:new Vb(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Vb(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var bV=new Vb(1,0,0);zxt.prototype=Vb.prototype;function zxt(e){for(;!e.__zoom;)if(!(e=e.parentNode))return bV;return e.__zoom}function IJ(e){e.stopImmediatePropagation()}function VA(e){e.preventDefault(),e.stopImmediatePropagation()}function Oqn(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function _qn(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function C8e(){return this.__zoom||bV}function Cqn(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Eqn(){return navigator.maxTouchPoints||"ontouchstart"in this}function jqn(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),i>a?(a+i)/2:Math.min(0,a)||Math.max(0,i))}function Bxt(){var e=Oqn,t=_qn,n=jqn,r=Cqn,s=Eqn,a=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,c=L9,u=mV("start","zoom","end"),d,f,p,h=500,m=150,g=0,y=10;function b(D){D.property("__zoom",C8e).on("wheel.zoom",j,{passive:!1}).on("mousedown.zoom",N).on("dblclick.zoom",I).filter(s).on("touchstart.zoom",R).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",F).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(D,V,W,L){var z=D.selection?D.selection():D;z.property("__zoom",C8e),D!==z?_(D,V,W,L):z.interrupt().each(function(){C(this,arguments).event(L).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},b.scaleBy=function(D,V,W,L){b.scaleTo(D,function(){var z=this.__zoom.k,B=typeof V=="function"?V.apply(this,arguments):V;return z*B},W,L)},b.scaleTo=function(D,V,W,L){b.transform(D,function(){var z=t.apply(this,arguments),B=this.__zoom,M=W==null?k(z):typeof W=="function"?W.apply(this,arguments):W,G=B.invert(M),U=typeof V=="function"?V.apply(this,arguments):V;return n(S(w(B,U),M,G),z,i)},W,L)},b.translateBy=function(D,V,W,L){b.transform(D,function(){return n(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),t.apply(this,arguments),i)},null,L)},b.translateTo=function(D,V,W,L,z){b.transform(D,function(){var B=t.apply(this,arguments),M=this.__zoom,G=L==null?k(B):typeof L=="function"?L.apply(this,arguments):L;return n(bV.translate(G[0],G[1]).scale(M.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),B,i)},L,z)};function w(D,V){return V=Math.max(a[0],Math.min(a[1],V)),V===D.k?D:new Vb(V,D.x,D.y)}function S(D,V,W){var L=V[0]-W[0]*D.k,z=V[1]-W[1]*D.k;return L===D.x&&z===D.y?D:new Vb(D.k,L,z)}function k(D){return[(+D[0][0]+ +D[1][0])/2,(+D[0][1]+ +D[1][1])/2]}function _(D,V,W,L){D.on("start.zoom",function(){C(this,arguments).event(L).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(L).end()}).tween("zoom",function(){var z=this,B=arguments,M=C(z,B).event(L),G=t.apply(z,B),U=W==null?k(G):typeof W=="function"?W.apply(z,B):W,P=Math.max(G[1][0]-G[0][0],G[1][1]-G[0][1]),q=z.__zoom,Z=typeof V=="function"?V.apply(z,B):V,X=c(q.invert(U).concat(P/q.k),Z.invert(U).concat(P/Z.k));return function(te){if(te===1)te=Z;else{var J=X(te),ee=P/J[2];te=new Vb(ee,U[0]-J[0]*ee,U[1]-J[1]*ee)}M.zoom(null,te)}})}function C(D,V,W){return!W&&D.__zooming||new E(D,V)}function E(D,V){this.that=D,this.args=V,this.active=0,this.sourceEvent=null,this.extent=t.apply(D,V),this.taps=0}E.prototype={event:function(D){return D&&(this.sourceEvent=D),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(D,V){return this.mouse&&D!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&D!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&D!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(D){var V=fp(this.that).datum();u.call(D,this.that,new kqn(D,{sourceEvent:this.sourceEvent,target:b,transform:this.that.__zoom,dispatch:u}),V)}};function j(D,...V){if(!e.apply(this,arguments))return;var W=C(this,V).event(D),L=this.__zoom,z=Math.max(a[0],Math.min(a[1],L.k*Math.pow(2,r.apply(this,arguments)))),B=Xm(D);if(W.wheel)(W.mouse[0][0]!==B[0]||W.mouse[0][1]!==B[1])&&(W.mouse[1]=L.invert(W.mouse[0]=B)),clearTimeout(W.wheel);else{if(L.k===z)return;W.mouse=[B,L.invert(B)],B9(this),W.start()}VA(D),W.wheel=setTimeout(M,m),W.zoom("mouse",n(S(w(L,z),W.mouse[0],W.mouse[1]),W.extent,i));function M(){W.wheel=null,W.end()}}function N(D,...V){if(p||!e.apply(this,arguments))return;var W=D.currentTarget,L=C(this,V,!0).event(D),z=fp(D.view).on("mousemove.zoom",U,!0).on("mouseup.zoom",P,!0),B=Xm(D,W),M=D.clientX,G=D.clientY;Oxt(D.view),IJ(D),L.mouse=[B,this.__zoom.invert(B)],B9(this),L.start();function U(q){if(VA(q),!L.moved){var Z=q.clientX-M,X=q.clientY-G;L.moved=Z*Z+X*X>g}L.event(q).zoom("mouse",n(S(L.that.__zoom,L.mouse[0]=Xm(q,W),L.mouse[1]),L.extent,i))}function P(q){z.on("mousemove.zoom mouseup.zoom",null),_xt(q.view,L.moved),VA(q),L.event(q).end()}}function I(D,...V){if(e.apply(this,arguments)){var W=this.__zoom,L=Xm(D.changedTouches?D.changedTouches[0]:D,this),z=W.invert(L),B=W.k*(D.shiftKey?.5:2),M=n(S(w(W,B),L,z),t.apply(this,V),i);VA(D),l>0?fp(this).transition().duration(l).call(_,M,L,D):fp(this).call(b.transform,M,L,D)}}function R(D,...V){if(e.apply(this,arguments)){var W=D.touches,L=W.length,z=C(this,V,D.changedTouches.length===L).event(D),B,M,G,U;for(IJ(D),M=0;M<L;++M)G=W[M],U=Xm(G,this),U=[U,this.__zoom.invert(U),G.identifier],z.touch0?!z.touch1&&z.touch0[2]!==U[2]&&(z.touch1=U,z.taps=0):(z.touch0=U,B=!0,z.taps=1+!!d);d&&(d=clearTimeout(d)),B&&(z.taps<2&&(f=U[0],d=setTimeout(function(){d=null},h)),B9(this),z.start())}}function $(D,...V){if(this.__zooming){var W=C(this,V).event(D),L=D.changedTouches,z=L.length,B,M,G,U;for(VA(D),B=0;B<z;++B)M=L[B],G=Xm(M,this),W.touch0&&W.touch0[2]===M.identifier?W.touch0[0]=G:W.touch1&&W.touch1[2]===M.identifier&&(W.touch1[0]=G);if(M=W.that.__zoom,W.touch1){var P=W.touch0[0],q=W.touch0[1],Z=W.touch1[0],X=W.touch1[1],te=(te=Z[0]-P[0])*te+(te=Z[1]-P[1])*te,J=(J=X[0]-q[0])*J+(J=X[1]-q[1])*J;M=w(M,Math.sqrt(te/J)),G=[(P[0]+Z[0])/2,(P[1]+Z[1])/2],U=[(q[0]+X[0])/2,(q[1]+X[1])/2]}else if(W.touch0)G=W.touch0[0],U=W.touch0[1];else return;W.zoom("touch",n(S(M,G,U),W.extent,i))}}function F(D,...V){if(this.__zooming){var W=C(this,V).event(D),L=D.changedTouches,z=L.length,B,M;for(IJ(D),p&&clearTimeout(p),p=setTimeout(function(){p=null},h),B=0;B<z;++B)M=L[B],W.touch0&&W.touch0[2]===M.identifier?delete W.touch0:W.touch1&&W.touch1[2]===M.identifier&&delete W.touch1;if(W.touch1&&!W.touch0&&(W.touch0=W.touch1,delete W.touch1),W.touch0)W.touch0[1]=this.__zoom.invert(W.touch0[0]);else if(W.end(),W.taps===2&&(M=Xm(M,this),Math.hypot(f[0]-M[0],f[1]-M[1])<y)){var G=fp(this).on("dblclick.zoom");G&&G.apply(this,arguments)}}}return b.wheelDelta=function(D){return arguments.length?(r=typeof D=="function"?D:y6(+D),b):r},b.filter=function(D){return arguments.length?(e=typeof D=="function"?D:y6(!!D),b):e},b.touchable=function(D){return arguments.length?(s=typeof D=="function"?D:y6(!!D),b):s},b.extent=function(D){return arguments.length?(t=typeof D=="function"?D:y6([[+D[0][0],+D[0][1]],[+D[1][0],+D[1][1]]]),b):t},b.scaleExtent=function(D){return arguments.length?(a[0]=+D[0],a[1]=+D[1],b):[a[0],a[1]]},b.translateExtent=function(D){return arguments.length?(i[0][0]=+D[0][0],i[1][0]=+D[1][0],i[0][1]=+D[0][1],i[1][1]=+D[1][1],b):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},b.constrain=function(D){return arguments.length?(n=D,b):n},b.duration=function(D){return arguments.length?(l=+D,b):l},b.interpolate=function(D){return arguments.length?(c=D,b):c},b.on=function(){var D=u.on.apply(u,arguments);return D===u?b:D},b.clickDistance=function(D){return arguments.length?(g=(D=+D)*D,b):Math.sqrt(g)},b.tapDistance=function(D){return arguments.length?(y=+D,b):y},b}const py={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},X$=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Uxt=["Enter"," ","Escape"],qxt={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var gT;(function(e){e.Strict="strict",e.Loose="loose"})(gT||(gT={}));var Bk;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Bk||(Bk={}));var K$;(function(e){e.Partial="partial",e.Full="full"})(K$||(K$={}));const Vxt={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var sw;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(sw||(sw={}));var J$;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(J$||(J$={}));var nr;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(nr||(nr={}));const E8e={[nr.Left]:nr.Right,[nr.Right]:nr.Left,[nr.Top]:nr.Bottom,[nr.Bottom]:nr.Top};function Hxt(e){return e===null?null:e?"valid":"invalid"}const Wxt=e=>"id"in e&&"source"in e&&"target"in e,Tqn=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),o1e=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),oD=(e,t=[0,0])=>{const{width:n,height:r}=Hx(e),s=e.origin??t,a=n*s[0],i=r*s[1];return{x:e.position.x-a,y:e.position.y-i}},Nqn=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const a=typeof s=="string";let i=!t.nodeLookup&&!a?s:void 0;t.nodeLookup&&(i=a?t.nodeLookup.get(s):o1e(s)?s:t.nodeLookup.get(s.id));const l=i?S7(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return xV(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return wV(n)},lD=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=xV(n,S7(s)),r=!0)}),r?wV(n):{x:0,y:0,width:0,height:0}},l1e=(e,t,[n,r,s]=[0,0,1],a=!1,i=!1)=>{const l={...uD(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const u of e.values()){const{measured:d,selectable:f=!0,hidden:p=!1}=u;if(i&&!f||p)continue;const h=d.width??u.width??u.initialWidth??null,m=d.height??u.height??u.initialHeight??null,g=eM(l,yT(u)),y=(h??0)*(m??0),b=a&&g>0;(!u.internals.handleBounds||b||g>=y||u.dragging)&&c.push(u)}return c},Iqn=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function Aqn(e,t){const n=new Map,r=t?.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&(t?.includeHiddenNodes||!s.hidden)&&(!r||r.has(s.id))&&n.set(s.id,s)}),n}async function Rqn({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:a},i){if(e.size===0)return Promise.resolve(!0);const l=Aqn(e,i),c=lD(l),u=c1e(c,t,n,i?.minZoom??s,i?.maxZoom??a,i?.padding??.1);return await r.setViewport(u,{duration:i?.duration,ease:i?.ease,interpolate:i?.interpolate}),Promise.resolve(!0)}function Zxt({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:s,onError:a}){const i=n.get(e),l=i.parentId?n.get(i.parentId):void 0,{x:c,y:u}=l?l.internals.positionAbsolute:{x:0,y:0},d=i.origin??r;let f=i.extent||s;if(i.extent==="parent"&&!i.expandParent)if(!l)a?.("005",py.error005());else{const h=l.measured.width,m=l.measured.height;h&&m&&(f=[[c,u],[c+h,u+m]])}else l&&bT(i.extent)&&(f=[[i.extent[0][0]+c,i.extent[0][1]+u],[i.extent[1][0]+c,i.extent[1][1]+u]]);const p=bT(f)?NO(t,f,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&a?.("015",py.error015()),{position:{x:p.x-c+(i.measured.width??0)*d[0],y:p.y-u+(i.measured.height??0)*d[1]},positionAbsolute:p}}async function Pqn({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const a=new Set(e.map(p=>p.id)),i=[];for(const p of n){if(p.deletable===!1)continue;const h=a.has(p.id),m=!h&&p.parentId&&i.find(g=>g.id===p.parentId);(h||m)&&i.push(p)}const l=new Set(t.map(p=>p.id)),c=r.filter(p=>p.deletable!==!1),d=Iqn(i,c);for(const p of c)l.has(p.id)&&!d.find(m=>m.id===p.id)&&d.push(p);if(!s)return{edges:d,nodes:i};const f=await s({nodes:i,edges:d});return typeof f=="boolean"?f?{edges:d,nodes:i}:{edges:[],nodes:[]}:f}const vT=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),NO=(e={x:0,y:0},t,n)=>({x:vT(e.x,t[0][0],t[1][0]-(n?.width??0)),y:vT(e.y,t[0][1],t[1][1]-(n?.height??0))});function Gxt(e,t,n){const{width:r,height:s}=Hx(n),{x:a,y:i}=n.internals.positionAbsolute;return NO(e,[[a,i],[a+r,i+s]],t)}const j8e=(e,t,n)=>e<t?vT(Math.abs(e-t),1,t)/t:e>n?-vT(Math.abs(e-n),1,t)/t:0,Qxt=(e,t,n=15,r=40)=>{const s=j8e(e.x,r,t.width-r)*n,a=j8e(e.y,r,t.height-r)*n;return[s,a]},xV=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),mhe=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),wV=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),yT=(e,t=[0,0])=>{const{x:n,y:r}=o1e(e)?e.internals.positionAbsolute:oD(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},S7=(e,t=[0,0])=>{const{x:n,y:r}=o1e(e)?e.internals.positionAbsolute:oD(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},Yxt=(e,t)=>wV(xV(mhe(e),mhe(t))),eM=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},T8e=e=>cg(e.width)&&cg(e.height)&&cg(e.x)&&cg(e.y),cg=e=>!isNaN(e)&&isFinite(e),$qn=(e,t)=>{},cD=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),uD=({x:e,y:t},[n,r,s],a=!1,i=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return a?cD(l,i):l},k7=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function MC(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Mqn(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=MC(e,n),s=MC(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=MC(e.top??e.y??0,n),s=MC(e.bottom??e.y??0,n),a=MC(e.left??e.x??0,t),i=MC(e.right??e.x??0,t);return{top:r,right:i,bottom:s,left:a,x:a+i,y:r+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Dqn(e,t,n,r,s,a){const{x:i,y:l}=k7(e,[t,n,r]),{x:c,y:u}=k7({x:e.x+e.width,y:e.y+e.height},[t,n,r]),d=s-c,f=a-u;return{left:Math.floor(i),top:Math.floor(l),right:Math.floor(d),bottom:Math.floor(f)}}const c1e=(e,t,n,r,s,a)=>{const i=Mqn(a,t,n),l=(t-i.x)/e.width,c=(n-i.y)/e.height,u=Math.min(l,c),d=vT(u,r,s),f=e.x+e.width/2,p=e.y+e.height/2,h=t/2-f*d,m=n/2-p*d,g=Dqn(e,h,m,d,t,n),y={left:Math.min(g.left-i.left,0),top:Math.min(g.top-i.top,0),right:Math.min(g.right-i.right,0),bottom:Math.min(g.bottom-i.bottom,0)};return{x:h-y.left+y.right,y:m-y.top+y.bottom,zoom:d}},tM=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function bT(e){return e!=null&&e!=="parent"}function Hx(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Xxt(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Kxt(e,t={width:0,height:0},n,r,s){const a={...e},i=r.get(n);if(i){const l=i.origin||s;a.x+=i.internals.positionAbsolute.x-(t.width??0)*l[0],a.y+=i.internals.positionAbsolute.y-(t.height??0)*l[1]}return a}function N8e(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Lqn(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function Fqn(e){return{...qxt,...e||{}}}function D2(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:a,y:i}=ug(e),l=uD({x:a-(s?.left??0),y:i-(s?.top??0)},r),{x:c,y:u}=n?cD(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const u1e=e=>({width:e.offsetWidth,height:e.offsetHeight}),Jxt=e=>e?.getRootNode?.()||window?.document,zqn=["INPUT","SELECT","TEXTAREA"];function e0t(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:zqn.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const t0t=e=>"clientX"in e,ug=(e,t)=>{const n=t0t(e),r=n?e.clientX:e.touches?.[0].clientX,s=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:s-(t?.top??0)}},I8e=(e,t,n,r,s)=>{const a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(i=>{const l=i.getBoundingClientRect();return{id:i.getAttribute("data-handleid"),type:e,nodeId:s,position:i.getAttribute("data-handlepos"),x:(l.left-n.left)/r,y:(l.top-n.top)/r,...u1e(i)}})};function n0t({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:a,targetControlX:i,targetControlY:l}){const c=e*.125+s*.375+i*.375+n*.125,u=t*.125+a*.375+l*.375+r*.125,d=Math.abs(c-e),f=Math.abs(u-t);return[c,u,d,f]}function b6(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function A8e({pos:e,x1:t,y1:n,x2:r,y2:s,c:a}){switch(e){case nr.Left:return[t-b6(t-r,a),n];case nr.Right:return[t+b6(r-t,a),n];case nr.Top:return[t,n-b6(n-s,a)];case nr.Bottom:return[t,n+b6(s-n,a)]}}function d1e({sourceX:e,sourceY:t,sourcePosition:n=nr.Bottom,targetX:r,targetY:s,targetPosition:a=nr.Top,curvature:i=.25}){const[l,c]=A8e({pos:n,x1:e,y1:t,x2:r,y2:s,c:i}),[u,d]=A8e({pos:a,x1:r,y1:s,x2:e,y2:t,c:i}),[f,p,h,m]=n0t({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${e},${t} C${l},${c} ${u},${d} ${r},${s}`,f,p,h,m]}function r0t({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,a=n<e?n+s:n-s,i=Math.abs(r-t)/2,l=r<t?r+i:r-i;return[a,l,s,i]}function Bqn({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:s=!1,zIndexMode:a="basic"}){if(a==="manual")return r;const i=s&&n?r+1e3:r,l=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return i+l}function Uqn({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const a=xV(S7(e),S7(t));a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1);const i={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:r/s[2]};return eM(i,wV(a))>0}const qqn=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,Vqn=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Hqn=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||qqn;let s;return Wxt(e)?s={...e}:s={...e,id:r(e)},Vqn(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function s0t({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,a,i,l]=r0t({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,a,i,l]}const R8e={[nr.Left]:{x:-1,y:0},[nr.Right]:{x:1,y:0},[nr.Top]:{x:0,y:-1},[nr.Bottom]:{x:0,y:1}},Wqn=({source:e,sourcePosition:t=nr.Bottom,target:n})=>t===nr.Left||t===nr.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},P8e=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Zqn({source:e,sourcePosition:t=nr.Bottom,target:n,targetPosition:r=nr.Top,center:s,offset:a,stepPosition:i}){const l=R8e[t],c=R8e[r],u={x:e.x+l.x*a,y:e.y+l.y*a},d={x:n.x+c.x*a,y:n.y+c.y*a},f=Wqn({source:u,sourcePosition:t,target:d}),p=f.x!==0?"x":"y",h=f[p];let m=[],g,y;const b={x:0,y:0},w={x:0,y:0},[,,S,k]=r0t({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){p==="x"?(g=s.x??u.x+(d.x-u.x)*i,y=s.y??(u.y+d.y)/2):(g=s.x??(u.x+d.x)/2,y=s.y??u.y+(d.y-u.y)*i);const j=[{x:g,y:u.y},{x:g,y:d.y}],N=[{x:u.x,y},{x:d.x,y}];l[p]===h?m=p==="x"?j:N:m=p==="x"?N:j}else{const j=[{x:u.x,y:d.y}],N=[{x:d.x,y:u.y}];if(p==="x"?m=l.x===h?N:j:m=l.y===h?j:N,t===r){const D=Math.abs(e[p]-n[p]);if(D<=a){const V=Math.min(a-1,a-D);l[p]===h?b[p]=(u[p]>e[p]?-1:1)*V:w[p]=(d[p]>n[p]?-1:1)*V}}if(t!==r){const D=p==="x"?"y":"x",V=l[p]===c[D],W=u[D]>d[D],L=u[D]<d[D];(l[p]===1&&(!V&&W||V&&L)||l[p]!==1&&(!V&&L||V&&W))&&(m=p==="x"?j:N)}const I={x:u.x+b.x,y:u.y+b.y},R={x:d.x+w.x,y:d.y+w.y},$=Math.max(Math.abs(I.x-m[0].x),Math.abs(R.x-m[0].x)),F=Math.max(Math.abs(I.y-m[0].y),Math.abs(R.y-m[0].y));$>=F?(g=(I.x+R.x)/2,y=m[0].y):(g=m[0].x,y=(I.y+R.y)/2)}const _={x:u.x+b.x,y:u.y+b.y},C={x:d.x+w.x,y:d.y+w.y};return[[e,..._.x!==m[0].x||_.y!==m[0].y?[_]:[],...m,...C.x!==m[m.length-1].x||C.y!==m[m.length-1].y?[C]:[],n],g,y,S,k]}function Gqn(e,t,n,r){const s=Math.min(P8e(e,t)/2,P8e(t,n)/2,r),{x:a,y:i}=t;if(e.x===a&&a===n.x||e.y===i&&i===n.y)return`L${a} ${i}`;if(e.y===i){const u=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${a+s*u},${i}Q ${a},${i} ${a},${i+s*d}`}const l=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${a},${i+s*c}Q ${a},${i} ${a+s*l},${i}`}function ghe({sourceX:e,sourceY:t,sourcePosition:n=nr.Bottom,targetX:r,targetY:s,targetPosition:a=nr.Top,borderRadius:i=5,centerX:l,centerY:c,offset:u=20,stepPosition:d=.5}){const[f,p,h,m,g]=Zqn({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:a,center:{x:l,y:c},offset:u,stepPosition:d});let y=`M${f[0].x} ${f[0].y}`;for(let b=1;b<f.length-1;b++)y+=Gqn(f[b-1],f[b],f[b+1],i);return y+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[y,p,h,m,g]}function $8e(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Qqn(e){const{sourceNode:t,targetNode:n}=e;if(!$8e(t)||!$8e(n))return null;const r=t.internals.handleBounds||M8e(t.handles),s=n.internals.handleBounds||M8e(n.handles),a=D8e(r?.source??[],e.sourceHandle),i=D8e(e.connectionMode===gT.Strict?s?.target??[]:(s?.target??[]).concat(s?.source??[]),e.targetHandle);if(!a||!i)return e.onError?.("008",py.error008(a?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=a?.position||nr.Bottom,c=i?.position||nr.Top,u=IO(t,a,l),d=IO(n,i,c);return{sourceX:u.x,sourceY:u.y,targetX:d.x,targetY:d.y,sourcePosition:l,targetPosition:c}}function M8e(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function IO(e,t,n=nr.Left,r=!1){const s=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:i,height:l}=t??Hx(e);if(r)return{x:s+i/2,y:a+l/2};switch(t?.position??n){case nr.Top:return{x:s+i/2,y:a};case nr.Right:return{x:s+i,y:a+l/2};case nr.Bottom:return{x:s+i/2,y:a+l};case nr.Left:return{x:s,y:a+l/2}}}function D8e(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function vhe(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function Yqn(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:s}){const a=new Set;return e.reduce((i,l)=>([l.markerStart||r,l.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const u=vhe(c,t);a.has(u)||(i.push({id:u,color:c.color||n,...c}),a.add(u))}}),i),[]).sort((i,l)=>i.id.localeCompare(l.id))}const a0t=1e3,Xqn=10,f1e={nodeOrigin:[0,0],nodeExtent:X$,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Kqn={...f1e,checkEquality:!0};function p1e(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function Jqn(e,t,n){const r=p1e(f1e,n);for(const s of e.values())if(s.parentId)m1e(s,e,t,r);else{const a=oD(s,r.nodeOrigin),i=bT(s.extent)?s.extent:r.nodeExtent,l=NO(a,i,Hx(s));s.internals.positionAbsolute=l}}function eVn(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],r=[];for(const s of e.handles){const a={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(a):s.type==="target"&&r.push(a)}return{source:n,target:r}}function h1e(e){return e==="manual"}function yhe(e,t,n,r={}){const s=p1e(Kqn,r),a={i:0},i=new Map(t),l=s?.elevateNodesOnSelect&&!h1e(s.zIndexMode)?a0t:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const d of e){let f=i.get(d.id);if(s.checkEquality&&d===f?.internals.userNode)t.set(d.id,f);else{const p=oD(d,s.nodeOrigin),h=bT(d.extent)?d.extent:s.nodeExtent,m=NO(p,h,Hx(d));f={...s.defaults,...d,measured:{width:d.measured?.width,height:d.measured?.height},internals:{positionAbsolute:m,handleBounds:eVn(d,f),z:i0t(d,l,s.zIndexMode),userNode:d}},t.set(d.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(c=!1),d.parentId&&m1e(f,t,n,r,a),u||=d.selected??!1}return{nodesInitialized:c,hasSelectedNodes:u}}function tVn(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function m1e(e,t,n,r,s){const{elevateNodesOnSelect:a,nodeOrigin:i,nodeExtent:l,zIndexMode:c}=p1e(f1e,r),u=e.parentId,d=t.get(u);if(!d){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}tVn(e,n),s&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++s.i,d.internals.z=d.internals.z+s.i*Xqn),s&&d.internals.rootParentIndex!==void 0&&(s.i=d.internals.rootParentIndex);const f=a&&!h1e(c)?a0t:0,{x:p,y:h,z:m}=nVn(e,d,i,l,f,c),{positionAbsolute:g}=e.internals,y=p!==g.x||h!==g.y;(y||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:p,y:h}:g,z:m}})}function i0t(e,t,n){const r=cg(e.zIndex)?e.zIndex:0;return h1e(n)?r:r+(e.selected?t:0)}function nVn(e,t,n,r,s,a){const{x:i,y:l}=t.internals.positionAbsolute,c=Hx(e),u=oD(e,n),d=bT(e.extent)?NO(u,e.extent,c):u;let f=NO({x:i+d.x,y:l+d.y},r,c);e.extent==="parent"&&(f=Gxt(f,c,t));const p=i0t(e,s,a),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=p?h+1:p}}function g1e(e,t,n,r=[0,0]){const s=[],a=new Map;for(const i of e){const l=t.get(i.parentId);if(!l)continue;const c=a.get(i.parentId)?.expandedRect??yT(l),u=Yxt(c,i.rect);a.set(i.parentId,{expandedRect:u,parent:l})}return a.size>0&&a.forEach(({expandedRect:i,parent:l},c)=>{const u=l.internals.positionAbsolute,d=Hx(l),f=l.origin??r,p=i.x<u.x?Math.round(Math.abs(u.x-i.x)):0,h=i.y<u.y?Math.round(Math.abs(u.y-i.y)):0,m=Math.max(d.width,Math.round(i.width)),g=Math.max(d.height,Math.round(i.height)),y=(m-d.width)*f[0],b=(g-d.height)*f[1];(p>0||h>0||y||b)&&(s.push({id:c,type:"position",position:{x:l.position.x-p+y,y:l.position.y-h+b}}),n.get(c)?.forEach(w=>{e.some(S=>S.id===w.id)||s.push({id:w.id,type:"position",position:{x:w.position.x+p,y:w.position.y+h}})})),(d.width<i.width||d.height<i.height||p||h)&&s.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:m+(p?f[0]*p-y:0),height:g+(h?f[1]*h-b:0)}})}),s}function rVn(e,t,n,r,s,a,i){const l=r?.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const u=[],d=window.getComputedStyle(l),{m22:f}=new window.DOMMatrixReadOnly(d.transform),p=[];for(const h of e.values()){const m=t.get(h.id);if(!m)continue;if(m.hidden){t.set(m.id,{...m,internals:{...m.internals,handleBounds:void 0}}),c=!0;continue}const g=u1e(h.nodeElement),y=m.measured.width!==g.width||m.measured.height!==g.height;if(!!(g.width&&g.height&&(y||!m.internals.handleBounds||h.force))){const w=h.nodeElement.getBoundingClientRect(),S=bT(m.extent)?m.extent:a;let{positionAbsolute:k}=m.internals;m.parentId&&m.extent==="parent"?k=Gxt(k,g,t.get(m.parentId)):S&&(k=NO(k,S,g));const _={...m,measured:g,internals:{...m.internals,positionAbsolute:k,handleBounds:{source:I8e("source",h.nodeElement,w,f,m.id),target:I8e("target",h.nodeElement,w,f,m.id)}}};t.set(m.id,_),m.parentId&&m1e(_,t,n,{nodeOrigin:s,zIndexMode:i}),c=!0,y&&(u.push({id:m.id,type:"dimensions",dimensions:g}),m.expandParent&&m.parentId&&p.push({id:m.id,parentId:m.parentId,rect:yT(_,s)}))}}if(p.length>0){const h=g1e(p,t,n,s);u.push(...h)}return{changes:u,updatedInternals:c}}async function sVn({delta:e,panZoom:t,transform:n,translateExtent:r,width:s,height:a}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const i=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,a]],r),l=!!i&&(i.x!==n[0]||i.y!==n[1]||i.k!==n[2]);return Promise.resolve(l)}function L8e(e,t,n,r,s,a){let i=s;const l=r.get(i)||new Map;r.set(i,l.set(n,t)),i=`${s}-${e}`;const c=r.get(i)||new Map;if(r.set(i,c.set(n,t)),a){i=`${s}-${e}-${a}`;const u=r.get(i)||new Map;r.set(i,u.set(n,t))}}function o0t(e,t,n){e.clear(),t.clear();for(const r of n){const{source:s,target:a,sourceHandle:i=null,targetHandle:l=null}=r,c={edgeId:r.id,source:s,target:a,sourceHandle:i,targetHandle:l},u=`${s}-${i}--${a}-${l}`,d=`${a}-${l}--${s}-${i}`;L8e("source",c,d,e,s,i),L8e("target",c,u,e,a,l),t.set(r.id,r)}}function l0t(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:l0t(n,t):!1}function F8e(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function aVn(e,t,n,r){const s=new Map;for(const[a,i]of e)if((i.selected||i.id===r)&&(!i.parentId||!l0t(i,e))&&(i.draggable||t&&typeof i.draggable>"u")){const l=e.get(a);l&&s.set(a,{id:a,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return s}function AJ({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){const s=[];for(const[i,l]of t){const c=n.get(i)?.internals.userNode;c&&s.push({...c,position:l.position,dragging:r})}if(!e)return[s[0],s];const a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:s[0],s]}function iVn({dragItems:e,snapGrid:t,x:n,y:r}){const s=e.values().next().value;if(!s)return null;const a={x:n-s.distance.x,y:r-s.distance.y},i=cD(a,t);return{x:i.x-a.x,y:i.y-a.y}}function oVn({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let a={x:null,y:null},i=0,l=new Map,c=!1,u={x:0,y:0},d=null,f=!1,p=null,h=!1,m=!1,g=null;function y({noDragClassName:w,handleSelector:S,domNode:k,isSelectable:_,nodeId:C,nodeClickDistance:E=0}){p=fp(k);function j({x:$,y:F}){const{nodeLookup:D,nodeExtent:V,snapGrid:W,snapToGrid:L,nodeOrigin:z,onNodeDrag:B,onSelectionDrag:M,onError:G,updateNodePositions:U}=t();a={x:$,y:F};let P=!1;const q=l.size>1,Z=q&&V?mhe(lD(l)):null,X=q&&L?iVn({dragItems:l,snapGrid:W,x:$,y:F}):null;for(const[te,J]of l){if(!D.has(te))continue;let ee={x:$-J.distance.x,y:F-J.distance.y};L&&(ee=X?{x:Math.round(ee.x+X.x),y:Math.round(ee.y+X.y)}:cD(ee,W));let ae=null;if(q&&V&&!J.extent&&Z){const{positionAbsolute:ne}=J.internals,ce=ne.x-Z.x+V[0][0],pe=ne.x+J.measured.width-Z.x2+V[1][0],le=ne.y-Z.y+V[0][1],ve=ne.y+J.measured.height-Z.y2+V[1][1];ae=[[ce,le],[pe,ve]]}const{position:de,positionAbsolute:Y}=Zxt({nodeId:te,nextPosition:ee,nodeLookup:D,nodeExtent:ae||V,nodeOrigin:z,onError:G});P=P||J.position.x!==de.x||J.position.y!==de.y,J.position=de,J.internals.positionAbsolute=Y}if(m=m||P,!!P&&(U(l,!0),g&&(r||B||!C&&M))){const[te,J]=AJ({nodeId:C,dragItems:l,nodeLookup:D});r?.(g,l,te,J),B?.(g,te,J),C||M?.(g,J)}}async function N(){if(!d)return;const{transform:$,panBy:F,autoPanSpeed:D,autoPanOnNodeDrag:V}=t();if(!V){c=!1,cancelAnimationFrame(i);return}const[W,L]=Qxt(u,d,D);(W!==0||L!==0)&&(a.x=(a.x??0)-W/$[2],a.y=(a.y??0)-L/$[2],await F({x:W,y:L})&&j(a)),i=requestAnimationFrame(N)}function I($){const{nodeLookup:F,multiSelectionActive:D,nodesDraggable:V,transform:W,snapGrid:L,snapToGrid:z,selectNodesOnDrag:B,onNodeDragStart:M,onSelectionDragStart:G,unselectNodesAndEdges:U}=t();f=!0,(!B||!_)&&!D&&C&&(F.get(C)?.selected||U()),_&&B&&C&&e?.(C);const P=D2($.sourceEvent,{transform:W,snapGrid:L,snapToGrid:z,containerBounds:d});if(a=P,l=aVn(F,V,P,C),l.size>0&&(n||M||!C&&G)){const[q,Z]=AJ({nodeId:C,dragItems:l,nodeLookup:F});n?.($.sourceEvent,l,q,Z),M?.($.sourceEvent,q,Z),C||G?.($.sourceEvent,Z)}}const R=Cxt().clickDistance(E).on("start",$=>{const{domNode:F,nodeDragThreshold:D,transform:V,snapGrid:W,snapToGrid:L}=t();d=F?.getBoundingClientRect()||null,h=!1,m=!1,g=$.sourceEvent,D===0&&I($),a=D2($.sourceEvent,{transform:V,snapGrid:W,snapToGrid:L,containerBounds:d}),u=ug($.sourceEvent,d)}).on("drag",$=>{const{autoPanOnNodeDrag:F,transform:D,snapGrid:V,snapToGrid:W,nodeDragThreshold:L,nodeLookup:z}=t(),B=D2($.sourceEvent,{transform:D,snapGrid:V,snapToGrid:W,containerBounds:d});if(g=$.sourceEvent,($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||C&&!z.has(C))&&(h=!0),!h){if(!c&&F&&f&&(c=!0,N()),!f){const M=ug($.sourceEvent,d),G=M.x-u.x,U=M.y-u.y;Math.sqrt(G*G+U*U)>L&&I($)}(a.x!==B.xSnapped||a.y!==B.ySnapped)&&l&&f&&(u=ug($.sourceEvent,d),j(B))}}).on("end",$=>{if(!(!f||h)&&(c=!1,f=!1,cancelAnimationFrame(i),l.size>0)){const{nodeLookup:F,updateNodePositions:D,onNodeDragStop:V,onSelectionDragStop:W}=t();if(m&&(D(l,!1),m=!1),s||V||!C&&W){const[L,z]=AJ({nodeId:C,dragItems:l,nodeLookup:F,dragging:!1});s?.($.sourceEvent,l,L,z),V?.($.sourceEvent,L,z),C||W?.($.sourceEvent,z)}}}).filter($=>{const F=$.target;return!$.button&&(!w||!F8e(F,`.${w}`,k))&&(!S||F8e(F,S,k))});p.call(R)}function b(){p?.on(".drag",null)}return{update:y,destroy:b}}function lVn(e,t,n){const r=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const a of t.values())eM(s,yT(a))>0&&r.push(a);return r}const cVn=250;function uVn(e,t,n,r){let s=[],a=1/0;const i=lVn(e,n,t+cVn);for(const l of i){const c=[...l.internals.handleBounds?.source??[],...l.internals.handleBounds?.target??[]];for(const u of c){if(r.nodeId===u.nodeId&&r.type===u.type&&r.id===u.id)continue;const{x:d,y:f}=IO(l,u,u.position,!0),p=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(f-e.y,2));p>t||(p<a?(s=[{...u,x:d,y:f}],a=p):p===a&&s.push({...u,x:d,y:f}))}}if(!s.length)return null;if(s.length>1){const l=r.type==="source"?"target":"source";return s.find(c=>c.type===l)??s[0]}return s[0]}function c0t(e,t,n,r,s,a=!1){const i=r.get(e);if(!i)return null;const l=s==="strict"?i.internals.handleBounds?.[t]:[...i.internals.handleBounds?.source??[],...i.internals.handleBounds?.target??[]],c=(n?l?.find(u=>u.id===n):l?.[0])??null;return c&&a?{...c,...IO(i,c,c.position,!0)}:c}function u0t(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function dVn(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const d0t=()=>!0;function fVn(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:a,isTarget:i,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:f,panBy:p,cancelConnection:h,onConnectStart:m,onConnect:g,onConnectEnd:y,isValidConnection:b=d0t,onReconnectEnd:w,updateConnection:S,getTransform:k,getFromHandle:_,autoPanSpeed:C,dragThreshold:E=1,handleDomNode:j}){const N=Jxt(e.target);let I=0,R;const{x:$,y:F}=ug(e),D=u0t(a,j),V=l?.getBoundingClientRect();let W=!1;if(!V||!D)return;const L=c0t(s,D,r,c,t);if(!L)return;let z=ug(e,V),B=!1,M=null,G=!1,U=null;function P(){if(!d||!V)return;const[de,Y]=Qxt(z,V,C);p({x:de,y:Y}),I=requestAnimationFrame(P)}const q={...L,nodeId:s,type:D,position:L.position},Z=c.get(s);let te={inProgress:!0,isValid:null,from:IO(Z,q,nr.Left,!0),fromHandle:q,fromPosition:q.position,fromNode:Z,to:z,toHandle:null,toPosition:E8e[q.position],toNode:null,pointer:z};function J(){W=!0,S(te),m?.(e,{nodeId:s,handleId:r,handleType:D})}E===0&&J();function ee(de){if(!W){const{x:ve,y:ye}=ug(de),Se=ve-$,Ne=ye-F;if(!(Se*Se+Ne*Ne>E*E))return;J()}if(!_()||!q){ae(de);return}const Y=k();z=ug(de,V),R=uVn(uD(z,Y,!1,[1,1]),n,c,q),B||(P(),B=!0);const ne=f0t(de,{handle:R,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:i?"target":"source",isValidConnection:b,doc:N,lib:u,flowId:f,nodeLookup:c});U=ne.handleDomNode,M=ne.connection,G=dVn(!!R,ne.isValid);const ce=c.get(s),pe=ce?IO(ce,q,nr.Left,!0):te.from,le={...te,from:pe,isValid:G,to:ne.toHandle&&G?k7({x:ne.toHandle.x,y:ne.toHandle.y},Y):z,toHandle:ne.toHandle,toPosition:G&&ne.toHandle?ne.toHandle.position:E8e[q.position],toNode:ne.toHandle?c.get(ne.toHandle.nodeId):null,pointer:z};S(le),te=le}function ae(de){if(!("touches"in de&&de.touches.length>0)){if(W){(R||U)&&M&&G&&g?.(M);const{inProgress:Y,...ne}=te,ce={...ne,toPosition:te.toHandle?te.toPosition:null};y?.(de,ce),a&&w?.(de,ce)}h(),cancelAnimationFrame(I),B=!1,G=!1,M=null,U=null,N.removeEventListener("mousemove",ee),N.removeEventListener("mouseup",ae),N.removeEventListener("touchmove",ee),N.removeEventListener("touchend",ae)}}N.addEventListener("mousemove",ee),N.addEventListener("mouseup",ae),N.addEventListener("touchmove",ee),N.addEventListener("touchend",ae)}function f0t(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:a,doc:i,lib:l,flowId:c,isValidConnection:u=d0t,nodeLookup:d}){const f=a==="target",p=t?i.querySelector(`.${l}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:m}=ug(e),g=i.elementFromPoint(h,m),y=g?.classList.contains(`${l}-flow__handle`)?g:p,b={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const w=u0t(void 0,y),S=y.getAttribute("data-nodeid"),k=y.getAttribute("data-handleid"),_=y.classList.contains("connectable"),C=y.classList.contains("connectableend");if(!S||!w)return b;const E={source:f?S:r,sourceHandle:f?k:s,target:f?r:S,targetHandle:f?s:k};b.connection=E;const N=_&&C&&(n===gT.Strict?f&&w==="source"||!f&&w==="target":S!==r||k!==s);b.isValid=N&&u(E),b.toHandle=c0t(S,w,k,d,n,!0)}return b}const bhe={onPointerDown:fVn,isValid:f0t};function pVn({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=fp(e);function a({translateExtent:l,width:c,height:u,zoomStep:d=1,pannable:f=!0,zoomable:p=!0,inversePan:h=!1}){const m=S=>{if(S.sourceEvent.type!=="wheel"||!t)return;const k=n(),_=S.sourceEvent.ctrlKey&&tM()?10:1,C=-S.sourceEvent.deltaY*(S.sourceEvent.deltaMode===1?.05:S.sourceEvent.deltaMode?1:.002)*d,E=k[2]*Math.pow(2,C*_);t.scaleTo(E)};let g=[0,0];const y=S=>{(S.sourceEvent.type==="mousedown"||S.sourceEvent.type==="touchstart")&&(g=[S.sourceEvent.clientX??S.sourceEvent.touches[0].clientX,S.sourceEvent.clientY??S.sourceEvent.touches[0].clientY])},b=S=>{const k=n();if(S.sourceEvent.type!=="mousemove"&&S.sourceEvent.type!=="touchmove"||!t)return;const _=[S.sourceEvent.clientX??S.sourceEvent.touches[0].clientX,S.sourceEvent.clientY??S.sourceEvent.touches[0].clientY],C=[_[0]-g[0],_[1]-g[1]];g=_;const E=r()*Math.max(k[2],Math.log(k[2]))*(h?-1:1),j={x:k[0]-C[0]*E,y:k[1]-C[1]*E},N=[[0,0],[c,u]];t.setViewportConstrained({x:j.x,y:j.y,zoom:k[2]},N,l)},w=Bxt().on("start",y).on("zoom",f?b:null).on("zoom.wheel",p?m:null);s.call(w,{})}function i(){s.on("zoom",null)}return{update:a,destroy:i,pointer:Xm}}const SV=e=>({x:e.x,y:e.y,zoom:e.k}),RJ=({x:e,y:t,zoom:n})=>bV.translate(e,t).scale(n),zE=(e,t)=>e.target.closest(`.${t}`),p0t=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),hVn=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,PJ=(e,t=0,n=hVn,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},h0t=e=>{const t=e.ctrlKey&&tM()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function mVn({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:a,zoomOnPinch:i,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(zE(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(d.ctrlKey&&i){const y=Xm(d),b=h0t(d),w=f*Math.pow(2,b);r.scaleTo(n,w,y,d);return}const p=d.deltaMode===1?20:1;let h=s===Bk.Vertical?0:d.deltaX*p,m=s===Bk.Horizontal?0:d.deltaY*p;!tM()&&d.shiftKey&&s!==Bk.Vertical&&(h=d.deltaY*p,m=0),r.translateBy(n,-(h/f)*a,-(m/f)*a,{internal:!0});const g=SV(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(d,g),e.panScrollTimeout=setTimeout(()=>{u?.(d,g),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l?.(d,g))}}function gVn({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const a=r.type==="wheel",i=!t&&a&&!r.ctrlKey,l=zE(r,e);if(r.ctrlKey&&a&&l&&r.preventDefault(),i||l)return null;r.preventDefault(),n.call(this,r,s)}}function vVn({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;const s=SV(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=s,r.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(r.sourceEvent,s)}}function yVn({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return a=>{e.usedRightMouseButton=!!(n&&p0t(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),s&&!a.sourceEvent?.internal&&s?.(a.sourceEvent,SV(a.transform))}}function bVn({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:a}){return i=>{if(!i.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&p0t(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&a(i.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const l=SV(i.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s?.(i.sourceEvent,l)},n?150:0)}}}function xVn({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:a,userSelectionActive:i,noWheelClassName:l,noPanClassName:c,lib:u,connectionInProgress:d}){return f=>{const p=e||t,h=n&&f.ctrlKey,m=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(zE(f,`${u}-flow__node`)||zE(f,`${u}-flow__edge`)))return!0;if(!r&&!p&&!s&&!a&&!n||i||d&&!m||zE(f,l)&&m||zE(f,c)&&(!m||s&&m&&!e)||!n&&f.ctrlKey&&m)return!1;if(!n&&f.type==="touchstart"&&f.touches?.length>1)return f.preventDefault(),!1;if(!p&&!s&&!h&&m||!r&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(r)&&!r.includes(f.button)&&f.type==="mousedown")return!1;const g=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||m)&&g}}function wVn({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:s,onPanZoom:a,onPanZoomStart:i,onPanZoomEnd:l,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),f=Bxt().scaleExtent([t,n]).translateExtent(r),p=fp(e).call(f);w({x:s.x,y:s.y,zoom:vT(s.zoom,t,n)},[[0,0],[d.width,d.height]],r);const h=p.on("wheel.zoom"),m=p.on("dblclick.zoom");f.wheelDelta(h0t);function g(R,$){return p?new Promise(F=>{f?.interpolate($?.interpolate==="linear"?rx:L9).transform(PJ(p,$?.duration,$?.ease,()=>F(!0)),R)}):Promise.resolve(!1)}function y({noWheelClassName:R,noPanClassName:$,onPaneContextMenu:F,userSelectionActive:D,panOnScroll:V,panOnDrag:W,panOnScrollMode:L,panOnScrollSpeed:z,preventScrolling:B,zoomOnPinch:M,zoomOnScroll:G,zoomOnDoubleClick:U,zoomActivationKeyPressed:P,lib:q,onTransformChange:Z,connectionInProgress:X,paneClickDistance:te,selectionOnDrag:J}){D&&!u.isZoomingOrPanning&&b();const ee=V&&!P&&!D;f.clickDistance(J?1/0:!cg(te)||te<0?0:te);const ae=ee?mVn({zoomPanValues:u,noWheelClassName:R,d3Selection:p,d3Zoom:f,panOnScrollMode:L,panOnScrollSpeed:z,zoomOnPinch:M,onPanZoomStart:i,onPanZoom:a,onPanZoomEnd:l}):gVn({noWheelClassName:R,preventScrolling:B,d3ZoomHandler:h});if(p.on("wheel.zoom",ae,{passive:!1}),!D){const Y=vVn({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:i});f.on("start",Y);const ne=yVn({zoomPanValues:u,panOnDrag:W,onPaneContextMenu:!!F,onPanZoom:a,onTransformChange:Z});f.on("zoom",ne);const ce=bVn({zoomPanValues:u,panOnDrag:W,panOnScroll:V,onPaneContextMenu:F,onPanZoomEnd:l,onDraggingChange:c});f.on("end",ce)}const de=xVn({zoomActivationKeyPressed:P,panOnDrag:W,zoomOnScroll:G,panOnScroll:V,zoomOnDoubleClick:U,zoomOnPinch:M,userSelectionActive:D,noPanClassName:$,noWheelClassName:R,lib:q,connectionInProgress:X});f.filter(de),U?p.on("dblclick.zoom",m):p.on("dblclick.zoom",null)}function b(){f.on("zoom",null)}async function w(R,$,F){const D=RJ(R),V=f?.constrain()(D,$,F);return V&&await g(V),new Promise(W=>W(V))}async function S(R,$){const F=RJ(R);return await g(F,$),new Promise(D=>D(F))}function k(R){if(p){const $=RJ(R),F=p.property("__zoom");(F.k!==R.zoom||F.x!==R.x||F.y!==R.y)&&f?.transform(p,$,null,{sync:!0})}}function _(){const R=p?zxt(p.node()):{x:0,y:0,k:1};return{x:R.x,y:R.y,zoom:R.k}}function C(R,$){return p?new Promise(F=>{f?.interpolate($?.interpolate==="linear"?rx:L9).scaleTo(PJ(p,$?.duration,$?.ease,()=>F(!0)),R)}):Promise.resolve(!1)}function E(R,$){return p?new Promise(F=>{f?.interpolate($?.interpolate==="linear"?rx:L9).scaleBy(PJ(p,$?.duration,$?.ease,()=>F(!0)),R)}):Promise.resolve(!1)}function j(R){f?.scaleExtent(R)}function N(R){f?.translateExtent(R)}function I(R){const $=!cg(R)||R<0?0:R;f?.clickDistance($)}return{update:y,destroy:b,setViewport:S,setViewportConstrained:w,getViewport:_,scaleTo:C,scaleBy:E,setScaleExtent:j,setTranslateExtent:N,syncViewport:k,setClickDistance:I}}var xT;(function(e){e.Line="line",e.Handle="handle"})(xT||(xT={}));function SVn({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:s,affectsY:a}){const i=e-t,l=n-r,c=[i>0?1:i<0?-1:0,l>0?1:l<0?-1:0];return i&&s&&(c[0]=c[0]*-1),l&&a&&(c[1]=c[1]*-1),c}function z8e(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:s}}function D0(e,t){return Math.max(0,t-e)}function L0(e,t){return Math.max(0,e-t)}function x6(e,t,n){return Math.max(0,t-e,e-n)}function B8e(e,t){return e?!t:t}function kVn(e,t,n,r,s,a,i,l){let{affectsX:c,affectsY:u}=t;const{isHorizontal:d,isVertical:f}=t,p=d&&f,{xSnapped:h,ySnapped:m}=n,{minWidth:g,maxWidth:y,minHeight:b,maxHeight:w}=r,{x:S,y:k,width:_,height:C,aspectRatio:E}=e;let j=Math.floor(d?h-e.pointerX:0),N=Math.floor(f?m-e.pointerY:0);const I=_+(c?-j:j),R=C+(u?-N:N),$=-a[0]*_,F=-a[1]*C;let D=x6(I,g,y),V=x6(R,b,w);if(i){let z=0,B=0;c&&j<0?z=D0(S+j+$,i[0][0]):!c&&j>0&&(z=L0(S+I+$,i[1][0])),u&&N<0?B=D0(k+N+F,i[0][1]):!u&&N>0&&(B=L0(k+R+F,i[1][1])),D=Math.max(D,z),V=Math.max(V,B)}if(l){let z=0,B=0;c&&j>0?z=L0(S+j,l[0][0]):!c&&j<0&&(z=D0(S+I,l[1][0])),u&&N>0?B=L0(k+N,l[0][1]):!u&&N<0&&(B=D0(k+R,l[1][1])),D=Math.max(D,z),V=Math.max(V,B)}if(s){if(d){const z=x6(I/E,b,w)*E;if(D=Math.max(D,z),i){let B=0;!c&&!u||c&&!u&&p?B=L0(k+F+I/E,i[1][1])*E:B=D0(k+F+(c?j:-j)/E,i[0][1])*E,D=Math.max(D,B)}if(l){let B=0;!c&&!u||c&&!u&&p?B=D0(k+I/E,l[1][1])*E:B=L0(k+(c?j:-j)/E,l[0][1])*E,D=Math.max(D,B)}}if(f){const z=x6(R*E,g,y)/E;if(V=Math.max(V,z),i){let B=0;!c&&!u||u&&!c&&p?B=L0(S+R*E+$,i[1][0])/E:B=D0(S+(u?N:-N)*E+$,i[0][0])/E,V=Math.max(V,B)}if(l){let B=0;!c&&!u||u&&!c&&p?B=D0(S+R*E,l[1][0])/E:B=L0(S+(u?N:-N)*E,l[0][0])/E,V=Math.max(V,B)}}}N=N+(N<0?V:-V),j=j+(j<0?D:-D),s&&(p?I>R*E?N=(B8e(c,u)?-j:j)/E:j=(B8e(c,u)?-N:N)*E:d?(N=j/E,u=c):(j=N*E,c=u));const W=c?S+j:S,L=u?k+N:k;return{width:_+(c?-j:j),height:C+(u?-N:N),x:a[0]*j*(c?-1:1)+W,y:a[1]*N*(u?-1:1)+L}}const m0t={width:0,height:0,x:0,y:0},OVn={...m0t,pointerX:0,pointerY:0,aspectRatio:1};function _Vn(e){return[[0,0],[e.measured.width,e.measured.height]]}function CVn(e,t,n){const r=t.position.x+e.position.x,s=t.position.y+e.position.y,a=e.measured.width??0,i=e.measured.height??0,l=n[0]*a,c=n[1]*i;return[[r-l,s-c],[r+a-l,s+i-c]]}function EVn({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const a=fp(e);let i={controlDirection:z8e("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:u,boundaries:d,keepAspectRatio:f,resizeDirection:p,onResizeStart:h,onResize:m,onResizeEnd:g,shouldResize:y}){let b={...m0t},w={...OVn};i={boundaries:d,resizeDirection:p,keepAspectRatio:f,controlDirection:z8e(u)};let S,k=null,_=[],C,E,j,N=!1;const I=Cxt().on("start",R=>{const{nodeLookup:$,transform:F,snapGrid:D,snapToGrid:V,nodeOrigin:W,paneDomNode:L}=n();if(S=$.get(t),!S)return;k=L?.getBoundingClientRect()??null;const{xSnapped:z,ySnapped:B}=D2(R.sourceEvent,{transform:F,snapGrid:D,snapToGrid:V,containerBounds:k});b={width:S.measured.width??0,height:S.measured.height??0,x:S.position.x??0,y:S.position.y??0},w={...b,pointerX:z,pointerY:B,aspectRatio:b.width/b.height},C=void 0,S.parentId&&(S.extent==="parent"||S.expandParent)&&(C=$.get(S.parentId),E=C&&S.extent==="parent"?_Vn(C):void 0),_=[],j=void 0;for(const[M,G]of $)if(G.parentId===t&&(_.push({id:M,position:{...G.position},extent:G.extent}),G.extent==="parent"||G.expandParent)){const U=CVn(G,S,G.origin??W);j?j=[[Math.min(U[0][0],j[0][0]),Math.min(U[0][1],j[0][1])],[Math.max(U[1][0],j[1][0]),Math.max(U[1][1],j[1][1])]]:j=U}h?.(R,{...b})}).on("drag",R=>{const{transform:$,snapGrid:F,snapToGrid:D,nodeOrigin:V}=n(),W=D2(R.sourceEvent,{transform:$,snapGrid:F,snapToGrid:D,containerBounds:k}),L=[];if(!S)return;const{x:z,y:B,width:M,height:G}=b,U={},P=S.origin??V,{width:q,height:Z,x:X,y:te}=kVn(w,i.controlDirection,W,i.boundaries,i.keepAspectRatio,P,E,j),J=q!==M,ee=Z!==G,ae=X!==z&&J,de=te!==B&ⅇif(!ae&&!de&&!J&&!ee)return;if((ae||de||P[0]===1||P[1]===1)&&(U.x=ae?X:b.x,U.y=de?te:b.y,b.x=U.x,b.y=U.y,_.length>0)){const pe=X-z,le=te-B;for(const ve of _)ve.position={x:ve.position.x-pe+P[0]*(q-M),y:ve.position.y-le+P[1]*(Z-G)},L.push(ve)}if((J||ee)&&(U.width=J&&(!i.resizeDirection||i.resizeDirection==="horizontal")?q:b.width,U.height=ee&&(!i.resizeDirection||i.resizeDirection==="vertical")?Z:b.height,b.width=U.width,b.height=U.height),C&&S.expandParent){const pe=P[0]*(U.width??0);U.x&&U.x<pe&&(b.x=pe,w.x=w.x-(U.x-pe));const le=P[1]*(U.height??0);U.y&&U.y<le&&(b.y=le,w.y=w.y-(U.y-le))}const Y=SVn({width:b.width,prevWidth:M,height:b.height,prevHeight:G,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),ne={...b,direction:Y};y?.(R,ne)!==!1&&(N=!0,m?.(R,ne),r(U,L))}).on("end",R=>{N&&(g?.(R,{...b}),s?.({...b}),N=!1)});a.call(I)}function c(){a.on(".drag",null)}return{update:l,destroy:c}}const jVn={},U8e=e=>{let t;const n=new Set,r=(d,f)=>{const p=typeof d=="function"?d(t):d;if(!Object.is(p,t)){const h=t;t=f??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(m=>m(t,h))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(jVn?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(r,s,c);return c},TVn=e=>e?U8e(e):U8e,{useDebugValue:NVn}=Le,{useSyncExternalStoreWithSelector:IVn}=swn,AVn=e=>e;function g0t(e,t=AVn,n){const r=IVn(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return NVn(r),r}const q8e=(e,t)=>{const n=TVn(e),r=(s,a=t)=>g0t(n,s,a);return Object.assign(r,n),r},RVn=(e,t)=>e?q8e(e,t):q8e;function to(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,s]of e)if(!Object.is(s,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const kV=v.createContext(null),PVn=kV.Provider,v0t=py.error001();function Us(e,t){const n=v.useContext(kV);if(n===null)throw new Error(v0t);return g0t(n,e,t)}function wo(){const e=v.useContext(kV);if(e===null)throw new Error(v0t);return v.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const V8e={display:"none"},$Vn={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},y0t="react-flow__node-desc",b0t="react-flow__edge-desc",MVn="react-flow__aria-live",DVn=e=>e.ariaLiveMessage,LVn=e=>e.ariaLabelConfig;function FVn({rfId:e}){const t=Us(DVn);return o.jsx("div",{id:`${MVn}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:$Vn,children:t})}function zVn({rfId:e,disableKeyboardA11y:t}){const n=Us(LVn);return o.jsxs(o.Fragment,{children:[o.jsx("div",{id:`${y0t}-${e}`,style:V8e,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),o.jsx("div",{id:`${b0t}-${e}`,style:V8e,children:n["edge.a11yDescription.default"]}),!t&&o.jsx(FVn,{rfId:e})]})}const dD=v.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},a)=>{const i=`${e}`.split("-");return o.jsx("div",{className:Pl(["react-flow__panel",n,...i]),style:r,ref:a,...s,children:t})});dD.displayName="Panel";function BVn({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:o.jsx(dD,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:o.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const UVn=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},w6=e=>e.id;function qVn(e,t){return to(e.selectedNodes.map(w6),t.selectedNodes.map(w6))&&to(e.selectedEdges.map(w6),t.selectedEdges.map(w6))}function VVn({onSelectionChange:e}){const t=wo(),{selectedNodes:n,selectedEdges:r}=Us(UVn,qVn);return v.useEffect(()=>{const s={nodes:n,edges:r};e?.(s),t.getState().onSelectionChangeHandlers.forEach(a=>a(s))},[n,r,e]),null}const HVn=e=>!!e.onSelectionChangeHandlers;function WVn({onSelectionChange:e}){const t=Us(HVn);return e||t?o.jsx(VVn,{onSelectionChange:e}):null}const xhe=typeof window<"u"?v.useLayoutEffect:v.useEffect,x0t=[0,0],ZVn={x:0,y:0,zoom:1},GVn=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],H8e=[...GVn,"rfId"],QVn=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),W8e={translateExtent:X$,nodeOrigin:x0t,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function YVn(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:a,setNodeExtent:i,reset:l,setDefaultNodesAndEdges:c}=Us(QVn,to),u=wo();xhe(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=W8e,l()}),[]);const d=v.useRef(W8e);return xhe(()=>{for(const f of H8e){const p=e[f],h=d.current[f];p!==h&&(typeof e[f]>"u"||(f==="nodes"?t(p):f==="edges"?n(p):f==="minZoom"?r(p):f==="maxZoom"?s(p):f==="translateExtent"?a(p):f==="nodeExtent"?i(p):f==="ariaLabelConfig"?u.setState({ariaLabelConfig:Fqn(p)}):f==="fitView"?u.setState({fitViewQueued:p}):f==="fitViewOptions"?u.setState({fitViewOptions:p}):u.setState({[f]:p})))}d.current=e},H8e.map(f=>e[f])),null}function Z8e(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function XVn(e){const[t,n]=v.useState(e==="system"?null:e);return v.useEffect(()=>{if(e!=="system"){n(e);return}const r=Z8e(),s=()=>n(r?.matches?"dark":"light");return s(),r?.addEventListener("change",s),()=>{r?.removeEventListener("change",s)}},[e]),t!==null?t:Z8e()?.matches?"dark":"light"}const G8e=typeof document<"u"?document:null;function nM(e=null,t={target:G8e,actInsideInputWithModifier:!0}){const[n,r]=v.useState(!1),s=v.useRef(!1),a=v.useRef(new Set([])),[i,l]=v.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
|
|
336
|
+
`:r=="r"?"\r":r=="t"?" ":"\\")}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord&&this.test==t.test}create(){return this.regexp?new rFn(this):new eFn(this)}getCursor(t,n=0,r){let s=t.doc?t:os.create({doc:t});return r==null&&(r=s.doc.length),this.regexp?vE(this,s,n,r):gE(this,s,n,r)}}class Qbt{constructor(t){this.spec=t}}function K9n(e,t,n){return(r,s,a,i)=>{if(n&&!n(r,s,a,i))return!1;let l=r>=i&&s<=i+a.length?a.slice(r-i,s-i):t.doc.sliceString(r,s);return e(l,t,r,s)}}function gE(e,t,n,r){let s;return e.wholeWord&&(s=J9n(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(s=K9n(e.test,t,s)),new Sx(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:a=>a.toLowerCase(),s)}function J9n(e,t){return(n,r,s,a)=>((a>n||a+s.length<r)&&(a=Math.max(0,n-2),s=e.sliceString(a,Math.min(e.length,r+2))),(t(u7(s,n-a))!=fo.Word||t(d7(s,n-a))!=fo.Word)&&(t(d7(s,r-a))!=fo.Word||t(u7(s,r-a))!=fo.Word))}class eFn extends Qbt{constructor(t){super(t)}nextMatch(t,n,r){let s=gE(this.spec,t,r,t.doc.length).nextOverlapping();if(s.done){let a=Math.min(t.doc.length,n+this.spec.unquoted.length);s=gE(this.spec,t,0,a).nextOverlapping()}return s.done||s.value.from==n&&s.value.to==r?null:s.value}prevMatchInRange(t,n,r){for(let s=r;;){let a=Math.max(n,s-1e4-this.spec.unquoted.length),i=gE(this.spec,t,a,s),l=null;for(;!i.nextOverlapping().done;)l=i.value;if(l)return l;if(a==n)return null;s-=1e4}}prevMatch(t,n,r){let s=this.prevMatchInRange(t,0,n);return s||(s=this.prevMatchInRange(t,Math.max(0,r-this.spec.unquoted.length),t.doc.length)),s&&(s.from!=n||s.to!=r)?s:null}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,n){let r=gE(this.spec,t,0,t.doc.length),s=[];for(;!r.next().done;){if(s.length>=n)return null;s.push(r.value)}return s}highlight(t,n,r,s){let a=gE(this.spec,t,Math.max(0,n-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,t.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}function tFn(e,t,n){return(r,s,a)=>(!n||n(r,s,a))&&e(a[0],t,r,s)}function vE(e,t,n,r){let s;return e.wholeWord&&(s=nFn(t.charCategorizer(t.selection.main.head))),e.test&&(s=tFn(e.test,t,s)),new Wbt(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:s},n,r)}function u7(e,t){return e.slice(vc(e,t,!1),t)}function d7(e,t){return e.slice(t,vc(e,t))}function nFn(e){return(t,n,r)=>!r[0].length||(e(u7(r.input,r.index))!=fo.Word||e(d7(r.input,r.index))!=fo.Word)&&(e(d7(r.input,r.index+r[0].length))!=fo.Word||e(u7(r.input,r.index+r[0].length))!=fo.Word)}class rFn extends Qbt{nextMatch(t,n,r){let s=vE(this.spec,t,r,t.doc.length).next();return s.done&&(s=vE(this.spec,t,0,n).next()),s.done?null:s.value}prevMatchInRange(t,n,r){for(let s=1;;s++){let a=Math.max(n,r-s*1e4),i=vE(this.spec,t,a,r),l=null;for(;!i.next().done;)l=i.value;if(l&&(a==n||l.from>a+10))return l;if(a==n)return null}}prevMatch(t,n,r){return this.prevMatchInRange(t,0,n)||this.prevMatchInRange(t,r,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,r)=>{if(r=="&")return t.match[0];if(r=="$")return"$";for(let s=r.length;s>0;s--){let a=+r.slice(0,s);if(a>0&&a<t.match.length)return t.match[a]+r.slice(s)}return n})}matchAll(t,n){let r=vE(this.spec,t,0,t.doc.length),s=[];for(;!r.next().done;){if(s.length>=n)return null;s.push(r.value)}return s}highlight(t,n,r,s){let a=vE(this.spec,t,Math.max(0,n-250),Math.min(r+250,t.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}const V$=vr.define(),Gwe=vr.define(),Rw=ml.define({create(e){return new IK(ahe(e).create(),null)},update(e,t){for(let n of t.effects)n.is(V$)?e=new IK(n.value.create(),e.panel):n.is(Gwe)&&(e=new IK(e.query,n.value?Qwe:null));return e},provide:e=>P$.from(e,t=>t.panel)});class IK{constructor(t,n){this.query=t,this.panel=n}}const sFn=Cn.mark({class:"cm-searchMatch"}),aFn=Cn.mark({class:"cm-searchMatch cm-searchMatch-selected"}),iFn=yo.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(Rw))}update(e){let t=e.state.field(Rw);(t!=e.startState.field(Rw)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return Cn.none;let{view:n}=this,r=new xd;for(let s=0,a=n.visibleRanges,i=a.length;s<i;s++){let{from:l,to:c}=a[s];for(;s<i-1&&c>a[s+1].from-500;)c=a[++s].to;e.highlight(n.state,l,c,(u,d)=>{let f=n.state.selection.ranges.some(p=>p.from==u&&p.to==d);r.add(u,d,f?aFn:sFn)})}return r.finish()}},{decorations:e=>e.decorations});function sD(e){return t=>{let n=t.state.field(Rw,!1);return n&&n.query.spec.valid?e(t,n):Kbt(t)}}const f7=sD((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let s=vt.single(r.from,r.to),a=e.state.facet(DN);return e.dispatch({selection:s,effects:[Ywe(e,r),a.scrollToMatch(s.main,e)],userEvent:"select.search"}),Xbt(e),!0}),p7=sD((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,s=t.prevMatch(n,r,r);if(!s)return!1;let a=vt.single(s.from,s.to),i=e.state.facet(DN);return e.dispatch({selection:a,effects:[Ywe(e,s),i.scrollToMatch(a.main,e)],userEvent:"select.search"}),Xbt(e),!0}),oFn=sD((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:vt.create(n.map(r=>vt.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),lFn=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:s}=n.main,a=[],i=0;for(let l=new Sx(e.doc,e.sliceDoc(r,s));!l.next().done;){if(a.length>1e3)return!1;l.value.from==r&&(i=a.length),a.push(vt.range(l.value.from,l.value.to))}return t(e.update({selection:vt.create(a,i),userEvent:"select.search.matches"})),!0},n6e=sD((e,{query:t})=>{let{state:n}=e,{from:r,to:s}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let i=a,l=[],c,u,d=[];i.precise?i.from==r&&i.to==s&&(u=n.toText(t.getReplacement(i)),l.push({from:i.from,to:i.to,insert:u}),d.push(It.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."))):i=t.nextMatch(n,i.from,i.to);let f=e.state.changes(l);return i&&(c=vt.single(i.from,i.to).map(f),d.push(Ywe(e,i)),d.push(n.facet(DN).scrollToMatch(c.main,e))),e.dispatch({changes:f,selection:c,effects:d,userEvent:"input.replace"}),!0}),cFn=sD((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let s of t.matchAll(e.state,1e9)){let{from:a,to:i,precise:l}=s;l&&n.push({from:a,to:i,insert:t.getReplacement(s)})}if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:It.announce.of(r),userEvent:"input.replace.all"}),!0});function Qwe(e){return e.state.facet(DN).createPanel(e)}function ahe(e,t){var n,r,s,a,i;let l=e.selection.main,c=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!c)return t;let u=e.facet(DN);return new Gbt({search:((n=t?.literal)!==null&&n!==void 0?n:u.literal)?c:c.replace(/\n/g,"\\n"),caseSensitive:(r=t?.caseSensitive)!==null&&r!==void 0?r:u.caseSensitive,literal:(s=t?.literal)!==null&&s!==void 0?s:u.literal,regexp:(a=t?.regexp)!==null&&a!==void 0?a:u.regexp,wholeWord:(i=t?.wholeWord)!==null&&i!==void 0?i:u.wholeWord})}function Ybt(e){let t=dwe(e,Qwe);return t&&t.dom.querySelector("[main-field]")}function Xbt(e){let t=Ybt(e);t&&t==e.root.activeElement&&t.select()}const Kbt=e=>{let t=e.state.field(Rw,!1);if(t&&t.panel){let n=Ybt(e);if(n&&n!=e.root.activeElement){let r=ahe(e.state,t.query.spec);r.valid&&e.dispatch({effects:V$.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[Gwe.of(!0),t?V$.of(ahe(e.state,t.query.spec)):vr.appendConfig.of(pFn)]});return!0},Jbt=e=>{let t=e.state.field(Rw,!1);if(!t||!t.panel)return!1;let n=dwe(e,Qwe);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:Gwe.of(!1)}),!0},uFn=[{key:"Mod-f",run:Kbt,scope:"editor search-panel"},{key:"F3",run:f7,shift:p7,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:f7,shift:p7,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Jbt,scope:"editor search-panel"},{key:"Mod-Shift-l",run:lFn},{key:"Mod-Alt-g",run:z9n},{key:"Mod-d",run:X9n,preventDefault:!0}];class dFn{constructor(t){this.view=t;let n=this.query=t.state.field(Rw).query.spec;this.commit=this.commit.bind(this),this.searchField=ii("input",{value:n.search,placeholder:Hf(t,"Find"),"aria-label":Hf(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ii("input",{value:n.replace,placeholder:Hf(t,"Replace"),"aria-label":Hf(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=ii("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=ii("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=ii("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(s,a,i){return ii("button",{class:"cm-button",name:s,onclick:a,type:"button"},i)}this.dom=ii("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,r("next",()=>f7(t),[Hf(t,"next")]),r("prev",()=>p7(t),[Hf(t,"previous")]),r("select",()=>oFn(t),[Hf(t,"all")]),ii("label",null,[this.caseField,Hf(t,"match case")]),ii("label",null,[this.reField,Hf(t,"regexp")]),ii("label",null,[this.wordField,Hf(t,"by word")]),...t.state.readOnly?[]:[ii("br"),this.replaceField,r("replace",()=>n6e(t),[Hf(t,"replace")]),r("replaceAll",()=>cFn(t),[Hf(t,"replace all")])],ii("button",{name:"close",onclick:()=>Jbt(t),"aria-label":Hf(t,"close"),type:"button"},["×"])])}commit(){let t=new Gbt({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:V$.of(t)}))}keydown(t){I3n(this.view,t,"search-panel")?t.preventDefault():t.keyCode==13&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?p7:f7)(this.view)):t.keyCode==13&&t.target==this.replaceField&&(t.preventDefault(),n6e(this.view))}update(t){for(let n of t.transactions)for(let r of n.effects)r.is(V$)&&!r.value.eq(this.query)&&this.setQuery(r.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(DN).top}}function Hf(e,t){return e.state.phrase(t)}const d6=30,f6=/[\s\.,:;?!]/;function Ywe(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),s=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-d6),i=Math.min(s,n+d6),l=e.state.sliceDoc(a,i);if(a!=r.from){for(let c=0;c<d6;c++)if(!f6.test(l[c+1])&&f6.test(l[c])){l=l.slice(c);break}}if(i!=s){for(let c=l.length-1;c>l.length-d6;c--)if(!f6.test(l[c-1])&&f6.test(l[c])){l=l.slice(0,c);break}}return It.announce.of(`${e.state.phrase("current match")}. ${l} ${e.state.phrase("on line")} ${r.number}.`)}const fFn=It.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),pFn=[Rw,Pg.low(iFn),fFn];class r6e{constructor(t,n,r){this.from=t,this.to=n,this.diagnostic=r}}class ck{constructor(t,n,r){this.diagnostics=t,this.panel=n,this.selected=r}static init(t,n,r){let s=r.facet(H$).markerFilter;s&&(t=s(t,r));let a=t.slice().sort((d,f)=>d.from-f.from||d.to-f.to),i=new xd,l=[],c=0;for(let d=0;;){let f=d==a.length?null:a[d];if(!f&&!l.length)break;let p,h;for(l.length?(p=c,h=l.reduce((g,y)=>Math.min(g,y.to),f&&f.from>p?f.from:1e8)):(p=f.from,h=f.to,l.push(f),d++);d<a.length;){let g=a[d];if(g.from==p&&(g.to>g.from||g.to==p))l.push(g),d++,h=Math.min(g.to,h);else{h=Math.min(g.from,h);break}}let m=CFn(l);if(l.some(g=>g.from==g.to||g.from==g.to-1&&r.doc.lineAt(g.from).to==g.from))i.add(p,p,Cn.widget({widget:new SFn(m),diagnostics:l.slice()}));else{let g=l.reduce((y,b)=>b.markClass?y+" "+b.markClass:y,"");i.add(p,h,Cn.mark({class:"cm-lintRange cm-lintRange-"+m+g,diagnostics:l.slice(),inclusiveEnd:l.some(y=>y.to>h)}))}c=h;for(let g=0;g<l.length;g++)l[g].to<=c&&l.splice(g--,1)}let u=i.finish();return new ck(u,n,pT(u))}}function pT(e,t=null,n=0){let r=null;return e.between(n,1e9,(s,a,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new r6e(s,a,t||i.diagnostics[0]);else{if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new r6e(r.from,a,r.diagnostic)}}),r}function hFn(e,t){let n=t.pos,r=t.end||n,s=e.state.facet(H$).hideOn(e,n,r);if(s!=null)return s;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(i=>i.is(ext))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function mFn(e,t){return e.field(gp,!1)?t:t.concat(vr.appendConfig.of(EFn))}const ext=vr.define(),Xwe=vr.define(),txt=vr.define(),gp=ml.define({create(){return new ck(Cn.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,s=e.panel;if(e.selected){let a=t.changes.mapPos(e.selected.from,1);r=pT(n,e.selected.diagnostic,a)||pT(n,null,a)}!n.size&&s&&t.state.facet(H$).autoPanel&&(s=null),e=new ck(n,s,r)}for(let n of t.effects)if(n.is(ext)){let r=t.state.facet(H$).autoPanel?n.value.length?W$.open:null:e.panel;e=ck.init(n.value,r,t.state)}else n.is(Xwe)?e=new ck(e.diagnostics,n.value?W$.open:null,e.selected):n.is(txt)&&(e=new ck(e.diagnostics,e.panel,n.value));return e},provide:e=>[P$.from(e,t=>t.panel),It.decorations.from(e,t=>t.diagnostics)]}),gFn=Cn.mark({class:"cm-lintRange cm-lintRange-active"});function vFn(e,t,n){let{diagnostics:r}=e.state.field(gp),s,a=-1,i=-1;r.between(t-(n<0?1:0),t+(n>0?1:0),(c,u,{spec:d})=>{if(t>=c&&t<=u&&(c==u||(t>c||n>0)&&(t<u||n<0)))return s=d.diagnostics,a=c,i=u,!1});let l=e.state.facet(H$).tooltipFilter;return s&&l&&(s=l(s,e.state)),s?{pos:a,end:i,above:e.state.doc.lineAt(a).to<i,create(){return{dom:yFn(e,s)}}}:null}function yFn(e,t){return ii("ul",{class:"cm-tooltip-lint"},t.map(n=>rxt(e,n,!1)))}const bFn=e=>{let t=e.state.field(gp,!1);(!t||!t.panel)&&e.dispatch({effects:mFn(e.state,[Xwe.of(!0)])});let n=dwe(e,W$.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},s6e=e=>{let t=e.state.field(gp,!1);return!t||!t.panel?!1:(e.dispatch({effects:Xwe.of(!1)}),!0)},xFn=e=>{let t=e.state.field(gp,!1);if(!t)return!1;let n=e.state.selection.main,r=t.diagnostics.iter(n.to+1);return!r.value&&(r=t.diagnostics.iter(0),!r.value||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)},wFn=[{key:"Mod-Shift-m",run:bFn,preventDefault:!0},{key:"F8",run:xFn}],H$=On.define({combine(e){return{sources:e.map(t=>t.source).filter(t=>t!=null),...Ry(e.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:a6e,tooltipFilter:a6e,needsRefresh:(t,n)=>t?n?r=>t(r)||n(r):t:n,hideOn:(t,n)=>t?n?(r,s,a)=>t(r,s,a)||n(r,s,a):t:n,autoPanel:(t,n)=>t||n})}}});function a6e(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function nxt(e){let t=[];if(e)e:for(let{name:n}of e){for(let r=0;r<n.length;r++){let s=n[r];if(/[a-zA-Z]/.test(s)&&!t.some(a=>a.toLowerCase()==s.toLowerCase())){t.push(s);continue e}}t.push("")}return t}function rxt(e,t,n){var r;let s=n?nxt(t.actions):[];return ii("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},ii("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),(r=t.actions)===null||r===void 0?void 0:r.map((a,i)=>{let l=!1,c=h=>{if(h.preventDefault(),l)return;l=!0;let m=pT(e.state.field(gp).diagnostics,t);m&&a.apply(e,m.from,m.to)},{name:u}=a,d=s[i]?u.indexOf(s[i]):-1,f=d<0?u:[u.slice(0,d),ii("u",u.slice(d,d+1)),u.slice(d+1)],p=a.markClass?" "+a.markClass:"";return ii("button",{type:"button",class:"cm-diagnosticAction"+p,onclick:c,onmousedown:c,"aria-label":` Action: ${u}${d<0?"":` (access key "${s[i]})"`}.`},f)}),t.source&&ii("div",{class:"cm-diagnosticSource"},t.source))}class SFn extends Wp{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return ii("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class i6e{constructor(t,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=rxt(t,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class W${constructor(t){this.view=t,this.items=[];let n=s=>{if(s.keyCode==27)s6e(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:a}=this.items[this.selectedIndex],i=nxt(a.actions);for(let l=0;l<i.length;l++)if(i[l].toUpperCase().charCodeAt(0)==s.keyCode){let c=pT(this.view.state.field(gp).diagnostics,a);c&&a.actions[l].apply(t,c.from,c.to)}}else return;s.preventDefault()},r=s=>{for(let a=0;a<this.items.length;a++)this.items[a].dom.contains(s.target)&&this.moveSelection(a)};this.list=ii("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=ii("div",{class:"cm-panel-lint"},this.list,ii("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>s6e(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(gp).selected;if(!t)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==t.diagnostic)return n;return-1}update(){let{diagnostics:t,selected:n}=this.view.state.field(gp),r=0,s=!1,a=null,i=new Set;for(t.between(0,this.view.state.doc.length,(l,c,{spec:u})=>{for(let d of u.diagnostics){if(i.has(d))continue;i.add(d);let f=-1,p;for(let h=r;h<this.items.length;h++)if(this.items[h].diagnostic==d){f=h;break}f<0?(p=new i6e(this.view,d),this.items.splice(r,0,p),s=!0):(p=this.items[f],f>r&&(this.items.splice(r,f-r),s=!0)),n&&p.diagnostic==n.diagnostic?p.dom.hasAttribute("aria-selected")||(p.dom.setAttribute("aria-selected","true"),a=p):p.dom.hasAttribute("aria-selected")&&p.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new i6e(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),a?(this.list.setAttribute("aria-activedescendant",a.id),this.view.requestMeasure({key:this,read:()=>({sel:a.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:c})=>{let u=c.height/this.list.offsetHeight;l.top<c.top?this.list.scrollTop-=(c.top-l.top)/u:l.bottom>c.bottom&&(this.list.scrollTop+=(l.bottom-c.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let t=this.list.firstChild;function n(){let r=t;t=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;t!=r.dom;)n();t=r.dom.nextSibling}else this.list.insertBefore(r.dom,t);for(;t;)n()}moveSelection(t){if(this.selectedIndex<0)return;let n=this.view.state.field(gp),r=pT(n.diagnostics,this.items[t].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:txt.of(r)})}static open(t){return new W$(t)}}function kFn(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function p6(e){return kFn(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const OFn=It.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:p6("#d11")},".cm-lintRange-warning":{backgroundImage:p6("orange")},".cm-lintRange-info":{backgroundImage:p6("#999")},".cm-lintRange-hint":{backgroundImage:p6("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function _Fn(e){return e=="error"?4:e=="warning"?3:e=="info"?2:1}function CFn(e){let t="hint",n=1;for(let r of e){let s=_Fn(r.severity);s>n&&(n=s,t=r.severity)}return t}const EFn=[gp,It.decorations.compute([gp],e=>{let{selected:t,panel:n}=e.field(gp);return!t||!n||t.from==t.to?Cn.none:Cn.set([gFn.range(t.from,t.to)])}),bDn(vFn,{hideOn:hFn}),OFn];var o6e=function(t){t===void 0&&(t={});var n=t,r=n.crosshairCursor,s=r===void 0?!1:r,a=[];t.closeBracketsKeymap!==!1&&(a=a.concat(g5n)),t.defaultKeymap!==!1&&(a=a.concat(D9n)),t.searchKeymap!==!1&&(a=a.concat(uFn)),t.historyKeymap!==!1&&(a=a.concat(V8n)),t.foldKeymap!==!1&&(a=a.concat(t4n)),t.completionKeymap!==!1&&(a=a.concat(Xvt)),t.lintKeymap!==!1&&(a=a.concat(wFn));var i=[];return t.lineNumbers!==!1&&i.push(IDn()),t.highlightActiveLineGutter!==!1&&i.push(PDn()),t.highlightSpecialChars!==!1&&i.push(Z3n()),t.history!==!1&&i.push($8n()),t.foldGutter!==!1&&i.push(a4n()),t.drawSelection!==!1&&i.push(D3n()),t.dropCursor!==!1&&i.push(U3n()),t.allowMultipleSelections!==!1&&i.push(os.allowMultipleSelections.of(!0)),t.indentOnInput!==!1&&i.push(ZDn()),t.syntaxHighlighting!==!1&&i.push(F1(c4n,{fallback:!0})),t.bracketMatching!==!1&&i.push(g4n()),t.closeBrackets!==!1&&i.push(f5n()),t.autocompletion!==!1&&i.push(Yvt()),t.rectangularSelection!==!1&&i.push(oDn()),s!==!1&&i.push(uDn()),t.highlightActiveLine!==!1&&i.push(J3n()),t.highlightSelectionMatches!==!1&&i.push(q9n()),t.tabSize&&typeof t.tabSize=="number"&&i.push(RN.of(" ".repeat(t.tabSize))),i.concat([AN.of(a.flat())]).filter(Boolean)};const jFn="#e5c07b",l6e="#e06c75",TFn="#56b6c2",NFn="#ffffff",M9="#abb2bf",ihe="#7d8799",IFn="#61afef",AFn="#98c379",c6e="#d19a66",RFn="#c678dd",PFn="#21252b",u6e="#2c313a",d6e="#282c34",AK="#353a42",$Fn="#3E4451",f6e="#528bff",MFn=It.theme({"&":{color:M9,backgroundColor:d6e},".cm-content":{caretColor:f6e},".cm-cursor, .cm-dropCursor":{borderLeftColor:f6e},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:$Fn},".cm-panels":{backgroundColor:PFn,color:M9},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:d6e,color:ihe,border:"none"},".cm-activeLineGutter":{backgroundColor:u6e},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:AK},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:AK,borderBottomColor:AK},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:u6e,color:M9}}},{dark:!0}),DFn=$g.define([{tag:fe.keyword,color:RFn},{tag:[fe.name,fe.deleted,fe.character,fe.propertyName,fe.macroName],color:l6e},{tag:[fe.function(fe.variableName),fe.labelName],color:IFn},{tag:[fe.color,fe.constant(fe.name),fe.standard(fe.name)],color:c6e},{tag:[fe.definition(fe.name),fe.separator],color:M9},{tag:[fe.typeName,fe.className,fe.number,fe.changed,fe.annotation,fe.modifier,fe.self,fe.namespace],color:jFn},{tag:[fe.operator,fe.operatorKeyword,fe.url,fe.escape,fe.regexp,fe.link,fe.special(fe.string)],color:TFn},{tag:[fe.meta,fe.comment],color:ihe},{tag:fe.strong,fontWeight:"bold"},{tag:fe.emphasis,fontStyle:"italic"},{tag:fe.strikethrough,textDecoration:"line-through"},{tag:fe.link,color:ihe,textDecoration:"underline"},{tag:fe.heading,fontWeight:"bold",color:l6e},{tag:[fe.atom,fe.bool,fe.special(fe.variableName)],color:c6e},{tag:[fe.processingInstruction,fe.string,fe.inserted],color:AFn},{tag:fe.invalid,color:NFn}]),LFn=[MFn,F1(DFn)];var FFn=It.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),zFn=function(t){t===void 0&&(t={});var n=t,r=n.indentWithTab,s=r===void 0?!0:r,a=n.editable,i=a===void 0?!0:a,l=n.readOnly,c=l===void 0?!1:l,u=n.theme,d=u===void 0?"light":u,f=n.placeholder,p=f===void 0?"":f,h=n.basicSetup,m=h===void 0?!0:h,g=[];switch(s&&g.unshift(AN.of([L9n])),m&&(typeof m=="boolean"?g.unshift(o6e()):g.unshift(o6e(m))),p&&g.unshift(rDn(p)),d){case"light":g.push(FFn);break;case"dark":g.push(LFn);break;case"none":break;default:g.push(d);break}return i===!1&&g.push(It.editable.of(!1)),c&&g.push(os.readOnly.of(!0)),[...g]},BFn=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(t=>!t.empty)});class UFn{constructor(t,n){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=n,this.timeoutMS=n,this.callbacks.push(t)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var t=this.callbacks.slice();this.callbacks.length=0,t.forEach(n=>{try{n()}catch(r){console.error("TimeoutLatch callback error:",r)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class p6e{constructor(){this.interval=null,this.latches=new Set}add(t){this.latches.add(t),this.start()}remove(t){this.latches.delete(t),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(t=>{t.tick(),t.isDone&&this.remove(t)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var RK=null,qFn=()=>typeof window>"u"?new p6e:(RK||(RK=new p6e),RK),h6e=Ay.define(),VFn=200,HFn=[];function WFn(e){var t=e.value,n=e.selection,r=e.onChange,s=e.onStatistics,a=e.onCreateEditor,i=e.onUpdate,l=e.extensions,c=l===void 0?HFn:l,u=e.autoFocus,d=e.theme,f=d===void 0?"light":d,p=e.height,h=p===void 0?null:p,m=e.minHeight,g=m===void 0?null:m,y=e.maxHeight,b=y===void 0?null:y,w=e.width,S=w===void 0?null:w,k=e.minWidth,_=k===void 0?null:k,C=e.maxWidth,E=C===void 0?null:C,j=e.placeholder,N=j===void 0?"":j,I=e.editable,R=I===void 0?!0:I,$=e.readOnly,F=$===void 0?!1:$,D=e.indentWithTab,V=D===void 0?!0:D,W=e.basicSetup,L=W===void 0?!0:W,z=e.root,B=e.initialState,M=v.useState(),G=M[0],U=M[1],P=v.useState(),q=P[0],Z=P[1],X=v.useState(),te=X[0],J=X[1],ee=v.useState(()=>({current:null}))[0],ae=v.useState(()=>({current:null}))[0],de=It.theme({"&":{height:h,minHeight:g,maxHeight:b,width:S,minWidth:_,maxWidth:E},"& .cm-scroller":{height:"100% !important"}}),Y=It.updateListener.of(pe=>{if(pe.docChanged&&typeof r=="function"&&!pe.transactions.some(ye=>ye.annotation(h6e))){ee.current?ee.current.reset():(ee.current=new UFn(()=>{if(ae.current){var ye=ae.current;ae.current=null,ye()}ee.current=null},VFn),qFn().add(ee.current));var le=pe.state.doc,ve=le.toString();r(ve,pe)}s&&s(BFn(pe))}),ne=zFn({theme:f,editable:R,readOnly:F,placeholder:N,indentWithTab:V,basicSetup:L}),ce=[Y,de,...ne];return i&&typeof i=="function"&&ce.push(It.updateListener.of(i)),ce=ce.concat(c),v.useLayoutEffect(()=>{if(G&&!te){var pe={doc:t,selection:n,extensions:ce},le=B?os.fromJSON(B.json,pe,B.fields):os.create(pe);if(J(le),!q){var ve=new It({state:le,parent:G,root:z});Z(ve),a&&a(ve,le)}}return()=>{q&&(J(void 0),Z(void 0))}},[G,te]),v.useEffect(()=>{e.container&&U(e.container)},[e.container]),v.useEffect(()=>()=>{q&&(q.destroy(),Z(void 0)),ee.current&&(ee.current.cancel(),ee.current=null)},[q]),v.useEffect(()=>{u&&q&&q.focus()},[u,q]),v.useEffect(()=>{q&&q.dispatch({effects:vr.reconfigure.of(ce)})},[f,c,h,g,b,S,_,E,N,R,F,V,L,r,i]),v.useEffect(()=>{if(t!==void 0){var pe=q?q.state.doc.toString():"";if(q&&t!==pe){var le=ee.current&&!ee.current.isDone,ve=()=>{q&&t!==q.state.doc.toString()&&q.dispatch({changes:{from:0,to:q.state.doc.toString().length,insert:t||""},annotations:[h6e.of(!0)]})};le?ae.current=ve:ve()}}},[t,q]),{state:te,setState:J,view:q,setView:Z,container:G,setContainer:U}}var ZFn=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Xc=v.forwardRef((e,t)=>{var n=e.className,r=e.value,s=r===void 0?"":r,a=e.selection,i=e.extensions,l=i===void 0?[]:i,c=e.onChange,u=e.onStatistics,d=e.onCreateEditor,f=e.onUpdate,p=e.autoFocus,h=e.theme,m=h===void 0?"light":h,g=e.height,y=e.minHeight,b=e.maxHeight,w=e.width,S=e.minWidth,k=e.maxWidth,_=e.basicSetup,C=e.placeholder,E=e.indentWithTab,j=e.editable,N=e.readOnly,I=e.root,R=e.initialState,$=dbt(e,ZFn),F=v.useRef(null),D=WFn({root:I,value:s,autoFocus:p,theme:m,height:g,minHeight:y,maxHeight:b,width:w,minWidth:S,maxWidth:k,basicSetup:_,placeholder:C,indentWithTab:E,editable:j,readOnly:N,selection:a,onChange:c,onStatistics:u,onCreateEditor:d,onUpdate:f,extensions:l,initialState:R}),V=D.state,W=D.view,L=D.container,z=D.setContainer;v.useImperativeHandle(t,()=>({editor:F.current,state:V,view:W}),[F,L,V,W]);var B=v.useCallback(G=>{F.current=G,z(G)},[z]);if(typeof s!="string")throw new Error("value must be typeof string but got "+typeof s);var M=typeof m=="string"?"cm-theme-"+m:"cm-theme";return o.jsx("div",EO({ref:B,className:""+M+(n?" "+n:"")},$))});Xc.displayName="CodeMirror";function GFn(e){return new kO(gwe.define(e))}const sxt=[Ym.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return Eo(()=>Promise.resolve().then(()=>c6),[],import.meta.url).then(e=>e.javascript())}}),Ym.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return Eo(()=>Promise.resolve().then(()=>j4n),void 0,import.meta.url).then(e=>e.json())}}),Ym.of({name:"JSX",extensions:["jsx"],load(){return Eo(()=>Promise.resolve().then(()=>c6),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),Ym.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return Eo(()=>Promise.resolve().then(()=>S8n),void 0,import.meta.url).then(e=>e.markdown())}}),Ym.of({name:"TSX",extensions:["tsx"],load(){return Eo(()=>Promise.resolve().then(()=>c6),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Ym.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return Eo(()=>Promise.resolve().then(()=>c6),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),Ym.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return Eo(()=>import("./shell-CjFT_Tl9.js"),[],import.meta.url).then(e=>GFn(e.shell))}})];function QFn(e,t=5){if(!e?.properties)return[];const n=[];function r(s,a,i){if(i>t)return;const l=Array.isArray(s.type)?s.type.join(" | "):s.type;if(n.push({path:a,label:a,description:s.description??s.title,type:l}),s.properties)for(const[c,u]of Object.entries(s.properties))r(u,`${a}.${c}`,i+1);if(s.items?.properties)for(const[c,u]of Object.entries(s.items.properties))r(u,`${a}[].${c}`,i+1)}for(const[s,a]of Object.entries(e.properties))r(a,s,1);return n}function YFn(e){const t=QFn(e);return Yvt({override:[XFn(t)],defaultKeymap:!0,closeOnBlur:!0,icons:!1})}function XFn(e){return t=>{const r=t.state.sliceDoc(Math.max(0,t.pos-50),t.pos).match(/\{\{([a-zA-Z0-9_.\[\]]*)?$/);if(!r)return null;const s=r[1]??"",a=t.pos-s.length,i=s?e.filter(c=>c.path.toLowerCase().startsWith(s.toLowerCase())):e;if(i.length===0)return null;const l=i.map(c=>({label:c.path,displayLabel:c.path,detail:c.type,info:c.description,apply:(u,d,f,p)=>{const g=u.state.sliceDoc(p,p+2)==="}}"?d.label:`${d.label}}}`;u.dispatch({changes:{from:f,to:p,insert:g},selection:{anchor:f+g.length}})}}));return{from:a,options:l,validFor:/^[a-zA-Z0-9_.\[\]]*$/}}}const KFn=/\{\{([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)\}\}/g,JFn=Cn.mark({class:"cm-variable-highlight"}),m6e=new uvt({regexp:KFn,decoration:()=>JFn}),ezn=yo.fromClass(class{decorations;constructor(e){this.decorations=m6e.createDeco(e)}update(e){this.decorations=m6e.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}),tzn=ezn;function nzn(){const e=$N({settings:{fontFamily:"var(--font-mono)",fontSize:"0.8rem",lineHighlight:"transparent",gutterBackground:"transparent",gutterForeground:"var(--neutral2)",background:"transparent",foreground:"var(--neutral6)",caret:"var(--neutral6)"},styles:[{tag:[fe.className,fe.propertyName],color:"var(--neutral6)"},{tag:fe.heading,color:"var(--accent3)",fontWeight:"bold"},{tag:[fe.heading1,fe.heading2,fe.heading3,fe.heading4,fe.heading5,fe.heading6],color:"var(--accent3)",fontWeight:"bold"},{tag:fe.emphasis,fontStyle:"italic",color:"var(--neutral6)"},{tag:fe.strong,fontWeight:"bold",color:"var(--neutral6)"},{tag:fe.link,color:"var(--accent3)",textDecoration:"underline"},{tag:fe.url,color:"var(--accent3)"},{tag:fe.monospace,color:"var(--neutral6)"},{tag:fe.strikethrough,textDecoration:"line-through"},{tag:fe.quote,fontStyle:"italic",color:"var(--neutral2)"}]}),t=It.theme({".cm-editor":{backgroundColor:"transparent"},".cm-content":{color:"var(--neutral6)",caretColor:"var(--neutral6)"},".cm-lineNumbers .cm-gutterElement":{color:"var(--neutral2)"},".cm-activeLineGutter":{color:"var(--neutral3)"},".cm-cursor":{borderLeftColor:"var(--neutral6)"},".cm-selectionBackground, .cm-content ::selection":{backgroundColor:"color-mix(in srgb, var(--accent3) 22%, transparent)"},".cm-tooltip-autocomplete":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",borderRadius:"6px",boxShadow:"0 8px 16px rgba(0, 0, 0, 0.2)"},".cm-tooltip-autocomplete > ul":{fontFamily:"var(--font-mono)"},".cm-completionLabel":{color:"var(--neutral6)"},".cm-completionDetail":{color:"var(--neutral3)",fontSize:"0.7rem",marginLeft:"auto",paddingLeft:"12px"},".cm-completionInfo":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",color:"var(--neutral3)",padding:"8px 12px"},".cm-completionIcon":{display:"none"},"ul.cm-completionList li[aria-selected]":{backgroundColor:"var(--surface4)",color:"var(--neutral6)"},".cm-line .cm-variable-highlight":{color:"var(--accent6) !important",fontWeight:"500"}});return[e,t]}function rzn(){const e=It.theme({"&":{backgroundColor:"transparent",color:"var(--neutral6)",fontSize:"0.8rem"},"&.cm-editor .cm-scroller":{fontFamily:"var(--font-mono)"},".cm-gutters":{backgroundColor:"transparent",color:"var(--neutral2)",borderRight:"none"},".cm-content":{color:"var(--neutral6)",caretColor:"var(--neutral6)"},".cm-activeLine":{backgroundColor:"transparent"},".cm-lineNumbers .cm-gutterElement":{color:"var(--neutral2)"},".cm-activeLineGutter":{backgroundColor:"transparent",color:"var(--neutral3)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--neutral6)"},"&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection":{background:"color-mix(in srgb, var(--accent3) 22%, transparent) !important"},".cm-tooltip-autocomplete":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",borderRadius:"6px",boxShadow:"0 8px 16px rgba(0, 0, 0, 0.2)"},".cm-tooltip-autocomplete > ul":{fontFamily:"var(--font-mono)"},".cm-completionLabel":{color:"var(--neutral6)"},".cm-completionDetail":{color:"var(--neutral3)",fontSize:"0.7rem",marginLeft:"auto",paddingLeft:"12px"},".cm-completionInfo":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",color:"var(--neutral3)",padding:"8px 12px"},".cm-completionIcon":{display:"none"},"ul.cm-completionList li[aria-selected]":{backgroundColor:"var(--surface4)",color:"var(--neutral6)"},".cm-line .cm-variable-highlight":{color:"var(--accent6) !important",fontWeight:"500"}}),t=$g.define([{tag:[fe.comment,fe.bracket],color:"var(--neutral2)"},{tag:[fe.string,fe.meta,fe.regexp],color:"var(--accent1)"},{tag:[fe.atom,fe.bool,fe.special(fe.variableName)],color:"var(--accent6)"},{tag:[fe.keyword,fe.operator,fe.tagName],color:"var(--accent2)"},{tag:[fe.function(fe.propertyName),fe.propertyName],color:"var(--accent5)"},{tag:[fe.definition(fe.variableName),fe.function(fe.variableName),fe.className,fe.attributeName],color:"var(--accent3)"},{tag:[fe.variableName,fe.number],color:"var(--accent5)"},{tag:[fe.name,fe.quote],color:"var(--accent1)"},{tag:fe.heading,color:"var(--accent3)",fontWeight:"bold"},{tag:[fe.heading1,fe.heading2,fe.heading3,fe.heading4,fe.heading5,fe.heading6],color:"var(--accent3)",fontWeight:"bold"},{tag:[fe.emphasis],fontStyle:"italic",color:"var(--neutral6)"},{tag:[fe.strong],fontWeight:"bold",color:"var(--neutral6)"},{tag:fe.link,color:"var(--accent3)",textDecoration:"underline"},{tag:fe.url,color:"var(--accent3)"},{tag:fe.monospace,color:"var(--neutral6)"},{tag:fe.strikethrough,textDecoration:"line-through"},{tag:[fe.deleted],color:"var(--accent2)"},{tag:fe.invalid,color:"var(--error)"},{tag:[fe.standard(fe.tagName)],color:"var(--accent1)"}]);return[e,F1(t)]}const Py=()=>{const e=EN().resolvedTheme==="dark";return v.useMemo(()=>e?nzn():rzn(),[e])},Qr=v.forwardRef(({data:e,value:t,onChange:n,showCopyButton:r=!0,className:s,language:a="json",highlightVariables:i=!1,placeholder:l,schema:c,autoFocus:u,lineNumbers:d=!0,lineWrapping:f=!0,editable:p,...h},m)=>{const g=Py(),y=e?JSON.stringify(e,null,2):t??"",b=v.useMemo(()=>{const w=[];return f&&w.push(It.lineWrapping),a==="json"?w.push(of):a==="markdown"&&w.push(qwe({base:CO,codeLanguages:sxt})),i&&a==="markdown"&&w.push(tzn),c&&a==="markdown"&&w.push(YFn(c)),p===!1&&w.push(os.readOnly.of(!0)),w},[a,i,c,p,f]);return o.jsxs("div",{className:K("rounded-md bg-surface3 p-1 font-mono relative border border-border1 overflow-hidden",s),...h,children:[r&&o.jsx(ya,{content:y,className:"absolute top-2 right-2 z-20"}),o.jsx(Xc,{ref:m,value:y,theme:g,extensions:b,onChange:n,editable:p,"aria-label":"Code editor",placeholder:l,height:"100%",style:{height:"100%"},autoFocus:u,basicSetup:{lineNumbers:d}})]})}),szn={js:"javascript",javascript:"javascript",mjs:"javascript",cjs:"javascript",node:"javascript",ts:"typescript",typescript:"typescript",mts:"typescript",cts:"typescript",tsx:"tsx",jsx:"jsx",json:"json",json5:"json",md:"markdown",markdown:"markdown",py:"python",python:"python",sh:"bash",bash:"bash",shell:"bash",zsh:"bash"};let PK=null;function azn(){return PK||(PK=(async()=>{const[{createHighlighterCore:e},{createJavaScriptRegexEngine:t}]=await Promise.all([Eo(()=>import("./core-BzGcCrGa.js"),__vite__mapDeps([0,1,2]),import.meta.url),Eo(()=>import("./engine-javascript-CSIo_1eZ.js"),__vite__mapDeps([3,1]),import.meta.url)]);return e({themes:[Eo(()=>import("./github-light-DAi9KRSo.js"),[],import.meta.url),Eo(()=>import("./github-dark-DHJKELXO.js"),[],import.meta.url)],langs:[Eo(()=>import("./javascript-ySlJ1b_l.js"),[],import.meta.url),Eo(()=>import("./typescript-Dj6nwHGl.js"),[],import.meta.url),Eo(()=>import("./tsx-B6W0miNI.js"),[],import.meta.url),Eo(()=>import("./jsx-BAng5TT0.js"),[],import.meta.url),Eo(()=>import("./json-BQoSv7ci.js"),[],import.meta.url),Eo(()=>import("./bash-atvbtKCR.js"),[],import.meta.url),Eo(()=>import("./markdown-UIAJJxZW.js"),[],import.meta.url),Eo(()=>import("./python-DhUJRlN_.js"),[],import.meta.url)],engine:t()})})()),PK}async function izn(e,t){const n=szn[t?.toLowerCase()];if(!n)return null;const r=await azn(),{tokens:s}=r.codeToTokens(e,{lang:n,defaultColor:!1,themes:{light:"github-light",dark:"github-dark"}});return s}const ozn=e=>{try{return JSON.stringify(e??{},null,2)}catch{return"{}"}},lzn=({editorClassName:e="h-[240px] max-h-[40vh]",onSaved:t})=>{const n=Py(),{settings:r,setSettings:s}=Bq(),a=r?.tracingOptions,i=v.useMemo(()=>ozn(a),[a]),[l,c]=v.useState(()=>i),u=v.useRef(!1);v.useEffect(()=>{u.current||c(i)},[i]);const d=p=>{u.current=!0,c(p)},f=()=>{if(!l){s({...r,tracingOptions:void 0}),t?.();return}try{const p=JSON.parse(l);typeof p=="object"&&p!==null&&s({...r,tracingOptions:p})}catch{return}t?.()};return o.jsxs("div",{className:"space-y-2 px-5 py-2",children:[o.jsx(ge,{as:"h3",variant:"ui-md",className:"text-neutral3",children:"Tracing Options"}),o.jsx(Xc,{value:l,onChange:d,theme:n,extensions:[of],className:K("overflow-y-scroll bg-surface3 rounded-lg overflow-hidden p-3",e)}),o.jsx("div",{className:"flex items-center justify-end",children:o.jsx(ue,{type:"button",onClick:f,children:"Save"})})]})},czn=()=>{const[e,t]=v.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx(ue,{type:"button",variant:"ghost",size:"icon-md","aria-label":"Run Options",onClick:()=>t(!0),children:o.jsx(Ue,{children:o.jsx(Yye,{})})})}),o.jsx(Bn,{children:"Run Options"})]}),o.jsx(br,{open:e,onOpenChange:t,children:o.jsxs(xr,{children:[o.jsxs(wr,{children:[o.jsx(gr,{children:"Run Options"}),o.jsx(Qs,{children:"Configure tracing and debug options for this workflow run"})]}),o.jsx(Ar,{children:o.jsx(lzn,{onSaved:()=>t(!1)})})]})})]})};function uzn({status:e}){switch(e){case"running":return o.jsx(Gt,{});case"failed":return o.jsx(vs,{className:"text-accent2"});case"canceled":return o.jsx(xf,{className:"text-neutral3"});case"pending":case"waiting":return o.jsx(sO,{className:"text-neutral3"});case"suspended":return o.jsx(ZU,{className:"text-accent3"});case"success":return o.jsx(Js,{className:"text-accent1"});default:return o.jsx(sO,{className:"text-neutral3"})}}function axt({status:e}){return o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx(Ue,{"aria-label":e,className:"shrink-0",children:o.jsx(uzn,{status:e})})}),o.jsx(Bn,{children:e})]})}var $K,g6e;function Kwe(){if(g6e)return $K;g6e=1;var e="\0",t="\0",n="";class r{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>{};_defaultEdgeLabelFn=()=>{};_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(d){d&&(this._isDirected=Object.hasOwn(d,"directed")?d.directed:!0,this._isMultigraph=Object.hasOwn(d,"multigraph")?d.multigraph:!1,this._isCompound=Object.hasOwn(d,"compound")?d.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(d){return this._label=d,this}graph(){return this._label}setDefaultNodeLabel(d){return this._defaultNodeLabelFn=d,typeof d!="function"&&(this._defaultNodeLabelFn=()=>d),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var d=this;return this.nodes().filter(f=>Object.keys(d._in[f]).length===0)}sinks(){var d=this;return this.nodes().filter(f=>Object.keys(d._out[f]).length===0)}setNodes(d,f){var p=arguments,h=this;return d.forEach(function(m){p.length>1?h.setNode(m,f):h.setNode(m)}),this}setNode(d,f){return Object.hasOwn(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=f),this):(this._nodes[d]=arguments.length>1?f:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=t,this._children[d]={},this._children[t][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)}node(d){return this._nodes[d]}hasNode(d){return Object.hasOwn(this._nodes,d)}removeNode(d){var f=this;if(Object.hasOwn(this._nodes,d)){var p=h=>f.removeEdge(f._edgeObjs[h]);delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],this.children(d).forEach(function(h){f.setParent(h)}),delete this._children[d]),Object.keys(this._in[d]).forEach(p),delete this._in[d],delete this._preds[d],Object.keys(this._out[d]).forEach(p),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this}setParent(d,f){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(f===void 0)f=t;else{f+="";for(var p=f;p!==void 0;p=this.parent(p))if(p===d)throw new Error("Setting "+f+" as parent of "+d+" would create a cycle");this.setNode(f)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=f,this._children[f][d]=!0,this}_removeFromParentsChildList(d){delete this._children[this._parent[d]][d]}parent(d){if(this._isCompound){var f=this._parent[d];if(f!==t)return f}}children(d=t){if(this._isCompound){var f=this._children[d];if(f)return Object.keys(f)}else{if(d===t)return this.nodes();if(this.hasNode(d))return[]}}predecessors(d){var f=this._preds[d];if(f)return Object.keys(f)}successors(d){var f=this._sucs[d];if(f)return Object.keys(f)}neighbors(d){var f=this.predecessors(d);if(f){const h=new Set(f);for(var p of this.successors(d))h.add(p);return Array.from(h.values())}}isLeaf(d){var f;return this.isDirected()?f=this.successors(d):f=this.neighbors(d),f.length===0}filterNodes(d){var f=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});f.setGraph(this.graph());var p=this;Object.entries(this._nodes).forEach(function([g,y]){d(g)&&f.setNode(g,y)}),Object.values(this._edgeObjs).forEach(function(g){f.hasNode(g.v)&&f.hasNode(g.w)&&f.setEdge(g,p.edge(g))});var h={};function m(g){var y=p.parent(g);return y===void 0||f.hasNode(y)?(h[g]=y,y):y in h?h[y]:m(y)}return this._isCompound&&f.nodes().forEach(g=>f.setParent(g,m(g))),f}setDefaultEdgeLabel(d){return this._defaultEdgeLabelFn=d,typeof d!="function"&&(this._defaultEdgeLabelFn=()=>d),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(d,f){var p=this,h=arguments;return d.reduce(function(m,g){return h.length>1?p.setEdge(m,g,f):p.setEdge(m,g),g}),this}setEdge(){var d,f,p,h,m=!1,g=arguments[0];typeof g=="object"&&g!==null&&"v"in g?(d=g.v,f=g.w,p=g.name,arguments.length===2&&(h=arguments[1],m=!0)):(d=g,f=arguments[1],p=arguments[3],arguments.length>2&&(h=arguments[2],m=!0)),d=""+d,f=""+f,p!==void 0&&(p=""+p);var y=i(this._isDirected,d,f,p);if(Object.hasOwn(this._edgeLabels,y))return m&&(this._edgeLabels[y]=h),this;if(p!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(f),this._edgeLabels[y]=m?h:this._defaultEdgeLabelFn(d,f,p);var b=l(this._isDirected,d,f,p);return d=b.v,f=b.w,Object.freeze(b),this._edgeObjs[y]=b,s(this._preds[f],d),s(this._sucs[d],f),this._in[f][y]=b,this._out[d][y]=b,this._edgeCount++,this}edge(d,f,p){var h=arguments.length===1?c(this._isDirected,arguments[0]):i(this._isDirected,d,f,p);return this._edgeLabels[h]}edgeAsObj(){const d=this.edge(...arguments);return typeof d!="object"?{label:d}:d}hasEdge(d,f,p){var h=arguments.length===1?c(this._isDirected,arguments[0]):i(this._isDirected,d,f,p);return Object.hasOwn(this._edgeLabels,h)}removeEdge(d,f,p){var h=arguments.length===1?c(this._isDirected,arguments[0]):i(this._isDirected,d,f,p),m=this._edgeObjs[h];return m&&(d=m.v,f=m.w,delete this._edgeLabels[h],delete this._edgeObjs[h],a(this._preds[f],d),a(this._sucs[d],f),delete this._in[f][h],delete this._out[d][h],this._edgeCount--),this}inEdges(d,f){var p=this._in[d];if(p){var h=Object.values(p);return f?h.filter(m=>m.v===f):h}}outEdges(d,f){var p=this._out[d];if(p){var h=Object.values(p);return f?h.filter(m=>m.w===f):h}}nodeEdges(d,f){var p=this.inEdges(d,f);if(p)return p.concat(this.outEdges(d,f))}}function s(u,d){u[d]?u[d]++:u[d]=1}function a(u,d){--u[d]||delete u[d]}function i(u,d,f,p){var h=""+d,m=""+f;if(!u&&h>m){var g=h;h=m,m=g}return h+n+m+n+(p===void 0?e:p)}function l(u,d,f,p){var h=""+d,m=""+f;if(!u&&h>m){var g=h;h=m,m=g}var y={v:h,w:m};return p&&(y.name=p),y}function c(u,d){return i(u,d.v,d.w,d.name)}return $K=r,$K}var MK,v6e;function dzn(){return v6e||(v6e=1,MK="2.2.4"),MK}var DK,y6e;function fzn(){return y6e||(y6e=1,DK={Graph:Kwe(),version:dzn()}),DK}var LK,b6e;function pzn(){if(b6e)return LK;b6e=1;var e=Kwe();LK={write:t,read:s};function t(a){var i={options:{directed:a.isDirected(),multigraph:a.isMultigraph(),compound:a.isCompound()},nodes:n(a),edges:r(a)};return a.graph()!==void 0&&(i.value=structuredClone(a.graph())),i}function n(a){return a.nodes().map(function(i){var l=a.node(i),c=a.parent(i),u={v:i};return l!==void 0&&(u.value=l),c!==void 0&&(u.parent=c),u})}function r(a){return a.edges().map(function(i){var l=a.edge(i),c={v:i.v,w:i.w};return i.name!==void 0&&(c.name=i.name),l!==void 0&&(c.value=l),c})}function s(a){var i=new e(a.options).setGraph(a.value);return a.nodes.forEach(function(l){i.setNode(l.v,l.value),l.parent&&i.setParent(l.v,l.parent)}),a.edges.forEach(function(l){i.setEdge({v:l.v,w:l.w,name:l.name},l.value)}),i}return LK}var FK,x6e;function hzn(){if(x6e)return FK;x6e=1,FK=e;function e(t){var n={},r=[],s;function a(i){Object.hasOwn(n,i)||(n[i]=!0,s.push(i),t.successors(i).forEach(a),t.predecessors(i).forEach(a))}return t.nodes().forEach(function(i){s=[],a(i),s.length&&r.push(s)}),r}return FK}var zK,w6e;function ixt(){if(w6e)return zK;w6e=1;class e{_arr=[];_keyIndices={};size(){return this._arr.length}keys(){return this._arr.map(function(n){return n.key})}has(n){return Object.hasOwn(this._keyIndices,n)}priority(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(n,r){var s=this._keyIndices;if(n=String(n),!Object.hasOwn(s,n)){var a=this._arr,i=a.length;return s[n]=i,a.push({key:n,priority:r}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key}decrease(n,r){var s=this._keyIndices[n];if(r>this._arr[s].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[s].priority+" New: "+r);this._arr[s].priority=r,this._decrease(s)}_heapify(n){var r=this._arr,s=2*n,a=s+1,i=n;s<r.length&&(i=r[s].priority<r[i].priority?s:i,a<r.length&&(i=r[a].priority<r[i].priority?a:i),i!==n&&(this._swap(n,i),this._heapify(i)))}_decrease(n){for(var r=this._arr,s=r[n].priority,a;n!==0&&(a=n>>1,!(r[a].priority<s));)this._swap(n,a),n=a}_swap(n,r){var s=this._arr,a=this._keyIndices,i=s[n],l=s[r];s[n]=l,s[r]=i,a[l.key]=n,a[i.key]=r}}return zK=e,zK}var BK,S6e;function oxt(){if(S6e)return BK;S6e=1;var e=ixt();BK=n;var t=()=>1;function n(s,a,i,l){return r(s,String(a),i||t,l||function(c){return s.outEdges(c)})}function r(s,a,i,l){var c={},u=new e,d,f,p=function(h){var m=h.v!==d?h.v:h.w,g=c[m],y=i(h),b=f.distance+y;if(y<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+h+" Weight: "+y);b<g.distance&&(g.distance=b,g.predecessor=d,u.decrease(m,b))};for(s.nodes().forEach(function(h){var m=h===a?0:Number.POSITIVE_INFINITY;c[h]={distance:m},u.add(h,m)});u.size()>0&&(d=u.removeMin(),f=c[d],f.distance!==Number.POSITIVE_INFINITY);)l(d).forEach(p);return c}return BK}var UK,k6e;function mzn(){if(k6e)return UK;k6e=1;var e=oxt();UK=t;function t(n,r,s){return n.nodes().reduce(function(a,i){return a[i]=e(n,i,r,s),a},{})}return UK}var qK,O6e;function lxt(){if(O6e)return qK;O6e=1,qK=e;function e(t){var n=0,r=[],s={},a=[];function i(l){var c=s[l]={onStack:!0,lowlink:n,index:n++};if(r.push(l),t.successors(l).forEach(function(f){Object.hasOwn(s,f)?s[f].onStack&&(c.lowlink=Math.min(c.lowlink,s[f].index)):(i(f),c.lowlink=Math.min(c.lowlink,s[f].lowlink))}),c.lowlink===c.index){var u=[],d;do d=r.pop(),s[d].onStack=!1,u.push(d);while(l!==d);a.push(u)}}return t.nodes().forEach(function(l){Object.hasOwn(s,l)||i(l)}),a}return qK}var VK,_6e;function gzn(){if(_6e)return VK;_6e=1;var e=lxt();VK=t;function t(n){return e(n).filter(function(r){return r.length>1||r.length===1&&n.hasEdge(r[0],r[0])})}return VK}var HK,C6e;function vzn(){if(C6e)return HK;C6e=1,HK=t;var e=()=>1;function t(r,s,a){return n(r,s||e,a||function(i){return r.outEdges(i)})}function n(r,s,a){var i={},l=r.nodes();return l.forEach(function(c){i[c]={},i[c][c]={distance:0},l.forEach(function(u){c!==u&&(i[c][u]={distance:Number.POSITIVE_INFINITY})}),a(c).forEach(function(u){var d=u.v===c?u.w:u.v,f=s(u);i[c][d]={distance:f,predecessor:c}})}),l.forEach(function(c){var u=i[c];l.forEach(function(d){var f=i[d];l.forEach(function(p){var h=f[c],m=u[p],g=f[p],y=h.distance+m.distance;y<g.distance&&(g.distance=y,g.predecessor=m.predecessor)})})}),i}return HK}var WK,E6e;function cxt(){if(E6e)return WK;E6e=1;function e(n){var r={},s={},a=[];function i(l){if(Object.hasOwn(s,l))throw new t;Object.hasOwn(r,l)||(s[l]=!0,r[l]=!0,n.predecessors(l).forEach(i),delete s[l],a.push(l))}if(n.sinks().forEach(i),Object.keys(r).length!==n.nodeCount())throw new t;return a}class t extends Error{constructor(){super(...arguments)}}return WK=e,e.CycleException=t,WK}var ZK,j6e;function yzn(){if(j6e)return ZK;j6e=1;var e=cxt();ZK=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return ZK}var GK,T6e;function uxt(){if(T6e)return GK;T6e=1,GK=e;function e(s,a,i){Array.isArray(a)||(a=[a]);var l=s.isDirected()?f=>s.successors(f):f=>s.neighbors(f),c=i==="post"?t:n,u=[],d={};return a.forEach(f=>{if(!s.hasNode(f))throw new Error("Graph does not have node: "+f);c(f,l,d,u)}),u}function t(s,a,i,l){for(var c=[[s,!1]];c.length>0;){var u=c.pop();u[1]?l.push(u[0]):Object.hasOwn(i,u[0])||(i[u[0]]=!0,c.push([u[0],!0]),r(a(u[0]),d=>c.push([d,!1])))}}function n(s,a,i,l){for(var c=[s];c.length>0;){var u=c.pop();Object.hasOwn(i,u)||(i[u]=!0,l.push(u),r(a(u),d=>c.push(d)))}}function r(s,a){for(var i=s.length;i--;)a(s[i],i,s);return s}return GK}var QK,N6e;function bzn(){if(N6e)return QK;N6e=1;var e=uxt();QK=t;function t(n,r){return e(n,r,"post")}return QK}var YK,I6e;function xzn(){if(I6e)return YK;I6e=1;var e=uxt();YK=t;function t(n,r){return e(n,r,"pre")}return YK}var XK,A6e;function wzn(){if(A6e)return XK;A6e=1;var e=Kwe(),t=ixt();XK=n;function n(r,s){var a=new e,i={},l=new t,c;function u(f){var p=f.v===c?f.w:f.v,h=l.priority(p);if(h!==void 0){var m=s(f);m<h&&(i[p]=c,l.decrease(p,m))}}if(r.nodeCount()===0)return a;r.nodes().forEach(function(f){l.add(f,Number.POSITIVE_INFINITY),a.setNode(f)}),l.decrease(r.nodes()[0],0);for(var d=!1;l.size()>0;){if(c=l.removeMin(),Object.hasOwn(i,c))a.setEdge(c,i[c]);else{if(d)throw new Error("Input graph is not connected: "+r);d=!0}r.nodeEdges(c).forEach(u)}return a}return XK}var KK,R6e;function Szn(){return R6e||(R6e=1,KK={components:hzn(),dijkstra:oxt(),dijkstraAll:mzn(),findCycles:gzn(),floydWarshall:vzn(),isAcyclic:yzn(),postorder:bzn(),preorder:xzn(),prim:wzn(),tarjan:lxt(),topsort:cxt()}),KK}var JK,P6e;function Eg(){if(P6e)return JK;P6e=1;var e=fzn();return JK={Graph:e.Graph,json:pzn(),alg:Szn(),version:e.version},JK}var eJ,$6e;function kzn(){if($6e)return eJ;$6e=1;class e{constructor(){let s={};s._next=s._prev=s,this._sentinel=s}dequeue(){let s=this._sentinel,a=s._prev;if(a!==s)return t(a),a}enqueue(s){let a=this._sentinel;s._prev&&s._next&&t(s),s._next=a._next,a._next._prev=s,a._next=s,s._prev=a}toString(){let s=[],a=this._sentinel,i=a._prev;for(;i!==a;)s.push(JSON.stringify(i,n)),i=i._prev;return"["+s.join(", ")+"]"}}function t(r){r._prev._next=r._next,r._next._prev=r._prev,delete r._next,delete r._prev}function n(r,s){if(r!=="_next"&&r!=="_prev")return s}return eJ=e,eJ}var tJ,M6e;function Ozn(){if(M6e)return tJ;M6e=1;let e=Eg().Graph,t=kzn();tJ=r;let n=()=>1;function r(u,d){if(u.nodeCount()<=1)return[];let f=i(u,d||n);return s(f.graph,f.buckets,f.zeroIdx).flatMap(h=>u.outEdges(h.v,h.w))}function s(u,d,f){let p=[],h=d[d.length-1],m=d[0],g;for(;u.nodeCount();){for(;g=m.dequeue();)a(u,d,f,g);for(;g=h.dequeue();)a(u,d,f,g);if(u.nodeCount()){for(let y=d.length-2;y>0;--y)if(g=d[y].dequeue(),g){p=p.concat(a(u,d,f,g,!0));break}}}return p}function a(u,d,f,p,h){let m=h?[]:void 0;return u.inEdges(p.v).forEach(g=>{let y=u.edge(g),b=u.node(g.v);h&&m.push({v:g.v,w:g.w}),b.out-=y,l(d,f,b)}),u.outEdges(p.v).forEach(g=>{let y=u.edge(g),b=g.w,w=u.node(b);w.in-=y,l(d,f,w)}),u.removeNode(p.v),m}function i(u,d){let f=new e,p=0,h=0;u.nodes().forEach(y=>{f.setNode(y,{v:y,in:0,out:0})}),u.edges().forEach(y=>{let b=f.edge(y.v,y.w)||0,w=d(y),S=b+w;f.setEdge(y.v,y.w,S),h=Math.max(h,f.node(y.v).out+=w),p=Math.max(p,f.node(y.w).in+=w)});let m=c(h+p+3).map(()=>new t),g=p+1;return f.nodes().forEach(y=>{l(m,g,f.node(y))}),{graph:f,buckets:m,zeroIdx:g}}function l(u,d,f){f.out?f.in?u[f.out-f.in+d].enqueue(f):u[u.length-1].enqueue(f):u[0].enqueue(f)}function c(u){const d=[];for(let f=0;f<u;f++)d.push(f);return d}return tJ}var nJ,D6e;function jl(){if(D6e)return nJ;D6e=1;let e=Eg().Graph;nJ={addBorderNode:d,addDummyNode:t,applyWithChunking:h,asNonCompoundGraph:r,buildLayerMatrix:l,intersectRect:i,mapValues:C,maxRank:m,normalizeRanks:c,notime:b,partition:g,pick:_,predecessorWeights:a,range:k,removeEmptyRanks:u,simplify:n,successorWeights:s,time:y,uniqueId:S,zipObject:E};function t(j,N,I,R){for(var $=R;j.hasNode($);)$=S(R);return I.dummy=N,j.setNode($,I),$}function n(j){let N=new e().setGraph(j.graph());return j.nodes().forEach(I=>N.setNode(I,j.node(I))),j.edges().forEach(I=>{let R=N.edge(I.v,I.w)||{weight:0,minlen:1},$=j.edge(I);N.setEdge(I.v,I.w,{weight:R.weight+$.weight,minlen:Math.max(R.minlen,$.minlen)})}),N}function r(j){let N=new e({multigraph:j.isMultigraph()}).setGraph(j.graph());return j.nodes().forEach(I=>{j.children(I).length||N.setNode(I,j.node(I))}),j.edges().forEach(I=>{N.setEdge(I,j.edge(I))}),N}function s(j){let N=j.nodes().map(I=>{let R={};return j.outEdges(I).forEach($=>{R[$.w]=(R[$.w]||0)+j.edge($).weight}),R});return E(j.nodes(),N)}function a(j){let N=j.nodes().map(I=>{let R={};return j.inEdges(I).forEach($=>{R[$.v]=(R[$.v]||0)+j.edge($).weight}),R});return E(j.nodes(),N)}function i(j,N){let I=j.x,R=j.y,$=N.x-I,F=N.y-R,D=j.width/2,V=j.height/2;if(!$&&!F)throw new Error("Not possible to find intersection inside of the rectangle");let W,L;return Math.abs(F)*D>Math.abs($)*V?(F<0&&(V=-V),W=V*$/F,L=V):($<0&&(D=-D),W=D,L=D*F/$),{x:I+W,y:R+L}}function l(j){let N=k(m(j)+1).map(()=>[]);return j.nodes().forEach(I=>{let R=j.node(I),$=R.rank;$!==void 0&&(N[$][R.order]=I)}),N}function c(j){let N=j.nodes().map(R=>{let $=j.node(R).rank;return $===void 0?Number.MAX_VALUE:$}),I=h(Math.min,N);j.nodes().forEach(R=>{let $=j.node(R);Object.hasOwn($,"rank")&&($.rank-=I)})}function u(j){let N=j.nodes().map(D=>j.node(D).rank),I=h(Math.min,N),R=[];j.nodes().forEach(D=>{let V=j.node(D).rank-I;R[V]||(R[V]=[]),R[V].push(D)});let $=0,F=j.graph().nodeRankFactor;Array.from(R).forEach((D,V)=>{D===void 0&&V%F!==0?--$:D!==void 0&&$&&D.forEach(W=>j.node(W).rank+=$)})}function d(j,N,I,R){let $={width:0,height:0};return arguments.length>=4&&($.rank=I,$.order=R),t(j,"border",$,N)}function f(j,N=p){const I=[];for(let R=0;R<j.length;R+=N){const $=j.slice(R,R+N);I.push($)}return I}const p=65535;function h(j,N){if(N.length>p){const I=f(N);return j.apply(null,I.map(R=>j.apply(null,R)))}else return j.apply(null,N)}function m(j){const I=j.nodes().map(R=>{let $=j.node(R).rank;return $===void 0?Number.MIN_VALUE:$});return h(Math.max,I)}function g(j,N){let I={lhs:[],rhs:[]};return j.forEach(R=>{N(R)?I.lhs.push(R):I.rhs.push(R)}),I}function y(j,N){let I=Date.now();try{return N()}finally{console.log(j+" time: "+(Date.now()-I)+"ms")}}function b(j,N){return N()}let w=0;function S(j){var N=++w;return j+(""+N)}function k(j,N,I=1){N==null&&(N=j,j=0);let R=F=>F<N;I<0&&(R=F=>N<F);const $=[];for(let F=j;R(F);F+=I)$.push(F);return $}function _(j,N){const I={};for(const R of N)j[R]!==void 0&&(I[R]=j[R]);return I}function C(j,N){let I=N;return typeof N=="string"&&(I=R=>R[N]),Object.entries(j).reduce((R,[$,F])=>(R[$]=I(F,$),R),{})}function E(j,N){return j.reduce((I,R,$)=>(I[R]=N[$],I),{})}return nJ}var rJ,L6e;function _zn(){if(L6e)return rJ;L6e=1;let e=Ozn(),t=jl().uniqueId;rJ={run:n,undo:s};function n(a){(a.graph().acyclicer==="greedy"?e(a,l(a)):r(a)).forEach(c=>{let u=a.edge(c);a.removeEdge(c),u.forwardName=c.name,u.reversed=!0,a.setEdge(c.w,c.v,u,t("rev"))});function l(c){return u=>c.edge(u).weight}}function r(a){let i=[],l={},c={};function u(d){Object.hasOwn(c,d)||(c[d]=!0,l[d]=!0,a.outEdges(d).forEach(f=>{Object.hasOwn(l,f.w)?i.push(f):u(f.w)}),delete l[d])}return a.nodes().forEach(u),i}function s(a){a.edges().forEach(i=>{let l=a.edge(i);if(l.reversed){a.removeEdge(i);let c=l.forwardName;delete l.reversed,delete l.forwardName,a.setEdge(i.w,i.v,l,c)}})}return rJ}var sJ,F6e;function Czn(){if(F6e)return sJ;F6e=1;let e=jl();sJ={run:t,undo:r};function t(s){s.graph().dummyChains=[],s.edges().forEach(a=>n(s,a))}function n(s,a){let i=a.v,l=s.node(i).rank,c=a.w,u=s.node(c).rank,d=a.name,f=s.edge(a),p=f.labelRank;if(u===l+1)return;s.removeEdge(a);let h,m,g;for(g=0,++l;l<u;++g,++l)f.points=[],m={width:0,height:0,edgeLabel:f,edgeObj:a,rank:l},h=e.addDummyNode(s,"edge",m,"_d"),l===p&&(m.width=f.width,m.height=f.height,m.dummy="edge-label",m.labelpos=f.labelpos),s.setEdge(i,h,{weight:f.weight},d),g===0&&s.graph().dummyChains.push(h),i=h;s.setEdge(i,c,{weight:f.weight},d)}function r(s){s.graph().dummyChains.forEach(a=>{let i=s.node(a),l=i.edgeLabel,c;for(s.setEdge(i.edgeObj,l);i.dummy;)c=s.successors(a)[0],s.removeNode(a),l.points.push({x:i.x,y:i.y}),i.dummy==="edge-label"&&(l.x=i.x,l.y=i.y,l.width=i.width,l.height=i.height),a=c,i=s.node(a)})}return sJ}var aJ,z6e;function h7(){if(z6e)return aJ;z6e=1;const{applyWithChunking:e}=jl();aJ={longestPath:t,slack:n};function t(r){var s={};function a(i){var l=r.node(i);if(Object.hasOwn(s,i))return l.rank;s[i]=!0;let c=r.outEdges(i).map(d=>d==null?Number.POSITIVE_INFINITY:a(d.w)-r.edge(d).minlen);var u=e(Math.min,c);return u===Number.POSITIVE_INFINITY&&(u=0),l.rank=u}r.sources().forEach(a)}function n(r,s){return r.node(s.w).rank-r.node(s.v).rank-r.edge(s).minlen}return aJ}var iJ,B6e;function dxt(){if(B6e)return iJ;B6e=1;var e=Eg().Graph,t=h7().slack;iJ=n;function n(i){var l=new e({directed:!1}),c=i.nodes()[0],u=i.nodeCount();l.setNode(c,{});for(var d,f;r(l,i)<u;)d=s(l,i),f=l.hasNode(d.v)?t(i,d):-t(i,d),a(l,i,f);return l}function r(i,l){function c(u){l.nodeEdges(u).forEach(d=>{var f=d.v,p=u===f?d.w:f;!i.hasNode(p)&&!t(l,d)&&(i.setNode(p,{}),i.setEdge(u,p,{}),c(p))})}return i.nodes().forEach(c),i.nodeCount()}function s(i,l){return l.edges().reduce((u,d)=>{let f=Number.POSITIVE_INFINITY;return i.hasNode(d.v)!==i.hasNode(d.w)&&(f=t(l,d)),f<u[0]?[f,d]:u},[Number.POSITIVE_INFINITY,null])[1]}function a(i,l,c){i.nodes().forEach(u=>l.node(u).rank+=c)}return iJ}var oJ,U6e;function Ezn(){if(U6e)return oJ;U6e=1;var e=dxt(),t=h7().slack,n=h7().longestPath,r=Eg().alg.preorder,s=Eg().alg.postorder,a=jl().simplify;oJ=i,i.initLowLimValues=d,i.initCutValues=l,i.calcCutValue=u,i.leaveEdge=p,i.enterEdge=h,i.exchangeEdges=m;function i(w){w=a(w),n(w);var S=e(w);d(S),l(S,w);for(var k,_;k=p(S);)_=h(S,w,k),m(S,w,k,_)}function l(w,S){var k=s(w,w.nodes());k=k.slice(0,k.length-1),k.forEach(_=>c(w,S,_))}function c(w,S,k){var _=w.node(k),C=_.parent;w.edge(k,C).cutvalue=u(w,S,k)}function u(w,S,k){var _=w.node(k),C=_.parent,E=!0,j=S.edge(k,C),N=0;return j||(E=!1,j=S.edge(C,k)),N=j.weight,S.nodeEdges(k).forEach(I=>{var R=I.v===k,$=R?I.w:I.v;if($!==C){var F=R===E,D=S.edge(I).weight;if(N+=F?D:-D,y(w,k,$)){var V=w.edge(k,$).cutvalue;N+=F?-V:V}}}),N}function d(w,S){arguments.length<2&&(S=w.nodes()[0]),f(w,{},1,S)}function f(w,S,k,_,C){var E=k,j=w.node(_);return S[_]=!0,w.neighbors(_).forEach(N=>{Object.hasOwn(S,N)||(k=f(w,S,k,N,_))}),j.low=E,j.lim=k++,C?j.parent=C:delete j.parent,k}function p(w){return w.edges().find(S=>w.edge(S).cutvalue<0)}function h(w,S,k){var _=k.v,C=k.w;S.hasEdge(_,C)||(_=k.w,C=k.v);var E=w.node(_),j=w.node(C),N=E,I=!1;E.lim>j.lim&&(N=j,I=!0);var R=S.edges().filter($=>I===b(w,w.node($.v),N)&&I!==b(w,w.node($.w),N));return R.reduce(($,F)=>t(S,F)<t(S,$)?F:$)}function m(w,S,k,_){var C=k.v,E=k.w;w.removeEdge(C,E),w.setEdge(_.v,_.w,{}),d(w),l(w,S),g(w,S)}function g(w,S){var k=w.nodes().find(C=>!S.node(C).parent),_=r(w,k);_=_.slice(1),_.forEach(C=>{var E=w.node(C).parent,j=S.edge(C,E),N=!1;j||(j=S.edge(E,C),N=!0),S.node(C).rank=S.node(E).rank+(N?j.minlen:-j.minlen)})}function y(w,S,k){return w.hasEdge(S,k)}function b(w,S,k){return k.low<=S.lim&&S.lim<=k.lim}return oJ}var lJ,q6e;function jzn(){if(q6e)return lJ;q6e=1;var e=h7(),t=e.longestPath,n=dxt(),r=Ezn();lJ=s;function s(c){var u=c.graph().ranker;if(u instanceof Function)return u(c);switch(c.graph().ranker){case"network-simplex":l(c);break;case"tight-tree":i(c);break;case"longest-path":a(c);break;case"none":break;default:l(c)}}var a=t;function i(c){t(c),n(c)}function l(c){r(c)}return lJ}var cJ,V6e;function Tzn(){if(V6e)return cJ;V6e=1,cJ=e;function e(r){let s=n(r);r.graph().dummyChains.forEach(a=>{let i=r.node(a),l=i.edgeObj,c=t(r,s,l.v,l.w),u=c.path,d=c.lca,f=0,p=u[f],h=!0;for(;a!==l.w;){if(i=r.node(a),h){for(;(p=u[f])!==d&&r.node(p).maxRank<i.rank;)f++;p===d&&(h=!1)}if(!h){for(;f<u.length-1&&r.node(p=u[f+1]).minRank<=i.rank;)f++;p=u[f]}r.setParent(a,p),a=r.successors(a)[0]}})}function t(r,s,a,i){let l=[],c=[],u=Math.min(s[a].low,s[i].low),d=Math.max(s[a].lim,s[i].lim),f,p;f=a;do f=r.parent(f),l.push(f);while(f&&(s[f].low>u||d>s[f].lim));for(p=f,f=i;(f=r.parent(f))!==p;)c.push(f);return{path:l.concat(c.reverse()),lca:p}}function n(r){let s={},a=0;function i(l){let c=a;r.children(l).forEach(i),s[l]={low:c,lim:a++}}return r.children().forEach(i),s}return cJ}var uJ,H6e;function Nzn(){if(H6e)return uJ;H6e=1;let e=jl();uJ={run:t,cleanup:a};function t(i){let l=e.addDummyNode(i,"root",{},"_root"),c=r(i),u=Object.values(c),d=e.applyWithChunking(Math.max,u)-1,f=2*d+1;i.graph().nestingRoot=l,i.edges().forEach(h=>i.edge(h).minlen*=f);let p=s(i)+1;i.children().forEach(h=>n(i,l,f,p,d,c,h)),i.graph().nodeRankFactor=f}function n(i,l,c,u,d,f,p){let h=i.children(p);if(!h.length){p!==l&&i.setEdge(l,p,{weight:0,minlen:c});return}let m=e.addBorderNode(i,"_bt"),g=e.addBorderNode(i,"_bb"),y=i.node(p);i.setParent(m,p),y.borderTop=m,i.setParent(g,p),y.borderBottom=g,h.forEach(b=>{n(i,l,c,u,d,f,b);let w=i.node(b),S=w.borderTop?w.borderTop:b,k=w.borderBottom?w.borderBottom:b,_=w.borderTop?u:2*u,C=S!==k?1:d-f[p]+1;i.setEdge(m,S,{weight:_,minlen:C,nestingEdge:!0}),i.setEdge(k,g,{weight:_,minlen:C,nestingEdge:!0})}),i.parent(p)||i.setEdge(l,m,{weight:0,minlen:d+f[p]})}function r(i){var l={};function c(u,d){var f=i.children(u);f&&f.length&&f.forEach(p=>c(p,d+1)),l[u]=d}return i.children().forEach(u=>c(u,1)),l}function s(i){return i.edges().reduce((l,c)=>l+i.edge(c).weight,0)}function a(i){var l=i.graph();i.removeNode(l.nestingRoot),delete l.nestingRoot,i.edges().forEach(c=>{var u=i.edge(c);u.nestingEdge&&i.removeEdge(c)})}return uJ}var dJ,W6e;function Izn(){if(W6e)return dJ;W6e=1;let e=jl();dJ=t;function t(r){function s(a){let i=r.children(a),l=r.node(a);if(i.length&&i.forEach(s),Object.hasOwn(l,"minRank")){l.borderLeft=[],l.borderRight=[];for(let c=l.minRank,u=l.maxRank+1;c<u;++c)n(r,"borderLeft","_bl",a,l,c),n(r,"borderRight","_br",a,l,c)}}r.children().forEach(s)}function n(r,s,a,i,l,c){let u={width:0,height:0,rank:c,borderType:s},d=l[s][c-1],f=e.addDummyNode(r,"border",u,a);l[s][c]=f,r.setParent(f,i),d&&r.setEdge(d,f,{weight:1})}return dJ}var fJ,Z6e;function Azn(){if(Z6e)return fJ;Z6e=1,fJ={adjust:e,undo:t};function e(c){let u=c.graph().rankdir.toLowerCase();(u==="lr"||u==="rl")&&n(c)}function t(c){let u=c.graph().rankdir.toLowerCase();(u==="bt"||u==="rl")&&s(c),(u==="lr"||u==="rl")&&(i(c),n(c))}function n(c){c.nodes().forEach(u=>r(c.node(u))),c.edges().forEach(u=>r(c.edge(u)))}function r(c){let u=c.width;c.width=c.height,c.height=u}function s(c){c.nodes().forEach(u=>a(c.node(u))),c.edges().forEach(u=>{let d=c.edge(u);d.points.forEach(a),Object.hasOwn(d,"y")&&a(d)})}function a(c){c.y=-c.y}function i(c){c.nodes().forEach(u=>l(c.node(u))),c.edges().forEach(u=>{let d=c.edge(u);d.points.forEach(l),Object.hasOwn(d,"x")&&l(d)})}function l(c){let u=c.x;c.x=c.y,c.y=u}return fJ}var pJ,G6e;function Rzn(){if(G6e)return pJ;G6e=1;let e=jl();pJ=t;function t(n){let r={},s=n.nodes().filter(d=>!n.children(d).length),a=s.map(d=>n.node(d).rank),i=e.applyWithChunking(Math.max,a),l=e.range(i+1).map(()=>[]);function c(d){if(r[d])return;r[d]=!0;let f=n.node(d);l[f.rank].push(d),n.successors(d).forEach(c)}return s.sort((d,f)=>n.node(d).rank-n.node(f).rank).forEach(c),l}return pJ}var hJ,Q6e;function Pzn(){if(Q6e)return hJ;Q6e=1;let e=jl().zipObject;hJ=t;function t(r,s){let a=0;for(let i=1;i<s.length;++i)a+=n(r,s[i-1],s[i]);return a}function n(r,s,a){let i=e(a,a.map((p,h)=>h)),l=s.flatMap(p=>r.outEdges(p).map(h=>({pos:i[h.w],weight:r.edge(h).weight})).sort((h,m)=>h.pos-m.pos)),c=1;for(;c<a.length;)c<<=1;let u=2*c-1;c-=1;let d=new Array(u).fill(0),f=0;return l.forEach(p=>{let h=p.pos+c;d[h]+=p.weight;let m=0;for(;h>0;)h%2&&(m+=d[h+1]),h=h-1>>1,d[h]+=p.weight;f+=p.weight*m}),f}return hJ}var mJ,Y6e;function $zn(){if(Y6e)return mJ;Y6e=1,mJ=e;function e(t,n=[]){return n.map(r=>{let s=t.inEdges(r);if(s.length){let a=s.reduce((i,l)=>{let c=t.edge(l),u=t.node(l.v);return{sum:i.sum+c.weight*u.order,weight:i.weight+c.weight}},{sum:0,weight:0});return{v:r,barycenter:a.sum/a.weight,weight:a.weight}}else return{v:r}})}return mJ}var gJ,X6e;function Mzn(){if(X6e)return gJ;X6e=1;let e=jl();gJ=t;function t(s,a){let i={};s.forEach((c,u)=>{let d=i[c.v]={indegree:0,in:[],out:[],vs:[c.v],i:u};c.barycenter!==void 0&&(d.barycenter=c.barycenter,d.weight=c.weight)}),a.edges().forEach(c=>{let u=i[c.v],d=i[c.w];u!==void 0&&d!==void 0&&(d.indegree++,u.out.push(i[c.w]))});let l=Object.values(i).filter(c=>!c.indegree);return n(l)}function n(s){let a=[];function i(c){return u=>{u.merged||(u.barycenter===void 0||c.barycenter===void 0||u.barycenter>=c.barycenter)&&r(c,u)}}function l(c){return u=>{u.in.push(c),--u.indegree===0&&s.push(u)}}for(;s.length;){let c=s.pop();a.push(c),c.in.reverse().forEach(i(c)),c.out.forEach(l(c))}return a.filter(c=>!c.merged).map(c=>e.pick(c,["vs","i","barycenter","weight"]))}function r(s,a){let i=0,l=0;s.weight&&(i+=s.barycenter*s.weight,l+=s.weight),a.weight&&(i+=a.barycenter*a.weight,l+=a.weight),s.vs=a.vs.concat(s.vs),s.barycenter=i/l,s.weight=l,s.i=Math.min(a.i,s.i),a.merged=!0}return gJ}var vJ,K6e;function Dzn(){if(K6e)return vJ;K6e=1;let e=jl();vJ=t;function t(s,a){let i=e.partition(s,m=>Object.hasOwn(m,"barycenter")),l=i.lhs,c=i.rhs.sort((m,g)=>g.i-m.i),u=[],d=0,f=0,p=0;l.sort(r(!!a)),p=n(u,c,p),l.forEach(m=>{p+=m.vs.length,u.push(m.vs),d+=m.barycenter*m.weight,f+=m.weight,p=n(u,c,p)});let h={vs:u.flat(!0)};return f&&(h.barycenter=d/f,h.weight=f),h}function n(s,a,i){let l;for(;a.length&&(l=a[a.length-1]).i<=i;)a.pop(),s.push(l.vs),i++;return i}function r(s){return(a,i)=>a.barycenter<i.barycenter?-1:a.barycenter>i.barycenter?1:s?i.i-a.i:a.i-i.i}return vJ}var yJ,J6e;function Lzn(){if(J6e)return yJ;J6e=1;let e=$zn(),t=Mzn(),n=Dzn();yJ=r;function r(i,l,c,u){let d=i.children(l),f=i.node(l),p=f?f.borderLeft:void 0,h=f?f.borderRight:void 0,m={};p&&(d=d.filter(w=>w!==p&&w!==h));let g=e(i,d);g.forEach(w=>{if(i.children(w.v).length){let S=r(i,w.v,c,u);m[w.v]=S,Object.hasOwn(S,"barycenter")&&a(w,S)}});let y=t(g,c);s(y,m);let b=n(y,u);if(p&&(b.vs=[p,b.vs,h].flat(!0),i.predecessors(p).length)){let w=i.node(i.predecessors(p)[0]),S=i.node(i.predecessors(h)[0]);Object.hasOwn(b,"barycenter")||(b.barycenter=0,b.weight=0),b.barycenter=(b.barycenter*b.weight+w.order+S.order)/(b.weight+2),b.weight+=2}return b}function s(i,l){i.forEach(c=>{c.vs=c.vs.flatMap(u=>l[u]?l[u].vs:u)})}function a(i,l){i.barycenter!==void 0?(i.barycenter=(i.barycenter*i.weight+l.barycenter*l.weight)/(i.weight+l.weight),i.weight+=l.weight):(i.barycenter=l.barycenter,i.weight=l.weight)}return yJ}var bJ,e8e;function Fzn(){if(e8e)return bJ;e8e=1;let e=Eg().Graph,t=jl();bJ=n;function n(s,a,i,l){l||(l=s.nodes());let c=r(s),u=new e({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(d=>s.node(d));return l.forEach(d=>{let f=s.node(d),p=s.parent(d);(f.rank===a||f.minRank<=a&&a<=f.maxRank)&&(u.setNode(d),u.setParent(d,p||c),s[i](d).forEach(h=>{let m=h.v===d?h.w:h.v,g=u.edge(m,d),y=g!==void 0?g.weight:0;u.setEdge(m,d,{weight:s.edge(h).weight+y})}),Object.hasOwn(f,"minRank")&&u.setNode(d,{borderLeft:f.borderLeft[a],borderRight:f.borderRight[a]}))}),u}function r(s){for(var a;s.hasNode(a=t.uniqueId("_root")););return a}return bJ}var xJ,t8e;function zzn(){if(t8e)return xJ;t8e=1,xJ=e;function e(t,n,r){let s={},a;r.forEach(i=>{let l=t.parent(i),c,u;for(;l;){if(c=t.parent(l),c?(u=s[c],s[c]=l):(u=a,a=l),u&&u!==l){n.setEdge(u,l);return}l=c}})}return xJ}var wJ,n8e;function Bzn(){if(n8e)return wJ;n8e=1;let e=Rzn(),t=Pzn(),n=Lzn(),r=Fzn(),s=zzn(),a=Eg().Graph,i=jl();wJ=l;function l(f,p){if(p&&typeof p.customOrder=="function"){p.customOrder(f,l);return}let h=i.maxRank(f),m=c(f,i.range(1,h+1),"inEdges"),g=c(f,i.range(h-1,-1,-1),"outEdges"),y=e(f);if(d(f,y),p&&p.disableOptimalOrderHeuristic)return;let b=Number.POSITIVE_INFINITY,w;for(let S=0,k=0;k<4;++S,++k){u(S%2?m:g,S%4>=2),y=i.buildLayerMatrix(f);let _=t(f,y);_<b&&(k=0,w=Object.assign({},y),b=_)}d(f,w)}function c(f,p,h){const m=new Map,g=(y,b)=>{m.has(y)||m.set(y,[]),m.get(y).push(b)};for(const y of f.nodes()){const b=f.node(y);if(typeof b.rank=="number"&&g(b.rank,y),typeof b.minRank=="number"&&typeof b.maxRank=="number")for(let w=b.minRank;w<=b.maxRank;w++)w!==b.rank&&g(w,y)}return p.map(function(y){return r(f,y,h,m.get(y)||[])})}function u(f,p){let h=new a;f.forEach(function(m){let g=m.graph().root,y=n(m,g,h,p);y.vs.forEach((b,w)=>m.node(b).order=w),s(m,h,y.vs)})}function d(f,p){Object.values(p).forEach(h=>h.forEach((m,g)=>f.node(m).order=g))}return wJ}var SJ,r8e;function Uzn(){if(r8e)return SJ;r8e=1;let e=Eg().Graph,t=jl();SJ={positionX:h,findType1Conflicts:n,findType2Conflicts:r,addConflict:a,hasConflict:i,verticalAlignment:l,horizontalCompaction:c,alignCoordinates:f,findSmallestWidthAlignment:d,balance:p};function n(y,b){let w={};function S(k,_){let C=0,E=0,j=k.length,N=_[_.length-1];return _.forEach((I,R)=>{let $=s(y,I),F=$?y.node($).order:j;($||I===N)&&(_.slice(E,R+1).forEach(D=>{y.predecessors(D).forEach(V=>{let W=y.node(V),L=W.order;(L<C||F<L)&&!(W.dummy&&y.node(D).dummy)&&a(w,V,D)})}),E=R+1,C=F)}),_}return b.length&&b.reduce(S),w}function r(y,b){let w={};function S(_,C,E,j,N){let I;t.range(C,E).forEach(R=>{I=_[R],y.node(I).dummy&&y.predecessors(I).forEach($=>{let F=y.node($);F.dummy&&(F.order<j||F.order>N)&&a(w,$,I)})})}function k(_,C){let E=-1,j,N=0;return C.forEach((I,R)=>{if(y.node(I).dummy==="border"){let $=y.predecessors(I);$.length&&(j=y.node($[0]).order,S(C,N,R,E,j),N=R,E=j)}S(C,N,C.length,j,_.length)}),C}return b.length&&b.reduce(k),w}function s(y,b){if(y.node(b).dummy)return y.predecessors(b).find(w=>y.node(w).dummy)}function a(y,b,w){if(b>w){let k=b;b=w,w=k}let S=y[b];S||(y[b]=S={}),S[w]=!0}function i(y,b,w){if(b>w){let S=b;b=w,w=S}return!!y[b]&&Object.hasOwn(y[b],w)}function l(y,b,w,S){let k={},_={},C={};return b.forEach(E=>{E.forEach((j,N)=>{k[j]=j,_[j]=j,C[j]=N})}),b.forEach(E=>{let j=-1;E.forEach(N=>{let I=S(N);if(I.length){I=I.sort(($,F)=>C[$]-C[F]);let R=(I.length-1)/2;for(let $=Math.floor(R),F=Math.ceil(R);$<=F;++$){let D=I[$];_[N]===N&&j<C[D]&&!i(w,N,D)&&(_[D]=N,_[N]=k[N]=k[D],j=C[D])}}})}),{root:k,align:_}}function c(y,b,w,S,k){let _={},C=u(y,b,w,k),E=k?"borderLeft":"borderRight";function j(R,$){let F=C.nodes(),D=F.pop(),V={};for(;D;)V[D]?R(D):(V[D]=!0,F.push(D),F=F.concat($(D))),D=F.pop()}function N(R){_[R]=C.inEdges(R).reduce(($,F)=>Math.max($,_[F.v]+C.edge(F)),0)}function I(R){let $=C.outEdges(R).reduce((D,V)=>Math.min(D,_[V.w]-C.edge(V)),Number.POSITIVE_INFINITY),F=y.node(R);$!==Number.POSITIVE_INFINITY&&F.borderType!==E&&(_[R]=Math.max(_[R],$))}return j(N,C.predecessors.bind(C)),j(I,C.successors.bind(C)),Object.keys(S).forEach(R=>_[R]=_[w[R]]),_}function u(y,b,w,S){let k=new e,_=y.graph(),C=m(_.nodesep,_.edgesep,S);return b.forEach(E=>{let j;E.forEach(N=>{let I=w[N];if(k.setNode(I),j){var R=w[j],$=k.edge(R,I);k.setEdge(R,I,Math.max(C(y,N,j),$||0))}j=N})}),k}function d(y,b){return Object.values(b).reduce((w,S)=>{let k=Number.NEGATIVE_INFINITY,_=Number.POSITIVE_INFINITY;Object.entries(S).forEach(([E,j])=>{let N=g(y,E)/2;k=Math.max(j+N,k),_=Math.min(j-N,_)});const C=k-_;return C<w[0]&&(w=[C,S]),w},[Number.POSITIVE_INFINITY,null])[1]}function f(y,b){let w=Object.values(b),S=t.applyWithChunking(Math.min,w),k=t.applyWithChunking(Math.max,w);["u","d"].forEach(_=>{["l","r"].forEach(C=>{let E=_+C,j=y[E];if(j===b)return;let N=Object.values(j),I=S-t.applyWithChunking(Math.min,N);C!=="l"&&(I=k-t.applyWithChunking(Math.max,N)),I&&(y[E]=t.mapValues(j,R=>R+I))})})}function p(y,b){return t.mapValues(y.ul,(w,S)=>{if(b)return y[b.toLowerCase()][S];{let k=Object.values(y).map(_=>_[S]).sort((_,C)=>_-C);return(k[1]+k[2])/2}})}function h(y){let b=t.buildLayerMatrix(y),w=Object.assign(n(y,b),r(y,b)),S={},k;["u","d"].forEach(C=>{k=C==="u"?b:Object.values(b).reverse(),["l","r"].forEach(E=>{E==="r"&&(k=k.map(R=>Object.values(R).reverse()));let j=(C==="u"?y.predecessors:y.successors).bind(y),N=l(y,k,w,j),I=c(y,k,N.root,N.align,E==="r");E==="r"&&(I=t.mapValues(I,R=>-R)),S[C+E]=I})});let _=d(y,S);return f(S,_),p(S,y.graph().align)}function m(y,b,w){return(S,k,_)=>{let C=S.node(k),E=S.node(_),j=0,N;if(j+=C.width/2,Object.hasOwn(C,"labelpos"))switch(C.labelpos.toLowerCase()){case"l":N=-C.width/2;break;case"r":N=C.width/2;break}if(N&&(j+=w?N:-N),N=0,j+=(C.dummy?b:y)/2,j+=(E.dummy?b:y)/2,j+=E.width/2,Object.hasOwn(E,"labelpos"))switch(E.labelpos.toLowerCase()){case"l":N=E.width/2;break;case"r":N=-E.width/2;break}return N&&(j+=w?N:-N),N=0,j}}function g(y,b){return y.node(b).width}return SJ}var kJ,s8e;function qzn(){if(s8e)return kJ;s8e=1;let e=jl(),t=Uzn().positionX;kJ=n;function n(s){s=e.asNonCompoundGraph(s),r(s),Object.entries(t(s)).forEach(([a,i])=>s.node(a).x=i)}function r(s){let a=e.buildLayerMatrix(s),i=s.graph().ranksep,l=0;a.forEach(c=>{const u=c.reduce((d,f)=>{const p=s.node(f).height;return d>p?d:p},0);c.forEach(d=>s.node(d).y=l+u/2),l+=u+i})}return kJ}var OJ,a8e;function Vzn(){if(a8e)return OJ;a8e=1;let e=_zn(),t=Czn(),n=jzn(),r=jl().normalizeRanks,s=Tzn(),a=jl().removeEmptyRanks,i=Nzn(),l=Izn(),c=Azn(),u=Bzn(),d=qzn(),f=jl(),p=Eg().Graph;OJ=h;function h(P,q){let Z=q&&q.debugTiming?f.time:f.notime;Z("layout",()=>{let X=Z(" buildLayoutGraph",()=>j(P));Z(" runLayout",()=>m(X,Z,q)),Z(" updateInputGraph",()=>g(P,X))})}function m(P,q,Z){q(" makeSpaceForEdgeLabels",()=>N(P)),q(" removeSelfEdges",()=>z(P)),q(" acyclic",()=>e.run(P)),q(" nestingGraph.run",()=>i.run(P)),q(" rank",()=>n(f.asNonCompoundGraph(P))),q(" injectEdgeLabelProxies",()=>I(P)),q(" removeEmptyRanks",()=>a(P)),q(" nestingGraph.cleanup",()=>i.cleanup(P)),q(" normalizeRanks",()=>r(P)),q(" assignRankMinMax",()=>R(P)),q(" removeEdgeLabelProxies",()=>$(P)),q(" normalize.run",()=>t.run(P)),q(" parentDummyChains",()=>s(P)),q(" addBorderSegments",()=>l(P)),q(" order",()=>u(P,Z)),q(" insertSelfEdges",()=>B(P)),q(" adjustCoordinateSystem",()=>c.adjust(P)),q(" position",()=>d(P)),q(" positionSelfEdges",()=>M(P)),q(" removeBorderNodes",()=>L(P)),q(" normalize.undo",()=>t.undo(P)),q(" fixupEdgeLabelCoords",()=>V(P)),q(" undoCoordinateSystem",()=>c.undo(P)),q(" translateGraph",()=>F(P)),q(" assignNodeIntersects",()=>D(P)),q(" reversePoints",()=>W(P)),q(" acyclic.undo",()=>e.undo(P))}function g(P,q){P.nodes().forEach(Z=>{let X=P.node(Z),te=q.node(Z);X&&(X.x=te.x,X.y=te.y,X.rank=te.rank,q.children(Z).length&&(X.width=te.width,X.height=te.height))}),P.edges().forEach(Z=>{let X=P.edge(Z),te=q.edge(Z);X.points=te.points,Object.hasOwn(te,"x")&&(X.x=te.x,X.y=te.y)}),P.graph().width=q.graph().width,P.graph().height=q.graph().height}let y=["nodesep","edgesep","ranksep","marginx","marginy"],b={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},w=["acyclicer","ranker","rankdir","align"],S=["width","height","rank"],k={width:0,height:0},_=["minlen","weight","width","height","labeloffset"],C={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},E=["labelpos"];function j(P){let q=new p({multigraph:!0,compound:!0}),Z=U(P.graph());return q.setGraph(Object.assign({},b,G(Z,y),f.pick(Z,w))),P.nodes().forEach(X=>{let te=U(P.node(X));const J=G(te,S);Object.keys(k).forEach(ee=>{J[ee]===void 0&&(J[ee]=k[ee])}),q.setNode(X,J),q.setParent(X,P.parent(X))}),P.edges().forEach(X=>{let te=U(P.edge(X));q.setEdge(X,Object.assign({},C,G(te,_),f.pick(te,E)))}),q}function N(P){let q=P.graph();q.ranksep/=2,P.edges().forEach(Z=>{let X=P.edge(Z);X.minlen*=2,X.labelpos.toLowerCase()!=="c"&&(q.rankdir==="TB"||q.rankdir==="BT"?X.width+=X.labeloffset:X.height+=X.labeloffset)})}function I(P){P.edges().forEach(q=>{let Z=P.edge(q);if(Z.width&&Z.height){let X=P.node(q.v),J={rank:(P.node(q.w).rank-X.rank)/2+X.rank,e:q};f.addDummyNode(P,"edge-proxy",J,"_ep")}})}function R(P){let q=0;P.nodes().forEach(Z=>{let X=P.node(Z);X.borderTop&&(X.minRank=P.node(X.borderTop).rank,X.maxRank=P.node(X.borderBottom).rank,q=Math.max(q,X.maxRank))}),P.graph().maxRank=q}function $(P){P.nodes().forEach(q=>{let Z=P.node(q);Z.dummy==="edge-proxy"&&(P.edge(Z.e).labelRank=Z.rank,P.removeNode(q))})}function F(P){let q=Number.POSITIVE_INFINITY,Z=0,X=Number.POSITIVE_INFINITY,te=0,J=P.graph(),ee=J.marginx||0,ae=J.marginy||0;function de(Y){let ne=Y.x,ce=Y.y,pe=Y.width,le=Y.height;q=Math.min(q,ne-pe/2),Z=Math.max(Z,ne+pe/2),X=Math.min(X,ce-le/2),te=Math.max(te,ce+le/2)}P.nodes().forEach(Y=>de(P.node(Y))),P.edges().forEach(Y=>{let ne=P.edge(Y);Object.hasOwn(ne,"x")&&de(ne)}),q-=ee,X-=ae,P.nodes().forEach(Y=>{let ne=P.node(Y);ne.x-=q,ne.y-=X}),P.edges().forEach(Y=>{let ne=P.edge(Y);ne.points.forEach(ce=>{ce.x-=q,ce.y-=X}),Object.hasOwn(ne,"x")&&(ne.x-=q),Object.hasOwn(ne,"y")&&(ne.y-=X)}),J.width=Z-q+ee,J.height=te-X+ae}function D(P){P.edges().forEach(q=>{let Z=P.edge(q),X=P.node(q.v),te=P.node(q.w),J,ee;Z.points?(J=Z.points[0],ee=Z.points[Z.points.length-1]):(Z.points=[],J=te,ee=X),Z.points.unshift(f.intersectRect(X,J)),Z.points.push(f.intersectRect(te,ee))})}function V(P){P.edges().forEach(q=>{let Z=P.edge(q);if(Object.hasOwn(Z,"x"))switch((Z.labelpos==="l"||Z.labelpos==="r")&&(Z.width-=Z.labeloffset),Z.labelpos){case"l":Z.x-=Z.width/2+Z.labeloffset;break;case"r":Z.x+=Z.width/2+Z.labeloffset;break}})}function W(P){P.edges().forEach(q=>{let Z=P.edge(q);Z.reversed&&Z.points.reverse()})}function L(P){P.nodes().forEach(q=>{if(P.children(q).length){let Z=P.node(q),X=P.node(Z.borderTop),te=P.node(Z.borderBottom),J=P.node(Z.borderLeft[Z.borderLeft.length-1]),ee=P.node(Z.borderRight[Z.borderRight.length-1]);Z.width=Math.abs(ee.x-J.x),Z.height=Math.abs(te.y-X.y),Z.x=J.x+Z.width/2,Z.y=X.y+Z.height/2}}),P.nodes().forEach(q=>{P.node(q).dummy==="border"&&P.removeNode(q)})}function z(P){P.edges().forEach(q=>{if(q.v===q.w){var Z=P.node(q.v);Z.selfEdges||(Z.selfEdges=[]),Z.selfEdges.push({e:q,label:P.edge(q)}),P.removeEdge(q)}})}function B(P){var q=f.buildLayerMatrix(P);q.forEach(Z=>{var X=0;Z.forEach((te,J)=>{var ee=P.node(te);ee.order=J+X,(ee.selfEdges||[]).forEach(ae=>{f.addDummyNode(P,"selfedge",{width:ae.label.width,height:ae.label.height,rank:ee.rank,order:J+ ++X,e:ae.e,label:ae.label},"_se")}),delete ee.selfEdges})})}function M(P){P.nodes().forEach(q=>{var Z=P.node(q);if(Z.dummy==="selfedge"){var X=P.node(Z.e.v),te=X.x+X.width/2,J=X.y,ee=Z.x-te,ae=X.height/2;P.setEdge(Z.e,Z.label),P.removeNode(q),Z.label.points=[{x:te+2*ee/3,y:J-ae},{x:te+5*ee/6,y:J-ae},{x:te+ee,y:J},{x:te+5*ee/6,y:J+ae},{x:te+2*ee/3,y:J+ae}],Z.label.x=Z.x,Z.label.y=Z.y}})}function G(P,q){return f.mapValues(f.pick(P,q),Number)}function U(P){var q={};return P&&Object.entries(P).forEach(([Z,X])=>{typeof Z=="string"&&(Z=Z.toLowerCase()),q[Z]=X}),q}return OJ}var _J,i8e;function Hzn(){if(i8e)return _J;i8e=1;let e=jl(),t=Eg().Graph;_J={debugOrdering:n};function n(r){let s=e.buildLayerMatrix(r),a=new t({compound:!0,multigraph:!0}).setGraph({});return r.nodes().forEach(i=>{a.setNode(i,{label:i}),a.setParent(i,"layer"+r.node(i).rank)}),r.edges().forEach(i=>a.setEdge(i.v,i.w,{},i.name)),s.forEach((i,l)=>{let c="layer"+l;a.setNode(c,{rank:"same"}),i.reduce((u,d)=>(a.setEdge(u,d,{style:"invis"}),d))}),a}return _J}var CJ,o8e;function Wzn(){return o8e||(o8e=1,CJ="1.1.8"),CJ}var EJ,l8e;function Zzn(){return l8e||(l8e=1,EJ={graphlib:Eg(),layout:Vzn(),debug:Hzn(),util:{time:jl().time,notime:jl().notime},version:Wzn()}),EJ}var Gzn=Zzn();const c8e=Cc(Gzn);function Pl(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=Pl(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Qzn={value:()=>{}};function mV(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new D9(n)}function D9(e){this._=e}function Yzn(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",s=n.indexOf(".");if(s>=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}D9.prototype=mV.prototype={constructor:D9,on:function(e,t){var n=this._,r=Yzn(e+"",n),s,a=-1,i=r.length;if(arguments.length<2){for(;++a<i;)if((s=(e=r[a]).type)&&(s=Xzn(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++a<i;)if(s=(e=r[a]).type)n[s]=u8e(n[s],e.name,t);else if(t==null)for(s in n)n[s]=u8e(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new D9(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,a;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],r=0,s=a.length;r<s;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],s=0,a=r.length;s<a;++s)r[s].value.apply(t,n)}};function Xzn(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function u8e(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=Qzn,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var ohe="http://www.w3.org/1999/xhtml";const d8e={svg:"http://www.w3.org/2000/svg",xhtml:ohe,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function gV(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),d8e.hasOwnProperty(t)?{space:d8e[t],local:e}:e}function Kzn(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===ohe&&t.documentElement.namespaceURI===ohe?t.createElement(e):t.createElementNS(n,e)}}function Jzn(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function fxt(e){var t=gV(e);return(t.local?Jzn:Kzn)(t)}function e7n(){}function Jwe(e){return e==null?e7n:function(){return this.querySelector(e)}}function t7n(e){typeof e!="function"&&(e=Jwe(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=r[s]=new Array(i),c,u,d=0;d<i;++d)(c=a[d])&&(u=e.call(c,c.__data__,d,a))&&("__data__"in c&&(u.__data__=c.__data__),l[d]=u);return new Dp(r,this._parents)}function n7n(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function r7n(){return[]}function pxt(e){return e==null?r7n:function(){return this.querySelectorAll(e)}}function s7n(e){return function(){return n7n(e.apply(this,arguments))}}function a7n(e){typeof e=="function"?e=s7n(e):e=pxt(e);for(var t=this._groups,n=t.length,r=[],s=[],a=0;a<n;++a)for(var i=t[a],l=i.length,c,u=0;u<l;++u)(c=i[u])&&(r.push(e.call(c,c.__data__,u,i)),s.push(c));return new Dp(r,s)}function hxt(e){return function(){return this.matches(e)}}function mxt(e){return function(t){return t.matches(e)}}var i7n=Array.prototype.find;function o7n(e){return function(){return i7n.call(this.children,e)}}function l7n(){return this.firstElementChild}function c7n(e){return this.select(e==null?l7n:o7n(typeof e=="function"?e:mxt(e)))}var u7n=Array.prototype.filter;function d7n(){return Array.from(this.children)}function f7n(e){return function(){return u7n.call(this.children,e)}}function p7n(e){return this.selectAll(e==null?d7n:f7n(typeof e=="function"?e:mxt(e)))}function h7n(e){typeof e!="function"&&(e=hxt(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=r[s]=[],c,u=0;u<i;++u)(c=a[u])&&e.call(c,c.__data__,u,a)&&l.push(c);return new Dp(r,this._parents)}function gxt(e){return new Array(e.length)}function m7n(){return new Dp(this._enter||this._groups.map(gxt),this._parents)}function m7(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}m7.prototype={constructor:m7,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function g7n(e){return function(){return e}}function v7n(e,t,n,r,s,a){for(var i=0,l,c=t.length,u=a.length;i<u;++i)(l=t[i])?(l.__data__=a[i],r[i]=l):n[i]=new m7(e,a[i]);for(;i<c;++i)(l=t[i])&&(s[i]=l)}function y7n(e,t,n,r,s,a,i){var l,c,u=new Map,d=t.length,f=a.length,p=new Array(d),h;for(l=0;l<d;++l)(c=t[l])&&(p[l]=h=i.call(c,c.__data__,l,t)+"",u.has(h)?s[l]=c:u.set(h,c));for(l=0;l<f;++l)h=i.call(e,a[l],l,a)+"",(c=u.get(h))?(r[l]=c,c.__data__=a[l],u.delete(h)):n[l]=new m7(e,a[l]);for(l=0;l<d;++l)(c=t[l])&&u.get(p[l])===c&&(s[l]=c)}function b7n(e){return e.__data__}function x7n(e,t){if(!arguments.length)return Array.from(this,b7n);var n=t?y7n:v7n,r=this._parents,s=this._groups;typeof e!="function"&&(e=g7n(e));for(var a=s.length,i=new Array(a),l=new Array(a),c=new Array(a),u=0;u<a;++u){var d=r[u],f=s[u],p=f.length,h=w7n(e.call(d,d&&d.__data__,u,r)),m=h.length,g=l[u]=new Array(m),y=i[u]=new Array(m),b=c[u]=new Array(p);n(d,f,g,y,b,h,t);for(var w=0,S=0,k,_;w<m;++w)if(k=g[w]){for(w>=S&&(S=w+1);!(_=y[S])&&++S<m;);k._next=_||null}}return i=new Dp(i,r),i._enter=l,i._exit=c,i}function w7n(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function S7n(){return new Dp(this._exit||this._groups.map(gxt),this._parents)}function k7n(e,t,n){var r=this.enter(),s=this,a=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?a.remove():n(a),r&&s?r.merge(s).order():s}function O7n(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,a=r.length,i=Math.min(s,a),l=new Array(s),c=0;c<i;++c)for(var u=n[c],d=r[c],f=u.length,p=l[c]=new Array(f),h,m=0;m<f;++m)(h=u[m]||d[m])&&(p[m]=h);for(;c<s;++c)l[c]=n[c];return new Dp(l,this._parents)}function _7n(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],s=r.length-1,a=r[s],i;--s>=0;)(i=r[s])&&(a&&i.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(i,a),a=i);return this}function C7n(e){e||(e=E7n);function t(f,p){return f&&p?e(f.__data__,p.__data__):!f-!p}for(var n=this._groups,r=n.length,s=new Array(r),a=0;a<r;++a){for(var i=n[a],l=i.length,c=s[a]=new Array(l),u,d=0;d<l;++d)(u=i[d])&&(c[d]=u);c.sort(t)}return new Dp(s,this._parents).order()}function E7n(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function j7n(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function T7n(){return Array.from(this)}function N7n(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,a=r.length;s<a;++s){var i=r[s];if(i)return i}return null}function I7n(){let e=0;for(const t of this)++e;return e}function A7n(){return!this.node()}function R7n(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var s=t[n],a=0,i=s.length,l;a<i;++a)(l=s[a])&&e.call(l,l.__data__,a,s);return this}function P7n(e){return function(){this.removeAttribute(e)}}function $7n(e){return function(){this.removeAttributeNS(e.space,e.local)}}function M7n(e,t){return function(){this.setAttribute(e,t)}}function D7n(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function L7n(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function F7n(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function z7n(e,t){var n=gV(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?$7n:P7n:typeof t=="function"?n.local?F7n:L7n:n.local?D7n:M7n)(n,t))}function vxt(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function B7n(e){return function(){this.style.removeProperty(e)}}function U7n(e,t,n){return function(){this.style.setProperty(e,t,n)}}function q7n(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function V7n(e,t,n){return arguments.length>1?this.each((t==null?B7n:typeof t=="function"?q7n:U7n)(e,t,n??"")):hT(this.node(),e)}function hT(e,t){return e.style.getPropertyValue(t)||vxt(e).getComputedStyle(e,null).getPropertyValue(t)}function H7n(e){return function(){delete this[e]}}function W7n(e,t){return function(){this[e]=t}}function Z7n(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function G7n(e,t){return arguments.length>1?this.each((t==null?H7n:typeof t=="function"?Z7n:W7n)(e,t)):this.node()[e]}function yxt(e){return e.trim().split(/^|\s+/)}function e1e(e){return e.classList||new bxt(e)}function bxt(e){this._node=e,this._names=yxt(e.getAttribute("class")||"")}bxt.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function xxt(e,t){for(var n=e1e(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function wxt(e,t){for(var n=e1e(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function Q7n(e){return function(){xxt(this,e)}}function Y7n(e){return function(){wxt(this,e)}}function X7n(e,t){return function(){(t.apply(this,arguments)?xxt:wxt)(this,e)}}function K7n(e,t){var n=yxt(e+"");if(arguments.length<2){for(var r=e1e(this.node()),s=-1,a=n.length;++s<a;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?X7n:t?Q7n:Y7n)(n,t))}function J7n(){this.textContent=""}function eBn(e){return function(){this.textContent=e}}function tBn(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function nBn(e){return arguments.length?this.each(e==null?J7n:(typeof e=="function"?tBn:eBn)(e)):this.node().textContent}function rBn(){this.innerHTML=""}function sBn(e){return function(){this.innerHTML=e}}function aBn(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function iBn(e){return arguments.length?this.each(e==null?rBn:(typeof e=="function"?aBn:sBn)(e)):this.node().innerHTML}function oBn(){this.nextSibling&&this.parentNode.appendChild(this)}function lBn(){return this.each(oBn)}function cBn(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function uBn(){return this.each(cBn)}function dBn(e){var t=typeof e=="function"?e:fxt(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function fBn(){return null}function pBn(e,t){var n=typeof e=="function"?e:fxt(e),r=t==null?fBn:typeof t=="function"?t:Jwe(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function hBn(){var e=this.parentNode;e&&e.removeChild(this)}function mBn(){return this.each(hBn)}function gBn(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function vBn(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function yBn(e){return this.select(e?vBn:gBn)}function bBn(e){return arguments.length?this.property("__data__",e):this.node().__data__}function xBn(e){return function(t){e.call(this,t,this.__data__)}}function wBn(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function SBn(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,a;n<s;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function kBn(e,t,n){return function(){var r=this.__on,s,a=xBn(t);if(r){for(var i=0,l=r.length;i<l;++i)if((s=r[i]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=a,s.options=n),s.value=t;return}}this.addEventListener(e.type,a,n),s={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(s):this.__on=[s]}}function OBn(e,t,n){var r=wBn(e+""),s,a=r.length,i;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,u=l.length,d;c<u;++c)for(s=0,d=l[c];s<a;++s)if((i=r[s]).type===d.type&&i.name===d.name)return d.value}return}for(l=t?kBn:SBn,s=0;s<a;++s)this.each(l(r[s],t,n));return this}function Sxt(e,t,n){var r=vxt(e),s=r.CustomEvent;typeof s=="function"?s=new s(t,n):(s=r.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function _Bn(e,t){return function(){return Sxt(this,e,t)}}function CBn(e,t){return function(){return Sxt(this,e,t.apply(this,arguments))}}function EBn(e,t){return this.each((typeof t=="function"?CBn:_Bn)(e,t))}function*jBn(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,a=r.length,i;s<a;++s)(i=r[s])&&(yield i)}var kxt=[null];function Dp(e,t){this._groups=e,this._parents=t}function aD(){return new Dp([[document.documentElement]],kxt)}function TBn(){return this}Dp.prototype=aD.prototype={constructor:Dp,select:t7n,selectAll:a7n,selectChild:c7n,selectChildren:p7n,filter:h7n,data:x7n,enter:m7n,exit:S7n,join:k7n,merge:O7n,selection:TBn,order:_7n,sort:C7n,call:j7n,nodes:T7n,node:N7n,size:I7n,empty:A7n,each:R7n,attr:z7n,style:V7n,property:G7n,classed:K7n,text:nBn,html:iBn,raise:lBn,lower:uBn,append:dBn,insert:pBn,remove:mBn,clone:yBn,datum:bBn,on:OBn,dispatch:EBn,[Symbol.iterator]:jBn};function fp(e){return typeof e=="string"?new Dp([[document.querySelector(e)]],[document.documentElement]):new Dp([[e]],kxt)}function NBn(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Xm(e,t){if(e=NBn(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const IBn={passive:!1},Z$={capture:!0,passive:!1};function jJ(e){e.stopImmediatePropagation()}function bj(e){e.preventDefault(),e.stopImmediatePropagation()}function Oxt(e){var t=e.document.documentElement,n=fp(e).on("dragstart.drag",bj,Z$);"onselectstart"in t?n.on("selectstart.drag",bj,Z$):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function _xt(e,t){var n=e.document.documentElement,r=fp(e).on("dragstart.drag",null);t&&(r.on("click.drag",bj,Z$),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const h6=e=>()=>e;function lhe(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:a,x:i,y:l,dx:c,dy:u,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}lhe.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function ABn(e){return!e.ctrlKey&&!e.button}function RBn(){return this.parentNode}function PBn(e,t){return t??{x:e.x,y:e.y}}function $Bn(){return navigator.maxTouchPoints||"ontouchstart"in this}function Cxt(){var e=ABn,t=RBn,n=PBn,r=$Bn,s={},a=mV("start","drag","end"),i=0,l,c,u,d,f=0;function p(k){k.on("mousedown.drag",h).filter(r).on("touchstart.drag",y).on("touchmove.drag",b,IBn).on("touchend.drag touchcancel.drag",w).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(k,_){if(!(d||!e.call(this,k,_))){var C=S(this,t.call(this,k,_),k,_,"mouse");C&&(fp(k.view).on("mousemove.drag",m,Z$).on("mouseup.drag",g,Z$),Oxt(k.view),jJ(k),u=!1,l=k.clientX,c=k.clientY,C("start",k))}}function m(k){if(bj(k),!u){var _=k.clientX-l,C=k.clientY-c;u=_*_+C*C>f}s.mouse("drag",k)}function g(k){fp(k.view).on("mousemove.drag mouseup.drag",null),_xt(k.view,u),bj(k),s.mouse("end",k)}function y(k,_){if(e.call(this,k,_)){var C=k.changedTouches,E=t.call(this,k,_),j=C.length,N,I;for(N=0;N<j;++N)(I=S(this,E,k,_,C[N].identifier,C[N]))&&(jJ(k),I("start",k,C[N]))}}function b(k){var _=k.changedTouches,C=_.length,E,j;for(E=0;E<C;++E)(j=s[_[E].identifier])&&(bj(k),j("drag",k,_[E]))}function w(k){var _=k.changedTouches,C=_.length,E,j;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),E=0;E<C;++E)(j=s[_[E].identifier])&&(jJ(k),j("end",k,_[E]))}function S(k,_,C,E,j,N){var I=a.copy(),R=Xm(N||C,_),$,F,D;if((D=n.call(k,new lhe("beforestart",{sourceEvent:C,target:p,identifier:j,active:i,x:R[0],y:R[1],dx:0,dy:0,dispatch:I}),E))!=null)return $=D.x-R[0]||0,F=D.y-R[1]||0,function V(W,L,z){var B=R,M;switch(W){case"start":s[j]=V,M=i++;break;case"end":delete s[j],--i;case"drag":R=Xm(z||L,_),M=i;break}I.call(W,k,new lhe(W,{sourceEvent:L,subject:D,target:p,identifier:j,active:M,x:R[0]+$,y:R[1]+F,dx:R[0]-B[0],dy:R[1]-B[1],dispatch:I}),E)}}return p.filter=function(k){return arguments.length?(e=typeof k=="function"?k:h6(!!k),p):e},p.container=function(k){return arguments.length?(t=typeof k=="function"?k:h6(k),p):t},p.subject=function(k){return arguments.length?(n=typeof k=="function"?k:h6(k),p):n},p.touchable=function(k){return arguments.length?(r=typeof k=="function"?k:h6(!!k),p):r},p.on=function(){var k=a.on.apply(a,arguments);return k===a?p:k},p.clickDistance=function(k){return arguments.length?(f=(k=+k)*k,p):Math.sqrt(f)},p}function t1e(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Ext(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function iD(){}var G$=.7,g7=1/G$,xj="\\s*([+-]?\\d+)\\s*",Q$="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Xv="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",MBn=/^#([0-9a-f]{3,8})$/,DBn=new RegExp(`^rgb\\(${xj},${xj},${xj}\\)$`),LBn=new RegExp(`^rgb\\(${Xv},${Xv},${Xv}\\)$`),FBn=new RegExp(`^rgba\\(${xj},${xj},${xj},${Q$}\\)$`),zBn=new RegExp(`^rgba\\(${Xv},${Xv},${Xv},${Q$}\\)$`),BBn=new RegExp(`^hsl\\(${Q$},${Xv},${Xv}\\)$`),UBn=new RegExp(`^hsla\\(${Q$},${Xv},${Xv},${Q$}\\)$`),f8e={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};t1e(iD,jO,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:p8e,formatHex:p8e,formatHex8:qBn,formatHsl:VBn,formatRgb:h8e,toString:h8e});function p8e(){return this.rgb().formatHex()}function qBn(){return this.rgb().formatHex8()}function VBn(){return jxt(this).formatHsl()}function h8e(){return this.rgb().formatRgb()}function jO(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=MBn.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?m8e(t):n===3?new Xd(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?m6(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?m6(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=DBn.exec(e))?new Xd(t[1],t[2],t[3],1):(t=LBn.exec(e))?new Xd(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=FBn.exec(e))?m6(t[1],t[2],t[3],t[4]):(t=zBn.exec(e))?m6(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=BBn.exec(e))?y8e(t[1],t[2]/100,t[3]/100,1):(t=UBn.exec(e))?y8e(t[1],t[2]/100,t[3]/100,t[4]):f8e.hasOwnProperty(e)?m8e(f8e[e]):e==="transparent"?new Xd(NaN,NaN,NaN,0):null}function m8e(e){return new Xd(e>>16&255,e>>8&255,e&255,1)}function m6(e,t,n,r){return r<=0&&(e=t=n=NaN),new Xd(e,t,n,r)}function HBn(e){return e instanceof iD||(e=jO(e)),e?(e=e.rgb(),new Xd(e.r,e.g,e.b,e.opacity)):new Xd}function che(e,t,n,r){return arguments.length===1?HBn(e):new Xd(e,t,n,r??1)}function Xd(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}t1e(Xd,che,Ext(iD,{brighter(e){return e=e==null?g7:Math.pow(g7,e),new Xd(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?G$:Math.pow(G$,e),new Xd(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Xd(zk(this.r),zk(this.g),zk(this.b),v7(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:g8e,formatHex:g8e,formatHex8:WBn,formatRgb:v8e,toString:v8e}));function g8e(){return`#${_k(this.r)}${_k(this.g)}${_k(this.b)}`}function WBn(){return`#${_k(this.r)}${_k(this.g)}${_k(this.b)}${_k((isNaN(this.opacity)?1:this.opacity)*255)}`}function v8e(){const e=v7(this.opacity);return`${e===1?"rgb(":"rgba("}${zk(this.r)}, ${zk(this.g)}, ${zk(this.b)}${e===1?")":`, ${e})`}`}function v7(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function zk(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function _k(e){return e=zk(e),(e<16?"0":"")+e.toString(16)}function y8e(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new rg(e,t,n,r)}function jxt(e){if(e instanceof rg)return new rg(e.h,e.s,e.l,e.opacity);if(e instanceof iD||(e=jO(e)),!e)return new rg;if(e instanceof rg)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),a=Math.max(t,n,r),i=NaN,l=a-s,c=(a+s)/2;return l?(t===a?i=(n-r)/l+(n<r)*6:n===a?i=(r-t)/l+2:i=(t-n)/l+4,l/=c<.5?a+s:2-a-s,i*=60):l=c>0&&c<1?0:i,new rg(i,l,c,e.opacity)}function ZBn(e,t,n,r){return arguments.length===1?jxt(e):new rg(e,t,n,r??1)}function rg(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}t1e(rg,ZBn,Ext(iD,{brighter(e){return e=e==null?g7:Math.pow(g7,e),new rg(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?G$:Math.pow(G$,e),new rg(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,s=2*n-r;return new Xd(TJ(e>=240?e-240:e+120,s,r),TJ(e,s,r),TJ(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new rg(b8e(this.h),g6(this.s),g6(this.l),v7(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=v7(this.opacity);return`${e===1?"hsl(":"hsla("}${b8e(this.h)}, ${g6(this.s)*100}%, ${g6(this.l)*100}%${e===1?")":`, ${e})`}`}}));function b8e(e){return e=(e||0)%360,e<0?e+360:e}function g6(e){return Math.max(0,Math.min(1,e||0))}function TJ(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const n1e=e=>()=>e;function GBn(e,t){return function(n){return e+n*t}}function QBn(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function YBn(e){return(e=+e)==1?Txt:function(t,n){return n-t?QBn(t,n,e):n1e(isNaN(t)?n:t)}}function Txt(e,t){var n=t-e;return n?GBn(e,n):n1e(isNaN(e)?t:e)}const y7=(function e(t){var n=YBn(t);function r(s,a){var i=n((s=che(s)).r,(a=che(a)).r),l=n(s.g,a.g),c=n(s.b,a.b),u=Txt(s.opacity,a.opacity);return function(d){return s.r=i(d),s.g=l(d),s.b=c(d),s.opacity=u(d),s+""}}return r.gamma=e,r})(1);function XBn(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),s;return function(a){for(s=0;s<n;++s)r[s]=e[s]*(1-a)+t[s]*a;return r}}function KBn(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function JBn(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,s=new Array(r),a=new Array(n),i;for(i=0;i<r;++i)s[i]=rx(e[i],t[i]);for(;i<n;++i)a[i]=t[i];return function(l){for(i=0;i<r;++i)a[i]=s[i](l);return a}}function eUn(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Jm(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function tUn(e,t){var n={},r={},s;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in e?n[s]=rx(e[s],t[s]):r[s]=t[s];return function(a){for(s in n)r[s]=n[s](a);return r}}var uhe=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,NJ=new RegExp(uhe.source,"g");function nUn(e){return function(){return e}}function rUn(e){return function(t){return e(t)+""}}function Nxt(e,t){var n=uhe.lastIndex=NJ.lastIndex=0,r,s,a,i=-1,l=[],c=[];for(e=e+"",t=t+"";(r=uhe.exec(e))&&(s=NJ.exec(t));)(a=s.index)>n&&(a=t.slice(n,a),l[i]?l[i]+=a:l[++i]=a),(r=r[0])===(s=s[0])?l[i]?l[i]+=s:l[++i]=s:(l[++i]=null,c.push({i,x:Jm(r,s)})),n=NJ.lastIndex;return n<t.length&&(a=t.slice(n),l[i]?l[i]+=a:l[++i]=a),l.length<2?c[0]?rUn(c[0].x):nUn(t):(t=c.length,function(u){for(var d=0,f;d<t;++d)l[(f=c[d]).i]=f.x(u);return l.join("")})}function rx(e,t){var n=typeof t,r;return t==null||n==="boolean"?n1e(t):(n==="number"?Jm:n==="string"?(r=jO(t))?(t=r,y7):Nxt:t instanceof jO?y7:t instanceof Date?eUn:KBn(t)?XBn:Array.isArray(t)?JBn:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?tUn:Jm)(e,t)}function r1e(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var x8e=180/Math.PI,dhe={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ixt(e,t,n,r,s,a){var i,l,c;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(l=Math.sqrt(n*n+r*r))&&(n/=l,r/=l,c/=l),e*r<t*n&&(e=-e,t=-t,c=-c,i=-i),{translateX:s,translateY:a,rotate:Math.atan2(t,e)*x8e,skewX:Math.atan(c)*x8e,scaleX:i,scaleY:l}}var v6;function sUn(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?dhe:Ixt(t.a,t.b,t.c,t.d,t.e,t.f)}function aUn(e){return e==null||(v6||(v6=document.createElementNS("http://www.w3.org/2000/svg","g")),v6.setAttribute("transform",e),!(e=v6.transform.baseVal.consolidate()))?dhe:(e=e.matrix,Ixt(e.a,e.b,e.c,e.d,e.e,e.f))}function Axt(e,t,n,r){function s(u){return u.length?u.pop()+" ":""}function a(u,d,f,p,h,m){if(u!==f||d!==p){var g=h.push("translate(",null,t,null,n);m.push({i:g-4,x:Jm(u,f)},{i:g-2,x:Jm(d,p)})}else(f||p)&&h.push("translate("+f+t+p+n)}function i(u,d,f,p){u!==d?(u-d>180?d+=360:d-u>180&&(u+=360),p.push({i:f.push(s(f)+"rotate(",null,r)-2,x:Jm(u,d)})):d&&f.push(s(f)+"rotate("+d+r)}function l(u,d,f,p){u!==d?p.push({i:f.push(s(f)+"skewX(",null,r)-2,x:Jm(u,d)}):d&&f.push(s(f)+"skewX("+d+r)}function c(u,d,f,p,h,m){if(u!==f||d!==p){var g=h.push(s(h)+"scale(",null,",",null,")");m.push({i:g-4,x:Jm(u,f)},{i:g-2,x:Jm(d,p)})}else(f!==1||p!==1)&&h.push(s(h)+"scale("+f+","+p+")")}return function(u,d){var f=[],p=[];return u=e(u),d=e(d),a(u.translateX,u.translateY,d.translateX,d.translateY,f,p),i(u.rotate,d.rotate,f,p),l(u.skewX,d.skewX,f,p),c(u.scaleX,u.scaleY,d.scaleX,d.scaleY,f,p),u=d=null,function(h){for(var m=-1,g=p.length,y;++m<g;)f[(y=p[m]).i]=y.x(h);return f.join("")}}}var iUn=Axt(sUn,"px, ","px)","deg)"),oUn=Axt(aUn,", ",")",")"),lUn=1e-12;function w8e(e){return((e=Math.exp(e))+1/e)/2}function cUn(e){return((e=Math.exp(e))-1/e)/2}function uUn(e){return((e=Math.exp(2*e))-1)/(e+1)}const L9=(function e(t,n,r){function s(a,i){var l=a[0],c=a[1],u=a[2],d=i[0],f=i[1],p=i[2],h=d-l,m=f-c,g=h*h+m*m,y,b;if(g<lUn)b=Math.log(p/u)/t,y=function(E){return[l+E*h,c+E*m,u*Math.exp(t*E*b)]};else{var w=Math.sqrt(g),S=(p*p-u*u+r*g)/(2*u*n*w),k=(p*p-u*u-r*g)/(2*p*n*w),_=Math.log(Math.sqrt(S*S+1)-S),C=Math.log(Math.sqrt(k*k+1)-k);b=(C-_)/t,y=function(E){var j=E*b,N=w8e(_),I=u/(n*w)*(N*uUn(t*j+_)-cUn(_));return[l+I*h,c+I*m,u*N/w8e(t*j+_)]}}return y.duration=b*1e3*t/Math.SQRT2,y}return s.rho=function(a){var i=Math.max(.001,+a),l=i*i,c=l*l;return e(i,l,c)},s})(Math.SQRT2,2,4);function dUn(e,t){t===void 0&&(t=e,e=rx);for(var n=0,r=t.length-1,s=t[0],a=new Array(r<0?0:r);n<r;)a[n]=e(s,s=t[++n]);return function(i){var l=Math.max(0,Math.min(r-1,Math.floor(i*=r)));return a[l](i-l)}}var mT=0,r2=0,qA=0,Rxt=1e3,b7,s2,x7=0,TO=0,vV=0,Y$=typeof performance=="object"&&performance.now?performance:Date,Pxt=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function s1e(){return TO||(Pxt(fUn),TO=Y$.now()+vV)}function fUn(){TO=0}function w7(){this._call=this._time=this._next=null}w7.prototype=$xt.prototype={constructor:w7,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?s1e():+n)+(t==null?0:+t),!this._next&&s2!==this&&(s2?s2._next=this:b7=this,s2=this),this._call=e,this._time=n,fhe()},stop:function(){this._call&&(this._call=null,this._time=1/0,fhe())}};function $xt(e,t,n){var r=new w7;return r.restart(e,t,n),r}function pUn(){s1e(),++mT;for(var e=b7,t;e;)(t=TO-e._time)>=0&&e._call.call(void 0,t),e=e._next;--mT}function S8e(){TO=(x7=Y$.now())+vV,mT=r2=0;try{pUn()}finally{mT=0,mUn(),TO=0}}function hUn(){var e=Y$.now(),t=e-x7;t>Rxt&&(vV-=t,x7=e)}function mUn(){for(var e,t=b7,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:b7=n);s2=e,fhe(r)}function fhe(e){if(!mT){r2&&(r2=clearTimeout(r2));var t=e-TO;t>24?(e<1/0&&(r2=setTimeout(S8e,e-Y$.now()-vV)),qA&&(qA=clearInterval(qA))):(qA||(x7=Y$.now(),qA=setInterval(hUn,Rxt)),mT=1,Pxt(S8e))}}function k8e(e,t,n){var r=new w7;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var gUn=mV("start","end","cancel","interrupt"),vUn=[],Mxt=0,O8e=1,phe=2,F9=3,_8e=4,hhe=5,z9=6;function yV(e,t,n,r,s,a){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;yUn(e,n,{name:t,index:r,group:s,on:gUn,tween:vUn,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:Mxt})}function a1e(e,t){var n=Lg(e,t);if(n.state>Mxt)throw new Error("too late; already scheduled");return n}function $y(e,t){var n=Lg(e,t);if(n.state>F9)throw new Error("too late; already running");return n}function Lg(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function yUn(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=$xt(a,0,n.time);function a(u){n.state=O8e,n.timer.restart(i,n.delay,n.time),n.delay<=u&&i(u-n.delay)}function i(u){var d,f,p,h;if(n.state!==O8e)return c();for(d in r)if(h=r[d],h.name===n.name){if(h.state===F9)return k8e(i);h.state===_8e?(h.state=z9,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[d]):+d<t&&(h.state=z9,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[d])}if(k8e(function(){n.state===F9&&(n.state=_8e,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=phe,n.on.call("start",e,e.__data__,n.index,n.group),n.state===phe){for(n.state=F9,s=new Array(p=n.tween.length),d=0,f=-1;d<p;++d)(h=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(s[++f]=h);s.length=f+1}}function l(u){for(var d=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=hhe,1),f=-1,p=s.length;++f<p;)s[f].call(e,d);n.state===hhe&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=z9,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function B9(e,t){var n=e.__transition,r,s,a=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((r=n[i]).name!==t){a=!1;continue}s=r.state>phe&&r.state<hhe,r.state=z9,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[i]}a&&delete e.__transition}}function bUn(e){return this.each(function(){B9(this,e)})}function xUn(e,t){var n,r;return function(){var s=$y(this,e),a=s.tween;if(a!==n){r=n=a;for(var i=0,l=r.length;i<l;++i)if(r[i].name===t){r=r.slice(),r.splice(i,1);break}}s.tween=r}}function wUn(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var a=$y(this,e),i=a.tween;if(i!==r){s=(r=i).slice();for(var l={name:t,value:n},c=0,u=s.length;c<u;++c)if(s[c].name===t){s[c]=l;break}c===u&&s.push(l)}a.tween=s}}function SUn(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Lg(this.node(),n).tween,s=0,a=r.length,i;s<a;++s)if((i=r[s]).name===e)return i.value;return null}return this.each((t==null?xUn:wUn)(n,e,t))}function i1e(e,t,n){var r=e._id;return e.each(function(){var s=$y(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return Lg(s,r).value[t]}}function Dxt(e,t){var n;return(typeof t=="number"?Jm:t instanceof jO?y7:(n=jO(t))?(t=n,y7):Nxt)(e,t)}function kUn(e){return function(){this.removeAttribute(e)}}function OUn(e){return function(){this.removeAttributeNS(e.space,e.local)}}function _Un(e,t,n){var r,s=n+"",a;return function(){var i=this.getAttribute(e);return i===s?null:i===r?a:a=t(r=i,n)}}function CUn(e,t,n){var r,s=n+"",a;return function(){var i=this.getAttributeNS(e.space,e.local);return i===s?null:i===r?a:a=t(r=i,n)}}function EUn(e,t,n){var r,s,a;return function(){var i,l=n(this),c;return l==null?void this.removeAttribute(e):(i=this.getAttribute(e),c=l+"",i===c?null:i===r&&c===s?a:(s=c,a=t(r=i,l)))}}function jUn(e,t,n){var r,s,a;return function(){var i,l=n(this),c;return l==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),c=l+"",i===c?null:i===r&&c===s?a:(s=c,a=t(r=i,l)))}}function TUn(e,t){var n=gV(e),r=n==="transform"?oUn:Dxt;return this.attrTween(e,typeof t=="function"?(n.local?jUn:EUn)(n,r,i1e(this,"attr."+e,t)):t==null?(n.local?OUn:kUn)(n):(n.local?CUn:_Un)(n,r,t))}function NUn(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function IUn(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function AUn(e,t){var n,r;function s(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&IUn(e,a)),n}return s._value=t,s}function RUn(e,t){var n,r;function s(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&NUn(e,a)),n}return s._value=t,s}function PUn(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=gV(e);return this.tween(n,(r.local?AUn:RUn)(r,t))}function $Un(e,t){return function(){a1e(this,e).delay=+t.apply(this,arguments)}}function MUn(e,t){return t=+t,function(){a1e(this,e).delay=t}}function DUn(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?$Un:MUn)(t,e)):Lg(this.node(),t).delay}function LUn(e,t){return function(){$y(this,e).duration=+t.apply(this,arguments)}}function FUn(e,t){return t=+t,function(){$y(this,e).duration=t}}function zUn(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?LUn:FUn)(t,e)):Lg(this.node(),t).duration}function BUn(e,t){if(typeof t!="function")throw new Error;return function(){$y(this,e).ease=t}}function UUn(e){var t=this._id;return arguments.length?this.each(BUn(t,e)):Lg(this.node(),t).ease}function qUn(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;$y(this,e).ease=n}}function VUn(e){if(typeof e!="function")throw new Error;return this.each(qUn(this._id,e))}function HUn(e){typeof e!="function"&&(e=hxt(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var a=t[s],i=a.length,l=r[s]=[],c,u=0;u<i;++u)(c=a[u])&&e.call(c,c.__data__,u,a)&&l.push(c);return new kx(r,this._parents,this._name,this._id)}function WUn(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,a=Math.min(r,s),i=new Array(r),l=0;l<a;++l)for(var c=t[l],u=n[l],d=c.length,f=i[l]=new Array(d),p,h=0;h<d;++h)(p=c[h]||u[h])&&(f[h]=p);for(;l<r;++l)i[l]=t[l];return new kx(i,this._parents,this._name,this._id)}function ZUn(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function GUn(e,t,n){var r,s,a=ZUn(t)?a1e:$y;return function(){var i=a(this,e),l=i.on;l!==r&&(s=(r=l).copy()).on(t,n),i.on=s}}function QUn(e,t){var n=this._id;return arguments.length<2?Lg(this.node(),n).on.on(e):this.each(GUn(n,e,t))}function YUn(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function XUn(){return this.on("end.remove",YUn(this._id))}function KUn(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Jwe(e));for(var r=this._groups,s=r.length,a=new Array(s),i=0;i<s;++i)for(var l=r[i],c=l.length,u=a[i]=new Array(c),d,f,p=0;p<c;++p)(d=l[p])&&(f=e.call(d,d.__data__,p,l))&&("__data__"in d&&(f.__data__=d.__data__),u[p]=f,yV(u[p],t,n,p,u,Lg(d,n)));return new kx(a,this._parents,t,n)}function JUn(e){var t=this._name,n=this._id;typeof e!="function"&&(e=pxt(e));for(var r=this._groups,s=r.length,a=[],i=[],l=0;l<s;++l)for(var c=r[l],u=c.length,d,f=0;f<u;++f)if(d=c[f]){for(var p=e.call(d,d.__data__,f,c),h,m=Lg(d,n),g=0,y=p.length;g<y;++g)(h=p[g])&&yV(h,t,n,g,p,m);a.push(p),i.push(d)}return new kx(a,i,t,n)}var eqn=aD.prototype.constructor;function tqn(){return new eqn(this._groups,this._parents)}function nqn(e,t){var n,r,s;return function(){var a=hT(this,e),i=(this.style.removeProperty(e),hT(this,e));return a===i?null:a===n&&i===r?s:s=t(n=a,r=i)}}function Lxt(e){return function(){this.style.removeProperty(e)}}function rqn(e,t,n){var r,s=n+"",a;return function(){var i=hT(this,e);return i===s?null:i===r?a:a=t(r=i,n)}}function sqn(e,t,n){var r,s,a;return function(){var i=hT(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),hT(this,e))),i===c?null:i===r&&c===s?a:(s=c,a=t(r=i,l))}}function aqn(e,t){var n,r,s,a="style."+t,i="end."+a,l;return function(){var c=$y(this,e),u=c.on,d=c.value[a]==null?l||(l=Lxt(t)):void 0;(u!==n||s!==d)&&(r=(n=u).copy()).on(i,s=d),c.on=r}}function iqn(e,t,n){var r=(e+="")=="transform"?iUn:Dxt;return t==null?this.styleTween(e,nqn(e,r)).on("end.style."+e,Lxt(e)):typeof t=="function"?this.styleTween(e,sqn(e,r,i1e(this,"style."+e,t))).each(aqn(this._id,e)):this.styleTween(e,rqn(e,r,t),n).on("end.style."+e,null)}function oqn(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function lqn(e,t,n){var r,s;function a(){var i=t.apply(this,arguments);return i!==s&&(r=(s=i)&&oqn(e,i,n)),r}return a._value=t,a}function cqn(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,lqn(e,t,n??""))}function uqn(e){return function(){this.textContent=e}}function dqn(e){return function(){var t=e(this);this.textContent=t??""}}function fqn(e){return this.tween("text",typeof e=="function"?dqn(i1e(this,"text",e)):uqn(e==null?"":e+""))}function pqn(e){return function(t){this.textContent=e.call(this,t)}}function hqn(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&pqn(s)),t}return r._value=e,r}function mqn(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,hqn(e))}function gqn(){for(var e=this._name,t=this._id,n=Fxt(),r=this._groups,s=r.length,a=0;a<s;++a)for(var i=r[a],l=i.length,c,u=0;u<l;++u)if(c=i[u]){var d=Lg(c,t);yV(c,e,n,u,i,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new kx(r,this._parents,e,n)}function vqn(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(a,i){var l={value:i},c={value:function(){--s===0&&a()}};n.each(function(){var u=$y(this,r),d=u.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),u.on=t}),s===0&&a()})}var yqn=0;function kx(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Fxt(){return++yqn}var pb=aD.prototype;kx.prototype={constructor:kx,select:KUn,selectAll:JUn,selectChild:pb.selectChild,selectChildren:pb.selectChildren,filter:HUn,merge:WUn,selection:tqn,transition:gqn,call:pb.call,nodes:pb.nodes,node:pb.node,size:pb.size,empty:pb.empty,each:pb.each,on:QUn,attr:TUn,attrTween:PUn,style:iqn,styleTween:cqn,text:fqn,textTween:mqn,remove:XUn,tween:SUn,delay:DUn,duration:zUn,ease:UUn,easeVarying:VUn,end:vqn,[Symbol.iterator]:pb[Symbol.iterator]};function bqn(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var xqn={time:null,delay:0,duration:250,ease:bqn};function wqn(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Sqn(e){var t,n;e instanceof kx?(t=e._id,e=e._name):(t=Fxt(),(n=xqn).time=s1e(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,a=0;a<s;++a)for(var i=r[a],l=i.length,c,u=0;u<l;++u)(c=i[u])&&yV(c,e,t,u,i,n||wqn(c,t));return new kx(r,this._parents,e,t)}aD.prototype.interrupt=bUn;aD.prototype.transition=Sqn;const y6=e=>()=>e;function kqn(e,{sourceEvent:t,target:n,transform:r,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:s}})}function Vb(e,t,n){this.k=e,this.x=t,this.y=n}Vb.prototype={constructor:Vb,scale:function(e){return e===1?this:new Vb(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Vb(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var bV=new Vb(1,0,0);zxt.prototype=Vb.prototype;function zxt(e){for(;!e.__zoom;)if(!(e=e.parentNode))return bV;return e.__zoom}function IJ(e){e.stopImmediatePropagation()}function VA(e){e.preventDefault(),e.stopImmediatePropagation()}function Oqn(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function _qn(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function C8e(){return this.__zoom||bV}function Cqn(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Eqn(){return navigator.maxTouchPoints||"ontouchstart"in this}function jqn(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),i>a?(a+i)/2:Math.min(0,a)||Math.max(0,i))}function Bxt(){var e=Oqn,t=_qn,n=jqn,r=Cqn,s=Eqn,a=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,c=L9,u=mV("start","zoom","end"),d,f,p,h=500,m=150,g=0,y=10;function b(D){D.property("__zoom",C8e).on("wheel.zoom",j,{passive:!1}).on("mousedown.zoom",N).on("dblclick.zoom",I).filter(s).on("touchstart.zoom",R).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",F).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(D,V,W,L){var z=D.selection?D.selection():D;z.property("__zoom",C8e),D!==z?_(D,V,W,L):z.interrupt().each(function(){C(this,arguments).event(L).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},b.scaleBy=function(D,V,W,L){b.scaleTo(D,function(){var z=this.__zoom.k,B=typeof V=="function"?V.apply(this,arguments):V;return z*B},W,L)},b.scaleTo=function(D,V,W,L){b.transform(D,function(){var z=t.apply(this,arguments),B=this.__zoom,M=W==null?k(z):typeof W=="function"?W.apply(this,arguments):W,G=B.invert(M),U=typeof V=="function"?V.apply(this,arguments):V;return n(S(w(B,U),M,G),z,i)},W,L)},b.translateBy=function(D,V,W,L){b.transform(D,function(){return n(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),t.apply(this,arguments),i)},null,L)},b.translateTo=function(D,V,W,L,z){b.transform(D,function(){var B=t.apply(this,arguments),M=this.__zoom,G=L==null?k(B):typeof L=="function"?L.apply(this,arguments):L;return n(bV.translate(G[0],G[1]).scale(M.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),B,i)},L,z)};function w(D,V){return V=Math.max(a[0],Math.min(a[1],V)),V===D.k?D:new Vb(V,D.x,D.y)}function S(D,V,W){var L=V[0]-W[0]*D.k,z=V[1]-W[1]*D.k;return L===D.x&&z===D.y?D:new Vb(D.k,L,z)}function k(D){return[(+D[0][0]+ +D[1][0])/2,(+D[0][1]+ +D[1][1])/2]}function _(D,V,W,L){D.on("start.zoom",function(){C(this,arguments).event(L).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(L).end()}).tween("zoom",function(){var z=this,B=arguments,M=C(z,B).event(L),G=t.apply(z,B),U=W==null?k(G):typeof W=="function"?W.apply(z,B):W,P=Math.max(G[1][0]-G[0][0],G[1][1]-G[0][1]),q=z.__zoom,Z=typeof V=="function"?V.apply(z,B):V,X=c(q.invert(U).concat(P/q.k),Z.invert(U).concat(P/Z.k));return function(te){if(te===1)te=Z;else{var J=X(te),ee=P/J[2];te=new Vb(ee,U[0]-J[0]*ee,U[1]-J[1]*ee)}M.zoom(null,te)}})}function C(D,V,W){return!W&&D.__zooming||new E(D,V)}function E(D,V){this.that=D,this.args=V,this.active=0,this.sourceEvent=null,this.extent=t.apply(D,V),this.taps=0}E.prototype={event:function(D){return D&&(this.sourceEvent=D),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(D,V){return this.mouse&&D!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&D!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&D!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(D){var V=fp(this.that).datum();u.call(D,this.that,new kqn(D,{sourceEvent:this.sourceEvent,target:b,transform:this.that.__zoom,dispatch:u}),V)}};function j(D,...V){if(!e.apply(this,arguments))return;var W=C(this,V).event(D),L=this.__zoom,z=Math.max(a[0],Math.min(a[1],L.k*Math.pow(2,r.apply(this,arguments)))),B=Xm(D);if(W.wheel)(W.mouse[0][0]!==B[0]||W.mouse[0][1]!==B[1])&&(W.mouse[1]=L.invert(W.mouse[0]=B)),clearTimeout(W.wheel);else{if(L.k===z)return;W.mouse=[B,L.invert(B)],B9(this),W.start()}VA(D),W.wheel=setTimeout(M,m),W.zoom("mouse",n(S(w(L,z),W.mouse[0],W.mouse[1]),W.extent,i));function M(){W.wheel=null,W.end()}}function N(D,...V){if(p||!e.apply(this,arguments))return;var W=D.currentTarget,L=C(this,V,!0).event(D),z=fp(D.view).on("mousemove.zoom",U,!0).on("mouseup.zoom",P,!0),B=Xm(D,W),M=D.clientX,G=D.clientY;Oxt(D.view),IJ(D),L.mouse=[B,this.__zoom.invert(B)],B9(this),L.start();function U(q){if(VA(q),!L.moved){var Z=q.clientX-M,X=q.clientY-G;L.moved=Z*Z+X*X>g}L.event(q).zoom("mouse",n(S(L.that.__zoom,L.mouse[0]=Xm(q,W),L.mouse[1]),L.extent,i))}function P(q){z.on("mousemove.zoom mouseup.zoom",null),_xt(q.view,L.moved),VA(q),L.event(q).end()}}function I(D,...V){if(e.apply(this,arguments)){var W=this.__zoom,L=Xm(D.changedTouches?D.changedTouches[0]:D,this),z=W.invert(L),B=W.k*(D.shiftKey?.5:2),M=n(S(w(W,B),L,z),t.apply(this,V),i);VA(D),l>0?fp(this).transition().duration(l).call(_,M,L,D):fp(this).call(b.transform,M,L,D)}}function R(D,...V){if(e.apply(this,arguments)){var W=D.touches,L=W.length,z=C(this,V,D.changedTouches.length===L).event(D),B,M,G,U;for(IJ(D),M=0;M<L;++M)G=W[M],U=Xm(G,this),U=[U,this.__zoom.invert(U),G.identifier],z.touch0?!z.touch1&&z.touch0[2]!==U[2]&&(z.touch1=U,z.taps=0):(z.touch0=U,B=!0,z.taps=1+!!d);d&&(d=clearTimeout(d)),B&&(z.taps<2&&(f=U[0],d=setTimeout(function(){d=null},h)),B9(this),z.start())}}function $(D,...V){if(this.__zooming){var W=C(this,V).event(D),L=D.changedTouches,z=L.length,B,M,G,U;for(VA(D),B=0;B<z;++B)M=L[B],G=Xm(M,this),W.touch0&&W.touch0[2]===M.identifier?W.touch0[0]=G:W.touch1&&W.touch1[2]===M.identifier&&(W.touch1[0]=G);if(M=W.that.__zoom,W.touch1){var P=W.touch0[0],q=W.touch0[1],Z=W.touch1[0],X=W.touch1[1],te=(te=Z[0]-P[0])*te+(te=Z[1]-P[1])*te,J=(J=X[0]-q[0])*J+(J=X[1]-q[1])*J;M=w(M,Math.sqrt(te/J)),G=[(P[0]+Z[0])/2,(P[1]+Z[1])/2],U=[(q[0]+X[0])/2,(q[1]+X[1])/2]}else if(W.touch0)G=W.touch0[0],U=W.touch0[1];else return;W.zoom("touch",n(S(M,G,U),W.extent,i))}}function F(D,...V){if(this.__zooming){var W=C(this,V).event(D),L=D.changedTouches,z=L.length,B,M;for(IJ(D),p&&clearTimeout(p),p=setTimeout(function(){p=null},h),B=0;B<z;++B)M=L[B],W.touch0&&W.touch0[2]===M.identifier?delete W.touch0:W.touch1&&W.touch1[2]===M.identifier&&delete W.touch1;if(W.touch1&&!W.touch0&&(W.touch0=W.touch1,delete W.touch1),W.touch0)W.touch0[1]=this.__zoom.invert(W.touch0[0]);else if(W.end(),W.taps===2&&(M=Xm(M,this),Math.hypot(f[0]-M[0],f[1]-M[1])<y)){var G=fp(this).on("dblclick.zoom");G&&G.apply(this,arguments)}}}return b.wheelDelta=function(D){return arguments.length?(r=typeof D=="function"?D:y6(+D),b):r},b.filter=function(D){return arguments.length?(e=typeof D=="function"?D:y6(!!D),b):e},b.touchable=function(D){return arguments.length?(s=typeof D=="function"?D:y6(!!D),b):s},b.extent=function(D){return arguments.length?(t=typeof D=="function"?D:y6([[+D[0][0],+D[0][1]],[+D[1][0],+D[1][1]]]),b):t},b.scaleExtent=function(D){return arguments.length?(a[0]=+D[0],a[1]=+D[1],b):[a[0],a[1]]},b.translateExtent=function(D){return arguments.length?(i[0][0]=+D[0][0],i[1][0]=+D[1][0],i[0][1]=+D[0][1],i[1][1]=+D[1][1],b):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},b.constrain=function(D){return arguments.length?(n=D,b):n},b.duration=function(D){return arguments.length?(l=+D,b):l},b.interpolate=function(D){return arguments.length?(c=D,b):c},b.on=function(){var D=u.on.apply(u,arguments);return D===u?b:D},b.clickDistance=function(D){return arguments.length?(g=(D=+D)*D,b):Math.sqrt(g)},b.tapDistance=function(D){return arguments.length?(y=+D,b):y},b}const py={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},X$=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Uxt=["Enter"," ","Escape"],qxt={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var gT;(function(e){e.Strict="strict",e.Loose="loose"})(gT||(gT={}));var Bk;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Bk||(Bk={}));var K$;(function(e){e.Partial="partial",e.Full="full"})(K$||(K$={}));const Vxt={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var sw;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(sw||(sw={}));var J$;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(J$||(J$={}));var nr;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(nr||(nr={}));const E8e={[nr.Left]:nr.Right,[nr.Right]:nr.Left,[nr.Top]:nr.Bottom,[nr.Bottom]:nr.Top};function Hxt(e){return e===null?null:e?"valid":"invalid"}const Wxt=e=>"id"in e&&"source"in e&&"target"in e,Tqn=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),o1e=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),oD=(e,t=[0,0])=>{const{width:n,height:r}=Hx(e),s=e.origin??t,a=n*s[0],i=r*s[1];return{x:e.position.x-a,y:e.position.y-i}},Nqn=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const a=typeof s=="string";let i=!t.nodeLookup&&!a?s:void 0;t.nodeLookup&&(i=a?t.nodeLookup.get(s):o1e(s)?s:t.nodeLookup.get(s.id));const l=i?S7(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return xV(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return wV(n)},lD=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=xV(n,S7(s)),r=!0)}),r?wV(n):{x:0,y:0,width:0,height:0}},l1e=(e,t,[n,r,s]=[0,0,1],a=!1,i=!1)=>{const l={...uD(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const u of e.values()){const{measured:d,selectable:f=!0,hidden:p=!1}=u;if(i&&!f||p)continue;const h=d.width??u.width??u.initialWidth??null,m=d.height??u.height??u.initialHeight??null,g=eM(l,yT(u)),y=(h??0)*(m??0),b=a&&g>0;(!u.internals.handleBounds||b||g>=y||u.dragging)&&c.push(u)}return c},Iqn=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function Aqn(e,t){const n=new Map,r=t?.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&(t?.includeHiddenNodes||!s.hidden)&&(!r||r.has(s.id))&&n.set(s.id,s)}),n}async function Rqn({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:a},i){if(e.size===0)return Promise.resolve(!0);const l=Aqn(e,i),c=lD(l),u=c1e(c,t,n,i?.minZoom??s,i?.maxZoom??a,i?.padding??.1);return await r.setViewport(u,{duration:i?.duration,ease:i?.ease,interpolate:i?.interpolate}),Promise.resolve(!0)}function Zxt({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:s,onError:a}){const i=n.get(e),l=i.parentId?n.get(i.parentId):void 0,{x:c,y:u}=l?l.internals.positionAbsolute:{x:0,y:0},d=i.origin??r;let f=i.extent||s;if(i.extent==="parent"&&!i.expandParent)if(!l)a?.("005",py.error005());else{const h=l.measured.width,m=l.measured.height;h&&m&&(f=[[c,u],[c+h,u+m]])}else l&&bT(i.extent)&&(f=[[i.extent[0][0]+c,i.extent[0][1]+u],[i.extent[1][0]+c,i.extent[1][1]+u]]);const p=bT(f)?NO(t,f,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&a?.("015",py.error015()),{position:{x:p.x-c+(i.measured.width??0)*d[0],y:p.y-u+(i.measured.height??0)*d[1]},positionAbsolute:p}}async function Pqn({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const a=new Set(e.map(p=>p.id)),i=[];for(const p of n){if(p.deletable===!1)continue;const h=a.has(p.id),m=!h&&p.parentId&&i.find(g=>g.id===p.parentId);(h||m)&&i.push(p)}const l=new Set(t.map(p=>p.id)),c=r.filter(p=>p.deletable!==!1),d=Iqn(i,c);for(const p of c)l.has(p.id)&&!d.find(m=>m.id===p.id)&&d.push(p);if(!s)return{edges:d,nodes:i};const f=await s({nodes:i,edges:d});return typeof f=="boolean"?f?{edges:d,nodes:i}:{edges:[],nodes:[]}:f}const vT=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),NO=(e={x:0,y:0},t,n)=>({x:vT(e.x,t[0][0],t[1][0]-(n?.width??0)),y:vT(e.y,t[0][1],t[1][1]-(n?.height??0))});function Gxt(e,t,n){const{width:r,height:s}=Hx(n),{x:a,y:i}=n.internals.positionAbsolute;return NO(e,[[a,i],[a+r,i+s]],t)}const j8e=(e,t,n)=>e<t?vT(Math.abs(e-t),1,t)/t:e>n?-vT(Math.abs(e-n),1,t)/t:0,Qxt=(e,t,n=15,r=40)=>{const s=j8e(e.x,r,t.width-r)*n,a=j8e(e.y,r,t.height-r)*n;return[s,a]},xV=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),mhe=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),wV=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),yT=(e,t=[0,0])=>{const{x:n,y:r}=o1e(e)?e.internals.positionAbsolute:oD(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},S7=(e,t=[0,0])=>{const{x:n,y:r}=o1e(e)?e.internals.positionAbsolute:oD(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},Yxt=(e,t)=>wV(xV(mhe(e),mhe(t))),eM=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},T8e=e=>cg(e.width)&&cg(e.height)&&cg(e.x)&&cg(e.y),cg=e=>!isNaN(e)&&isFinite(e),$qn=(e,t)=>{},cD=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),uD=({x:e,y:t},[n,r,s],a=!1,i=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return a?cD(l,i):l},k7=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function MC(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Mqn(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=MC(e,n),s=MC(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=MC(e.top??e.y??0,n),s=MC(e.bottom??e.y??0,n),a=MC(e.left??e.x??0,t),i=MC(e.right??e.x??0,t);return{top:r,right:i,bottom:s,left:a,x:a+i,y:r+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Dqn(e,t,n,r,s,a){const{x:i,y:l}=k7(e,[t,n,r]),{x:c,y:u}=k7({x:e.x+e.width,y:e.y+e.height},[t,n,r]),d=s-c,f=a-u;return{left:Math.floor(i),top:Math.floor(l),right:Math.floor(d),bottom:Math.floor(f)}}const c1e=(e,t,n,r,s,a)=>{const i=Mqn(a,t,n),l=(t-i.x)/e.width,c=(n-i.y)/e.height,u=Math.min(l,c),d=vT(u,r,s),f=e.x+e.width/2,p=e.y+e.height/2,h=t/2-f*d,m=n/2-p*d,g=Dqn(e,h,m,d,t,n),y={left:Math.min(g.left-i.left,0),top:Math.min(g.top-i.top,0),right:Math.min(g.right-i.right,0),bottom:Math.min(g.bottom-i.bottom,0)};return{x:h-y.left+y.right,y:m-y.top+y.bottom,zoom:d}},tM=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function bT(e){return e!=null&&e!=="parent"}function Hx(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Xxt(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Kxt(e,t={width:0,height:0},n,r,s){const a={...e},i=r.get(n);if(i){const l=i.origin||s;a.x+=i.internals.positionAbsolute.x-(t.width??0)*l[0],a.y+=i.internals.positionAbsolute.y-(t.height??0)*l[1]}return a}function N8e(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Lqn(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function Fqn(e){return{...qxt,...e||{}}}function D2(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:a,y:i}=ug(e),l=uD({x:a-(s?.left??0),y:i-(s?.top??0)},r),{x:c,y:u}=n?cD(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const u1e=e=>({width:e.offsetWidth,height:e.offsetHeight}),Jxt=e=>e?.getRootNode?.()||window?.document,zqn=["INPUT","SELECT","TEXTAREA"];function e0t(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:zqn.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const t0t=e=>"clientX"in e,ug=(e,t)=>{const n=t0t(e),r=n?e.clientX:e.touches?.[0].clientX,s=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:s-(t?.top??0)}},I8e=(e,t,n,r,s)=>{const a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(i=>{const l=i.getBoundingClientRect();return{id:i.getAttribute("data-handleid"),type:e,nodeId:s,position:i.getAttribute("data-handlepos"),x:(l.left-n.left)/r,y:(l.top-n.top)/r,...u1e(i)}})};function n0t({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:a,targetControlX:i,targetControlY:l}){const c=e*.125+s*.375+i*.375+n*.125,u=t*.125+a*.375+l*.375+r*.125,d=Math.abs(c-e),f=Math.abs(u-t);return[c,u,d,f]}function b6(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function A8e({pos:e,x1:t,y1:n,x2:r,y2:s,c:a}){switch(e){case nr.Left:return[t-b6(t-r,a),n];case nr.Right:return[t+b6(r-t,a),n];case nr.Top:return[t,n-b6(n-s,a)];case nr.Bottom:return[t,n+b6(s-n,a)]}}function d1e({sourceX:e,sourceY:t,sourcePosition:n=nr.Bottom,targetX:r,targetY:s,targetPosition:a=nr.Top,curvature:i=.25}){const[l,c]=A8e({pos:n,x1:e,y1:t,x2:r,y2:s,c:i}),[u,d]=A8e({pos:a,x1:r,y1:s,x2:e,y2:t,c:i}),[f,p,h,m]=n0t({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${e},${t} C${l},${c} ${u},${d} ${r},${s}`,f,p,h,m]}function r0t({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,a=n<e?n+s:n-s,i=Math.abs(r-t)/2,l=r<t?r+i:r-i;return[a,l,s,i]}function Bqn({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:s=!1,zIndexMode:a="basic"}){if(a==="manual")return r;const i=s&&n?r+1e3:r,l=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return i+l}function Uqn({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const a=xV(S7(e),S7(t));a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1);const i={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:r/s[2]};return eM(i,wV(a))>0}const qqn=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,Vqn=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Hqn=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||qqn;let s;return Wxt(e)?s={...e}:s={...e,id:r(e)},Vqn(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function s0t({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,a,i,l]=r0t({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,a,i,l]}const R8e={[nr.Left]:{x:-1,y:0},[nr.Right]:{x:1,y:0},[nr.Top]:{x:0,y:-1},[nr.Bottom]:{x:0,y:1}},Wqn=({source:e,sourcePosition:t=nr.Bottom,target:n})=>t===nr.Left||t===nr.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},P8e=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Zqn({source:e,sourcePosition:t=nr.Bottom,target:n,targetPosition:r=nr.Top,center:s,offset:a,stepPosition:i}){const l=R8e[t],c=R8e[r],u={x:e.x+l.x*a,y:e.y+l.y*a},d={x:n.x+c.x*a,y:n.y+c.y*a},f=Wqn({source:u,sourcePosition:t,target:d}),p=f.x!==0?"x":"y",h=f[p];let m=[],g,y;const b={x:0,y:0},w={x:0,y:0},[,,S,k]=r0t({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){p==="x"?(g=s.x??u.x+(d.x-u.x)*i,y=s.y??(u.y+d.y)/2):(g=s.x??(u.x+d.x)/2,y=s.y??u.y+(d.y-u.y)*i);const j=[{x:g,y:u.y},{x:g,y:d.y}],N=[{x:u.x,y},{x:d.x,y}];l[p]===h?m=p==="x"?j:N:m=p==="x"?N:j}else{const j=[{x:u.x,y:d.y}],N=[{x:d.x,y:u.y}];if(p==="x"?m=l.x===h?N:j:m=l.y===h?j:N,t===r){const D=Math.abs(e[p]-n[p]);if(D<=a){const V=Math.min(a-1,a-D);l[p]===h?b[p]=(u[p]>e[p]?-1:1)*V:w[p]=(d[p]>n[p]?-1:1)*V}}if(t!==r){const D=p==="x"?"y":"x",V=l[p]===c[D],W=u[D]>d[D],L=u[D]<d[D];(l[p]===1&&(!V&&W||V&&L)||l[p]!==1&&(!V&&L||V&&W))&&(m=p==="x"?j:N)}const I={x:u.x+b.x,y:u.y+b.y},R={x:d.x+w.x,y:d.y+w.y},$=Math.max(Math.abs(I.x-m[0].x),Math.abs(R.x-m[0].x)),F=Math.max(Math.abs(I.y-m[0].y),Math.abs(R.y-m[0].y));$>=F?(g=(I.x+R.x)/2,y=m[0].y):(g=m[0].x,y=(I.y+R.y)/2)}const _={x:u.x+b.x,y:u.y+b.y},C={x:d.x+w.x,y:d.y+w.y};return[[e,..._.x!==m[0].x||_.y!==m[0].y?[_]:[],...m,...C.x!==m[m.length-1].x||C.y!==m[m.length-1].y?[C]:[],n],g,y,S,k]}function Gqn(e,t,n,r){const s=Math.min(P8e(e,t)/2,P8e(t,n)/2,r),{x:a,y:i}=t;if(e.x===a&&a===n.x||e.y===i&&i===n.y)return`L${a} ${i}`;if(e.y===i){const u=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${a+s*u},${i}Q ${a},${i} ${a},${i+s*d}`}const l=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${a},${i+s*c}Q ${a},${i} ${a+s*l},${i}`}function ghe({sourceX:e,sourceY:t,sourcePosition:n=nr.Bottom,targetX:r,targetY:s,targetPosition:a=nr.Top,borderRadius:i=5,centerX:l,centerY:c,offset:u=20,stepPosition:d=.5}){const[f,p,h,m,g]=Zqn({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:a,center:{x:l,y:c},offset:u,stepPosition:d});let y=`M${f[0].x} ${f[0].y}`;for(let b=1;b<f.length-1;b++)y+=Gqn(f[b-1],f[b],f[b+1],i);return y+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[y,p,h,m,g]}function $8e(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Qqn(e){const{sourceNode:t,targetNode:n}=e;if(!$8e(t)||!$8e(n))return null;const r=t.internals.handleBounds||M8e(t.handles),s=n.internals.handleBounds||M8e(n.handles),a=D8e(r?.source??[],e.sourceHandle),i=D8e(e.connectionMode===gT.Strict?s?.target??[]:(s?.target??[]).concat(s?.source??[]),e.targetHandle);if(!a||!i)return e.onError?.("008",py.error008(a?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=a?.position||nr.Bottom,c=i?.position||nr.Top,u=IO(t,a,l),d=IO(n,i,c);return{sourceX:u.x,sourceY:u.y,targetX:d.x,targetY:d.y,sourcePosition:l,targetPosition:c}}function M8e(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function IO(e,t,n=nr.Left,r=!1){const s=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:i,height:l}=t??Hx(e);if(r)return{x:s+i/2,y:a+l/2};switch(t?.position??n){case nr.Top:return{x:s+i/2,y:a};case nr.Right:return{x:s+i,y:a+l/2};case nr.Bottom:return{x:s+i/2,y:a+l};case nr.Left:return{x:s,y:a+l/2}}}function D8e(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function vhe(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function Yqn(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:s}){const a=new Set;return e.reduce((i,l)=>([l.markerStart||r,l.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const u=vhe(c,t);a.has(u)||(i.push({id:u,color:c.color||n,...c}),a.add(u))}}),i),[]).sort((i,l)=>i.id.localeCompare(l.id))}const a0t=1e3,Xqn=10,f1e={nodeOrigin:[0,0],nodeExtent:X$,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Kqn={...f1e,checkEquality:!0};function p1e(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function Jqn(e,t,n){const r=p1e(f1e,n);for(const s of e.values())if(s.parentId)m1e(s,e,t,r);else{const a=oD(s,r.nodeOrigin),i=bT(s.extent)?s.extent:r.nodeExtent,l=NO(a,i,Hx(s));s.internals.positionAbsolute=l}}function eVn(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],r=[];for(const s of e.handles){const a={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(a):s.type==="target"&&r.push(a)}return{source:n,target:r}}function h1e(e){return e==="manual"}function yhe(e,t,n,r={}){const s=p1e(Kqn,r),a={i:0},i=new Map(t),l=s?.elevateNodesOnSelect&&!h1e(s.zIndexMode)?a0t:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const d of e){let f=i.get(d.id);if(s.checkEquality&&d===f?.internals.userNode)t.set(d.id,f);else{const p=oD(d,s.nodeOrigin),h=bT(d.extent)?d.extent:s.nodeExtent,m=NO(p,h,Hx(d));f={...s.defaults,...d,measured:{width:d.measured?.width,height:d.measured?.height},internals:{positionAbsolute:m,handleBounds:eVn(d,f),z:i0t(d,l,s.zIndexMode),userNode:d}},t.set(d.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(c=!1),d.parentId&&m1e(f,t,n,r,a),u||=d.selected??!1}return{nodesInitialized:c,hasSelectedNodes:u}}function tVn(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function m1e(e,t,n,r,s){const{elevateNodesOnSelect:a,nodeOrigin:i,nodeExtent:l,zIndexMode:c}=p1e(f1e,r),u=e.parentId,d=t.get(u);if(!d){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}tVn(e,n),s&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++s.i,d.internals.z=d.internals.z+s.i*Xqn),s&&d.internals.rootParentIndex!==void 0&&(s.i=d.internals.rootParentIndex);const f=a&&!h1e(c)?a0t:0,{x:p,y:h,z:m}=nVn(e,d,i,l,f,c),{positionAbsolute:g}=e.internals,y=p!==g.x||h!==g.y;(y||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:p,y:h}:g,z:m}})}function i0t(e,t,n){const r=cg(e.zIndex)?e.zIndex:0;return h1e(n)?r:r+(e.selected?t:0)}function nVn(e,t,n,r,s,a){const{x:i,y:l}=t.internals.positionAbsolute,c=Hx(e),u=oD(e,n),d=bT(e.extent)?NO(u,e.extent,c):u;let f=NO({x:i+d.x,y:l+d.y},r,c);e.extent==="parent"&&(f=Gxt(f,c,t));const p=i0t(e,s,a),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=p?h+1:p}}function g1e(e,t,n,r=[0,0]){const s=[],a=new Map;for(const i of e){const l=t.get(i.parentId);if(!l)continue;const c=a.get(i.parentId)?.expandedRect??yT(l),u=Yxt(c,i.rect);a.set(i.parentId,{expandedRect:u,parent:l})}return a.size>0&&a.forEach(({expandedRect:i,parent:l},c)=>{const u=l.internals.positionAbsolute,d=Hx(l),f=l.origin??r,p=i.x<u.x?Math.round(Math.abs(u.x-i.x)):0,h=i.y<u.y?Math.round(Math.abs(u.y-i.y)):0,m=Math.max(d.width,Math.round(i.width)),g=Math.max(d.height,Math.round(i.height)),y=(m-d.width)*f[0],b=(g-d.height)*f[1];(p>0||h>0||y||b)&&(s.push({id:c,type:"position",position:{x:l.position.x-p+y,y:l.position.y-h+b}}),n.get(c)?.forEach(w=>{e.some(S=>S.id===w.id)||s.push({id:w.id,type:"position",position:{x:w.position.x+p,y:w.position.y+h}})})),(d.width<i.width||d.height<i.height||p||h)&&s.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:m+(p?f[0]*p-y:0),height:g+(h?f[1]*h-b:0)}})}),s}function rVn(e,t,n,r,s,a,i){const l=r?.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const u=[],d=window.getComputedStyle(l),{m22:f}=new window.DOMMatrixReadOnly(d.transform),p=[];for(const h of e.values()){const m=t.get(h.id);if(!m)continue;if(m.hidden){t.set(m.id,{...m,internals:{...m.internals,handleBounds:void 0}}),c=!0;continue}const g=u1e(h.nodeElement),y=m.measured.width!==g.width||m.measured.height!==g.height;if(!!(g.width&&g.height&&(y||!m.internals.handleBounds||h.force))){const w=h.nodeElement.getBoundingClientRect(),S=bT(m.extent)?m.extent:a;let{positionAbsolute:k}=m.internals;m.parentId&&m.extent==="parent"?k=Gxt(k,g,t.get(m.parentId)):S&&(k=NO(k,S,g));const _={...m,measured:g,internals:{...m.internals,positionAbsolute:k,handleBounds:{source:I8e("source",h.nodeElement,w,f,m.id),target:I8e("target",h.nodeElement,w,f,m.id)}}};t.set(m.id,_),m.parentId&&m1e(_,t,n,{nodeOrigin:s,zIndexMode:i}),c=!0,y&&(u.push({id:m.id,type:"dimensions",dimensions:g}),m.expandParent&&m.parentId&&p.push({id:m.id,parentId:m.parentId,rect:yT(_,s)}))}}if(p.length>0){const h=g1e(p,t,n,s);u.push(...h)}return{changes:u,updatedInternals:c}}async function sVn({delta:e,panZoom:t,transform:n,translateExtent:r,width:s,height:a}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const i=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,a]],r),l=!!i&&(i.x!==n[0]||i.y!==n[1]||i.k!==n[2]);return Promise.resolve(l)}function L8e(e,t,n,r,s,a){let i=s;const l=r.get(i)||new Map;r.set(i,l.set(n,t)),i=`${s}-${e}`;const c=r.get(i)||new Map;if(r.set(i,c.set(n,t)),a){i=`${s}-${e}-${a}`;const u=r.get(i)||new Map;r.set(i,u.set(n,t))}}function o0t(e,t,n){e.clear(),t.clear();for(const r of n){const{source:s,target:a,sourceHandle:i=null,targetHandle:l=null}=r,c={edgeId:r.id,source:s,target:a,sourceHandle:i,targetHandle:l},u=`${s}-${i}--${a}-${l}`,d=`${a}-${l}--${s}-${i}`;L8e("source",c,d,e,s,i),L8e("target",c,u,e,a,l),t.set(r.id,r)}}function l0t(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:l0t(n,t):!1}function F8e(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function aVn(e,t,n,r){const s=new Map;for(const[a,i]of e)if((i.selected||i.id===r)&&(!i.parentId||!l0t(i,e))&&(i.draggable||t&&typeof i.draggable>"u")){const l=e.get(a);l&&s.set(a,{id:a,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return s}function AJ({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){const s=[];for(const[i,l]of t){const c=n.get(i)?.internals.userNode;c&&s.push({...c,position:l.position,dragging:r})}if(!e)return[s[0],s];const a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:s[0],s]}function iVn({dragItems:e,snapGrid:t,x:n,y:r}){const s=e.values().next().value;if(!s)return null;const a={x:n-s.distance.x,y:r-s.distance.y},i=cD(a,t);return{x:i.x-a.x,y:i.y-a.y}}function oVn({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let a={x:null,y:null},i=0,l=new Map,c=!1,u={x:0,y:0},d=null,f=!1,p=null,h=!1,m=!1,g=null;function y({noDragClassName:w,handleSelector:S,domNode:k,isSelectable:_,nodeId:C,nodeClickDistance:E=0}){p=fp(k);function j({x:$,y:F}){const{nodeLookup:D,nodeExtent:V,snapGrid:W,snapToGrid:L,nodeOrigin:z,onNodeDrag:B,onSelectionDrag:M,onError:G,updateNodePositions:U}=t();a={x:$,y:F};let P=!1;const q=l.size>1,Z=q&&V?mhe(lD(l)):null,X=q&&L?iVn({dragItems:l,snapGrid:W,x:$,y:F}):null;for(const[te,J]of l){if(!D.has(te))continue;let ee={x:$-J.distance.x,y:F-J.distance.y};L&&(ee=X?{x:Math.round(ee.x+X.x),y:Math.round(ee.y+X.y)}:cD(ee,W));let ae=null;if(q&&V&&!J.extent&&Z){const{positionAbsolute:ne}=J.internals,ce=ne.x-Z.x+V[0][0],pe=ne.x+J.measured.width-Z.x2+V[1][0],le=ne.y-Z.y+V[0][1],ve=ne.y+J.measured.height-Z.y2+V[1][1];ae=[[ce,le],[pe,ve]]}const{position:de,positionAbsolute:Y}=Zxt({nodeId:te,nextPosition:ee,nodeLookup:D,nodeExtent:ae||V,nodeOrigin:z,onError:G});P=P||J.position.x!==de.x||J.position.y!==de.y,J.position=de,J.internals.positionAbsolute=Y}if(m=m||P,!!P&&(U(l,!0),g&&(r||B||!C&&M))){const[te,J]=AJ({nodeId:C,dragItems:l,nodeLookup:D});r?.(g,l,te,J),B?.(g,te,J),C||M?.(g,J)}}async function N(){if(!d)return;const{transform:$,panBy:F,autoPanSpeed:D,autoPanOnNodeDrag:V}=t();if(!V){c=!1,cancelAnimationFrame(i);return}const[W,L]=Qxt(u,d,D);(W!==0||L!==0)&&(a.x=(a.x??0)-W/$[2],a.y=(a.y??0)-L/$[2],await F({x:W,y:L})&&j(a)),i=requestAnimationFrame(N)}function I($){const{nodeLookup:F,multiSelectionActive:D,nodesDraggable:V,transform:W,snapGrid:L,snapToGrid:z,selectNodesOnDrag:B,onNodeDragStart:M,onSelectionDragStart:G,unselectNodesAndEdges:U}=t();f=!0,(!B||!_)&&!D&&C&&(F.get(C)?.selected||U()),_&&B&&C&&e?.(C);const P=D2($.sourceEvent,{transform:W,snapGrid:L,snapToGrid:z,containerBounds:d});if(a=P,l=aVn(F,V,P,C),l.size>0&&(n||M||!C&&G)){const[q,Z]=AJ({nodeId:C,dragItems:l,nodeLookup:F});n?.($.sourceEvent,l,q,Z),M?.($.sourceEvent,q,Z),C||G?.($.sourceEvent,Z)}}const R=Cxt().clickDistance(E).on("start",$=>{const{domNode:F,nodeDragThreshold:D,transform:V,snapGrid:W,snapToGrid:L}=t();d=F?.getBoundingClientRect()||null,h=!1,m=!1,g=$.sourceEvent,D===0&&I($),a=D2($.sourceEvent,{transform:V,snapGrid:W,snapToGrid:L,containerBounds:d}),u=ug($.sourceEvent,d)}).on("drag",$=>{const{autoPanOnNodeDrag:F,transform:D,snapGrid:V,snapToGrid:W,nodeDragThreshold:L,nodeLookup:z}=t(),B=D2($.sourceEvent,{transform:D,snapGrid:V,snapToGrid:W,containerBounds:d});if(g=$.sourceEvent,($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||C&&!z.has(C))&&(h=!0),!h){if(!c&&F&&f&&(c=!0,N()),!f){const M=ug($.sourceEvent,d),G=M.x-u.x,U=M.y-u.y;Math.sqrt(G*G+U*U)>L&&I($)}(a.x!==B.xSnapped||a.y!==B.ySnapped)&&l&&f&&(u=ug($.sourceEvent,d),j(B))}}).on("end",$=>{if(!(!f||h)&&(c=!1,f=!1,cancelAnimationFrame(i),l.size>0)){const{nodeLookup:F,updateNodePositions:D,onNodeDragStop:V,onSelectionDragStop:W}=t();if(m&&(D(l,!1),m=!1),s||V||!C&&W){const[L,z]=AJ({nodeId:C,dragItems:l,nodeLookup:F,dragging:!1});s?.($.sourceEvent,l,L,z),V?.($.sourceEvent,L,z),C||W?.($.sourceEvent,z)}}}).filter($=>{const F=$.target;return!$.button&&(!w||!F8e(F,`.${w}`,k))&&(!S||F8e(F,S,k))});p.call(R)}function b(){p?.on(".drag",null)}return{update:y,destroy:b}}function lVn(e,t,n){const r=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const a of t.values())eM(s,yT(a))>0&&r.push(a);return r}const cVn=250;function uVn(e,t,n,r){let s=[],a=1/0;const i=lVn(e,n,t+cVn);for(const l of i){const c=[...l.internals.handleBounds?.source??[],...l.internals.handleBounds?.target??[]];for(const u of c){if(r.nodeId===u.nodeId&&r.type===u.type&&r.id===u.id)continue;const{x:d,y:f}=IO(l,u,u.position,!0),p=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(f-e.y,2));p>t||(p<a?(s=[{...u,x:d,y:f}],a=p):p===a&&s.push({...u,x:d,y:f}))}}if(!s.length)return null;if(s.length>1){const l=r.type==="source"?"target":"source";return s.find(c=>c.type===l)??s[0]}return s[0]}function c0t(e,t,n,r,s,a=!1){const i=r.get(e);if(!i)return null;const l=s==="strict"?i.internals.handleBounds?.[t]:[...i.internals.handleBounds?.source??[],...i.internals.handleBounds?.target??[]],c=(n?l?.find(u=>u.id===n):l?.[0])??null;return c&&a?{...c,...IO(i,c,c.position,!0)}:c}function u0t(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function dVn(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const d0t=()=>!0;function fVn(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:a,isTarget:i,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:f,panBy:p,cancelConnection:h,onConnectStart:m,onConnect:g,onConnectEnd:y,isValidConnection:b=d0t,onReconnectEnd:w,updateConnection:S,getTransform:k,getFromHandle:_,autoPanSpeed:C,dragThreshold:E=1,handleDomNode:j}){const N=Jxt(e.target);let I=0,R;const{x:$,y:F}=ug(e),D=u0t(a,j),V=l?.getBoundingClientRect();let W=!1;if(!V||!D)return;const L=c0t(s,D,r,c,t);if(!L)return;let z=ug(e,V),B=!1,M=null,G=!1,U=null;function P(){if(!d||!V)return;const[de,Y]=Qxt(z,V,C);p({x:de,y:Y}),I=requestAnimationFrame(P)}const q={...L,nodeId:s,type:D,position:L.position},Z=c.get(s);let te={inProgress:!0,isValid:null,from:IO(Z,q,nr.Left,!0),fromHandle:q,fromPosition:q.position,fromNode:Z,to:z,toHandle:null,toPosition:E8e[q.position],toNode:null,pointer:z};function J(){W=!0,S(te),m?.(e,{nodeId:s,handleId:r,handleType:D})}E===0&&J();function ee(de){if(!W){const{x:ve,y:ye}=ug(de),Se=ve-$,Ne=ye-F;if(!(Se*Se+Ne*Ne>E*E))return;J()}if(!_()||!q){ae(de);return}const Y=k();z=ug(de,V),R=uVn(uD(z,Y,!1,[1,1]),n,c,q),B||(P(),B=!0);const ne=f0t(de,{handle:R,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:i?"target":"source",isValidConnection:b,doc:N,lib:u,flowId:f,nodeLookup:c});U=ne.handleDomNode,M=ne.connection,G=dVn(!!R,ne.isValid);const ce=c.get(s),pe=ce?IO(ce,q,nr.Left,!0):te.from,le={...te,from:pe,isValid:G,to:ne.toHandle&&G?k7({x:ne.toHandle.x,y:ne.toHandle.y},Y):z,toHandle:ne.toHandle,toPosition:G&&ne.toHandle?ne.toHandle.position:E8e[q.position],toNode:ne.toHandle?c.get(ne.toHandle.nodeId):null,pointer:z};S(le),te=le}function ae(de){if(!("touches"in de&&de.touches.length>0)){if(W){(R||U)&&M&&G&&g?.(M);const{inProgress:Y,...ne}=te,ce={...ne,toPosition:te.toHandle?te.toPosition:null};y?.(de,ce),a&&w?.(de,ce)}h(),cancelAnimationFrame(I),B=!1,G=!1,M=null,U=null,N.removeEventListener("mousemove",ee),N.removeEventListener("mouseup",ae),N.removeEventListener("touchmove",ee),N.removeEventListener("touchend",ae)}}N.addEventListener("mousemove",ee),N.addEventListener("mouseup",ae),N.addEventListener("touchmove",ee),N.addEventListener("touchend",ae)}function f0t(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:a,doc:i,lib:l,flowId:c,isValidConnection:u=d0t,nodeLookup:d}){const f=a==="target",p=t?i.querySelector(`.${l}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:m}=ug(e),g=i.elementFromPoint(h,m),y=g?.classList.contains(`${l}-flow__handle`)?g:p,b={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const w=u0t(void 0,y),S=y.getAttribute("data-nodeid"),k=y.getAttribute("data-handleid"),_=y.classList.contains("connectable"),C=y.classList.contains("connectableend");if(!S||!w)return b;const E={source:f?S:r,sourceHandle:f?k:s,target:f?r:S,targetHandle:f?s:k};b.connection=E;const N=_&&C&&(n===gT.Strict?f&&w==="source"||!f&&w==="target":S!==r||k!==s);b.isValid=N&&u(E),b.toHandle=c0t(S,w,k,d,n,!0)}return b}const bhe={onPointerDown:fVn,isValid:f0t};function pVn({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=fp(e);function a({translateExtent:l,width:c,height:u,zoomStep:d=1,pannable:f=!0,zoomable:p=!0,inversePan:h=!1}){const m=S=>{if(S.sourceEvent.type!=="wheel"||!t)return;const k=n(),_=S.sourceEvent.ctrlKey&&tM()?10:1,C=-S.sourceEvent.deltaY*(S.sourceEvent.deltaMode===1?.05:S.sourceEvent.deltaMode?1:.002)*d,E=k[2]*Math.pow(2,C*_);t.scaleTo(E)};let g=[0,0];const y=S=>{(S.sourceEvent.type==="mousedown"||S.sourceEvent.type==="touchstart")&&(g=[S.sourceEvent.clientX??S.sourceEvent.touches[0].clientX,S.sourceEvent.clientY??S.sourceEvent.touches[0].clientY])},b=S=>{const k=n();if(S.sourceEvent.type!=="mousemove"&&S.sourceEvent.type!=="touchmove"||!t)return;const _=[S.sourceEvent.clientX??S.sourceEvent.touches[0].clientX,S.sourceEvent.clientY??S.sourceEvent.touches[0].clientY],C=[_[0]-g[0],_[1]-g[1]];g=_;const E=r()*Math.max(k[2],Math.log(k[2]))*(h?-1:1),j={x:k[0]-C[0]*E,y:k[1]-C[1]*E},N=[[0,0],[c,u]];t.setViewportConstrained({x:j.x,y:j.y,zoom:k[2]},N,l)},w=Bxt().on("start",y).on("zoom",f?b:null).on("zoom.wheel",p?m:null);s.call(w,{})}function i(){s.on("zoom",null)}return{update:a,destroy:i,pointer:Xm}}const SV=e=>({x:e.x,y:e.y,zoom:e.k}),RJ=({x:e,y:t,zoom:n})=>bV.translate(e,t).scale(n),zE=(e,t)=>e.target.closest(`.${t}`),p0t=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),hVn=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,PJ=(e,t=0,n=hVn,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},h0t=e=>{const t=e.ctrlKey&&tM()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function mVn({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:a,zoomOnPinch:i,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(zE(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(d.ctrlKey&&i){const y=Xm(d),b=h0t(d),w=f*Math.pow(2,b);r.scaleTo(n,w,y,d);return}const p=d.deltaMode===1?20:1;let h=s===Bk.Vertical?0:d.deltaX*p,m=s===Bk.Horizontal?0:d.deltaY*p;!tM()&&d.shiftKey&&s!==Bk.Vertical&&(h=d.deltaY*p,m=0),r.translateBy(n,-(h/f)*a,-(m/f)*a,{internal:!0});const g=SV(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(d,g),e.panScrollTimeout=setTimeout(()=>{u?.(d,g),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l?.(d,g))}}function gVn({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const a=r.type==="wheel",i=!t&&a&&!r.ctrlKey,l=zE(r,e);if(r.ctrlKey&&a&&l&&r.preventDefault(),i||l)return null;r.preventDefault(),n.call(this,r,s)}}function vVn({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;const s=SV(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=s,r.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(r.sourceEvent,s)}}function yVn({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return a=>{e.usedRightMouseButton=!!(n&&p0t(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),s&&!a.sourceEvent?.internal&&s?.(a.sourceEvent,SV(a.transform))}}function bVn({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:a}){return i=>{if(!i.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&p0t(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&a(i.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const l=SV(i.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s?.(i.sourceEvent,l)},n?150:0)}}}function xVn({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:a,userSelectionActive:i,noWheelClassName:l,noPanClassName:c,lib:u,connectionInProgress:d}){return f=>{const p=e||t,h=n&&f.ctrlKey,m=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(zE(f,`${u}-flow__node`)||zE(f,`${u}-flow__edge`)))return!0;if(!r&&!p&&!s&&!a&&!n||i||d&&!m||zE(f,l)&&m||zE(f,c)&&(!m||s&&m&&!e)||!n&&f.ctrlKey&&m)return!1;if(!n&&f.type==="touchstart"&&f.touches?.length>1)return f.preventDefault(),!1;if(!p&&!s&&!h&&m||!r&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(r)&&!r.includes(f.button)&&f.type==="mousedown")return!1;const g=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||m)&&g}}function wVn({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:s,onPanZoom:a,onPanZoomStart:i,onPanZoomEnd:l,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),f=Bxt().scaleExtent([t,n]).translateExtent(r),p=fp(e).call(f);w({x:s.x,y:s.y,zoom:vT(s.zoom,t,n)},[[0,0],[d.width,d.height]],r);const h=p.on("wheel.zoom"),m=p.on("dblclick.zoom");f.wheelDelta(h0t);function g(R,$){return p?new Promise(F=>{f?.interpolate($?.interpolate==="linear"?rx:L9).transform(PJ(p,$?.duration,$?.ease,()=>F(!0)),R)}):Promise.resolve(!1)}function y({noWheelClassName:R,noPanClassName:$,onPaneContextMenu:F,userSelectionActive:D,panOnScroll:V,panOnDrag:W,panOnScrollMode:L,panOnScrollSpeed:z,preventScrolling:B,zoomOnPinch:M,zoomOnScroll:G,zoomOnDoubleClick:U,zoomActivationKeyPressed:P,lib:q,onTransformChange:Z,connectionInProgress:X,paneClickDistance:te,selectionOnDrag:J}){D&&!u.isZoomingOrPanning&&b();const ee=V&&!P&&!D;f.clickDistance(J?1/0:!cg(te)||te<0?0:te);const ae=ee?mVn({zoomPanValues:u,noWheelClassName:R,d3Selection:p,d3Zoom:f,panOnScrollMode:L,panOnScrollSpeed:z,zoomOnPinch:M,onPanZoomStart:i,onPanZoom:a,onPanZoomEnd:l}):gVn({noWheelClassName:R,preventScrolling:B,d3ZoomHandler:h});if(p.on("wheel.zoom",ae,{passive:!1}),!D){const Y=vVn({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:i});f.on("start",Y);const ne=yVn({zoomPanValues:u,panOnDrag:W,onPaneContextMenu:!!F,onPanZoom:a,onTransformChange:Z});f.on("zoom",ne);const ce=bVn({zoomPanValues:u,panOnDrag:W,panOnScroll:V,onPaneContextMenu:F,onPanZoomEnd:l,onDraggingChange:c});f.on("end",ce)}const de=xVn({zoomActivationKeyPressed:P,panOnDrag:W,zoomOnScroll:G,panOnScroll:V,zoomOnDoubleClick:U,zoomOnPinch:M,userSelectionActive:D,noPanClassName:$,noWheelClassName:R,lib:q,connectionInProgress:X});f.filter(de),U?p.on("dblclick.zoom",m):p.on("dblclick.zoom",null)}function b(){f.on("zoom",null)}async function w(R,$,F){const D=RJ(R),V=f?.constrain()(D,$,F);return V&&await g(V),new Promise(W=>W(V))}async function S(R,$){const F=RJ(R);return await g(F,$),new Promise(D=>D(F))}function k(R){if(p){const $=RJ(R),F=p.property("__zoom");(F.k!==R.zoom||F.x!==R.x||F.y!==R.y)&&f?.transform(p,$,null,{sync:!0})}}function _(){const R=p?zxt(p.node()):{x:0,y:0,k:1};return{x:R.x,y:R.y,zoom:R.k}}function C(R,$){return p?new Promise(F=>{f?.interpolate($?.interpolate==="linear"?rx:L9).scaleTo(PJ(p,$?.duration,$?.ease,()=>F(!0)),R)}):Promise.resolve(!1)}function E(R,$){return p?new Promise(F=>{f?.interpolate($?.interpolate==="linear"?rx:L9).scaleBy(PJ(p,$?.duration,$?.ease,()=>F(!0)),R)}):Promise.resolve(!1)}function j(R){f?.scaleExtent(R)}function N(R){f?.translateExtent(R)}function I(R){const $=!cg(R)||R<0?0:R;f?.clickDistance($)}return{update:y,destroy:b,setViewport:S,setViewportConstrained:w,getViewport:_,scaleTo:C,scaleBy:E,setScaleExtent:j,setTranslateExtent:N,syncViewport:k,setClickDistance:I}}var xT;(function(e){e.Line="line",e.Handle="handle"})(xT||(xT={}));function SVn({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:s,affectsY:a}){const i=e-t,l=n-r,c=[i>0?1:i<0?-1:0,l>0?1:l<0?-1:0];return i&&s&&(c[0]=c[0]*-1),l&&a&&(c[1]=c[1]*-1),c}function z8e(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:s}}function D0(e,t){return Math.max(0,t-e)}function L0(e,t){return Math.max(0,e-t)}function x6(e,t,n){return Math.max(0,t-e,e-n)}function B8e(e,t){return e?!t:t}function kVn(e,t,n,r,s,a,i,l){let{affectsX:c,affectsY:u}=t;const{isHorizontal:d,isVertical:f}=t,p=d&&f,{xSnapped:h,ySnapped:m}=n,{minWidth:g,maxWidth:y,minHeight:b,maxHeight:w}=r,{x:S,y:k,width:_,height:C,aspectRatio:E}=e;let j=Math.floor(d?h-e.pointerX:0),N=Math.floor(f?m-e.pointerY:0);const I=_+(c?-j:j),R=C+(u?-N:N),$=-a[0]*_,F=-a[1]*C;let D=x6(I,g,y),V=x6(R,b,w);if(i){let z=0,B=0;c&&j<0?z=D0(S+j+$,i[0][0]):!c&&j>0&&(z=L0(S+I+$,i[1][0])),u&&N<0?B=D0(k+N+F,i[0][1]):!u&&N>0&&(B=L0(k+R+F,i[1][1])),D=Math.max(D,z),V=Math.max(V,B)}if(l){let z=0,B=0;c&&j>0?z=L0(S+j,l[0][0]):!c&&j<0&&(z=D0(S+I,l[1][0])),u&&N>0?B=L0(k+N,l[0][1]):!u&&N<0&&(B=D0(k+R,l[1][1])),D=Math.max(D,z),V=Math.max(V,B)}if(s){if(d){const z=x6(I/E,b,w)*E;if(D=Math.max(D,z),i){let B=0;!c&&!u||c&&!u&&p?B=L0(k+F+I/E,i[1][1])*E:B=D0(k+F+(c?j:-j)/E,i[0][1])*E,D=Math.max(D,B)}if(l){let B=0;!c&&!u||c&&!u&&p?B=D0(k+I/E,l[1][1])*E:B=L0(k+(c?j:-j)/E,l[0][1])*E,D=Math.max(D,B)}}if(f){const z=x6(R*E,g,y)/E;if(V=Math.max(V,z),i){let B=0;!c&&!u||u&&!c&&p?B=L0(S+R*E+$,i[1][0])/E:B=D0(S+(u?N:-N)*E+$,i[0][0])/E,V=Math.max(V,B)}if(l){let B=0;!c&&!u||u&&!c&&p?B=D0(S+R*E,l[1][0])/E:B=L0(S+(u?N:-N)*E,l[0][0])/E,V=Math.max(V,B)}}}N=N+(N<0?V:-V),j=j+(j<0?D:-D),s&&(p?I>R*E?N=(B8e(c,u)?-j:j)/E:j=(B8e(c,u)?-N:N)*E:d?(N=j/E,u=c):(j=N*E,c=u));const W=c?S+j:S,L=u?k+N:k;return{width:_+(c?-j:j),height:C+(u?-N:N),x:a[0]*j*(c?-1:1)+W,y:a[1]*N*(u?-1:1)+L}}const m0t={width:0,height:0,x:0,y:0},OVn={...m0t,pointerX:0,pointerY:0,aspectRatio:1};function _Vn(e){return[[0,0],[e.measured.width,e.measured.height]]}function CVn(e,t,n){const r=t.position.x+e.position.x,s=t.position.y+e.position.y,a=e.measured.width??0,i=e.measured.height??0,l=n[0]*a,c=n[1]*i;return[[r-l,s-c],[r+a-l,s+i-c]]}function EVn({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const a=fp(e);let i={controlDirection:z8e("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:u,boundaries:d,keepAspectRatio:f,resizeDirection:p,onResizeStart:h,onResize:m,onResizeEnd:g,shouldResize:y}){let b={...m0t},w={...OVn};i={boundaries:d,resizeDirection:p,keepAspectRatio:f,controlDirection:z8e(u)};let S,k=null,_=[],C,E,j,N=!1;const I=Cxt().on("start",R=>{const{nodeLookup:$,transform:F,snapGrid:D,snapToGrid:V,nodeOrigin:W,paneDomNode:L}=n();if(S=$.get(t),!S)return;k=L?.getBoundingClientRect()??null;const{xSnapped:z,ySnapped:B}=D2(R.sourceEvent,{transform:F,snapGrid:D,snapToGrid:V,containerBounds:k});b={width:S.measured.width??0,height:S.measured.height??0,x:S.position.x??0,y:S.position.y??0},w={...b,pointerX:z,pointerY:B,aspectRatio:b.width/b.height},C=void 0,S.parentId&&(S.extent==="parent"||S.expandParent)&&(C=$.get(S.parentId),E=C&&S.extent==="parent"?_Vn(C):void 0),_=[],j=void 0;for(const[M,G]of $)if(G.parentId===t&&(_.push({id:M,position:{...G.position},extent:G.extent}),G.extent==="parent"||G.expandParent)){const U=CVn(G,S,G.origin??W);j?j=[[Math.min(U[0][0],j[0][0]),Math.min(U[0][1],j[0][1])],[Math.max(U[1][0],j[1][0]),Math.max(U[1][1],j[1][1])]]:j=U}h?.(R,{...b})}).on("drag",R=>{const{transform:$,snapGrid:F,snapToGrid:D,nodeOrigin:V}=n(),W=D2(R.sourceEvent,{transform:$,snapGrid:F,snapToGrid:D,containerBounds:k}),L=[];if(!S)return;const{x:z,y:B,width:M,height:G}=b,U={},P=S.origin??V,{width:q,height:Z,x:X,y:te}=kVn(w,i.controlDirection,W,i.boundaries,i.keepAspectRatio,P,E,j),J=q!==M,ee=Z!==G,ae=X!==z&&J,de=te!==B&ⅇif(!ae&&!de&&!J&&!ee)return;if((ae||de||P[0]===1||P[1]===1)&&(U.x=ae?X:b.x,U.y=de?te:b.y,b.x=U.x,b.y=U.y,_.length>0)){const pe=X-z,le=te-B;for(const ve of _)ve.position={x:ve.position.x-pe+P[0]*(q-M),y:ve.position.y-le+P[1]*(Z-G)},L.push(ve)}if((J||ee)&&(U.width=J&&(!i.resizeDirection||i.resizeDirection==="horizontal")?q:b.width,U.height=ee&&(!i.resizeDirection||i.resizeDirection==="vertical")?Z:b.height,b.width=U.width,b.height=U.height),C&&S.expandParent){const pe=P[0]*(U.width??0);U.x&&U.x<pe&&(b.x=pe,w.x=w.x-(U.x-pe));const le=P[1]*(U.height??0);U.y&&U.y<le&&(b.y=le,w.y=w.y-(U.y-le))}const Y=SVn({width:b.width,prevWidth:M,height:b.height,prevHeight:G,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),ne={...b,direction:Y};y?.(R,ne)!==!1&&(N=!0,m?.(R,ne),r(U,L))}).on("end",R=>{N&&(g?.(R,{...b}),s?.({...b}),N=!1)});a.call(I)}function c(){a.on(".drag",null)}return{update:l,destroy:c}}const jVn={},U8e=e=>{let t;const n=new Set,r=(d,f)=>{const p=typeof d=="function"?d(t):d;if(!Object.is(p,t)){const h=t;t=f??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(m=>m(t,h))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(jVn?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(r,s,c);return c},TVn=e=>e?U8e(e):U8e,{useDebugValue:NVn}=Le,{useSyncExternalStoreWithSelector:IVn}=swn,AVn=e=>e;function g0t(e,t=AVn,n){const r=IVn(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return NVn(r),r}const q8e=(e,t)=>{const n=TVn(e),r=(s,a=t)=>g0t(n,s,a);return Object.assign(r,n),r},RVn=(e,t)=>e?q8e(e,t):q8e;function to(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,s]of e)if(!Object.is(s,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const kV=v.createContext(null),PVn=kV.Provider,v0t=py.error001();function Us(e,t){const n=v.useContext(kV);if(n===null)throw new Error(v0t);return g0t(n,e,t)}function wo(){const e=v.useContext(kV);if(e===null)throw new Error(v0t);return v.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const V8e={display:"none"},$Vn={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},y0t="react-flow__node-desc",b0t="react-flow__edge-desc",MVn="react-flow__aria-live",DVn=e=>e.ariaLiveMessage,LVn=e=>e.ariaLabelConfig;function FVn({rfId:e}){const t=Us(DVn);return o.jsx("div",{id:`${MVn}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:$Vn,children:t})}function zVn({rfId:e,disableKeyboardA11y:t}){const n=Us(LVn);return o.jsxs(o.Fragment,{children:[o.jsx("div",{id:`${y0t}-${e}`,style:V8e,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),o.jsx("div",{id:`${b0t}-${e}`,style:V8e,children:n["edge.a11yDescription.default"]}),!t&&o.jsx(FVn,{rfId:e})]})}const dD=v.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},a)=>{const i=`${e}`.split("-");return o.jsx("div",{className:Pl(["react-flow__panel",n,...i]),style:r,ref:a,...s,children:t})});dD.displayName="Panel";function BVn({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:o.jsx(dD,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:o.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const UVn=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},w6=e=>e.id;function qVn(e,t){return to(e.selectedNodes.map(w6),t.selectedNodes.map(w6))&&to(e.selectedEdges.map(w6),t.selectedEdges.map(w6))}function VVn({onSelectionChange:e}){const t=wo(),{selectedNodes:n,selectedEdges:r}=Us(UVn,qVn);return v.useEffect(()=>{const s={nodes:n,edges:r};e?.(s),t.getState().onSelectionChangeHandlers.forEach(a=>a(s))},[n,r,e]),null}const HVn=e=>!!e.onSelectionChangeHandlers;function WVn({onSelectionChange:e}){const t=Us(HVn);return e||t?o.jsx(VVn,{onSelectionChange:e}):null}const xhe=typeof window<"u"?v.useLayoutEffect:v.useEffect,x0t=[0,0],ZVn={x:0,y:0,zoom:1},GVn=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],H8e=[...GVn,"rfId"],QVn=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),W8e={translateExtent:X$,nodeOrigin:x0t,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function YVn(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:a,setNodeExtent:i,reset:l,setDefaultNodesAndEdges:c}=Us(QVn,to),u=wo();xhe(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=W8e,l()}),[]);const d=v.useRef(W8e);return xhe(()=>{for(const f of H8e){const p=e[f],h=d.current[f];p!==h&&(typeof e[f]>"u"||(f==="nodes"?t(p):f==="edges"?n(p):f==="minZoom"?r(p):f==="maxZoom"?s(p):f==="translateExtent"?a(p):f==="nodeExtent"?i(p):f==="ariaLabelConfig"?u.setState({ariaLabelConfig:Fqn(p)}):f==="fitView"?u.setState({fitViewQueued:p}):f==="fitViewOptions"?u.setState({fitViewOptions:p}):u.setState({[f]:p})))}d.current=e},H8e.map(f=>e[f])),null}function Z8e(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function XVn(e){const[t,n]=v.useState(e==="system"?null:e);return v.useEffect(()=>{if(e!=="system"){n(e);return}const r=Z8e(),s=()=>n(r?.matches?"dark":"light");return s(),r?.addEventListener("change",s),()=>{r?.removeEventListener("change",s)}},[e]),t!==null?t:Z8e()?.matches?"dark":"light"}const G8e=typeof document<"u"?document:null;function nM(e=null,t={target:G8e,actInsideInputWithModifier:!0}){const[n,r]=v.useState(!1),s=v.useRef(!1),a=v.useRef(new Set([])),[i,l]=v.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
|
|
337
337
|
`).replace(`
|
|
338
338
|
|
|
339
339
|
`,`
|
|
@@ -724,7 +724,7 @@ window.parent.postMessage({jsonrpc:'2.0',method:'ui/notifications/sandbox-proxy-
|
|
|
724
724
|
"groundTruth": "Expected result (optional)",
|
|
725
725
|
"metadata": { "key": "value" } // optional
|
|
726
726
|
}
|
|
727
|
-
]`})]})]})}function ies({errors:e,maxErrors:t=5}){if(e.length===0)return null;const n=e.slice(0,t),r=e.length-t;return o.jsxs("div",{className:"bg-accent2/10 border border-accent2/30 rounded-md p-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-accent2 mb-2",children:[o.jsx(Ue,{children:o.jsx(kp,{className:"w-4 h-4"})}),o.jsxs("span",{className:"font-medium text-sm",children:[e.length," validation error",e.length!==1?"s":""]})]}),o.jsx("ul",{className:"text-sm text-accent2/80 space-y-1",children:n.map((s,a)=>o.jsxs("li",{className:"flex gap-2",children:[o.jsx("span",{className:"shrink-0",children:"•"}),o.jsx("span",{children:s.message})]},a))}),r>0&&o.jsxs("div",{className:"text-xs text-accent2/60 mt-2",children:["+",r," more error",r!==1?"s":""]})]})}function oes({datasetId:e,open:t,onOpenChange:n,onSuccess:r}){const[s,a]=v.useState("upload"),[i,l]=v.useState(null),[c,u]=v.useState({current:0,total:0}),[d,f]=v.useState(null),[p,h]=v.useState(!1),{parseFile:m,isParsing:g,error:y}=RKr(),{batchInsertItems:b}=_i(),w=v.useCallback(async I=>{try{const R=await m(I);l(R),a("preview")}catch{}},[m]),S=v.useCallback(async()=>{if(!i||i.items.length===0)return;a("importing"),h(!0);const{items:I}=i;u({current:0,total:I.length});try{await b.mutateAsync({datasetId:e,items:I.map(R=>({input:R.input,groundTruth:R.groundTruth,metadata:R.metadata}))}),f({success:I.length,errors:0})}catch{f({success:0,errors:I.length})}u({current:I.length,total:I.length}),h(!1),a("complete")},[i,b,e]),k=v.useCallback(()=>{n(!1),r?.(),d&&d.success>0&&De.success(`Imported ${d.success} item${d.success!==1?"s":""}`),setTimeout(()=>{a("upload"),l(null),u({current:0,total:0}),f(null)},150)},[n,r,d]),_=v.useCallback(()=>{p||(n(!1),setTimeout(()=>{a("upload"),l(null),u({current:0,total:0}),f(null)},150))},[p,n]),C=i&&i.items.length>0&&i.errors.length===0,E=()=>{switch(s){case"upload":return o.jsx(aes,{onFileSelect:w,isParsing:g,error:y?.message});case"preview":return i?o.jsx("div",{className:"flex flex-col gap-4",children:i.errors.length>0?o.jsxs(o.Fragment,{children:[o.jsx(ies,{errors:i.errors}),o.jsx("div",{className:"text-sm text-neutral4",children:"Please fix the errors in your JSON file and try again."})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"text-sm text-neutral4",children:["Found ",i.items.length," valid item",i.items.length!==1?"s":""," to import."]}),o.jsx(ses,{items:i.items,maxRows:5})]})}):null;case"importing":return o.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[o.jsx(Gt,{}),o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-lg font-medium text-neutral1",children:"Importing items..."}),o.jsxs("div",{className:"text-sm text-neutral4 mt-1",children:[c.current," of ",c.total]})]})]});case"complete":return o.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[o.jsx("div",{className:"text-4xl",children:d&&d.errors===0?"✓":"⚠"}),o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-lg font-medium text-neutral1",children:"Import Complete"}),o.jsxs("div",{className:"text-sm text-neutral4 mt-1",children:[d?.success??0," item",d?.success!==1?"s":""," imported",d&&d.errors>0&&o.jsxs("span",{className:"text-accent2",children:[" ","(",d.errors," error",d.errors!==1?"s":"",")"]})]})]})]})}},j=()=>{switch(s){case"upload":return o.jsx(ue,{onClick:_,children:"Cancel"});case"preview":return o.jsxs(o.Fragment,{children:[o.jsx(ue,{onClick:()=>a("upload"),children:"Back"}),o.jsxs(ue,{variant:"primary",onClick:S,disabled:!C,children:["Import ",i?.items.length??0," Item",i?.items.length!==1?"s":""]})]});case"importing":return null;case"complete":return o.jsx(ue,{variant:"primary",onClick:k,children:"Done"})}},N={upload:"Import JSON",preview:"Preview Data",importing:"Importing",complete:"Import Complete"};return o.jsx(br,{open:t,onOpenChange:_,children:o.jsxs(xr,{className:"max-w-2xl max-h-[90vh]",children:[o.jsxs(wr,{children:[o.jsx(gr,{children:N[s]}),o.jsx(Qs,{children:"Import dataset items from a JSON file."})]}),o.jsx(Ar,{className:"min-h-[200px] max-h-[50vh] overflow-y-auto",children:E()}),o.jsx(kc,{className:"px-6 pt-4 flex justify-end gap-2",children:j()})]})})}const fTe=e=>{const t=We(),{data:n}=GM(e),r=n?.experiments;return wt({queryKey:["dataset-review-items",e,r?.map(s=>s.id)],queryFn:async()=>!r||r.length===0?[]:(await Promise.all(r.map(async a=>{if(!a.datasetId)return[];try{const{results:i}=await t.listDatasetExperimentResults(a.datasetId,a.id);return i.filter(l=>l.status==="needs-review").map(l=>({id:l.id,input:l.input,output:l.output,error:l.error,itemId:l.itemId,experimentId:l.experimentId,datasetId:a.datasetId??void 0,traceId:l.traceId??void 0,scores:l.scores?Object.fromEntries(l.scores.map(c=>[c.scorerId,c.score??0])):{},tags:l.tags??[],comment:""}))}catch{return[]}}))).flat(),enabled:!!e&&!!r&&r.length>0,refetchOnWindowFocus:!1})},les=e=>{const t=We(),{data:n}=GM(e),r=n?.experiments;return wt({queryKey:["dataset-completed-items",e,r?.map(s=>s.id)],queryFn:async()=>!r||r.length===0?[]:(await Promise.all(r.map(async a=>{if(!a.datasetId)return[];try{const{results:i}=await t.listDatasetExperimentResults(a.datasetId,a.id);return i.filter(l=>l.status==="complete").map(l=>({id:l.id,input:l.input,output:l.output,error:l.error,itemId:l.itemId,experimentId:l.experimentId,datasetId:a.datasetId??void 0,traceId:l.traceId??void 0,scores:l.scores?Object.fromEntries(l.scores.map(c=>[c.scorerId,c.score??0])):{},tags:l.tags??[],comment:""}))}catch{return[]}}))).flat(),enabled:!!e&&!!r&&r.length>0,refetchOnWindowFocus:!1})};function ces(e,t){if(typeof e=="string")return e.length>t?e.slice(0,t)+"...":e;try{const n=JSON.stringify(e);return n.length>t?n.slice(0,t)+"...":n}catch{return String(e)}}function i8t({datasetId:e,experimentId:t,featuredItemId:n}){const r=We(),{data:s}=Ux(e),{data:a,isLoading:i}=fTe(e),{data:l,isLoading:c}=les(e),u=v.useMemo(()=>t?(a??[]).filter(Ce=>Ce.experimentId===t):a,[a,t]),d=v.useMemo(()=>t?(l??[]).filter(Ce=>Ce.experimentId===t):l,[l,t]),{updateExperimentResult:f}=_i(),[p,h]=v.useState(n??null);v.useEffect(()=>{n!==void 0&&h(n)},[n]);const[m,g]=v.useState(null),[y,b]=v.useState(new Set),[w,S]=v.useState(!1),[k,_]=v.useState(!1),[C,E]=v.useState(!1),[j,N]=v.useState(""),[I,R]=v.useState(""),[$,F]=v.useState(""),[D,V]=v.useState([]),[W,L]=v.useState(!1),[z,B]=v.useState(null),M=v.useMemo(()=>z??u??[],[z,u]);v.useEffect(()=>{B(null)},[e,t]),v.useEffect(()=>{u&&z===null&&B(u)},[u,z]);const G=v.useMemo(()=>{const Ce=new Set;if(s?.tags)for(const je of s.tags)Ce.add(je);for(const je of M)for(const _e of je.tags)Ce.add(_e);return[...Ce].sort()},[s,M]),U=v.useCallback(Ce=>{!s||!e||(s.tags??[]).includes(Ce)},[s,e]),P=v.useMemo(()=>m?m==="__untagged__"?M.filter(Ce=>Ce.tags.length===0):M.filter(Ce=>Ce.tags.includes(m)):M,[M,m]),q=v.useMemo(()=>{const Ce=new Map;for(const je of M)for(const _e of je.tags)Ce.set(_e,(Ce.get(_e)??0)+1);return[...Ce.entries()].sort((je,_e)=>_e[1]-je[1])},[M]),Z=v.useMemo(()=>M.filter(Ce=>Ce.tags.length===0).length,[M]),X=v.useMemo(()=>{let Ce=0;return m&&Ce++,w&&Ce++,Ce},[m,w]),te=v.useCallback((Ce,je)=>{B(Oe=>(Oe??[]).map(Re=>Re.id===Ce?{...Re,tags:je}:Re));const _e=M.find(Oe=>Oe.id===Ce);_e?.experimentId&&_e?.datasetId&&f.mutate({datasetId:_e.datasetId,experimentId:_e.experimentId,resultId:_e.id,tags:je})},[M,f]),J=v.useCallback((Ce,je)=>{const _e=M.find(Oe=>Oe.id===Ce);_e?.traceId&&je!==void 0&&r.createFeedback({feedback:{traceId:_e.traceId,source:"studio",feedbackSource:"studio",feedbackType:"rating",value:je==="positive"?1:-1,experimentId:_e.experimentId??void 0,sourceId:_e.id}}).catch(()=>{}),B(Oe=>(Oe??[]).map(Re=>Re.id===Ce?{...Re,rating:je}:Re))},[M,r]),ee=v.useCallback((Ce,je)=>{const _e=M.find(Oe=>Oe.id===Ce);_e?.traceId&&r.createFeedback({feedback:{traceId:_e.traceId,source:"studio",feedbackSource:"studio",feedbackType:"comment",value:je,comment:je,experimentId:_e.experimentId??void 0,sourceId:_e.id}}).catch(()=>{}),B(Oe=>(Oe??[]).map(Re=>Re.id===Ce?{...Re,comment:je}:Re))},[M,r]),ae=v.useCallback(Ce=>{const je=M.find(_e=>_e.id===Ce);B(_e=>(_e??[]).filter(Oe=>Oe.id!==Ce)),b(_e=>{const Oe=new Set(_e);return Oe.delete(Ce),Oe}),p===Ce&&h(null),je?.experimentId&&je?.datasetId&&f.mutate({datasetId:je.datasetId,experimentId:je.experimentId,resultId:je.id,status:null})},[M,f,p]),de=v.useCallback(Ce=>{const je=M.find(_e=>_e.id===Ce);B(_e=>(_e??[]).filter(Oe=>Oe.id!==Ce)),b(_e=>{const Oe=new Set(_e);return Oe.delete(Ce),Oe}),p===Ce&&h(null),je?.experimentId&&je?.datasetId&&f.mutate({datasetId:je.datasetId,experimentId:je.experimentId,resultId:je.id,status:"complete"})},[M,f,p]),Y=v.useMemo(()=>{const Ce=w?d??[]:P;return!w||!m?Ce:m==="__untagged__"?Ce.filter(je=>je.tags.length===0):Ce.filter(je=>je.tags.includes(m))},[w,d,P,m]),ne=w?c:!1,ce=v.useMemo(()=>new Set(Y.map(Ce=>Ce.id)),[Y]),pe=v.useMemo(()=>[...y].filter(Ce=>ce.has(Ce)).length,[y,ce]),le=Y.length>0&&pe===Y.length,ve=pe>0&&!le,ye=v.useCallback(Ce=>{b(je=>{const _e=new Set(je);return _e.has(Ce)?_e.delete(Ce):_e.add(Ce),_e})},[]),Se=v.useCallback(()=>{b(le?new Set:new Set(Y.map(Ce=>Ce.id)))},[le,Y]),Ne=v.useCallback(Ce=>{for(const je of y){const _e=M.find(Oe=>Oe.id===je);_e&&!_e.tags.includes(Ce)&&te(je,[..._e.tags,Ce])}},[M,y,te]),ke=v.useCallback(Ce=>{for(const je of y){const _e=M.find(Oe=>Oe.id===je);_e&&_e.tags.includes(Ce)&&te(je,_e.tags.filter(Oe=>Oe!==Ce))}},[M,y,te]),Ie=v.useCallback(()=>{for(const Ce of y)de(Ce);b(new Set)},[y,de]),ze=v.useCallback(()=>{for(const Ce of y)ae(Ce);b(new Set)},[y,ae]),oe=v.useCallback(()=>{N(""),E(!0)},[]),se=v.useCallback(async()=>{if(!(!I||!$)){_(!0),E(!1);try{const Ce=M.filter(_e=>y.has(_e.id));if(Ce.length===0){_(!1);return}const je=await r.clusterFailures({modelId:`${I}/${$}`,items:Ce.map(_e=>({id:_e.id,input:_e.input,output:_e.output??void 0,error:typeof _e.error=="string"?_e.error:_e.error?String(_e.error):void 0,scores:_e.scores,existingTags:_e.tags.length>0?_e.tags:void 0})),availableTags:G.length>0?G:void 0,prompt:j||void 0});je.proposedTags&&je.proposedTags.length>0&&(V(je.proposedTags.map(_e=>({..._e,accepted:!0}))),L(!0))}catch(Ce){console.error("Analysis failed:",Ce)}finally{_(!1)}}},[I,$,M,y,r,G,j]),re=v.useCallback(()=>{for(const Ce of D){if(!Ce.accepted)continue;const je=M.find(_e=>_e.id===Ce.itemId);if(je){const _e=[...new Set([...je.tags,...Ce.tags])];te(je.id,_e)}}L(!1)},[D,M,te]),he=v.useCallback(Ce=>{h(je=>je===Ce?null:Ce)},[]),xe=v.useMemo(()=>p?Y.find(Ce=>Ce.id===p)??null:null,[p,Y]),Ee=p?Y.findIndex(Ce=>Ce.id===p):-1,Pe=Ee>0?()=>h(Y[Ee-1].id):void 0,Qe=Ee>=0&&Ee<Y.length-1?()=>h(Y[Ee+1].id):void 0,Ze="auto minmax(15rem,1fr) 10rem 8rem 6rem 6rem";return i?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Gt,{className:"w-6 h-6"})}):o.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[o.jsx(br,{open:C,onOpenChange:E,children:o.jsxs(xr,{children:[o.jsxs(wr,{children:[o.jsx(gr,{children:"Analyze Items"}),o.jsx(Qs,{children:"Use an LLM to automatically suggest tags for the selected items."})]}),o.jsxs("div",{className:"space-y-4 py-2",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx(Rt,{className:"text-xs mb-1 block",children:"Provider"}),o.jsx(Fy,{value:I,onValueChange:R})]}),o.jsxs("div",{children:[o.jsx(Rt,{className:"text-xs mb-1 block",children:"Model"}),o.jsx(zy,{llmId:I,value:$,onValueChange:F})]})]}),o.jsxs(ge,{variant:"ui-xs",className:"text-neutral3",children:[y.size," item",y.size!==1?"s":""," will be analyzed"]}),o.jsxs("div",{children:[o.jsx(Rt,{className:"text-xs",children:"Instructions (optional)"}),o.jsx(Yl,{value:j,onChange:Ce=>N(Ce.target.value),placeholder:"E.g., Focus on safety issues and factual errors...",rows:3,className:"text-xs mt-1"})]})]}),o.jsxs(kc,{children:[o.jsx(ue,{variant:"outline",onClick:()=>E(!1),children:"Cancel"}),o.jsxs(ue,{onClick:se,disabled:!I||!$||k,children:[k?o.jsx(Gt,{className:"w-4 h-4 mr-1"}):null,"Analyze"]})]})]})}),o.jsx(br,{open:W,onOpenChange:L,children:o.jsxs(xr,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[o.jsxs(wr,{children:[o.jsx(gr,{children:"Review Proposed Tags"}),o.jsxs(Qs,{children:[D.filter(Ce=>Ce.accepted).length," of ",D.length," proposals selected"]})]}),o.jsx("div",{className:"space-y-3 py-2",children:D.map((Ce,je)=>{const _e=M.find(Oe=>Oe.id===Ce.itemId);return o.jsx("div",{className:K("p-3 border rounded-lg",!Ce.accepted&&"opacity-50"),children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx($o,{checked:Ce.accepted,onCheckedChange:Oe=>V(Re=>Re.map((qe,Ke)=>Ke===je?{...qe,accepted:!!Oe}:qe))}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 truncate block",children:_e?typeof _e.input=="string"?_e.input.slice(0,100):JSON.stringify(_e.input).slice(0,100):Ce.itemId}),o.jsx("div",{className:"flex gap-1 flex-wrap mt-1.5",children:Ce.tags.map((Oe,Re)=>o.jsx(z6t,{tag:Oe,onRename:qe=>V(Ke=>Ke.map((Ge,Ot)=>Ot===je?{...Ge,tags:Ge.tags.map((yt,rn)=>rn===Re?qe:yt)}:Ge)),onRemove:()=>V(qe=>qe.map((Ke,Ge)=>Ge===je?{...Ke,tags:Ke.tags.filter((Ot,yt)=>yt!==Re)}:Ke))},`${Oe}-${Re}`))}),Ce.reason&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-1 block italic",children:Ce.reason})]})]})},Ce.itemId)})}),o.jsxs(kc,{children:[o.jsx(ue,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),o.jsxs(ue,{onClick:re,disabled:D.filter(Ce=>Ce.accepted).length===0,children:["Accept ",D.filter(Ce=>Ce.accepted).length," proposals"]})]})]})}),o.jsxs("div",{className:K("grid w-full h-full grid-cols-1 gap-4 overflow-y-auto",xe&&"grid-cols-[1fr_1fr]"),children:[o.jsxs("div",{className:"grid gap-8 content-start w-full overflow-y-auto",children:[o.jsxs("div",{className:"flex items-center justify-between w-full flex-wrap gap-4 gap-x-6",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs(ft,{children:[o.jsx(ft.Trigger,{asChild:!0,children:o.jsxs(ue,{variant:"outline",size:"md",children:[o.jsx(blt,{}),"Filter",X>0&&o.jsx("span",{className:K("ml-0.5 inline-flex items-center justify-center rounded-full bg-accent1/50 text-neutral5 text-ui-sm w-5 h-5"),children:X})]})}),o.jsxs(ft.Content,{align:"start",className:K("min-w-48"),children:[o.jsxs(ft.Sub,{children:[o.jsxs(ft.SubTrigger,{children:["Status",w&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(ft.SubContent,{children:[o.jsx(ft.CheckboxItem,{checked:!w,onCheckedChange:()=>{S(!1),h(null)},onSelect:Ce=>Ce.preventDefault(),children:"Review Queue"}),o.jsx(ft.CheckboxItem,{checked:w,onCheckedChange:()=>{S(!0),h(null)},onSelect:Ce=>Ce.preventDefault(),children:"Completed"})]})]}),o.jsxs(ft.Sub,{children:[o.jsxs(ft.SubTrigger,{children:["Tags",m&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(ft.SubContent,{children:[o.jsx(ft.CheckboxItem,{checked:!m,onCheckedChange:()=>g(null),onSelect:Ce=>Ce.preventDefault(),children:"All"}),Z>0&&o.jsx(ft.CheckboxItem,{checked:m==="__untagged__",onCheckedChange:()=>g(m==="__untagged__"?null:"__untagged__"),onSelect:Ce=>Ce.preventDefault(),children:"Untagged"}),q.length>0&&o.jsx(ft.Separator,{}),q.map(([Ce])=>o.jsx(ft.CheckboxItem,{checked:m===Ce,onCheckedChange:()=>g(m===Ce?null:Ce),onSelect:je=>je.preventDefault(),children:Ce},Ce))]})]}),X>0&&o.jsxs(o.Fragment,{children:[o.jsx(ft.Separator,{}),o.jsxs(ft.Item,{onSelect:()=>{g(null),S(!1),h(null)},children:[o.jsx(vs,{}),"Clear all filters"]})]})]})]}),X>0&&o.jsxs(ue,{variant:"outline",size:"md",onClick:()=>{g(null),S(!1),h(null)},children:[o.jsx(vs,{}),"Reset"]})]}),!w&&y.size>0&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(F6t,{selectedCount:y.size,vocabulary:G,onApplyTag:Ne,onRemoveTag:ke,onNewTag:Ce=>Ne(Ce)}),o.jsxs(ft,{children:[o.jsx(ft.Trigger,{asChild:!0,children:o.jsxs(ue,{disabled:k,children:[k?o.jsx(Gt,{className:"w-4 h-4"}):o.jsx(Ue,{size:"sm",children:o.jsx(Na,{})}),"Actions"]})}),o.jsxs(ft.Content,{align:"end",children:[o.jsxs(ft.Item,{onSelect:Ie,children:[o.jsx(Ue,{size:"sm",children:o.jsx(rO,{})}),"Complete"]}),o.jsxs(ft.Item,{onSelect:ze,children:[o.jsx(Ue,{size:"sm",children:o.jsx(Jc,{})}),"Remove"]}),o.jsx(ft.Separator,{}),o.jsxs(ft.Item,{onSelect:oe,children:[o.jsx(Ue,{size:"sm",children:o.jsx(bg,{})}),"Analyze"]})]})]})]})]}),ne?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Gt,{className:"w-6 h-6"})}):Y.length===0?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsxs("div",{className:"text-center px-8",children:[o.jsx(ge,{variant:"ui-sm",className:"text-neutral3 block",children:w?"No completed reviews yet":"No items to review"}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-2 block",children:w?"Items marked as complete will appear here for auditing.":"When experiment results are flagged for review, they will appear here."})]})}):o.jsxs(me,{columns:Ze,className:"min-w-0",children:[o.jsxs(me.Top,{hasLeadingCell:!0,children:[w?o.jsx(me.TopCell,{children:" "}):o.jsx(me.TopSelectCell,{checked:le?!0:ve?"indeterminate":!1,onToggle:()=>Se(),"aria-label":"Select all"}),o.jsxs(me.TopCells,{colStart:2,children:[o.jsx(me.TopCell,{children:"Input"}),o.jsx(me.TopCell,{children:"Comment"}),o.jsx(me.TopCell,{children:"Tags"}),o.jsx(me.TopCell,{children:"Rating"}),o.jsx(me.TopCell,{children:"Scores"})]})]}),Y.map(Ce=>{const je=Ce.scores?Object.entries(Ce.scores):[],_e=p===Ce.id,Oe=o.jsxs(o.Fragment,{children:[o.jsx(me.Cell,{height:"compact",className:"min-w-0 text-neutral4",children:o.jsx("span",{className:"block truncate",children:ces(Ce.input,200)})}),o.jsx(me.Cell,{height:"compact",className:"min-w-0",children:Ce.comment?o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 truncate",children:Ce.comment}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsx(me.Cell,{height:"compact",className:"min-w-0",children:Ce.tags.length>0?o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 truncate",children:Ce.tags.join(", ")}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsxs(me.Cell,{height:"compact",children:[Ce.rating==="positive"&&o.jsx(Ue,{size:"sm",className:"text-positive1",children:o.jsx(Jye,{})}),Ce.rating==="negative"&&o.jsx(Ue,{size:"sm",className:"text-negative1",children:o.jsx(Kye,{})}),!Ce.rating&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})]}),o.jsx(me.Cell,{height:"compact",children:je.length>0?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(Ue,{size:"sm",className:"text-neutral3",children:o.jsx(Jh,{})}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 font-mono",children:je[0][1].toFixed(2)}),je.length>1&&o.jsxs(fn,{variant:"default",children:["+",je.length-1]})]}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})})]});return o.jsxs(me.RowWrapper,{children:[w?o.jsx(me.Cell,{height:"compact",className:"justify-items-center px-4",children:o.jsx("div",{role:"img","aria-label":Ce.error?"Error":"Success",title:Ce.error?"Error":"Success",className:K("w-2 h-2 rounded-full",Ce.error?"bg-red-700":"bg-green-600")})}):o.jsx(me.SelectCell,{checked:y.has(Ce.id),onToggle:()=>ye(Ce.id),"aria-label":`Select item ${Ce.id}`}),o.jsx(me.RowButton,{flushLeft:!0,colStart:2,featured:_e,onClick:()=>he(Ce.id),children:Oe})]},Ce.id)})]})]}),xe&&o.jsx(L6t,{item:xe,isCompleted:w,tagVocabulary:G,onRate:Ce=>J(xe.id,Ce),onSetTags:Ce=>{te(xe.id,Ce);for(const je of Ce)G.includes(je)||U(je)},onComment:Ce=>ee(xe.id,Ce),onRemove:()=>ae(xe.id),onComplete:w?void 0:()=>de(xe.id),onPrevious:Pe,onNext:Qe,onClose:()=>h(null)})]})]})}function ues({datasetId:e,onAddItemClick:t,onNavigateToDataset:n}){const{navigate:r}=yn(),[s,a]=ji(),{tab:i,activeVersion:l,handleTabChange:c}=uTe(s,a),[u,d]=v.useState(!1),[f,p]=v.useState(!1),[h,m]=v.useState(!1),[g,y]=v.useState([]),[b,w]=v.useState(!1),[S,k]=v.useState([]),[_,C]=v.useState(!1),[E,j]=v.useState([]),[N,I]=v.useState(0),[R,$]=v.useState(null),[F,D]=v.useState(""),[V]=w0e(F,300),{data:W}=Ux(e),{data:L=[],total:z,isLoading:B,setEndOfListElement:M,isFetchingNextPage:G,hasNextPage:U}=_1(e,V||void 0,l),{total:P}=_1(e,void 0,l),[q,Z]=v.useState({}),{data:X,isLoading:te}=GM(e,void 0,q),{data:J}=GM(e),{deleteItems:ee}=_i(),ae=X?.experiments??[],de=J?.experiments??[],Y=dJr({hasSearchQuery:!!V,filteredItemsLength:L.length,unfilteredItemsTotal:P,itemsTotal:z}),{data:ne}=fTe(e),ce=ne?.length??0,pe=re=>{$(re)},le=()=>{$(null)},ve=re=>{y(re),m(!0)},ye=re=>{k(re),w(!0)},Se=re=>{w(re),re||(k([]),I(he=>he+1))},Ne=re=>{r(`/datasets/${e}/items?items=${re.join(",")}`)},ke=re=>{r(`/datasets/${e}/versions?ids=${re.join(",")}`)},Ie=re=>{j(re),C(!0)},ze=async()=>{await ee.mutateAsync({datasetId:e,itemIds:E}),De.success(`Deleted ${E.length} items`),C(!1),j([]),I(re=>re+1)},oe=re=>{m(!1),y([]),I(he=>he+1),n?.(re)},se=re=>{m(re),re||(y([]),I(he=>he+1))};return o.jsxs(o.Fragment,{children:[o.jsxs(ru,{defaultTab:"items",value:i,onValueChange:c,className:"grid grid-rows-[auto_1fr] h-full",children:[o.jsxs(su,{children:[o.jsxs(Vr,{value:"items",children:["Items ",o.jsx(Xs,{color:"gray",children:Y})]}),o.jsxs(Vr,{value:"experiments",children:["Experiments",o.jsx(Xs,{color:"gray",children:ae.length})]}),o.jsxs(Vr,{value:"review",children:["Review",ce>0&&o.jsx(Xs,{color:"orange",children:ce})]})]}),o.jsx(ps,{value:"items",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(res,{datasetId:e,items:L,isLoading:B,featuredItemId:R,onItemSelect:pe,onItemClose:le,onAddClick:t??(()=>{}),onImportClick:()=>d(!0),onImportJsonClick:()=>p(!0),onBulkDeleteClick:Ie,onCreateDatasetClick:ve,onAddToDatasetClick:ye,onCompareItemsClick:Ne,datasetName:W?.name,clearSelectionTrigger:N,setEndOfListElement:M,isFetchingNextPage:G,hasNextPage:U,searchQuery:F,activeSearchQuery:V,onSearchChange:D,currentDatasetVersion:W?.version,onCompareVersionsClick:ke})}),o.jsx(ps,{value:"experiments",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(jJr,{experiments:ae,allExperiments:de,isLoading:te,datasetId:e,filters:q,onFiltersChange:Z})}),o.jsx(ps,{value:"review",className:"overflow-auto mt-2 pb-0",children:o.jsx(i8t,{datasetId:e})})]}),o.jsx(xJr,{datasetId:e,open:u,onOpenChange:d}),o.jsx(oes,{datasetId:e,open:f,onOpenChange:p}),o.jsx(YKr,{open:h,onOpenChange:se,items:g,onSuccess:oe}),o.jsx(XKr,{open:b,onOpenChange:Se,items:S,currentDatasetId:e}),o.jsx(Tt,{open:_,onOpenChange:C,children:o.jsxs(Tt.Content,{children:[o.jsxs(Tt.Header,{children:[o.jsx(Tt.Title,{children:"Delete Items"}),o.jsxs(Tt.Description,{children:["Are you sure you want to delete ",E.length," item",E.length!==1?"s":"","? This action cannot be undone."]})]}),o.jsxs(Tt.Footer,{children:[o.jsx(Tt.Cancel,{children:"Cancel"}),o.jsx(Tt.Action,{onClick:ze,children:ee.isPending?"Deleting...":"Delete"})]})]})})]})}function des(e){if(!(e instanceof Error))return null;const t=e.message.match(/- ({.*})$/);if(!t)return null;try{const n=JSON.parse(t[1]);if(n.field&&Array.isArray(n.errors))return{field:n.field,errors:n.errors}}catch{}return null}function Dre({field:e,errors:t}){return t.length?o.jsx("div",{className:"mt-2 space-y-1",children:t.map((n,r)=>o.jsxs("p",{className:"text-xs text-destructive",children:[o.jsxs("code",{className:"bg-destructive/10 px-1 rounded",children:[e,n.path!=="/"?n.path:""]}),": ",n.message]},r))}):null}function fes({datasetId:e,open:t,onOpenChange:n,onSuccess:r}){const[s,a]=v.useState("{}"),[i,l]=v.useState(""),[c,u]=v.useState(""),[d,f]=v.useState(""),[p,h]=v.useState(""),[m,g]=v.useState(null),{addItem:y}=_i(),b=async C=>{C.preventDefault();let E;try{E=JSON.parse(s)}catch{De.error("Input must be valid JSON");return}let j;if(i.trim())try{j=JSON.parse(i)}catch{De.error("Ground Truth must be valid JSON");return}let N;if(c.trim())try{N=JSON.parse(c)}catch{De.error("Expected Trajectory must be valid JSON");return}let I;if(d.trim())try{const $=JSON.parse(d);if(!Array.isArray($)){De.error("Tool Mocks must be a JSON array");return}I=$}catch{De.error("Tool Mocks must be valid JSON");return}let R;if(p.trim())try{R=JSON.parse(p)}catch{De.error("Request Context must be valid JSON");return}try{await y.mutateAsync({datasetId:e,input:E,groundTruth:j,expectedTrajectory:N,toolMocks:I,requestContext:R}),De.success("Item added successfully"),g(null),a("{}"),l(""),u(""),f(""),h(""),n(!1),r?.()}catch($){const F=des($);F?g(F):De.error(`Failed to add item: ${$ instanceof Error?$.message:"Unknown error"}`)}},w=C=>{a(C),m?.field==="input"&&g(null)},S=C=>{l(C),m?.field==="groundTruth"&&g(null)},k=C=>{f(C),m?.field==="toolMocks"&&g(null)},_=()=>{a("{}"),l(""),u(""),f(""),h(""),g(null),n(!1)};return o.jsx(br,{open:t,onOpenChange:n,children:o.jsxs(xr,{className:"max-w-lg",children:[o.jsx(wr,{children:o.jsx(gr,{children:"Add Item"})}),o.jsx(Ar,{children:o.jsxs("form",{onSubmit:b,className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{htmlFor:"item-input",children:"Input (JSON) *"}),o.jsx(Qr,{value:s,onChange:w,showCopyButton:!1,className:"min-h-[120px]"}),m?.field==="input"&&o.jsx(Dre,{field:"input",errors:m.errors})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{htmlFor:"item-ground-truth",children:"Ground Truth (JSON, optional)"}),o.jsx(Qr,{value:i,onChange:S,showCopyButton:!1,className:"min-h-[80px]"}),m?.field==="groundTruth"&&o.jsx(Dre,{field:"groundTruth",errors:m.errors})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{htmlFor:"item-trajectory",children:"Expected Trajectory (JSON, optional)"}),o.jsx(Qr,{value:c,onChange:u,showCopyButton:!1,className:"min-h-[80px]"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{htmlFor:"item-tool-mocks",children:"Tool Mocks (JSON array, optional)"}),o.jsx(Qr,{value:d,onChange:k,showCopyButton:!1,className:"min-h-[80px]"}),m?.field==="toolMocks"&&o.jsx(Dre,{field:"toolMocks",errors:m.errors})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{htmlFor:"item-request-context",children:"Request Context (JSON, optional)"}),o.jsx(Qr,{value:p,onChange:h,showCopyButton:!1,className:"min-h-[80px]"})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[o.jsx(ue,{type:"button",onClick:_,children:"Cancel"}),o.jsx(ue,{type:"submit",variant:"primary",disabled:y.isPending,children:y.isPending?"Adding...":"Add Item"})]})]})})]})})}function pes({item:e}){return o.jsx(ua,{withMargins:!1,children:o.jsxs(ua.Column,{children:[o.jsxs(ua.Title,{size:"smaller",children:[o.jsx(dN,{}),o.jsx("span",{className:"truncate",children:e.id}),o.jsx(ya,{content:e.id,tooltip:`Copy item ID: ${e.id}`})]}),o.jsxs(ua.Description,{children:[o.jsxs(Nl,{children:[o.jsx(ult,{})," Created ",er(new Date(e.createdAt),"MMM d, yyyy h:mm aaa")]}),e.datasetVersion!=null&&o.jsxs(Nl,{children:[o.jsx(i_,{})," Version v",e.datasetVersion]})]})]})})}function pTe({item:e}){const t=e?.input?JSON.stringify(e.input,null,2):"null",n=e?.groundTruth?JSON.stringify(e.groundTruth,null,2):"null",r=e?.metadata?JSON.stringify(e.metadata,null,2):"null",s=e?.expectedTrajectory?JSON.stringify(e.expectedTrajectory,null,2):null;return o.jsxs(Rje,{children:[o.jsx(Ps.CodeSection,{title:"Input",icon:o.jsx(aO,{}),codeStr:t}),o.jsx(Ps.CodeSection,{title:"Ground Truth",icon:o.jsx(hg,{}),codeStr:n}),s&&o.jsx(Ps.CodeSection,{title:"Expected Trajectory",icon:o.jsx(Gye,{}),codeStr:s}),o.jsx(Ps.CodeSection,{title:"Metadata",icon:o.jsx(hN,{}),codeStr:r})]})}function hes({selectedScorers:e,setSelectedScorers:t,disabled:n=!1,container:r}){const{data:s,isLoading:a}=eh(),i=v.useMemo(()=>s?Object.entries(s).map(([l,c])=>({value:l,label:c.scorer?.config?.name||l,description:c.scorer?.config?.description||""})):[],[s]);return o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Rt,{children:"Scorers (Optional)"}),o.jsx(Xl,{multiple:!0,options:i,value:e,onValueChange:t,placeholder:"Select scorers...",searchPlaceholder:"Search scorers...",emptyText:"No scorers available",disabled:n||a,container:r})]})}const mes=[{value:"agent",label:"Agent"},{value:"workflow",label:"Workflow"},{value:"scorer",label:"Scorer"}];function ges({targetType:e,setTargetType:t,targetId:n,setTargetId:r,container:s}){const{data:a,isLoading:i}=Sm(),{data:l,isLoading:c}=By(),{data:u,isLoading:d}=eh(),f=e==="agent"?Object.entries(a??{}).map(([g,y])=>({value:g,label:y.name??g})):e==="workflow"?Object.entries(l??{}).map(([g,y])=>({value:g,label:y.name??g})):e==="scorer"?Object.entries(u??{}).map(([g,y])=>({value:g,label:y.scorer?.config?.name??g})):[],p=e==="agent"&&i||e==="workflow"&&c||e==="scorer"&&d,h=g=>{t(g),r("")},m=e==="agent"?"Agent":e==="workflow"?"Workflow":"Scorer";return o.jsxs("div",{className:"grid gap-6",children:[o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Rt,{children:"Target Type"}),o.jsx(Xl,{options:mes,value:e,onValueChange:h,placeholder:"Select target type",searchPlaceholder:"Search types...",emptyText:"No types available",container:s})]}),e&&o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Rt,{children:m}),o.jsx(Xl,{options:f,value:n,onValueChange:r,placeholder:`Select ${e}`,searchPlaceholder:"Search...",emptyText:"No targets available",disabled:p,container:s})]})]})}function ves({requestContextSchema:e,onChange:t}){const n=v.useMemo(()=>{try{return im(sm(e))}catch(r){return console.error("Failed to parse requestContextSchema:",r),null}},[e]);return n?o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{children:"Request Context"}),o.jsx(X3,{schema:n,onValuesChange:t,className:"[&_button[type=submit]]:hidden"})]}):o.jsx("p",{className:"text-sm text-destructive",children:"Failed to parse request context schema"})}function yes({datasetId:e,version:t,requestContextSchema:n,open:r,onOpenChange:s,onSuccess:a}){const i=v.useRef(null),[l,c]=v.useState(""),[u,d]=v.useState(""),[f,p]=v.useState([]),[h,m]=v.useState({}),[g,y]=v.useState(""),{triggerExperiment:b}=_i(),w=!!(n&&Object.keys(n).length>0),S=l&&u,k=b.isPending,_=()=>{c(""),d(""),p([]),m({}),y("")},C=()=>{if(w){const N=Object.entries(h).filter(([,I])=>I!==void 0&&I!=="");return N.length>0?Object.fromEntries(N):void 0}if(g.trim()){let N;try{N=JSON.parse(g)}catch{throw new Error("Request Context must be valid JSON")}if(!N||typeof N!="object"||Array.isArray(N))throw new Error("Request Context must be a JSON object");return N}},E=async()=>{if(!S)return;let N;try{N=C()}catch(I){const R=I instanceof Error?I.message:"Request Context must be valid JSON";ju.error(R);return}try{const I=await b.mutateAsync({datasetId:e,targetType:l,targetId:u,scorerIds:f.length>0?f:void 0,version:t,requestContext:N});ju.success("Experiment triggered successfully"),s(!1),a?.(I.experimentId),_()}catch(I){const R=I instanceof Error?I.message:"Failed to trigger experiment";ju.error(R)}},j=()=>{k||(s(!1),_())};return o.jsx(br,{open:r,onOpenChange:j,children:o.jsxs(xr,{ref:i,children:[o.jsxs(wr,{children:[o.jsx(gr,{children:"Run Experiment"}),o.jsx(Qs,{children:t?`Execute items from ${er(new Date(t),"MMM d, yyyy")} version against a target.`:"Execute all items in this dataset against a target."})]}),o.jsxs(Ar,{className:"grid gap-6",children:[o.jsx(ges,{targetType:l,setTargetType:c,targetId:u,setTargetId:d,container:i}),l&&l!=="scorer"&&o.jsx(hes,{selectedScorers:f,setSelectedScorers:p,disabled:k,container:i}),w?o.jsx(ves,{requestContextSchema:n,onChange:m}):o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{children:"Request Context (JSON, optional)"}),o.jsx(Qr,{value:g,onChange:y,showCopyButton:!1,className:"min-h-[80px]"})]})]}),o.jsxs(kc,{className:"px-6 pt-4",children:[o.jsx(ue,{onClick:j,disabled:k,children:"Cancel"}),o.jsx(ue,{variant:"primary",onClick:E,disabled:!S||k,children:k?o.jsxs(o.Fragment,{children:[o.jsx(Gt,{className:"w-4 h-4"}),"Running..."]}):"Run"})]})]})})}const bes=e=>{const t=We();return wt({queryKey:["experiment-trace-light",e],queryFn:async()=>{if(!e)throw new Error("Trace ID is required");return t.getTraceLight(e)},enabled:!!e})},hTe=e=>o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 9.45892 8.88606",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[o.jsx("path",{d:"M8.53702 7.36403C8.98547 7.36403 9.34918 7.70502 9.34918 8.12535C9.34906 8.54559 8.9854 8.88606 8.53702 8.88606H5.6839C5.23552 8.88606 4.87186 8.54559 4.87174 8.12535C4.87174 7.70502 5.23545 7.36403 5.6839 7.36403H8.53702Z",fill:"currentColor"}),o.jsx("path",{d:"M8.53702 3.67209C8.98547 3.67209 9.34918 4.01309 9.34918 4.43342C9.34911 4.8537 8.98543 5.19413 8.53702 5.19413H5.6839C5.23549 5.19413 4.87181 4.8537 4.87174 4.43342C4.87174 4.01309 5.23545 3.67209 5.6839 3.67209H8.53702Z",fill:"currentColor"}),o.jsx("path",{d:"M8.67155 0C9.10635 2.06584e-05 9.45892 0.341006 9.45892 0.761326C9.45878 1.18153 9.10627 1.52201 8.67155 1.52203H2.88163C2.4469 1.52203 2.0944 1.18154 2.09427 0.761326C2.09427 0.340993 2.44681 3.80132e-08 2.88163 0H8.67155Z",fill:"currentColor"}),o.jsx("path",{d:"M0.757606 0.760086V4.01122H3.50594V4.76883H0.759466L0.762566 5.4291C0.76837 6.70703 1.8058 7.73972 3.08374 7.73973H3.67953V8.49796H3.08374C1.38863 8.49795 0.0120204 7.1273 0.00433981 5.4322L0 4.39188V0.760086H0.757606Z",fill:"currentColor"})]});function Lre(e){try{return JSON.stringify(e??{})}catch{return String(e)}}function xes({report:e}){const{served:t,unconsumed:n,liveCalls:r,failure:s}=e,a=[...t.map(i=>({outcome:"served",toolName:i.toolName,args:i.args})),...r.map(i=>({outcome:"live",toolName:i.toolName,args:i.args})),...n.map(i=>({outcome:"unconsumed",toolName:i.toolName,args:i.args}))];return o.jsxs("div",{className:"grid gap-2","data-testid":"tool-mock-report",children:[o.jsx(bn.SectionHeading,{icon:o.jsx(tm,{}),className:"mb-2",children:"Tool Mocks"}),s&&o.jsx(In,{variant:"destructive",title:"Mock mismatch",children:o.jsxs(In.Message,{children:[o.jsx("span",{className:"block",children:`Tool "${s.toolName}" was called with arguments that did not match an available mock (${s.code}).`}),o.jsxs("span",{className:"mt-1 block font-mono text-xs",children:["Called with: ",Lre(s.args)]}),n.length>0&&o.jsxs("span",{className:"mt-1 block font-mono text-xs",children:["Unconsumed mocks: ",n.map(i=>Lre(i.args)).join(", ")]})]})}),o.jsx("div",{className:"rounded border border-border1 divide-y divide-border1 text-sm",children:a.map((i,l)=>o.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-1.5",children:[o.jsxs("span",{className:"min-w-0 truncate",children:[o.jsx("span",{className:"font-mono text-neutral4",children:i.toolName}),o.jsx("span",{className:"ml-2 font-mono text-xs text-neutral3",children:Lre(i.args)})]}),o.jsx("span",{className:`shrink-0 text-xs px-2 py-0.5 rounded ${wes(i.outcome)}`,children:i.outcome})]},`${i.outcome}-${i.toolName}-${l}`))})]})}function wes(e){switch(e){case"served":return"bg-accent1/10 text-accent1";case"live":return"bg-orange-500/10 text-orange-400";case"unconsumed":return"bg-neutral3/10 text-neutral4"}}function Ses({result:e,scores:t,onPrevious:n,onNext:r,onClose:s,onShowTrace:a,onOpenInReview:i,onScoreClick:l,featuredScoreId:c,onFlagForReview:u,collapsed:d,onCollapsedChange:f}){const[p,h]=v.useState(!1),m=d??p,g=f??h,y=!!e?.error,b=U8(e?.input),w=U8(e?.output),S=U8(e?.groundTruth),k=u&&e.status!=="needs-review"&&e.status!=="complete",_=Array.isArray(e.tags)?e.tags:[];return o.jsxs(bn,{collapsed:m,children:[o.jsxs(bn.Header,{children:[o.jsxs(bn.Heading,{children:["Result ",o.jsxs("b",{children:["# ",e.id.length>12?`${e.id.slice(0,12)}…`:e.id]})]}),o.jsxs($r,{className:"ml-auto shrink-0",children:[f&&o.jsx(ue,{size:"md",tooltip:m?"Expand panel":"Collapse panel",onClick:()=>g(!m),children:m?o.jsx(hlt,{}):o.jsx(plt,{})}),o.jsx(bn.NextPrevNav,{onPrevious:n,onNext:r,previousLabel:"Previous result",nextLabel:"Next result"}),o.jsxs(ue,{size:"md",onClick:a,disabled:!e.traceId,children:[o.jsx(hTe,{}),"Trace"]}),o.jsx(bn.CloseButton,{onClick:s,tooltip:"Close result panel"})]})]}),!m&&o.jsxs(bn.Content,{children:[o.jsxs("div",{className:"grid gap-4 mb-6",children:[o.jsxs(zt,{children:[o.jsx(zt.Key,{children:"Item Id"}),o.jsx(zt.ValueWithCopyBtn,{copyTooltip:"Copy Item Id to clipboard",copyValue:e.itemId,children:e.itemId}),o.jsx(zt.Key,{children:"Created"}),o.jsx(zt.Value,{children:er(new Date(e.createdAt),"MMM d, yyyy 'at' h:mm a")})]}),y&&o.jsx(In,{variant:"destructive",title:"Error",children:o.jsx(In.Message,{children:U8(e?.error&&typeof e.error=="object"?e.error.message:e?.error)})}),t&&t.length>0&&o.jsxs(me,{columns:"1fr 1fr",children:[o.jsxs(me.Top,{children:[o.jsx(me.TopCell,{children:"Scorer"}),o.jsx(me.TopCell,{children:"Score"})]}),t.map(C=>o.jsxs(me.RowButton,{featured:c===C.id,onClick:()=>l?.(C.id),children:[o.jsx(me.Cell,{height:"compact",children:C.scorerId}),o.jsx(me.MonoCell,{children:C.score.toFixed(3)})]},C.id))]}),e.toolMockReport&&o.jsx(xes,{report:e.toolMockReport}),(e.status||_.length>0||k)&&o.jsxs("div",{className:"grid gap-2",children:[o.jsx(bn.SectionHeading,{icon:o.jsx(hN,{}),className:"mb-2",children:"Review"}),(e.status||_.length>0)&&o.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[e.status&&o.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${e.status==="needs-review"?"bg-orange-500/10 text-orange-400":e.status==="complete"?"bg-accent1/10 text-accent1":"bg-neutral3/10 text-neutral4"}`,children:e.status}),_.map(C=>o.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-surface4 text-neutral4",children:C},C))]}),k&&o.jsx("div",{children:o.jsxs(ue,{size:"sm",onClick:()=>u(e.id),children:[o.jsx(GU,{}),"Flag for Review"]})}),e.status==="needs-review"&&i&&o.jsx("div",{children:o.jsxs(ue,{size:"sm",onClick:i,children:[o.jsx(Pa,{}),"Review"]})})]})]}),o.jsxs("div",{className:"grid gap-3",children:[o.jsx(bn.CodeSection,{title:"Input",icon:o.jsx(dN,{}),codeStr:b}),o.jsx(bn.CodeSection,{title:"Output",icon:o.jsx(hg,{}),codeStr:w}),o.jsx(bn.CodeSection,{title:"Ground Truth",icon:o.jsx(Xye,{}),codeStr:S})]})]})]})}function U8(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function kes({results:e,isLoading:t,featuredResultId:n,onResultClick:r,columns:s,scoresByItemId:a,scorerIds:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u,selectedIds:d,onToggleSelect:f}){const p=!!(d&&f),h=[p?"auto":"",...s.map(g=>g.size)].filter(Boolean).join(" "),m=s.some(g=>g.name==="input");return t?o.jsx(el,{columns:h}):o.jsxs(me,{columns:h,className:"min-w-0",children:[o.jsxs(me.Top,{hasLeadingCell:p,children:[p&&o.jsx(me.TopCell,{children:" "}),p?o.jsx(me.TopCells,{colStart:2,children:s.map(g=>o.jsx(me.TopCell,{children:g.label},g.name))}):s.map(g=>o.jsx(me.TopCell,{children:g.label},g.name))]}),e.length===0?o.jsx(me.NoMatch,{message:"No results yet"}):o.jsxs(o.Fragment,{children:[e.map(g=>{const y=!!g.error,b=g.id===n,w=o.jsxs(o.Fragment,{children:[o.jsx(me.IdCell,{id:g.itemId}),o.jsx(me.Cell,{height:"compact",children:o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx("div",{className:"flex items-center justify-center w-10 relative bg-transparent h-full",children:o.jsx("div",{role:"img","aria-label":y?"Error":"Success",className:K("w-2 h-2 rounded-full",y?"bg-red-700":"bg-green-600")})})}),o.jsx(Bn,{children:y?"Error":"Success"})]})}),m&&o.jsx(me.MonoCell,{children:_es(Oes(g.input),200)}),i?.map(S=>{const _=a?.[g.itemId]?.find(C=>C.scorerId===S);return o.jsx(me.Cell,{height:"compact",className:"font-mono text-neutral3 text-ui-smd",children:_!=null?_.score.toFixed(3):"-"},S)})]});return p?o.jsxs(me.RowWrapper,{children:[o.jsx(me.SelectCell,{checked:d.has(g.id),onToggle:()=>f(g.id),"aria-label":`Select result ${g.itemId}`}),o.jsx(me.RowButton,{flushLeft:!0,colStart:2,featured:b,onClick:()=>r(g.id),children:w})]},g.id):o.jsx(me.RowButton,{featured:b,onClick:()=>r(g.id),children:w},g.id)}),o.jsx(me.NextPageLoading,{isLoading:c,hasMore:u,setEndOfListElement:l})]})]})}function Oes(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function _es(e,t){return e.length<=t?e:e.slice(0,t-1)+"..."}function Ces(e){const t=e.scorer;return t?.hasJudge===!1?!0:t?.hasJudge===!0?!1:!e.preprocessPrompt&&!e.analyzePrompt&&!e.generateScorePrompt&&!e.generateReasonPrompt}function Ees({score:e,onNext:t,onPrevious:n,onClose:r,onShowTrace:s,collapsed:a,onCollapsedChange:i}){const[l,c]=v.useState(!1),u=a??l,d=i??c,f=Ces(e),p=f?"N/A — code-based scorer":"N/A — step not configured";return o.jsxs(bn,{collapsed:u,children:[o.jsxs(bn.Header,{children:[o.jsxs(bn.Heading,{children:["Score ",o.jsx("b",{children:e.scorerId})]}),o.jsxs($r,{className:"ml-auto shrink-0",children:[i&&o.jsx(ue,{size:"md",tooltip:u?"Expand panel":"Collapse panel",onClick:()=>d(!u),children:u?o.jsx(hlt,{}):o.jsx(plt,{})}),(n||t)&&o.jsx(bn.NextPrevNav,{onPrevious:n,onNext:t,previousLabel:"Previous score",nextLabel:"Next score"}),s&&o.jsxs(ue,{size:"md",onClick:s,disabled:!e.traceId,children:[o.jsx(hTe,{}),"Trace"]}),o.jsx(bn.CloseButton,{onClick:r,tooltip:"Close score panel"})]})]}),!u&&o.jsx(bn.Content,{children:o.jsxs("div",{className:"grid gap-3",children:[o.jsx(bn.CodeSection,{title:`Score: ${e.score}`,icon:o.jsx(Jh,{}),codeStr:e.reason||p,simplified:!0}),!f&&o.jsxs(o.Fragment,{children:[o.jsx(bn.CodeSection,{title:"Preprocess Prompt",icon:o.jsx(bh,{}),codeStr:e.preprocessPrompt||p,simplified:!0}),o.jsx(bn.CodeSection,{title:"Analyze Prompt",icon:o.jsx(bh,{}),codeStr:e.analyzePrompt||p,simplified:!0}),o.jsx(bn.CodeSection,{title:"Generate Score Prompt",icon:o.jsx(bh,{}),codeStr:e.generateScorePrompt||p,simplified:!0}),o.jsx(bn.CodeSection,{title:"Generate Reason Prompt",icon:o.jsx(bh,{}),codeStr:e.generateReasonPrompt||p,simplified:!0})]})]})})]})}const mQe=[{name:"scorer",label:"Scorer",size:"1fr"},{name:"avg",label:"Avg Score",size:"1fr"},{name:"count",label:"Items Scored",size:"1fr"}];function jes({scoresByItemId:e,experimentStatus:t}){const n=v.useMemo(()=>{if(!e)return[];const r={};for(const s of Object.values(e))for(const a of s)r[a.scorerId]||(r[a.scorerId]={sum:0,count:0}),r[a.scorerId].sum+=a.score,r[a.scorerId].count++;return Object.entries(r).map(([s,{sum:a,count:i}])=>({scorerId:s,avg:a/i,count:i})).sort((s,a)=>s.scorerId.localeCompare(a.scorerId))},[e]);if(n.length===0){const r=t==="running"||t==="pending",s=e!==void 0;let a,i;return r?(a="Experiment in progress",i="Summary metrics will appear here once the experiment completes."):s?(a="No scorers configured",i="Add scorers when triggering an experiment to evaluate results and see summary metrics here."):(a="Loading scores",i="Fetching scorer results…"),o.jsx("div",{className:"flex h-full items-center justify-center py-12",children:o.jsx(Lr,{iconSlot:o.jsx(Jh,{className:"w-8 h-8 text-neutral3"}),titleSlot:a,descriptionSlot:i})})}return o.jsxs(gn,{children:[o.jsxs(gn.Header,{columns:mQe,children:[o.jsx(gn.HeaderCol,{children:"Scorer"}),o.jsx(gn.HeaderCol,{children:"Avg Score"}),o.jsx(gn.HeaderCol,{children:"Items Scored"})]}),o.jsx(gn.Scroller,{children:o.jsx(gn.Items,{children:n.map(({scorerId:r,avg:s,count:a})=>o.jsxs(gn.Row,{columns:mQe,children:[o.jsx(gn.TextCell,{children:r}),o.jsx(gn.TextCell,{className:"font-mono",children:s.toFixed(3)}),o.jsx(gn.TextCell,{className:"font-mono",children:a})]},r))})})]})}function o8t({experimentId:e,datasetId:t,experimentStatus:n,results:r,isLoading:s,setEndOfListElement:a,isFetchingNextPage:i,hasNextPage:l}){const[c,u]=v.useState(null),[d,f]=v.useState(null),[p,h]=v.useState(void 0),[m,g]=v.useState(null),[y,b]=v.useState(new Set),[w,S]=v.useState(!1),[k,_]=v.useState(!1),[C,E]=v.useState(!1),[j,N]=v.useState(!1),{updateExperimentResult:I}=_i(),R=v.useCallback(se=>{b(re=>{const he=new Set(re);return he.has(se)?he.delete(se):he.add(se),he})},[]),$=v.useCallback(()=>b(new Set),[]),F=v.useCallback(()=>{const se=r.filter(re=>!!re.error).map(re=>re.id);b(new Set(se))},[r]),D=v.useCallback(async se=>{if(w||se.length===0)return;S(!0);let re=0;const he=new Set;try{for(const xe of se)try{await I.mutateAsync({datasetId:t,experimentId:e,resultId:xe,status:"needs-review"}),re++,he.add(xe)}catch{}}finally{S(!1)}he.size>0&&b(xe=>{const Ee=new Set(xe);for(const Pe of he)Ee.delete(Pe);return Ee}),re>0&&De(`${re} result${re>1?"s":""} flagged for review`)},[t,e,w,I]),V=r.find(se=>se.id===c)??null,[W,L]=v.useState("summary"),[z,B]=v.useState(null),M=se=>{L(se),se!=="reviews"&&B(null)},{data:G}=fTe(t),U=(G??[]).filter(se=>se.experimentId===e).length,{data:P}=E6t(e,n),q=v.useMemo(()=>{if(!P)return[];const se=new Set;for(const re of Object.values(P))for(const he of re)se.add(he.scorerId);return[...se].sort()},[P]),Z=se=>{u(se),f(null),h(void 0),g(null)},X=se=>{Z(se===c?null:se)},te=()=>{Z(null)},J=()=>{if(!V)return;const se=r.findIndex(re=>re.id===V.id);if(se>=0&&se<r.length-1)return()=>Z(r[se+1].id)},ee=()=>{if(!V)return;const se=r.findIndex(re=>re.id===V.id);if(se>0)return()=>Z(r[se-1].id)},ae=V?P?.[V.itemId]:void 0,de=ae?.find(se=>se.id===m)??null,Y=se=>{g(se===m?null:se),f(null),h(void 0)},ne=()=>{if(!m||!ae)return;const se=ae.findIndex(re=>re.id===m);if(se>=0&&se<ae.length-1)return()=>g(ae[se+1].id)},ce=()=>{if(!m||!ae)return;const se=ae.findIndex(re=>re.id===m);if(se>0)return()=>g(ae[se-1].id)},{data:pe,isLoading:le}=bes(d),ve=pe?.spans,{data:ye,isLoading:Se}=aI(d,p),Ne=ye?.span,{handlePreviousSpan:ke,handleNextSpan:Ie}=WH(ve,p??null,h),ze=(()=>{const se=[],re=!!de,he=!!d;return se.push(k?"auto":re||he?"2fr":"1fr"),re&&se.push(j?"auto":"3fr"),he&&se.push(C?"auto":"3fr"),he&&p&&se.push("3fr"),se.join(" ")})(),oe=v.useMemo(()=>[{name:"itemId",label:"Item ID",size:"7rem"},{name:"status",label:"Status",size:"5rem"},{name:"input",label:"Input",size:"minmax(15rem,1fr)"},...q.map(se=>({name:se,label:se,size:"12rem"}))],[q]);return o.jsxs(ru,{defaultTab:"summary",value:W,onValueChange:M,className:"grid grid-rows-[auto_1fr] h-full overflow-hidden",children:[o.jsxs(su,{children:[o.jsx(Vr,{value:"summary",children:"Summary"}),o.jsx(Vr,{value:"results",children:"Results"}),o.jsxs(Vr,{value:"reviews",children:["Reviews",U>0&&o.jsx(Xs,{color:"orange",children:U})]})]}),o.jsx(ps,{value:"summary",className:"overflow-y-auto mt-5",children:o.jsx(jes,{scoresByItemId:P,experimentStatus:n})}),o.jsx(ps,{value:"reviews",className:"overflow-auto mt-2 pb-0",children:o.jsx(i8t,{datasetId:t,experimentId:e,featuredItemId:z})}),o.jsxs(ps,{value:"results",className:"grid grid-rows-[auto_1fr] overflow-hidden mt-2",children:[o.jsxs("div",{className:"mb-4",children:[y.size>0&&o.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-surface3",children:[o.jsxs(ge,{variant:"ui-xs",className:"text-neutral5 font-medium",children:[y.size," selected"]}),o.jsx("div",{className:"flex-1"}),o.jsxs(ue,{variant:"outline",size:"sm",disabled:w,onClick:()=>D([...y]),children:[o.jsx(Ue,{size:"sm",children:o.jsx(GU,{})}),"Flag for Review"]}),o.jsx(ue,{variant:"ghost",size:"sm",onClick:$,children:"Clear"})]}),r.length>0&&y.size===0&&!s&&o.jsx("div",{className:"flex items-center gap-2 px-4 py-2",children:o.jsx(ue,{variant:"ghost",size:"sm",onClick:F,children:"Select loaded failures"})})]}),o.jsxs("div",{className:K("grid w-full h-full grid-cols-1 gap-4 overflow-y-auto",V&&"grid-cols-[1fr_1fr]"),children:[o.jsx("div",{className:"flex overflow-y-auto w-full",children:o.jsx("div",{className:"grid gap-8 content-start w-full overflow-y-auto",children:o.jsx(kes,{results:r,isLoading:s,featuredResultId:c,onResultClick:X,columns:oe,scoresByItemId:P,scorerIds:q,setEndOfListElement:a,isFetchingNextPage:i,hasNextPage:l,selectedIds:y,onToggleSelect:R})})}),V&&o.jsxs("div",{className:"grid gap-4 max-h-full min-h-0 overflow-auto content-start",style:{gridTemplateRows:ze},children:[o.jsx(Ses,{result:V,scores:ae,onPrevious:ee(),onNext:J(),onClose:te,onScoreClick:Y,featuredScoreId:m,onShowTrace:()=>{V.traceId&&(f(V.traceId),h(void 0),g(null),_(!0),E(!1))},onOpenInReview:()=>{B(V.id),L("reviews")},onFlagForReview:se=>D([se]),collapsed:k,onCollapsedChange:_}),de&&o.jsx(Ees,{score:de,onNext:ne(),onPrevious:ce(),onClose:()=>g(null),onShowTrace:()=>{de.traceId&&(f(de.traceId),h(void 0),_(!0),N(!0),E(!1))},collapsed:j,onCollapsedChange:N}),d&&o.jsxs(o.Fragment,{children:[o.jsx(sTe,{traceId:d,spans:ve,isLoading:le,onClose:()=>{f(null),h(void 0),_(!1),N(!1)},onSpanSelect:h,initialSpanId:p??null,placement:"traces-list",showUnavailableFeaturesMsg:!1,collapsed:C,onCollapsedChange:E,LinkComponent:R3,traceHref:`/traces/${d}`}),p&&o.jsx(qH,{traceId:d,spanId:p,span:Ne,isLoading:Se,onPrevious:ke,onNext:Ie,onClose:()=>h(void 0)})]})]})]})]})]})}const Tes={pending:o.jsx(sO,{}),running:o.jsx(Fde,{}),completed:o.jsx(Js,{}),failed:o.jsx(vs,{})};function Nes({experiment:e,className:t}){const n=e.status,r=e.totalItems-e.succeededCount-e.failedCount;return o.jsxs("div",{className:K("grid justify-items-end gap-3",t),children:[o.jsxs("div",{className:"flex p-1 px-3 text-ui-lg capitalize text-neutral4 gap-2 items-center bg-surface5 rounded-lg ",children:[o.jsx("span",{className:K("w-5 h-5 flex items-center justify-center rounded-full text-black","[&>svg]:w-4 [&>svg]:h-4",{"bg-green-700":n==="completed","bg-red-700":n==="failed","bg-cyan-600":n==="running","bg-yellow-600":n==="pending"}),children:Tes[n]}),e.status]}),o.jsxs("div",{className:K("flex items-center gap-3 text-neutral3 text-ui-md ","[&>span]:flex [&>span]:gap-1 [&>span]:items-center ","[&_b]:text-neutral4 [&_b]:font-semibold"),children:[o.jsxs("span",{children:["Total: ",o.jsx("b",{children:e.totalItems})]}),o.jsxs("span",{children:["Succeeded: ",o.jsx("b",{children:e.succeededCount})]}),o.jsxs("span",{children:["Failed: ",o.jsx("b",{children:e.failedCount})]}),(n==="pending"||n==="running")&&o.jsxs("span",{children:["Pending: ",o.jsx("b",{children:r})]})]})]})}function Ies({onPrevious:e,onNext:t,previousAriaLabel:n="Previous",nextAriaLabel:r="Next"}){return o.jsxs($r,{spacing:"close",children:[o.jsxs(ue,{onClick:e,disabled:!e,"aria-label":n,children:[o.jsx($q,{})," Prev"]}),o.jsxs(ue,{onClick:t,disabled:!t,"aria-label":r,children:["Next",o.jsx(Rq,{})]})]})}function mTe({delta:e}){const t=e>0?o.jsx(Xs,{size:"small",color:"green",intensity:"muted",children:o.jsx(i3,{})}):e<0?o.jsx(Xs,{size:"small",color:"red",intensity:"muted",children:o.jsx(Gon,{})}):null;return o.jsxs("span",{className:K("font-mono text-sm text-neutral4 min-w-20"),children:[o.jsx("span",{className:"w-3 inline-block",children:e>0?"+ ":e<0?"- ":""}),Math.abs(e).toFixed(2)," ",t]})}function q8(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function Aes({item:e,baselineId:t,contenderId:n,baselineVersion:r,contenderVersion:s,onPrevious:a,onNext:i,onClose:l}){const c=e.results[t],u=e.results[n],d=!!(c&&u),f=new Set;if(c)for(const h of Object.keys(c.scores))f.add(h);if(u)for(const h of Object.keys(u.scores))f.add(h);const p=[...f].sort();return o.jsxs(Gr,{withLeftSeparator:!0,children:[o.jsxs(Gr.Toolbar,{children:[o.jsx(Ies,{onPrevious:a,onNext:i,previousAriaLabel:"Previous comparison item",nextAriaLabel:"Next comparison item"}),o.jsx($r,{children:o.jsx(ue,{onClick:l,"aria-label":"Close comparison detail panel",children:o.jsx(vs,{})})})]}),o.jsxs(Gr.Content,{className:"pb-6",children:[o.jsx(ua,{withMargins:!1,children:o.jsx(ua.Column,{children:o.jsxs(ua.Title,{size:"smaller",children:[o.jsx(dN,{})," ",e.itemId]})})}),d?o.jsx(o.Fragment,{children:o.jsxs(Rje,{children:[p.length>0&&o.jsxs("div",{className:"grid gap-3",children:[o.jsx("h4",{className:"text-sm font-medium text-neutral5",children:"Scores"}),o.jsx("div",{className:"grid gap-2",children:p.map(h=>{const m=c?.scores[h]??null,g=u?.scores[h]??null,y=m!=null&&g!=null?g-m:null;return o.jsxs("div",{className:"flex items-center justify-between gap-4 px-3 py-2 rounded-lg bg-surface2",children:[o.jsx("span",{className:"text-sm text-neutral5 font-medium",children:h}),o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("span",{className:"text-sm text-neutral3",children:[m!=null?m.toFixed(3):"-"," →"," ",g!=null?g.toFixed(3):"-"]}),y!=null&&o.jsx(mTe,{delta:y})]})]},h)})})]}),o.jsx(Ps.CodeSection,{title:o.jsxs(o.Fragment,{children:[o.jsx(Xs,{color:"purple",children:"Baseline "})," Experiment Output"]}),icon:o.jsx(hg,{}),codeStr:q8(c?.output)}),o.jsx(Ps.CodeSection,{title:o.jsxs(o.Fragment,{children:[o.jsx(Xs,{color:"cyan",children:"Contender "})," Experiment Output"]}),icon:o.jsx(hg,{}),codeStr:q8(u?.output)}),o.jsx(Ps.CodeSection,{title:"Item Input",icon:o.jsx(aO,{}),codeStr:q8(e.input)}),o.jsx(Ps.CodeSection,{title:"Item Ground Truth",icon:o.jsx(Xye,{}),codeStr:q8(e.groundTruth)})]})}):o.jsx(In,{variant:"warning",title:"Comparison not available",children:o.jsx(In.Message,{children:(()=>{const h=c?"Contender":"Baseline",m=c?s:r;return o.jsxs(o.Fragment,{children:["The ",h," experiment was run against dataset",m!=null?` v. ${m}`:"",", which does not contain this item."]})})()})})]})]})}function Res({items:e,baselineId:t,contenderId:n,scorerIds:r,featuredItemId:s,columns:a,onItemClick:i}){return o.jsx(Gr,{children:o.jsxs(gn,{children:[o.jsxs(gn.Header,{columns:a,children:[o.jsx(gn.HeaderCol,{children:"Item ID"}),!s&&r.map(l=>o.jsx(gn.HeaderCol,{className:"flex justify-center",children:l},l))]}),o.jsx(gn.Scroller,{children:o.jsx(gn.Items,{children:e.map(l=>{const c=l.results[t],u=l.results[n],d=!!(c&&u);return o.jsx(gn.Row,{children:o.jsxs(gn.RowButton,{item:{id:l.itemId},columns:a,isFeatured:s===l.itemId,onClick:i,children:[o.jsx(gn.IdCell,{id:l.itemId,className:d?"":"text-neutral1"}),!s&&o.jsx(o.Fragment,{children:r.map(f=>{const p=c?.scores[f]??null,h=u?.scores[f]??null,m=p!=null&&h!=null?h-p:null;return o.jsx(gn.Cell,{className:"flex items-center gap-5 justify-center font-mono",children:m!=null?o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"flex items-center text-neutral2 min-w-24",children:[p?.toFixed(2)," → ",h?.toFixed(2)]}),o.jsx(mTe,{delta:m})]}):o.jsx("span",{className:"text-neutral1",children:"-"})},f)})})]})},l.itemId)})})})]})})}const Pes={baseline:{label:"Baseline",color:"purple",customStyle:"items-end justify-items-end [&>div]:justify-end border-r-0 rounded-r-none"},contender:{label:"Contender",color:"cyan",customStyle:"items-start justify-items-start [&>div]:justify-start border-l-0 rounded-l-none"}};function gQe({datasetId:e,experiment:t,type:n}){const{Link:r}=yn(),{label:s,color:a,customStyle:i}=Pes[n];if(!t)return null;const l=t.createdAt?new Date(t.createdAt):null;return o.jsxs("div",{className:`grid border-2 border-border1 rounded-lg p-5 gap-3 ${i}`,children:[o.jsxs("div",{className:"flex items-center gap-3 w-full overflow-clip",children:[n==="contender"&&o.jsxs(Xs,{size:"small",color:a,children:[s,o.jsx(hm,{})]}),o.jsx(ue,{as:r,href:`/datasets/${e}/experiments/${t.id}`,children:o.jsx("span",{className:"truncate min-w-0",children:t.id})}),n==="baseline"&&o.jsxs(Xs,{size:"small",color:a,children:[o.jsx(Ec,{})," ",s]})]}),o.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-ui-sm text-neutral3",children:[o.jsxs(Nl,{children:[o.jsx(Xye,{})," ",t.targetType," / ",t.targetId]}),o.jsxs(Nl,{children:[o.jsx(XU,{})," v",t.datasetVersion??"—"]}),l&&o.jsxs(Nl,{children:[o.jsx(dlt,{})," ",er(l,"MMM d, yyyy HH:mm")]})]})]})}function $es({datasetId:e,experimentIdA:t,experimentIdB:n,onSwap:r}){const[s,a]=v.useState(null),{data:i,isLoading:l,error:c}=kKr(e,t,n),{data:u}=_U(e,t),{data:d}=_U(e,n),f=u&&d&&u.datasetVersion!==d.datasetVersion,p=v.useMemo(()=>{if(!i)return[];const E=new Set;for(const j of i.items)for(const N of Object.values(j.results))if(N)for(const I of Object.keys(N.scores))E.add(I);return[...E].sort()},[i]),h=v.useMemo(()=>{if(!i||p.length===0)return[];const E=i.baselineId,j=t===E?n:t;return p.map(N=>{let I=0,R=0,$=0,F=0;for(const L of i.items){const z=L.results[E]?.scores[N],B=L.results[j]?.scores[N];z!=null&&(I+=z,$++),B!=null&&(R+=B,F++)}const D=$>0?I/$:null,V=F>0?R/F:null,W=D!=null&&V!=null?V-D:null;return{scorerId:N,avgA:D,avgB:V,delta:W}})},[i,p,t,n]),m=[{name:"scorer",label:"Scorer",size:"1fr"},{name:"baselineAvg",label:"Baseline Avg",size:"1fr"},{name:"comparisonAvg",label:"Comparison Avg",size:"1fr"},{name:"delta",label:"Delta",size:"1fr"}],g=v.useMemo(()=>[{name:"itemId",label:"Item ID",size:"8rem"},...s?[]:p.map(E=>({name:E,label:E,size:"1fr"}))],[p,s]),y=i?.items.find(E=>E.itemId===s)??null,b=E=>{a(E===s?null:E)},w=()=>{a(null)},S=()=>{if(!i||!s)return;const E=i.items.findIndex(j=>j.itemId===s);if(E>=0&&E<i.items.length-1)return()=>a(i.items[E+1].itemId)},k=()=>{if(!i||!s)return;const E=i.items.findIndex(j=>j.itemId===s);if(E>0)return()=>a(i.items[E-1].itemId)};if(l)return o.jsx("div",{className:"flex items-center justify-center h-64",children:o.jsx(Gt,{})});if(c)return o.jsx(In,{variant:"warning",title:"Error loading comparison",children:o.jsx(In.Message,{children:c instanceof Error?c.message:"Unknown error"})});if(!i||i.items.length===0)return o.jsx("div",{className:"text-neutral4 text-sm text-center py-8",children:"No comparison data"});const _=i.baselineId,C=t===_?n:t;return o.jsxs("div",{className:"grid gap-10",children:[u&&d&&o.jsxs("div",{className:K("relative grid xl:grid-cols-[1fr_auto_1fr] gap-4 xl:gap-0"),children:[o.jsx(gQe,{datasetId:e,experiment:u,type:"baseline"}),o.jsx("div",{className:"relative flex items-center justify-center px-[2vw] before:absolute before:inset-y-0 before:left-1/2 before:-translate-x-1/2 before:w-[2px] before:bg-border1",children:o.jsx("div",{className:"relative z-1 bg-surface2 rounded-lg p-2",children:o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx(ue,{onClick:r,children:"VS"})}),o.jsx(Bn,{children:"Switch the order"})]})})}),o.jsx(gQe,{datasetId:e,experiment:d,type:"contender"})]}),f&&o.jsx(In,{variant:"warning",title:"Version mismatch",children:o.jsxs(In.Message,{children:["These experiments used different dataset versions (v",u.datasetVersion," vs v",d.datasetVersion,"). Results may not be directly comparable."]})}),h.length>0&&o.jsxs(gn,{children:[o.jsxs(gn.Header,{columns:m,children:[o.jsx(gn.HeaderCol,{children:"Scorer"}),o.jsx(gn.HeaderCol,{className:"flex justify-center",children:o.jsxs(vGe,{children:[o.jsx(Xs,{color:"purple",size:"small",intensity:"muted",children:"Baseline"}),o.jsx(Xs,{color:"purple",size:"small",children:"Avg"})]})}),o.jsx(gn.HeaderCol,{className:"flex justify-center",children:o.jsxs(vGe,{children:[o.jsx(Xs,{color:"cyan",size:"small",intensity:"muted",children:"Contender"}),o.jsx(Xs,{color:"cyan",size:"small",children:"Avg"})]})}),o.jsx(gn.HeaderCol,{className:"flex justify-center",children:"Delta"})]}),o.jsx(gn.Scroller,{children:o.jsx(gn.Items,{children:h.map(({scorerId:E,avgA:j,avgB:N,delta:I})=>o.jsxs(gn.Row,{columns:m,children:[o.jsx(gn.TextCell,{children:E}),o.jsx(gn.TextCell,{className:"text-center font-mono",children:j!=null?j.toFixed(3):"-"}),o.jsx(gn.TextCell,{className:"text-center font-mono",children:N!=null?N.toFixed(3):"-"}),o.jsx(gn.TextCell,{className:"flex justify-center",children:I!=null?o.jsx(mTe,{delta:I}):"-"})]},E))})})]}),o.jsxs(ry,{className:K({"grid-cols-[1fr_2fr]":!!y}),children:[o.jsx(Res,{items:i.items,baselineId:_,contenderId:C,scorerIds:p,featuredItemId:s,columns:g,onItemClick:b}),!!y&&o.jsx(Aes,{item:y,baselineId:_,contenderId:C,baselineVersion:u?.datasetVersion,contenderVersion:d?.datasetVersion,onPrevious:k(),onNext:S(),onClose:w})]})]})}function Mes({datasetId:e,itemId:t,onVersionSelect:n,onCompareVersionsClick:r,activeVersion:s}){const{data:a,isLoading:i}=cTe(e,t),[l,c]=v.useState(!1),[u,d]=v.useState(new Set),f=b=>{n?.(b)},p=b=>s==null?b.isLatest:b.datasetVersion===s,h=b=>{d(w=>{const S=new Set(w);if(S.has(b))S.delete(b);else if(S.size>=2){const[k]=Array.from(S);return new Set([k,b])}else S.add(b);return S})},m=()=>{c(!1),d(new Set)},g=()=>{c(!0)},y=()=>{u.size===2&&r?.([...u])};return o.jsxs(Gr,{className:"min-w-56",children:[l?o.jsx(Gr.Toolbar,{className:"grid justify-stretch gap-3 w-full",children:o.jsxs($r,{children:[o.jsx(ue,{onClick:m,children:"Cancel"}),o.jsx(ue,{variant:"primary",disabled:u.size!==2,onClick:y,tooltip:u.size!==2?"Check 2 versions to compare":void 0,className:"grow",children:"Compare"})]})}):o.jsx(o.Fragment,{children:(a||[]).length>1&&o.jsx(Gr.Toolbar,{children:o.jsxs(ue,{onClick:g,className:"w-full",children:[o.jsx(Qw,{})," Compare Ver."]})})}),i?o.jsx(Des,{}):o.jsxs(gn,{children:[o.jsx(gn.Header,{children:o.jsx(gn.HeaderCol,{children:"Item Version History"})}),o.jsx(gn.Scroller,{children:o.jsx(gn.Items,{children:a?.map(b=>{const w=String(b.datasetVersion),S=typeof b.updatedAt=="string"?new Date(b.updatedAt):b.updatedAt;return o.jsxs(gn.Row,{isSelected:l&&u.has(w),children:[l&&o.jsx(gn.LabelCell,{children:o.jsx($o,{checked:u.has(w),disabled:b.isDeleted,onCheckedChange:()=>{},onClick:k=>{k.stopPropagation(),b.isDeleted||h(w)},"aria-label":`Select version ${b.datasetVersion}`})}),o.jsx(gn.RowButton,{item:b,columns:[{name:"version",label:"Item Version History",size:"1fr"}],isFeatured:p(b),onClick:()=>f(b),className:"py-2",children:o.jsx(gn.VersionCell,{version:b.datasetVersion,date:S,isLatest:b.isLatest,isDeleted:b.isDeleted})})]},String(b.datasetVersion))})})})]})]})}function Des(){return o.jsxs(gn,{children:[o.jsx(gn.Header,{columns:[{name:"version",label:"Item Version History",size:"1fr"}],children:o.jsx(gn.HeaderCol,{children:"Item Version History"})}),o.jsx(gn.Items,{children:Array.from({length:3}).map((e,t)=>o.jsx(gn.Row,{children:o.jsx(gn.RowButton,{columns:[{name:"version",label:"Item Version History",size:"1fr"}],children:o.jsx(gn.TextCell,{isLoading:!0,children:"Loading..."})})},t))})]})}function Les(e,t){if(t){const n=typeof t=="string"?new Date(t):t;return`v${e} ${er(n,"MMM dd 'at' H:mm:ss a")}`}return`v${e}`}function Fes({datasetId:e,versionA:t,versionB:n,onVersionChange:r}){const{data:s}=Yje(e),a=(s??[]).map(i=>({value:String(i.version),label:`${Les(i.version,i.createdAt)}${i.isCurrent?" (current)":""}`}));return o.jsxs(Gr.Toolbar,{className:"grid grid-cols-[1fr_1fr_1fr_10rem] gap-4 w-full",children:[o.jsx("div",{}),o.jsx(xc,{label:"Version A",labelIsHidden:!0,name:"version-a",placeholder:"Select version",options:a,value:t??"",onValueChange:i=>r?.(i,n??"")}),o.jsx(xc,{label:"Version B",labelIsHidden:!0,name:"version-b",options:a,value:n??"",onValueChange:i=>r?.(t??"",i)}),o.jsx("div",{})]})}const zes=[{name:"id",label:"ID",size:"1fr"},{name:"versionA",label:"Version A",size:"1fr"},{name:"versionB",label:"Version B",size:"1fr"},{name:"compare",label:"Compare",size:"10rem"}],Bes={added:{color:"blue",borderColor:"border-blue-900",icon:o.jsx(Fr,{}),tooltip:"Added in this version"},changed:{color:"orange",borderColor:"border-yellow-900",icon:o.jsx(Nlt,{}),tooltip:"Changed in this version"},same:{color:"green",borderColor:"border-green-900",icon:o.jsx(ycn,{}),tooltip:"Same in both versions"}};function Fre({red:e=!1,tooltip:t}){return o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx(sln,{className:K("text-neutral3/40 w-5 h-5 ",{"text-red-900":e})})}),t&&o.jsx(Bn,{children:t})]})}function VS({variant:e,version:t}){if(!e)return o.jsxs("span",{className:"text-ui-md text-neutral4",children:["v. ",t]});const{color:n,icon:r,tooltip:s}=Bes[e];return o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsxs("div",{className:"grid grid-cols-[1fr_auto]",children:[t!==void 0&&o.jsxs("span",{className:"pr-3 text-ui-md text-neutral4 min-w-16 flex justify-end",children:["v. ",t]}),o.jsx(Xs,{color:n,size:"small",children:r})]})}),o.jsx(Bn,{children:s})]})}function Ues(e,t){return e&&t&&e.datasetVersion===t.datasetVersion?"same":e&&t&&e.datasetVersion!==t.datasetVersion?"changed":e?"added":"removed"}function qes({datasetId:e,versionA:t,versionB:n,allItems:r,itemsAMap:s,itemsBMap:a}){const{Link:i}=yn(),l=t>n;return o.jsx(gn,{children:o.jsx(gn.Scroller,{children:o.jsx(gn.Items,{children:r.map(({id:c})=>{const u=s.get(c),d=a.get(c),f=Ues(u,d);return o.jsxs(gn.Row,{columns:zes,children:[o.jsx(gn.IdCell,{id:c,isShortened:!1}),f!=="same"?o.jsxs(o.Fragment,{children:[u?.datasetVersion?o.jsx(gn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}`,className:"gap-2",children:!d&&l?o.jsx(VS,{variant:"added",version:u.datasetVersion}):f==="changed"&&l?o.jsx(VS,{variant:"changed",version:u.datasetVersion}):o.jsx(VS,{version:u.datasetVersion})}):o.jsx(gn.Cell,{className:"justify-center flex items-center",children:o.jsx(Fre,{red:l,tooltip:l?"Deleted in this version":"Not present in this version"})}),d?.datasetVersion?o.jsx(gn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}`,className:"gap-2",children:!u&&!l?o.jsx(VS,{variant:"added",version:d.datasetVersion}):f==="changed"&&!l?o.jsx(VS,{variant:"changed",version:d.datasetVersion}):o.jsx(VS,{version:d.datasetVersion})}):o.jsx(gn.Cell,{className:"justify-center flex items-center",children:o.jsx(Fre,{red:!l,tooltip:l?"Not present in this version":"Deleted in this version"})})]}):o.jsx(gn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}`,className:"col-span-2 gap-2",children:o.jsx(VS,{variant:"same",version:d?.datasetVersion})}),f==="changed"?o.jsx(gn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}/versions?ids=${u?.datasetVersion},${d?.datasetVersion}`,children:"Compare"}):o.jsx(gn.Cell,{children:o.jsx(Fre,{tooltip:o.jsxs(o.Fragment,{children:["Comparing is available",o.jsx("br",{})," only for changed items"]})})})]},c)})})})})}const vQe={needsReview:"#facc15",complete:"#22c55e"},Ves=[{label:"Needs Review",color:vQe.needsReview},{label:"Reviewed",color:vQe.complete}];function Hes({reviewSummary:e,experiments:t,datasets:n,isLoading:r,isError:s}){const{data:a,maxVal:i,totalInPipeline:l}=v.useMemo(()=>{if(!e?.counts||!t)return{data:[],maxVal:0,totalInPipeline:0};const u=new Map;for(const m of t)u.set(m.id,m);const d=new Map;if(n)for(const m of n)d.set(m.id,m.name);let f=0,p=0;const h=[];for(const m of e.counts){const g=m.needsReview+m.complete;if(g===0)continue;p+=g,g>f&&(f=g);const y=u.get(m.experimentId),b=y?.datasetId?d.get(y.datasetId):void 0,w=b?`${b} · ${m.experimentId.slice(0,8)}`:m.experimentId.slice(0,8);h.push({name:w,values:[m.needsReview,m.complete]})}return{data:h,maxVal:f,totalInPipeline:p}},[e,t,n]),c=a.length>0;return o.jsxs(Bt,{children:[o.jsxs(Bt.TopBar,{children:[o.jsx(Bt.TitleAndDescription,{title:"Review Pipeline",description:"Items in review across experiments."}),c&&o.jsx(Bt.Summary,{value:String(l),label:"Items in pipeline"})]}),r?o.jsx(Bt.Loading,{}):s?o.jsx(Bt.Error,{message:"Failed to load review data"}):o.jsx(Bt.Content,{children:c?o.jsx(aN,{data:a,segments:Ves,maxVal:i,fmt:u=>String(u)}):o.jsx(Bt.NoData,{message:"No items have been sent to review yet"})})]})}function gTe(){const e=We();return wt({queryKey:["experiment-review-summary"],queryFn:()=>e.getExperimentReviewSummary()})}function l8t(e){const t=new Map;if(!e?.counts)return t;for(const n of e.counts)t.set(n.experimentId,{needsReview:n.needsReview,complete:n.complete,total:n.total});return t}function Wes(e,t){const n=new Map,r=l8t(e);if(!r.size||!t)return n;for(const s of t){const a=r.get(s.id);if(!a||!s.datasetId||a.needsReview+a.complete===0)continue;const l=n.get(s.datasetId)??{needsReview:0,complete:0};l.needsReview+=a.needsReview,l.complete+=a.complete,n.set(s.datasetId,l)}return n}function Zes(e){return e?.counts?e.counts.reduce((t,n)=>({needsReview:t.needsReview+n.needsReview,complete:t.complete+n.complete,inPipeline:t.inPipeline+n.needsReview+n.complete}),{needsReview:0,complete:0,inPipeline:0}):{needsReview:0,complete:0,inPipeline:0}}const Ges=10;function Qes(){const[e,t]=v.useState(!1),[n,r]=v.useState(""),[s,a]=v.useState("all"),[i,l]=v.useState("all"),[c,u]=v.useState("all"),[d,f]=v.useState(0),{data:p,isLoading:h,error:m}=Rg({page:d,perPage:Ges}),{data:g,isLoading:y,error:b}=zZ(),{data:w}=gTe(),S=v.useMemo(()=>p?.datasets??[],[p?.datasets]),k=p?.pagination?.hasMore??!1,_=v.useMemo(()=>g?.experiments??[],[g?.experiments]),C=v.useMemo(()=>BKr(S),[S]),E=v.useMemo(()=>Wes(w,_),[w,_]),j=h||y,N=m||b,I=()=>t(!0),R=v.useCallback(()=>f(B=>B+1),[]),$=v.useCallback(()=>f(B=>Math.max(0,B-1)),[]),F=v.useCallback(B=>{r(B),f(0)},[]),D=v.useCallback(B=>{a(B),f(0)},[]),V=v.useCallback(B=>{l(B),f(0)},[]),W=v.useCallback(B=>{u(B),f(0)},[]);if(N&&gs(N))return o.jsx(lr,{children:o.jsx(Vs,{})});if(N&&ys(N))return o.jsx(lr,{children:o.jsx(Ds,{resource:"datasets"})});if(N)return o.jsx(lr,{children:o.jsx(Fi,{title:"Failed to load datasets",message:N.message})});if(S.length===0&&!j&&d===0)return o.jsxs(o.Fragment,{children:[o.jsx(lr,{children:o.jsx(WKr,{onCreateClick:I})}),o.jsx(Eve,{open:e,onOpenChange:t})]});const L=s!=="all"||i!=="all"||c!=="all"||n!=="",z=()=>{r(""),a("all"),l("all"),u("all"),f(0)};return o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx(QKr,{search:n,onSearchChange:F,targetFilter:s,onTargetFilterChange:D,experimentFilter:i,onExperimentFilterChange:V,tagFilter:c,onTagFilterChange:W,tagOptions:C,onReset:z,hasActiveFilters:L,onCreateClick:I})}),o.jsx(HKr,{datasets:S,experiments:_,reviewByDataset:E,isLoading:j,search:n,targetFilter:s,experimentFilter:i,tagFilter:c,currentPage:d,hasMore:k,onNextPage:R,onPrevPage:$}),o.jsx(Eve,{open:e,onOpenChange:t})]})}function V8({children:e}){return o.jsxs(Lt,{height:"full",children:[o.jsx("div",{}),o.jsx(Lt.MainArea,{isCentered:!0,children:e})]})}function Yes(){const{datasetId:e}=dr(),t=bs(),[n,r]=ji(),{activeVersion:s}=uTe(n,r),[a,i]=v.useState(!1),[l,c]=v.useState(!1),[u,d]=v.useState(!1),[f,p]=v.useState(!1),[h,m]=v.useState(!1),{data:g,error:y,isLoading:b}=Ux(e),{data:w=[],isLoading:S}=_1(e,void 0,s),k=!S&&w.length===0;if(b)return null;if(y&&gs(y))return o.jsx(V8,{children:o.jsx(Vs,{})});if(y&&ys(y))return o.jsx(V8,{children:o.jsx(Ds,{resource:"datasets"})});if(y&&z1e(y)||!b&&!y&&!g)return o.jsx(V8,{children:o.jsx(Lr,{iconSlot:o.jsx(ay,{}),titleSlot:"Dataset not found",descriptionSlot:`No dataset with id "${e}".`,actionSlot:o.jsxs(ue,{as:ci,to:"/datasets",children:[o.jsx(Ec,{}),"Back to Datasets"]})})});if(y)return o.jsx(V8,{children:o.jsx(Fi,{title:"Failed to load dataset",message:y instanceof Error?y.message:"An unexpected error occurred. Please try again."})});const _=E=>{t(`/datasets/${e}/experiments/${E}`)},C=()=>{t("/datasets")};return o.jsxs(o.Fragment,{children:[o.jsxs(Lt,{height:"full",children:[o.jsx(Lt.TopArea,{children:o.jsxs(Lt.Row,{children:[o.jsxs(Lt.Column,{children:[g?.description&&o.jsx("p",{className:"text-ui-smd text-neutral3 mb-1",children:g.description}),o.jsxs(zt,{numOfCol:2,children:[o.jsx(zt.Key,{children:"Created at"}),o.jsx(zt.Value,{children:g?.createdAt?er(new Date(g.createdAt),"MMM d, yyyy"):""}),o.jsx(zt.Key,{children:"Latest version"}),o.jsxs(zt.Value,{children:["v",g?.version??""]})]})]}),o.jsx(Lt.Column,{children:o.jsxs($r,{children:[k?o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx("span",{className:"cursor-not-allowed",children:o.jsx("div",{className:"pointer-events-none opacity-50",inert:!0,"aria-disabled":"true",children:o.jsxs(ue,{variant:"primary",children:[o.jsx(Pp,{}),s!=null?`Run on v${s}`:"Run Experiment"]})})})}),o.jsx(Bn,{children:"Add items to the dataset before running an experiment"})]}):o.jsxs(ue,{variant:"primary",onClick:()=>i(!0),children:[o.jsx(Pp,{}),s!=null?`Run on v${s}`:"Run Experiment"]}),o.jsxs(ft,{children:[o.jsx(ft.Trigger,{asChild:!0,children:o.jsx(ue,{size:"lg","aria-label":"Dataset actions menu",children:o.jsx(l3,{})})}),o.jsxs(ft.Content,{align:"end",className:"w-48",children:[o.jsxs(ft.Item,{onSelect:()=>d(!0),children:[o.jsx(em,{})," Edit Dataset"]}),o.jsxs(ft.Item,{onSelect:()=>m(!0),children:[o.jsx(Rp,{})," Duplicate Dataset"]}),o.jsxs(ft.Item,{onSelect:()=>p(!0),className:"text-red-500 focus:text-red-400",children:[o.jsx(Jc,{})," Delete Dataset"]})]})]})]})})]})}),o.jsx(Lt.MainArea,{children:o.jsx(ues,{datasetId:e,onAddItemClick:()=>c(!0)})})]}),o.jsx(yes,{datasetId:e,version:s??void 0,requestContextSchema:g?.requestContextSchema,open:a,onOpenChange:i,onSuccess:_}),o.jsx(fes,{datasetId:e,open:l,onOpenChange:c}),g&&o.jsx(tJr,{open:u,onOpenChange:d,dataset:{id:g.id,name:g.name,description:g?.description||"",targetType:g.targetType,inputSchema:g.inputSchema,groundTruthSchema:g.groundTruthSchema,requestContextSchema:g.requestContextSchema}}),g&&o.jsx(KKr,{open:h,onOpenChange:m,sourceDatasetId:g.id,sourceDatasetName:g.name,sourceDatasetDescription:g.description,sourceDatasetTargetType:g.targetType}),g&&o.jsx(rJr,{open:f,onOpenChange:p,datasetId:g.id,datasetName:g.name,onSuccess:C})]})}function c8t({experiment:e}){const{Link:t,paths:n}=yn(),{data:r}=Sm(),{data:s}=By(),{data:a}=eh(),i=()=>{switch(e.targetType){case"agent":return n.agentLink(e.targetId);case"workflow":return n.workflowLink(e.targetId);case"scorer":return n.scorerLink(e.targetId);default:return"#"}},l=()=>{const u=e.targetId;if(!u)return u;switch(e.targetType){case"agent":return r?.[u]?.name??u;case"workflow":return s?.[u]?.name??u;case"scorer":return a?.[u]?.scorer?.config?.name??u;default:return u}},c=e.agentVersion&&e.targetType==="agent"&&e.targetId?`${n.agentLink(e.targetId)}/editor?version=${encodeURIComponent(e.agentVersion)}`:null;return o.jsx(Lt.TopArea,{children:o.jsxs(Lt.Row,{children:[o.jsx(Lt.Column,{children:o.jsxs(zt,{numOfCol:2,children:[o.jsx(zt.Key,{children:"Created at"}),o.jsx(zt.Value,{children:er(new Date(e.createdAt),"MMM d, yyyy 'at' h:mm a")}),e.completedAt&&o.jsxs(o.Fragment,{children:[o.jsx(zt.Key,{children:"Completed at"}),o.jsx(zt.Value,{children:er(new Date(e.completedAt),"MMM d, yyyy 'at' h:mm a")})]}),o.jsx(zt.Key,{children:"Target"}),o.jsx(zt.ValueLink,{href:i(),as:t,children:l()}),e.agentVersion&&o.jsxs(o.Fragment,{children:[o.jsx(zt.Key,{children:"Version"}),c?o.jsx(zt.ValueLink,{href:c,as:t,children:e.agentVersion}):o.jsx(zt.Value,{children:e.agentVersion})]})]})}),o.jsx(Lt.Column,{children:o.jsx(Nes,{experiment:e})})]})})}function H8({children:e}){return o.jsxs(Lt,{height:"full",children:[o.jsx("div",{}),o.jsx(Lt.MainArea,{isCentered:!0,children:e})]})}function Xes(){const{datasetId:e,experimentId:t}=dr(),{data:n,isLoading:r,error:s}=_U(e,t),{data:a,isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u}=$Z({datasetId:e,experimentId:t,experimentStatus:n?.status});return!e||!t||r?null:s&&gs(s)?o.jsx(H8,{children:o.jsx(Vs,{})}):s&&ys(s)?o.jsx(H8,{children:o.jsx(Ds,{resource:"datasets"})}):s&&z1e(s)||!r&&!s&&!n?o.jsx(H8,{children:o.jsx(Lr,{iconSlot:o.jsx(Bye,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${t}".`,actionSlot:o.jsxs(ue,{as:ci,to:`/datasets/${e}?tab=experiments`,children:[o.jsx(Ec,{}),"Back to Dataset"]})})}):s?o.jsx(H8,{children:o.jsx(Fi,{title:"Failed to load experiment",message:s instanceof Error?s.message:"An unexpected error occurred. Please try again."})}):o.jsxs(Lt,{height:"full",children:[o.jsx(c8t,{experiment:n}),o.jsx(Lt.MainArea,{children:o.jsx(o8t,{experimentId:t,datasetId:e,experimentStatus:n.status,results:a??[],isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u})})]})}function Kes(){const{datasetId:e}=dr(),[t,n]=ji(),{error:r}=Ux(e??""),s=t.get("baseline")??"",a=t.get("contender")??"";return r&&gs(r)?o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):r&&ys(r)?o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ds,{resource:"datasets"})})}):!e||!s||!a?o.jsx(cs,{children:o.jsx(xy,{children:o.jsxs("div",{className:"text-neutral4 text-center py-8",children:[o.jsx("p",{children:"Select two experiments to compare."}),o.jsxs("p",{className:"text-sm mt-2",children:["Use the URL format: /datasets/","{datasetId}","/experiments?baseline=","{experimentIdA}","&contender=","{experimentIdB}"]})]})})}):o.jsx(cs,{children:o.jsx(xy,{children:o.jsxs("div",{className:"max-w-[100rem] w-full px-12 mx-auto grid content-start ",children:[o.jsxs(ua,{children:[o.jsxs(ua.Column,{children:[o.jsxs(ua.Title,{children:[o.jsx(Qw,{})," Dataset Experiments Comparison"]}),o.jsxs(ua.Description,{children:["Comparing"," ",o.jsx(ci,{to:`/datasets/${e}/experiments/${s}`,children:s.slice(0,8)})," vs"," ",o.jsx(ci,{to:`/datasets/${e}/experiments/${a}`,children:a.slice(0,8)})]})]}),o.jsx(ua.Column,{children:o.jsxs(ue,{as:ci,to:`/datasets/${e}`,children:[o.jsx(Ec,{}),"Back to Dataset"]})})]}),o.jsx($es,{datasetId:e,experimentIdA:s,experimentIdB:a,onSwap:()=>{n({baseline:a,contender:s})}})]})})})}function Jes(){const{datasetId:e,itemId:t}=dr(),{Link:n}=yn(),r=bs(),{data:s,isLoading:a,error:i}=cTe(e??"",t??""),{updateItem:l,deleteItem:c}=_i(),{data:u}=Ux(e??""),d=s?.[0]??null,f=d?.isDeleted??!1,[p,h]=v.useState(null),m=v.useMemo(()=>!d||f?{input:"",groundTruth:"",metadata:"",trajectory:"",toolMocks:"",requestContext:""}:{input:JSON.stringify(d.input,null,2),groundTruth:d.groundTruth?JSON.stringify(d.groundTruth,null,2):"",metadata:d.metadata?JSON.stringify(d.metadata,null,2):"",trajectory:d.expectedTrajectory!=null?JSON.stringify(d.expectedTrajectory,null,2):"",toolMocks:d.toolMocks?.length?JSON.stringify(d.toolMocks,null,2):"",requestContext:d.requestContext?JSON.stringify(d.requestContext,null,2):""},[d,f]),g=d?.datasetVersion??0,[y,b]=v.useState(!1),[w,S]=v.useState(m.input),[k,_]=v.useState(m.groundTruth),[C,E]=v.useState(m.metadata),[j,N]=v.useState(m.trajectory),[I,R]=v.useState(m.toolMocks),[$,F]=v.useState(m.requestContext),[D,V]=v.useState(g);g!==D&&(V(g),S(m.input),_(m.groundTruth),E(m.metadata),N(m.trajectory),R(m.toolMocks),F(m.requestContext));const[W,L]=v.useState(!1),z=J=>{h(f?J:J.isLatest?null:J)},B=()=>{h(null)},M=!f&&p!=null,G=()=>{M||b(!0)},U=()=>{M||L(!0)},P=async()=>{if(!e||!t)return;let J;try{J=JSON.parse(w)}catch{De.error("Input must be valid JSON");return}let ee;if(k.trim())try{ee=JSON.parse(k)}catch{De.error("Ground Truth must be valid JSON");return}let ae;if(C.trim())try{ae=JSON.parse(C)}catch{De.error("Metadata must be valid JSON");return}let de;const Y=j!==m.trajectory;if(Y&&j.trim())try{de=JSON.parse(j)}catch{De.error("Expected Trajectory must be valid JSON");return}let ne;const ce=I!==m.toolMocks;if(ce&&I.trim())try{const ve=JSON.parse(I);if(!Array.isArray(ve)){De.error("Tool Mocks must be a JSON array");return}ne=ve}catch{De.error("Tool Mocks must be valid JSON");return}let pe;const le=$!==m.requestContext;if(le&&$.trim())try{pe=JSON.parse($)}catch{De.error("Request Context must be valid JSON");return}try{await l.mutateAsync({datasetId:e,itemId:t,input:J,groundTruth:ee,metadata:ae,...Y?{expectedTrajectory:de??null}:{},...ce?{toolMocks:ne??[]}:{},...le?{requestContext:pe}:{}}),De.success("Item updated successfully"),b(!1)}catch(ve){De.error(`Failed to update item: ${ve instanceof Error?ve.message:"Unknown error"}`)}},q=()=>{d&&(S(JSON.stringify(d.input,null,2)),_(d.groundTruth?JSON.stringify(d.groundTruth,null,2):""),E(d.metadata?JSON.stringify(d.metadata,null,2):""),N(d.expectedTrajectory!=null?JSON.stringify(d.expectedTrajectory,null,2):""),R(d.toolMocks?.length?JSON.stringify(d.toolMocks,null,2):""),F(d.requestContext?JSON.stringify(d.requestContext,null,2):"")),b(!1)},Z=async()=>{if(!(!e||!t))try{await c.mutateAsync({datasetId:e,itemId:t}),De.success("Item deleted successfully"),L(!1),r(`/datasets/${e}`)}catch(J){De.error(`Failed to delete item: ${J instanceof Error?J.message:"Unknown error"}`)}},X=p??d,te=X?{id:t??"",datasetId:e??"",datasetVersion:X.datasetVersion,input:X.input,groundTruth:X.groundTruth,expectedTrajectory:X.expectedTrajectory,metadata:X.metadata,createdAt:X.createdAt,updatedAt:X.updatedAt}:null;return i&&gs(i)?o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):i&&ys(i)?o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ds,{resource:"datasets"})})}):a?null:!e||!t||!s||s.length===0?o.jsx(cs,{children:o.jsx(xy,{children:o.jsx("div",{className:"text-neutral3 p-4",children:"Item not found"})})}):o.jsxs(o.Fragment,{children:[o.jsx(cs,{children:o.jsx("div",{className:"h-full overflow-hidden px-6 pb-4",children:o.jsxs("div",{className:"grid gap-6 max-w-[60rem] mx-auto grid-rows-[auto_1fr] h-full",children:[o.jsxs(ua,{children:[o.jsxs(ua.Column,{children:[o.jsxs(ua.Title,{children:[o.jsx(dN,{}),t," ",o.jsx(ya,{content:t})]}),o.jsx(ua.Description,{children:o.jsxs(Nl,{children:["Item of ",o.jsx(ay,{})," ",u?.name]})}),o.jsxs(ua.Description,{children:[o.jsxs(Nl,{children:[o.jsx(ult,{})," Created at"," ",d?.createdAt?er(new Date(d.createdAt),"MMM d, yyyy"):""]}),o.jsxs(Nl,{children:[o.jsx(i_,{})," Latest version v",d?.datasetVersion??""]})]})]}),o.jsx(ua.Column,{children:!y&&!f&&o.jsxs($r,{children:[o.jsxs(ue,{onClick:G,disabled:M,title:M?"Return to latest version to edit":void 0,children:[o.jsx(Nlt,{})," Edit"]}),o.jsxs(ue,{onClick:U,disabled:M,title:M?"Return to latest version to delete":void 0,children:[o.jsx(Jc,{})," Delete"]})]})})]}),o.jsxs(ry,{className:y?"grid-cols-1":"grid-cols-[1fr_auto]",children:[o.jsxs(Gr,{withRightSeparator:!y,children:[f&&d&&o.jsx(In,{variant:"destructive",title:"Item deleted",children:o.jsxs(In.Message,{children:["This item was deleted at version v",d.datasetVersion]})}),!f&&M&&p&&o.jsx(In,{variant:"warning",title:"Previous version",action:o.jsxs(In.Button,{onClick:B,children:[o.jsx(alt,{})," Return to the latest version"]}),children:o.jsxs(In.Message,{children:["Viewing version v",p.datasetVersion]})}),y?o.jsx(s8t,{inputValue:w,setInputValue:S,groundTruthValue:k,setGroundTruthValue:_,metadataValue:C,setMetadataValue:E,trajectoryValue:j,setTrajectoryValue:N,toolMocksValue:I,setToolMocksValue:R,requestContextValue:$,setRequestContextValue:F,validationErrors:null,onSave:P,onCancel:q,isSaving:l.isPending}):te?o.jsx(pTe,{item:te,Link:n}):o.jsx("div",{className:"text-neutral4 text-sm",children:"Item data not available"})]}),!y&&o.jsx(Gr,{children:o.jsx(Mes,{datasetId:e,itemId:t,onClose:()=>{},onVersionSelect:z,onCompareVersionsClick:J=>{r(`/datasets/${e}/items/${t}/versions?ids=${J.join(",")}`)},activeVersion:p?.datasetVersion??null})})]})]})})}),o.jsx(Tt,{open:W,onOpenChange:L,children:o.jsxs(Tt.Content,{children:[o.jsxs(Tt.Header,{children:[o.jsx(Tt.Title,{children:"Delete Item"}),o.jsx(Tt.Description,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),o.jsxs(Tt.Footer,{children:[o.jsx(Tt.Cancel,{children:"Cancel"}),o.jsx(Tt.Action,{onClick:Z,children:c.isPending?"Deleting...":"Delete"})]})]})})]})}function yQe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function ets(){const{datasetId:e}=dr(),[t,n]=ji(),r=t.get("items")?.split(",").filter(Boolean)??[],{data:s,error:a}=Ux(e??""),{Link:i}=yn(),[l,c]=v.useState(!1),{data:u}=CU(e??"",r[0]??""),{data:d}=CU(e??"",r[1]??"");return a&&gs(a)?o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):a&&ys(a)?o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ds,{resource:"datasets"})})}):!e||r.length<2?o.jsx(cs,{children:o.jsx(xy,{children:o.jsx("div",{className:"text-neutral4 text-center py-8",children:o.jsx("p",{children:"Select at least two items to compare."})})})}):o.jsxs(cs,{children:[o.jsx(Ty,{owner:"dataset-items-compare",children:o.jsxs(ue,{as:ci,to:`/datasets/${e}`,variant:"outline",children:[o.jsx(Ec,{}),"Back to Dataset"]})}),o.jsx("div",{className:"h-full overflow-hidden px-[3vw] pb-4",children:o.jsxs("div",{className:K("grid gap-6 max-w-[140rem] mx-auto grid-rows-[auto_1fr] h-full",{"grid-rows-[auto_auto_1fr]":l}),children:[o.jsxs(ua,{children:[o.jsxs(ua.Column,{children:[o.jsxs(ua.Title,{children:[o.jsx(Qw,{}),"Compare Dataset Items"]}),o.jsx(ua.Description,{children:o.jsxs(Nl,{children:["Comparing ",r.length," items of"," ",o.jsx(ci,{to:`/datasets/${e}`,className:"text-info1 hover:underline",children:s?.name||e?.slice(0,8)})]})})]}),o.jsx(ua.Column,{children:o.jsx($r,{children:o.jsx(ue,{variant:"primary",onClick:()=>c(f=>!f),children:l?o.jsxs(o.Fragment,{children:[o.jsx(vlt,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx(ucn,{})," Diff View"]})})})})]}),o.jsx(ry,{className:"grid-cols-[1fr_3vw_1fr]",children:r.map((f,p)=>o.jsxs(v.Fragment,{children:[o.jsx(tts,{datasetId:e,itemId:f,Link:i,idx:p,itemIds:r,showContent:!l,onItemChange:h=>{const m=[...r];m[p]=h,n({items:m.join(",")})}}),p==0&&o.jsx("div",{className:K("bg-surface5 w-[3px] shrink-0 mx-[1.5vw]")})]},f))}),l&&u&&d&&o.jsx(S_e,{codeA:yQe(u),codeB:yQe(d)})]})})]})}function tts({datasetId:e,itemId:t,Link:n,idx:r,itemIds:s,onItemChange:a,showContent:i=!0}){const{data:l,isLoading:c}=CU(e,t),{data:u}=_1(e),d=new Set(s.filter((p,h)=>h!==r)),f=(u??[]).map(p=>({value:p.id,label:p.id,disabled:d.has(p.id)}));return o.jsxs(Gr,{children:[o.jsxs(Gr.Toolbar,{className:"flex gap-4",children:[o.jsxs(ba,{name:`compare-item-${r}`,value:t,onValueChange:a,children:[o.jsx(wa,{"aria-label":"Item",children:o.jsx(xa,{placeholder:"Select item"})}),o.jsx(Sa,{children:f.map(p=>o.jsx(qr,{value:p.value,disabled:p.disabled,children:p.label},p.value))})]}),o.jsxs(ue,{as:n,to:`/datasets/${e}/items/${t}`,children:[o.jsx(i_,{}),"Versions"]})]}),i&&o.jsx(Gr.Content,{children:c?o.jsx("div",{className:"text-neutral4 text-sm",children:"Loading..."}):l?o.jsxs(o.Fragment,{children:[o.jsx(pes,{item:l}),o.jsx(pTe,{item:l,Link:n})]}):o.jsxs("div",{className:"text-neutral4 text-sm",children:["Item ",t.slice(0,8)," not found"]})})]})}function bQe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function nts(){const{datasetId:e,itemId:t}=dr(),[n,r]=ji(),[s,a]=v.useState(!1),i=n.get("ids")?.split(",").map(Number).filter(h=>!isNaN(h)&&h>0)??[],{data:l,error:c}=Ux(e??""),{Link:u}=yn(),{data:d}=cTe(e??"",t??""),{data:f}=Tve(e??"",t??"",i[0]??0,l?.version),{data:p}=Tve(e??"",t??"",i[1]??0,l?.version);return c&&gs(c)?o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):c&&ys(c)?o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ds,{resource:"datasets"})})}):!e||!t||i.length<2?o.jsx(cs,{children:o.jsx(xy,{children:o.jsx("div",{className:"text-neutral4 text-center py-8",children:o.jsx("p",{children:"Select at least two versions to compare."})})})}):o.jsxs(cs,{children:[o.jsx(Ty,{owner:"dataset-item-versions-compare",children:o.jsxs(ue,{as:ci,to:`/datasets/${e}/items/${t}`,variant:"outline",children:[o.jsx(Ec,{}),"Back to Item"]})}),o.jsx("div",{className:"h-full overflow-hidden px-[3vw] pb-4",children:o.jsxs("div",{className:K("grid gap-6 max-w-[140rem] mx-auto grid-rows-[auto_1fr] h-full",{"grid-rows-[auto_auto_1fr]":s}),children:[o.jsxs(ua,{children:[o.jsxs(ua.Column,{children:[o.jsxs(ua.Title,{children:[o.jsx(Qw,{}),"Compare Dataset Item Versions"]}),o.jsx(ua.Description,{children:o.jsxs(Nl,{children:["Comparing ",i.length," versions of"," ",o.jsx(ci,{to:`/datasets/${e}/items/${t}`,className:"text-info1 hover:underline",children:t})]})})]}),o.jsx(ua.Column,{children:o.jsx($r,{children:o.jsx(ue,{variant:"primary",onClick:()=>a(h=>!h),children:s?o.jsxs(o.Fragment,{children:[o.jsx(vlt,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx(Qcn,{})," Diff View"]})})})})]}),o.jsx(ry,{className:"grid-cols-[1fr_3vw_1fr]",children:i.map((h,m)=>o.jsxs(v.Fragment,{children:[o.jsx(rts,{datasetId:e,itemId:t,datasetVersion:h,latestVersion:l?.version,allVersions:d??[],versionNumbers:i,Link:u,idx:m,showContent:!s,onVersionChange:g=>{const y=[...i];y[m]=g,r({ids:y.join(",")})}}),m===0&&o.jsx("div",{className:K("bg-surface5 w-[3px] shrink-0 mx-[1.5vw]")})]},h))}),s&&f&&p&&o.jsx(S_e,{codeA:bQe(f),codeB:bQe(p)})]})})]})}function rts({datasetId:e,itemId:t,datasetVersion:n,latestVersion:r,allVersions:s,versionNumbers:a,Link:i,idx:l,showContent:c=!0,onVersionChange:u}){const{data:d,isLoading:f}=Tve(e,t,n,r),p=new Set(a.filter((g,y)=>y!==l)),h=s.map(g=>{const y=typeof g.updatedAt=="string"?new Date(g.updatedAt):g.updatedAt;return{value:String(g.datasetVersion),label:o.jsxs(o.Fragment,{children:[o.jsxs("b",{children:["v. ",g.datasetVersion]})," - ",er(y,"MMM d, yyyy h:mm a"),g.isLatest?o.jsx(Xs,{color:"blue",size:"small",children:"Latest"}):null]}),disabled:p.has(g.datasetVersion)}}),m=d?{id:d.id,datasetId:e,datasetVersion:d.datasetVersion,input:d.input,groundTruth:d.groundTruth,metadata:d.metadata,createdAt:d.createdAt,updatedAt:d.updatedAt}:null;return o.jsxs(Gr,{children:[o.jsxs(Gr.Toolbar,{className:"grid gap-4 grid-cols-[auto_1fr]",children:[o.jsx(i_,{className:"w-6 h-6 opacity-50"}),o.jsxs(ba,{name:`compare-version-${l}`,value:String(n),onValueChange:g=>u(Number(g)),children:[o.jsx(wa,{"aria-label":"Version",className:"w-full",children:o.jsx(xa,{placeholder:"Select version"})}),o.jsx(Sa,{children:h.map(g=>o.jsx(qr,{value:g.value,disabled:g.disabled,children:g.label},g.value))})]})]}),c&&o.jsx(Gr.Content,{children:f?o.jsx("div",{className:"text-neutral4 text-sm",children:"Loading..."}):!d||!m?o.jsxs("div",{className:"text-neutral4 text-sm",children:["Version ",n," not found"]}):o.jsx(pTe,{item:m,Link:i})})]})}function sts(){const{datasetId:e}=dr(),[t]=ji(),n=t.get("ids")?.split(",").map(Number).filter(g=>!isNaN(g)&&g>0)??[],r=bs(),{data:s,error:a}=Ux(e??""),i=_1(e??"",void 0,n[0]??null),l=_1(e??"",void 0,n[1]??null),c=v.useMemo(()=>i.data??[],[i.data]),u=v.useMemo(()=>l.data??[],[l.data]),d=v.useMemo(()=>{const g=new Map;for(const y of[...c,...u])g.has(y.id)||g.set(y.id,{id:y.id,createdAt:new Date(y.createdAt)});return[...g.values()].sort((y,b)=>b.createdAt.getTime()-y.createdAt.getTime())},[c,u]),f=v.useMemo(()=>new Map(c.map(g=>[g.id,g])),[c]),p=v.useMemo(()=>new Map(u.map(g=>[g.id,g])),[u]);if(a&&gs(a))return o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})});if(a&&ys(a))return o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ds,{resource:"datasets"})})});if(!e||n.length<2)return o.jsx(cs,{children:o.jsx(xy,{children:o.jsx("div",{className:"text-neutral4 text-center py-8",children:o.jsx("p",{children:"Select at least two versions to compare."})})})});const h=(g,y,b)=>{r(`/datasets/${e}/items/${g}/versions?ids=${y?.datasetVersion??""},${b?.datasetVersion??""}`)},m=(g,y)=>{r(`/datasets/${e}/versions?ids=${g},${y}`,{replace:!0})};return o.jsx(cs,{children:o.jsx("div",{className:"h-full overflow-hidden px-[3vw] pb-4",children:o.jsxs("div",{className:"grid gap-6 max-w-[140rem] mx-auto grid-rows-[auto_1fr] h-full",children:[o.jsxs(ua,{children:[o.jsxs(ua.Column,{children:[o.jsxs(ua.Title,{children:[o.jsx(Idn,{})," Compare Dataset Versions"]}),o.jsx(ua.Description,{children:o.jsxs(Nl,{children:[o.jsx(i_,{})," Comparing ",n.length," versions of"," ",s?.name||e?.slice(0,8)]})})]}),o.jsx(ua.Column,{children:o.jsxs(ue,{as:ci,to:`/datasets/${e}`,children:[o.jsx(Ec,{}),"Back to Dataset"]})})]}),o.jsx(ry,{children:o.jsxs(Gr,{children:[o.jsx(Fes,{datasetId:e,versionA:String(n[0]),versionB:String(n[1]),onVersionChange:m}),o.jsx(qes,{datasetId:e,versionA:n[0],versionB:n[1],allItems:d,itemsAMap:f,itemsBMap:p,onItemClick:h})]})})]})})})}function Nve({children:e,className:t}){return o.jsx("div",{className:K("flex flex-wrap gap-8",t),children:e})}function ats(e){if(!e||e.length<2)return null;const t=[...e].sort((i,l)=>new Date(i.createdAt).getTime()-new Date(l.createdAt).getTime()),n=Math.floor(t.length/2),r=n,s=t.length-n;if(r===0)return null;const a=(s-r)/r*100;return{changePct:Math.round(a*10)/10,prevValue:String(r)}}function its({scorers:e,datasets:t,experiments:n,avgScore:r,prevAvgScore:s,totalNeedsReview:a,isLoadingScorers:i,isLoadingDatasets:l,isLoadingExperiments:c,isLoadingScores:u,isLoadingReview:d}){const f=e?Object.keys(e).length:void 0,p=t?.length,h=n?.length,m=r!=null&&s!=null&&s!==0?{changePct:Math.round((r-s)/s*100*10)/10,prevValue:String(s)}:null,g=ats(n);return o.jsxs(o.Fragment,{children:[o.jsxs(Kr,{children:[o.jsx(Kr.Label,{children:"Total Scorers"}),i?o.jsx(Kr.Loading,{}):f!=null?o.jsxs(o.Fragment,{children:[o.jsx(Kr.Value,{children:String(f)}),o.jsx(Kr.NoChange,{message:"Static count"})]}):o.jsx(Kr.NoData,{})]}),o.jsxs(Kr,{children:[o.jsx(Kr.Label,{children:"Total Datasets"}),l?o.jsx(Kr.Loading,{}):p!=null?o.jsxs(o.Fragment,{children:[o.jsx(Kr.Value,{children:String(p)}),o.jsx(Kr.NoChange,{message:"Static count"})]}):o.jsx(Kr.NoData,{})]}),o.jsxs(Kr,{children:[o.jsx(Kr.Label,{children:"Avg Score"}),u?o.jsx(Kr.Loading,{}):r!=null?o.jsxs(o.Fragment,{children:[o.jsx(Kr.Value,{children:String(r)}),m?o.jsx(Kr.Change,{changePct:m.changePct,prevValue:m.prevValue}):o.jsx(Kr.NoChange,{})]}):o.jsx(Kr.NoData,{})]}),o.jsxs(Kr,{children:[o.jsx(Kr.Label,{children:"Total Experiments"}),c?o.jsx(Kr.Loading,{}):h!=null?o.jsxs(o.Fragment,{children:[o.jsx(Kr.Value,{children:String(h)}),g?o.jsx(Kr.Change,{changePct:g.changePct,prevValue:g.prevValue}):o.jsx(Kr.NoChange,{})]}):o.jsx(Kr.NoData,{})]}),o.jsxs(Kr,{children:[o.jsx(Kr.Label,{children:"Needs Review"}),d?o.jsx(Kr.Loading,{}):a!=null?o.jsxs(o.Fragment,{children:[o.jsx(Kr.Value,{children:String(a)}),a>0?o.jsx(Kr.NoChange,{message:"items pending review"}):o.jsx(Kr.NoChange,{message:"All caught up"})]}):o.jsx(Kr.NoData,{})]})]})}const xQe="auto 1fr auto auto auto auto auto auto auto";function ots(e){return e?(typeof e=="string"?new Date(e):e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}const lts={completed:"success",running:"warning",failed:"error",pending:"neutral"};function cts({experiments:e,datasets:t,reviewByExperiment:n,isLoading:r,search:s="",statusFilter:a="all",datasetFilter:i="all"}){const{paths:l,Link:c}=yn(),u=v.useMemo(()=>{const p=new Map;return t?.forEach(h=>p.set(h.id,h.name)),p},[t]),d=v.useMemo(()=>[...e].sort((p,h)=>{const m=p.createdAt?new Date(p.createdAt).getTime():0;return(h.createdAt?new Date(h.createdAt).getTime():0)-m}),[e]),f=v.useMemo(()=>{const p=s.toLowerCase();return d.filter(h=>{const m=h.datasetId?u.get(h.datasetId)??"":"",g=!p||h.id.toLowerCase().includes(p)||m.toLowerCase().includes(p)||(h.targetId??"").toLowerCase().includes(p),y=a==="all"||h.status===a,b=i==="all"||h.datasetId===i;return g&&y&&b})},[d,s,u,a,i]);return r?o.jsx(el,{columns:xQe}):o.jsxs(me,{columns:xQe,variant:"striped",children:[o.jsxs(me.Top,{children:[o.jsx(me.TopCell,{children:"Experiment"}),o.jsx(me.TopCell,{children:"Dataset"}),o.jsx(me.TopCell,{children:"Target"}),o.jsx(me.TopCell,{children:"Status"}),o.jsx(me.TopCell,{className:"text-center",children:"Items"}),o.jsx(me.TopCell,{className:"text-center",children:"Succeeded"}),o.jsx(me.TopCell,{className:"text-center",children:"Failed"}),o.jsx(me.TopCell,{className:"text-center",children:"Review"}),o.jsx(me.TopCell,{children:"Date"})]}),f.map(p=>{const h=p.datasetId?u.get(p.datasetId)??p.datasetId.slice(0,8):"—",m=p.status??"pending",g=p.succeededCount??0,y=p.failedCount??0,b=p.totalItems??0,w=b>0?Math.round(g/b*100):0;return o.jsxs(me.RowLink,{to:l.experimentLink(p.id),LinkComponent:c,children:[o.jsx(me.NameCell,{className:"font-mono",children:p.id.slice(0,8)}),o.jsx(me.TextCell,{children:h}),o.jsx(me.Cell,{children:o.jsxs("span",{className:"truncate",children:[p.targetType," ",p.targetId]})}),o.jsx(me.Cell,{children:o.jsx(dg,{variant:lts[m]??"neutral",withDot:!0,children:m})}),o.jsx(me.TextCell,{className:"text-center",children:b}),o.jsx(me.TextCell,{className:"text-center",children:o.jsxs("span",{className:g>0?"text-accent1":"",children:[g," (",w,"%)"]})}),o.jsx(me.TextCell,{className:"text-center",children:o.jsx("span",{className:y>0?"text-accent2":"",children:y})}),o.jsx(me.Cell,{className:"text-center",children:(()=>{const S=n?.get(p.id);if(!S)return o.jsx("span",{className:"text-neutral2",children:"—"});const k=S.needsReview+S.complete;return k===0?o.jsx("span",{className:"text-neutral2",children:"—"}):S.needsReview>0?o.jsxs(Xs,{size:"small",color:"yellow",children:[S.needsReview," pending"]}):o.jsxs(Xs,{size:"small",color:"green",children:[S.complete,"/",k," reviewed"]})})()}),o.jsx(me.TextCell,{children:ots(p.createdAt)})]},p.id)})]})}const uts=[{value:"all",label:"All statuses"},{value:"completed",label:"Completed"},{value:"running",label:"Running"},{value:"failed",label:"Failed"},{value:"pending",label:"Pending"}];function dts(e){return[{value:"all",label:"All datasets"},...(e??[]).map(t=>({value:t.id,label:t.name}))]}const W8={completed:"#22c55e",running:"#facc15",pending:"#fb923c",failed:"#f87171"},fts=[{label:"Completed",color:W8.completed},{label:"Running",color:W8.running},{label:"Pending",color:W8.pending},{label:"Failed",color:W8.failed}];function pts({experiments:e,datasets:t,isLoading:n,isError:r}){const{data:s,maxVal:a}=v.useMemo(()=>{if(!e||e.length===0)return{data:[],maxVal:0};const l=new Map;if(t)for(const f of t)l.set(f.id,f.name);const c=new Map;for(const f of e){const p=f.datasetId??"unknown";c.has(p)||c.set(p,{completed:0,running:0,pending:0,failed:0});const h=c.get(p),m=f.status;m in h&&h[m]++}let u=0;return{data:Array.from(c.entries()).map(([f,p])=>{const h=p.completed+p.running+p.pending+p.failed;return h>u&&(u=h),{name:l.get(f)??f.slice(0,12),values:[p.completed,p.running,p.pending,p.failed]}}),maxVal:u}},[e,t]),i=s.length>0;return o.jsxs(Bt,{children:[o.jsxs(Bt.TopBar,{children:[o.jsx(Bt.TitleAndDescription,{title:"Experiments by Dataset",description:"Experiment status breakdown per dataset."}),i&&o.jsx(Bt.Summary,{value:String(e?.length??0),label:"Total experiments"})]}),n?o.jsx(Bt.Loading,{}):r?o.jsx(Bt.Error,{message:"Failed to load experiments data"}):o.jsx(Bt.Content,{children:i?o.jsx(aN,{data:s,segments:fts,maxVal:a,fmt:l=>String(l)}):o.jsx(Bt.NoData,{message:"No experiments have been run yet"})})]})}const hts=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Lr,{iconSlot:o.jsx(xf,{}),titleSlot:"No Experiments yet",descriptionSlot:o.jsxs(o.Fragment,{children:["Run an experiment from a dataset to evaluate ",o.jsx("br",{}),"your agents and workflows."]}),actionSlot:o.jsx("div",{className:"flex flex-col items-center gap-2",children:o.jsxs(ue,{variant:"ghost",as:"a",href:"https://mastra.ai/en/docs/evals/datasets/running-experiments",target:"_blank",rel:"noopener noreferrer",children:["Experiments Documentation ",o.jsx(Pa,{})]})})})});function mts({search:e,onSearchChange:t,statusFilter:n,onStatusFilterChange:r,datasetFilter:s,onDatasetFilterChange:a,datasetOptions:i,onReset:l,hasActiveFilters:c}){return o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx(Of,{label:"Search experiments",placeholder:"Filter by experiment, dataset, or target",value:e,onSearch:t}),o.jsxs($r,{children:[o.jsx(xc,{label:"Status",labelIsHidden:!0,name:"filter-status",options:[...uts],value:n,onValueChange:r,className:"whitespace-nowrap"}),o.jsx(xc,{label:"Dataset",labelIsHidden:!0,name:"filter-dataset",options:i,value:s,onValueChange:a,className:"whitespace-nowrap"}),l&&c&&o.jsxs(ue,{onClick:l,size:"sm",variant:"default",children:[o.jsx(vs,{className:"size-3"})," Reset"]})]})]})}function gts(){const{data:e,isLoading:t,error:n}=eh(),{data:r,isLoading:s,error:a}=Rg(),{data:i,isLoading:l,error:c}=zZ(),{data:u,isLoading:d,isError:f,error:p}=fWr(),{data:h,isLoading:m,isError:g,error:y}=gTe(),b=r?.datasets,w=i?.experiments,S=v.useMemo(()=>Zes(h),[h]),k=n||a||c||p||y;return k&&gs(k)?o.jsx(lr,{children:o.jsx(Vs,{})}):k&&ys(k)?o.jsx(lr,{children:o.jsx(Ds,{resource:"evaluation"})}):k?o.jsx(lr,{children:o.jsx(Fi,{title:"Failed to load evaluation data",message:k.message})}):o.jsx(Lt,{width:"wide",height:"full",children:o.jsxs("div",{className:"flex flex-col gap-6",children:[o.jsx(Nve,{children:o.jsx(its,{scorers:e,datasets:b,experiments:w,avgScore:u?.avgScore??null,prevAvgScore:u?.prevAvgScore??null,totalNeedsReview:S.needsReview,isLoadingScorers:t,isLoadingDatasets:s,isLoadingExperiments:l,isLoadingScores:d,isLoadingReview:m})}),o.jsx(yHr,{summaryData:u?.summaryData??[],overTimeData:u?.overTimeData??[],scorerNames:u?.scorerNames??[],avgScore:u?.avgScore??null,isLoading:d,isError:f}),o.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[o.jsx(GKr,{experiments:w,isLoading:l,isError:!!c}),o.jsx(pts,{experiments:w,datasets:b,isLoading:l,isError:!!c})]}),o.jsx(Hes,{reviewSummary:h,experiments:w,datasets:b,isLoading:m,isError:!!g})]})})}function vts(){const[e,t]=v.useState(""),[n,r]=v.useState("all"),[s,a]=v.useState("all"),{data:i,isLoading:l,error:c}=Rg(),{data:u,isLoading:d,error:f}=zZ(),{data:p}=gTe(),h=v.useMemo(()=>i?.datasets??[],[i?.datasets]),m=v.useMemo(()=>u?.experiments??[],[u?.experiments]),g=v.useMemo(()=>dts(h),[h]),y=v.useMemo(()=>l8t(p),[p]),b=l||d,w=f||c;if(w&&gs(w))return o.jsx(lr,{children:o.jsx(Vs,{})});if(f&&ys(f))return o.jsx(lr,{children:o.jsx(Ds,{resource:"experiments"})});if(c&&ys(c))return o.jsx(lr,{children:o.jsx(Ds,{resource:"datasets"})});if(w)return o.jsx(lr,{children:o.jsx(Fi,{title:"Failed to load experiments",message:w.message})});if(m.length===0&&!b)return o.jsx(lr,{children:o.jsx(hts,{})});const S=n!=="all"||s!=="all"||e!=="",k=()=>{t(""),r("all"),a("all")};return o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx(mts,{search:e,onSearchChange:t,statusFilter:n,onStatusFilterChange:r,datasetFilter:s,onDatasetFilterChange:a,datasetOptions:g,onReset:k,hasActiveFilters:S})}),o.jsx(cts,{experiments:m,datasets:h,reviewByExperiment:y,isLoading:b,search:e,statusFilter:n,datasetFilter:s})]})}function Z8({children:e}){return o.jsxs(Lt,{height:"full",children:[o.jsx("div",{}),o.jsx(Lt.MainArea,{isCentered:!0,children:e})]})}function yts(){const{experimentId:e}=dr(),{data:t,isLoading:n}=zZ(),s=t?.experiments?.find(h=>h.id===e)?.datasetId??"",{data:a,isLoading:i,error:l}=_U(s,e??""),{data:c,isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p}=$Z({datasetId:s,experimentId:e??"",experimentStatus:a?.status});return!e||n||i?null:l&&gs(l)?o.jsx(Z8,{children:o.jsx(Vs,{})}):l&&ys(l)?o.jsx(Z8,{children:o.jsx(Ds,{resource:"datasets"})}):l&&z1e(l)||!n&&!s||!i&&!l&&!a?o.jsx(Z8,{children:o.jsx(Lr,{iconSlot:o.jsx(Bye,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${e}".`,actionSlot:o.jsxs(ue,{as:ci,to:"/experiments",children:[o.jsx(Ec,{}),"Back to Experiments"]})})}):l?o.jsx(Z8,{children:o.jsx(Fi,{title:"Failed to load experiment",message:l instanceof Error?l.message:"An unexpected error occurred. Please try again."})}):o.jsxs(Lt,{height:"full",children:[o.jsx(c8t,{experiment:a}),o.jsx(Lt.MainArea,{children:o.jsx(o8t,{experimentId:e,datasetId:s,experimentStatus:a.status,results:c??[],isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p})})]})}function bts({connection:e,isAdmin:t,disconnectPending:n,onDisconnect:r}){return o.jsxs("li",{className:"flex items-center justify-between border-b py-2",children:[o.jsxs("div",{children:[o.jsx("div",{className:"font-mono text-xs",children:e.connectionId}),o.jsxs("div",{className:"text-xs text-gray-500",children:[e.label??"(no label)"," · ",e.status,e.scope?` · ${e.scope}`:"",t&&e.authorId?` · author: ${e.authorId}`:""]})]}),o.jsx("button",{type:"button",className:"text-red-600 underline disabled:opacity-50",onClick:r,disabled:n,children:"Disconnect"})]})}function u8t({connections:e,isAdmin:t,disconnectPending:n,onDisconnect:r}){return o.jsx("ul",{className:"space-y-1",children:e.map(s=>o.jsx(bts,{connection:s,isAdmin:t,disconnectPending:n,onDisconnect:()=>r(s.connectionId)},s.connectionId))})}function xts({groups:e,isAdmin:t,disconnectPending:n,onDisconnect:r}){return o.jsx("div",{className:"space-y-4",children:e.map(([s,a])=>o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold text-gray-700","data-testid":`integration-author-group-${s}`,children:s==="shared"?"Shared":`Owned by ${s}`}),o.jsx(u8t,{connections:a,isAdmin:t,disconnectPending:n,onDisconnect:r})]},s))})}function wts({providerId:e,toolkit:t,connections:n,groupedByAuthor:r,isAdmin:s,isLoading:a,error:i,disconnectPending:l,disconnectError:c,onDisconnect:u}){return o.jsxs("div",{className:"space-y-2 border rounded p-4",children:[o.jsx("h2",{className:"text-lg font-semibold",children:"Existing connections"}),!e||!t?o.jsx("p",{className:"text-gray-500",children:"Pick a provider and toolkit to list connections."}):a?o.jsx("p",{className:"text-gray-500",children:"Loading…"}):i?o.jsx("p",{className:"text-red-600",children:String(i)}):n.length===0?o.jsx("p",{className:"text-gray-500",children:"No connections."}):r?o.jsx(xts,{groups:r,isAdmin:s,disconnectPending:l,onDisconnect:u}):o.jsx(u8t,{connections:n,isAdmin:s,disconnectPending:l,onDisconnect:u}),c?o.jsx("p",{className:"text-red-600",children:String(c)}):null]})}function Sts({providers:e,toolkits:t,providerId:n,toolkit:r,label:s,providersLoading:a,providersError:i,toolkitsLoading:l,toolkitsError:c,authorizePending:u,authorizeError:d,authorizedConnection:f,onProviderChange:p,onToolkitChange:h,onLabelChange:m,onConnect:g}){return o.jsxs("div",{className:"space-y-4 border rounded p-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"block font-medium",htmlFor:"provider-select",children:"Provider"}),o.jsxs("select",{id:"provider-select",className:"border rounded px-2 py-1 w-full",value:n,onChange:y=>p(y.target.value),disabled:a,children:[o.jsx("option",{value:"",children:"— select provider —"}),e.map(y=>o.jsxs("option",{value:y.id,children:[y.displayName??y.name," (",y.id,")"]},y.id))]}),a&&o.jsx("span",{className:"text-gray-500",children:"Loading providers…"}),i?o.jsx("span",{className:"text-red-600",children:String(i)}):null]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"block font-medium",htmlFor:"toolkit-select",children:"Toolkit"}),o.jsxs("select",{id:"toolkit-select",className:"border rounded px-2 py-1 w-full",value:r,onChange:y=>h(y.target.value),disabled:!n||l,children:[o.jsx("option",{value:"",children:"— select toolkit —"}),t.map(y=>o.jsxs("option",{value:y.slug,children:[y.name," (",y.slug,")"]},y.slug))]}),l&&o.jsx("span",{className:"text-gray-500",children:"Loading toolkits…"}),c?o.jsx("span",{className:"text-red-600",children:String(c)}):null]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"block font-medium",htmlFor:"label-input",children:"Label (optional)"}),o.jsx("input",{id:"label-input",type:"text",className:"border rounded px-2 py-1 w-full",placeholder:"My personal Gmail",value:s,onChange:y=>m(y.target.value),disabled:!n||!r})]}),o.jsx("button",{type:"button",className:"bg-blue-600 text-white rounded px-4 py-2 disabled:opacity-50",onClick:g,disabled:!n||!r||u,children:u?"Authorizing…":"Connect"}),d?o.jsx("p",{className:"text-red-600",children:String(d)}):null,f&&o.jsxs("p",{className:"text-green-700",children:["Authorized: ",f.connectionId," (status: ",f.status,")"]})]})}const wQe=e=>e.authorId?.trim()||"shared",kts=(e,t)=>{if(!t||new Set(e.map(wQe)).size<=1)return null;const r=new Map;for(const a of e){const i=wQe(a);r.set(i,[...r.get(i)??[],a])}const s=Array.from(r.entries());return s.sort(([a],[i])=>a==="shared"?1:i==="shared"?-1:a.localeCompare(i)),s},Ots=["*","tool-providers:*","tool-providers:admin"];function _ts(){const{data:e}=wm();return e?.permissions?.some(t=>Ots.includes(t))??!1}function Cts(){const[e,t]=v.useState(""),[n,r]=v.useState(""),[s,a]=v.useState(""),i=cI(),l=lW(e||null),c=iAt(e||null,n||null),u=aAt(),d=nAt(),f=_ts(),p=i.data?.providers??[],h=l.data?.data??[],m=v.useMemo(()=>c.data?.items??[],[c.data?.items]),g=v.useMemo(()=>kts(m,f),[m,f]),y=S=>{t(S),r("")},b=()=>{!e||!n||u.mutate({providerId:e,toolkit:n,label:s.trim()||null},{onSuccess:()=>{a(""),c.refetch()}})},w=S=>{d.mutate({providerId:e,connectionId:S})};return o.jsxs("div",{className:"p-6 max-w-3xl space-y-6 text-sm",children:[o.jsx("h1",{className:"text-2xl font-semibold",children:"Integrations"}),o.jsx("p",{className:"text-gray-500",children:"Minimal page to verify the ToolProvider backend. Pick a provider and toolkit, then connect."}),o.jsx(Sts,{providers:p,toolkits:h,providerId:e,toolkit:n,label:s,providersLoading:i.isLoading,providersError:i.error,toolkitsLoading:l.isLoading,toolkitsError:l.error,authorizePending:u.isPending,authorizeError:u.error,authorizedConnection:u.data,onProviderChange:y,onToolkitChange:r,onLabelChange:a,onConnect:b}),o.jsx(wts,{providerId:e,toolkit:n,connections:m,groupedByAuthor:g,isAdmin:f,isLoading:c.isLoading,error:c.error,disconnectPending:d.isPending,disconnectError:d.error,onDisconnect:w})]})}function Ets({title:e,description:t,errorBanner:n,children:r}){return o.jsx("div",{"data-testid":"login-page",className:"flex min-h-screen items-center justify-center bg-surface1",children:o.jsxs("div",{className:"w-full max-w-sm space-y-6",children:[o.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[o.jsx(Zh,{className:"h-10 w-10"}),o.jsx("h1",{className:"text-xl font-semibold text-neutral6",children:e})]}),t,n,r]})})}function d8t({redirectUri:e,onSuccess:t,initialMode:n="signin",errorMessage:r}){const{data:s,isLoading:a}=rc(),{mutate:i,isPending:l,error:c}=u1r(),{mutate:u,isPending:d,error:f}=f1r(),{mutate:p,isPending:h}=TNt(),[m,g]=v.useState(n),[y,b]=v.useState(""),[w,S]=v.useState(""),[k,_]=v.useState("");if(a)return o.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface1",children:o.jsx("div",{className:"text-neutral3",children:"Loading..."})});if(!s?.enabled||!s?.login)return o.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface1",children:o.jsx("div",{className:"text-neutral3",children:"Authentication is not configured"})});const{login:C}=s,E=C.type==="sso"||C.type==="both",j=C.type==="credentials"||C.type==="both",N=C.sso,I=C.signUpEnabled!==!1,R=m==="signin"||!I,$=R?l:d,F=R?c:f,D=()=>{t?t():e?window.location.href=e:window.location.href="/"},V=M=>{M.preventDefault(),R?i({email:w,password:k},{onSuccess:D}):u({email:w,password:k,name:y||void 0},{onSuccess:D})},W=()=>{p({redirectUri:e},{onSuccess:M=>{window.location.href=M.url}})},L=()=>{g(R?"signup":"signin")},z=C.description?o.jsxs("div",{className:"flex items-start gap-2.5 rounded-md border border-border1 bg-surface1 p-3",children:[o.jsx(pf,{className:"mt-0.5 h-4 w-4 shrink-0 text-neutral4"}),o.jsx("p",{className:"text-sm text-neutral3",children:C.description})]}):null,B=r?o.jsx("div",{className:"rounded-md bg-red-500/10 p-3 text-sm text-red-400",children:r}):null;return o.jsxs(Ets,{title:R?"Sign in to Mastra Studio":"Create your account",description:z,errorBanner:B,children:[j&&o.jsxs("form",{onSubmit:V,className:"space-y-4",children:[!R&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"name",className:"block text-sm text-neutral4",children:"Name"}),o.jsx(kn,{id:"name",type:"text",value:y,onChange:M=>b(M.target.value),placeholder:"Your name",variant:"default",size:"lg"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"email",className:"block text-sm text-neutral4",children:"Email"}),o.jsx(kn,{id:"email",type:"email",value:w,onChange:M=>S(M.target.value),placeholder:"you@example.com",required:!0,variant:"default",size:"lg"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"password",className:"block text-sm text-neutral4",children:"Password"}),o.jsx(kn,{id:"password",type:"password",value:k,onChange:M=>_(M.target.value),placeholder:R?"Enter your password":"Create a password",required:!0,variant:"default",size:"lg"})]}),F&&o.jsx("div",{className:"rounded-md bg-red-500/10 p-3 text-sm text-red-400",children:F.message}),o.jsx(ue,{type:"submit",disabled:$,className:"w-full",size:"lg",children:$?R?"Signing in...":"Creating account...":R?"Sign in":"Create account"}),I&&o.jsxs("div",{className:"text-center text-sm",children:[o.jsx("span",{className:"text-neutral3",children:R?"Don't have an account? ":"Already have an account? "}),o.jsx("button",{type:"button",onClick:L,className:"text-neutral6 hover:underline",children:R?"Sign up":"Sign in"})]})]}),E&&j&&o.jsxs("div",{className:"relative",children:[o.jsx("div",{className:"absolute inset-0 flex items-center",children:o.jsx("div",{className:"w-full border-t border-border1"})}),o.jsx("div",{className:"relative flex justify-center text-sm",children:o.jsx("span",{className:"bg-surface1 px-2 text-neutral3",children:"or continue with"})})]}),E&&N&&o.jsxs(ue,{onClick:W,disabled:h,className:"w-full",size:"lg",variant:"outline",children:[N.icon&&o.jsx("span",{className:"mr-2",children:N.icon}),h?"Redirecting...":N.text||"Sign in"]})]})}function jts(){const[e]=ji(),t=bs(),n=e.get("redirect")||"/",s=e.get("mode")==="signup"?"signup":"signin",a=e.get("error_description")||e.get("error")||null,i=()=>{n.startsWith("http")?window.location.href=n:t(n,{replace:!0})};return o.jsx(d8t,{redirectUri:n,onSuccess:i,initialMode:s,errorMessage:a})}function Tts({error:e,resource:t,errorTitle:n}){if(gs(e))return o.jsx(Vs,{});if(ys(e))return o.jsx(Ds,{resource:t});if(b1t(e,"logs"))return o.jsx(Lr,{iconSlot:o.jsx(_xe,{}),titleSlot:"Logs are not available with your current storage",descriptionSlot:"The configured observability storage provider does not support listing logs. Switch to a storage provider with logs support to view runtime logs in Studio."});const r=e instanceof Error?e.message:void 0;return o.jsx(Fi,{title:n,message:r??"Unknown error"})}function Nts({listSlot:e,logPanelSlot:t,tracePanelSlot:n,spanPanelSlot:r,logCollapsed:s}){const a=!!t;return o.jsxs("div",{className:K("grid h-full min-h-0 gap-4 items-start",a?"grid-cols-[1fr_1fr]":"grid-cols-[1fr]"),children:[e,a&&o.jsxs("div",{className:K("grid gap-4 h-full overflow-auto",n&&r?s?"grid-rows-[auto_1fr_1fr]":"grid-rows-[1fr_1fr_1fr]":n?s?"grid-rows-[auto_1fr]":"grid-rows-[1fr_1fr]":s?"grid-rows-[auto]":"grid-rows-[1fr]"),children:[t,n,r]})]})}const Its={debug:{label:"DEBUG",color:"#71717a"},info:{label:"INFO",color:"#60a5fa"},warn:{label:"WARN",color:"#facc15"},error:{label:"ERROR",color:"#f87171"},fatal:{label:"FATAL",color:"#dc2626"}};function Ats({level:e}){const t=Its[e];return o.jsx(So,{height:"compact",children:o.jsx("span",{className:"uppercase text-ui-sm font-semibold",style:{color:t.color},children:t.label})})}function Rts({entityType:e,className:t}){const n=K("size-3.5 shrink-0 text-neutral2",t);switch(e.toLowerCase()){case Os.AGENT:return o.jsx(rl,{className:n,"aria-hidden":!0});case"workflow":case Os.WORKFLOW_RUN:return o.jsx(kd,{className:n,"aria-hidden":!0});case Os.TOOL:return o.jsx(Gp,{className:n,"aria-hidden":!0});default:return null}}function Pts({entityType:e,entityName:t}){const n=e??"";return o.jsxs(So,{height:"compact",className:"flex min-w-0 items-center gap-2",children:[o.jsx(Rts,{entityType:n}),t?o.jsx("span",{className:"min-w-0 text-ui-smd truncate",children:t}):"-"]})}function $ts({message:e}){return o.jsx(So,{height:"compact",className:"text-neutral4 text-ui-smd min-w-0 truncate font-mono",children:e})}function Mts({data:e}){if(!e||Object.keys(e).length===0)return o.jsx(So,{height:"compact",children:null});const t=Object.entries(e).map(([n,r])=>{if(typeof r=="string")return`${n}: ${r}`;try{return`${n}: ${JSON.stringify(r)}`}catch{return`${n}: <unserializable>`}}).join(", ");return o.jsx(Wke,{children:t})}const zl=Object.assign(FD,{Top:BH,TopCell:$_,TopCellWithTooltip:UH,TopCellSmart:REt,RowWrapper:Xke,RowButton:zD,RowLink:PEt,Spacer:Yke,NoMatch:zH,DateCell:Zke,TimeCell:Gke,LevelCell:Ats,EntityCell:Pts,MessageCell:$ts,DataCell:Mts,NextPageLoading:FH}),SQe="6rem 9rem 5rem 10rem minmax(8rem,1fr) minmax(8rem,1fr)",Dts=36,Lts=8;function Fts({logs:e,isLoading:t,isFetchingNextPage:n,hasNextPage:r,setEndOfListElement:s,logIdMap:a,featuredLogId:i,onLogClick:l}){const c=v.useRef(null),u=P6t({count:e.length,getScrollElement:()=>c.current,estimateSize:()=>Dts,overscan:Lts}),d=v.useRef(t);if(v.useEffect(()=>{d.current&&!t&&c.current?.dispatchEvent(new Event("scroll")),d.current=t},[t]),t)return o.jsx(el,{columns:SQe});const f=u.getVirtualItems(),p=u.getTotalSize(),h=f[0]?.start??0,m=f.length>0?Math.max(0,p-(f[f.length-1]?.end??0)):0;return o.jsxs(zl,{columns:SQe,variant:"striped",scrollRef:c,className:"min-w-0",children:[o.jsxs(zl.Top,{children:[o.jsx(zl.TopCell,{children:"Date"}),o.jsx(zl.TopCell,{children:"Time"}),o.jsx(zl.TopCell,{children:"Level"}),o.jsx(zl.TopCell,{children:"Entity"}),o.jsx(zl.TopCell,{children:"Message"}),o.jsx(zl.TopCell,{children:"Data"})]}),e.length===0?o.jsx(zl.NoMatch,{message:"No logs match your search"}):o.jsxs(o.Fragment,{children:[o.jsx(zl.Spacer,{height:h}),f.map(g=>{const y=e[g.index];if(!y)return null;const b=a.get(y);if(!b)return null;const w=b===i;return o.jsxs(zl.RowButton,{ref:u.measureElement,"data-index":g.index,onClick:()=>l(y),featured:w,variant:y.level==="error"||y.level==="fatal"?"error":"default",children:[o.jsx(zl.DateCell,{timestamp:y.timestamp}),o.jsx(zl.TimeCell,{timestamp:y.timestamp}),o.jsx(zl.LevelCell,{level:y.level}),o.jsx(zl.EntityCell,{entityType:y.entityType,entityName:y.entityName}),o.jsx(zl.MessageCell,{message:y.message}),o.jsx(zl.DataCell,{data:y.data})]},b)}),o.jsx(zl.Spacer,{height:m})]}),o.jsx(zl.NextPageLoading,{isLoading:n,hasMore:r,setEndOfListElement:s})]})}function zts({onClear:e,onRemoveAll:t,onSave:n,onRemoveSaved:r,isLoading:s,filterFields:a,filterTokens:i,onFilterTokensChange:l,autoFocusFilterFieldId:c}){const u=i.length>0,d=i.some(f=>Bts(f,a));return o.jsxs("div",{className:K("grid grid-cols-[1fr_auto] gap-3 items-start"),children:[o.jsx(nTe,{fields:a,tokens:i,onTokensChange:l,disabled:s,autoFocusFieldId:c}),u&&o.jsx(eTe,{disabled:s,onClear:d?e:void 0,onRemoveAll:t,onSave:n,onRemoveSaved:r})]})}function Bts(e,t){const n=t.find(r=>r.id===e.fieldId);return n?n.kind==="text"?typeof e.value=="string"&&e.value.trim()!=="":n.kind==="pick-multi"?n.multi?Array.isArray(e.value)&&e.value.length>0:typeof e.value=="string"&&e.value!==""&&e.value!=="Any":n.kind==="multi-select"?Array.isArray(e.value)&&e.value.length>0:!1:!1}const Uts={"last-24h":"the last 24 hours","last-3d":"the last 3 days","last-7d":"the last 7 days","last-14d":"the last 14 days","last-30d":"the last 30 days"},zre="MMM d, yyyy HH:mm",Bre="Pick a wider range or lower the logging level — verbose entries (debug, info) may be filtered out.";function qts({datePreset:e,dateFrom:t,dateTo:n}){return e&&e!=="all"&&e!=="custom"?{title:`No logs for ${Uts[e]}`,description:Bre}:t&&n?{title:`No logs between ${er(t,zre)} and ${er(n,zre)}`,description:Bre}:t?{title:`No logs since ${er(t,zre)}`,description:Bre}:{title:"No logs yet",description:"Logs will appear here once agents, workflows, or tools are executed."}}const Vts=({datePreset:e,dateFrom:t,dateTo:n}={})=>{const{title:r,description:s}=qts({datePreset:e,dateFrom:t,dateTo:n});return o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Lr,{iconSlot:o.jsx(_xe,{}),titleSlot:r,descriptionSlot:s,actionSlot:o.jsxs(ue,{variant:"ghost",as:"a",href:"https://mastra.ai/en/docs/observability/logging",target:"_blank",rel:"noopener noreferrer",children:["Logging Documentation ",o.jsx(Cxe,{})]})})})},Hts=20,Wts=1e4;function Zts(e,t,n){if(e?.pagination?.hasMore)return n+1}function Gts(e){const t=new Set,n=[];for(const r of e.pages)for(const s of r.logs??[]){const a=s.logId??JSON.stringify(s);t.has(a)||(t.add(a),n.push(s))}return n}function Qts(e){return b1t(e.state.error,"logs")?!1:Wts}const Yts=({filters:e}={})=>{const t=We(),{inView:n,setRef:r}=__(),s=R1({queryKey:["logs",e],queryFn:({pageParam:p})=>t.listLogsVNext({pagination:{page:p,perPage:Hts},filters:e,orderBy:{field:"timestamp",direction:"DESC"}}),initialPageParam:0,getNextPageParam:Zts,select:Gts,retry:!1,refetchInterval:Qts}),{hasNextPage:a,isFetchingNextPage:i,fetchNextPage:l,data:c,isLoading:u,isError:d,error:f}=s;return v.useEffect(()=>{n&&a&&!i&&l()},[n,a,i,l]),{data:c,hasNextPage:a,isFetchingNextPage:i,fetchNextPage:l,isLoading:u,isError:d,error:f,setEndOfListElement:r}},Xts="Filters setting for Logs saved",Kts="Filters setting for Logs cleared up";function Jts(e,t,n){const{storageKey:r,messages:s,skipHydration:a}={},[i,l]=v.useState(()=>MGe(r)!==null),c=v.useCallback(()=>{RQr(e,r),l(!0);const f=s?.saved??Xts;f!==!1&&De.success(f)},[e,r,s?.saved]),u=v.useCallback(()=>{PQr(r),l(!1);const f=s?.cleared??Kts;f!==!1&&De.success(f)},[r,s?.cleared]),d=v.useRef(!1);return v.useEffect(()=>{if(a||d.current||(d.current=!0,$Qr(e)))return;const f=MGe(r);f&&t(p=>{const h=new URLSearchParams(p);for(const[m,g]of f)h.append(m,g);return h},{replace:!0})},[]),{hasSavedFilters:i,handleSave:c,handleRemoveSaved:u}}function ens(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return(t>>>0).toString(36)}function tns(e){const t=new Map;for(const n of e){if(n.logId){t.set(n,n.logId);continue}const r=n.timestamp instanceof Date?n.timestamp.toISOString():n.timestamp;t.set(n,ens(`${r}${n.message??""}${n.data?JSON.stringify(n.data):""}`))}return t}function nns(e,t,n,r){const s=v.useMemo(()=>tns(e),[e]),a=v.useMemo(()=>{const h=new Map;for(let m=0;m<e.length;m++){const g=s.get(e[m]);g&&h.set(g,{log:e[m],idx:m})}return h},[e,s]),l=(t?a.get(t):void 0)?.idx??-1,c=l>=0?e[l]:null,u=v.useCallback(h=>s.get(h),[s]),d=v.useCallback(h=>{const m=s.get(h);if(m){if(t===m){n({logId:null});return}n(r?{logId:m,traceId:h.traceId??null,spanId:null}:{logId:m})}},[s,t,r,n]),f=l>0?()=>{const h=e[l-1],m=s.get(h);n(r?{logId:m,traceId:h.traceId??null,spanId:null}:{logId:m})}:void 0,p=l>=0&&l<e.length-1?()=>{const h=e[l+1],m=s.get(h);n(r?{logId:m,traceId:h.traceId??null,spanId:null}:{logId:m})}:void 0;return{logIdMap:s,getLogId:u,featuredLog:c,handleLogClick:d,handlePreviousLog:f,handleNextLog:p}}const Ive="logId",Ave="traceId",Rve="spanId",IR=1440*60*1e3,rns={"last-24h":IR,"last-3d":3*IR,"last-7d":7*IR,"last-14d":14*IR,"last-30d":30*IR};function G8(e){e.delete(Ive),e.delete(Ave),e.delete(Rve)}function sns(e,t,n){const{onRemoveAll:r}={},s=v.useMemo(()=>{const _=e.get(zb);return _&&AQr.has(_)?_:"last-24h"},[e]),a=e.get(Bb),i=e.get(Ub),l=v.useMemo(()=>{if(s==="custom"){if(!a)return;const C=new Date(a);return Number.isNaN(C.getTime())?void 0:C}if(s==="all")return;const _=rns[s];return _?new Date(Date.now()-_):void 0},[s,a]),c=v.useMemo(()=>{if(s!=="custom"||!i)return;const _=new Date(i);return Number.isNaN(_.getTime())?void 0:_},[s,i]),u=v.useRef(s);u.current=s;const d=e.get(Ive),f=e.get(Ave),p=e.get(Rve),h=v.useMemo(()=>A6t.find(_=>_.entityType===e.get(Px)),[e]),m=v.useMemo(()=>DQr(e),[e]),g=v.useCallback(_=>{t(C=>{const E=new URLSearchParams(C);for(const[j,N]of Object.entries(_)){const I=j==="logId"?Ive:j==="traceId"?Ave:Rve;N?E.set(I,N):E.delete(I)}return E},{replace:!0})},[t]),y=v.useCallback(_=>{t(C=>{const E=new URLSearchParams(C);return FQr(E,_),G8(E),E},{replace:!0})},[t]),b=y,w=v.useCallback((_,C)=>{if(u.current!=="custom")return;const E=C==="from"?Bb:Ub;t(j=>{const N=new URLSearchParams(j);return _?N.set(E,_.toISOString()):N.delete(E),G8(N),N},{replace:!0})},[t]),S=v.useCallback(_=>{u.current=_,t(C=>{const E=new URLSearchParams(C);return _==="last-24h"?(E.delete(zb),E.delete(Bb),E.delete(Ub)):_==="custom"?E.set(zb,"custom"):(E.set(zb,_),E.delete(Bb),E.delete(Ub)),G8(E),E},{replace:!0})},[t]),k=v.useCallback(()=>{t(_=>{const C=new URLSearchParams(_);C.delete(Px);for(const E of U4)C.delete(kl[E]);return C.delete(zb),C.delete(Bb),C.delete(Ub),G8(C),C},{replace:!0}),r?.()},[t,r]);return v.useMemo(()=>({searchParams:e,setSearchParams:t,datePreset:s,selectedDateFrom:l,selectedDateTo:c,datePresetRef:u,featuredLogId:d,featuredTraceId:f,featuredSpanId:p,selectedEntityOption:h,filterTokens:m,handleFeaturedChange:g,handleFilterTokensChange:b,handleDateChange:w,handleDatePresetChange:S,handleRemoveAll:k,applyFilterTokens:y}),[e,t,s,l,c,u,d,f,p,h,m,g,b,w,S,k,y])}function ans(){const[e,t]=ji(),n=sns(e,t),r=Jts(e,t),[s,a]=v.useState(),[i,l]=v.useState(!1),{data:c=[],isPending:u}=lTe(),{data:d=[],isPending:f}=aTe({entityType:n.selectedEntityOption?.entityType,rootOnly:!0}),{data:p=[],isPending:h}=iTe(),{data:m=[],isPending:g}=oTe(),y=v.useMemo(()=>MQr({availableTags:c,availableRootEntityNames:d,availableServiceNames:m,availableEnvironments:p,loading:{tags:u,entityNames:f,serviceNames:g,environments:h}}),[c,d,m,p,u,f,g,h]),b=v.useMemo(()=>zQr({rootEntityType:n.selectedEntityOption?.entityType,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,tokens:n.filterTokens}),[n.filterTokens,n.selectedDateFrom,n.selectedDateTo,n.selectedEntityOption]),{data:w=[],isLoading:S,error:k,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:E}=Yts({filters:b}),{logIdMap:j,featuredLog:N,handleLogClick:I,handlePreviousLog:R,handleNextLog:$}=nns(w,n.featuredLogId,n.handleFeaturedChange,n.featuredTraceId),{data:F,isLoading:D}=HH(n.featuredTraceId??null),{data:V,isLoading:W}=aI(n.featuredTraceId??"",n.featuredSpanId??""),L=v.useCallback(()=>n.applyFilterTokens(BQr(y,n.filterTokens)),[y,n]),z=v.useCallback(()=>n.handleFeaturedChange({logId:null}),[n]),B=v.useCallback(X=>n.handleFeaturedChange({traceId:X,spanId:null}),[n]),M=v.useCallback((X,te)=>n.handleFeaturedChange({traceId:X,spanId:te}),[n]),G=v.useCallback(()=>{n.handleFeaturedChange({traceId:null,spanId:null}),l(!1)},[n]),U=v.useCallback(()=>n.handleFeaturedChange({spanId:null}),[n]),P=v.useCallback(X=>n.handleFeaturedChange({spanId:X??null}),[n]),q=o.jsxs(Lt.TopArea,{children:[o.jsx(Lt.Row,{children:o.jsxs(Lt.Column,{className:"flex flex-wrap items-start justify-start gap-2",children:[o.jsx(Jje,{preset:n.datePreset,onPresetChange:n.handleDatePresetChange,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,onDateChange:n.handleDateChange,disabled:S,presets:["last-24h","last-3d","last-7d","last-14d","last-30d","custom"]}),o.jsx(rTe,{fields:y,tokens:n.filterTokens,onTokensChange:n.handleFilterTokensChange,disabled:S,onStartTextFilter:a})]})}),o.jsx(zts,{isLoading:S,filterFields:y,filterTokens:n.filterTokens,onFilterTokensChange:n.handleFilterTokensChange,onClear:L,onRemoveAll:n.handleRemoveAll,onSave:r.handleSave,onRemoveSaved:r.hasSavedFilters?r.handleRemoveSaved:void 0,autoFocusFilterFieldId:s})]});if(k)return o.jsxs(Lt,{width:"wide",height:"full",children:[q,o.jsx(Lt.MainArea,{isCentered:!0,children:o.jsx(Tts,{error:k,resource:"logs",errorTitle:"Failed to load logs"})})]});const Z=!!n.selectedEntityOption||n.filterTokens.length>0;return w.length===0&&!S&&!Z?o.jsxs(Lt,{width:"wide",height:"full",children:[q,o.jsx(Lt.MainArea,{isCentered:!0,children:o.jsx(Vts,{datePreset:n.datePreset,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo})})]}):o.jsxs(Lt,{width:"wide",height:"full",children:[q,o.jsx(Nts,{logCollapsed:i,listSlot:o.jsx(Fts,{logs:w,isLoading:S,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:E,logIdMap:j,featuredLogId:n.featuredLogId,onLogClick:I}),logPanelSlot:N?o.jsx(tYr,{log:N,onClose:z,onTraceClick:B,onSpanClick:M,onPrevious:R,onNext:$,collapsed:i,onCollapsedChange:l}):null,tracePanelSlot:n.featuredTraceId?o.jsx(QEt,{traceId:n.featuredTraceId,spans:F?.spans,isLoading:D,onClose:G,onSpanSelect:P,selectedSpanId:n.featuredSpanId}):null,spanPanelSlot:n.featuredTraceId&&n.featuredSpanId?o.jsx(UQr,{spanId:n.featuredSpanId,span:V?.span,isLoading:W,onClose:U}):null})]})}function ins({server:e}){const{paths:t,Link:n}=yn(),s=We().options.baseUrl,a=s?`${s}/api/mcp/${e.id}/sse`:"",{data:i}=Q4t(e),l=Object.values(i||{}),c=l.length,u=l.filter(p=>p.toolType==="agent").length,d=l.filter(p=>p.toolType==="workflow").length,f=dm(e.name,50);return o.jsxs(me.RowLink,{to:t.mcpServerLink(e.id),LinkComponent:n,children:[o.jsx(me.NameCell,{children:f}),o.jsx(me.DescriptionCell,{children:a}),o.jsx(me.TextCell,{className:"text-center",children:u||""}),o.jsx(me.TextCell,{className:"text-center",children:c||""}),o.jsx(me.TextCell,{className:"text-center",children:d||""})]})}function ons({mcpServers:e,isLoading:t,search:n=""}){const r=v.useMemo(()=>{const s=n.toLowerCase();return e.filter(a=>a.name?.toLowerCase().includes(s)||a.id?.toLowerCase().includes(s))},[e,n]);return t?o.jsx(el,{columns:"auto 1fr auto auto auto"}):o.jsxs(me,{columns:"auto 1fr auto auto auto",variant:"striped",children:[o.jsxs(me.Top,{children:[o.jsx(me.TopCell,{children:"Name"}),o.jsx(me.TopCell,{children:"URL"}),o.jsx(me.TopCellSmart,{long:"Agents",short:o.jsx(rl,{}),tooltip:"Agent Tools",className:"text-center"}),o.jsx(me.TopCellSmart,{long:"Tools",short:o.jsx(Gp,{}),tooltip:"Tools",className:"text-center"}),o.jsx(me.TopCellSmart,{long:"Workflows",short:o.jsx(kd,{}),tooltip:"Workflow Tools",className:"text-center"})]}),r.length===0&&n?o.jsx(me.NoMatch,{message:"No MCP Servers match your search"}):null,r.map(s=>o.jsx(ins,{server:s},s.id))]})}const lns=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Lr,{iconSlot:o.jsx(xf,{}),titleSlot:"No MCP Servers yet",descriptionSlot:o.jsxs(o.Fragment,{children:["MCP servers are not configured yet. ",o.jsx("br",{}),"More information in the documentation."]}),actionSlot:o.jsxs(ue,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/tools-mcp/mcp-overview",target:"_blank",rel:"noopener noreferrer",children:["MCP Documentation ",o.jsx(Pa,{})]})})}),cns=()=>{const{data:e=[],isLoading:t,error:n}=vZ(),[r,s]=v.useState("");return n&&gs(n)?o.jsx(lr,{children:o.jsx(Vs,{})}):n&&ys(n)?o.jsx(lr,{children:o.jsx(Ds,{resource:"MCP servers"})}):n?o.jsx(lr,{children:o.jsx(Fi,{title:"Failed to load MCP servers",message:n.message})}):e.length===0&&!t?o.jsx(lr,{children:o.jsx(lns,{})}):o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx("div",{className:"max-w-120",children:o.jsx(Of,{onSearch:s,label:"Filter MCP servers",placeholder:"Filter by name"})})}),o.jsx(ons,{mcpServers:e,isLoading:t,search:r})]})},uns=(e,t)=>{const n=new Map,r=Object.keys(t);for(const s of r){const a=t[s],i=a.tools,l=Object.keys(i);for(const c of l){const u=i[c];n.has(u.id)||n.set(u.id,{...u,agents:[]}),n.get(u.id).agents.push({...a,id:s})}}for(const[s,a]of Object.entries(e))n.has(a.id)||n.set(a.id,{...a,agents:[]});return Array.from(n.values())};function dns({tools:e,agents:t,isLoading:n,search:r=""}){const{paths:s,Link:a}=yn(),i=v.useMemo(()=>uns(e,t),[e,t]),l=v.useMemo(()=>i.filter(c=>c.id.toLowerCase().includes(r.toLowerCase())),[i,r]);return n?o.jsx(el,{columns:"auto 1fr auto"}):o.jsxs(me,{columns:"auto 1fr auto",variant:"striped",children:[o.jsxs(me.Top,{children:[o.jsx(me.TopCell,{children:"Name"}),o.jsx(me.TopCell,{children:"Description"}),o.jsx(me.TopCellSmart,{long:"Agents",short:o.jsx(rl,{}),tooltip:"Attached Agents",className:"text-center"})]}),l.length===0&&r?o.jsx(me.NoMatch,{message:"No Tools match your search"}):null,l.map(c=>{const u=dm(c.id,50),d=dm(c.description??"",200),f=c.agents.length;return o.jsxs(me.RowLink,{to:s.toolLink(c.id),LinkComponent:a,children:[o.jsx(me.NameCell,{children:u}),o.jsx(me.DescriptionCell,{children:d}),o.jsx(me.TextCell,{className:"text-center",children:f||""})]},c.id)})]})}const fns=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Lr,{iconSlot:o.jsx(xf,{}),titleSlot:"No Tools yet",descriptionSlot:o.jsxs(o.Fragment,{children:["Mastra tools are not configured yet. ",o.jsx("br",{}),"More information in the documentation."]}),actionSlot:o.jsxs(ue,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/agents/using-tools-and-mcp",target:"_blank",rel:"noopener noreferrer",children:["Tools Documentation ",o.jsx(Pa,{})]})})}),pns=()=>{const e=We();return Rn({mutationFn:async({toolId:t,input:n,requestContext:r})=>{const s=new r_;Object.entries(r??{}).forEach(([a,i])=>{s.set(a,i)});try{return await e.getTool(t).execute({data:n,requestContext:s})}catch(a){throw De.error("Error executing dev tool"),console.error("Error executing dev tool:",a),a}}})},hns=({toolId:e})=>{const{canExecute:t}=al(),n=t("tools"),{data:r={}}=Sm(),s=v.useMemo(()=>{for(const g of Object.values(r))if(g.tools){const y=Object.values(g.tools).find(b=>b.id===e);if(y)return y}return null},[r,e]),{data:a,isLoading:i,error:l}=G0r(e,{enabled:!s}),c=s||a,{mutateAsync:u,isPending:d,data:f}=pns(),{requestContext:p}=_s();v.useEffect(()=>{if(l){const g=l instanceof Error?l.message:"Failed to load tool";De.error(`Error loading tool: ${g}`)}},[l]);const h=async(g,y)=>{if(!c)return;const b={...p??{},...y??{}};return u({toolId:c.id,input:g,requestContext:b})},m=c?.inputSchema?im(sm(mx(c?.inputSchema))):Ss({});return i?o.jsxs("div",{className:"p-6",children:[o.jsx(At,{className:"h-8 w-48 mb-4"}),o.jsx(At,{className:"h-32 w-full"})]}):l?null:c?n?o.jsx(Mje,{executionResult:f,isExecutingTool:d,zodInputSchema:m,handleExecuteTool:h,toolDescription:c.description,toolId:c.id,requestContextSchema:c.requestContextSchema}):o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"ui-sm",className:"text-neutral3",children:"You don't have permission to execute tools."})}):o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"header-md",className:"text-neutral3",children:"Tool not found"})})};function mns({value:e,onValueChange:t,placeholder:n="Select a tool...",searchPlaceholder:r="Search tools...",emptyText:s="No tools found.",className:a,disabled:i=!1,variant:l}){const{data:c={},isLoading:u,isError:d,error:f}=oI(),{data:p={},isLoading:h,isError:m,error:g}=Sm(),{navigate:y,paths:b}=yn();v.useEffect(()=>{if(d){const _=f instanceof Error?f.message:"Failed to load tools";De.error(`Error loading tools: ${_}`)}},[d,f]),v.useEffect(()=>{if(m){const _=g instanceof Error?g.message:"Failed to load agents";De.error(`Error loading agents: ${_}`)}},[m,g]);const w=new Map;Object.values(p).forEach(_=>{_.tools&&Object.values(_.tools).forEach(C=>{w.has(C.id)||w.set(C.id,C)})}),Object.values(c).forEach(_=>{w.has(_.id)||w.set(_.id,_)});const S=Array.from(w.values()).map(_=>({label:_.id,value:_.id})),k=_=>{t?t(_):_&&_!==e&&y(b.toolLink(_))};return o.jsx(Xl,{options:S,value:e,onValueChange:k,placeholder:u||h?"Loading tools...":n,searchPlaceholder:r,emptyText:s,className:a,disabled:i||u||h||d||m,variant:l})}const gns=({isLoading:e,server:t})=>{const[{sseUrl:n,httpStreamUrl:r},s]=v.useState({sseUrl:"",httpStreamUrl:""});if(v.useEffect(()=>{if(!t)return;const i=window.MASTRA_SERVER_HOST,l=window.MASTRA_SERVER_PORT;let c=null;i&&l&&(c=`http://${i}:${l}`);const u=c||"http://localhost:4111",d=`${u}/api/mcp/${t.id}/sse`,f=`${u}/api/mcp/${t.id}/mcp`;s({sseUrl:d,httpStreamUrl:f})},[t]),e)return null;if(!t)return o.jsx(xy,{children:o.jsx(ge,{as:"h1",variant:"header-md",className:"text-neutral3 font-medium py-20 text-center",children:"Server not found"})});const a=`npx -y mcp-remote ${n}`;return o.jsxs(xy,{isDivided:!0,children:[o.jsxs("div",{className:"px-8 py-12 mx-auto max-w-2xl w-full",children:[o.jsx(ge,{as:"h1",variant:"header-md",className:"text-neutral6 font-medium pb-4",children:t.name}),o.jsxs("div",{className:"flex items-center gap-1 pb-6",children:[o.jsx(fn,{icon:o.jsx(FEt,{className:"text-neutral6"}),className:"rounded-r-sm text-neutral4!",children:"Version"}),o.jsx(fn,{className:"rounded-l-sm text-neutral4!",children:t.version_detail.version})]}),o.jsx(ge,{className:"text-neutral3 pb-4",children:"This MCP server can be accessed through multiple transport methods. Choose the one that best fits your use case."}),o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(fn,{icon:o.jsx("span",{className:"font-mono w-6 text-accent1 font-medium mr-1",children:"HTTP"}),children:"Regular HTTP Endpoint"}),o.jsx(ge,{className:"text-neutral3 pt-1 pb-2",children:"Use for stateless HTTP transport with streamable responses."}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(ge,{className:"px-2 py-1 bg-surface4 rounded-lg",children:r}),o.jsx("div",{className:"pt-1",children:o.jsx(ya,{tooltip:"Copy HTTP Stream URL",content:r})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(fn,{icon:o.jsx("span",{className:"font-mono w-6 text-accent1 font-medium mr-1",children:"SSE"}),children:"Server-Sent Events"}),o.jsx(ge,{className:"text-neutral3 pt-1 pb-2",children:"Use for real-time communication via SSE."}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(ge,{className:"px-2 py-1 bg-surface4 rounded-lg",children:n}),o.jsx("div",{className:"pt-1",children:o.jsx(ya,{tooltip:"Copy SSE URL",content:n})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(fn,{icon:o.jsx("span",{className:"font-mono w-6 text-accent1 font-medium mr-1",children:"CLI"}),children:"Command Line"}),o.jsx(ge,{className:"text-neutral3 pt-1 pb-2",children:"Use for local command-line access via npx and mcp-remote."}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(ge,{className:"px-2 py-1 bg-surface4 rounded-lg",children:a}),o.jsx("div",{className:"pt-1",children:o.jsx(ya,{tooltip:"Copy Command Line Config",content:a})})]})]})]})]}),o.jsx("div",{className:"h-full overflow-y-scroll border-l border-border1",children:o.jsx(vns,{server:t})})]})},vns=({server:e})=>{const{data:t={},isLoading:n}=Q4t(e);if(n)return null;const r=Object.keys(t);return o.jsxs("div",{className:"p-5 overflow-y-scroll",children:[o.jsxs("div",{className:"text-neutral6 flex gap-2 items-center",children:[o.jsx(Ue,{size:"lg",className:"bg-surface4 rounded-md p-1",children:o.jsx(M_,{})}),o.jsx(ge,{variant:"header-md",as:"h2",className:"font-medium",children:"Available Tools"})]}),o.jsx("div",{className:"flex flex-col gap-2 pt-6",children:r.map(s=>{const a=t[s];return o.jsx(bns,{tool:a,serverId:e.id},s)})})]})};function yns(e){if(!e)return!1;const t=e.ui;return!!(typeof t?.resourceUri=="string"&&t.resourceUri.startsWith("ui://")||typeof e["ui/resourceUri"]=="string"&&e["ui/resourceUri"].startsWith("ui://"))}const bns=({tool:e,serverId:t})=>{const n=v.useRef(null),{Link:r,paths:s}=yn(),a=ILt[e.toolType||"tool"],i=yns(e._meta);return o.jsxs(Cf,{onClick:()=>n.current?.click(),children:[o.jsx(sAt,{children:o.jsx(a,{className:"group-hover/entity:text-accent6"})}),o.jsxs(jf,{children:[o.jsx(Ef,{children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx(r,{ref:n,href:s.mcpServerToolLink(t,e.id),children:e.id}),i&&o.jsx(fn,{className:"text-[10px] py-0",children:"App"})]})}),o.jsx(Qp,{children:e.description})]})]})},xns=()=>{const{serverId:e}=dr(),{data:t=[],isLoading:n}=vZ(),r=t.find(s=>s.id===e);return o.jsx("div",{className:"h-full w-full overflow-hidden",children:o.jsx(gns,{isLoading:n,server:r})})};function wns(e){if(!e)return;const t=e.ui;if(t?.resourceUri)return t.resourceUri;const n=e["ui/resourceUri"];if(typeof n=="string")return n}const Sns=({toolId:e,serverId:t})=>{const{canExecute:n}=al(),r=n("tools"),s=We(),{data:a,isLoading:i,error:l}=eje(t,e),{mutateAsync:c,isPending:u,data:d}=GFr(t,e),f=a?wns(a._meta):void 0,{data:p}=wt({queryKey:["mcp-app-resource",t,f],queryFn:async()=>f?(await s.readMcpServerResource(t,f)).contents[0]?.text??null:null,enabled:!!f}),h=v.useCallback(async(y,b)=>await c(b),[c]);v.useEffect(()=>{if(l){const y=l instanceof Error?l.message:"Failed to load tool";De.error(`Error loading tool: ${y}`)}},[l]);const m=async y=>{if(a)return await c(y)};if(i)return o.jsxs("div",{className:"p-6",children:[o.jsx(At,{className:"h-8 w-48 mb-4"}),o.jsx(At,{className:"h-32 w-full"})]});if(l)return null;if(!a)return o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"header-md",className:"text-neutral3",children:"Tool not found"})});if(!r)return o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"ui-sm",className:"text-neutral3",children:"You don't have permission to execute tools."})});let g;try{g=im(sm(a.inputSchema))}catch(y){console.error("Error processing input schema:",y),De.error("Failed to process tool input schema."),g=Ss({})}return o.jsxs("div",{className:"flex flex-col gap-4",children:[p&&o.jsx("div",{className:"border-b border-border1 p-4",children:o.jsx(G4t,{html:p,toolName:a.name??a.id,onToolCall:h})}),o.jsx(Mje,{executionResult:d,isExecutingTool:u,zodInputSchema:g,handleExecuteTool:m,toolDescription:a.description||"",toolId:a.id})]})},kns=()=>{const{serverId:e,toolId:t}=dr(),{data:n,isLoading:r}=eje(e,t);return r||!n?null:o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(Sns,{toolId:t,serverId:e})})},Ons=["last-24h","last-3d","last-7d","last-14d","last-30d","custom"];function _ns(e){switch(e){case"3d":return"last-3d";case"7d":return"last-7d";case"14d":return"last-14d";case"30d":return"last-30d";case"custom":return"custom";default:return"last-24h"}}function Cns(e){switch(e){case"last-3d":return"3d";case"last-7d":return"7d";case"last-14d":return"14d";case"last-30d":return"30d";case"custom":return"custom";default:return"24h"}}function Ens(){const{datePreset:e,setDatePreset:t,customRange:n,setCustomRange:r}=DZ(),s=v.useRef(e);s.current=e;const a=v.useRef(n);return a.current=n,o.jsx(Jje,{preset:_ns(e),onPresetChange:i=>{const l=Cns(i);s.current=l,t(l)},dateFrom:n?.from,dateTo:n?.to,onDateChange:(i,l)=>{if(s.current!=="custom")return;const c={...a.current,[l]:i};a.current=c,r(c)},presets:Ons})}const Ure={"24h":1440*60*1e3,"3d":4320*60*1e3,"7d":10080*60*1e3,"14d":336*60*60*1e3,"30d":720*60*60*1e3};function jns(e,t,n){if(e!=="custom"){const r=Ure[e]??Ure["24h"];return{start:new Date(n-r),end:new Date(n)}}return{start:t?.from??new Date(n-Ure["24h"]),end:t?.to??new Date(n)}}function Cm(){const{datePreset:e,customRange:t,dimensionalFilter:n,dimensionalFilterKey:r}=DZ(),s=v.useRef(null),a=e==="custom"?`custom:${t?.from?.getTime()??""}:${t?.to?.getTime()??""}`:`preset:${e}`;(!s.current||s.current.key!==a)&&(s.current={key:a,anchor:Date.now()});const i=s.current.anchor,l=v.useMemo(()=>jns(e,t,i),[e,t,i]),c=v.useMemo(()=>({timestamp:l,...n}),[l,r]),u=v.useMemo(()=>`${a}|${r}`,[a,r]);return{datePreset:e,customRange:t,timestamp:l,filters:c,dimensionalFilter:n,filterKey:u}}function f8t(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","agent-runs-kpi",n],queryFn:()=>e.getMetricAggregate({name:["mastra_agent_duration_ms"],aggregation:"count",filters:t,comparePeriod:"previous_period"})})}function q4({href:e,LinkComponent:t="a"}){return o.jsx(ue,{as:t,href:e,variant:"ghost",size:"icon-md",tooltip:"View in Traces","aria-label":"View in Traces",children:o.jsx(wkn,{})})}function Tns({href:e,LinkComponent:t="a"}){return o.jsx(ue,{as:t,href:e,variant:"ghost",size:"icon-md",tooltip:"View errors in Logs","aria-label":"View errors in Logs",children:o.jsx(rOn,{})})}function Nns(e){switch(e){case"24h":return"last-24h";case"3d":return"last-3d";case"7d":return"last-7d";case"14d":return"last-14d";case"30d":return"last-30d";case"custom":return"custom";default:return}}function Ins(e,t){if(t==="1h"){const s=new Date(e);s.setUTCMinutes(0,0,0);const a=new Date(s.getTime()+3600*1e3);return{from:s,to:a}}const n=new Date(e);n.setUTCHours(0,0,0,0);const r=new Date(n.getTime()+1440*60*1e3);return{from:n,to:r}}function p8t(e,t,n,r,s,a,i){if(i){e.set(t,"custom"),e.set(n,i.from.toISOString()),e.set(r,i.to.toISOString());return}if(s==="custom"){e.set(t,"custom"),a?.from&&e.set(n,a.from.toISOString()),a?.to&&e.set(r,a.to.toISOString());return}const l=Nns(s);l&&e.set(t,l)}function jo(e,t,n){typeof n=="string"&&n.length>0&&e.set(t,n)}function h8t(e,t,n){if(!(!Array.isArray(n)||n.length===0))for(const r of n)r&&e.append(t,r)}function kQe({preset:e,customRange:t,dashboardFilter:n,scope:r,tracesBasePath:s="/observability"}){const a=new URLSearchParams;a.set(gw,"branches"),p8t(a,vw,yw,bw,e,t,r.window);const i=r.rootEntityType??n.rootEntityType;i&&a.set(_x,i),r.status&&a.set(Cx,r.status),jo(a,Sl.entityName,r.entityName??n.entityName),jo(a,Sl.threadId,r.threadId??n.threadId),jo(a,Sl.resourceId,r.resourceId??n.resourceId),jo(a,Sl.entityId,n.entityId),jo(a,Sl.runId,n.runId),jo(a,Sl.sessionId,n.sessionId),jo(a,Sl.requestId,n.requestId),jo(a,Sl.userId,n.userId),jo(a,Sl.organizationId,n.organizationId),jo(a,Sl.experimentId,n.experimentId),jo(a,Sl.serviceName,n.serviceName),jo(a,Sl.environment,n.environment),h8t(a,Sl.tags,n.tags);const l=a.toString();return l?`${s}?${l}`:s}function Ans({preset:e,customRange:t,dashboardFilter:n,scope:r,logsBasePath:s="/logs"}){const a=new URLSearchParams;p8t(a,zb,Bb,Ub,e,t,r.window);const i=r.rootEntityType??n.rootEntityType;i&&a.set(Px,i),jo(a,kl.entityName,r.entityName??n.entityName),jo(a,kl.threadId,r.threadId??n.threadId),jo(a,kl.resourceId,r.resourceId??n.resourceId),jo(a,kl.runId,n.runId),jo(a,kl.sessionId,n.sessionId),jo(a,kl.requestId,n.requestId),jo(a,kl.userId,n.userId),jo(a,kl.organizationId,n.organizationId),jo(a,kl.experimentId,n.experimentId),jo(a,kl.serviceName,n.serviceName),jo(a,kl.environment,n.environment),h8t(a,kl.tags,n.tags),r.status==="error"&&a.append(kl.level,"error");const l=a.toString();return l?`${s}?${l}`:s}function wI(){const{datePreset:e,customRange:t,dimensionalFilter:n,tracesBasePath:r,logsBasePath:s}=DZ(),a=v.useCallback((c={})=>kQe({preset:e,customRange:t,dashboardFilter:n,scope:c,tracesBasePath:r}),[e,t,n,r]),i=v.useCallback((c={})=>Ans({preset:e,customRange:t,dashboardFilter:n,scope:c,logsBasePath:s}),[e,t,n,s]),l=v.useCallback((c,u,d)=>{const f=Ins(u,d);return kQe({preset:e,customRange:t,dashboardFilter:n,scope:{...c,window:f},tracesBasePath:r})},[e,t,n,r]);return{getTracesHref:a,getLogsHref:i,getBucketTracesHref:l}}const m8t="1h";async function qre(e,t,n){const r=await e.getMetricPercentiles({name:t,percentiles:[.5,.95],interval:m8t,filters:n}),s=r.series.find(l=>l.percentile===.5),a=r.series.find(l=>l.percentile===.95);if(!s||!a)return[];const i=new Map(a.points.map(l=>[new Date(l.timestamp).getTime(),l.value]));return s.points.map(l=>{const c=new Date(l.timestamp),u=c.getTime();return{time:c.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}),tsMs:u,p50:Math.round(l.value),p95:Math.round(i.get(u)??0)}})}function Rns(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","latency",n],queryFn:async()=>{const[r,s,a]=await Promise.all([qre(e,"mastra_agent_duration_ms",t),qre(e,"mastra_workflow_duration_ms",t),qre(e,"mastra_tool_duration_ms",t)]);return{agentData:r,workflowData:s,toolData:a,interval:m8t}}})}const OQe={agents:Os.AGENT,workflows:Os.WORKFLOW_RUN,tools:Os.TOOL};function Pns(){const{data:e,isLoading:t,isError:n}=Rns(),{getTracesHref:r,getBucketTracesHref:s}=wI(),{Link:a}=yn(),i=bs();return o.jsx(EQr,{data:e,isLoading:t,isError:n,onPointClick:(l,c)=>{Number.isFinite(c.tsMs)&&i(s({rootEntityType:OQe[l]},c.tsMs,"1h"))},actions:l=>o.jsx(q4,{href:r({rootEntityType:OQe[l]}),LinkComponent:a})})}function $ns(e){return e==="threads"||e==="resources"}function Vre(e){return e.length<=12?e:`${e.slice(0,6)}…${e.slice(-4)}`}function Mns({threads:e,resources:t,getThreadRowHref:n,getResourceRowHref:r,actions:s,LinkComponent:a}){const[i,l]=v.useState("threads"),c=e.data?.map(y=>({...y,key:y.threadId}))??[],u=t.data?.map(y=>({...y,key:y.resourceId}))??[],d=c.length>0,f=u.length>0,p=e.data?.reduce((y,b)=>y+b.runs,0)??0,h=t.data?.reduce((y,b)=>y+b.threadCount,0)??0,m=i==="threads"?e:t,g=typeof s=="function"?s(i):s;return o.jsxs(Bt,{children:[o.jsxs(Bt.TopBar,{children:[o.jsx(Bt.TitleAndDescription,{title:"Memory",description:"Resource and Thread consumption"}),i==="threads"&&d&&o.jsx(Bt.Summary,{value:p.toLocaleString(),label:"Total runs"}),i==="resources"&&f&&o.jsx(Bt.Summary,{value:h.toLocaleString(),label:"Total threads"}),g?o.jsx(Bt.Actions,{children:g}):null]}),m.isLoading?o.jsx(Bt.Loading,{}):m.isError?o.jsx(Bt.Error,{message:"Failed to load memory data"}):o.jsx(Bt.Content,{children:o.jsxs(ru,{defaultTab:"threads",value:i,onValueChange:y=>{$ns(y)&&l(y)},className:"grid grid-rows-[auto_1fr] overflow-y-auto h-full",children:[o.jsxs(su,{children:[o.jsx(Vr,{value:"threads",children:"Threads"}),o.jsx(Vr,{value:"resources",children:"Resources"})]}),o.jsx(ps,{value:"threads",children:d?o.jsxs(me,{columns:"auto auto auto auto auto",...kve,children:[o.jsxs(me.Top,{children:[o.jsx(me.TopCell,{sticky:"start",children:"Thread ID"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Resource ID"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Runs"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Tokens"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Cost"})]}),c.map(y=>{const b=n?.(y),w=o.jsxs(o.Fragment,{children:[o.jsx(me.RowHeaderCell,{height:"compact",className:"text-ui-sm",children:Vre(y.threadId)}),o.jsx(me.NumberCell,{children:y.resourceId?Vre(y.resourceId):"—"}),o.jsx(me.NumberCell,{highlight:!0,children:y.runs.toLocaleString()}),o.jsx(me.NumberCell,{children:y.tokens>0?yc(y.tokens):"—"}),o.jsx(me.NumberCell,{children:y.cost!=null?vg(y.cost,y.costUnit):"—"})]});return b?o.jsx(me.RowLink,{to:b,LinkComponent:a,children:w},y.key):o.jsx(me.RowStatic,{children:w},y.key)})]}):o.jsx(Bt.NoData,{message:"No thread activity yet"})}),o.jsx(ps,{value:"resources",children:f?o.jsxs(me,{columns:"auto auto auto auto",...kve,children:[o.jsxs(me.Top,{children:[o.jsx(me.TopCell,{sticky:"start",children:"Resource ID"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Threads"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Tokens"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Cost"})]}),u.map(y=>{const b=r?.(y),w=o.jsxs(o.Fragment,{children:[o.jsx(me.RowHeaderCell,{height:"compact",className:"text-ui-sm",children:Vre(y.resourceId)}),o.jsx(me.NumberCell,{highlight:!0,children:y.threadCount.toLocaleString()}),o.jsx(me.NumberCell,{children:y.tokens>0?yc(y.tokens):"—"}),o.jsx(me.NumberCell,{children:y.cost!=null?vg(y.cost,y.costUnit):"—"})]});return b?o.jsx(me.RowLink,{to:b,LinkComponent:a,children:w},y.key):o.jsx(me.RowStatic,{children:w},y.key)})]}):o.jsx(Bt.NoData,{message:"No resource activity yet"})})]})})]})}const Hre=20;function Dns(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","top-active-threads",n],queryFn:async()=>{const r={groupBy:["threadId","resourceId"],orderDirection:"DESC",filters:t},[s,a,i]=await Promise.all([e.getMetricBreakdown({...r,name:["mastra_agent_duration_ms"],aggregation:"count",limit:Hre}),e.getMetricBreakdown({...r,name:["mastra_model_total_input_tokens"],aggregation:"sum",limit:Hre}),e.getMetricBreakdown({...r,name:["mastra_model_total_output_tokens"],aggregation:"sum",limit:Hre})]),l=new Map,c=d=>(l.has(d)||l.set(d,{tokens:0,cost:null,costUnit:null}),l.get(d)),u=d=>{for(const f of d){const p=f.dimensions.threadId;if(!p)continue;const h=c(p);h.tokens+=f.value,f.estimatedCost!=null&&(h.cost=(h.cost??0)+f.estimatedCost,f.costUnit&&(h.costUnit=f.costUnit))}};return u(a.groups),u(i.groups),s.groups.filter(d=>!!d.dimensions.threadId).map(d=>{const f=d.dimensions.threadId,p=l.get(f);return{threadId:f,resourceId:d.dimensions.resourceId??null,runs:d.value,tokens:p?.tokens??0,cost:p?.cost??null,costUnit:p?.costUnit??null}})}})}const Wre=20;function Lns(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","top-resources-by-threads",n],queryFn:async()=>{const r={groupBy:["resourceId"],orderDirection:"DESC",filters:t},[s,a,i]=await Promise.all([e.getMetricBreakdown({...r,name:["mastra_agent_duration_ms"],aggregation:"count_distinct",distinctColumn:"threadId",limit:Wre}),e.getMetricBreakdown({...r,name:["mastra_model_total_input_tokens"],aggregation:"sum",limit:Wre}),e.getMetricBreakdown({...r,name:["mastra_model_total_output_tokens"],aggregation:"sum",limit:Wre})]),l=new Map,c=d=>(l.has(d)||l.set(d,{tokens:0,cost:null,costUnit:null}),l.get(d)),u=d=>{for(const f of d){const p=f.dimensions.resourceId;if(!p)continue;const h=c(p);h.tokens+=f.value,f.estimatedCost!=null&&(h.cost=(h.cost??0)+f.estimatedCost,f.costUnit&&(h.costUnit=f.costUnit))}};return u(a.groups),u(i.groups),s.groups.filter(d=>!!d.dimensions.resourceId).map(d=>{const f=d.dimensions.resourceId,p=l.get(f);return{resourceId:f,threadCount:d.value,tokens:p?.tokens??0,cost:p?.cost??null,costUnit:p?.costUnit??null}})}})}function Fns(){const e=Dns(),t=Lns(),{getTracesHref:n}=wI(),{Link:r}=yn();return o.jsx(Mns,{threads:{data:e.data,isLoading:e.isLoading,isError:e.isError},resources:{data:t.data,isLoading:t.isLoading,isError:t.isError},LinkComponent:r,getThreadRowHref:s=>n({threadId:s.threadId,...s.resourceId?{resourceId:s.resourceId}:{}}),getResourceRowHref:s=>n({resourceId:s.resourceId})})}function V4({label:e,value:t,prevValue:n,changePct:r,isLoading:s,isError:a}){const i=t!=null;return o.jsxs(Kr,{children:[o.jsx(Kr.Label,{children:e}),o.jsx(Kr.Value,{className:i?void 0:"invisible",children:i?t:"—"}),a?o.jsx(Kr.Error,{}):s?o.jsx(Kr.Loading,{}):i?r!=null?o.jsx(Kr.Change,{changePct:r,prevValue:n}):o.jsx(Kr.NoChange,{}):o.jsx(Kr.NoData,{})]})}function zns(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","active-resources-kpi",n],queryFn:()=>e.getMetricAggregate({name:["mastra_agent_duration_ms"],aggregation:"count_distinct",distinctColumn:"resourceId",filters:t,comparePeriod:"previous_period"})})}function Bns(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","active-threads-kpi",n],queryFn:()=>e.getMetricAggregate({name:["mastra_agent_duration_ms"],aggregation:"count_distinct",distinctColumn:"threadId",filters:t,comparePeriod:"previous_period"})})}function Uns(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","model-cost-kpi",n],queryFn:async()=>{const r=await e.getMetricAggregate({name:["mastra_model_total_input_tokens","mastra_model_total_output_tokens"],aggregation:"sum",filters:t,comparePeriod:"previous_period"});return{cost:r.estimatedCost??null,costUnit:r.costUnit??null,previousCost:r.previousEstimatedCost??null,costChangePercent:r.costChangePercent??null}}})}function qns(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","total-tokens-kpi",n],queryFn:async()=>{const[r,s]=await Promise.all([e.getMetricAggregate({name:["mastra_model_total_input_tokens"],aggregation:"sum",filters:t,comparePeriod:"previous_period"}),e.getMetricAggregate({name:["mastra_model_total_output_tokens"],aggregation:"sum",filters:t,comparePeriod:"previous_period"})]),a=r.value!=null||s.value!=null,i=r.previousValue!=null||s.previousValue!=null,l=(r.value??0)+(s.value??0),c=(r.previousValue??0)+(s.previousValue??0),u=i&&c>0?(l-c)/c*100:null;return{value:a?l:null,previousValue:i?c:null,changePercent:u}}})}function Vns(){const{data:e,isLoading:t,isError:n}=f8t();return o.jsx(V4,{label:"Total Agent Runs",value:e?.value!=null?e.value.toLocaleString():null,prevValue:e?.previousValue!=null?e.previousValue.toLocaleString():void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function Hns(){const{data:e,isLoading:t,isError:n}=Uns();return o.jsx(V4,{label:"Total Model Cost",value:e?.cost!=null?vg(e.cost,e.costUnit):null,prevValue:e?.previousCost!=null?vg(e.previousCost,e.costUnit):void 0,changePct:e?.costChangePercent??null,isLoading:t,isError:n})}function Wns(){const{data:e,isLoading:t,isError:n}=qns();return o.jsx(V4,{label:"Total Tokens",value:e?.value!=null?yc(e.value):null,prevValue:e?.previousValue!=null?yc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function Zns(){const{data:e,isLoading:t,isError:n}=Bns();return o.jsx(V4,{label:"Total Threads",value:e?.value!=null?yc(e.value):null,prevValue:e?.previousValue!=null?yc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function Gns(){const{data:e,isLoading:t,isError:n}=zns();return o.jsx(V4,{label:"Total Resources",value:e?.value!=null?yc(e.value):null,prevValue:e?.previousValue!=null?yc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function Qns({onClear:e,onRemoveAll:t,onSave:n,onRemoveSaved:r,isLoading:s,filterFields:a,filterTokens:i,onFilterTokensChange:l,autoFocusFilterFieldId:c}){const u=i.length>0,d=i.some(f=>Yns(f,a));return o.jsxs("div",{className:K("grid grid-cols-[1fr_auto] gap-3 items-start"),children:[o.jsx(nTe,{fields:a,tokens:i,onTokensChange:l,disabled:s,autoFocusFieldId:c}),u&&o.jsx(eTe,{disabled:s,onClear:d?e:void 0,onRemoveAll:t,onSave:n,onRemoveSaved:r})]})}function Yns(e,t){const n=t.find(r=>r.id===e.fieldId);return n?n.kind==="text"?typeof e.value=="string"&&e.value.trim()!=="":n.kind==="pick-multi"?n.multi?Array.isArray(e.value)&&e.value.length>0:typeof e.value=="string"&&e.value!==""&&e.value!=="Any":n.kind==="multi-select"?Array.isArray(e.value)&&e.value.length>0:!1:!1}function Xns({rows:e,isLoading:t,isError:n,getRowHref:r,actions:s,LinkComponent:a}){const i=!!e&&e.length>0;return o.jsxs(Bt,{children:[o.jsxs(Bt.TopBar,{children:[o.jsx(Bt.TitleAndDescription,{title:"Model Usage & Cost",description:"Token consumption by model."}),i&&(()=>{const l=e.reduce((d,f)=>d+(f.cost??0),0),c=new Set;for(const d of e)d.cost!=null&&d.costUnit&&c.add(d.costUnit);let u;return c.size===0?u=l>0?vg(l):"—":c.size===1?u=l>0?vg(l,[...c][0]):"—":u="Mixed",o.jsx(Bt.Summary,{value:u,label:"Total cost"})})(),s?o.jsx(Bt.Actions,{children:s}):null]}),t?o.jsx(Bt.Loading,{}):n?o.jsx(Bt.Error,{message:"Failed to load model usage data"}):o.jsx(Bt.Content,{children:i?o.jsxs(me,{columns:"auto auto auto auto auto auto",...kve,children:[o.jsxs(me.Top,{children:[o.jsx(me.TopCell,{sticky:"start",children:"Model"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Input"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Output"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Cache Read"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Cache Write"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Cost"})]}),e.map(l=>{const c=r?.(l),u=o.jsxs(o.Fragment,{children:[o.jsx(me.RowHeaderCell,{height:"compact",className:"text-ui-sm",children:l.model}),o.jsx(me.NumberCell,{children:l.input}),o.jsx(me.NumberCell,{children:l.output}),o.jsx(me.NumberCell,{children:l.cacheRead}),o.jsx(me.NumberCell,{children:l.cacheWrite}),o.jsx(me.NumberCell,{highlight:!0,children:l.cost!=null?vg(l.cost,l.costUnit):"—"})]});return c?o.jsx(me.RowLink,{to:c,LinkComponent:a,children:u},l.model):o.jsx(me.RowStatic,{children:u},l.model)})]}):o.jsx(Bt.NoData,{message:"No model usage data yet"})})]})}function Kns(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","model-usage-cost",n],queryFn:async()=>{const[r,s,a,i]=await Promise.all(["mastra_model_total_input_tokens","mastra_model_total_output_tokens","mastra_model_input_cache_read_tokens","mastra_model_input_cache_write_tokens"].map(d=>e.getMetricBreakdown({name:[d],groupBy:["model"],aggregation:"sum",orderDirection:"DESC",filters:t}))),l=new Map,c=d=>(l.has(d)||l.set(d,{input:0,output:0,cacheRead:0,cacheWrite:0,cost:null,costUnit:null}),l.get(d)),u=(d,f)=>{f.estimatedCost!=null&&(d.cost=(d.cost??0)+f.estimatedCost,f.costUnit&&(d.costUnit=f.costUnit))};for(const d of r.groups){const f=d.dimensions.model??"unknown",p=c(f);p.input=d.value,u(p,d)}for(const d of s.groups){const f=d.dimensions.model??"unknown",p=c(f);p.output=d.value,u(p,d)}for(const d of a.groups){const f=d.dimensions.model??"unknown",p=c(f);p.cacheRead=d.value}for(const d of i.groups){const f=d.dimensions.model??"unknown",p=c(f);p.cacheWrite=d.value}return Array.from(l.entries()).map(([d,f])=>({model:d,input:yc(f.input),output:yc(f.output),cacheRead:yc(f.cacheRead),cacheWrite:yc(f.cacheWrite),cost:f.cost,costUnit:f.costUnit})).sort((d,f)=>d.model.localeCompare(f.model))}})}function Jns(){const{data:e,isLoading:t,isError:n}=Kns(),{getTracesHref:r}=wI(),{Link:s}=yn();return o.jsx(Xns,{rows:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:()=>r({rootEntityType:Os.AGENT}),actions:o.jsx(q4,{href:r({rootEntityType:Os.AGENT}),LinkComponent:s})})}function ers(e){return e==="tokens"||e==="cost"}function trs({data:e,isLoading:t,isError:n,getRowHref:r,actions:s,LinkComponent:a}){const[i,l]=v.useState("tokens"),c=e??[],u=c.length>0,d=c.reduce((b,w)=>b+w.total,0),f=c.filter(b=>b.cost!=null&&b.cost>0),p=new Set(f.map(b=>b.costUnit??"usd")),h=p.size<=1,m=h?[...p][0]??"usd":null,g=h?f.reduce((b,w)=>b+(w.cost??0),0):0,y=h&&g>0;return o.jsxs(Bt,{children:[o.jsxs(Bt.TopBar,{children:[o.jsx(Bt.TitleAndDescription,{title:"Token Usage by Agent",description:"Token consumption grouped by agent."}),u&&(i==="cost"&&y?o.jsx(Bt.Summary,{value:vg(g,m),label:"Total cost"}):o.jsx(Bt.Summary,{value:yc(d),label:"Total tokens"})),u&&s?o.jsx(Bt.Actions,{children:s}):null]}),t?o.jsx(Bt.Loading,{}):n?o.jsx(Bt.Error,{message:"Failed to load token usage data"}):o.jsx(Bt.Content,{children:u?o.jsxs(ru,{defaultTab:"tokens",value:i,onValueChange:b=>{ers(b)&&l(b)},className:"grid grid-rows-[auto_1fr] overflow-y-auto h-full",children:[o.jsxs(su,{children:[o.jsx(Vr,{value:"tokens",children:"Tokens"}),o.jsx(Vr,{value:"cost",children:"Cost"})]}),o.jsx(ps,{value:"tokens",children:o.jsx(aN,{LinkComponent:a,data:c.map(b=>({name:b.name,values:[b.input,b.output],href:r?.(b)})),segments:[{label:"Input",color:Np.blueDark},{label:"Output",color:Np.blue}],maxVal:Math.max(...c.map(b=>b.input+b.output)),fmt:yc})}),o.jsx(ps,{value:"cost",children:y?o.jsx(aN,{LinkComponent:a,data:f.slice().sort((b,w)=>(w.cost??0)-(b.cost??0)).map(b=>({name:b.name,values:[b.cost],href:r?.(b)})),segments:[{label:"Cost",color:Np.purple}],maxVal:Math.max(...f.map(b=>b.cost??0)),fmt:b=>vg(b,m)}):o.jsx(Bt.NoData,{message:"No cost data yet"})})]}):o.jsx(Bt.NoData,{message:"No token usage data yet"})})]})}function nrs(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","token-usage-by-agent",n],queryFn:async()=>{const r={groupBy:["entityName"],aggregation:"sum",orderDirection:"DESC",filters:t},[s,a]=await Promise.all([e.getMetricBreakdown({...r,name:["mastra_model_total_input_tokens"]}),e.getMetricBreakdown({...r,name:["mastra_model_total_output_tokens"]})]),i=new Map,l=u=>(i.has(u)||i.set(u,{input:0,output:0,cost:null,costUnit:null}),i.get(u)),c=(u,d)=>{d.estimatedCost!=null&&(u.cost=(u.cost??0)+d.estimatedCost,d.costUnit&&(u.costUnit=d.costUnit))};for(const u of s.groups){const d=u.dimensions.entityName??"unknown",f=l(d);f.input=u.value,c(f,u)}for(const u of a.groups){const d=u.dimensions.entityName??"unknown",f=l(d);f.output=u.value,c(f,u)}return Array.from(i.entries()).map(([u,d])=>({name:u,input:d.input,output:d.output,total:d.input+d.output,cost:d.cost,costUnit:d.costUnit})).sort((u,d)=>d.total-u.total)}})}function rrs(){const{data:e,isLoading:t,isError:n}=nrs(),{getTracesHref:r}=wI(),{Link:s}=yn();return o.jsx(trs,{data:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:a=>r({rootEntityType:Os.AGENT,entityName:a.name}),actions:o.jsx(q4,{href:r({rootEntityType:Os.AGENT}),LinkComponent:s})})}function srs(e){return e==="24h"?"1h":"1d"}function ars(e,t){return t==="1h"?e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}):e.toLocaleDateString("en-US",{month:"short",day:"2-digit"})}function _Qe(e,t,n){for(const r of t?.points??[]){const s=new Date(r.timestamp).getTime();if(!Number.isFinite(s))continue;const a=e.get(s)??{tsMs:s,input:0,output:0,cost:null,costUnits:new Set,hasUnknownCostUnit:!1};a[n]+=r.value,r.estimatedCost!=null&&(a.cost=(a.cost??0)+r.estimatedCost,t?.costUnit?a.costUnits.add(t.costUnit):a.hasUnknownCostUnit=!0),e.set(s,a)}}function irs(e){return e.cost==null||e.hasUnknownCostUnit||e.costUnits.size!==1?null:[...e.costUnits][0]??null}function ors(){const e=We(),{datePreset:t,filters:n,filterKey:r}=Cm(),s=srs(t);return wt({queryKey:["metrics","token-usage-timeseries",r,s],queryFn:async()=>{const[a,i]=await Promise.all([e.getMetricTimeSeries({name:["mastra_model_total_input_tokens"],interval:s,aggregation:"sum",filters:n}),e.getMetricTimeSeries({name:["mastra_model_total_output_tokens"],interval:s,aggregation:"sum",filters:n})]),l=new Map;return _Qe(l,a.series[0],"input"),_Qe(l,i.series[0],"output"),{data:Array.from(l.values()).sort((u,d)=>u.tsMs-d.tsMs).map(u=>{const d=new Date(u.tsMs);return{time:ars(d,s),tsMs:u.tsMs,input:u.input,output:u.output,total:u.input+u.output,cost:u.cost,costUnit:irs(u)}}),interval:s}}})}function lrs(){const{data:e,isLoading:t,isError:n}=ors(),{getTracesHref:r}=wI(),{Link:s}=yn();return o.jsx(NQr,{data:e?.data,interval:e?.interval,isLoading:t,isError:n,actions:o.jsx(q4,{href:r(),LinkComponent:s})})}function Zre({data:e,rowHrefs:t,errorHrefs:n,LinkComponent:r}){return o.jsx(aN,{LinkComponent:r,data:e.map(s=>{const a=n?.(s),i=t?.(s);return a?{name:s.name,values:[s.completed,s.errors],hrefs:[i,a]}:{name:s.name,values:[s.completed,s.errors],href:i}}),segments:[{label:"Completed",color:Np.blueDark},{label:"Errors",color:Np.pink}],maxVal:Math.max(...e.map(s=>s.completed+s.errors)),fmt:yc})}function crs({data:e,isLoading:t,isError:n,getRowHref:r,getErrorSegmentHref:s,actions:a,LinkComponent:i}){const[l,c]=v.useState("agents"),u=typeof a=="function"?a(l):a,d=!!e&&(e.agentData.length>0||e.workflowData.length>0||e.toolData.length>0),f=e?[...e.agentData,...e.workflowData,...e.toolData].reduce((m,g)=>m+g.completed+g.errors,0):0,p=m=>r?g=>r(m,g):void 0,h=m=>s?g=>s(m,g):void 0;return o.jsxs(Bt,{children:[o.jsxs(Bt.TopBar,{children:[o.jsx(Bt.TitleAndDescription,{title:"Trace Volume",description:"Runs and call counts."}),d&&o.jsx(Bt.Summary,{value:yc(f),label:"Total runs"}),u?o.jsx(Bt.Actions,{children:u}):null]}),t?o.jsx(Bt.Loading,{}):n?o.jsx(Bt.Error,{message:"Failed to load trace volume data"}):o.jsx(Bt.Content,{children:d?o.jsxs(ru,{value:l,onValueChange:c,defaultTab:"agents",className:"grid grid-rows-[auto_1fr] overflow-y-auto h-full",children:[o.jsxs(su,{children:[o.jsx(Vr,{value:"agents",children:"Agents"}),o.jsx(Vr,{value:"workflows",children:"Workflows"}),o.jsx(Vr,{value:"tools",children:"Tools"})]}),o.jsx(ps,{value:"agents",children:e.agentData.length>0?o.jsx(Zre,{data:e.agentData,rowHrefs:p("agents"),errorHrefs:h("agents"),LinkComponent:i}):o.jsx(Bt.NoData,{message:"No agent data yet"})}),o.jsx(ps,{value:"workflows",children:e.workflowData.length>0?o.jsx(Zre,{data:e.workflowData,rowHrefs:p("workflows"),errorHrefs:h("workflows"),LinkComponent:i}):o.jsx(Bt.NoData,{message:"No workflow data yet"})}),o.jsx(ps,{value:"tools",children:e.toolData.length>0?o.jsx(Zre,{data:e.toolData,rowHrefs:p("tools"),errorHrefs:h("tools"),LinkComponent:i}):o.jsx(Bt.NoData,{message:"No tool data yet"})})]}):o.jsx(Bt.NoData,{message:"No trace volume data yet"})})]})}async function Gre(e,t,n){const r=await e.getMetricBreakdown({name:[t],groupBy:["entityName","status"],aggregation:"count",orderDirection:"DESC",filters:n}),s=new Map;for(const a of r.groups){const i=a.dimensions.entityName??"unknown",l=a.dimensions.status??"ok";s.has(i)||s.set(i,{completed:0,errors:0});const c=s.get(i);l==="error"?c.errors+=a.value:c.completed+=a.value}return Array.from(s.entries()).map(([a,i])=>({name:a,...i})).sort((a,i)=>i.completed+i.errors-(a.completed+a.errors))}function urs(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","trace-volume",n],queryFn:async()=>{const[r,s,a]=await Promise.all([Gre(e,"mastra_agent_duration_ms",t),Gre(e,"mastra_workflow_duration_ms",t),Gre(e,"mastra_tool_duration_ms",t)]);return{agentData:r,workflowData:s,toolData:a}}})}const Q8={agents:Os.AGENT,workflows:Os.WORKFLOW_RUN,tools:Os.TOOL};function drs(){const{data:e,isLoading:t,isError:n}=urs(),{getTracesHref:r,getLogsHref:s}=wI(),{Link:a}=yn();return o.jsx(crs,{data:e,isLoading:t,isError:n,LinkComponent:a,getRowHref:(i,l)=>r({rootEntityType:Q8[i],entityName:l.name}),getErrorSegmentHref:(i,l)=>l.errors>0?s({rootEntityType:Q8[i],entityName:l.name,status:"error"}):void 0,actions:i=>o.jsxs(o.Fragment,{children:[o.jsx(q4,{href:r({rootEntityType:Q8[i]}),LinkComponent:a}),o.jsx(Tns,{href:s({rootEntityType:Q8[i],status:"error"}),LinkComponent:a})]})})}const frs=new Set(["ObservabilityStorageClickhouseVNext","ObservabilityStorageDuckDB","ObservabilityInMemory","ObservabilitySpanner","ObservabilityStoragePostgresVNext"]),Qre="period",Y8="dateFrom",X8="dateTo";function prs(){const[e,t]=ji(),n=e.get(Qre),r=kQr(n)?n:"24h",s=v.useMemo(()=>{if(r!=="custom")return;const d=h=>{if(!h)return;const m=new Date(h);return Number.isNaN(m.getTime())?void 0:m},f=d(e.get(Y8)),p=d(e.get(X8));if(!(!f&&!p))return{from:f,to:p}},[r,e.toString()]),a=v.useMemo(()=>gQr(e),[e.toString()]),i=v.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d==="24h"?p.delete(Qre):p.set(Qre,d),d!=="custom"&&(p.delete(Y8),p.delete(X8)),p},{replace:!0})},[t]),l=v.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d?.from?p.set(Y8,d.from.toISOString()):p.delete(Y8),d?.to?p.set(X8,d.to.toISOString()):p.delete(X8),p},{replace:!0})},[t]),c=v.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return yQr(p,d),p},{replace:!0})},[t]),u=v.useRef(!1);return v.useEffect(()=>{if(u.current||(u.current=!0,hQr(e)))return;const d=T6t();d&&t(f=>{const p=new URLSearchParams(f);for(const[h,m]of d)p.append(h,m);return p},{replace:!0})},[]),o.jsx(_Qr,{preset:r,filterTokens:a,onPresetChange:i,onFilterTokensChange:c,customRange:s,onCustomRangeChange:l,children:o.jsx(hrs,{})})}function hrs(){const[e]=ji(),{error:t,isLoading:n}=f8t(),{filterTokens:r,setFilterTokens:s}=DZ(),[a,i]=v.useState(),{data:l,isLoading:c}=M4(),u=l?.observabilityStorageType,d=u?frs.has(u):!1,f=u==="ObservabilityInMemory",{data:p,isLoading:h}=lTe(),{data:m,isLoading:g}=aTe(),{data:y,isLoading:b}=oTe(),{data:w,isLoading:S}=iTe(),k=v.useMemo(()=>mQr({availableTags:p??[],availableEntityNames:m??[],availableServiceNames:y??[],availableEnvironments:w??[],loading:{tags:h,entityNames:g,serviceNames:b,environments:S}}),[p,m,y,w,h,g,b,S]),[_,C]=v.useState(()=>T6t()!==null),E=v.useCallback(()=>{fQr(e),C(!0),De.success("Filters setting for Metrics saved")},[e]),j=v.useCallback(()=>{pQr(),C(!1),De.success("Filters setting for Metrics cleared up")},[]),N=v.useCallback(()=>{s([])},[s]),I=v.useCallback(()=>{const R=r.map($=>{const F=k.find(D=>D.id===$.fieldId);return F?F.kind==="text"?{fieldId:$.fieldId,value:""}:F.kind==="pick-multi"?F.multi?{fieldId:$.fieldId,value:[]}:{fieldId:$.fieldId,value:"Any"}:F.kind==="multi-select"?{fieldId:$.fieldId,value:[]}:$:$});s(R)},[k,r,s]);return t&&gs(t)?o.jsx(lr,{children:o.jsx(Vs,{})}):t&&ys(t)?o.jsx(lr,{children:o.jsx(Ds,{resource:"metrics"})}):t?o.jsx(lr,{children:o.jsx(Fi,{title:"Failed to load metrics",message:t.message})}):o.jsxs(Lt,{width:"wide",height:"full",children:[o.jsxs(Lt.TopArea,{children:[o.jsx(Lt.Row,{children:o.jsxs(Lt.Column,{className:"flex flex-wrap items-start justify-start gap-2",children:[o.jsx(Ens,{}),o.jsx(rTe,{fields:k,tokens:r,onTokensChange:s,disabled:n,onStartTextFilter:i})]})}),o.jsx(Qns,{isLoading:n,filterFields:k,filterTokens:r,onFilterTokensChange:s,onClear:I,onRemoveAll:N,onSave:E,onRemoveSaved:_?j:void 0,autoFocusFilterFieldId:a})]}),c?null:d?o.jsxs("div",{className:"grid gap-8 content-start pb-10",children:[f&&o.jsx(In,{variant:"info",title:"Metrics are not persisted",children:o.jsx(In.Message,{children:"This project uses in-memory storage for observability. Metrics will be lost on every server restart. For persistent metrics, switch the observability storage to ClickHouse, DuckDB, Postgres v-next, or Spanner."})}),o.jsxs(Nve,{children:[o.jsx(Vns,{}),o.jsx(Hns,{}),o.jsx(Wns,{}),o.jsx(Zns,{}),o.jsx(Gns,{})]}),o.jsxs(Nve,{children:[o.jsx(Jns,{}),o.jsx(rrs,{}),o.jsx(lrs,{}),o.jsx(Fns,{}),o.jsx(drs,{}),o.jsx(Pns,{})]})]}):o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Lr,{iconSlot:o.jsx(xf,{}),titleSlot:"Metrics are not available with your current storage",descriptionSlot:"Metrics require ClickHouse, DuckDB, Postgres v-next, Spanner, or in-memory storage for observability. Other relational databases (LibSQL, MSSQL) and document stores (MongoDB) do not support metrics collection. To enable metrics on an existing project, switch the observability storage in the Mastra configuration.",actionSlot:o.jsxs(ue,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/observability/metrics/overview",target:"_blank",rel:"noopener noreferrer",children:["Metrics Documentation ",o.jsx(Pa,{})]})})})]})}function mrs(){const{paths:e}=yn(),{data:t,isLoading:n,error:r}=RLt(),{isCmsAvailable:s}=yI(),[a,i]=v.useState(""),l=t?.promptBlocks??[];return r&&gs(r)?o.jsx(lr,{children:o.jsx(Vs,{})}):r&&ys(r)?o.jsx(lr,{children:o.jsx(Ds,{resource:"prompt blocks"})}):r?o.jsx(lr,{children:o.jsx(Fi,{title:"Failed to load prompt blocks",message:r.message})}):l.length===0&&!n?o.jsx(lr,{children:o.jsx(vZr,{})}):o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsxs(Lt.Row,{align:"center",stack:"responsive",children:[o.jsx("div",{className:"max-w-120 flex-1",children:o.jsx(Of,{onSearch:i,label:"Filter prompts",placeholder:"Filter by name or description"})}),s&&o.jsxs(ue,{as:ci,to:e.cmsPromptBlockCreateLink(),variant:"primary",className:"shrink-0",children:[o.jsx(Fr,{}),"Create Prompt"]})]})}),o.jsx(gZr,{promptBlocks:l,isLoading:n,search:a})]})}function grs(){return o.jsx(Lt,{width:"narrow",children:o.jsx(Lt.MainArea,{children:o.jsx(_zr,{children:o.jsx(eve,{})})})})}const vrs=[{title:"Mastra APIs",description:"Explore and test the available REST API endpoints with the interactive Swagger UI.",icon:mcn,href:"/swagger-ui",external:!1},{title:"Documentation",description:"Read the official Mastra documentation for guides, references, and tutorials.",icon:llt,href:"https://mastra.ai/en/docs",external:!0},{title:"Github",description:"Browse the source code, report issues, and contribute to the Mastra project.",icon:Pa,href:"https://github.com/mastra-ai/mastra",external:!0},{title:"Community",description:"Join the Mastra Discord community for help, discussion, and collaboration.",icon:qj,href:"https://discord.gg/BTYqqHKUrf",external:!0},{title:"Share with your team",description:"Running Mastra Studio locally? Deploy to the cloud so your team can collaborate.",icon:glt,href:"https://mastra.ai/cloud",external:!0},{title:"Talk to our Sales team",description:"Get a custom demo, discuss on-prem deployments, and how we can help you accelerate getting agents into production.",icon:clt,href:"https://mastra.ai/contact?ref=studio",external:!0}];function yrs(){return o.jsx(Lt,{width:"narrow",children:o.jsx(Lt.MainArea,{children:o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 max-w-3xl",children:vrs.map(e=>o.jsxs("a",{href:e.href,...e.external?{target:"_blank",rel:"noreferrer"}:{},className:"group flex flex-col gap-3 rounded-lg border border-border1 bg-surface2 p-5 transition-colors hover:border-accent1 hover:bg-surface3",children:[o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx(e.icon,{className:"h-5 w-5 text-icon3 group-hover:text-accent1 transition-colors"}),o.jsx("span",{className:"text-ui-md font-medium text-text1",children:e.title}),e.external&&o.jsx(Pa,{className:"h-3.5 w-3.5 text-icon3 ml-auto opacity-0 group-hover:opacity-100 transition-opacity"})]}),o.jsx("p",{className:"text-ui-sm text-text3 leading-relaxed",children:e.description})]},e.href))})})})}function brs(){const{data:e={},isLoading:t,error:n}=eh(),[r,s]=v.useState(""),[a,i]=v.useState("all");if(n&&gs(n))return o.jsx(lr,{children:o.jsx(Vs,{})});if(n&&ys(n))return o.jsx(lr,{children:o.jsx(Ds,{resource:"scorers"})});if(n)return o.jsx(lr,{children:o.jsx(Fi,{title:"Failed to load scorers",message:n.message})});if(Object.keys(e).length===0&&!t)return o.jsx(lr,{children:o.jsx(kHr,{})});const l=a!=="all"||r!=="",c=()=>{s(""),i("all")};return o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx(IHr,{search:r,onSearchChange:s,sourceFilter:a,onSourceFilterChange:i,onReset:c,hasActiveFilters:l})}),o.jsx(SHr,{scorers:e,isLoading:t,search:r,sourceFilter:a})]})}function xrs(){const{scorerId:e}=dr(),[t,n]=ji(),r=t.get("scoreId")??void 0,[s,a]=v.useState(r),[i,l]=v.useState({value:"all",label:"All Entities",type:"ALL"}),{scorer:c,error:u}=JVr(e),{data:d={},isLoading:f,error:p}=Sm(),{isLoading:h,error:m}=By(),{data:g=[],isLoading:y,error:b,isFetchingNextPage:w,hasNextPage:S,setEndOfListElement:k}=KVr({scorerId:e,entityId:i?.value==="all"?void 0:i?.value,entityType:i?.type==="ALL"?void 0:i?.type}),_=v.useMemo(()=>c?.agentIds?.filter(B=>d[B]).map(B=>({value:B,label:d[B].name,type:"AGENT"}))||[],[c?.agentIds,d]),C=v.useMemo(()=>c?.workflowIds?.map(B=>({value:B,label:B,type:"WORKFLOW"}))||[],[c?.workflowIds]),E=v.useMemo(()=>[{value:"all",label:"All Entities",type:"ALL"},..._,...C],[_,C]),j=t.get("entity")??"all",N=E.find(B=>B.value===j);N&&N.value!==i?.value&&l(N),v.useEffect(()=>{if(u){const B=u instanceof Error?u.message:"Failed to load scorer";De.error(`Error loading scorer: ${B}`)}},[u]),v.useEffect(()=>{if(p){const B=p instanceof Error?p.message:"Failed to load agents";De.error(`Error loading agents: ${B}`)}},[p]),v.useEffect(()=>{if(m){const B=m instanceof Error?m.message:"Failed to load workflows";De.error(`Error loading workflows: ${B}`)}},[m]);const I=B=>{B?.value&&n(M=>{const G=new URLSearchParams(M);return G.set("entity",B.value),G})};v.useEffect(()=>{const B=t.get("scoreId")??void 0;if(B===s)return;if(!B){a(void 0);return}g.find(G=>G.id===B)&&a(B)},[t,g]);const R=v.useCallback(B=>{a(B||void 0),n(M=>{const G=new URLSearchParams(M);return B?G.set("scoreId",B):G.delete("scoreId"),G})},[n]);if(!c)return null;const $=gs(u)||gs(p)||gs(m),F=u&&ys(u),D=!$&&!F&&(u||p||m),V=!y&&g.length===0,W=i?.value!=="all",L=c?.scorer?.source==="stored"?o.jsx(Ty,{owner:"scorer-detail",children:o.jsxs(ue,{variant:"default",as:ci,to:`/cms/scorers/${e}/edit`,size:"sm",children:[o.jsx(em,{})," Edit"]})}):null;if($||F||D||V&&!W){const B=(u instanceof Error?u.message:void 0)??(p instanceof Error?p.message:void 0)??(m instanceof Error?m.message:void 0)??"An unexpected error occurred";return o.jsxs(Lt,{width:"wide",height:"full",children:[L,o.jsx(Lt.MainArea,{isCentered:!0,children:$?o.jsx(Vs,{}):F?o.jsx(Ds,{resource:"scorers"}):D?o.jsx(Fi,{title:"Failed to load scorer",message:B}):o.jsx(ZVr,{})})]})}return o.jsxs(Lt,{width:"wide",children:[L,o.jsx(Lt.TopArea,{children:o.jsx(GVr,{selectedEntity:i,entityOptions:E,onEntityChange:I,onReset:()=>{n(B=>{const M=new URLSearchParams(B);return M.set("entity","all"),M})},isLoading:y||f||h})}),o.jsx(WVr,{scores:g,isLoading:y,selectedScoreId:s,isFetchingNextPage:w,hasNextPage:S,setEndOfListElement:k,onScoreClick:R,errorMsg:b?.message})]})}function wrs({label:e,description:t,htmlFor:n,className:r,children:s}){return o.jsxs("div",{className:K("flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",r),"data-slot":"settings-row",children:[o.jsxs("div",{children:[n?o.jsx(Rt,{htmlFor:n,className:"text-sm font-medium",children:e}):o.jsx("p",{className:"text-sm font-medium",children:e}),t&&o.jsx("p",{className:"text-sm text-neutral3",children:t})]}),s]})}const g8t=[{value:"dark",label:"Dark",Icon:Vun},{value:"light",label:"Light",Icon:Jdn},{value:"system",label:"System",Icon:Clt}],Srs=e=>g8t.some(t=>t.value===e);function krs({option:e}){const{Icon:t}=e;return o.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-2",children:[o.jsx(t,{"aria-hidden":"true",className:"h-4 w-4 shrink-0 opacity-70"}),o.jsx("span",{className:"min-w-0 truncate",children:e.label})]})}const Ors=()=>{const{baseUrl:e,headers:t,apiPrefix:n}=Axe(),{theme:r,setTheme:s}=EN();return o.jsx(Lt,{width:"narrow",children:o.jsxs(Lt.MainArea,{className:"flex flex-col gap-5 mt-6",children:[o.jsx(Pge,{title:"Theme",description:"Customize the appearance of the studio.",children:o.jsx(wrs,{label:"Theme mode",htmlFor:"theme",children:o.jsxs(ba,{value:r,onValueChange:a=>{Srs(a)&&s(a)},children:[o.jsx(wa,{id:"theme",className:"w-full sm:w-48",children:o.jsx(xa,{className:"inline-flex min-w-0 max-w-full items-center"})}),o.jsx(Sa,{children:g8t.map(a=>o.jsx(qr,{value:a.value,children:o.jsx(krs,{option:a})},a.value))})]})})}),o.jsx(Pge,{title:"Mastra Connection",description:"Configure the Mastra instance URL, API prefix, and request headers used by the studio.",children:o.jsx(eLt,{initialConfig:{baseUrl:e,headers:t,apiPrefix:n}})})]})})};function _rs(){const[e]=ji(),t=bs(),n=e.get("redirect")||"/",r=()=>{n.startsWith("http")?window.location.href=n:t(n,{replace:!0})};return o.jsx(d8t,{redirectUri:n,onSuccess:r,initialMode:"signup"})}const v8t=e=>o.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[o.jsx("g",{clipPath:"url(#clip0_21999_22095)",children:o.jsx("path",{d:"M7.5 0.75C3.6325 0.75 0.5 3.8825 0.5 7.75C0.5 10.8475 2.50375 13.4637 5.28625 14.3912C5.63625 14.4525 5.7675 14.2425 5.7675 14.0587C5.7675 13.8925 5.75875 13.3412 5.75875 12.755C4 13.0787 3.545 12.3262 3.405 11.9325C3.32625 11.7312 2.985 11.11 2.6875 10.9437C2.4425 10.8125 2.0925 10.4887 2.67875 10.48C3.23 10.4712 3.62375 10.9875 3.755 11.1975C4.385 12.2562 5.39125 11.9587 5.79375 11.775C5.855 11.32 6.03875 11.0137 6.24 10.8387C4.6825 10.6637 3.055 10.06 3.055 7.3825C3.055 6.62125 3.32625 5.99125 3.7725 5.50125C3.7025 5.32625 3.4575 4.60875 3.8425 3.64625C3.8425 3.64625 4.42875 3.4625 5.7675 4.36375C6.3275 4.20625 6.9225 4.1275 7.5175 4.1275C8.1125 4.1275 8.7075 4.20625 9.2675 4.36375C10.6062 3.45375 11.1925 3.64625 11.1925 3.64625C11.5775 4.60875 11.3325 5.32625 11.2625 5.50125C11.7087 5.99125 11.98 6.6125 11.98 7.3825C11.98 10.0687 10.3438 10.6637 8.78625 10.8387C9.04 11.0575 9.25875 11.4775 9.25875 12.1337C9.25875 13.07 9.25 13.8225 9.25 14.0587C9.25 14.2425 9.38125 14.4612 9.73125 14.3912C11.1209 13.9221 12.3284 13.029 13.1839 11.8377C14.0393 10.6463 14.4996 9.21668 14.5 7.75C14.5 3.8825 11.3675 0.75 7.5 0.75Z",fill:"currentColor"})}),o.jsx("defs",{children:o.jsx("clipPath",{id:"clip0_21999_22095",children:o.jsx("rect",{width:"14",height:"14",fill:"currentColor",transform:"translate(0.5 0.75)"})})})]});function Crs(e){return e.replace(/\/$/,"").split("/").pop()}function BZ({children:e,className:t}){return o.jsx("div",{className:K("border border-border1 rounded-lg mt-12 py-8 lg:min-h-[25rem] transition-height px-4 lg:px-12",t),children:e})}function Ers({templates:e,linkComponent:t,className:n,isLoading:r}){const s=t||"a";return r?o.jsx("div",{className:K("grid gap-y-4",n),children:Array.from({length:5}).map((a,i)=>o.jsx("div",{className:"h-16 bg-surface3 animate-pulse rounded-lg"},i))}):o.jsx("div",{className:K("grid gap-y-4",n),children:e.map(a=>{const i=a?.agents||a?.tools||a?.networks||a?.workflows||a?.mcp;return o.jsxs("article",{className:K("border border-border1 rounded-lg overflow-hidden w-full grid grid-cols-[1fr_auto] bg-surface3 transition-colors hover:bg-surface4"),children:[o.jsxs(s,{to:`/templates/${a.slug}`,className:K("grid [&:hover_p]:text-neutral5",{"grid-cols-[8rem_1fr] lg:grid-cols-[12rem_1fr]":a.imageURL}),children:[a.imageURL&&o.jsx("div",{className:K("overflow-hidden"),children:o.jsx("div",{className:"w-full h-full bg-cover thumb transition-scale duration-150",style:{backgroundImage:`url(${a.imageURL})`}})}),o.jsxs("div",{className:K("grid py-3 px-6 w-full gap-0.5","[&_svg]:w-[1em] [&_svg]:h-[1em] [&_svg]:text-neutral3"),children:[o.jsx("h2",{className:"text-ui-lg text-neutral5",children:a.title}),o.jsx("p",{className:"text-ui-md text-neutral4 transition-colors duration-500",children:a.description}),o.jsxs("div",{className:"hidden 2xl:flex text-neutral3 text-ui-md flex-wrap items-center gap-4 mt-3",children:[i&&o.jsxs("ul",{className:K("flex gap-4 text-ui-md text-neutral3 m-0 p-0 list-none","[&>li]:flex [&>li]:items-center [&>li]:gap-0.5 text-neutral4"),children:[a?.agents&&a.agents.length>0&&o.jsxs("li",{children:[o.jsx(rl,{})," ",a.agents.length]}),a?.tools&&a.tools.length>0&&o.jsxs("li",{children:[o.jsx(Gp,{})," ",a.tools.length]}),a?.networks&&a.networks.length>0&&o.jsxs("li",{children:[o.jsx(Elt,{})," ",a.networks.length]}),a?.workflows&&a.workflows.length>0&&o.jsxs("li",{children:[o.jsx(eq,{})," ",a.workflows.length]}),a?.mcp&&a.mcp.length>0&&o.jsxs("li",{children:[o.jsx(M_,{})," ",a.mcp.length]})]}),i&&a.supportedProviders&&o.jsx("small",{children:"|"}),o.jsx("div",{className:"flex items-center text-neutral3 gap-4",children:a.supportedProviders.map(l=>o.jsx("span",{className:"",children:l},l))})]})]})]}),o.jsx("a",{href:a.githubUrl,className:K("group items-center gap-2 text-ui-md ml-auto pr-4 hidden","lg:flex"),target:"_blank",rel:"noopener noreferrer",children:o.jsxs("span",{className:"flex items-center gap-2 px-2 py-1 rounded bg-surface1 group-hover:bg-surface2 text-neutral3 transition-colors group-hover:text-neutral5",children:[o.jsx(v8t,{})," ",Crs(a.githubUrl)]})})]},a.slug)})})}function jrs({tagOptions:e,selectedTag:t,providerOptions:n,selectedProvider:r,onTagChange:s,onProviderChange:a,searchTerm:i,onSearchChange:l,onReset:c,className:u,isLoading:d}){return d?o.jsxs("div",{className:K("h-[6.5rem] flex items-center gap-8","[&>div]:bg-surface3 [&>div]:w-48 [&>div]:h-8 [&>div]:animate-pulse",u),children:[o.jsx("div",{})," ",o.jsx("div",{})," ",o.jsx("div",{})]}):o.jsxs("div",{className:K("flex flex-wrap mx-auto sticky top-0 gap-4 bg-surface2 py-8",u),children:[o.jsx($T,{name:"search-templates",label:"Search templates",labelIsHidden:!0,value:i,onChange:f=>l?.(f.target.value),placeholder:"Search Template"}),o.jsx(xc,{label:"Filter by tag",labelIsHidden:!0,name:"filter-tag",value:t,onValueChange:s,options:e}),o.jsx(xc,{label:"Filter by provider",labelIsHidden:!0,name:"filter-provider",value:r,onValueChange:a,options:n}),c&&o.jsxs(ue,{onClick:c,children:["Reset ",o.jsx(vs,{})]})]})}function Trs(){const{data:e,isLoading:t}=FQn(),{templates:n,tags:r,providers:s}=e??{templates:[],tags:[],providers:[]},[a,i]=v.useState("all"),[l,c]=v.useState("all"),[u,d]=v.useState(""),f=[{value:"all",label:"Any tag"}];(r||[]).forEach(w=>{f.push({value:w,label:w})});const p=[{value:"all",label:"Any provider"}];(s||[]).forEach(w=>{p.push({value:w,label:w})});const h=(w,S)=>{S==="tag"?i(w):S==="provider"&&c(w)},m=w=>{d(w)},g=()=>{i("all"),c("all"),d("")},y=n.filter(w=>!(u&&!w.title.toLowerCase().includes(u)&&!w.description.toLowerCase().includes(u)||a!=="all"&&!w.tags.includes(a)||l!=="all"&&!w.supportedProviders.includes(l))),b=u||a!=="all"||l!=="all";return o.jsxs(cs,{children:[o.jsx(qxe,{children:o.jsxs(gpt,{children:[o.jsx(Ue,{children:o.jsx(Hv,{})}),"Templates"]})}),o.jsxs("div",{className:K("overflow-y-auto w-full h-full px-8 pb-12 z-10"),children:[o.jsx(jrs,{selectedTag:a,onTagChange:w=>h(w,"tag"),tagOptions:f,selectedProvider:l,onProviderChange:w=>h(w,"provider"),providerOptions:p,searchTerm:u,onSearchChange:m,onReset:b?g:void 0,className:"max-w-[80rem]",isLoading:t}),o.jsx(Ers,{templates:y,linkComponent:ci,className:"max-w-[80rem] mx-auto",isLoading:t})]})]})}const Nrs="1.48.0-alpha.8";function Irs({errorMsg:e,validationErrors:t}){const n=typeof e=="string"?e:e!=null?String(e):void 0,r=n?.includes("Invalid schema for function"),s=n?.includes("validation issue")||t&&t.length>0,a=()=>s?"Template installation completed but some validation issues remain. The template may still be functional, but you should review and fix these issues.":r?"There was an issue with the AI model configuration. This may be related to the selected model or AI SDK version compatibility.":"An unexpected error occurred during template installation.",i=()=>s?{icon:o.jsx(kp,{className:"text-yellow-500"}),title:"Template Installed with Warnings"}:{icon:o.jsx(Vcn,{}),title:"Template Installation Failed"},{icon:l,title:c}=i();return o.jsxs(BZ,{className:"space-y-4 text-neutral3 mb-8 content-center",children:[o.jsxs("div",{className:K("grid items-center justify-items-center gap-4 content-center","[&>svg]:w-8 [&>svg]:h-8"),children:[l,o.jsxs("div",{className:"text-center space-y-2",children:[o.jsx("p",{className:"text-ui-md font-medium text-neutral5",children:c}),o.jsx("p",{className:"text-ui-md text-neutral3",children:a()})]})]}),t&&t.length>0&&o.jsxs("details",{className:"text-xs",children:[o.jsxs("summary",{className:"cursor-pointer text-neutral3 hover:text-neutral4 select-none text-center",children:["Show Validation Issues (",t.length,")"]}),o.jsx("div",{className:"mt-4 p-3 bg-gray-100 dark:bg-gray-800 rounded text-xs overflow-auto max-h-60 text-left space-y-2",children:t.map((u,d)=>o.jsxs("div",{className:"border-l-2 border-red-400 pl-2",children:[o.jsx("div",{className:"font-medium text-red-600 dark:text-red-400",children:u.type==="typescript"?"🔴 TypeScript Error":"⚠️ Lint Error"}),o.jsx("div",{className:"text-xs font-mono text-gray-700 dark:text-gray-300 mt-1 whitespace-pre-wrap wrap-break-word",children:u.message})]},d))})]}),n&&!s&&o.jsxs("details",{className:"text-xs",children:[o.jsx("summary",{className:"cursor-pointer text-neutral3 hover:text-neutral4 select-none text-center",children:"Show Details"}),o.jsx("div",{className:"mt-4 p-3 bg-gray-100 dark:bg-gray-800 rounded text-xs font-mono overflow-auto max-h-60 text-left",children:o.jsx("div",{className:"whitespace-pre-wrap wrap-break-word",children:n})})]})]})}function Ars({providerOptions:e,selectedProvider:t,onProviderChange:n,variables:r,errors:s,handleInstallTemplate:a,handleVariableChange:i,isLoadingEnvVars:l,isInstalling:c,defaultModelProvider:u,defaultModelId:d,onModelUpdate:f}){return o.jsx(BZ,{children:o.jsxs("div",{className:"max-w-[40rem] my-4 p-4 lg:p-8 mx-auto gap-8 grid",children:[o.jsxs("h2",{className:K("text-neutral4 text-header-sm font-semibold flex items-center gap-2","[&>svg]:w-[1.2em] [&_svg]:h-[1.2em] [&_svg]:opacity-70"),children:["Install Template ",o.jsx(jlt,{})]}),o.jsx(xc,{name:"template-provider",options:e,label:"Template AI Model Provider",onValueChange:n,value:t,placeholder:"Select",layout:"horizontal"}),t&&Object.entries(r||{}).length>0&&o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"text-neutral3 text-ui-md",children:"Set required Environmental Variables"}),o.jsx("div",{className:"grid grid-cols-[1fr_1fr] gap-4 items-start",children:l?o.jsxs("div",{className:K("flex items-center justify-center col-span-2 text-neutral3 text-ui-sm gap-4","[&_svg]:opacity-50 [&_svg]:w-[1.1em] [&_svg]:h-[1.1em]","animate-in fade-in duration-300"),children:[o.jsx(Gt,{})," Loading variables..."]}):Object.entries(r).map(([p,h])=>o.jsxs(v.Fragment,{children:[o.jsx(dO,{name:`env-${p}`,labelIsHidden:!0,label:"Key",value:p,disabled:!0,className:"w-full"}),o.jsx(dO,{name:p,labelIsHidden:!0,label:"Value",value:h,onChange:i,errorMsg:s.includes(p)?"Value is required.":"",autoComplete:"off",className:"w-full"})]},p))}),o.jsxs("div",{className:"border-t border-border1 pt-12 mt-3.5 relative",children:[o.jsx("div",{className:"absolute w-8 h-8 rounded-full bg-surface2 top-0 left-1/2 -translate-x-1/2 -translate-y-4 text-ui-sm text-neutral3 flex items-center justify-center",children:"And"}),o.jsx("h3",{className:"text-neutral4 text-ui-lg",children:"Set AI Model for Template Installation"}),o.jsx("p",{className:"text-neutral3 text-ui-md mt-2 mb-8",children:"This model will be used by the workflow to process and install the template"}),o.jsx(J5t,{defaultProvider:u||"",defaultModel:d||"",updateModel:f||(()=>Promise.resolve({message:"Updated"})),closeEditor:()=>{},autoSave:!0,selectProviderPlaceholder:"Provider"})]})]}),t&&!l&&o.jsx(ue,{className:K("flex items-center gap-2 mt-4 justify-center text-ui-md w-full bg-surface5 min-h-10 rounded-lg text-neutral5 hover:bg-surface6 transition-colors","[&>svg]:w-[1.1em] [&_svg]:h-[1.1em] [&_svg]:text-neutral5"),onClick:a,disabled:!t||!u||!d||s.length>0||c,children:c?o.jsxs(o.Fragment,{children:[o.jsx(Gt,{className:"w-4 h-4"})," Installing..."]}):o.jsxs(o.Fragment,{children:["Install ",o.jsx(hm,{})]})})]})})}function Rrs({title:e,description:t,githubUrl:n,isLoading:r,infoData:s,templateSlug:a}){const i=a?`feat/install-template-${a}`:"feat/install-template-[slug]";return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:K("grid mt-8 items-center"),children:o.jsxs("div",{className:K("text-header-lg flex items-center gap-3","[&>svg]:w-[1.2em] [&>svg]:h-[1.2em] [&>svg]:opacity-50",{"[&>svg]:opacity-20":r}),children:[o.jsx(Hv,{}),o.jsx("h2",{className:K({"bg-surface4 flex rounded-lg min-w-[50%]":r}),children:r?o.jsx(o.Fragment,{children:" "}):e})]})}),o.jsxs("div",{className:"grid lg:grid-cols-[1fr_1fr] gap-x-24",children:[o.jsxs("div",{className:"grid",children:[o.jsx("p",{className:K("mb-4 text-ui-md text-neutral4 mt-2 leading-7",{"bg-surface4 rounded-lg ":r}),children:r?o.jsx(o.Fragment,{children:" "}):t}),!r&&a&&o.jsxs("div",{className:K("bg-surface2 border border-surface4 rounded-lg p-4 mb-4","flex items-start gap-3"),children:[o.jsx("div",{className:"shrink-0 mt-0.5",children:o.jsx(Mx,{className:"w-[1.1em] h-[1.1em] text-blue-500"})}),o.jsxs("div",{className:"flex-1 space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Vye,{className:"w-[1em] h-[1em] text-neutral4"}),o.jsx("span",{className:"text-ui-md font-medium text-neutral5",children:"A new Git branch will be created"})]}),o.jsxs("div",{className:"text-ui-sm text-neutral4 space-y-1",children:[o.jsxs("div",{children:[o.jsx("span",{className:"font-medium",children:"Branch name:"})," ",o.jsx("code",{className:"bg-surface3 px-1.5 py-0.5 rounded text-ui-sm font-mono",children:i})]}),o.jsx("div",{children:"This ensures safe installation with easy rollback if needed. Your main branch remains unchanged."})]})]})]}),n&&o.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 mt-auto text-neutral3 text-ui-md hover:text-neutral5",children:[o.jsx(v8t,{}),n?.split("/")?.pop()]})]}),s&&o.jsx(Aje,{data:s,labelsAreHidden:!0,isLoading:r})]})]})}function Prs(e){switch(e){case"running":return o.jsx(Gt,{});case"success":return o.jsx(hx,{});case"failed":return o.jsx(Pu,{});default:return null}}function $rs({stepId:e,step:t,isActive:n,position:r}){const s=a=>a.charAt(0).toUpperCase()+a.slice(1).replace(/-/g," ");return o.jsxs("div",{className:K("grid gap-6 grid-cols-[1fr_auto] py-3 px-4 rounded-lg",is.all,{"border border-dashed border-neutral2 bg-surface3":n}),children:[o.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-2",children:[o.jsxs("span",{className:K("text-ui-md min-w-6 flex justify-end",is.colors,{"text-neutral5":n||t.status==="success","text-neutral3":!n&&t.status!=="success"}),children:[r,"."]}),o.jsxs("div",{children:[o.jsx("h4",{className:K("text-ui-md",is.colors,{"text-neutral5":n||t.status==="success","text-neutral3":!n&&t.status!=="success"}),children:s(e)}),t.description&&o.jsx("p",{className:"text-ui-md text-neutral2 -mt-0.5",children:t.description})]})]}),o.jsx("div",{className:K("w-[1.75rem] h-[1.75rem] rounded-full flex items-center justify-center self-center",is.all,{"border border-neutral2 border-dashed":t.status==="pending","[&>svg]:text-white [&>svg]:w-4 [&>svg]:h-4":t.status!=="running","w-[1.75rem] h-[1.75rem]":t.status==="running","bg-accent1Dark shadow-glow-accent1":t.status==="success","bg-accent2Dark shadow-glow-accent2":t.status==="failed","scale-110":t.status==="success"||t.status==="failed"}),children:Prs(t.status)})]})}function Mrs({currentStep:e,steps:t=[],className:n}){return o.jsx("div",{className:K(n),children:t.map((r,s)=>o.jsx($rs,{stepId:r.id,step:r,isActive:e?.id===r.id,position:s+1},r.id))})}function Drs({steps:e}){const t=e.length,n=e.filter(r=>r.status==="success").length;return o.jsxs("div",{className:"flex justify-center flex-col gap-4 content-center w-full",children:[o.jsx("div",{className:"grid grid-cols-[0_repeat(9,1fr)] w-full",children:e.map((r,s)=>o.jsx("div",{className:K("flex justify-end items-center relative h-[2rem]",is.colors,{"bg-accent1Dark":r.status==="success"&&e?.[s-1]?.status==="success"}),children:o.jsx("div",{className:K("w-[2rem] h-[2rem] rounded-full flex items-center justify-center self-center absolute right-0 translate-x-[50%] bg-surface3 z-10 text-neutral3 font-bold text-ui-sm",is.all,{"border border-neutral2 border-dashed":r.status==="pending","[&>svg]:text-surface1 [&>svg]:w-[1.1rem] [&>svg]:h-[1.1rem]":r.status!=="running","bg-accent1Dark text-white shadow-glow-accent1 scale-110":r.status==="success","bg-accent2Dark text-white shadow-glow-accent2 scale-110":r.status==="failed"}),children:r.status==="running"?o.jsx(Gt,{}):s+1})},r.id))}),o.jsxs("div",{className:K("text-xs text-neutral3 text-center",is.colors),children:[n," of ",t," steps completed"]})]})}function Lrs({name:e,streamResult:t,runId:n,workflowInfo:r}){const s=t?.phase||"initializing",a=t?.payload?.workflowState,i=t?.payload?.currentStep,l=t?.error,c=a?.steps||{},u=Object.keys(c).length>0,d=g=>g==="input"||g.endsWith(".input")||g.startsWith("Mapping_")&&/[0-9a-f]{8}/.test(g)||/[0-9a-f]{8,}/.test(g)?!1:r?.allSteps?g in r.allSteps:!0,f=Object.entries(c).filter(([g,y])=>d(g)),p=f.length,h=()=>{switch(s){case"initializing":return"Preparing template installation...";case"processing":return`Installing ${e} template`;case"completed":return"Template installation completed!";case"error":return"Template installation failed";default:return"Installing template..."}},m=f.map(([g,y])=>({id:g,status:y?.status,description:y?.description,title:g.charAt(0).toUpperCase()+g.slice(1).replace(/-/g," "),isActive:i?.id===g}));return o.jsxs(BZ,{className:"space-y-6 text-neutral3 mb-8 content-center",children:[o.jsxs("div",{className:"text-center",children:[o.jsx("h3",{className:"text-lg font-semibold text-neutral5",children:h()}),(t?.runId||n)&&o.jsxs("div",{className:"mt-2 text-ui-sm text-neutral3",children:["Run ID: ",t?.runId??n]})]}),u&&p>0&&!["error"].includes(s)&&o.jsx("div",{className:"max-w-[30rem] w-full mx-auto px-6",children:o.jsx(Drs,{steps:m})}),l&&s==="error"&&o.jsxs("div",{className:K("rounded-lg text-neutral5 p-6 flex items-center gap-3 text-ui-md bg-red-500/10","[&>svg]:w-6 [&>svg]:h-6 [&>svg]:opacity-70 [&>svg]:text-red-500"),children:[o.jsx(edn,{}),l||"Something went wrong"]}),u&&o.jsx(Mrs,{steps:m,currentStep:i,className:"pb-4"}),!u&&s==="initializing"&&o.jsxs("div",{className:"text-center text-sm text-neutral3 grid gap-4 justify-items-center",children:[o.jsx(Gt,{}),o.jsx("p",{children:"This may take some time..."})]})]})}function Frs({name:e,installedEntities:t}){return o.jsxs(BZ,{className:K("grid items-center justify-items-center gap-4 content-center","[&>svg]:w-8 [&>svg]:h-8"),children:[o.jsx(jlt,{}),o.jsx("h2",{className:"text-header-md",children:"Done!"}),o.jsxs("p",{className:"text-ui-md text-center text-neutral3 ",children:["The ",o.jsx("b",{className:"text-neutral4",children:e})," template has been successfully installed.",t&&t.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("br",{})," Installed entities are listed below."]})]}),t&&t.length>0&&o.jsx(Aje,{data:t})]})}function zrs(){const{templateSlug:e}=dr(),[t,n]=ji(),[r,s]=v.useState(""),[a,i]=v.useState(""),[l,c]=v.useState(""),[u,d]=v.useState({}),[f,p]=v.useState([]),[h,m]=v.useState(null),[g,y]=v.useState(!1),[b,w]=v.useState(""),[S,k]=v.useState(!1),[_,C]=v.useState(!1),[E,j]=v.useState([]),{data:N,isLoading:I}=zQn({repoOrSlug:e,owner:"mastra-ai"}),$=Nrs?.includes("beta")??!1?"beta":"main",{data:F,isLoading:D}=BQn({repo:N?.githubUrl?new URL(N.githubUrl).pathname.split("/")[2]:`template-${e}`,owner:"mastra-ai",branch:$}),{data:V,isLoading:W}=UQn(),{mutateAsync:L,isPending:z}=qQn(),{mutateAsync:B}=VQn(),{streamInstall:M,streamResult:G,isStreaming:U}=WQn(V),{observeInstall:P,streamResult:q,isStreaming:Z}=ZQn(V);v.useEffect(()=>{const ne=t.get("runId");ne&&!g&&!h&&!U&&!Z&&(console.info("🔄 Checking completed run after hot reload:",{runId:ne}),w(ne),B({runId:ne}).then(ce=>{const pe=ce.snapshot;if(pe?.status==="success"&&pe?.result?.success)y(!0);else if(pe?.result?.success===!1)if(pe?.result?.validationResults&&!pe?.result?.validationResults?.valid&&pe?.result?.validationResults?.remainingErrors>0){const{remainingErrors:ve,errors:ye}=pe.result.validationResults,Se=`Template installation completed but ${ve} validation issue${ve>1?"s":""} remain unresolved.`;m(Se),j(ye||[])}else{const ve=pe?.result?.message||pe?.result?.error||"Template installation failed";m(typeof ve=="string"?ve:String(ve))}}).catch(ce=>{console.error("❌ Failed to fetch run details:",ce),m("Failed to retrieve installation status after reload")}))},[t,g,h,U,Z,B]),v.useEffect(()=>{const ne=t.get("runId"),ce=t.get("resume"),pe=t.get("provider");if(ne&&ce==="true"&&pe&&!U&&!Z&&!S&&!_&&V){w(ne),k(!0);try{B({runId:ne}).then(le=>{if(le.snapshot?.status==="running")return P.mutateAsync({runId:ne})}).then(()=>{n(le=>{const ve=new URLSearchParams(le);return ve.delete("resume"),ve})}).catch(le=>{console.error("❌ Failed to resume template installation:",le),le.message?.includes("404")||le.message?.includes("not found")?m("Template installation run not found. It may have expired or been completed."):m("Failed to resume template installation. Please try again.")})}catch(le){console.error("❌ Auto-resume failed with error:",le),m("Failed to resume template installation. Please refresh and try again.")}}},[t,e,U,Z,S,_,V,B,P,n]);const X=[{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"groq",label:"Groq"},{value:"google",label:"Google"}],te=[{key:"tools",label:"Tools",value:N?.tools?.length?N.tools.map(ne=>ne).join(", "):"n/a",icon:o.jsx(Gp,{})},{key:"agents",label:"Agents",value:N?.agents?.length?N.agents.map(ne=>ne).join(", "):"n/a",icon:o.jsx(rl,{})},{key:"workflows",label:"Workflows",value:N?.workflows?.length?N.workflows.map(ne=>ne).join(", "):"n/a",icon:o.jsx(eq,{})},{key:"providers",label:"Providers",value:N?.supportedProviders?.length?N.supportedProviders.join(", "):"n/a",icon:o.jsx(Iv,{})},{key:"tags",label:"Tags",value:N?.tags?.length?N.tags.join(", "):"n/a",icon:o.jsx(hN,{})}],J=[{...te[0]},{...te[1]},{...te[2]}].filter(ne=>ne.value!=="n/a");v.useEffect(()=>{F&&d(F)},[F]),v.useEffect(()=>{const ne=G||q;ne?.phase==="error"&&ne?.error&&m(typeof ne.error=="string"?ne.error:String(ne.error))},[G?.phase,G?.error,q?.phase,q?.error]);const ee=ne=>{s(ne)},ae=async ne=>(i(ne.provider),c(ne.modelId),{message:"Model updated successfully"}),de=async()=>{const ne=Object.entries(u).reduce((ce,[pe,le])=>(le===""&&ce.push(pe),ce),[]);if(ne.length>0){p(ne);return}if(N){m(null),y(!1),w(""),C(!0);try{const pe={repo:N.githubUrl||`https://github.com/mastra-ai/template-${N.slug}`,ref:$,slug:N.slug,variables:u},{runId:le}=await L({});w(le),n(ve=>{const ye=new URLSearchParams(ve);return ye.set("runId",le),ye.set("resume","true"),ye.set("provider",r||"openai"),ye}),await M.mutateAsync({inputData:pe,selectedModel:{provider:a,modelId:l},runId:le})}catch(ce){C(!1),m(ce?.message||"Template installation failed"),console.error("Template installation failed",ce)}}},Y=ne=>{const{name:ce,value:pe}=ne.target;pe.trim()===""?p(le=>[...le,ce]):p(le=>le.filter(ve=>ve!==ce)),d(le=>({...le,[ce]:pe}))};return o.jsx(cs,{children:o.jsx("div",{className:K("w-full lg:px-12 h-full overflow-y-scroll"),children:o.jsxs("div",{className:"p-6 w-full max-w-[80rem] mx-auto grid gap-y-4",children:[o.jsx(Rrs,{isLoading:I,title:N?.title,description:N?.longDescription,imageURL:N?.imageURL,githubUrl:N?.githubUrl,infoData:te,templateSlug:e}),N&&o.jsxs(o.Fragment,{children:[(U||Z)&&o.jsx(Lrs,{name:N.title,streamResult:Z?q:G,runId:b,workflowInfo:V}),g&&o.jsx(Frs,{name:N.title,installedEntities:J,linkComponent:ci}),h&&o.jsx(Irs,{errorMsg:h,validationErrors:E.length>0?E:G?.validationResults?.errors||q?.validationResults?.errors}),!U&&!Z&&!g&&!h&&o.jsx(Ars,{providerOptions:X,selectedProvider:r,onProviderChange:ee,variables:u,setVariables:d,errors:f,setErrors:p,handleInstallTemplate:de,handleVariableChange:Y,isLoadingEnvVars:D||W,isInstalling:z,defaultModelProvider:a,defaultModelId:l,onModelUpdate:ae})]})]})})})}const Brs=()=>{const{toolId:e,agentId:t}=dr();return o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(PWr,{toolId:e,agentId:t})})},Urs=()=>{const{toolId:e}=dr();return o.jsx("div",{className:"h-full w-full overflow-y-hidden",children:o.jsx(hns,{toolId:e})})};function qrs(){const{traceId:e}=dr(),[t,n]=ji(),r=bs(),s=t.get("spanId")||void 0,a=t.get("tab"),i=a==="scoring"?"scoring":a==="feedback"?"feedback":"details",l=t.get("scoreId")||void 0,[c,u]=v.useState(s??null),[d,f]=v.useState(),[p,h]=v.useState(i),[m,g]=v.useState(0),[y,b]=v.useState(!1),{data:w,isLoading:S,error:k}=HH(e),_=v.useMemo(()=>w?.spans??[],[w?.spans]),C=v.useMemo(()=>_.find(ae=>ae.parentSpanId==null),[_]),{data:E,isLoading:j}=aI(e,c??"");v.useEffect(()=>g(0),[e,c]);const{data:N,isLoading:I}=eh(),{data:R,isLoading:$}=ELt({traceId:e,spanId:c??void 0,page:m}),[F,D]=v.useState(0);v.useEffect(()=>D(0),[e,c]);const{data:V,isLoading:W}=e8t({traceId:e,page:F});v.useEffect(()=>{if(l&&R?.scores&&!d){const ae=R.scores.find(de=>de.id===l);ae&&f(ae)}},[l,R?.scores,d]);const L=v.useCallback(ae=>{const de=new URLSearchParams(t);for(const[Y,ne]of Object.entries(ae))ne===null||ne===""?de.delete(Y):de.set(Y,ne);n(de,{replace:!0})},[t,n]),z=v.useCallback(ae=>{const de=ae??null,Y=de===c;u(de),Y||(f(void 0),h("details"),L({spanId:de,tab:null,scoreId:null}))},[c,L]),B=v.useCallback(()=>{u(null),f(void 0),h("details"),L({spanId:null,tab:null,scoreId:null})},[L]),M=v.useCallback(ae=>{u(ae),f(void 0),h("details"),L({spanId:ae,tab:null,scoreId:null})},[L]),{handlePreviousSpan:G,handleNextSpan:U}=WH(_,c,M),P=v.useCallback(ae=>{const de=ae;h(de),f(void 0),L({tab:de==="details"?null:de,scoreId:null})},[L]),q=v.useCallback(ae=>{f(ae),L({scoreId:ae.id})},[L]),Z=v.useCallback(()=>{f(void 0),L({scoreId:null})},[L]),X=v.useCallback(()=>{r("/observability")},[r]),te=v.useCallback(()=>{h("scoring"),C&&c!==C.spanId?(u(C.spanId),f(void 0),L({spanId:C.spanId,tab:"scoring",scoreId:null})):L({tab:"scoring"})},[C,c,L]),J=C?o.jsx(Ty,{owner:"trace-detail",children:o.jsxs($r,{children:[o.jsxs(ue,{tooltip:"Evaluate Trace","aria-label":"Evaluate Trace",onClick:te,children:[o.jsx(Mln,{}),"Evaluate"]}),o.jsxs(ue,{tooltip:"Save as Dataset Item","aria-label":"Save as Dataset Item",onClick:()=>b(!0),children:[o.jsx(fd,{}),"Save"]})]})}):null,ee=C?o.jsx(Lt.Row,{children:o.jsx(Lt.Column,{children:o.jsx(H6t,{rootSpan:C,numOfCol:3})})}):null;return k?o.jsxs(Lt,{height:"full",children:[J,ee&&o.jsx(Lt.TopArea,{children:ee}),o.jsx(Lt.MainArea,{isCentered:!0,children:o.jsx(W6t,{error:k,resource:"traces",errorTitle:"Failed to load trace"})})]}):o.jsxs(Lt,{children:[J,ee&&o.jsx(Lt.TopArea,{children:ee}),o.jsx(Q6t,{rootSpanId:C?.spanId,traceId:e,isOpen:y,onClose:()=>b(!1)}),o.jsxs("div",{className:K("grid h-full min-h-0 gap-4 overflow-hidden items-start mt-4",c?"grid-cols-[2fr_3fr]":"grid-cols-[1fr]"),children:[o.jsx(sTe,{traceId:e,spans:_,isLoading:S,onClose:X,onSpanSelect:z,onEvaluateTrace:te,initialSpanId:c,placement:"trace-page",timelineChartWidth:c?"default":"wide"}),c&&!S&&o.jsxs("div",{className:K("grid gap-4 max-h-full min-h-0 overflow-auto",d?"grid-rows-[1fr_1fr]":"grid-rows-[1fr]"),children:[o.jsx(qH,{traceId:e,spanId:c,span:E?.span,isLoading:j,onClose:B,onPrevious:G,onNext:U,activeTab:p,onTabChange:P,feedbackTabBadge:V?.pagination?.total??void 0,feedbackTabSlot:()=>o.jsx(X6t,{feedbackData:V,onPageChange:D,isLoadingFeedbackData:W}),scoringTabBadge:R?.pagination?.total??void 0,scoringTabSlot:({span:ae,traceId:de,spanId:Y})=>o.jsxs("div",{className:"grid gap-6",children:[o.jsx(J6t,{traceId:de,isTopLevelSpan:!ae.parentSpanId,spanId:Y,entityType:ae.attributes?.agentId||ae.entityType===Os.AGENT?"Agent":ae.attributes?.workflowId||ae.entityType===Os.WORKFLOW_RUN?"Workflow":void 0,scorers:N,isLoadingScorers:I}),o.jsx(K6t,{scoresData:R,onPageChange:g,isLoadingScoresData:$,onScoreSelect:q})]})}),d&&o.jsx(Ije,{score:d,onClose:Z})]})]})]})}function Vrs(){const{data:e,isLoading:t,error:n}=By(),[r,s]=v.useState("");return n&&gs(n)?o.jsx(lr,{children:o.jsx(Vs,{})}):n&&ys(n)?o.jsx(lr,{children:o.jsx(Ds,{resource:"workflows"})}):n?o.jsx(lr,{children:o.jsx(Fi,{title:"Failed to load workflows",message:n.message})}):Object.keys(e||{}).length===0&&!t?o.jsx(lr,{children:o.jsx(X$r,{})}):o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsxs(Lt.Row,{align:"center",stack:"responsive",children:[o.jsx("div",{className:"max-w-120 flex-1",children:o.jsx(Of,{onSearch:s,label:"Filter workflows",placeholder:"Filter by name or description"})}),o.jsxs(ue,{as:ci,to:"/workflows/schedules",variant:"primary",className:"shrink-0",children:[o.jsx(o3,{}),"Schedules"]})]})}),o.jsx(Y$r,{workflows:e||{},isLoading:t,search:r})]})}const Hrs={active:"bg-accent1",paused:"bg-accent3"},Wrs={active:"text-accent1",paused:"text-accent3"},y8t=({status:e})=>o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${Hrs[e]}`,"aria-hidden":!0}),o.jsx("span",{className:`text-ui-sm ${Wrs[e]}`,children:e})]}),Aj=e=>!e||e<=0?"—":new Date(e).toLocaleString(),sP=e=>{if(!e||e<=0)return"—";const t=e-Date.now(),n=Math.abs(t),r=Math.floor(n/1e3);if(r<60)return t>=0?`in ${r}s`:`${r}s ago`;const s=Math.floor(r/60);if(s<60)return t>=0?`in ${s}m`:`${s}m ago`;const a=Math.floor(s/60);if(a<24)return t>=0?`in ${a}h`:`${a}h ago`;const i=Math.floor(a/24);return t>=0?`in ${i}d`:`${i}d ago`};function b8t({status:e}){const{icon:t,color:n}=Zrs(e);return o.jsxs("span",{className:`inline-flex items-center gap-1.5 whitespace-nowrap text-ui-sm ${n}`,children:[o.jsx("span",{className:"inline-flex shrink-0 items-center","aria-hidden":!0,children:t}),o.jsx("span",{children:e})]})}function Zrs(e){switch(e){case"success":return{icon:o.jsx(Js,{size:14}),color:"text-accent1"};case"failed":return{icon:o.jsx(vs,{size:14}),color:"text-accent2"};case"running":return{icon:o.jsx(Gt,{}),color:"text-neutral3"};case"suspended":return{icon:o.jsx(ZU,{size:14}),color:"text-accent3"};case"canceled":return{icon:o.jsx(xf,{size:14}),color:"text-neutral3"};case"pending":case"waiting":return{icon:o.jsx(sO,{size:14}),color:"text-neutral3"};default:return{icon:null,color:"text-neutral3"}}}const CQe="auto auto auto auto 1fr";function Grs(e){if(e===void 0)return"—";if(e<1e3)return`${e}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;const t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${t}m ${n}s`}function Qrs(e){const t=Math.abs(e),n=e<0?"-":"";return t<1e3?`${n}${t}ms`:t<6e4?`${n}${(t/1e3).toFixed(1)}s`:t<36e5?`${n}${(t/6e4).toFixed(1)}m`:`${n}${(t/36e5).toFixed(1)}h`}const Yrs=3e4,Xrs=5*6e4;function Krs({triggers:e,isLoading:t,workflowId:n,hasNextPage:r,isFetchingNextPage:s,setEndOfListElement:a}){const{Link:i,paths:l}=yn();return t?o.jsx(el,{columns:CQe}):e.length===0?o.jsx(ge,{variant:"ui-md",className:"text-neutral4 p-4",children:"No trigger history yet."}):o.jsxs(me,{columns:CQe,className:"min-w-0",children:[o.jsxs(me.Top,{children:[o.jsx(me.TopCell,{children:"Run"}),o.jsx(me.TopCell,{children:"Status"}),o.jsx(me.TopCell,{children:"Started"}),o.jsx(me.TopCell,{children:"Duration"}),o.jsx(me.TopCell,{children:" "})]}),e.map(c=>{const u=c.actualFireAt-c.scheduledFireAt,d=Qrs(u),f=`Scheduled ${Aj(c.scheduledFireAt)} — published ${Aj(c.actualFireAt)} (drift ${d})`,p=c.outcome==="failed",h=p?c.error:c.run?.error,m=Math.abs(u),g=!p&&m>Yrs&&m<=Xrs,y=`${c.scheduleId}-${c.runId}-${c.actualFireAt}`,b=!!(n&&c.runId&&!p),w=o.jsx("span",{className:b?"text-accent1 font-mono text-ui-sm whitespace-nowrap":"text-neutral3 font-mono text-ui-sm whitespace-nowrap",children:c.runId}),S=o.jsxs(o.Fragment,{children:[o.jsx(me.Cell,{height:"compact",children:w}),o.jsx(me.Cell,{height:"compact",children:o.jsxs("span",{className:"inline-flex items-center gap-2",children:[p?o.jsxs("span",{className:"inline-flex items-center gap-1.5 whitespace-nowrap text-ui-sm text-accent2",children:[o.jsx(kp,{size:14}),"publish failed"]}):c.run?o.jsx(b8t,{status:c.run.status}):o.jsx("span",{className:"inline-flex items-center gap-1.5 whitespace-nowrap text-ui-sm text-neutral3",children:"pending"}),h?o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx("span",{className:"text-accent2 inline-flex",children:o.jsx(kp,{size:14})})}),o.jsx(Bn,{children:h})]}):null]})}),o.jsx(me.Cell,{height:"compact",children:o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx("span",{title:f,children:sP(c.actualFireAt)}),g?o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx("span",{className:"text-accent3 inline-flex",children:o.jsx(kp,{size:14})})}),o.jsxs(Bn,{children:["Published ",d," after the scheduled fire time"]})]}):null]})}),o.jsx(me.Cell,{height:"compact",children:c.run?o.jsx("span",{children:Grs(c.run.durationMs)}):o.jsx("span",{className:"text-neutral4",children:"—"})}),o.jsx(me.Cell,{height:"compact",children:" "})]});return b?o.jsx(me.RowLink,{to:l.workflowRunLink(n,c.runId),LinkComponent:i,children:S},y):o.jsx(me.RowStatic,{children:S},y)}),o.jsx(me.NextPageLoading,{isLoading:s,hasMore:r,setEndOfListElement:a})]})}const Jrs=e=>{const t=We();return wt({queryKey:["schedule",e],enabled:!!e,queryFn:async()=>{if(!e)throw new Error("scheduleId is required");return t.getSchedule(e)}})},EQe=25,ess=e=>{const t=We(),{inView:n,setRef:r}=__(),s=R1({queryKey:["schedule-triggers",e],enabled:!!e,initialPageParam:void 0,queryFn:async({pageParam:u})=>e?t.listScheduleTriggers(e,{limit:EQe,toActualFireAt:u}):{triggers:[]},getNextPageParam:u=>{if(!(!u?.triggers?.length||u.triggers.length<EQe))return u.triggers[u.triggers.length-1].actualFireAt},refetchInterval:u=>(u.state.data?.pages.flatMap(p=>p.triggers)??[]).some(p=>p.run?p.run.status==="pending"||p.run.status==="running"||p.run.status==="waiting":p.outcome==="published")?5e3:!1}),a=s.data?.pages.flatMap(u=>u?.triggers??[])??[],{hasNextPage:i,isFetchingNextPage:l,fetchNextPage:c}=s;return v.useEffect(()=>{n&&i&&!l&&c()},[n,i,l,c]),{...s,data:a,setEndOfListElement:r}},tss=e=>{const t=We(),n=Hr();return Rn({mutationFn:async r=>{if(!e)throw new Error("scheduleId is required");return r==="pause"?t.pauseSchedule(e):t.resumeSchedule(e)},onSuccess:(r,s)=>{n.invalidateQueries({queryKey:["schedule",e]}),n.invalidateQueries({queryKey:["schedules"]}),De.success(s==="pause"?"Schedule paused":"Schedule resumed")},onError:r=>{De.error(r.message)}})};function K8({label:e,children:t}){return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 uppercase tracking-wide",children:e}),o.jsx("div",{className:"text-ui-md",children:t})]})}function nss(){const{scheduleId:e}=dr(),{paths:t}=yn(),{data:n,error:r}=Jrs(e),{data:s,isLoading:a,error:i,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u}=ess(e),d=tss(e);if(r&&gs(r))return o.jsx(lr,{children:o.jsx(Vs,{})});if(r&&ys(r))return o.jsx(lr,{children:o.jsx(Ds,{resource:"schedules"})});if(r)return o.jsx(lr,{children:o.jsx(Fi,{title:"Failed to load schedule",message:r.message})});const f=n?.target.type==="workflow"?n.target.workflowId:void 0;return o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx(Lt.Row,{className:"justify-end",children:o.jsxs(Lt.Column,{className:"flex justify-end gap-2",children:[o.jsxs(ue,{as:ci,to:t.schedulesLink(),variant:"ghost",children:[o.jsx(Ec,{}),"Back to schedules"]}),f?o.jsx(ue,{as:ci,to:t.workflowLink(f),variant:"ghost",children:"Open workflow"}):null,n?o.jsx(ue,{onClick:()=>d.mutate(n.status==="active"?"pause":"resume"),disabled:d.isPending,"data-testid":"schedule-toggle-button",children:n.status==="active"?o.jsxs(o.Fragment,{children:[o.jsx(Tlt,{}),"Pause"]}):o.jsxs(o.Fragment,{children:[o.jsx(Pp,{}),"Resume"]})}):null]})})}),n?o.jsxs("div",{className:"grid gap-6 h-full overflow-hidden grid-cols-[minmax(0,20rem)_1fr]",children:[o.jsxs("div",{className:"flex flex-col gap-4 border border-border1 rounded-md p-4 h-fit",children:[o.jsx(K8,{label:"Workflow",children:f?o.jsx(ci,{to:t.workflowLink(f),className:"text-accent1 hover:underline",children:f}):"—"}),o.jsxs(K8,{label:"Cron",children:[o.jsx("code",{className:"font-mono text-ui-md",children:n.cron}),n.timezone?o.jsx("span",{className:"text-neutral4 ml-2 text-ui-sm",children:n.timezone}):null]}),o.jsx(K8,{label:"Status",children:o.jsx(y8t,{status:n.status})}),o.jsx(K8,{label:"Next fire",children:o.jsx("span",{title:Aj(n.nextFireAt),children:sP(n.nextFireAt)})})]}),o.jsxs("div",{className:"overflow-y-auto","data-testid":"schedule-triggers-panel",children:[o.jsx(ge,{variant:"ui-md",className:"mb-3",children:"Trigger history"}),i?o.jsx(Fi,{title:"Failed to load trigger history",message:i.message}):o.jsx(Krs,{triggers:s??[],isLoading:a,workflowId:f,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u})]})]}):null]})}const jQe="minmax(0, 1.2fr) minmax(0, 1.4fr) minmax(0, 1fr) auto auto auto";function rss({schedules:e,isLoading:t,search:n=""}){const{paths:r,Link:s}=yn(),a=v.useMemo(()=>{const i=n.toLowerCase();return i?e.filter(l=>l.id.toLowerCase().includes(i)||l.target.workflowId.toLowerCase().includes(i)):e},[e,n]);return t?o.jsx(el,{columns:jQe}):o.jsxs(me,{columns:jQe,variant:"striped",className:"min-w-0",children:[o.jsxs(me.Top,{children:[o.jsx(me.TopCell,{children:"Workflow"}),o.jsx(me.TopCell,{children:"Schedule ID"}),o.jsx(me.TopCell,{children:"Cron"}),o.jsx(me.TopCell,{children:"Status"}),o.jsx(me.TopCell,{children:"Next fire"}),o.jsx(me.TopCell,{children:"Last run"})]}),a.length===0&&n?o.jsx(me.NoMatch,{message:"No schedules match your search"}):null,a.length===0&&!n?o.jsx(me.NoMatch,{message:"No schedules configured"}):null,a.map(i=>o.jsxs(me.RowLink,{to:r.scheduleLink(i.id),LinkComponent:s,children:[o.jsx(me.NameCell,{children:i.target.workflowId}),o.jsx(me.Cell,{height:"compact",className:"min-w-0",children:o.jsx("span",{className:"block truncate font-mono text-ui-smd text-neutral3",title:i.id,children:i.id})}),o.jsx(me.Cell,{height:"compact",children:o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx("code",{className:"font-mono text-ui-sm",children:i.cron}),i.timezone?o.jsx("span",{className:"text-neutral4 text-ui-xs",children:i.timezone}):null]})}),o.jsx(me.Cell,{height:"compact",children:o.jsx(y8t,{status:i.status})}),o.jsx(me.Cell,{height:"compact",children:o.jsx("span",{className:"whitespace-nowrap",title:Aj(i.nextFireAt),children:sP(i.nextFireAt)})}),o.jsx(me.Cell,{height:"compact",children:i.lastRun?o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx(b8t,{status:i.lastRun.status}),o.jsx("span",{className:"text-neutral4 text-ui-sm",title:Aj(i.lastFireAt),children:i.lastFireAt?sP(i.lastFireAt):""})]}):i.lastFireAt?o.jsx("span",{className:"whitespace-nowrap",title:Aj(i.lastFireAt),children:sP(i.lastFireAt)}):o.jsx("span",{className:"text-neutral4",children:"Never"})})]},i.id))]})}function sss({workflowId:e}={}){const{data:t,isLoading:n,error:r}=Bxe(e?{workflowId:e}:{}),[s,a]=v.useState("");return r?o.jsx(Fi,{title:"Failed to load schedules",message:r.message}):o.jsxs("div",{className:"grid grid-rows-[auto_1fr] gap-4 h-full overflow-hidden",children:[o.jsx("div",{className:"max-w-120",children:o.jsx(Of,{onSearch:a,label:"Filter schedules",placeholder:"Filter by id or workflow"})}),o.jsx("div",{className:"overflow-y-auto",children:o.jsx(rss,{schedules:t??[],isLoading:n,search:s})})]})}function ass(){const[e]=ji(),t=e.get("workflowId")??void 0,{error:n}=Bxe(t?{workflowId:t}:{});return n&&gs(n)?o.jsx(lr,{children:o.jsx(Vs,{})}):n&&ys(n)?o.jsx(lr,{children:o.jsx(Ds,{resource:"schedules"})}):o.jsx(Lt,{children:o.jsx("div",{className:"h-full",children:o.jsx(sss,{workflowId:t})})})}function iss({stepGraph:e,open:t,workflowName:n}){const{nodes:r,edges:s}=b1e({stepGraph:e}),[a,i]=v.useState(!1),[l,c,u]=Q0t(r),[d]=Y0t(s),{edgeTypes:f,nodeTypes:p,styledEdges:h}=WRt({edges:d,workflowName:n,stepGraph:e});return v.useEffect(()=>{if(t){const m=setTimeout(()=>{i(!0)},500);return()=>clearTimeout(m)}},[t]),o.jsx("div",{className:"w-full h-full relative bg-surface1",children:a?o.jsxs(G0t,{nodes:l,edges:h,edgeTypes:f,fitView:!0,fitViewOptions:{maxZoom:1},minZoom:.01,maxZoom:1,nodeTypes:p,onNodesChange:u,children:[o.jsx(I_e,{position:"bottom-left"}),o.jsx(K0t,{variant:Kv.Lines,gap:12,size:.5})]}):o.jsx("div",{className:"w-full h-full flex items-center justify-center",children:o.jsx(Gt,{})})})}function oss(){const{stepDetail:e,closeStepDetail:t}=RV();return e?o.jsxs("div",{className:"flex flex-col h-full","data-testid":"workflow-step-detail-panel",children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border1 bg-surface1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[e.type==="map-config"&&o.jsx(Lde,{className:"w-4 h-4",style:{color:xu.map}}),e.type==="nested-graph"&&o.jsx(kd,{className:"w-4 h-4",style:{color:xu.workflow}}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx(ge,{variant:"ui-md",className:"text-neutral6 font-medium",children:e.type==="map-config"?`${e.stepName} Config`:`${e.stepName} Workflow`}),e.type==="map-config"&&e.stepId&&e.stepId!==e.stepName&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral3",children:e.stepId})]})]}),o.jsx("button",{onClick:t,className:"p-1 hover:bg-surface3 rounded transition-colors","aria-label":"Close",children:o.jsx(vs,{className:"w-4 h-4 text-neutral3"})})]}),o.jsxs("div",{className:"flex-1 overflow-auto",children:[e.type==="map-config"&&e.mapConfig&&o.jsx(J2,{data:e.mapConfig}),e.type==="nested-graph"&&e.nestedGraph&&o.jsx("div",{className:"h-full min-h-[400px]",children:o.jsx(y1e,{children:o.jsx(iss,{stepGraph:e.nestedGraph.stepGraph,open:!0,workflowName:e.nestedGraph.fullStep})},`nested-graph-${e.nestedGraph.fullStep}`)})]})]}):null}function lss(e){const t=new Blob([JSON.stringify(e??null)]).size;return t<1024?`${t} B`:`${(t/1024).toFixed(1)} KB`}function css(e,t){if(e&&typeof e=="object"&&!Array.isArray(e)){const n=Object.keys(e);if(n.length===1)return n[0]}return t}function uss({suspendedSteps:e,workflow:t,isStreaming:n,onResume:r}){return n||e.length===0?null:o.jsxs("div",{className:"space-y-5 rounded-lg border border-border1 bg-surface4 p-5","data-testid":"workflow-suspended-steps",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs(ge,{as:"p",variant:"ui-md",className:"flex items-center gap-2 text-neutral6 font-semibold",children:[o.jsx(Ue,{children:o.jsx(ZU,{})}),"Step suspended"]}),o.jsx(fn,{variant:"warning",children:"Needs input"})]}),e.map((s,a)=>{const i=t.allSteps[s.stepId];if(!i||i.isWorkflow)return null;const l=i?.resumeSchema?im(sm(mx(i.resumeSchema))):rp(ur(),nT());return o.jsx(dss,{step:s,stepSchema:l,description:i.description,isStreaming:n,onResume:r},`${s.runId}-${s.stepId}-${a}`)})]})}function dss({step:e,stepSchema:t,description:n,isStreaming:r,onResume:s}){const[a,i]=v.useState(!1);return o.jsxs("div",{className:"space-y-5",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ge,{as:"p",variant:"ui-md",className:"text-neutral6 font-medium truncate",children:e.stepId}),n&&o.jsx(ge,{as:"p",variant:"ui-sm",className:"text-neutral3",children:n})]}),e.suspendPayload&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ge,{as:"p",variant:"ui-sm",className:"flex items-center gap-2 text-neutral3",children:[o.jsx(Ue,{children:o.jsx(Wun,{})}),"The step is asking"]}),o.jsxs(Lp,{open:a,onOpenChange:i,children:[o.jsxs(mf,{className:"flex w-full items-center justify-between gap-2 rounded-lg border border-border1 bg-surface3 px-3 py-2.5",children:[o.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[o.jsx(Ue,{children:o.jsx(la,{className:K("transition-transform text-neutral3",{"transform rotate-90":a})})}),o.jsx(ge,{as:"span",variant:"ui-md",className:"text-neutral6 truncate",children:css(e.suspendPayload,e.stepId)})]}),o.jsx(ge,{as:"span",variant:"ui-sm",className:"text-neutral3 shrink-0",children:lss(e.suspendPayload)})]}),o.jsx(gf,{children:o.jsx("div",{"data-testid":"suspended-payload",className:"pt-2",children:o.jsx(Qr,{data:e.suspendPayload,className:"w-full overflow-x-auto p-2",showCopyButton:!1})})})]})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs(ge,{as:"p",variant:"ui-sm",className:"flex items-center gap-2 text-neutral3",children:[o.jsx(Ue,{children:o.jsx(Qun,{})}),"Your response"]}),o.jsx("div",{className:"-mx-5",children:o.jsx(C7,{schema:t,isSubmitLoading:r,submitButtonLabel:"Resume",submitButtonIcon:o.jsx(Pp,{}),submitButtonFullWidth:!0,collapsible:!1,hideHeading:!0,hideInputTypeLabel:!0,onSubmit:l=>{const c=e.stepId?.split(".");s({stepId:c,runId:e.runId,suspendPayload:e.suspendPayload,resumeData:l,isLoading:!1})}})})]})]})}function fss(){const{result:e,runSnapshot:t,workflow:n,runId:r,isStreamingWorkflow:s}=v.useContext(Rl),{runId:a}=dr(),i=awt(e,r??""),l=sZn(),c=!!a,u=t?.status==="suspended",f=!!(a&&r&&a===r)&&e?.status==="suspended";return s||!n||i.length===0||c&&!u&&!f?null:o.jsx("div",{"data-testid":"workflow-suspended-overlay",className:"absolute top-2 right-2 z-20 w-[380px] max-w-[calc(100%-1rem)] max-h-[calc(100%-1rem)] overflow-y-auto rounded-lg shadow-lg animate-in fade-in-0 slide-in-from-top-2 zoom-in-95 duration-300",children:o.jsx(uss,{suspendedSteps:i,workflow:n,isStreaming:s,onResume:l})},r)}const pss=e=>o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.99982 2.0625C3.8252 2.0625 2.06232 3.82538 2.06232 6C2.06232 8.17462 3.8252 9.9375 5.99982 9.9375C8.17444 9.9375 9.93732 8.17462 9.93732 6C9.93732 3.82538 8.17444 2.0625 5.99982 2.0625ZM0.937317 6C0.937317 3.20406 3.20388 0.9375 5.99982 0.9375C8.79576 0.9375 11.0623 3.20406 11.0623 6C11.0623 8.79594 8.79576 11.0625 5.99982 11.0625C3.20388 11.0625 0.937317 8.79594 0.937317 6Z",fill:"currentColor"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.97865 4.57004C8.22604 4.75795 8.27426 5.11082 8.08635 5.35821L6.05486 8.03279C5.94873 8.17251 5.78348 8.25471 5.60803 8.25505C5.43257 8.2554 5.267 8.17385 5.16032 8.03454L3.80937 6.27034C3.6205 6.02369 3.66733 5.67063 3.91398 5.48176C4.16063 5.29288 4.51369 5.33972 4.70257 5.58637L5.6051 6.76498L7.19048 4.67774C7.37839 4.43036 7.73126 4.38213 7.97865 4.57004Z",fill:"currentColor"})]}),hss=e=>o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.99982 2.0625C3.8252 2.0625 2.06232 3.82538 2.06232 6C2.06232 8.17462 3.8252 9.9375 5.99982 9.9375C8.17444 9.9375 9.93732 8.17462 9.93732 6C9.93732 3.82538 8.17444 2.0625 5.99982 2.0625ZM0.937317 6C0.937317 3.20406 3.20388 0.9375 5.99982 0.9375C8.79576 0.9375 11.0623 3.20406 11.0623 6C11.0623 8.79594 8.79576 11.0625 5.99982 11.0625C3.20388 11.0625 0.937317 8.79594 0.937317 6Z",fill:"currentColor"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.89741 4.10293C8.11707 4.32261 8.11706 4.67877 7.89738 4.89843L6.79517 6.00058L7.8962 7.10155C8.11588 7.32122 8.11589 7.67737 7.89623 7.89705C7.67656 8.11673 7.32041 8.11674 7.10073 7.89707L5.99965 6.79605L4.89856 7.89707C4.67889 8.11673 4.32273 8.11672 4.10307 7.89704C3.88341 7.67737 3.88342 7.32121 4.10309 7.10155L5.20413 6.00058L4.10191 4.89843C3.88224 4.67877 3.88223 4.32262 4.10189 4.10294C4.32155 3.88326 4.67771 3.88325 4.89738 4.10292L5.99965 5.20511L7.10191 4.10291C7.32159 3.88325 7.67774 3.88326 7.89741 4.10293Z",fill:"currentColor"})]}),mss=e=>e.includes("."),gss=e=>e==="input"||e.endsWith(".input"),vss=1;function yss(e){return`${Number((e/1e3).toPrecision(3))}s`}function bss(e,t){const n=Object.entries(e).filter(([i])=>!gss(i));if(n.length===0)return[];const r=Math.min(...n.map(([,i])=>i.startedAt)),s=Math.max(...n.map(([,i])=>i.endedAt??t)),a=Math.max(s-r,1);return n.map(([i,l])=>{const c=l.endedAt===void 0,d=(l.endedAt??t)-l.startedAt,f=(l.startedAt-r)/a*100,p=Math.max(d/a*100,vss);return{stepId:i,step:l,status:l.status,offsetPct:f,widthPct:p,durationMs:d,isRunning:c,isNestedEntry:mss(i)}})}const xss=({status:e})=>o.jsxs(Ue,{children:[e==="success"&&o.jsx(pss,{className:"text-accent1"}),e==="failed"&&o.jsx(hss,{className:"text-accent2"}),e==="suspended"&&o.jsx(ZU,{className:"text-accent3"}),e==="waiting"&&o.jsx(Dde,{className:"text-accent5"}),e==="skipped"&&o.jsx(Dde,{className:"text-icon3"}),e==="running"&&o.jsx(ia,{className:"text-accent6 animate-spin"})]}),wss={success:"bg-accent1",failed:"bg-accent2",suspended:"bg-accent3",waiting:"bg-accent5",skipped:"bg-border1",running:"bg-accent6"};function x8t(e){return e.split(/[-_.\s]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}const TQe=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{value:e},Sss=e=>{const t=e;return DRt({duration:t.duration,date:t.date,isForEach:t.isForEach,mapConfig:t.mapConfig,canSuspend:t.canSuspend,isParallel:t.isParallel,stepGraph:t.stepGraph})},kss=({row:e,index:t,isSelected:n,isHovered:r,onSelectStep:s,onHoverStep:a,onOpenInput:i,onOpenOutput:l})=>{const c=Sss(e.step),u=e.status==="running",d=!e.isNestedEntry;return o.jsxs("div",{role:"button",tabIndex:0,"data-testid":"workflow-timeline-row","data-workflow-step-key":e.stepId,"data-workflow-step-active":n?"true":void 0,"data-workflow-step-hovered":r?"true":void 0,"data-workflow-step-nested":e.isNestedEntry?"true":void 0,"aria-pressed":n,"aria-disabled":!d,onMouseEnter:()=>{d&&a(e.stepId)},onMouseLeave:()=>{d&&a(null)},onClick:()=>{d&&s(e.stepId)},onKeyDown:f=>{!d||f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),s(e.stepId))},className:K("grid grid-cols-[auto_auto_auto_minmax(0,10rem)_minmax(0,1fr)_auto_5rem] items-center gap-2 rounded-md border border-transparent px-2 py-1 text-left transition-colors focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-accent1",d&&"cursor-pointer",d&&"hover:bg-surface4",d&&r&&!n&&"border-neutral6 bg-surface4",d&&n&&"border-accent1",e.isNestedEntry&&"cursor-default opacity-55"),children:[o.jsx("div",{className:"flex justify-center",children:o.jsx(xss,{status:e.status})}),o.jsx("div",{className:"flex justify-center",children:o.jsx(ue,{type:"button",variant:"ghost",size:"icon-sm",tooltip:"View step input",disabled:u,className:"text-neutral3 hover:text-neutral6 disabled:cursor-not-allowed disabled:opacity-40",onClick:f=>{f.stopPropagation(),u||i(e)},children:o.jsx(Zdn,{})})}),o.jsx("div",{className:"flex overflow-hidden",children:o.jsx(JB,{indicators:c,className:"shrink-0"})}),o.jsx(ge,{as:"span",variant:"ui-sm",className:"block min-w-0 max-w-full justify-self-stretch overflow-hidden text-ellipsis whitespace-nowrap text-left text-neutral6",children:x8t(e.stepId)}),o.jsx("div",{className:"relative h-2 min-w-0 rounded bg-surface4",children:o.jsx("div",{"data-testid":"workflow-timeline-bar","data-offset":String(e.offsetPct),"data-width":String(e.widthPct),className:`absolute top-0 h-full rounded ${wss[e.status]}`,style:{left:`${e.offsetPct}%`,width:`${e.widthPct}%`}})}),o.jsx("div",{className:"flex justify-center",children:o.jsx(ue,{type:"button",variant:"ghost",size:"icon-sm",tooltip:"View step output",disabled:u,className:"text-neutral3 hover:text-neutral6 disabled:cursor-not-allowed disabled:opacity-40",onClick:f=>{f.stopPropagation(),u||l(e)},children:o.jsx(Hdn,{})})}),o.jsx(ge,{as:"span",variant:"ui-sm",className:"w-20 justify-self-end text-right text-neutral3 tabular-nums",children:yss(e.durationMs)})]},`timeline-item-${e.stepId}-${t}`)};function Oss(){const{steps:e}=JD(),{selectedStepId:t,hoverStepId:n,setSelectedStepId:r,setHoverStepId:s}=Vq(),[a,i]=v.useState(()=>Date.now()),[l,c]=v.useState(!1),[u,d]=v.useState(null),f=v.useRef(null);Qxe(f,{enabled:!l});const p=bss(e,a),h=p.some(m=>m.isRunning);return v.useEffect(()=>{if(!h)return;const m=setInterval(()=>i(Date.now()),100);return()=>clearInterval(m)},[h]),v.useEffect(()=>{if(l||p.length===0)return;const m=f.current;m&&(m.scrollTop=m.scrollHeight)},[l,p.length]),p.length===0?null:o.jsxs(o.Fragment,{children:[o.jsx("div",{"data-testid":"workflow-timeline",className:"pointer-events-none absolute right-0 bottom-0 z-20 px-2 pb-2",style:{left:"var(--workflow-left-panel-width, 0px)"},children:o.jsxs("div",{className:"pointer-events-auto flex max-h-64 w-full min-w-0 flex-col gap-3 overflow-hidden rounded-studio-panel border border-border1/50 bg-surface3 p-4 shadow-lg",children:[o.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3",children:[o.jsx(ge,{as:"p",variant:"ui-md",className:"text-neutral3",children:"Timeline"}),o.jsx("button",{type:"button","aria-label":l?"Expand timeline":"Collapse timeline","aria-expanded":!l,onClick:()=>c(m=>!m),className:"rounded-md p-1 text-neutral3 transition-colors hover:bg-surface4 hover:text-neutral6",children:o.jsx(Na,{className:K("h-4 w-4 transition-transform",l&&"-rotate-90")})})]}),!l&&o.jsx("div",{ref:f,"data-testid":"workflow-timeline-list",className:"flex min-h-0 flex-col gap-2 overflow-y-auto",children:p.map((m,g)=>o.jsx(kss,{row:m,index:g,isSelected:t===m.stepId,isHovered:n===m.stepId,onSelectStep:r,onHoverStep:s,onOpenInput:y=>d({type:"input",stepId:y.stepId,data:TQe(y.step.input)}),onOpenOutput:y=>d({type:"output",stepId:y.stepId,data:TQe(y.step.output)})},`timeline-item-${m.stepId}-${g}`))})]})}),o.jsx(br,{open:!!u,onOpenChange:m=>!m&&d(null),children:u&&o.jsx(owt,{data:u.data,title:`${x8t(u.stepId)} ${u.type==="input"?"input":"output"}`})})]})}const _ss=({workflowId:e,workflow:t,isLoading:n})=>{const{stepDetail:r}=RV();return o.jsxs("div",{className:"flex h-full min-h-0",children:[o.jsx("div",{className:"flex h-full min-h-0 flex-1 flex-col",children:o.jsxs("div",{className:"relative min-h-0 flex-1 p-2 pb-0",children:[o.jsx(e2t,{workflowId:e,workflow:t,isLoading:n}),o.jsx(fss,{}),o.jsx(Oss,{})]})}),r&&o.jsx("div",{className:"w-[420px] min-h-0 overflow-hidden border-l border-border1",children:o.jsx(oss,{})})]})},NQe=()=>{const{workflowId:e}=dr(),{data:t,isLoading:n,error:r}=hD(e);return r&&gs(r)?o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})}):r&&ys(r)?o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ds,{resource:"workflows"})}):o.jsx(L1e,{children:o.jsx(_ss,{workflowId:e,workflow:t??void 0,isLoading:n})})};function Css(e,t){if(e==null)return{};var n,r,s=dbt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function Pve(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ess(e){if(Array.isArray(e))return Pve(e)}function jss(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Tss(e,t){if(e){if(typeof e=="string")return Pve(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Pve(e,t):void 0}}function Nss(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
727
|
+
]`})]})]})}function ies({errors:e,maxErrors:t=5}){if(e.length===0)return null;const n=e.slice(0,t),r=e.length-t;return o.jsxs("div",{className:"bg-accent2/10 border border-accent2/30 rounded-md p-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-accent2 mb-2",children:[o.jsx(Ue,{children:o.jsx(kp,{className:"w-4 h-4"})}),o.jsxs("span",{className:"font-medium text-sm",children:[e.length," validation error",e.length!==1?"s":""]})]}),o.jsx("ul",{className:"text-sm text-accent2/80 space-y-1",children:n.map((s,a)=>o.jsxs("li",{className:"flex gap-2",children:[o.jsx("span",{className:"shrink-0",children:"•"}),o.jsx("span",{children:s.message})]},a))}),r>0&&o.jsxs("div",{className:"text-xs text-accent2/60 mt-2",children:["+",r," more error",r!==1?"s":""]})]})}function oes({datasetId:e,open:t,onOpenChange:n,onSuccess:r}){const[s,a]=v.useState("upload"),[i,l]=v.useState(null),[c,u]=v.useState({current:0,total:0}),[d,f]=v.useState(null),[p,h]=v.useState(!1),{parseFile:m,isParsing:g,error:y}=RKr(),{batchInsertItems:b}=_i(),w=v.useCallback(async I=>{try{const R=await m(I);l(R),a("preview")}catch{}},[m]),S=v.useCallback(async()=>{if(!i||i.items.length===0)return;a("importing"),h(!0);const{items:I}=i;u({current:0,total:I.length});try{await b.mutateAsync({datasetId:e,items:I.map(R=>({input:R.input,groundTruth:R.groundTruth,metadata:R.metadata}))}),f({success:I.length,errors:0})}catch{f({success:0,errors:I.length})}u({current:I.length,total:I.length}),h(!1),a("complete")},[i,b,e]),k=v.useCallback(()=>{n(!1),r?.(),d&&d.success>0&&De.success(`Imported ${d.success} item${d.success!==1?"s":""}`),setTimeout(()=>{a("upload"),l(null),u({current:0,total:0}),f(null)},150)},[n,r,d]),_=v.useCallback(()=>{p||(n(!1),setTimeout(()=>{a("upload"),l(null),u({current:0,total:0}),f(null)},150))},[p,n]),C=i&&i.items.length>0&&i.errors.length===0,E=()=>{switch(s){case"upload":return o.jsx(aes,{onFileSelect:w,isParsing:g,error:y?.message});case"preview":return i?o.jsx("div",{className:"flex flex-col gap-4",children:i.errors.length>0?o.jsxs(o.Fragment,{children:[o.jsx(ies,{errors:i.errors}),o.jsx("div",{className:"text-sm text-neutral4",children:"Please fix the errors in your JSON file and try again."})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"text-sm text-neutral4",children:["Found ",i.items.length," valid item",i.items.length!==1?"s":""," to import."]}),o.jsx(ses,{items:i.items,maxRows:5})]})}):null;case"importing":return o.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[o.jsx(Gt,{}),o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-lg font-medium text-neutral1",children:"Importing items..."}),o.jsxs("div",{className:"text-sm text-neutral4 mt-1",children:[c.current," of ",c.total]})]})]});case"complete":return o.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[o.jsx("div",{className:"text-4xl",children:d&&d.errors===0?"✓":"⚠"}),o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-lg font-medium text-neutral1",children:"Import Complete"}),o.jsxs("div",{className:"text-sm text-neutral4 mt-1",children:[d?.success??0," item",d?.success!==1?"s":""," imported",d&&d.errors>0&&o.jsxs("span",{className:"text-accent2",children:[" ","(",d.errors," error",d.errors!==1?"s":"",")"]})]})]})]})}},j=()=>{switch(s){case"upload":return o.jsx(ue,{onClick:_,children:"Cancel"});case"preview":return o.jsxs(o.Fragment,{children:[o.jsx(ue,{onClick:()=>a("upload"),children:"Back"}),o.jsxs(ue,{variant:"primary",onClick:S,disabled:!C,children:["Import ",i?.items.length??0," Item",i?.items.length!==1?"s":""]})]});case"importing":return null;case"complete":return o.jsx(ue,{variant:"primary",onClick:k,children:"Done"})}},N={upload:"Import JSON",preview:"Preview Data",importing:"Importing",complete:"Import Complete"};return o.jsx(br,{open:t,onOpenChange:_,children:o.jsxs(xr,{className:"max-w-2xl max-h-[90vh]",children:[o.jsxs(wr,{children:[o.jsx(gr,{children:N[s]}),o.jsx(Qs,{children:"Import dataset items from a JSON file."})]}),o.jsx(Ar,{className:"min-h-[200px] max-h-[50vh] overflow-y-auto",children:E()}),o.jsx(kc,{className:"px-6 pt-4 flex justify-end gap-2",children:j()})]})})}const fTe=e=>{const t=We(),{data:n}=GM(e),r=n?.experiments;return wt({queryKey:["dataset-review-items",e,r?.map(s=>s.id)],queryFn:async()=>!r||r.length===0?[]:(await Promise.all(r.map(async a=>{if(!a.datasetId)return[];try{const{results:i}=await t.listDatasetExperimentResults(a.datasetId,a.id);return i.filter(l=>l.status==="needs-review").map(l=>({id:l.id,input:l.input,output:l.output,error:l.error,itemId:l.itemId,experimentId:l.experimentId,datasetId:a.datasetId??void 0,traceId:l.traceId??void 0,scores:l.scores?Object.fromEntries(l.scores.map(c=>[c.scorerId,c.score??0])):{},tags:l.tags??[],comment:""}))}catch{return[]}}))).flat(),enabled:!!e&&!!r&&r.length>0,refetchOnWindowFocus:!1})},les=e=>{const t=We(),{data:n}=GM(e),r=n?.experiments;return wt({queryKey:["dataset-completed-items",e,r?.map(s=>s.id)],queryFn:async()=>!r||r.length===0?[]:(await Promise.all(r.map(async a=>{if(!a.datasetId)return[];try{const{results:i}=await t.listDatasetExperimentResults(a.datasetId,a.id);return i.filter(l=>l.status==="complete").map(l=>({id:l.id,input:l.input,output:l.output,error:l.error,itemId:l.itemId,experimentId:l.experimentId,datasetId:a.datasetId??void 0,traceId:l.traceId??void 0,scores:l.scores?Object.fromEntries(l.scores.map(c=>[c.scorerId,c.score??0])):{},tags:l.tags??[],comment:""}))}catch{return[]}}))).flat(),enabled:!!e&&!!r&&r.length>0,refetchOnWindowFocus:!1})};function ces(e,t){if(typeof e=="string")return e.length>t?e.slice(0,t)+"...":e;try{const n=JSON.stringify(e);return n.length>t?n.slice(0,t)+"...":n}catch{return String(e)}}function i8t({datasetId:e,experimentId:t,featuredItemId:n}){const r=We(),{data:s}=Ux(e),{data:a,isLoading:i}=fTe(e),{data:l,isLoading:c}=les(e),u=v.useMemo(()=>t?(a??[]).filter(Ce=>Ce.experimentId===t):a,[a,t]),d=v.useMemo(()=>t?(l??[]).filter(Ce=>Ce.experimentId===t):l,[l,t]),{updateExperimentResult:f}=_i(),[p,h]=v.useState(n??null);v.useEffect(()=>{n!==void 0&&h(n)},[n]);const[m,g]=v.useState(null),[y,b]=v.useState(new Set),[w,S]=v.useState(!1),[k,_]=v.useState(!1),[C,E]=v.useState(!1),[j,N]=v.useState(""),[I,R]=v.useState(""),[$,F]=v.useState(""),[D,V]=v.useState([]),[W,L]=v.useState(!1),[z,B]=v.useState(null),M=v.useMemo(()=>z??u??[],[z,u]);v.useEffect(()=>{B(null)},[e,t]),v.useEffect(()=>{u&&z===null&&B(u)},[u,z]);const G=v.useMemo(()=>{const Ce=new Set;if(s?.tags)for(const je of s.tags)Ce.add(je);for(const je of M)for(const _e of je.tags)Ce.add(_e);return[...Ce].sort()},[s,M]),U=v.useCallback(Ce=>{!s||!e||(s.tags??[]).includes(Ce)},[s,e]),P=v.useMemo(()=>m?m==="__untagged__"?M.filter(Ce=>Ce.tags.length===0):M.filter(Ce=>Ce.tags.includes(m)):M,[M,m]),q=v.useMemo(()=>{const Ce=new Map;for(const je of M)for(const _e of je.tags)Ce.set(_e,(Ce.get(_e)??0)+1);return[...Ce.entries()].sort((je,_e)=>_e[1]-je[1])},[M]),Z=v.useMemo(()=>M.filter(Ce=>Ce.tags.length===0).length,[M]),X=v.useMemo(()=>{let Ce=0;return m&&Ce++,w&&Ce++,Ce},[m,w]),te=v.useCallback((Ce,je)=>{B(Oe=>(Oe??[]).map(Re=>Re.id===Ce?{...Re,tags:je}:Re));const _e=M.find(Oe=>Oe.id===Ce);_e?.experimentId&&_e?.datasetId&&f.mutate({datasetId:_e.datasetId,experimentId:_e.experimentId,resultId:_e.id,tags:je})},[M,f]),J=v.useCallback((Ce,je)=>{const _e=M.find(Oe=>Oe.id===Ce);_e?.traceId&&je!==void 0&&r.createFeedback({feedback:{traceId:_e.traceId,source:"studio",feedbackSource:"studio",feedbackType:"rating",value:je==="positive"?1:-1,experimentId:_e.experimentId??void 0,sourceId:_e.id}}).catch(()=>{}),B(Oe=>(Oe??[]).map(Re=>Re.id===Ce?{...Re,rating:je}:Re))},[M,r]),ee=v.useCallback((Ce,je)=>{const _e=M.find(Oe=>Oe.id===Ce);_e?.traceId&&r.createFeedback({feedback:{traceId:_e.traceId,source:"studio",feedbackSource:"studio",feedbackType:"comment",value:je,comment:je,experimentId:_e.experimentId??void 0,sourceId:_e.id}}).catch(()=>{}),B(Oe=>(Oe??[]).map(Re=>Re.id===Ce?{...Re,comment:je}:Re))},[M,r]),ae=v.useCallback(Ce=>{const je=M.find(_e=>_e.id===Ce);B(_e=>(_e??[]).filter(Oe=>Oe.id!==Ce)),b(_e=>{const Oe=new Set(_e);return Oe.delete(Ce),Oe}),p===Ce&&h(null),je?.experimentId&&je?.datasetId&&f.mutate({datasetId:je.datasetId,experimentId:je.experimentId,resultId:je.id,status:null})},[M,f,p]),de=v.useCallback(Ce=>{const je=M.find(_e=>_e.id===Ce);B(_e=>(_e??[]).filter(Oe=>Oe.id!==Ce)),b(_e=>{const Oe=new Set(_e);return Oe.delete(Ce),Oe}),p===Ce&&h(null),je?.experimentId&&je?.datasetId&&f.mutate({datasetId:je.datasetId,experimentId:je.experimentId,resultId:je.id,status:"complete"})},[M,f,p]),Y=v.useMemo(()=>{const Ce=w?d??[]:P;return!w||!m?Ce:m==="__untagged__"?Ce.filter(je=>je.tags.length===0):Ce.filter(je=>je.tags.includes(m))},[w,d,P,m]),ne=w?c:!1,ce=v.useMemo(()=>new Set(Y.map(Ce=>Ce.id)),[Y]),pe=v.useMemo(()=>[...y].filter(Ce=>ce.has(Ce)).length,[y,ce]),le=Y.length>0&&pe===Y.length,ve=pe>0&&!le,ye=v.useCallback(Ce=>{b(je=>{const _e=new Set(je);return _e.has(Ce)?_e.delete(Ce):_e.add(Ce),_e})},[]),Se=v.useCallback(()=>{b(le?new Set:new Set(Y.map(Ce=>Ce.id)))},[le,Y]),Ne=v.useCallback(Ce=>{for(const je of y){const _e=M.find(Oe=>Oe.id===je);_e&&!_e.tags.includes(Ce)&&te(je,[..._e.tags,Ce])}},[M,y,te]),ke=v.useCallback(Ce=>{for(const je of y){const _e=M.find(Oe=>Oe.id===je);_e&&_e.tags.includes(Ce)&&te(je,_e.tags.filter(Oe=>Oe!==Ce))}},[M,y,te]),Ie=v.useCallback(()=>{for(const Ce of y)de(Ce);b(new Set)},[y,de]),ze=v.useCallback(()=>{for(const Ce of y)ae(Ce);b(new Set)},[y,ae]),oe=v.useCallback(()=>{N(""),E(!0)},[]),se=v.useCallback(async()=>{if(!(!I||!$)){_(!0),E(!1);try{const Ce=M.filter(_e=>y.has(_e.id));if(Ce.length===0){_(!1);return}const je=await r.clusterFailures({modelId:`${I}/${$}`,items:Ce.map(_e=>({id:_e.id,input:_e.input,output:_e.output??void 0,error:typeof _e.error=="string"?_e.error:_e.error?String(_e.error):void 0,scores:_e.scores,existingTags:_e.tags.length>0?_e.tags:void 0})),availableTags:G.length>0?G:void 0,prompt:j||void 0});je.proposedTags&&je.proposedTags.length>0&&(V(je.proposedTags.map(_e=>({..._e,accepted:!0}))),L(!0))}catch(Ce){console.error("Analysis failed:",Ce)}finally{_(!1)}}},[I,$,M,y,r,G,j]),re=v.useCallback(()=>{for(const Ce of D){if(!Ce.accepted)continue;const je=M.find(_e=>_e.id===Ce.itemId);if(je){const _e=[...new Set([...je.tags,...Ce.tags])];te(je.id,_e)}}L(!1)},[D,M,te]),he=v.useCallback(Ce=>{h(je=>je===Ce?null:Ce)},[]),xe=v.useMemo(()=>p?Y.find(Ce=>Ce.id===p)??null:null,[p,Y]),Ee=p?Y.findIndex(Ce=>Ce.id===p):-1,Pe=Ee>0?()=>h(Y[Ee-1].id):void 0,Qe=Ee>=0&&Ee<Y.length-1?()=>h(Y[Ee+1].id):void 0,Ze="auto minmax(15rem,1fr) 10rem 8rem 6rem 6rem";return i?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Gt,{className:"w-6 h-6"})}):o.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[o.jsx(br,{open:C,onOpenChange:E,children:o.jsxs(xr,{children:[o.jsxs(wr,{children:[o.jsx(gr,{children:"Analyze Items"}),o.jsx(Qs,{children:"Use an LLM to automatically suggest tags for the selected items."})]}),o.jsxs("div",{className:"space-y-4 py-2",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx(Rt,{className:"text-xs mb-1 block",children:"Provider"}),o.jsx(Fy,{value:I,onValueChange:R})]}),o.jsxs("div",{children:[o.jsx(Rt,{className:"text-xs mb-1 block",children:"Model"}),o.jsx(zy,{llmId:I,value:$,onValueChange:F})]})]}),o.jsxs(ge,{variant:"ui-xs",className:"text-neutral3",children:[y.size," item",y.size!==1?"s":""," will be analyzed"]}),o.jsxs("div",{children:[o.jsx(Rt,{className:"text-xs",children:"Instructions (optional)"}),o.jsx(Yl,{value:j,onChange:Ce=>N(Ce.target.value),placeholder:"E.g., Focus on safety issues and factual errors...",rows:3,className:"text-xs mt-1"})]})]}),o.jsxs(kc,{children:[o.jsx(ue,{variant:"outline",onClick:()=>E(!1),children:"Cancel"}),o.jsxs(ue,{onClick:se,disabled:!I||!$||k,children:[k?o.jsx(Gt,{className:"w-4 h-4 mr-1"}):null,"Analyze"]})]})]})}),o.jsx(br,{open:W,onOpenChange:L,children:o.jsxs(xr,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[o.jsxs(wr,{children:[o.jsx(gr,{children:"Review Proposed Tags"}),o.jsxs(Qs,{children:[D.filter(Ce=>Ce.accepted).length," of ",D.length," proposals selected"]})]}),o.jsx("div",{className:"space-y-3 py-2",children:D.map((Ce,je)=>{const _e=M.find(Oe=>Oe.id===Ce.itemId);return o.jsx("div",{className:K("p-3 border rounded-lg",!Ce.accepted&&"opacity-50"),children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx($o,{checked:Ce.accepted,onCheckedChange:Oe=>V(Re=>Re.map((qe,Ke)=>Ke===je?{...qe,accepted:!!Oe}:qe))}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 truncate block",children:_e?typeof _e.input=="string"?_e.input.slice(0,100):JSON.stringify(_e.input).slice(0,100):Ce.itemId}),o.jsx("div",{className:"flex gap-1 flex-wrap mt-1.5",children:Ce.tags.map((Oe,Re)=>o.jsx(z6t,{tag:Oe,onRename:qe=>V(Ke=>Ke.map((Ge,Ot)=>Ot===je?{...Ge,tags:Ge.tags.map((yt,rn)=>rn===Re?qe:yt)}:Ge)),onRemove:()=>V(qe=>qe.map((Ke,Ge)=>Ge===je?{...Ke,tags:Ke.tags.filter((Ot,yt)=>yt!==Re)}:Ke))},`${Oe}-${Re}`))}),Ce.reason&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-1 block italic",children:Ce.reason})]})]})},Ce.itemId)})}),o.jsxs(kc,{children:[o.jsx(ue,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),o.jsxs(ue,{onClick:re,disabled:D.filter(Ce=>Ce.accepted).length===0,children:["Accept ",D.filter(Ce=>Ce.accepted).length," proposals"]})]})]})}),o.jsxs("div",{className:K("grid w-full h-full grid-cols-1 gap-4 overflow-y-auto",xe&&"grid-cols-[1fr_1fr]"),children:[o.jsxs("div",{className:"grid gap-8 content-start w-full overflow-y-auto",children:[o.jsxs("div",{className:"flex items-center justify-between w-full flex-wrap gap-4 gap-x-6",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs(ft,{children:[o.jsx(ft.Trigger,{asChild:!0,children:o.jsxs(ue,{variant:"outline",size:"md",children:[o.jsx(blt,{}),"Filter",X>0&&o.jsx("span",{className:K("ml-0.5 inline-flex items-center justify-center rounded-full bg-accent1/50 text-neutral5 text-ui-sm w-5 h-5"),children:X})]})}),o.jsxs(ft.Content,{align:"start",className:K("min-w-48"),children:[o.jsxs(ft.Sub,{children:[o.jsxs(ft.SubTrigger,{children:["Status",w&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(ft.SubContent,{children:[o.jsx(ft.CheckboxItem,{checked:!w,onCheckedChange:()=>{S(!1),h(null)},onSelect:Ce=>Ce.preventDefault(),children:"Review Queue"}),o.jsx(ft.CheckboxItem,{checked:w,onCheckedChange:()=>{S(!0),h(null)},onSelect:Ce=>Ce.preventDefault(),children:"Completed"})]})]}),o.jsxs(ft.Sub,{children:[o.jsxs(ft.SubTrigger,{children:["Tags",m&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(ft.SubContent,{children:[o.jsx(ft.CheckboxItem,{checked:!m,onCheckedChange:()=>g(null),onSelect:Ce=>Ce.preventDefault(),children:"All"}),Z>0&&o.jsx(ft.CheckboxItem,{checked:m==="__untagged__",onCheckedChange:()=>g(m==="__untagged__"?null:"__untagged__"),onSelect:Ce=>Ce.preventDefault(),children:"Untagged"}),q.length>0&&o.jsx(ft.Separator,{}),q.map(([Ce])=>o.jsx(ft.CheckboxItem,{checked:m===Ce,onCheckedChange:()=>g(m===Ce?null:Ce),onSelect:je=>je.preventDefault(),children:Ce},Ce))]})]}),X>0&&o.jsxs(o.Fragment,{children:[o.jsx(ft.Separator,{}),o.jsxs(ft.Item,{onSelect:()=>{g(null),S(!1),h(null)},children:[o.jsx(vs,{}),"Clear all filters"]})]})]})]}),X>0&&o.jsxs(ue,{variant:"outline",size:"md",onClick:()=>{g(null),S(!1),h(null)},children:[o.jsx(vs,{}),"Reset"]})]}),!w&&y.size>0&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(F6t,{selectedCount:y.size,vocabulary:G,onApplyTag:Ne,onRemoveTag:ke,onNewTag:Ce=>Ne(Ce)}),o.jsxs(ft,{children:[o.jsx(ft.Trigger,{asChild:!0,children:o.jsxs(ue,{disabled:k,children:[k?o.jsx(Gt,{className:"w-4 h-4"}):o.jsx(Ue,{size:"sm",children:o.jsx(Na,{})}),"Actions"]})}),o.jsxs(ft.Content,{align:"end",children:[o.jsxs(ft.Item,{onSelect:Ie,children:[o.jsx(Ue,{size:"sm",children:o.jsx(rO,{})}),"Complete"]}),o.jsxs(ft.Item,{onSelect:ze,children:[o.jsx(Ue,{size:"sm",children:o.jsx(Jc,{})}),"Remove"]}),o.jsx(ft.Separator,{}),o.jsxs(ft.Item,{onSelect:oe,children:[o.jsx(Ue,{size:"sm",children:o.jsx(bg,{})}),"Analyze"]})]})]})]})]}),ne?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Gt,{className:"w-6 h-6"})}):Y.length===0?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsxs("div",{className:"text-center px-8",children:[o.jsx(ge,{variant:"ui-sm",className:"text-neutral3 block",children:w?"No completed reviews yet":"No items to review"}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-2 block",children:w?"Items marked as complete will appear here for auditing.":"When experiment results are flagged for review, they will appear here."})]})}):o.jsxs(me,{columns:Ze,className:"min-w-0",children:[o.jsxs(me.Top,{hasLeadingCell:!0,children:[w?o.jsx(me.TopCell,{children:" "}):o.jsx(me.TopSelectCell,{checked:le?!0:ve?"indeterminate":!1,onToggle:()=>Se(),"aria-label":"Select all"}),o.jsxs(me.TopCells,{colStart:2,children:[o.jsx(me.TopCell,{children:"Input"}),o.jsx(me.TopCell,{children:"Comment"}),o.jsx(me.TopCell,{children:"Tags"}),o.jsx(me.TopCell,{children:"Rating"}),o.jsx(me.TopCell,{children:"Scores"})]})]}),Y.map(Ce=>{const je=Ce.scores?Object.entries(Ce.scores):[],_e=p===Ce.id,Oe=o.jsxs(o.Fragment,{children:[o.jsx(me.Cell,{height:"compact",className:"min-w-0 text-neutral4",children:o.jsx("span",{className:"block truncate",children:ces(Ce.input,200)})}),o.jsx(me.Cell,{height:"compact",className:"min-w-0",children:Ce.comment?o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 truncate",children:Ce.comment}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsx(me.Cell,{height:"compact",className:"min-w-0",children:Ce.tags.length>0?o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 truncate",children:Ce.tags.join(", ")}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsxs(me.Cell,{height:"compact",children:[Ce.rating==="positive"&&o.jsx(Ue,{size:"sm",className:"text-positive1",children:o.jsx(Jye,{})}),Ce.rating==="negative"&&o.jsx(Ue,{size:"sm",className:"text-negative1",children:o.jsx(Kye,{})}),!Ce.rating&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})]}),o.jsx(me.Cell,{height:"compact",children:je.length>0?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(Ue,{size:"sm",className:"text-neutral3",children:o.jsx(Jh,{})}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 font-mono",children:je[0][1].toFixed(2)}),je.length>1&&o.jsxs(fn,{variant:"default",children:["+",je.length-1]})]}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})})]});return o.jsxs(me.RowWrapper,{children:[w?o.jsx(me.Cell,{height:"compact",className:"justify-items-center px-4",children:o.jsx("div",{role:"img","aria-label":Ce.error?"Error":"Success",title:Ce.error?"Error":"Success",className:K("w-2 h-2 rounded-full",Ce.error?"bg-red-700":"bg-green-600")})}):o.jsx(me.SelectCell,{checked:y.has(Ce.id),onToggle:()=>ye(Ce.id),"aria-label":`Select item ${Ce.id}`}),o.jsx(me.RowButton,{flushLeft:!0,colStart:2,featured:_e,onClick:()=>he(Ce.id),children:Oe})]},Ce.id)})]})]}),xe&&o.jsx(L6t,{item:xe,isCompleted:w,tagVocabulary:G,onRate:Ce=>J(xe.id,Ce),onSetTags:Ce=>{te(xe.id,Ce);for(const je of Ce)G.includes(je)||U(je)},onComment:Ce=>ee(xe.id,Ce),onRemove:()=>ae(xe.id),onComplete:w?void 0:()=>de(xe.id),onPrevious:Pe,onNext:Qe,onClose:()=>h(null)})]})]})}function ues({datasetId:e,onAddItemClick:t,onNavigateToDataset:n}){const{navigate:r}=yn(),[s,a]=ji(),{tab:i,activeVersion:l,handleTabChange:c}=uTe(s,a),[u,d]=v.useState(!1),[f,p]=v.useState(!1),[h,m]=v.useState(!1),[g,y]=v.useState([]),[b,w]=v.useState(!1),[S,k]=v.useState([]),[_,C]=v.useState(!1),[E,j]=v.useState([]),[N,I]=v.useState(0),[R,$]=v.useState(null),[F,D]=v.useState(""),[V]=w0e(F,300),{data:W}=Ux(e),{data:L=[],total:z,isLoading:B,setEndOfListElement:M,isFetchingNextPage:G,hasNextPage:U}=_1(e,V||void 0,l),{total:P}=_1(e,void 0,l),[q,Z]=v.useState({}),{data:X,isLoading:te}=GM(e,void 0,q),{data:J}=GM(e),{deleteItems:ee}=_i(),ae=X?.experiments??[],de=J?.experiments??[],Y=dJr({hasSearchQuery:!!V,filteredItemsLength:L.length,unfilteredItemsTotal:P,itemsTotal:z}),{data:ne}=fTe(e),ce=ne?.length??0,pe=re=>{$(re)},le=()=>{$(null)},ve=re=>{y(re),m(!0)},ye=re=>{k(re),w(!0)},Se=re=>{w(re),re||(k([]),I(he=>he+1))},Ne=re=>{r(`/datasets/${e}/items?items=${re.join(",")}`)},ke=re=>{r(`/datasets/${e}/versions?ids=${re.join(",")}`)},Ie=re=>{j(re),C(!0)},ze=async()=>{await ee.mutateAsync({datasetId:e,itemIds:E}),De.success(`Deleted ${E.length} items`),C(!1),j([]),I(re=>re+1)},oe=re=>{m(!1),y([]),I(he=>he+1),n?.(re)},se=re=>{m(re),re||(y([]),I(he=>he+1))};return o.jsxs(o.Fragment,{children:[o.jsxs(ru,{defaultTab:"items",value:i,onValueChange:c,className:"grid grid-rows-[auto_1fr] h-full",children:[o.jsxs(su,{children:[o.jsxs(Vr,{value:"items",children:["Items ",o.jsx(Xs,{color:"gray",children:Y})]}),o.jsxs(Vr,{value:"experiments",children:["Experiments",o.jsx(Xs,{color:"gray",children:ae.length})]}),o.jsxs(Vr,{value:"review",children:["Review",ce>0&&o.jsx(Xs,{color:"orange",children:ce})]})]}),o.jsx(ps,{value:"items",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(res,{datasetId:e,items:L,isLoading:B,featuredItemId:R,onItemSelect:pe,onItemClose:le,onAddClick:t??(()=>{}),onImportClick:()=>d(!0),onImportJsonClick:()=>p(!0),onBulkDeleteClick:Ie,onCreateDatasetClick:ve,onAddToDatasetClick:ye,onCompareItemsClick:Ne,datasetName:W?.name,clearSelectionTrigger:N,setEndOfListElement:M,isFetchingNextPage:G,hasNextPage:U,searchQuery:F,activeSearchQuery:V,onSearchChange:D,currentDatasetVersion:W?.version,onCompareVersionsClick:ke})}),o.jsx(ps,{value:"experiments",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(jJr,{experiments:ae,allExperiments:de,isLoading:te,datasetId:e,filters:q,onFiltersChange:Z})}),o.jsx(ps,{value:"review",className:"overflow-auto mt-2 pb-0",children:o.jsx(i8t,{datasetId:e})})]}),o.jsx(xJr,{datasetId:e,open:u,onOpenChange:d}),o.jsx(oes,{datasetId:e,open:f,onOpenChange:p}),o.jsx(YKr,{open:h,onOpenChange:se,items:g,onSuccess:oe}),o.jsx(XKr,{open:b,onOpenChange:Se,items:S,currentDatasetId:e}),o.jsx(Tt,{open:_,onOpenChange:C,children:o.jsxs(Tt.Content,{children:[o.jsxs(Tt.Header,{children:[o.jsx(Tt.Title,{children:"Delete Items"}),o.jsxs(Tt.Description,{children:["Are you sure you want to delete ",E.length," item",E.length!==1?"s":"","? This action cannot be undone."]})]}),o.jsxs(Tt.Footer,{children:[o.jsx(Tt.Cancel,{children:"Cancel"}),o.jsx(Tt.Action,{onClick:ze,children:ee.isPending?"Deleting...":"Delete"})]})]})})]})}function des(e){if(!(e instanceof Error))return null;const t=e.message.match(/- ({.*})$/);if(!t)return null;try{const n=JSON.parse(t[1]);if(n.field&&Array.isArray(n.errors))return{field:n.field,errors:n.errors}}catch{}return null}function Dre({field:e,errors:t}){return t.length?o.jsx("div",{className:"mt-2 space-y-1",children:t.map((n,r)=>o.jsxs("p",{className:"text-xs text-destructive",children:[o.jsxs("code",{className:"bg-destructive/10 px-1 rounded",children:[e,n.path!=="/"?n.path:""]}),": ",n.message]},r))}):null}function fes({datasetId:e,open:t,onOpenChange:n,onSuccess:r}){const[s,a]=v.useState("{}"),[i,l]=v.useState(""),[c,u]=v.useState(""),[d,f]=v.useState(""),[p,h]=v.useState(""),[m,g]=v.useState(null),{addItem:y}=_i(),b=async C=>{C.preventDefault();let E;try{E=JSON.parse(s)}catch{De.error("Input must be valid JSON");return}let j;if(i.trim())try{j=JSON.parse(i)}catch{De.error("Ground Truth must be valid JSON");return}let N;if(c.trim())try{N=JSON.parse(c)}catch{De.error("Expected Trajectory must be valid JSON");return}let I;if(d.trim())try{const $=JSON.parse(d);if(!Array.isArray($)){De.error("Tool Mocks must be a JSON array");return}I=$}catch{De.error("Tool Mocks must be valid JSON");return}let R;if(p.trim())try{R=JSON.parse(p)}catch{De.error("Request Context must be valid JSON");return}try{await y.mutateAsync({datasetId:e,input:E,groundTruth:j,expectedTrajectory:N,toolMocks:I,requestContext:R}),De.success("Item added successfully"),g(null),a("{}"),l(""),u(""),f(""),h(""),n(!1),r?.()}catch($){const F=des($);F?g(F):De.error(`Failed to add item: ${$ instanceof Error?$.message:"Unknown error"}`)}},w=C=>{a(C),m?.field==="input"&&g(null)},S=C=>{l(C),m?.field==="groundTruth"&&g(null)},k=C=>{f(C),m?.field==="toolMocks"&&g(null)},_=()=>{a("{}"),l(""),u(""),f(""),h(""),g(null),n(!1)};return o.jsx(br,{open:t,onOpenChange:n,children:o.jsxs(xr,{className:"max-w-lg",children:[o.jsx(wr,{children:o.jsx(gr,{children:"Add Item"})}),o.jsx(Ar,{children:o.jsxs("form",{onSubmit:b,className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{htmlFor:"item-input",children:"Input (JSON) *"}),o.jsx(Qr,{value:s,onChange:w,showCopyButton:!1,className:"min-h-[120px]"}),m?.field==="input"&&o.jsx(Dre,{field:"input",errors:m.errors})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{htmlFor:"item-ground-truth",children:"Ground Truth (JSON, optional)"}),o.jsx(Qr,{value:i,onChange:S,showCopyButton:!1,className:"min-h-[80px]"}),m?.field==="groundTruth"&&o.jsx(Dre,{field:"groundTruth",errors:m.errors})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{htmlFor:"item-trajectory",children:"Expected Trajectory (JSON, optional)"}),o.jsx(Qr,{value:c,onChange:u,showCopyButton:!1,className:"min-h-[80px]"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{htmlFor:"item-tool-mocks",children:"Tool Mocks (JSON array, optional)"}),o.jsx(Qr,{value:d,onChange:k,showCopyButton:!1,className:"min-h-[80px]"}),m?.field==="toolMocks"&&o.jsx(Dre,{field:"toolMocks",errors:m.errors})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{htmlFor:"item-request-context",children:"Request Context (JSON, optional)"}),o.jsx(Qr,{value:p,onChange:h,showCopyButton:!1,className:"min-h-[80px]"})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[o.jsx(ue,{type:"button",onClick:_,children:"Cancel"}),o.jsx(ue,{type:"submit",variant:"primary",disabled:y.isPending,children:y.isPending?"Adding...":"Add Item"})]})]})})]})})}function pes({item:e}){return o.jsx(ua,{withMargins:!1,children:o.jsxs(ua.Column,{children:[o.jsxs(ua.Title,{size:"smaller",children:[o.jsx(dN,{}),o.jsx("span",{className:"truncate",children:e.id}),o.jsx(ya,{content:e.id,tooltip:`Copy item ID: ${e.id}`})]}),o.jsxs(ua.Description,{children:[o.jsxs(Nl,{children:[o.jsx(ult,{})," Created ",er(new Date(e.createdAt),"MMM d, yyyy h:mm aaa")]}),e.datasetVersion!=null&&o.jsxs(Nl,{children:[o.jsx(i_,{})," Version v",e.datasetVersion]})]})]})})}function pTe({item:e}){const t=e?.input?JSON.stringify(e.input,null,2):"null",n=e?.groundTruth?JSON.stringify(e.groundTruth,null,2):"null",r=e?.metadata?JSON.stringify(e.metadata,null,2):"null",s=e?.expectedTrajectory?JSON.stringify(e.expectedTrajectory,null,2):null;return o.jsxs(Rje,{children:[o.jsx(Ps.CodeSection,{title:"Input",icon:o.jsx(aO,{}),codeStr:t}),o.jsx(Ps.CodeSection,{title:"Ground Truth",icon:o.jsx(hg,{}),codeStr:n}),s&&o.jsx(Ps.CodeSection,{title:"Expected Trajectory",icon:o.jsx(Gye,{}),codeStr:s}),o.jsx(Ps.CodeSection,{title:"Metadata",icon:o.jsx(hN,{}),codeStr:r})]})}function hes({selectedScorers:e,setSelectedScorers:t,disabled:n=!1,container:r}){const{data:s,isLoading:a}=eh(),i=v.useMemo(()=>s?Object.entries(s).map(([l,c])=>({value:l,label:c.scorer?.config?.name||l,description:c.scorer?.config?.description||""})):[],[s]);return o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Rt,{children:"Scorers (Optional)"}),o.jsx(Xl,{multiple:!0,options:i,value:e,onValueChange:t,placeholder:"Select scorers...",searchPlaceholder:"Search scorers...",emptyText:"No scorers available",disabled:n||a,container:r})]})}const mes=[{value:"agent",label:"Agent"},{value:"workflow",label:"Workflow"},{value:"scorer",label:"Scorer"}];function ges({targetType:e,setTargetType:t,targetId:n,setTargetId:r,container:s}){const{data:a,isLoading:i}=Sm(),{data:l,isLoading:c}=By(),{data:u,isLoading:d}=eh(),f=e==="agent"?Object.entries(a??{}).map(([g,y])=>({value:g,label:y.name??g})):e==="workflow"?Object.entries(l??{}).map(([g,y])=>({value:g,label:y.name??g})):e==="scorer"?Object.entries(u??{}).map(([g,y])=>({value:g,label:y.scorer?.config?.name??g})):[],p=e==="agent"&&i||e==="workflow"&&c||e==="scorer"&&d,h=g=>{t(g),r("")},m=e==="agent"?"Agent":e==="workflow"?"Workflow":"Scorer";return o.jsxs("div",{className:"grid gap-6",children:[o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Rt,{children:"Target Type"}),o.jsx(Xl,{options:mes,value:e,onValueChange:h,placeholder:"Select target type",searchPlaceholder:"Search types...",emptyText:"No types available",container:s})]}),e&&o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Rt,{children:m}),o.jsx(Xl,{options:f,value:n,onValueChange:r,placeholder:`Select ${e}`,searchPlaceholder:"Search...",emptyText:"No targets available",disabled:p,container:s})]})]})}function ves({requestContextSchema:e,onChange:t}){const n=v.useMemo(()=>{try{return im(sm(e))}catch(r){return console.error("Failed to parse requestContextSchema:",r),null}},[e]);return n?o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{children:"Request Context"}),o.jsx(X3,{schema:n,onValuesChange:t,className:"[&_button[type=submit]]:hidden"})]}):o.jsx("p",{className:"text-sm text-destructive",children:"Failed to parse request context schema"})}function yes({datasetId:e,version:t,requestContextSchema:n,open:r,onOpenChange:s,onSuccess:a}){const i=v.useRef(null),[l,c]=v.useState(""),[u,d]=v.useState(""),[f,p]=v.useState([]),[h,m]=v.useState({}),[g,y]=v.useState(""),{triggerExperiment:b}=_i(),w=!!(n&&Object.keys(n).length>0),S=l&&u,k=b.isPending,_=()=>{c(""),d(""),p([]),m({}),y("")},C=()=>{if(w){const N=Object.entries(h).filter(([,I])=>I!==void 0&&I!=="");return N.length>0?Object.fromEntries(N):void 0}if(g.trim()){let N;try{N=JSON.parse(g)}catch{throw new Error("Request Context must be valid JSON")}if(!N||typeof N!="object"||Array.isArray(N))throw new Error("Request Context must be a JSON object");return N}},E=async()=>{if(!S)return;let N;try{N=C()}catch(I){const R=I instanceof Error?I.message:"Request Context must be valid JSON";ju.error(R);return}try{const I=await b.mutateAsync({datasetId:e,targetType:l,targetId:u,scorerIds:f.length>0?f:void 0,version:t,requestContext:N});ju.success("Experiment triggered successfully"),s(!1),a?.(I.experimentId),_()}catch(I){const R=I instanceof Error?I.message:"Failed to trigger experiment";ju.error(R)}},j=()=>{k||(s(!1),_())};return o.jsx(br,{open:r,onOpenChange:j,children:o.jsxs(xr,{ref:i,children:[o.jsxs(wr,{children:[o.jsx(gr,{children:"Run Experiment"}),o.jsx(Qs,{children:t?`Execute items from ${er(new Date(t),"MMM d, yyyy")} version against a target.`:"Execute all items in this dataset against a target."})]}),o.jsxs(Ar,{className:"grid gap-6",children:[o.jsx(ges,{targetType:l,setTargetType:c,targetId:u,setTargetId:d,container:i}),l&&l!=="scorer"&&o.jsx(hes,{selectedScorers:f,setSelectedScorers:p,disabled:k,container:i}),w?o.jsx(ves,{requestContextSchema:n,onChange:m}):o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{children:"Request Context (JSON, optional)"}),o.jsx(Qr,{value:g,onChange:y,showCopyButton:!1,className:"min-h-[80px]"})]})]}),o.jsxs(kc,{className:"px-6 pt-4",children:[o.jsx(ue,{onClick:j,disabled:k,children:"Cancel"}),o.jsx(ue,{variant:"primary",onClick:E,disabled:!S||k,children:k?o.jsxs(o.Fragment,{children:[o.jsx(Gt,{className:"w-4 h-4"}),"Running..."]}):"Run"})]})]})})}const bes=e=>{const t=We();return wt({queryKey:["experiment-trace-light",e],queryFn:async()=>{if(!e)throw new Error("Trace ID is required");return t.getTraceLight(e)},enabled:!!e})},hTe=e=>o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 9.45892 8.88606",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[o.jsx("path",{d:"M8.53702 7.36403C8.98547 7.36403 9.34918 7.70502 9.34918 8.12535C9.34906 8.54559 8.9854 8.88606 8.53702 8.88606H5.6839C5.23552 8.88606 4.87186 8.54559 4.87174 8.12535C4.87174 7.70502 5.23545 7.36403 5.6839 7.36403H8.53702Z",fill:"currentColor"}),o.jsx("path",{d:"M8.53702 3.67209C8.98547 3.67209 9.34918 4.01309 9.34918 4.43342C9.34911 4.8537 8.98543 5.19413 8.53702 5.19413H5.6839C5.23549 5.19413 4.87181 4.8537 4.87174 4.43342C4.87174 4.01309 5.23545 3.67209 5.6839 3.67209H8.53702Z",fill:"currentColor"}),o.jsx("path",{d:"M8.67155 0C9.10635 2.06584e-05 9.45892 0.341006 9.45892 0.761326C9.45878 1.18153 9.10627 1.52201 8.67155 1.52203H2.88163C2.4469 1.52203 2.0944 1.18154 2.09427 0.761326C2.09427 0.340993 2.44681 3.80132e-08 2.88163 0H8.67155Z",fill:"currentColor"}),o.jsx("path",{d:"M0.757606 0.760086V4.01122H3.50594V4.76883H0.759466L0.762566 5.4291C0.76837 6.70703 1.8058 7.73972 3.08374 7.73973H3.67953V8.49796H3.08374C1.38863 8.49795 0.0120204 7.1273 0.00433981 5.4322L0 4.39188V0.760086H0.757606Z",fill:"currentColor"})]});function Lre(e){try{return JSON.stringify(e??{})}catch{return String(e)}}function xes({report:e}){const{served:t,unconsumed:n,liveCalls:r,failure:s}=e,a=[...t.map(i=>({outcome:"served",toolName:i.toolName,args:i.args})),...r.map(i=>({outcome:"live",toolName:i.toolName,args:i.args})),...n.map(i=>({outcome:"unconsumed",toolName:i.toolName,args:i.args}))];return o.jsxs("div",{className:"grid gap-2","data-testid":"tool-mock-report",children:[o.jsx(bn.SectionHeading,{icon:o.jsx(tm,{}),className:"mb-2",children:"Tool Mocks"}),s&&o.jsx(In,{variant:"destructive",title:"Mock mismatch",children:o.jsxs(In.Message,{children:[o.jsx("span",{className:"block",children:`Tool "${s.toolName}" was called with arguments that did not match an available mock (${s.code}).`}),o.jsxs("span",{className:"mt-1 block font-mono text-xs",children:["Called with: ",Lre(s.args)]}),n.length>0&&o.jsxs("span",{className:"mt-1 block font-mono text-xs",children:["Unconsumed mocks: ",n.map(i=>Lre(i.args)).join(", ")]})]})}),o.jsx("div",{className:"rounded border border-border1 divide-y divide-border1 text-sm",children:a.map((i,l)=>o.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-1.5",children:[o.jsxs("span",{className:"min-w-0 truncate",children:[o.jsx("span",{className:"font-mono text-neutral4",children:i.toolName}),o.jsx("span",{className:"ml-2 font-mono text-xs text-neutral3",children:Lre(i.args)})]}),o.jsx("span",{className:`shrink-0 text-xs px-2 py-0.5 rounded ${wes(i.outcome)}`,children:i.outcome})]},`${i.outcome}-${i.toolName}-${l}`))})]})}function wes(e){switch(e){case"served":return"bg-accent1/10 text-accent1";case"live":return"bg-orange-500/10 text-orange-400";case"unconsumed":return"bg-neutral3/10 text-neutral4"}}function Ses({result:e,scores:t,onPrevious:n,onNext:r,onClose:s,onShowTrace:a,onOpenInReview:i,onScoreClick:l,featuredScoreId:c,onFlagForReview:u,collapsed:d,onCollapsedChange:f}){const[p,h]=v.useState(!1),m=d??p,g=f??h,y=!!e?.error,b=U8(e?.input),w=U8(e?.output),S=U8(e?.groundTruth),k=u&&e.status!=="needs-review"&&e.status!=="complete",_=Array.isArray(e.tags)?e.tags:[];return o.jsxs(bn,{collapsed:m,children:[o.jsxs(bn.Header,{children:[o.jsxs(bn.Heading,{children:["Result ",o.jsxs("b",{children:["# ",e.id.length>12?`${e.id.slice(0,12)}…`:e.id]})]}),o.jsxs($r,{className:"ml-auto shrink-0",children:[f&&o.jsx(ue,{size:"md",tooltip:m?"Expand panel":"Collapse panel",onClick:()=>g(!m),children:m?o.jsx(hlt,{}):o.jsx(plt,{})}),o.jsx(bn.NextPrevNav,{onPrevious:n,onNext:r,previousLabel:"Previous result",nextLabel:"Next result"}),o.jsxs(ue,{size:"md",onClick:a,disabled:!e.traceId,children:[o.jsx(hTe,{}),"Trace"]}),o.jsx(bn.CloseButton,{onClick:s,tooltip:"Close result panel"})]})]}),!m&&o.jsxs(bn.Content,{children:[o.jsxs("div",{className:"grid gap-4 mb-6",children:[o.jsxs(zt,{children:[o.jsx(zt.Key,{children:"Item Id"}),o.jsx(zt.ValueWithCopyBtn,{copyTooltip:"Copy Item Id to clipboard",copyValue:e.itemId,children:e.itemId}),o.jsx(zt.Key,{children:"Created"}),o.jsx(zt.Value,{children:er(new Date(e.createdAt),"MMM d, yyyy 'at' h:mm a")})]}),y&&o.jsx(In,{variant:"destructive",title:"Error",children:o.jsx(In.Message,{children:U8(e?.error&&typeof e.error=="object"?e.error.message:e?.error)})}),t&&t.length>0&&o.jsxs(me,{columns:"1fr 1fr",children:[o.jsxs(me.Top,{children:[o.jsx(me.TopCell,{children:"Scorer"}),o.jsx(me.TopCell,{children:"Score"})]}),t.map(C=>o.jsxs(me.RowButton,{featured:c===C.id,onClick:()=>l?.(C.id),children:[o.jsx(me.Cell,{height:"compact",children:C.scorerId}),o.jsx(me.MonoCell,{children:C.score.toFixed(3)})]},C.id))]}),e.toolMockReport&&o.jsx(xes,{report:e.toolMockReport}),(e.status||_.length>0||k)&&o.jsxs("div",{className:"grid gap-2",children:[o.jsx(bn.SectionHeading,{icon:o.jsx(hN,{}),className:"mb-2",children:"Review"}),(e.status||_.length>0)&&o.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[e.status&&o.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${e.status==="needs-review"?"bg-orange-500/10 text-orange-400":e.status==="complete"?"bg-accent1/10 text-accent1":"bg-neutral3/10 text-neutral4"}`,children:e.status}),_.map(C=>o.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-surface4 text-neutral4",children:C},C))]}),k&&o.jsx("div",{children:o.jsxs(ue,{size:"sm",onClick:()=>u(e.id),children:[o.jsx(GU,{}),"Flag for Review"]})}),e.status==="needs-review"&&i&&o.jsx("div",{children:o.jsxs(ue,{size:"sm",onClick:i,children:[o.jsx(Pa,{}),"Review"]})})]})]}),o.jsxs("div",{className:"grid gap-3",children:[o.jsx(bn.CodeSection,{title:"Input",icon:o.jsx(dN,{}),codeStr:b}),o.jsx(bn.CodeSection,{title:"Output",icon:o.jsx(hg,{}),codeStr:w}),o.jsx(bn.CodeSection,{title:"Ground Truth",icon:o.jsx(Xye,{}),codeStr:S})]})]})]})}function U8(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function kes({results:e,isLoading:t,featuredResultId:n,onResultClick:r,columns:s,scoresByItemId:a,scorerIds:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u,selectedIds:d,onToggleSelect:f}){const p=!!(d&&f),h=[p?"auto":"",...s.map(g=>g.size)].filter(Boolean).join(" "),m=s.some(g=>g.name==="input");return t?o.jsx(el,{columns:h}):o.jsxs(me,{columns:h,className:"min-w-0",children:[o.jsxs(me.Top,{hasLeadingCell:p,children:[p&&o.jsx(me.TopCell,{children:" "}),p?o.jsx(me.TopCells,{colStart:2,children:s.map(g=>o.jsx(me.TopCell,{children:g.label},g.name))}):s.map(g=>o.jsx(me.TopCell,{children:g.label},g.name))]}),e.length===0?o.jsx(me.NoMatch,{message:"No results yet"}):o.jsxs(o.Fragment,{children:[e.map(g=>{const y=!!g.error,b=g.id===n,w=o.jsxs(o.Fragment,{children:[o.jsx(me.IdCell,{id:g.itemId}),o.jsx(me.Cell,{height:"compact",children:o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx("div",{className:"flex items-center justify-center w-10 relative bg-transparent h-full",children:o.jsx("div",{role:"img","aria-label":y?"Error":"Success",className:K("w-2 h-2 rounded-full",y?"bg-red-700":"bg-green-600")})})}),o.jsx(Bn,{children:y?"Error":"Success"})]})}),m&&o.jsx(me.MonoCell,{children:_es(Oes(g.input),200)}),i?.map(S=>{const _=a?.[g.itemId]?.find(C=>C.scorerId===S);return o.jsx(me.Cell,{height:"compact",className:"font-mono text-neutral3 text-ui-smd",children:_!=null?_.score.toFixed(3):"-"},S)})]});return p?o.jsxs(me.RowWrapper,{children:[o.jsx(me.SelectCell,{checked:d.has(g.id),onToggle:()=>f(g.id),"aria-label":`Select result ${g.itemId}`}),o.jsx(me.RowButton,{flushLeft:!0,colStart:2,featured:b,onClick:()=>r(g.id),children:w})]},g.id):o.jsx(me.RowButton,{featured:b,onClick:()=>r(g.id),children:w},g.id)}),o.jsx(me.NextPageLoading,{isLoading:c,hasMore:u,setEndOfListElement:l})]})]})}function Oes(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function _es(e,t){return e.length<=t?e:e.slice(0,t-1)+"..."}function Ces(e){const t=e.scorer;return t?.hasJudge===!1?!0:t?.hasJudge===!0?!1:!e.preprocessPrompt&&!e.analyzePrompt&&!e.generateScorePrompt&&!e.generateReasonPrompt}function Ees({score:e,onNext:t,onPrevious:n,onClose:r,onShowTrace:s,collapsed:a,onCollapsedChange:i}){const[l,c]=v.useState(!1),u=a??l,d=i??c,f=Ces(e),p=f?"N/A — code-based scorer":"N/A — step not configured";return o.jsxs(bn,{collapsed:u,children:[o.jsxs(bn.Header,{children:[o.jsxs(bn.Heading,{children:["Score ",o.jsx("b",{children:e.scorerId})]}),o.jsxs($r,{className:"ml-auto shrink-0",children:[i&&o.jsx(ue,{size:"md",tooltip:u?"Expand panel":"Collapse panel",onClick:()=>d(!u),children:u?o.jsx(hlt,{}):o.jsx(plt,{})}),(n||t)&&o.jsx(bn.NextPrevNav,{onPrevious:n,onNext:t,previousLabel:"Previous score",nextLabel:"Next score"}),s&&o.jsxs(ue,{size:"md",onClick:s,disabled:!e.traceId,children:[o.jsx(hTe,{}),"Trace"]}),o.jsx(bn.CloseButton,{onClick:r,tooltip:"Close score panel"})]})]}),!u&&o.jsx(bn.Content,{children:o.jsxs("div",{className:"grid gap-3",children:[o.jsx(bn.CodeSection,{title:`Score: ${e.score}`,icon:o.jsx(Jh,{}),codeStr:e.reason||p,simplified:!0}),!f&&o.jsxs(o.Fragment,{children:[o.jsx(bn.CodeSection,{title:"Preprocess Prompt",icon:o.jsx(bh,{}),codeStr:e.preprocessPrompt||p,simplified:!0}),o.jsx(bn.CodeSection,{title:"Analyze Prompt",icon:o.jsx(bh,{}),codeStr:e.analyzePrompt||p,simplified:!0}),o.jsx(bn.CodeSection,{title:"Generate Score Prompt",icon:o.jsx(bh,{}),codeStr:e.generateScorePrompt||p,simplified:!0}),o.jsx(bn.CodeSection,{title:"Generate Reason Prompt",icon:o.jsx(bh,{}),codeStr:e.generateReasonPrompt||p,simplified:!0})]})]})})]})}const mQe=[{name:"scorer",label:"Scorer",size:"1fr"},{name:"avg",label:"Avg Score",size:"1fr"},{name:"count",label:"Items Scored",size:"1fr"}];function jes({scoresByItemId:e,experimentStatus:t}){const n=v.useMemo(()=>{if(!e)return[];const r={};for(const s of Object.values(e))for(const a of s)r[a.scorerId]||(r[a.scorerId]={sum:0,count:0}),r[a.scorerId].sum+=a.score,r[a.scorerId].count++;return Object.entries(r).map(([s,{sum:a,count:i}])=>({scorerId:s,avg:a/i,count:i})).sort((s,a)=>s.scorerId.localeCompare(a.scorerId))},[e]);if(n.length===0){const r=t==="running"||t==="pending",s=e!==void 0;let a,i;return r?(a="Experiment in progress",i="Summary metrics will appear here once the experiment completes."):s?(a="No scorers configured",i="Add scorers when triggering an experiment to evaluate results and see summary metrics here."):(a="Loading scores",i="Fetching scorer results…"),o.jsx("div",{className:"flex h-full items-center justify-center py-12",children:o.jsx(Lr,{iconSlot:o.jsx(Jh,{className:"w-8 h-8 text-neutral3"}),titleSlot:a,descriptionSlot:i})})}return o.jsxs(gn,{children:[o.jsxs(gn.Header,{columns:mQe,children:[o.jsx(gn.HeaderCol,{children:"Scorer"}),o.jsx(gn.HeaderCol,{children:"Avg Score"}),o.jsx(gn.HeaderCol,{children:"Items Scored"})]}),o.jsx(gn.Scroller,{children:o.jsx(gn.Items,{children:n.map(({scorerId:r,avg:s,count:a})=>o.jsxs(gn.Row,{columns:mQe,children:[o.jsx(gn.TextCell,{children:r}),o.jsx(gn.TextCell,{className:"font-mono",children:s.toFixed(3)}),o.jsx(gn.TextCell,{className:"font-mono",children:a})]},r))})})]})}function o8t({experimentId:e,datasetId:t,experimentStatus:n,results:r,isLoading:s,setEndOfListElement:a,isFetchingNextPage:i,hasNextPage:l}){const[c,u]=v.useState(null),[d,f]=v.useState(null),[p,h]=v.useState(void 0),[m,g]=v.useState(null),[y,b]=v.useState(new Set),[w,S]=v.useState(!1),[k,_]=v.useState(!1),[C,E]=v.useState(!1),[j,N]=v.useState(!1),{updateExperimentResult:I}=_i(),R=v.useCallback(se=>{b(re=>{const he=new Set(re);return he.has(se)?he.delete(se):he.add(se),he})},[]),$=v.useCallback(()=>b(new Set),[]),F=v.useCallback(()=>{const se=r.filter(re=>!!re.error).map(re=>re.id);b(new Set(se))},[r]),D=v.useCallback(async se=>{if(w||se.length===0)return;S(!0);let re=0;const he=new Set;try{for(const xe of se)try{await I.mutateAsync({datasetId:t,experimentId:e,resultId:xe,status:"needs-review"}),re++,he.add(xe)}catch{}}finally{S(!1)}he.size>0&&b(xe=>{const Ee=new Set(xe);for(const Pe of he)Ee.delete(Pe);return Ee}),re>0&&De(`${re} result${re>1?"s":""} flagged for review`)},[t,e,w,I]),V=r.find(se=>se.id===c)??null,[W,L]=v.useState("summary"),[z,B]=v.useState(null),M=se=>{L(se),se!=="reviews"&&B(null)},{data:G}=fTe(t),U=(G??[]).filter(se=>se.experimentId===e).length,{data:P}=E6t(e,n),q=v.useMemo(()=>{if(!P)return[];const se=new Set;for(const re of Object.values(P))for(const he of re)se.add(he.scorerId);return[...se].sort()},[P]),Z=se=>{u(se),f(null),h(void 0),g(null)},X=se=>{Z(se===c?null:se)},te=()=>{Z(null)},J=()=>{if(!V)return;const se=r.findIndex(re=>re.id===V.id);if(se>=0&&se<r.length-1)return()=>Z(r[se+1].id)},ee=()=>{if(!V)return;const se=r.findIndex(re=>re.id===V.id);if(se>0)return()=>Z(r[se-1].id)},ae=V?P?.[V.itemId]:void 0,de=ae?.find(se=>se.id===m)??null,Y=se=>{g(se===m?null:se),f(null),h(void 0)},ne=()=>{if(!m||!ae)return;const se=ae.findIndex(re=>re.id===m);if(se>=0&&se<ae.length-1)return()=>g(ae[se+1].id)},ce=()=>{if(!m||!ae)return;const se=ae.findIndex(re=>re.id===m);if(se>0)return()=>g(ae[se-1].id)},{data:pe,isLoading:le}=bes(d),ve=pe?.spans,{data:ye,isLoading:Se}=aI(d,p),Ne=ye?.span,{handlePreviousSpan:ke,handleNextSpan:Ie}=WH(ve,p??null,h),ze=(()=>{const se=[],re=!!de,he=!!d;return se.push(k?"auto":re||he?"2fr":"1fr"),re&&se.push(j?"auto":"3fr"),he&&se.push(C?"auto":"3fr"),he&&p&&se.push("3fr"),se.join(" ")})(),oe=v.useMemo(()=>[{name:"itemId",label:"Item ID",size:"7rem"},{name:"status",label:"Status",size:"5rem"},{name:"input",label:"Input",size:"minmax(15rem,1fr)"},...q.map(se=>({name:se,label:se,size:"12rem"}))],[q]);return o.jsxs(ru,{defaultTab:"summary",value:W,onValueChange:M,className:"grid grid-rows-[auto_1fr] h-full overflow-hidden",children:[o.jsxs(su,{children:[o.jsx(Vr,{value:"summary",children:"Summary"}),o.jsx(Vr,{value:"results",children:"Results"}),o.jsxs(Vr,{value:"reviews",children:["Reviews",U>0&&o.jsx(Xs,{color:"orange",children:U})]})]}),o.jsx(ps,{value:"summary",className:"overflow-y-auto mt-5",children:o.jsx(jes,{scoresByItemId:P,experimentStatus:n})}),o.jsx(ps,{value:"reviews",className:"overflow-auto mt-2 pb-0",children:o.jsx(i8t,{datasetId:t,experimentId:e,featuredItemId:z})}),o.jsxs(ps,{value:"results",className:"grid grid-rows-[auto_1fr] overflow-hidden mt-2",children:[o.jsxs("div",{className:"mb-4",children:[y.size>0&&o.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-surface3",children:[o.jsxs(ge,{variant:"ui-xs",className:"text-neutral5 font-medium",children:[y.size," selected"]}),o.jsx("div",{className:"flex-1"}),o.jsxs(ue,{variant:"outline",size:"sm",disabled:w,onClick:()=>D([...y]),children:[o.jsx(Ue,{size:"sm",children:o.jsx(GU,{})}),"Flag for Review"]}),o.jsx(ue,{variant:"ghost",size:"sm",onClick:$,children:"Clear"})]}),r.length>0&&y.size===0&&!s&&o.jsx("div",{className:"flex items-center gap-2 px-4 py-2",children:o.jsx(ue,{variant:"ghost",size:"sm",onClick:F,children:"Select loaded failures"})})]}),o.jsxs("div",{className:K("grid w-full h-full grid-cols-1 gap-4 overflow-y-auto",V&&"grid-cols-[1fr_1fr]"),children:[o.jsx("div",{className:"flex overflow-y-auto w-full",children:o.jsx("div",{className:"grid gap-8 content-start w-full overflow-y-auto",children:o.jsx(kes,{results:r,isLoading:s,featuredResultId:c,onResultClick:X,columns:oe,scoresByItemId:P,scorerIds:q,setEndOfListElement:a,isFetchingNextPage:i,hasNextPage:l,selectedIds:y,onToggleSelect:R})})}),V&&o.jsxs("div",{className:"grid gap-4 max-h-full min-h-0 overflow-auto content-start",style:{gridTemplateRows:ze},children:[o.jsx(Ses,{result:V,scores:ae,onPrevious:ee(),onNext:J(),onClose:te,onScoreClick:Y,featuredScoreId:m,onShowTrace:()=>{V.traceId&&(f(V.traceId),h(void 0),g(null),_(!0),E(!1))},onOpenInReview:()=>{B(V.id),L("reviews")},onFlagForReview:se=>D([se]),collapsed:k,onCollapsedChange:_}),de&&o.jsx(Ees,{score:de,onNext:ne(),onPrevious:ce(),onClose:()=>g(null),onShowTrace:()=>{de.traceId&&(f(de.traceId),h(void 0),_(!0),N(!0),E(!1))},collapsed:j,onCollapsedChange:N}),d&&o.jsxs(o.Fragment,{children:[o.jsx(sTe,{traceId:d,spans:ve,isLoading:le,onClose:()=>{f(null),h(void 0),_(!1),N(!1)},onSpanSelect:h,initialSpanId:p??null,placement:"traces-list",showUnavailableFeaturesMsg:!1,collapsed:C,onCollapsedChange:E,LinkComponent:R3,traceHref:`/traces/${d}`}),p&&o.jsx(qH,{traceId:d,spanId:p,span:Ne,isLoading:Se,onPrevious:ke,onNext:Ie,onClose:()=>h(void 0)})]})]})]})]})]})}const Tes={pending:o.jsx(sO,{}),running:o.jsx(Fde,{}),completed:o.jsx(Js,{}),failed:o.jsx(vs,{})};function Nes({experiment:e,className:t}){const n=e.status,r=e.totalItems-e.succeededCount-e.failedCount;return o.jsxs("div",{className:K("grid justify-items-end gap-3",t),children:[o.jsxs("div",{className:"flex p-1 px-3 text-ui-lg capitalize text-neutral4 gap-2 items-center bg-surface5 rounded-lg ",children:[o.jsx("span",{className:K("w-5 h-5 flex items-center justify-center rounded-full text-black","[&>svg]:w-4 [&>svg]:h-4",{"bg-green-700":n==="completed","bg-red-700":n==="failed","bg-cyan-600":n==="running","bg-yellow-600":n==="pending"}),children:Tes[n]}),e.status]}),o.jsxs("div",{className:K("flex items-center gap-3 text-neutral3 text-ui-md ","[&>span]:flex [&>span]:gap-1 [&>span]:items-center ","[&_b]:text-neutral4 [&_b]:font-semibold"),children:[o.jsxs("span",{children:["Total: ",o.jsx("b",{children:e.totalItems})]}),o.jsxs("span",{children:["Succeeded: ",o.jsx("b",{children:e.succeededCount})]}),o.jsxs("span",{children:["Failed: ",o.jsx("b",{children:e.failedCount})]}),(n==="pending"||n==="running")&&o.jsxs("span",{children:["Pending: ",o.jsx("b",{children:r})]})]})]})}function Ies({onPrevious:e,onNext:t,previousAriaLabel:n="Previous",nextAriaLabel:r="Next"}){return o.jsxs($r,{spacing:"close",children:[o.jsxs(ue,{onClick:e,disabled:!e,"aria-label":n,children:[o.jsx($q,{})," Prev"]}),o.jsxs(ue,{onClick:t,disabled:!t,"aria-label":r,children:["Next",o.jsx(Rq,{})]})]})}function mTe({delta:e}){const t=e>0?o.jsx(Xs,{size:"small",color:"green",intensity:"muted",children:o.jsx(i3,{})}):e<0?o.jsx(Xs,{size:"small",color:"red",intensity:"muted",children:o.jsx(Gon,{})}):null;return o.jsxs("span",{className:K("font-mono text-sm text-neutral4 min-w-20"),children:[o.jsx("span",{className:"w-3 inline-block",children:e>0?"+ ":e<0?"- ":""}),Math.abs(e).toFixed(2)," ",t]})}function q8(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function Aes({item:e,baselineId:t,contenderId:n,baselineVersion:r,contenderVersion:s,onPrevious:a,onNext:i,onClose:l}){const c=e.results[t],u=e.results[n],d=!!(c&&u),f=new Set;if(c)for(const h of Object.keys(c.scores))f.add(h);if(u)for(const h of Object.keys(u.scores))f.add(h);const p=[...f].sort();return o.jsxs(Gr,{withLeftSeparator:!0,children:[o.jsxs(Gr.Toolbar,{children:[o.jsx(Ies,{onPrevious:a,onNext:i,previousAriaLabel:"Previous comparison item",nextAriaLabel:"Next comparison item"}),o.jsx($r,{children:o.jsx(ue,{onClick:l,"aria-label":"Close comparison detail panel",children:o.jsx(vs,{})})})]}),o.jsxs(Gr.Content,{className:"pb-6",children:[o.jsx(ua,{withMargins:!1,children:o.jsx(ua.Column,{children:o.jsxs(ua.Title,{size:"smaller",children:[o.jsx(dN,{})," ",e.itemId]})})}),d?o.jsx(o.Fragment,{children:o.jsxs(Rje,{children:[p.length>0&&o.jsxs("div",{className:"grid gap-3",children:[o.jsx("h4",{className:"text-sm font-medium text-neutral5",children:"Scores"}),o.jsx("div",{className:"grid gap-2",children:p.map(h=>{const m=c?.scores[h]??null,g=u?.scores[h]??null,y=m!=null&&g!=null?g-m:null;return o.jsxs("div",{className:"flex items-center justify-between gap-4 px-3 py-2 rounded-lg bg-surface2",children:[o.jsx("span",{className:"text-sm text-neutral5 font-medium",children:h}),o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("span",{className:"text-sm text-neutral3",children:[m!=null?m.toFixed(3):"-"," →"," ",g!=null?g.toFixed(3):"-"]}),y!=null&&o.jsx(mTe,{delta:y})]})]},h)})})]}),o.jsx(Ps.CodeSection,{title:o.jsxs(o.Fragment,{children:[o.jsx(Xs,{color:"purple",children:"Baseline "})," Experiment Output"]}),icon:o.jsx(hg,{}),codeStr:q8(c?.output)}),o.jsx(Ps.CodeSection,{title:o.jsxs(o.Fragment,{children:[o.jsx(Xs,{color:"cyan",children:"Contender "})," Experiment Output"]}),icon:o.jsx(hg,{}),codeStr:q8(u?.output)}),o.jsx(Ps.CodeSection,{title:"Item Input",icon:o.jsx(aO,{}),codeStr:q8(e.input)}),o.jsx(Ps.CodeSection,{title:"Item Ground Truth",icon:o.jsx(Xye,{}),codeStr:q8(e.groundTruth)})]})}):o.jsx(In,{variant:"warning",title:"Comparison not available",children:o.jsx(In.Message,{children:(()=>{const h=c?"Contender":"Baseline",m=c?s:r;return o.jsxs(o.Fragment,{children:["The ",h," experiment was run against dataset",m!=null?` v. ${m}`:"",", which does not contain this item."]})})()})})]})]})}function Res({items:e,baselineId:t,contenderId:n,scorerIds:r,featuredItemId:s,columns:a,onItemClick:i}){return o.jsx(Gr,{children:o.jsxs(gn,{children:[o.jsxs(gn.Header,{columns:a,children:[o.jsx(gn.HeaderCol,{children:"Item ID"}),!s&&r.map(l=>o.jsx(gn.HeaderCol,{className:"flex justify-center",children:l},l))]}),o.jsx(gn.Scroller,{children:o.jsx(gn.Items,{children:e.map(l=>{const c=l.results[t],u=l.results[n],d=!!(c&&u);return o.jsx(gn.Row,{children:o.jsxs(gn.RowButton,{item:{id:l.itemId},columns:a,isFeatured:s===l.itemId,onClick:i,children:[o.jsx(gn.IdCell,{id:l.itemId,className:d?"":"text-neutral1"}),!s&&o.jsx(o.Fragment,{children:r.map(f=>{const p=c?.scores[f]??null,h=u?.scores[f]??null,m=p!=null&&h!=null?h-p:null;return o.jsx(gn.Cell,{className:"flex items-center gap-5 justify-center font-mono",children:m!=null?o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"flex items-center text-neutral2 min-w-24",children:[p?.toFixed(2)," → ",h?.toFixed(2)]}),o.jsx(mTe,{delta:m})]}):o.jsx("span",{className:"text-neutral1",children:"-"})},f)})})]})},l.itemId)})})})]})})}const Pes={baseline:{label:"Baseline",color:"purple",customStyle:"items-end justify-items-end [&>div]:justify-end border-r-0 rounded-r-none"},contender:{label:"Contender",color:"cyan",customStyle:"items-start justify-items-start [&>div]:justify-start border-l-0 rounded-l-none"}};function gQe({datasetId:e,experiment:t,type:n}){const{Link:r}=yn(),{label:s,color:a,customStyle:i}=Pes[n];if(!t)return null;const l=t.createdAt?new Date(t.createdAt):null;return o.jsxs("div",{className:`grid border-2 border-border1 rounded-lg p-5 gap-3 ${i}`,children:[o.jsxs("div",{className:"flex items-center gap-3 w-full overflow-clip",children:[n==="contender"&&o.jsxs(Xs,{size:"small",color:a,children:[s,o.jsx(hm,{})]}),o.jsx(ue,{as:r,href:`/datasets/${e}/experiments/${t.id}`,children:o.jsx("span",{className:"truncate min-w-0",children:t.id})}),n==="baseline"&&o.jsxs(Xs,{size:"small",color:a,children:[o.jsx(Ec,{})," ",s]})]}),o.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-ui-sm text-neutral3",children:[o.jsxs(Nl,{children:[o.jsx(Xye,{})," ",t.targetType," / ",t.targetId]}),o.jsxs(Nl,{children:[o.jsx(XU,{})," v",t.datasetVersion??"—"]}),l&&o.jsxs(Nl,{children:[o.jsx(dlt,{})," ",er(l,"MMM d, yyyy HH:mm")]})]})]})}function $es({datasetId:e,experimentIdA:t,experimentIdB:n,onSwap:r}){const[s,a]=v.useState(null),{data:i,isLoading:l,error:c}=kKr(e,t,n),{data:u}=_U(e,t),{data:d}=_U(e,n),f=u&&d&&u.datasetVersion!==d.datasetVersion,p=v.useMemo(()=>{if(!i)return[];const E=new Set;for(const j of i.items)for(const N of Object.values(j.results))if(N)for(const I of Object.keys(N.scores))E.add(I);return[...E].sort()},[i]),h=v.useMemo(()=>{if(!i||p.length===0)return[];const E=i.baselineId,j=t===E?n:t;return p.map(N=>{let I=0,R=0,$=0,F=0;for(const L of i.items){const z=L.results[E]?.scores[N],B=L.results[j]?.scores[N];z!=null&&(I+=z,$++),B!=null&&(R+=B,F++)}const D=$>0?I/$:null,V=F>0?R/F:null,W=D!=null&&V!=null?V-D:null;return{scorerId:N,avgA:D,avgB:V,delta:W}})},[i,p,t,n]),m=[{name:"scorer",label:"Scorer",size:"1fr"},{name:"baselineAvg",label:"Baseline Avg",size:"1fr"},{name:"comparisonAvg",label:"Comparison Avg",size:"1fr"},{name:"delta",label:"Delta",size:"1fr"}],g=v.useMemo(()=>[{name:"itemId",label:"Item ID",size:"8rem"},...s?[]:p.map(E=>({name:E,label:E,size:"1fr"}))],[p,s]),y=i?.items.find(E=>E.itemId===s)??null,b=E=>{a(E===s?null:E)},w=()=>{a(null)},S=()=>{if(!i||!s)return;const E=i.items.findIndex(j=>j.itemId===s);if(E>=0&&E<i.items.length-1)return()=>a(i.items[E+1].itemId)},k=()=>{if(!i||!s)return;const E=i.items.findIndex(j=>j.itemId===s);if(E>0)return()=>a(i.items[E-1].itemId)};if(l)return o.jsx("div",{className:"flex items-center justify-center h-64",children:o.jsx(Gt,{})});if(c)return o.jsx(In,{variant:"warning",title:"Error loading comparison",children:o.jsx(In.Message,{children:c instanceof Error?c.message:"Unknown error"})});if(!i||i.items.length===0)return o.jsx("div",{className:"text-neutral4 text-sm text-center py-8",children:"No comparison data"});const _=i.baselineId,C=t===_?n:t;return o.jsxs("div",{className:"grid gap-10",children:[u&&d&&o.jsxs("div",{className:K("relative grid xl:grid-cols-[1fr_auto_1fr] gap-4 xl:gap-0"),children:[o.jsx(gQe,{datasetId:e,experiment:u,type:"baseline"}),o.jsx("div",{className:"relative flex items-center justify-center px-[2vw] before:absolute before:inset-y-0 before:left-1/2 before:-translate-x-1/2 before:w-[2px] before:bg-border1",children:o.jsx("div",{className:"relative z-1 bg-surface2 rounded-lg p-2",children:o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx(ue,{onClick:r,children:"VS"})}),o.jsx(Bn,{children:"Switch the order"})]})})}),o.jsx(gQe,{datasetId:e,experiment:d,type:"contender"})]}),f&&o.jsx(In,{variant:"warning",title:"Version mismatch",children:o.jsxs(In.Message,{children:["These experiments used different dataset versions (v",u.datasetVersion," vs v",d.datasetVersion,"). Results may not be directly comparable."]})}),h.length>0&&o.jsxs(gn,{children:[o.jsxs(gn.Header,{columns:m,children:[o.jsx(gn.HeaderCol,{children:"Scorer"}),o.jsx(gn.HeaderCol,{className:"flex justify-center",children:o.jsxs(vGe,{children:[o.jsx(Xs,{color:"purple",size:"small",intensity:"muted",children:"Baseline"}),o.jsx(Xs,{color:"purple",size:"small",children:"Avg"})]})}),o.jsx(gn.HeaderCol,{className:"flex justify-center",children:o.jsxs(vGe,{children:[o.jsx(Xs,{color:"cyan",size:"small",intensity:"muted",children:"Contender"}),o.jsx(Xs,{color:"cyan",size:"small",children:"Avg"})]})}),o.jsx(gn.HeaderCol,{className:"flex justify-center",children:"Delta"})]}),o.jsx(gn.Scroller,{children:o.jsx(gn.Items,{children:h.map(({scorerId:E,avgA:j,avgB:N,delta:I})=>o.jsxs(gn.Row,{columns:m,children:[o.jsx(gn.TextCell,{children:E}),o.jsx(gn.TextCell,{className:"text-center font-mono",children:j!=null?j.toFixed(3):"-"}),o.jsx(gn.TextCell,{className:"text-center font-mono",children:N!=null?N.toFixed(3):"-"}),o.jsx(gn.TextCell,{className:"flex justify-center",children:I!=null?o.jsx(mTe,{delta:I}):"-"})]},E))})})]}),o.jsxs(ry,{className:K({"grid-cols-[1fr_2fr]":!!y}),children:[o.jsx(Res,{items:i.items,baselineId:_,contenderId:C,scorerIds:p,featuredItemId:s,columns:g,onItemClick:b}),!!y&&o.jsx(Aes,{item:y,baselineId:_,contenderId:C,baselineVersion:u?.datasetVersion,contenderVersion:d?.datasetVersion,onPrevious:k(),onNext:S(),onClose:w})]})]})}function Mes({datasetId:e,itemId:t,onVersionSelect:n,onCompareVersionsClick:r,activeVersion:s}){const{data:a,isLoading:i}=cTe(e,t),[l,c]=v.useState(!1),[u,d]=v.useState(new Set),f=b=>{n?.(b)},p=b=>s==null?b.isLatest:b.datasetVersion===s,h=b=>{d(w=>{const S=new Set(w);if(S.has(b))S.delete(b);else if(S.size>=2){const[k]=Array.from(S);return new Set([k,b])}else S.add(b);return S})},m=()=>{c(!1),d(new Set)},g=()=>{c(!0)},y=()=>{u.size===2&&r?.([...u])};return o.jsxs(Gr,{className:"min-w-56",children:[l?o.jsx(Gr.Toolbar,{className:"grid justify-stretch gap-3 w-full",children:o.jsxs($r,{children:[o.jsx(ue,{onClick:m,children:"Cancel"}),o.jsx(ue,{variant:"primary",disabled:u.size!==2,onClick:y,tooltip:u.size!==2?"Check 2 versions to compare":void 0,className:"grow",children:"Compare"})]})}):o.jsx(o.Fragment,{children:(a||[]).length>1&&o.jsx(Gr.Toolbar,{children:o.jsxs(ue,{onClick:g,className:"w-full",children:[o.jsx(Qw,{})," Compare Ver."]})})}),i?o.jsx(Des,{}):o.jsxs(gn,{children:[o.jsx(gn.Header,{children:o.jsx(gn.HeaderCol,{children:"Item Version History"})}),o.jsx(gn.Scroller,{children:o.jsx(gn.Items,{children:a?.map(b=>{const w=String(b.datasetVersion),S=typeof b.updatedAt=="string"?new Date(b.updatedAt):b.updatedAt;return o.jsxs(gn.Row,{isSelected:l&&u.has(w),children:[l&&o.jsx(gn.LabelCell,{children:o.jsx($o,{checked:u.has(w),disabled:b.isDeleted,onCheckedChange:()=>{},onClick:k=>{k.stopPropagation(),b.isDeleted||h(w)},"aria-label":`Select version ${b.datasetVersion}`})}),o.jsx(gn.RowButton,{item:b,columns:[{name:"version",label:"Item Version History",size:"1fr"}],isFeatured:p(b),onClick:()=>f(b),className:"py-2",children:o.jsx(gn.VersionCell,{version:b.datasetVersion,date:S,isLatest:b.isLatest,isDeleted:b.isDeleted})})]},String(b.datasetVersion))})})})]})]})}function Des(){return o.jsxs(gn,{children:[o.jsx(gn.Header,{columns:[{name:"version",label:"Item Version History",size:"1fr"}],children:o.jsx(gn.HeaderCol,{children:"Item Version History"})}),o.jsx(gn.Items,{children:Array.from({length:3}).map((e,t)=>o.jsx(gn.Row,{children:o.jsx(gn.RowButton,{columns:[{name:"version",label:"Item Version History",size:"1fr"}],children:o.jsx(gn.TextCell,{isLoading:!0,children:"Loading..."})})},t))})]})}function Les(e,t){if(t){const n=typeof t=="string"?new Date(t):t;return`v${e} ${er(n,"MMM dd 'at' H:mm:ss a")}`}return`v${e}`}function Fes({datasetId:e,versionA:t,versionB:n,onVersionChange:r}){const{data:s}=Yje(e),a=(s??[]).map(i=>({value:String(i.version),label:`${Les(i.version,i.createdAt)}${i.isCurrent?" (current)":""}`}));return o.jsxs(Gr.Toolbar,{className:"grid grid-cols-[1fr_1fr_1fr_10rem] gap-4 w-full",children:[o.jsx("div",{}),o.jsx(xc,{label:"Version A",labelIsHidden:!0,name:"version-a",placeholder:"Select version",options:a,value:t??"",onValueChange:i=>r?.(i,n??"")}),o.jsx(xc,{label:"Version B",labelIsHidden:!0,name:"version-b",options:a,value:n??"",onValueChange:i=>r?.(t??"",i)}),o.jsx("div",{})]})}const zes=[{name:"id",label:"ID",size:"1fr"},{name:"versionA",label:"Version A",size:"1fr"},{name:"versionB",label:"Version B",size:"1fr"},{name:"compare",label:"Compare",size:"10rem"}],Bes={added:{color:"blue",borderColor:"border-blue-900",icon:o.jsx(Fr,{}),tooltip:"Added in this version"},changed:{color:"orange",borderColor:"border-yellow-900",icon:o.jsx(Nlt,{}),tooltip:"Changed in this version"},same:{color:"green",borderColor:"border-green-900",icon:o.jsx(ycn,{}),tooltip:"Same in both versions"}};function Fre({red:e=!1,tooltip:t}){return o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx(sln,{className:K("text-neutral3/40 w-5 h-5 ",{"text-red-900":e})})}),t&&o.jsx(Bn,{children:t})]})}function VS({variant:e,version:t}){if(!e)return o.jsxs("span",{className:"text-ui-md text-neutral4",children:["v. ",t]});const{color:n,icon:r,tooltip:s}=Bes[e];return o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsxs("div",{className:"grid grid-cols-[1fr_auto]",children:[t!==void 0&&o.jsxs("span",{className:"pr-3 text-ui-md text-neutral4 min-w-16 flex justify-end",children:["v. ",t]}),o.jsx(Xs,{color:n,size:"small",children:r})]})}),o.jsx(Bn,{children:s})]})}function Ues(e,t){return e&&t&&e.datasetVersion===t.datasetVersion?"same":e&&t&&e.datasetVersion!==t.datasetVersion?"changed":e?"added":"removed"}function qes({datasetId:e,versionA:t,versionB:n,allItems:r,itemsAMap:s,itemsBMap:a}){const{Link:i}=yn(),l=t>n;return o.jsx(gn,{children:o.jsx(gn.Scroller,{children:o.jsx(gn.Items,{children:r.map(({id:c})=>{const u=s.get(c),d=a.get(c),f=Ues(u,d);return o.jsxs(gn.Row,{columns:zes,children:[o.jsx(gn.IdCell,{id:c,isShortened:!1}),f!=="same"?o.jsxs(o.Fragment,{children:[u?.datasetVersion?o.jsx(gn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}`,className:"gap-2",children:!d&&l?o.jsx(VS,{variant:"added",version:u.datasetVersion}):f==="changed"&&l?o.jsx(VS,{variant:"changed",version:u.datasetVersion}):o.jsx(VS,{version:u.datasetVersion})}):o.jsx(gn.Cell,{className:"justify-center flex items-center",children:o.jsx(Fre,{red:l,tooltip:l?"Deleted in this version":"Not present in this version"})}),d?.datasetVersion?o.jsx(gn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}`,className:"gap-2",children:!u&&!l?o.jsx(VS,{variant:"added",version:d.datasetVersion}):f==="changed"&&!l?o.jsx(VS,{variant:"changed",version:d.datasetVersion}):o.jsx(VS,{version:d.datasetVersion})}):o.jsx(gn.Cell,{className:"justify-center flex items-center",children:o.jsx(Fre,{red:!l,tooltip:l?"Not present in this version":"Deleted in this version"})})]}):o.jsx(gn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}`,className:"col-span-2 gap-2",children:o.jsx(VS,{variant:"same",version:d?.datasetVersion})}),f==="changed"?o.jsx(gn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}/versions?ids=${u?.datasetVersion},${d?.datasetVersion}`,children:"Compare"}):o.jsx(gn.Cell,{children:o.jsx(Fre,{tooltip:o.jsxs(o.Fragment,{children:["Comparing is available",o.jsx("br",{})," only for changed items"]})})})]},c)})})})})}const vQe={needsReview:"#facc15",complete:"#22c55e"},Ves=[{label:"Needs Review",color:vQe.needsReview},{label:"Reviewed",color:vQe.complete}];function Hes({reviewSummary:e,experiments:t,datasets:n,isLoading:r,isError:s}){const{data:a,maxVal:i,totalInPipeline:l}=v.useMemo(()=>{if(!e?.counts||!t)return{data:[],maxVal:0,totalInPipeline:0};const u=new Map;for(const m of t)u.set(m.id,m);const d=new Map;if(n)for(const m of n)d.set(m.id,m.name);let f=0,p=0;const h=[];for(const m of e.counts){const g=m.needsReview+m.complete;if(g===0)continue;p+=g,g>f&&(f=g);const y=u.get(m.experimentId),b=y?.datasetId?d.get(y.datasetId):void 0,w=b?`${b} · ${m.experimentId.slice(0,8)}`:m.experimentId.slice(0,8);h.push({name:w,values:[m.needsReview,m.complete]})}return{data:h,maxVal:f,totalInPipeline:p}},[e,t,n]),c=a.length>0;return o.jsxs(Bt,{children:[o.jsxs(Bt.TopBar,{children:[o.jsx(Bt.TitleAndDescription,{title:"Review Pipeline",description:"Items in review across experiments."}),c&&o.jsx(Bt.Summary,{value:String(l),label:"Items in pipeline"})]}),r?o.jsx(Bt.Loading,{}):s?o.jsx(Bt.Error,{message:"Failed to load review data"}):o.jsx(Bt.Content,{children:c?o.jsx(aN,{data:a,segments:Ves,maxVal:i,fmt:u=>String(u)}):o.jsx(Bt.NoData,{message:"No items have been sent to review yet"})})]})}function gTe(){const e=We();return wt({queryKey:["experiment-review-summary"],queryFn:()=>e.getExperimentReviewSummary()})}function l8t(e){const t=new Map;if(!e?.counts)return t;for(const n of e.counts)t.set(n.experimentId,{needsReview:n.needsReview,complete:n.complete,total:n.total});return t}function Wes(e,t){const n=new Map,r=l8t(e);if(!r.size||!t)return n;for(const s of t){const a=r.get(s.id);if(!a||!s.datasetId||a.needsReview+a.complete===0)continue;const l=n.get(s.datasetId)??{needsReview:0,complete:0};l.needsReview+=a.needsReview,l.complete+=a.complete,n.set(s.datasetId,l)}return n}function Zes(e){return e?.counts?e.counts.reduce((t,n)=>({needsReview:t.needsReview+n.needsReview,complete:t.complete+n.complete,inPipeline:t.inPipeline+n.needsReview+n.complete}),{needsReview:0,complete:0,inPipeline:0}):{needsReview:0,complete:0,inPipeline:0}}const Ges=10;function Qes(){const[e,t]=v.useState(!1),[n,r]=v.useState(""),[s,a]=v.useState("all"),[i,l]=v.useState("all"),[c,u]=v.useState("all"),[d,f]=v.useState(0),{data:p,isLoading:h,error:m}=Rg({page:d,perPage:Ges}),{data:g,isLoading:y,error:b}=zZ(),{data:w}=gTe(),S=v.useMemo(()=>p?.datasets??[],[p?.datasets]),k=p?.pagination?.hasMore??!1,_=v.useMemo(()=>g?.experiments??[],[g?.experiments]),C=v.useMemo(()=>BKr(S),[S]),E=v.useMemo(()=>Wes(w,_),[w,_]),j=h||y,N=m||b,I=()=>t(!0),R=v.useCallback(()=>f(B=>B+1),[]),$=v.useCallback(()=>f(B=>Math.max(0,B-1)),[]),F=v.useCallback(B=>{r(B),f(0)},[]),D=v.useCallback(B=>{a(B),f(0)},[]),V=v.useCallback(B=>{l(B),f(0)},[]),W=v.useCallback(B=>{u(B),f(0)},[]);if(N&&gs(N))return o.jsx(lr,{children:o.jsx(Vs,{})});if(N&&ys(N))return o.jsx(lr,{children:o.jsx(Ds,{resource:"datasets"})});if(N)return o.jsx(lr,{children:o.jsx(Fi,{title:"Failed to load datasets",message:N.message})});if(S.length===0&&!j&&d===0)return o.jsxs(o.Fragment,{children:[o.jsx(lr,{children:o.jsx(WKr,{onCreateClick:I})}),o.jsx(Eve,{open:e,onOpenChange:t})]});const L=s!=="all"||i!=="all"||c!=="all"||n!=="",z=()=>{r(""),a("all"),l("all"),u("all"),f(0)};return o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx(QKr,{search:n,onSearchChange:F,targetFilter:s,onTargetFilterChange:D,experimentFilter:i,onExperimentFilterChange:V,tagFilter:c,onTagFilterChange:W,tagOptions:C,onReset:z,hasActiveFilters:L,onCreateClick:I})}),o.jsx(HKr,{datasets:S,experiments:_,reviewByDataset:E,isLoading:j,search:n,targetFilter:s,experimentFilter:i,tagFilter:c,currentPage:d,hasMore:k,onNextPage:R,onPrevPage:$}),o.jsx(Eve,{open:e,onOpenChange:t})]})}function V8({children:e}){return o.jsxs(Lt,{height:"full",children:[o.jsx("div",{}),o.jsx(Lt.MainArea,{isCentered:!0,children:e})]})}function Yes(){const{datasetId:e}=dr(),t=bs(),[n,r]=ji(),{activeVersion:s}=uTe(n,r),[a,i]=v.useState(!1),[l,c]=v.useState(!1),[u,d]=v.useState(!1),[f,p]=v.useState(!1),[h,m]=v.useState(!1),{data:g,error:y,isLoading:b}=Ux(e),{data:w=[],isLoading:S}=_1(e,void 0,s),k=!S&&w.length===0;if(b)return null;if(y&&gs(y))return o.jsx(V8,{children:o.jsx(Vs,{})});if(y&&ys(y))return o.jsx(V8,{children:o.jsx(Ds,{resource:"datasets"})});if(y&&z1e(y)||!b&&!y&&!g)return o.jsx(V8,{children:o.jsx(Lr,{iconSlot:o.jsx(ay,{}),titleSlot:"Dataset not found",descriptionSlot:`No dataset with id "${e}".`,actionSlot:o.jsxs(ue,{as:ci,to:"/datasets",children:[o.jsx(Ec,{}),"Back to Datasets"]})})});if(y)return o.jsx(V8,{children:o.jsx(Fi,{title:"Failed to load dataset",message:y instanceof Error?y.message:"An unexpected error occurred. Please try again."})});const _=E=>{t(`/datasets/${e}/experiments/${E}`)},C=()=>{t("/datasets")};return o.jsxs(o.Fragment,{children:[o.jsxs(Lt,{height:"full",children:[o.jsx(Lt.TopArea,{children:o.jsxs(Lt.Row,{children:[o.jsxs(Lt.Column,{children:[g?.description&&o.jsx("p",{className:"text-ui-smd text-neutral3 mb-1",children:g.description}),o.jsxs(zt,{numOfCol:2,children:[o.jsx(zt.Key,{children:"Created at"}),o.jsx(zt.Value,{children:g?.createdAt?er(new Date(g.createdAt),"MMM d, yyyy"):""}),o.jsx(zt.Key,{children:"Latest version"}),o.jsxs(zt.Value,{children:["v",g?.version??""]})]})]}),o.jsx(Lt.Column,{children:o.jsxs($r,{children:[k?o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx("span",{className:"cursor-not-allowed",children:o.jsx("div",{className:"pointer-events-none opacity-50",inert:!0,"aria-disabled":"true",children:o.jsxs(ue,{variant:"primary",children:[o.jsx(Pp,{}),s!=null?`Run on v${s}`:"Run Experiment"]})})})}),o.jsx(Bn,{children:"Add items to the dataset before running an experiment"})]}):o.jsxs(ue,{variant:"primary",onClick:()=>i(!0),children:[o.jsx(Pp,{}),s!=null?`Run on v${s}`:"Run Experiment"]}),o.jsxs(ft,{children:[o.jsx(ft.Trigger,{asChild:!0,children:o.jsx(ue,{size:"lg","aria-label":"Dataset actions menu",children:o.jsx(l3,{})})}),o.jsxs(ft.Content,{align:"end",className:"w-48",children:[o.jsxs(ft.Item,{onSelect:()=>d(!0),children:[o.jsx(em,{})," Edit Dataset"]}),o.jsxs(ft.Item,{onSelect:()=>m(!0),children:[o.jsx(Rp,{})," Duplicate Dataset"]}),o.jsxs(ft.Item,{onSelect:()=>p(!0),className:"text-red-500 focus:text-red-400",children:[o.jsx(Jc,{})," Delete Dataset"]})]})]})]})})]})}),o.jsx(Lt.MainArea,{children:o.jsx(ues,{datasetId:e,onAddItemClick:()=>c(!0)})})]}),o.jsx(yes,{datasetId:e,version:s??void 0,requestContextSchema:g?.requestContextSchema,open:a,onOpenChange:i,onSuccess:_}),o.jsx(fes,{datasetId:e,open:l,onOpenChange:c}),g&&o.jsx(tJr,{open:u,onOpenChange:d,dataset:{id:g.id,name:g.name,description:g?.description||"",targetType:g.targetType,inputSchema:g.inputSchema,groundTruthSchema:g.groundTruthSchema,requestContextSchema:g.requestContextSchema}}),g&&o.jsx(KKr,{open:h,onOpenChange:m,sourceDatasetId:g.id,sourceDatasetName:g.name,sourceDatasetDescription:g.description,sourceDatasetTargetType:g.targetType}),g&&o.jsx(rJr,{open:f,onOpenChange:p,datasetId:g.id,datasetName:g.name,onSuccess:C})]})}function c8t({experiment:e}){const{Link:t,paths:n}=yn(),{data:r}=Sm(),{data:s}=By(),{data:a}=eh(),i=()=>{switch(e.targetType){case"agent":return n.agentLink(e.targetId);case"workflow":return n.workflowLink(e.targetId);case"scorer":return n.scorerLink(e.targetId);default:return"#"}},l=()=>{const u=e.targetId;if(!u)return u;switch(e.targetType){case"agent":return r?.[u]?.name??u;case"workflow":return s?.[u]?.name??u;case"scorer":return a?.[u]?.scorer?.config?.name??u;default:return u}},c=e.agentVersion&&e.targetType==="agent"&&e.targetId?`${n.agentLink(e.targetId)}/editor?version=${encodeURIComponent(e.agentVersion)}`:null;return o.jsx(Lt.TopArea,{children:o.jsxs(Lt.Row,{children:[o.jsx(Lt.Column,{children:o.jsxs(zt,{numOfCol:2,children:[o.jsx(zt.Key,{children:"Created at"}),o.jsx(zt.Value,{children:er(new Date(e.createdAt),"MMM d, yyyy 'at' h:mm a")}),e.completedAt&&o.jsxs(o.Fragment,{children:[o.jsx(zt.Key,{children:"Completed at"}),o.jsx(zt.Value,{children:er(new Date(e.completedAt),"MMM d, yyyy 'at' h:mm a")})]}),o.jsx(zt.Key,{children:"Target"}),o.jsx(zt.ValueLink,{href:i(),as:t,children:l()}),e.agentVersion&&o.jsxs(o.Fragment,{children:[o.jsx(zt.Key,{children:"Version"}),c?o.jsx(zt.ValueLink,{href:c,as:t,children:e.agentVersion}):o.jsx(zt.Value,{children:e.agentVersion})]})]})}),o.jsx(Lt.Column,{children:o.jsx(Nes,{experiment:e})})]})})}function H8({children:e}){return o.jsxs(Lt,{height:"full",children:[o.jsx("div",{}),o.jsx(Lt.MainArea,{isCentered:!0,children:e})]})}function Xes(){const{datasetId:e,experimentId:t}=dr(),{data:n,isLoading:r,error:s}=_U(e,t),{data:a,isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u}=$Z({datasetId:e,experimentId:t,experimentStatus:n?.status});return!e||!t||r?null:s&&gs(s)?o.jsx(H8,{children:o.jsx(Vs,{})}):s&&ys(s)?o.jsx(H8,{children:o.jsx(Ds,{resource:"datasets"})}):s&&z1e(s)||!r&&!s&&!n?o.jsx(H8,{children:o.jsx(Lr,{iconSlot:o.jsx(Bye,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${t}".`,actionSlot:o.jsxs(ue,{as:ci,to:`/datasets/${e}?tab=experiments`,children:[o.jsx(Ec,{}),"Back to Dataset"]})})}):s?o.jsx(H8,{children:o.jsx(Fi,{title:"Failed to load experiment",message:s instanceof Error?s.message:"An unexpected error occurred. Please try again."})}):o.jsxs(Lt,{height:"full",children:[o.jsx(c8t,{experiment:n}),o.jsx(Lt.MainArea,{children:o.jsx(o8t,{experimentId:t,datasetId:e,experimentStatus:n.status,results:a??[],isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u})})]})}function Kes(){const{datasetId:e}=dr(),[t,n]=ji(),{error:r}=Ux(e??""),s=t.get("baseline")??"",a=t.get("contender")??"";return r&&gs(r)?o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):r&&ys(r)?o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ds,{resource:"datasets"})})}):!e||!s||!a?o.jsx(cs,{children:o.jsx(xy,{children:o.jsxs("div",{className:"text-neutral4 text-center py-8",children:[o.jsx("p",{children:"Select two experiments to compare."}),o.jsxs("p",{className:"text-sm mt-2",children:["Use the URL format: /datasets/","{datasetId}","/experiments?baseline=","{experimentIdA}","&contender=","{experimentIdB}"]})]})})}):o.jsx(cs,{children:o.jsx(xy,{children:o.jsxs("div",{className:"max-w-[100rem] w-full px-12 mx-auto grid content-start ",children:[o.jsxs(ua,{children:[o.jsxs(ua.Column,{children:[o.jsxs(ua.Title,{children:[o.jsx(Qw,{})," Dataset Experiments Comparison"]}),o.jsxs(ua.Description,{children:["Comparing"," ",o.jsx(ci,{to:`/datasets/${e}/experiments/${s}`,children:s.slice(0,8)})," vs"," ",o.jsx(ci,{to:`/datasets/${e}/experiments/${a}`,children:a.slice(0,8)})]})]}),o.jsx(ua.Column,{children:o.jsxs(ue,{as:ci,to:`/datasets/${e}`,children:[o.jsx(Ec,{}),"Back to Dataset"]})})]}),o.jsx($es,{datasetId:e,experimentIdA:s,experimentIdB:a,onSwap:()=>{n({baseline:a,contender:s})}})]})})})}function Jes(){const{datasetId:e,itemId:t}=dr(),{Link:n}=yn(),r=bs(),{data:s,isLoading:a,error:i}=cTe(e??"",t??""),{updateItem:l,deleteItem:c}=_i(),{data:u}=Ux(e??""),d=s?.[0]??null,f=d?.isDeleted??!1,[p,h]=v.useState(null),m=v.useMemo(()=>!d||f?{input:"",groundTruth:"",metadata:"",trajectory:"",toolMocks:"",requestContext:""}:{input:JSON.stringify(d.input,null,2),groundTruth:d.groundTruth?JSON.stringify(d.groundTruth,null,2):"",metadata:d.metadata?JSON.stringify(d.metadata,null,2):"",trajectory:d.expectedTrajectory!=null?JSON.stringify(d.expectedTrajectory,null,2):"",toolMocks:d.toolMocks?.length?JSON.stringify(d.toolMocks,null,2):"",requestContext:d.requestContext?JSON.stringify(d.requestContext,null,2):""},[d,f]),g=d?.datasetVersion??0,[y,b]=v.useState(!1),[w,S]=v.useState(m.input),[k,_]=v.useState(m.groundTruth),[C,E]=v.useState(m.metadata),[j,N]=v.useState(m.trajectory),[I,R]=v.useState(m.toolMocks),[$,F]=v.useState(m.requestContext),[D,V]=v.useState(g);g!==D&&(V(g),S(m.input),_(m.groundTruth),E(m.metadata),N(m.trajectory),R(m.toolMocks),F(m.requestContext));const[W,L]=v.useState(!1),z=J=>{h(f?J:J.isLatest?null:J)},B=()=>{h(null)},M=!f&&p!=null,G=()=>{M||b(!0)},U=()=>{M||L(!0)},P=async()=>{if(!e||!t)return;let J;try{J=JSON.parse(w)}catch{De.error("Input must be valid JSON");return}let ee;if(k.trim())try{ee=JSON.parse(k)}catch{De.error("Ground Truth must be valid JSON");return}let ae;if(C.trim())try{ae=JSON.parse(C)}catch{De.error("Metadata must be valid JSON");return}let de;const Y=j!==m.trajectory;if(Y&&j.trim())try{de=JSON.parse(j)}catch{De.error("Expected Trajectory must be valid JSON");return}let ne;const ce=I!==m.toolMocks;if(ce&&I.trim())try{const ve=JSON.parse(I);if(!Array.isArray(ve)){De.error("Tool Mocks must be a JSON array");return}ne=ve}catch{De.error("Tool Mocks must be valid JSON");return}let pe;const le=$!==m.requestContext;if(le&&$.trim())try{pe=JSON.parse($)}catch{De.error("Request Context must be valid JSON");return}try{await l.mutateAsync({datasetId:e,itemId:t,input:J,groundTruth:ee,metadata:ae,...Y?{expectedTrajectory:de??null}:{},...ce?{toolMocks:ne??[]}:{},...le?{requestContext:pe}:{}}),De.success("Item updated successfully"),b(!1)}catch(ve){De.error(`Failed to update item: ${ve instanceof Error?ve.message:"Unknown error"}`)}},q=()=>{d&&(S(JSON.stringify(d.input,null,2)),_(d.groundTruth?JSON.stringify(d.groundTruth,null,2):""),E(d.metadata?JSON.stringify(d.metadata,null,2):""),N(d.expectedTrajectory!=null?JSON.stringify(d.expectedTrajectory,null,2):""),R(d.toolMocks?.length?JSON.stringify(d.toolMocks,null,2):""),F(d.requestContext?JSON.stringify(d.requestContext,null,2):"")),b(!1)},Z=async()=>{if(!(!e||!t))try{await c.mutateAsync({datasetId:e,itemId:t}),De.success("Item deleted successfully"),L(!1),r(`/datasets/${e}`)}catch(J){De.error(`Failed to delete item: ${J instanceof Error?J.message:"Unknown error"}`)}},X=p??d,te=X?{id:t??"",datasetId:e??"",datasetVersion:X.datasetVersion,input:X.input,groundTruth:X.groundTruth,expectedTrajectory:X.expectedTrajectory,metadata:X.metadata,createdAt:X.createdAt,updatedAt:X.updatedAt}:null;return i&&gs(i)?o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):i&&ys(i)?o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ds,{resource:"datasets"})})}):a?null:!e||!t||!s||s.length===0?o.jsx(cs,{children:o.jsx(xy,{children:o.jsx("div",{className:"text-neutral3 p-4",children:"Item not found"})})}):o.jsxs(o.Fragment,{children:[o.jsx(cs,{children:o.jsx("div",{className:"h-full overflow-hidden px-6 pb-4",children:o.jsxs("div",{className:"grid gap-6 max-w-[60rem] mx-auto grid-rows-[auto_1fr] h-full",children:[o.jsxs(ua,{children:[o.jsxs(ua.Column,{children:[o.jsxs(ua.Title,{children:[o.jsx(dN,{}),t," ",o.jsx(ya,{content:t})]}),o.jsx(ua.Description,{children:o.jsxs(Nl,{children:["Item of ",o.jsx(ay,{})," ",u?.name]})}),o.jsxs(ua.Description,{children:[o.jsxs(Nl,{children:[o.jsx(ult,{})," Created at"," ",d?.createdAt?er(new Date(d.createdAt),"MMM d, yyyy"):""]}),o.jsxs(Nl,{children:[o.jsx(i_,{})," Latest version v",d?.datasetVersion??""]})]})]}),o.jsx(ua.Column,{children:!y&&!f&&o.jsxs($r,{children:[o.jsxs(ue,{onClick:G,disabled:M,title:M?"Return to latest version to edit":void 0,children:[o.jsx(Nlt,{})," Edit"]}),o.jsxs(ue,{onClick:U,disabled:M,title:M?"Return to latest version to delete":void 0,children:[o.jsx(Jc,{})," Delete"]})]})})]}),o.jsxs(ry,{className:y?"grid-cols-1":"grid-cols-[1fr_auto]",children:[o.jsxs(Gr,{withRightSeparator:!y,children:[f&&d&&o.jsx(In,{variant:"destructive",title:"Item deleted",children:o.jsxs(In.Message,{children:["This item was deleted at version v",d.datasetVersion]})}),!f&&M&&p&&o.jsx(In,{variant:"warning",title:"Previous version",action:o.jsxs(In.Button,{onClick:B,children:[o.jsx(alt,{})," Return to the latest version"]}),children:o.jsxs(In.Message,{children:["Viewing version v",p.datasetVersion]})}),y?o.jsx(s8t,{inputValue:w,setInputValue:S,groundTruthValue:k,setGroundTruthValue:_,metadataValue:C,setMetadataValue:E,trajectoryValue:j,setTrajectoryValue:N,toolMocksValue:I,setToolMocksValue:R,requestContextValue:$,setRequestContextValue:F,validationErrors:null,onSave:P,onCancel:q,isSaving:l.isPending}):te?o.jsx(pTe,{item:te,Link:n}):o.jsx("div",{className:"text-neutral4 text-sm",children:"Item data not available"})]}),!y&&o.jsx(Gr,{children:o.jsx(Mes,{datasetId:e,itemId:t,onClose:()=>{},onVersionSelect:z,onCompareVersionsClick:J=>{r(`/datasets/${e}/items/${t}/versions?ids=${J.join(",")}`)},activeVersion:p?.datasetVersion??null})})]})]})})}),o.jsx(Tt,{open:W,onOpenChange:L,children:o.jsxs(Tt.Content,{children:[o.jsxs(Tt.Header,{children:[o.jsx(Tt.Title,{children:"Delete Item"}),o.jsx(Tt.Description,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),o.jsxs(Tt.Footer,{children:[o.jsx(Tt.Cancel,{children:"Cancel"}),o.jsx(Tt.Action,{onClick:Z,children:c.isPending?"Deleting...":"Delete"})]})]})})]})}function yQe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function ets(){const{datasetId:e}=dr(),[t,n]=ji(),r=t.get("items")?.split(",").filter(Boolean)??[],{data:s,error:a}=Ux(e??""),{Link:i}=yn(),[l,c]=v.useState(!1),{data:u}=CU(e??"",r[0]??""),{data:d}=CU(e??"",r[1]??"");return a&&gs(a)?o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):a&&ys(a)?o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ds,{resource:"datasets"})})}):!e||r.length<2?o.jsx(cs,{children:o.jsx(xy,{children:o.jsx("div",{className:"text-neutral4 text-center py-8",children:o.jsx("p",{children:"Select at least two items to compare."})})})}):o.jsxs(cs,{children:[o.jsx(Ty,{owner:"dataset-items-compare",children:o.jsxs(ue,{as:ci,to:`/datasets/${e}`,variant:"outline",children:[o.jsx(Ec,{}),"Back to Dataset"]})}),o.jsx("div",{className:"h-full overflow-hidden px-[3vw] pb-4",children:o.jsxs("div",{className:K("grid gap-6 max-w-[140rem] mx-auto grid-rows-[auto_1fr] h-full",{"grid-rows-[auto_auto_1fr]":l}),children:[o.jsxs(ua,{children:[o.jsxs(ua.Column,{children:[o.jsxs(ua.Title,{children:[o.jsx(Qw,{}),"Compare Dataset Items"]}),o.jsx(ua.Description,{children:o.jsxs(Nl,{children:["Comparing ",r.length," items of"," ",o.jsx(ci,{to:`/datasets/${e}`,className:"text-info1 hover:underline",children:s?.name||e?.slice(0,8)})]})})]}),o.jsx(ua.Column,{children:o.jsx($r,{children:o.jsx(ue,{variant:"primary",onClick:()=>c(f=>!f),children:l?o.jsxs(o.Fragment,{children:[o.jsx(vlt,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx(ucn,{})," Diff View"]})})})})]}),o.jsx(ry,{className:"grid-cols-[1fr_3vw_1fr]",children:r.map((f,p)=>o.jsxs(v.Fragment,{children:[o.jsx(tts,{datasetId:e,itemId:f,Link:i,idx:p,itemIds:r,showContent:!l,onItemChange:h=>{const m=[...r];m[p]=h,n({items:m.join(",")})}}),p==0&&o.jsx("div",{className:K("bg-surface5 w-[3px] shrink-0 mx-[1.5vw]")})]},f))}),l&&u&&d&&o.jsx(S_e,{codeA:yQe(u),codeB:yQe(d)})]})})]})}function tts({datasetId:e,itemId:t,Link:n,idx:r,itemIds:s,onItemChange:a,showContent:i=!0}){const{data:l,isLoading:c}=CU(e,t),{data:u}=_1(e),d=new Set(s.filter((p,h)=>h!==r)),f=(u??[]).map(p=>({value:p.id,label:p.id,disabled:d.has(p.id)}));return o.jsxs(Gr,{children:[o.jsxs(Gr.Toolbar,{className:"flex gap-4",children:[o.jsxs(ba,{name:`compare-item-${r}`,value:t,onValueChange:a,children:[o.jsx(wa,{"aria-label":"Item",children:o.jsx(xa,{placeholder:"Select item"})}),o.jsx(Sa,{children:f.map(p=>o.jsx(qr,{value:p.value,disabled:p.disabled,children:p.label},p.value))})]}),o.jsxs(ue,{as:n,to:`/datasets/${e}/items/${t}`,children:[o.jsx(i_,{}),"Versions"]})]}),i&&o.jsx(Gr.Content,{children:c?o.jsx("div",{className:"text-neutral4 text-sm",children:"Loading..."}):l?o.jsxs(o.Fragment,{children:[o.jsx(pes,{item:l}),o.jsx(pTe,{item:l,Link:n})]}):o.jsxs("div",{className:"text-neutral4 text-sm",children:["Item ",t.slice(0,8)," not found"]})})]})}function bQe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function nts(){const{datasetId:e,itemId:t}=dr(),[n,r]=ji(),[s,a]=v.useState(!1),i=n.get("ids")?.split(",").map(Number).filter(h=>!isNaN(h)&&h>0)??[],{data:l,error:c}=Ux(e??""),{Link:u}=yn(),{data:d}=cTe(e??"",t??""),{data:f}=Tve(e??"",t??"",i[0]??0,l?.version),{data:p}=Tve(e??"",t??"",i[1]??0,l?.version);return c&&gs(c)?o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):c&&ys(c)?o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ds,{resource:"datasets"})})}):!e||!t||i.length<2?o.jsx(cs,{children:o.jsx(xy,{children:o.jsx("div",{className:"text-neutral4 text-center py-8",children:o.jsx("p",{children:"Select at least two versions to compare."})})})}):o.jsxs(cs,{children:[o.jsx(Ty,{owner:"dataset-item-versions-compare",children:o.jsxs(ue,{as:ci,to:`/datasets/${e}/items/${t}`,variant:"outline",children:[o.jsx(Ec,{}),"Back to Item"]})}),o.jsx("div",{className:"h-full overflow-hidden px-[3vw] pb-4",children:o.jsxs("div",{className:K("grid gap-6 max-w-[140rem] mx-auto grid-rows-[auto_1fr] h-full",{"grid-rows-[auto_auto_1fr]":s}),children:[o.jsxs(ua,{children:[o.jsxs(ua.Column,{children:[o.jsxs(ua.Title,{children:[o.jsx(Qw,{}),"Compare Dataset Item Versions"]}),o.jsx(ua.Description,{children:o.jsxs(Nl,{children:["Comparing ",i.length," versions of"," ",o.jsx(ci,{to:`/datasets/${e}/items/${t}`,className:"text-info1 hover:underline",children:t})]})})]}),o.jsx(ua.Column,{children:o.jsx($r,{children:o.jsx(ue,{variant:"primary",onClick:()=>a(h=>!h),children:s?o.jsxs(o.Fragment,{children:[o.jsx(vlt,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx(Qcn,{})," Diff View"]})})})})]}),o.jsx(ry,{className:"grid-cols-[1fr_3vw_1fr]",children:i.map((h,m)=>o.jsxs(v.Fragment,{children:[o.jsx(rts,{datasetId:e,itemId:t,datasetVersion:h,latestVersion:l?.version,allVersions:d??[],versionNumbers:i,Link:u,idx:m,showContent:!s,onVersionChange:g=>{const y=[...i];y[m]=g,r({ids:y.join(",")})}}),m===0&&o.jsx("div",{className:K("bg-surface5 w-[3px] shrink-0 mx-[1.5vw]")})]},h))}),s&&f&&p&&o.jsx(S_e,{codeA:bQe(f),codeB:bQe(p)})]})})]})}function rts({datasetId:e,itemId:t,datasetVersion:n,latestVersion:r,allVersions:s,versionNumbers:a,Link:i,idx:l,showContent:c=!0,onVersionChange:u}){const{data:d,isLoading:f}=Tve(e,t,n,r),p=new Set(a.filter((g,y)=>y!==l)),h=s.map(g=>{const y=typeof g.updatedAt=="string"?new Date(g.updatedAt):g.updatedAt;return{value:String(g.datasetVersion),label:o.jsxs(o.Fragment,{children:[o.jsxs("b",{children:["v. ",g.datasetVersion]})," - ",er(y,"MMM d, yyyy h:mm a"),g.isLatest?o.jsx(Xs,{color:"blue",size:"small",children:"Latest"}):null]}),disabled:p.has(g.datasetVersion)}}),m=d?{id:d.id,datasetId:e,datasetVersion:d.datasetVersion,input:d.input,groundTruth:d.groundTruth,metadata:d.metadata,createdAt:d.createdAt,updatedAt:d.updatedAt}:null;return o.jsxs(Gr,{children:[o.jsxs(Gr.Toolbar,{className:"grid gap-4 grid-cols-[auto_1fr]",children:[o.jsx(i_,{className:"w-6 h-6 opacity-50"}),o.jsxs(ba,{name:`compare-version-${l}`,value:String(n),onValueChange:g=>u(Number(g)),children:[o.jsx(wa,{"aria-label":"Version",className:"w-full",children:o.jsx(xa,{placeholder:"Select version"})}),o.jsx(Sa,{children:h.map(g=>o.jsx(qr,{value:g.value,disabled:g.disabled,children:g.label},g.value))})]})]}),c&&o.jsx(Gr.Content,{children:f?o.jsx("div",{className:"text-neutral4 text-sm",children:"Loading..."}):!d||!m?o.jsxs("div",{className:"text-neutral4 text-sm",children:["Version ",n," not found"]}):o.jsx(pTe,{item:m,Link:i})})]})}function sts(){const{datasetId:e}=dr(),[t]=ji(),n=t.get("ids")?.split(",").map(Number).filter(g=>!isNaN(g)&&g>0)??[],r=bs(),{data:s,error:a}=Ux(e??""),i=_1(e??"",void 0,n[0]??null),l=_1(e??"",void 0,n[1]??null),c=v.useMemo(()=>i.data??[],[i.data]),u=v.useMemo(()=>l.data??[],[l.data]),d=v.useMemo(()=>{const g=new Map;for(const y of[...c,...u])g.has(y.id)||g.set(y.id,{id:y.id,createdAt:new Date(y.createdAt)});return[...g.values()].sort((y,b)=>b.createdAt.getTime()-y.createdAt.getTime())},[c,u]),f=v.useMemo(()=>new Map(c.map(g=>[g.id,g])),[c]),p=v.useMemo(()=>new Map(u.map(g=>[g.id,g])),[u]);if(a&&gs(a))return o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})});if(a&&ys(a))return o.jsx(cs,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ds,{resource:"datasets"})})});if(!e||n.length<2)return o.jsx(cs,{children:o.jsx(xy,{children:o.jsx("div",{className:"text-neutral4 text-center py-8",children:o.jsx("p",{children:"Select at least two versions to compare."})})})});const h=(g,y,b)=>{r(`/datasets/${e}/items/${g}/versions?ids=${y?.datasetVersion??""},${b?.datasetVersion??""}`)},m=(g,y)=>{r(`/datasets/${e}/versions?ids=${g},${y}`,{replace:!0})};return o.jsx(cs,{children:o.jsx("div",{className:"h-full overflow-hidden px-[3vw] pb-4",children:o.jsxs("div",{className:"grid gap-6 max-w-[140rem] mx-auto grid-rows-[auto_1fr] h-full",children:[o.jsxs(ua,{children:[o.jsxs(ua.Column,{children:[o.jsxs(ua.Title,{children:[o.jsx(Idn,{})," Compare Dataset Versions"]}),o.jsx(ua.Description,{children:o.jsxs(Nl,{children:[o.jsx(i_,{})," Comparing ",n.length," versions of"," ",s?.name||e?.slice(0,8)]})})]}),o.jsx(ua.Column,{children:o.jsxs(ue,{as:ci,to:`/datasets/${e}`,children:[o.jsx(Ec,{}),"Back to Dataset"]})})]}),o.jsx(ry,{children:o.jsxs(Gr,{children:[o.jsx(Fes,{datasetId:e,versionA:String(n[0]),versionB:String(n[1]),onVersionChange:m}),o.jsx(qes,{datasetId:e,versionA:n[0],versionB:n[1],allItems:d,itemsAMap:f,itemsBMap:p,onItemClick:h})]})})]})})})}function Nve({children:e,className:t}){return o.jsx("div",{className:K("flex flex-wrap gap-8",t),children:e})}function ats(e){if(!e||e.length<2)return null;const t=[...e].sort((i,l)=>new Date(i.createdAt).getTime()-new Date(l.createdAt).getTime()),n=Math.floor(t.length/2),r=n,s=t.length-n;if(r===0)return null;const a=(s-r)/r*100;return{changePct:Math.round(a*10)/10,prevValue:String(r)}}function its({scorers:e,datasets:t,experiments:n,avgScore:r,prevAvgScore:s,totalNeedsReview:a,isLoadingScorers:i,isLoadingDatasets:l,isLoadingExperiments:c,isLoadingScores:u,isLoadingReview:d}){const f=e?Object.keys(e).length:void 0,p=t?.length,h=n?.length,m=r!=null&&s!=null&&s!==0?{changePct:Math.round((r-s)/s*100*10)/10,prevValue:String(s)}:null,g=ats(n);return o.jsxs(o.Fragment,{children:[o.jsxs(Kr,{children:[o.jsx(Kr.Label,{children:"Total Scorers"}),i?o.jsx(Kr.Loading,{}):f!=null?o.jsxs(o.Fragment,{children:[o.jsx(Kr.Value,{children:String(f)}),o.jsx(Kr.NoChange,{message:"Static count"})]}):o.jsx(Kr.NoData,{})]}),o.jsxs(Kr,{children:[o.jsx(Kr.Label,{children:"Total Datasets"}),l?o.jsx(Kr.Loading,{}):p!=null?o.jsxs(o.Fragment,{children:[o.jsx(Kr.Value,{children:String(p)}),o.jsx(Kr.NoChange,{message:"Static count"})]}):o.jsx(Kr.NoData,{})]}),o.jsxs(Kr,{children:[o.jsx(Kr.Label,{children:"Avg Score"}),u?o.jsx(Kr.Loading,{}):r!=null?o.jsxs(o.Fragment,{children:[o.jsx(Kr.Value,{children:String(r)}),m?o.jsx(Kr.Change,{changePct:m.changePct,prevValue:m.prevValue}):o.jsx(Kr.NoChange,{})]}):o.jsx(Kr.NoData,{})]}),o.jsxs(Kr,{children:[o.jsx(Kr.Label,{children:"Total Experiments"}),c?o.jsx(Kr.Loading,{}):h!=null?o.jsxs(o.Fragment,{children:[o.jsx(Kr.Value,{children:String(h)}),g?o.jsx(Kr.Change,{changePct:g.changePct,prevValue:g.prevValue}):o.jsx(Kr.NoChange,{})]}):o.jsx(Kr.NoData,{})]}),o.jsxs(Kr,{children:[o.jsx(Kr.Label,{children:"Needs Review"}),d?o.jsx(Kr.Loading,{}):a!=null?o.jsxs(o.Fragment,{children:[o.jsx(Kr.Value,{children:String(a)}),a>0?o.jsx(Kr.NoChange,{message:"items pending review"}):o.jsx(Kr.NoChange,{message:"All caught up"})]}):o.jsx(Kr.NoData,{})]})]})}const xQe="auto 1fr auto auto auto auto auto auto auto";function ots(e){return e?(typeof e=="string"?new Date(e):e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}const lts={completed:"success",running:"warning",failed:"error",pending:"neutral"};function cts({experiments:e,datasets:t,reviewByExperiment:n,isLoading:r,search:s="",statusFilter:a="all",datasetFilter:i="all"}){const{paths:l,Link:c}=yn(),u=v.useMemo(()=>{const p=new Map;return t?.forEach(h=>p.set(h.id,h.name)),p},[t]),d=v.useMemo(()=>[...e].sort((p,h)=>{const m=p.createdAt?new Date(p.createdAt).getTime():0;return(h.createdAt?new Date(h.createdAt).getTime():0)-m}),[e]),f=v.useMemo(()=>{const p=s.toLowerCase();return d.filter(h=>{const m=h.datasetId?u.get(h.datasetId)??"":"",g=!p||h.id.toLowerCase().includes(p)||m.toLowerCase().includes(p)||(h.targetId??"").toLowerCase().includes(p),y=a==="all"||h.status===a,b=i==="all"||h.datasetId===i;return g&&y&&b})},[d,s,u,a,i]);return r?o.jsx(el,{columns:xQe}):o.jsxs(me,{columns:xQe,variant:"striped",children:[o.jsxs(me.Top,{children:[o.jsx(me.TopCell,{children:"Experiment"}),o.jsx(me.TopCell,{children:"Dataset"}),o.jsx(me.TopCell,{children:"Target"}),o.jsx(me.TopCell,{children:"Status"}),o.jsx(me.TopCell,{className:"text-center",children:"Items"}),o.jsx(me.TopCell,{className:"text-center",children:"Succeeded"}),o.jsx(me.TopCell,{className:"text-center",children:"Failed"}),o.jsx(me.TopCell,{className:"text-center",children:"Review"}),o.jsx(me.TopCell,{children:"Date"})]}),f.map(p=>{const h=p.datasetId?u.get(p.datasetId)??p.datasetId.slice(0,8):"—",m=p.status??"pending",g=p.succeededCount??0,y=p.failedCount??0,b=p.totalItems??0,w=b>0?Math.round(g/b*100):0;return o.jsxs(me.RowLink,{to:l.experimentLink(p.id),LinkComponent:c,children:[o.jsx(me.NameCell,{className:"font-mono",children:p.id.slice(0,8)}),o.jsx(me.TextCell,{children:h}),o.jsx(me.Cell,{children:o.jsxs("span",{className:"truncate",children:[p.targetType," ",p.targetId]})}),o.jsx(me.Cell,{children:o.jsx(dg,{variant:lts[m]??"neutral",withDot:!0,children:m})}),o.jsx(me.TextCell,{className:"text-center",children:b}),o.jsx(me.TextCell,{className:"text-center",children:o.jsxs("span",{className:g>0?"text-accent1":"",children:[g," (",w,"%)"]})}),o.jsx(me.TextCell,{className:"text-center",children:o.jsx("span",{className:y>0?"text-accent2":"",children:y})}),o.jsx(me.Cell,{className:"text-center",children:(()=>{const S=n?.get(p.id);if(!S)return o.jsx("span",{className:"text-neutral2",children:"—"});const k=S.needsReview+S.complete;return k===0?o.jsx("span",{className:"text-neutral2",children:"—"}):S.needsReview>0?o.jsxs(Xs,{size:"small",color:"yellow",children:[S.needsReview," pending"]}):o.jsxs(Xs,{size:"small",color:"green",children:[S.complete,"/",k," reviewed"]})})()}),o.jsx(me.TextCell,{children:ots(p.createdAt)})]},p.id)})]})}const uts=[{value:"all",label:"All statuses"},{value:"completed",label:"Completed"},{value:"running",label:"Running"},{value:"failed",label:"Failed"},{value:"pending",label:"Pending"}];function dts(e){return[{value:"all",label:"All datasets"},...(e??[]).map(t=>({value:t.id,label:t.name}))]}const W8={completed:"#22c55e",running:"#facc15",pending:"#fb923c",failed:"#f87171"},fts=[{label:"Completed",color:W8.completed},{label:"Running",color:W8.running},{label:"Pending",color:W8.pending},{label:"Failed",color:W8.failed}];function pts({experiments:e,datasets:t,isLoading:n,isError:r}){const{data:s,maxVal:a}=v.useMemo(()=>{if(!e||e.length===0)return{data:[],maxVal:0};const l=new Map;if(t)for(const f of t)l.set(f.id,f.name);const c=new Map;for(const f of e){const p=f.datasetId??"unknown";c.has(p)||c.set(p,{completed:0,running:0,pending:0,failed:0});const h=c.get(p),m=f.status;m in h&&h[m]++}let u=0;return{data:Array.from(c.entries()).map(([f,p])=>{const h=p.completed+p.running+p.pending+p.failed;return h>u&&(u=h),{name:l.get(f)??f.slice(0,12),values:[p.completed,p.running,p.pending,p.failed]}}),maxVal:u}},[e,t]),i=s.length>0;return o.jsxs(Bt,{children:[o.jsxs(Bt.TopBar,{children:[o.jsx(Bt.TitleAndDescription,{title:"Experiments by Dataset",description:"Experiment status breakdown per dataset."}),i&&o.jsx(Bt.Summary,{value:String(e?.length??0),label:"Total experiments"})]}),n?o.jsx(Bt.Loading,{}):r?o.jsx(Bt.Error,{message:"Failed to load experiments data"}):o.jsx(Bt.Content,{children:i?o.jsx(aN,{data:s,segments:fts,maxVal:a,fmt:l=>String(l)}):o.jsx(Bt.NoData,{message:"No experiments have been run yet"})})]})}const hts=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Lr,{iconSlot:o.jsx(xf,{}),titleSlot:"No Experiments yet",descriptionSlot:o.jsxs(o.Fragment,{children:["Run an experiment from a dataset to evaluate ",o.jsx("br",{}),"your agents and workflows."]}),actionSlot:o.jsx("div",{className:"flex flex-col items-center gap-2",children:o.jsxs(ue,{variant:"ghost",as:"a",href:"https://mastra.ai/en/docs/evals/datasets/running-experiments",target:"_blank",rel:"noopener noreferrer",children:["Experiments Documentation ",o.jsx(Pa,{})]})})})});function mts({search:e,onSearchChange:t,statusFilter:n,onStatusFilterChange:r,datasetFilter:s,onDatasetFilterChange:a,datasetOptions:i,onReset:l,hasActiveFilters:c}){return o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx(Of,{label:"Search experiments",placeholder:"Filter by experiment, dataset, or target",value:e,onSearch:t}),o.jsxs($r,{children:[o.jsx(xc,{label:"Status",labelIsHidden:!0,name:"filter-status",options:[...uts],value:n,onValueChange:r,className:"whitespace-nowrap"}),o.jsx(xc,{label:"Dataset",labelIsHidden:!0,name:"filter-dataset",options:i,value:s,onValueChange:a,className:"whitespace-nowrap"}),l&&c&&o.jsxs(ue,{onClick:l,size:"sm",variant:"default",children:[o.jsx(vs,{className:"size-3"})," Reset"]})]})]})}function gts(){const{data:e,isLoading:t,error:n}=eh(),{data:r,isLoading:s,error:a}=Rg(),{data:i,isLoading:l,error:c}=zZ(),{data:u,isLoading:d,isError:f,error:p}=fWr(),{data:h,isLoading:m,isError:g,error:y}=gTe(),b=r?.datasets,w=i?.experiments,S=v.useMemo(()=>Zes(h),[h]),k=n||a||c||p||y;return k&&gs(k)?o.jsx(lr,{children:o.jsx(Vs,{})}):k&&ys(k)?o.jsx(lr,{children:o.jsx(Ds,{resource:"evaluation"})}):k?o.jsx(lr,{children:o.jsx(Fi,{title:"Failed to load evaluation data",message:k.message})}):o.jsx(Lt,{width:"wide",height:"full",children:o.jsxs("div",{className:"flex flex-col gap-6",children:[o.jsx(Nve,{children:o.jsx(its,{scorers:e,datasets:b,experiments:w,avgScore:u?.avgScore??null,prevAvgScore:u?.prevAvgScore??null,totalNeedsReview:S.needsReview,isLoadingScorers:t,isLoadingDatasets:s,isLoadingExperiments:l,isLoadingScores:d,isLoadingReview:m})}),o.jsx(yHr,{summaryData:u?.summaryData??[],overTimeData:u?.overTimeData??[],scorerNames:u?.scorerNames??[],avgScore:u?.avgScore??null,isLoading:d,isError:f}),o.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[o.jsx(GKr,{experiments:w,isLoading:l,isError:!!c}),o.jsx(pts,{experiments:w,datasets:b,isLoading:l,isError:!!c})]}),o.jsx(Hes,{reviewSummary:h,experiments:w,datasets:b,isLoading:m,isError:!!g})]})})}function vts(){const[e,t]=v.useState(""),[n,r]=v.useState("all"),[s,a]=v.useState("all"),{data:i,isLoading:l,error:c}=Rg(),{data:u,isLoading:d,error:f}=zZ(),{data:p}=gTe(),h=v.useMemo(()=>i?.datasets??[],[i?.datasets]),m=v.useMemo(()=>u?.experiments??[],[u?.experiments]),g=v.useMemo(()=>dts(h),[h]),y=v.useMemo(()=>l8t(p),[p]),b=l||d,w=f||c;if(w&&gs(w))return o.jsx(lr,{children:o.jsx(Vs,{})});if(f&&ys(f))return o.jsx(lr,{children:o.jsx(Ds,{resource:"experiments"})});if(c&&ys(c))return o.jsx(lr,{children:o.jsx(Ds,{resource:"datasets"})});if(w)return o.jsx(lr,{children:o.jsx(Fi,{title:"Failed to load experiments",message:w.message})});if(m.length===0&&!b)return o.jsx(lr,{children:o.jsx(hts,{})});const S=n!=="all"||s!=="all"||e!=="",k=()=>{t(""),r("all"),a("all")};return o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx(mts,{search:e,onSearchChange:t,statusFilter:n,onStatusFilterChange:r,datasetFilter:s,onDatasetFilterChange:a,datasetOptions:g,onReset:k,hasActiveFilters:S})}),o.jsx(cts,{experiments:m,datasets:h,reviewByExperiment:y,isLoading:b,search:e,statusFilter:n,datasetFilter:s})]})}function Z8({children:e}){return o.jsxs(Lt,{height:"full",children:[o.jsx("div",{}),o.jsx(Lt.MainArea,{isCentered:!0,children:e})]})}function yts(){const{experimentId:e}=dr(),{data:t,isLoading:n}=zZ(),s=t?.experiments?.find(h=>h.id===e)?.datasetId??"",{data:a,isLoading:i,error:l}=_U(s,e??""),{data:c,isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p}=$Z({datasetId:s,experimentId:e??"",experimentStatus:a?.status});return!e||n||i?null:l&&gs(l)?o.jsx(Z8,{children:o.jsx(Vs,{})}):l&&ys(l)?o.jsx(Z8,{children:o.jsx(Ds,{resource:"datasets"})}):l&&z1e(l)||!n&&!s||!i&&!l&&!a?o.jsx(Z8,{children:o.jsx(Lr,{iconSlot:o.jsx(Bye,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${e}".`,actionSlot:o.jsxs(ue,{as:ci,to:"/experiments",children:[o.jsx(Ec,{}),"Back to Experiments"]})})}):l?o.jsx(Z8,{children:o.jsx(Fi,{title:"Failed to load experiment",message:l instanceof Error?l.message:"An unexpected error occurred. Please try again."})}):o.jsxs(Lt,{height:"full",children:[o.jsx(c8t,{experiment:a}),o.jsx(Lt.MainArea,{children:o.jsx(o8t,{experimentId:e,datasetId:s,experimentStatus:a.status,results:c??[],isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p})})]})}function bts({connection:e,isAdmin:t,disconnectPending:n,onDisconnect:r}){return o.jsxs("li",{className:"flex items-center justify-between border-b py-2",children:[o.jsxs("div",{children:[o.jsx("div",{className:"font-mono text-xs",children:e.connectionId}),o.jsxs("div",{className:"text-xs text-gray-500",children:[e.label??"(no label)"," · ",e.status,e.scope?` · ${e.scope}`:"",t&&e.authorId?` · author: ${e.authorId}`:""]})]}),o.jsx("button",{type:"button",className:"text-red-600 underline disabled:opacity-50",onClick:r,disabled:n,children:"Disconnect"})]})}function u8t({connections:e,isAdmin:t,disconnectPending:n,onDisconnect:r}){return o.jsx("ul",{className:"space-y-1",children:e.map(s=>o.jsx(bts,{connection:s,isAdmin:t,disconnectPending:n,onDisconnect:()=>r(s.connectionId)},s.connectionId))})}function xts({groups:e,isAdmin:t,disconnectPending:n,onDisconnect:r}){return o.jsx("div",{className:"space-y-4",children:e.map(([s,a])=>o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold text-gray-700","data-testid":`integration-author-group-${s}`,children:s==="shared"?"Shared":`Owned by ${s}`}),o.jsx(u8t,{connections:a,isAdmin:t,disconnectPending:n,onDisconnect:r})]},s))})}function wts({providerId:e,toolkit:t,connections:n,groupedByAuthor:r,isAdmin:s,isLoading:a,error:i,disconnectPending:l,disconnectError:c,onDisconnect:u}){return o.jsxs("div",{className:"space-y-2 border rounded p-4",children:[o.jsx("h2",{className:"text-lg font-semibold",children:"Existing connections"}),!e||!t?o.jsx("p",{className:"text-gray-500",children:"Pick a provider and toolkit to list connections."}):a?o.jsx("p",{className:"text-gray-500",children:"Loading…"}):i?o.jsx("p",{className:"text-red-600",children:String(i)}):n.length===0?o.jsx("p",{className:"text-gray-500",children:"No connections."}):r?o.jsx(xts,{groups:r,isAdmin:s,disconnectPending:l,onDisconnect:u}):o.jsx(u8t,{connections:n,isAdmin:s,disconnectPending:l,onDisconnect:u}),c?o.jsx("p",{className:"text-red-600",children:String(c)}):null]})}function Sts({providers:e,toolkits:t,providerId:n,toolkit:r,label:s,providersLoading:a,providersError:i,toolkitsLoading:l,toolkitsError:c,authorizePending:u,authorizeError:d,authorizedConnection:f,onProviderChange:p,onToolkitChange:h,onLabelChange:m,onConnect:g}){return o.jsxs("div",{className:"space-y-4 border rounded p-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"block font-medium",htmlFor:"provider-select",children:"Provider"}),o.jsxs("select",{id:"provider-select",className:"border rounded px-2 py-1 w-full",value:n,onChange:y=>p(y.target.value),disabled:a,children:[o.jsx("option",{value:"",children:"— select provider —"}),e.map(y=>o.jsxs("option",{value:y.id,children:[y.displayName??y.name," (",y.id,")"]},y.id))]}),a&&o.jsx("span",{className:"text-gray-500",children:"Loading providers…"}),i?o.jsx("span",{className:"text-red-600",children:String(i)}):null]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"block font-medium",htmlFor:"toolkit-select",children:"Toolkit"}),o.jsxs("select",{id:"toolkit-select",className:"border rounded px-2 py-1 w-full",value:r,onChange:y=>h(y.target.value),disabled:!n||l,children:[o.jsx("option",{value:"",children:"— select toolkit —"}),t.map(y=>o.jsxs("option",{value:y.slug,children:[y.name," (",y.slug,")"]},y.slug))]}),l&&o.jsx("span",{className:"text-gray-500",children:"Loading toolkits…"}),c?o.jsx("span",{className:"text-red-600",children:String(c)}):null]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"block font-medium",htmlFor:"label-input",children:"Label (optional)"}),o.jsx("input",{id:"label-input",type:"text",className:"border rounded px-2 py-1 w-full",placeholder:"My personal Gmail",value:s,onChange:y=>m(y.target.value),disabled:!n||!r})]}),o.jsx("button",{type:"button",className:"bg-blue-600 text-white rounded px-4 py-2 disabled:opacity-50",onClick:g,disabled:!n||!r||u,children:u?"Authorizing…":"Connect"}),d?o.jsx("p",{className:"text-red-600",children:String(d)}):null,f&&o.jsxs("p",{className:"text-green-700",children:["Authorized: ",f.connectionId," (status: ",f.status,")"]})]})}const wQe=e=>e.authorId?.trim()||"shared",kts=(e,t)=>{if(!t||new Set(e.map(wQe)).size<=1)return null;const r=new Map;for(const a of e){const i=wQe(a);r.set(i,[...r.get(i)??[],a])}const s=Array.from(r.entries());return s.sort(([a],[i])=>a==="shared"?1:i==="shared"?-1:a.localeCompare(i)),s},Ots=["*","tool-providers:*","tool-providers:admin"];function _ts(){const{data:e}=wm();return e?.permissions?.some(t=>Ots.includes(t))??!1}function Cts(){const[e,t]=v.useState(""),[n,r]=v.useState(""),[s,a]=v.useState(""),i=cI(),l=lW(e||null),c=iAt(e||null,n||null),u=aAt(),d=nAt(),f=_ts(),p=i.data?.providers??[],h=l.data?.data??[],m=v.useMemo(()=>c.data?.items??[],[c.data?.items]),g=v.useMemo(()=>kts(m,f),[m,f]),y=S=>{t(S),r("")},b=()=>{!e||!n||u.mutate({providerId:e,toolkit:n,label:s.trim()||null},{onSuccess:()=>{a(""),c.refetch()}})},w=S=>{d.mutate({providerId:e,connectionId:S})};return o.jsxs("div",{className:"p-6 max-w-3xl space-y-6 text-sm",children:[o.jsx("h1",{className:"text-2xl font-semibold",children:"Integrations"}),o.jsx("p",{className:"text-gray-500",children:"Minimal page to verify the ToolProvider backend. Pick a provider and toolkit, then connect."}),o.jsx(Sts,{providers:p,toolkits:h,providerId:e,toolkit:n,label:s,providersLoading:i.isLoading,providersError:i.error,toolkitsLoading:l.isLoading,toolkitsError:l.error,authorizePending:u.isPending,authorizeError:u.error,authorizedConnection:u.data,onProviderChange:y,onToolkitChange:r,onLabelChange:a,onConnect:b}),o.jsx(wts,{providerId:e,toolkit:n,connections:m,groupedByAuthor:g,isAdmin:f,isLoading:c.isLoading,error:c.error,disconnectPending:d.isPending,disconnectError:d.error,onDisconnect:w})]})}function Ets({title:e,description:t,errorBanner:n,children:r}){return o.jsx("div",{"data-testid":"login-page",className:"flex min-h-screen items-center justify-center bg-surface1",children:o.jsxs("div",{className:"w-full max-w-sm space-y-6",children:[o.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[o.jsx(Zh,{className:"h-10 w-10"}),o.jsx("h1",{className:"text-xl font-semibold text-neutral6",children:e})]}),t,n,r]})})}function d8t({redirectUri:e,onSuccess:t,initialMode:n="signin",errorMessage:r}){const{data:s,isLoading:a}=rc(),{mutate:i,isPending:l,error:c}=u1r(),{mutate:u,isPending:d,error:f}=f1r(),{mutate:p,isPending:h}=TNt(),[m,g]=v.useState(n),[y,b]=v.useState(""),[w,S]=v.useState(""),[k,_]=v.useState("");if(a)return o.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface1",children:o.jsx("div",{className:"text-neutral3",children:"Loading..."})});if(!s?.enabled||!s?.login)return o.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface1",children:o.jsx("div",{className:"text-neutral3",children:"Authentication is not configured"})});const{login:C}=s,E=C.type==="sso"||C.type==="both",j=C.type==="credentials"||C.type==="both",N=C.sso,I=C.signUpEnabled!==!1,R=m==="signin"||!I,$=R?l:d,F=R?c:f,D=()=>{t?t():e?window.location.href=e:window.location.href="/"},V=M=>{M.preventDefault(),R?i({email:w,password:k},{onSuccess:D}):u({email:w,password:k,name:y||void 0},{onSuccess:D})},W=()=>{p({redirectUri:e},{onSuccess:M=>{window.location.href=M.url}})},L=()=>{g(R?"signup":"signin")},z=C.description?o.jsxs("div",{className:"flex items-start gap-2.5 rounded-md border border-border1 bg-surface1 p-3",children:[o.jsx(pf,{className:"mt-0.5 h-4 w-4 shrink-0 text-neutral4"}),o.jsx("p",{className:"text-sm text-neutral3",children:C.description})]}):null,B=r?o.jsx("div",{className:"rounded-md bg-red-500/10 p-3 text-sm text-red-400",children:r}):null;return o.jsxs(Ets,{title:R?"Sign in to Mastra Studio":"Create your account",description:z,errorBanner:B,children:[j&&o.jsxs("form",{onSubmit:V,className:"space-y-4",children:[!R&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"name",className:"block text-sm text-neutral4",children:"Name"}),o.jsx(kn,{id:"name",type:"text",value:y,onChange:M=>b(M.target.value),placeholder:"Your name",variant:"default",size:"lg"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"email",className:"block text-sm text-neutral4",children:"Email"}),o.jsx(kn,{id:"email",type:"email",value:w,onChange:M=>S(M.target.value),placeholder:"you@example.com",required:!0,variant:"default",size:"lg"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"password",className:"block text-sm text-neutral4",children:"Password"}),o.jsx(kn,{id:"password",type:"password",value:k,onChange:M=>_(M.target.value),placeholder:R?"Enter your password":"Create a password",required:!0,variant:"default",size:"lg"})]}),F&&o.jsx("div",{className:"rounded-md bg-red-500/10 p-3 text-sm text-red-400",children:F.message}),o.jsx(ue,{type:"submit",disabled:$,className:"w-full",size:"lg",children:$?R?"Signing in...":"Creating account...":R?"Sign in":"Create account"}),I&&o.jsxs("div",{className:"text-center text-sm",children:[o.jsx("span",{className:"text-neutral3",children:R?"Don't have an account? ":"Already have an account? "}),o.jsx("button",{type:"button",onClick:L,className:"text-neutral6 hover:underline",children:R?"Sign up":"Sign in"})]})]}),E&&j&&o.jsxs("div",{className:"relative",children:[o.jsx("div",{className:"absolute inset-0 flex items-center",children:o.jsx("div",{className:"w-full border-t border-border1"})}),o.jsx("div",{className:"relative flex justify-center text-sm",children:o.jsx("span",{className:"bg-surface1 px-2 text-neutral3",children:"or continue with"})})]}),E&&N&&o.jsxs(ue,{onClick:W,disabled:h,className:"w-full",size:"lg",variant:"outline",children:[N.icon&&o.jsx("span",{className:"mr-2",children:N.icon}),h?"Redirecting...":N.text||"Sign in"]})]})}function jts(){const[e]=ji(),t=bs(),n=e.get("redirect")||"/",s=e.get("mode")==="signup"?"signup":"signin",a=e.get("error_description")||e.get("error")||null,i=()=>{n.startsWith("http")?window.location.href=n:t(n,{replace:!0})};return o.jsx(d8t,{redirectUri:n,onSuccess:i,initialMode:s,errorMessage:a})}function Tts({error:e,resource:t,errorTitle:n}){if(gs(e))return o.jsx(Vs,{});if(ys(e))return o.jsx(Ds,{resource:t});if(b1t(e,"logs"))return o.jsx(Lr,{iconSlot:o.jsx(_xe,{}),titleSlot:"Logs are not available with your current storage",descriptionSlot:"The configured observability storage provider does not support listing logs. Switch to a storage provider with logs support to view runtime logs in Studio."});const r=e instanceof Error?e.message:void 0;return o.jsx(Fi,{title:n,message:r??"Unknown error"})}function Nts({listSlot:e,logPanelSlot:t,tracePanelSlot:n,spanPanelSlot:r,logCollapsed:s}){const a=!!t;return o.jsxs("div",{className:K("grid h-full min-h-0 gap-4 items-start",a?"grid-cols-[1fr_1fr]":"grid-cols-[1fr]"),children:[e,a&&o.jsxs("div",{className:K("grid gap-4 h-full overflow-auto",n&&r?s?"grid-rows-[auto_1fr_1fr]":"grid-rows-[1fr_1fr_1fr]":n?s?"grid-rows-[auto_1fr]":"grid-rows-[1fr_1fr]":s?"grid-rows-[auto]":"grid-rows-[1fr]"),children:[t,n,r]})]})}const Its={debug:{label:"DEBUG",color:"#71717a"},info:{label:"INFO",color:"#60a5fa"},warn:{label:"WARN",color:"#facc15"},error:{label:"ERROR",color:"#f87171"},fatal:{label:"FATAL",color:"#dc2626"}};function Ats({level:e}){const t=Its[e];return o.jsx(So,{height:"compact",children:o.jsx("span",{className:"uppercase text-ui-sm font-semibold",style:{color:t.color},children:t.label})})}function Rts({entityType:e,className:t}){const n=K("size-3.5 shrink-0 text-neutral2",t);switch(e.toLowerCase()){case Os.AGENT:return o.jsx(rl,{className:n,"aria-hidden":!0});case"workflow":case Os.WORKFLOW_RUN:return o.jsx(kd,{className:n,"aria-hidden":!0});case Os.TOOL:return o.jsx(Gp,{className:n,"aria-hidden":!0});default:return null}}function Pts({entityType:e,entityName:t}){const n=e??"";return o.jsxs(So,{height:"compact",className:"flex min-w-0 items-center gap-2",children:[o.jsx(Rts,{entityType:n}),t?o.jsx("span",{className:"min-w-0 text-ui-smd truncate",children:t}):"-"]})}function $ts({message:e}){return o.jsx(So,{height:"compact",className:"text-neutral4 text-ui-smd min-w-0 truncate font-mono",children:e})}function Mts({data:e}){if(!e||Object.keys(e).length===0)return o.jsx(So,{height:"compact",children:null});const t=Object.entries(e).map(([n,r])=>{if(typeof r=="string")return`${n}: ${r}`;try{return`${n}: ${JSON.stringify(r)}`}catch{return`${n}: <unserializable>`}}).join(", ");return o.jsx(Wke,{children:t})}const zl=Object.assign(FD,{Top:BH,TopCell:$_,TopCellWithTooltip:UH,TopCellSmart:REt,RowWrapper:Xke,RowButton:zD,RowLink:PEt,Spacer:Yke,NoMatch:zH,DateCell:Zke,TimeCell:Gke,LevelCell:Ats,EntityCell:Pts,MessageCell:$ts,DataCell:Mts,NextPageLoading:FH}),SQe="6rem 9rem 5rem 10rem minmax(8rem,1fr) minmax(8rem,1fr)",Dts=36,Lts=8;function Fts({logs:e,isLoading:t,isFetchingNextPage:n,hasNextPage:r,setEndOfListElement:s,logIdMap:a,featuredLogId:i,onLogClick:l}){const c=v.useRef(null),u=P6t({count:e.length,getScrollElement:()=>c.current,estimateSize:()=>Dts,overscan:Lts}),d=v.useRef(t);if(v.useEffect(()=>{d.current&&!t&&c.current?.dispatchEvent(new Event("scroll")),d.current=t},[t]),t)return o.jsx(el,{columns:SQe});const f=u.getVirtualItems(),p=u.getTotalSize(),h=f[0]?.start??0,m=f.length>0?Math.max(0,p-(f[f.length-1]?.end??0)):0;return o.jsxs(zl,{columns:SQe,variant:"striped",scrollRef:c,className:"min-w-0",children:[o.jsxs(zl.Top,{children:[o.jsx(zl.TopCell,{children:"Date"}),o.jsx(zl.TopCell,{children:"Time"}),o.jsx(zl.TopCell,{children:"Level"}),o.jsx(zl.TopCell,{children:"Entity"}),o.jsx(zl.TopCell,{children:"Message"}),o.jsx(zl.TopCell,{children:"Data"})]}),e.length===0?o.jsx(zl.NoMatch,{message:"No logs match your search"}):o.jsxs(o.Fragment,{children:[o.jsx(zl.Spacer,{height:h}),f.map(g=>{const y=e[g.index];if(!y)return null;const b=a.get(y);if(!b)return null;const w=b===i;return o.jsxs(zl.RowButton,{ref:u.measureElement,"data-index":g.index,onClick:()=>l(y),featured:w,variant:y.level==="error"||y.level==="fatal"?"error":"default",children:[o.jsx(zl.DateCell,{timestamp:y.timestamp}),o.jsx(zl.TimeCell,{timestamp:y.timestamp}),o.jsx(zl.LevelCell,{level:y.level}),o.jsx(zl.EntityCell,{entityType:y.entityType,entityName:y.entityName}),o.jsx(zl.MessageCell,{message:y.message}),o.jsx(zl.DataCell,{data:y.data})]},b)}),o.jsx(zl.Spacer,{height:m})]}),o.jsx(zl.NextPageLoading,{isLoading:n,hasMore:r,setEndOfListElement:s})]})}function zts({onClear:e,onRemoveAll:t,onSave:n,onRemoveSaved:r,isLoading:s,filterFields:a,filterTokens:i,onFilterTokensChange:l,autoFocusFilterFieldId:c}){const u=i.length>0,d=i.some(f=>Bts(f,a));return o.jsxs("div",{className:K("grid grid-cols-[1fr_auto] gap-3 items-start"),children:[o.jsx(nTe,{fields:a,tokens:i,onTokensChange:l,disabled:s,autoFocusFieldId:c}),u&&o.jsx(eTe,{disabled:s,onClear:d?e:void 0,onRemoveAll:t,onSave:n,onRemoveSaved:r})]})}function Bts(e,t){const n=t.find(r=>r.id===e.fieldId);return n?n.kind==="text"?typeof e.value=="string"&&e.value.trim()!=="":n.kind==="pick-multi"?n.multi?Array.isArray(e.value)&&e.value.length>0:typeof e.value=="string"&&e.value!==""&&e.value!=="Any":n.kind==="multi-select"?Array.isArray(e.value)&&e.value.length>0:!1:!1}const Uts={"last-24h":"the last 24 hours","last-3d":"the last 3 days","last-7d":"the last 7 days","last-14d":"the last 14 days","last-30d":"the last 30 days"},zre="MMM d, yyyy HH:mm",Bre="Pick a wider range or lower the logging level — verbose entries (debug, info) may be filtered out.";function qts({datePreset:e,dateFrom:t,dateTo:n}){return e&&e!=="all"&&e!=="custom"?{title:`No logs for ${Uts[e]}`,description:Bre}:t&&n?{title:`No logs between ${er(t,zre)} and ${er(n,zre)}`,description:Bre}:t?{title:`No logs since ${er(t,zre)}`,description:Bre}:{title:"No logs yet",description:"Logs will appear here once agents, workflows, or tools are executed."}}const Vts=({datePreset:e,dateFrom:t,dateTo:n}={})=>{const{title:r,description:s}=qts({datePreset:e,dateFrom:t,dateTo:n});return o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Lr,{iconSlot:o.jsx(_xe,{}),titleSlot:r,descriptionSlot:s,actionSlot:o.jsxs(ue,{variant:"ghost",as:"a",href:"https://mastra.ai/en/docs/observability/logging",target:"_blank",rel:"noopener noreferrer",children:["Logging Documentation ",o.jsx(Cxe,{})]})})})},Hts=20,Wts=1e4;function Zts(e,t,n){if(e?.pagination?.hasMore)return n+1}function Gts(e){const t=new Set,n=[];for(const r of e.pages)for(const s of r.logs??[]){const a=s.logId??JSON.stringify(s);t.has(a)||(t.add(a),n.push(s))}return n}function Qts(e){return b1t(e.state.error,"logs")?!1:Wts}const Yts=({filters:e}={})=>{const t=We(),{inView:n,setRef:r}=__(),s=R1({queryKey:["logs",e],queryFn:({pageParam:p})=>t.listLogsVNext({pagination:{page:p,perPage:Hts},filters:e,orderBy:{field:"timestamp",direction:"DESC"}}),initialPageParam:0,getNextPageParam:Zts,select:Gts,retry:!1,refetchInterval:Qts}),{hasNextPage:a,isFetchingNextPage:i,fetchNextPage:l,data:c,isLoading:u,isError:d,error:f}=s;return v.useEffect(()=>{n&&a&&!i&&l()},[n,a,i,l]),{data:c,hasNextPage:a,isFetchingNextPage:i,fetchNextPage:l,isLoading:u,isError:d,error:f,setEndOfListElement:r}},Xts="Filters setting for Logs saved",Kts="Filters setting for Logs cleared up";function Jts(e,t,n){const{storageKey:r,messages:s,skipHydration:a}={},[i,l]=v.useState(()=>MGe(r)!==null),c=v.useCallback(()=>{RQr(e,r),l(!0);const f=s?.saved??Xts;f!==!1&&De.success(f)},[e,r,s?.saved]),u=v.useCallback(()=>{PQr(r),l(!1);const f=s?.cleared??Kts;f!==!1&&De.success(f)},[r,s?.cleared]),d=v.useRef(!1);return v.useEffect(()=>{if(a||d.current||(d.current=!0,$Qr(e)))return;const f=MGe(r);f&&t(p=>{const h=new URLSearchParams(p);for(const[m,g]of f)h.append(m,g);return h},{replace:!0})},[]),{hasSavedFilters:i,handleSave:c,handleRemoveSaved:u}}function ens(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return(t>>>0).toString(36)}function tns(e){const t=new Map;for(const n of e){if(n.logId){t.set(n,n.logId);continue}const r=n.timestamp instanceof Date?n.timestamp.toISOString():n.timestamp;t.set(n,ens(`${r}${n.message??""}${n.data?JSON.stringify(n.data):""}`))}return t}function nns(e,t,n,r){const s=v.useMemo(()=>tns(e),[e]),a=v.useMemo(()=>{const h=new Map;for(let m=0;m<e.length;m++){const g=s.get(e[m]);g&&h.set(g,{log:e[m],idx:m})}return h},[e,s]),l=(t?a.get(t):void 0)?.idx??-1,c=l>=0?e[l]:null,u=v.useCallback(h=>s.get(h),[s]),d=v.useCallback(h=>{const m=s.get(h);if(m){if(t===m){n({logId:null});return}n(r?{logId:m,traceId:h.traceId??null,spanId:null}:{logId:m})}},[s,t,r,n]),f=l>0?()=>{const h=e[l-1],m=s.get(h);n(r?{logId:m,traceId:h.traceId??null,spanId:null}:{logId:m})}:void 0,p=l>=0&&l<e.length-1?()=>{const h=e[l+1],m=s.get(h);n(r?{logId:m,traceId:h.traceId??null,spanId:null}:{logId:m})}:void 0;return{logIdMap:s,getLogId:u,featuredLog:c,handleLogClick:d,handlePreviousLog:f,handleNextLog:p}}const Ive="logId",Ave="traceId",Rve="spanId",IR=1440*60*1e3,rns={"last-24h":IR,"last-3d":3*IR,"last-7d":7*IR,"last-14d":14*IR,"last-30d":30*IR};function G8(e){e.delete(Ive),e.delete(Ave),e.delete(Rve)}function sns(e,t,n){const{onRemoveAll:r}={},s=v.useMemo(()=>{const _=e.get(zb);return _&&AQr.has(_)?_:"last-24h"},[e]),a=e.get(Bb),i=e.get(Ub),l=v.useMemo(()=>{if(s==="custom"){if(!a)return;const C=new Date(a);return Number.isNaN(C.getTime())?void 0:C}if(s==="all")return;const _=rns[s];return _?new Date(Date.now()-_):void 0},[s,a]),c=v.useMemo(()=>{if(s!=="custom"||!i)return;const _=new Date(i);return Number.isNaN(_.getTime())?void 0:_},[s,i]),u=v.useRef(s);u.current=s;const d=e.get(Ive),f=e.get(Ave),p=e.get(Rve),h=v.useMemo(()=>A6t.find(_=>_.entityType===e.get(Px)),[e]),m=v.useMemo(()=>DQr(e),[e]),g=v.useCallback(_=>{t(C=>{const E=new URLSearchParams(C);for(const[j,N]of Object.entries(_)){const I=j==="logId"?Ive:j==="traceId"?Ave:Rve;N?E.set(I,N):E.delete(I)}return E},{replace:!0})},[t]),y=v.useCallback(_=>{t(C=>{const E=new URLSearchParams(C);return FQr(E,_),G8(E),E},{replace:!0})},[t]),b=y,w=v.useCallback((_,C)=>{if(u.current!=="custom")return;const E=C==="from"?Bb:Ub;t(j=>{const N=new URLSearchParams(j);return _?N.set(E,_.toISOString()):N.delete(E),G8(N),N},{replace:!0})},[t]),S=v.useCallback(_=>{u.current=_,t(C=>{const E=new URLSearchParams(C);return _==="last-24h"?(E.delete(zb),E.delete(Bb),E.delete(Ub)):_==="custom"?E.set(zb,"custom"):(E.set(zb,_),E.delete(Bb),E.delete(Ub)),G8(E),E},{replace:!0})},[t]),k=v.useCallback(()=>{t(_=>{const C=new URLSearchParams(_);C.delete(Px);for(const E of U4)C.delete(kl[E]);return C.delete(zb),C.delete(Bb),C.delete(Ub),G8(C),C},{replace:!0}),r?.()},[t,r]);return v.useMemo(()=>({searchParams:e,setSearchParams:t,datePreset:s,selectedDateFrom:l,selectedDateTo:c,datePresetRef:u,featuredLogId:d,featuredTraceId:f,featuredSpanId:p,selectedEntityOption:h,filterTokens:m,handleFeaturedChange:g,handleFilterTokensChange:b,handleDateChange:w,handleDatePresetChange:S,handleRemoveAll:k,applyFilterTokens:y}),[e,t,s,l,c,u,d,f,p,h,m,g,b,w,S,k,y])}function ans(){const[e,t]=ji(),n=sns(e,t),r=Jts(e,t),[s,a]=v.useState(),[i,l]=v.useState(!1),{data:c=[],isPending:u}=lTe(),{data:d=[],isPending:f}=aTe({entityType:n.selectedEntityOption?.entityType,rootOnly:!0}),{data:p=[],isPending:h}=iTe(),{data:m=[],isPending:g}=oTe(),y=v.useMemo(()=>MQr({availableTags:c,availableRootEntityNames:d,availableServiceNames:m,availableEnvironments:p,loading:{tags:u,entityNames:f,serviceNames:g,environments:h}}),[c,d,m,p,u,f,g,h]),b=v.useMemo(()=>zQr({rootEntityType:n.selectedEntityOption?.entityType,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,tokens:n.filterTokens}),[n.filterTokens,n.selectedDateFrom,n.selectedDateTo,n.selectedEntityOption]),{data:w=[],isLoading:S,error:k,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:E}=Yts({filters:b}),{logIdMap:j,featuredLog:N,handleLogClick:I,handlePreviousLog:R,handleNextLog:$}=nns(w,n.featuredLogId,n.handleFeaturedChange,n.featuredTraceId),{data:F,isLoading:D}=HH(n.featuredTraceId??null),{data:V,isLoading:W}=aI(n.featuredTraceId??"",n.featuredSpanId??""),L=v.useCallback(()=>n.applyFilterTokens(BQr(y,n.filterTokens)),[y,n]),z=v.useCallback(()=>n.handleFeaturedChange({logId:null}),[n]),B=v.useCallback(X=>n.handleFeaturedChange({traceId:X,spanId:null}),[n]),M=v.useCallback((X,te)=>n.handleFeaturedChange({traceId:X,spanId:te}),[n]),G=v.useCallback(()=>{n.handleFeaturedChange({traceId:null,spanId:null}),l(!1)},[n]),U=v.useCallback(()=>n.handleFeaturedChange({spanId:null}),[n]),P=v.useCallback(X=>n.handleFeaturedChange({spanId:X??null}),[n]),q=o.jsxs(Lt.TopArea,{children:[o.jsx(Lt.Row,{children:o.jsxs(Lt.Column,{className:"flex flex-wrap items-start justify-start gap-2",children:[o.jsx(Jje,{preset:n.datePreset,onPresetChange:n.handleDatePresetChange,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,onDateChange:n.handleDateChange,disabled:S,presets:["last-24h","last-3d","last-7d","last-14d","last-30d","custom"]}),o.jsx(rTe,{fields:y,tokens:n.filterTokens,onTokensChange:n.handleFilterTokensChange,disabled:S,onStartTextFilter:a})]})}),o.jsx(zts,{isLoading:S,filterFields:y,filterTokens:n.filterTokens,onFilterTokensChange:n.handleFilterTokensChange,onClear:L,onRemoveAll:n.handleRemoveAll,onSave:r.handleSave,onRemoveSaved:r.hasSavedFilters?r.handleRemoveSaved:void 0,autoFocusFilterFieldId:s})]});if(k)return o.jsxs(Lt,{width:"wide",height:"full",children:[q,o.jsx(Lt.MainArea,{isCentered:!0,children:o.jsx(Tts,{error:k,resource:"logs",errorTitle:"Failed to load logs"})})]});const Z=!!n.selectedEntityOption||n.filterTokens.length>0;return w.length===0&&!S&&!Z?o.jsxs(Lt,{width:"wide",height:"full",children:[q,o.jsx(Lt.MainArea,{isCentered:!0,children:o.jsx(Vts,{datePreset:n.datePreset,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo})})]}):o.jsxs(Lt,{width:"wide",height:"full",children:[q,o.jsx(Nts,{logCollapsed:i,listSlot:o.jsx(Fts,{logs:w,isLoading:S,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:E,logIdMap:j,featuredLogId:n.featuredLogId,onLogClick:I}),logPanelSlot:N?o.jsx(tYr,{log:N,onClose:z,onTraceClick:B,onSpanClick:M,onPrevious:R,onNext:$,collapsed:i,onCollapsedChange:l}):null,tracePanelSlot:n.featuredTraceId?o.jsx(QEt,{traceId:n.featuredTraceId,spans:F?.spans,isLoading:D,onClose:G,onSpanSelect:P,selectedSpanId:n.featuredSpanId}):null,spanPanelSlot:n.featuredTraceId&&n.featuredSpanId?o.jsx(UQr,{spanId:n.featuredSpanId,span:V?.span,isLoading:W,onClose:U}):null})]})}function ins({server:e}){const{paths:t,Link:n}=yn(),s=We().options.baseUrl,a=s?`${s}/api/mcp/${e.id}/sse`:"",{data:i}=Q4t(e),l=Object.values(i||{}),c=l.length,u=l.filter(p=>p.toolType==="agent").length,d=l.filter(p=>p.toolType==="workflow").length,f=dm(e.name,50);return o.jsxs(me.RowLink,{to:t.mcpServerLink(e.id),LinkComponent:n,children:[o.jsx(me.NameCell,{children:f}),o.jsx(me.DescriptionCell,{children:a}),o.jsx(me.TextCell,{className:"text-center",children:u||""}),o.jsx(me.TextCell,{className:"text-center",children:c||""}),o.jsx(me.TextCell,{className:"text-center",children:d||""})]})}function ons({mcpServers:e,isLoading:t,search:n=""}){const r=v.useMemo(()=>{const s=n.toLowerCase();return e.filter(a=>a.name?.toLowerCase().includes(s)||a.id?.toLowerCase().includes(s))},[e,n]);return t?o.jsx(el,{columns:"auto 1fr auto auto auto"}):o.jsxs(me,{columns:"auto 1fr auto auto auto",variant:"striped",children:[o.jsxs(me.Top,{children:[o.jsx(me.TopCell,{children:"Name"}),o.jsx(me.TopCell,{children:"URL"}),o.jsx(me.TopCellSmart,{long:"Agents",short:o.jsx(rl,{}),tooltip:"Agent Tools",className:"text-center"}),o.jsx(me.TopCellSmart,{long:"Tools",short:o.jsx(Gp,{}),tooltip:"Tools",className:"text-center"}),o.jsx(me.TopCellSmart,{long:"Workflows",short:o.jsx(kd,{}),tooltip:"Workflow Tools",className:"text-center"})]}),r.length===0&&n?o.jsx(me.NoMatch,{message:"No MCP Servers match your search"}):null,r.map(s=>o.jsx(ins,{server:s},s.id))]})}const lns=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Lr,{iconSlot:o.jsx(xf,{}),titleSlot:"No MCP Servers yet",descriptionSlot:o.jsxs(o.Fragment,{children:["MCP servers are not configured yet. ",o.jsx("br",{}),"More information in the documentation."]}),actionSlot:o.jsxs(ue,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/tools-mcp/mcp-overview",target:"_blank",rel:"noopener noreferrer",children:["MCP Documentation ",o.jsx(Pa,{})]})})}),cns=()=>{const{data:e=[],isLoading:t,error:n}=vZ(),[r,s]=v.useState("");return n&&gs(n)?o.jsx(lr,{children:o.jsx(Vs,{})}):n&&ys(n)?o.jsx(lr,{children:o.jsx(Ds,{resource:"MCP servers"})}):n?o.jsx(lr,{children:o.jsx(Fi,{title:"Failed to load MCP servers",message:n.message})}):e.length===0&&!t?o.jsx(lr,{children:o.jsx(lns,{})}):o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx("div",{className:"max-w-120",children:o.jsx(Of,{onSearch:s,label:"Filter MCP servers",placeholder:"Filter by name"})})}),o.jsx(ons,{mcpServers:e,isLoading:t,search:r})]})},uns=(e,t)=>{const n=new Map,r=Object.keys(t);for(const s of r){const a=t[s],i=a.tools,l=Object.keys(i);for(const c of l){const u=i[c];n.has(u.id)||n.set(u.id,{...u,agents:[]}),n.get(u.id).agents.push({...a,id:s})}}for(const[s,a]of Object.entries(e))n.has(a.id)||n.set(a.id,{...a,agents:[]});return Array.from(n.values())};function dns({tools:e,agents:t,isLoading:n,search:r=""}){const{paths:s,Link:a}=yn(),i=v.useMemo(()=>uns(e,t),[e,t]),l=v.useMemo(()=>i.filter(c=>c.id.toLowerCase().includes(r.toLowerCase())),[i,r]);return n?o.jsx(el,{columns:"auto 1fr auto"}):o.jsxs(me,{columns:"auto 1fr auto",variant:"striped",children:[o.jsxs(me.Top,{children:[o.jsx(me.TopCell,{children:"Name"}),o.jsx(me.TopCell,{children:"Description"}),o.jsx(me.TopCellSmart,{long:"Agents",short:o.jsx(rl,{}),tooltip:"Attached Agents",className:"text-center"})]}),l.length===0&&r?o.jsx(me.NoMatch,{message:"No Tools match your search"}):null,l.map(c=>{const u=dm(c.id,50),d=dm(c.description??"",200),f=c.agents.length;return o.jsxs(me.RowLink,{to:s.toolLink(c.id),LinkComponent:a,children:[o.jsx(me.NameCell,{children:u}),o.jsx(me.DescriptionCell,{children:d}),o.jsx(me.TextCell,{className:"text-center",children:f||""})]},c.id)})]})}const fns=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Lr,{iconSlot:o.jsx(xf,{}),titleSlot:"No Tools yet",descriptionSlot:o.jsxs(o.Fragment,{children:["Mastra tools are not configured yet. ",o.jsx("br",{}),"More information in the documentation."]}),actionSlot:o.jsxs(ue,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/agents/using-tools-and-mcp",target:"_blank",rel:"noopener noreferrer",children:["Tools Documentation ",o.jsx(Pa,{})]})})}),pns=()=>{const e=We();return Rn({mutationFn:async({toolId:t,input:n,requestContext:r})=>{const s=new r_;Object.entries(r??{}).forEach(([a,i])=>{s.set(a,i)});try{return await e.getTool(t).execute({data:n,requestContext:s})}catch(a){throw De.error("Error executing dev tool"),console.error("Error executing dev tool:",a),a}}})},hns=({toolId:e})=>{const{canExecute:t}=al(),n=t("tools"),{data:r={}}=Sm(),s=v.useMemo(()=>{for(const g of Object.values(r))if(g.tools){const y=Object.values(g.tools).find(b=>b.id===e);if(y)return y}return null},[r,e]),{data:a,isLoading:i,error:l}=G0r(e,{enabled:!s}),c=s||a,{mutateAsync:u,isPending:d,data:f}=pns(),{requestContext:p}=_s();v.useEffect(()=>{if(l){const g=l instanceof Error?l.message:"Failed to load tool";De.error(`Error loading tool: ${g}`)}},[l]);const h=async(g,y)=>{if(!c)return;const b={...p??{},...y??{}};return u({toolId:c.id,input:g,requestContext:b})},m=c?.inputSchema?im(sm(mx(c?.inputSchema))):Ss({});return i?o.jsxs("div",{className:"p-6",children:[o.jsx(At,{className:"h-8 w-48 mb-4"}),o.jsx(At,{className:"h-32 w-full"})]}):l?null:c?n?o.jsx(Mje,{executionResult:f,isExecutingTool:d,zodInputSchema:m,handleExecuteTool:h,toolDescription:c.description,toolId:c.id,requestContextSchema:c.requestContextSchema}):o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"ui-sm",className:"text-neutral3",children:"You don't have permission to execute tools."})}):o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"header-md",className:"text-neutral3",children:"Tool not found"})})};function mns({value:e,onValueChange:t,placeholder:n="Select a tool...",searchPlaceholder:r="Search tools...",emptyText:s="No tools found.",className:a,disabled:i=!1,variant:l}){const{data:c={},isLoading:u,isError:d,error:f}=oI(),{data:p={},isLoading:h,isError:m,error:g}=Sm(),{navigate:y,paths:b}=yn();v.useEffect(()=>{if(d){const _=f instanceof Error?f.message:"Failed to load tools";De.error(`Error loading tools: ${_}`)}},[d,f]),v.useEffect(()=>{if(m){const _=g instanceof Error?g.message:"Failed to load agents";De.error(`Error loading agents: ${_}`)}},[m,g]);const w=new Map;Object.values(p).forEach(_=>{_.tools&&Object.values(_.tools).forEach(C=>{w.has(C.id)||w.set(C.id,C)})}),Object.values(c).forEach(_=>{w.has(_.id)||w.set(_.id,_)});const S=Array.from(w.values()).map(_=>({label:_.id,value:_.id})),k=_=>{t?t(_):_&&_!==e&&y(b.toolLink(_))};return o.jsx(Xl,{options:S,value:e,onValueChange:k,placeholder:u||h?"Loading tools...":n,searchPlaceholder:r,emptyText:s,className:a,disabled:i||u||h||d||m,variant:l})}const gns=({isLoading:e,server:t})=>{const[{sseUrl:n,httpStreamUrl:r},s]=v.useState({sseUrl:"",httpStreamUrl:""});if(v.useEffect(()=>{if(!t)return;const i=window.MASTRA_SERVER_HOST,l=window.MASTRA_SERVER_PORT;let c=null;i&&l&&(c=`http://${i}:${l}`);const u=c||"http://localhost:4111",d=`${u}/api/mcp/${t.id}/sse`,f=`${u}/api/mcp/${t.id}/mcp`;s({sseUrl:d,httpStreamUrl:f})},[t]),e)return null;if(!t)return o.jsx(xy,{children:o.jsx(ge,{as:"h1",variant:"header-md",className:"text-neutral3 font-medium py-20 text-center",children:"Server not found"})});const a=`npx -y mcp-remote ${n}`;return o.jsxs(xy,{isDivided:!0,children:[o.jsxs("div",{className:"px-8 py-12 mx-auto max-w-2xl w-full",children:[o.jsx(ge,{as:"h1",variant:"header-md",className:"text-neutral6 font-medium pb-4",children:t.name}),o.jsxs("div",{className:"flex items-center gap-1 pb-6",children:[o.jsx(fn,{icon:o.jsx(FEt,{className:"text-neutral6"}),className:"rounded-r-sm text-neutral4!",children:"Version"}),o.jsx(fn,{className:"rounded-l-sm text-neutral4!",children:t.version_detail.version})]}),o.jsx(ge,{className:"text-neutral3 pb-4",children:"This MCP server can be accessed through multiple transport methods. Choose the one that best fits your use case."}),o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(fn,{icon:o.jsx("span",{className:"font-mono w-6 text-accent1 font-medium mr-1",children:"HTTP"}),children:"Regular HTTP Endpoint"}),o.jsx(ge,{className:"text-neutral3 pt-1 pb-2",children:"Use for stateless HTTP transport with streamable responses."}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(ge,{className:"px-2 py-1 bg-surface4 rounded-lg",children:r}),o.jsx("div",{className:"pt-1",children:o.jsx(ya,{tooltip:"Copy HTTP Stream URL",content:r})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(fn,{icon:o.jsx("span",{className:"font-mono w-6 text-accent1 font-medium mr-1",children:"SSE"}),children:"Server-Sent Events"}),o.jsx(ge,{className:"text-neutral3 pt-1 pb-2",children:"Use for real-time communication via SSE."}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(ge,{className:"px-2 py-1 bg-surface4 rounded-lg",children:n}),o.jsx("div",{className:"pt-1",children:o.jsx(ya,{tooltip:"Copy SSE URL",content:n})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(fn,{icon:o.jsx("span",{className:"font-mono w-6 text-accent1 font-medium mr-1",children:"CLI"}),children:"Command Line"}),o.jsx(ge,{className:"text-neutral3 pt-1 pb-2",children:"Use for local command-line access via npx and mcp-remote."}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(ge,{className:"px-2 py-1 bg-surface4 rounded-lg",children:a}),o.jsx("div",{className:"pt-1",children:o.jsx(ya,{tooltip:"Copy Command Line Config",content:a})})]})]})]})]}),o.jsx("div",{className:"h-full overflow-y-scroll border-l border-border1",children:o.jsx(vns,{server:t})})]})},vns=({server:e})=>{const{data:t={},isLoading:n}=Q4t(e);if(n)return null;const r=Object.keys(t);return o.jsxs("div",{className:"p-5 overflow-y-scroll",children:[o.jsxs("div",{className:"text-neutral6 flex gap-2 items-center",children:[o.jsx(Ue,{size:"lg",className:"bg-surface4 rounded-md p-1",children:o.jsx(M_,{})}),o.jsx(ge,{variant:"header-md",as:"h2",className:"font-medium",children:"Available Tools"})]}),o.jsx("div",{className:"flex flex-col gap-2 pt-6",children:r.map(s=>{const a=t[s];return o.jsx(bns,{tool:a,serverId:e.id},s)})})]})};function yns(e){if(!e)return!1;const t=e.ui;return!!(typeof t?.resourceUri=="string"&&t.resourceUri.startsWith("ui://")||typeof e["ui/resourceUri"]=="string"&&e["ui/resourceUri"].startsWith("ui://"))}const bns=({tool:e,serverId:t})=>{const n=v.useRef(null),{Link:r,paths:s}=yn(),a=ILt[e.toolType||"tool"],i=yns(e._meta);return o.jsxs(Cf,{onClick:()=>n.current?.click(),children:[o.jsx(sAt,{children:o.jsx(a,{className:"group-hover/entity:text-accent6"})}),o.jsxs(jf,{children:[o.jsx(Ef,{children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx(r,{ref:n,href:s.mcpServerToolLink(t,e.id),children:e.id}),i&&o.jsx(fn,{className:"text-[10px] py-0",children:"App"})]})}),o.jsx(Qp,{children:e.description})]})]})},xns=()=>{const{serverId:e}=dr(),{data:t=[],isLoading:n}=vZ(),r=t.find(s=>s.id===e);return o.jsx("div",{className:"h-full w-full overflow-hidden",children:o.jsx(gns,{isLoading:n,server:r})})};function wns(e){if(!e)return;const t=e.ui;if(t?.resourceUri)return t.resourceUri;const n=e["ui/resourceUri"];if(typeof n=="string")return n}const Sns=({toolId:e,serverId:t})=>{const{canExecute:n}=al(),r=n("tools"),s=We(),{data:a,isLoading:i,error:l}=eje(t,e),{mutateAsync:c,isPending:u,data:d}=GFr(t,e),f=a?wns(a._meta):void 0,{data:p}=wt({queryKey:["mcp-app-resource",t,f],queryFn:async()=>f?(await s.readMcpServerResource(t,f)).contents[0]?.text??null:null,enabled:!!f}),h=v.useCallback(async(y,b)=>await c(b),[c]);v.useEffect(()=>{if(l){const y=l instanceof Error?l.message:"Failed to load tool";De.error(`Error loading tool: ${y}`)}},[l]);const m=async y=>{if(a)return await c(y)};if(i)return o.jsxs("div",{className:"p-6",children:[o.jsx(At,{className:"h-8 w-48 mb-4"}),o.jsx(At,{className:"h-32 w-full"})]});if(l)return null;if(!a)return o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"header-md",className:"text-neutral3",children:"Tool not found"})});if(!r)return o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"ui-sm",className:"text-neutral3",children:"You don't have permission to execute tools."})});let g;try{g=im(sm(a.inputSchema))}catch(y){console.error("Error processing input schema:",y),De.error("Failed to process tool input schema."),g=Ss({})}return o.jsxs("div",{className:"flex flex-col gap-4",children:[p&&o.jsx("div",{className:"border-b border-border1 p-4",children:o.jsx(G4t,{html:p,toolName:a.name??a.id,onToolCall:h})}),o.jsx(Mje,{executionResult:d,isExecutingTool:u,zodInputSchema:g,handleExecuteTool:m,toolDescription:a.description||"",toolId:a.id})]})},kns=()=>{const{serverId:e,toolId:t}=dr(),{data:n,isLoading:r}=eje(e,t);return r||!n?null:o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(Sns,{toolId:t,serverId:e})})},Ons=["last-24h","last-3d","last-7d","last-14d","last-30d","custom"];function _ns(e){switch(e){case"3d":return"last-3d";case"7d":return"last-7d";case"14d":return"last-14d";case"30d":return"last-30d";case"custom":return"custom";default:return"last-24h"}}function Cns(e){switch(e){case"last-3d":return"3d";case"last-7d":return"7d";case"last-14d":return"14d";case"last-30d":return"30d";case"custom":return"custom";default:return"24h"}}function Ens(){const{datePreset:e,setDatePreset:t,customRange:n,setCustomRange:r}=DZ(),s=v.useRef(e);s.current=e;const a=v.useRef(n);return a.current=n,o.jsx(Jje,{preset:_ns(e),onPresetChange:i=>{const l=Cns(i);s.current=l,t(l)},dateFrom:n?.from,dateTo:n?.to,onDateChange:(i,l)=>{if(s.current!=="custom")return;const c={...a.current,[l]:i};a.current=c,r(c)},presets:Ons})}const Ure={"24h":1440*60*1e3,"3d":4320*60*1e3,"7d":10080*60*1e3,"14d":336*60*60*1e3,"30d":720*60*60*1e3};function jns(e,t,n){if(e!=="custom"){const r=Ure[e]??Ure["24h"];return{start:new Date(n-r),end:new Date(n)}}return{start:t?.from??new Date(n-Ure["24h"]),end:t?.to??new Date(n)}}function Cm(){const{datePreset:e,customRange:t,dimensionalFilter:n,dimensionalFilterKey:r}=DZ(),s=v.useRef(null),a=e==="custom"?`custom:${t?.from?.getTime()??""}:${t?.to?.getTime()??""}`:`preset:${e}`;(!s.current||s.current.key!==a)&&(s.current={key:a,anchor:Date.now()});const i=s.current.anchor,l=v.useMemo(()=>jns(e,t,i),[e,t,i]),c=v.useMemo(()=>({timestamp:l,...n}),[l,r]),u=v.useMemo(()=>`${a}|${r}`,[a,r]);return{datePreset:e,customRange:t,timestamp:l,filters:c,dimensionalFilter:n,filterKey:u}}function f8t(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","agent-runs-kpi",n],queryFn:()=>e.getMetricAggregate({name:["mastra_agent_duration_ms"],aggregation:"count",filters:t,comparePeriod:"previous_period"})})}function q4({href:e,LinkComponent:t="a"}){return o.jsx(ue,{as:t,href:e,variant:"ghost",size:"icon-md",tooltip:"View in Traces","aria-label":"View in Traces",children:o.jsx(wkn,{})})}function Tns({href:e,LinkComponent:t="a"}){return o.jsx(ue,{as:t,href:e,variant:"ghost",size:"icon-md",tooltip:"View errors in Logs","aria-label":"View errors in Logs",children:o.jsx(rOn,{})})}function Nns(e){switch(e){case"24h":return"last-24h";case"3d":return"last-3d";case"7d":return"last-7d";case"14d":return"last-14d";case"30d":return"last-30d";case"custom":return"custom";default:return}}function Ins(e,t){if(t==="1h"){const s=new Date(e);s.setUTCMinutes(0,0,0);const a=new Date(s.getTime()+3600*1e3);return{from:s,to:a}}const n=new Date(e);n.setUTCHours(0,0,0,0);const r=new Date(n.getTime()+1440*60*1e3);return{from:n,to:r}}function p8t(e,t,n,r,s,a,i){if(i){e.set(t,"custom"),e.set(n,i.from.toISOString()),e.set(r,i.to.toISOString());return}if(s==="custom"){e.set(t,"custom"),a?.from&&e.set(n,a.from.toISOString()),a?.to&&e.set(r,a.to.toISOString());return}const l=Nns(s);l&&e.set(t,l)}function jo(e,t,n){typeof n=="string"&&n.length>0&&e.set(t,n)}function h8t(e,t,n){if(!(!Array.isArray(n)||n.length===0))for(const r of n)r&&e.append(t,r)}function kQe({preset:e,customRange:t,dashboardFilter:n,scope:r,tracesBasePath:s="/observability"}){const a=new URLSearchParams;a.set(gw,"branches"),p8t(a,vw,yw,bw,e,t,r.window);const i=r.rootEntityType??n.rootEntityType;i&&a.set(_x,i),r.status&&a.set(Cx,r.status),jo(a,Sl.entityName,r.entityName??n.entityName),jo(a,Sl.threadId,r.threadId??n.threadId),jo(a,Sl.resourceId,r.resourceId??n.resourceId),jo(a,Sl.entityId,n.entityId),jo(a,Sl.runId,n.runId),jo(a,Sl.sessionId,n.sessionId),jo(a,Sl.requestId,n.requestId),jo(a,Sl.userId,n.userId),jo(a,Sl.organizationId,n.organizationId),jo(a,Sl.experimentId,n.experimentId),jo(a,Sl.serviceName,n.serviceName),jo(a,Sl.environment,n.environment),h8t(a,Sl.tags,n.tags);const l=a.toString();return l?`${s}?${l}`:s}function Ans({preset:e,customRange:t,dashboardFilter:n,scope:r,logsBasePath:s="/logs"}){const a=new URLSearchParams;p8t(a,zb,Bb,Ub,e,t,r.window);const i=r.rootEntityType??n.rootEntityType;i&&a.set(Px,i),jo(a,kl.entityName,r.entityName??n.entityName),jo(a,kl.threadId,r.threadId??n.threadId),jo(a,kl.resourceId,r.resourceId??n.resourceId),jo(a,kl.runId,n.runId),jo(a,kl.sessionId,n.sessionId),jo(a,kl.requestId,n.requestId),jo(a,kl.userId,n.userId),jo(a,kl.organizationId,n.organizationId),jo(a,kl.experimentId,n.experimentId),jo(a,kl.serviceName,n.serviceName),jo(a,kl.environment,n.environment),h8t(a,kl.tags,n.tags),r.status==="error"&&a.append(kl.level,"error");const l=a.toString();return l?`${s}?${l}`:s}function wI(){const{datePreset:e,customRange:t,dimensionalFilter:n,tracesBasePath:r,logsBasePath:s}=DZ(),a=v.useCallback((c={})=>kQe({preset:e,customRange:t,dashboardFilter:n,scope:c,tracesBasePath:r}),[e,t,n,r]),i=v.useCallback((c={})=>Ans({preset:e,customRange:t,dashboardFilter:n,scope:c,logsBasePath:s}),[e,t,n,s]),l=v.useCallback((c,u,d)=>{const f=Ins(u,d);return kQe({preset:e,customRange:t,dashboardFilter:n,scope:{...c,window:f},tracesBasePath:r})},[e,t,n,r]);return{getTracesHref:a,getLogsHref:i,getBucketTracesHref:l}}const m8t="1h";async function qre(e,t,n){const r=await e.getMetricPercentiles({name:t,percentiles:[.5,.95],interval:m8t,filters:n}),s=r.series.find(l=>l.percentile===.5),a=r.series.find(l=>l.percentile===.95);if(!s||!a)return[];const i=new Map(a.points.map(l=>[new Date(l.timestamp).getTime(),l.value]));return s.points.map(l=>{const c=new Date(l.timestamp),u=c.getTime();return{time:c.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}),tsMs:u,p50:Math.round(l.value),p95:Math.round(i.get(u)??0)}})}function Rns(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","latency",n],queryFn:async()=>{const[r,s,a]=await Promise.all([qre(e,"mastra_agent_duration_ms",t),qre(e,"mastra_workflow_duration_ms",t),qre(e,"mastra_tool_duration_ms",t)]);return{agentData:r,workflowData:s,toolData:a,interval:m8t}}})}const OQe={agents:Os.AGENT,workflows:Os.WORKFLOW_RUN,tools:Os.TOOL};function Pns(){const{data:e,isLoading:t,isError:n}=Rns(),{getTracesHref:r,getBucketTracesHref:s}=wI(),{Link:a}=yn(),i=bs();return o.jsx(EQr,{data:e,isLoading:t,isError:n,onPointClick:(l,c)=>{Number.isFinite(c.tsMs)&&i(s({rootEntityType:OQe[l]},c.tsMs,"1h"))},actions:l=>o.jsx(q4,{href:r({rootEntityType:OQe[l]}),LinkComponent:a})})}function $ns(e){return e==="threads"||e==="resources"}function Vre(e){return e.length<=12?e:`${e.slice(0,6)}…${e.slice(-4)}`}function Mns({threads:e,resources:t,getThreadRowHref:n,getResourceRowHref:r,actions:s,LinkComponent:a}){const[i,l]=v.useState("threads"),c=e.data?.map(y=>({...y,key:y.threadId}))??[],u=t.data?.map(y=>({...y,key:y.resourceId}))??[],d=c.length>0,f=u.length>0,p=e.data?.reduce((y,b)=>y+b.runs,0)??0,h=t.data?.reduce((y,b)=>y+b.threadCount,0)??0,m=i==="threads"?e:t,g=typeof s=="function"?s(i):s;return o.jsxs(Bt,{children:[o.jsxs(Bt.TopBar,{children:[o.jsx(Bt.TitleAndDescription,{title:"Memory",description:"Resource and Thread consumption"}),i==="threads"&&d&&o.jsx(Bt.Summary,{value:p.toLocaleString(),label:"Total runs"}),i==="resources"&&f&&o.jsx(Bt.Summary,{value:h.toLocaleString(),label:"Total threads"}),g?o.jsx(Bt.Actions,{children:g}):null]}),m.isLoading?o.jsx(Bt.Loading,{}):m.isError?o.jsx(Bt.Error,{message:"Failed to load memory data"}):o.jsx(Bt.Content,{children:o.jsxs(ru,{defaultTab:"threads",value:i,onValueChange:y=>{$ns(y)&&l(y)},className:"grid grid-rows-[auto_1fr] overflow-y-auto h-full",children:[o.jsxs(su,{children:[o.jsx(Vr,{value:"threads",children:"Threads"}),o.jsx(Vr,{value:"resources",children:"Resources"})]}),o.jsx(ps,{value:"threads",children:d?o.jsxs(me,{columns:"auto auto auto auto auto",...kve,children:[o.jsxs(me.Top,{children:[o.jsx(me.TopCell,{sticky:"start",children:"Thread ID"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Resource ID"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Runs"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Tokens"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Cost"})]}),c.map(y=>{const b=n?.(y),w=o.jsxs(o.Fragment,{children:[o.jsx(me.RowHeaderCell,{height:"compact",className:"text-ui-sm",children:Vre(y.threadId)}),o.jsx(me.NumberCell,{children:y.resourceId?Vre(y.resourceId):"—"}),o.jsx(me.NumberCell,{highlight:!0,children:y.runs.toLocaleString()}),o.jsx(me.NumberCell,{children:y.tokens>0?yc(y.tokens):"—"}),o.jsx(me.NumberCell,{children:y.cost!=null?vg(y.cost,y.costUnit):"—"})]});return b?o.jsx(me.RowLink,{to:b,LinkComponent:a,children:w},y.key):o.jsx(me.RowStatic,{children:w},y.key)})]}):o.jsx(Bt.NoData,{message:"No thread activity yet"})}),o.jsx(ps,{value:"resources",children:f?o.jsxs(me,{columns:"auto auto auto auto",...kve,children:[o.jsxs(me.Top,{children:[o.jsx(me.TopCell,{sticky:"start",children:"Resource ID"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Threads"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Tokens"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Cost"})]}),u.map(y=>{const b=r?.(y),w=o.jsxs(o.Fragment,{children:[o.jsx(me.RowHeaderCell,{height:"compact",className:"text-ui-sm",children:Vre(y.resourceId)}),o.jsx(me.NumberCell,{highlight:!0,children:y.threadCount.toLocaleString()}),o.jsx(me.NumberCell,{children:y.tokens>0?yc(y.tokens):"—"}),o.jsx(me.NumberCell,{children:y.cost!=null?vg(y.cost,y.costUnit):"—"})]});return b?o.jsx(me.RowLink,{to:b,LinkComponent:a,children:w},y.key):o.jsx(me.RowStatic,{children:w},y.key)})]}):o.jsx(Bt.NoData,{message:"No resource activity yet"})})]})})]})}const Hre=20;function Dns(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","top-active-threads",n],queryFn:async()=>{const r={groupBy:["threadId","resourceId"],orderDirection:"DESC",filters:t},[s,a,i]=await Promise.all([e.getMetricBreakdown({...r,name:["mastra_agent_duration_ms"],aggregation:"count",limit:Hre}),e.getMetricBreakdown({...r,name:["mastra_model_total_input_tokens"],aggregation:"sum",limit:Hre}),e.getMetricBreakdown({...r,name:["mastra_model_total_output_tokens"],aggregation:"sum",limit:Hre})]),l=new Map,c=d=>(l.has(d)||l.set(d,{tokens:0,cost:null,costUnit:null}),l.get(d)),u=d=>{for(const f of d){const p=f.dimensions.threadId;if(!p)continue;const h=c(p);h.tokens+=f.value,f.estimatedCost!=null&&(h.cost=(h.cost??0)+f.estimatedCost,f.costUnit&&(h.costUnit=f.costUnit))}};return u(a.groups),u(i.groups),s.groups.filter(d=>!!d.dimensions.threadId).map(d=>{const f=d.dimensions.threadId,p=l.get(f);return{threadId:f,resourceId:d.dimensions.resourceId??null,runs:d.value,tokens:p?.tokens??0,cost:p?.cost??null,costUnit:p?.costUnit??null}})}})}const Wre=20;function Lns(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","top-resources-by-threads",n],queryFn:async()=>{const r={groupBy:["resourceId"],orderDirection:"DESC",filters:t},[s,a,i]=await Promise.all([e.getMetricBreakdown({...r,name:["mastra_agent_duration_ms"],aggregation:"count_distinct",distinctColumn:"threadId",limit:Wre}),e.getMetricBreakdown({...r,name:["mastra_model_total_input_tokens"],aggregation:"sum",limit:Wre}),e.getMetricBreakdown({...r,name:["mastra_model_total_output_tokens"],aggregation:"sum",limit:Wre})]),l=new Map,c=d=>(l.has(d)||l.set(d,{tokens:0,cost:null,costUnit:null}),l.get(d)),u=d=>{for(const f of d){const p=f.dimensions.resourceId;if(!p)continue;const h=c(p);h.tokens+=f.value,f.estimatedCost!=null&&(h.cost=(h.cost??0)+f.estimatedCost,f.costUnit&&(h.costUnit=f.costUnit))}};return u(a.groups),u(i.groups),s.groups.filter(d=>!!d.dimensions.resourceId).map(d=>{const f=d.dimensions.resourceId,p=l.get(f);return{resourceId:f,threadCount:d.value,tokens:p?.tokens??0,cost:p?.cost??null,costUnit:p?.costUnit??null}})}})}function Fns(){const e=Dns(),t=Lns(),{getTracesHref:n}=wI(),{Link:r}=yn();return o.jsx(Mns,{threads:{data:e.data,isLoading:e.isLoading,isError:e.isError},resources:{data:t.data,isLoading:t.isLoading,isError:t.isError},LinkComponent:r,getThreadRowHref:s=>n({threadId:s.threadId,...s.resourceId?{resourceId:s.resourceId}:{}}),getResourceRowHref:s=>n({resourceId:s.resourceId})})}function V4({label:e,value:t,prevValue:n,changePct:r,isLoading:s,isError:a}){const i=t!=null;return o.jsxs(Kr,{children:[o.jsx(Kr.Label,{children:e}),o.jsx(Kr.Value,{className:i?void 0:"invisible",children:i?t:"—"}),a?o.jsx(Kr.Error,{}):s?o.jsx(Kr.Loading,{}):i?r!=null?o.jsx(Kr.Change,{changePct:r,prevValue:n}):o.jsx(Kr.NoChange,{}):o.jsx(Kr.NoData,{})]})}function zns(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","active-resources-kpi",n],queryFn:()=>e.getMetricAggregate({name:["mastra_agent_duration_ms"],aggregation:"count_distinct",distinctColumn:"resourceId",filters:t,comparePeriod:"previous_period"})})}function Bns(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","active-threads-kpi",n],queryFn:()=>e.getMetricAggregate({name:["mastra_agent_duration_ms"],aggregation:"count_distinct",distinctColumn:"threadId",filters:t,comparePeriod:"previous_period"})})}function Uns(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","model-cost-kpi",n],queryFn:async()=>{const r=await e.getMetricAggregate({name:["mastra_model_total_input_tokens","mastra_model_total_output_tokens"],aggregation:"sum",filters:t,comparePeriod:"previous_period"});return{cost:r.estimatedCost??null,costUnit:r.costUnit??null,previousCost:r.previousEstimatedCost??null,costChangePercent:r.costChangePercent??null}}})}function qns(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","total-tokens-kpi",n],queryFn:async()=>{const[r,s]=await Promise.all([e.getMetricAggregate({name:["mastra_model_total_input_tokens"],aggregation:"sum",filters:t,comparePeriod:"previous_period"}),e.getMetricAggregate({name:["mastra_model_total_output_tokens"],aggregation:"sum",filters:t,comparePeriod:"previous_period"})]),a=r.value!=null||s.value!=null,i=r.previousValue!=null||s.previousValue!=null,l=(r.value??0)+(s.value??0),c=(r.previousValue??0)+(s.previousValue??0),u=i&&c>0?(l-c)/c*100:null;return{value:a?l:null,previousValue:i?c:null,changePercent:u}}})}function Vns(){const{data:e,isLoading:t,isError:n}=f8t();return o.jsx(V4,{label:"Total Agent Runs",value:e?.value!=null?e.value.toLocaleString():null,prevValue:e?.previousValue!=null?e.previousValue.toLocaleString():void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function Hns(){const{data:e,isLoading:t,isError:n}=Uns();return o.jsx(V4,{label:"Total Model Cost",value:e?.cost!=null?vg(e.cost,e.costUnit):null,prevValue:e?.previousCost!=null?vg(e.previousCost,e.costUnit):void 0,changePct:e?.costChangePercent??null,isLoading:t,isError:n})}function Wns(){const{data:e,isLoading:t,isError:n}=qns();return o.jsx(V4,{label:"Total Tokens",value:e?.value!=null?yc(e.value):null,prevValue:e?.previousValue!=null?yc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function Zns(){const{data:e,isLoading:t,isError:n}=Bns();return o.jsx(V4,{label:"Total Threads",value:e?.value!=null?yc(e.value):null,prevValue:e?.previousValue!=null?yc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function Gns(){const{data:e,isLoading:t,isError:n}=zns();return o.jsx(V4,{label:"Total Resources",value:e?.value!=null?yc(e.value):null,prevValue:e?.previousValue!=null?yc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function Qns({onClear:e,onRemoveAll:t,onSave:n,onRemoveSaved:r,isLoading:s,filterFields:a,filterTokens:i,onFilterTokensChange:l,autoFocusFilterFieldId:c}){const u=i.length>0,d=i.some(f=>Yns(f,a));return o.jsxs("div",{className:K("grid grid-cols-[1fr_auto] gap-3 items-start"),children:[o.jsx(nTe,{fields:a,tokens:i,onTokensChange:l,disabled:s,autoFocusFieldId:c}),u&&o.jsx(eTe,{disabled:s,onClear:d?e:void 0,onRemoveAll:t,onSave:n,onRemoveSaved:r})]})}function Yns(e,t){const n=t.find(r=>r.id===e.fieldId);return n?n.kind==="text"?typeof e.value=="string"&&e.value.trim()!=="":n.kind==="pick-multi"?n.multi?Array.isArray(e.value)&&e.value.length>0:typeof e.value=="string"&&e.value!==""&&e.value!=="Any":n.kind==="multi-select"?Array.isArray(e.value)&&e.value.length>0:!1:!1}function Xns({rows:e,isLoading:t,isError:n,getRowHref:r,actions:s,LinkComponent:a}){const i=!!e&&e.length>0;return o.jsxs(Bt,{children:[o.jsxs(Bt.TopBar,{children:[o.jsx(Bt.TitleAndDescription,{title:"Model Usage & Cost",description:"Token consumption by model."}),i&&(()=>{const l=e.reduce((d,f)=>d+(f.cost??0),0),c=new Set;for(const d of e)d.cost!=null&&d.costUnit&&c.add(d.costUnit);let u;return c.size===0?u=l>0?vg(l):"—":c.size===1?u=l>0?vg(l,[...c][0]):"—":u="Mixed",o.jsx(Bt.Summary,{value:u,label:"Total cost"})})(),s?o.jsx(Bt.Actions,{children:s}):null]}),t?o.jsx(Bt.Loading,{}):n?o.jsx(Bt.Error,{message:"Failed to load model usage data"}):o.jsx(Bt.Content,{children:i?o.jsxs(me,{columns:"auto auto auto auto auto auto",...kve,children:[o.jsxs(me.Top,{children:[o.jsx(me.TopCell,{sticky:"start",children:"Model"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Input"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Output"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Cache Read"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Cache Write"}),o.jsx(me.TopCell,{className:"justify-end text-right",children:"Cost"})]}),e.map(l=>{const c=r?.(l),u=o.jsxs(o.Fragment,{children:[o.jsx(me.RowHeaderCell,{height:"compact",className:"text-ui-sm",children:l.model}),o.jsx(me.NumberCell,{children:l.input}),o.jsx(me.NumberCell,{children:l.output}),o.jsx(me.NumberCell,{children:l.cacheRead}),o.jsx(me.NumberCell,{children:l.cacheWrite}),o.jsx(me.NumberCell,{highlight:!0,children:l.cost!=null?vg(l.cost,l.costUnit):"—"})]});return c?o.jsx(me.RowLink,{to:c,LinkComponent:a,children:u},l.model):o.jsx(me.RowStatic,{children:u},l.model)})]}):o.jsx(Bt.NoData,{message:"No model usage data yet"})})]})}function Kns(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","model-usage-cost",n],queryFn:async()=>{const[r,s,a,i]=await Promise.all(["mastra_model_total_input_tokens","mastra_model_total_output_tokens","mastra_model_input_cache_read_tokens","mastra_model_input_cache_write_tokens"].map(d=>e.getMetricBreakdown({name:[d],groupBy:["model"],aggregation:"sum",orderDirection:"DESC",filters:t}))),l=new Map,c=d=>(l.has(d)||l.set(d,{input:0,output:0,cacheRead:0,cacheWrite:0,cost:null,costUnit:null}),l.get(d)),u=(d,f)=>{f.estimatedCost!=null&&(d.cost=(d.cost??0)+f.estimatedCost,f.costUnit&&(d.costUnit=f.costUnit))};for(const d of r.groups){const f=d.dimensions.model??"unknown",p=c(f);p.input=d.value,u(p,d)}for(const d of s.groups){const f=d.dimensions.model??"unknown",p=c(f);p.output=d.value,u(p,d)}for(const d of a.groups){const f=d.dimensions.model??"unknown",p=c(f);p.cacheRead=d.value}for(const d of i.groups){const f=d.dimensions.model??"unknown",p=c(f);p.cacheWrite=d.value}return Array.from(l.entries()).map(([d,f])=>({model:d,input:yc(f.input),output:yc(f.output),cacheRead:yc(f.cacheRead),cacheWrite:yc(f.cacheWrite),cost:f.cost,costUnit:f.costUnit})).sort((d,f)=>d.model.localeCompare(f.model))}})}function Jns(){const{data:e,isLoading:t,isError:n}=Kns(),{getTracesHref:r}=wI(),{Link:s}=yn();return o.jsx(Xns,{rows:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:()=>r({rootEntityType:Os.AGENT}),actions:o.jsx(q4,{href:r({rootEntityType:Os.AGENT}),LinkComponent:s})})}function ers(e){return e==="tokens"||e==="cost"}function trs({data:e,isLoading:t,isError:n,getRowHref:r,actions:s,LinkComponent:a}){const[i,l]=v.useState("tokens"),c=e??[],u=c.length>0,d=c.reduce((b,w)=>b+w.total,0),f=c.filter(b=>b.cost!=null&&b.cost>0),p=new Set(f.map(b=>b.costUnit??"usd")),h=p.size<=1,m=h?[...p][0]??"usd":null,g=h?f.reduce((b,w)=>b+(w.cost??0),0):0,y=h&&g>0;return o.jsxs(Bt,{children:[o.jsxs(Bt.TopBar,{children:[o.jsx(Bt.TitleAndDescription,{title:"Token Usage by Agent",description:"Token consumption grouped by agent."}),u&&(i==="cost"&&y?o.jsx(Bt.Summary,{value:vg(g,m),label:"Total cost"}):o.jsx(Bt.Summary,{value:yc(d),label:"Total tokens"})),u&&s?o.jsx(Bt.Actions,{children:s}):null]}),t?o.jsx(Bt.Loading,{}):n?o.jsx(Bt.Error,{message:"Failed to load token usage data"}):o.jsx(Bt.Content,{children:u?o.jsxs(ru,{defaultTab:"tokens",value:i,onValueChange:b=>{ers(b)&&l(b)},className:"grid grid-rows-[auto_1fr] overflow-y-auto h-full",children:[o.jsxs(su,{children:[o.jsx(Vr,{value:"tokens",children:"Tokens"}),o.jsx(Vr,{value:"cost",children:"Cost"})]}),o.jsx(ps,{value:"tokens",children:o.jsx(aN,{LinkComponent:a,data:c.map(b=>({name:b.name,values:[b.input,b.output],href:r?.(b)})),segments:[{label:"Input",color:Np.blueDark},{label:"Output",color:Np.blue}],maxVal:Math.max(...c.map(b=>b.input+b.output)),fmt:yc})}),o.jsx(ps,{value:"cost",children:y?o.jsx(aN,{LinkComponent:a,data:f.slice().sort((b,w)=>(w.cost??0)-(b.cost??0)).map(b=>({name:b.name,values:[b.cost],href:r?.(b)})),segments:[{label:"Cost",color:Np.purple}],maxVal:Math.max(...f.map(b=>b.cost??0)),fmt:b=>vg(b,m)}):o.jsx(Bt.NoData,{message:"No cost data yet"})})]}):o.jsx(Bt.NoData,{message:"No token usage data yet"})})]})}function nrs(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","token-usage-by-agent",n],queryFn:async()=>{const r={groupBy:["entityName"],aggregation:"sum",orderDirection:"DESC",filters:t},[s,a]=await Promise.all([e.getMetricBreakdown({...r,name:["mastra_model_total_input_tokens"]}),e.getMetricBreakdown({...r,name:["mastra_model_total_output_tokens"]})]),i=new Map,l=u=>(i.has(u)||i.set(u,{input:0,output:0,cost:null,costUnit:null}),i.get(u)),c=(u,d)=>{d.estimatedCost!=null&&(u.cost=(u.cost??0)+d.estimatedCost,d.costUnit&&(u.costUnit=d.costUnit))};for(const u of s.groups){const d=u.dimensions.entityName??"unknown",f=l(d);f.input=u.value,c(f,u)}for(const u of a.groups){const d=u.dimensions.entityName??"unknown",f=l(d);f.output=u.value,c(f,u)}return Array.from(i.entries()).map(([u,d])=>({name:u,input:d.input,output:d.output,total:d.input+d.output,cost:d.cost,costUnit:d.costUnit})).sort((u,d)=>d.total-u.total)}})}function rrs(){const{data:e,isLoading:t,isError:n}=nrs(),{getTracesHref:r}=wI(),{Link:s}=yn();return o.jsx(trs,{data:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:a=>r({rootEntityType:Os.AGENT,entityName:a.name}),actions:o.jsx(q4,{href:r({rootEntityType:Os.AGENT}),LinkComponent:s})})}function srs(e){return e==="24h"?"1h":"1d"}function ars(e,t){return t==="1h"?e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1}):e.toLocaleDateString("en-US",{month:"short",day:"2-digit"})}function _Qe(e,t,n){for(const r of t?.points??[]){const s=new Date(r.timestamp).getTime();if(!Number.isFinite(s))continue;const a=e.get(s)??{tsMs:s,input:0,output:0,cost:null,costUnits:new Set,hasUnknownCostUnit:!1};a[n]+=r.value,r.estimatedCost!=null&&(a.cost=(a.cost??0)+r.estimatedCost,t?.costUnit?a.costUnits.add(t.costUnit):a.hasUnknownCostUnit=!0),e.set(s,a)}}function irs(e){return e.cost==null||e.hasUnknownCostUnit||e.costUnits.size!==1?null:[...e.costUnits][0]??null}function ors(){const e=We(),{datePreset:t,filters:n,filterKey:r}=Cm(),s=srs(t);return wt({queryKey:["metrics","token-usage-timeseries",r,s],queryFn:async()=>{const[a,i]=await Promise.all([e.getMetricTimeSeries({name:["mastra_model_total_input_tokens"],interval:s,aggregation:"sum",filters:n}),e.getMetricTimeSeries({name:["mastra_model_total_output_tokens"],interval:s,aggregation:"sum",filters:n})]),l=new Map;return _Qe(l,a.series[0],"input"),_Qe(l,i.series[0],"output"),{data:Array.from(l.values()).sort((u,d)=>u.tsMs-d.tsMs).map(u=>{const d=new Date(u.tsMs);return{time:ars(d,s),tsMs:u.tsMs,input:u.input,output:u.output,total:u.input+u.output,cost:u.cost,costUnit:irs(u)}}),interval:s}}})}function lrs(){const{data:e,isLoading:t,isError:n}=ors(),{getTracesHref:r}=wI(),{Link:s}=yn();return o.jsx(NQr,{data:e?.data,interval:e?.interval,isLoading:t,isError:n,actions:o.jsx(q4,{href:r(),LinkComponent:s})})}function Zre({data:e,rowHrefs:t,errorHrefs:n,LinkComponent:r}){return o.jsx(aN,{LinkComponent:r,data:e.map(s=>{const a=n?.(s),i=t?.(s);return a?{name:s.name,values:[s.completed,s.errors],hrefs:[i,a]}:{name:s.name,values:[s.completed,s.errors],href:i}}),segments:[{label:"Completed",color:Np.blueDark},{label:"Errors",color:Np.pink}],maxVal:Math.max(...e.map(s=>s.completed+s.errors)),fmt:yc})}function crs({data:e,isLoading:t,isError:n,getRowHref:r,getErrorSegmentHref:s,actions:a,LinkComponent:i}){const[l,c]=v.useState("agents"),u=typeof a=="function"?a(l):a,d=!!e&&(e.agentData.length>0||e.workflowData.length>0||e.toolData.length>0),f=e?[...e.agentData,...e.workflowData,...e.toolData].reduce((m,g)=>m+g.completed+g.errors,0):0,p=m=>r?g=>r(m,g):void 0,h=m=>s?g=>s(m,g):void 0;return o.jsxs(Bt,{children:[o.jsxs(Bt.TopBar,{children:[o.jsx(Bt.TitleAndDescription,{title:"Trace Volume",description:"Runs and call counts."}),d&&o.jsx(Bt.Summary,{value:yc(f),label:"Total runs"}),u?o.jsx(Bt.Actions,{children:u}):null]}),t?o.jsx(Bt.Loading,{}):n?o.jsx(Bt.Error,{message:"Failed to load trace volume data"}):o.jsx(Bt.Content,{children:d?o.jsxs(ru,{value:l,onValueChange:c,defaultTab:"agents",className:"grid grid-rows-[auto_1fr] overflow-y-auto h-full",children:[o.jsxs(su,{children:[o.jsx(Vr,{value:"agents",children:"Agents"}),o.jsx(Vr,{value:"workflows",children:"Workflows"}),o.jsx(Vr,{value:"tools",children:"Tools"})]}),o.jsx(ps,{value:"agents",children:e.agentData.length>0?o.jsx(Zre,{data:e.agentData,rowHrefs:p("agents"),errorHrefs:h("agents"),LinkComponent:i}):o.jsx(Bt.NoData,{message:"No agent data yet"})}),o.jsx(ps,{value:"workflows",children:e.workflowData.length>0?o.jsx(Zre,{data:e.workflowData,rowHrefs:p("workflows"),errorHrefs:h("workflows"),LinkComponent:i}):o.jsx(Bt.NoData,{message:"No workflow data yet"})}),o.jsx(ps,{value:"tools",children:e.toolData.length>0?o.jsx(Zre,{data:e.toolData,rowHrefs:p("tools"),errorHrefs:h("tools"),LinkComponent:i}):o.jsx(Bt.NoData,{message:"No tool data yet"})})]}):o.jsx(Bt.NoData,{message:"No trace volume data yet"})})]})}async function Gre(e,t,n){const r=await e.getMetricBreakdown({name:[t],groupBy:["entityName","status"],aggregation:"count",orderDirection:"DESC",filters:n}),s=new Map;for(const a of r.groups){const i=a.dimensions.entityName??"unknown",l=a.dimensions.status??"ok";s.has(i)||s.set(i,{completed:0,errors:0});const c=s.get(i);l==="error"?c.errors+=a.value:c.completed+=a.value}return Array.from(s.entries()).map(([a,i])=>({name:a,...i})).sort((a,i)=>i.completed+i.errors-(a.completed+a.errors))}function urs(){const e=We(),{filters:t,filterKey:n}=Cm();return wt({queryKey:["metrics","trace-volume",n],queryFn:async()=>{const[r,s,a]=await Promise.all([Gre(e,"mastra_agent_duration_ms",t),Gre(e,"mastra_workflow_duration_ms",t),Gre(e,"mastra_tool_duration_ms",t)]);return{agentData:r,workflowData:s,toolData:a}}})}const Q8={agents:Os.AGENT,workflows:Os.WORKFLOW_RUN,tools:Os.TOOL};function drs(){const{data:e,isLoading:t,isError:n}=urs(),{getTracesHref:r,getLogsHref:s}=wI(),{Link:a}=yn();return o.jsx(crs,{data:e,isLoading:t,isError:n,LinkComponent:a,getRowHref:(i,l)=>r({rootEntityType:Q8[i],entityName:l.name}),getErrorSegmentHref:(i,l)=>l.errors>0?s({rootEntityType:Q8[i],entityName:l.name,status:"error"}):void 0,actions:i=>o.jsxs(o.Fragment,{children:[o.jsx(q4,{href:r({rootEntityType:Q8[i]}),LinkComponent:a}),o.jsx(Tns,{href:s({rootEntityType:Q8[i],status:"error"}),LinkComponent:a})]})})}const frs=new Set(["ObservabilityStorageClickhouseVNext","ObservabilityStorageDuckDB","ObservabilityInMemory","ObservabilitySpanner","ObservabilityStoragePostgresVNext"]),Qre="period",Y8="dateFrom",X8="dateTo";function prs(){const[e,t]=ji(),n=e.get(Qre),r=kQr(n)?n:"24h",s=v.useMemo(()=>{if(r!=="custom")return;const d=h=>{if(!h)return;const m=new Date(h);return Number.isNaN(m.getTime())?void 0:m},f=d(e.get(Y8)),p=d(e.get(X8));if(!(!f&&!p))return{from:f,to:p}},[r,e.toString()]),a=v.useMemo(()=>gQr(e),[e.toString()]),i=v.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d==="24h"?p.delete(Qre):p.set(Qre,d),d!=="custom"&&(p.delete(Y8),p.delete(X8)),p},{replace:!0})},[t]),l=v.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d?.from?p.set(Y8,d.from.toISOString()):p.delete(Y8),d?.to?p.set(X8,d.to.toISOString()):p.delete(X8),p},{replace:!0})},[t]),c=v.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return yQr(p,d),p},{replace:!0})},[t]),u=v.useRef(!1);return v.useEffect(()=>{if(u.current||(u.current=!0,hQr(e)))return;const d=T6t();d&&t(f=>{const p=new URLSearchParams(f);for(const[h,m]of d)p.append(h,m);return p},{replace:!0})},[]),o.jsx(_Qr,{preset:r,filterTokens:a,onPresetChange:i,onFilterTokensChange:c,customRange:s,onCustomRangeChange:l,children:o.jsx(hrs,{})})}function hrs(){const[e]=ji(),{error:t,isLoading:n}=f8t(),{filterTokens:r,setFilterTokens:s}=DZ(),[a,i]=v.useState(),{data:l,isLoading:c}=M4(),u=l?.observabilityStorageType,d=u?frs.has(u):!1,f=u==="ObservabilityInMemory",{data:p,isLoading:h}=lTe(),{data:m,isLoading:g}=aTe(),{data:y,isLoading:b}=oTe(),{data:w,isLoading:S}=iTe(),k=v.useMemo(()=>mQr({availableTags:p??[],availableEntityNames:m??[],availableServiceNames:y??[],availableEnvironments:w??[],loading:{tags:h,entityNames:g,serviceNames:b,environments:S}}),[p,m,y,w,h,g,b,S]),[_,C]=v.useState(()=>T6t()!==null),E=v.useCallback(()=>{fQr(e),C(!0),De.success("Filters setting for Metrics saved")},[e]),j=v.useCallback(()=>{pQr(),C(!1),De.success("Filters setting for Metrics cleared up")},[]),N=v.useCallback(()=>{s([])},[s]),I=v.useCallback(()=>{const R=r.map($=>{const F=k.find(D=>D.id===$.fieldId);return F?F.kind==="text"?{fieldId:$.fieldId,value:""}:F.kind==="pick-multi"?F.multi?{fieldId:$.fieldId,value:[]}:{fieldId:$.fieldId,value:"Any"}:F.kind==="multi-select"?{fieldId:$.fieldId,value:[]}:$:$});s(R)},[k,r,s]);return t&&gs(t)?o.jsx(lr,{children:o.jsx(Vs,{})}):t&&ys(t)?o.jsx(lr,{children:o.jsx(Ds,{resource:"metrics"})}):t?o.jsx(lr,{children:o.jsx(Fi,{title:"Failed to load metrics",message:t.message})}):o.jsxs(Lt,{width:"wide",height:"full",children:[o.jsxs(Lt.TopArea,{children:[o.jsx(Lt.Row,{children:o.jsxs(Lt.Column,{className:"flex flex-wrap items-start justify-start gap-2",children:[o.jsx(Ens,{}),o.jsx(rTe,{fields:k,tokens:r,onTokensChange:s,disabled:n,onStartTextFilter:i})]})}),o.jsx(Qns,{isLoading:n,filterFields:k,filterTokens:r,onFilterTokensChange:s,onClear:I,onRemoveAll:N,onSave:E,onRemoveSaved:_?j:void 0,autoFocusFilterFieldId:a})]}),c?null:d?o.jsxs("div",{className:"grid gap-8 content-start pb-10",children:[f&&o.jsx(In,{variant:"info",title:"Metrics are not persisted",children:o.jsx(In.Message,{children:"This project uses in-memory storage for observability. Metrics will be lost on every server restart. For persistent metrics, switch the observability storage to ClickHouse, DuckDB, Postgres v-next, or Spanner."})}),o.jsxs(Nve,{children:[o.jsx(Vns,{}),o.jsx(Hns,{}),o.jsx(Wns,{}),o.jsx(Zns,{}),o.jsx(Gns,{})]}),o.jsxs(Nve,{children:[o.jsx(Jns,{}),o.jsx(rrs,{}),o.jsx(lrs,{}),o.jsx(Fns,{}),o.jsx(drs,{}),o.jsx(Pns,{})]})]}):o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Lr,{iconSlot:o.jsx(xf,{}),titleSlot:"Metrics are not available with your current storage",descriptionSlot:"Metrics require ClickHouse, DuckDB, Postgres v-next, Spanner, or in-memory storage for observability. Other relational databases (LibSQL, MSSQL) and document stores (MongoDB) do not support metrics collection. To enable metrics on an existing project, switch the observability storage in the Mastra configuration.",actionSlot:o.jsxs(ue,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/observability/metrics/overview",target:"_blank",rel:"noopener noreferrer",children:["Metrics Documentation ",o.jsx(Pa,{})]})})})]})}function mrs(){const{paths:e}=yn(),{data:t,isLoading:n,error:r}=RLt(),{isCmsAvailable:s}=yI(),[a,i]=v.useState(""),l=t?.promptBlocks??[];return r&&gs(r)?o.jsx(lr,{children:o.jsx(Vs,{})}):r&&ys(r)?o.jsx(lr,{children:o.jsx(Ds,{resource:"prompt blocks"})}):r?o.jsx(lr,{children:o.jsx(Fi,{title:"Failed to load prompt blocks",message:r.message})}):l.length===0&&!n?o.jsx(lr,{children:o.jsx(vZr,{})}):o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsxs(Lt.Row,{align:"center",stack:"responsive",children:[o.jsx("div",{className:"max-w-120 flex-1",children:o.jsx(Of,{onSearch:i,label:"Filter prompts",placeholder:"Filter by name or description"})}),s&&o.jsxs(ue,{as:ci,to:e.cmsPromptBlockCreateLink(),variant:"primary",className:"shrink-0",children:[o.jsx(Fr,{}),"Create Prompt"]})]})}),o.jsx(gZr,{promptBlocks:l,isLoading:n,search:a})]})}function grs(){return o.jsx(Lt,{width:"narrow",children:o.jsx(Lt.MainArea,{children:o.jsx(_zr,{children:o.jsx(eve,{})})})})}const vrs=[{title:"Mastra APIs",description:"Explore and test the available REST API endpoints with the interactive Swagger UI.",icon:mcn,href:"/swagger-ui",external:!1},{title:"Documentation",description:"Read the official Mastra documentation for guides, references, and tutorials.",icon:llt,href:"https://mastra.ai/en/docs",external:!0},{title:"Github",description:"Browse the source code, report issues, and contribute to the Mastra project.",icon:Pa,href:"https://github.com/mastra-ai/mastra",external:!0},{title:"Community",description:"Join the Mastra Discord community for help, discussion, and collaboration.",icon:qj,href:"https://discord.gg/BTYqqHKUrf",external:!0},{title:"Share with your team",description:"Running Mastra Studio locally? Deploy to the cloud so your team can collaborate.",icon:glt,href:"https://mastra.ai/cloud",external:!0},{title:"Talk to our Sales team",description:"Get a custom demo, discuss on-prem deployments, and how we can help you accelerate getting agents into production.",icon:clt,href:"https://mastra.ai/contact?ref=studio",external:!0}];function yrs(){return o.jsx(Lt,{width:"narrow",children:o.jsx(Lt.MainArea,{children:o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 max-w-3xl",children:vrs.map(e=>o.jsxs("a",{href:e.href,...e.external?{target:"_blank",rel:"noreferrer"}:{},className:"group flex flex-col gap-3 rounded-lg border border-border1 bg-surface2 p-5 transition-colors hover:border-accent1 hover:bg-surface3",children:[o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx(e.icon,{className:"h-5 w-5 text-icon3 group-hover:text-accent1 transition-colors"}),o.jsx("span",{className:"text-ui-md font-medium text-text1",children:e.title}),e.external&&o.jsx(Pa,{className:"h-3.5 w-3.5 text-icon3 ml-auto opacity-0 group-hover:opacity-100 transition-opacity"})]}),o.jsx("p",{className:"text-ui-sm text-text3 leading-relaxed",children:e.description})]},e.href))})})})}function brs(){const{data:e={},isLoading:t,error:n}=eh(),[r,s]=v.useState(""),[a,i]=v.useState("all");if(n&&gs(n))return o.jsx(lr,{children:o.jsx(Vs,{})});if(n&&ys(n))return o.jsx(lr,{children:o.jsx(Ds,{resource:"scorers"})});if(n)return o.jsx(lr,{children:o.jsx(Fi,{title:"Failed to load scorers",message:n.message})});if(Object.keys(e).length===0&&!t)return o.jsx(lr,{children:o.jsx(kHr,{})});const l=a!=="all"||r!=="",c=()=>{s(""),i("all")};return o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx(IHr,{search:r,onSearchChange:s,sourceFilter:a,onSourceFilterChange:i,onReset:c,hasActiveFilters:l})}),o.jsx(SHr,{scorers:e,isLoading:t,search:r,sourceFilter:a})]})}function xrs(){const{scorerId:e}=dr(),[t,n]=ji(),r=t.get("scoreId")??void 0,[s,a]=v.useState(r),[i,l]=v.useState({value:"all",label:"All Entities",type:"ALL"}),{scorer:c,error:u}=JVr(e),{data:d={},isLoading:f,error:p}=Sm(),{isLoading:h,error:m}=By(),{data:g=[],isLoading:y,error:b,isFetchingNextPage:w,hasNextPage:S,setEndOfListElement:k}=KVr({scorerId:e,entityId:i?.value==="all"?void 0:i?.value,entityType:i?.type==="ALL"?void 0:i?.type}),_=v.useMemo(()=>c?.agentIds?.filter(B=>d[B]).map(B=>({value:B,label:d[B].name,type:"AGENT"}))||[],[c?.agentIds,d]),C=v.useMemo(()=>c?.workflowIds?.map(B=>({value:B,label:B,type:"WORKFLOW"}))||[],[c?.workflowIds]),E=v.useMemo(()=>[{value:"all",label:"All Entities",type:"ALL"},..._,...C],[_,C]),j=t.get("entity")??"all",N=E.find(B=>B.value===j);N&&N.value!==i?.value&&l(N),v.useEffect(()=>{if(u){const B=u instanceof Error?u.message:"Failed to load scorer";De.error(`Error loading scorer: ${B}`)}},[u]),v.useEffect(()=>{if(p){const B=p instanceof Error?p.message:"Failed to load agents";De.error(`Error loading agents: ${B}`)}},[p]),v.useEffect(()=>{if(m){const B=m instanceof Error?m.message:"Failed to load workflows";De.error(`Error loading workflows: ${B}`)}},[m]);const I=B=>{B?.value&&n(M=>{const G=new URLSearchParams(M);return G.set("entity",B.value),G})};v.useEffect(()=>{const B=t.get("scoreId")??void 0;if(B===s)return;if(!B){a(void 0);return}g.find(G=>G.id===B)&&a(B)},[t,g]);const R=v.useCallback(B=>{a(B||void 0),n(M=>{const G=new URLSearchParams(M);return B?G.set("scoreId",B):G.delete("scoreId"),G})},[n]);if(!c)return null;const $=gs(u)||gs(p)||gs(m),F=u&&ys(u),D=!$&&!F&&(u||p||m),V=!y&&g.length===0,W=i?.value!=="all",L=c?.scorer?.source==="stored"?o.jsx(Ty,{owner:"scorer-detail",children:o.jsxs(ue,{variant:"default",as:ci,to:`/cms/scorers/${e}/edit`,size:"sm",children:[o.jsx(em,{})," Edit"]})}):null;if($||F||D||V&&!W){const B=(u instanceof Error?u.message:void 0)??(p instanceof Error?p.message:void 0)??(m instanceof Error?m.message:void 0)??"An unexpected error occurred";return o.jsxs(Lt,{width:"wide",height:"full",children:[L,o.jsx(Lt.MainArea,{isCentered:!0,children:$?o.jsx(Vs,{}):F?o.jsx(Ds,{resource:"scorers"}):D?o.jsx(Fi,{title:"Failed to load scorer",message:B}):o.jsx(ZVr,{})})]})}return o.jsxs(Lt,{width:"wide",children:[L,o.jsx(Lt.TopArea,{children:o.jsx(GVr,{selectedEntity:i,entityOptions:E,onEntityChange:I,onReset:()=>{n(B=>{const M=new URLSearchParams(B);return M.set("entity","all"),M})},isLoading:y||f||h})}),o.jsx(WVr,{scores:g,isLoading:y,selectedScoreId:s,isFetchingNextPage:w,hasNextPage:S,setEndOfListElement:k,onScoreClick:R,errorMsg:b?.message})]})}function wrs({label:e,description:t,htmlFor:n,className:r,children:s}){return o.jsxs("div",{className:K("flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",r),"data-slot":"settings-row",children:[o.jsxs("div",{children:[n?o.jsx(Rt,{htmlFor:n,className:"text-sm font-medium",children:e}):o.jsx("p",{className:"text-sm font-medium",children:e}),t&&o.jsx("p",{className:"text-sm text-neutral3",children:t})]}),s]})}const g8t=[{value:"dark",label:"Dark",Icon:Vun},{value:"light",label:"Light",Icon:Jdn},{value:"system",label:"System",Icon:Clt}],Srs=e=>g8t.some(t=>t.value===e);function krs({option:e}){const{Icon:t}=e;return o.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-2",children:[o.jsx(t,{"aria-hidden":"true",className:"h-4 w-4 shrink-0 opacity-70"}),o.jsx("span",{className:"min-w-0 truncate",children:e.label})]})}const Ors=()=>{const{baseUrl:e,headers:t,apiPrefix:n}=Axe(),{theme:r,setTheme:s}=EN();return o.jsx(Lt,{width:"narrow",children:o.jsxs(Lt.MainArea,{className:"flex flex-col gap-5 mt-6",children:[o.jsx(Pge,{title:"Theme",description:"Customize the appearance of the studio.",children:o.jsx(wrs,{label:"Theme mode",htmlFor:"theme",children:o.jsxs(ba,{value:r,onValueChange:a=>{Srs(a)&&s(a)},children:[o.jsx(wa,{id:"theme",className:"w-full sm:w-48",children:o.jsx(xa,{className:"inline-flex min-w-0 max-w-full items-center"})}),o.jsx(Sa,{children:g8t.map(a=>o.jsx(qr,{value:a.value,children:o.jsx(krs,{option:a})},a.value))})]})})}),o.jsx(Pge,{title:"Mastra Connection",description:"Configure the Mastra instance URL, API prefix, and request headers used by the studio.",children:o.jsx(eLt,{initialConfig:{baseUrl:e,headers:t,apiPrefix:n}})})]})})};function _rs(){const[e]=ji(),t=bs(),n=e.get("redirect")||"/",r=()=>{n.startsWith("http")?window.location.href=n:t(n,{replace:!0})};return o.jsx(d8t,{redirectUri:n,onSuccess:r,initialMode:"signup"})}const v8t=e=>o.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[o.jsx("g",{clipPath:"url(#clip0_21999_22095)",children:o.jsx("path",{d:"M7.5 0.75C3.6325 0.75 0.5 3.8825 0.5 7.75C0.5 10.8475 2.50375 13.4637 5.28625 14.3912C5.63625 14.4525 5.7675 14.2425 5.7675 14.0587C5.7675 13.8925 5.75875 13.3412 5.75875 12.755C4 13.0787 3.545 12.3262 3.405 11.9325C3.32625 11.7312 2.985 11.11 2.6875 10.9437C2.4425 10.8125 2.0925 10.4887 2.67875 10.48C3.23 10.4712 3.62375 10.9875 3.755 11.1975C4.385 12.2562 5.39125 11.9587 5.79375 11.775C5.855 11.32 6.03875 11.0137 6.24 10.8387C4.6825 10.6637 3.055 10.06 3.055 7.3825C3.055 6.62125 3.32625 5.99125 3.7725 5.50125C3.7025 5.32625 3.4575 4.60875 3.8425 3.64625C3.8425 3.64625 4.42875 3.4625 5.7675 4.36375C6.3275 4.20625 6.9225 4.1275 7.5175 4.1275C8.1125 4.1275 8.7075 4.20625 9.2675 4.36375C10.6062 3.45375 11.1925 3.64625 11.1925 3.64625C11.5775 4.60875 11.3325 5.32625 11.2625 5.50125C11.7087 5.99125 11.98 6.6125 11.98 7.3825C11.98 10.0687 10.3438 10.6637 8.78625 10.8387C9.04 11.0575 9.25875 11.4775 9.25875 12.1337C9.25875 13.07 9.25 13.8225 9.25 14.0587C9.25 14.2425 9.38125 14.4612 9.73125 14.3912C11.1209 13.9221 12.3284 13.029 13.1839 11.8377C14.0393 10.6463 14.4996 9.21668 14.5 7.75C14.5 3.8825 11.3675 0.75 7.5 0.75Z",fill:"currentColor"})}),o.jsx("defs",{children:o.jsx("clipPath",{id:"clip0_21999_22095",children:o.jsx("rect",{width:"14",height:"14",fill:"currentColor",transform:"translate(0.5 0.75)"})})})]});function Crs(e){return e.replace(/\/$/,"").split("/").pop()}function BZ({children:e,className:t}){return o.jsx("div",{className:K("border border-border1 rounded-lg mt-12 py-8 lg:min-h-[25rem] transition-height px-4 lg:px-12",t),children:e})}function Ers({templates:e,linkComponent:t,className:n,isLoading:r}){const s=t||"a";return r?o.jsx("div",{className:K("grid gap-y-4",n),children:Array.from({length:5}).map((a,i)=>o.jsx("div",{className:"h-16 bg-surface3 animate-pulse rounded-lg"},i))}):o.jsx("div",{className:K("grid gap-y-4",n),children:e.map(a=>{const i=a?.agents||a?.tools||a?.networks||a?.workflows||a?.mcp;return o.jsxs("article",{className:K("border border-border1 rounded-lg overflow-hidden w-full grid grid-cols-[1fr_auto] bg-surface3 transition-colors hover:bg-surface4"),children:[o.jsxs(s,{to:`/templates/${a.slug}`,className:K("grid [&:hover_p]:text-neutral5",{"grid-cols-[8rem_1fr] lg:grid-cols-[12rem_1fr]":a.imageURL}),children:[a.imageURL&&o.jsx("div",{className:K("overflow-hidden"),children:o.jsx("div",{className:"w-full h-full bg-cover thumb transition-scale duration-150",style:{backgroundImage:`url(${a.imageURL})`}})}),o.jsxs("div",{className:K("grid py-3 px-6 w-full gap-0.5","[&_svg]:w-[1em] [&_svg]:h-[1em] [&_svg]:text-neutral3"),children:[o.jsx("h2",{className:"text-ui-lg text-neutral5",children:a.title}),o.jsx("p",{className:"text-ui-md text-neutral4 transition-colors duration-500",children:a.description}),o.jsxs("div",{className:"hidden 2xl:flex text-neutral3 text-ui-md flex-wrap items-center gap-4 mt-3",children:[i&&o.jsxs("ul",{className:K("flex gap-4 text-ui-md text-neutral3 m-0 p-0 list-none","[&>li]:flex [&>li]:items-center [&>li]:gap-0.5 text-neutral4"),children:[a?.agents&&a.agents.length>0&&o.jsxs("li",{children:[o.jsx(rl,{})," ",a.agents.length]}),a?.tools&&a.tools.length>0&&o.jsxs("li",{children:[o.jsx(Gp,{})," ",a.tools.length]}),a?.networks&&a.networks.length>0&&o.jsxs("li",{children:[o.jsx(Elt,{})," ",a.networks.length]}),a?.workflows&&a.workflows.length>0&&o.jsxs("li",{children:[o.jsx(eq,{})," ",a.workflows.length]}),a?.mcp&&a.mcp.length>0&&o.jsxs("li",{children:[o.jsx(M_,{})," ",a.mcp.length]})]}),i&&a.supportedProviders&&o.jsx("small",{children:"|"}),o.jsx("div",{className:"flex items-center text-neutral3 gap-4",children:a.supportedProviders.map(l=>o.jsx("span",{className:"",children:l},l))})]})]})]}),o.jsx("a",{href:a.githubUrl,className:K("group items-center gap-2 text-ui-md ml-auto pr-4 hidden","lg:flex"),target:"_blank",rel:"noopener noreferrer",children:o.jsxs("span",{className:"flex items-center gap-2 px-2 py-1 rounded bg-surface1 group-hover:bg-surface2 text-neutral3 transition-colors group-hover:text-neutral5",children:[o.jsx(v8t,{})," ",Crs(a.githubUrl)]})})]},a.slug)})})}function jrs({tagOptions:e,selectedTag:t,providerOptions:n,selectedProvider:r,onTagChange:s,onProviderChange:a,searchTerm:i,onSearchChange:l,onReset:c,className:u,isLoading:d}){return d?o.jsxs("div",{className:K("h-[6.5rem] flex items-center gap-8","[&>div]:bg-surface3 [&>div]:w-48 [&>div]:h-8 [&>div]:animate-pulse",u),children:[o.jsx("div",{})," ",o.jsx("div",{})," ",o.jsx("div",{})]}):o.jsxs("div",{className:K("flex flex-wrap mx-auto sticky top-0 gap-4 bg-surface2 py-8",u),children:[o.jsx($T,{name:"search-templates",label:"Search templates",labelIsHidden:!0,value:i,onChange:f=>l?.(f.target.value),placeholder:"Search Template"}),o.jsx(xc,{label:"Filter by tag",labelIsHidden:!0,name:"filter-tag",value:t,onValueChange:s,options:e}),o.jsx(xc,{label:"Filter by provider",labelIsHidden:!0,name:"filter-provider",value:r,onValueChange:a,options:n}),c&&o.jsxs(ue,{onClick:c,children:["Reset ",o.jsx(vs,{})]})]})}function Trs(){const{data:e,isLoading:t}=FQn(),{templates:n,tags:r,providers:s}=e??{templates:[],tags:[],providers:[]},[a,i]=v.useState("all"),[l,c]=v.useState("all"),[u,d]=v.useState(""),f=[{value:"all",label:"Any tag"}];(r||[]).forEach(w=>{f.push({value:w,label:w})});const p=[{value:"all",label:"Any provider"}];(s||[]).forEach(w=>{p.push({value:w,label:w})});const h=(w,S)=>{S==="tag"?i(w):S==="provider"&&c(w)},m=w=>{d(w)},g=()=>{i("all"),c("all"),d("")},y=n.filter(w=>!(u&&!w.title.toLowerCase().includes(u)&&!w.description.toLowerCase().includes(u)||a!=="all"&&!w.tags.includes(a)||l!=="all"&&!w.supportedProviders.includes(l))),b=u||a!=="all"||l!=="all";return o.jsxs(cs,{children:[o.jsx(qxe,{children:o.jsxs(gpt,{children:[o.jsx(Ue,{children:o.jsx(Hv,{})}),"Templates"]})}),o.jsxs("div",{className:K("overflow-y-auto w-full h-full px-8 pb-12 z-10"),children:[o.jsx(jrs,{selectedTag:a,onTagChange:w=>h(w,"tag"),tagOptions:f,selectedProvider:l,onProviderChange:w=>h(w,"provider"),providerOptions:p,searchTerm:u,onSearchChange:m,onReset:b?g:void 0,className:"max-w-[80rem]",isLoading:t}),o.jsx(Ers,{templates:y,linkComponent:ci,className:"max-w-[80rem] mx-auto",isLoading:t})]})]})}const Nrs="1.48.0-alpha.9";function Irs({errorMsg:e,validationErrors:t}){const n=typeof e=="string"?e:e!=null?String(e):void 0,r=n?.includes("Invalid schema for function"),s=n?.includes("validation issue")||t&&t.length>0,a=()=>s?"Template installation completed but some validation issues remain. The template may still be functional, but you should review and fix these issues.":r?"There was an issue with the AI model configuration. This may be related to the selected model or AI SDK version compatibility.":"An unexpected error occurred during template installation.",i=()=>s?{icon:o.jsx(kp,{className:"text-yellow-500"}),title:"Template Installed with Warnings"}:{icon:o.jsx(Vcn,{}),title:"Template Installation Failed"},{icon:l,title:c}=i();return o.jsxs(BZ,{className:"space-y-4 text-neutral3 mb-8 content-center",children:[o.jsxs("div",{className:K("grid items-center justify-items-center gap-4 content-center","[&>svg]:w-8 [&>svg]:h-8"),children:[l,o.jsxs("div",{className:"text-center space-y-2",children:[o.jsx("p",{className:"text-ui-md font-medium text-neutral5",children:c}),o.jsx("p",{className:"text-ui-md text-neutral3",children:a()})]})]}),t&&t.length>0&&o.jsxs("details",{className:"text-xs",children:[o.jsxs("summary",{className:"cursor-pointer text-neutral3 hover:text-neutral4 select-none text-center",children:["Show Validation Issues (",t.length,")"]}),o.jsx("div",{className:"mt-4 p-3 bg-gray-100 dark:bg-gray-800 rounded text-xs overflow-auto max-h-60 text-left space-y-2",children:t.map((u,d)=>o.jsxs("div",{className:"border-l-2 border-red-400 pl-2",children:[o.jsx("div",{className:"font-medium text-red-600 dark:text-red-400",children:u.type==="typescript"?"🔴 TypeScript Error":"⚠️ Lint Error"}),o.jsx("div",{className:"text-xs font-mono text-gray-700 dark:text-gray-300 mt-1 whitespace-pre-wrap wrap-break-word",children:u.message})]},d))})]}),n&&!s&&o.jsxs("details",{className:"text-xs",children:[o.jsx("summary",{className:"cursor-pointer text-neutral3 hover:text-neutral4 select-none text-center",children:"Show Details"}),o.jsx("div",{className:"mt-4 p-3 bg-gray-100 dark:bg-gray-800 rounded text-xs font-mono overflow-auto max-h-60 text-left",children:o.jsx("div",{className:"whitespace-pre-wrap wrap-break-word",children:n})})]})]})}function Ars({providerOptions:e,selectedProvider:t,onProviderChange:n,variables:r,errors:s,handleInstallTemplate:a,handleVariableChange:i,isLoadingEnvVars:l,isInstalling:c,defaultModelProvider:u,defaultModelId:d,onModelUpdate:f}){return o.jsx(BZ,{children:o.jsxs("div",{className:"max-w-[40rem] my-4 p-4 lg:p-8 mx-auto gap-8 grid",children:[o.jsxs("h2",{className:K("text-neutral4 text-header-sm font-semibold flex items-center gap-2","[&>svg]:w-[1.2em] [&_svg]:h-[1.2em] [&_svg]:opacity-70"),children:["Install Template ",o.jsx(jlt,{})]}),o.jsx(xc,{name:"template-provider",options:e,label:"Template AI Model Provider",onValueChange:n,value:t,placeholder:"Select",layout:"horizontal"}),t&&Object.entries(r||{}).length>0&&o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"text-neutral3 text-ui-md",children:"Set required Environmental Variables"}),o.jsx("div",{className:"grid grid-cols-[1fr_1fr] gap-4 items-start",children:l?o.jsxs("div",{className:K("flex items-center justify-center col-span-2 text-neutral3 text-ui-sm gap-4","[&_svg]:opacity-50 [&_svg]:w-[1.1em] [&_svg]:h-[1.1em]","animate-in fade-in duration-300"),children:[o.jsx(Gt,{})," Loading variables..."]}):Object.entries(r).map(([p,h])=>o.jsxs(v.Fragment,{children:[o.jsx(dO,{name:`env-${p}`,labelIsHidden:!0,label:"Key",value:p,disabled:!0,className:"w-full"}),o.jsx(dO,{name:p,labelIsHidden:!0,label:"Value",value:h,onChange:i,errorMsg:s.includes(p)?"Value is required.":"",autoComplete:"off",className:"w-full"})]},p))}),o.jsxs("div",{className:"border-t border-border1 pt-12 mt-3.5 relative",children:[o.jsx("div",{className:"absolute w-8 h-8 rounded-full bg-surface2 top-0 left-1/2 -translate-x-1/2 -translate-y-4 text-ui-sm text-neutral3 flex items-center justify-center",children:"And"}),o.jsx("h3",{className:"text-neutral4 text-ui-lg",children:"Set AI Model for Template Installation"}),o.jsx("p",{className:"text-neutral3 text-ui-md mt-2 mb-8",children:"This model will be used by the workflow to process and install the template"}),o.jsx(J5t,{defaultProvider:u||"",defaultModel:d||"",updateModel:f||(()=>Promise.resolve({message:"Updated"})),closeEditor:()=>{},autoSave:!0,selectProviderPlaceholder:"Provider"})]})]}),t&&!l&&o.jsx(ue,{className:K("flex items-center gap-2 mt-4 justify-center text-ui-md w-full bg-surface5 min-h-10 rounded-lg text-neutral5 hover:bg-surface6 transition-colors","[&>svg]:w-[1.1em] [&_svg]:h-[1.1em] [&_svg]:text-neutral5"),onClick:a,disabled:!t||!u||!d||s.length>0||c,children:c?o.jsxs(o.Fragment,{children:[o.jsx(Gt,{className:"w-4 h-4"})," Installing..."]}):o.jsxs(o.Fragment,{children:["Install ",o.jsx(hm,{})]})})]})})}function Rrs({title:e,description:t,githubUrl:n,isLoading:r,infoData:s,templateSlug:a}){const i=a?`feat/install-template-${a}`:"feat/install-template-[slug]";return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:K("grid mt-8 items-center"),children:o.jsxs("div",{className:K("text-header-lg flex items-center gap-3","[&>svg]:w-[1.2em] [&>svg]:h-[1.2em] [&>svg]:opacity-50",{"[&>svg]:opacity-20":r}),children:[o.jsx(Hv,{}),o.jsx("h2",{className:K({"bg-surface4 flex rounded-lg min-w-[50%]":r}),children:r?o.jsx(o.Fragment,{children:" "}):e})]})}),o.jsxs("div",{className:"grid lg:grid-cols-[1fr_1fr] gap-x-24",children:[o.jsxs("div",{className:"grid",children:[o.jsx("p",{className:K("mb-4 text-ui-md text-neutral4 mt-2 leading-7",{"bg-surface4 rounded-lg ":r}),children:r?o.jsx(o.Fragment,{children:" "}):t}),!r&&a&&o.jsxs("div",{className:K("bg-surface2 border border-surface4 rounded-lg p-4 mb-4","flex items-start gap-3"),children:[o.jsx("div",{className:"shrink-0 mt-0.5",children:o.jsx(Mx,{className:"w-[1.1em] h-[1.1em] text-blue-500"})}),o.jsxs("div",{className:"flex-1 space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Vye,{className:"w-[1em] h-[1em] text-neutral4"}),o.jsx("span",{className:"text-ui-md font-medium text-neutral5",children:"A new Git branch will be created"})]}),o.jsxs("div",{className:"text-ui-sm text-neutral4 space-y-1",children:[o.jsxs("div",{children:[o.jsx("span",{className:"font-medium",children:"Branch name:"})," ",o.jsx("code",{className:"bg-surface3 px-1.5 py-0.5 rounded text-ui-sm font-mono",children:i})]}),o.jsx("div",{children:"This ensures safe installation with easy rollback if needed. Your main branch remains unchanged."})]})]})]}),n&&o.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 mt-auto text-neutral3 text-ui-md hover:text-neutral5",children:[o.jsx(v8t,{}),n?.split("/")?.pop()]})]}),s&&o.jsx(Aje,{data:s,labelsAreHidden:!0,isLoading:r})]})]})}function Prs(e){switch(e){case"running":return o.jsx(Gt,{});case"success":return o.jsx(hx,{});case"failed":return o.jsx(Pu,{});default:return null}}function $rs({stepId:e,step:t,isActive:n,position:r}){const s=a=>a.charAt(0).toUpperCase()+a.slice(1).replace(/-/g," ");return o.jsxs("div",{className:K("grid gap-6 grid-cols-[1fr_auto] py-3 px-4 rounded-lg",is.all,{"border border-dashed border-neutral2 bg-surface3":n}),children:[o.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-2",children:[o.jsxs("span",{className:K("text-ui-md min-w-6 flex justify-end",is.colors,{"text-neutral5":n||t.status==="success","text-neutral3":!n&&t.status!=="success"}),children:[r,"."]}),o.jsxs("div",{children:[o.jsx("h4",{className:K("text-ui-md",is.colors,{"text-neutral5":n||t.status==="success","text-neutral3":!n&&t.status!=="success"}),children:s(e)}),t.description&&o.jsx("p",{className:"text-ui-md text-neutral2 -mt-0.5",children:t.description})]})]}),o.jsx("div",{className:K("w-[1.75rem] h-[1.75rem] rounded-full flex items-center justify-center self-center",is.all,{"border border-neutral2 border-dashed":t.status==="pending","[&>svg]:text-white [&>svg]:w-4 [&>svg]:h-4":t.status!=="running","w-[1.75rem] h-[1.75rem]":t.status==="running","bg-accent1Dark shadow-glow-accent1":t.status==="success","bg-accent2Dark shadow-glow-accent2":t.status==="failed","scale-110":t.status==="success"||t.status==="failed"}),children:Prs(t.status)})]})}function Mrs({currentStep:e,steps:t=[],className:n}){return o.jsx("div",{className:K(n),children:t.map((r,s)=>o.jsx($rs,{stepId:r.id,step:r,isActive:e?.id===r.id,position:s+1},r.id))})}function Drs({steps:e}){const t=e.length,n=e.filter(r=>r.status==="success").length;return o.jsxs("div",{className:"flex justify-center flex-col gap-4 content-center w-full",children:[o.jsx("div",{className:"grid grid-cols-[0_repeat(9,1fr)] w-full",children:e.map((r,s)=>o.jsx("div",{className:K("flex justify-end items-center relative h-[2rem]",is.colors,{"bg-accent1Dark":r.status==="success"&&e?.[s-1]?.status==="success"}),children:o.jsx("div",{className:K("w-[2rem] h-[2rem] rounded-full flex items-center justify-center self-center absolute right-0 translate-x-[50%] bg-surface3 z-10 text-neutral3 font-bold text-ui-sm",is.all,{"border border-neutral2 border-dashed":r.status==="pending","[&>svg]:text-surface1 [&>svg]:w-[1.1rem] [&>svg]:h-[1.1rem]":r.status!=="running","bg-accent1Dark text-white shadow-glow-accent1 scale-110":r.status==="success","bg-accent2Dark text-white shadow-glow-accent2 scale-110":r.status==="failed"}),children:r.status==="running"?o.jsx(Gt,{}):s+1})},r.id))}),o.jsxs("div",{className:K("text-xs text-neutral3 text-center",is.colors),children:[n," of ",t," steps completed"]})]})}function Lrs({name:e,streamResult:t,runId:n,workflowInfo:r}){const s=t?.phase||"initializing",a=t?.payload?.workflowState,i=t?.payload?.currentStep,l=t?.error,c=a?.steps||{},u=Object.keys(c).length>0,d=g=>g==="input"||g.endsWith(".input")||g.startsWith("Mapping_")&&/[0-9a-f]{8}/.test(g)||/[0-9a-f]{8,}/.test(g)?!1:r?.allSteps?g in r.allSteps:!0,f=Object.entries(c).filter(([g,y])=>d(g)),p=f.length,h=()=>{switch(s){case"initializing":return"Preparing template installation...";case"processing":return`Installing ${e} template`;case"completed":return"Template installation completed!";case"error":return"Template installation failed";default:return"Installing template..."}},m=f.map(([g,y])=>({id:g,status:y?.status,description:y?.description,title:g.charAt(0).toUpperCase()+g.slice(1).replace(/-/g," "),isActive:i?.id===g}));return o.jsxs(BZ,{className:"space-y-6 text-neutral3 mb-8 content-center",children:[o.jsxs("div",{className:"text-center",children:[o.jsx("h3",{className:"text-lg font-semibold text-neutral5",children:h()}),(t?.runId||n)&&o.jsxs("div",{className:"mt-2 text-ui-sm text-neutral3",children:["Run ID: ",t?.runId??n]})]}),u&&p>0&&!["error"].includes(s)&&o.jsx("div",{className:"max-w-[30rem] w-full mx-auto px-6",children:o.jsx(Drs,{steps:m})}),l&&s==="error"&&o.jsxs("div",{className:K("rounded-lg text-neutral5 p-6 flex items-center gap-3 text-ui-md bg-red-500/10","[&>svg]:w-6 [&>svg]:h-6 [&>svg]:opacity-70 [&>svg]:text-red-500"),children:[o.jsx(edn,{}),l||"Something went wrong"]}),u&&o.jsx(Mrs,{steps:m,currentStep:i,className:"pb-4"}),!u&&s==="initializing"&&o.jsxs("div",{className:"text-center text-sm text-neutral3 grid gap-4 justify-items-center",children:[o.jsx(Gt,{}),o.jsx("p",{children:"This may take some time..."})]})]})}function Frs({name:e,installedEntities:t}){return o.jsxs(BZ,{className:K("grid items-center justify-items-center gap-4 content-center","[&>svg]:w-8 [&>svg]:h-8"),children:[o.jsx(jlt,{}),o.jsx("h2",{className:"text-header-md",children:"Done!"}),o.jsxs("p",{className:"text-ui-md text-center text-neutral3 ",children:["The ",o.jsx("b",{className:"text-neutral4",children:e})," template has been successfully installed.",t&&t.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("br",{})," Installed entities are listed below."]})]}),t&&t.length>0&&o.jsx(Aje,{data:t})]})}function zrs(){const{templateSlug:e}=dr(),[t,n]=ji(),[r,s]=v.useState(""),[a,i]=v.useState(""),[l,c]=v.useState(""),[u,d]=v.useState({}),[f,p]=v.useState([]),[h,m]=v.useState(null),[g,y]=v.useState(!1),[b,w]=v.useState(""),[S,k]=v.useState(!1),[_,C]=v.useState(!1),[E,j]=v.useState([]),{data:N,isLoading:I}=zQn({repoOrSlug:e,owner:"mastra-ai"}),$=Nrs?.includes("beta")??!1?"beta":"main",{data:F,isLoading:D}=BQn({repo:N?.githubUrl?new URL(N.githubUrl).pathname.split("/")[2]:`template-${e}`,owner:"mastra-ai",branch:$}),{data:V,isLoading:W}=UQn(),{mutateAsync:L,isPending:z}=qQn(),{mutateAsync:B}=VQn(),{streamInstall:M,streamResult:G,isStreaming:U}=WQn(V),{observeInstall:P,streamResult:q,isStreaming:Z}=ZQn(V);v.useEffect(()=>{const ne=t.get("runId");ne&&!g&&!h&&!U&&!Z&&(console.info("🔄 Checking completed run after hot reload:",{runId:ne}),w(ne),B({runId:ne}).then(ce=>{const pe=ce.snapshot;if(pe?.status==="success"&&pe?.result?.success)y(!0);else if(pe?.result?.success===!1)if(pe?.result?.validationResults&&!pe?.result?.validationResults?.valid&&pe?.result?.validationResults?.remainingErrors>0){const{remainingErrors:ve,errors:ye}=pe.result.validationResults,Se=`Template installation completed but ${ve} validation issue${ve>1?"s":""} remain unresolved.`;m(Se),j(ye||[])}else{const ve=pe?.result?.message||pe?.result?.error||"Template installation failed";m(typeof ve=="string"?ve:String(ve))}}).catch(ce=>{console.error("❌ Failed to fetch run details:",ce),m("Failed to retrieve installation status after reload")}))},[t,g,h,U,Z,B]),v.useEffect(()=>{const ne=t.get("runId"),ce=t.get("resume"),pe=t.get("provider");if(ne&&ce==="true"&&pe&&!U&&!Z&&!S&&!_&&V){w(ne),k(!0);try{B({runId:ne}).then(le=>{if(le.snapshot?.status==="running")return P.mutateAsync({runId:ne})}).then(()=>{n(le=>{const ve=new URLSearchParams(le);return ve.delete("resume"),ve})}).catch(le=>{console.error("❌ Failed to resume template installation:",le),le.message?.includes("404")||le.message?.includes("not found")?m("Template installation run not found. It may have expired or been completed."):m("Failed to resume template installation. Please try again.")})}catch(le){console.error("❌ Auto-resume failed with error:",le),m("Failed to resume template installation. Please refresh and try again.")}}},[t,e,U,Z,S,_,V,B,P,n]);const X=[{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"groq",label:"Groq"},{value:"google",label:"Google"}],te=[{key:"tools",label:"Tools",value:N?.tools?.length?N.tools.map(ne=>ne).join(", "):"n/a",icon:o.jsx(Gp,{})},{key:"agents",label:"Agents",value:N?.agents?.length?N.agents.map(ne=>ne).join(", "):"n/a",icon:o.jsx(rl,{})},{key:"workflows",label:"Workflows",value:N?.workflows?.length?N.workflows.map(ne=>ne).join(", "):"n/a",icon:o.jsx(eq,{})},{key:"providers",label:"Providers",value:N?.supportedProviders?.length?N.supportedProviders.join(", "):"n/a",icon:o.jsx(Iv,{})},{key:"tags",label:"Tags",value:N?.tags?.length?N.tags.join(", "):"n/a",icon:o.jsx(hN,{})}],J=[{...te[0]},{...te[1]},{...te[2]}].filter(ne=>ne.value!=="n/a");v.useEffect(()=>{F&&d(F)},[F]),v.useEffect(()=>{const ne=G||q;ne?.phase==="error"&&ne?.error&&m(typeof ne.error=="string"?ne.error:String(ne.error))},[G?.phase,G?.error,q?.phase,q?.error]);const ee=ne=>{s(ne)},ae=async ne=>(i(ne.provider),c(ne.modelId),{message:"Model updated successfully"}),de=async()=>{const ne=Object.entries(u).reduce((ce,[pe,le])=>(le===""&&ce.push(pe),ce),[]);if(ne.length>0){p(ne);return}if(N){m(null),y(!1),w(""),C(!0);try{const pe={repo:N.githubUrl||`https://github.com/mastra-ai/template-${N.slug}`,ref:$,slug:N.slug,variables:u},{runId:le}=await L({});w(le),n(ve=>{const ye=new URLSearchParams(ve);return ye.set("runId",le),ye.set("resume","true"),ye.set("provider",r||"openai"),ye}),await M.mutateAsync({inputData:pe,selectedModel:{provider:a,modelId:l},runId:le})}catch(ce){C(!1),m(ce?.message||"Template installation failed"),console.error("Template installation failed",ce)}}},Y=ne=>{const{name:ce,value:pe}=ne.target;pe.trim()===""?p(le=>[...le,ce]):p(le=>le.filter(ve=>ve!==ce)),d(le=>({...le,[ce]:pe}))};return o.jsx(cs,{children:o.jsx("div",{className:K("w-full lg:px-12 h-full overflow-y-scroll"),children:o.jsxs("div",{className:"p-6 w-full max-w-[80rem] mx-auto grid gap-y-4",children:[o.jsx(Rrs,{isLoading:I,title:N?.title,description:N?.longDescription,imageURL:N?.imageURL,githubUrl:N?.githubUrl,infoData:te,templateSlug:e}),N&&o.jsxs(o.Fragment,{children:[(U||Z)&&o.jsx(Lrs,{name:N.title,streamResult:Z?q:G,runId:b,workflowInfo:V}),g&&o.jsx(Frs,{name:N.title,installedEntities:J,linkComponent:ci}),h&&o.jsx(Irs,{errorMsg:h,validationErrors:E.length>0?E:G?.validationResults?.errors||q?.validationResults?.errors}),!U&&!Z&&!g&&!h&&o.jsx(Ars,{providerOptions:X,selectedProvider:r,onProviderChange:ee,variables:u,setVariables:d,errors:f,setErrors:p,handleInstallTemplate:de,handleVariableChange:Y,isLoadingEnvVars:D||W,isInstalling:z,defaultModelProvider:a,defaultModelId:l,onModelUpdate:ae})]})]})})})}const Brs=()=>{const{toolId:e,agentId:t}=dr();return o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(PWr,{toolId:e,agentId:t})})},Urs=()=>{const{toolId:e}=dr();return o.jsx("div",{className:"h-full w-full overflow-y-hidden",children:o.jsx(hns,{toolId:e})})};function qrs(){const{traceId:e}=dr(),[t,n]=ji(),r=bs(),s=t.get("spanId")||void 0,a=t.get("tab"),i=a==="scoring"?"scoring":a==="feedback"?"feedback":"details",l=t.get("scoreId")||void 0,[c,u]=v.useState(s??null),[d,f]=v.useState(),[p,h]=v.useState(i),[m,g]=v.useState(0),[y,b]=v.useState(!1),{data:w,isLoading:S,error:k}=HH(e),_=v.useMemo(()=>w?.spans??[],[w?.spans]),C=v.useMemo(()=>_.find(ae=>ae.parentSpanId==null),[_]),{data:E,isLoading:j}=aI(e,c??"");v.useEffect(()=>g(0),[e,c]);const{data:N,isLoading:I}=eh(),{data:R,isLoading:$}=ELt({traceId:e,spanId:c??void 0,page:m}),[F,D]=v.useState(0);v.useEffect(()=>D(0),[e,c]);const{data:V,isLoading:W}=e8t({traceId:e,page:F});v.useEffect(()=>{if(l&&R?.scores&&!d){const ae=R.scores.find(de=>de.id===l);ae&&f(ae)}},[l,R?.scores,d]);const L=v.useCallback(ae=>{const de=new URLSearchParams(t);for(const[Y,ne]of Object.entries(ae))ne===null||ne===""?de.delete(Y):de.set(Y,ne);n(de,{replace:!0})},[t,n]),z=v.useCallback(ae=>{const de=ae??null,Y=de===c;u(de),Y||(f(void 0),h("details"),L({spanId:de,tab:null,scoreId:null}))},[c,L]),B=v.useCallback(()=>{u(null),f(void 0),h("details"),L({spanId:null,tab:null,scoreId:null})},[L]),M=v.useCallback(ae=>{u(ae),f(void 0),h("details"),L({spanId:ae,tab:null,scoreId:null})},[L]),{handlePreviousSpan:G,handleNextSpan:U}=WH(_,c,M),P=v.useCallback(ae=>{const de=ae;h(de),f(void 0),L({tab:de==="details"?null:de,scoreId:null})},[L]),q=v.useCallback(ae=>{f(ae),L({scoreId:ae.id})},[L]),Z=v.useCallback(()=>{f(void 0),L({scoreId:null})},[L]),X=v.useCallback(()=>{r("/observability")},[r]),te=v.useCallback(()=>{h("scoring"),C&&c!==C.spanId?(u(C.spanId),f(void 0),L({spanId:C.spanId,tab:"scoring",scoreId:null})):L({tab:"scoring"})},[C,c,L]),J=C?o.jsx(Ty,{owner:"trace-detail",children:o.jsxs($r,{children:[o.jsxs(ue,{tooltip:"Evaluate Trace","aria-label":"Evaluate Trace",onClick:te,children:[o.jsx(Mln,{}),"Evaluate"]}),o.jsxs(ue,{tooltip:"Save as Dataset Item","aria-label":"Save as Dataset Item",onClick:()=>b(!0),children:[o.jsx(fd,{}),"Save"]})]})}):null,ee=C?o.jsx(Lt.Row,{children:o.jsx(Lt.Column,{children:o.jsx(H6t,{rootSpan:C,numOfCol:3})})}):null;return k?o.jsxs(Lt,{height:"full",children:[J,ee&&o.jsx(Lt.TopArea,{children:ee}),o.jsx(Lt.MainArea,{isCentered:!0,children:o.jsx(W6t,{error:k,resource:"traces",errorTitle:"Failed to load trace"})})]}):o.jsxs(Lt,{children:[J,ee&&o.jsx(Lt.TopArea,{children:ee}),o.jsx(Q6t,{rootSpanId:C?.spanId,traceId:e,isOpen:y,onClose:()=>b(!1)}),o.jsxs("div",{className:K("grid h-full min-h-0 gap-4 overflow-hidden items-start mt-4",c?"grid-cols-[2fr_3fr]":"grid-cols-[1fr]"),children:[o.jsx(sTe,{traceId:e,spans:_,isLoading:S,onClose:X,onSpanSelect:z,onEvaluateTrace:te,initialSpanId:c,placement:"trace-page",timelineChartWidth:c?"default":"wide"}),c&&!S&&o.jsxs("div",{className:K("grid gap-4 max-h-full min-h-0 overflow-auto",d?"grid-rows-[1fr_1fr]":"grid-rows-[1fr]"),children:[o.jsx(qH,{traceId:e,spanId:c,span:E?.span,isLoading:j,onClose:B,onPrevious:G,onNext:U,activeTab:p,onTabChange:P,feedbackTabBadge:V?.pagination?.total??void 0,feedbackTabSlot:()=>o.jsx(X6t,{feedbackData:V,onPageChange:D,isLoadingFeedbackData:W}),scoringTabBadge:R?.pagination?.total??void 0,scoringTabSlot:({span:ae,traceId:de,spanId:Y})=>o.jsxs("div",{className:"grid gap-6",children:[o.jsx(J6t,{traceId:de,isTopLevelSpan:!ae.parentSpanId,spanId:Y,entityType:ae.attributes?.agentId||ae.entityType===Os.AGENT?"Agent":ae.attributes?.workflowId||ae.entityType===Os.WORKFLOW_RUN?"Workflow":void 0,scorers:N,isLoadingScorers:I}),o.jsx(K6t,{scoresData:R,onPageChange:g,isLoadingScoresData:$,onScoreSelect:q})]})}),d&&o.jsx(Ije,{score:d,onClose:Z})]})]})]})}function Vrs(){const{data:e,isLoading:t,error:n}=By(),[r,s]=v.useState("");return n&&gs(n)?o.jsx(lr,{children:o.jsx(Vs,{})}):n&&ys(n)?o.jsx(lr,{children:o.jsx(Ds,{resource:"workflows"})}):n?o.jsx(lr,{children:o.jsx(Fi,{title:"Failed to load workflows",message:n.message})}):Object.keys(e||{}).length===0&&!t?o.jsx(lr,{children:o.jsx(X$r,{})}):o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsxs(Lt.Row,{align:"center",stack:"responsive",children:[o.jsx("div",{className:"max-w-120 flex-1",children:o.jsx(Of,{onSearch:s,label:"Filter workflows",placeholder:"Filter by name or description"})}),o.jsxs(ue,{as:ci,to:"/workflows/schedules",variant:"primary",className:"shrink-0",children:[o.jsx(o3,{}),"Schedules"]})]})}),o.jsx(Y$r,{workflows:e||{},isLoading:t,search:r})]})}const Hrs={active:"bg-accent1",paused:"bg-accent3"},Wrs={active:"text-accent1",paused:"text-accent3"},y8t=({status:e})=>o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${Hrs[e]}`,"aria-hidden":!0}),o.jsx("span",{className:`text-ui-sm ${Wrs[e]}`,children:e})]}),Aj=e=>!e||e<=0?"—":new Date(e).toLocaleString(),sP=e=>{if(!e||e<=0)return"—";const t=e-Date.now(),n=Math.abs(t),r=Math.floor(n/1e3);if(r<60)return t>=0?`in ${r}s`:`${r}s ago`;const s=Math.floor(r/60);if(s<60)return t>=0?`in ${s}m`:`${s}m ago`;const a=Math.floor(s/60);if(a<24)return t>=0?`in ${a}h`:`${a}h ago`;const i=Math.floor(a/24);return t>=0?`in ${i}d`:`${i}d ago`};function b8t({status:e}){const{icon:t,color:n}=Zrs(e);return o.jsxs("span",{className:`inline-flex items-center gap-1.5 whitespace-nowrap text-ui-sm ${n}`,children:[o.jsx("span",{className:"inline-flex shrink-0 items-center","aria-hidden":!0,children:t}),o.jsx("span",{children:e})]})}function Zrs(e){switch(e){case"success":return{icon:o.jsx(Js,{size:14}),color:"text-accent1"};case"failed":return{icon:o.jsx(vs,{size:14}),color:"text-accent2"};case"running":return{icon:o.jsx(Gt,{}),color:"text-neutral3"};case"suspended":return{icon:o.jsx(ZU,{size:14}),color:"text-accent3"};case"canceled":return{icon:o.jsx(xf,{size:14}),color:"text-neutral3"};case"pending":case"waiting":return{icon:o.jsx(sO,{size:14}),color:"text-neutral3"};default:return{icon:null,color:"text-neutral3"}}}const CQe="auto auto auto auto 1fr";function Grs(e){if(e===void 0)return"—";if(e<1e3)return`${e}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;const t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${t}m ${n}s`}function Qrs(e){const t=Math.abs(e),n=e<0?"-":"";return t<1e3?`${n}${t}ms`:t<6e4?`${n}${(t/1e3).toFixed(1)}s`:t<36e5?`${n}${(t/6e4).toFixed(1)}m`:`${n}${(t/36e5).toFixed(1)}h`}const Yrs=3e4,Xrs=5*6e4;function Krs({triggers:e,isLoading:t,workflowId:n,hasNextPage:r,isFetchingNextPage:s,setEndOfListElement:a}){const{Link:i,paths:l}=yn();return t?o.jsx(el,{columns:CQe}):e.length===0?o.jsx(ge,{variant:"ui-md",className:"text-neutral4 p-4",children:"No trigger history yet."}):o.jsxs(me,{columns:CQe,className:"min-w-0",children:[o.jsxs(me.Top,{children:[o.jsx(me.TopCell,{children:"Run"}),o.jsx(me.TopCell,{children:"Status"}),o.jsx(me.TopCell,{children:"Started"}),o.jsx(me.TopCell,{children:"Duration"}),o.jsx(me.TopCell,{children:" "})]}),e.map(c=>{const u=c.actualFireAt-c.scheduledFireAt,d=Qrs(u),f=`Scheduled ${Aj(c.scheduledFireAt)} — published ${Aj(c.actualFireAt)} (drift ${d})`,p=c.outcome==="failed",h=p?c.error:c.run?.error,m=Math.abs(u),g=!p&&m>Yrs&&m<=Xrs,y=`${c.scheduleId}-${c.runId}-${c.actualFireAt}`,b=!!(n&&c.runId&&!p),w=o.jsx("span",{className:b?"text-accent1 font-mono text-ui-sm whitespace-nowrap":"text-neutral3 font-mono text-ui-sm whitespace-nowrap",children:c.runId}),S=o.jsxs(o.Fragment,{children:[o.jsx(me.Cell,{height:"compact",children:w}),o.jsx(me.Cell,{height:"compact",children:o.jsxs("span",{className:"inline-flex items-center gap-2",children:[p?o.jsxs("span",{className:"inline-flex items-center gap-1.5 whitespace-nowrap text-ui-sm text-accent2",children:[o.jsx(kp,{size:14}),"publish failed"]}):c.run?o.jsx(b8t,{status:c.run.status}):o.jsx("span",{className:"inline-flex items-center gap-1.5 whitespace-nowrap text-ui-sm text-neutral3",children:"pending"}),h?o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx("span",{className:"text-accent2 inline-flex",children:o.jsx(kp,{size:14})})}),o.jsx(Bn,{children:h})]}):null]})}),o.jsx(me.Cell,{height:"compact",children:o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx("span",{title:f,children:sP(c.actualFireAt)}),g?o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx("span",{className:"text-accent3 inline-flex",children:o.jsx(kp,{size:14})})}),o.jsxs(Bn,{children:["Published ",d," after the scheduled fire time"]})]}):null]})}),o.jsx(me.Cell,{height:"compact",children:c.run?o.jsx("span",{children:Grs(c.run.durationMs)}):o.jsx("span",{className:"text-neutral4",children:"—"})}),o.jsx(me.Cell,{height:"compact",children:" "})]});return b?o.jsx(me.RowLink,{to:l.workflowRunLink(n,c.runId),LinkComponent:i,children:S},y):o.jsx(me.RowStatic,{children:S},y)}),o.jsx(me.NextPageLoading,{isLoading:s,hasMore:r,setEndOfListElement:a})]})}const Jrs=e=>{const t=We();return wt({queryKey:["schedule",e],enabled:!!e,queryFn:async()=>{if(!e)throw new Error("scheduleId is required");return t.getSchedule(e)}})},EQe=25,ess=e=>{const t=We(),{inView:n,setRef:r}=__(),s=R1({queryKey:["schedule-triggers",e],enabled:!!e,initialPageParam:void 0,queryFn:async({pageParam:u})=>e?t.listScheduleTriggers(e,{limit:EQe,toActualFireAt:u}):{triggers:[]},getNextPageParam:u=>{if(!(!u?.triggers?.length||u.triggers.length<EQe))return u.triggers[u.triggers.length-1].actualFireAt},refetchInterval:u=>(u.state.data?.pages.flatMap(p=>p.triggers)??[]).some(p=>p.run?p.run.status==="pending"||p.run.status==="running"||p.run.status==="waiting":p.outcome==="published")?5e3:!1}),a=s.data?.pages.flatMap(u=>u?.triggers??[])??[],{hasNextPage:i,isFetchingNextPage:l,fetchNextPage:c}=s;return v.useEffect(()=>{n&&i&&!l&&c()},[n,i,l,c]),{...s,data:a,setEndOfListElement:r}},tss=e=>{const t=We(),n=Hr();return Rn({mutationFn:async r=>{if(!e)throw new Error("scheduleId is required");return r==="pause"?t.pauseSchedule(e):t.resumeSchedule(e)},onSuccess:(r,s)=>{n.invalidateQueries({queryKey:["schedule",e]}),n.invalidateQueries({queryKey:["schedules"]}),De.success(s==="pause"?"Schedule paused":"Schedule resumed")},onError:r=>{De.error(r.message)}})};function K8({label:e,children:t}){return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 uppercase tracking-wide",children:e}),o.jsx("div",{className:"text-ui-md",children:t})]})}function nss(){const{scheduleId:e}=dr(),{paths:t}=yn(),{data:n,error:r}=Jrs(e),{data:s,isLoading:a,error:i,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u}=ess(e),d=tss(e);if(r&&gs(r))return o.jsx(lr,{children:o.jsx(Vs,{})});if(r&&ys(r))return o.jsx(lr,{children:o.jsx(Ds,{resource:"schedules"})});if(r)return o.jsx(lr,{children:o.jsx(Fi,{title:"Failed to load schedule",message:r.message})});const f=n?.target.type==="workflow"?n.target.workflowId:void 0;return o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx(Lt.Row,{className:"justify-end",children:o.jsxs(Lt.Column,{className:"flex justify-end gap-2",children:[o.jsxs(ue,{as:ci,to:t.schedulesLink(),variant:"ghost",children:[o.jsx(Ec,{}),"Back to schedules"]}),f?o.jsx(ue,{as:ci,to:t.workflowLink(f),variant:"ghost",children:"Open workflow"}):null,n?o.jsx(ue,{onClick:()=>d.mutate(n.status==="active"?"pause":"resume"),disabled:d.isPending,"data-testid":"schedule-toggle-button",children:n.status==="active"?o.jsxs(o.Fragment,{children:[o.jsx(Tlt,{}),"Pause"]}):o.jsxs(o.Fragment,{children:[o.jsx(Pp,{}),"Resume"]})}):null]})})}),n?o.jsxs("div",{className:"grid gap-6 h-full overflow-hidden grid-cols-[minmax(0,20rem)_1fr]",children:[o.jsxs("div",{className:"flex flex-col gap-4 border border-border1 rounded-md p-4 h-fit",children:[o.jsx(K8,{label:"Workflow",children:f?o.jsx(ci,{to:t.workflowLink(f),className:"text-accent1 hover:underline",children:f}):"—"}),o.jsxs(K8,{label:"Cron",children:[o.jsx("code",{className:"font-mono text-ui-md",children:n.cron}),n.timezone?o.jsx("span",{className:"text-neutral4 ml-2 text-ui-sm",children:n.timezone}):null]}),o.jsx(K8,{label:"Status",children:o.jsx(y8t,{status:n.status})}),o.jsx(K8,{label:"Next fire",children:o.jsx("span",{title:Aj(n.nextFireAt),children:sP(n.nextFireAt)})})]}),o.jsxs("div",{className:"overflow-y-auto","data-testid":"schedule-triggers-panel",children:[o.jsx(ge,{variant:"ui-md",className:"mb-3",children:"Trigger history"}),i?o.jsx(Fi,{title:"Failed to load trigger history",message:i.message}):o.jsx(Krs,{triggers:s??[],isLoading:a,workflowId:f,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u})]})]}):null]})}const jQe="minmax(0, 1.2fr) minmax(0, 1.4fr) minmax(0, 1fr) auto auto auto";function rss({schedules:e,isLoading:t,search:n=""}){const{paths:r,Link:s}=yn(),a=v.useMemo(()=>{const i=n.toLowerCase();return i?e.filter(l=>l.id.toLowerCase().includes(i)||l.target.workflowId.toLowerCase().includes(i)):e},[e,n]);return t?o.jsx(el,{columns:jQe}):o.jsxs(me,{columns:jQe,variant:"striped",className:"min-w-0",children:[o.jsxs(me.Top,{children:[o.jsx(me.TopCell,{children:"Workflow"}),o.jsx(me.TopCell,{children:"Schedule ID"}),o.jsx(me.TopCell,{children:"Cron"}),o.jsx(me.TopCell,{children:"Status"}),o.jsx(me.TopCell,{children:"Next fire"}),o.jsx(me.TopCell,{children:"Last run"})]}),a.length===0&&n?o.jsx(me.NoMatch,{message:"No schedules match your search"}):null,a.length===0&&!n?o.jsx(me.NoMatch,{message:"No schedules configured"}):null,a.map(i=>o.jsxs(me.RowLink,{to:r.scheduleLink(i.id),LinkComponent:s,children:[o.jsx(me.NameCell,{children:i.target.workflowId}),o.jsx(me.Cell,{height:"compact",className:"min-w-0",children:o.jsx("span",{className:"block truncate font-mono text-ui-smd text-neutral3",title:i.id,children:i.id})}),o.jsx(me.Cell,{height:"compact",children:o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx("code",{className:"font-mono text-ui-sm",children:i.cron}),i.timezone?o.jsx("span",{className:"text-neutral4 text-ui-xs",children:i.timezone}):null]})}),o.jsx(me.Cell,{height:"compact",children:o.jsx(y8t,{status:i.status})}),o.jsx(me.Cell,{height:"compact",children:o.jsx("span",{className:"whitespace-nowrap",title:Aj(i.nextFireAt),children:sP(i.nextFireAt)})}),o.jsx(me.Cell,{height:"compact",children:i.lastRun?o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx(b8t,{status:i.lastRun.status}),o.jsx("span",{className:"text-neutral4 text-ui-sm",title:Aj(i.lastFireAt),children:i.lastFireAt?sP(i.lastFireAt):""})]}):i.lastFireAt?o.jsx("span",{className:"whitespace-nowrap",title:Aj(i.lastFireAt),children:sP(i.lastFireAt)}):o.jsx("span",{className:"text-neutral4",children:"Never"})})]},i.id))]})}function sss({workflowId:e}={}){const{data:t,isLoading:n,error:r}=Bxe(e?{workflowId:e}:{}),[s,a]=v.useState("");return r?o.jsx(Fi,{title:"Failed to load schedules",message:r.message}):o.jsxs("div",{className:"grid grid-rows-[auto_1fr] gap-4 h-full overflow-hidden",children:[o.jsx("div",{className:"max-w-120",children:o.jsx(Of,{onSearch:a,label:"Filter schedules",placeholder:"Filter by id or workflow"})}),o.jsx("div",{className:"overflow-y-auto",children:o.jsx(rss,{schedules:t??[],isLoading:n,search:s})})]})}function ass(){const[e]=ji(),t=e.get("workflowId")??void 0,{error:n}=Bxe(t?{workflowId:t}:{});return n&&gs(n)?o.jsx(lr,{children:o.jsx(Vs,{})}):n&&ys(n)?o.jsx(lr,{children:o.jsx(Ds,{resource:"schedules"})}):o.jsx(Lt,{children:o.jsx("div",{className:"h-full",children:o.jsx(sss,{workflowId:t})})})}function iss({stepGraph:e,open:t,workflowName:n}){const{nodes:r,edges:s}=b1e({stepGraph:e}),[a,i]=v.useState(!1),[l,c,u]=Q0t(r),[d]=Y0t(s),{edgeTypes:f,nodeTypes:p,styledEdges:h}=WRt({edges:d,workflowName:n,stepGraph:e});return v.useEffect(()=>{if(t){const m=setTimeout(()=>{i(!0)},500);return()=>clearTimeout(m)}},[t]),o.jsx("div",{className:"w-full h-full relative bg-surface1",children:a?o.jsxs(G0t,{nodes:l,edges:h,edgeTypes:f,fitView:!0,fitViewOptions:{maxZoom:1},minZoom:.01,maxZoom:1,nodeTypes:p,onNodesChange:u,children:[o.jsx(I_e,{position:"bottom-left"}),o.jsx(K0t,{variant:Kv.Lines,gap:12,size:.5})]}):o.jsx("div",{className:"w-full h-full flex items-center justify-center",children:o.jsx(Gt,{})})})}function oss(){const{stepDetail:e,closeStepDetail:t}=RV();return e?o.jsxs("div",{className:"flex flex-col h-full","data-testid":"workflow-step-detail-panel",children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border1 bg-surface1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[e.type==="map-config"&&o.jsx(Lde,{className:"w-4 h-4",style:{color:xu.map}}),e.type==="nested-graph"&&o.jsx(kd,{className:"w-4 h-4",style:{color:xu.workflow}}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx(ge,{variant:"ui-md",className:"text-neutral6 font-medium",children:e.type==="map-config"?`${e.stepName} Config`:`${e.stepName} Workflow`}),e.type==="map-config"&&e.stepId&&e.stepId!==e.stepName&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral3",children:e.stepId})]})]}),o.jsx("button",{onClick:t,className:"p-1 hover:bg-surface3 rounded transition-colors","aria-label":"Close",children:o.jsx(vs,{className:"w-4 h-4 text-neutral3"})})]}),o.jsxs("div",{className:"flex-1 overflow-auto",children:[e.type==="map-config"&&e.mapConfig&&o.jsx(J2,{data:e.mapConfig}),e.type==="nested-graph"&&e.nestedGraph&&o.jsx("div",{className:"h-full min-h-[400px]",children:o.jsx(y1e,{children:o.jsx(iss,{stepGraph:e.nestedGraph.stepGraph,open:!0,workflowName:e.nestedGraph.fullStep})},`nested-graph-${e.nestedGraph.fullStep}`)})]})]}):null}function lss(e){const t=new Blob([JSON.stringify(e??null)]).size;return t<1024?`${t} B`:`${(t/1024).toFixed(1)} KB`}function css(e,t){if(e&&typeof e=="object"&&!Array.isArray(e)){const n=Object.keys(e);if(n.length===1)return n[0]}return t}function uss({suspendedSteps:e,workflow:t,isStreaming:n,onResume:r}){return n||e.length===0?null:o.jsxs("div",{className:"space-y-5 rounded-lg border border-border1 bg-surface4 p-5","data-testid":"workflow-suspended-steps",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs(ge,{as:"p",variant:"ui-md",className:"flex items-center gap-2 text-neutral6 font-semibold",children:[o.jsx(Ue,{children:o.jsx(ZU,{})}),"Step suspended"]}),o.jsx(fn,{variant:"warning",children:"Needs input"})]}),e.map((s,a)=>{const i=t.allSteps[s.stepId];if(!i||i.isWorkflow)return null;const l=i?.resumeSchema?im(sm(mx(i.resumeSchema))):rp(ur(),nT());return o.jsx(dss,{step:s,stepSchema:l,description:i.description,isStreaming:n,onResume:r},`${s.runId}-${s.stepId}-${a}`)})]})}function dss({step:e,stepSchema:t,description:n,isStreaming:r,onResume:s}){const[a,i]=v.useState(!1);return o.jsxs("div",{className:"space-y-5",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ge,{as:"p",variant:"ui-md",className:"text-neutral6 font-medium truncate",children:e.stepId}),n&&o.jsx(ge,{as:"p",variant:"ui-sm",className:"text-neutral3",children:n})]}),e.suspendPayload&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ge,{as:"p",variant:"ui-sm",className:"flex items-center gap-2 text-neutral3",children:[o.jsx(Ue,{children:o.jsx(Wun,{})}),"The step is asking"]}),o.jsxs(Lp,{open:a,onOpenChange:i,children:[o.jsxs(mf,{className:"flex w-full items-center justify-between gap-2 rounded-lg border border-border1 bg-surface3 px-3 py-2.5",children:[o.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[o.jsx(Ue,{children:o.jsx(la,{className:K("transition-transform text-neutral3",{"transform rotate-90":a})})}),o.jsx(ge,{as:"span",variant:"ui-md",className:"text-neutral6 truncate",children:css(e.suspendPayload,e.stepId)})]}),o.jsx(ge,{as:"span",variant:"ui-sm",className:"text-neutral3 shrink-0",children:lss(e.suspendPayload)})]}),o.jsx(gf,{children:o.jsx("div",{"data-testid":"suspended-payload",className:"pt-2",children:o.jsx(Qr,{data:e.suspendPayload,className:"w-full overflow-x-auto p-2",showCopyButton:!1})})})]})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs(ge,{as:"p",variant:"ui-sm",className:"flex items-center gap-2 text-neutral3",children:[o.jsx(Ue,{children:o.jsx(Qun,{})}),"Your response"]}),o.jsx("div",{className:"-mx-5",children:o.jsx(C7,{schema:t,isSubmitLoading:r,submitButtonLabel:"Resume",submitButtonIcon:o.jsx(Pp,{}),submitButtonFullWidth:!0,collapsible:!1,hideHeading:!0,hideInputTypeLabel:!0,onSubmit:l=>{const c=e.stepId?.split(".");s({stepId:c,runId:e.runId,suspendPayload:e.suspendPayload,resumeData:l,isLoading:!1})}})})]})]})}function fss(){const{result:e,runSnapshot:t,workflow:n,runId:r,isStreamingWorkflow:s}=v.useContext(Rl),{runId:a}=dr(),i=awt(e,r??""),l=sZn(),c=!!a,u=t?.status==="suspended",f=!!(a&&r&&a===r)&&e?.status==="suspended";return s||!n||i.length===0||c&&!u&&!f?null:o.jsx("div",{"data-testid":"workflow-suspended-overlay",className:"absolute top-2 right-2 z-20 w-[380px] max-w-[calc(100%-1rem)] max-h-[calc(100%-1rem)] overflow-y-auto rounded-lg shadow-lg animate-in fade-in-0 slide-in-from-top-2 zoom-in-95 duration-300",children:o.jsx(uss,{suspendedSteps:i,workflow:n,isStreaming:s,onResume:l})},r)}const pss=e=>o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.99982 2.0625C3.8252 2.0625 2.06232 3.82538 2.06232 6C2.06232 8.17462 3.8252 9.9375 5.99982 9.9375C8.17444 9.9375 9.93732 8.17462 9.93732 6C9.93732 3.82538 8.17444 2.0625 5.99982 2.0625ZM0.937317 6C0.937317 3.20406 3.20388 0.9375 5.99982 0.9375C8.79576 0.9375 11.0623 3.20406 11.0623 6C11.0623 8.79594 8.79576 11.0625 5.99982 11.0625C3.20388 11.0625 0.937317 8.79594 0.937317 6Z",fill:"currentColor"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.97865 4.57004C8.22604 4.75795 8.27426 5.11082 8.08635 5.35821L6.05486 8.03279C5.94873 8.17251 5.78348 8.25471 5.60803 8.25505C5.43257 8.2554 5.267 8.17385 5.16032 8.03454L3.80937 6.27034C3.6205 6.02369 3.66733 5.67063 3.91398 5.48176C4.16063 5.29288 4.51369 5.33972 4.70257 5.58637L5.6051 6.76498L7.19048 4.67774C7.37839 4.43036 7.73126 4.38213 7.97865 4.57004Z",fill:"currentColor"})]}),hss=e=>o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.99982 2.0625C3.8252 2.0625 2.06232 3.82538 2.06232 6C2.06232 8.17462 3.8252 9.9375 5.99982 9.9375C8.17444 9.9375 9.93732 8.17462 9.93732 6C9.93732 3.82538 8.17444 2.0625 5.99982 2.0625ZM0.937317 6C0.937317 3.20406 3.20388 0.9375 5.99982 0.9375C8.79576 0.9375 11.0623 3.20406 11.0623 6C11.0623 8.79594 8.79576 11.0625 5.99982 11.0625C3.20388 11.0625 0.937317 8.79594 0.937317 6Z",fill:"currentColor"}),o.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.89741 4.10293C8.11707 4.32261 8.11706 4.67877 7.89738 4.89843L6.79517 6.00058L7.8962 7.10155C8.11588 7.32122 8.11589 7.67737 7.89623 7.89705C7.67656 8.11673 7.32041 8.11674 7.10073 7.89707L5.99965 6.79605L4.89856 7.89707C4.67889 8.11673 4.32273 8.11672 4.10307 7.89704C3.88341 7.67737 3.88342 7.32121 4.10309 7.10155L5.20413 6.00058L4.10191 4.89843C3.88224 4.67877 3.88223 4.32262 4.10189 4.10294C4.32155 3.88326 4.67771 3.88325 4.89738 4.10292L5.99965 5.20511L7.10191 4.10291C7.32159 3.88325 7.67774 3.88326 7.89741 4.10293Z",fill:"currentColor"})]}),mss=e=>e.includes("."),gss=e=>e==="input"||e.endsWith(".input"),vss=1;function yss(e){return`${Number((e/1e3).toPrecision(3))}s`}function bss(e,t){const n=Object.entries(e).filter(([i])=>!gss(i));if(n.length===0)return[];const r=Math.min(...n.map(([,i])=>i.startedAt)),s=Math.max(...n.map(([,i])=>i.endedAt??t)),a=Math.max(s-r,1);return n.map(([i,l])=>{const c=l.endedAt===void 0,d=(l.endedAt??t)-l.startedAt,f=(l.startedAt-r)/a*100,p=Math.max(d/a*100,vss);return{stepId:i,step:l,status:l.status,offsetPct:f,widthPct:p,durationMs:d,isRunning:c,isNestedEntry:mss(i)}})}const xss=({status:e})=>o.jsxs(Ue,{children:[e==="success"&&o.jsx(pss,{className:"text-accent1"}),e==="failed"&&o.jsx(hss,{className:"text-accent2"}),e==="suspended"&&o.jsx(ZU,{className:"text-accent3"}),e==="waiting"&&o.jsx(Dde,{className:"text-accent5"}),e==="skipped"&&o.jsx(Dde,{className:"text-icon3"}),e==="running"&&o.jsx(ia,{className:"text-accent6 animate-spin"})]}),wss={success:"bg-accent1",failed:"bg-accent2",suspended:"bg-accent3",waiting:"bg-accent5",skipped:"bg-border1",running:"bg-accent6"};function x8t(e){return e.split(/[-_.\s]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}const TQe=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{value:e},Sss=e=>{const t=e;return DRt({duration:t.duration,date:t.date,isForEach:t.isForEach,mapConfig:t.mapConfig,canSuspend:t.canSuspend,isParallel:t.isParallel,stepGraph:t.stepGraph})},kss=({row:e,index:t,isSelected:n,isHovered:r,onSelectStep:s,onHoverStep:a,onOpenInput:i,onOpenOutput:l})=>{const c=Sss(e.step),u=e.status==="running",d=!e.isNestedEntry;return o.jsxs("div",{role:"button",tabIndex:0,"data-testid":"workflow-timeline-row","data-workflow-step-key":e.stepId,"data-workflow-step-active":n?"true":void 0,"data-workflow-step-hovered":r?"true":void 0,"data-workflow-step-nested":e.isNestedEntry?"true":void 0,"aria-pressed":n,"aria-disabled":!d,onMouseEnter:()=>{d&&a(e.stepId)},onMouseLeave:()=>{d&&a(null)},onClick:()=>{d&&s(e.stepId)},onKeyDown:f=>{!d||f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),s(e.stepId))},className:K("grid grid-cols-[auto_auto_auto_minmax(0,10rem)_minmax(0,1fr)_auto_5rem] items-center gap-2 rounded-md border border-transparent px-2 py-1 text-left transition-colors focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-accent1",d&&"cursor-pointer",d&&"hover:bg-surface4",d&&r&&!n&&"border-neutral6 bg-surface4",d&&n&&"border-accent1",e.isNestedEntry&&"cursor-default opacity-55"),children:[o.jsx("div",{className:"flex justify-center",children:o.jsx(xss,{status:e.status})}),o.jsx("div",{className:"flex justify-center",children:o.jsx(ue,{type:"button",variant:"ghost",size:"icon-sm",tooltip:"View step input",disabled:u,className:"text-neutral3 hover:text-neutral6 disabled:cursor-not-allowed disabled:opacity-40",onClick:f=>{f.stopPropagation(),u||i(e)},children:o.jsx(Zdn,{})})}),o.jsx("div",{className:"flex overflow-hidden",children:o.jsx(JB,{indicators:c,className:"shrink-0"})}),o.jsx(ge,{as:"span",variant:"ui-sm",className:"block min-w-0 max-w-full justify-self-stretch overflow-hidden text-ellipsis whitespace-nowrap text-left text-neutral6",children:x8t(e.stepId)}),o.jsx("div",{className:"relative h-2 min-w-0 rounded bg-surface4",children:o.jsx("div",{"data-testid":"workflow-timeline-bar","data-offset":String(e.offsetPct),"data-width":String(e.widthPct),className:`absolute top-0 h-full rounded ${wss[e.status]}`,style:{left:`${e.offsetPct}%`,width:`${e.widthPct}%`}})}),o.jsx("div",{className:"flex justify-center",children:o.jsx(ue,{type:"button",variant:"ghost",size:"icon-sm",tooltip:"View step output",disabled:u,className:"text-neutral3 hover:text-neutral6 disabled:cursor-not-allowed disabled:opacity-40",onClick:f=>{f.stopPropagation(),u||l(e)},children:o.jsx(Hdn,{})})}),o.jsx(ge,{as:"span",variant:"ui-sm",className:"w-20 justify-self-end text-right text-neutral3 tabular-nums",children:yss(e.durationMs)})]},`timeline-item-${e.stepId}-${t}`)};function Oss(){const{steps:e}=JD(),{selectedStepId:t,hoverStepId:n,setSelectedStepId:r,setHoverStepId:s}=Vq(),[a,i]=v.useState(()=>Date.now()),[l,c]=v.useState(!1),[u,d]=v.useState(null),f=v.useRef(null);Qxe(f,{enabled:!l});const p=bss(e,a),h=p.some(m=>m.isRunning);return v.useEffect(()=>{if(!h)return;const m=setInterval(()=>i(Date.now()),100);return()=>clearInterval(m)},[h]),v.useEffect(()=>{if(l||p.length===0)return;const m=f.current;m&&(m.scrollTop=m.scrollHeight)},[l,p.length]),p.length===0?null:o.jsxs(o.Fragment,{children:[o.jsx("div",{"data-testid":"workflow-timeline",className:"pointer-events-none absolute right-0 bottom-0 z-20 px-2 pb-2",style:{left:"var(--workflow-left-panel-width, 0px)"},children:o.jsxs("div",{className:"pointer-events-auto flex max-h-64 w-full min-w-0 flex-col gap-3 overflow-hidden rounded-studio-panel border border-border1/50 bg-surface3 p-4 shadow-lg",children:[o.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3",children:[o.jsx(ge,{as:"p",variant:"ui-md",className:"text-neutral3",children:"Timeline"}),o.jsx("button",{type:"button","aria-label":l?"Expand timeline":"Collapse timeline","aria-expanded":!l,onClick:()=>c(m=>!m),className:"rounded-md p-1 text-neutral3 transition-colors hover:bg-surface4 hover:text-neutral6",children:o.jsx(Na,{className:K("h-4 w-4 transition-transform",l&&"-rotate-90")})})]}),!l&&o.jsx("div",{ref:f,"data-testid":"workflow-timeline-list",className:"flex min-h-0 flex-col gap-2 overflow-y-auto",children:p.map((m,g)=>o.jsx(kss,{row:m,index:g,isSelected:t===m.stepId,isHovered:n===m.stepId,onSelectStep:r,onHoverStep:s,onOpenInput:y=>d({type:"input",stepId:y.stepId,data:TQe(y.step.input)}),onOpenOutput:y=>d({type:"output",stepId:y.stepId,data:TQe(y.step.output)})},`timeline-item-${m.stepId}-${g}`))})]})}),o.jsx(br,{open:!!u,onOpenChange:m=>!m&&d(null),children:u&&o.jsx(owt,{data:u.data,title:`${x8t(u.stepId)} ${u.type==="input"?"input":"output"}`})})]})}const _ss=({workflowId:e,workflow:t,isLoading:n})=>{const{stepDetail:r}=RV();return o.jsxs("div",{className:"flex h-full min-h-0",children:[o.jsx("div",{className:"flex h-full min-h-0 flex-1 flex-col",children:o.jsxs("div",{className:"relative min-h-0 flex-1 p-2 pb-0",children:[o.jsx(e2t,{workflowId:e,workflow:t,isLoading:n}),o.jsx(fss,{}),o.jsx(Oss,{})]})}),r&&o.jsx("div",{className:"w-[420px] min-h-0 overflow-hidden border-l border-border1",children:o.jsx(oss,{})})]})},NQe=()=>{const{workflowId:e}=dr(),{data:t,isLoading:n,error:r}=hD(e);return r&&gs(r)?o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})}):r&&ys(r)?o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ds,{resource:"workflows"})}):o.jsx(L1e,{children:o.jsx(_ss,{workflowId:e,workflow:t??void 0,isLoading:n})})};function Css(e,t){if(e==null)return{};var n,r,s=dbt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function Pve(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ess(e){if(Array.isArray(e))return Pve(e)}function jss(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Tss(e,t){if(e){if(typeof e=="string")return Pve(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Pve(e,t):void 0}}function Nss(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
728
728
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $ve(e){return Ess(e)||jss(e)||Tss(e)||Nss()}function YM(e){"@babel/helpers - typeof";return YM=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},YM(e)}function Iss(e,t){if(YM(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(YM(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ass(e){var t=Iss(e,"string");return YM(t)=="symbol"?t:t+""}function w8t(e,t,n){return(t=Ass(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function IQe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function KE(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?IQe(Object(n),!0).forEach(function(r){w8t(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):IQe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Rss(e){var t=e.length;if(t===0||t===1)return e;if(t===2)return[e[0],e[1],"".concat(e[0],".").concat(e[1]),"".concat(e[1],".").concat(e[0])];if(t===3)return[e[0],e[1],e[2],"".concat(e[0],".").concat(e[1]),"".concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[0]),"".concat(e[1],".").concat(e[2]),"".concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[1],".").concat(e[0])];if(t>=4)return[e[0],e[1],e[2],e[3],"".concat(e[0],".").concat(e[1]),"".concat(e[0],".").concat(e[2]),"".concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[0]),"".concat(e[1],".").concat(e[2]),"".concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[1]),"".concat(e[2],".").concat(e[3]),"".concat(e[3],".").concat(e[0]),"".concat(e[3],".").concat(e[1]),"".concat(e[3],".").concat(e[2]),"".concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[1],".").concat(e[3]),"".concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[2],".").concat(e[3]),"".concat(e[0],".").concat(e[3],".").concat(e[1]),"".concat(e[0],".").concat(e[3],".").concat(e[2]),"".concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[1],".").concat(e[2],".").concat(e[3]),"".concat(e[1],".").concat(e[3],".").concat(e[0]),"".concat(e[1],".").concat(e[3],".").concat(e[2]),"".concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[0],".").concat(e[3]),"".concat(e[2],".").concat(e[1],".").concat(e[0]),"".concat(e[2],".").concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[3],".").concat(e[0]),"".concat(e[2],".").concat(e[3],".").concat(e[1]),"".concat(e[3],".").concat(e[0],".").concat(e[1]),"".concat(e[3],".").concat(e[0],".").concat(e[2]),"".concat(e[3],".").concat(e[1],".").concat(e[0]),"".concat(e[3],".").concat(e[1],".").concat(e[2]),"".concat(e[3],".").concat(e[2],".").concat(e[0]),"".concat(e[3],".").concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[1],".").concat(e[2],".").concat(e[3]),"".concat(e[0],".").concat(e[1],".").concat(e[3],".").concat(e[2]),"".concat(e[0],".").concat(e[2],".").concat(e[1],".").concat(e[3]),"".concat(e[0],".").concat(e[2],".").concat(e[3],".").concat(e[1]),"".concat(e[0],".").concat(e[3],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[3],".").concat(e[2],".").concat(e[1]),"".concat(e[1],".").concat(e[0],".").concat(e[2],".").concat(e[3]),"".concat(e[1],".").concat(e[0],".").concat(e[3],".").concat(e[2]),"".concat(e[1],".").concat(e[2],".").concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[2],".").concat(e[3],".").concat(e[0]),"".concat(e[1],".").concat(e[3],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[3],".").concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[0],".").concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[0],".").concat(e[3],".").concat(e[1]),"".concat(e[2],".").concat(e[1],".").concat(e[0],".").concat(e[3]),"".concat(e[2],".").concat(e[1],".").concat(e[3],".").concat(e[0]),"".concat(e[2],".").concat(e[3],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[3],".").concat(e[1],".").concat(e[0]),"".concat(e[3],".").concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[3],".").concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[3],".").concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[3],".").concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[3],".").concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[3],".").concat(e[2],".").concat(e[1],".").concat(e[0])]}var Yre={};function Pss(e){if(e.length===0||e.length===1)return e;var t=e.join(".");return Yre[t]||(Yre[t]=Rss(e)),Yre[t]}function $ss(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,r=e.filter(function(a){return a!=="token"}),s=Pss(r);return s.reduce(function(a,i){return KE(KE({},a),n[i])},t)}function AQe(e){return e.join(" ")}function Mss(e,t){var n=0;return function(r){return n+=1,r.map(function(s,a){return S8t({node:s,stylesheet:e,useInlineStyles:t,key:"code-segment-".concat(n,"-").concat(a)})})}}function S8t(e){var t=e.node,n=e.stylesheet,r=e.style,s=r===void 0?{}:r,a=e.useInlineStyles,i=e.key,l=t.properties,c=t.type,u=t.tagName,d=t.value;if(c==="text")return d;if(u){var f=Mss(n,a),p;if(!a)p=KE(KE({},l),{},{className:AQe(l.className)});else{var h=Object.keys(n).reduce(function(b,w){return w.split(".").forEach(function(S){b.includes(S)||b.push(S)}),b},[]),m=l.className&&l.className.includes("token")?["token"]:[],g=l.className&&m.concat(l.className.filter(function(b){return!h.includes(b)}));p=KE(KE({},l),{},{className:AQe(g)||void 0,style:$ss(l.className,Object.assign({},l.style,s),n)})}var y=f(t.children);return Le.createElement(u,EO({key:i},p),y)}}const Dss=(function(e,t){var n=e.listLanguages();return n.indexOf(t)!==-1});var Lss=["language","children","style","customStyle","codeTagProps","useInlineStyles","showLineNumbers","showInlineLineNumbers","startingLineNumber","lineNumberContainerStyle","lineNumberStyle","wrapLines","wrapLongLines","lineProps","renderer","PreTag","CodeTag","code","astGenerator"];function RQe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function Sw(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?RQe(Object(n),!0).forEach(function(r){w8t(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):RQe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var Fss=/\n/g;function zss(e){return e.match(Fss)}function Bss(e){var t=e.lines,n=e.startingLineNumber,r=e.style;return t.map(function(s,a){var i=a+n;return Le.createElement("span",{key:"line-".concat(a),className:"react-syntax-highlighter-line-number",style:typeof r=="function"?r(i):r},"".concat(i,`
|
|
729
729
|
`))})}function Uss(e){var t=e.codeString,n=e.codeStyle,r=e.containerStyle,s=r===void 0?{float:"left",paddingRight:"10px"}:r,a=e.numberStyle,i=a===void 0?{}:a,l=e.startingLineNumber;return Le.createElement("code",{style:Object.assign({},n,s)},Bss({lines:t.replace(/\n$/,"").split(`
|
|
730
730
|
`),style:i,startingLineNumber:l}))}function qss(e){return"".concat(e.toString().length,".25em")}function k8t(e,t){return{type:"element",tagName:"span",properties:{key:"line-number--".concat(e),className:["comment","linenumber","react-syntax-highlighter-line-number"],style:t},children:[{type:"text",value:e}]}}function O8t(e,t,n){var r={display:"inline-block",minWidth:qss(n),paddingRight:"1em",textAlign:"right",userSelect:"none"},s=typeof e=="function"?e(t):e,a=Sw(Sw({},r),s);return a}function pF(e){var t=e.children,n=e.lineNumber,r=e.lineNumberStyle,s=e.largestLineNumber,a=e.showInlineLineNumbers,i=e.lineProps,l=i===void 0?{}:i,c=e.className,u=c===void 0?[]:c,d=e.showLineNumbers,f=e.wrapLongLines,p=e.wrapLines,h=p===void 0?!1:p,m=h?Sw({},typeof l=="function"?l(n):l):{};if(m.className=m.className?[].concat($ve(m.className.trim().split(/\s+/)),$ve(u)):u,n&&a){var g=O8t(r,n,s);t.unshift(k8t(n,g))}return f&d&&(m.style=Sw({display:"flex"},m.style)),{type:"element",tagName:"span",properties:m,children:t}}function _8t(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],r=0;r<e.length;r++){var s=e[r];if(s.type==="text")n.push(pF({children:[s],className:$ve(new Set(t))}));else if(s.children){var a=t.concat(s.properties.className);_8t(s.children,a).forEach(function(i){return n.push(i)})}}return n}function Vss(e,t,n,r,s,a,i,l,c){var u,d=_8t(e.value),f=[],p=-1,h=0;function m(_,C){var E=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return pF({children:_,lineNumber:C,lineNumberStyle:l,largestLineNumber:i,showInlineLineNumbers:s,lineProps:n,className:E,showLineNumbers:r,wrapLongLines:c,wrapLines:t})}function g(_,C){if(r&&C&&s){var E=O8t(l,C,i);_.unshift(k8t(C,E))}return _}function y(_,C){var E=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return t||E.length>0?m(_,C,E):g(_,C)}for(var b=function(){var C=d[h],E=C.children[0].value,j=zss(E);if(j){var N=E.split(`
|