@mastra/deployer-cloud 1.50.0-alpha.1 → 1.50.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./core-B6cOHeaZ.js","./engine-compile-BkERmzkH.js","./preload-helper-PPVm8Dsz.js","./engine-javascript-CSIo_1eZ.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./core-DsIK9rAU.js","./engine-compile-BkERmzkH.js","./preload-helper-PPVm8Dsz.js","./engine-javascript-CSIo_1eZ.js"])))=>i.map(i=>d[i]);
2
2
  import{_ as jo}from"./preload-helper-PPVm8Dsz.js";function O7t(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 Bj=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Tc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var fY={exports:{}},bA={};var ERe;function _7t(){if(ERe)return bA;ERe=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 bA.Fragment=t,bA.jsx=n,bA.jsxs=n,bA}var jRe;function C7t(){return jRe||(jRe=1,fY.exports=_7t()),fY.exports}var o=C7t(),pY={exports:{}},Br={},TRe;function E7t(){if(TRe)return Br;TRe=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(V){return V===null||typeof V!="object"?null:(V=h&&V[h]||V["@@iterator"],typeof V=="function"?V:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,b={};function S(V,$,U){this.props=V,this.context=$,this.refs=b,this.updater=U||v}S.prototype.isReactComponent={},S.prototype.setState=function(V,$){if(typeof V!="object"&&typeof V!="function"&&V!=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,V,$,"setState")},S.prototype.forceUpdate=function(V){this.updater.enqueueForceUpdate(this,V,"forceUpdate")};function w(){}w.prototype=S.prototype;function k(V,$,U){this.props=V,this.context=$,this.refs=b,this.updater=U||v}var _=k.prototype=new w;_.constructor=k,y(_,S.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(V,$,U){var Z=U.ref;return{$$typeof:t,type:V,key:$,ref:Z!==void 0?Z:null,props:U}}function R(V,$){return I(V.type,$,V.props)}function P(V){return typeof V=="object"&&V!==null&&V.$$typeof===t}function L(V){var $={"=":"=0",":":"=2"};return"$"+V.replace(/[=:]/g,function(U){return $[U]})}var M=/\/+/g;function q(V,$){return typeof V=="object"&&V!==null&&V.key!=null?L(""+V.key):$.toString(36)}function H(V){switch(V.status){case"fulfilled":return V.value;case"rejected":throw V.reason;default:switch(typeof V.status=="string"?V.then(E,E):(V.status="pending",V.then(function($){V.status==="pending"&&(V.status="fulfilled",V.value=$)},function($){V.status==="pending"&&(V.status="rejected",V.reason=$)})),V.status){case"fulfilled":return V.value;case"rejected":throw V.reason}}throw V}function F(V,$,U,Z,X){var te=typeof V;(te==="undefined"||te==="boolean")&&(V=null);var J=!1;if(V===null)J=!0;else switch(te){case"bigint":case"string":case"number":J=!0;break;case"object":switch(V.$$typeof){case t:case n:J=!0;break;case f:return J=V._init,F(J(V._payload),$,U,Z,X)}}if(J)return X=X(V),J=Z===""?"."+q(V,0):Z,C(X)?(U="",J!=null&&(U=J.replace(M,"$&/")+"/"),F(X,$,U,"",function(ce){return ce})):X!=null&&(P(X)&&(X=R(X,U+(X.key==null||V&&V.key===X.key?"":(""+X.key).replace(M,"$&/")+"/")+J)),$.push(X)),1;J=0;var ee=Z===""?".":Z+":";if(C(V))for(var ae=0;ae<V.length;ae++)Z=V[ae],te=ee+q(Z,ae),J+=F(Z,$,U,te,X);else if(ae=m(V),typeof ae=="function")for(V=ae.call(V),ae=0;!(Z=V.next()).done;)Z=Z.value,te=ee+q(Z,ae++),J+=F(Z,$,U,te,X);else if(te==="object"){if(typeof V.then=="function")return F(H(V),$,U,Z,X);throw $=String(V),Error("Objects are not valid as a React child (found: "+($==="[object Object]"?"object with keys {"+Object.keys(V).join(", ")+"}":$)+"). If you meant to render a collection of children, use an array instead.")}return J}function z(V,$,U){if(V==null)return V;var Z=[],X=0;return F(V,Z,"","",function(te){return $.call(U,te,X++)}),Z}function B(V){if(V._status===-1){var $=V._result;$=$(),$.then(function(U){(V._status===0||V._status===-1)&&(V._status=1,V._result=U)},function(U){(V._status===0||V._status===-1)&&(V._status=2,V._result=U)}),V._status===-1&&(V._status=0,V._result=$)}if(V._status===1)return V._result.default;throw V._result}var D=typeof reportError=="function"?reportError:function(V){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var $=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof V=="object"&&V!==null&&typeof V.message=="string"?String(V.message):String(V),error:V});if(!window.dispatchEvent($))return}else if(typeof e=="object"&&typeof e.emit=="function"){e.emit("uncaughtException",V);return}console.error(V)},Q={map:z,forEach:function(V,$,U){z(V,function(){$.apply(this,arguments)},U)},count:function(V){var $=0;return z(V,function(){$++}),$},toArray:function(V){return z(V,function($){return $})||[]},only:function(V){if(!P(V))throw Error("React.Children.only expected to receive a single React element child.");return V}};return Br.Activity=p,Br.Children=Q,Br.Component=S,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(V){return j.H.useMemoCache(V)}},Br.cache=function(V){return function(){return V.apply(null,arguments)}},Br.cacheSignal=function(){return null},Br.cloneElement=function(V,$,U){if(V==null)throw Error("The argument must be a React element, but you passed "+V+".");var Z=y({},V.props),X=V.key;if($!=null)for(te in $.key!==void 0&&(X=""+$.key),$)!N.call($,te)||te==="key"||te==="__self"||te==="__source"||te==="ref"&&$.ref===void 0||(Z[te]=$[te]);var te=arguments.length-2;if(te===1)Z.children=U;else if(1<te){for(var J=Array(te),ee=0;ee<te;ee++)J[ee]=arguments[ee+2];Z.children=J}return I(V.type,X,Z)},Br.createContext=function(V){return V={$$typeof:l,_currentValue:V,_currentValue2:V,_threadCount:0,Provider:null,Consumer:null},V.Provider=V,V.Consumer={$$typeof:i,_context:V},V},Br.createElement=function(V,$,U){var Z,X={},te=null;if($!=null)for(Z in $.key!==void 0&&(te=""+$.key),$)N.call($,Z)&&Z!=="key"&&Z!=="__self"&&Z!=="__source"&&(X[Z]=$[Z]);var J=arguments.length-2;if(J===1)X.children=U;else if(1<J){for(var ee=Array(J),ae=0;ae<J;ae++)ee[ae]=arguments[ae+2];X.children=ee}if(V&&V.defaultProps)for(Z in J=V.defaultProps,J)X[Z]===void 0&&(X[Z]=J[Z]);return I(V,te,X)},Br.createRef=function(){return{current:null}},Br.forwardRef=function(V){return{$$typeof:c,render:V}},Br.isValidElement=P,Br.lazy=function(V){return{$$typeof:f,_payload:{_status:-1,_result:V},_init:B}},Br.memo=function(V,$){return{$$typeof:d,type:V,compare:$===void 0?null:$}},Br.startTransition=function(V){var $=j.T,U={};j.T=U;try{var Z=V(),X=j.S;X!==null&&X(U,Z),typeof Z=="object"&&Z!==null&&typeof Z.then=="function"&&Z.then(E,D)}catch(te){D(te)}finally{$!==null&&U.types!==null&&($.types=U.types),j.T=$}},Br.unstable_useCacheRefresh=function(){return j.H.useCacheRefresh()},Br.use=function(V){return j.H.use(V)},Br.useActionState=function(V,$,U){return j.H.useActionState(V,$,U)},Br.useCallback=function(V,$){return j.H.useCallback(V,$)},Br.useContext=function(V){return j.H.useContext(V)},Br.useDebugValue=function(){},Br.useDeferredValue=function(V,$){return j.H.useDeferredValue(V,$)},Br.useEffect=function(V,$){return j.H.useEffect(V,$)},Br.useEffectEvent=function(V){return j.H.useEffectEvent(V)},Br.useId=function(){return j.H.useId()},Br.useImperativeHandle=function(V,$,U){return j.H.useImperativeHandle(V,$,U)},Br.useInsertionEffect=function(V,$){return j.H.useInsertionEffect(V,$)},Br.useLayoutEffect=function(V,$){return j.H.useLayoutEffect(V,$)},Br.useMemo=function(V,$){return j.H.useMemo(V,$)},Br.useOptimistic=function(V,$){return j.H.useOptimistic(V,$)},Br.useReducer=function(V,$,U){return j.H.useReducer(V,$,U)},Br.useRef=function(V){return j.H.useRef(V)},Br.useState=function(V){return j.H.useState(V)},Br.useSyncExternalStore=function(V,$,U){return j.H.useSyncExternalStore(V,$,U)},Br.useTransition=function(){return j.H.useTransition()},Br.version="19.2.6",Br}var NRe;function pN(){return NRe||(NRe=1,pY.exports=E7t()),pY.exports}var g=pN();const Le=Tc(g),hN=O7t({__proto__:null,default:Le},[g]);var hY={exports:{}},xA={},mY={exports:{}},gY={};var IRe;function j7t(){return IRe||(IRe=1,(function(e){function t(H,F){var z=H.length;H.push(F);e:for(;0<z;){var B=z-1>>>1,D=H[B];if(0<s(D,F))H[B]=F,H[z]=D,z=B;else break e}}function n(H){return H.length===0?null:H[0]}function r(H){if(H.length===0)return null;var F=H[0],z=H.pop();if(z!==F){H[0]=z;e:for(var B=0,D=H.length,Q=D>>>1;B<Q;){var V=2*(B+1)-1,$=H[V],U=V+1,Z=H[U];if(0>s($,z))U<D&&0>s(Z,$)?(H[B]=Z,H[U]=z,B=U):(H[B]=$,H[V]=z,B=V);else if(U<D&&0>s(Z,z))H[B]=Z,H[U]=z,B=U;else break e}}return F}function s(H,F){var z=H.sortIndex-F.sortIndex;return z!==0?z:H.id-F.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,v=!1,y=!1,b=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;function k(H){for(var F=n(u);F!==null;){if(F.callback===null)r(u);else if(F.startTime<=H)r(u),F.sortIndex=F.expirationTime,t(c,F);else break;F=n(u)}}function _(H){if(v=!1,k(H),!m)if(n(c)!==null)m=!0,C||(C=!0,P());else{var F=n(u);F!==null&&q(_,F.startTime-H)}}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 H=e.unstable_now();N=H;var F=!0;try{e:{m=!1,v&&(v=!1,S(E),E=-1),h=!0;var z=p;try{t:{for(k(H),f=n(c);f!==null&&!(f.expirationTime>H&&I());){var B=f.callback;if(typeof B=="function"){f.callback=null,p=f.priorityLevel;var D=B(f.expirationTime<=H);if(H=e.unstable_now(),typeof D=="function"){f.callback=D,k(H),F=!0;break t}f===n(c)&&r(c),k(H)}else r(c);f=n(c)}if(f!==null)F=!0;else{var Q=n(u);Q!==null&&q(_,Q.startTime-H),F=!1}}break e}finally{f=null,p=z,h=!1}F=void 0}}finally{F?P():C=!1}}}var P;if(typeof w=="function")P=function(){w(R)};else if(typeof MessageChannel<"u"){var L=new MessageChannel,M=L.port2;L.port1.onmessage=R,P=function(){M.postMessage(null)}}else P=function(){b(R,0)};function q(H,F){E=b(function(){H(e.unstable_now())},F)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(H){H.callback=null},e.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):j=0<H?Math.floor(1e3/H):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_next=function(H){switch(p){case 1:case 2:case 3:var F=3;break;default:F=p}var z=p;p=F;try{return H()}finally{p=z}},e.unstable_requestPaint=function(){y=!0},e.unstable_runWithPriority=function(H,F){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var z=p;p=H;try{return F()}finally{p=z}},e.unstable_scheduleCallback=function(H,F,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,H){case 1:var D=-1;break;case 2:D=250;break;case 5:D=1073741823;break;case 4:D=1e4;break;default:D=5e3}return D=z+D,H={id:d++,callback:F,priorityLevel:H,startTime:z,expirationTime:D,sortIndex:-1},z>B?(H.sortIndex=z,t(u,H),n(c)===null&&H===n(u)&&(v?(S(E),E=-1):v=!0,q(_,z-B))):(H.sortIndex=D,t(c,H),m||h||(m=!0,C||(C=!0,P()))),H},e.unstable_shouldYield=I,e.unstable_wrapCallback=function(H){var F=p;return function(){var z=p;p=F;try{return H.apply(this,arguments)}finally{p=z}}}})(gY)),gY}var ARe;function T7t(){return ARe||(ARe=1,mY.exports=j7t()),mY.exports}var vY={exports:{}},mu={};var RRe;function N7t(){if(RRe)return mu;RRe=1;var e=pN();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 mu.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,mu.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)},mu.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()}},mu.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))},mu.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},mu.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})}},mu.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)},mu.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})}},mu.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)},mu.requestFormReset=function(c){r.d.r(c)},mu.unstable_batchedUpdates=function(c,u){return c(u)},mu.useFormState=function(c,u,d){return i.H.useFormState(c,u,d)},mu.useFormStatus=function(){return i.H.useHostTransitionStatus()},mu.version="19.2.6",mu}var PRe;function frt(){if(PRe)return vY.exports;PRe=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(),vY.exports=N7t(),vY.exports}var $Re;function I7t(){if($Re)return xA;$Re=1;var e={env:{}};var t=T7t(),n=pN(),r=frt();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 W=T.return;if(W===null)break;var G=W.alternate;if(G===null){if(A=W.return,A!==null){T=A;continue}break}if(W.child===G.child){for(G=W.child;G;){if(G===T)return u(W),x;if(G===A)return u(W),O;G=G.sibling}throw Error(s(188))}if(T.return!==A.return)T=W,A=G;else{for(var ie=!1,we=W.child;we;){if(we===T){ie=!0,T=W,A=G;break}if(we===A){ie=!0,A=W,T=G;break}we=we.sibling}if(!ie){for(we=G.child;we;){if(we===T){ie=!0,T=G,A=W;break}if(we===A){ie=!0,A=G,T=W;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"),v=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),w=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"),P=Symbol.iterator;function L(x){return x===null||typeof x!="object"?null:(x=P&&x[P]||x["@@iterator"],typeof x=="function"?x:null)}var M=Symbol.for("react.client.reference");function q(x){if(x==null)return null;if(typeof x=="function")return x.$$typeof===M?null:x.displayName||x.name||null;if(typeof x=="string")return x;switch(x){case y:return"Fragment";case S: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 v:return"Portal";case k:return x.displayName||"Context";case w: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:q(x.type)||"Memo";case N:O=x._payload,x=x._init;try{return q(x(O))}catch{}}return null}var H=Array.isArray,F=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},D=[],Q=-1;function V(x){return{current:x}}function $(x){0>Q||(x.current=D[Q],D[Q]=null,Q--)}function U(x,O){Q++,D[Q]=x.current,x.current=O}var Z=V(null),X=V(null),te=V(null),J=V(null);function ee(x,O){switch(U(te,O),U(X,x),U(Z,null),O.nodeType){case 9:case 11:x=(x=O.documentElement)&&(x=x.namespaceURI)?YAe(x):0;break;default:if(x=O.tagName,O=O.namespaceURI)O=YAe(O),x=XAe(O,x);else switch(x){case"svg":x=1;break;case"math":x=2;break;default:x=0}}$(Z),U(Z,x)}function ae(){$(Z),$(X),$(te)}function ce(x){x.memoizedState!==null&&U(J,x);var O=Z.current,T=XAe(O,x.type);O!==T&&(U(X,x),U(Z,T))}function Y(x){X.current===x&&($(Z),$(X)),J.current===x&&($(J),mA._currentValue=B)}var ne,ue;function pe(x){if(ne===void 0)try{throw Error()}catch(T){var O=T.stack.trim().match(/\n( *(at )?)/);ne=O&&O[1]||"",ue=-1<T.stack.indexOf(`
3
3
  at`)?" (<anonymous>)":-1<T.stack.indexOf("@")?"@unknown:0:0":""}return`
4
4
  `+ne+x+ue}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(ft){var ct=ft}Reflect.construct(x,[],Ct)}else{try{Ct.call()}catch(ft){ct=ft}x.call(Ct.prototype)}}else{try{throw Error()}catch(ft){ct=ft}(Ct=x())&&typeof Ct.catch=="function"&&Ct.catch(function(){})}}catch(ft){if(ft&&ct&&typeof ft.stack=="string")return[ft.stack,ct.stack]}return[null,null]}};A.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var W=Object.getOwnPropertyDescriptor(A.DetermineComponentFrameRoot,"name");W&&W.configurable&&Object.defineProperty(A.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var G=A.DetermineComponentFrameRoot(),ie=G[0],we=G[1];if(ie&&we){var Be=ie.split(`
@@ -191,7 +191,7 @@ Error message: ${kot(n)}`,cause:n}),this[Aot]=!0,this.value=t}static isInstance(
191
191
  `)}):a=aon(e,t),{role:"user",content:a,...e.providerOptions?{providerOptions:e.providerOptions}:{}}}function oon(e,t){return{type:e.type==="user"?"data-user-message":"data-signal",data:{id:e.id,type:e.type,tagName:e.tagName,contents:vlt(t),createdAt:e.createdAt.toISOString(),...e.acceptedAt?{acceptedAt:e.acceptedAt.toISOString()}:{},...e.attributes?{attributes:e.attributes}:{},...e.metadata?{metadata:e.metadata}:{},...e.providerOptions?{providerOptions:e.providerOptions}:{}},transient:!0}}function lon(e,t,n){const r=t.length>0?t.map(s=>s.type==="file"?{type:"file",data:s.data,mimeType:s.mediaType,...s.filename?{filename:s.filename}:{},...s.providerOptions?{providerMetadata:s.providerOptions}:{}}:{type:"text",text:s.text,...s.providerOptions?{providerMetadata:s.providerOptions}:{}}):[{type:"text",text:""}];return{id:e.id,role:"signal",createdAt:e.createdAt,threadId:n?.threadId,resourceId:n?.resourceId,type:e.tagName,content:{format:2,parts:r,...e.providerOptions?{providerMetadata:e.providerOptions}:{},metadata:{signal:{id:e.id,type:e.type,tagName:e.tagName,createdAt:e.createdAt.toISOString(),...e.acceptedAt?{acceptedAt:e.acceptedAt.toISOString()}:{},...e.attributes?{attributes:e.attributes}:{},...e.metadata?{metadata:e.metadata}:{}}}}}}function nMe(e){return!e||typeof e!="object"||Array.isArray(e)?!1:e.__isCreatedSignal===!0}function ylt(e){const t=Xin(e),n=non(t.contents);return{...t,__isCreatedSignal:!0,toDBMessage:r=>lon(t,n,r),toLLMMessage:()=>ion(t,n),toDataPart:()=>oon(t,n)}}function con(e){const t=e.content.metadata?.signal,n=t&&typeof t=="object"&&!Array.isArray(t)?t:void 0,s=typeof n?.type=="string"?n.type:e.type??"user-message",a=typeof n?.tagName=="string"?n.tagName:void 0,i=n&&"contents"in n?n.contents:void 0,l=ton(i),c=vlt(ron(e.content.parts)),u=l??c,d=e.content.providerMetadata,f={id:typeof n?.id=="string"?n.id:e.id,createdAt:typeof n?.createdAt=="string"?n.createdAt:e.createdAt,acceptedAt:typeof n?.acceptedAt=="string"?n.acceptedAt:void 0,attributes:n?.attributes&&typeof n.attributes=="object"&&!Array.isArray(n.attributes)?n.attributes:void 0,metadata:n?.metadata&&typeof n.metadata=="object"&&!Array.isArray(n.metadata)?n.metadata:void 0,providerOptions:d&&typeof d=="object"&&!Array.isArray(d)?d:void 0};return ylt({...f,type:s,tagName:a,contents:u})}var Za=class ul{static isMastraDBMessage(t){return!!("content"in t&&t.content&&!Array.isArray(t.content)&&typeof t.content!="string"&&"format"in t.content&&t.content.format===2)}static isMastraMessageV1(t){return!ul.isMastraDBMessage(t)&&("threadId"in t||"resourceId"in t)}static isMastraMessage(t){return ul.isMastraDBMessage(t)||ul.isMastraMessageV1(t)}static isAIV4UIMessage(t){return!ul.isMastraMessage(t)&&!ul.isAIV4CoreMessage(t)&&"parts"in t&&!ul.hasAIV5UIMessageCharacteristics(t)}static isAIV6UIMessage(t){return!ul.isMastraMessage(t)&&!ul.isAIV4CoreMessage(t)&&"parts"in t&&ul.hasAIV6UIMessageCharacteristics(t)}static isAIV5UIMessage(t){return!ul.isMastraMessage(t)&&!ul.isAIV6UIMessage(t)&&!ul.isAIV5CoreMessage(t)&&"parts"in t&&ul.hasAIV5UIMessageCharacteristics(t)}static isAIV4CoreMessage(t){return!ul.isMastraMessage(t)&&!("parts"in t)&&"content"in t&&!ul.hasAIV5CoreMessageCharacteristics(t)}static isAIV6CoreMessage(t){return!ul.isMastraMessage(t)&&!("parts"in t)&&"content"in t&&ul.hasAIV6CoreMessageCharacteristics(t)}static isAIV5CoreMessage(t){return!ul.isMastraMessage(t)&&!ul.isAIV6CoreMessage(t)&&!("parts"in t)&&"content"in t&&ul.hasAIV5CoreMessageCharacteristics(t)}static hasAIV6UIMessageCharacteristics(t){if(!("parts"in t)||!t.parts)return!1;for(const n of t.parts)if(n.type==="source-document"||n.type==="dynamic-tool"||"toolCallId"in n&&"state"in n&&(n.state==="approval-requested"||n.state==="approval-responded"||n.state==="output-denied"))return!0;return!1}static hasAIV5UIMessageCharacteristics(t){if("toolInvocations"in t||"reasoning"in t||"experimental_attachments"in t||"data"in t||"annotations"in t||!t.parts)return!1;for(const n of t.parts){if("metadata"in n)return!0;if("toolInvocation"in n)return!1;if("toolCallId"in n)return!0;if(n.type==="source")return!1;if(n.type==="source-url")return!0;if(n.type==="reasoning"){if("state"in n||"text"in n)return!0;if("reasoning"in n||"details"in n)return!1}if(n.type==="file"&&"mediaType"in n)return!0}return!1}static hasAIV6CoreMessageCharacteristics(t){return"parts"in t||typeof t.content=="string"?!1:t.content.some(n=>n.type==="tool-approval-request"||n.type==="tool-approval-response")}static hasAIV5CoreMessageCharacteristics(t){if("experimental_providerMetadata"in t)return!1;if(typeof t.content=="string")return!0;for(const n of t.content){if(n.type==="tool-result"&&"output"in n||n.type==="tool-call"&&"input"in n)return!0;if(n.type==="tool-result"&&"result"in n||n.type==="tool-call"&&"args"in n)return!1;if("mediaType"in n)return!0;if("mimeType"in n||"experimental_providerMetadata"in n||n.type==="reasoning"&&"signature"in n||n.type==="redacted-reasoning")return!1}return!0}static getRole(t){if(t.role==="assistant"||t.role==="tool")return"assistant";if(t.role==="user")return"user";if(t.role==="system")return"system";throw new Error(`BUG: add handling for message role ${t.role} in message ${JSON.stringify(t,null,2)}`)}};function iz(e){if(!e.startsWith("data:"))return{isDataUri:!1,base64Content:e};const t=e.indexOf(",");if(t===-1)return{isDataUri:!0,base64Content:e};const n=e.substring(5,t),r=e.substring(t+1),s=n.indexOf(";");return{isDataUri:!0,mimeType:(s!==-1?n.substring(0,s):n)||void 0,base64Content:r}}function Xye(e,t="application/octet-stream"){return e.startsWith("data:")?e:`data:${t};base64,${e}`}function uon(e,t){return typeof e=="string"?e:e instanceof URL?e.toString():e instanceof Uint8Array||e instanceof ArrayBuffer||globalThis.Buffer&&Buffer.isBuffer(e)?cO(e):String(e)}function rMe(e){return e instanceof URL?e.toString():typeof e=="string"?e.length:e instanceof Uint8Array||e instanceof ArrayBuffer?e.byteLength:e}function don(e){try{return new URL(e),!0}catch{if(e.startsWith("//"))try{return new URL(`https:${e}`),!0}catch{return!1}return!1}}function BP(e,t){const n=iz(e),r=n.isDataUri&&n.mimeType?n.mimeType:t;return n.isDataUri?{type:"dataUri",mimeType:r,data:e}:don(e)?{type:"url",mimeType:r,data:e}:{type:"raw",mimeType:r,data:e}}var fon=["openai","azure"];function blt(e,t){return`${e}:${t}`}function pon(e){return xlt(e)[0]}function sMe(e){const t=pon(e);return t?blt(t.provider,t.itemId):void 0}function xlt(e){if(!e)return[];const n=e.azure?.itemId,s=e.openai?.itemId;return typeof n=="string"&&n===s?[{provider:"azure",itemId:n}]:fon.flatMap(a=>{const l=e[a]?.itemId;return typeof l=="string"?[{provider:a,itemId:l}]:[]})}function hon(e){return xlt(e).map(({provider:t,itemId:n})=>blt(t,n))}function vL(e,t){const n=[...e],r=n.findIndex(s=>s.role!=="system");return r===-1?n.length>0&&t?.warn("No user or assistant messages in the request. Some providers (e.g. Gemini) require at least one user message to generate a response."):n[r]?.role==="assistant"&&n.splice(r,0,{role:"user",content:"."}),n}function mon(e,t){return e.map(n=>von(n,t))}function gon(e){const t=e.map(r=>Array.isArray(r.content)?[...r.content]:null);for(let r=0;r<e.length;r++){const s=e[r];if(s.role==="assistant"&&Array.isArray(s.content)){const a=new Set,i=new Set;for(const d of s.content)d.type==="tool-call"?a.add(d.toolCallId):d.type==="tool-result"&&i.add(d.toolCallId);const l=e[r+1],c=new Set;if(l&&l.role==="tool"&&Array.isArray(l.content))for(const d of l.content)d.type==="tool-result"&&c.add(d.toolCallId);const u=new Set([...a].filter(d=>i.has(d)||c.has(d)));t[r]=t[r].filter(d=>{if(d.type!=="tool-call")return!0;const f=d;return f.providerExecuted===!0||u.has(f.toolCallId)}),l&&l.role==="tool"&&Array.isArray(l.content)&&(t[r+1]=t[r+1].filter(d=>d.type!=="tool-result"||u.has(d.toolCallId)))}else if(s.role==="tool"&&Array.isArray(s.content)){const a=e[r-1];(!a||a.role!=="assistant"||!Array.isArray(a.content))&&(t[r]=t[r].filter(i=>i.type!=="tool-result"))}}const n=[];for(let r=0;r<e.length;r++){const s=e[r],a=t[r];if(a==null){n.push(s);continue}if(a.length!==0){if(Array.isArray(s.content)&&a.length===s.content.length){n.push(s);continue}n.push({...s,content:a})}}return n}function von(e,t){return e.role!=="tool"||!Array.isArray(e.content)?e:{...e,content:e.content.map(n=>n.type==="tool-result"?{...n,input:iq(t,n.toolCallId)}:n)}}function iq(e,t){for(let n=e.length-1;n>=0;n--){const r=e[n];if(!(!r||r.role!=="assistant")){if(r.content.parts){const s=r.content.parts.find(a=>a.type==="tool-invocation"&&a.toolInvocation.toolCallId===t);if(s&&s.type==="tool-invocation"){const a=s.toolInvocation.args||{};if(typeof a=="object"&&Object.keys(a).length>0)return a}}if(r.content.toolInvocations){const s=r.content.toolInvocations.find(a=>a.toolCallId===t);if(s){const a=s.args||{};if(typeof a=="object"&&Object.keys(a).length>0)return a}}}}return{}}function oj(e,t,n,r=!0){if(!r)return n;const s=eg(e,"display",t);return wu(s)?s.transformed:n}function yon(e,t,n){return{...e,args:oj(t,"input-available",e.args,n),...e.state==="result"?{result:oj(t,"output-available",oj(t,"error",e.result,n),n)}:{}}}function aMe(e){return e.some(n=>!(n.type==="text"&&n.text===""))?e.filter(n=>n.type==="text"?n.text!=="":!0):e}function Kye(e){const t=e.content.metadata?.signal;if(t&&typeof t=="object"&&!Array.isArray(t)){const n=t.type;return typeof n=="string"?n:e.type}return e.type}function bon(e){const t=e.content.metadata?.signal;if(t&&typeof t=="object"&&!Array.isArray(t)){const r=t.tagName;if(typeof r=="string")return r}const n=Kye(e);return n==="user"?"user":n==="reactive"?e.type:n}function xon(e){return e==="user"||e==="user-message"}function won(e,t){const n=e.content.metadata?.signal&&typeof e.content.metadata.signal=="object"?e.content.metadata.signal:{},r=n.metadata&&typeof n.metadata=="object"&&!Array.isArray(n.metadata)?n.metadata:{},s=n.attributes&&typeof n.attributes=="object"&&!Array.isArray(n.attributes)?n.attributes:{},a=Kye(e)??"signal",i=bon(e)??a;return{type:a==="user"?"data-user-message":"data-signal",data:{id:typeof n.id=="string"?n.id:e.id,type:a,tagName:i,contents:"contents"in n?n.contents:t,createdAt:typeof n.createdAt=="string"?n.createdAt:e.createdAt.toISOString(),...typeof n.acceptedAt=="string"?{acceptedAt:n.acceptedAt}:{},...Object.keys(s).length?{attributes:s}:{},...Object.keys(r).length?{metadata:r}:{}}}}var Ew=class{static toUIMessage(e,t){const n=t?.transformToolPayloads??!0,r=e.content.experimental_attachments?[...e.content.experimental_attachments]:[],s=typeof e.content.content=="string"&&e.content.content!==""?e.content.content:(e.content.parts??[]).reduce((f,p)=>p.type==="text"?p.text:f,""),a=[],i=e.content.parts??[];if(i.length)for(const f of i)if(f.type==="file"){let p;typeof f.data=="string"&&BP(f.data,f.mimeType).type==="raw"?p=Xye(f.data,f.mimeType||"application/octet-stream"):p=f.data,r.push({contentType:f.mimeType,url:p})}else{if(f.type==="tool-invocation"&&(f.toolInvocation.state==="call"||f.toolInvocation.state==="partial-call"))continue;if(f.type==="tool-invocation"){const p=f.toolInvocation.state==="output-denied",h={...f.toolInvocation,...p?{state:"result"}:{},args:oj(f.providerMetadata,"input-available",f.toolInvocation.args,n),...f.toolInvocation.state==="result"?{result:oj(f.providerMetadata,"output-available",oj(f.providerMetadata,"error",f.toolInvocation.result,n),n)}:p?{result:f.toolInvocation.approval?.reason??"Tool call was not approved by the user"}:{}};let m=-1,v=-1;for(const y of i)if(y.type==="step-start"&&m++,y.type==="tool-invocation"&&y.toolInvocation.toolCallId===f.toolInvocation.toolCallId){v=m;break}if(v>=0){const y={step:v,...h};a.push({type:"tool-invocation",toolInvocation:y})}else a.push({type:"tool-invocation",toolInvocation:h})}else a.push(f)}a.length===0&&r.length>0&&a.push({type:"text",text:""});const l=e.role==="signal"?Kye(e):void 0,c=xon(l),u=e.role==="signal"&&!c?[won(e,e.content.content||s)]:a;if(e.role==="user"){const f={id:e.id,role:e.role,content:e.content.content||s,createdAt:e.createdAt,parts:u,experimental_attachments:r};return e.content.metadata&&(f.metadata=e.content.metadata),f}else if(e.role==="assistant"){const f=Array.isArray(e.content.content)&&e.content.content.length===1&&e.content.content[0].type==="text",p={id:e.id,role:e.role,content:f?s:e.content.content||s,createdAt:e.createdAt,parts:u,reasoning:void 0,toolInvocations:"toolInvocations"in e.content?e.content.toolInvocations?.filter(h=>h.state==="result").map(h=>{const m=e.content.parts?.find(v=>v.type==="tool-invocation"&&v.toolInvocation.toolCallId===h.toolCallId)?.providerMetadata;return yon(h,m,n)}):void 0};return e.content.metadata&&(p.metadata=e.content.metadata),p}const d={id:e.id,role:e.role==="signal"?c?"user":"system":e.role,content:e.role==="signal"&&!c?"":e.content.content||s,createdAt:e.createdAt,parts:u,experimental_attachments:r};return e.content.metadata&&(d.metadata=e.content.metadata),d}static systemToV4Core(e){if(e.role!=="system"||!e.content.content)throw new sO({id:"INVALID_SYSTEM_MESSAGE_FORMAT",domain:Hw.AGENT,category:Ww.USER,text:"Invalid system message format. System messages must include 'role' and 'content' properties. The content should be a string.",details:{receivedMessage:JSON.stringify(e,null,2)}});const t={role:"system",content:e.content.content};return e.content.providerMetadata&&(t.experimental_providerMetadata=e.content.providerMetadata),t}static fromUIMessage(e,t,n){const s={format:2,parts:e.parts?aMe(e.parts):[]};return e.toolInvocations&&(s.toolInvocations=e.toolInvocations),e.reasoning&&(s.reasoning=e.reasoning),e.annotations&&(s.annotations=e.annotations),e.experimental_attachments&&(s.experimental_attachments=e.experimental_attachments),"metadata"in e&&e.metadata!==null&&e.metadata!==void 0&&(s.metadata=e.metadata),{id:e.id||t.newMessageId(),role:Za.getRole(e),createdAt:t.generateCreatedAt(n,e.createdAt),threadId:t.memoryInfo?.threadId,resourceId:t.memoryInfo?.resourceId,content:s}}static fromCoreMessage(e,t,n){const r="id"in e?e.id:t.newMessageId(),s=[],a=[],i=[],l=n==="response"&&Array.isArray(e.content)&&e.content.length===1&&e.content[0]&&e.content[0].type==="text"&&"text"in e.content[0]&&e.content[0].text;if(l&&n==="response"&&(e.content=l),typeof e.content=="string")s.push({type:"text",text:e.content});else if(Array.isArray(e.content))for(const f of e.content)switch(f.type){case"text":{const p=s.at(-1);e.role==="assistant"&&p&&p.type==="tool-invocation"&&s.push({type:"step-start"});const h={type:"text",text:f.text};f.providerOptions&&(h.providerMetadata=f.providerOptions),s.push(h);break}case"tool-call":{const p={type:"tool-invocation",toolInvocation:{state:"call",toolCallId:f.toolCallId,toolName:f.toolName,args:f.args}};f.providerOptions&&(p.providerMetadata=f.providerOptions),s.push(p);break}case"tool-result":{let p={};const h=e.content.find(y=>y.type==="tool-call"&&y.toolCallId===f.toolCallId);h&&h.type==="tool-call"&&(p=h.args),Object.keys(p).length===0&&t.dbMessages&&(p=iq(t.dbMessages,f.toolCallId));const m={state:"result",toolCallId:f.toolCallId,toolName:f.toolName,result:f.result??"",args:p},v={type:"tool-invocation",toolInvocation:m};f.providerOptions&&(v.providerMetadata=f.providerOptions),s.push(v),i.push(m)}break;case"reasoning":{const p={type:"reasoning",reasoning:f.text,details:[{type:"text",text:f.text,signature:f.signature}]};f.providerOptions&&(p.providerMetadata=f.providerOptions),s.push(p)}break;case"redacted-reasoning":{const p={type:"reasoning",reasoning:"",details:[{type:"redacted",data:f.data}]};f.providerOptions&&(p.providerMetadata=f.providerOptions),s.push(p)}break;case"image":{const p={type:"file",data:uon(f.image),mimeType:f.mimeType};f.providerOptions&&(p.providerMetadata=f.providerOptions),s.push(p);break}case"file":{if(f.data instanceof URL){const p={type:"file",data:f.data.toString(),mimeType:f.mimeType};f.providerOptions&&(p.providerMetadata=f.providerOptions),f.filename&&(p.filename=f.filename),s.push(p)}else if(typeof f.data=="string"){const p=BP(f.data,f.mimeType);if(p.type==="url"||p.type==="dataUri"){const h={type:"file",data:f.data,mimeType:p.mimeType||"image/png"};f.providerOptions&&(h.providerMetadata=f.providerOptions),f.filename&&(h.filename=f.filename),s.push(h)}else try{const h={type:"file",mimeType:p.mimeType||"image/png",data:cO(f.data)};f.providerOptions&&(h.providerMetadata=f.providerOptions),f.filename&&(h.filename=f.filename),s.push(h)}catch(h){console.error(`Failed to convert binary data to base64 in CoreMessage file part: ${h}`,h)}}else try{const p={type:"file",mimeType:f.mimeType,data:cO(f.data)};f.providerOptions&&(p.providerMetadata=f.providerOptions),f.filename&&(p.filename=f.filename),s.push(p)}catch(p){console.error(`Failed to convert binary data to base64 in CoreMessage file part: ${p}`,p)}break}}const u={format:2,parts:aMe(s)};i.length&&(u.toolInvocations=i),typeof e.content=="string"&&(u.content=e.content),a.length&&(u.experimental_attachments=a),e.providerOptions?u.providerMetadata=e.providerOptions:"experimental_providerMetadata"in e&&e.experimental_providerMetadata&&(u.providerMetadata=e.experimental_providerMetadata),"metadata"in e&&e.metadata!==null&&e.metadata!==void 0&&(u.metadata=e.metadata);const d="metadata"in e&&e.metadata&&typeof e.metadata=="object"&&"createdAt"in e.metadata?e.metadata.createdAt:void 0;return{id:r,role:Za.getRole(e),createdAt:t.generateCreatedAt(n,d),threadId:t.memoryInfo?.threadId,resourceId:t.memoryInfo?.resourceId,content:u}}},Son=/^[a-zA-Z0-9_-]+$/,iMe="unknown_tool";function Xc(e){return typeof e!="string"?iMe:Son.test(e)?e:iMe}function oMe(e){return e.some(n=>!(n.type==="text"&&n.text===""))?e.filter(n=>n.type==="text"?n.text!=="":!0):e}function Jye(e){const t=e.content.metadata?.signal;if(t&&typeof t=="object"&&!Array.isArray(t)){const n=t.type;return typeof n=="string"?n:e.type}return e.type}function kon(e){const t=e.content.metadata?.signal;if(t&&typeof t=="object"&&!Array.isArray(t)){const r=t.tagName;if(typeof r=="string")return r}const n=Jye(e);return n==="user"?"user":n==="reactive"?e.type:n}function Oon(e){return e==="user"||e==="user-message"}function _on(e){return typeof e.content.content=="string"?e.content.content:e.content.parts.find(t=>t.type==="text")?.text??""}function Con(e){const t=e.content.metadata?.signal&&typeof e.content.metadata.signal=="object"?e.content.metadata.signal:{},n=t.metadata&&typeof t.metadata=="object"&&!Array.isArray(t.metadata)?t.metadata:{},r=t.attributes&&typeof t.attributes=="object"&&!Array.isArray(t.attributes)?t.attributes:{},s=Jye(e)??"signal",a=kon(e)??s;return{type:s==="user"?"data-user-message":"data-signal",data:{id:typeof t.id=="string"?t.id:e.id,type:s,tagName:a,contents:"contents"in t?t.contents:_on(e),createdAt:typeof t.createdAt=="string"?t.createdAt:e.createdAt.toISOString(),...typeof t.acceptedAt=="string"?{acceptedAt:t.acceptedAt}:{},...Object.keys(r).length?{attributes:r}:{},...Object.keys(n).length?{metadata:n}:{}}}}function lMe(e){return typeof e=="object"&&e&&"type"in e&&(e=e.type),typeof e!="string"?Xc(e):e==="dynamic-tool"?"dynamic-tool":e.startsWith("tool-")?Xc(e.slice(5)):Xc(e)}function cb(e,t){return t==null?e:{...e||{},mastra:{...(e||{}).mastra||{},createdAt:t}}}function Wf(e){const t=e?.mastra;if(!t||typeof t!="object")return;const n=t.createdAt;return typeof n=="number"?n:void 0}function OS(e,t,n,r=!0){if(!r)return n;const s=eg(e,"display",t);return wu(s)?s.transformed:n}function tX(e,t,n=!0){if(!n||!e||typeof e!="object")return e;const r=e,s=r.metadata??r.providerMetadata,a=eg(s,"display",t),i=eg(s,"display","input-available"),l=t==="approval"?wu(a)?a.transformed:wu(i)?i.transformed:void 0:wu(i)?i.transformed:wu(a)?a.transformed:void 0,c=t==="suspend"&&wu(a)?a.transformed:void 0;return{...r,...l!==void 0?{args:l}:{},...c!==void 0?{suspendPayload:c}:{}}}var Av=class{static toUIMessage(e,t){const n=e.role==="signal"?Jye(e):void 0,r=Oon(n),s=t?.transformToolPayloads??!0,a=[],i={...e.content.metadata||{}};if(e.role==="signal"&&!r&&a.push(Con(e)),e.createdAt&&(i.createdAt=e.createdAt),e.threadId&&(i.threadId=e.threadId),e.resourceId&&(i.resourceId=e.resourceId),e.content.providerMetadata&&(i.providerMetadata=e.content.providerMetadata),e.role==="signal"&&!r)return{id:e.id,role:"system",metadata:i,parts:a};const l=e.content.parts?.some(y=>y.type==="tool-invocation");if(e.content.toolInvocations&&!l)for(const y of e.content.toolInvocations)y.state==="result"?a.push({type:`tool-${y.toolName}`,toolCallId:y.toolCallId,state:"output-available",input:y.args,output:y.result}):a.push({type:`tool-${y.toolName}`,toolCallId:y.toolCallId,state:y.state==="call"?"input-available":"input-streaming",input:y.args});const c=e.content.parts?.some(y=>y.type==="reasoning"),u=e.content.parts?.some(y=>y.type==="file");e.content.reasoning&&!c&&a.push({type:"reasoning",text:e.content.reasoning});const d=new Set;if(e.content.experimental_attachments&&!u)for(const y of e.content.experimental_attachments)d.add(y.url),a.push({type:"file",url:y.url,mediaType:y.contentType||"unknown"});let f=!1;if(e.content.parts)for(const y of e.content.parts){if(y.type==="tool-invocation"&&y.toolInvocation){const b=y.toolInvocation;b.state==="result"?a.push({type:`tool-${b.toolName}`,toolCallId:b.toolCallId,input:OS(y.providerMetadata,"input-available",b.args,s),output:OS(y.providerMetadata,"output-available",OS(y.providerMetadata,"error",b.result,s),s),state:"output-available",callProviderMetadata:cb(y.providerMetadata,y.createdAt),providerExecuted:y.providerExecuted}):b.state==="output-error"?a.push({type:`tool-${b.toolName}`,toolCallId:b.toolCallId,input:OS(y.providerMetadata,"input-available",b.args,s),errorText:OS(y.providerMetadata,"error",b.errorText||"",s),state:"output-error",callProviderMetadata:cb(y.providerMetadata,y.createdAt),providerExecuted:y.providerExecuted}):b.state==="output-denied"?a.push({type:`tool-${b.toolName}`,toolCallId:b.toolCallId,input:OS(y.providerMetadata,"input-available",b.args,s),output:b.approval?.reason??"Tool call was not approved by the user",state:"output-available",callProviderMetadata:cb(y.providerMetadata,y.createdAt),providerExecuted:y.providerExecuted}):a.push({type:`tool-${b.toolName}`,toolCallId:b.toolCallId,input:OS(y.providerMetadata,"input-available",b.args,s),state:"input-available",callProviderMetadata:cb(y.providerMetadata,y.createdAt),providerExecuted:y.providerExecuted});continue}if(y.type==="reasoning"){const b=y.reasoning||(y.details?.reduce((S,w)=>w.type==="text"&&w.text?S+w.text:S,"")??"");if(b||y.details?.length){const S={type:"reasoning",text:b||"",state:"done"};S.providerMetadata=cb(y.providerMetadata,y.createdAt),a.push(S)}continue}if(!(y.type==="tool-invocation"||y.type.startsWith("tool-")))if(y.type==="file"){if(typeof y.data=="string"&&d.has(y.data))continue;const b=typeof y.data=="string"?BP(y.data,y.mimeType):{type:"raw",mimeType:y.mimeType};if(b.type==="url"&&typeof y.data=="string"){const S={type:"file",url:y.data,mediaType:b.mimeType||"image/png"};S.providerMetadata=cb(y.providerMetadata,y.createdAt),a.push(S)}else{let S,w=y.mimeType;if(typeof y.data=="string"){const E=iz(y.data);E.isDataUri?(S=E.base64Content,E.mimeType&&(w=w||E.mimeType)):S=y.data}else S=y.data;const k=w||"image/png";let _;typeof S=="string"&&S.startsWith("data:")?_=S:_=Xye(S,k);const C={type:"file",url:_,mediaType:k};C.providerMetadata=cb(y.providerMetadata,y.createdAt),a.push(C)}}else if(y.type==="source"){const b={type:"source-url",url:y.source.url,sourceId:y.source.id,title:y.source.title};b.providerMetadata=cb(y.providerMetadata,y.createdAt),a.push(b)}else{if(y.type==="source-document")continue;if(y.type==="text"){const b={type:"text",text:y.text};b.providerMetadata=cb(y.providerMetadata,y.createdAt),a.push(b),f=!0}else y.type==="data-tool-call-suspended"||y.type==="data-tool-call-approval"?a.push({...y,data:tX(y.data,y.type==="data-tool-call-suspended"?"suspend":"approval",s)}):(a.push(y),f=!0)}}e.content.content&&!f&&a.push({type:"text",text:e.content.content});const p=new Set(a.filter(y=>y.type==="data-tool-call-suspended"||y.type==="data-tool-call-approval").map(y=>{const b=y.data;return typeof b?.toolCallId=="string"?b.toolCallId:void 0}).filter(y=>typeof y=="string")),h=(y,b)=>{const S=a.findIndex(w=>w.type.startsWith("tool-")&&w.toolCallId===y);if(S===-1){a.push(b);return}a.splice(S+1,0,b)},m=i.suspendedTools;if(m&&typeof m=="object")for(const y of Object.values(m)){if(!y||typeof y!="object")continue;const b="toolCallId"in y?y.toolCallId:void 0;typeof b!="string"||p.has(b)||(h(b,{type:"data-tool-call-suspended",data:tX(y,"suspend",s)}),p.add(b))}const v=i.pendingToolApprovals;if(v&&typeof v=="object")for(const y of Object.values(v)){if(!y||typeof y!="object")continue;const b="toolCallId"in y?y.toolCallId:void 0;typeof b!="string"||p.has(b)||(h(b,{type:"data-tool-call-approval",data:tX(y,"approval",s)}),p.add(b))}return{id:e.id,role:e.role==="signal"?r?"user":"system":e.role,metadata:i,parts:a}}static fromUIMessage(e){const{parts:t,metadata:n}=e,r=n||{},s=r.createdAt,a=s?typeof s=="string"?new Date(s):s instanceof Date?s:new Date:new Date,i=r.threadId,l=r.resourceId,c={...r};delete c.createdAt,delete c.threadId,delete c.resourceId;const u=t.filter(w=>Cp(w)),d=t.filter(w=>w.type==="reasoning"),f=t.filter(w=>w.type==="file"),p=t.filter(w=>w.type==="text");let h;u.length>0&&(h=u.map(w=>{const k=lMe(w);return w.state==="output-available"?{args:w.input,result:typeof w.output=="object"&&w.output&&"value"in w.output?w.output.value:w.output,toolCallId:w.toolCallId,toolName:k,state:"result"}:{args:w.input,toolCallId:w.toolCallId,toolName:k,state:"call"}}));let m;d.length>0&&(m=d.map(w=>w.text).join(`
192
192
  `));let v;f.length>0&&(v=f.map(w=>({url:w.url||"",contentType:w.mediaType})));let y;p.length>0&&(y=p.map(w=>w.text).join(""));const b=t.map(w=>{if(Cp(w)){const k=lMe(w),_="callProviderMetadata"in w?w.callProviderMetadata:void 0;return w.state==="output-available"?{type:"tool-invocation",toolInvocation:{toolCallId:w.toolCallId,toolName:k,args:w.input,result:typeof w.output=="object"&&w.output&&"value"in w.output?w.output.value:w.output,state:"result"},providerMetadata:_,createdAt:Wf(_)}:{type:"tool-invocation",toolInvocation:{toolCallId:w.toolCallId,toolName:k,args:w.input,state:"call"},providerMetadata:_,createdAt:Wf(_)}}return w.type==="reasoning"?{type:"reasoning",reasoning:w.text,details:[{type:"text",text:w.text}],providerMetadata:w.providerMetadata,createdAt:Wf(w.providerMetadata)}:w.type==="file"?{type:"file",mimeType:w.mediaType,data:w.url||"",providerMetadata:w.providerMetadata,createdAt:Wf(w.providerMetadata),...w.filename?{filename:w.filename}:{}}:w.type==="source-url"?{type:"source",source:{url:w.url,sourceType:"url",id:w.url,providerMetadata:w.providerMetadata},providerMetadata:w.providerMetadata,createdAt:Wf(w.providerMetadata)}:w.type==="text"?{type:"text",text:w.text,providerMetadata:w.providerMetadata,createdAt:Wf(w.providerMetadata)}:w.type==="step-start"?w:typeof w.type=="string"&&w.type.startsWith("data-")?{type:w.type,data:"data"in w?w.data:void 0}:null}).filter(w=>w!==null),S=oMe(b);return{id:e.id,role:e.role,createdAt:a,threadId:i,resourceId:l,content:{format:2,parts:S,toolInvocations:h,reasoning:m,experimental_attachments:v,content:y,metadata:Object.keys(c).length>0?c:void 0}}}static getDataStringFromAIV5DataPart(e){let t,n;if("data"in e)t=e.mediaType||"application/octet-stream",n=e.data;else if("image"in e)t=e.mediaType||"image/jpeg",n=e.image;else{if("url"in e&&typeof e.url=="string")return e.url;throw new sO({id:"MASTRA_AIV5_DATA_PART_INVALID",domain:Hw.AGENT,category:Ww.USER,text:"Invalid AIV5 data part in getDataStringFromAIV5DataPart",details:{part:e}})}if(n instanceof URL)return n.toString();if(n instanceof Buffer){const r=n.toString("base64");return`data:${t};base64,${r}`}else{if(typeof n=="string")return n.startsWith("data:")||n.startsWith("http")?n:`data:${t};base64,${n}`;if(n instanceof Uint8Array){const r=Buffer.from(n).toString("base64");return`data:${t};base64,${r}`}else if(n instanceof ArrayBuffer){const r=Buffer.from(n).toString("base64");return`data:${t};base64,${r}`}else return""}}static fromModelMessage(e,t,n={}){const r=Array.isArray(e.content)?e.content:[{type:"text",text:e.content}],s=[],a=[],i=[],l=[];for(const h of r)if(h.type==="text"){const m={type:"text",text:h.text};h.providerOptions&&(m.providerMetadata=h.providerOptions,m.createdAt=Wf(h.providerOptions)),s.push(m)}else if(h.type==="tool-call"){const m=h,v={type:"tool-invocation",toolInvocation:{toolCallId:m.toolCallId,toolName:Xc(m.toolName),args:m.input,state:"call"}};h.providerOptions&&(v.providerMetadata=h.providerOptions,v.createdAt=Wf(h.providerOptions)),s.push(v),a.push({toolCallId:m.toolCallId,toolName:Xc(m.toolName),args:m.input,state:"call"})}else if(h.type==="tool-result"){const m=h,v=a.find(k=>k.toolCallId===m.toolCallId),y=s.find(k=>k.type==="tool-invocation"&&"toolInvocation"in k&&k.toolInvocation.toolCallId===m.toolCallId),b=(k,_)=>{_.state="result",_.result=typeof k.output=="object"&&k.output&&"value"in k.output?k.output.value:k.output},S=n.dbMessages?iq(n.dbMessages,m.toolCallId):void 0,w=S&&Object.keys(S).length>0?S:m.input??{};if(v)b(m,v);else{const k={state:"call",toolCallId:m.toolCallId,toolName:Xc(m.toolName),args:w};b(m,k),a.push(k)}if(y&&y.type==="tool-invocation")b(m,y.toolInvocation),m.providerOptions&&(y.providerMetadata=m.providerOptions,y.createdAt=Wf(m.providerOptions)??y.createdAt);else{const k={type:"tool-invocation",toolInvocation:{toolCallId:m.toolCallId,toolName:Xc(m.toolName),args:w,state:"call"}};b(m,k.toolInvocation),m.providerOptions&&(k.providerMetadata=m.providerOptions,k.createdAt=Wf(m.providerOptions)),s.push(k)}}else if(h.type==="reasoning"){const m={type:"reasoning",reasoning:h.text,details:[{type:"text",text:h.text}]};h.providerOptions&&(m.providerMetadata=h.providerOptions,m.createdAt=Wf(h.providerOptions)),s.push(m),i.push(h.text)}else if(h.type==="image"){const m=h,v=m.mediaType||"image/jpeg",y=this.getDataStringFromAIV5DataPart(m),b={type:"file",data:y,mimeType:v};h.providerOptions&&(b.providerMetadata=h.providerOptions,b.createdAt=Wf(h.providerOptions)),s.push(b),l.push({url:y,contentType:v})}else if(h.type==="file"){const m=h,v=m.mediaType||"application/octet-stream",y=this.getDataStringFromAIV5DataPart(m),b={type:"file",data:y,mimeType:v};h.providerOptions&&(b.providerMetadata=h.providerOptions,b.createdAt=Wf(h.providerOptions)),m.filename&&(b.filename=m.filename),s.push(b),l.push({url:y,contentType:v})}const c=oMe(s),u=c.filter(h=>h.type==="text").map(h=>h.text).join(`
193
193
  `),d="metadata"in e&&e.metadata!==null&&e.metadata!==void 0?e.metadata:{},p={id:"id"in e&&typeof e.id=="string"?e.id:`msg-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,role:e.role==="tool"?"assistant":e.role,createdAt:new Date,content:{format:2,parts:c,toolInvocations:a.length>0?a:void 0,reasoning:i.length>0?i.join(`
194
- `):void 0,experimental_attachments:l.length>0?l:void 0,content:u||void 0,metadata:Object.keys(d).length>0?d:void 0}};return e.providerOptions&&(p.content.providerMetadata=e.providerOptions),p}};function id(e,t){for(const[n,r]of Object.entries(t))r!==void 0&&(e[n]=r);return e}function tv(e,t,n){const r=eg(e,"display",t);return wu(r)?r.transformed:n}function Eon(e){return e.startsWith("tool-")?Xc(e.slice(5)):Xc(e)}function wlt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{}}function jon(e){return typeof e=="object"&&e&&"value"in e?e.value:e}function Ton(e){return e==="approval-requested"||e==="approval-responded"||e==="output-denied"}function Non(e){if(e)return{id:e.id,approved:"approved"in e?e.approved:void 0,reason:"reason"in e?e.reason:void 0}}function Ion(e){return e.type==="dynamic-tool"?Xc(e.toolName):Eon(e.type)}function Aon(e){const t={toolCallId:e.toolCallId,toolName:Ion(e),args:wlt(e.input),approval:"approval"in e?Non(e.approval):void 0,providerMetadata:"callProviderMetadata"in e?e.callProviderMetadata:void 0,providerExecuted:e.providerExecuted,title:e.title,preliminary:"preliminary"in e?e.preliminary:void 0};switch(e.state){case"input-streaming":return ck({...t,state:"partial-call"});case"input-available":return ck({...t,state:"call"});case"output-available":return ck({...t,state:"result",result:jon(e.output)});case"output-error":return ck({...t,state:"output-error",errorText:e.errorText,rawInput:"rawInput"in e?e.rawInput:void 0});case"approval-requested":case"approval-responded":case"output-denied":return ck({...t,state:e.state})}}function Ron(e){return e.type==="dynamic-tool"&&!Ton(e.state)?{...e,type:`tool-${Xc(e.toolName)}`}:e}function ck({toolCallId:e,toolName:t,args:n,state:r,approval:s,result:a,errorText:i,rawInput:l,providerMetadata:c,providerExecuted:u,title:d,preliminary:f}){return id({type:"tool-invocation",toolInvocation:id({toolCallId:e,toolName:t,args:n,state:r},{approval:s,result:a,errorText:i,rawInput:l})},{providerMetadata:c,providerExecuted:u,title:d,preliminary:f})}function Pon(e,t){for(const n of e)if(n.type==="tool-invocation"&&n.toolInvocation.toolCallId===t)return n}function $on(e,t){if(e){for(const n of[...e].reverse())for(const r of[...n.content.parts||[]].reverse())if(r.type==="tool-invocation"&&r.toolInvocation.approval?.id===t&&r.toolInvocation.state==="approval-requested")return r}}function Mon(e){const t=[];for(const n of e){if(n.type!=="tool-invocation")continue;const r=n.toolInvocation;if(r.state==="result"){t.push({args:r.args,result:r.result,toolCallId:r.toolCallId,toolName:r.toolName,state:"result"});continue}(r.state==="call"||r.state==="partial-call")&&t.push({args:r.args,toolCallId:r.toolCallId,toolName:r.toolName,state:r.state})}return t.length>0?t:void 0}var oz=class G0{static toUIMessage(t){const n=Av.toUIMessage(t),r=n.metadata||{},s=[];if(t.role==="signal"&&n.role!=="user")return{id:t.id,role:"system",metadata:Object.keys(r).length>0?r:void 0,parts:n.parts.map(d=>G0.toUIPartFromV5(d))};const a=t.content.parts||[],i=a.some(d=>d.type==="tool-invocation"),l=a.some(d=>d.type==="reasoning"),c=a.some(d=>d.type==="file"),u=a.some(d=>d.type==="text");for(const d of a)s.push(G0.toUIPart(d));if(!i||!l||!c||!u)for(const d of n.parts){if(Cp(d)){i||s.push(G0.toUIPartFromV5(d));continue}if(d.type==="reasoning"){l||s.push(G0.toUIPartFromV5(d));continue}if(d.type==="file"){c||s.push(G0.toUIPartFromV5(d));continue}d.type==="text"&&!u&&s.push(G0.toUIPartFromV5(d))}return{id:t.id,role:t.role==="signal"?n.role:t.role,metadata:Object.keys(r).length>0?r:void 0,parts:s}}static fromUIMessage(t){const n=t.parts.filter(l=>!(l.type==="source-document"||R$e(l))),r=Av.fromUIMessage({...t,parts:n.map(l=>Ron(l))}),s=r.content.parts||[],a=[];let i=0;for(const l of t.parts){if(l.type==="source-document"){a.push(id({type:"source-document",sourceId:l.sourceId,mediaType:l.mediaType,title:l.title},{filename:l.filename,providerMetadata:l.providerMetadata}));continue}if(!R$e(l)){const c=s[i++];c&&a.push(c);continue}a.push(Aon(l))}return{...r,content:{...r.content,parts:a,toolInvocations:Mon(a)||r.content.toolInvocations}}}static fromModelMessage(t,n,r={}){const s=Array.isArray(t.content)?t.content:[{type:"text",text:t.content}],a=s.filter(c=>c.type!=="tool-approval-request"&&c.type!=="tool-approval-response"),i=Av.fromModelMessage({...t,content:a},n,r),l=[...i.content.parts];if(t.role==="assistant"){const c=new Map;for(const u of s){if(u.type==="tool-call"){c.set(u.toolCallId,{toolName:Xc(u.toolName),args:wlt(u.input)});continue}if(u.type!=="tool-approval-request")continue;const d=c.get(u.toolCallId),f=Pon(l,u.toolCallId);if(f){f.toolInvocation.state="approval-requested",f.toolInvocation.approval={id:u.approvalId};continue}l.push(ck({toolCallId:u.toolCallId,toolName:d?.toolName||"unknown",args:d?.args||{},state:"approval-requested",approval:{id:u.approvalId}}))}}else if(t.role==="tool")for(const c of s){if(c.type!=="tool-approval-response")continue;const u=$on(r.dbMessages,c.approvalId);u&&l.push(ck({toolCallId:u.toolInvocation.toolCallId,toolName:u.toolInvocation.toolName,args:u.toolInvocation.args,state:"approval-responded",approval:{id:c.approvalId,approved:c.approved,reason:c.reason},providerMetadata:u.providerMetadata,providerExecuted:u.providerExecuted,title:u.title}))}return{...i,content:{...i.content,parts:l}}}static toUIPart(t){if(t.type==="tool-invocation"){const n=id({type:`tool-${Xc(t.toolInvocation.toolName)}`,toolCallId:t.toolInvocation.toolCallId,providerExecuted:t.providerExecuted},{callProviderMetadata:t.providerMetadata,title:t.title});switch(t.toolInvocation.state){case"partial-call":return{...n,state:"input-streaming",input:tv(t.providerMetadata,"input-available",t.toolInvocation.args)};case"call":return{...n,state:"input-available",input:tv(t.providerMetadata,"input-available",t.toolInvocation.args)};case"approval-requested":return{...n,state:"approval-requested",input:tv(t.providerMetadata,"input-available",t.toolInvocation.args),approval:{id:t.toolInvocation.approval?.id||t.toolInvocation.toolCallId}};case"approval-responded":return{...n,state:"approval-responded",input:tv(t.providerMetadata,"input-available",t.toolInvocation.args),approval:{id:t.toolInvocation.approval?.id||t.toolInvocation.toolCallId,approved:t.toolInvocation.approval?.approved??!1,reason:t.toolInvocation.approval?.reason}};case"output-error":return id({...n,state:"output-error",input:tv(t.providerMetadata,"input-available",t.toolInvocation.args),errorText:tv(t.providerMetadata,"error",t.toolInvocation.errorText||"")},{rawInput:t.toolInvocation.rawInput,approval:t.toolInvocation.approval?.approved===!0?{id:t.toolInvocation.approval.id,approved:!0,reason:t.toolInvocation.approval.reason}:void 0});case"output-denied":return{...n,state:"output-denied",input:tv(t.providerMetadata,"input-available",t.toolInvocation.args),approval:{id:t.toolInvocation.approval?.id||t.toolInvocation.toolCallId,approved:!1,reason:t.toolInvocation.approval?.reason}};case"result":return id({...n,state:"output-available",input:tv(t.providerMetadata,"input-available",t.toolInvocation.args),output:tv(t.providerMetadata,"output-available",tv(t.providerMetadata,"error",t.toolInvocation.result))},{preliminary:t.preliminary,approval:t.toolInvocation.approval?.approved===!0?{id:t.toolInvocation.approval.id,approved:!0,reason:t.toolInvocation.approval.reason}:void 0});default:throw new Error(`Unhandled toolInvocation.state: ${String(t.toolInvocation.state)}`)}}return t.type==="source-document"?id({type:"source-document",sourceId:t.sourceId,mediaType:t.mediaType,title:t.title},{filename:t.filename,providerMetadata:t.providerMetadata}):G0.toUIPartFromV5(Av.toUIMessage({id:"tmp",role:"assistant",createdAt:new Date,content:{format:2,parts:[t]}}).parts[0])}static toUIPartFromV5(t){if(Cp(t)){const n={type:t.type,toolCallId:t.toolCallId,providerExecuted:t.providerExecuted};switch(t.state){case"input-streaming":return id({...n,state:"input-streaming",input:t.input},{callProviderMetadata:"callProviderMetadata"in t?t.callProviderMetadata:void 0,title:"title"in t?t.title:void 0});case"input-available":return id({...n,state:"input-available",input:t.input},{callProviderMetadata:"callProviderMetadata"in t?t.callProviderMetadata:void 0,title:"title"in t?t.title:void 0});case"output-available":return id({...n,state:"output-available",input:t.input,output:t.output},{callProviderMetadata:"callProviderMetadata"in t?t.callProviderMetadata:void 0,preliminary:"preliminary"in t?t.preliminary:void 0,title:"title"in t?t.title:void 0});case"output-error":return id({...n,state:"output-error",input:t.input,errorText:t.errorText},{rawInput:"rawInput"in t?t.rawInput:void 0,callProviderMetadata:"callProviderMetadata"in t?t.callProviderMetadata:void 0,title:"title"in t?t.title:void 0})}}switch(t.type){case"text":return id({type:"text",text:t.text},{providerMetadata:t.providerMetadata});case"reasoning":return id({type:"reasoning",text:t.text,state:t.state},{providerMetadata:t.providerMetadata});case"file":return id({type:"file",url:t.url,mediaType:t.mediaType},{filename:"filename"in t?t.filename:void 0,providerMetadata:t.providerMetadata});case"source-url":return id({type:"source-url",sourceId:t.sourceId,url:t.url},{title:t.title,providerMetadata:t.providerMetadata});case"step-start":return{type:"step-start"};default:return typeof t.type=="string"&&t.type.startsWith("data-")?{type:t.type,data:"data"in t?t.data:void 0}:t}}};function Don(e){return JSON.stringify(e,(t,n)=>{if(n&&typeof n=="object"&&!Array.isArray(n)){const r={};for(const s of Object.keys(n).sort())r[s]=n[s];return r}return n})}function A0(e,...t){const n=new Set(t.flatMap(r=>hon(r)));for(const r of n)e+=`|${r}`;return e}var Wo=class Xde{static fromAIV4Parts(t){let n="";for(const r of t)n+=r.type,n+=Xde.fromAIV4Part(r);return n}static fromAIV4Part(t){let n="";if(t.type==="text"&&(n+=t.text,n=A0(n,t.providerMetadata)),t.type==="tool-invocation"){if(!t.toolInvocation)return n;n+=t.toolInvocation.toolCallId,n+=t.toolInvocation.state}if(t.type==="reasoning"){n+=t.reasoning,n+=(t.details??[]).reduce((s,a)=>a.type==="text"?s+(a.text?.length??0)+(a.signature?.length||0):s,0);const r=t;r&&Object.hasOwn(r,"providerMetadata")&&(n=A0(n,r.providerMetadata))}return t.type==="file"&&(n+=t.data,n+=t.mimeType),n}static fromDBParts(t){let n="";for(const r of t)if(n+=r.type,r.type.startsWith("data-")){const s=r.data;n+=Don(s)}else n+=Xde.fromAIV4Part(r);return n}static fromAIV4CoreMessageContent(t){if(typeof t=="string")return t;let n="";for(const r of t){if(n+=r.type,r.type==="text"){n+=r.text.length;const s=r;n=A0(n,s.providerMetadata,s.providerOptions)}if(r.type==="reasoning"){n+=r.text.length;const s=r;n=A0(n,s.providerMetadata,s.providerOptions)}r.type==="tool-call"&&(n+=r.toolCallId,n+=r.toolName),r.type==="tool-result"&&(n+=r.toolCallId,n+=r.toolName),r.type==="file"&&(n+=r.filename,n+=r.mimeType),r.type==="image"&&(n+=rMe(r.image),n+=r.mimeType),r.type==="redacted-reasoning"&&(n+=r.data.length)}return n}static fromAIV5Parts(t){let n="";for(const r of t)n+=r.type,r.type==="text"&&(n+=r.text,n=A0(n,r.providerMetadata)),(Cp(r)||r.type==="dynamic-tool")&&(n+=r.toolCallId,n+=r.state),r.type==="reasoning"&&(n+=r.text,n=A0(n,r.providerMetadata)),r.type==="file"&&(n+=r.url.length,n+=r.mediaType,n+=r.filename||"");return n}static fromAIV5ModelMessageContent(t){if(typeof t=="string")return t;let n="";for(const r of t)n+=r.type,r.type==="text"&&(n+=r.text.length,n=A0(n,r.providerOptions)),r.type==="reasoning"&&(n+=r.text.length,n=A0(n,r.providerOptions)),r.type==="tool-call"&&(n+=r.toolCallId,n+=r.toolName),r.type==="tool-result"&&(n+=r.toolCallId,n+=r.toolName),r.type==="file"&&(n+=r.filename,n+=r.mediaType),r.type==="image"&&(n+=rMe(r.image),n+=r.mediaType);return n}};function Lon(e){if(e.role==="system")return e;if(typeof e.content=="string"&&(e.role==="assistant"||e.role==="user"))return{...e,content:[{type:"text",text:e.content}]};if(typeof e.content=="string")throw new Error(`Saw text content for input CoreMessage, but the role is ${e.role}. This is only allowed for "system", "assistant", and "user" roles.`);const t={user:[],assistant:[],tool:[]},n=e.role;for(const r of e.content){const s=`Saw incompatible message content part type ${r.type} for message role ${n}`;switch(r.type){case"text":{if(n==="tool")throw new Error(s);t[n].push(r);break}case"redacted-reasoning":case"reasoning":{if(n!=="assistant")throw new Error(s);t[n].push(r);break}case"tool-call":{if(n==="tool"||n==="user")throw new Error(s);t[n].push({...r,toolName:Xc(r.toolName)});break}case"tool-result":{if(n==="assistant"||n==="user")throw new Error(s);t[n].push({...r,toolName:Xc(r.toolName)});break}case"image":{if(n==="tool"||n==="assistant")throw new Error(s);let a;r.image instanceof URL||r.image instanceof Uint8Array?a=r.image:Buffer.isBuffer(r.image)||r.image instanceof ArrayBuffer?a=new Uint8Array(r.image):BP(r.image,r.mimeType).type==="raw"?a=new Uint8Array(Buffer.from(r.image,"base64")):a=new URL(r.image),t[n].push({...r,image:a});break}case"file":{if(n==="tool")throw new Error(s);t[n].push({...r,data:r.data instanceof URL||typeof r.data=="string"?r.data:cO(r.data)});break}}}if(n==="tool")return{...e,content:t[n]};if(n==="user")return{...e,content:t[n]};if(n==="assistant")return{...e,content:t[n]};throw new Error(`Encountered unknown role ${n} when converting V4 CoreMessage -> V4 LanguageModelV1Prompt, input message: ${JSON.stringify(e,null,2)}`)}function Fon(e){if(e.role==="system")return e;if(typeof e.content=="string"&&(e.role==="assistant"||e.role==="user"))return{role:e.role,content:[{type:"text",text:e.content}],providerOptions:e.providerOptions};if(typeof e.content=="string")throw new Error(`Saw text content for input ModelMessage, but the role is ${e.role}. This is only allowed for "system", "assistant", and "user" roles.`);const t={user:[],assistant:[],tool:[]},n=e.role;for(const r of e.content){const s=`Saw incompatible message content part type ${r.type} for message role ${n}`;switch(r.type){case"text":{if(n==="tool")throw new Error(s);t[n].push(r);break}case"reasoning":{if(n==="tool"||n==="user")throw new Error(s);t[n].push(r);break}case"tool-call":{if(n!=="assistant")throw new Error(s);t[n].push({...r,toolName:Xc(r.toolName)});break}case"tool-result":{if(n==="user")throw new Error(s);t[n].push({...r,toolName:Xc(r.toolName)});break}case"file":{if(n==="tool")throw new Error(s);t[n].push({...r,data:r.data instanceof ArrayBuffer?new Uint8Array(r.data):r.data});break}case"image":{if(n==="tool")throw new Error(s);t[n].push({...r,mediaType:r.mediaType||"image/unknown",type:"file",data:r.image instanceof ArrayBuffer?new Uint8Array(r.image):r.image});break}}}if(n==="tool")return{...e,content:t[n]};if(n==="user")return{...e,content:t[n]};if(n==="assistant")return{...e,content:t[n]};throw new Error(`Encountered unknown role ${n} when converting V5 ModelMessage -> V5 LanguageModelV2Message, input message: ${JSON.stringify(e,null,2)}`)}function zon(e){return e.map(t=>{if(t.role!=="tool")return t;let n=!1;const r=t.content.map(s=>{if(s.type!=="tool-result")return s;const a=s.output;if(!a||a.type!=="content"||!Array.isArray(a.value))return s;let i=!1;const l=a.value.map(c=>{if(c==null||typeof c!="object")return c;const u=c;if(u.type!=="media"||typeof u.data!="string")return c;i=!0;const d=typeof u.mediaType=="string"?u.mediaType:"";return d.startsWith("image/")?{type:"image-data",data:u.data,mediaType:d}:{type:"file-data",data:u.data,mediaType:d}});return i?(n=!0,{...s,output:{...a,value:l}}):s});return n?{...t,content:r}:t})}function Bon(e){return typeof e=="string"?e:e.reduce((t,n)=>(n.type==="text"&&(t+=n.text),t),"")}function nX(e,t){const n=Za.isAIV4UIMessage(e)&&e,r=Za.isAIV4UIMessage(t)&&t;if(n&&!r)return!1;if(n&&r)return Wo.fromAIV4Parts(e.parts)===Wo.fromAIV4Parts(t.parts);const s=Za.isAIV4CoreMessage(e)&&e,a=Za.isAIV4CoreMessage(t)&&t;if(s&&!a)return!1;if(s&&a)return Wo.fromAIV4CoreMessageContent(s.content)===Wo.fromAIV4CoreMessageContent(a.content);const i=Za.isMastraMessageV1(e)&&e,l=Za.isMastraMessageV1(t)&&t;if(i&&!l)return!1;if(i&&l)return i.id===l.id&&Wo.fromAIV4CoreMessageContent(i.content)===Wo.fromAIV4CoreMessageContent(l.content);const c=Za.isMastraDBMessage(e)&&e,u=Za.isMastraDBMessage(t)&&t;if(c&&!u)return!1;if(c&&u)return c.id===u.id&&Wo.fromDBParts(c.content.parts)===Wo.fromDBParts(u.content.parts);const d=Za.isAIV5UIMessage(e)&&e,f=Za.isAIV5UIMessage(t)&&t;if(d&&!f)return!1;if(d&&f)return Wo.fromAIV5Parts(e.parts)===Wo.fromAIV5Parts(t.parts);const p=Za.isAIV5CoreMessage(e)&&e,h=Za.isAIV5CoreMessage(t)&&t;return p&&!h?!1:p&&h?Wo.fromAIV5ModelMessageContent(p.content)===Wo.fromAIV5ModelMessageContent(h.content):!0}function ebe(e){return e.createdAt==null&&(e.createdAt=Date.now()),e}function $C(e,t){return t==="memory"||!Array.isArray(e.content.parts)||(e.content.parts=e.content.parts.map(n=>ebe(n))),e}function cMe(e,t,n){if(t!=="memory"&&"threadId"in e&&e.threadId&&n.memoryInfo&&e.threadId!==n.memoryInfo.threadId)throw new Error(`Received input message with wrong threadId. Input ${e.threadId}, expected ${n.memoryInfo.threadId}`);if("resourceId"in e&&e.resourceId&&n.memoryInfo?.resourceId&&e.resourceId!==n.memoryInfo.resourceId)throw new Error(`Received input message with wrong resourceId. Input ${e.resourceId}, expected ${n.memoryInfo.resourceId}`);if(Za.isMastraMessageV1(e))return $C(Uon(e,t,n),t);if(Za.isMastraDBMessage(e))return $C(qon(e,n,t),t);if(Za.isAIV4CoreMessage(e))return $C(Ew.fromCoreMessage(e,n,t),t);if(Za.isAIV4UIMessage(e))return $C(Ew.fromUIMessage(e,n,t),t);const s="id"in e&&typeof e.id=="string"?e.id:n.newMessageId();if(Za.isAIV6CoreMessage(e)){const a=oz.fromModelMessage(e,t,n),i="metadata"in e&&e.metadata&&typeof e.metadata=="object"&&"createdAt"in e.metadata?e.metadata.createdAt:void 0;return{...a,id:s,createdAt:n.generateCreatedAt(t,i),threadId:n.memoryInfo?.threadId,resourceId:n.memoryInfo?.resourceId}}if(Za.isAIV6UIMessage(e)){const a=oz.fromUIMessage(e),i="createdAt"in e?e.createdAt:void 0;return{...a,id:s,createdAt:n.generateCreatedAt(t,i),threadId:n.memoryInfo?.threadId,resourceId:n.memoryInfo?.resourceId}}if(Za.isAIV5CoreMessage(e)){const a=Av.fromModelMessage(e,t,n),i="metadata"in e&&e.metadata&&typeof e.metadata=="object"&&"createdAt"in e.metadata?e.metadata.createdAt:void 0;return $C({...a,id:s,createdAt:n.generateCreatedAt(t,i),threadId:n.memoryInfo?.threadId,resourceId:n.memoryInfo?.resourceId},t)}if(Za.isAIV5UIMessage(e)){const a=Av.fromUIMessage(e),i="createdAt"in e?e.createdAt:void 0;return $C({...a,id:s,createdAt:n.generateCreatedAt(t,i),threadId:n.memoryInfo?.threadId,resourceId:n.memoryInfo?.resourceId},t)}throw new Error(`Found unhandled message ${JSON.stringify(e)}`)}function Uon(e,t,n){const r=Ew.fromCoreMessage({content:e.content,role:e.role},n,t);return{id:e.id,role:r.role,createdAt:n.generateCreatedAt(t,e.createdAt),threadId:e.threadId,resourceId:e.resourceId,content:r.content}}function qon(e,t,n){return e.id||(e.id=t.newMessageId()),e.createdAt===void 0||e.createdAt===null?e.createdAt=t.generateCreatedAt(n):e.createdAt instanceof Date||(e.createdAt=new Date(e.createdAt)),e.content.toolInvocations&&e.content.parts&&(e.content.toolInvocations=e.content.toolInvocations.map(r=>{if(!r.args||Object.keys(r.args).length===0){const s=e.content.parts.find(a=>a.type==="tool-invocation"&&a.toolInvocation&&a.toolInvocation.toolCallId===r.toolCallId&&a.toolInvocation.args&&Object.keys(a.toolInvocation.args).length>0);if(s&&s.type==="tool-invocation")return{...r,args:s.toolInvocation.args}}return r})),!e.threadId&&t.memoryInfo?.threadId&&(e.threadId=t.memoryInfo.threadId,!e.resourceId&&t.memoryInfo?.resourceId&&(e.resourceId=t.memoryInfo.resourceId)),e}function Von(e){return e.type.startsWith("source-")}function Hon(e){const t=[];for(const n of e){if(n.type!=="text"){t.push(n);continue}const r=n,s=sMe(r.providerMetadata);if(!s){t.push(n);continue}let a=!1;for(let i=t.length-1;i>=0;i--){const l=t[i];if(l.type==="text"){const c=l;sMe(c.providerMetadata)===s&&(t[i]={...c,text:c.text+r.text},a=!0);break}if(!Von(l))break}a||t.push(n)}return t}function Won(e){return e.map(n=>{if(n.parts.length===0)return!1;const r=n.parts.filter(a=>a.type!=="tool-invocation"||a.toolInvocation.state!=="call"&&a.toolInvocation.state!=="partial-call");if(!r.length)return!1;const s={...n,parts:r};return"toolInvocations"in n&&n.toolInvocations&&(s.toolInvocations=n.toolInvocations.filter(a=>a.state==="result")),s}).filter(n=>!!n)}function Slt(e,t=!1){let n=-1;for(let i=e.length-1;i>=0;i--)if(e[i].role==="user"){n=i;break}const r=(i,l)=>i.parts.filter(c=>typeof c.type=="string"&&c.type.startsWith("data-")||c.type==="text"&&(!("text"in c)||c.text===""||c.text?.trim()==="")&&(i.role==="user"||i.parts.some(d=>!(d.type==="text"&&(!("text"in d)||d.text===""||d.text?.trim()===""))))?!1:Cp(c)?t?!!(c.state==="output-available"||c.state==="output-error"||c.state==="input-available"&&c.providerExecuted&&l):c.state!=="input-streaming":!0);let s=-1;if(n!==e.length-1)for(let i=e.length-1;i>n;i--){const l=e[i];if(!(l.role!=="assistant"||l.parts.length===0)&&r(l,!0).length>0){s=i;break}}return e.map((i,l)=>{if(i.parts.length===0)return!1;const c=i.role==="assistant"&&l===s,u=r(i,c);if(!u.length)return!1;const d=Hon(u);return{...i,parts:d.map(p=>Cp(p)&&p.state==="output-available"?{...p,output:(()=>{const h=p.output;if(h==null||typeof h!="object")return h;const m=h;return m.type==="content"&&Array.isArray(m.value)?h:"value"in m?m.value:h})()}:p)}}).filter(i=>!!i)}function Zon(e){for(const t of e)if(t.role==="assistant")for(const[n,r]of t.parts.entries()){if(!Cp(r))continue;const s=t.parts.at(n+1);s&&s.type!=="step-start"&&!Cp(s)&&t.parts.splice(n+1,0,{type:"step-start"}),s&&Cp(s)&&!r.providerExecuted&&s.providerExecuted&&(s.state==="output-available"||s.state==="output-error")&&t.parts.splice(n+1,0,{type:"step-start"})}return e}function mh(e){return ein(Won(e))}function Gon(e){if(!e||typeof e!="object")return;const t=e.content;if(!Array.isArray(t)||!t.some(s=>{if(!s||typeof s!="object")return!1;const a=s;return(a.type==="image"||a.type==="audio")&&typeof a.data=="string"}))return;const r=t.map(s=>{if(!s||typeof s!="object")return null;const a=s;switch(a.type){case"text":return{type:"text",text:String(a.text??"")};case"image":return typeof a.data=="string"?{type:"image-data",data:a.data,mediaType:String(a.mimeType??"image/png")}:{type:"text",text:JSON.stringify(a)};case"audio":return typeof a.data=="string"?{type:"file-data",data:a.data,mediaType:String(a.mimeType??"audio/wav")}:{type:"text",text:JSON.stringify(a)};default:return{type:"text",text:JSON.stringify(a)}}}).filter(Boolean);return r.length>0?{type:"content",value:r}:void 0}function Qon(e){const t=new Map;for(const n of e)if(!(n.content?.format!==2||!n.content.parts))for(const r of n.content.parts)r.type!=="tool-invocation"||r.toolInvocation?.state!=="result"||t.set(r.toolInvocation.toolCallId,r.toolInvocation.result);return t}function Yon(e,t){if(!e||typeof e!="object")return!1;const n=e;return n.type!=="json"?!1:JSON.stringify(n.value)===JSON.stringify(t)}function Xon(e,t){const n=Qon(t);return n.size===0?e:e.map(r=>{if(r.role!=="tool"||!Array.isArray(r.content))return r;let s=!1;const a=r.content.map(i=>{if(i.type!=="tool-result"||!n.has(i.toolCallId))return i;const l=n.get(i.toolCallId);if(!Yon(i.output,l))return i;const c=Gon(l);return c?(s=!0,{...i,output:c}):i});return s?{...r,content:a}:r})}function Kon(e,t){const n=[];for(const s of t)if(s.role==="assistant")for(const a of s.parts)a.type==="file"&&n.push(a.providerMetadata??void 0);if(n.length===0||n.every(s=>s==null))return e;let r=0;return e.map(s=>{if(s.role!=="assistant"||typeof s.content=="string")return s;let a=!1;const i=s.content.map(l=>{if(l.type!=="file"||r>=n.length)return l;const c=n[r++];return l.providerOptions||!c?l:(a=!0,{...l,providerOptions:c})});return a?{...s,content:i}:s})}function pv(e,t,n=!1){const r=Slt(e,n),s=Zon(r),a=[];for(const u of s){const d=kit([u]);if(d.length===0)continue;const f=u.metadata&&typeof u.metadata=="object"&&"providerMetadata"in u.metadata?u.metadata.providerMetadata:void 0;if(f){let p=-1;for(let h=d.length-1;h>=0;h--)if(d[h]?.role===u.role){p=h;break}p!==-1&&(d[p]={...d[p],providerOptions:f})}a.push(...d)}const i=Kon(a,s),l=Xon(i,t),c=mon(l,t);return n?gon(c):c}function uMe(e,t,n,r){return pv(e.map(s=>Ew.fromCoreMessage(s,n,t)).map(s=>Av.toUIMessage(s)),r)}function Jon(e){if(typeof e=="string")return{role:"system",content:e};if(Za.isAIV6CoreMessage(e)){const t=oz.fromModelMessage(e,"system");return Ew.systemToV4Core(t)}if(Za.isAIV5CoreMessage(e)){const t=Av.fromModelMessage(e,"system");return Ew.systemToV4Core(t)}return Za.isMastraDBMessage(e)?Ew.systemToV4Core(e):e}var dMe=class Ob{static extractStepContent(t,n,r){const s=t.flatMap(i=>i.parts),a=[];return s.forEach((i,l)=>{i.type==="step-start"&&a.push(l)}),n===-1?Ob.extractLastStep(s,a,r):n===1?Ob.extractFirstStep(s,a,r):Ob.extractMiddleStep(s,a,n,r)}static extractLastStep(t,n,r){const s=t.filter(u=>u.type?.startsWith("tool-")),a=n.length>0;if(!a&&s.length>0){const u=s[s.length-1];if(!u)return[];const d=t.indexOf(u),f=s[s.length-2],h=(f?t.indexOf(f):-1)+1,m=t.slice(h,d+1);return Ob.convertPartsToContent(m,"last-step",r)}if(n.length+1===1&&!a)return Ob.convertPartsToContent(t,"last-step",r);const l=n[n.length-1];if(l===void 0)return[];const c=t.slice(l+1);return c.length===0?[]:Ob.convertPartsToContent(c,"last-step",r)}static extractFirstStep(t,n,r){const s=n[0]??t.length;if(s===0)return[];const a=t.slice(0,s);return Ob.convertPartsToContent(a,"step-1",r)}static extractMiddleStep(t,n,r,s){const a=r-2;if(a<0||a>=n.length)return[];const i=(n[a]??0)+1,l=n[a+1]??t.length;if(i>=l)return[];const c=t.slice(i,l);return Ob.convertPartsToContent(c,`step-${r}`,s)}static convertPartsToContent(t,n,r){return kit(Slt([{id:n,role:"assistant",parts:t}])).flatMap(r)}static convertToStepContent(t,n,r){const s=t||r();return s?typeof s.content=="string"?[{type:"text",text:s.content}]:s.content.map(a=>a.type==="tool-result"?{type:"tool-result",input:iq(n,a.toolCallId),output:a.output,toolCallId:a.toolCallId,toolName:a.toolName}:a.type==="file"?{type:"file",file:new K$e({data:typeof a.data=="string"?iz(a.data).base64Content:a.data instanceof URL?a.data.toString():cO(a.data),mediaType:a.mediaType})}:a.type==="image"?{type:"file",file:new K$e({data:typeof a.image=="string"?iz(a.image).base64Content:a.image instanceof URL?a.image.toString():cO(a.image),mediaType:a.mediaType||"unknown"})}:{...a}):[]}},ub=class ZR{static isSealed(t){return t.content?.metadata?.mastra?.sealed===!0}static shouldMerge(t,n,r,s,a=!1){if(!t||ZR.isSealed(t)||t.content?.metadata?.mastra?.responseBoundary||n.content.metadata?.completionResult||t.content.metadata?.completionResult||n.content.metadata?.isTaskCompleteResult||t.content.metadata?.isTaskCompleteResult)return!1;const i=t.content?.parts??[];return i.length>0&&i.every(d=>d.type.startsWith("data-"))&&t.id!==n.id?!1:t.role==="assistant"&&n.role==="assistant"&&t.threadId===n.threadId&&r!=="memory"&&(a?!s:!0)}static merge(t,n){n.content.metadata&&(t.content.metadata={...t.content.metadata??{},...n.content.metadata});const r=new Map,s=new Map;for(const[a,i]of n.content.parts.entries())if(i.type==="tool-invocation"){if(!i.toolInvocation)continue;const l=[...t.content.parts].reverse().find(u=>u.type==="tool-invocation"&&u.toolInvocation?.toolCallId===i.toolInvocation.toolCallId);if(!!l&&l.type==="tool-invocation"){if(i.toolInvocation.state==="result"){l.toolInvocation={...l.toolInvocation,step:i.toolInvocation.step,state:"result",result:i.toolInvocation.result,args:{...l.toolInvocation.args,...i.toolInvocation.args}},i.providerMetadata&&(l.providerMetadata={...l.providerMetadata,...i.providerMetadata}),t.content.toolInvocations||(t.content.toolInvocations=[]);const d=t.content.toolInvocations.findIndex(f=>f.toolCallId===l.toolInvocation.toolCallId);d===-1?t.content.toolInvocations.push(l.toolInvocation):t.content.toolInvocations[d]=l.toolInvocation}else(i.toolInvocation.state==="approval-requested"||i.toolInvocation.state==="approval-responded"||i.toolInvocation.state==="output-denied"||i.toolInvocation.state==="output-error")&&(l.toolInvocation={...l.toolInvocation,state:i.toolInvocation.state,approval:i.toolInvocation.approval,errorText:i.toolInvocation.errorText,rawInput:i.toolInvocation.rawInput,args:{...l.toolInvocation.args,...i.toolInvocation.args}},i.providerMetadata&&(l.providerMetadata={...l.providerMetadata,...i.providerMetadata}),"providerExecuted"in i&&i.providerExecuted!==void 0&&(l.providerExecuted=i.providerExecuted),"title"in i&&i.title!==void 0&&(l.title=i.title),"preliminary"in i&&i.preliminary!==void 0&&(l.preliminary=i.preliminary));const u=t.content.parts.findIndex(d=>d===l);r.set(a,u)}else s.set(a,i)}else s.set(a,i);ZR.addPartsToMessage({latestMessage:t,incomingMessage:n,anchorMap:r,partsToAdd:s}),!t.content.content&&n.content.content&&(t.content.content=n.content.content),t.content.content&&n.content.content&&t.content.content!==n.content.content&&(t.content.content=n.content.content)}static addPartsToMessage({latestMessage:t,incomingMessage:n,anchorMap:r,partsToAdd:s}){for(let a=0;a<n.content.parts.length;++a){const i=n.content.parts[a];if(!i)continue;const l=Wo.fromDBParts([i]),c=s.get(a);if(!(!l||!c))if(r.size>0){if(r.has(a))continue;const u=[...r.keys()].filter(v=>v<a).pop()??-1,d=[...r.keys()].find(v=>v>a)??-1,f=u!==-1?r.get(u):0,p=u===-1?a:a-u,h=f+p,m=d!==-1?r.get(d):t.content.parts.length;if(h>=0&&h<=m&&!t.content.parts.slice(h,m).some(v=>Wo.fromDBParts([v])===Wo.fromDBParts([i]))){ZR.pushNewPart({latestMessage:t,newMessage:n,part:i,insertAt:h});for(const[v,y]of r.entries())y>=h&&r.set(v,y+1)}}else ZR.pushNewPart({latestMessage:t,newMessage:n,part:i})}}static pushNewPart({latestMessage:t,newMessage:n,part:r,insertAt:s}){const a=Wo.fromDBParts([r]),i=t.content.parts.filter(c=>Wo.fromDBParts([c])===a).length,l=n.content.parts.filter(c=>Wo.fromDBParts([c])===a).length;if(i<l){const c=n.content.parts.indexOf(r),u=c>0&&n.content.parts[c-1]?.type==="step-start",d=t.role==="assistant"&&r.type==="text"&&!u&&t.content.parts.length>0&&t.content.parts.at(-1)?.type==="tool-invocation",f=[...t.content.parts].reverse().find(h=>h.type==="step-start"),p=f?.model?ebe({type:"step-start",model:f.model}):{type:"step-start"};typeof s=="number"?d?(t.content.parts.splice(s,0,p),t.content.parts.splice(s+1,0,r)):t.content.parts.splice(s,0,r):(d&&t.content.parts.push(p),t.content.parts.push(r))}}};function eln(e){try{const[t,n]=e.split(",");return{mediaType:t?.split(";")[0]?.split(":")[1],base64Content:n}}catch{return{mediaType:void 0,base64Content:void 0}}}function tln(e){if(e instanceof Uint8Array)return{data:e,mediaType:void 0};if(e instanceof ArrayBuffer)return{data:new Uint8Array(e),mediaType:void 0};if(typeof e=="string")try{e=new URL(e)}catch{}if(e instanceof URL&&e.protocol==="data:"){const{mediaType:t,base64Content:n}=eln(e.toString());if(t==null||n==null)throw new sO({id:"INVALID_DATA_URL_FORMAT",text:`Invalid data URL format in content ${e.toString()}`,domain:Hw.LLM,category:Ww.USER});return{data:n,mediaType:t}}return{data:e,mediaType:void 0}}var nln=[{mediaType:"image/gif",bytesPrefix:[71,73,70],base64Prefix:"R0lG"},{mediaType:"image/png",bytesPrefix:[137,80,78,71],base64Prefix:"iVBORw"},{mediaType:"image/jpeg",bytesPrefix:[255,216],base64Prefix:"/9j/"},{mediaType:"image/webp",bytesPrefix:[82,73,70,70],base64Prefix:"UklGRg"},{mediaType:"image/bmp",bytesPrefix:[66,77],base64Prefix:"Qk"},{mediaType:"image/tiff",bytesPrefix:[73,73,42,0],base64Prefix:"SUkqAA"},{mediaType:"image/tiff",bytesPrefix:[77,77,0,42],base64Prefix:"TU0AKg"},{mediaType:"image/avif",bytesPrefix:[0,0,0,32,102,116,121,112,97,118,105,102],base64Prefix:"AAAAIGZ0eXBhdmlm"},{mediaType:"image/heic",bytesPrefix:[0,0,0,32,102,116,121,112,104,101,105,99],base64Prefix:"AAAAIGZ0eXBoZWlj"}],rln=e=>{const t=typeof e=="string"?plt(e):e,n=(t[6]&127)<<21|(t[7]&127)<<14|(t[8]&127)<<7|t[9]&127;return t.slice(n+10)};function sln(e){return typeof e=="string"&&e.startsWith("SUQz")||typeof e!="string"&&e.length>10&&e[0]===73&&e[1]===68&&e[2]===51?rln(e):e}function aln({data:e,signatures:t}){const n=sln(e);for(const r of t)if(typeof n=="string"?n.startsWith(r.base64Prefix):n.length>=r.bytesPrefix.length&&r.bytesPrefix.every((s,a)=>n[a]===s))return r.mediaType}function fMe(e,t){let n;const r=e.type;switch(r){case"image":n=e.image;break;case"file":n=e.data;break;default:throw new Error(`Unsupported part type: ${r}`)}const{data:s,mediaType:a}=tln(n);let i=a??e.mediaType,l=s;if(l instanceof URL&&t){const c=t[l.toString()];c&&(l=c.data,i??=c.mediaType)}switch(r){case"image":return(l instanceof Uint8Array||typeof l=="string")&&(i=aln({data:l,signatures:nln})??i),{type:"file",mediaType:i??"image/*",filename:void 0,data:l,providerOptions:e.providerOptions};case"file":{if(i==null)throw new Error("Media type is missing for file part");return{type:"file",mediaType:i,filename:e.filename,data:l,providerOptions:e.providerOptions}}}}function pMe(e){const t=[];for(const n of e){const r=BP(n.url,n.contentType);let s=n.url;r.type==="raw"&&(s=Xye(n.url,n.contentType||"application/octet-stream"));let a;try{a=new URL(s)}catch{throw new Error(`Invalid URL: ${n.url}`)}switch(a.protocol){case"http:":case"https:":case"gs:":case"s3:":{if(n.contentType?.startsWith("image/"))t.push({type:"image",image:a.toString(),mimeType:n.contentType});else{if(!n.contentType)throw new Error("If the attachment is not an image, it must specify a content type");t.push({type:"file",data:a.toString(),mimeType:n.contentType})}break}case"data:":{if(n.contentType?.startsWith("image/"))t.push({type:"image",image:s,mimeType:n.contentType});else if(n.contentType?.startsWith("text/"))t.push({type:"file",data:s,mimeType:n.contentType});else{if(!n.contentType)throw new Error("If the attachment is not an image or text, it must specify a content type");t.push({type:"file",data:s,mimeType:n.contentType})}break}default:throw new Error(`Unsupported URL protocol: ${a.protocol}`)}}return t}var iln=e=>{const t=new Map,n=/__split-\d+$/;return r=>{const s=e.at(-1);if(r.role===s?.role&&Array.isArray(s.content)&&Array.isArray(r.content)&&(r.role!=="assistant"||r.role==="assistant"&&r.content.at(-1)?.type!=="tool-call"))for(const a of r.content)s.content.push(a);else{let a=r.id;if(n.test(a)){e.push(r);return}const l=t.get(a)||0;l>0&&(r.id=`${a}__split-${l}`),t.set(a,l+1),e.push(r)}}};function MC(e){const t=[],n=iln(t);for(let r=0;r<e.length;r++){const s=e[r],a=r===e.length-1;if(!s?.content)continue;const{content:i,experimental_attachments:l=[],parts:c}=s.content,{role:u}=s,d={id:s.id,createdAt:s.createdAt,resourceId:s.resourceId,threadId:s.threadId},f=[...l],p=[];for(const h of c)h.type==="file"?f.push({url:h.data,contentType:h.mimeType}):p.push(h);switch(u){case"user":{if(p==null){const h=f?[{type:"text",text:i||""},...pMe(f)]:{type:"text",text:i||""};n({role:"user",...d,type:"text",content:h})}else{const h=s.content.parts.filter(v=>v.type==="text").map(v=>({type:"text",text:v.text})),m=f?[...h,...pMe(f)]:h;n({role:"user",...d,type:"text",content:Array.isArray(m)&&m.length===1&&m[0]?.type==="text"&&typeof i<"u"?i:m})}break}case"assistant":{if(s.content.parts!=null){let v=function(){const k=[];for(const E of S)switch(E.type){case"file":case"text":{k.push(E);break}case"reasoning":{for(const j of E.details)switch(j.type){case"text":k.push({type:"reasoning",text:j.text,signature:j.signature});break;case"redacted":k.push({type:"redacted-reasoning",data:j.data});break}break}case"tool-invocation":E.toolInvocation.toolName!=="updateWorkingMemory"&&k.push({type:"tool-call",toolCallId:E.toolInvocation.toolCallId,toolName:E.toolInvocation.toolName,args:E.toolInvocation.args});break}n({role:"assistant",...d,type:k.some(E=>E.type==="tool-call")?"tool-call":"text",content:typeof k!="string"&&Array.isArray(k)&&k.length===1&&k[0]?.type==="text"?k[0].text:k});const C=S.filter(E=>"type"in E&&E.type==="tool-invocation").map(E=>E.toolInvocation).filter(E=>E.toolName!=="updateWorkingMemory").filter(E=>E.state==="result"&&"result"in E);C.length>0&&n({role:"tool",...d,type:"tool-result",content:C.map(E=>{const{toolCallId:j,toolName:N,result:I}=E;return{type:"tool-result",toolCallId:j,toolName:N,result:I}})}),S=[],b=!1,y++},y=0,b=!1,S=[];for(const k of s.content.parts)switch(k.type){case"text":{b&&v(),S.push(k);break}case"file":case"reasoning":{S.push(k);break}case"tool-invocation":{(S.some(C=>C.type==="text"||C.type==="file"||C.type==="reasoning")||(k.toolInvocation.step??0)!==y)&&v(),S.push(k),b=!0;break}}v();const w=s.content.toolInvocations;if(w&&w.length>0){const k=new Set;for(const C of s.content.parts)C.type==="tool-invocation"&&C.toolInvocation.toolCallId&&k.add(C.toolInvocation.toolCallId);const _=w.filter(C=>!k.has(C.toolCallId)&&C.toolName!=="updateWorkingMemory");if(_.length>0){const C=new Map;for(const j of _){const N=j.step??0;C.has(N)||C.set(N,[]),C.get(N).push(j)}const E=Array.from(C.keys()).sort((j,N)=>j-N);for(const j of E){const N=C.get(j);n({role:"assistant",...d,type:"tool-call",content:[...N.map(({toolCallId:R,toolName:P,args:L})=>({type:"tool-call",toolCallId:R,toolName:P,args:L}))]});const I=N.filter(R=>R.state==="result"&&"result"in R);I.length>0&&n({role:"tool",...d,type:"tool-result",content:I.map(R=>{const{toolCallId:P,toolName:L,result:M}=R;return{type:"tool-result",toolCallId:P,toolName:L,result:M}})})}}}break}const h=s.content.toolInvocations;if(h==null||h.length===0){n({role:"assistant",...d,content:i||"",type:"text"});break}const m=h.reduce((v,y)=>Math.max(v,y.step??0),0);for(let v=0;v<=m;v++){const y=h.filter(S=>(S.step??0)===v&&S.toolName!=="updateWorkingMemory");if(y.length===0)continue;n({role:"assistant",...d,type:"tool-call",content:[...a&&i&&v===0?[{type:"text",text:i}]:[],...y.map(({toolCallId:S,toolName:w,args:k})=>({type:"tool-call",toolCallId:S,toolName:w,args:k}))]});const b=y.filter(S=>S.state==="result"&&"result"in S);b.length>0&&n({role:"tool",...d,type:"tool-result",content:b.map(S=>{const{toolCallId:w,toolName:k,result:_}=S;return{type:"tool-result",toolCallId:w,toolName:k,result:_}})})}i&&!a&&n({role:"assistant",...d,type:"text",content:i||""});break}}}return t}function oln(e){return`${e.origin}${e.pathname}`}var lln=async({url:e,downloadRetries:t})=>{const n=e.toString(),r=oln(e);try{const s=await Yin(n,{method:"GET"},t,{shouldRetryResponse:a=>a.status>=500});if(!s.ok)throw new sO({id:"DOWNLOAD_ASSETS_FAILED",text:`Failed to download asset: ${r}`,domain:Hw.LLM,category:Ww.USER,details:{url:n}});return{data:new Uint8Array(await s.arrayBuffer()),mediaType:s.headers.get("content-type")??void 0}}catch(s){throw new sO({id:"DOWNLOAD_ASSETS_FAILED",text:`Failed to download asset: ${r}`,domain:Hw.LLM,category:Ww.USER,details:{url:n}},s)}};async function cln({messages:e,downloadConcurrency:t=10,downloadRetries:n=3,supportedUrls:r}){const s=(await jo(async()=>{const{default:c}=await import("./index-yUiD89B4.js");return{default:c}},[],import.meta.url)).default,a=e.filter(c=>c.role==="user").map(c=>c.content).filter(c=>Array.isArray(c)).flat().filter(c=>c.type==="image"||c.type==="file").map(c=>{const u=c.mediaType??(c.type==="image"?"image/*":void 0);let d=c.type==="image"?c.image:c.data;if(typeof d=="string")try{d=new URL(d)}catch{}return{mediaType:u,data:d}}).filter(c=>c.data instanceof URL).map(c=>({url:c.data,isUrlSupportedByModel:c.mediaType!=null&&Hin({url:c.data.toString(),mediaType:c.mediaType,supportedUrls:r??{}})})),l=(await s(a,async c=>c.isUrlSupportedByModel?null:{url:c.url.toString(),...await lln({url:c.url,downloadRetries:n})},{concurrency:t})).filter(c=>c?.data!=null).map(({url:c,data:u,mediaType:d})=>[c,{data:u,mediaType:d}]);return Object.fromEntries(l)}function uln(e){return{...e,createdAt:e.createdAt.toISOString()}}function dln(e){return{...e,createdAt:new Date(e.createdAt)}}function fln(e){return e.map(uln)}function pln(e){return e.map(dln)}var hln=class{memoryMessages=new Set;newUserMessages=new Set;newResponseMessages=new Set;userContextMessages=new Set;memoryMessagesPersisted=new Set;newUserMessagesPersisted=new Set;newResponseMessagesPersisted=new Set;userContextMessagesPersisted=new Set;addToSource(e,t){switch(t){case"memory":this.memoryMessages.add(e),this.memoryMessagesPersisted.add(e);break;case"response":this.memoryMessages.has(e)&&this.memoryMessages.delete(e),this.newResponseMessages.add(e),this.newResponseMessagesPersisted.add(e),this.newUserMessages.has(e)&&this.newUserMessages.delete(e);break;case"input":case"user":this.newUserMessages.add(e),this.newUserMessagesPersisted.add(e);break;case"context":this.userContextMessages.add(e),this.userContextMessagesPersisted.add(e);break;default:throw new Error(`Missing message source for message ${e}`)}}isMemoryMessage(e){return this.memoryMessages.has(e)}isUserMessage(e){return this.newUserMessages.has(e)}isResponseMessage(e){return this.newResponseMessages.has(e)}isContextMessage(e){return this.userContextMessages.has(e)}getMemoryMessages(){return this.memoryMessages}getUserMessages(){return this.newUserMessages}getResponseMessages(){return this.newResponseMessages}getContextMessages(){return this.userContextMessages}getMemoryMessagesPersisted(){return this.memoryMessagesPersisted}getUserMessagesPersisted(){return this.newUserMessagesPersisted}getResponseMessagesPersisted(){return this.newResponseMessagesPersisted}getContextMessagesPersisted(){return this.userContextMessagesPersisted}removeMessage(e){this.memoryMessages.delete(e),this.newUserMessages.delete(e),this.newResponseMessages.delete(e),this.userContextMessages.delete(e)}clearUserMessages(){this.newUserMessages.clear()}clearResponseMessages(){this.newResponseMessages.clear()}clearContextMessages(){this.userContextMessages.clear()}clearAll(){this.newUserMessages.clear(),this.newResponseMessages.clear(),this.userContextMessages.clear()}createSourceChecker(){const e={memory:new Set(Array.from(this.memoryMessages.values()).map(t=>t.id)),output:new Set(Array.from(this.newResponseMessages.values()).map(t=>t.id)),input:new Set(Array.from(this.newUserMessages.values()).map(t=>t.id)),context:new Set(Array.from(this.userContextMessages.values()).map(t=>t.id))};return{...e,getSource:t=>e.memory.has(t.id)?"memory":e.input.has(t.id)?"input":e.output.has(t.id)?"response":e.context.has(t.id)?"context":null}}isNewMessage(e){const t=typeof e=="string"?e:e.id;return typeof e!="string"&&(this.newUserMessages.has(e)||this.newResponseMessages.has(e))?!0:Array.from(this.newUserMessages).some(n=>n.id===t)||Array.from(this.newResponseMessages).some(n=>n.id===t)}serializeSourceTracking(){const e=t=>Array.from(t).map(n=>n.id);return{memoryMessages:e(this.memoryMessages),newUserMessages:e(this.newUserMessages),newResponseMessages:e(this.newResponseMessages),userContextMessages:e(this.userContextMessages),memoryMessagesPersisted:e(this.memoryMessagesPersisted),newUserMessagesPersisted:e(this.newUserMessagesPersisted),newResponseMessagesPersisted:e(this.newResponseMessagesPersisted),userContextMessagesPersisted:e(this.userContextMessagesPersisted)}}deserializeSourceTracking(e,t){const n=r=>new Set(r.map(s=>t.find(a=>a.id===s)).filter(Boolean));this.memoryMessages=n(e.memoryMessages),this.newUserMessages=n(e.newUserMessages),this.newResponseMessages=n(e.newResponseMessages),this.userContextMessages=n(e.userContextMessages),this.memoryMessagesPersisted=n(e.memoryMessagesPersisted),this.newUserMessagesPersisted=n(e.newUserMessagesPersisted),this.newResponseMessagesPersisted=n(e.newResponseMessagesPersisted),this.userContextMessagesPersisted=n(e.userContextMessagesPersisted)}serializeAll(e){return{messages:fln(e.messages),systemMessages:e.systemMessages,taggedSystemMessages:e.taggedSystemMessages,memoryInfo:e.memoryInfo,_agentNetworkAppend:e.agentNetworkAppend,...this.serializeSourceTracking()}}deserializeAll(e){const t=pln(e.messages);return this.deserializeSourceTracking({memoryMessages:e.memoryMessages,newUserMessages:e.newUserMessages,newResponseMessages:e.newResponseMessages,userContextMessages:e.userContextMessages,memoryMessagesPersisted:e.memoryMessagesPersisted,newUserMessagesPersisted:e.newUserMessagesPersisted,newResponseMessagesPersisted:e.newResponseMessagesPersisted,userContextMessagesPersisted:e.userContextMessagesPersisted},t),{messages:t,systemMessages:e.systemMessages,taggedSystemMessages:e.taggedSystemMessages,memoryInfo:e.memoryInfo,agentNetworkAppend:e._agentNetworkAppend}}};function mln(e){return e.role==="system"&&e.parts.length>0&&e.parts.every(t=>t.type.startsWith("data-"))}function rX(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n];if(!mln(r)){t.push(r);continue}const s=t[t.length-1],a=e[n+1];s&&s.role==="assistant"?t[t.length-1]={...s,parts:[...s.parts,...r.parts]}:a&&a.role==="assistant"?e[n+1]={...a,parts:[...r.parts,...a.parts]}:t.push({...r,role:"assistant"})}return t}function hMe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function mMe(e,t){if(!e&&!t)return;const n={...e??{}};for(const[r,s]of Object.entries(t??{})){const a=n[r];n[r]=hMe(a)&&hMe(s)?{...a,...s}:s}return n}var gln=class{messages=[];systemMessages=[];taggedSystemMessages={};memoryInfo=null;stateManager=new hln;get memoryMessages(){return this.stateManager.getMemoryMessages()}get newUserMessages(){return this.stateManager.getUserMessages()}get newResponseMessages(){return this.stateManager.getResponseMessages()}get userContextMessages(){return this.stateManager.getContextMessages()}get memoryMessagesPersisted(){return this.stateManager.getMemoryMessagesPersisted()}get newUserMessagesPersisted(){return this.stateManager.getUserMessagesPersisted()}get newResponseMessagesPersisted(){return this.stateManager.getResponseMessagesPersisted()}get userContextMessagesPersisted(){return this.stateManager.getContextMessagesPersisted()}generateMessageId;_agentNetworkAppend=!1;filterIncompleteToolCalls;logger;toAIV5UIMessages(t,n){return rX(t.map(r=>Av.toUIMessage(r,n)))}toAIV4UIMessages(t,n){return rX(t.map(r=>Ew.toUIMessage(r,n)))}toAIV6UIMessages(t){return rX(t.map(oz.toUIMessage))}isRecording=!1;recordedEvents=[];constructor({threadId:t,resourceId:n,generateMessageId:r,logger:s,filterIncompleteToolCalls:a,_agentNetworkAppend:i}={}){t&&(this.memoryInfo={threadId:t,resourceId:n}),this.generateMessageId=r,this.logger=s,this.filterIncompleteToolCalls=a??!0,this._agentNetworkAppend=i||!1}startRecording(){this.isRecording=!0,this.recordedEvents=[]}hasRecordedEvents(){return this.recordedEvents.length>0}getRecordedEvents(){return[...this.recordedEvents]}stopRecording(){this.isRecording=!1;const t=this.getRecordedEvents();return this.recordedEvents=[],t}addSignal(t,n){const r=n?.source??"input",s=this.generateCreatedAt(r,new Date),a=t.acceptedAt??t.createdAt,i=ylt({id:t.id,type:t.type,tagName:t.tagName,contents:t.contents,attributes:t.attributes,metadata:t.metadata,providerOptions:t.providerOptions,createdAt:s,acceptedAt:a});return this.addOne(i.toDBMessage(this.memoryInfo??void 0),r),i}add(t,n,r={}){if(n==="user"&&(n="input"),!t)return this;const s=Array.isArray(t)?t:[t];this.isRecording&&this.recordedEvents.push({type:"add",source:n,count:s.length});for(const a of s){if(nMe(a)&&n==="input"){this.addSignal(a,{source:n});continue}const i=nMe(a)?a.toDBMessage(this.memoryInfo??void 0):typeof a=="string"?{role:"user",content:a}:a;if(Array.isArray(i)){for(const l of i)this.addOne(typeof l=="string"?{role:"user",content:l}:l,n,r);continue}this.addOne(typeof i=="string"?{role:"user",content:i}:i,n,r)}return this}serialize(){return this.stateManager.serializeAll({messages:this.messages,systemMessages:this.systemMessages,taggedSystemMessages:this.taggedSystemMessages,memoryInfo:this.memoryInfo,agentNetworkAppend:this._agentNetworkAppend})}serializeForSpan(){return{messages:this.all.aiV4.core().map(n=>({role:n.role,content:n.content})),systemMessages:[...this.systemMessages.map(n=>({role:n.role,content:n.content})),...Object.entries(this.taggedSystemMessages).flatMap(([n,r])=>r.map(s=>({role:s.role,content:s.content,tag:n})))]}}deserialize(t){const n=this.stateManager.deserializeAll(t);this.messages=n.messages,this.systemMessages=n.systemMessages,this.taggedSystemMessages=n.taggedSystemMessages,this.memoryInfo=n.memoryInfo,this._agentNetworkAppend=n.agentNetworkAppend;for(const r of this.messages)this.updateLastCreatedAt(r);return this}getMessagesForModelPrompt(){return this.messages.flatMap(t=>t.role!=="signal"?[t]:this.convertSignalForModelPrompt(t))}convertSignalForModelPrompt(t){const n=con(t).toLLMMessage(),r=t.createdAt,s={...n,id:t.id,metadata:{createdAt:r}};return[cMe(s,"input",{memoryInfo:this.memoryInfo,newMessageId:()=>t.id,generateCreatedAt:(a,i)=>i instanceof Date?i:typeof i=="string"||typeof i=="number"?new Date(i):r,dbMessages:this.messages})]}makeMessageSourceChecker(){return this.stateManager.createSourceChecker()}getLatestUserContent(){const n=this.all.core().filter(r=>r.role==="user").at(-1)?.content;return n?Bon(n):null}get get(){return{all:this.all,remembered:this.remembered,input:this.input,response:this.response}}get getPersisted(){return{remembered:this.rememberedPersisted,input:this.inputPersisted,taggedSystemMessages:this.taggedSystemMessages,response:this.responsePersisted}}get clear(){return{all:{db:()=>{const t=[...this.messages];return this.messages=[],this.stateManager.clearAll(),this.isRecording&&t.length>0&&this.recordedEvents.push({type:"clear",count:t.length}),t}},input:{db:()=>{const t=Array.from(this.stateManager.getUserMessages());return this.messages=this.messages.filter(n=>!this.stateManager.isUserMessage(n)),this.stateManager.clearUserMessages(),this.isRecording&&t.length>0&&this.recordedEvents.push({type:"clear",source:"input",count:t.length}),t}},response:{db:()=>{const t=Array.from(this.stateManager.getResponseMessages());return this.messages=this.messages.filter(n=>!this.stateManager.isResponseMessage(n)),this.stateManager.clearResponseMessages(),this.isRecording&&t.length>0&&this.recordedEvents.push({type:"clear",source:"response",count:t.length}),t}}}}removeByIds(t){const n=new Set(t),r=[];return this.messages=this.messages.filter(s=>n.has(s.id)?(r.push(s),this.stateManager.removeMessage(s),!1):!0),this.isRecording&&r.length>0&&this.recordedEvents.push({type:"removeByIds",ids:t,count:r.length}),r}all={db:()=>this.messages,v1:()=>MC(this.all.db()),aiV5:{model:()=>{const t=this.getMessagesForModelPrompt();return pv(this.toAIV5UIMessages(t,{transformToolPayloads:!1}),t)},ui:()=>this.toAIV5UIMessages(this.all.db()),prompt:()=>{const t=uMe([...this.systemMessages,...Object.values(this.taggedSystemMessages).flat()],"system",this.createAdapterContext(),this.messages),n=this.getMessagesForModelPrompt(),r=pv(this.toAIV5UIMessages(n,{transformToolPayloads:!1}),n,this.filterIncompleteToolCalls),s=[...t,...r];return vL(s,this.logger)},llmPrompt:async(t={downloadConcurrency:10,downloadRetries:3})=>{const n=this.getMessagesForModelPrompt(),r=pv(this.toAIV5UIMessages(n,{transformToolPayloads:!1}),n,this.filterIncompleteToolCalls),s=new Map;for(const u of this.messages)if(!(u.content?.format!==2||!u.content.parts))for(const d of u.content.parts)d.type==="tool-invocation"&&d.toolInvocation?.state==="result"&&d.providerMetadata?.mastra&&typeof d.providerMetadata.mastra=="object"&&"modelOutput"in d.providerMetadata.mastra&&s.set(d.toolInvocation.toolCallId,d.providerMetadata.mastra.modelOutput);if(s.size>0){for(const u of r)if(!(u.role!=="tool"||!Array.isArray(u.content)))for(let d=0;d<u.content.length;d++){const f=u.content[d];f.type==="tool-result"&&s.has(f.toolCallId)&&(u.content[d]={...f,output:s.get(f.toolCallId)})}}const a=uMe([...this.systemMessages,...Object.values(this.taggedSystemMessages).flat()],"system",this.createAdapterContext(),this.messages),i=await cln({messages:r,downloadConcurrency:t?.downloadConcurrency,downloadRetries:t?.downloadRetries,supportedUrls:t?.supportedUrls});let l=[...a,...r];return r.some(u=>(u.role==="user"||u.role==="assistant")&&typeof u.content!="string"&&u.content.some(d=>d.type==="image"||d.type==="file"))&&(l=l.map(u=>{if(u.role==="user")return typeof u.content=="string"?{role:"user",content:[{type:"text",text:u.content}],providerOptions:u.providerOptions}:{role:"user",content:u.content.map(f=>f.type==="image"||f.type==="file"?fMe(f,i):f).filter(f=>f.type!=="text"||f.text!==""),providerOptions:u.providerOptions};if(u.role==="assistant"&&typeof u.content!="string"){const d=u.content.map(f=>f.type==="file"?fMe(f,i):f);return{...u,content:d}}return u})),l=vL(l,this.logger),l.map(Fon).filter(u=>u.role==="system"||typeof u.content=="string"||u.content.length>0)}},aiV6:{ui:()=>this.toAIV6UIMessages(this.all.db()),llmPrompt:async t=>zon(await this.all.aiV5.llmPrompt(t))},prompt:()=>this.all.aiV4.prompt(),ui:()=>this.toAIV4UIMessages(this.all.db()),core:()=>mh(this.toAIV4UIMessages(this.all.db(),{transformToolPayloads:!1})),aiV4:{ui:()=>this.toAIV4UIMessages(this.all.db()),core:()=>mh(this.toAIV4UIMessages(this.getMessagesForModelPrompt(),{transformToolPayloads:!1})),prompt:()=>{const t=this.all.aiV4.core(),n=[...this.systemMessages,...Object.values(this.taggedSystemMessages).flat(),...t];return vL(n,this.logger)},llmPrompt:()=>{const t=this.all.aiV4.core();let r=[...[...this.systemMessages,...Object.values(this.taggedSystemMessages).flat()],...t];return r=vL(r,this.logger),r.map(Lon)}}};remembered={db:()=>this.messages.filter(t=>this.memoryMessages.has(t)),v1:()=>MC(this.remembered.db()),aiV5:{model:()=>pv(this.toAIV5UIMessages(this.remembered.db(),{transformToolPayloads:!1}),this.messages),ui:()=>this.toAIV5UIMessages(this.remembered.db())},aiV6:{ui:()=>this.toAIV6UIMessages(this.remembered.db())},ui:()=>this.toAIV4UIMessages(this.remembered.db()),core:()=>mh(this.toAIV4UIMessages(this.remembered.db(),{transformToolPayloads:!1})),aiV4:{ui:()=>this.toAIV4UIMessages(this.remembered.db()),core:()=>mh(this.toAIV4UIMessages(this.remembered.db(),{transformToolPayloads:!1}))}};rememberedPersisted={db:()=>this.all.db().filter(t=>this.memoryMessagesPersisted.has(t)),v1:()=>MC(this.rememberedPersisted.db()),aiV5:{model:()=>pv(this.toAIV5UIMessages(this.rememberedPersisted.db(),{transformToolPayloads:!1}),this.messages),ui:()=>this.toAIV5UIMessages(this.rememberedPersisted.db())},aiV6:{ui:()=>this.toAIV6UIMessages(this.rememberedPersisted.db())},ui:()=>this.toAIV4UIMessages(this.rememberedPersisted.db()),core:()=>mh(this.toAIV4UIMessages(this.rememberedPersisted.db(),{transformToolPayloads:!1})),aiV4:{ui:()=>this.toAIV4UIMessages(this.rememberedPersisted.db()),core:()=>mh(this.toAIV4UIMessages(this.rememberedPersisted.db(),{transformToolPayloads:!1}))}};input={db:()=>this.messages.filter(t=>this.newUserMessages.has(t)),v1:()=>MC(this.input.db()),aiV5:{model:()=>pv(this.toAIV5UIMessages(this.input.db(),{transformToolPayloads:!1}),this.messages),ui:()=>this.toAIV5UIMessages(this.input.db())},aiV6:{ui:()=>this.toAIV6UIMessages(this.input.db())},ui:()=>this.toAIV4UIMessages(this.input.db()),core:()=>mh(this.toAIV4UIMessages(this.input.db(),{transformToolPayloads:!1})),aiV4:{ui:()=>this.toAIV4UIMessages(this.input.db()),core:()=>mh(this.toAIV4UIMessages(this.input.db(),{transformToolPayloads:!1}))}};inputPersisted={db:()=>this.messages.filter(t=>this.newUserMessagesPersisted.has(t)),v1:()=>MC(this.inputPersisted.db()),aiV5:{model:()=>pv(this.toAIV5UIMessages(this.inputPersisted.db(),{transformToolPayloads:!1}),this.messages),ui:()=>this.toAIV5UIMessages(this.inputPersisted.db())},aiV6:{ui:()=>this.toAIV6UIMessages(this.inputPersisted.db())},ui:()=>this.toAIV4UIMessages(this.inputPersisted.db()),core:()=>mh(this.toAIV4UIMessages(this.inputPersisted.db(),{transformToolPayloads:!1})),aiV4:{ui:()=>this.toAIV4UIMessages(this.inputPersisted.db()),core:()=>mh(this.toAIV4UIMessages(this.inputPersisted.db(),{transformToolPayloads:!1}))}};response={db:()=>this.messages.filter(t=>this.newResponseMessages.has(t)),v1:()=>MC(this.response.db()),aiV5:{ui:()=>this.toAIV5UIMessages(this.response.db()),model:()=>pv(this.toAIV5UIMessages(this.response.db(),{transformToolPayloads:!1}),this.messages).filter(t=>t.role==="tool"||t.role==="assistant"),modelContent:t=>typeof t=="number"?dMe.extractStepContent(this.response.aiV5.ui(),t,this.response.aiV5.stepContent):this.response.aiV5.model().map(this.response.aiV5.stepContent).flat(),stepContent:t=>dMe.convertToStepContent(t,this.messages,()=>this.response.aiV5.model().at(-1))},aiV6:{ui:()=>this.toAIV6UIMessages(this.response.db())},aiV4:{ui:()=>this.toAIV4UIMessages(this.response.db()),core:()=>mh(this.toAIV4UIMessages(this.response.db(),{transformToolPayloads:!1}))}};responsePersisted={db:()=>this.messages.filter(t=>this.newResponseMessagesPersisted.has(t)),aiV5:{model:()=>pv(this.toAIV5UIMessages(this.responsePersisted.db(),{transformToolPayloads:!1}),this.messages),ui:()=>this.toAIV5UIMessages(this.responsePersisted.db())},aiV6:{ui:()=>this.toAIV6UIMessages(this.responsePersisted.db())},ui:()=>this.toAIV4UIMessages(this.responsePersisted.db()),aiV4:{ui:()=>this.toAIV4UIMessages(this.responsePersisted.db()),core:()=>mh(this.toAIV4UIMessages(this.responsePersisted.db(),{transformToolPayloads:!1}))}};drainUnsavedMessages(){const t=this.messages.filter(n=>this.newUserMessages.has(n)||this.newResponseMessages.has(n));return this.newUserMessages.clear(),this.newResponseMessages.clear(),t.map(n=>this.transformMessageForTranscript(n))}transformToolStateDataForTranscript(t,n){if(!t||typeof t!="object")return t;const r=t,s=r.metadata??r.providerMetadata,a=eg(s,"transcript",n),i=eg(s,"transcript","input-available"),l=n==="approval"?wu(a)?a.transformed:wu(i)?i.transformed:void 0:wu(i)?i.transformed:wu(a)?a.transformed:void 0,c=n==="suspend"&&wu(a)?a.transformed:void 0;return{...r,...l!==void 0?{args:l}:{},...c!==void 0?{suspendPayload:c}:{}}}transformMessageForTranscript(t){if(t.content?.format!==2||!t.content.parts)return t;let n=!1;const r=new Map,s=t.content.parts.map(l=>{if(l.type==="tool-invocation"&&l.toolInvocation){const c=eg(l.providerMetadata,"transcript","input-available"),u=l.toolInvocation.state==="result"?eg(l.providerMetadata,"transcript","output-available")??eg(l.providerMetadata,"transcript","error"):l.toolInvocation.state==="output-error"?eg(l.providerMetadata,"transcript","error"):void 0;if(!c&&!u)return l;n=!0;const d=wu(c)?c.transformed:l.toolInvocation.args,f=l.toolInvocation.state==="result"?wu(u)?u.transformed:l.toolInvocation.result:void 0,p=l.toolInvocation.state==="output-error"?wu(u)?u.transformed:l.toolInvocation.errorText:void 0;return r.set(l.toolInvocation.toolCallId,{args:d,...l.toolInvocation.state==="result"?{result:f}:{},...l.toolInvocation.state==="output-error"?{errorText:p}:{}}),{...l,toolInvocation:{...l.toolInvocation,args:d,...l.toolInvocation.state==="result"?{result:f}:{},...l.toolInvocation.state==="output-error"?{errorText:p}:{}}}}return l.type==="data-tool-call-suspended"||l.type==="data-tool-call-approval"?(n=!0,{...l,data:this.transformToolStateDataForTranscript(l.data,l.type==="data-tool-call-suspended"?"suspend":"approval")}):l}),a=t.content.toolInvocations?.map(l=>{const c=r.get(l.toolCallId);if(!c)return l;const u=l.state;return n=!0,{...l,...c.args!==void 0?{args:c.args}:{},...l.state==="result"&&c.result!==void 0?{result:c.result}:{},...u==="output-error"&&c.errorText!==void 0?{errorText:c.errorText}:{}}}),i=t.content.metadata&&typeof t.content.metadata=="object"?{...t.content.metadata}:t.content.metadata;if(i&&typeof i=="object")for(const[l,c]of[["suspendedTools","suspend"],["pendingToolApprovals","approval"]]){const u=i[l];!u||typeof u!="object"||(n=!0,i[l]=Object.fromEntries(Object.entries(u).map(([d,f])=>[d,this.transformToolStateDataForTranscript(f,c)])))}return n?{...t,content:{...t.content,parts:s,...a?{toolInvocations:a}:{},...i?{metadata:i}:{}}}:t}getEarliestUnsavedMessageTimestamp(){const t=this.messages.filter(n=>this.newUserMessages.has(n)||this.newResponseMessages.has(n));if(t.length!==0)return Math.min(...t.map(n=>new Date(n.createdAt).getTime()))}isNewMessage(t){return this.stateManager.isNewMessage(t)}updateToolInvocation(t,n){if(!t.toolInvocation?.toolCallId)return!1;const r=t.toolInvocation.toolCallId;for(let s=this.messages.length-1;s>=0;s--){const a=this.messages[s];if(!(a.role!=="assistant"||!a.content?.parts))for(let i=0;i<a.content.parts.length;i++){const l=a.content.parts[i];if(l?.type==="tool-invocation"&&l.toolInvocation?.toolCallId===r){const c=l,u=t,d=c.providerMetadata!==void 0||u.providerMetadata!==void 0?{...c.providerMetadata??{},...u.providerMetadata??{}}:void 0;a.content.parts[i]={...t,toolInvocation:{...t.toolInvocation,args:l.toolInvocation.args},...c.providerExecuted!==void 0&&u.providerExecuted===void 0?{providerExecuted:c.providerExecuted}:{},...d!==void 0?{providerMetadata:d}:{}},this.lastCreatedAt=Math.max(this.lastCreatedAt||0,Date.now()),this.updateLastCreatedAt(a);const f=a.content.metadata??{},p=n??{},h=f.backgroundTasks,m=p.backgroundTasks,v=mMe(h,m);return a.content.metadata={...f,...p,...v?{backgroundTasks:v}:{}},this.stateManager.isResponseMessage(a)||(this.stateManager.removeMessage(a),this.stateManager.addToSource(a,"response")),!0}}}return this.logger?.warn(`updateToolInvocation: no matching tool call found for toolCallId=${r}`),!1}updateMessageMetadataByToolCallId(t,n){if(!t)return!1;for(let r=this.messages.length-1;r>=0;r--){const s=this.messages[r];if(s.role!=="assistant"||!s.content?.parts||!s.content.parts.some(f=>f?.type==="tool-invocation"&&f.toolInvocation?.toolCallId===t))continue;const i=s.content.metadata??{},l=n??{},c=i.backgroundTasks,u=l.backgroundTasks,d=mMe(c,u);return s.content.metadata={...i,...l,...d?{backgroundTasks:d}:{}},this.lastCreatedAt=Math.max(this.lastCreatedAt||0,Date.now()),this.updateLastCreatedAt(s),this.stateManager.isResponseMessage(s)||(this.stateManager.removeMessage(s),this.stateManager.addToSource(s,"response")),!0}return this.logger?.warn(`updateMessageMetadataByToolCallId: no matching tool call found for toolCallId=${t}`),!1}stepStart(){const t=this.messages[this.messages.length-1];return!t||t.role!=="assistant"||!t.content?.parts||ub.isSealed(t)||t.content.parts[t.content.parts.length-1]?.type==="step-start"?!1:(t.content.parts.push(ebe({type:"step-start"})),this.stateManager.isResponseMessage(t)||(this.stateManager.removeMessage(t),this.stateManager.addToSource(t,"response")),!0)}markResponseMessageBoundary(t){const n=t?this.messages.find(r=>r.id===t):[...this.messages].reverse().find(r=>r.role==="assistant");return!n||n.role!=="assistant"?!1:(n.content.metadata={...n.content.metadata??{},mastra:{...n.content.metadata?.mastra??{},responseBoundary:!0}},this.stateManager.isResponseMessage(n)||(this.stateManager.removeMessage(n),this.stateManager.addToSource(n,"response")),!0)}enrichLastStepStart(t){const n=this.messages[this.messages.length-1];if(!n||n.role!=="assistant"||!n.content?.parts||ub.isSealed(n))return!1;for(let r=n.content.parts.length-1;r>=0;r--){const s=n.content.parts[r];if(s?.type==="step-start")return s.model?!1:(s.model=t,this.stateManager.isResponseMessage(n)||(this.stateManager.removeMessage(n),this.stateManager.addToSource(n,"response")),!0)}return!1}getSystemMessages(t){return t?this.taggedSystemMessages[t]||[]:this.systemMessages}getAllSystemMessages(){return[...this.systemMessages,...Object.values(this.taggedSystemMessages).flat()]}clearSystemMessages(t){return t?delete this.taggedSystemMessages[t]:this.systemMessages=[],this}replaceAllSystemMessages(t){this.systemMessages=[];for(const n of t)n.role==="system"&&this.systemMessages.push(n);return this}addSystem(t,n){if(!t)return this;for(const r of Array.isArray(t)?t:[t])this.addOneSystem(r,n);return this}addOneSystem(t,n){const r=Jon(t);if(r.role!=="system")throw new Error(`Expected role "system" but saw ${r.role} for message ${JSON.stringify(r,null,2)}`);n&&!this.isDuplicateSystem(r,n)?(this.taggedSystemMessages[n]||=[],this.taggedSystemMessages[n].push(r),this.isRecording&&this.recordedEvents.push({type:"addSystem",tag:n,message:r})):!n&&!this.isDuplicateSystem(r)&&(this.systemMessages.push(r),this.isRecording&&this.recordedEvents.push({type:"addSystem",message:r}))}isDuplicateSystem(t,n){return n?this.taggedSystemMessages[n]?this.taggedSystemMessages[n].some(r=>Wo.fromAIV4CoreMessageContent(r.content)===Wo.fromAIV4CoreMessageContent(t.content)):!1:this.systemMessages.some(r=>Wo.fromAIV4CoreMessageContent(r.content)===Wo.fromAIV4CoreMessageContent(t.content))}getMessageById(t){return this.messages.find(n=>n.id===t)}shouldReplaceMessage(t){if(!this.messages.length)return{exists:!1};if(!("id"in t)||!t?.id)return{exists:!1};const n=this.getMessageById(t.id);return n?{exists:!0,shouldReplace:!nX(n,t),id:n.id}:{exists:!1}}addOne(t,n,r={}){if((!("content"in t)||!t.content&&typeof t.content!="string")&&(!("parts"in t)||!t.parts))throw new sO({id:"INVALID_MESSAGE_CONTENT",domain:Hw.AGENT,category:Ww.USER,text:`Message with role "${t.role}" must have either a 'content' property (string or array) or a 'parts' property (array) that is not empty, null, or undefined. Received message: ${JSON.stringify(t,null,2)}`,details:{role:t.role,messageSource:n,hasContent:"content"in t,hasParts:"parts"in t}});if(t.role==="system"){if(n==="memory")return null;if(Za.isAIV4CoreMessage(t)||Za.isAIV6CoreMessage(t)||Za.isAIV5CoreMessage(t)||Za.isMastraDBMessage(t))return this.addSystem(t);throw new sO({id:"INVALID_SYSTEM_MESSAGE_FORMAT",domain:Hw.AGENT,category:Ww.USER,text:"Invalid system message format. System messages must be CoreMessage format with 'role' and 'content' properties. The content should be a string or valid content array.",details:{messageSource:n,receivedMessage:JSON.stringify(t,null,2)}})}const s=cMe(t,n,this.createAdapterContext()),a=s.role==="signal"?s.content.metadata?.signal:void 0;if(n==="input"&&s.role==="signal"&&!a?.acceptedAt){const b=a?.createdAt??s.createdAt.toISOString();s.createdAt=this.generateCreatedAt(n,s.createdAt),s.content.metadata={...s.content.metadata,signal:{...a,createdAt:s.createdAt.toISOString(),acceptedAt:b}}}const{exists:i,shouldReplace:l,id:c}=this.shouldReplaceMessage(s),u=this.messages.findLastIndex(b=>ub.isSealed(b)),d=this.messages.at(-1),f=this.messages.length-1,p=u===-1||f>u;if(n==="memory"){for(const b of this.messages)if(nX(b,s))return}const h=i&&c?this.messages.find(b=>b.id===c):void 0,m=!!h&&ub.isSealed(h),v=d?this.memoryMessages.has(d):!1;if(r.merge!==!1&&p&&!m&&ub.shouldMerge(d,s,n,v,this._agentNetworkAppend)&&d)ub.merge(d,s),this.updateLastCreatedAt(d),this.pushMessageToSource(d,n);else{let b=-1;l&&(b=this.messages.findIndex(w=>w.id===c));const S=b!==-1&&this.messages[b];if(l&&S){const w=u!==-1&&b<=u;if(ub.isSealed(S)){const k=S.content?.parts||[];let _=0;for(let j=k.length-1;j>=0;j--)if(k[j]?.metadata?.mastra?.sealedAt){_=j+1;break}_===0&&(_=k.length);const C=s.content.parts;let E;if(C.length<=_){if(nX(S,s))return this;E=C}else E=C.slice(_);E.length>0&&(s.id=this.generateMessageId?.({idType:"message",source:"memory"})??fo(),s.content.parts=E,s.createdAt<=S.createdAt&&(s.createdAt=new Date(S.createdAt.getTime()+1)),this.messages.push(s))}else if(w)s.id=this.generateMessageId?.({idType:"message",source:"memory"})??fo(),s.createdAt<=S.createdAt&&(s.createdAt=new Date(S.createdAt.getTime()+1)),this.messages.push(s);else{const k=this.memoryMessages.has(S);if(r.merge!==!1&&ub.shouldMerge(S,s,n,k,this._agentNetworkAppend))return ub.merge(S,s),this.updateLastCreatedAt(S),this.pushMessageToSource(S,n),this.messages.sort((C,E)=>C.createdAt.getTime()-E.createdAt.getTime()),this;this.messages[b]=s}}else i||this.messages.push(s);this.pushMessageToSource(s,n)}for(const b of this.messages)this.updateLastCreatedAt(b);return this.messages.sort((b,S)=>b.createdAt.getTime()-S.createdAt.getTime()),this}pushMessageToSource(t,n){this.stateManager.addToSource(t,n)}lastCreatedAt;updateLastCreatedAt(t){this.lastCreatedAt=Math.max(this.lastCreatedAt||0,t.createdAt.getTime())}generateCreatedAt(t,n){const r=n instanceof Date?n:typeof n=="string"||typeof n=="number"?new Date(n):void 0;if(r&&!this.lastCreatedAt)return this.lastCreatedAt=r.getTime(),r;if(r&&t==="memory")return r;const s=new Date,a=r?.getTime()||s.getTime(),i=this.lastCreatedAt||0;if(a<=i){const l=new Date(i+1);return this.lastCreatedAt=l.getTime(),l}return this.lastCreatedAt=a,r??s}newMessageId(t){return this.generateMessageId?this.generateMessageId({idType:"message",source:"agent",threadId:this.memoryInfo?.threadId,resourceId:this.memoryInfo?.resourceId,role:t}):fo()}createAdapterContext(){return{memoryInfo:this.memoryInfo,newMessageId:()=>this.newMessageId(),generateCreatedAt:(t,n)=>this.generateCreatedAt(t,n),dbMessages:this.messages}}};const vln=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),yln=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),gMe=e=>{const t=yln(e);return t.charAt(0).toUpperCase()+t.slice(1)},klt=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),bln=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var xln={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const wln=g.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:i,...l},c)=>g.createElement("svg",{ref:c,...xln,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:klt("lucide",s),...!a&&!bln(l)&&{"aria-hidden":"true"},...l},[...i.map(([u,d])=>g.createElement(u,d)),...Array.isArray(a)?a:[a]]));const Xe=(e,t)=>{const n=g.forwardRef(({className:r,...s},a)=>g.createElement(wln,{ref:a,iconNode:t,className:klt(`lucide-${vln(gMe(e))}`,`lucide-${e}`,r),...s}));return n.displayName=gMe(e),n};const Sln=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],Olt=Xe("align-left",Sln);const kln=[["path",{d:"M17.5 12c0 4.4-3.6 8-8 8A4.5 4.5 0 0 1 5 15.5c0-6 8-4 8-8.5a3 3 0 1 0-6 0c0 3 2.5 8.5 12 13",key:"1o9ehi"}],["path",{d:"M16 12h3",key:"4uvgyw"}]],Oln=Xe("ampersand",kln);const _ln=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Cln=Xe("arrow-down",_ln);const Eln=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Nc=Xe("arrow-left",Eln);const jln=[["path",{d:"M17 12H3",key:"8awo09"}],["path",{d:"m11 18 6-6-6-6",key:"8c2y43"}],["path",{d:"M21 5v14",key:"nzette"}]],_lt=Xe("arrow-right-to-line",jln);const Tln=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],mm=Xe("arrow-right",Tln);const Nln=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],pD=Xe("arrow-up",Nln);const Iln=[["path",{d:"M2 10v3",key:"1fnikh"}],["path",{d:"M6 6v11",key:"11sgs0"}],["path",{d:"M10 3v18",key:"yhl04a"}],["path",{d:"M14 8v7",key:"3a1oy3"}],["path",{d:"M18 5v13",key:"123xd1"}],["path",{d:"M22 10v3",key:"154ddg"}]],Aln=Xe("audio-lines",Iln);const Rln=[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]],Pln=Xe("award",Rln);const $ln=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]],Mln=Xe("ban",$ln);const Dln=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Lln=Xe("bell",Dln);const Fln=[["path",{d:"M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2",key:"1ah6g2"}],["rect",{x:"14",y:"2",width:"8",height:"8",rx:"1",key:"88lufb"}]],Clt=Xe("blocks",Fln);const zln=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],Elt=Xe("book-open",zln);const Bln=[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]],jlt=Xe("book",Bln);const Uln=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"12",x2:"12",y1:"7",y2:"13",key:"1cppfj"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]],qln=Xe("bookmark-plus",Uln);const Vln=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],EF=Xe("bot",Vln);const Hln=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],ky=Xe("braces",Hln);const Wln=[["path",{d:"M16 3h3a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1h-3",key:"1kt8lf"}],["path",{d:"M8 21H5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h3",key:"gduv9"}]],Zln=Xe("brackets",Wln);const Gln=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]],Rv=Xe("brain",Gln);const Qln=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]],Tlt=Xe("building",Qln);const Yln=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]],Xln=Xe("calculator",Yln);const Kln=[["path",{d:"M11 14h1v4",key:"fy54vd"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]],Nlt=Xe("calendar-1",Kln);const Jln=[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],hD=Xe("calendar-clock",Jln);const ecn=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Ilt=Xe("calendar",ecn);const tcn=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Js=Xe("check",tcn);const ncn=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Sa=Xe("chevron-down",ncn);const rcn=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Alt=Xe("chevron-left",rcn);const scn=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ta=Xe("chevron-right",scn);const acn=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],f_=Xe("chevron-up",acn);const icn=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],Rlt=Xe("chevrons-down-up",icn);const ocn=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Plt=Xe("chevrons-up-down",ocn);const lcn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Qj=Xe("circle-alert",lcn);const ccn=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],uO=Xe("circle-check-big",ccn);const ucn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],oq=Xe("circle-check",ucn);const dcn=[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]],fcn=Xe("circle-dashed",dcn);const pcn=[["path",{d:"M15.6 2.7a10 10 0 1 0 5.7 5.7",key:"1e0p6d"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M13.4 10.6 19 5",key:"1kr7tw"}]],hcn=Xe("circle-gauge",pcn);const mcn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]],lq=Xe("circle-pause",mcn);const gcn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]],tbe=Xe("circle-play",gcn);const vcn=[["path",{d:"M22 2 2 22",key:"y4kqgn"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ycn=Xe("circle-slash-2",vcn);const bcn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]],Of=Xe("circle-slash",bcn);const xcn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],$lt=Xe("circle-stop",xcn);const wcn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],UP=Xe("circle-x",wcn);const Scn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],kcn=Xe("circle",Scn);const Ocn=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]],cq=Xe("clipboard-check",Ocn);const _cn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]],Ccn=Xe("clock-3",_cn);const Ecn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],dO=Xe("clock",Ecn);const jcn=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],Mlt=Xe("cloud-upload",jcn);const Tcn=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],sX=Xe("cloud",Tcn);const Ncn=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],Icn=Xe("code",Ncn);const Acn=[["path",{d:"M12 20a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",key:"sobvz5"}],["path",{d:"M12 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z",key:"11i496"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 22v-2",key:"1osdcq"}],["path",{d:"m17 20.66-1-1.73",key:"eq3orb"}],["path",{d:"M11 10.27 7 3.34",key:"16pf9h"}],["path",{d:"m20.66 17-1.73-1",key:"sg0v6f"}],["path",{d:"m3.34 7 1.73 1",key:"1ulond"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"m20.66 7-1.73 1",key:"1ow05n"}],["path",{d:"m3.34 17 1.73-1",key:"nuk764"}],["path",{d:"m17 3.34-1 1.73",key:"2wel8s"}],["path",{d:"m11 13.73-4 6.93",key:"794ttg"}]],Rcn=Xe("cog",Acn);const Pcn=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Dlt=Xe("columns-2",Pcn);const $cn=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Dp=Xe("copy",$cn);const Mcn=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],Dcn=Xe("corner-down-right",Mcn);const Lcn=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],nbe=Xe("cpu",Lcn);const Fcn=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],iy=Xe("database",Fcn);const zcn=[["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 10h14",key:"elsbfy"}],["path",{d:"M5 21h14",key:"11awu3"}]],Bcn=Xe("diff",zcn);const Ucn=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],lf=Xe("download",Ucn);const qcn=[["path",{d:"M10 18a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H5a3 3 0 0 1-3-3 1 1 0 0 1 1-1z",key:"ioqxb1"}],["path",{d:"M13 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1l-.81 3.242a1 1 0 0 1-.97.758H8",key:"1rs59n"}],["path",{d:"M14 4h3a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-3",key:"105ega"}],["path",{d:"M18 6h4",key:"66u95g"}],["path",{d:"m5 10-2 8",key:"xt2lic"}],["path",{d:"m7 18 2-8",key:"1bzku2"}]],Vcn=Xe("drill",qcn);const Hcn=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Wcn=Xe("earth",Hcn);const Zcn=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],mD=Xe("ellipsis-vertical",Zcn);const Gcn=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],Qcn=Xe("equal",Gcn);const Ycn=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],_a=Xe("external-link",Ycn);const Xcn=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Kcn=Xe("eye-off",Xcn);const Jcn=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Kc=Xe("eye",Jcn);const eun=[["path",{d:"M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"rslqgf"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0",key:"9f7x3i"}]],tun=Xe("file-audio",eun);const nun=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],run=Xe("file-code-2",nun);const sun=[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]],yN=Xe("file-code",sun);const aun=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 15h10",key:"jfw4w8"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],fO=Xe("file-input",aun);const iun=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],bN=Xe("file-json",iun);const oun=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 7V4a2 2 0 0 1 2-2 2 2 0 0 0-2 2",key:"1vk7w2"}],["path",{d:"M4.063 20.999a2 2 0 0 0 2 1L18 22a2 2 0 0 0 2-2V7l-5-5H6",key:"1jink5"}],["path",{d:"m5 11-3 3",key:"1dgrs4"}],["path",{d:"m5 17-3-3h10",key:"1mvvaf"}]],gg=Xe("file-output",oun);const lun=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Oc=Xe("file-text",lun);const cun=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m10 11 5 3-5 3v-6Z",key:"7ntvm4"}]],uun=Xe("file-video",cun);const dun=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]],rbe=Xe("file",dun);const fun=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],Llt=Xe("flask-conical",fun);const pun=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],xN=Xe("folder-open",pun);const hun=[["path",{d:"M2 7.5V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-1.5",key:"1yk7aj"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m5 10-3 3 3 3",key:"1r8ie0"}]],mun=Xe("folder-output",hun);const gun=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],uq=Xe("folder-plus",gun);const vun=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],yun=Xe("folder-tree",vun);const bun=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],gD=Xe("folder",bun);const xun=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],wun=Xe("frown",xun);const Sun=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Flt=Xe("funnel",Sun);const kun=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],rm=Xe("gauge",kun);const Oun=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],sbe=Xe("git-branch",Oun);const _un=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]],Cun=Xe("git-compare-arrows",_un);const Eun=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]],Xw=Xe("git-compare",Eun);const jun=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]],zlt=Xe("git-pull-request",jun);const Tun=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],Blt=Xe("github",Tun);const Nun=[["path",{d:"M15.686 15A14.5 14.5 0 0 1 12 22a14.5 14.5 0 0 1 0-20 10 10 0 1 0 9.542 13",key:"qkt0x6"}],["path",{d:"M2 12h8.5",key:"ovaggd"}],["path",{d:"M20 6V4a2 2 0 1 0-4 0v2",key:"1of5e8"}],["rect",{width:"8",height:"5",x:"14",y:"6",rx:"1",key:"1fmf51"}]],Iun=Xe("globe-lock",Nun);const Aun=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Lx=Xe("globe",Aun);const Run=[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]],Ult=Xe("graduation-cap",Run);const Pun=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],dq=Xe("grip-vertical",Pun);const $un=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],Kde=Xe("hard-drive",$un);const Mun=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],vMe=Xe("hash",Mun);const Dun=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],p_=Xe("history",Dun);const Lun=[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]],Jde=Xe("hourglass",Lun);const Fun=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]],zun=Xe("house",Fun);const Bun=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],abe=Xe("image",Bun);const Uun=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Fx=Xe("info",Uun);const qun=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],Vun=Xe("key-round",qun);const Hun=[["rect",{width:"18",height:"12",x:"3",y:"4",rx:"2",ry:"2",key:"1qhy41"}],["line",{x1:"2",x2:"22",y1:"20",y2:"20",key:"ni3hll"}]],yMe=Xe("laptop-minimal",Hun);const Wun=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],fq=Xe("layers",Wun);const Zun=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],Gun=Xe("layout-grid",Zun);const Qun=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],qP=Xe("library",Qun);const Yun=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],Xun=Xe("lightbulb",Yun);const Kun=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Jun=Xe("link-2",Kun);const edn=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],qlt=Xe("link",edn);const tdn=[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]],Vlt=Xe("list-checks",tdn);const ndn=[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]],efe=Xe("list",ndn);const rdn=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],oa=Xe("loader-circle",rdn);const sdn=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],yf=Xe("lock",sdn);const adn=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],idn=Xe("maximize",adn);const odn=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],ldn=Xe("maximize-2",odn);const cdn=[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Hlt=Xe("message-circle-question-mark",cdn);const udn=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]],Yj=Xe("message-square",udn);const ddn=[["path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z",key:"p1xzt8"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1",key:"1cx29u"}]],fdn=Xe("messages-square",ddn);const pdn=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],hdn=Xe("mic",pdn);const mdn=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],gdn=Xe("minimize-2",mdn);const vdn=[["path",{d:"M5 12h14",key:"1ays0h"}]],ydn=Xe("minus",vdn);const bdn=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Wlt=Xe("monitor",bdn);const xdn=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],wdn=Xe("moon",xdn);const Sdn=[["path",{d:"M11 19H5V13",key:"1akmht"}],["path",{d:"M19 5L5 19",key:"72u4yj"}]],kdn=Xe("move-down-left",Sdn);const Odn=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],ibe=Xe("move-right",Odn);const _dn=[["path",{d:"M13 5H19V11",key:"1n1gyv"}],["path",{d:"M19 5L5 19",key:"72u4yj"}]],Cdn=Xe("move-up-right",_dn);const Edn=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],Zlt=Xe("network",Edn);const jdn=[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]],Tdn=Xe("notebook-pen",jdn);const Ndn=[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Idn=Xe("octagon-x",Ndn);const Adn=[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]],Glt=Xe("package-open",Adn);const Rdn=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],Zv=Xe("package",Rdn);const Pdn=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],$dn=Xe("panel-left",Pdn);const Mdn=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],bMe=Xe("paperclip",Mdn);const Ddn=[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]],Qlt=Xe("pause",Ddn);const Ldn=[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]],Fdn=Xe("pen-line",Ldn);const zdn=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Ylt=Xe("pen",zdn);const Bdn=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Lp=Xe("pencil",Bdn);const Udn=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],Fp=Xe("play",Udn);const qdn=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],Vdn=Xe("plug",qdn);const Hdn=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Vr=Xe("plus",Hdn);const Wdn=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],Xlt=Xe("radio",Wdn);const Zdn=[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M14 8H8",key:"1l3xfs"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M13 16H8",key:"wsln4y"}]],Oh=Xe("receipt-text",Zdn);const Gdn=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M7 12h.01",key:"eqddd0"}]],obe=Xe("rectangle-ellipsis",Gdn);const Qdn=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],Ydn=Xe("refresh-ccw",Qdn);const Xdn=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Kw=Xe("refresh-cw",Xdn);const Kdn=[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}],["path",{d:"M11 10h1v4",key:"70cz1p"}]],Jdn=Xe("repeat-1",Kdn);const efn=[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]],tfn=Xe("repeat",efn);const nfn=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Klt=Xe("rotate-ccw",nfn);const rfn=[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]],lbe=Xe("route",rfn);const sfn=[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]],afn=Xe("ruler",sfn);const ifn=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],gd=Xe("save",ifn);const ofn=[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]],lfn=Xe("scale",ofn);const cfn=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Xa=Xe("search",cfn);const ufn=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],xMe=Xe("send",ufn);const dfn=[["path",{d:"m10.852 14.772-.383.923",key:"11vil6"}],["path",{d:"M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923",key:"1v3clb"}],["path",{d:"m13.148 9.228.383-.923",key:"t2zzyc"}],["path",{d:"m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544",key:"1bxfiv"}],["path",{d:"m14.772 10.852.923-.383",key:"k9m8cz"}],["path",{d:"m14.772 13.148.923.383",key:"1xvhww"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"m9.228 10.852-.923-.383",key:"1wtb30"}],["path",{d:"m9.228 13.148-.923.383",key:"1a830x"}]],Jlt=Xe("server-cog",dfn);const ffn=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],jF=Xe("server",ffn);const pfn=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],pq=Xe("settings-2",pfn);const hfn=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],lz=Xe("settings",hfn);const mfn=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],ect=Xe("share-2",mfn);const gfn=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],cbe=Xe("shield-alert",gfn);const vfn=[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]],hq=Xe("sliders-horizontal",vfn);const yfn=[["line",{x1:"4",x2:"4",y1:"21",y2:"14",key:"1p332r"}],["line",{x1:"4",x2:"4",y1:"10",y2:"3",key:"gb41h5"}],["line",{x1:"12",x2:"12",y1:"21",y2:"12",key:"hf2csr"}],["line",{x1:"12",x2:"12",y1:"8",y2:"3",key:"1kfi7u"}],["line",{x1:"20",x2:"20",y1:"21",y2:"16",key:"1lhrwl"}],["line",{x1:"20",x2:"20",y1:"12",y2:"3",key:"16vvfq"}],["line",{x1:"2",x2:"6",y1:"14",y2:"14",key:"1uebub"}],["line",{x1:"10",x2:"14",y1:"8",y2:"8",key:"1yglbp"}],["line",{x1:"18",x2:"22",y1:"16",y2:"16",key:"1jxqpz"}]],bfn=Xe("sliders-vertical",yfn);const xfn=[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]],wg=Xe("sparkles",xfn);const wfn=[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]],Sfn=Xe("square-arrow-out-up-right",wfn);const kfn=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]],Ofn=Xe("square-arrow-right",kfn);const _fn=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],Cfn=Xe("square-terminal",_fn);const Efn=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],Xj=Xe("star",Efn);const jfn=[["line",{x1:"6",x2:"6",y1:"4",y2:"20",key:"fy8qot"}],["polygon",{points:"10,4 20,12 10,20",key:"1mc1pf"}]],tct=Xe("step-forward",jfn);const Tfn=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],Nfn=Xe("sun",Tfn);const Ifn=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],wN=Xe("tag",Ifn);const Afn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],ube=Xe("target",Afn);const Rfn=[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]],dbe=Xe("thumbs-down",Rfn);const Pfn=[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]],fbe=Xe("thumbs-up",Pfn);const $fn=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],tfe=Xe("timer",$fn);const Mfn=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],au=Xe("trash-2",Mfn);const Dfn=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]],pbe=Xe("trash",Dfn);const Lfn=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Ep=Xe("triangle-alert",Lfn);const Ffn=[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]],zfn=Xe("unplug",Ffn);const Bfn=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],mq=Xe("upload",Bfn);const Ufn=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],nct=Xe("wand-sparkles",Ufn);const qfn=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],vD=Xe("workflow",qfn);const Vfn=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]],zp=Xe("wrench",Vfn);const Hfn=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],vs=Xe("x",Hfn);const Wfn=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],hbe=Xe("zap",Wfn),Zfn=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},Gfn=(e,t)=>({classGroupId:e,validator:t}),rct=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),cz="-",wMe=[],Qfn="arbitrary..",Yfn=e=>{const t=Kfn(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return Xfn(i);const l=i.split(cz),c=l[0]===""&&l.length>1?1:0;return sct(l,c,t)},getConflictingClassGroupIds:(i,l)=>{if(l){const c=r[i],u=n[i];return c?u?Zfn(u,c):c:u||wMe}return n[i]||wMe}}},sct=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const s=e[t],a=n.nextPart.get(s);if(a){const u=sct(e,t+1,a);if(u)return u}const i=n.validators;if(i===null)return;const l=t===0?e.join(cz):e.slice(t).join(cz),c=i.length;for(let u=0;u<c;u++){const d=i[u];if(d.validator(l))return d.classGroupId}},Xfn=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?Qfn+r:void 0})(),Kfn=e=>{const{theme:t,classGroups:n}=e;return Jfn(n,t)},Jfn=(e,t)=>{const n=rct();for(const r in e){const s=e[r];mbe(s,n,r,t)}return n},mbe=(e,t,n,r)=>{const s=e.length;for(let a=0;a<s;a++){const i=e[a];epn(i,t,n,r)}},epn=(e,t,n,r)=>{if(typeof e=="string"){tpn(e,t,n);return}if(typeof e=="function"){npn(e,t,n,r);return}rpn(e,t,n,r)},tpn=(e,t,n)=>{const r=e===""?t:act(t,e);r.classGroupId=n},npn=(e,t,n,r)=>{if(spn(e)){mbe(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Gfn(n,e))},rpn=(e,t,n,r)=>{const s=Object.entries(e),a=s.length;for(let i=0;i<a;i++){const[l,c]=s[i];mbe(c,act(t,l),n,r)}},act=(e,t)=>{let n=e;const r=t.split(cz),s=r.length;for(let a=0;a<s;a++){const i=r[a];let l=n.nextPart.get(i);l||(l=rct(),n.nextPart.set(i,l)),n=l}return n},spn=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,apn=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const s=(a,i)=>{n[a]=i,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(a){let i=n[a];if(i!==void 0)return i;if((i=r[a])!==void 0)return s(a,i),i},set(a,i){a in n?n[a]=i:s(a,i)}}},nfe="!",SMe=":",ipn=[],kMe=(e,t,n,r,s)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:s}),opn=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=s=>{const a=[];let i=0,l=0,c=0,u;const d=s.length;for(let v=0;v<d;v++){const y=s[v];if(i===0&&l===0){if(y===SMe){a.push(s.slice(c,v)),c=v+1;continue}if(y==="/"){u=v;continue}}y==="["?i++:y==="]"?i--:y==="("?l++:y===")"&&l--}const f=a.length===0?s:s.slice(c);let p=f,h=!1;f.endsWith(nfe)?(p=f.slice(0,-1),h=!0):f.startsWith(nfe)&&(p=f.slice(1),h=!0);const m=u&&u>c?u-c:void 0;return kMe(a,h,p,m)};if(t){const s=t+SMe,a=r;r=i=>i.startsWith(s)?a(i.slice(s.length)):kMe(ipn,!1,i,void 0,!0)}if(n){const s=r;r=a=>n({className:a,parseClassName:s})}return r},lpn=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let s=[];for(let a=0;a<n.length;a++){const i=n[a],l=i[0]==="[",c=t.has(i);l||c?(s.length>0&&(s.sort(),r.push(...s),s=[]),r.push(i)):s.push(i)}return s.length>0&&(s.sort(),r.push(...s)),r}},cpn=e=>({cache:apn(e.cacheSize),parseClassName:opn(e),sortModifiers:lpn(e),...Yfn(e)}),upn=/\s+/,dpn=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:s,sortModifiers:a}=t,i=[],l=e.trim().split(upn);let c="";for(let u=l.length-1;u>=0;u-=1){const d=l[u],{isExternal:f,modifiers:p,hasImportantModifier:h,baseClassName:m,maybePostfixModifierPosition:v}=n(d);if(f){c=d+(c.length>0?" "+c:c);continue}let y=!!v,b=r(y?m.substring(0,v):m);if(!b){if(!y){c=d+(c.length>0?" "+c:c);continue}if(b=r(m),!b){c=d+(c.length>0?" "+c:c);continue}y=!1}const S=p.length===0?"":p.length===1?p[0]:a(p).join(":"),w=h?S+nfe:S,k=w+b;if(i.indexOf(k)>-1)continue;i.push(k);const _=s(b,y);for(let C=0;C<_.length;++C){const E=_[C];i.push(w+E)}c=d+(c.length>0?" "+c:c)}return c},fpn=(...e)=>{let t=0,n,r,s="";for(;t<e.length;)(n=e[t++])&&(r=ict(n))&&(s&&(s+=" "),s+=r);return s},ict=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=ict(e[r]))&&(n&&(n+=" "),n+=t);return n},ppn=(e,...t)=>{let n,r,s,a;const i=c=>{const u=t.reduce((d,f)=>f(d),e());return n=cpn(u),r=n.cache.get,s=n.cache.set,a=l,l(c)},l=c=>{const u=r(c);if(u)return u;const d=dpn(c,n);return s(c,d),d};return a=i,(...c)=>a(fpn(...c))},hpn=[],Fl=e=>{const t=n=>n[e]||hpn;return t.isThemeGetter=!0,t},oct=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,lct=/^\((?:(\w[\w-]*):)?(.+)\)$/i,mpn=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,gpn=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,vpn=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ypn=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,bpn=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,xpn=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,R0=e=>mpn.test(e),us=e=>!!e&&!Number.isNaN(Number(e)),P0=e=>!!e&&Number.isInteger(Number(e)),aX=e=>e.endsWith("%")&&us(e.slice(0,-1)),db=e=>gpn.test(e),cct=()=>!0,wpn=e=>vpn.test(e)&&!ypn.test(e),gbe=()=>!1,Spn=e=>bpn.test(e),kpn=e=>xpn.test(e),Opn=e=>!Ln(e)&&!Un(e),_pn=e=>I1(e,fct,gbe),Ln=e=>oct.test(e),_S=e=>I1(e,pct,wpn),OMe=e=>I1(e,Rpn,us),Cpn=e=>I1(e,mct,cct),Epn=e=>I1(e,hct,gbe),_Me=e=>I1(e,uct,gbe),jpn=e=>I1(e,dct,kpn),yL=e=>I1(e,gct,Spn),Un=e=>lct.test(e),EA=e=>h_(e,pct),Tpn=e=>h_(e,hct),CMe=e=>h_(e,uct),Npn=e=>h_(e,fct),Ipn=e=>h_(e,dct),bL=e=>h_(e,gct,!0),Apn=e=>h_(e,mct,!0),I1=(e,t,n)=>{const r=oct.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},h_=(e,t,n=!1)=>{const r=lct.exec(e);return r?r[1]?t(r[1]):n:!1},uct=e=>e==="position"||e==="percentage",dct=e=>e==="image"||e==="url",fct=e=>e==="length"||e==="size"||e==="bg-size",pct=e=>e==="length",Rpn=e=>e==="number",hct=e=>e==="family-name",mct=e=>e==="number"||e==="weight",gct=e=>e==="shadow",Ppn=()=>{const e=Fl("color"),t=Fl("font"),n=Fl("text"),r=Fl("font-weight"),s=Fl("tracking"),a=Fl("leading"),i=Fl("breakpoint"),l=Fl("container"),c=Fl("spacing"),u=Fl("radius"),d=Fl("shadow"),f=Fl("inset-shadow"),p=Fl("text-shadow"),h=Fl("drop-shadow"),m=Fl("blur"),v=Fl("perspective"),y=Fl("aspect"),b=Fl("ease"),S=Fl("animate"),w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],k=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],_=()=>[...k(),Un,Ln],C=()=>["auto","hidden","clip","visible","scroll"],E=()=>["auto","contain","none"],j=()=>[Un,Ln,c],N=()=>[R0,"full","auto",...j()],I=()=>[P0,"none","subgrid",Un,Ln],R=()=>["auto",{span:["full",P0,Un,Ln]},P0,Un,Ln],P=()=>[P0,"auto",Un,Ln],L=()=>["auto","min","max","fr",Un,Ln],M=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],q=()=>["start","end","center","stretch","center-safe","end-safe"],H=()=>["auto",...j()],F=()=>[R0,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...j()],z=()=>[R0,"screen","full","dvw","lvw","svw","min","max","fit",...j()],B=()=>[R0,"screen","full","lh","dvh","lvh","svh","min","max","fit",...j()],D=()=>[e,Un,Ln],Q=()=>[...k(),CMe,_Me,{position:[Un,Ln]}],V=()=>["no-repeat",{repeat:["","x","y","space","round"]}],$=()=>["auto","cover","contain",Npn,_pn,{size:[Un,Ln]}],U=()=>[aX,EA,_S],Z=()=>["","none","full",u,Un,Ln],X=()=>["",us,EA,_S],te=()=>["solid","dashed","dotted","double"],J=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ee=()=>[us,aX,CMe,_Me],ae=()=>["","none",m,Un,Ln],ce=()=>["none",us,Un,Ln],Y=()=>["none",us,Un,Ln],ne=()=>[us,Un,Ln],ue=()=>[R0,"full",...j()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[db],breakpoint:[db],color:[cct],container:[db],"drop-shadow":[db],ease:["in","out","in-out"],font:[Opn],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[db],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[db],shadow:[db],spacing:["px",us],text:[db],"text-shadow":[db],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",R0,Ln,Un,y]}],container:["container"],columns:[{columns:[us,Ln,Un,l]}],"break-after":[{"break-after":w()}],"break-before":[{"break-before":w()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:_()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:E()}],"overscroll-x":[{"overscroll-x":E()}],"overscroll-y":[{"overscroll-y":E()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:N()}],"inset-x":[{"inset-x":N()}],"inset-y":[{"inset-y":N()}],start:[{"inset-s":N(),start:N()}],end:[{"inset-e":N(),end:N()}],"inset-bs":[{"inset-bs":N()}],"inset-be":[{"inset-be":N()}],top:[{top:N()}],right:[{right:N()}],bottom:[{bottom:N()}],left:[{left:N()}],visibility:["visible","invisible","collapse"],z:[{z:[P0,"auto",Un,Ln]}],basis:[{basis:[R0,"full","auto",l,...j()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[us,R0,"auto","initial","none",Ln]}],grow:[{grow:["",us,Un,Ln]}],shrink:[{shrink:["",us,Un,Ln]}],order:[{order:[P0,"first","last","none",Un,Ln]}],"grid-cols":[{"grid-cols":I()}],"col-start-end":[{col:R()}],"col-start":[{"col-start":P()}],"col-end":[{"col-end":P()}],"grid-rows":[{"grid-rows":I()}],"row-start-end":[{row:R()}],"row-start":[{"row-start":P()}],"row-end":[{"row-end":P()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":L()}],"auto-rows":[{"auto-rows":L()}],gap:[{gap:j()}],"gap-x":[{"gap-x":j()}],"gap-y":[{"gap-y":j()}],"justify-content":[{justify:[...M(),"normal"]}],"justify-items":[{"justify-items":[...q(),"normal"]}],"justify-self":[{"justify-self":["auto",...q()]}],"align-content":[{content:["normal",...M()]}],"align-items":[{items:[...q(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...q(),{baseline:["","last"]}]}],"place-content":[{"place-content":M()}],"place-items":[{"place-items":[...q(),"baseline"]}],"place-self":[{"place-self":["auto",...q()]}],p:[{p:j()}],px:[{px:j()}],py:[{py:j()}],ps:[{ps:j()}],pe:[{pe:j()}],pbs:[{pbs:j()}],pbe:[{pbe:j()}],pt:[{pt:j()}],pr:[{pr:j()}],pb:[{pb:j()}],pl:[{pl:j()}],m:[{m:H()}],mx:[{mx:H()}],my:[{my:H()}],ms:[{ms:H()}],me:[{me:H()}],mbs:[{mbs:H()}],mbe:[{mbe:H()}],mt:[{mt:H()}],mr:[{mr:H()}],mb:[{mb:H()}],ml:[{ml:H()}],"space-x":[{"space-x":j()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":j()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],"inline-size":[{inline:["auto",...z()]}],"min-inline-size":[{"min-inline":["auto",...z()]}],"max-inline-size":[{"max-inline":["none",...z()]}],"block-size":[{block:["auto",...B()]}],"min-block-size":[{"min-block":["auto",...B()]}],"max-block-size":[{"max-block":["none",...B()]}],w:[{w:[l,"screen",...F()]}],"min-w":[{"min-w":[l,"screen","none",...F()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",n,EA,_S]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Apn,Cpn]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",aX,Ln]}],"font-family":[{font:[Tpn,Epn,t]}],"font-features":[{"font-features":[Ln]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,Un,Ln]}],"line-clamp":[{"line-clamp":[us,"none",Un,OMe]}],leading:[{leading:[a,...j()]}],"list-image":[{"list-image":["none",Un,Ln]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Un,Ln]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...te(),"wavy"]}],"text-decoration-thickness":[{decoration:[us,"from-font","auto",Un,_S]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[us,"auto",Un,Ln]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:j()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Un,Ln]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Un,Ln]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Q()}],"bg-repeat":[{bg:V()}],"bg-size":[{bg:$()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},P0,Un,Ln],radial:["",Un,Ln],conic:[P0,Un,Ln]},Ipn,jpn]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:U()}],"gradient-via-pos":[{via:U()}],"gradient-to-pos":[{to:U()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:Z()}],"rounded-s":[{"rounded-s":Z()}],"rounded-e":[{"rounded-e":Z()}],"rounded-t":[{"rounded-t":Z()}],"rounded-r":[{"rounded-r":Z()}],"rounded-b":[{"rounded-b":Z()}],"rounded-l":[{"rounded-l":Z()}],"rounded-ss":[{"rounded-ss":Z()}],"rounded-se":[{"rounded-se":Z()}],"rounded-ee":[{"rounded-ee":Z()}],"rounded-es":[{"rounded-es":Z()}],"rounded-tl":[{"rounded-tl":Z()}],"rounded-tr":[{"rounded-tr":Z()}],"rounded-br":[{"rounded-br":Z()}],"rounded-bl":[{"rounded-bl":Z()}],"border-w":[{border:X()}],"border-w-x":[{"border-x":X()}],"border-w-y":[{"border-y":X()}],"border-w-s":[{"border-s":X()}],"border-w-e":[{"border-e":X()}],"border-w-bs":[{"border-bs":X()}],"border-w-be":[{"border-be":X()}],"border-w-t":[{"border-t":X()}],"border-w-r":[{"border-r":X()}],"border-w-b":[{"border-b":X()}],"border-w-l":[{"border-l":X()}],"divide-x":[{"divide-x":X()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":X()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...te(),"hidden","none"]}],"divide-style":[{divide:[...te(),"hidden","none"]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-bs":[{"border-bs":D()}],"border-color-be":[{"border-be":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...te(),"none","hidden"]}],"outline-offset":[{"outline-offset":[us,Un,Ln]}],"outline-w":[{outline:["",us,EA,_S]}],"outline-color":[{outline:D()}],shadow:[{shadow:["","none",d,bL,yL]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":["none",f,bL,yL]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:X()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[us,_S]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":X()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":["none",p,bL,yL]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[us,Un,Ln]}],"mix-blend":[{"mix-blend":[...J(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":J()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[us]}],"mask-image-linear-from-pos":[{"mask-linear-from":ee()}],"mask-image-linear-to-pos":[{"mask-linear-to":ee()}],"mask-image-linear-from-color":[{"mask-linear-from":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"mask-image-t-from-pos":[{"mask-t-from":ee()}],"mask-image-t-to-pos":[{"mask-t-to":ee()}],"mask-image-t-from-color":[{"mask-t-from":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"mask-image-r-from-pos":[{"mask-r-from":ee()}],"mask-image-r-to-pos":[{"mask-r-to":ee()}],"mask-image-r-from-color":[{"mask-r-from":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"mask-image-b-from-pos":[{"mask-b-from":ee()}],"mask-image-b-to-pos":[{"mask-b-to":ee()}],"mask-image-b-from-color":[{"mask-b-from":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"mask-image-l-from-pos":[{"mask-l-from":ee()}],"mask-image-l-to-pos":[{"mask-l-to":ee()}],"mask-image-l-from-color":[{"mask-l-from":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"mask-image-x-from-pos":[{"mask-x-from":ee()}],"mask-image-x-to-pos":[{"mask-x-to":ee()}],"mask-image-x-from-color":[{"mask-x-from":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"mask-image-y-from-pos":[{"mask-y-from":ee()}],"mask-image-y-to-pos":[{"mask-y-to":ee()}],"mask-image-y-from-color":[{"mask-y-from":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[Un,Ln]}],"mask-image-radial-from-pos":[{"mask-radial-from":ee()}],"mask-image-radial-to-pos":[{"mask-radial-to":ee()}],"mask-image-radial-from-color":[{"mask-radial-from":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":k()}],"mask-image-conic-pos":[{"mask-conic":[us]}],"mask-image-conic-from-pos":[{"mask-conic-from":ee()}],"mask-image-conic-to-pos":[{"mask-conic-to":ee()}],"mask-image-conic-from-color":[{"mask-conic-from":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Q()}],"mask-repeat":[{mask:V()}],"mask-size":[{mask:$()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Un,Ln]}],filter:[{filter:["","none",Un,Ln]}],blur:[{blur:ae()}],brightness:[{brightness:[us,Un,Ln]}],contrast:[{contrast:[us,Un,Ln]}],"drop-shadow":[{"drop-shadow":["","none",h,bL,yL]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:["",us,Un,Ln]}],"hue-rotate":[{"hue-rotate":[us,Un,Ln]}],invert:[{invert:["",us,Un,Ln]}],saturate:[{saturate:[us,Un,Ln]}],sepia:[{sepia:["",us,Un,Ln]}],"backdrop-filter":[{"backdrop-filter":["","none",Un,Ln]}],"backdrop-blur":[{"backdrop-blur":ae()}],"backdrop-brightness":[{"backdrop-brightness":[us,Un,Ln]}],"backdrop-contrast":[{"backdrop-contrast":[us,Un,Ln]}],"backdrop-grayscale":[{"backdrop-grayscale":["",us,Un,Ln]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[us,Un,Ln]}],"backdrop-invert":[{"backdrop-invert":["",us,Un,Ln]}],"backdrop-opacity":[{"backdrop-opacity":[us,Un,Ln]}],"backdrop-saturate":[{"backdrop-saturate":[us,Un,Ln]}],"backdrop-sepia":[{"backdrop-sepia":["",us,Un,Ln]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":j()}],"border-spacing-x":[{"border-spacing-x":j()}],"border-spacing-y":[{"border-spacing-y":j()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Un,Ln]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[us,"initial",Un,Ln]}],ease:[{ease:["linear","initial",b,Un,Ln]}],delay:[{delay:[us,Un,Ln]}],animate:[{animate:["none",S,Un,Ln]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,Un,Ln]}],"perspective-origin":[{"perspective-origin":_()}],rotate:[{rotate:ce()}],"rotate-x":[{"rotate-x":ce()}],"rotate-y":[{"rotate-y":ce()}],"rotate-z":[{"rotate-z":ce()}],scale:[{scale:Y()}],"scale-x":[{"scale-x":Y()}],"scale-y":[{"scale-y":Y()}],"scale-z":[{"scale-z":Y()}],"scale-3d":["scale-3d"],skew:[{skew:ne()}],"skew-x":[{"skew-x":ne()}],"skew-y":[{"skew-y":ne()}],transform:[{transform:[Un,Ln,"","none","gpu","cpu"]}],"transform-origin":[{origin:_()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ue()}],"translate-x":[{"translate-x":ue()}],"translate-y":[{"translate-y":ue()}],"translate-z":[{"translate-z":ue()}],"translate-none":["translate-none"],accent:[{accent:D()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:D()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Un,Ln]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":j()}],"scroll-mx":[{"scroll-mx":j()}],"scroll-my":[{"scroll-my":j()}],"scroll-ms":[{"scroll-ms":j()}],"scroll-me":[{"scroll-me":j()}],"scroll-mbs":[{"scroll-mbs":j()}],"scroll-mbe":[{"scroll-mbe":j()}],"scroll-mt":[{"scroll-mt":j()}],"scroll-mr":[{"scroll-mr":j()}],"scroll-mb":[{"scroll-mb":j()}],"scroll-ml":[{"scroll-ml":j()}],"scroll-p":[{"scroll-p":j()}],"scroll-px":[{"scroll-px":j()}],"scroll-py":[{"scroll-py":j()}],"scroll-ps":[{"scroll-ps":j()}],"scroll-pe":[{"scroll-pe":j()}],"scroll-pbs":[{"scroll-pbs":j()}],"scroll-pbe":[{"scroll-pbe":j()}],"scroll-pt":[{"scroll-pt":j()}],"scroll-pr":[{"scroll-pr":j()}],"scroll-pb":[{"scroll-pb":j()}],"scroll-pl":[{"scroll-pl":j()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Un,Ln]}],fill:[{fill:["none",...D()]}],"stroke-w":[{stroke:[us,EA,_S,OMe]}],stroke:[{stroke:["none",...D()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},m_=ppn(Ppn);function Vd(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e?.(s),n===!1||!s.defaultPrevented)return t?.(s)}}function EMe(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Jw(...e){return t=>{let n=!1;const r=e.map(s=>{const a=EMe(s,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let s=0;s<r.length;s++){const a=r[s];typeof a=="function"?a():EMe(e[s],null)}}}}function Rg(...e){return g.useCallback(Jw(...e),e)}function $pn(e,t){const n=g.createContext(t),r=a=>{const{children:i,...l}=a,c=g.useMemo(()=>l,Object.values(l));return o.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function s(a){const i=g.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[r,s]}function vbe(e,t=[]){let n=[];function r(a,i){const l=g.createContext(i),c=n.length;n=[...n,i];const u=f=>{const{scope:p,children:h,...m}=f,v=p?.[e]?.[c]||l,y=g.useMemo(()=>m,Object.values(m));return o.jsx(v.Provider,{value:y,children:h})};u.displayName=a+"Provider";function d(f,p){const h=p?.[e]?.[c]||l,m=g.useContext(h);if(m)return m;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${a}\``)}return[u,d]}const s=()=>{const a=n.map(i=>g.createContext(i));return function(l){const c=l?.[e]||a;return g.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return s.scopeName=e,[r,Mpn(s,...t)]}function Mpn(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const i=r.reduce((l,{useScope:c,scopeName:u})=>{const f=c(a)[`__scope${u}`];return{...l,...f}},{});return g.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var yo=frt();const ybe=Tc(yo);function vct(e){const t=Dpn(e),n=g.forwardRef((r,s)=>{const{children:a,...i}=r,l=g.Children.toArray(a),c=l.find(Fpn);if(c){const u=c.props.children,d=l.map(f=>f===c?g.Children.count(u)>1?g.Children.only(null):g.isValidElement(u)?u.props.children:null:f);return o.jsx(t,{...i,ref:s,children:g.isValidElement(u)?g.cloneElement(u,void 0,d):null})}return o.jsx(t,{...i,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}function Dpn(e){const t=g.forwardRef((n,r)=>{const{children:s,...a}=n;if(g.isValidElement(s)){const i=Bpn(s),l=zpn(a,s.props);return s.type!==g.Fragment&&(l.ref=r?Jw(r,i):i),g.cloneElement(s,l)}return g.Children.count(s)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var yct=Symbol("radix.slottable");function Lpn(e){const t=({children:n})=>o.jsx(o.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=yct,t}function Fpn(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===yct}function zpn(e,t){const n={...t};for(const r in t){const s=e[r],a=t[r];/^on[A-Z]/.test(r)?s&&a?n[r]=(...l)=>{const c=a(...l);return s(...l),c}:s&&(n[r]=s):r==="style"?n[r]={...s,...a}:r==="className"&&(n[r]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function Bpn(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Upn=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_f=Upn.reduce((e,t)=>{const n=vct(`Primitive.${t}`),r=g.forwardRef((s,a)=>{const{asChild:i,...l}=s,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(c,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function qpn(e,t){e&&yo.flushSync(()=>e.dispatchEvent(t))}function Kj(e){const t=g.useRef(e);return g.useEffect(()=>{t.current=e}),g.useMemo(()=>(...n)=>t.current?.(...n),[])}function Vpn(e,t=globalThis?.document){const n=Kj(e);g.useEffect(()=>{const r=s=>{s.key==="Escape"&&n(s)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Hpn="DismissableLayer",rfe="dismissableLayer.update",Wpn="dismissableLayer.pointerDownOutside",Zpn="dismissableLayer.focusOutside",jMe,bct=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),bbe=g.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...c}=e,u=g.useContext(bct),[d,f]=g.useState(null),p=d?.ownerDocument??globalThis?.document,[,h]=g.useState({}),m=Rg(t,E=>f(E)),v=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),b=v.indexOf(y),S=d?v.indexOf(d):-1,w=u.layersWithOutsidePointerEventsDisabled.size>0,k=S>=b,_=Ypn(E=>{const j=E.target,N=[...u.branches].some(I=>I.contains(j));!k||N||(s?.(E),i?.(E),E.defaultPrevented||l?.())},p),C=Xpn(E=>{const j=E.target;[...u.branches].some(I=>I.contains(j))||(a?.(E),i?.(E),E.defaultPrevented||l?.())},p);return Vpn(E=>{S===u.layers.size-1&&(r?.(E),!E.defaultPrevented&&l&&(E.preventDefault(),l()))},p),g.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(jMe=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),TMe(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=jMe)}},[d,p,n,u]),g.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),TMe())},[d,u]),g.useEffect(()=>{const E=()=>h({});return document.addEventListener(rfe,E),()=>document.removeEventListener(rfe,E)},[]),o.jsx(_f.div,{...c,ref:m,style:{pointerEvents:w?k?"auto":"none":void 0,...e.style},onFocusCapture:Vd(e.onFocusCapture,C.onFocusCapture),onBlurCapture:Vd(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:Vd(e.onPointerDownCapture,_.onPointerDownCapture)})});bbe.displayName=Hpn;var Gpn="DismissableLayerBranch",Qpn=g.forwardRef((e,t)=>{const n=g.useContext(bct),r=g.useRef(null),s=Rg(t,r);return g.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),o.jsx(_f.div,{...e,ref:s})});Qpn.displayName=Gpn;function Ypn(e,t=globalThis?.document){const n=Kj(e),r=g.useRef(!1),s=g.useRef(()=>{});return g.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let c=function(){xct(Wpn,n,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",s.current),s.current=c,t.addEventListener("click",s.current,{once:!0})):c()}else t.removeEventListener("click",s.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",s.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Xpn(e,t=globalThis?.document){const n=Kj(e),r=g.useRef(!1);return g.useEffect(()=>{const s=a=>{a.target&&!r.current&&xct(Zpn,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function TMe(){const e=new CustomEvent(rfe);document.dispatchEvent(e)}function xct(e,t,n,{discrete:r}){const s=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),r?qpn(s,a):s.dispatchEvent(a)}var e1=globalThis?.document?g.useLayoutEffect:()=>{},Kpn=hN[" useId ".trim().toString()]||(()=>{}),Jpn=0;function ex(e){const[t,n]=g.useState(Kpn());return e1(()=>{n(r=>r??String(Jpn++))},[e]),t?`radix-${t}`:""}const ehn=["top","right","bottom","left"],t1=Math.min,hp=Math.max,Jj=Math.round,wk=Math.floor,Gv=e=>({x:e,y:e}),thn={left:"right",right:"left",bottom:"top",top:"bottom"};function uz(e,t,n){return hp(e,t1(t,n))}function oy(e,t){return typeof e=="function"?e(t):e}function cf(e){return e.split("-")[0]}function zx(e){return e.split("-")[1]}function xbe(e){return e==="x"?"y":"x"}function gq(e){return e==="y"?"height":"width"}function Ah(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function vq(e){return xbe(Ah(e))}function nhn(e,t,n){n===void 0&&(n=!1);const r=zx(e),s=vq(e),a=gq(s);let i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=dz(i)),[i,dz(i)]}function rhn(e){const t=dz(e);return[sfe(e),t,sfe(t)]}function sfe(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const NMe=["left","right"],IMe=["right","left"],shn=["top","bottom"],ahn=["bottom","top"];function ihn(e,t,n){switch(e){case"top":case"bottom":return n?t?IMe:NMe:t?NMe:IMe;case"left":case"right":return t?shn:ahn;default:return[]}}function ohn(e,t,n,r){const s=zx(e);let a=ihn(cf(e),n==="start",r);return s&&(a=a.map(i=>i+"-"+s),t&&(a=a.concat(a.map(sfe)))),a}function dz(e){const t=cf(e);return thn[t]+e.slice(t.length)}function lhn(e){return{top:0,right:0,bottom:0,left:0,...e}}function wbe(e){return typeof e!="number"?lhn(e):{top:e,right:e,bottom:e,left:e}}function VP(e){const{x:t,y:n,width:r,height:s}=e;return{width:r,height:s,top:n,left:t,right:t+r,bottom:n+s,x:t,y:n}}function AMe(e,t,n){let{reference:r,floating:s}=e;const a=Ah(t),i=vq(t),l=gq(i),c=cf(t),u=a==="y",d=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,p=r[l]/2-s[l]/2;let h;switch(c){case"top":h={x:d,y:r.y-s.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-s.width,y:f};break;default:h={x:r.x,y:r.y}}switch(zx(t)){case"start":h[i]-=p*(n&&u?-1:1);break;case"end":h[i]+=p*(n&&u?-1:1);break}return h}async function chn(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:a,rects:i,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:p=!1,padding:h=0}=oy(t,e),m=wbe(h),y=l[p?f==="floating"?"reference":"floating":f],b=VP(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(y)))==null||n?y:y.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(l.floating)),boundary:u,rootBoundary:d,strategy:c})),S=f==="floating"?{x:r,y:s,width:i.floating.width,height:i.floating.height}:i.reference,w=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l.floating)),k=await(a.isElement==null?void 0:a.isElement(w))?await(a.getScale==null?void 0:a.getScale(w))||{x:1,y:1}:{x:1,y:1},_=VP(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:S,offsetParent:w,strategy:c}):S);return{top:(b.top-_.top+m.top)/k.y,bottom:(_.bottom-b.bottom+m.bottom)/k.y,left:(b.left-_.left+m.left)/k.x,right:(_.right-b.right+m.right)/k.x}}const uhn=50,dhn=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:a=[],platform:i}=n,l=i.detectOverflow?i:{...i,detectOverflow:chn},c=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:s}),{x:d,y:f}=AMe(u,r,c),p=r,h=0;const m={};for(let v=0;v<a.length;v++){const y=a[v];if(!y)continue;const{name:b,fn:S}=y,{x:w,y:k,data:_,reset:C}=await S({x:d,y:f,initialPlacement:r,placement:p,strategy:s,middlewareData:m,rects:u,platform:l,elements:{reference:e,floating:t}});d=w??d,f=k??f,m[b]={...m[b],..._},C&&h<uhn&&(h++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:s}):C.rects),{x:d,y:f}=AMe(u,p,c)),v=-1)}return{x:d,y:f,placement:p,strategy:s,middlewareData:m}},fhn=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:a,platform:i,elements:l,middlewareData:c}=t,{element:u,padding:d=0}=oy(e,t)||{};if(u==null)return{};const f=wbe(d),p={x:n,y:r},h=vq(s),m=gq(h),v=await i.getDimensions(u),y=h==="y",b=y?"top":"left",S=y?"bottom":"right",w=y?"clientHeight":"clientWidth",k=a.reference[m]+a.reference[h]-p[h]-a.floating[m],_=p[h]-a.reference[h],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let E=C?C[w]:0;(!E||!await(i.isElement==null?void 0:i.isElement(C)))&&(E=l.floating[w]||a.floating[m]);const j=k/2-_/2,N=E/2-v[m]/2-1,I=t1(f[b],N),R=t1(f[S],N),P=I,L=E-v[m]-R,M=E/2-v[m]/2+j,q=uz(P,M,L),H=!c.arrow&&zx(s)!=null&&M!==q&&a.reference[m]/2-(M<P?I:R)-v[m]/2<0,F=H?M<P?M-P:M-L:0;return{[h]:p[h]+F,data:{[h]:q,centerOffset:M-q-F,...H&&{alignmentOffset:F}},reset:H}}}),phn=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:a,rects:i,initialPlacement:l,platform:c,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:v=!0,...y}=oy(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const b=cf(s),S=Ah(l),w=cf(l)===l,k=await(c.isRTL==null?void 0:c.isRTL(u.floating)),_=p||(w||!v?[dz(l)]:rhn(l)),C=m!=="none";!p&&C&&_.push(...ohn(l,v,m,k));const E=[l,..._],j=await c.detectOverflow(t,y),N=[];let I=((r=a.flip)==null?void 0:r.overflows)||[];if(d&&N.push(j[b]),f){const M=nhn(s,i,k);N.push(j[M[0]],j[M[1]])}if(I=[...I,{placement:s,overflows:N}],!N.every(M=>M<=0)){var R,P;const M=(((R=a.flip)==null?void 0:R.index)||0)+1,q=E[M];if(q&&(!(f==="alignment"?S!==Ah(q):!1)||I.every(z=>Ah(z.placement)===S?z.overflows[0]>0:!0)))return{data:{index:M,overflows:I},reset:{placement:q}};let H=(P=I.filter(F=>F.overflows[0]<=0).sort((F,z)=>F.overflows[1]-z.overflows[1])[0])==null?void 0:P.placement;if(!H)switch(h){case"bestFit":{var L;const F=(L=I.filter(z=>{if(C){const B=Ah(z.placement);return B===S||B==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(B=>B>0).reduce((B,D)=>B+D,0)]).sort((z,B)=>z[1]-B[1])[0])==null?void 0:L[0];F&&(H=F);break}case"initialPlacement":H=l;break}if(s!==H)return{reset:{placement:H}}}return{}}}};function RMe(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function PMe(e){return ehn.some(t=>e[t]>=0)}const hhn=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:s="referenceHidden",...a}=oy(e,t);switch(s){case"referenceHidden":{const i=await r.detectOverflow(t,{...a,elementContext:"reference"}),l=RMe(i,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:PMe(l)}}}case"escaped":{const i=await r.detectOverflow(t,{...a,altBoundary:!0}),l=RMe(i,n.floating);return{data:{escapedOffsets:l,escaped:PMe(l)}}}default:return{}}}}},wct=new Set(["left","top"]);async function mhn(e,t){const{placement:n,platform:r,elements:s}=e,a=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=cf(n),l=zx(n),c=Ah(n)==="y",u=wct.has(i)?-1:1,d=a&&c?-1:1,f=oy(t,e);let{mainAxis:p,crossAxis:h,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof m=="number"&&(h=l==="end"?m*-1:m),c?{x:h*d,y:p*u}:{x:p*u,y:h*d}}const ghn=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:a,placement:i,middlewareData:l}=t,c=await mhn(t,e);return i===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+c.x,y:a+c.y,data:{...c,placement:i}}}}},vhn=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s,platform:a}=t,{mainAxis:i=!0,crossAxis:l=!1,limiter:c={fn:b=>{let{x:S,y:w}=b;return{x:S,y:w}}},...u}=oy(e,t),d={x:n,y:r},f=await a.detectOverflow(t,u),p=Ah(cf(s)),h=xbe(p);let m=d[h],v=d[p];if(i){const b=h==="y"?"top":"left",S=h==="y"?"bottom":"right",w=m+f[b],k=m-f[S];m=uz(w,m,k)}if(l){const b=p==="y"?"top":"left",S=p==="y"?"bottom":"right",w=v+f[b],k=v-f[S];v=uz(w,v,k)}const y=c.fn({...t,[h]:m,[p]:v});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[h]:i,[p]:l}}}}}},yhn=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:s,rects:a,middlewareData:i}=t,{offset:l=0,mainAxis:c=!0,crossAxis:u=!0}=oy(e,t),d={x:n,y:r},f=Ah(s),p=xbe(f);let h=d[p],m=d[f];const v=oy(l,t),y=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(c){const w=p==="y"?"height":"width",k=a.reference[p]-a.floating[w]+y.mainAxis,_=a.reference[p]+a.reference[w]-y.mainAxis;h<k?h=k:h>_&&(h=_)}if(u){var b,S;const w=p==="y"?"width":"height",k=wct.has(cf(s)),_=a.reference[f]-a.floating[w]+(k&&((b=i.offset)==null?void 0:b[f])||0)+(k?0:y.crossAxis),C=a.reference[f]+a.reference[w]+(k?0:((S=i.offset)==null?void 0:S[f])||0)-(k?y.crossAxis:0);m<_?m=_:m>C&&(m=C)}return{[p]:h,[f]:m}}}},bhn=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:s,rects:a,platform:i,elements:l}=t,{apply:c=()=>{},...u}=oy(e,t),d=await i.detectOverflow(t,u),f=cf(s),p=zx(s),h=Ah(s)==="y",{width:m,height:v}=a.floating;let y,b;f==="top"||f==="bottom"?(y=f,b=p===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(b=f,y=p==="end"?"top":"bottom");const S=v-d.top-d.bottom,w=m-d.left-d.right,k=t1(v-d[y],S),_=t1(m-d[b],w),C=!t.middlewareData.shift;let E=k,j=_;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=w),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=S),C&&!p){const I=hp(d.left,0),R=hp(d.right,0),P=hp(d.top,0),L=hp(d.bottom,0);h?j=m-2*(I!==0||R!==0?I+R:hp(d.left,d.right)):E=v-2*(P!==0||L!==0?P+L:hp(d.top,d.bottom))}await c({...t,availableWidth:j,availableHeight:E});const N=await i.getDimensions(l.floating);return m!==N.width||v!==N.height?{reset:{rects:!0}}:{}}}};function yq(){return typeof window<"u"}function $u(e){return Sbe(e)?(e.nodeName||"").toLowerCase():"#document"}function Ks(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Oy(e){var t;return(t=(Sbe(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Sbe(e){return yq()?e instanceof Node||e instanceof Ks(e).Node:!1}function _r(e){return yq()?e instanceof Element||e instanceof Ks(e).Element:!1}function Ra(e){return yq()?e instanceof HTMLElement||e instanceof Ks(e).HTMLElement:!1}function eT(e){return!yq()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ks(e).ShadowRoot}function A1(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=Mu(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function xhn(e){return/^(table|td|th)$/.test($u(e))}function bq(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const whn=/transform|translate|scale|rotate|perspective|filter/,Shn=/paint|layout|strict|content/,CS=e=>!!e&&e!=="none";let iX;function kbe(e){const t=_r(e)?Mu(e):e;return CS(t.transform)||CS(t.translate)||CS(t.scale)||CS(t.rotate)||CS(t.perspective)||!xq()&&(CS(t.backdropFilter)||CS(t.filter))||whn.test(t.willChange||"")||Shn.test(t.contain||"")}function khn(e){let t=ly(e);for(;Ra(t)&&!Qv(t);){if(kbe(t))return t;if(bq(t))return null;t=ly(t)}return null}function xq(){return iX==null&&(iX=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),iX}function Qv(e){return/^(html|body|#document)$/.test($u(e))}function Mu(e){return Ks(e).getComputedStyle(e)}function wq(e){return _r(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ly(e){if($u(e)==="html")return e;const t=e.assignedSlot||e.parentNode||eT(e)&&e.host||Oy(e);return eT(t)?t.host:t}function Sct(e){const t=ly(e);return Qv(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ra(t)&&A1(t)?t:Sct(t)}function HP(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=Sct(e),a=s===((r=e.ownerDocument)==null?void 0:r.body),i=Ks(s);if(a){const l=afe(i);return t.concat(i,i.visualViewport||[],A1(s)?s:[],l&&n?HP(l):[])}else return t.concat(s,HP(s,[],n))}function afe(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function kct(e){const t=Mu(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=Ra(e),a=s?e.offsetWidth:n,i=s?e.offsetHeight:r,l=Jj(n)!==a||Jj(r)!==i;return l&&(n=a,r=i),{width:n,height:r,$:l}}function Obe(e){return _r(e)?e:e.contextElement}function lj(e){const t=Obe(e);if(!Ra(t))return Gv(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:a}=kct(t);let i=(a?Jj(n.width):n.width)/r,l=(a?Jj(n.height):n.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const Ohn=Gv(0);function Oct(e){const t=Ks(e);return!xq()||!t.visualViewport?Ohn:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function _hn(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ks(e)?!1:t}function pO(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),a=Obe(e);let i=Gv(1);t&&(r?_r(r)&&(i=lj(r)):i=lj(e));const l=_hn(a,n,r)?Oct(a):Gv(0);let c=(s.left+l.x)/i.x,u=(s.top+l.y)/i.y,d=s.width/i.x,f=s.height/i.y;if(a){const p=Ks(a),h=r&&_r(r)?Ks(r):r;let m=p,v=afe(m);for(;v&&r&&h!==m;){const y=lj(v),b=v.getBoundingClientRect(),S=Mu(v),w=b.left+(v.clientLeft+parseFloat(S.paddingLeft))*y.x,k=b.top+(v.clientTop+parseFloat(S.paddingTop))*y.y;c*=y.x,u*=y.y,d*=y.x,f*=y.y,c+=w,u+=k,m=Ks(v),v=afe(m)}}return VP({width:d,height:f,x:c,y:u})}function Sq(e,t){const n=wq(e).scrollLeft;return t?t.left+n:pO(Oy(e)).left+n}function _ct(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Sq(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function Chn(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const a=s==="fixed",i=Oy(r),l=t?bq(t.floating):!1;if(r===i||l&&a)return n;let c={scrollLeft:0,scrollTop:0},u=Gv(1);const d=Gv(0),f=Ra(r);if((f||!f&&!a)&&(($u(r)!=="body"||A1(i))&&(c=wq(r)),f)){const h=pO(r);u=lj(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const p=i&&!f&&!a?_ct(i,c):Gv(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+p.x,y:n.y*u.y-c.scrollTop*u.y+d.y+p.y}}function Ehn(e){return Array.from(e.getClientRects())}function jhn(e){const t=Oy(e),n=wq(e),r=e.ownerDocument.body,s=hp(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=hp(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Sq(e);const l=-n.scrollTop;return Mu(r).direction==="rtl"&&(i+=hp(t.clientWidth,r.clientWidth)-s),{width:s,height:a,x:i,y:l}}const $Me=25;function Thn(e,t){const n=Ks(e),r=Oy(e),s=n.visualViewport;let a=r.clientWidth,i=r.clientHeight,l=0,c=0;if(s){a=s.width,i=s.height;const d=xq();(!d||d&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const u=Sq(r);if(u<=0){const d=r.ownerDocument,f=d.body,p=getComputedStyle(f),h=d.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,m=Math.abs(r.clientWidth-f.clientWidth-h);m<=$Me&&(a-=m)}else u<=$Me&&(a+=u);return{width:a,height:i,x:l,y:c}}function Nhn(e,t){const n=pO(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,a=Ra(e)?lj(e):Gv(1),i=e.clientWidth*a.x,l=e.clientHeight*a.y,c=s*a.x,u=r*a.y;return{width:i,height:l,x:c,y:u}}function MMe(e,t,n){let r;if(t==="viewport")r=Thn(e,n);else if(t==="document")r=jhn(Oy(e));else if(_r(t))r=Nhn(t,n);else{const s=Oct(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return VP(r)}function Cct(e,t){const n=ly(e);return n===t||!_r(n)||Qv(n)?!1:Mu(n).position==="fixed"||Cct(n,t)}function Ihn(e,t){const n=t.get(e);if(n)return n;let r=HP(e,[],!1).filter(l=>_r(l)&&$u(l)!=="body"),s=null;const a=Mu(e).position==="fixed";let i=a?ly(e):e;for(;_r(i)&&!Qv(i);){const l=Mu(i),c=kbe(i);!c&&l.position==="fixed"&&(s=null),(a?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||A1(i)&&!c&&Cct(e,i))?r=r.filter(d=>d!==i):s=l,i=ly(i)}return t.set(e,r),r}function Ahn(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const i=[...n==="clippingAncestors"?bq(t)?[]:Ihn(t,this._c):[].concat(n),r],l=MMe(t,i[0],s);let c=l.top,u=l.right,d=l.bottom,f=l.left;for(let p=1;p<i.length;p++){const h=MMe(t,i[p],s);c=hp(h.top,c),u=t1(h.right,u),d=t1(h.bottom,d),f=hp(h.left,f)}return{width:u-f,height:d-c,x:f,y:c}}function Rhn(e){const{width:t,height:n}=kct(e);return{width:t,height:n}}function Phn(e,t,n){const r=Ra(t),s=Oy(t),a=n==="fixed",i=pO(e,!0,a,t);let l={scrollLeft:0,scrollTop:0};const c=Gv(0);function u(){c.x=Sq(s)}if(r||!r&&!a)if(($u(t)!=="body"||A1(s))&&(l=wq(t)),r){const h=pO(t,!0,a,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else s&&u();a&&!r&&s&&u();const d=s&&!r&&!a?_ct(s,l):Gv(0),f=i.left+l.scrollLeft-c.x-d.x,p=i.top+l.scrollTop-c.y-d.y;return{x:f,y:p,width:i.width,height:i.height}}function oX(e){return Mu(e).position==="static"}function DMe(e,t){if(!Ra(e)||Mu(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Oy(e)===n&&(n=n.ownerDocument.body),n}function Ect(e,t){const n=Ks(e);if(bq(e))return n;if(!Ra(e)){let s=ly(e);for(;s&&!Qv(s);){if(_r(s)&&!oX(s))return s;s=ly(s)}return n}let r=DMe(e,t);for(;r&&xhn(r)&&oX(r);)r=DMe(r,t);return r&&Qv(r)&&oX(r)&&!kbe(r)?n:r||khn(e)||n}const $hn=async function(e){const t=this.getOffsetParent||Ect,n=this.getDimensions,r=await n(e.floating);return{reference:Phn(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Mhn(e){return Mu(e).direction==="rtl"}const jct={convertOffsetParentRelativeRectToViewportRelativeRect:Chn,getDocumentElement:Oy,getClippingRect:Ahn,getOffsetParent:Ect,getElementRects:$hn,getClientRects:Ehn,getDimensions:Rhn,getScale:lj,isElement:_r,isRTL:Mhn};function Tct(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Dhn(e,t){let n=null,r;const s=Oy(e);function a(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function i(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),a();const u=e.getBoundingClientRect(),{left:d,top:f,width:p,height:h}=u;if(l||t(),!p||!h)return;const m=wk(f),v=wk(s.clientWidth-(d+p)),y=wk(s.clientHeight-(f+h)),b=wk(d),w={rootMargin:-m+"px "+-v+"px "+-y+"px "+-b+"px",threshold:hp(0,t1(1,c))||1};let k=!0;function _(C){const E=C[0].intersectionRatio;if(E!==c){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Tct(u,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(_,{...w,root:s.ownerDocument})}catch{n=new IntersectionObserver(_,w)}n.observe(e)}return i(!0),a}function ife(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=Obe(e),d=s||a?[...u?HP(u):[],...t?HP(t):[]]:[];d.forEach(b=>{s&&b.addEventListener("scroll",n,{passive:!0}),a&&b.addEventListener("resize",n)});const f=u&&l?Dhn(u,n):null;let p=-1,h=null;i&&(h=new ResizeObserver(b=>{let[S]=b;S&&S.target===u&&h&&t&&(h.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var w;(w=h)==null||w.observe(t)})),n()}),u&&!c&&h.observe(u),t&&h.observe(t));let m,v=c?pO(e):null;c&&y();function y(){const b=pO(e);v&&!Tct(v,b)&&n(),v=b,m=requestAnimationFrame(y)}return n(),()=>{var b;d.forEach(S=>{s&&S.removeEventListener("scroll",n),a&&S.removeEventListener("resize",n)}),f?.(),(b=h)==null||b.disconnect(),h=null,c&&cancelAnimationFrame(m)}}const Lhn=ghn,Fhn=vhn,zhn=phn,Bhn=bhn,Uhn=hhn,LMe=fhn,qhn=yhn,Vhn=(e,t,n)=>{const r=new Map,s={platform:jct,...n},a={...s.platform,_c:r};return dhn(e,t,{...s,platform:a})};var Hhn=typeof document<"u",Whn=function(){},TF=Hhn?g.useLayoutEffect:Whn;function fz(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!fz(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const a=s[r];if(!(a==="_owner"&&e.$$typeof)&&!fz(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function Nct(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function FMe(e,t){const n=Nct(e);return Math.round(t*n)/n}function lX(e){const t=g.useRef(e);return TF(()=>{t.current=e}),t}function Ict(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:a,floating:i}={},transform:l=!0,whileElementsMounted:c,open:u}=e,[d,f]=g.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,h]=g.useState(r);fz(p,r)||h(r);const[m,v]=g.useState(null),[y,b]=g.useState(null),S=g.useCallback(z=>{z!==C.current&&(C.current=z,v(z))},[]),w=g.useCallback(z=>{z!==E.current&&(E.current=z,b(z))},[]),k=a||m,_=i||y,C=g.useRef(null),E=g.useRef(null),j=g.useRef(d),N=c!=null,I=lX(c),R=lX(s),P=lX(u),L=g.useCallback(()=>{if(!C.current||!E.current)return;const z={placement:t,strategy:n,middleware:p};R.current&&(z.platform=R.current),Vhn(C.current,E.current,z).then(B=>{const D={...B,isPositioned:P.current!==!1};M.current&&!fz(j.current,D)&&(j.current=D,yo.flushSync(()=>{f(D)}))})},[p,t,n,R,P]);TF(()=>{u===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,f(z=>({...z,isPositioned:!1})))},[u]);const M=g.useRef(!1);TF(()=>(M.current=!0,()=>{M.current=!1}),[]),TF(()=>{if(k&&(C.current=k),_&&(E.current=_),k&&_){if(I.current)return I.current(k,_,L);L()}},[k,_,L,I,N]);const q=g.useMemo(()=>({reference:C,floating:E,setReference:S,setFloating:w}),[S,w]),H=g.useMemo(()=>({reference:k,floating:_}),[k,_]),F=g.useMemo(()=>{const z={position:n,left:0,top:0};if(!H.floating)return z;const B=FMe(H.floating,d.x),D=FMe(H.floating,d.y);return l?{...z,transform:"translate("+B+"px, "+D+"px)",...Nct(H.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:B,top:D}},[n,l,H.floating,d.x,d.y]);return g.useMemo(()=>({...d,update:L,refs:q,elements:H,floatingStyles:F}),[d,L,q,H,F])}const Zhn=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:s}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?LMe({element:r.current,padding:s}).fn(n):{}:r?LMe({element:r,padding:s}).fn(n):{}}}},Act=(e,t)=>{const n=Lhn(e);return{name:n.name,fn:n.fn,options:[e,t]}},Rct=(e,t)=>{const n=Fhn(e);return{name:n.name,fn:n.fn,options:[e,t]}},Pct=(e,t)=>({fn:qhn(e).fn,options:[e,t]}),$ct=(e,t)=>{const n=zhn(e);return{name:n.name,fn:n.fn,options:[e,t]}},Mct=(e,t)=>{const n=Bhn(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dct=(e,t)=>{const n=Uhn(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ghn=(e,t)=>{const n=Zhn(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Qhn="Arrow",Lct=g.forwardRef((e,t)=>{const{children:n,width:r=10,height:s=5,...a}=e;return o.jsx(_f.svg,{...a,ref:t,width:r,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:o.jsx("polygon",{points:"0,0 30,0 15,10"})})});Lct.displayName=Qhn;var Yhn=Lct;function Xhn(e){const[t,n]=g.useState(void 0);return e1(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const a=s[0];let i,l;if("borderBoxSize"in a){const c=a.borderBoxSize,u=Array.isArray(c)?c[0]:c;i=u.inlineSize,l=u.blockSize}else i=e.offsetWidth,l=e.offsetHeight;n({width:i,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Fct="Popper",[zct,Bct]=vbe(Fct),[abs,Uct]=zct(Fct),qct="PopperAnchor",Vct=g.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...s}=e,a=Uct(qct,n),i=g.useRef(null),l=Rg(t,i),c=g.useRef(null);return g.useEffect(()=>{const u=c.current;c.current=r?.current||i.current,u!==c.current&&a.onAnchorChange(c.current)}),r?null:o.jsx(_f.div,{...s,ref:l})});Vct.displayName=qct;var _be="PopperContent",[Khn,Jhn]=zct(_be),Hct=g.forwardRef((e,t)=>{const{__scopePopper:n,side:r="bottom",sideOffset:s=0,align:a="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:h="optimized",onPlaced:m,...v}=e,y=Uct(_be,n),[b,S]=g.useState(null),w=Rg(t,te=>S(te)),[k,_]=g.useState(null),C=Xhn(k),E=C?.width??0,j=C?.height??0,N=r+(a!=="center"?"-"+a:""),I=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},R=Array.isArray(u)?u:[u],P=R.length>0,L={padding:I,boundary:R.filter(tmn),altBoundary:P},{refs:M,floatingStyles:q,placement:H,isPositioned:F,middlewareData:z}=Ict({strategy:"fixed",placement:N,whileElementsMounted:(...te)=>ife(...te,{animationFrame:h==="always"}),elements:{reference:y.anchor},middleware:[Act({mainAxis:s+j,alignmentAxis:i}),c&&Rct({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Pct():void 0,...L}),c&&$ct({...L}),Mct({...L,apply:({elements:te,rects:J,availableWidth:ee,availableHeight:ae})=>{const{width:ce,height:Y}=J.reference,ne=te.floating.style;ne.setProperty("--radix-popper-available-width",`${ee}px`),ne.setProperty("--radix-popper-available-height",`${ae}px`),ne.setProperty("--radix-popper-anchor-width",`${ce}px`),ne.setProperty("--radix-popper-anchor-height",`${Y}px`)}}),k&&Ghn({element:k,padding:l}),nmn({arrowWidth:E,arrowHeight:j}),p&&Dct({strategy:"referenceHidden",...L})]}),[B,D]=Gct(H),Q=Kj(m);e1(()=>{F&&Q?.()},[F,Q]);const V=z.arrow?.x,$=z.arrow?.y,U=z.arrow?.centerOffset!==0,[Z,X]=g.useState();return e1(()=>{b&&X(window.getComputedStyle(b).zIndex)},[b]),o.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...q,transform:F?q.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Z,"--radix-popper-transform-origin":[z.transformOrigin?.x,z.transformOrigin?.y].join(" "),...z.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:o.jsx(Khn,{scope:n,placedSide:B,onArrowChange:_,arrowX:V,arrowY:$,shouldHideArrow:U,children:o.jsx(_f.div,{"data-side":B,"data-align":D,...v,ref:w,style:{...v.style,animation:F?void 0:"none"}})})})});Hct.displayName=_be;var Wct="PopperArrow",emn={top:"bottom",right:"left",bottom:"top",left:"right"},Zct=g.forwardRef(function(t,n){const{__scopePopper:r,...s}=t,a=Jhn(Wct,r),i=emn[a.placedSide];return o.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:o.jsx(Yhn,{...s,ref:n,style:{...s.style,display:"block"}})})});Zct.displayName=Wct;function tmn(e){return e!==null}var nmn=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:s}=t,i=s.arrow?.centerOffset!==0,l=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,d]=Gct(n),f={start:"0%",center:"50%",end:"100%"}[d],p=(s.arrow?.x??0)+l/2,h=(s.arrow?.y??0)+c/2;let m="",v="";return u==="bottom"?(m=i?f:`${p}px`,v=`${-c}px`):u==="top"?(m=i?f:`${p}px`,v=`${r.floating.height+c}px`):u==="right"?(m=`${-c}px`,v=i?f:`${h}px`):u==="left"&&(m=`${r.floating.width+c}px`,v=i?f:`${h}px`),{data:{x:m,y:v}}}});function Gct(e){const[t,n="center"]=e.split("-");return[t,n]}var rmn=Vct,smn=Hct,amn=Zct,imn="Portal",Qct=g.forwardRef((e,t)=>{const{container:n,...r}=e,[s,a]=g.useState(!1);e1(()=>a(!0),[]);const i=n||s&&globalThis?.document?.body;return i?ybe.createPortal(o.jsx(_f.div,{...r,ref:t}),i):null});Qct.displayName=imn;function omn(e,t){return g.useReducer((n,r)=>t[n][r]??n,e)}var yD=e=>{const{present:t,children:n}=e,r=lmn(t),s=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),a=Rg(r.ref,cmn(s));return typeof n=="function"||r.isPresent?g.cloneElement(s,{ref:a}):null};yD.displayName="Presence";function lmn(e){const[t,n]=g.useState(),r=g.useRef(null),s=g.useRef(e),a=g.useRef("none"),i=e?"mounted":"unmounted",[l,c]=omn(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const u=xL(r.current);a.current=l==="mounted"?u:"none"},[l]),e1(()=>{const u=r.current,d=s.current;if(d!==e){const p=a.current,h=xL(u);e?c("MOUNT"):h==="none"||u?.display==="none"?c("UNMOUNT"):c(d&&p!==h?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,c]),e1(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=h=>{const v=xL(r.current).includes(CSS.escape(h.animationName));if(h.target===t&&v&&(c("ANIMATION_END"),!s.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},p=h=>{h.target===t&&(a.current=xL(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:g.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function xL(e){return e?.animationName||"none"}function cmn(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var umn=hN[" useInsertionEffect ".trim().toString()]||e1;function dmn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[s,a,i]=fmn({defaultProp:t,onChange:n}),l=e!==void 0,c=l?e:s;{const d=g.useRef(e!==void 0);g.useEffect(()=>{const f=d.current;f!==l&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=l},[l,r])}const u=g.useCallback(d=>{if(l){const f=pmn(d)?d(e):d;f!==e&&i.current?.(f)}else a(d)},[l,e,a,i]);return[c,u]}function fmn({defaultProp:e,onChange:t}){const[n,r]=g.useState(e),s=g.useRef(n),a=g.useRef(t);return umn(()=>{a.current=t},[t]),g.useEffect(()=>{s.current!==n&&(a.current?.(n),s.current=n)},[n,s]),[n,r,a]}function pmn(e){return typeof e=="function"}var hmn=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),mmn="VisuallyHidden",Yct=g.forwardRef((e,t)=>o.jsx(_f.span,{...e,ref:t,style:{...hmn,...e.style}}));Yct.displayName=mmn;var gmn=Yct,[kq]=vbe("Tooltip",[Bct]),Cbe=Bct(),Xct="TooltipProvider",vmn=700,zMe="tooltip.open",[ymn,Kct]=kq(Xct),Jct=e=>{const{__scopeTooltip:t,delayDuration:n=vmn,skipDelayDuration:r=300,disableHoverableContent:s=!1,children:a}=e,i=g.useRef(!0),l=g.useRef(!1),c=g.useRef(0);return g.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),o.jsx(ymn,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:g.useCallback(()=>{window.clearTimeout(c.current),i.current=!1},[]),onClose:g.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:g.useCallback(u=>{l.current=u},[]),disableHoverableContent:s,children:a})};Jct.displayName=Xct;var eut="Tooltip",[ibs,Oq]=kq(eut),ofe="TooltipTrigger",bmn=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,s=Oq(ofe,n),a=Kct(ofe,n),i=Cbe(n),l=g.useRef(null),c=Rg(t,l,s.onTriggerChange),u=g.useRef(!1),d=g.useRef(!1),f=g.useCallback(()=>u.current=!1,[]);return g.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),o.jsx(rmn,{asChild:!0,...i,children:o.jsx(_f.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...r,ref:c,onPointerMove:Vd(e.onPointerMove,p=>{p.pointerType!=="touch"&&!d.current&&!a.isPointerInTransitRef.current&&(s.onTriggerEnter(),d.current=!0)}),onPointerLeave:Vd(e.onPointerLeave,()=>{s.onTriggerLeave(),d.current=!1}),onPointerDown:Vd(e.onPointerDown,()=>{s.open&&s.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Vd(e.onFocus,()=>{u.current||s.onOpen()}),onBlur:Vd(e.onBlur,s.onClose),onClick:Vd(e.onClick,s.onClose)})})});bmn.displayName=ofe;var xmn="TooltipPortal",[obs,wmn]=kq(xmn,{forceMount:void 0}),tT="TooltipContent",Smn=g.forwardRef((e,t)=>{const n=wmn(tT,e.__scopeTooltip),{forceMount:r=n.forceMount,side:s="top",...a}=e,i=Oq(tT,e.__scopeTooltip);return o.jsx(yD,{present:r||i.open,children:i.disableHoverableContent?o.jsx(tut,{side:s,...a,ref:t}):o.jsx(kmn,{side:s,...a,ref:t})})}),kmn=g.forwardRef((e,t)=>{const n=Oq(tT,e.__scopeTooltip),r=Kct(tT,e.__scopeTooltip),s=g.useRef(null),a=Rg(t,s),[i,l]=g.useState(null),{trigger:c,onClose:u}=n,d=s.current,{onPointerInTransitChange:f}=r,p=g.useCallback(()=>{l(null),f(!1)},[f]),h=g.useCallback((m,v)=>{const y=m.currentTarget,b={x:m.clientX,y:m.clientY},S=jmn(b,y.getBoundingClientRect()),w=Tmn(b,S),k=Nmn(v.getBoundingClientRect()),_=Amn([...w,...k]);l(_),f(!0)},[f]);return g.useEffect(()=>()=>p(),[p]),g.useEffect(()=>{if(c&&d){const m=y=>h(y,d),v=y=>h(y,c);return c.addEventListener("pointerleave",m),d.addEventListener("pointerleave",v),()=>{c.removeEventListener("pointerleave",m),d.removeEventListener("pointerleave",v)}}},[c,d,h,p]),g.useEffect(()=>{if(i){const m=v=>{const y=v.target,b={x:v.clientX,y:v.clientY},S=c?.contains(y)||d?.contains(y),w=!Imn(b,i);S?p():w&&(p(),u())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[c,d,i,u,p]),o.jsx(tut,{...e,ref:a})}),[Omn,_mn]=kq(eut,{isInside:!1}),Cmn=Lpn("TooltipContent"),tut=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":s,onEscapeKeyDown:a,onPointerDownOutside:i,...l}=e,c=Oq(tT,n),u=Cbe(n),{onClose:d}=c;return g.useEffect(()=>(document.addEventListener(zMe,d),()=>document.removeEventListener(zMe,d)),[d]),g.useEffect(()=>{if(c.trigger){const f=p=>{p.target?.contains(c.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,d]),o.jsx(bbe,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:o.jsxs(smn,{"data-state":c.stateAttribute,...u,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[o.jsx(Cmn,{children:r}),o.jsx(Omn,{scope:n,isInside:!0,children:o.jsx(gmn,{id:c.contentId,role:"tooltip",children:s||r})})]})})});Smn.displayName=tT;var nut="TooltipArrow",Emn=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,s=Cbe(n);return _mn(nut,n).isInside?null:o.jsx(amn,{...s,...r,ref:t})});Emn.displayName=nut;function jmn(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),s=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,s,a)){case a:return"left";case s:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function Tmn(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Nmn(e){const{top:t,right:n,bottom:r,left:s}=e;return[{x:s,y:t},{x:n,y:t},{x:n,y:r},{x:s,y:r}]}function Imn(e,t){const{x:n,y:r}=e;let s=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const l=t[a],c=t[i],u=l.x,d=l.y,f=c.x,p=c.y;d>r!=p>r&&n<(f-u)*(r-d)/(p-d)+u&&(s=!s)}return s}function Amn(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),Rmn(t)}function Rmn(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const s=e[r];for(;t.length>=2;){const a=t[t.length-1],i=t[t.length-2];if((a.x-i.x)*(s.y-i.y)>=(a.y-i.y)*(s.x-i.x))t.pop();else break}t.push(s)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const s=e[r];for(;n.length>=2;){const a=n[n.length-1],i=n[n.length-2];if((a.x-i.x)*(s.y-i.y)>=(a.y-i.y)*(s.x-i.x))n.pop();else break}n.push(s)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}function Pmn(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const $mn=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Mmn=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Dmn={};function BMe(e,t){return(Dmn.jsx?Mmn:$mn).test(e)}const Lmn=/[ \t\n\f\r]/g;function Fmn(e){return typeof e=="object"?e.type==="text"?UMe(e.value):!1:UMe(e)}function UMe(e){return e.replace(Lmn,"")===""}let bD=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};bD.prototype.normal={};bD.prototype.property={};bD.prototype.space=void 0;function rut(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new bD(n,r,t)}function lfe(e){return e.toLowerCase()}let Cf=class{constructor(t,n){this.attribute=n,this.property=t}};Cf.prototype.attribute="";Cf.prototype.booleanish=!1;Cf.prototype.boolean=!1;Cf.prototype.commaOrSpaceSeparated=!1;Cf.prototype.commaSeparated=!1;Cf.prototype.defined=!1;Cf.prototype.mustUseProperty=!1;Cf.prototype.number=!1;Cf.prototype.overloadedBoolean=!1;Cf.prototype.property="";Cf.prototype.spaceSeparated=!1;Cf.prototype.space=void 0;let zmn=0;const ss=g_(),kl=g_(),cfe=g_(),Qt=g_(),Ri=g_(),cj=g_(),Jf=g_();function g_(){return 2**++zmn}const ufe=Object.freeze(Object.defineProperty({__proto__:null,boolean:ss,booleanish:kl,commaOrSpaceSeparated:Jf,commaSeparated:cj,number:Qt,overloadedBoolean:cfe,spaceSeparated:Ri},Symbol.toStringTag,{value:"Module"})),cX=Object.keys(ufe);class Ebe extends Cf{constructor(t,n,r,s){let a=-1;if(super(t,n),qMe(this,"space",s),typeof r=="number")for(;++a<cX.length;){const i=cX[a];qMe(this,cX[a],(r&ufe[i])===ufe[i])}}}Ebe.prototype.defined=!0;function qMe(e,t,n){n&&(e[t]=n)}function SN(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const a=new Ebe(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[lfe(r)]=r,n[lfe(a.attribute)]=r}return new bD(t,n,e.space)}const sut=SN({properties:{ariaActiveDescendant:null,ariaAtomic:kl,ariaAutoComplete:null,ariaBusy:kl,ariaChecked:kl,ariaColCount:Qt,ariaColIndex:Qt,ariaColSpan:Qt,ariaControls:Ri,ariaCurrent:null,ariaDescribedBy:Ri,ariaDetails:null,ariaDisabled:kl,ariaDropEffect:Ri,ariaErrorMessage:null,ariaExpanded:kl,ariaFlowTo:Ri,ariaGrabbed:kl,ariaHasPopup:null,ariaHidden:kl,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ri,ariaLevel:Qt,ariaLive:null,ariaModal:kl,ariaMultiLine:kl,ariaMultiSelectable:kl,ariaOrientation:null,ariaOwns:Ri,ariaPlaceholder:null,ariaPosInSet:Qt,ariaPressed:kl,ariaReadOnly:kl,ariaRelevant:null,ariaRequired:kl,ariaRoleDescription:Ri,ariaRowCount:Qt,ariaRowIndex:Qt,ariaRowSpan:Qt,ariaSelected:kl,ariaSetSize:Qt,ariaSort:null,ariaValueMax:Qt,ariaValueMin:Qt,ariaValueNow:Qt,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function aut(e,t){return t in e?e[t]:t}function iut(e,t){return aut(e,t.toLowerCase())}const Bmn=SN({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:cj,acceptCharset:Ri,accessKey:Ri,action:null,allow:null,allowFullScreen:ss,allowPaymentRequest:ss,allowUserMedia:ss,alt:null,as:null,async:ss,autoCapitalize:null,autoComplete:Ri,autoFocus:ss,autoPlay:ss,blocking:Ri,capture:null,charSet:null,checked:ss,cite:null,className:Ri,cols:Qt,colSpan:null,content:null,contentEditable:kl,controls:ss,controlsList:Ri,coords:Qt|cj,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ss,defer:ss,dir:null,dirName:null,disabled:ss,download:cfe,draggable:kl,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ss,formTarget:null,headers:Ri,height:Qt,hidden:cfe,high:Qt,href:null,hrefLang:null,htmlFor:Ri,httpEquiv:Ri,id:null,imageSizes:null,imageSrcSet:null,inert:ss,inputMode:null,integrity:null,is:null,isMap:ss,itemId:null,itemProp:Ri,itemRef:Ri,itemScope:ss,itemType:Ri,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ss,low:Qt,manifest:null,max:null,maxLength:Qt,media:null,method:null,min:null,minLength:Qt,multiple:ss,muted:ss,name:null,nonce:null,noModule:ss,noValidate:ss,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ss,optimum:Qt,pattern:null,ping:Ri,placeholder:null,playsInline:ss,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ss,referrerPolicy:null,rel:Ri,required:ss,reversed:ss,rows:Qt,rowSpan:Qt,sandbox:Ri,scope:null,scoped:ss,seamless:ss,selected:ss,shadowRootClonable:ss,shadowRootDelegatesFocus:ss,shadowRootMode:null,shape:null,size:Qt,sizes:null,slot:null,span:Qt,spellCheck:kl,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Qt,step:null,style:null,tabIndex:Qt,target:null,title:null,translate:null,type:null,typeMustMatch:ss,useMap:null,value:kl,width:Qt,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ri,axis:null,background:null,bgColor:null,border:Qt,borderColor:null,bottomMargin:Qt,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ss,declare:ss,event:null,face:null,frame:null,frameBorder:null,hSpace:Qt,leftMargin:Qt,link:null,longDesc:null,lowSrc:null,marginHeight:Qt,marginWidth:Qt,noResize:ss,noHref:ss,noShade:ss,noWrap:ss,object:null,profile:null,prompt:null,rev:null,rightMargin:Qt,rules:null,scheme:null,scrolling:kl,standby:null,summary:null,text:null,topMargin:Qt,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Qt,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ss,disableRemotePlayback:ss,prefix:null,property:null,results:Qt,security:null,unselectable:null},space:"html",transform:iut}),Umn=SN({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",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",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",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",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",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",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Jf,accentHeight:Qt,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Qt,amplitude:Qt,arabicForm:null,ascent:Qt,attributeName:null,attributeType:null,azimuth:Qt,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Qt,by:null,calcMode:null,capHeight:Qt,className:Ri,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Qt,diffuseConstant:Qt,direction:null,display:null,dur:null,divisor:Qt,dominantBaseline:null,download:ss,dx:null,dy:null,edgeMode:null,editable:null,elevation:Qt,enableBackground:null,end:null,event:null,exponent:Qt,externalResourcesRequired:null,fill:null,fillOpacity:Qt,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:cj,g2:cj,glyphName:cj,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Qt,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Qt,horizOriginX:Qt,horizOriginY:Qt,id:null,ideographic:Qt,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Qt,k:Qt,k1:Qt,k2:Qt,k3:Qt,k4:Qt,kernelMatrix:Jf,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Qt,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Qt,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Qt,overlineThickness:Qt,paintOrder:null,panose1:null,path:null,pathLength:Qt,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ri,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Qt,pointsAtY:Qt,pointsAtZ:Qt,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Jf,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Jf,rev:Jf,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Jf,requiredFeatures:Jf,requiredFonts:Jf,requiredFormats:Jf,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Qt,specularExponent:Qt,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Qt,strikethroughThickness:Qt,string:null,stroke:null,strokeDashArray:Jf,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Qt,strokeOpacity:Qt,strokeWidth:null,style:null,surfaceScale:Qt,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Jf,tabIndex:Qt,tableValues:null,target:null,targetX:Qt,targetY:Qt,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Jf,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Qt,underlineThickness:Qt,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Qt,values:null,vAlphabetic:Qt,vMathematical:Qt,vectorEffect:null,vHanging:Qt,vIdeographic:Qt,version:null,vertAdvY:Qt,vertOriginX:Qt,vertOriginY:Qt,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Qt,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:aut}),out=SN({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),lut=SN({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:iut}),cut=SN({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),qmn={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Vmn=/[A-Z]/g,VMe=/-[a-z]/g,Hmn=/^data[-\w.:]+$/i;function Wmn(e,t){const n=lfe(t);let r=t,s=Cf;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Hmn.test(t)){if(t.charAt(4)==="-"){const a=t.slice(5).replace(VMe,Gmn);r="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{const a=t.slice(4);if(!VMe.test(a)){let i=a.replace(Vmn,Zmn);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}s=Ebe}return new s(r,t)}function Zmn(e){return"-"+e.toLowerCase()}function Gmn(e){return e.charAt(1).toUpperCase()}const Qmn=rut([sut,Bmn,out,lut,cut],"html"),jbe=rut([sut,Umn,out,lut,cut],"svg");function Ymn(e){return e.join(" ").trim()}var DC={},uX,HMe;function Xmn(){if(HMe)return uX;HMe=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,i=/^[;\s]*/,l=/^\s+|\s+$/g,c=`
194
+ `):void 0,experimental_attachments:l.length>0?l:void 0,content:u||void 0,metadata:Object.keys(d).length>0?d:void 0}};return e.providerOptions&&(p.content.providerMetadata=e.providerOptions),p}};function id(e,t){for(const[n,r]of Object.entries(t))r!==void 0&&(e[n]=r);return e}function tv(e,t,n){const r=eg(e,"display",t);return wu(r)?r.transformed:n}function Eon(e){return e.startsWith("tool-")?Xc(e.slice(5)):Xc(e)}function wlt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{}}function jon(e){return typeof e=="object"&&e&&"value"in e?e.value:e}function Ton(e){return e==="approval-requested"||e==="approval-responded"||e==="output-denied"}function Non(e){if(e)return{id:e.id,approved:"approved"in e?e.approved:void 0,reason:"reason"in e?e.reason:void 0}}function Ion(e){return e.type==="dynamic-tool"?Xc(e.toolName):Eon(e.type)}function Aon(e){const t={toolCallId:e.toolCallId,toolName:Ion(e),args:wlt(e.input),approval:"approval"in e?Non(e.approval):void 0,providerMetadata:"callProviderMetadata"in e?e.callProviderMetadata:void 0,providerExecuted:e.providerExecuted,title:e.title,preliminary:"preliminary"in e?e.preliminary:void 0};switch(e.state){case"input-streaming":return ck({...t,state:"partial-call"});case"input-available":return ck({...t,state:"call"});case"output-available":return ck({...t,state:"result",result:jon(e.output)});case"output-error":return ck({...t,state:"output-error",errorText:e.errorText,rawInput:"rawInput"in e?e.rawInput:void 0});case"approval-requested":case"approval-responded":case"output-denied":return ck({...t,state:e.state})}}function Ron(e){return e.type==="dynamic-tool"&&!Ton(e.state)?{...e,type:`tool-${Xc(e.toolName)}`}:e}function ck({toolCallId:e,toolName:t,args:n,state:r,approval:s,result:a,errorText:i,rawInput:l,providerMetadata:c,providerExecuted:u,title:d,preliminary:f}){return id({type:"tool-invocation",toolInvocation:id({toolCallId:e,toolName:t,args:n,state:r},{approval:s,result:a,errorText:i,rawInput:l})},{providerMetadata:c,providerExecuted:u,title:d,preliminary:f})}function Pon(e,t){for(const n of e)if(n.type==="tool-invocation"&&n.toolInvocation.toolCallId===t)return n}function $on(e,t){if(e){for(const n of[...e].reverse())for(const r of[...n.content.parts||[]].reverse())if(r.type==="tool-invocation"&&r.toolInvocation.approval?.id===t&&r.toolInvocation.state==="approval-requested")return r}}function Mon(e){const t=[];for(const n of e){if(n.type!=="tool-invocation")continue;const r=n.toolInvocation;if(r.state==="result"){t.push({args:r.args,result:r.result,toolCallId:r.toolCallId,toolName:r.toolName,state:"result"});continue}(r.state==="call"||r.state==="partial-call")&&t.push({args:r.args,toolCallId:r.toolCallId,toolName:r.toolName,state:r.state})}return t.length>0?t:void 0}var oz=class G0{static toUIMessage(t){const n=Av.toUIMessage(t),r=n.metadata||{},s=[];if(t.role==="signal"&&n.role!=="user")return{id:t.id,role:"system",metadata:Object.keys(r).length>0?r:void 0,parts:n.parts.map(d=>G0.toUIPartFromV5(d))};const a=t.content.parts||[],i=a.some(d=>d.type==="tool-invocation"),l=a.some(d=>d.type==="reasoning"),c=a.some(d=>d.type==="file"),u=a.some(d=>d.type==="text");for(const d of a)s.push(G0.toUIPart(d));if(!i||!l||!c||!u)for(const d of n.parts){if(Cp(d)){i||s.push(G0.toUIPartFromV5(d));continue}if(d.type==="reasoning"){l||s.push(G0.toUIPartFromV5(d));continue}if(d.type==="file"){c||s.push(G0.toUIPartFromV5(d));continue}d.type==="text"&&!u&&s.push(G0.toUIPartFromV5(d))}return{id:t.id,role:t.role==="signal"?n.role:t.role,metadata:Object.keys(r).length>0?r:void 0,parts:s}}static fromUIMessage(t){const n=t.parts.filter(l=>!(l.type==="source-document"||R$e(l))),r=Av.fromUIMessage({...t,parts:n.map(l=>Ron(l))}),s=r.content.parts||[],a=[];let i=0;for(const l of t.parts){if(l.type==="source-document"){a.push(id({type:"source-document",sourceId:l.sourceId,mediaType:l.mediaType,title:l.title},{filename:l.filename,providerMetadata:l.providerMetadata}));continue}if(!R$e(l)){const c=s[i++];c&&a.push(c);continue}a.push(Aon(l))}return{...r,content:{...r.content,parts:a,toolInvocations:Mon(a)||r.content.toolInvocations}}}static fromModelMessage(t,n,r={}){const s=Array.isArray(t.content)?t.content:[{type:"text",text:t.content}],a=s.filter(c=>c.type!=="tool-approval-request"&&c.type!=="tool-approval-response"),i=Av.fromModelMessage({...t,content:a},n,r),l=[...i.content.parts];if(t.role==="assistant"){const c=new Map;for(const u of s){if(u.type==="tool-call"){c.set(u.toolCallId,{toolName:Xc(u.toolName),args:wlt(u.input)});continue}if(u.type!=="tool-approval-request")continue;const d=c.get(u.toolCallId),f=Pon(l,u.toolCallId);if(f){f.toolInvocation.state="approval-requested",f.toolInvocation.approval={id:u.approvalId};continue}l.push(ck({toolCallId:u.toolCallId,toolName:d?.toolName||"unknown",args:d?.args||{},state:"approval-requested",approval:{id:u.approvalId}}))}}else if(t.role==="tool")for(const c of s){if(c.type!=="tool-approval-response")continue;const u=$on(r.dbMessages,c.approvalId);u&&l.push(ck({toolCallId:u.toolInvocation.toolCallId,toolName:u.toolInvocation.toolName,args:u.toolInvocation.args,state:"approval-responded",approval:{id:c.approvalId,approved:c.approved,reason:c.reason},providerMetadata:u.providerMetadata,providerExecuted:u.providerExecuted,title:u.title}))}return{...i,content:{...i.content,parts:l}}}static toUIPart(t){if(t.type==="tool-invocation"){const n=id({type:`tool-${Xc(t.toolInvocation.toolName)}`,toolCallId:t.toolInvocation.toolCallId,providerExecuted:t.providerExecuted},{callProviderMetadata:t.providerMetadata,title:t.title});switch(t.toolInvocation.state){case"partial-call":return{...n,state:"input-streaming",input:tv(t.providerMetadata,"input-available",t.toolInvocation.args)};case"call":return{...n,state:"input-available",input:tv(t.providerMetadata,"input-available",t.toolInvocation.args)};case"approval-requested":return{...n,state:"approval-requested",input:tv(t.providerMetadata,"input-available",t.toolInvocation.args),approval:{id:t.toolInvocation.approval?.id||t.toolInvocation.toolCallId}};case"approval-responded":return{...n,state:"approval-responded",input:tv(t.providerMetadata,"input-available",t.toolInvocation.args),approval:{id:t.toolInvocation.approval?.id||t.toolInvocation.toolCallId,approved:t.toolInvocation.approval?.approved??!1,reason:t.toolInvocation.approval?.reason}};case"output-error":return id({...n,state:"output-error",input:tv(t.providerMetadata,"input-available",t.toolInvocation.args),errorText:tv(t.providerMetadata,"error",t.toolInvocation.errorText||"")},{rawInput:t.toolInvocation.rawInput,approval:t.toolInvocation.approval?.approved===!0?{id:t.toolInvocation.approval.id,approved:!0,reason:t.toolInvocation.approval.reason}:void 0});case"output-denied":return{...n,state:"output-denied",input:tv(t.providerMetadata,"input-available",t.toolInvocation.args),approval:{id:t.toolInvocation.approval?.id||t.toolInvocation.toolCallId,approved:!1,reason:t.toolInvocation.approval?.reason}};case"result":return id({...n,state:"output-available",input:tv(t.providerMetadata,"input-available",t.toolInvocation.args),output:tv(t.providerMetadata,"output-available",tv(t.providerMetadata,"error",t.toolInvocation.result))},{preliminary:t.preliminary,approval:t.toolInvocation.approval?.approved===!0?{id:t.toolInvocation.approval.id,approved:!0,reason:t.toolInvocation.approval.reason}:void 0});default:throw new Error(`Unhandled toolInvocation.state: ${String(t.toolInvocation.state)}`)}}return t.type==="source-document"?id({type:"source-document",sourceId:t.sourceId,mediaType:t.mediaType,title:t.title},{filename:t.filename,providerMetadata:t.providerMetadata}):G0.toUIPartFromV5(Av.toUIMessage({id:"tmp",role:"assistant",createdAt:new Date,content:{format:2,parts:[t]}}).parts[0])}static toUIPartFromV5(t){if(Cp(t)){const n={type:t.type,toolCallId:t.toolCallId,providerExecuted:t.providerExecuted};switch(t.state){case"input-streaming":return id({...n,state:"input-streaming",input:t.input},{callProviderMetadata:"callProviderMetadata"in t?t.callProviderMetadata:void 0,title:"title"in t?t.title:void 0});case"input-available":return id({...n,state:"input-available",input:t.input},{callProviderMetadata:"callProviderMetadata"in t?t.callProviderMetadata:void 0,title:"title"in t?t.title:void 0});case"output-available":return id({...n,state:"output-available",input:t.input,output:t.output},{callProviderMetadata:"callProviderMetadata"in t?t.callProviderMetadata:void 0,preliminary:"preliminary"in t?t.preliminary:void 0,title:"title"in t?t.title:void 0});case"output-error":return id({...n,state:"output-error",input:t.input,errorText:t.errorText},{rawInput:"rawInput"in t?t.rawInput:void 0,callProviderMetadata:"callProviderMetadata"in t?t.callProviderMetadata:void 0,title:"title"in t?t.title:void 0})}}switch(t.type){case"text":return id({type:"text",text:t.text},{providerMetadata:t.providerMetadata});case"reasoning":return id({type:"reasoning",text:t.text,state:t.state},{providerMetadata:t.providerMetadata});case"file":return id({type:"file",url:t.url,mediaType:t.mediaType},{filename:"filename"in t?t.filename:void 0,providerMetadata:t.providerMetadata});case"source-url":return id({type:"source-url",sourceId:t.sourceId,url:t.url},{title:t.title,providerMetadata:t.providerMetadata});case"step-start":return{type:"step-start"};default:return typeof t.type=="string"&&t.type.startsWith("data-")?{type:t.type,data:"data"in t?t.data:void 0}:t}}};function Don(e){return JSON.stringify(e,(t,n)=>{if(n&&typeof n=="object"&&!Array.isArray(n)){const r={};for(const s of Object.keys(n).sort())r[s]=n[s];return r}return n})}function A0(e,...t){const n=new Set(t.flatMap(r=>hon(r)));for(const r of n)e+=`|${r}`;return e}var Wo=class Xde{static fromAIV4Parts(t){let n="";for(const r of t)n+=r.type,n+=Xde.fromAIV4Part(r);return n}static fromAIV4Part(t){let n="";if(t.type==="text"&&(n+=t.text,n=A0(n,t.providerMetadata)),t.type==="tool-invocation"){if(!t.toolInvocation)return n;n+=t.toolInvocation.toolCallId,n+=t.toolInvocation.state}if(t.type==="reasoning"){n+=t.reasoning,n+=(t.details??[]).reduce((s,a)=>a.type==="text"?s+(a.text?.length??0)+(a.signature?.length||0):s,0);const r=t;r&&Object.hasOwn(r,"providerMetadata")&&(n=A0(n,r.providerMetadata))}return t.type==="file"&&(n+=t.data,n+=t.mimeType),n}static fromDBParts(t){let n="";for(const r of t)if(n+=r.type,r.type.startsWith("data-")){const s=r.data;n+=Don(s)}else n+=Xde.fromAIV4Part(r);return n}static fromAIV4CoreMessageContent(t){if(typeof t=="string")return t;let n="";for(const r of t){if(n+=r.type,r.type==="text"){n+=r.text.length;const s=r;n=A0(n,s.providerMetadata,s.providerOptions)}if(r.type==="reasoning"){n+=r.text.length;const s=r;n=A0(n,s.providerMetadata,s.providerOptions)}r.type==="tool-call"&&(n+=r.toolCallId,n+=r.toolName),r.type==="tool-result"&&(n+=r.toolCallId,n+=r.toolName),r.type==="file"&&(n+=r.filename,n+=r.mimeType),r.type==="image"&&(n+=rMe(r.image),n+=r.mimeType),r.type==="redacted-reasoning"&&(n+=r.data.length)}return n}static fromAIV5Parts(t){let n="";for(const r of t)n+=r.type,r.type==="text"&&(n+=r.text,n=A0(n,r.providerMetadata)),(Cp(r)||r.type==="dynamic-tool")&&(n+=r.toolCallId,n+=r.state),r.type==="reasoning"&&(n+=r.text,n=A0(n,r.providerMetadata)),r.type==="file"&&(n+=r.url.length,n+=r.mediaType,n+=r.filename||"");return n}static fromAIV5ModelMessageContent(t){if(typeof t=="string")return t;let n="";for(const r of t)n+=r.type,r.type==="text"&&(n+=r.text.length,n=A0(n,r.providerOptions)),r.type==="reasoning"&&(n+=r.text.length,n=A0(n,r.providerOptions)),r.type==="tool-call"&&(n+=r.toolCallId,n+=r.toolName),r.type==="tool-result"&&(n+=r.toolCallId,n+=r.toolName),r.type==="file"&&(n+=r.filename,n+=r.mediaType),r.type==="image"&&(n+=rMe(r.image),n+=r.mediaType);return n}};function Lon(e){if(e.role==="system")return e;if(typeof e.content=="string"&&(e.role==="assistant"||e.role==="user"))return{...e,content:[{type:"text",text:e.content}]};if(typeof e.content=="string")throw new Error(`Saw text content for input CoreMessage, but the role is ${e.role}. This is only allowed for "system", "assistant", and "user" roles.`);const t={user:[],assistant:[],tool:[]},n=e.role;for(const r of e.content){const s=`Saw incompatible message content part type ${r.type} for message role ${n}`;switch(r.type){case"text":{if(n==="tool")throw new Error(s);t[n].push(r);break}case"redacted-reasoning":case"reasoning":{if(n!=="assistant")throw new Error(s);t[n].push(r);break}case"tool-call":{if(n==="tool"||n==="user")throw new Error(s);t[n].push({...r,toolName:Xc(r.toolName)});break}case"tool-result":{if(n==="assistant"||n==="user")throw new Error(s);t[n].push({...r,toolName:Xc(r.toolName)});break}case"image":{if(n==="tool"||n==="assistant")throw new Error(s);let a;r.image instanceof URL||r.image instanceof Uint8Array?a=r.image:Buffer.isBuffer(r.image)||r.image instanceof ArrayBuffer?a=new Uint8Array(r.image):BP(r.image,r.mimeType).type==="raw"?a=new Uint8Array(Buffer.from(r.image,"base64")):a=new URL(r.image),t[n].push({...r,image:a});break}case"file":{if(n==="tool")throw new Error(s);t[n].push({...r,data:r.data instanceof URL||typeof r.data=="string"?r.data:cO(r.data)});break}}}if(n==="tool")return{...e,content:t[n]};if(n==="user")return{...e,content:t[n]};if(n==="assistant")return{...e,content:t[n]};throw new Error(`Encountered unknown role ${n} when converting V4 CoreMessage -> V4 LanguageModelV1Prompt, input message: ${JSON.stringify(e,null,2)}`)}function Fon(e){if(e.role==="system")return e;if(typeof e.content=="string"&&(e.role==="assistant"||e.role==="user"))return{role:e.role,content:[{type:"text",text:e.content}],providerOptions:e.providerOptions};if(typeof e.content=="string")throw new Error(`Saw text content for input ModelMessage, but the role is ${e.role}. This is only allowed for "system", "assistant", and "user" roles.`);const t={user:[],assistant:[],tool:[]},n=e.role;for(const r of e.content){const s=`Saw incompatible message content part type ${r.type} for message role ${n}`;switch(r.type){case"text":{if(n==="tool")throw new Error(s);t[n].push(r);break}case"reasoning":{if(n==="tool"||n==="user")throw new Error(s);t[n].push(r);break}case"tool-call":{if(n!=="assistant")throw new Error(s);t[n].push({...r,toolName:Xc(r.toolName)});break}case"tool-result":{if(n==="user")throw new Error(s);t[n].push({...r,toolName:Xc(r.toolName)});break}case"file":{if(n==="tool")throw new Error(s);t[n].push({...r,data:r.data instanceof ArrayBuffer?new Uint8Array(r.data):r.data});break}case"image":{if(n==="tool")throw new Error(s);t[n].push({...r,mediaType:r.mediaType||"image/unknown",type:"file",data:r.image instanceof ArrayBuffer?new Uint8Array(r.image):r.image});break}}}if(n==="tool")return{...e,content:t[n]};if(n==="user")return{...e,content:t[n]};if(n==="assistant")return{...e,content:t[n]};throw new Error(`Encountered unknown role ${n} when converting V5 ModelMessage -> V5 LanguageModelV2Message, input message: ${JSON.stringify(e,null,2)}`)}function zon(e){return e.map(t=>{if(t.role!=="tool")return t;let n=!1;const r=t.content.map(s=>{if(s.type!=="tool-result")return s;const a=s.output;if(!a||a.type!=="content"||!Array.isArray(a.value))return s;let i=!1;const l=a.value.map(c=>{if(c==null||typeof c!="object")return c;const u=c;if(u.type!=="media"||typeof u.data!="string")return c;i=!0;const d=typeof u.mediaType=="string"?u.mediaType:"";return d.startsWith("image/")?{type:"image-data",data:u.data,mediaType:d}:{type:"file-data",data:u.data,mediaType:d}});return i?(n=!0,{...s,output:{...a,value:l}}):s});return n?{...t,content:r}:t})}function Bon(e){return typeof e=="string"?e:e.reduce((t,n)=>(n.type==="text"&&(t+=n.text),t),"")}function nX(e,t){const n=Za.isAIV4UIMessage(e)&&e,r=Za.isAIV4UIMessage(t)&&t;if(n&&!r)return!1;if(n&&r)return Wo.fromAIV4Parts(e.parts)===Wo.fromAIV4Parts(t.parts);const s=Za.isAIV4CoreMessage(e)&&e,a=Za.isAIV4CoreMessage(t)&&t;if(s&&!a)return!1;if(s&&a)return Wo.fromAIV4CoreMessageContent(s.content)===Wo.fromAIV4CoreMessageContent(a.content);const i=Za.isMastraMessageV1(e)&&e,l=Za.isMastraMessageV1(t)&&t;if(i&&!l)return!1;if(i&&l)return i.id===l.id&&Wo.fromAIV4CoreMessageContent(i.content)===Wo.fromAIV4CoreMessageContent(l.content);const c=Za.isMastraDBMessage(e)&&e,u=Za.isMastraDBMessage(t)&&t;if(c&&!u)return!1;if(c&&u)return c.id===u.id&&Wo.fromDBParts(c.content.parts)===Wo.fromDBParts(u.content.parts);const d=Za.isAIV5UIMessage(e)&&e,f=Za.isAIV5UIMessage(t)&&t;if(d&&!f)return!1;if(d&&f)return Wo.fromAIV5Parts(e.parts)===Wo.fromAIV5Parts(t.parts);const p=Za.isAIV5CoreMessage(e)&&e,h=Za.isAIV5CoreMessage(t)&&t;return p&&!h?!1:p&&h?Wo.fromAIV5ModelMessageContent(p.content)===Wo.fromAIV5ModelMessageContent(h.content):!0}function ebe(e){return e.createdAt==null&&(e.createdAt=Date.now()),e}function $C(e,t){return t==="memory"||!Array.isArray(e.content.parts)||(e.content.parts=e.content.parts.map(n=>ebe(n))),e}function cMe(e,t,n){if(t!=="memory"&&"threadId"in e&&e.threadId&&n.memoryInfo&&e.threadId!==n.memoryInfo.threadId)throw new Error(`Received input message with wrong threadId. Input ${e.threadId}, expected ${n.memoryInfo.threadId}`);if("resourceId"in e&&e.resourceId&&n.memoryInfo?.resourceId&&e.resourceId!==n.memoryInfo.resourceId)throw new Error(`Received input message with wrong resourceId. Input ${e.resourceId}, expected ${n.memoryInfo.resourceId}`);if(Za.isMastraMessageV1(e))return $C(Uon(e,t,n),t);if(Za.isMastraDBMessage(e))return $C(qon(e,n,t),t);if(Za.isAIV4CoreMessage(e))return $C(Ew.fromCoreMessage(e,n,t),t);if(Za.isAIV4UIMessage(e))return $C(Ew.fromUIMessage(e,n,t),t);const s="id"in e&&typeof e.id=="string"?e.id:n.newMessageId();if(Za.isAIV6CoreMessage(e)){const a=oz.fromModelMessage(e,t,n),i="metadata"in e&&e.metadata&&typeof e.metadata=="object"&&"createdAt"in e.metadata?e.metadata.createdAt:void 0;return{...a,id:s,createdAt:n.generateCreatedAt(t,i),threadId:n.memoryInfo?.threadId,resourceId:n.memoryInfo?.resourceId}}if(Za.isAIV6UIMessage(e)){const a=oz.fromUIMessage(e),i="createdAt"in e?e.createdAt:void 0;return{...a,id:s,createdAt:n.generateCreatedAt(t,i),threadId:n.memoryInfo?.threadId,resourceId:n.memoryInfo?.resourceId}}if(Za.isAIV5CoreMessage(e)){const a=Av.fromModelMessage(e,t,n),i="metadata"in e&&e.metadata&&typeof e.metadata=="object"&&"createdAt"in e.metadata?e.metadata.createdAt:void 0;return $C({...a,id:s,createdAt:n.generateCreatedAt(t,i),threadId:n.memoryInfo?.threadId,resourceId:n.memoryInfo?.resourceId},t)}if(Za.isAIV5UIMessage(e)){const a=Av.fromUIMessage(e),i="createdAt"in e?e.createdAt:void 0;return $C({...a,id:s,createdAt:n.generateCreatedAt(t,i),threadId:n.memoryInfo?.threadId,resourceId:n.memoryInfo?.resourceId},t)}throw new Error(`Found unhandled message ${JSON.stringify(e)}`)}function Uon(e,t,n){const r=Ew.fromCoreMessage({content:e.content,role:e.role},n,t);return{id:e.id,role:r.role,createdAt:n.generateCreatedAt(t,e.createdAt),threadId:e.threadId,resourceId:e.resourceId,content:r.content}}function qon(e,t,n){return e.id||(e.id=t.newMessageId()),e.createdAt===void 0||e.createdAt===null?e.createdAt=t.generateCreatedAt(n):e.createdAt instanceof Date||(e.createdAt=new Date(e.createdAt)),e.content.toolInvocations&&e.content.parts&&(e.content.toolInvocations=e.content.toolInvocations.map(r=>{if(!r.args||Object.keys(r.args).length===0){const s=e.content.parts.find(a=>a.type==="tool-invocation"&&a.toolInvocation&&a.toolInvocation.toolCallId===r.toolCallId&&a.toolInvocation.args&&Object.keys(a.toolInvocation.args).length>0);if(s&&s.type==="tool-invocation")return{...r,args:s.toolInvocation.args}}return r})),!e.threadId&&t.memoryInfo?.threadId&&(e.threadId=t.memoryInfo.threadId),!e.resourceId&&t.memoryInfo?.resourceId&&(e.resourceId=t.memoryInfo.resourceId),e}function Von(e){return e.type.startsWith("source-")}function Hon(e){const t=[];for(const n of e){if(n.type!=="text"){t.push(n);continue}const r=n,s=sMe(r.providerMetadata);if(!s){t.push(n);continue}let a=!1;for(let i=t.length-1;i>=0;i--){const l=t[i];if(l.type==="text"){const c=l;sMe(c.providerMetadata)===s&&(t[i]={...c,text:c.text+r.text},a=!0);break}if(!Von(l))break}a||t.push(n)}return t}function Won(e){return e.map(n=>{if(n.parts.length===0)return!1;const r=n.parts.filter(a=>a.type!=="tool-invocation"||a.toolInvocation.state!=="call"&&a.toolInvocation.state!=="partial-call");if(!r.length)return!1;const s={...n,parts:r};return"toolInvocations"in n&&n.toolInvocations&&(s.toolInvocations=n.toolInvocations.filter(a=>a.state==="result")),s}).filter(n=>!!n)}function Slt(e,t=!1){let n=-1;for(let i=e.length-1;i>=0;i--)if(e[i].role==="user"){n=i;break}const r=(i,l)=>i.parts.filter(c=>typeof c.type=="string"&&c.type.startsWith("data-")||c.type==="text"&&(!("text"in c)||c.text===""||c.text?.trim()==="")&&(i.role==="user"||i.parts.some(d=>!(d.type==="text"&&(!("text"in d)||d.text===""||d.text?.trim()===""))))?!1:Cp(c)?t?!!(c.state==="output-available"||c.state==="output-error"||c.state==="input-available"&&c.providerExecuted&&l):c.state!=="input-streaming":!0);let s=-1;if(n!==e.length-1)for(let i=e.length-1;i>n;i--){const l=e[i];if(!(l.role!=="assistant"||l.parts.length===0)&&r(l,!0).length>0){s=i;break}}return e.map((i,l)=>{if(i.parts.length===0)return!1;const c=i.role==="assistant"&&l===s,u=r(i,c);if(!u.length)return!1;const d=Hon(u);return{...i,parts:d.map(p=>Cp(p)&&p.state==="output-available"?{...p,output:(()=>{const h=p.output;if(h==null||typeof h!="object")return h;const m=h;return m.type==="content"&&Array.isArray(m.value)?h:"value"in m?m.value:h})()}:p)}}).filter(i=>!!i)}function Zon(e){for(const t of e)if(t.role==="assistant")for(const[n,r]of t.parts.entries()){if(!Cp(r))continue;const s=t.parts.at(n+1);s&&s.type!=="step-start"&&!Cp(s)&&t.parts.splice(n+1,0,{type:"step-start"}),s&&Cp(s)&&!r.providerExecuted&&s.providerExecuted&&(s.state==="output-available"||s.state==="output-error")&&t.parts.splice(n+1,0,{type:"step-start"})}return e}function mh(e){return ein(Won(e))}function Gon(e){if(!e||typeof e!="object")return;const t=e.content;if(!Array.isArray(t)||!t.some(s=>{if(!s||typeof s!="object")return!1;const a=s;return(a.type==="image"||a.type==="audio")&&typeof a.data=="string"}))return;const r=t.map(s=>{if(!s||typeof s!="object")return null;const a=s;switch(a.type){case"text":return{type:"text",text:String(a.text??"")};case"image":return typeof a.data=="string"?{type:"image-data",data:a.data,mediaType:String(a.mimeType??"image/png")}:{type:"text",text:JSON.stringify(a)};case"audio":return typeof a.data=="string"?{type:"file-data",data:a.data,mediaType:String(a.mimeType??"audio/wav")}:{type:"text",text:JSON.stringify(a)};default:return{type:"text",text:JSON.stringify(a)}}}).filter(Boolean);return r.length>0?{type:"content",value:r}:void 0}function Qon(e){const t=new Map;for(const n of e)if(!(n.content?.format!==2||!n.content.parts))for(const r of n.content.parts)r.type!=="tool-invocation"||r.toolInvocation?.state!=="result"||t.set(r.toolInvocation.toolCallId,r.toolInvocation.result);return t}function Yon(e,t){if(!e||typeof e!="object")return!1;const n=e;return n.type!=="json"?!1:JSON.stringify(n.value)===JSON.stringify(t)}function Xon(e,t){const n=Qon(t);return n.size===0?e:e.map(r=>{if(r.role!=="tool"||!Array.isArray(r.content))return r;let s=!1;const a=r.content.map(i=>{if(i.type!=="tool-result"||!n.has(i.toolCallId))return i;const l=n.get(i.toolCallId);if(!Yon(i.output,l))return i;const c=Gon(l);return c?(s=!0,{...i,output:c}):i});return s?{...r,content:a}:r})}function Kon(e,t){const n=[];for(const s of t)if(s.role==="assistant")for(const a of s.parts)a.type==="file"&&n.push(a.providerMetadata??void 0);if(n.length===0||n.every(s=>s==null))return e;let r=0;return e.map(s=>{if(s.role!=="assistant"||typeof s.content=="string")return s;let a=!1;const i=s.content.map(l=>{if(l.type!=="file"||r>=n.length)return l;const c=n[r++];return l.providerOptions||!c?l:(a=!0,{...l,providerOptions:c})});return a?{...s,content:i}:s})}function pv(e,t,n=!1){const r=Slt(e,n),s=Zon(r),a=[];for(const u of s){const d=kit([u]);if(d.length===0)continue;const f=u.metadata&&typeof u.metadata=="object"&&"providerMetadata"in u.metadata?u.metadata.providerMetadata:void 0;if(f){let p=-1;for(let h=d.length-1;h>=0;h--)if(d[h]?.role===u.role){p=h;break}p!==-1&&(d[p]={...d[p],providerOptions:f})}a.push(...d)}const i=Kon(a,s),l=Xon(i,t),c=mon(l,t);return n?gon(c):c}function uMe(e,t,n,r){return pv(e.map(s=>Ew.fromCoreMessage(s,n,t)).map(s=>Av.toUIMessage(s)),r)}function Jon(e){if(typeof e=="string")return{role:"system",content:e};if(Za.isAIV6CoreMessage(e)){const t=oz.fromModelMessage(e,"system");return Ew.systemToV4Core(t)}if(Za.isAIV5CoreMessage(e)){const t=Av.fromModelMessage(e,"system");return Ew.systemToV4Core(t)}return Za.isMastraDBMessage(e)?Ew.systemToV4Core(e):e}var dMe=class Ob{static extractStepContent(t,n,r){const s=t.flatMap(i=>i.parts),a=[];return s.forEach((i,l)=>{i.type==="step-start"&&a.push(l)}),n===-1?Ob.extractLastStep(s,a,r):n===1?Ob.extractFirstStep(s,a,r):Ob.extractMiddleStep(s,a,n,r)}static extractLastStep(t,n,r){const s=t.filter(u=>u.type?.startsWith("tool-")),a=n.length>0;if(!a&&s.length>0){const u=s[s.length-1];if(!u)return[];const d=t.indexOf(u),f=s[s.length-2],h=(f?t.indexOf(f):-1)+1,m=t.slice(h,d+1);return Ob.convertPartsToContent(m,"last-step",r)}if(n.length+1===1&&!a)return Ob.convertPartsToContent(t,"last-step",r);const l=n[n.length-1];if(l===void 0)return[];const c=t.slice(l+1);return c.length===0?[]:Ob.convertPartsToContent(c,"last-step",r)}static extractFirstStep(t,n,r){const s=n[0]??t.length;if(s===0)return[];const a=t.slice(0,s);return Ob.convertPartsToContent(a,"step-1",r)}static extractMiddleStep(t,n,r,s){const a=r-2;if(a<0||a>=n.length)return[];const i=(n[a]??0)+1,l=n[a+1]??t.length;if(i>=l)return[];const c=t.slice(i,l);return Ob.convertPartsToContent(c,`step-${r}`,s)}static convertPartsToContent(t,n,r){return kit(Slt([{id:n,role:"assistant",parts:t}])).flatMap(r)}static convertToStepContent(t,n,r){const s=t||r();return s?typeof s.content=="string"?[{type:"text",text:s.content}]:s.content.map(a=>a.type==="tool-result"?{type:"tool-result",input:iq(n,a.toolCallId),output:a.output,toolCallId:a.toolCallId,toolName:a.toolName}:a.type==="file"?{type:"file",file:new K$e({data:typeof a.data=="string"?iz(a.data).base64Content:a.data instanceof URL?a.data.toString():cO(a.data),mediaType:a.mediaType})}:a.type==="image"?{type:"file",file:new K$e({data:typeof a.image=="string"?iz(a.image).base64Content:a.image instanceof URL?a.image.toString():cO(a.image),mediaType:a.mediaType||"unknown"})}:{...a}):[]}},ub=class ZR{static isSealed(t){return t.content?.metadata?.mastra?.sealed===!0}static shouldMerge(t,n,r,s,a=!1){if(!t||ZR.isSealed(t)||t.content?.metadata?.mastra?.responseBoundary||n.content.metadata?.completionResult||t.content.metadata?.completionResult||n.content.metadata?.isTaskCompleteResult||t.content.metadata?.isTaskCompleteResult)return!1;const i=t.content?.parts??[];return i.length>0&&i.every(d=>d.type.startsWith("data-"))&&t.id!==n.id?!1:t.role==="assistant"&&n.role==="assistant"&&t.threadId===n.threadId&&r!=="memory"&&(a?!s:!0)}static merge(t,n){n.content.metadata&&(t.content.metadata={...t.content.metadata??{},...n.content.metadata});const r=new Map,s=new Map;for(const[a,i]of n.content.parts.entries())if(i.type==="tool-invocation"){if(!i.toolInvocation)continue;const l=[...t.content.parts].reverse().find(u=>u.type==="tool-invocation"&&u.toolInvocation?.toolCallId===i.toolInvocation.toolCallId);if(!!l&&l.type==="tool-invocation"){if(i.toolInvocation.state==="result"){l.toolInvocation={...l.toolInvocation,step:i.toolInvocation.step,state:"result",result:i.toolInvocation.result,args:{...l.toolInvocation.args,...i.toolInvocation.args}},i.providerMetadata&&(l.providerMetadata={...l.providerMetadata,...i.providerMetadata}),t.content.toolInvocations||(t.content.toolInvocations=[]);const d=t.content.toolInvocations.findIndex(f=>f.toolCallId===l.toolInvocation.toolCallId);d===-1?t.content.toolInvocations.push(l.toolInvocation):t.content.toolInvocations[d]=l.toolInvocation}else(i.toolInvocation.state==="approval-requested"||i.toolInvocation.state==="approval-responded"||i.toolInvocation.state==="output-denied"||i.toolInvocation.state==="output-error")&&(l.toolInvocation={...l.toolInvocation,state:i.toolInvocation.state,approval:i.toolInvocation.approval,errorText:i.toolInvocation.errorText,rawInput:i.toolInvocation.rawInput,args:{...l.toolInvocation.args,...i.toolInvocation.args}},i.providerMetadata&&(l.providerMetadata={...l.providerMetadata,...i.providerMetadata}),"providerExecuted"in i&&i.providerExecuted!==void 0&&(l.providerExecuted=i.providerExecuted),"title"in i&&i.title!==void 0&&(l.title=i.title),"preliminary"in i&&i.preliminary!==void 0&&(l.preliminary=i.preliminary));const u=t.content.parts.findIndex(d=>d===l);r.set(a,u)}else s.set(a,i)}else s.set(a,i);ZR.addPartsToMessage({latestMessage:t,incomingMessage:n,anchorMap:r,partsToAdd:s}),!t.content.content&&n.content.content&&(t.content.content=n.content.content),t.content.content&&n.content.content&&t.content.content!==n.content.content&&(t.content.content=n.content.content)}static addPartsToMessage({latestMessage:t,incomingMessage:n,anchorMap:r,partsToAdd:s}){for(let a=0;a<n.content.parts.length;++a){const i=n.content.parts[a];if(!i)continue;const l=Wo.fromDBParts([i]),c=s.get(a);if(!(!l||!c))if(r.size>0){if(r.has(a))continue;const u=[...r.keys()].filter(v=>v<a).pop()??-1,d=[...r.keys()].find(v=>v>a)??-1,f=u!==-1?r.get(u):0,p=u===-1?a:a-u,h=f+p,m=d!==-1?r.get(d):t.content.parts.length;if(h>=0&&h<=m&&!t.content.parts.slice(h,m).some(v=>Wo.fromDBParts([v])===Wo.fromDBParts([i]))){ZR.pushNewPart({latestMessage:t,newMessage:n,part:i,insertAt:h});for(const[v,y]of r.entries())y>=h&&r.set(v,y+1)}}else ZR.pushNewPart({latestMessage:t,newMessage:n,part:i})}}static pushNewPart({latestMessage:t,newMessage:n,part:r,insertAt:s}){const a=Wo.fromDBParts([r]),i=t.content.parts.filter(c=>Wo.fromDBParts([c])===a).length,l=n.content.parts.filter(c=>Wo.fromDBParts([c])===a).length;if(i<l){const c=n.content.parts.indexOf(r),u=c>0&&n.content.parts[c-1]?.type==="step-start",d=t.role==="assistant"&&r.type==="text"&&!u&&t.content.parts.length>0&&t.content.parts.at(-1)?.type==="tool-invocation",f=[...t.content.parts].reverse().find(h=>h.type==="step-start"),p=f?.model?ebe({type:"step-start",model:f.model}):{type:"step-start"};typeof s=="number"?d?(t.content.parts.splice(s,0,p),t.content.parts.splice(s+1,0,r)):t.content.parts.splice(s,0,r):(d&&t.content.parts.push(p),t.content.parts.push(r))}}};function eln(e){try{const[t,n]=e.split(",");return{mediaType:t?.split(";")[0]?.split(":")[1],base64Content:n}}catch{return{mediaType:void 0,base64Content:void 0}}}function tln(e){if(e instanceof Uint8Array)return{data:e,mediaType:void 0};if(e instanceof ArrayBuffer)return{data:new Uint8Array(e),mediaType:void 0};if(typeof e=="string")try{e=new URL(e)}catch{}if(e instanceof URL&&e.protocol==="data:"){const{mediaType:t,base64Content:n}=eln(e.toString());if(t==null||n==null)throw new sO({id:"INVALID_DATA_URL_FORMAT",text:`Invalid data URL format in content ${e.toString()}`,domain:Hw.LLM,category:Ww.USER});return{data:n,mediaType:t}}return{data:e,mediaType:void 0}}var nln=[{mediaType:"image/gif",bytesPrefix:[71,73,70],base64Prefix:"R0lG"},{mediaType:"image/png",bytesPrefix:[137,80,78,71],base64Prefix:"iVBORw"},{mediaType:"image/jpeg",bytesPrefix:[255,216],base64Prefix:"/9j/"},{mediaType:"image/webp",bytesPrefix:[82,73,70,70],base64Prefix:"UklGRg"},{mediaType:"image/bmp",bytesPrefix:[66,77],base64Prefix:"Qk"},{mediaType:"image/tiff",bytesPrefix:[73,73,42,0],base64Prefix:"SUkqAA"},{mediaType:"image/tiff",bytesPrefix:[77,77,0,42],base64Prefix:"TU0AKg"},{mediaType:"image/avif",bytesPrefix:[0,0,0,32,102,116,121,112,97,118,105,102],base64Prefix:"AAAAIGZ0eXBhdmlm"},{mediaType:"image/heic",bytesPrefix:[0,0,0,32,102,116,121,112,104,101,105,99],base64Prefix:"AAAAIGZ0eXBoZWlj"}],rln=e=>{const t=typeof e=="string"?plt(e):e,n=(t[6]&127)<<21|(t[7]&127)<<14|(t[8]&127)<<7|t[9]&127;return t.slice(n+10)};function sln(e){return typeof e=="string"&&e.startsWith("SUQz")||typeof e!="string"&&e.length>10&&e[0]===73&&e[1]===68&&e[2]===51?rln(e):e}function aln({data:e,signatures:t}){const n=sln(e);for(const r of t)if(typeof n=="string"?n.startsWith(r.base64Prefix):n.length>=r.bytesPrefix.length&&r.bytesPrefix.every((s,a)=>n[a]===s))return r.mediaType}function fMe(e,t){let n;const r=e.type;switch(r){case"image":n=e.image;break;case"file":n=e.data;break;default:throw new Error(`Unsupported part type: ${r}`)}const{data:s,mediaType:a}=tln(n);let i=a??e.mediaType,l=s;if(l instanceof URL&&t){const c=t[l.toString()];c&&(l=c.data,i??=c.mediaType)}switch(r){case"image":return(l instanceof Uint8Array||typeof l=="string")&&(i=aln({data:l,signatures:nln})??i),{type:"file",mediaType:i??"image/*",filename:void 0,data:l,providerOptions:e.providerOptions};case"file":{if(i==null)throw new Error("Media type is missing for file part");return{type:"file",mediaType:i,filename:e.filename,data:l,providerOptions:e.providerOptions}}}}function pMe(e){const t=[];for(const n of e){const r=BP(n.url,n.contentType);let s=n.url;r.type==="raw"&&(s=Xye(n.url,n.contentType||"application/octet-stream"));let a;try{a=new URL(s)}catch{throw new Error(`Invalid URL: ${n.url}`)}switch(a.protocol){case"http:":case"https:":case"gs:":case"s3:":{if(n.contentType?.startsWith("image/"))t.push({type:"image",image:a.toString(),mimeType:n.contentType});else{if(!n.contentType)throw new Error("If the attachment is not an image, it must specify a content type");t.push({type:"file",data:a.toString(),mimeType:n.contentType})}break}case"data:":{if(n.contentType?.startsWith("image/"))t.push({type:"image",image:s,mimeType:n.contentType});else if(n.contentType?.startsWith("text/"))t.push({type:"file",data:s,mimeType:n.contentType});else{if(!n.contentType)throw new Error("If the attachment is not an image or text, it must specify a content type");t.push({type:"file",data:s,mimeType:n.contentType})}break}default:throw new Error(`Unsupported URL protocol: ${a.protocol}`)}}return t}var iln=e=>{const t=new Map,n=/__split-\d+$/;return r=>{const s=e.at(-1);if(r.role===s?.role&&Array.isArray(s.content)&&Array.isArray(r.content)&&(r.role!=="assistant"||r.role==="assistant"&&r.content.at(-1)?.type!=="tool-call"))for(const a of r.content)s.content.push(a);else{let a=r.id;if(n.test(a)){e.push(r);return}const l=t.get(a)||0;l>0&&(r.id=`${a}__split-${l}`),t.set(a,l+1),e.push(r)}}};function MC(e){const t=[],n=iln(t);for(let r=0;r<e.length;r++){const s=e[r],a=r===e.length-1;if(!s?.content)continue;const{content:i,experimental_attachments:l=[],parts:c}=s.content,{role:u}=s,d={id:s.id,createdAt:s.createdAt,resourceId:s.resourceId,threadId:s.threadId},f=[...l],p=[];for(const h of c)h.type==="file"?f.push({url:h.data,contentType:h.mimeType}):p.push(h);switch(u){case"user":{if(p==null){const h=f?[{type:"text",text:i||""},...pMe(f)]:{type:"text",text:i||""};n({role:"user",...d,type:"text",content:h})}else{const h=s.content.parts.filter(v=>v.type==="text").map(v=>({type:"text",text:v.text})),m=f?[...h,...pMe(f)]:h;n({role:"user",...d,type:"text",content:Array.isArray(m)&&m.length===1&&m[0]?.type==="text"&&typeof i<"u"?i:m})}break}case"assistant":{if(s.content.parts!=null){let v=function(){const k=[];for(const E of S)switch(E.type){case"file":case"text":{k.push(E);break}case"reasoning":{for(const j of E.details)switch(j.type){case"text":k.push({type:"reasoning",text:j.text,signature:j.signature});break;case"redacted":k.push({type:"redacted-reasoning",data:j.data});break}break}case"tool-invocation":E.toolInvocation.toolName!=="updateWorkingMemory"&&k.push({type:"tool-call",toolCallId:E.toolInvocation.toolCallId,toolName:E.toolInvocation.toolName,args:E.toolInvocation.args});break}n({role:"assistant",...d,type:k.some(E=>E.type==="tool-call")?"tool-call":"text",content:typeof k!="string"&&Array.isArray(k)&&k.length===1&&k[0]?.type==="text"?k[0].text:k});const C=S.filter(E=>"type"in E&&E.type==="tool-invocation").map(E=>E.toolInvocation).filter(E=>E.toolName!=="updateWorkingMemory").filter(E=>E.state==="result"&&"result"in E);C.length>0&&n({role:"tool",...d,type:"tool-result",content:C.map(E=>{const{toolCallId:j,toolName:N,result:I}=E;return{type:"tool-result",toolCallId:j,toolName:N,result:I}})}),S=[],b=!1,y++},y=0,b=!1,S=[];for(const k of s.content.parts)switch(k.type){case"text":{b&&v(),S.push(k);break}case"file":case"reasoning":{S.push(k);break}case"tool-invocation":{(S.some(C=>C.type==="text"||C.type==="file"||C.type==="reasoning")||(k.toolInvocation.step??0)!==y)&&v(),S.push(k),b=!0;break}}v();const w=s.content.toolInvocations;if(w&&w.length>0){const k=new Set;for(const C of s.content.parts)C.type==="tool-invocation"&&C.toolInvocation.toolCallId&&k.add(C.toolInvocation.toolCallId);const _=w.filter(C=>!k.has(C.toolCallId)&&C.toolName!=="updateWorkingMemory");if(_.length>0){const C=new Map;for(const j of _){const N=j.step??0;C.has(N)||C.set(N,[]),C.get(N).push(j)}const E=Array.from(C.keys()).sort((j,N)=>j-N);for(const j of E){const N=C.get(j);n({role:"assistant",...d,type:"tool-call",content:[...N.map(({toolCallId:R,toolName:P,args:L})=>({type:"tool-call",toolCallId:R,toolName:P,args:L}))]});const I=N.filter(R=>R.state==="result"&&"result"in R);I.length>0&&n({role:"tool",...d,type:"tool-result",content:I.map(R=>{const{toolCallId:P,toolName:L,result:M}=R;return{type:"tool-result",toolCallId:P,toolName:L,result:M}})})}}}break}const h=s.content.toolInvocations;if(h==null||h.length===0){n({role:"assistant",...d,content:i||"",type:"text"});break}const m=h.reduce((v,y)=>Math.max(v,y.step??0),0);for(let v=0;v<=m;v++){const y=h.filter(S=>(S.step??0)===v&&S.toolName!=="updateWorkingMemory");if(y.length===0)continue;n({role:"assistant",...d,type:"tool-call",content:[...a&&i&&v===0?[{type:"text",text:i}]:[],...y.map(({toolCallId:S,toolName:w,args:k})=>({type:"tool-call",toolCallId:S,toolName:w,args:k}))]});const b=y.filter(S=>S.state==="result"&&"result"in S);b.length>0&&n({role:"tool",...d,type:"tool-result",content:b.map(S=>{const{toolCallId:w,toolName:k,result:_}=S;return{type:"tool-result",toolCallId:w,toolName:k,result:_}})})}i&&!a&&n({role:"assistant",...d,type:"text",content:i||""});break}}}return t}function oln(e){return`${e.origin}${e.pathname}`}var lln=async({url:e,downloadRetries:t})=>{const n=e.toString(),r=oln(e);try{const s=await Yin(n,{method:"GET"},t,{shouldRetryResponse:a=>a.status>=500});if(!s.ok)throw new sO({id:"DOWNLOAD_ASSETS_FAILED",text:`Failed to download asset: ${r}`,domain:Hw.LLM,category:Ww.USER,details:{url:n}});return{data:new Uint8Array(await s.arrayBuffer()),mediaType:s.headers.get("content-type")??void 0}}catch(s){throw new sO({id:"DOWNLOAD_ASSETS_FAILED",text:`Failed to download asset: ${r}`,domain:Hw.LLM,category:Ww.USER,details:{url:n}},s)}};async function cln({messages:e,downloadConcurrency:t=10,downloadRetries:n=3,supportedUrls:r}){const s=(await jo(async()=>{const{default:c}=await import("./index-yUiD89B4.js");return{default:c}},[],import.meta.url)).default,a=e.filter(c=>c.role==="user").map(c=>c.content).filter(c=>Array.isArray(c)).flat().filter(c=>c.type==="image"||c.type==="file").map(c=>{const u=c.mediaType??(c.type==="image"?"image/*":void 0);let d=c.type==="image"?c.image:c.data;if(typeof d=="string")try{d=new URL(d)}catch{}return{mediaType:u,data:d}}).filter(c=>c.data instanceof URL).map(c=>({url:c.data,isUrlSupportedByModel:c.mediaType!=null&&Hin({url:c.data.toString(),mediaType:c.mediaType,supportedUrls:r??{}})})),l=(await s(a,async c=>c.isUrlSupportedByModel?null:{url:c.url.toString(),...await lln({url:c.url,downloadRetries:n})},{concurrency:t})).filter(c=>c?.data!=null).map(({url:c,data:u,mediaType:d})=>[c,{data:u,mediaType:d}]);return Object.fromEntries(l)}function uln(e){return{...e,createdAt:e.createdAt.toISOString()}}function dln(e){return{...e,createdAt:new Date(e.createdAt)}}function fln(e){return e.map(uln)}function pln(e){return e.map(dln)}var hln=class{memoryMessages=new Set;newUserMessages=new Set;newResponseMessages=new Set;userContextMessages=new Set;memoryMessagesPersisted=new Set;newUserMessagesPersisted=new Set;newResponseMessagesPersisted=new Set;userContextMessagesPersisted=new Set;addToSource(e,t){switch(t){case"memory":this.memoryMessages.add(e),this.memoryMessagesPersisted.add(e);break;case"response":this.memoryMessages.has(e)&&this.memoryMessages.delete(e),this.newResponseMessages.add(e),this.newResponseMessagesPersisted.add(e),this.newUserMessages.has(e)&&this.newUserMessages.delete(e);break;case"input":case"user":this.newUserMessages.add(e),this.newUserMessagesPersisted.add(e);break;case"context":this.userContextMessages.add(e),this.userContextMessagesPersisted.add(e);break;default:throw new Error(`Missing message source for message ${e}`)}}isMemoryMessage(e){return this.memoryMessages.has(e)}isUserMessage(e){return this.newUserMessages.has(e)}isResponseMessage(e){return this.newResponseMessages.has(e)}isContextMessage(e){return this.userContextMessages.has(e)}getMemoryMessages(){return this.memoryMessages}getUserMessages(){return this.newUserMessages}getResponseMessages(){return this.newResponseMessages}getContextMessages(){return this.userContextMessages}getMemoryMessagesPersisted(){return this.memoryMessagesPersisted}getUserMessagesPersisted(){return this.newUserMessagesPersisted}getResponseMessagesPersisted(){return this.newResponseMessagesPersisted}getContextMessagesPersisted(){return this.userContextMessagesPersisted}removeMessage(e){this.memoryMessages.delete(e),this.newUserMessages.delete(e),this.newResponseMessages.delete(e),this.userContextMessages.delete(e)}clearUserMessages(){this.newUserMessages.clear()}clearResponseMessages(){this.newResponseMessages.clear()}clearContextMessages(){this.userContextMessages.clear()}clearAll(){this.newUserMessages.clear(),this.newResponseMessages.clear(),this.userContextMessages.clear()}createSourceChecker(){const e={memory:new Set(Array.from(this.memoryMessages.values()).map(t=>t.id)),output:new Set(Array.from(this.newResponseMessages.values()).map(t=>t.id)),input:new Set(Array.from(this.newUserMessages.values()).map(t=>t.id)),context:new Set(Array.from(this.userContextMessages.values()).map(t=>t.id))};return{...e,getSource:t=>e.memory.has(t.id)?"memory":e.input.has(t.id)?"input":e.output.has(t.id)?"response":e.context.has(t.id)?"context":null}}isNewMessage(e){const t=typeof e=="string"?e:e.id;return typeof e!="string"&&(this.newUserMessages.has(e)||this.newResponseMessages.has(e))?!0:Array.from(this.newUserMessages).some(n=>n.id===t)||Array.from(this.newResponseMessages).some(n=>n.id===t)}serializeSourceTracking(){const e=t=>Array.from(t).map(n=>n.id);return{memoryMessages:e(this.memoryMessages),newUserMessages:e(this.newUserMessages),newResponseMessages:e(this.newResponseMessages),userContextMessages:e(this.userContextMessages),memoryMessagesPersisted:e(this.memoryMessagesPersisted),newUserMessagesPersisted:e(this.newUserMessagesPersisted),newResponseMessagesPersisted:e(this.newResponseMessagesPersisted),userContextMessagesPersisted:e(this.userContextMessagesPersisted)}}deserializeSourceTracking(e,t){const n=r=>new Set(r.map(s=>t.find(a=>a.id===s)).filter(Boolean));this.memoryMessages=n(e.memoryMessages),this.newUserMessages=n(e.newUserMessages),this.newResponseMessages=n(e.newResponseMessages),this.userContextMessages=n(e.userContextMessages),this.memoryMessagesPersisted=n(e.memoryMessagesPersisted),this.newUserMessagesPersisted=n(e.newUserMessagesPersisted),this.newResponseMessagesPersisted=n(e.newResponseMessagesPersisted),this.userContextMessagesPersisted=n(e.userContextMessagesPersisted)}serializeAll(e){return{messages:fln(e.messages),systemMessages:e.systemMessages,taggedSystemMessages:e.taggedSystemMessages,memoryInfo:e.memoryInfo,_agentNetworkAppend:e.agentNetworkAppend,...this.serializeSourceTracking()}}deserializeAll(e){const t=pln(e.messages);return this.deserializeSourceTracking({memoryMessages:e.memoryMessages,newUserMessages:e.newUserMessages,newResponseMessages:e.newResponseMessages,userContextMessages:e.userContextMessages,memoryMessagesPersisted:e.memoryMessagesPersisted,newUserMessagesPersisted:e.newUserMessagesPersisted,newResponseMessagesPersisted:e.newResponseMessagesPersisted,userContextMessagesPersisted:e.userContextMessagesPersisted},t),{messages:t,systemMessages:e.systemMessages,taggedSystemMessages:e.taggedSystemMessages,memoryInfo:e.memoryInfo,agentNetworkAppend:e._agentNetworkAppend}}};function mln(e){return e.role==="system"&&e.parts.length>0&&e.parts.every(t=>t.type.startsWith("data-"))}function rX(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n];if(!mln(r)){t.push(r);continue}const s=t[t.length-1],a=e[n+1];s&&s.role==="assistant"?t[t.length-1]={...s,parts:[...s.parts,...r.parts]}:a&&a.role==="assistant"?e[n+1]={...a,parts:[...r.parts,...a.parts]}:t.push({...r,role:"assistant"})}return t}function hMe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function mMe(e,t){if(!e&&!t)return;const n={...e??{}};for(const[r,s]of Object.entries(t??{})){const a=n[r];n[r]=hMe(a)&&hMe(s)?{...a,...s}:s}return n}var gln=class{messages=[];systemMessages=[];taggedSystemMessages={};memoryInfo=null;stateManager=new hln;get memoryMessages(){return this.stateManager.getMemoryMessages()}get newUserMessages(){return this.stateManager.getUserMessages()}get newResponseMessages(){return this.stateManager.getResponseMessages()}get userContextMessages(){return this.stateManager.getContextMessages()}get memoryMessagesPersisted(){return this.stateManager.getMemoryMessagesPersisted()}get newUserMessagesPersisted(){return this.stateManager.getUserMessagesPersisted()}get newResponseMessagesPersisted(){return this.stateManager.getResponseMessagesPersisted()}get userContextMessagesPersisted(){return this.stateManager.getContextMessagesPersisted()}generateMessageId;_agentNetworkAppend=!1;filterIncompleteToolCalls;logger;toAIV5UIMessages(t,n){return rX(t.map(r=>Av.toUIMessage(r,n)))}toAIV4UIMessages(t,n){return rX(t.map(r=>Ew.toUIMessage(r,n)))}toAIV6UIMessages(t){return rX(t.map(oz.toUIMessage))}isRecording=!1;recordedEvents=[];constructor({threadId:t,resourceId:n,generateMessageId:r,logger:s,filterIncompleteToolCalls:a,_agentNetworkAppend:i}={}){t&&(this.memoryInfo={threadId:t,resourceId:n}),this.generateMessageId=r,this.logger=s,this.filterIncompleteToolCalls=a??!0,this._agentNetworkAppend=i||!1}startRecording(){this.isRecording=!0,this.recordedEvents=[]}hasRecordedEvents(){return this.recordedEvents.length>0}getRecordedEvents(){return[...this.recordedEvents]}stopRecording(){this.isRecording=!1;const t=this.getRecordedEvents();return this.recordedEvents=[],t}addSignal(t,n){const r=n?.source??"input",s=this.generateCreatedAt(r,new Date),a=t.acceptedAt??t.createdAt,i=ylt({id:t.id,type:t.type,tagName:t.tagName,contents:t.contents,attributes:t.attributes,metadata:t.metadata,providerOptions:t.providerOptions,createdAt:s,acceptedAt:a});return this.addOne(i.toDBMessage(this.memoryInfo??void 0),r),i}add(t,n,r={}){if(n==="user"&&(n="input"),!t)return this;const s=Array.isArray(t)?t:[t];this.isRecording&&this.recordedEvents.push({type:"add",source:n,count:s.length});for(const a of s){if(nMe(a)&&n==="input"){this.addSignal(a,{source:n});continue}const i=nMe(a)?a.toDBMessage(this.memoryInfo??void 0):typeof a=="string"?{role:"user",content:a}:a;if(Array.isArray(i)){for(const l of i)this.addOne(typeof l=="string"?{role:"user",content:l}:l,n,r);continue}this.addOne(typeof i=="string"?{role:"user",content:i}:i,n,r)}return this}serialize(){return this.stateManager.serializeAll({messages:this.messages,systemMessages:this.systemMessages,taggedSystemMessages:this.taggedSystemMessages,memoryInfo:this.memoryInfo,agentNetworkAppend:this._agentNetworkAppend})}serializeForSpan(){return{messages:this.all.aiV4.core().map(n=>({role:n.role,content:n.content})),systemMessages:[...this.systemMessages.map(n=>({role:n.role,content:n.content})),...Object.entries(this.taggedSystemMessages).flatMap(([n,r])=>r.map(s=>({role:s.role,content:s.content,tag:n})))]}}deserialize(t){const n=this.stateManager.deserializeAll(t);this.messages=n.messages,this.systemMessages=n.systemMessages,this.taggedSystemMessages=n.taggedSystemMessages,this.memoryInfo=n.memoryInfo,this._agentNetworkAppend=n.agentNetworkAppend;for(const r of this.messages)this.updateLastCreatedAt(r);return this}getMessagesForModelPrompt(){return this.messages.flatMap(t=>t.role!=="signal"?[t]:this.convertSignalForModelPrompt(t))}convertSignalForModelPrompt(t){const n=con(t).toLLMMessage(),r=t.createdAt,s={...n,id:t.id,metadata:{createdAt:r}};return[cMe(s,"input",{memoryInfo:this.memoryInfo,newMessageId:()=>t.id,generateCreatedAt:(a,i)=>i instanceof Date?i:typeof i=="string"||typeof i=="number"?new Date(i):r,dbMessages:this.messages})]}makeMessageSourceChecker(){return this.stateManager.createSourceChecker()}getLatestUserContent(){const n=this.all.core().filter(r=>r.role==="user").at(-1)?.content;return n?Bon(n):null}get get(){return{all:this.all,remembered:this.remembered,input:this.input,response:this.response}}get getPersisted(){return{remembered:this.rememberedPersisted,input:this.inputPersisted,taggedSystemMessages:this.taggedSystemMessages,response:this.responsePersisted}}get clear(){return{all:{db:()=>{const t=[...this.messages];return this.messages=[],this.stateManager.clearAll(),this.isRecording&&t.length>0&&this.recordedEvents.push({type:"clear",count:t.length}),t}},input:{db:()=>{const t=Array.from(this.stateManager.getUserMessages());return this.messages=this.messages.filter(n=>!this.stateManager.isUserMessage(n)),this.stateManager.clearUserMessages(),this.isRecording&&t.length>0&&this.recordedEvents.push({type:"clear",source:"input",count:t.length}),t}},response:{db:()=>{const t=Array.from(this.stateManager.getResponseMessages());return this.messages=this.messages.filter(n=>!this.stateManager.isResponseMessage(n)),this.stateManager.clearResponseMessages(),this.isRecording&&t.length>0&&this.recordedEvents.push({type:"clear",source:"response",count:t.length}),t}}}}removeByIds(t){const n=new Set(t),r=[];return this.messages=this.messages.filter(s=>n.has(s.id)?(r.push(s),this.stateManager.removeMessage(s),!1):!0),this.isRecording&&r.length>0&&this.recordedEvents.push({type:"removeByIds",ids:t,count:r.length}),r}all={db:()=>this.messages,v1:()=>MC(this.all.db()),aiV5:{model:()=>{const t=this.getMessagesForModelPrompt();return pv(this.toAIV5UIMessages(t,{transformToolPayloads:!1}),t)},ui:()=>this.toAIV5UIMessages(this.all.db()),prompt:()=>{const t=uMe([...this.systemMessages,...Object.values(this.taggedSystemMessages).flat()],"system",this.createAdapterContext(),this.messages),n=this.getMessagesForModelPrompt(),r=pv(this.toAIV5UIMessages(n,{transformToolPayloads:!1}),n,this.filterIncompleteToolCalls),s=[...t,...r];return vL(s,this.logger)},llmPrompt:async(t={downloadConcurrency:10,downloadRetries:3})=>{const n=this.getMessagesForModelPrompt(),r=pv(this.toAIV5UIMessages(n,{transformToolPayloads:!1}),n,this.filterIncompleteToolCalls),s=new Map;for(const u of this.messages)if(!(u.content?.format!==2||!u.content.parts))for(const d of u.content.parts)d.type==="tool-invocation"&&d.toolInvocation?.state==="result"&&d.providerMetadata?.mastra&&typeof d.providerMetadata.mastra=="object"&&"modelOutput"in d.providerMetadata.mastra&&s.set(d.toolInvocation.toolCallId,d.providerMetadata.mastra.modelOutput);if(s.size>0){for(const u of r)if(!(u.role!=="tool"||!Array.isArray(u.content)))for(let d=0;d<u.content.length;d++){const f=u.content[d];f.type==="tool-result"&&s.has(f.toolCallId)&&(u.content[d]={...f,output:s.get(f.toolCallId)})}}const a=uMe([...this.systemMessages,...Object.values(this.taggedSystemMessages).flat()],"system",this.createAdapterContext(),this.messages),i=await cln({messages:r,downloadConcurrency:t?.downloadConcurrency,downloadRetries:t?.downloadRetries,supportedUrls:t?.supportedUrls});let l=[...a,...r];return r.some(u=>(u.role==="user"||u.role==="assistant")&&typeof u.content!="string"&&u.content.some(d=>d.type==="image"||d.type==="file"))&&(l=l.map(u=>{if(u.role==="user")return typeof u.content=="string"?{role:"user",content:[{type:"text",text:u.content}],providerOptions:u.providerOptions}:{role:"user",content:u.content.map(f=>f.type==="image"||f.type==="file"?fMe(f,i):f).filter(f=>f.type!=="text"||f.text!==""),providerOptions:u.providerOptions};if(u.role==="assistant"&&typeof u.content!="string"){const d=u.content.map(f=>f.type==="file"?fMe(f,i):f);return{...u,content:d}}return u})),l=vL(l,this.logger),l.map(Fon).filter(u=>u.role==="system"||typeof u.content=="string"||u.content.length>0)}},aiV6:{ui:()=>this.toAIV6UIMessages(this.all.db()),llmPrompt:async t=>zon(await this.all.aiV5.llmPrompt(t))},prompt:()=>this.all.aiV4.prompt(),ui:()=>this.toAIV4UIMessages(this.all.db()),core:()=>mh(this.toAIV4UIMessages(this.all.db(),{transformToolPayloads:!1})),aiV4:{ui:()=>this.toAIV4UIMessages(this.all.db()),core:()=>mh(this.toAIV4UIMessages(this.getMessagesForModelPrompt(),{transformToolPayloads:!1})),prompt:()=>{const t=this.all.aiV4.core(),n=[...this.systemMessages,...Object.values(this.taggedSystemMessages).flat(),...t];return vL(n,this.logger)},llmPrompt:()=>{const t=this.all.aiV4.core();let r=[...[...this.systemMessages,...Object.values(this.taggedSystemMessages).flat()],...t];return r=vL(r,this.logger),r.map(Lon)}}};remembered={db:()=>this.messages.filter(t=>this.memoryMessages.has(t)),v1:()=>MC(this.remembered.db()),aiV5:{model:()=>pv(this.toAIV5UIMessages(this.remembered.db(),{transformToolPayloads:!1}),this.messages),ui:()=>this.toAIV5UIMessages(this.remembered.db())},aiV6:{ui:()=>this.toAIV6UIMessages(this.remembered.db())},ui:()=>this.toAIV4UIMessages(this.remembered.db()),core:()=>mh(this.toAIV4UIMessages(this.remembered.db(),{transformToolPayloads:!1})),aiV4:{ui:()=>this.toAIV4UIMessages(this.remembered.db()),core:()=>mh(this.toAIV4UIMessages(this.remembered.db(),{transformToolPayloads:!1}))}};rememberedPersisted={db:()=>this.all.db().filter(t=>this.memoryMessagesPersisted.has(t)),v1:()=>MC(this.rememberedPersisted.db()),aiV5:{model:()=>pv(this.toAIV5UIMessages(this.rememberedPersisted.db(),{transformToolPayloads:!1}),this.messages),ui:()=>this.toAIV5UIMessages(this.rememberedPersisted.db())},aiV6:{ui:()=>this.toAIV6UIMessages(this.rememberedPersisted.db())},ui:()=>this.toAIV4UIMessages(this.rememberedPersisted.db()),core:()=>mh(this.toAIV4UIMessages(this.rememberedPersisted.db(),{transformToolPayloads:!1})),aiV4:{ui:()=>this.toAIV4UIMessages(this.rememberedPersisted.db()),core:()=>mh(this.toAIV4UIMessages(this.rememberedPersisted.db(),{transformToolPayloads:!1}))}};input={db:()=>this.messages.filter(t=>this.newUserMessages.has(t)),v1:()=>MC(this.input.db()),aiV5:{model:()=>pv(this.toAIV5UIMessages(this.input.db(),{transformToolPayloads:!1}),this.messages),ui:()=>this.toAIV5UIMessages(this.input.db())},aiV6:{ui:()=>this.toAIV6UIMessages(this.input.db())},ui:()=>this.toAIV4UIMessages(this.input.db()),core:()=>mh(this.toAIV4UIMessages(this.input.db(),{transformToolPayloads:!1})),aiV4:{ui:()=>this.toAIV4UIMessages(this.input.db()),core:()=>mh(this.toAIV4UIMessages(this.input.db(),{transformToolPayloads:!1}))}};inputPersisted={db:()=>this.messages.filter(t=>this.newUserMessagesPersisted.has(t)),v1:()=>MC(this.inputPersisted.db()),aiV5:{model:()=>pv(this.toAIV5UIMessages(this.inputPersisted.db(),{transformToolPayloads:!1}),this.messages),ui:()=>this.toAIV5UIMessages(this.inputPersisted.db())},aiV6:{ui:()=>this.toAIV6UIMessages(this.inputPersisted.db())},ui:()=>this.toAIV4UIMessages(this.inputPersisted.db()),core:()=>mh(this.toAIV4UIMessages(this.inputPersisted.db(),{transformToolPayloads:!1})),aiV4:{ui:()=>this.toAIV4UIMessages(this.inputPersisted.db()),core:()=>mh(this.toAIV4UIMessages(this.inputPersisted.db(),{transformToolPayloads:!1}))}};response={db:()=>this.messages.filter(t=>this.newResponseMessages.has(t)),v1:()=>MC(this.response.db()),aiV5:{ui:()=>this.toAIV5UIMessages(this.response.db()),model:()=>pv(this.toAIV5UIMessages(this.response.db(),{transformToolPayloads:!1}),this.messages).filter(t=>t.role==="tool"||t.role==="assistant"),modelContent:t=>typeof t=="number"?dMe.extractStepContent(this.response.aiV5.ui(),t,this.response.aiV5.stepContent):this.response.aiV5.model().map(this.response.aiV5.stepContent).flat(),stepContent:t=>dMe.convertToStepContent(t,this.messages,()=>this.response.aiV5.model().at(-1))},aiV6:{ui:()=>this.toAIV6UIMessages(this.response.db())},aiV4:{ui:()=>this.toAIV4UIMessages(this.response.db()),core:()=>mh(this.toAIV4UIMessages(this.response.db(),{transformToolPayloads:!1}))}};responsePersisted={db:()=>this.messages.filter(t=>this.newResponseMessagesPersisted.has(t)),aiV5:{model:()=>pv(this.toAIV5UIMessages(this.responsePersisted.db(),{transformToolPayloads:!1}),this.messages),ui:()=>this.toAIV5UIMessages(this.responsePersisted.db())},aiV6:{ui:()=>this.toAIV6UIMessages(this.responsePersisted.db())},ui:()=>this.toAIV4UIMessages(this.responsePersisted.db()),aiV4:{ui:()=>this.toAIV4UIMessages(this.responsePersisted.db()),core:()=>mh(this.toAIV4UIMessages(this.responsePersisted.db(),{transformToolPayloads:!1}))}};drainUnsavedMessages(){const t=this.messages.filter(n=>this.newUserMessages.has(n)||this.newResponseMessages.has(n));return this.newUserMessages.clear(),this.newResponseMessages.clear(),t.map(n=>this.transformMessageForTranscript(n))}transformToolStateDataForTranscript(t,n){if(!t||typeof t!="object")return t;const r=t,s=r.metadata??r.providerMetadata,a=eg(s,"transcript",n),i=eg(s,"transcript","input-available"),l=n==="approval"?wu(a)?a.transformed:wu(i)?i.transformed:void 0:wu(i)?i.transformed:wu(a)?a.transformed:void 0,c=n==="suspend"&&wu(a)?a.transformed:void 0;return{...r,...l!==void 0?{args:l}:{},...c!==void 0?{suspendPayload:c}:{}}}transformMessageForTranscript(t){if(t.content?.format!==2||!t.content.parts)return t;let n=!1;const r=new Map,s=t.content.parts.map(l=>{if(l.type==="tool-invocation"&&l.toolInvocation){const c=eg(l.providerMetadata,"transcript","input-available"),u=l.toolInvocation.state==="result"?eg(l.providerMetadata,"transcript","output-available")??eg(l.providerMetadata,"transcript","error"):l.toolInvocation.state==="output-error"?eg(l.providerMetadata,"transcript","error"):void 0;if(!c&&!u)return l;n=!0;const d=wu(c)?c.transformed:l.toolInvocation.args,f=l.toolInvocation.state==="result"?wu(u)?u.transformed:l.toolInvocation.result:void 0,p=l.toolInvocation.state==="output-error"?wu(u)?u.transformed:l.toolInvocation.errorText:void 0;return r.set(l.toolInvocation.toolCallId,{args:d,...l.toolInvocation.state==="result"?{result:f}:{},...l.toolInvocation.state==="output-error"?{errorText:p}:{}}),{...l,toolInvocation:{...l.toolInvocation,args:d,...l.toolInvocation.state==="result"?{result:f}:{},...l.toolInvocation.state==="output-error"?{errorText:p}:{}}}}return l.type==="data-tool-call-suspended"||l.type==="data-tool-call-approval"?(n=!0,{...l,data:this.transformToolStateDataForTranscript(l.data,l.type==="data-tool-call-suspended"?"suspend":"approval")}):l}),a=t.content.toolInvocations?.map(l=>{const c=r.get(l.toolCallId);if(!c)return l;const u=l.state;return n=!0,{...l,...c.args!==void 0?{args:c.args}:{},...l.state==="result"&&c.result!==void 0?{result:c.result}:{},...u==="output-error"&&c.errorText!==void 0?{errorText:c.errorText}:{}}}),i=t.content.metadata&&typeof t.content.metadata=="object"?{...t.content.metadata}:t.content.metadata;if(i&&typeof i=="object")for(const[l,c]of[["suspendedTools","suspend"],["pendingToolApprovals","approval"]]){const u=i[l];!u||typeof u!="object"||(n=!0,i[l]=Object.fromEntries(Object.entries(u).map(([d,f])=>[d,this.transformToolStateDataForTranscript(f,c)])))}return n?{...t,content:{...t.content,parts:s,...a?{toolInvocations:a}:{},...i?{metadata:i}:{}}}:t}getEarliestUnsavedMessageTimestamp(){const t=this.messages.filter(n=>this.newUserMessages.has(n)||this.newResponseMessages.has(n));if(t.length!==0)return Math.min(...t.map(n=>new Date(n.createdAt).getTime()))}isNewMessage(t){return this.stateManager.isNewMessage(t)}updateToolInvocation(t,n){if(!t.toolInvocation?.toolCallId)return!1;const r=t.toolInvocation.toolCallId;for(let s=this.messages.length-1;s>=0;s--){const a=this.messages[s];if(!(a.role!=="assistant"||!a.content?.parts))for(let i=0;i<a.content.parts.length;i++){const l=a.content.parts[i];if(l?.type==="tool-invocation"&&l.toolInvocation?.toolCallId===r){const c=l,u=t,d=c.providerMetadata!==void 0||u.providerMetadata!==void 0?{...c.providerMetadata??{},...u.providerMetadata??{}}:void 0;a.content.parts[i]={...t,toolInvocation:{...t.toolInvocation,args:l.toolInvocation.args},...c.providerExecuted!==void 0&&u.providerExecuted===void 0?{providerExecuted:c.providerExecuted}:{},...d!==void 0?{providerMetadata:d}:{}},this.lastCreatedAt=Math.max(this.lastCreatedAt||0,Date.now()),this.updateLastCreatedAt(a);const f=a.content.metadata??{},p=n??{},h=f.backgroundTasks,m=p.backgroundTasks,v=mMe(h,m);return a.content.metadata={...f,...p,...v?{backgroundTasks:v}:{}},this.stateManager.isResponseMessage(a)||(this.stateManager.removeMessage(a),this.stateManager.addToSource(a,"response")),!0}}}return this.logger?.warn(`updateToolInvocation: no matching tool call found for toolCallId=${r}`),!1}updateMessageMetadataByToolCallId(t,n){if(!t)return!1;for(let r=this.messages.length-1;r>=0;r--){const s=this.messages[r];if(s.role!=="assistant"||!s.content?.parts||!s.content.parts.some(f=>f?.type==="tool-invocation"&&f.toolInvocation?.toolCallId===t))continue;const i=s.content.metadata??{},l=n??{},c=i.backgroundTasks,u=l.backgroundTasks,d=mMe(c,u);return s.content.metadata={...i,...l,...d?{backgroundTasks:d}:{}},this.lastCreatedAt=Math.max(this.lastCreatedAt||0,Date.now()),this.updateLastCreatedAt(s),this.stateManager.isResponseMessage(s)||(this.stateManager.removeMessage(s),this.stateManager.addToSource(s,"response")),!0}return this.logger?.warn(`updateMessageMetadataByToolCallId: no matching tool call found for toolCallId=${t}`),!1}stepStart(){const t=this.messages[this.messages.length-1];return!t||t.role!=="assistant"||!t.content?.parts||ub.isSealed(t)||t.content.parts[t.content.parts.length-1]?.type==="step-start"?!1:(t.content.parts.push(ebe({type:"step-start"})),this.stateManager.isResponseMessage(t)||(this.stateManager.removeMessage(t),this.stateManager.addToSource(t,"response")),!0)}markResponseMessageBoundary(t){const n=t?this.messages.find(r=>r.id===t):[...this.messages].reverse().find(r=>r.role==="assistant");return!n||n.role!=="assistant"?!1:(n.content.metadata={...n.content.metadata??{},mastra:{...n.content.metadata?.mastra??{},responseBoundary:!0}},this.stateManager.isResponseMessage(n)||(this.stateManager.removeMessage(n),this.stateManager.addToSource(n,"response")),!0)}enrichLastStepStart(t){const n=this.messages[this.messages.length-1];if(!n||n.role!=="assistant"||!n.content?.parts||ub.isSealed(n))return!1;for(let r=n.content.parts.length-1;r>=0;r--){const s=n.content.parts[r];if(s?.type==="step-start")return s.model?!1:(s.model=t,this.stateManager.isResponseMessage(n)||(this.stateManager.removeMessage(n),this.stateManager.addToSource(n,"response")),!0)}return!1}getSystemMessages(t){return t?this.taggedSystemMessages[t]||[]:this.systemMessages}getAllSystemMessages(){return[...this.systemMessages,...Object.values(this.taggedSystemMessages).flat()]}clearSystemMessages(t){return t?delete this.taggedSystemMessages[t]:this.systemMessages=[],this}replaceAllSystemMessages(t){this.systemMessages=[];for(const n of t)n.role==="system"&&this.systemMessages.push(n);return this}addSystem(t,n){if(!t)return this;for(const r of Array.isArray(t)?t:[t])this.addOneSystem(r,n);return this}addOneSystem(t,n){const r=Jon(t);if(r.role!=="system")throw new Error(`Expected role "system" but saw ${r.role} for message ${JSON.stringify(r,null,2)}`);n&&!this.isDuplicateSystem(r,n)?(this.taggedSystemMessages[n]||=[],this.taggedSystemMessages[n].push(r),this.isRecording&&this.recordedEvents.push({type:"addSystem",tag:n,message:r})):!n&&!this.isDuplicateSystem(r)&&(this.systemMessages.push(r),this.isRecording&&this.recordedEvents.push({type:"addSystem",message:r}))}isDuplicateSystem(t,n){return n?this.taggedSystemMessages[n]?this.taggedSystemMessages[n].some(r=>Wo.fromAIV4CoreMessageContent(r.content)===Wo.fromAIV4CoreMessageContent(t.content)):!1:this.systemMessages.some(r=>Wo.fromAIV4CoreMessageContent(r.content)===Wo.fromAIV4CoreMessageContent(t.content))}getMessageById(t){return this.messages.find(n=>n.id===t)}shouldReplaceMessage(t){if(!this.messages.length)return{exists:!1};if(!("id"in t)||!t?.id)return{exists:!1};const n=this.getMessageById(t.id);return n?{exists:!0,shouldReplace:!nX(n,t),id:n.id}:{exists:!1}}addOne(t,n,r={}){if((!("content"in t)||!t.content&&typeof t.content!="string")&&(!("parts"in t)||!t.parts))throw new sO({id:"INVALID_MESSAGE_CONTENT",domain:Hw.AGENT,category:Ww.USER,text:`Message with role "${t.role}" must have either a 'content' property (string or array) or a 'parts' property (array) that is not empty, null, or undefined. Received message: ${JSON.stringify(t,null,2)}`,details:{role:t.role,messageSource:n,hasContent:"content"in t,hasParts:"parts"in t}});if(t.role==="system"){if(n==="memory")return null;if(Za.isAIV4CoreMessage(t)||Za.isAIV6CoreMessage(t)||Za.isAIV5CoreMessage(t)||Za.isMastraDBMessage(t))return this.addSystem(t);throw new sO({id:"INVALID_SYSTEM_MESSAGE_FORMAT",domain:Hw.AGENT,category:Ww.USER,text:"Invalid system message format. System messages must be CoreMessage format with 'role' and 'content' properties. The content should be a string or valid content array.",details:{messageSource:n,receivedMessage:JSON.stringify(t,null,2)}})}const s=cMe(t,n,this.createAdapterContext()),a=s.role==="signal"?s.content.metadata?.signal:void 0;if(n==="input"&&s.role==="signal"&&!a?.acceptedAt){const b=a?.createdAt??s.createdAt.toISOString();s.createdAt=this.generateCreatedAt(n,s.createdAt),s.content.metadata={...s.content.metadata,signal:{...a,createdAt:s.createdAt.toISOString(),acceptedAt:b}}}const{exists:i,shouldReplace:l,id:c}=this.shouldReplaceMessage(s),u=this.messages.findLastIndex(b=>ub.isSealed(b)),d=this.messages.at(-1),f=this.messages.length-1,p=u===-1||f>u;if(n==="memory"){for(const b of this.messages)if(nX(b,s))return}const h=i&&c?this.messages.find(b=>b.id===c):void 0,m=!!h&&ub.isSealed(h),v=d?this.memoryMessages.has(d):!1;if(r.merge!==!1&&p&&!m&&ub.shouldMerge(d,s,n,v,this._agentNetworkAppend)&&d)ub.merge(d,s),this.updateLastCreatedAt(d),this.pushMessageToSource(d,n);else{let b=-1;l&&(b=this.messages.findIndex(w=>w.id===c));const S=b!==-1&&this.messages[b];if(l&&S){const w=u!==-1&&b<=u;if(ub.isSealed(S)){const k=S.content?.parts||[];let _=0;for(let j=k.length-1;j>=0;j--)if(k[j]?.metadata?.mastra?.sealedAt){_=j+1;break}_===0&&(_=k.length);const C=s.content.parts;let E;if(C.length<=_){if(nX(S,s))return this;E=C}else E=C.slice(_);E.length>0&&(s.id=this.generateMessageId?.({idType:"message",source:"memory"})??fo(),s.content.parts=E,s.createdAt<=S.createdAt&&(s.createdAt=new Date(S.createdAt.getTime()+1)),this.messages.push(s))}else if(w)s.id=this.generateMessageId?.({idType:"message",source:"memory"})??fo(),s.createdAt<=S.createdAt&&(s.createdAt=new Date(S.createdAt.getTime()+1)),this.messages.push(s);else{const k=this.memoryMessages.has(S);if(r.merge!==!1&&ub.shouldMerge(S,s,n,k,this._agentNetworkAppend))return ub.merge(S,s),this.updateLastCreatedAt(S),this.pushMessageToSource(S,n),this.messages.sort((C,E)=>C.createdAt.getTime()-E.createdAt.getTime()),this;this.messages[b]=s}}else i||this.messages.push(s);this.pushMessageToSource(s,n)}for(const b of this.messages)this.updateLastCreatedAt(b);return this.messages.sort((b,S)=>b.createdAt.getTime()-S.createdAt.getTime()),this}pushMessageToSource(t,n){this.stateManager.addToSource(t,n)}lastCreatedAt;updateLastCreatedAt(t){this.lastCreatedAt=Math.max(this.lastCreatedAt||0,t.createdAt.getTime())}generateCreatedAt(t,n){const r=n instanceof Date?n:typeof n=="string"||typeof n=="number"?new Date(n):void 0;if(r&&!this.lastCreatedAt)return this.lastCreatedAt=r.getTime(),r;if(r&&t==="memory")return r;const s=new Date,a=r?.getTime()||s.getTime(),i=this.lastCreatedAt||0;if(a<=i){const l=new Date(i+1);return this.lastCreatedAt=l.getTime(),l}return this.lastCreatedAt=a,r??s}newMessageId(t){return this.generateMessageId?this.generateMessageId({idType:"message",source:"agent",threadId:this.memoryInfo?.threadId,resourceId:this.memoryInfo?.resourceId,role:t}):fo()}createAdapterContext(){return{memoryInfo:this.memoryInfo,newMessageId:()=>this.newMessageId(),generateCreatedAt:(t,n)=>this.generateCreatedAt(t,n),dbMessages:this.messages}}};const vln=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),yln=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),gMe=e=>{const t=yln(e);return t.charAt(0).toUpperCase()+t.slice(1)},klt=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),bln=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var xln={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const wln=g.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:i,...l},c)=>g.createElement("svg",{ref:c,...xln,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:klt("lucide",s),...!a&&!bln(l)&&{"aria-hidden":"true"},...l},[...i.map(([u,d])=>g.createElement(u,d)),...Array.isArray(a)?a:[a]]));const Xe=(e,t)=>{const n=g.forwardRef(({className:r,...s},a)=>g.createElement(wln,{ref:a,iconNode:t,className:klt(`lucide-${vln(gMe(e))}`,`lucide-${e}`,r),...s}));return n.displayName=gMe(e),n};const Sln=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],Olt=Xe("align-left",Sln);const kln=[["path",{d:"M17.5 12c0 4.4-3.6 8-8 8A4.5 4.5 0 0 1 5 15.5c0-6 8-4 8-8.5a3 3 0 1 0-6 0c0 3 2.5 8.5 12 13",key:"1o9ehi"}],["path",{d:"M16 12h3",key:"4uvgyw"}]],Oln=Xe("ampersand",kln);const _ln=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Cln=Xe("arrow-down",_ln);const Eln=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Nc=Xe("arrow-left",Eln);const jln=[["path",{d:"M17 12H3",key:"8awo09"}],["path",{d:"m11 18 6-6-6-6",key:"8c2y43"}],["path",{d:"M21 5v14",key:"nzette"}]],_lt=Xe("arrow-right-to-line",jln);const Tln=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],mm=Xe("arrow-right",Tln);const Nln=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],pD=Xe("arrow-up",Nln);const Iln=[["path",{d:"M2 10v3",key:"1fnikh"}],["path",{d:"M6 6v11",key:"11sgs0"}],["path",{d:"M10 3v18",key:"yhl04a"}],["path",{d:"M14 8v7",key:"3a1oy3"}],["path",{d:"M18 5v13",key:"123xd1"}],["path",{d:"M22 10v3",key:"154ddg"}]],Aln=Xe("audio-lines",Iln);const Rln=[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]],Pln=Xe("award",Rln);const $ln=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]],Mln=Xe("ban",$ln);const Dln=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Lln=Xe("bell",Dln);const Fln=[["path",{d:"M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2",key:"1ah6g2"}],["rect",{x:"14",y:"2",width:"8",height:"8",rx:"1",key:"88lufb"}]],Clt=Xe("blocks",Fln);const zln=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],Elt=Xe("book-open",zln);const Bln=[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]],jlt=Xe("book",Bln);const Uln=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"12",x2:"12",y1:"7",y2:"13",key:"1cppfj"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]],qln=Xe("bookmark-plus",Uln);const Vln=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],EF=Xe("bot",Vln);const Hln=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],ky=Xe("braces",Hln);const Wln=[["path",{d:"M16 3h3a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1h-3",key:"1kt8lf"}],["path",{d:"M8 21H5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h3",key:"gduv9"}]],Zln=Xe("brackets",Wln);const Gln=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]],Rv=Xe("brain",Gln);const Qln=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]],Tlt=Xe("building",Qln);const Yln=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]],Xln=Xe("calculator",Yln);const Kln=[["path",{d:"M11 14h1v4",key:"fy54vd"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]],Nlt=Xe("calendar-1",Kln);const Jln=[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],hD=Xe("calendar-clock",Jln);const ecn=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Ilt=Xe("calendar",ecn);const tcn=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Js=Xe("check",tcn);const ncn=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Sa=Xe("chevron-down",ncn);const rcn=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Alt=Xe("chevron-left",rcn);const scn=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ta=Xe("chevron-right",scn);const acn=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],f_=Xe("chevron-up",acn);const icn=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],Rlt=Xe("chevrons-down-up",icn);const ocn=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Plt=Xe("chevrons-up-down",ocn);const lcn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Qj=Xe("circle-alert",lcn);const ccn=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],uO=Xe("circle-check-big",ccn);const ucn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],oq=Xe("circle-check",ucn);const dcn=[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]],fcn=Xe("circle-dashed",dcn);const pcn=[["path",{d:"M15.6 2.7a10 10 0 1 0 5.7 5.7",key:"1e0p6d"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M13.4 10.6 19 5",key:"1kr7tw"}]],hcn=Xe("circle-gauge",pcn);const mcn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]],lq=Xe("circle-pause",mcn);const gcn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]],tbe=Xe("circle-play",gcn);const vcn=[["path",{d:"M22 2 2 22",key:"y4kqgn"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ycn=Xe("circle-slash-2",vcn);const bcn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]],Of=Xe("circle-slash",bcn);const xcn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],$lt=Xe("circle-stop",xcn);const wcn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],UP=Xe("circle-x",wcn);const Scn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],kcn=Xe("circle",Scn);const Ocn=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]],cq=Xe("clipboard-check",Ocn);const _cn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]],Ccn=Xe("clock-3",_cn);const Ecn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],dO=Xe("clock",Ecn);const jcn=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],Mlt=Xe("cloud-upload",jcn);const Tcn=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],sX=Xe("cloud",Tcn);const Ncn=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],Icn=Xe("code",Ncn);const Acn=[["path",{d:"M12 20a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",key:"sobvz5"}],["path",{d:"M12 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z",key:"11i496"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 22v-2",key:"1osdcq"}],["path",{d:"m17 20.66-1-1.73",key:"eq3orb"}],["path",{d:"M11 10.27 7 3.34",key:"16pf9h"}],["path",{d:"m20.66 17-1.73-1",key:"sg0v6f"}],["path",{d:"m3.34 7 1.73 1",key:"1ulond"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"m20.66 7-1.73 1",key:"1ow05n"}],["path",{d:"m3.34 17 1.73-1",key:"nuk764"}],["path",{d:"m17 3.34-1 1.73",key:"2wel8s"}],["path",{d:"m11 13.73-4 6.93",key:"794ttg"}]],Rcn=Xe("cog",Acn);const Pcn=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Dlt=Xe("columns-2",Pcn);const $cn=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Dp=Xe("copy",$cn);const Mcn=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],Dcn=Xe("corner-down-right",Mcn);const Lcn=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],nbe=Xe("cpu",Lcn);const Fcn=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],iy=Xe("database",Fcn);const zcn=[["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 10h14",key:"elsbfy"}],["path",{d:"M5 21h14",key:"11awu3"}]],Bcn=Xe("diff",zcn);const Ucn=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],lf=Xe("download",Ucn);const qcn=[["path",{d:"M10 18a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H5a3 3 0 0 1-3-3 1 1 0 0 1 1-1z",key:"ioqxb1"}],["path",{d:"M13 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1l-.81 3.242a1 1 0 0 1-.97.758H8",key:"1rs59n"}],["path",{d:"M14 4h3a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-3",key:"105ega"}],["path",{d:"M18 6h4",key:"66u95g"}],["path",{d:"m5 10-2 8",key:"xt2lic"}],["path",{d:"m7 18 2-8",key:"1bzku2"}]],Vcn=Xe("drill",qcn);const Hcn=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Wcn=Xe("earth",Hcn);const Zcn=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],mD=Xe("ellipsis-vertical",Zcn);const Gcn=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],Qcn=Xe("equal",Gcn);const Ycn=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],_a=Xe("external-link",Ycn);const Xcn=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Kcn=Xe("eye-off",Xcn);const Jcn=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Kc=Xe("eye",Jcn);const eun=[["path",{d:"M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"rslqgf"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0",key:"9f7x3i"}]],tun=Xe("file-audio",eun);const nun=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],run=Xe("file-code-2",nun);const sun=[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]],yN=Xe("file-code",sun);const aun=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 15h10",key:"jfw4w8"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],fO=Xe("file-input",aun);const iun=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],bN=Xe("file-json",iun);const oun=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 7V4a2 2 0 0 1 2-2 2 2 0 0 0-2 2",key:"1vk7w2"}],["path",{d:"M4.063 20.999a2 2 0 0 0 2 1L18 22a2 2 0 0 0 2-2V7l-5-5H6",key:"1jink5"}],["path",{d:"m5 11-3 3",key:"1dgrs4"}],["path",{d:"m5 17-3-3h10",key:"1mvvaf"}]],gg=Xe("file-output",oun);const lun=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Oc=Xe("file-text",lun);const cun=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m10 11 5 3-5 3v-6Z",key:"7ntvm4"}]],uun=Xe("file-video",cun);const dun=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]],rbe=Xe("file",dun);const fun=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],Llt=Xe("flask-conical",fun);const pun=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],xN=Xe("folder-open",pun);const hun=[["path",{d:"M2 7.5V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-1.5",key:"1yk7aj"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m5 10-3 3 3 3",key:"1r8ie0"}]],mun=Xe("folder-output",hun);const gun=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],uq=Xe("folder-plus",gun);const vun=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],yun=Xe("folder-tree",vun);const bun=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],gD=Xe("folder",bun);const xun=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],wun=Xe("frown",xun);const Sun=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Flt=Xe("funnel",Sun);const kun=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],rm=Xe("gauge",kun);const Oun=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],sbe=Xe("git-branch",Oun);const _un=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]],Cun=Xe("git-compare-arrows",_un);const Eun=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]],Xw=Xe("git-compare",Eun);const jun=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]],zlt=Xe("git-pull-request",jun);const Tun=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],Blt=Xe("github",Tun);const Nun=[["path",{d:"M15.686 15A14.5 14.5 0 0 1 12 22a14.5 14.5 0 0 1 0-20 10 10 0 1 0 9.542 13",key:"qkt0x6"}],["path",{d:"M2 12h8.5",key:"ovaggd"}],["path",{d:"M20 6V4a2 2 0 1 0-4 0v2",key:"1of5e8"}],["rect",{width:"8",height:"5",x:"14",y:"6",rx:"1",key:"1fmf51"}]],Iun=Xe("globe-lock",Nun);const Aun=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Lx=Xe("globe",Aun);const Run=[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]],Ult=Xe("graduation-cap",Run);const Pun=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],dq=Xe("grip-vertical",Pun);const $un=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],Kde=Xe("hard-drive",$un);const Mun=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],vMe=Xe("hash",Mun);const Dun=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],p_=Xe("history",Dun);const Lun=[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]],Jde=Xe("hourglass",Lun);const Fun=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]],zun=Xe("house",Fun);const Bun=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],abe=Xe("image",Bun);const Uun=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Fx=Xe("info",Uun);const qun=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],Vun=Xe("key-round",qun);const Hun=[["rect",{width:"18",height:"12",x:"3",y:"4",rx:"2",ry:"2",key:"1qhy41"}],["line",{x1:"2",x2:"22",y1:"20",y2:"20",key:"ni3hll"}]],yMe=Xe("laptop-minimal",Hun);const Wun=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],fq=Xe("layers",Wun);const Zun=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],Gun=Xe("layout-grid",Zun);const Qun=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],qP=Xe("library",Qun);const Yun=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],Xun=Xe("lightbulb",Yun);const Kun=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Jun=Xe("link-2",Kun);const edn=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],qlt=Xe("link",edn);const tdn=[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]],Vlt=Xe("list-checks",tdn);const ndn=[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]],efe=Xe("list",ndn);const rdn=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],oa=Xe("loader-circle",rdn);const sdn=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],yf=Xe("lock",sdn);const adn=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],idn=Xe("maximize",adn);const odn=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],ldn=Xe("maximize-2",odn);const cdn=[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Hlt=Xe("message-circle-question-mark",cdn);const udn=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]],Yj=Xe("message-square",udn);const ddn=[["path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z",key:"p1xzt8"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1",key:"1cx29u"}]],fdn=Xe("messages-square",ddn);const pdn=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],hdn=Xe("mic",pdn);const mdn=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],gdn=Xe("minimize-2",mdn);const vdn=[["path",{d:"M5 12h14",key:"1ays0h"}]],ydn=Xe("minus",vdn);const bdn=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Wlt=Xe("monitor",bdn);const xdn=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],wdn=Xe("moon",xdn);const Sdn=[["path",{d:"M11 19H5V13",key:"1akmht"}],["path",{d:"M19 5L5 19",key:"72u4yj"}]],kdn=Xe("move-down-left",Sdn);const Odn=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],ibe=Xe("move-right",Odn);const _dn=[["path",{d:"M13 5H19V11",key:"1n1gyv"}],["path",{d:"M19 5L5 19",key:"72u4yj"}]],Cdn=Xe("move-up-right",_dn);const Edn=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],Zlt=Xe("network",Edn);const jdn=[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]],Tdn=Xe("notebook-pen",jdn);const Ndn=[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Idn=Xe("octagon-x",Ndn);const Adn=[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]],Glt=Xe("package-open",Adn);const Rdn=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],Zv=Xe("package",Rdn);const Pdn=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],$dn=Xe("panel-left",Pdn);const Mdn=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],bMe=Xe("paperclip",Mdn);const Ddn=[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]],Qlt=Xe("pause",Ddn);const Ldn=[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]],Fdn=Xe("pen-line",Ldn);const zdn=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Ylt=Xe("pen",zdn);const Bdn=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Lp=Xe("pencil",Bdn);const Udn=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],Fp=Xe("play",Udn);const qdn=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],Vdn=Xe("plug",qdn);const Hdn=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Vr=Xe("plus",Hdn);const Wdn=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],Xlt=Xe("radio",Wdn);const Zdn=[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M14 8H8",key:"1l3xfs"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M13 16H8",key:"wsln4y"}]],Oh=Xe("receipt-text",Zdn);const Gdn=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M7 12h.01",key:"eqddd0"}]],obe=Xe("rectangle-ellipsis",Gdn);const Qdn=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],Ydn=Xe("refresh-ccw",Qdn);const Xdn=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Kw=Xe("refresh-cw",Xdn);const Kdn=[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}],["path",{d:"M11 10h1v4",key:"70cz1p"}]],Jdn=Xe("repeat-1",Kdn);const efn=[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]],tfn=Xe("repeat",efn);const nfn=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Klt=Xe("rotate-ccw",nfn);const rfn=[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]],lbe=Xe("route",rfn);const sfn=[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]],afn=Xe("ruler",sfn);const ifn=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],gd=Xe("save",ifn);const ofn=[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]],lfn=Xe("scale",ofn);const cfn=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Xa=Xe("search",cfn);const ufn=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],xMe=Xe("send",ufn);const dfn=[["path",{d:"m10.852 14.772-.383.923",key:"11vil6"}],["path",{d:"M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923",key:"1v3clb"}],["path",{d:"m13.148 9.228.383-.923",key:"t2zzyc"}],["path",{d:"m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544",key:"1bxfiv"}],["path",{d:"m14.772 10.852.923-.383",key:"k9m8cz"}],["path",{d:"m14.772 13.148.923.383",key:"1xvhww"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"m9.228 10.852-.923-.383",key:"1wtb30"}],["path",{d:"m9.228 13.148-.923.383",key:"1a830x"}]],Jlt=Xe("server-cog",dfn);const ffn=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],jF=Xe("server",ffn);const pfn=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],pq=Xe("settings-2",pfn);const hfn=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],lz=Xe("settings",hfn);const mfn=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],ect=Xe("share-2",mfn);const gfn=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],cbe=Xe("shield-alert",gfn);const vfn=[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]],hq=Xe("sliders-horizontal",vfn);const yfn=[["line",{x1:"4",x2:"4",y1:"21",y2:"14",key:"1p332r"}],["line",{x1:"4",x2:"4",y1:"10",y2:"3",key:"gb41h5"}],["line",{x1:"12",x2:"12",y1:"21",y2:"12",key:"hf2csr"}],["line",{x1:"12",x2:"12",y1:"8",y2:"3",key:"1kfi7u"}],["line",{x1:"20",x2:"20",y1:"21",y2:"16",key:"1lhrwl"}],["line",{x1:"20",x2:"20",y1:"12",y2:"3",key:"16vvfq"}],["line",{x1:"2",x2:"6",y1:"14",y2:"14",key:"1uebub"}],["line",{x1:"10",x2:"14",y1:"8",y2:"8",key:"1yglbp"}],["line",{x1:"18",x2:"22",y1:"16",y2:"16",key:"1jxqpz"}]],bfn=Xe("sliders-vertical",yfn);const xfn=[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]],wg=Xe("sparkles",xfn);const wfn=[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]],Sfn=Xe("square-arrow-out-up-right",wfn);const kfn=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]],Ofn=Xe("square-arrow-right",kfn);const _fn=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],Cfn=Xe("square-terminal",_fn);const Efn=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],Xj=Xe("star",Efn);const jfn=[["line",{x1:"6",x2:"6",y1:"4",y2:"20",key:"fy8qot"}],["polygon",{points:"10,4 20,12 10,20",key:"1mc1pf"}]],tct=Xe("step-forward",jfn);const Tfn=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],Nfn=Xe("sun",Tfn);const Ifn=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],wN=Xe("tag",Ifn);const Afn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],ube=Xe("target",Afn);const Rfn=[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]],dbe=Xe("thumbs-down",Rfn);const Pfn=[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]],fbe=Xe("thumbs-up",Pfn);const $fn=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],tfe=Xe("timer",$fn);const Mfn=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],au=Xe("trash-2",Mfn);const Dfn=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]],pbe=Xe("trash",Dfn);const Lfn=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Ep=Xe("triangle-alert",Lfn);const Ffn=[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]],zfn=Xe("unplug",Ffn);const Bfn=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],mq=Xe("upload",Bfn);const Ufn=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],nct=Xe("wand-sparkles",Ufn);const qfn=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],vD=Xe("workflow",qfn);const Vfn=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]],zp=Xe("wrench",Vfn);const Hfn=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],vs=Xe("x",Hfn);const Wfn=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],hbe=Xe("zap",Wfn),Zfn=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},Gfn=(e,t)=>({classGroupId:e,validator:t}),rct=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),cz="-",wMe=[],Qfn="arbitrary..",Yfn=e=>{const t=Kfn(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return Xfn(i);const l=i.split(cz),c=l[0]===""&&l.length>1?1:0;return sct(l,c,t)},getConflictingClassGroupIds:(i,l)=>{if(l){const c=r[i],u=n[i];return c?u?Zfn(u,c):c:u||wMe}return n[i]||wMe}}},sct=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const s=e[t],a=n.nextPart.get(s);if(a){const u=sct(e,t+1,a);if(u)return u}const i=n.validators;if(i===null)return;const l=t===0?e.join(cz):e.slice(t).join(cz),c=i.length;for(let u=0;u<c;u++){const d=i[u];if(d.validator(l))return d.classGroupId}},Xfn=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?Qfn+r:void 0})(),Kfn=e=>{const{theme:t,classGroups:n}=e;return Jfn(n,t)},Jfn=(e,t)=>{const n=rct();for(const r in e){const s=e[r];mbe(s,n,r,t)}return n},mbe=(e,t,n,r)=>{const s=e.length;for(let a=0;a<s;a++){const i=e[a];epn(i,t,n,r)}},epn=(e,t,n,r)=>{if(typeof e=="string"){tpn(e,t,n);return}if(typeof e=="function"){npn(e,t,n,r);return}rpn(e,t,n,r)},tpn=(e,t,n)=>{const r=e===""?t:act(t,e);r.classGroupId=n},npn=(e,t,n,r)=>{if(spn(e)){mbe(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Gfn(n,e))},rpn=(e,t,n,r)=>{const s=Object.entries(e),a=s.length;for(let i=0;i<a;i++){const[l,c]=s[i];mbe(c,act(t,l),n,r)}},act=(e,t)=>{let n=e;const r=t.split(cz),s=r.length;for(let a=0;a<s;a++){const i=r[a];let l=n.nextPart.get(i);l||(l=rct(),n.nextPart.set(i,l)),n=l}return n},spn=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,apn=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const s=(a,i)=>{n[a]=i,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(a){let i=n[a];if(i!==void 0)return i;if((i=r[a])!==void 0)return s(a,i),i},set(a,i){a in n?n[a]=i:s(a,i)}}},nfe="!",SMe=":",ipn=[],kMe=(e,t,n,r,s)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:s}),opn=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=s=>{const a=[];let i=0,l=0,c=0,u;const d=s.length;for(let v=0;v<d;v++){const y=s[v];if(i===0&&l===0){if(y===SMe){a.push(s.slice(c,v)),c=v+1;continue}if(y==="/"){u=v;continue}}y==="["?i++:y==="]"?i--:y==="("?l++:y===")"&&l--}const f=a.length===0?s:s.slice(c);let p=f,h=!1;f.endsWith(nfe)?(p=f.slice(0,-1),h=!0):f.startsWith(nfe)&&(p=f.slice(1),h=!0);const m=u&&u>c?u-c:void 0;return kMe(a,h,p,m)};if(t){const s=t+SMe,a=r;r=i=>i.startsWith(s)?a(i.slice(s.length)):kMe(ipn,!1,i,void 0,!0)}if(n){const s=r;r=a=>n({className:a,parseClassName:s})}return r},lpn=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let s=[];for(let a=0;a<n.length;a++){const i=n[a],l=i[0]==="[",c=t.has(i);l||c?(s.length>0&&(s.sort(),r.push(...s),s=[]),r.push(i)):s.push(i)}return s.length>0&&(s.sort(),r.push(...s)),r}},cpn=e=>({cache:apn(e.cacheSize),parseClassName:opn(e),sortModifiers:lpn(e),...Yfn(e)}),upn=/\s+/,dpn=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:s,sortModifiers:a}=t,i=[],l=e.trim().split(upn);let c="";for(let u=l.length-1;u>=0;u-=1){const d=l[u],{isExternal:f,modifiers:p,hasImportantModifier:h,baseClassName:m,maybePostfixModifierPosition:v}=n(d);if(f){c=d+(c.length>0?" "+c:c);continue}let y=!!v,b=r(y?m.substring(0,v):m);if(!b){if(!y){c=d+(c.length>0?" "+c:c);continue}if(b=r(m),!b){c=d+(c.length>0?" "+c:c);continue}y=!1}const S=p.length===0?"":p.length===1?p[0]:a(p).join(":"),w=h?S+nfe:S,k=w+b;if(i.indexOf(k)>-1)continue;i.push(k);const _=s(b,y);for(let C=0;C<_.length;++C){const E=_[C];i.push(w+E)}c=d+(c.length>0?" "+c:c)}return c},fpn=(...e)=>{let t=0,n,r,s="";for(;t<e.length;)(n=e[t++])&&(r=ict(n))&&(s&&(s+=" "),s+=r);return s},ict=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=ict(e[r]))&&(n&&(n+=" "),n+=t);return n},ppn=(e,...t)=>{let n,r,s,a;const i=c=>{const u=t.reduce((d,f)=>f(d),e());return n=cpn(u),r=n.cache.get,s=n.cache.set,a=l,l(c)},l=c=>{const u=r(c);if(u)return u;const d=dpn(c,n);return s(c,d),d};return a=i,(...c)=>a(fpn(...c))},hpn=[],Fl=e=>{const t=n=>n[e]||hpn;return t.isThemeGetter=!0,t},oct=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,lct=/^\((?:(\w[\w-]*):)?(.+)\)$/i,mpn=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,gpn=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,vpn=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ypn=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,bpn=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,xpn=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,R0=e=>mpn.test(e),us=e=>!!e&&!Number.isNaN(Number(e)),P0=e=>!!e&&Number.isInteger(Number(e)),aX=e=>e.endsWith("%")&&us(e.slice(0,-1)),db=e=>gpn.test(e),cct=()=>!0,wpn=e=>vpn.test(e)&&!ypn.test(e),gbe=()=>!1,Spn=e=>bpn.test(e),kpn=e=>xpn.test(e),Opn=e=>!Ln(e)&&!Un(e),_pn=e=>I1(e,fct,gbe),Ln=e=>oct.test(e),_S=e=>I1(e,pct,wpn),OMe=e=>I1(e,Rpn,us),Cpn=e=>I1(e,mct,cct),Epn=e=>I1(e,hct,gbe),_Me=e=>I1(e,uct,gbe),jpn=e=>I1(e,dct,kpn),yL=e=>I1(e,gct,Spn),Un=e=>lct.test(e),EA=e=>h_(e,pct),Tpn=e=>h_(e,hct),CMe=e=>h_(e,uct),Npn=e=>h_(e,fct),Ipn=e=>h_(e,dct),bL=e=>h_(e,gct,!0),Apn=e=>h_(e,mct,!0),I1=(e,t,n)=>{const r=oct.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},h_=(e,t,n=!1)=>{const r=lct.exec(e);return r?r[1]?t(r[1]):n:!1},uct=e=>e==="position"||e==="percentage",dct=e=>e==="image"||e==="url",fct=e=>e==="length"||e==="size"||e==="bg-size",pct=e=>e==="length",Rpn=e=>e==="number",hct=e=>e==="family-name",mct=e=>e==="number"||e==="weight",gct=e=>e==="shadow",Ppn=()=>{const e=Fl("color"),t=Fl("font"),n=Fl("text"),r=Fl("font-weight"),s=Fl("tracking"),a=Fl("leading"),i=Fl("breakpoint"),l=Fl("container"),c=Fl("spacing"),u=Fl("radius"),d=Fl("shadow"),f=Fl("inset-shadow"),p=Fl("text-shadow"),h=Fl("drop-shadow"),m=Fl("blur"),v=Fl("perspective"),y=Fl("aspect"),b=Fl("ease"),S=Fl("animate"),w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],k=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],_=()=>[...k(),Un,Ln],C=()=>["auto","hidden","clip","visible","scroll"],E=()=>["auto","contain","none"],j=()=>[Un,Ln,c],N=()=>[R0,"full","auto",...j()],I=()=>[P0,"none","subgrid",Un,Ln],R=()=>["auto",{span:["full",P0,Un,Ln]},P0,Un,Ln],P=()=>[P0,"auto",Un,Ln],L=()=>["auto","min","max","fr",Un,Ln],M=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],q=()=>["start","end","center","stretch","center-safe","end-safe"],H=()=>["auto",...j()],F=()=>[R0,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...j()],z=()=>[R0,"screen","full","dvw","lvw","svw","min","max","fit",...j()],B=()=>[R0,"screen","full","lh","dvh","lvh","svh","min","max","fit",...j()],D=()=>[e,Un,Ln],Q=()=>[...k(),CMe,_Me,{position:[Un,Ln]}],V=()=>["no-repeat",{repeat:["","x","y","space","round"]}],$=()=>["auto","cover","contain",Npn,_pn,{size:[Un,Ln]}],U=()=>[aX,EA,_S],Z=()=>["","none","full",u,Un,Ln],X=()=>["",us,EA,_S],te=()=>["solid","dashed","dotted","double"],J=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ee=()=>[us,aX,CMe,_Me],ae=()=>["","none",m,Un,Ln],ce=()=>["none",us,Un,Ln],Y=()=>["none",us,Un,Ln],ne=()=>[us,Un,Ln],ue=()=>[R0,"full",...j()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[db],breakpoint:[db],color:[cct],container:[db],"drop-shadow":[db],ease:["in","out","in-out"],font:[Opn],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[db],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[db],shadow:[db],spacing:["px",us],text:[db],"text-shadow":[db],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",R0,Ln,Un,y]}],container:["container"],columns:[{columns:[us,Ln,Un,l]}],"break-after":[{"break-after":w()}],"break-before":[{"break-before":w()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:_()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:E()}],"overscroll-x":[{"overscroll-x":E()}],"overscroll-y":[{"overscroll-y":E()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:N()}],"inset-x":[{"inset-x":N()}],"inset-y":[{"inset-y":N()}],start:[{"inset-s":N(),start:N()}],end:[{"inset-e":N(),end:N()}],"inset-bs":[{"inset-bs":N()}],"inset-be":[{"inset-be":N()}],top:[{top:N()}],right:[{right:N()}],bottom:[{bottom:N()}],left:[{left:N()}],visibility:["visible","invisible","collapse"],z:[{z:[P0,"auto",Un,Ln]}],basis:[{basis:[R0,"full","auto",l,...j()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[us,R0,"auto","initial","none",Ln]}],grow:[{grow:["",us,Un,Ln]}],shrink:[{shrink:["",us,Un,Ln]}],order:[{order:[P0,"first","last","none",Un,Ln]}],"grid-cols":[{"grid-cols":I()}],"col-start-end":[{col:R()}],"col-start":[{"col-start":P()}],"col-end":[{"col-end":P()}],"grid-rows":[{"grid-rows":I()}],"row-start-end":[{row:R()}],"row-start":[{"row-start":P()}],"row-end":[{"row-end":P()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":L()}],"auto-rows":[{"auto-rows":L()}],gap:[{gap:j()}],"gap-x":[{"gap-x":j()}],"gap-y":[{"gap-y":j()}],"justify-content":[{justify:[...M(),"normal"]}],"justify-items":[{"justify-items":[...q(),"normal"]}],"justify-self":[{"justify-self":["auto",...q()]}],"align-content":[{content:["normal",...M()]}],"align-items":[{items:[...q(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...q(),{baseline:["","last"]}]}],"place-content":[{"place-content":M()}],"place-items":[{"place-items":[...q(),"baseline"]}],"place-self":[{"place-self":["auto",...q()]}],p:[{p:j()}],px:[{px:j()}],py:[{py:j()}],ps:[{ps:j()}],pe:[{pe:j()}],pbs:[{pbs:j()}],pbe:[{pbe:j()}],pt:[{pt:j()}],pr:[{pr:j()}],pb:[{pb:j()}],pl:[{pl:j()}],m:[{m:H()}],mx:[{mx:H()}],my:[{my:H()}],ms:[{ms:H()}],me:[{me:H()}],mbs:[{mbs:H()}],mbe:[{mbe:H()}],mt:[{mt:H()}],mr:[{mr:H()}],mb:[{mb:H()}],ml:[{ml:H()}],"space-x":[{"space-x":j()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":j()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],"inline-size":[{inline:["auto",...z()]}],"min-inline-size":[{"min-inline":["auto",...z()]}],"max-inline-size":[{"max-inline":["none",...z()]}],"block-size":[{block:["auto",...B()]}],"min-block-size":[{"min-block":["auto",...B()]}],"max-block-size":[{"max-block":["none",...B()]}],w:[{w:[l,"screen",...F()]}],"min-w":[{"min-w":[l,"screen","none",...F()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",n,EA,_S]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Apn,Cpn]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",aX,Ln]}],"font-family":[{font:[Tpn,Epn,t]}],"font-features":[{"font-features":[Ln]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,Un,Ln]}],"line-clamp":[{"line-clamp":[us,"none",Un,OMe]}],leading:[{leading:[a,...j()]}],"list-image":[{"list-image":["none",Un,Ln]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Un,Ln]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...te(),"wavy"]}],"text-decoration-thickness":[{decoration:[us,"from-font","auto",Un,_S]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[us,"auto",Un,Ln]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:j()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Un,Ln]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Un,Ln]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Q()}],"bg-repeat":[{bg:V()}],"bg-size":[{bg:$()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},P0,Un,Ln],radial:["",Un,Ln],conic:[P0,Un,Ln]},Ipn,jpn]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:U()}],"gradient-via-pos":[{via:U()}],"gradient-to-pos":[{to:U()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:Z()}],"rounded-s":[{"rounded-s":Z()}],"rounded-e":[{"rounded-e":Z()}],"rounded-t":[{"rounded-t":Z()}],"rounded-r":[{"rounded-r":Z()}],"rounded-b":[{"rounded-b":Z()}],"rounded-l":[{"rounded-l":Z()}],"rounded-ss":[{"rounded-ss":Z()}],"rounded-se":[{"rounded-se":Z()}],"rounded-ee":[{"rounded-ee":Z()}],"rounded-es":[{"rounded-es":Z()}],"rounded-tl":[{"rounded-tl":Z()}],"rounded-tr":[{"rounded-tr":Z()}],"rounded-br":[{"rounded-br":Z()}],"rounded-bl":[{"rounded-bl":Z()}],"border-w":[{border:X()}],"border-w-x":[{"border-x":X()}],"border-w-y":[{"border-y":X()}],"border-w-s":[{"border-s":X()}],"border-w-e":[{"border-e":X()}],"border-w-bs":[{"border-bs":X()}],"border-w-be":[{"border-be":X()}],"border-w-t":[{"border-t":X()}],"border-w-r":[{"border-r":X()}],"border-w-b":[{"border-b":X()}],"border-w-l":[{"border-l":X()}],"divide-x":[{"divide-x":X()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":X()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...te(),"hidden","none"]}],"divide-style":[{divide:[...te(),"hidden","none"]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-bs":[{"border-bs":D()}],"border-color-be":[{"border-be":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...te(),"none","hidden"]}],"outline-offset":[{"outline-offset":[us,Un,Ln]}],"outline-w":[{outline:["",us,EA,_S]}],"outline-color":[{outline:D()}],shadow:[{shadow:["","none",d,bL,yL]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":["none",f,bL,yL]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:X()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[us,_S]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":X()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":["none",p,bL,yL]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[us,Un,Ln]}],"mix-blend":[{"mix-blend":[...J(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":J()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[us]}],"mask-image-linear-from-pos":[{"mask-linear-from":ee()}],"mask-image-linear-to-pos":[{"mask-linear-to":ee()}],"mask-image-linear-from-color":[{"mask-linear-from":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"mask-image-t-from-pos":[{"mask-t-from":ee()}],"mask-image-t-to-pos":[{"mask-t-to":ee()}],"mask-image-t-from-color":[{"mask-t-from":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"mask-image-r-from-pos":[{"mask-r-from":ee()}],"mask-image-r-to-pos":[{"mask-r-to":ee()}],"mask-image-r-from-color":[{"mask-r-from":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"mask-image-b-from-pos":[{"mask-b-from":ee()}],"mask-image-b-to-pos":[{"mask-b-to":ee()}],"mask-image-b-from-color":[{"mask-b-from":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"mask-image-l-from-pos":[{"mask-l-from":ee()}],"mask-image-l-to-pos":[{"mask-l-to":ee()}],"mask-image-l-from-color":[{"mask-l-from":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"mask-image-x-from-pos":[{"mask-x-from":ee()}],"mask-image-x-to-pos":[{"mask-x-to":ee()}],"mask-image-x-from-color":[{"mask-x-from":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"mask-image-y-from-pos":[{"mask-y-from":ee()}],"mask-image-y-to-pos":[{"mask-y-to":ee()}],"mask-image-y-from-color":[{"mask-y-from":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[Un,Ln]}],"mask-image-radial-from-pos":[{"mask-radial-from":ee()}],"mask-image-radial-to-pos":[{"mask-radial-to":ee()}],"mask-image-radial-from-color":[{"mask-radial-from":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":k()}],"mask-image-conic-pos":[{"mask-conic":[us]}],"mask-image-conic-from-pos":[{"mask-conic-from":ee()}],"mask-image-conic-to-pos":[{"mask-conic-to":ee()}],"mask-image-conic-from-color":[{"mask-conic-from":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Q()}],"mask-repeat":[{mask:V()}],"mask-size":[{mask:$()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Un,Ln]}],filter:[{filter:["","none",Un,Ln]}],blur:[{blur:ae()}],brightness:[{brightness:[us,Un,Ln]}],contrast:[{contrast:[us,Un,Ln]}],"drop-shadow":[{"drop-shadow":["","none",h,bL,yL]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:["",us,Un,Ln]}],"hue-rotate":[{"hue-rotate":[us,Un,Ln]}],invert:[{invert:["",us,Un,Ln]}],saturate:[{saturate:[us,Un,Ln]}],sepia:[{sepia:["",us,Un,Ln]}],"backdrop-filter":[{"backdrop-filter":["","none",Un,Ln]}],"backdrop-blur":[{"backdrop-blur":ae()}],"backdrop-brightness":[{"backdrop-brightness":[us,Un,Ln]}],"backdrop-contrast":[{"backdrop-contrast":[us,Un,Ln]}],"backdrop-grayscale":[{"backdrop-grayscale":["",us,Un,Ln]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[us,Un,Ln]}],"backdrop-invert":[{"backdrop-invert":["",us,Un,Ln]}],"backdrop-opacity":[{"backdrop-opacity":[us,Un,Ln]}],"backdrop-saturate":[{"backdrop-saturate":[us,Un,Ln]}],"backdrop-sepia":[{"backdrop-sepia":["",us,Un,Ln]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":j()}],"border-spacing-x":[{"border-spacing-x":j()}],"border-spacing-y":[{"border-spacing-y":j()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Un,Ln]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[us,"initial",Un,Ln]}],ease:[{ease:["linear","initial",b,Un,Ln]}],delay:[{delay:[us,Un,Ln]}],animate:[{animate:["none",S,Un,Ln]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,Un,Ln]}],"perspective-origin":[{"perspective-origin":_()}],rotate:[{rotate:ce()}],"rotate-x":[{"rotate-x":ce()}],"rotate-y":[{"rotate-y":ce()}],"rotate-z":[{"rotate-z":ce()}],scale:[{scale:Y()}],"scale-x":[{"scale-x":Y()}],"scale-y":[{"scale-y":Y()}],"scale-z":[{"scale-z":Y()}],"scale-3d":["scale-3d"],skew:[{skew:ne()}],"skew-x":[{"skew-x":ne()}],"skew-y":[{"skew-y":ne()}],transform:[{transform:[Un,Ln,"","none","gpu","cpu"]}],"transform-origin":[{origin:_()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ue()}],"translate-x":[{"translate-x":ue()}],"translate-y":[{"translate-y":ue()}],"translate-z":[{"translate-z":ue()}],"translate-none":["translate-none"],accent:[{accent:D()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:D()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Un,Ln]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":j()}],"scroll-mx":[{"scroll-mx":j()}],"scroll-my":[{"scroll-my":j()}],"scroll-ms":[{"scroll-ms":j()}],"scroll-me":[{"scroll-me":j()}],"scroll-mbs":[{"scroll-mbs":j()}],"scroll-mbe":[{"scroll-mbe":j()}],"scroll-mt":[{"scroll-mt":j()}],"scroll-mr":[{"scroll-mr":j()}],"scroll-mb":[{"scroll-mb":j()}],"scroll-ml":[{"scroll-ml":j()}],"scroll-p":[{"scroll-p":j()}],"scroll-px":[{"scroll-px":j()}],"scroll-py":[{"scroll-py":j()}],"scroll-ps":[{"scroll-ps":j()}],"scroll-pe":[{"scroll-pe":j()}],"scroll-pbs":[{"scroll-pbs":j()}],"scroll-pbe":[{"scroll-pbe":j()}],"scroll-pt":[{"scroll-pt":j()}],"scroll-pr":[{"scroll-pr":j()}],"scroll-pb":[{"scroll-pb":j()}],"scroll-pl":[{"scroll-pl":j()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Un,Ln]}],fill:[{fill:["none",...D()]}],"stroke-w":[{stroke:[us,EA,_S,OMe]}],stroke:[{stroke:["none",...D()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},m_=ppn(Ppn);function Vd(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e?.(s),n===!1||!s.defaultPrevented)return t?.(s)}}function EMe(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Jw(...e){return t=>{let n=!1;const r=e.map(s=>{const a=EMe(s,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let s=0;s<r.length;s++){const a=r[s];typeof a=="function"?a():EMe(e[s],null)}}}}function Rg(...e){return g.useCallback(Jw(...e),e)}function $pn(e,t){const n=g.createContext(t),r=a=>{const{children:i,...l}=a,c=g.useMemo(()=>l,Object.values(l));return o.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function s(a){const i=g.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[r,s]}function vbe(e,t=[]){let n=[];function r(a,i){const l=g.createContext(i),c=n.length;n=[...n,i];const u=f=>{const{scope:p,children:h,...m}=f,v=p?.[e]?.[c]||l,y=g.useMemo(()=>m,Object.values(m));return o.jsx(v.Provider,{value:y,children:h})};u.displayName=a+"Provider";function d(f,p){const h=p?.[e]?.[c]||l,m=g.useContext(h);if(m)return m;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${a}\``)}return[u,d]}const s=()=>{const a=n.map(i=>g.createContext(i));return function(l){const c=l?.[e]||a;return g.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return s.scopeName=e,[r,Mpn(s,...t)]}function Mpn(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const i=r.reduce((l,{useScope:c,scopeName:u})=>{const f=c(a)[`__scope${u}`];return{...l,...f}},{});return g.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var yo=frt();const ybe=Tc(yo);function vct(e){const t=Dpn(e),n=g.forwardRef((r,s)=>{const{children:a,...i}=r,l=g.Children.toArray(a),c=l.find(Fpn);if(c){const u=c.props.children,d=l.map(f=>f===c?g.Children.count(u)>1?g.Children.only(null):g.isValidElement(u)?u.props.children:null:f);return o.jsx(t,{...i,ref:s,children:g.isValidElement(u)?g.cloneElement(u,void 0,d):null})}return o.jsx(t,{...i,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}function Dpn(e){const t=g.forwardRef((n,r)=>{const{children:s,...a}=n;if(g.isValidElement(s)){const i=Bpn(s),l=zpn(a,s.props);return s.type!==g.Fragment&&(l.ref=r?Jw(r,i):i),g.cloneElement(s,l)}return g.Children.count(s)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var yct=Symbol("radix.slottable");function Lpn(e){const t=({children:n})=>o.jsx(o.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=yct,t}function Fpn(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===yct}function zpn(e,t){const n={...t};for(const r in t){const s=e[r],a=t[r];/^on[A-Z]/.test(r)?s&&a?n[r]=(...l)=>{const c=a(...l);return s(...l),c}:s&&(n[r]=s):r==="style"?n[r]={...s,...a}:r==="className"&&(n[r]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function Bpn(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Upn=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_f=Upn.reduce((e,t)=>{const n=vct(`Primitive.${t}`),r=g.forwardRef((s,a)=>{const{asChild:i,...l}=s,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(c,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function qpn(e,t){e&&yo.flushSync(()=>e.dispatchEvent(t))}function Kj(e){const t=g.useRef(e);return g.useEffect(()=>{t.current=e}),g.useMemo(()=>(...n)=>t.current?.(...n),[])}function Vpn(e,t=globalThis?.document){const n=Kj(e);g.useEffect(()=>{const r=s=>{s.key==="Escape"&&n(s)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Hpn="DismissableLayer",rfe="dismissableLayer.update",Wpn="dismissableLayer.pointerDownOutside",Zpn="dismissableLayer.focusOutside",jMe,bct=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),bbe=g.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...c}=e,u=g.useContext(bct),[d,f]=g.useState(null),p=d?.ownerDocument??globalThis?.document,[,h]=g.useState({}),m=Rg(t,E=>f(E)),v=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),b=v.indexOf(y),S=d?v.indexOf(d):-1,w=u.layersWithOutsidePointerEventsDisabled.size>0,k=S>=b,_=Ypn(E=>{const j=E.target,N=[...u.branches].some(I=>I.contains(j));!k||N||(s?.(E),i?.(E),E.defaultPrevented||l?.())},p),C=Xpn(E=>{const j=E.target;[...u.branches].some(I=>I.contains(j))||(a?.(E),i?.(E),E.defaultPrevented||l?.())},p);return Vpn(E=>{S===u.layers.size-1&&(r?.(E),!E.defaultPrevented&&l&&(E.preventDefault(),l()))},p),g.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(jMe=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),TMe(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=jMe)}},[d,p,n,u]),g.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),TMe())},[d,u]),g.useEffect(()=>{const E=()=>h({});return document.addEventListener(rfe,E),()=>document.removeEventListener(rfe,E)},[]),o.jsx(_f.div,{...c,ref:m,style:{pointerEvents:w?k?"auto":"none":void 0,...e.style},onFocusCapture:Vd(e.onFocusCapture,C.onFocusCapture),onBlurCapture:Vd(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:Vd(e.onPointerDownCapture,_.onPointerDownCapture)})});bbe.displayName=Hpn;var Gpn="DismissableLayerBranch",Qpn=g.forwardRef((e,t)=>{const n=g.useContext(bct),r=g.useRef(null),s=Rg(t,r);return g.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),o.jsx(_f.div,{...e,ref:s})});Qpn.displayName=Gpn;function Ypn(e,t=globalThis?.document){const n=Kj(e),r=g.useRef(!1),s=g.useRef(()=>{});return g.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let c=function(){xct(Wpn,n,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",s.current),s.current=c,t.addEventListener("click",s.current,{once:!0})):c()}else t.removeEventListener("click",s.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",s.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Xpn(e,t=globalThis?.document){const n=Kj(e),r=g.useRef(!1);return g.useEffect(()=>{const s=a=>{a.target&&!r.current&&xct(Zpn,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function TMe(){const e=new CustomEvent(rfe);document.dispatchEvent(e)}function xct(e,t,n,{discrete:r}){const s=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),r?qpn(s,a):s.dispatchEvent(a)}var e1=globalThis?.document?g.useLayoutEffect:()=>{},Kpn=hN[" useId ".trim().toString()]||(()=>{}),Jpn=0;function ex(e){const[t,n]=g.useState(Kpn());return e1(()=>{n(r=>r??String(Jpn++))},[e]),t?`radix-${t}`:""}const ehn=["top","right","bottom","left"],t1=Math.min,hp=Math.max,Jj=Math.round,wk=Math.floor,Gv=e=>({x:e,y:e}),thn={left:"right",right:"left",bottom:"top",top:"bottom"};function uz(e,t,n){return hp(e,t1(t,n))}function oy(e,t){return typeof e=="function"?e(t):e}function cf(e){return e.split("-")[0]}function zx(e){return e.split("-")[1]}function xbe(e){return e==="x"?"y":"x"}function gq(e){return e==="y"?"height":"width"}function Ah(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function vq(e){return xbe(Ah(e))}function nhn(e,t,n){n===void 0&&(n=!1);const r=zx(e),s=vq(e),a=gq(s);let i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=dz(i)),[i,dz(i)]}function rhn(e){const t=dz(e);return[sfe(e),t,sfe(t)]}function sfe(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const NMe=["left","right"],IMe=["right","left"],shn=["top","bottom"],ahn=["bottom","top"];function ihn(e,t,n){switch(e){case"top":case"bottom":return n?t?IMe:NMe:t?NMe:IMe;case"left":case"right":return t?shn:ahn;default:return[]}}function ohn(e,t,n,r){const s=zx(e);let a=ihn(cf(e),n==="start",r);return s&&(a=a.map(i=>i+"-"+s),t&&(a=a.concat(a.map(sfe)))),a}function dz(e){const t=cf(e);return thn[t]+e.slice(t.length)}function lhn(e){return{top:0,right:0,bottom:0,left:0,...e}}function wbe(e){return typeof e!="number"?lhn(e):{top:e,right:e,bottom:e,left:e}}function VP(e){const{x:t,y:n,width:r,height:s}=e;return{width:r,height:s,top:n,left:t,right:t+r,bottom:n+s,x:t,y:n}}function AMe(e,t,n){let{reference:r,floating:s}=e;const a=Ah(t),i=vq(t),l=gq(i),c=cf(t),u=a==="y",d=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,p=r[l]/2-s[l]/2;let h;switch(c){case"top":h={x:d,y:r.y-s.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-s.width,y:f};break;default:h={x:r.x,y:r.y}}switch(zx(t)){case"start":h[i]-=p*(n&&u?-1:1);break;case"end":h[i]+=p*(n&&u?-1:1);break}return h}async function chn(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:a,rects:i,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:p=!1,padding:h=0}=oy(t,e),m=wbe(h),y=l[p?f==="floating"?"reference":"floating":f],b=VP(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(y)))==null||n?y:y.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(l.floating)),boundary:u,rootBoundary:d,strategy:c})),S=f==="floating"?{x:r,y:s,width:i.floating.width,height:i.floating.height}:i.reference,w=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l.floating)),k=await(a.isElement==null?void 0:a.isElement(w))?await(a.getScale==null?void 0:a.getScale(w))||{x:1,y:1}:{x:1,y:1},_=VP(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:S,offsetParent:w,strategy:c}):S);return{top:(b.top-_.top+m.top)/k.y,bottom:(_.bottom-b.bottom+m.bottom)/k.y,left:(b.left-_.left+m.left)/k.x,right:(_.right-b.right+m.right)/k.x}}const uhn=50,dhn=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:a=[],platform:i}=n,l=i.detectOverflow?i:{...i,detectOverflow:chn},c=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:s}),{x:d,y:f}=AMe(u,r,c),p=r,h=0;const m={};for(let v=0;v<a.length;v++){const y=a[v];if(!y)continue;const{name:b,fn:S}=y,{x:w,y:k,data:_,reset:C}=await S({x:d,y:f,initialPlacement:r,placement:p,strategy:s,middlewareData:m,rects:u,platform:l,elements:{reference:e,floating:t}});d=w??d,f=k??f,m[b]={...m[b],..._},C&&h<uhn&&(h++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:s}):C.rects),{x:d,y:f}=AMe(u,p,c)),v=-1)}return{x:d,y:f,placement:p,strategy:s,middlewareData:m}},fhn=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:a,platform:i,elements:l,middlewareData:c}=t,{element:u,padding:d=0}=oy(e,t)||{};if(u==null)return{};const f=wbe(d),p={x:n,y:r},h=vq(s),m=gq(h),v=await i.getDimensions(u),y=h==="y",b=y?"top":"left",S=y?"bottom":"right",w=y?"clientHeight":"clientWidth",k=a.reference[m]+a.reference[h]-p[h]-a.floating[m],_=p[h]-a.reference[h],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let E=C?C[w]:0;(!E||!await(i.isElement==null?void 0:i.isElement(C)))&&(E=l.floating[w]||a.floating[m]);const j=k/2-_/2,N=E/2-v[m]/2-1,I=t1(f[b],N),R=t1(f[S],N),P=I,L=E-v[m]-R,M=E/2-v[m]/2+j,q=uz(P,M,L),H=!c.arrow&&zx(s)!=null&&M!==q&&a.reference[m]/2-(M<P?I:R)-v[m]/2<0,F=H?M<P?M-P:M-L:0;return{[h]:p[h]+F,data:{[h]:q,centerOffset:M-q-F,...H&&{alignmentOffset:F}},reset:H}}}),phn=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:a,rects:i,initialPlacement:l,platform:c,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:v=!0,...y}=oy(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const b=cf(s),S=Ah(l),w=cf(l)===l,k=await(c.isRTL==null?void 0:c.isRTL(u.floating)),_=p||(w||!v?[dz(l)]:rhn(l)),C=m!=="none";!p&&C&&_.push(...ohn(l,v,m,k));const E=[l,..._],j=await c.detectOverflow(t,y),N=[];let I=((r=a.flip)==null?void 0:r.overflows)||[];if(d&&N.push(j[b]),f){const M=nhn(s,i,k);N.push(j[M[0]],j[M[1]])}if(I=[...I,{placement:s,overflows:N}],!N.every(M=>M<=0)){var R,P;const M=(((R=a.flip)==null?void 0:R.index)||0)+1,q=E[M];if(q&&(!(f==="alignment"?S!==Ah(q):!1)||I.every(z=>Ah(z.placement)===S?z.overflows[0]>0:!0)))return{data:{index:M,overflows:I},reset:{placement:q}};let H=(P=I.filter(F=>F.overflows[0]<=0).sort((F,z)=>F.overflows[1]-z.overflows[1])[0])==null?void 0:P.placement;if(!H)switch(h){case"bestFit":{var L;const F=(L=I.filter(z=>{if(C){const B=Ah(z.placement);return B===S||B==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(B=>B>0).reduce((B,D)=>B+D,0)]).sort((z,B)=>z[1]-B[1])[0])==null?void 0:L[0];F&&(H=F);break}case"initialPlacement":H=l;break}if(s!==H)return{reset:{placement:H}}}return{}}}};function RMe(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function PMe(e){return ehn.some(t=>e[t]>=0)}const hhn=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:s="referenceHidden",...a}=oy(e,t);switch(s){case"referenceHidden":{const i=await r.detectOverflow(t,{...a,elementContext:"reference"}),l=RMe(i,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:PMe(l)}}}case"escaped":{const i=await r.detectOverflow(t,{...a,altBoundary:!0}),l=RMe(i,n.floating);return{data:{escapedOffsets:l,escaped:PMe(l)}}}default:return{}}}}},wct=new Set(["left","top"]);async function mhn(e,t){const{placement:n,platform:r,elements:s}=e,a=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=cf(n),l=zx(n),c=Ah(n)==="y",u=wct.has(i)?-1:1,d=a&&c?-1:1,f=oy(t,e);let{mainAxis:p,crossAxis:h,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof m=="number"&&(h=l==="end"?m*-1:m),c?{x:h*d,y:p*u}:{x:p*u,y:h*d}}const ghn=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:a,placement:i,middlewareData:l}=t,c=await mhn(t,e);return i===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+c.x,y:a+c.y,data:{...c,placement:i}}}}},vhn=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s,platform:a}=t,{mainAxis:i=!0,crossAxis:l=!1,limiter:c={fn:b=>{let{x:S,y:w}=b;return{x:S,y:w}}},...u}=oy(e,t),d={x:n,y:r},f=await a.detectOverflow(t,u),p=Ah(cf(s)),h=xbe(p);let m=d[h],v=d[p];if(i){const b=h==="y"?"top":"left",S=h==="y"?"bottom":"right",w=m+f[b],k=m-f[S];m=uz(w,m,k)}if(l){const b=p==="y"?"top":"left",S=p==="y"?"bottom":"right",w=v+f[b],k=v-f[S];v=uz(w,v,k)}const y=c.fn({...t,[h]:m,[p]:v});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[h]:i,[p]:l}}}}}},yhn=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:s,rects:a,middlewareData:i}=t,{offset:l=0,mainAxis:c=!0,crossAxis:u=!0}=oy(e,t),d={x:n,y:r},f=Ah(s),p=xbe(f);let h=d[p],m=d[f];const v=oy(l,t),y=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(c){const w=p==="y"?"height":"width",k=a.reference[p]-a.floating[w]+y.mainAxis,_=a.reference[p]+a.reference[w]-y.mainAxis;h<k?h=k:h>_&&(h=_)}if(u){var b,S;const w=p==="y"?"width":"height",k=wct.has(cf(s)),_=a.reference[f]-a.floating[w]+(k&&((b=i.offset)==null?void 0:b[f])||0)+(k?0:y.crossAxis),C=a.reference[f]+a.reference[w]+(k?0:((S=i.offset)==null?void 0:S[f])||0)-(k?y.crossAxis:0);m<_?m=_:m>C&&(m=C)}return{[p]:h,[f]:m}}}},bhn=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:s,rects:a,platform:i,elements:l}=t,{apply:c=()=>{},...u}=oy(e,t),d=await i.detectOverflow(t,u),f=cf(s),p=zx(s),h=Ah(s)==="y",{width:m,height:v}=a.floating;let y,b;f==="top"||f==="bottom"?(y=f,b=p===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(b=f,y=p==="end"?"top":"bottom");const S=v-d.top-d.bottom,w=m-d.left-d.right,k=t1(v-d[y],S),_=t1(m-d[b],w),C=!t.middlewareData.shift;let E=k,j=_;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=w),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=S),C&&!p){const I=hp(d.left,0),R=hp(d.right,0),P=hp(d.top,0),L=hp(d.bottom,0);h?j=m-2*(I!==0||R!==0?I+R:hp(d.left,d.right)):E=v-2*(P!==0||L!==0?P+L:hp(d.top,d.bottom))}await c({...t,availableWidth:j,availableHeight:E});const N=await i.getDimensions(l.floating);return m!==N.width||v!==N.height?{reset:{rects:!0}}:{}}}};function yq(){return typeof window<"u"}function $u(e){return Sbe(e)?(e.nodeName||"").toLowerCase():"#document"}function Ks(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Oy(e){var t;return(t=(Sbe(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Sbe(e){return yq()?e instanceof Node||e instanceof Ks(e).Node:!1}function _r(e){return yq()?e instanceof Element||e instanceof Ks(e).Element:!1}function Ra(e){return yq()?e instanceof HTMLElement||e instanceof Ks(e).HTMLElement:!1}function eT(e){return!yq()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ks(e).ShadowRoot}function A1(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=Mu(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function xhn(e){return/^(table|td|th)$/.test($u(e))}function bq(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const whn=/transform|translate|scale|rotate|perspective|filter/,Shn=/paint|layout|strict|content/,CS=e=>!!e&&e!=="none";let iX;function kbe(e){const t=_r(e)?Mu(e):e;return CS(t.transform)||CS(t.translate)||CS(t.scale)||CS(t.rotate)||CS(t.perspective)||!xq()&&(CS(t.backdropFilter)||CS(t.filter))||whn.test(t.willChange||"")||Shn.test(t.contain||"")}function khn(e){let t=ly(e);for(;Ra(t)&&!Qv(t);){if(kbe(t))return t;if(bq(t))return null;t=ly(t)}return null}function xq(){return iX==null&&(iX=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),iX}function Qv(e){return/^(html|body|#document)$/.test($u(e))}function Mu(e){return Ks(e).getComputedStyle(e)}function wq(e){return _r(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ly(e){if($u(e)==="html")return e;const t=e.assignedSlot||e.parentNode||eT(e)&&e.host||Oy(e);return eT(t)?t.host:t}function Sct(e){const t=ly(e);return Qv(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ra(t)&&A1(t)?t:Sct(t)}function HP(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=Sct(e),a=s===((r=e.ownerDocument)==null?void 0:r.body),i=Ks(s);if(a){const l=afe(i);return t.concat(i,i.visualViewport||[],A1(s)?s:[],l&&n?HP(l):[])}else return t.concat(s,HP(s,[],n))}function afe(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function kct(e){const t=Mu(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=Ra(e),a=s?e.offsetWidth:n,i=s?e.offsetHeight:r,l=Jj(n)!==a||Jj(r)!==i;return l&&(n=a,r=i),{width:n,height:r,$:l}}function Obe(e){return _r(e)?e:e.contextElement}function lj(e){const t=Obe(e);if(!Ra(t))return Gv(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:a}=kct(t);let i=(a?Jj(n.width):n.width)/r,l=(a?Jj(n.height):n.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const Ohn=Gv(0);function Oct(e){const t=Ks(e);return!xq()||!t.visualViewport?Ohn:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function _hn(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ks(e)?!1:t}function pO(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),a=Obe(e);let i=Gv(1);t&&(r?_r(r)&&(i=lj(r)):i=lj(e));const l=_hn(a,n,r)?Oct(a):Gv(0);let c=(s.left+l.x)/i.x,u=(s.top+l.y)/i.y,d=s.width/i.x,f=s.height/i.y;if(a){const p=Ks(a),h=r&&_r(r)?Ks(r):r;let m=p,v=afe(m);for(;v&&r&&h!==m;){const y=lj(v),b=v.getBoundingClientRect(),S=Mu(v),w=b.left+(v.clientLeft+parseFloat(S.paddingLeft))*y.x,k=b.top+(v.clientTop+parseFloat(S.paddingTop))*y.y;c*=y.x,u*=y.y,d*=y.x,f*=y.y,c+=w,u+=k,m=Ks(v),v=afe(m)}}return VP({width:d,height:f,x:c,y:u})}function Sq(e,t){const n=wq(e).scrollLeft;return t?t.left+n:pO(Oy(e)).left+n}function _ct(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Sq(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function Chn(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const a=s==="fixed",i=Oy(r),l=t?bq(t.floating):!1;if(r===i||l&&a)return n;let c={scrollLeft:0,scrollTop:0},u=Gv(1);const d=Gv(0),f=Ra(r);if((f||!f&&!a)&&(($u(r)!=="body"||A1(i))&&(c=wq(r)),f)){const h=pO(r);u=lj(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const p=i&&!f&&!a?_ct(i,c):Gv(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+p.x,y:n.y*u.y-c.scrollTop*u.y+d.y+p.y}}function Ehn(e){return Array.from(e.getClientRects())}function jhn(e){const t=Oy(e),n=wq(e),r=e.ownerDocument.body,s=hp(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=hp(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Sq(e);const l=-n.scrollTop;return Mu(r).direction==="rtl"&&(i+=hp(t.clientWidth,r.clientWidth)-s),{width:s,height:a,x:i,y:l}}const $Me=25;function Thn(e,t){const n=Ks(e),r=Oy(e),s=n.visualViewport;let a=r.clientWidth,i=r.clientHeight,l=0,c=0;if(s){a=s.width,i=s.height;const d=xq();(!d||d&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const u=Sq(r);if(u<=0){const d=r.ownerDocument,f=d.body,p=getComputedStyle(f),h=d.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,m=Math.abs(r.clientWidth-f.clientWidth-h);m<=$Me&&(a-=m)}else u<=$Me&&(a+=u);return{width:a,height:i,x:l,y:c}}function Nhn(e,t){const n=pO(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,a=Ra(e)?lj(e):Gv(1),i=e.clientWidth*a.x,l=e.clientHeight*a.y,c=s*a.x,u=r*a.y;return{width:i,height:l,x:c,y:u}}function MMe(e,t,n){let r;if(t==="viewport")r=Thn(e,n);else if(t==="document")r=jhn(Oy(e));else if(_r(t))r=Nhn(t,n);else{const s=Oct(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return VP(r)}function Cct(e,t){const n=ly(e);return n===t||!_r(n)||Qv(n)?!1:Mu(n).position==="fixed"||Cct(n,t)}function Ihn(e,t){const n=t.get(e);if(n)return n;let r=HP(e,[],!1).filter(l=>_r(l)&&$u(l)!=="body"),s=null;const a=Mu(e).position==="fixed";let i=a?ly(e):e;for(;_r(i)&&!Qv(i);){const l=Mu(i),c=kbe(i);!c&&l.position==="fixed"&&(s=null),(a?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||A1(i)&&!c&&Cct(e,i))?r=r.filter(d=>d!==i):s=l,i=ly(i)}return t.set(e,r),r}function Ahn(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const i=[...n==="clippingAncestors"?bq(t)?[]:Ihn(t,this._c):[].concat(n),r],l=MMe(t,i[0],s);let c=l.top,u=l.right,d=l.bottom,f=l.left;for(let p=1;p<i.length;p++){const h=MMe(t,i[p],s);c=hp(h.top,c),u=t1(h.right,u),d=t1(h.bottom,d),f=hp(h.left,f)}return{width:u-f,height:d-c,x:f,y:c}}function Rhn(e){const{width:t,height:n}=kct(e);return{width:t,height:n}}function Phn(e,t,n){const r=Ra(t),s=Oy(t),a=n==="fixed",i=pO(e,!0,a,t);let l={scrollLeft:0,scrollTop:0};const c=Gv(0);function u(){c.x=Sq(s)}if(r||!r&&!a)if(($u(t)!=="body"||A1(s))&&(l=wq(t)),r){const h=pO(t,!0,a,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else s&&u();a&&!r&&s&&u();const d=s&&!r&&!a?_ct(s,l):Gv(0),f=i.left+l.scrollLeft-c.x-d.x,p=i.top+l.scrollTop-c.y-d.y;return{x:f,y:p,width:i.width,height:i.height}}function oX(e){return Mu(e).position==="static"}function DMe(e,t){if(!Ra(e)||Mu(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Oy(e)===n&&(n=n.ownerDocument.body),n}function Ect(e,t){const n=Ks(e);if(bq(e))return n;if(!Ra(e)){let s=ly(e);for(;s&&!Qv(s);){if(_r(s)&&!oX(s))return s;s=ly(s)}return n}let r=DMe(e,t);for(;r&&xhn(r)&&oX(r);)r=DMe(r,t);return r&&Qv(r)&&oX(r)&&!kbe(r)?n:r||khn(e)||n}const $hn=async function(e){const t=this.getOffsetParent||Ect,n=this.getDimensions,r=await n(e.floating);return{reference:Phn(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Mhn(e){return Mu(e).direction==="rtl"}const jct={convertOffsetParentRelativeRectToViewportRelativeRect:Chn,getDocumentElement:Oy,getClippingRect:Ahn,getOffsetParent:Ect,getElementRects:$hn,getClientRects:Ehn,getDimensions:Rhn,getScale:lj,isElement:_r,isRTL:Mhn};function Tct(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Dhn(e,t){let n=null,r;const s=Oy(e);function a(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function i(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),a();const u=e.getBoundingClientRect(),{left:d,top:f,width:p,height:h}=u;if(l||t(),!p||!h)return;const m=wk(f),v=wk(s.clientWidth-(d+p)),y=wk(s.clientHeight-(f+h)),b=wk(d),w={rootMargin:-m+"px "+-v+"px "+-y+"px "+-b+"px",threshold:hp(0,t1(1,c))||1};let k=!0;function _(C){const E=C[0].intersectionRatio;if(E!==c){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Tct(u,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(_,{...w,root:s.ownerDocument})}catch{n=new IntersectionObserver(_,w)}n.observe(e)}return i(!0),a}function ife(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=Obe(e),d=s||a?[...u?HP(u):[],...t?HP(t):[]]:[];d.forEach(b=>{s&&b.addEventListener("scroll",n,{passive:!0}),a&&b.addEventListener("resize",n)});const f=u&&l?Dhn(u,n):null;let p=-1,h=null;i&&(h=new ResizeObserver(b=>{let[S]=b;S&&S.target===u&&h&&t&&(h.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var w;(w=h)==null||w.observe(t)})),n()}),u&&!c&&h.observe(u),t&&h.observe(t));let m,v=c?pO(e):null;c&&y();function y(){const b=pO(e);v&&!Tct(v,b)&&n(),v=b,m=requestAnimationFrame(y)}return n(),()=>{var b;d.forEach(S=>{s&&S.removeEventListener("scroll",n),a&&S.removeEventListener("resize",n)}),f?.(),(b=h)==null||b.disconnect(),h=null,c&&cancelAnimationFrame(m)}}const Lhn=ghn,Fhn=vhn,zhn=phn,Bhn=bhn,Uhn=hhn,LMe=fhn,qhn=yhn,Vhn=(e,t,n)=>{const r=new Map,s={platform:jct,...n},a={...s.platform,_c:r};return dhn(e,t,{...s,platform:a})};var Hhn=typeof document<"u",Whn=function(){},TF=Hhn?g.useLayoutEffect:Whn;function fz(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!fz(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const a=s[r];if(!(a==="_owner"&&e.$$typeof)&&!fz(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function Nct(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function FMe(e,t){const n=Nct(e);return Math.round(t*n)/n}function lX(e){const t=g.useRef(e);return TF(()=>{t.current=e}),t}function Ict(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:a,floating:i}={},transform:l=!0,whileElementsMounted:c,open:u}=e,[d,f]=g.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,h]=g.useState(r);fz(p,r)||h(r);const[m,v]=g.useState(null),[y,b]=g.useState(null),S=g.useCallback(z=>{z!==C.current&&(C.current=z,v(z))},[]),w=g.useCallback(z=>{z!==E.current&&(E.current=z,b(z))},[]),k=a||m,_=i||y,C=g.useRef(null),E=g.useRef(null),j=g.useRef(d),N=c!=null,I=lX(c),R=lX(s),P=lX(u),L=g.useCallback(()=>{if(!C.current||!E.current)return;const z={placement:t,strategy:n,middleware:p};R.current&&(z.platform=R.current),Vhn(C.current,E.current,z).then(B=>{const D={...B,isPositioned:P.current!==!1};M.current&&!fz(j.current,D)&&(j.current=D,yo.flushSync(()=>{f(D)}))})},[p,t,n,R,P]);TF(()=>{u===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,f(z=>({...z,isPositioned:!1})))},[u]);const M=g.useRef(!1);TF(()=>(M.current=!0,()=>{M.current=!1}),[]),TF(()=>{if(k&&(C.current=k),_&&(E.current=_),k&&_){if(I.current)return I.current(k,_,L);L()}},[k,_,L,I,N]);const q=g.useMemo(()=>({reference:C,floating:E,setReference:S,setFloating:w}),[S,w]),H=g.useMemo(()=>({reference:k,floating:_}),[k,_]),F=g.useMemo(()=>{const z={position:n,left:0,top:0};if(!H.floating)return z;const B=FMe(H.floating,d.x),D=FMe(H.floating,d.y);return l?{...z,transform:"translate("+B+"px, "+D+"px)",...Nct(H.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:B,top:D}},[n,l,H.floating,d.x,d.y]);return g.useMemo(()=>({...d,update:L,refs:q,elements:H,floatingStyles:F}),[d,L,q,H,F])}const Zhn=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:s}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?LMe({element:r.current,padding:s}).fn(n):{}:r?LMe({element:r,padding:s}).fn(n):{}}}},Act=(e,t)=>{const n=Lhn(e);return{name:n.name,fn:n.fn,options:[e,t]}},Rct=(e,t)=>{const n=Fhn(e);return{name:n.name,fn:n.fn,options:[e,t]}},Pct=(e,t)=>({fn:qhn(e).fn,options:[e,t]}),$ct=(e,t)=>{const n=zhn(e);return{name:n.name,fn:n.fn,options:[e,t]}},Mct=(e,t)=>{const n=Bhn(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dct=(e,t)=>{const n=Uhn(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ghn=(e,t)=>{const n=Zhn(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Qhn="Arrow",Lct=g.forwardRef((e,t)=>{const{children:n,width:r=10,height:s=5,...a}=e;return o.jsx(_f.svg,{...a,ref:t,width:r,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:o.jsx("polygon",{points:"0,0 30,0 15,10"})})});Lct.displayName=Qhn;var Yhn=Lct;function Xhn(e){const[t,n]=g.useState(void 0);return e1(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const a=s[0];let i,l;if("borderBoxSize"in a){const c=a.borderBoxSize,u=Array.isArray(c)?c[0]:c;i=u.inlineSize,l=u.blockSize}else i=e.offsetWidth,l=e.offsetHeight;n({width:i,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Fct="Popper",[zct,Bct]=vbe(Fct),[abs,Uct]=zct(Fct),qct="PopperAnchor",Vct=g.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...s}=e,a=Uct(qct,n),i=g.useRef(null),l=Rg(t,i),c=g.useRef(null);return g.useEffect(()=>{const u=c.current;c.current=r?.current||i.current,u!==c.current&&a.onAnchorChange(c.current)}),r?null:o.jsx(_f.div,{...s,ref:l})});Vct.displayName=qct;var _be="PopperContent",[Khn,Jhn]=zct(_be),Hct=g.forwardRef((e,t)=>{const{__scopePopper:n,side:r="bottom",sideOffset:s=0,align:a="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:h="optimized",onPlaced:m,...v}=e,y=Uct(_be,n),[b,S]=g.useState(null),w=Rg(t,te=>S(te)),[k,_]=g.useState(null),C=Xhn(k),E=C?.width??0,j=C?.height??0,N=r+(a!=="center"?"-"+a:""),I=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},R=Array.isArray(u)?u:[u],P=R.length>0,L={padding:I,boundary:R.filter(tmn),altBoundary:P},{refs:M,floatingStyles:q,placement:H,isPositioned:F,middlewareData:z}=Ict({strategy:"fixed",placement:N,whileElementsMounted:(...te)=>ife(...te,{animationFrame:h==="always"}),elements:{reference:y.anchor},middleware:[Act({mainAxis:s+j,alignmentAxis:i}),c&&Rct({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Pct():void 0,...L}),c&&$ct({...L}),Mct({...L,apply:({elements:te,rects:J,availableWidth:ee,availableHeight:ae})=>{const{width:ce,height:Y}=J.reference,ne=te.floating.style;ne.setProperty("--radix-popper-available-width",`${ee}px`),ne.setProperty("--radix-popper-available-height",`${ae}px`),ne.setProperty("--radix-popper-anchor-width",`${ce}px`),ne.setProperty("--radix-popper-anchor-height",`${Y}px`)}}),k&&Ghn({element:k,padding:l}),nmn({arrowWidth:E,arrowHeight:j}),p&&Dct({strategy:"referenceHidden",...L})]}),[B,D]=Gct(H),Q=Kj(m);e1(()=>{F&&Q?.()},[F,Q]);const V=z.arrow?.x,$=z.arrow?.y,U=z.arrow?.centerOffset!==0,[Z,X]=g.useState();return e1(()=>{b&&X(window.getComputedStyle(b).zIndex)},[b]),o.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...q,transform:F?q.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Z,"--radix-popper-transform-origin":[z.transformOrigin?.x,z.transformOrigin?.y].join(" "),...z.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:o.jsx(Khn,{scope:n,placedSide:B,onArrowChange:_,arrowX:V,arrowY:$,shouldHideArrow:U,children:o.jsx(_f.div,{"data-side":B,"data-align":D,...v,ref:w,style:{...v.style,animation:F?void 0:"none"}})})})});Hct.displayName=_be;var Wct="PopperArrow",emn={top:"bottom",right:"left",bottom:"top",left:"right"},Zct=g.forwardRef(function(t,n){const{__scopePopper:r,...s}=t,a=Jhn(Wct,r),i=emn[a.placedSide];return o.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:o.jsx(Yhn,{...s,ref:n,style:{...s.style,display:"block"}})})});Zct.displayName=Wct;function tmn(e){return e!==null}var nmn=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:s}=t,i=s.arrow?.centerOffset!==0,l=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,d]=Gct(n),f={start:"0%",center:"50%",end:"100%"}[d],p=(s.arrow?.x??0)+l/2,h=(s.arrow?.y??0)+c/2;let m="",v="";return u==="bottom"?(m=i?f:`${p}px`,v=`${-c}px`):u==="top"?(m=i?f:`${p}px`,v=`${r.floating.height+c}px`):u==="right"?(m=`${-c}px`,v=i?f:`${h}px`):u==="left"&&(m=`${r.floating.width+c}px`,v=i?f:`${h}px`),{data:{x:m,y:v}}}});function Gct(e){const[t,n="center"]=e.split("-");return[t,n]}var rmn=Vct,smn=Hct,amn=Zct,imn="Portal",Qct=g.forwardRef((e,t)=>{const{container:n,...r}=e,[s,a]=g.useState(!1);e1(()=>a(!0),[]);const i=n||s&&globalThis?.document?.body;return i?ybe.createPortal(o.jsx(_f.div,{...r,ref:t}),i):null});Qct.displayName=imn;function omn(e,t){return g.useReducer((n,r)=>t[n][r]??n,e)}var yD=e=>{const{present:t,children:n}=e,r=lmn(t),s=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),a=Rg(r.ref,cmn(s));return typeof n=="function"||r.isPresent?g.cloneElement(s,{ref:a}):null};yD.displayName="Presence";function lmn(e){const[t,n]=g.useState(),r=g.useRef(null),s=g.useRef(e),a=g.useRef("none"),i=e?"mounted":"unmounted",[l,c]=omn(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const u=xL(r.current);a.current=l==="mounted"?u:"none"},[l]),e1(()=>{const u=r.current,d=s.current;if(d!==e){const p=a.current,h=xL(u);e?c("MOUNT"):h==="none"||u?.display==="none"?c("UNMOUNT"):c(d&&p!==h?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,c]),e1(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=h=>{const v=xL(r.current).includes(CSS.escape(h.animationName));if(h.target===t&&v&&(c("ANIMATION_END"),!s.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},p=h=>{h.target===t&&(a.current=xL(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:g.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function xL(e){return e?.animationName||"none"}function cmn(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var umn=hN[" useInsertionEffect ".trim().toString()]||e1;function dmn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[s,a,i]=fmn({defaultProp:t,onChange:n}),l=e!==void 0,c=l?e:s;{const d=g.useRef(e!==void 0);g.useEffect(()=>{const f=d.current;f!==l&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=l},[l,r])}const u=g.useCallback(d=>{if(l){const f=pmn(d)?d(e):d;f!==e&&i.current?.(f)}else a(d)},[l,e,a,i]);return[c,u]}function fmn({defaultProp:e,onChange:t}){const[n,r]=g.useState(e),s=g.useRef(n),a=g.useRef(t);return umn(()=>{a.current=t},[t]),g.useEffect(()=>{s.current!==n&&(a.current?.(n),s.current=n)},[n,s]),[n,r,a]}function pmn(e){return typeof e=="function"}var hmn=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),mmn="VisuallyHidden",Yct=g.forwardRef((e,t)=>o.jsx(_f.span,{...e,ref:t,style:{...hmn,...e.style}}));Yct.displayName=mmn;var gmn=Yct,[kq]=vbe("Tooltip",[Bct]),Cbe=Bct(),Xct="TooltipProvider",vmn=700,zMe="tooltip.open",[ymn,Kct]=kq(Xct),Jct=e=>{const{__scopeTooltip:t,delayDuration:n=vmn,skipDelayDuration:r=300,disableHoverableContent:s=!1,children:a}=e,i=g.useRef(!0),l=g.useRef(!1),c=g.useRef(0);return g.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),o.jsx(ymn,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:g.useCallback(()=>{window.clearTimeout(c.current),i.current=!1},[]),onClose:g.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:g.useCallback(u=>{l.current=u},[]),disableHoverableContent:s,children:a})};Jct.displayName=Xct;var eut="Tooltip",[ibs,Oq]=kq(eut),ofe="TooltipTrigger",bmn=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,s=Oq(ofe,n),a=Kct(ofe,n),i=Cbe(n),l=g.useRef(null),c=Rg(t,l,s.onTriggerChange),u=g.useRef(!1),d=g.useRef(!1),f=g.useCallback(()=>u.current=!1,[]);return g.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),o.jsx(rmn,{asChild:!0,...i,children:o.jsx(_f.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...r,ref:c,onPointerMove:Vd(e.onPointerMove,p=>{p.pointerType!=="touch"&&!d.current&&!a.isPointerInTransitRef.current&&(s.onTriggerEnter(),d.current=!0)}),onPointerLeave:Vd(e.onPointerLeave,()=>{s.onTriggerLeave(),d.current=!1}),onPointerDown:Vd(e.onPointerDown,()=>{s.open&&s.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Vd(e.onFocus,()=>{u.current||s.onOpen()}),onBlur:Vd(e.onBlur,s.onClose),onClick:Vd(e.onClick,s.onClose)})})});bmn.displayName=ofe;var xmn="TooltipPortal",[obs,wmn]=kq(xmn,{forceMount:void 0}),tT="TooltipContent",Smn=g.forwardRef((e,t)=>{const n=wmn(tT,e.__scopeTooltip),{forceMount:r=n.forceMount,side:s="top",...a}=e,i=Oq(tT,e.__scopeTooltip);return o.jsx(yD,{present:r||i.open,children:i.disableHoverableContent?o.jsx(tut,{side:s,...a,ref:t}):o.jsx(kmn,{side:s,...a,ref:t})})}),kmn=g.forwardRef((e,t)=>{const n=Oq(tT,e.__scopeTooltip),r=Kct(tT,e.__scopeTooltip),s=g.useRef(null),a=Rg(t,s),[i,l]=g.useState(null),{trigger:c,onClose:u}=n,d=s.current,{onPointerInTransitChange:f}=r,p=g.useCallback(()=>{l(null),f(!1)},[f]),h=g.useCallback((m,v)=>{const y=m.currentTarget,b={x:m.clientX,y:m.clientY},S=jmn(b,y.getBoundingClientRect()),w=Tmn(b,S),k=Nmn(v.getBoundingClientRect()),_=Amn([...w,...k]);l(_),f(!0)},[f]);return g.useEffect(()=>()=>p(),[p]),g.useEffect(()=>{if(c&&d){const m=y=>h(y,d),v=y=>h(y,c);return c.addEventListener("pointerleave",m),d.addEventListener("pointerleave",v),()=>{c.removeEventListener("pointerleave",m),d.removeEventListener("pointerleave",v)}}},[c,d,h,p]),g.useEffect(()=>{if(i){const m=v=>{const y=v.target,b={x:v.clientX,y:v.clientY},S=c?.contains(y)||d?.contains(y),w=!Imn(b,i);S?p():w&&(p(),u())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[c,d,i,u,p]),o.jsx(tut,{...e,ref:a})}),[Omn,_mn]=kq(eut,{isInside:!1}),Cmn=Lpn("TooltipContent"),tut=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":s,onEscapeKeyDown:a,onPointerDownOutside:i,...l}=e,c=Oq(tT,n),u=Cbe(n),{onClose:d}=c;return g.useEffect(()=>(document.addEventListener(zMe,d),()=>document.removeEventListener(zMe,d)),[d]),g.useEffect(()=>{if(c.trigger){const f=p=>{p.target?.contains(c.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,d]),o.jsx(bbe,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:o.jsxs(smn,{"data-state":c.stateAttribute,...u,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[o.jsx(Cmn,{children:r}),o.jsx(Omn,{scope:n,isInside:!0,children:o.jsx(gmn,{id:c.contentId,role:"tooltip",children:s||r})})]})})});Smn.displayName=tT;var nut="TooltipArrow",Emn=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,s=Cbe(n);return _mn(nut,n).isInside?null:o.jsx(amn,{...s,...r,ref:t})});Emn.displayName=nut;function jmn(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),s=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,s,a)){case a:return"left";case s:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function Tmn(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Nmn(e){const{top:t,right:n,bottom:r,left:s}=e;return[{x:s,y:t},{x:n,y:t},{x:n,y:r},{x:s,y:r}]}function Imn(e,t){const{x:n,y:r}=e;let s=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const l=t[a],c=t[i],u=l.x,d=l.y,f=c.x,p=c.y;d>r!=p>r&&n<(f-u)*(r-d)/(p-d)+u&&(s=!s)}return s}function Amn(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),Rmn(t)}function Rmn(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const s=e[r];for(;t.length>=2;){const a=t[t.length-1],i=t[t.length-2];if((a.x-i.x)*(s.y-i.y)>=(a.y-i.y)*(s.x-i.x))t.pop();else break}t.push(s)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const s=e[r];for(;n.length>=2;){const a=n[n.length-1],i=n[n.length-2];if((a.x-i.x)*(s.y-i.y)>=(a.y-i.y)*(s.x-i.x))n.pop();else break}n.push(s)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}function Pmn(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const $mn=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Mmn=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Dmn={};function BMe(e,t){return(Dmn.jsx?Mmn:$mn).test(e)}const Lmn=/[ \t\n\f\r]/g;function Fmn(e){return typeof e=="object"?e.type==="text"?UMe(e.value):!1:UMe(e)}function UMe(e){return e.replace(Lmn,"")===""}let bD=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};bD.prototype.normal={};bD.prototype.property={};bD.prototype.space=void 0;function rut(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new bD(n,r,t)}function lfe(e){return e.toLowerCase()}let Cf=class{constructor(t,n){this.attribute=n,this.property=t}};Cf.prototype.attribute="";Cf.prototype.booleanish=!1;Cf.prototype.boolean=!1;Cf.prototype.commaOrSpaceSeparated=!1;Cf.prototype.commaSeparated=!1;Cf.prototype.defined=!1;Cf.prototype.mustUseProperty=!1;Cf.prototype.number=!1;Cf.prototype.overloadedBoolean=!1;Cf.prototype.property="";Cf.prototype.spaceSeparated=!1;Cf.prototype.space=void 0;let zmn=0;const ss=g_(),kl=g_(),cfe=g_(),Qt=g_(),Ri=g_(),cj=g_(),Jf=g_();function g_(){return 2**++zmn}const ufe=Object.freeze(Object.defineProperty({__proto__:null,boolean:ss,booleanish:kl,commaOrSpaceSeparated:Jf,commaSeparated:cj,number:Qt,overloadedBoolean:cfe,spaceSeparated:Ri},Symbol.toStringTag,{value:"Module"})),cX=Object.keys(ufe);class Ebe extends Cf{constructor(t,n,r,s){let a=-1;if(super(t,n),qMe(this,"space",s),typeof r=="number")for(;++a<cX.length;){const i=cX[a];qMe(this,cX[a],(r&ufe[i])===ufe[i])}}}Ebe.prototype.defined=!0;function qMe(e,t,n){n&&(e[t]=n)}function SN(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const a=new Ebe(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[lfe(r)]=r,n[lfe(a.attribute)]=r}return new bD(t,n,e.space)}const sut=SN({properties:{ariaActiveDescendant:null,ariaAtomic:kl,ariaAutoComplete:null,ariaBusy:kl,ariaChecked:kl,ariaColCount:Qt,ariaColIndex:Qt,ariaColSpan:Qt,ariaControls:Ri,ariaCurrent:null,ariaDescribedBy:Ri,ariaDetails:null,ariaDisabled:kl,ariaDropEffect:Ri,ariaErrorMessage:null,ariaExpanded:kl,ariaFlowTo:Ri,ariaGrabbed:kl,ariaHasPopup:null,ariaHidden:kl,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ri,ariaLevel:Qt,ariaLive:null,ariaModal:kl,ariaMultiLine:kl,ariaMultiSelectable:kl,ariaOrientation:null,ariaOwns:Ri,ariaPlaceholder:null,ariaPosInSet:Qt,ariaPressed:kl,ariaReadOnly:kl,ariaRelevant:null,ariaRequired:kl,ariaRoleDescription:Ri,ariaRowCount:Qt,ariaRowIndex:Qt,ariaRowSpan:Qt,ariaSelected:kl,ariaSetSize:Qt,ariaSort:null,ariaValueMax:Qt,ariaValueMin:Qt,ariaValueNow:Qt,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function aut(e,t){return t in e?e[t]:t}function iut(e,t){return aut(e,t.toLowerCase())}const Bmn=SN({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:cj,acceptCharset:Ri,accessKey:Ri,action:null,allow:null,allowFullScreen:ss,allowPaymentRequest:ss,allowUserMedia:ss,alt:null,as:null,async:ss,autoCapitalize:null,autoComplete:Ri,autoFocus:ss,autoPlay:ss,blocking:Ri,capture:null,charSet:null,checked:ss,cite:null,className:Ri,cols:Qt,colSpan:null,content:null,contentEditable:kl,controls:ss,controlsList:Ri,coords:Qt|cj,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ss,defer:ss,dir:null,dirName:null,disabled:ss,download:cfe,draggable:kl,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ss,formTarget:null,headers:Ri,height:Qt,hidden:cfe,high:Qt,href:null,hrefLang:null,htmlFor:Ri,httpEquiv:Ri,id:null,imageSizes:null,imageSrcSet:null,inert:ss,inputMode:null,integrity:null,is:null,isMap:ss,itemId:null,itemProp:Ri,itemRef:Ri,itemScope:ss,itemType:Ri,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ss,low:Qt,manifest:null,max:null,maxLength:Qt,media:null,method:null,min:null,minLength:Qt,multiple:ss,muted:ss,name:null,nonce:null,noModule:ss,noValidate:ss,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ss,optimum:Qt,pattern:null,ping:Ri,placeholder:null,playsInline:ss,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ss,referrerPolicy:null,rel:Ri,required:ss,reversed:ss,rows:Qt,rowSpan:Qt,sandbox:Ri,scope:null,scoped:ss,seamless:ss,selected:ss,shadowRootClonable:ss,shadowRootDelegatesFocus:ss,shadowRootMode:null,shape:null,size:Qt,sizes:null,slot:null,span:Qt,spellCheck:kl,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Qt,step:null,style:null,tabIndex:Qt,target:null,title:null,translate:null,type:null,typeMustMatch:ss,useMap:null,value:kl,width:Qt,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ri,axis:null,background:null,bgColor:null,border:Qt,borderColor:null,bottomMargin:Qt,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ss,declare:ss,event:null,face:null,frame:null,frameBorder:null,hSpace:Qt,leftMargin:Qt,link:null,longDesc:null,lowSrc:null,marginHeight:Qt,marginWidth:Qt,noResize:ss,noHref:ss,noShade:ss,noWrap:ss,object:null,profile:null,prompt:null,rev:null,rightMargin:Qt,rules:null,scheme:null,scrolling:kl,standby:null,summary:null,text:null,topMargin:Qt,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Qt,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ss,disableRemotePlayback:ss,prefix:null,property:null,results:Qt,security:null,unselectable:null},space:"html",transform:iut}),Umn=SN({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",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",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",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",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",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",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Jf,accentHeight:Qt,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Qt,amplitude:Qt,arabicForm:null,ascent:Qt,attributeName:null,attributeType:null,azimuth:Qt,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Qt,by:null,calcMode:null,capHeight:Qt,className:Ri,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Qt,diffuseConstant:Qt,direction:null,display:null,dur:null,divisor:Qt,dominantBaseline:null,download:ss,dx:null,dy:null,edgeMode:null,editable:null,elevation:Qt,enableBackground:null,end:null,event:null,exponent:Qt,externalResourcesRequired:null,fill:null,fillOpacity:Qt,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:cj,g2:cj,glyphName:cj,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Qt,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Qt,horizOriginX:Qt,horizOriginY:Qt,id:null,ideographic:Qt,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Qt,k:Qt,k1:Qt,k2:Qt,k3:Qt,k4:Qt,kernelMatrix:Jf,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Qt,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Qt,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Qt,overlineThickness:Qt,paintOrder:null,panose1:null,path:null,pathLength:Qt,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ri,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Qt,pointsAtY:Qt,pointsAtZ:Qt,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Jf,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Jf,rev:Jf,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Jf,requiredFeatures:Jf,requiredFonts:Jf,requiredFormats:Jf,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Qt,specularExponent:Qt,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Qt,strikethroughThickness:Qt,string:null,stroke:null,strokeDashArray:Jf,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Qt,strokeOpacity:Qt,strokeWidth:null,style:null,surfaceScale:Qt,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Jf,tabIndex:Qt,tableValues:null,target:null,targetX:Qt,targetY:Qt,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Jf,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Qt,underlineThickness:Qt,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Qt,values:null,vAlphabetic:Qt,vMathematical:Qt,vectorEffect:null,vHanging:Qt,vIdeographic:Qt,version:null,vertAdvY:Qt,vertOriginX:Qt,vertOriginY:Qt,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Qt,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:aut}),out=SN({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),lut=SN({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:iut}),cut=SN({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),qmn={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Vmn=/[A-Z]/g,VMe=/-[a-z]/g,Hmn=/^data[-\w.:]+$/i;function Wmn(e,t){const n=lfe(t);let r=t,s=Cf;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Hmn.test(t)){if(t.charAt(4)==="-"){const a=t.slice(5).replace(VMe,Gmn);r="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{const a=t.slice(4);if(!VMe.test(a)){let i=a.replace(Vmn,Zmn);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}s=Ebe}return new s(r,t)}function Zmn(e){return"-"+e.toLowerCase()}function Gmn(e){return e.charAt(1).toUpperCase()}const Qmn=rut([sut,Bmn,out,lut,cut],"html"),jbe=rut([sut,Umn,out,lut,cut],"svg");function Ymn(e){return e.join(" ").trim()}var DC={},uX,HMe;function Xmn(){if(HMe)return uX;HMe=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,i=/^[;\s]*/,l=/^\s+|\s+$/g,c=`
195
195
  `,u="/",d="*",f="",p="comment",h="declaration";uX=function(v,y){if(typeof v!="string")throw new TypeError("First argument must be a string");if(!v)return[];y=y||{};var b=1,S=1;function w(L){var M=L.match(t);M&&(b+=M.length);var q=L.lastIndexOf(c);S=~q?L.length-q:S+L.length}function k(){var L={line:b,column:S};return function(M){return M.position=new _(L),j(),M}}function _(L){this.start=L,this.end={line:b,column:S},this.source=y.source}_.prototype.content=v;function C(L){var M=new Error(y.source+":"+b+":"+S+": "+L);if(M.reason=L,M.filename=y.source,M.line=b,M.column=S,M.source=v,!y.silent)throw M}function E(L){var M=L.exec(v);if(M){var q=M[0];return w(q),v=v.slice(q.length),M}}function j(){E(n)}function N(L){var M;for(L=L||[];M=I();)M!==!1&&L.push(M);return L}function I(){var L=k();if(!(u!=v.charAt(0)||d!=v.charAt(1))){for(var M=2;f!=v.charAt(M)&&(d!=v.charAt(M)||u!=v.charAt(M+1));)++M;if(M+=2,f===v.charAt(M-1))return C("End of comment missing");var q=v.slice(2,M-2);return S+=2,w(q),v=v.slice(M),S+=2,L({type:p,comment:q})}}function R(){var L=k(),M=E(r);if(M){if(I(),!E(s))return C("property missing ':'");var q=E(a),H=L({type:h,property:m(M[0].replace(e,f)),value:q?m(q[0].replace(e,f)):f});return E(i),H}}function P(){var L=[];N(L);for(var M;M=R();)M!==!1&&(L.push(M),N(L));return L}return j(),P()};function m(v){return v?v.replace(l,f):f}return uX}var WMe;function Kmn(){if(WMe)return DC;WMe=1;var e=DC&&DC.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(DC,"__esModule",{value:!0}),DC.default=n;const t=e(Xmn());function n(r,s){let a=null;if(!r||typeof r!="string")return a;const i=(0,t.default)(r),l=typeof s=="function";return i.forEach(c=>{if(c.type!=="declaration")return;const{property:u,value:d}=c;l?s(u,d,c):d&&(a=a||{},a[u]=d)}),a}return DC}var jA={},ZMe;function Jmn(){if(ZMe)return jA;ZMe=1,Object.defineProperty(jA,"__esModule",{value:!0}),jA.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,s=/^-(ms)-/,a=function(u){return!u||n.test(u)||e.test(u)},i=function(u,d){return d.toUpperCase()},l=function(u,d){return"".concat(d,"-")},c=function(u,d){return d===void 0&&(d={}),a(u)?u:(u=u.toLowerCase(),d.reactCompat?u=u.replace(s,l):u=u.replace(r,l),u.replace(t,i))};return jA.camelCase=c,jA}var TA,GMe;function egn(){if(GMe)return TA;GMe=1;var e=TA&&TA.__importDefault||function(s){return s&&s.__esModule?s:{default:s}},t=e(Kmn()),n=Jmn();function r(s,a){var i={};return!s||typeof s!="string"||(0,t.default)(s,function(l,c){l&&c&&(i[(0,n.camelCase)(l,a)]=c)}),i}return r.default=r,TA=r,TA}var tgn=egn();const ngn=Tc(tgn),uut=dut("end"),Tbe=dut("start");function dut(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function rgn(e){const t=Tbe(e),n=uut(e);if(t&&n)return{start:t,end:n}}function I2(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?QMe(e.position):"start"in e||"end"in e?QMe(e):"line"in e||"column"in e?dfe(e):""}function dfe(e){return YMe(e&&e.line)+":"+YMe(e&&e.column)}function QMe(e){return dfe(e&&e.start)+"-"+dfe(e&&e.end)}function YMe(e){return e&&typeof e=="number"?e:1}class qu extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",a={},i=!1;if(n&&("line"in n&&"column"in n?a={place:n}:"start"in n&&"end"in n?a={place:n}:"type"in n?a={ancestors:[n],place:n.position}:a={...n}),typeof t=="string"?s=t:!a.cause&&t&&(i=!0,s=t.message,a.cause=t),!a.ruleId&&!a.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?a.ruleId=r:(a.source=r.slice(0,c),a.ruleId=r.slice(c+1))}if(!a.place&&a.ancestors&&a.ancestors){const c=a.ancestors[a.ancestors.length-1];c&&(a.place=c.position)}const l=a.place&&"start"in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=l?l.line:void 0,this.name=I2(a.place)||"1:1",this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=i&&a.cause&&typeof a.cause.stack=="string"?a.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}qu.prototype.file="";qu.prototype.name="";qu.prototype.reason="";qu.prototype.message="";qu.prototype.stack="";qu.prototype.column=void 0;qu.prototype.line=void 0;qu.prototype.ancestors=void 0;qu.prototype.cause=void 0;qu.prototype.fatal=void 0;qu.prototype.place=void 0;qu.prototype.ruleId=void 0;qu.prototype.source=void 0;const Nbe={}.hasOwnProperty,sgn=new Map,agn=/[A-Z]/g,ign=new Set(["table","tbody","thead","tfoot","tr"]),ogn=new Set(["td","th"]),fut="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function lgn(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=ggn(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=mgn(n,t.jsx,t.jsxs)}const s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?jbe:Qmn,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=put(s,e,void 0);return a&&typeof a!="string"?a:s.create(e,s.Fragment,{children:a||void 0},void 0)}function put(e,t,n){if(t.type==="element")return cgn(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return ugn(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return fgn(e,t,n);if(t.type==="mdxjsEsm")return dgn(e,t);if(t.type==="root")return pgn(e,t,n);if(t.type==="text")return hgn(e,t)}function cgn(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=jbe,e.schema=s),e.ancestors.push(t);const a=mut(e,t.tagName,!1),i=vgn(e,t);let l=Abe(e,t);return ign.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!Fmn(c):!0})),hut(e,i,a,t),Ibe(i,l),e.ancestors.pop(),e.schema=r,e.create(t,a,i,n)}function ugn(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}WP(e,t.position)}function dgn(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);WP(e,t.position)}function fgn(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=jbe,e.schema=s),e.ancestors.push(t);const a=t.name===null?e.Fragment:mut(e,t.name,!0),i=ygn(e,t),l=Abe(e,t);return hut(e,i,a,t),Ibe(i,l),e.ancestors.pop(),e.schema=r,e.create(t,a,i,n)}function pgn(e,t,n){const r={};return Ibe(r,Abe(e,t)),e.create(t,e.Fragment,r,n)}function hgn(e,t){return t.value}function hut(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Ibe(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function mgn(e,t,n){return r;function r(s,a,i,l){const u=Array.isArray(i.children)?n:t;return l?u(a,i,l):u(a,i)}}function ggn(e,t){return n;function n(r,s,a,i){const l=Array.isArray(a.children),c=Tbe(r);return t(s,a,i,l,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function vgn(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&Nbe.call(t.properties,s)){const a=bgn(e,s,t.properties[s]);if(a){const[i,l]=a;e.tableCellAlignToStyle&&i==="align"&&typeof l=="string"&&ogn.has(t.tagName)?r=l:n[i]=l}}if(r){const a=n.style||(n.style={});a[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function ygn(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const a=r.data.estree.body[0];a.type;const i=a.expression;i.type;const l=i.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else WP(e,t.position);else{const s=r.name;let a;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,a=e.evaluater.evaluateExpression(l.expression)}else WP(e,t.position);else a=r.value===null?!0:r.value;n[s]=a}return n}function Abe(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:sgn;for(;++r<t.children.length;){const a=t.children[r];let i;if(e.passKeys){const c=a.type==="element"?a.tagName:a.type==="mdxJsxFlowElement"||a.type==="mdxJsxTextElement"?a.name:void 0;if(c){const u=s.get(c)||0;i=c+"-"+u,s.set(c,u+1)}}const l=put(e,a,i);l!==void 0&&n.push(l)}return n}function bgn(e,t,n){const r=Wmn(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Pmn(n):Ymn(n)),r.property==="style"){let s=typeof n=="object"?n:xgn(e,String(n));return e.stylePropertyNameCase==="css"&&(s=wgn(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?qmn[r.property]||r.property:r.attribute,n]}}function xgn(e,t){try{return ngn(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new qu("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=fut+"#cannot-parse-style-attribute",s}}function mut(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let a=-1,i;for(;++a<s.length;){const l=BMe(s[a])?{type:"Identifier",name:s[a]}:{type:"Literal",value:s[a]};i=i?{type:"MemberExpression",object:i,property:l,computed:!!(a&&l.type==="Literal"),optional:!1}:l}r=i}else r=BMe(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return Nbe.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);WP(e)}function WP(e,t){const n=new qu("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=fut+"#cannot-handle-mdx-estrees-without-createevaluater",n}function wgn(e){const t={};let n;for(n in e)Nbe.call(e,n)&&(t[Sgn(n)]=e[n]);return t}function Sgn(e){let t=e.replace(agn,kgn);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function kgn(e){return"-"+e.toLowerCase()}function XMe(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,s=n.indexOf(t);for(;s!==-1;)r++,s=n.indexOf(t,s+t.length);return r}var gut=g.createContext({}),Ogn=({children:e,baseUrl:t,headers:n,apiPrefix:r,credentials:s="include",customFetch:a})=>{const i=jgn(t,n,r,s,a);return o.jsx(gut.Provider,{value:i,children:e})},We=()=>g.useContext(gut),_gn=/^127\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,Cgn=e=>{const t=_gn.exec(e);return t?+t[1]<=255&&+t[2]<=255&&+t[3]<=255:!1},Egn=e=>{if(!e)return!0;try{const{hostname:t}=new URL(e);return t==="localhost"||t.endsWith(".localhost")||Cgn(t)||t==="::1"||t==="[::1]"}catch{return!1}},jgn=(e,t={},n,r="include",s)=>new VR({baseUrl:e||"",headers:Egn(e)?{...t,"x-mastra-dev-playground":"true"}:t,apiPrefix:n,credentials:r,fetch:s}),Tgn=({children:e,baseUrl:t,headers:n,apiPrefix:r,credentials:s,customFetch:a})=>o.jsx(Ogn,{baseUrl:t,headers:n,apiPrefix:r,credentials:s,customFetch:a,children:e}),vut=(e,t,n,r)=>{const s=[];s.push("#### Completion Check Results"),s.push(""),s.push(`Overall: ${e.complete?"✅ COMPLETE":"❌ NOT COMPLETE"}`),s.push(`Duration: ${e.totalDuration}ms`),e.timedOut&&s.push("⚠️ Scoring timed out"),s.push("");for(const a of e.scorers)s.push(n(a)),s.push(`Score: ${a.score} ${a.passed?"✅":"❌"}`),a.reason&&s.push(`Reason: ${a.reason}`),s.push("");return e.complete?s.push("✅ The task is complete."):t?s.push("⚠️ Max iterations reached."):s.push(r),s.join(`
196
196
  `)},Ngn=(e,t)=>vut(e,t,n=>`###### ${n.scorerName} (${n.scorerId})`,"🔄 Will continue working on the task."),Ign=(e,t)=>vut(e,t,n=>`**${n.scorerName}** (${n.scorerId})`,"🔄 The task is not yet complete. Please continue working based on the feedback above."),tx="clientMessageId",hO=e=>e?{...e}:{},Hi=(e,t)=>({...e,content:{...e.content,parts:t}}),nx=(e,t)=>({...e,content:{...e.content,metadata:t}}),Agn=e=>{const{status:t,[tx]:n,...r}=e.content.metadata??{};return nx(e,r)},Rgn=e=>{const{status:t,...n}=e.content.metadata??{};return nx(e,n)},bi=(e,t)=>[...e.slice(0,-1),t],ES=(e,t,n)=>[...e.slice(0,t),n,...e.slice(t+1)],GR=(e,t,n)=>({id:e,role:"assistant",createdAt:new Date,content:{format:2,parts:t,metadata:hO(n)}}),Ud=(e,t,n,r)=>[...e,GR(t,n,r)],uk=e=>e.type==="tool-invocation",KMe=e=>e.type==="text"?e.textId:void 0,ffe=e=>e.state,uw=e=>{const t=e[e.length-1];if(!t||t.role!=="assistant")return e;if(t.content.parts.length===0)return e.slice(0,-1);const n=t.content.parts.map(r=>(r.type==="text"||r.type==="reasoning")&&ffe(r)==="streaming"?{...r,state:"done"}:r);return bi(e,Hi(t,n))},jS=(e,t,n)=>{const r=l=>l.findIndex(c=>uk(c)&&c.toolInvocation.toolCallId===t),s=e[e.length-1];if(s&&s.role==="assistant"){const l=r(s.content.parts);if(l!==-1)return{messageIndex:e.length-1,toolPartIndex:l}}let a=0;const i=10;for(let l=e.length-1;l>=0&&!(a>i);l--){const c=e[l];if(c.role!=="assistant")continue;const u=r(c.content.parts);if(u!==-1)return{messageIndex:l,toolPartIndex:u};a++}if(!n)return null;for(let l=e.length-1;l>=0;l--)if(e[l].role==="assistant")return{messageIndex:l,toolPartIndex:-1};return null},dX=(e,t,n,r)=>{const s=hO(e),a=s.backgroundTasks??{},i={...a};if(n.perTaskEntry){const{toolCallId:c,startedAt:u,completedAt:d,taskId:f,suspendedAt:p}=n.perTaskEntry,h=a[c]??{taskId:f};i[c]={...h,taskId:f,...u!==void 0?{startedAt:u}:{},...d!==void 0?{completedAt:d}:{},...p!==void 0?{suspendedAt:p}:{}}}const l={...s,...r??{},mode:t,backgroundTasks:i};return n.resetRunningCount&&(l.runningBackgroundTasksCount=void 0),l},dw=(e,t)=>{if(t.type==="workflow-start")return{input:e?.input,status:"running",steps:e?.steps||{}};if(t.type==="workflow-canceled")return{...e,status:"canceled"};if(t.type==="workflow-finish"){const i=t.payload.workflowStatus,l=e?.steps??{},c=Object.values(l).pop();return{...e,status:t.payload.workflowStatus,...i==="success"&&c?.status==="success"?{result:c?.output}:i==="failed"&&c?.status==="failed"?{error:c?.error}:i==="tripwire"&&t.payload.tripwire?{tripwire:t.payload.tripwire}:{}}}const{stepCallId:n,stepName:r,...s}=t.payload??{},a={...e?.steps,[t.payload.id]:{...e?.steps?.[t.payload.id],...s}};if(t.type==="workflow-step-start")return{...e,steps:a};if(t.type==="workflow-step-suspended"){const i=Object.entries(a).flatMap(([l,c])=>{if(c?.status==="suspended"){const u=c?.suspendPayload?.__workflow_meta?.path;return u?[[l,...u]]:[[l]]}return[]});return{...e,status:"suspended",steps:a,suspendPayload:t.payload.suspendPayload,suspended:i}}return t.type==="workflow-step-waiting"?{...e,status:"waiting",steps:a}:t.type==="workflow-step-progress"?{...e,steps:{...e?.steps,[t.payload.id]:{...e?.steps?.[t.payload.id],foreachProgress:{completedCount:t.payload.completedCount,totalCount:t.payload.totalCount,currentIndex:t.payload.currentIndex,iterationStatus:t.payload.iterationStatus,iterationOutput:t.payload.iterationOutput}}}}:t.type==="workflow-step-result"?{...e,steps:a}:e},yut=(e,t)=>{const n=l=>({id:`signal-${Date.now()}`,role:"user",createdAt:new Date,content:{format:2,parts:l,metadata:hO(t)}}),r=l=>{if(!l||typeof l!="object")return[];const c=l;if(c.type==="text"&&typeof c.text=="string")return[{type:"text",text:c.text}];if(c.type==="image"){const u=c.image;return[{type:"file",mediaType:typeof c.mediaType=="string"?c.mediaType:typeof c.mimeType=="string"?c.mimeType:"image/*",url:typeof u=="string"?u:u instanceof URL?u.toString():""}]}if(c.type==="file"){const u=c.data;return[{type:"file",mediaType:typeof c.mediaType=="string"?c.mediaType:typeof c.mimeType=="string"?c.mimeType:"application/octet-stream",url:typeof u=="string"?u:u instanceof URL?u.toString():"",...typeof c.filename=="string"?{filename:c.filename}:{}}]}return[]};if(typeof e=="string")return[n([{type:"text",text:e}])];if(Array.isArray(e)){const l=e.flatMap(r);return l.length?[n(l)]:e.flatMap(c=>yut(c,t))}if(!e||typeof e!="object")return[];const s=e;if(s.role&&s.role!=="user")return[];const a=s.content;if(typeof a=="string")return[n([{type:"text",text:a}])];if(!Array.isArray(a))return[];const i=a.flatMap(r);return i.length?[n(i)]:[]},JMe=e=>({type:"tool-invocation",toolInvocation:e}),Pgn=e=>e.type.startsWith("agent-execution-event-")||e.type.startsWith("workflow-execution-event-"),$gn=e=>e.type.startsWith("data-"),Mgn=({chunk:e,conversation:t,metadata:n})=>{const r=[...t];if(Pgn(e))return r;if($gn(e)){if(e.type==="data-user-message"&&"data"in e&&(e.data?.type==="user-message"||e.data?.type==="user")){const i=e.data.id,l=e.data?.metadata?.[tx];if(typeof l=="string"&&r.some(f=>f.content.metadata?.status==="pending"&&f.content.metadata[tx]===l))return uw(r.map(f=>f.content.metadata?.status==="pending"&&f.content.metadata[tx]===l?Rgn(typeof i=="string"?{...f,id:i}:f):f));if(typeof i=="string"&&r.some(f=>f.id===i))return uw(r.map(f=>f.id===i&&f.content.metadata?.status==="pending"?Agn(f):f));const c=yut(e.data.contents,n);if(!c.length)return r;const u=uw(r),d=typeof i=="string"?i:`signal-${e.runId}-${Date.now()}`;return[...u,...c.map((f,p)=>({...f,id:p===0?d:`${d}-${p}`}))]}const s={type:e.type,data:"data"in e?e.data:void 0,..."id"in e&&typeof e.id=="string"?{id:e.id}:{}},a=r[r.length-1];return!a||a.role!=="assistant"?Ud(r,`data-${e.runId}-${Date.now()}`,[s],n):bi(r,Hi(a,[...a.content.parts,s]))}switch(e.type){case"tripwire":{const s=GR(`tripwire-${e.runId+Date.now()}`,[{type:"text",text:e.payload.reason}],{...n,status:"tripwire",tripwire:{reason:e.payload.reason,retry:e.payload.retry,metadata:e.payload.metadata,processorId:e.payload.processorId}});return[...r,s]}case"start":{const s=typeof e.payload.messageId=="string"?e.payload.messageId:void 0;return s&&r.some(a=>a.id===s)?r:[...r,GR(s??`start-${e.runId+Date.now()}`,[],n)]}case"text-start":{const s=r[r.length-1],a=e.payload.id||`text-${Date.now()}`;if(e.payload.id&&s?.role==="assistant"&&s.content.parts.some(l=>l.type==="text"&&KMe(l)===a))return r;const i={type:"text",text:"",state:"streaming",textId:a,providerMetadata:e.payload.providerMetadata};return!s||s.role!=="assistant"?Ud(r,`start-${e.runId}-${Date.now()}`,[i],n):s.content.metadata?.completionResult?Ud(r,`start-${e.runId}-${Date.now()}`,[i],n):bi(r,Hi(s,[...s.content.parts,i]))}case"background-task-progress":{const s=r[r.length-1];return!s||s.role!=="assistant"?r:bi(r,nx(s,{mode:n.mode,...s.content.metadata,runningBackgroundTasksCount:e.payload.runningCount}))}case"text-delta":{const s=r[r.length-1],a=e.payload.id;if(!s||s.role!=="assistant"){const c={type:"text",text:e.payload.text,state:"streaming",textId:a,providerMetadata:e.payload.providerMetadata};return Ud(r,`text-${e.runId}-${Date.now()}`,[c],n)}const i=[...s.content.parts];let l=a?i.findLastIndex(c=>c.type==="text"&&KMe(c)===a):-1;if(l===-1&&(l=i.findLastIndex(c=>c.type==="text"&&ffe(c)==="streaming")),l===-1){const c={type:"text",text:e.payload.text,state:"streaming",textId:a,providerMetadata:e.payload.providerMetadata};i.push(c)}else{const c=i[l];i[l]={...c,text:c.text+e.payload.text,state:"streaming"}}return bi(r,Hi(s,i))}case"text-end":return r;case"reasoning-start":{const s=r[r.length-1],a={type:"reasoning",reasoning:"",state:"streaming",providerMetadata:e.payload.providerMetadata};return!s||s.role!=="assistant"?Ud(r,`reasoning-${e.runId+Date.now()}`,[a],n):bi(r,Hi(s,[...s.content.parts,a]))}case"reasoning-delta":{const s=r[r.length-1];if(!s||s.role!=="assistant"){const c={type:"reasoning",reasoning:e.payload.text,state:"streaming",providerMetadata:e.payload.providerMetadata};return Ud(r,`reasoning-${e.runId+Date.now()}`,[c],n)}const a=[...s.content.parts],i=a.length-1,l=a[i];if(l?.type==="reasoning"){const c=l;a[i]={...c,reasoning:c.reasoning+e.payload.text,state:"streaming"}}else{const c={type:"reasoning",reasoning:e.payload.text,state:"streaming",providerMetadata:e.payload.providerMetadata};a.push(c)}return bi(r,Hi(s,a))}case"reasoning-end":{const s=r[r.length-1];if(!s||s.role!=="assistant")return r;const a=[...s.content.parts],i=a.findLastIndex(d=>d.type==="reasoning"&&ffe(d)==="streaming");if(i===-1)return r;const l=a[i],c=l.providerMetadata,u=e.payload.providerMetadata;return a[i]={...l,state:"done",...c||u?{providerMetadata:{...c??{},...u??{}}}:{}},bi(r,Hi(s,a))}case"reasoning-signature":{const s=r[r.length-1];if(!s||s.role!=="assistant")return r;const a=[...s.content.parts],i=a.findLastIndex(d=>d.type==="reasoning");if(i===-1)return r;const l=a[i],c=l.providerMetadata,u=e.payload.providerMetadata;return a[i]={...l,...c||u?{providerMetadata:{...c??{},...u??{}}}:{}},bi(r,Hi(s,a))}case"redacted-reasoning":{const s=r[r.length-1],a=e.payload.data,i={type:"reasoning",reasoning:typeof a=="string"?a:"",state:"done",redacted:!0,providerMetadata:e.payload.providerMetadata};return!s||s.role!=="assistant"?Ud(r,`redacted-reasoning-${e.runId+Date.now()}`,[i],n):bi(r,Hi(s,[...s.content.parts,i]))}case"tool-call":{const s={state:"call",toolCallId:e.payload.toolCallId,toolName:e.payload.toolName,args:e.payload.args},a={...JMe(s),providerMetadata:e.payload.providerMetadata},i=jS(r,e.payload.toolCallId,!1);if(i&&i.toolPartIndex>=0){const{messageIndex:c,toolPartIndex:u}=i,d=r[c];if(d&&d.role==="assistant"){const f=[...d.content.parts],p=f[u];if(uk(p)){const{argsText:h,...m}=p;return f[u]={...m,toolInvocation:{...p.toolInvocation,state:"call",toolName:e.payload.toolName,toolCallId:e.payload.toolCallId,args:e.payload.args},providerMetadata:e.payload.providerMetadata??p.providerMetadata},ES(r,c,Hi(d,f))}}}const l=r[r.length-1];return!l||l.role!=="assistant"?Ud(r,`tool-call-${e.runId+Date.now()}`,[a],n):bi(r,Hi(l,[...l.content.parts,a]))}case"tool-call-input-streaming-start":{const s=r[r.length-1],a={state:"partial-call",toolCallId:e.payload.toolCallId,toolName:e.payload.toolName,args:{}},i={...JMe(a),argsText:""};return!s||s.role!=="assistant"?Ud(r,`tool-call-streaming-${e.runId+Date.now()}`,[i],n):bi(r,Hi(s,[...s.content.parts,i]))}case"tool-call-delta":{const s=jS(r,e.payload.toolCallId,!1);if(!s||s.toolPartIndex<0)return r;const{messageIndex:a,toolPartIndex:i}=s,l=r[a];if(!l||l.role!=="assistant")return r;const c=[...l.content.parts],u=c[i];if(!uk(u))return r;const d=(u.argsText??"")+(e.payload.argsTextDelta??"");return c[i]={...u,argsText:d,toolInvocation:{...u.toolInvocation,state:"partial-call"}},ES(r,a,Hi(l,c))}case"tool-call-input-streaming-end":{const s=jS(r,e.payload.toolCallId,!1);if(!s||s.toolPartIndex<0)return r;const{messageIndex:a,toolPartIndex:i}=s,l=r[a];if(!l||l.role!=="assistant")return r;const c=[...l.content.parts],u=c[i];if(!uk(u))return r;let d={};const f=u.argsText;if(typeof f=="string"&&f.length>0)try{const p=JSON.parse(f);p&&typeof p=="object"&&!Array.isArray(p)&&(d=p)}catch{d={}}return c[i]={...u,toolInvocation:{...u.toolInvocation,state:"call",args:d}},ES(r,a,Hi(l,c))}case"tool-error":case"tool-result":case"background-task-completed":case"background-task-failed":{const s=e.type==="background-task-completed"||e.type==="background-task-failed",a=jS(r,e.payload.toolCallId,s);if(!a)return r;const{messageIndex:i,toolPartIndex:l}=a,c=r[i];if(!c||c.role!=="assistant")return r;const u=[...c.content.parts],d=l>=0?u[l]:void 0;let f,p,h=!1,m,v,y;switch(e.type){case"tool-result":f=e.payload.result,h=!!e.payload.isError,m=e.payload.providerMetadata;break;case"tool-error":p=e.payload.error,m=e.payload.providerMetadata;break;case"background-task-completed":f=e.payload.result,v=e.payload.completedAt,y=e.payload.taskId;break;case"background-task-failed":p=e.payload.error,v=e.payload.completedAt,y=e.payload.taskId;break}if(d&&uk(d)){const{toolName:w,toolCallId:k,args:_}=d.toolInvocation,C=m??d.providerMetadata;if(e.type==="tool-error"||e.type==="background-task-failed"||h){const j=e.type==="tool-error"||e.type==="background-task-failed"?p:f,N=typeof j=="string"?j:j instanceof Error?j.message:j?.message??String(j);u[l]={...d,providerMetadata:C,toolInvocation:{state:"output-error",toolCallId:k,toolName:w,args:_,errorText:N}}}else{const j=f,N=d.toolInvocation.state==="partial-call"||d.toolInvocation.state==="result"?d.toolInvocation.result:void 0,I=!!(N&&typeof N=="object"&&"steps"in N),R=!!j?.result?.steps||w?.startsWith("workflow-")||I,P=e.from==="AGENT";let L;if(R){const M=I&&N&&typeof N=="object"?N:void 0,q=j?.result&&typeof j.result=="object"?j.result:void 0;M||q?L={...M??{},...q??{},steps:q?.steps??M?.steps??[],status:q?.status??M?.status??"success",output:f}:L=f}else if(P){const M=d.toolInvocation.state==="result"?d.toolInvocation.result:void 0,q=M?.childMessages;L=M?{...f,childMessages:q?.length?q:j?.childMessages}:f}else L=f;u[l]={...d,providerMetadata:C,toolInvocation:{state:"result",toolCallId:k,toolName:w,args:_,result:L}}}}const b=dX(c.content.metadata,n.mode,{resetRunningCount:s,perTaskEntry:s&&y?{toolCallId:e.payload.toolCallId,completedAt:v,taskId:y}:void 0}),S={...c,content:{...c.content,parts:u,metadata:b}};return ES(r,i,S)}case"background-task-running":{const s=jS(r,e.payload.toolCallId,!0);if(!s)return r;const{messageIndex:a}=s,i=r[a];if(!i||i.role!=="assistant")return r;const l=dX(i.content.metadata,n.mode,{perTaskEntry:{toolCallId:e.payload.toolCallId,startedAt:e.payload.startedAt,taskId:e.payload.taskId}});return ES(r,a,nx(i,l))}case"tool-output":case"background-task-output":{const s=e.type==="background-task-output",a=jS(r,e.payload.toolCallId,s);if(!a||a.toolPartIndex<0)return r;const{messageIndex:i,toolPartIndex:l}=a,c=r[i];if(!c||c.role!=="assistant")return r;const u=[...c.content.parts],d=u[l];if(!uk(d))return r;const{toolName:f,toolCallId:p,args:h}=d.toolInvocation,m=e.type==="background-task-output"?e.payload.payload.payload.output:e.payload.output;if(m?.type?.startsWith("workflow-")){const v=d.toolInvocation.result||{},y=dw(v,m);u[l]={...d,toolInvocation:{state:"partial-call",toolCallId:p,toolName:f,args:h,result:y}}}else{if(m?.from==="AGENT"||m?.from==="USER"&&m?.payload?.output?.type?.startsWith("workflow-"))return Lgn(m,r,n,p,f);{const v=d.toolInvocation.result,y=Array.isArray(v)?v:[];u[l]={...d,toolInvocation:{state:"partial-call",toolCallId:p,toolName:f,args:h,result:[...y,m]}}}}return ES(r,i,Hi(c,u))}case"is-task-complete":{if(e.payload.suppressFeedback)return r;const s=Ign({complete:e.payload.passed,scorers:e.payload.results,totalDuration:e.payload.duration,timedOut:e.payload.timedOut},e.payload.maxIterationReached),a=GR(`is-task-complete-${e.runId+Date.now()}`,[{type:"text",text:s}],{...n,completionResult:{passed:e.payload.passed}});return[...r,a]}case"source":{const s=r[r.length-1];if(!s||s.role!=="assistant")return r;const a=[...s.content.parts];if(e.payload.sourceType==="url"){const i={type:"source-url",sourceId:e.payload.id,url:e.payload.url||"",title:e.payload.title,providerMetadata:e.payload.providerMetadata};a.push(i)}else e.payload.sourceType==="document"&&a.push({type:"source-document",sourceId:e.payload.id,mediaType:e.payload.mimeType||"application/octet-stream",title:e.payload.title,filename:e.payload.filename,providerMetadata:e.payload.providerMetadata});return bi(r,Hi(s,a))}case"file":{const s=r[r.length-1];if(!s||s.role!=="assistant")return r;const a=[...s.content.parts];let i;if(typeof e.payload.data=="string")i=e.payload.base64?`data:${e.payload.mimeType};base64,${e.payload.data}`:`data:${e.payload.mimeType},${encodeURIComponent(e.payload.data)}`;else{const l=btoa(String.fromCharCode(...e.payload.data));i=`data:${e.payload.mimeType};base64,${l}`}return a.push({type:"file",mediaType:e.payload.mimeType,url:i,providerMetadata:e.payload.providerMetadata}),bi(r,Hi(s,a))}case"tool-call-approval":{const s=r[r.length-1];if(!s||s.role!=="assistant")return r;const a=s.content.metadata??{},i=a.mode==="stream"?a.requireApprovalMetadata??{}:{};return bi(r,{...s,content:{...s.content,metadata:{...a,mode:"stream",requireApprovalMetadata:{...i,[e.payload.toolName]:{toolCallId:e.payload.toolCallId,toolName:e.payload.toolName,args:e.payload.args}}}}})}case"tool-call-suspended":case"background-task-suspended":{const s=e.type==="background-task-suspended";let a,i,l,c,u,d;e.type==="background-task-suspended"?(a=e.payload.toolCallId,i=e.payload.toolName,l=e.payload.args,c=e.payload.suspendPayload,u=e.payload.suspendedAt,d=e.payload.taskId):(a=e.payload.toolCallId,i=e.payload.toolName,l=e.payload.args,c=e.payload.suspendPayload);const f=s?jS(r,a,!0):{messageIndex:r.length-1};if(!f)return r;const{messageIndex:p}=f,h=r[p];if(!h||h.role!=="assistant")return r;const m=h.content.metadata??{},v=m.mode==="stream"?m.suspendedTools??{}:{},y=dX(m,"stream",{resetRunningCount:s,perTaskEntry:s&&d?{toolCallId:a,suspendedAt:u,taskId:d}:void 0},{suspendedTools:{...v,[i]:{toolCallId:a,toolName:i,args:l,suspendPayload:c,runId:e.runId}}});return ES(r,p,nx(h,y))}case"finish":case"abort":return uw(r);case"error":{const s=GR(`error-${e.runId+Date.now()}`,[{type:"text",text:typeof e.payload.error=="string"?e.payload.error:JSON.stringify(e.payload.error)}],{...n,status:"error"});return[...r,s]}case"step-start":case"step-finish":case"step-output":case"raw":case"watch":case"response-metadata":return r;case"goal":return r;case"object":case"object-result":return r;case"background-task-started":case"background-task-cancelled":case"background-task-resumed":return r;case"workflow-start":case"workflow-finish":case"workflow-canceled":case"workflow-paused":case"workflow-step-start":case"workflow-step-finish":case"workflow-step-suspended":case"workflow-step-waiting":case"workflow-step-output":case"workflow-step-progress":case"workflow-step-result":return r;case"agent-execution-start":case"agent-execution-approval":case"agent-execution-suspended":case"agent-execution-end":case"agent-execution-abort":case"tool-execution-start":case"tool-execution-end":case"tool-execution-approval":case"tool-execution-suspended":case"tool-execution-abort":case"routing-agent-start":case"routing-agent-text-delta":case"routing-agent-text-start":case"routing-agent-end":case"routing-agent-abort":case"workflow-execution-start":case"workflow-execution-end":case"workflow-execution-suspended":case"workflow-execution-abort":case"network-execution-event-step-finish":case"network-execution-event-finish":case"network-validation-start":case"network-validation-end":case"network-object":case"network-object-result":return r;default:return Dgn(e,r)}},Dgn=(e,t)=>t,Lgn=(e,t,n,r,s)=>{const a=t[t.length-1];if(!a||a.role!=="assistant")return t;const i=[...a.content.parts],l=()=>i.findIndex(c=>uk(c)&&(r&&c.toolInvocation.toolCallId===r||s&&c.toolInvocation.toolName===s));if(e.type==="text-delta"){const c=e.payload,u=l();if(u===-1)return t;const d=i[u],f=d.toolInvocation.result||{},p=f.childMessages||[],h=p[p.length-1],m={type:"text",content:(h?.content||"")+c.text},v=h?.type==="text"?[...p.slice(0,-1),m]:[...p,m];i[u]={...d,toolInvocation:{...d.toolInvocation,result:{...f,childMessages:v}}}}else if(e.type==="tool-call"){const c=e.payload,u=l();if(u===-1)return t;const d=i[u],f=d.toolInvocation.result||{},p=f.childMessages||[];i[u]={...d,toolInvocation:{...d.toolInvocation,result:{...f,childMessages:[...p,{type:"tool",toolCallId:c.toolCallId,toolName:c.toolName,args:c.args}]}}}}else if(e.type==="tool-output"){const c=e.payload,u=l();if(u===-1)return t;const d=i[u];if(c?.output?.type?.startsWith("workflow-")){const f=d.toolInvocation.result||{},p=f.childMessages||[],h=p.length-1,m=p[h],v=m?.toolOutput||{},y=dw(v,c.output);h>=0&&p[h]?.type==="tool"&&(i[u]={...d,toolInvocation:{...d.toolInvocation,result:{...f,childMessages:[...p.slice(0,-1),{...m,toolOutput:{...y,runId:c.output.runId}}]}}})}}else if(e.type==="tool-result"){const c=e.payload,u=l();if(u===-1)return t;const d=i[u],f=d.toolInvocation.result||{},p=f.childMessages||[],h=p.length-1,m=c?.toolName?.startsWith("workflow-");h>=0&&p[h]?.type==="tool"&&(i[u]={...d,toolInvocation:{...d.toolInvocation,result:{...f,childMessages:[...p.slice(0,-1),{...p[h],toolOutput:m?{...c.result?.result,runId:c.result?.runId}:c.result}]}}})}return bi(t,Hi(a,i))},xD=e=>({...e,mode:"network"}),ZP=(e,t)=>e.findIndex(t),pz=e=>e.type==="dynamic-tool",Pv=e=>{const t=e[e.length-1];return t&&t.role==="assistant"?t:void 0},Fgn=e=>{const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return null;try{const n=JSON.parse(t);return n&&typeof n=="object"?n:null}catch{return null}},zgn=(e,t,n)=>{const r=e.payload?.text??"";if(!r)return t;const s=Pv(t),a=i=>{const l=(i.routingDecisionBuffer??"")+r,c={...hO(i),mode:"network"},u=Fgn(l);return u?(c.routingDecision=u,delete c.routingDecisionBuffer,delete c.routingDecisionText):(c.routingDecisionBuffer=l,c.routingDecisionText=l),c};if(!s){const i=a({});return Ud(t,`routing-agent-${e.payload?.runId??"unknown"}-${Date.now()}`,[],{...xD(n),...i})}return bi(t,nx(s,a(s.content.metadata??{})))},Bgn=(e,t,n)=>{if(e.type==="agent-execution-start"){const r=e.payload?.args?.primitiveId,s=e.payload.runId;if(!r||!s)return t;const a={type:"dynamic-tool",toolName:r,toolCallId:s,state:"input-available",input:e.payload.args};return Ud(t,`agent-execution-start-${s}-${Date.now()}`,[a],{...xD(n),selectionReason:e.payload?.args?.selectionReason||"",agentInput:e.payload?.args?.task,from:"AGENT"})}if(e.type==="agent-execution-end"){const r=Pv(t);if(!r)return t;const s=[...r.content.parts],a=ZP(s,i=>pz(i));if(a!==-1){const i=s[a],l=i.output;s[a]={type:"dynamic-tool",toolName:i.toolName,toolCallId:i.toolCallId,state:"output-available",input:i.input,output:{...l,result:l?.result||e.payload?.result||""}}}return bi(t,Hi(r,s))}if(e.type.startsWith("agent-execution-event-")){const r=Pv(t);if(!r)return t;const s=e.payload,a=[...r.content.parts],i=ZP(a,c=>pz(c));if(i===-1)return t;const l=a[i];if(s.type==="text-delta"){const c=l?.output?.childMessages||[],u=c[c.length-1],d={type:"text",content:(u?.content||"")+s.payload.text},f=u?.type==="text"?[...c.slice(0,-1),d]:[...c,d];a[i]={...l,output:{childMessages:f}}}else if(s.type==="tool-call"){const c=l?.output?.childMessages||[];a[i]={...l,output:{...l?.output,childMessages:[...c,{type:"tool",toolCallId:s.payload.toolCallId,toolName:s.payload.toolName,args:s.payload.args}]}}}else if(s.type==="tool-output"){if(s.payload?.output?.type?.startsWith("workflow-")){const c=l?.output?.childMessages||[],u=c.length-1,d=c[u],f=d?.toolOutput||{},p=dw(f,s.payload.output);u>=0&&c[u]?.type==="tool"&&(a[i]={...l,output:{...l?.output,childMessages:[...c.slice(0,-1),{...d,toolOutput:p}]}})}}else if(s.type==="tool-result"){const c=l?.output?.childMessages||[],u=c.length-1,d=!!s.payload?.result?.result?.steps;u>=0&&c[u]?.type==="tool"&&(a[i]={...l,output:{...l?.output,childMessages:[...c.slice(0,-1),{...c[u],toolOutput:d?s.payload.result.result:s.payload.result}]}})}return bi(t,Hi(r,a))}return t},Ugn=(e,t,n)=>{if(e.type==="workflow-execution-start"){const r=e.payload?.args?.primitiveId,s=e.payload.runId;if(!r||!s)return t;let a;try{a=JSON.parse(e.payload?.args?.prompt)}catch{a=e.payload?.args?.prompt}const i={type:"dynamic-tool",toolName:r,toolCallId:s,state:"input-available",input:e.payload.args};return Ud(t,`workflow-start-${s}-${Date.now()}`,[i],{...xD(n),selectionReason:e.payload?.args?.selectionReason||"",from:"WORKFLOW",agentInput:a})}if(e.type==="workflow-execution-suspended"){const r=Pv(t);if(!r)return t;const s=r.content.metadata?.suspendedTools??{};return bi(t,nx(r,{...hO(r.content.metadata),mode:"network",suspendedTools:{...s,[e.payload.toolName]:{toolCallId:e.payload.toolCallId,toolName:e.payload.toolName,args:e.payload.args,suspendPayload:e.payload.suspendPayload,runId:e.payload.runId}}}))}if(e.type.startsWith("workflow-execution-event-")){const r=Pv(t);if(!r)return t;const s=[...r.content.parts],a=ZP(s,u=>pz(u));if(a===-1)return t;const i=s[a],l=i.output||{},c=dw(l,e.payload);return s[a]={...i,output:c},bi(t,Hi(r,s))}return t},qgn=(e,t,n)=>{if(e.type==="tool-execution-start"){const r=e.payload.args,s=r.args||{},a=Pv(t),i={type:"dynamic-tool",toolName:r.toolName||"unknown",toolCallId:r.toolCallId||"unknown",state:"input-available",input:s};if(!a)return Ud(t,`tool-start-${e.payload.runId}-${Date.now()}`,[i],{...xD(n),selectionReason:n.mode==="network"?n.selectionReason||r.selectionReason:"",agentInput:s});const l=[...a.content.parts,i];return bi(t,Hi(a,l))}if(e.type==="tool-execution-approval"){const r=Pv(t);if(!r)return t;const s=r.content.metadata?.requireApprovalMetadata??{};return bi(t,nx(r,{...hO(r.content.metadata),mode:"network",requireApprovalMetadata:{...s,[e.payload.toolName]:{toolCallId:e.payload.toolCallId,toolName:e.payload.toolName,args:e.payload.args,runId:e.payload.runId}}}))}if(e.type==="tool-execution-suspended"){const r=Pv(t);if(!r)return t;const s=r.content.metadata?.suspendedTools??{};return bi(t,nx(r,{...hO(r.content.metadata),mode:"network",suspendedTools:{...s,[e.payload.toolName]:{toolCallId:e.payload.toolCallId,toolName:e.payload.toolName,args:e.payload.args,suspendPayload:e.payload.suspendPayload,runId:e.payload.runId}}}))}if(e.type==="tool-execution-end"){const r=Pv(t);if(!r)return t;const s=[...r.content.parts],a=ZP(s,i=>pz(i)&&i.toolCallId===e.payload.toolCallId);if(a!==-1){const i=s[a],l=i.output;s[a]={type:"dynamic-tool",toolName:i.toolName,toolCallId:i.toolCallId,state:"output-available",input:i.input,output:l?.result||e.payload?.result||""}}return bi(t,Hi(r,s))}return t},fX=({chunk:e,conversation:t,metadata:n})=>{const r=[...t];if(e.type==="routing-agent-text-delta")return zgn(e,r,n);if(e.type.startsWith("agent-execution-"))return Bgn(e,r,n);if(e.type.startsWith("workflow-execution-"))return Ugn(e,r,n);if(e.type.startsWith("tool-execution-"))return qgn(e,r,n);if(e.type==="network-validation-end"){if(e.payload.suppressFeedback)return r;const a={type:"text",text:Ngn({complete:e.payload.passed,scorers:e.payload.results,totalDuration:e.payload.duration,timedOut:e.payload.timedOut},e.payload.maxIterationReached)};return Ud(r,`network-validation-end-${e.payload.runId}-${Date.now()}`,[a],{...xD(n),completionResult:{passed:e.payload.passed}})}if(e.type==="network-execution-event-step-finish"){const s=Pv(r);if(!s)return r;const a=e.payload,i=[...s.content.parts],l=ZP(i,u=>u.type==="text");if(l===-1)return i.push({type:"text",text:a.result,state:"done"}),bi(r,Hi(s,i));const c=i[l];return c.type==="text"?(i[l]={...c,state:"done"},bi(r,Hi(s,i))):r}return r},Vgn=e=>typeof e.content=="string"?[{type:"text",text:e.content}]:e.content.map(t=>{switch(t.type){case"text":return{type:"text",text:t.text};case"image":{const n=typeof t.image=="string"?t.image:t.image instanceof URL?t.image.toString():"";return{type:"file",mimeType:t.mimeType??"image/*",data:n}}case"file":{const n=typeof t.data=="string"?t.data:t.data instanceof URL?t.data.toString():"";return{type:"file",mimeType:t.mimeType,data:n,...t.filename!==void 0?{filename:t.filename}:{}}}default:{const n=t;throw new Error(`Unhandled content part type: ${n.type}`)}}}),Hgn=e=>({id:`user-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,role:"user",createdAt:new Date,content:{format:2,parts:e}}),eDe=e=>Hgn(e.flatMap(Vgn)),but=new Set(["task_write","task_update","task_complete","task_check"]),Wgn="tasks",Zgn=new Set(["current-task-list","task-list-update"]),Ggn=new Set(["pending","in_progress","completed"]),Qgn=e=>typeof e.type=="string"&&e.type.startsWith("data-"),Hh=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Ygn=e=>typeof e=="string"&&Ggn.has(e),pfe=e=>Array.isArray(e)&&e.every(t=>Hh(t)&&typeof t.id=="string"&&typeof t.content=="string"&&Ygn(t.status)&&typeof t.activeForm=="string"),Xgn=e=>Hh(e)?e.id===Wgn||typeof e.tagName=="string"&&Zgn.has(e.tagName):!1,Rbe=e=>{if(!Xgn(e)||!Hh(e))return;const t=e.metadata;if(!Hh(t))return;const n=t.value;if(Hh(n))return pfe(n.tasks)?n.tasks:void 0},xut=e=>{if(Hh(e)&&pfe(e.tasks))return e.tasks;if(typeof e=="string")try{const t=JSON.parse(e);return Hh(t)&&pfe(t.tasks)?t.tasks:void 0}catch{return}},Kgn=e=>{if(Qgn(e))return Rbe(e.data)},Jgn=e=>{if(e.type!=="tool-result")return;const t=e.payload;if(!(!Hh(t)||typeof t.toolName!="string"||!but.has(t.toolName)))return xut(t.result)},evn=e=>{if(!Hh(e)||e.type!=="tool-invocation"||!Hh(e.toolInvocation))return;const t=e.toolInvocation;if(!(typeof t.toolName!="string"||!but.has(t.toolName)))return xut(t.result)},tvn=e=>{if(!(!Hh(e)||typeof e.type!="string"||!e.type.startsWith("data-")))return Rbe(e.data)},nvn=e=>{if(e.role!=="signal")return;const t=e.content?.metadata;if(Hh(t))return Rbe(t.signal)},rvn=e=>{let t;for(const n of e){for(const s of n.content?.parts??[]){const a=evn(s);a!==void 0&&(t=a)}const r=nvn(n);r!==void 0&&(t=r);for(const s of n.content?.parts??[]){const a=tvn(s);a!==void 0&&(t=a)}}return t??[]},hz=e=>e!==null&&typeof e=="object",svn=["pendingToolApprovals","requireApprovalMetadata","suspendedTools"],avn=e=>hz(e)&&Object.values(e).every(t=>hz(t)),ivn=e=>{if(!hz(e))return[];const t=[];for(const n of svn){const r=e[n];avn(r)&&t.push(r)}return t},ovn=e=>{for(const t of e)for(const n of ivn(t.content?.metadata))for(const r of Object.values(n))if(hz(r)&&typeof r.runId=="string"&&r.runId.length>0)return r.runId};function lvn(e){if(typeof e=="string")return e;const t=e instanceof ArrayBuffer?new Uint8Array(e):e;let n="";for(const r of t)n+=String.fromCharCode(r);return btoa(n)}var cvn=e=>{const t=new Set;for(const n of e){const r=n.content?.metadata;if(!r)continue;const s=[r.pendingToolApprovals,r.requireApprovalMetadata,r.suspendedTools];for(const a of s)if(!(!a||typeof a!="object"))for(const i of Object.values(a)){const l=i?.toolCallId;typeof l=="string"&&l.length>0&&t.add(l)}}return t},uvn=(e,t)=>e.some(n=>{if(n.type!=="tool-invocation")return!1;const r=n.toolInvocation;return r.toolCallId!==t?!1:r.state==="result"||r.result!=null}),dvn=e=>e.filter(t=>{const n=t.content?.metadata;return!(n?.completionResult?.suppressFeedback||n?.isTaskCompleteResult?.suppressFeedback)}).map(t=>{const n=t.content?.metadata,r=n&&(n.status==="pending"||tx in n)?(()=>{const{[tx]:d,...f}=n,{status:p,...h}=f;return{...t,content:{...t.content,metadata:n.status==="pending"?h:f}}})():t,s=r.content?.metadata,a=s?.pendingToolApprovals;if(!a||typeof a!="object")return r;const i=Object.fromEntries(Object.entries(a).filter(([,d])=>d&&typeof d=="object"&&typeof d.toolCallId=="string"&&!uvn(r.content.parts,d.toolCallId))),{pendingToolApprovals:l,...c}=s,u=Object.keys(i).length>0;return{...r,content:{...r.content,metadata:{...c,mode:"stream",...u?{pendingToolApprovals:i,requireApprovalMetadata:i}:{}}}}}),wut=e=>typeof e=="object"&&e!==null,fvn=e=>wut(e)&&typeof e.name=="string"?e.name:void 0,pX=e=>fvn(e)==="AbortError",hX=e=>{if(!wut(e))return!1;const t=e.status;return t===404||t===405||t===501?!0:t===400&&typeof e.message=="string"&&e.message.includes("No active agent run found for signal target")},pvn=e=>typeof e.type=="string"&&e.type.startsWith("data-"),wL=(e,t)=>e.map(n=>{const r=Av.fromUIMessage(n);return{...r,content:{...r.content,metadata:{...r.content.metadata??{},...t}}}}),Pbe=({agentId:e,resourceId:t,threadId:n,initialMessages:r,requestContext:s,clientTools:a,onSignalSent:i,onSignalEcho:l,onThreadSignalsUnsupported:c,enableThreadSignals:u=!1})=>{const d=u===!1,f=g.useRef(void 0),p=g.useRef(void 0),h=g.useRef(void 0),m=g.useRef(void 0),v=g.useRef(s),y=g.useRef(null),b=g.useRef(null),S=g.useRef(null),w=g.useRef(void 0),k=g.useRef(null),_=g.useRef(!1),[C,E]=g.useState([]),[j,N]=g.useState([]),[I,R]=g.useState({}),[P,L]=g.useState({}),M=g.useRef(new Set),[q,H]=g.useState(!1),F=We(),[z,B]=g.useState(!1);g.useEffect(()=>{const ye=dvn(r??[]);E(ye),N(rvn(ye)),M.current=cvn(ye),H(M.current.size>0),f.current=ovn(ye)},[r]),g.useEffect(()=>{v.current=s},[s]);const D=ye=>ye instanceof URL?ye.toString():lvn(ye),Q=ye=>{const Se=ye.reduce((Ne,ke)=>{if(typeof ke.content=="string")return Ne.push({type:"text",text:ke.content}),Ne;for(const Ie of ke.content)Ie.type==="text"?Ne.push({type:"text",text:Ie.text}):Ie.type==="file"?Ne.push({type:"file",data:D(Ie.data),mediaType:Ie.mimeType,...Ie.filename?{filename:Ie.filename}:{}}):Ie.type==="image"&&Ne.push({type:"file",data:D(Ie.image),mediaType:Ie.mimeType??"image/png"});return Ne},[]);return Se.length===1&&Se[0]?.type==="text"?Se[0].text:Se},V=g.useCallback(()=>{_.current=!0,c?.()},[c]),$=ye=>ye.flatMap(Ne=>typeof Ne.content=="string"?[Ne.content]:Ne.content.map(ke=>ke.type==="text"?ke.text:ke.type==="image"?"Image":ke.filename?`File: ${ke.filename}`:"File")).join(" ").replace(/\s+/g," ").trim()||"Attachment",U=g.useCallback(()=>{const ye=S.current;ye?.unsubscribe?ye.unsubscribe():b.current?.abort(),S.current=null,b.current=null,w.current=void 0,k.current=null},[]),Z=g.useCallback(async(ye,Se)=>{E(Ie=>Mgn({chunk:ye,conversation:Ie,metadata:{mode:"stream"}}));const Ne=Kgn(ye);Ne!==void 0&&N(Ne);const ke=Jgn(ye);if(ke!==void 0&&N(ke),ye.type==="data-user-message"&&pvn(ye)&&(ye.data?.type==="user-message"||ye.data?.type==="user")&&typeof ye.data?.id=="string"&&l?.(ye.data.id),ye.type==="start"&&(B(!0),"runId"in ye&&typeof ye.runId=="string"&&(f.current=ye.runId)),ye.type==="tool-call-approval"||ye.type==="tool-call-suspended"){const Ie=ye.payload?.toolCallId;typeof Ie=="string"&&(M.current.add(Ie),H(!0)),B(!1)}(ye.type==="finish"||ye.type==="abort"||ye.type==="error")&&(M.current.clear(),H(!1),B(!1)),(Se??p.current)?.(ye)},[l]),X=g.useCallback(async({threadId:ye,resourceId:Se})=>{const Ne=`${e}:${Se??""}:${ye}`;if(w.current===Ne&&k.current){await k.current;return}U();const ke=new AbortController;b.current=ke,w.current=Ne;const ze=new VR({...F.options,abortSignal:ke.signal}).getAgent(e);k.current=ze.subscribeToThread({resourceId:Se,threadId:ye}).then(oe=>{const se=oe;if(b.current!==ke){se.unsubscribe();return}S.current=se,se.processDataStream({onChunk:re=>Z(re)}).catch(re=>{pX(re)||(console.error("[useChat] Thread subscription failed",re),B(!1))}).finally(()=>{S.current===se&&(S.current=null),b.current===ke&&(b.current=null,w.current=void 0,k.current=null)})}).catch(oe=>{if(hX(oe)){V(),b.current===ke&&(S.current=null,b.current=null,w.current=void 0,k.current=null);return}throw pX(oe)||(console.error("[useChat] Thread subscription failed",oe),B(!1)),oe}),await k.current},[e,F,U,V,Z]);g.useEffect(()=>(_.current=!1,U),[e,t,n,U]),g.useEffect(()=>{if(!n||d){U();return}X({threadId:n,resourceId:t||e}).catch(ye=>{pX(ye)||console.error("[useChat] Thread subscription failed",ye)})},[e,U,X,t,n,d]);const te=async({coreUserMessages:ye,requestContext:Se,threadId:Ne,modelSettings:ke,signal:Ie,onFinish:ze,tracingOptions:oe,clientTools:se})=>{const{frequencyPenalty:re,presencePenalty:he,maxRetries:xe,maxTokens:je,temperature:Pe,topK:Ge,topP:Ze,instructions:Ee,providerOptions:_e,maxSteps:Ce,requireToolApproval:Oe}=ke||{},Re=Se??s,qe=se??a;v.current=Re,B(!0);const tt=new VR({...F.options,abortSignal:Ie}).getAgent(e),At=fo();f.current=At;const ot=await tt.generate(ye,{runId:At,maxSteps:Ce,modelSettings:{frequencyPenalty:re,presencePenalty:he,maxRetries:xe,maxOutputTokens:je,temperature:Pe,topK:Ge,topP:Ze},instructions:Ee,requestContext:Re,...Ne?{memory:{thread:Ne,resource:t||e}}:{},providerOptions:_e,tracingOptions:oe,requireToolApproval:Oe,clientTools:qe});if(ot.finishReason==="suspended"&&ot.suspendPayload){const{toolCallId:zt,toolName:mt,args:Pt}=ot.suspendPayload;if(ot.response?.uiMessages){const tn=wL(ot.response.uiMessages,{mode:"generate",requireApprovalMetadata:{[mt]:{toolCallId:zt,toolName:mt,args:Pt}}});E(Qe=>[...Qe,...tn])}B(!1);return}if(B(!1),ot&&"uiMessages"in ot.response&&ot.response.uiMessages){const zt=wL(ot.response.uiMessages,{mode:"generate"});ze?.(zt),E(mt=>[...mt,...zt])}},J=async({coreUserMessages:ye,requestContext:Se,threadId:Ne,onChunk:ke,modelSettings:Ie,signal:ze,tracingOptions:oe,clientTools:se,signalId:re,clientMessageId:he})=>{const{frequencyPenalty:xe,presencePenalty:je,maxRetries:Pe,maxTokens:Ge,temperature:Ze,topK:Ee,topP:_e,instructions:Ce,providerOptions:Oe,maxSteps:Re,requireToolApproval:qe}=Ie||{},Ye=Se??s,tt=se??a,At={maxSteps:Re,modelSettings:{frequencyPenalty:xe,presencePenalty:je,maxRetries:Pe,maxOutputTokens:Ge,temperature:Ze,topK:Ee,topP:_e},instructions:Ce,providerOptions:Oe,requireToolApproval:qe,tracingOptions:oe};v.current=Ye,B(!0),y.current?.abort();const ot=new AbortController;y.current=ot,ze&&(ze.aborted?ot.abort():ze.addEventListener("abort",()=>ot.abort(),{once:!0}));const mt=new VR({...F.options,abortSignal:ot.signal}).getAgent(e),Pt=async()=>{const it=fo(),Xt=await mt.stream(ye,{runId:it,maxSteps:Re,untilIdle:!0,modelSettings:{frequencyPenalty:xe,presencePenalty:je,maxRetries:Pe,maxOutputTokens:Ge,temperature:Ze,topK:Ee,topP:_e},instructions:Ce,requestContext:Ye,...Ne?{memory:{thread:Ne,resource:t||e}}:{},providerOptions:Oe,requireToolApproval:qe,tracingOptions:oe,clientTools:tt});p.current=ke,f.current=it,await Xt.processDataStream({onChunk:Zt=>Z(Zt,ke)}),y.current===ot&&(y.current=null),B(!1)};if(!Ne||_.current||d){await Pt();return}if(p.current=ke,await X({threadId:Ne,resourceId:t||e}),_.current){await Pt();return}const tn=re??fo(),Qe=Q(ye),lt={maxSteps:Re,modelSettings:{frequencyPenalty:xe,presencePenalty:je,maxRetries:Pe,maxOutputTokens:Ge,temperature:Ze,topK:Ee,topP:_e},instructions:Ce,requestContext:Ye,providerOptions:Oe,requireToolApproval:qe,tracingOptions:oe};try{const it=await mt.sendMessage({message:he?{contents:Qe,metadata:{[tx]:he}}:Qe,resourceId:t||e,threadId:Ne,ifIdle:{streamOptions:{...At,requestContext:Ye,clientTools:tt}}}),Xt=it.signal&&typeof it.signal=="object"&&"id"in it.signal&&typeof it.signal.id=="string"?it.signal.id:tn;i?.(Xt,$(ye)),M.current.size>0&&B(!1)}catch(it){if(hX(it)){i?.(tn,$(ye));try{await mt.sendSignal({signal:{id:tn,type:"user-message",contents:Qe},resourceId:t||e,threadId:Ne,ifIdle:{streamOptions:lt}});return}catch(Xt){if(l?.(tn),hX(Xt)){V(),E(Zt=>[...Zt,eDe(ye)]),await Pt();return}throw Xt}}throw it}y.current===ot&&(y.current=null)},ee=async({coreUserMessages:ye,requestContext:Se,threadId:Ne,onNetworkChunk:ke,modelSettings:Ie,signal:ze,tracingOptions:oe})=>{const{frequencyPenalty:se,presencePenalty:re,maxRetries:he,maxTokens:xe,temperature:je,topK:Pe,topP:Ge,maxSteps:Ze}=Ie||{},Ee=Se??s;v.current=Ee,B(!0);const Ce=new VR({...F.options,abortSignal:ze}).getAgent(e),Oe=fo(),Re=await Ce.network(ye,{maxSteps:Ze,modelSettings:{frequencyPenalty:se,presencePenalty:re,maxRetries:he,maxOutputTokens:xe,temperature:je,topK:Pe,topP:Ge},runId:Oe,requestContext:Ee,...Ne?{memory:{thread:Ne,resource:t||e}}:{},tracingOptions:oe});m.current=ke,h.current=Oe,await Re.processDataStream({onChunk:async qe=>{E(Ye=>fX({chunk:qe,conversation:Ye,metadata:{mode:"network"}})),ke?.(qe)}}),E(qe=>uw(qe)),B(!1)};return{setMessages:E,sendMessage:async({mode:ye="stream",...Se})=>{const ke=[{role:"user",content:[{type:"text",text:Se.message}]}];Se.coreUserMessages&&ke.push(...Se.coreUserMessages);const Ie=eDe(ke),ze=ye==="stream"&&Se.threadId&&!_.current&&!d?`client-set-${fo()}`:void 0,oe=ze,se=ze;if(oe){const re={...Ie.content.metadata,mode:"stream",status:"pending",[tx]:se},he={...Ie,id:ze,content:{...Ie.content,metadata:re}};E(xe=>[...xe,he])}else E(re=>[...re,Ie]);ye==="generate"?await te({...Se,coreUserMessages:ke}):ye==="stream"?await J({...Se,coreUserMessages:ke,signalId:oe,clientMessageId:se}):ye==="network"&&await ee({...Se,coreUserMessages:ke})},isRunning:z,isAwaitingToolApproval:q,messages:C,tasks:j,approveToolCall:async(ye,Se)=>{const Ne=p.current,ke=f.current;if(!ke)return console.info("[approveToolCall] approveToolCall can only be called after a stream has started");B(!0),R(oe=>({...oe,[ye]:{status:"approved"}}));const Ie=F.getAgent(e);if(w.current&&n){try{await Ie.sendToolApproval({resourceId:t||e,threadId:n,toolCallId:ye,approved:!0,...Se!==void 0?{resumeData:Se}:{},requestContext:v.current}),M.current.delete(ye),H(M.current.size>0),B(!1)}catch(oe){throw R(se=>{const re={...se};return delete re[ye],re}),B(!1),oe}return}await(await Ie.approveToolCall({runId:ke,toolCallId:ye,requestContext:v.current})).processDataStream({onChunk:async oe=>{await Z(oe,Ne)}}),B(!1)},declineToolCall:async ye=>{const Se=p.current,Ne=f.current;if(!Ne)return console.info("[declineToolCall] declineToolCall can only be called after a stream has started");B(!0),R(ze=>({...ze,[ye]:{status:"declined"}}));const ke=F.getAgent(e);if(w.current&&n){try{await ke.sendToolApproval({resourceId:t||e,threadId:n,toolCallId:ye,approved:!1,requestContext:v.current}),M.current.delete(ye),H(M.current.size>0),B(!1)}catch(ze){throw R(oe=>{const se={...oe};return delete se[ye],se}),B(!1),ze}return}await(await ke.declineToolCall({runId:Ne,toolCallId:ye,requestContext:v.current})).processDataStream({onChunk:async ze=>{await Z(ze,Se)}}),B(!1)},approveToolCallGenerate:async ye=>{const Se=f.current;if(!Se)return console.info("[approveToolCallGenerate] approveToolCallGenerate can only be called after a generate has started");B(!0),R(Ie=>({...Ie,[ye]:{status:"approved"}}));const ke=await F.getAgent(e).approveToolCallGenerate({runId:Se,toolCallId:ye,requestContext:v.current});if(ke&&"uiMessages"in ke.response&&ke.response.uiMessages){const Ie=wL(ke.response.uiMessages,{mode:"generate"});E(ze=>[...ze,...Ie])}B(!1)},declineToolCallGenerate:async ye=>{const Se=f.current;if(!Se)return console.info("[declineToolCallGenerate] declineToolCallGenerate can only be called after a generate has started");B(!0),R(Ie=>({...Ie,[ye]:{status:"declined"}}));const ke=await F.getAgent(e).declineToolCallGenerate({runId:Se,toolCallId:ye,requestContext:v.current});if(ke&&"uiMessages"in ke.response&&ke.response.uiMessages){const Ie=wL(ke.response.uiMessages,{mode:"generate"});E(ze=>[...ze,...Ie])}B(!1)},cancelRun:()=>{y.current?.abort(),y.current=null;const ye=S.current;Promise.resolve(ye?.abort?.()).catch(Se=>{console.error("[useChat] Failed to abort thread subscription",Se)}),U(),E(Se=>uw(Se)),M.current.clear(),H(!1),B(!1),f.current=void 0,p.current=void 0,h.current=void 0,m.current=void 0,v.current=void 0},toolCallApprovals:I,approveNetworkToolCall:async(ye,Se)=>{const Ne=m.current,ke=Se||h.current;if(!ke)return console.info("[approveNetworkToolCall] approveNetworkToolCall can only be called after a network stream has started");B(!0),L(oe=>({...oe,[Se?`${Se}-${ye}`:ye]:{status:"approved"}})),await(await F.getAgent(e).approveNetworkToolCall({runId:ke,requestContext:v.current})).processDataStream({onChunk:async oe=>{E(se=>fX({chunk:oe,conversation:se,metadata:{mode:"network"}})),Ne?.(oe)}}),E(oe=>uw(oe)),B(!1)},declineNetworkToolCall:async(ye,Se)=>{const Ne=m.current,ke=Se||h.current;if(!ke)return console.info("[declineNetworkToolCall] declineNetworkToolCall can only be called after a network stream has started");B(!0),L(oe=>({...oe,[Se?`${Se}-${ye}`:ye]:{status:"declined"}})),await(await F.getAgent(e).declineNetworkToolCall({runId:ke,requestContext:v.current})).processDataStream({onChunk:async oe=>{E(se=>fX({chunk:oe,conversation:se,metadata:{mode:"network"}})),Ne?.(oe)}}),E(oe=>uw(oe)),B(!1)},networkToolCallApprovals:P}},hvn=g.createContext({expanded:!1,setExpanded:()=>{},variant:"initial",disabled:!1});hvn.Provider;m_("mastra:aria-disabled:cursor-not-allowed mastra:aria-disabled:bg-surface5 mastra:aria-disabled:text-text3","mastra:aria-expanded:rounded-b-none mastra:aria-expanded:border-b-0","mastra:bg-surface3 mastra:text-text6 mastra:hover:bg-surface4 mastra:active:bg-surface5","mastra:rounded-lg mastra:py-2 mastra:px-4 mastra:border mastra:border-border1","mastra:cursor-pointer mastra:inline-flex mastra:items-center mastra:gap-1 mastra:font-mono");m_("mastra:space-y-4","mastra:rounded-lg mastra:rounded-tl-none mastra:p-4 mastra:border mastra:border-border1 mastra:-mt-[0.5px]","mastra:bg-surface3 mastra:text-text6");m_("mastra:rounded-lg mastra:border mastra:border-border1 mastra:max-w-1/2 mastra:mt-2","mastra:bg-surface3 mastra:text-text6");m_("mastra:text-text6 mastra:inline-flex mastra:items-center mastra:gap-1");m_("mastra:flex mastra:justify-between mastra:items-center mastra:gap-2","mastra:border-b mastra:border-border1 mastra:px-4 mastra:py-2");m_("mastra:text-text6 mastra:p-4");m_("mastra:flex mastra:gap-2 mastra:items-center");var Sut=e=>e.type==="dynamic-tool"||e.type.startsWith("tool-")&&e.type!=="tool-invocation",mvn=e=>e.type.startsWith("data-"),gvn=e=>({type:"source-url",sourceId:e.source.id,url:e.source.url,title:e.source.title,providerMetadata:e.providerMetadata}),vvn=(e,t)=>{if(Sut(e))return e.toolCallId??`${e.type}-${t}`;switch(e.type){case"text":return e.textId??`text-${t}`;case"reasoning":return e.reasoningId??`reasoning-${t}`;case"tool-invocation":return e.toolInvocation.toolCallId??`tool-invocation-${t}`;case"source-url":return e.sourceId||`source-url-${t}`;case"source":return e.source.id??`source-${t}`}return e.id??`${e.type}-${t}`},yvn=(e,t,n)=>{if(Sut(e))return t.DynamicTool?.(e)??n?.(e)??null;if(mvn(e))return t.Data?.(e)??n?.(e)??null;switch(e.type){case"text":return t.Text?.(e)??n?.(e)??null;case"reasoning":return t.Reasoning?.(e)??n?.(e)??null;case"file":return t.File?.(e)??n?.(e)??null;case"step-start":return t.StepStart?.(e)??null;case"tool-invocation":return t.ToolInvocation?.(e)??n?.(e)??null;case"source":return t.SourceUrl?.(gvn(e))??n?.(e)??null;case"source-url":return t.SourceUrl?.(e)??n?.(e)??null;case"source-document":return t.SourceDocument?.(e)??n?.(e)??null;default:return n?.(e)??null}},kut=g.memo(({part:e,renderers:t,fallback:n})=>o.jsx(o.Fragment,{children:yvn(e,t,n)}));kut.displayName="PartRenderer";var NA=e=>e.filter(t=>t.type==="text").map(t=>t.text).join(""),bvn=e=>{const t=e?.completionResult??e?.isTaskCompleteResult;if(t)return{passed:!!t.passed,suppressFeedback:t.suppressFeedback}},xvn=(e,t)=>{switch(e){case"user":return t?.User;case"assistant":return t?.Assistant;case"system":return t?.System;case"signal":return t?.Signal;default:return}},wvn=({message:e,roles:t,status:n,fallback:r,...s})=>{const a=e.content.parts??[],i=e.content.metadata;let l;if(i?.status==="tripwire"&&n?.Tripwire)l=n.Tripwire({text:NA(a),tripwire:i.tripwire,message:e});else if(i?.status==="warning"&&n?.Warning)l=n.Warning({text:NA(a),message:e});else if(i?.status==="error"&&n?.Error)l=n.Error({text:NA(a),message:e});else{l=o.jsx(o.Fragment,{children:a.map((d,f)=>o.jsx(kut,{part:d,renderers:s,fallback:r},vvn(d,f)))}),i?.status==="pending"&&n?.Pending&&(l=n.Pending({children:l,text:NA(a),message:e}));const u=bvn(i);u&&n?.Task&&(l=o.jsxs(o.Fragment,{children:[l,n.Task({...u,text:NA(a),message:e})]}))}const c=xvn(e.role,t);return c?o.jsx(o.Fragment,{children:c({message:e,children:l})}):o.jsx(o.Fragment,{children:l})},mz=g.memo(wvn);mz.displayName="MessageFactory";function PE(e){const[t,n]=g.useState(!1),[r,s]=g.useState(!1),[a,i]=g.useState(!1),[l,c]=g.useState(null),[u,d]=g.useState(void 0),f=g.useRef(e);f.current=e;const p=g.useCallback(()=>{n(!1),s(!1),i(!1),c(null),d(void 0)},[]),h=g.useCallback(async v=>{n(!0),s(!1),i(!1),c(null);try{const y=await f.current(v);return d(y),s(!0),y}catch(y){throw c(y),i(!0),y}finally{n(!1)}},[]);return{mutate:g.useCallback(v=>{h(v).catch(()=>{})},[h]),mutateAsync:h,isPending:t,isSuccess:r,isError:a,error:l,data:u,reset:p}}function Svn({debugMode:e,tracingOptions:t,onError:n}){const r=We(),[s,a]=g.useState({}),[i,l]=g.useState(!1),c=g.useRef(null),u=g.useRef(null),d=g.useRef(null),f=g.useRef(null),p=g.useRef(!0);g.useEffect(()=>(p.current=!0,()=>{if(p.current=!1,c.current){try{c.current.releaseLock()}catch{}c.current=null}if(u.current){try{u.current.releaseLock()}catch{}u.current=null}if(d.current){try{d.current.releaseLock()}catch{}d.current=null}if(f.current){try{f.current.releaseLock()}catch{}f.current=null}}),[]);const h=g.useCallback((k,_,C)=>{if(k instanceof TypeError)return;const E=k instanceof Error?k:new Error(_);n?.(E,_),C?.(!1)},[n]),m=g.useCallback(k=>{if(k.type==="workflow-finish"){const _=k.payload?.workflowStatus,C=k.payload?.metadata;if(a(E=>({...E,status:_})),_==="failed")throw new Error(C?.errorMessage||"Workflow execution failed")}},[]),v=PE(async({workflowId:k,runId:_,inputData:C,initialState:E,requestContext:j,perStep:N})=>{if(c.current&&c.current.releaseLock(),!p.current)return;l(!0),a({input:C});const P=await(await r.getWorkflow(k).createRun({runId:_})).stream({inputData:C,initialState:E,requestContext:j,closeOnSuspend:!0,tracingOptions:t,perStep:N??e});if(!P)return h(new Error("No stream returned"),"No stream returned",l);const L=P.getReader();c.current=L;try{for(;p.current;){const{done:M,value:q}=await L.read();if(M)break;p.current&&(a(H=>dw(H,q)),q.type==="workflow-step-start"&&l(!0),q.type==="workflow-step-suspended"&&l(!1),q.type==="workflow-finish"&&m(q))}}catch(M){h(M,"Error streaming workflow")}finally{p.current&&l(!1),c.current&&(c.current.releaseLock(),c.current=null)}}),y=PE(async({workflowId:k,runId:_,storeRunResult:C})=>{if(u.current&&u.current.releaseLock(),!p.current)return;if(l(!0),a(C||{}),C?.status==="suspended"){l(!1);return}const N=await(await r.getWorkflow(k).createRun({runId:_})).observeStream();if(!N)return h(new Error("No stream returned"),"No stream returned",l);const I=N.getReader();u.current=I;try{for(;p.current;){const{done:R,value:P}=await I.read();if(R)break;p.current&&(a(L=>dw(L,P)),P.type==="workflow-step-start"&&l(!0),P.type==="workflow-step-suspended"&&l(!1),P.type==="workflow-finish"&&m(P))}}catch(R){h(R,"Error observing workflow")}finally{p.current&&l(!1),u.current&&(u.current.releaseLock(),u.current=null)}}),b=PE(async({workflowId:k,runId:_,step:C,resumeData:E,requestContext:j,perStep:N})=>{if(d.current&&d.current.releaseLock(),!p.current)return;l(!0);const P=await(await r.getWorkflow(k).createRun({runId:_})).resumeStream({step:C,resumeData:E,requestContext:j,tracingOptions:t,perStep:N??e});if(!P)return h(new Error("No stream returned"),"No stream returned",l);const L=P.getReader();d.current=L;try{for(;p.current;){const{done:M,value:q}=await L.read();if(M)break;p.current&&(a(H=>dw(H,q)),q.type==="workflow-step-start"&&l(!0),q.type==="workflow-step-suspended"&&l(!1),q.type==="workflow-finish"&&m(q))}}catch(M){h(M,"Error resuming workflow stream")}finally{p.current&&l(!1),d.current&&(d.current.releaseLock(),d.current=null)}}),S=PE(async({workflowId:k,requestContext:_,runId:C,perStep:E,...j})=>{if(f.current&&f.current.releaseLock(),!p.current)return;l(!0);const R=await(await r.getWorkflow(k).createRun({runId:C})).timeTravelStream({...j,perStep:E??e,requestContext:_,tracingOptions:t});if(!R)return h(new Error("No stream returned"),"No stream returned",l);const P=R.getReader();f.current=P;try{for(;p.current;){const{done:L,value:M}=await P.read();if(L)break;p.current&&(a(q=>dw(q,M)),M.type==="workflow-step-start"&&l(!0),M.type==="workflow-step-suspended"&&l(!1),M.type==="workflow-finish"&&m(M))}}catch(L){h(L,"Error time traveling workflow stream")}finally{p.current&&l(!1),f.current&&(f.current.releaseLock(),f.current=null)}}),w=g.useCallback(()=>{if(l(!1),a({}),c.current){try{c.current.releaseLock()}catch{}c.current=null}if(u.current){try{u.current.releaseLock()}catch{}u.current=null}if(d.current){try{d.current.releaseLock()}catch{}d.current=null}if(f.current){try{f.current.releaseLock()}catch{}f.current=null}},[]);return{streamWorkflow:v,streamResult:s,isStreaming:i,observeWorkflowStream:y,closeStreamsAndReset:w,resumeWorkflowStream:b,timeTravelWorkflowStream:S}}function kvn(){const e=We();return PE(async({workflowId:t,prevRunId:n})=>{try{const r=e.getWorkflow(t),{runId:s}=await r.createRun({runId:n});return{runId:s}}catch(r){throw console.error("Error creating workflow run:",r),r}})}function Ovn(){const e=We();return PE(async({workflowId:t,runId:n})=>{try{return(await e.getWorkflow(t).createRun({runId:n})).cancelRun()}catch(r){throw console.error("Error canceling workflow run:",r),r}})}var nv=(e,t)=>t?.(e)??null,_vn=({step:e,Step:t,MapStep:n,ForEachStep:r,ParallelStep:s,Conditional:a,LoopStep:i,SleepStep:l,SleepUntilStep:c,NestedWorkflowStep:u,UnknownStep:d})=>{switch(e.kind){case"step":return o.jsx(o.Fragment,{children:t?.(e)??nv(e,d)});case"map-step":return o.jsx(o.Fragment,{children:n?.(e)??nv(e,d)});case"foreach-step":return o.jsx(o.Fragment,{children:r?.(e)??nv(e,d)});case"parallel-step":return o.jsx(o.Fragment,{children:s?.(e)??nv(e,d)});case"conditional":return o.jsx(o.Fragment,{children:a?.(e)??nv(e,d)});case"loop-step":return o.jsx(o.Fragment,{children:i?.(e)??nv(e,d)});case"sleep-step":return o.jsx(o.Fragment,{children:l?.(e)??nv(e,d)});case"sleep-until-step":return o.jsx(o.Fragment,{children:c?.(e)??nv(e,d)});case"nested-workflow-step":return o.jsx(o.Fragment,{children:u?.(e)??nv(e,d)});default:return o.jsx(o.Fragment,{children:nv(e,d)})}};g.memo(_vn);async function Cvn(e){const t=await navigator.mediaDevices.getUserMedia({audio:!0}),n=new MediaRecorder(t);let r=[];return n.ondataavailable=s=>{r.push(s.data)},n.onstop=()=>{const s=new Blob(r,{type:"audio/webm"}),a=new File([s],`recording-${Date.now()}.webm`,{type:"audio/webm",lastModified:Date.now()});t.getTracks().forEach(i=>i.stop()),e(a)},n}async function Evn(e,t){const n=new window.AudioContext,r=e.getReader(),s=[];try{for(;;){const{done:d,value:f}=await r.read();if(d)break;s.push(f)}const a=s.reduce((d,f)=>d+f.length,0),i=new Uint8Array(a);let l=0;for(const d of s)i.set(d,l),l+=d.length;const c=await n.decodeAudioData(i.buffer),u=n.createBufferSource();return u.buffer=c,u.onended=t??null,u.connect(n.destination),u.start(),()=>{u.onended=null,u.stop(),n.close()}}catch(a){throw await r.cancel().catch(()=>{}),await n.close().catch(()=>{}),a}finally{r.releaseLock()}}var jvn=({language:e="en-US",agentId:t,requestContext:n})=>{const r=We(),[s,a]=g.useState(null);g.useEffect(()=>{let c=!1;if(!t)return a(null),()=>{c=!0};const u=r.getAgent(t);return(async()=>{try{const f=await u.voice.getSpeakers(n);c||a(f.length>0?u:null)}catch{c||a(null)}})(),()=>{c=!0}},[t,r,n]);const i=Tvn({language:e}),l=Nvn({agent:s,language:e});return s?l:i},Tvn=({language:e="en-US"})=>{const t=g.useRef(null),[n,r]=g.useState({isListening:!1,transcript:"",error:null}),s=()=>{t.current&&t.current.start()},a=()=>{t.current&&t.current.stop()};return g.useEffect(()=>{if(!("webkitSpeechRecognition"in window)&&!("SpeechRecognition"in window)){r(c=>({...c,error:"Speech Recognition not supported in this browser"}));return}const i=window.SpeechRecognition||window.webkitSpeechRecognition,l=new i;return t.current=l,l.continuous=!0,l.lang=e,l.onstart=()=>{r(c=>({...c,isListening:!0,error:null}))},l.onresult=c=>{let u="";for(let d=c.resultIndex;d<c.results.length;d++){const f=c.results[d][0].transcript;c.results[d].isFinal&&(u+=f+" ")}r(d=>({...d,transcript:u}))},l.onerror=c=>{r(u=>({...u,error:`Error: ${c.error}`}))},l.onend=()=>r(c=>({...c,isListening:!1})),()=>{try{l.stop()}catch{}l.onstart=null,l.onresult=null,l.onerror=null,l.onend=null,t.current=null}},[e]),{...n,start:s,stop:a}},Nvn=({agent:e,language:t})=>{const[n,r]=g.useState({isListening:!1,transcript:"",error:null}),s=g.useRef(null),a=g.useRef(0),i=g.useRef(!1);g.useEffect(()=>()=>{a.current+=1,i.current=!1,s.current?.stop(),s.current=null},[e]);const l=d=>f=>{!e||d!==a.current||(s.current=null,r(p=>({...p,isListening:!1})),e.voice.listen(f,{language:t}).then(p=>{d===a.current&&r(h=>({...h,transcript:p.text,error:null}))}).catch(p=>{if(d!==a.current)return;const h=p instanceof Error?p.message:"Failed to transcribe speech";r(m=>({...m,error:h}))}))};return{...n,start:()=>{if(!e||i.current||s.current)return;i.current=!0;const d=a.current;Cvn(l(d)).then(f=>{if(i.current=!1,d!==a.current){try{f.stop()}catch{}return}s.current=f,r(p=>({...p,isListening:!0,error:null})),f.start()}).catch(f=>{if(i.current=!1,d!==a.current)return;const p=f instanceof Error?f.message:"Failed to start speech recording";r(h=>({...h,isListening:!1,error:p}))})},stop:()=>{a.current+=1,i.current=!1,s.current?.stop(),s.current=null,r(d=>({...d,isListening:!1}))}}};var Out=e=>{throw TypeError(e)},_ut=(e,t,n)=>t.has(e)||Out("Cannot "+n),kh=(e,t,n)=>(_ut(e,t,"read from private field"),n?n.call(e):t.get(e)),QR=(e,t,n)=>t.has(e)?Out("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),rv=(e,t,n,r)=>(_ut(e,t,"write to private field"),t.set(e,n),n),tDe="popstate";function nDe(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Ivn(e={}){function t(r,s){let a=s.state?.masked,{pathname:i,search:l,hash:c}=a||r.location;return GP("",{pathname:i,search:l,hash:c},s.state&&s.state.usr||null,s.state&&s.state.key||"default",a?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,s){return typeof s=="string"?s:cy(s)}return Rvn(t,n,null,e)}function os(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Jo(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Avn(){return Math.random().toString(36).substring(2,10)}function rDe(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function GP(e,t,n=null,r,s){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?_y(t):t,state:n,key:t&&t.key||r||Avn(),mask:s}}function cy({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function _y(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Rvn(e,t,n,r={}){let{window:s=document.defaultView,v5Compat:a=!1}=r,i=s.history,l="POP",c=null,u=d();u==null&&(u=0,i.replaceState({...i.state,idx:u},""));function d(){return(i.state||{idx:null}).idx}function f(){l="POP";let y=d(),b=y==null?null:y-u;u=y,c&&c({action:l,location:v.location,delta:b})}function p(y,b){l="PUSH";let S=nDe(y)?y:GP(v.location,y,b);u=d()+1;let w=rDe(S,u),k=v.createHref(S.mask||S);try{i.pushState(w,"",k)}catch(_){if(_ instanceof DOMException&&_.name==="DataCloneError")throw _;s.location.assign(k)}a&&c&&c({action:l,location:v.location,delta:1})}function h(y,b){l="REPLACE";let S=nDe(y)?y:GP(v.location,y,b);u=d();let w=rDe(S,u),k=v.createHref(S.mask||S);i.replaceState(w,"",k),a&&c&&c({action:l,location:v.location,delta:0})}function m(y){return Cut(y)}let v={get action(){return l},get location(){return e(s,i)},listen(y){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(tDe,f),c=y,()=>{s.removeEventListener(tDe,f),c=null}},createHref(y){return t(s,y)},createURL:m,encodeLocation(y){let b=m(y);return{pathname:b.pathname,search:b.search,hash:b.hash}},push:p,replace:h,go(y){return i.go(y)}};return v}function Cut(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),os(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:cy(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}var YR,sDe=class{constructor(e){if(QR(this,YR,new Map),e)for(let[t,n]of e)this.set(t,n)}get(e){if(kh(this,YR).has(e))return kh(this,YR).get(e);if(e.defaultValue!==void 0)return e.defaultValue;throw new Error("No value found for context")}set(e,t){kh(this,YR).set(e,t)}};YR=new WeakMap;var Pvn=new Set(["lazy","caseSensitive","path","id","index","children"]);function $vn(e){return Pvn.has(e)}var Mvn=new Set(["lazy","caseSensitive","path","id","index","middleware","children"]);function Dvn(e){return Mvn.has(e)}function Lvn(e){return e.index===!0}function QP(e,t,n=[],r={},s=!1){return e.map((a,i)=>{let l=[...n,String(i)],c=typeof a.id=="string"?a.id:l.join("-");if(os(a.index!==!0||!a.children,"Cannot specify children on an index route"),os(s||!r[c],`Found a route id collision on id "${c}". Route id's must be globally unique within Data Router usages`),Lvn(a)){let u={...a,id:c};return r[c]=aDe(u,t(u)),u}else{let u={...a,id:c,children:void 0};return r[c]=aDe(u,t(u)),a.children&&(u.children=QP(a.children,t,l,r,s)),u}})}function aDe(e,t){return Object.assign(e,{...t,...typeof t.lazy=="object"&&t.lazy!=null?{lazy:{...e.lazy,...t.lazy}}:{}})}function Eut(e,t,n="/"){return Qm(e,t,n,!1)}function Qm(e,t,n,r,s){let a=typeof t=="string"?_y(t):t,i=sm(a.pathname||"/",n);if(i==null)return null;let l=s??NF(e),c=null,u=Yvn(i);for(let d=0;c==null&&d<l.length;++d)c=Gvn(l[d],u,r);return c}function jut(e,t){let{route:n,pathname:r,params:s}=e;return{id:n.id,pathname:r,params:s,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function NF(e){let t=Tut(e);return Fvn(t),t}function Tut(e,t=[],n=[],r="",s=!1){let a=(i,l,c=s,u)=>{let d={relativePath:u===void 0?i.path||"":u,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(r)&&c)return;os(d.relativePath.startsWith(r),`Absolute route path "${d.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(r.length)}let f=Wh([r,d.relativePath]),p=n.concat(d);i.children&&i.children.length>0&&(os(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),Tut(i.children,t,p,f,c)),!(i.path==null&&!i.index)&&t.push({path:f,score:Wvn(f,i.index),routesMeta:p})};return e.forEach((i,l)=>{if(i.path===""||!i.path?.includes("?"))a(i,l);else for(let c of Nut(i.path))a(i,l,!0,c)}),t}function Nut(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return s?[a,""]:[a];let i=Nut(r.join("/")),l=[];return l.push(...i.map(c=>c===""?a:[a,c].join("/"))),s&&l.push(...i),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function Fvn(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Zvn(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var zvn=/^:[\w-]+$/,Bvn=3,Uvn=2,qvn=1,Vvn=10,Hvn=-2,iDe=e=>e==="*";function Wvn(e,t){let n=e.split("/"),r=n.length;return n.some(iDe)&&(r+=Hvn),t&&(r+=Uvn),n.filter(s=>!iDe(s)).reduce((s,a)=>s+(zvn.test(a)?Bvn:a===""?qvn:Vvn),r)}function Zvn(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function Gvn(e,t,n=!1){let{routesMeta:r}=e,s={},a="/",i=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.length-1,d=a==="/"?t:t.slice(a.length)||"/",f=gz({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),p=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=gz({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(s,f.params),i.push({params:s,pathname:Wh([a,f.pathname]),pathnameBase:Jvn(Wh([a,f.pathnameBase])),route:p}),f.pathnameBase!=="/"&&(a=Wh([a,f.pathnameBase]))}return i}function gz(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Qvn(e.path,e.caseSensitive,e.end),s=t.match(n);if(!s)return null;let a=s[0],i=a.replace(/(.)\/+$/,"$1"),l=s.slice(1);return{params:r.reduce((u,{paramName:d,isOptional:f},p)=>{if(d==="*"){let m=l[p]||"";i=a.slice(0,a.length-m.length).replace(/(.)\/+$/,"$1")}const h=l[p];return f&&!h?u[d]=void 0:u[d]=(h||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:i,pattern:e}}function Qvn(e,t=!1,n=!0){Jo(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,l,c,u,d)=>{if(r.push({paramName:l,isOptional:c!=null}),c){let f=d.charAt(u+i.length);return f&&f!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function Yvn(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Jo(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function sm(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}function Xvn({basename:e,pathname:t}){return t==="/"?e:Wh([e,t])}var Iut=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,$be=e=>Iut.test(e);function Kvn(e,t="/"){let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?_y(e):e,a;return n?(n=Mbe(n),n.startsWith("/")?a=oDe(n.substring(1),"/"):a=oDe(n,t)):a=t,{pathname:a,search:eyn(r),hash:tyn(s)}}function oDe(e,t){let n=vz(t).split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function mX(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Aut(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function _q(e){let t=Aut(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function wD(e,t,n,r=!1){let s;typeof e=="string"?s=_y(e):(s={...e},os(!s.pathname||!s.pathname.includes("?"),mX("?","pathname","search",s)),os(!s.pathname||!s.pathname.includes("#"),mX("#","pathname","hash",s)),os(!s.search||!s.search.includes("#"),mX("#","search","hash",s)));let a=e===""||s.pathname==="",i=a?"/":s.pathname,l;if(i==null)l=n;else{let f=t.length-1;if(!r&&i.startsWith("..")){let p=i.split("/");for(;p[0]==="..";)p.shift(),f-=1;s.pathname=p.join("/")}l=f>=0?t[f]:"/"}let c=Kvn(s,l),u=i&&i!=="/"&&i.endsWith("/"),d=(a||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Mbe=e=>e.replace(/\/\/+/g,"/"),Wh=e=>Mbe(e.join("/")),vz=e=>e.replace(/\/+$/,""),Jvn=e=>vz(e).replace(/^\/*/,"/"),eyn=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,tyn=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,IA=(e,t=302)=>{let n=t;typeof n=="number"?n={status:n}:typeof n.status>"u"&&(n.status=302);let r=new Headers(n.headers);return r.set("Location",e),new Response(null,{...n,headers:r})},SD=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function YP(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function kD(e){let t=e.map(n=>n.route.path).filter(Boolean);return Wh(t)||"/"}var Rut=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Put(e,t){let n=e;if(typeof n!="string"||!Iut.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,s=!1;if(Rut)try{let a=new URL(window.location.href),i=n.startsWith("//")?new URL(a.protocol+n):new URL(n),l=sm(i.pathname,t);i.origin===a.origin&&l!=null?n=l+i.search+i.hash:s=!0}catch{Jo(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:s,to:n}}var fw=Symbol("Uninstrumented");function nyn(e,t){let n={lazy:[],"lazy.loader":[],"lazy.action":[],"lazy.middleware":[],middleware:[],loader:[],action:[]};e.forEach(s=>s({id:t.id,index:t.index,path:t.path,instrument(a){let i=Object.keys(n);for(let l of i)a[l]&&n[l].push(a[l])}}));let r={};if(typeof t.lazy=="function"&&n.lazy.length>0){let s=$E(n.lazy,t.lazy,()=>{});s&&(r.lazy=s)}if(typeof t.lazy=="object"){let s=t.lazy;["middleware","loader","action"].forEach(a=>{let i=s[a],l=n[`lazy.${a}`];if(typeof i=="function"&&l.length>0){let c=$E(l,i,()=>{});c&&(r.lazy=Object.assign(r.lazy||{},{[a]:c}))}})}return["loader","action"].forEach(s=>{let a=t[s];if(typeof a=="function"&&n[s].length>0){let i=a[fw]??a,l=$E(n[s],i,(...c)=>lDe(c[0]));l&&(s==="loader"&&i.hydrate===!0&&(l.hydrate=!0),l[fw]=i,r[s]=l)}}),t.middleware&&t.middleware.length>0&&n.middleware.length>0&&(r.middleware=t.middleware.map(s=>{let a=s[fw]??s,i=$E(n.middleware,a,(...l)=>lDe(l[0]));return i?(i[fw]=a,i):s})),r}function ryn(e,t){let n={navigate:[],fetch:[]};if(t.forEach(r=>r({instrument(s){let a=Object.keys(s);for(let i of a)s[i]&&n[i].push(s[i])}})),n.navigate.length>0){let r=e.navigate[fw]??e.navigate,s=$E(n.navigate,r,(...a)=>{let[i,l]=a;return{to:typeof i=="number"||typeof i=="string"?i:i?cy(i):".",...cDe(e,l??{})}});s&&(s[fw]=r,e.navigate=s)}if(n.fetch.length>0){let r=e.fetch[fw]??e.fetch,s=$E(n.fetch,r,(...a)=>{let[i,,l,c]=a;return{href:l??".",fetcherKey:i,...cDe(e,c??{})}});s&&(s[fw]=r,e.fetch=s)}return e}function $E(e,t,n){return e.length===0?null:async(...r)=>{let s=await $ut(e,n(...r),()=>t(...r),e.length-1);if(s.type==="error")throw s.value;return s.value}}async function $ut(e,t,n,r){let s=e[r],a;if(s){let i,l=async()=>(i?console.error("You cannot call instrumented handlers more than once"):i=$ut(e,t,n,r-1),a=await i,os(a,"Expected a result"),a.type==="error"&&a.value instanceof Error?{status:"error",error:a.value}:{status:"success",error:void 0});try{await s(l,t)}catch(c){console.error("An instrumentation function threw an error:",c)}i||await l(),await i}else try{a={type:"success",value:await n()}}catch(i){a={type:"error",value:i}}return a||{type:"error",value:new Error("No result assigned in instrumentation chain.")}}function lDe(e){let{request:t,context:n,params:r,pattern:s}=e;return{request:syn(t),params:{...r},pattern:s,context:ayn(n)}}function cDe(e,t){return{currentUrl:cy(e.state.location),..."formMethod"in t?{formMethod:t.formMethod}:{},..."formEncType"in t?{formEncType:t.formEncType}:{},..."formData"in t?{formData:t.formData}:{},..."body"in t?{body:t.body}:{}}}function syn(e){return{method:e.method,url:e.url,headers:{get:(...t)=>e.headers.get(...t)}}}function ayn(e){if(oyn(e)){let t={...e};return Object.freeze(t),t}else return{get:t=>e.get(t)}}var iyn=Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function oyn(e){if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getOwnPropertyNames(t).sort().join("\0")===iyn}var Mut=["POST","PUT","PATCH","DELETE"],lyn=new Set(Mut),cyn=["GET",...Mut],uyn=new Set(cyn),Dut=new Set([301,302,303,307,308]),dyn=new Set([307,308]),gX={state:"idle",location:void 0,matches:void 0,historyAction:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},fyn={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},AA={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},pyn=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),Lut="remix-router-transitions",Fut=Symbol("ResetLoaderData"),YS,gE,Q0,vE,hyn=class{constructor(e){QR(this,YS),QR(this,gE),QR(this,Q0),QR(this,vE),rv(this,YS,e),rv(this,gE,NF(e))}get stableRoutes(){return kh(this,YS)}get activeRoutes(){return kh(this,Q0)??kh(this,YS)}get branches(){return kh(this,vE)??kh(this,gE)}get hasHMRRoutes(){return kh(this,Q0)!=null}setRoutes(e){rv(this,YS,e),rv(this,gE,NF(e))}setHmrRoutes(e){rv(this,Q0,e),rv(this,vE,NF(e))}commitHmrRoutes(){kh(this,Q0)&&(rv(this,YS,kh(this,Q0)),rv(this,gE,kh(this,vE)),rv(this,Q0,void 0),rv(this,vE,void 0))}};YS=new WeakMap;gE=new WeakMap;Q0=new WeakMap;vE=new WeakMap;function myn(e){const t=e.window?e.window:typeof window<"u"?window:void 0,n=typeof t<"u"&&typeof t.document<"u"&&typeof t.document.createElement<"u";os(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let r=e.hydrationRouteProperties||[],s=e.mapRouteProperties||pyn,a=s;if(e.instrumentations){let Te=e.instrumentations;a=Fe=>({...s(Fe),...nyn(Te.map(Me=>Me.route).filter(Boolean),Fe)})}let i={},l=new hyn(QP(e.routes,a,void 0,i)),c=e.basename||"/";c.startsWith("/")||(c=`/${c}`);let u=e.dataStrategy||xyn,d={...e.future},f=null,p=new Set,h=null,m=null,v=null,y=null,b=e.hydrationData!=null,S=Qm(l.activeRoutes,e.history.location,c,!1,l.branches),w=!1,k=null,_,C;if(S==null&&!e.patchRoutesOnNavigation){let Te=_h(404,{pathname:e.history.location.pathname}),{matches:Fe,route:Me}=SL(l.activeRoutes);_=!0,C=!_,S=Fe,k={[Me.id]:Te}}else if(S&&!e.hydrationData&&lt(S,l.activeRoutes,e.history.location.pathname).active&&(S=null),S)if(S.some(Te=>Te.route.lazy))_=!1,C=!_;else if(!S.some(Te=>Dbe(Te.route)))_=!0,C=!_;else{let Te=e.hydrationData?e.hydrationData.loaderData:null,Fe=e.hydrationData?e.hydrationData.errors:null,Me=S;if(Fe){let Ke=S.findIndex(nt=>Fe[nt.route.id]!==void 0);Me=Me.slice(0,Ke+1)}C=!1,_=!0,Me.forEach(Ke=>{let nt=zut(Ke.route,Te,Fe);C=C||nt.renderFallback,_=_&&!nt.shouldLoad})}else{_=!1,C=!_,S=[];let Te=lt(null,l.activeRoutes,e.history.location.pathname);Te.active&&Te.matches&&(w=!0,S=Te.matches)}let E,j={historyAction:e.history.action,location:e.history.location,matches:S,initialized:_,renderFallback:C,navigation:gX,restoreScrollPosition:e.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||k,fetchers:new Map,blockers:new Map},N="POP",I=null,R=!1,P,L=!1,M=new Map,q=null,H=!1,F=!1,z=new Set,B=new Map,D=0,Q=-1,V=new Map,$=new Set,U=new Map,Z=new Map,X=new Set,te=new Map,J,ee=null;function ae(){if(f=e.history.listen(({action:Te,location:Fe,delta:Me})=>{if(J){J(),J=void 0;return}Jo(te.size===0||Me!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let Ke=ot({currentLocation:j.location,nextLocation:Fe,historyAction:Te});if(Ke&&Me!=null){let nt=new Promise(Dt=>{J=Dt});e.history.go(Me*-1),At(Ke,{state:"blocked",location:Fe,proceed(){At(Ke,{state:"proceeding",proceed:void 0,reset:void 0,location:Fe}),nt.then(()=>e.history.go(Me))},reset(){let Dt=new Map(j.blockers);Dt.set(Ke,AA),ne({blockers:Dt})}}),I?.resolve(),I=null;return}return ve(Te,Fe)}),n){Lyn(t,M);let Te=()=>Fyn(t,M);t.addEventListener("pagehide",Te),q=()=>t.removeEventListener("pagehide",Te)}return j.initialized||ve("POP",j.location,{initialHydration:!0}),E}function ce(){f&&f(),q&&q(),p.clear(),P&&P.abort(),j.fetchers.forEach((Te,Fe)=>Ee(j.fetchers,Fe)),j.blockers.forEach((Te,Fe)=>tt(Fe))}function Y(Te){if(p.add(Te),h){let{newErrors:Fe}=h;h=null,Te(j,{deletedFetchers:[],newErrors:Fe,viewTransitionOpts:void 0,flushSync:!1})}return()=>p.delete(Te)}function ne(Te,Fe={}){Te.matches&&(Te.matches=Te.matches.map(nt=>{let Dt=i[nt.route.id],_t=nt.route;return _t.element!==Dt.element||_t.errorElement!==Dt.errorElement||_t.hydrateFallbackElement!==Dt.hydrateFallbackElement?{...nt,route:Dt}:nt})),j={...j,...Te};let Me=[],Ke=[];j.fetchers.forEach((nt,Dt)=>{nt.state==="idle"&&(X.has(Dt)?Me.push(Dt):Ke.push(Dt))}),X.forEach(nt=>{!j.fetchers.has(nt)&&!B.has(nt)&&Me.push(nt)}),p.size===0&&(h={newErrors:Te.errors??null}),[...p].forEach(nt=>nt(j,{deletedFetchers:Me,newErrors:Te.errors??null,viewTransitionOpts:Fe.viewTransitionOpts,flushSync:Fe.flushSync===!0})),Me.forEach(nt=>Ee(j.fetchers,nt)),Ke.forEach(nt=>j.fetchers.delete(nt))}function ue(Te,Fe,{flushSync:Me}={}){let Ke=j.actionData!=null&&j.navigation.formMethod!=null&&Su(j.navigation.formMethod)&&j.navigation.state==="loading"&&Te.state?._isRedirect!==!0,nt;Fe.actionData?Object.keys(Fe.actionData).length>0?nt=Fe.actionData:nt=null:Ke?nt=j.actionData:nt=null;let Dt=Fe.loaderData?xDe(j.loaderData,Fe.loaderData,Fe.matches||[],Fe.errors):j.loaderData,_t=j.blockers;_t.size>0&&(_t=new Map(_t),_t.forEach((xn,sr)=>_t.set(sr,AA)));let Ft=H?!1:Qe(Te,Fe.matches||j.matches),$t=R===!0||j.navigation.formMethod!=null&&Su(j.navigation.formMethod)&&Te.state?._isRedirect!==!0;l.commitHmrRoutes(),H||N==="POP"||(N==="PUSH"?e.history.push(Te,Te.state):N==="REPLACE"&&e.history.replace(Te,Te.state));let jt;if(N==="POP"){let xn=M.get(j.location.pathname);xn&&xn.has(Te.pathname)?jt={currentLocation:j.location,nextLocation:Te}:M.has(Te.pathname)&&(jt={currentLocation:Te,nextLocation:j.location})}else if(L){let xn=M.get(j.location.pathname);xn?xn.add(Te.pathname):(xn=new Set([Te.pathname]),M.set(j.location.pathname,xn)),jt={currentLocation:j.location,nextLocation:Te}}ne({...Fe,actionData:nt,loaderData:Dt,historyAction:N,location:Te,initialized:!0,renderFallback:!1,navigation:gX,revalidation:"idle",restoreScrollPosition:Ft,preventScrollReset:$t,blockers:_t},{viewTransitionOpts:jt,flushSync:Me===!0}),N="POP",R=!1,L=!1,H=!1,F=!1,I?.resolve(),I=null,ee?.resolve(),ee=null}async function pe(Te,Fe){if(I?.resolve(),I=null,typeof Te=="number"){I||(I=ODe());let hr=I.promise;return e.history.go(Te),hr}let Me=hfe(j.location,j.matches,c,Te,Fe?.fromRouteId,Fe?.relative),{path:Ke,submission:nt,error:Dt}=uDe(!1,Me,Fe),_t;Fe?.mask&&(_t={pathname:"",search:"",hash:"",...typeof Fe.mask=="string"?_y(Fe.mask):{...j.location.mask,...Fe.mask}});let Ft=j.location,$t=GP(Ft,Ke,Fe&&Fe.state,void 0,_t);$t={...$t,...e.history.encodeLocation($t)};let jt=Fe&&Fe.replace!=null?Fe.replace:void 0,xn="PUSH";jt===!0?xn="REPLACE":jt===!1||nt!=null&&Su(nt.formMethod)&&nt.formAction===j.location.pathname+j.location.search&&(xn="REPLACE");let sr=Fe&&"preventScrollReset"in Fe?Fe.preventScrollReset===!0:void 0,Zn=(Fe&&Fe.flushSync)===!0,jr=ot({currentLocation:Ft,nextLocation:$t,historyAction:xn});if(jr){At(jr,{state:"blocked",location:$t,proceed(){At(jr,{state:"proceeding",proceed:void 0,reset:void 0,location:$t}),pe(Te,Fe)},reset(){let hr=new Map(j.blockers);hr.set(jr,AA),ne({blockers:hr})}});return}await ve(xn,$t,{submission:nt,pendingError:Dt,preventScrollReset:sr,replace:Fe&&Fe.replace,enableViewTransition:Fe&&Fe.viewTransition,flushSync:Zn,callSiteDefaultShouldRevalidate:Fe&&Fe.defaultShouldRevalidate})}function le(){ee||(ee=ODe()),xe(),ne({revalidation:"loading"});let Te=ee.promise;return j.navigation.state==="submitting"?Te:j.navigation.state==="idle"?(ve(j.historyAction,j.location,{startUninterruptedRevalidation:!0}),Te):(ve(N||j.historyAction,j.navigation.location,{overrideNavigation:j.navigation,enableViewTransition:L===!0}),Te)}async function ve(Te,Fe,Me){P&&P.abort(),P=null,N=Te,H=(Me&&Me.startUninterruptedRevalidation)===!0,tn(j.location,j.matches),R=(Me&&Me.preventScrollReset)===!0,L=(Me&&Me.enableViewTransition)===!0;let Ke=l.activeRoutes,nt=Me?.initialHydration&&j.matches&&j.matches.length>0&&!w?j.matches:Qm(Ke,Fe,c,!1,l.branches),Dt=(Me&&Me.flushSync)===!0;if(nt&&j.initialized&&!F&&jyn(j.location,Fe)&&!(Me&&Me.submission&&Su(Me.submission.formMethod))){ue(Fe,{matches:nt},{flushSync:Dt});return}let _t=lt(nt,Ke,Fe.pathname);if(_t.active&&_t.matches&&(nt=_t.matches),!nt){let{error:Dr,notFoundMatches:fr,route:Hs}=zt(Fe.pathname);ue(Fe,{matches:fr,loaderData:{},errors:{[Hs.id]:Dr}},{flushSync:Dt});return}let Ft=Me&&Me.overrideNavigation?{...Me.overrideNavigation,matches:nt,historyAction:Te}:void 0;P=new AbortController;let $t=yE(e.history,Fe,P.signal,Me&&Me.submission),jt=e.getContext?await e.getContext():new sDe,xn;if(Me&&Me.pendingError)xn=[sw(nt).route.id,{type:"error",error:Me.pendingError}];else if(Me&&Me.submission&&Su(Me.submission.formMethod)){let Dr=await ye($t,Fe,Me.submission,nt,Te,jt,_t.active,Me&&Me.initialHydration===!0,{replace:Me.replace,flushSync:Dt});if(Dr.shortCircuited)return;if(Dr.pendingActionResult){let[fr,Hs]=Dr.pendingActionResult;if(up(Hs)&&YP(Hs.error)&&Hs.error.status===404){P=null,ue(Fe,{matches:Dr.matches,loaderData:{},errors:{[fr]:Hs.error}});return}}nt=Dr.matches||nt,xn=Dr.pendingActionResult,Ft=vX(Fe,nt,Te,Me.submission),Dt=!1,_t.active=!1,$t=yE(e.history,$t.url,$t.signal)}let{shortCircuited:sr,matches:Zn,loaderData:jr,errors:hr,workingFetchers:xs}=await Se($t,Fe,nt,Te,jt,_t.active,Ft,Me&&Me.submission,Me&&Me.fetcherSubmission,Me&&Me.replace,Me&&Me.initialHydration===!0,Dt,xn,Me&&Me.callSiteDefaultShouldRevalidate);sr||(P=null,ue(Fe,{matches:Zn||nt,...wDe(xn),loaderData:jr,errors:hr,...xs?{fetchers:xs}:{}}))}async function ye(Te,Fe,Me,Ke,nt,Dt,_t,Ft,$t={}){xe();let jt=Myn(Fe,Ke,nt,Me);if(ne({navigation:jt},{flushSync:$t.flushSync===!0}),_t){let Zn=await it(Ke,Fe.pathname,Te.signal);if(Zn.type==="aborted")return{shortCircuited:!0};if(Zn.type==="error"){if(Zn.partialMatches.length===0){let{matches:hr,route:xs}=SL(l.activeRoutes);return{matches:hr,pendingActionResult:[xs.id,{type:"error",error:Zn.error}]}}let jr=sw(Zn.partialMatches).route.id;return{matches:Zn.partialMatches,pendingActionResult:[jr,{type:"error",error:Zn.error}]}}else if(Zn.matches)Ke=Zn.matches;else{let{notFoundMatches:jr,error:hr,route:xs}=zt(Fe.pathname);return{matches:jr,pendingActionResult:[xs.id,{type:"error",error:hr}]}}}let xn,sr=IF(Ke,Fe);if(!sr.route.action&&!sr.route.lazy)xn={type:"error",error:_h(405,{method:Te.method,pathname:Fe.pathname,routeId:sr.route.id})};else{let Zn=uj(a,i,Te,Fe,Ke,sr,Ft?[]:r,Dt),jr=await re(Te,Fe,Zn,Dt,null);if(xn=jr[sr.route.id],!xn){for(let hr of Ke)if(jr[hr.route.id]){xn=jr[hr.route.id];break}}if(Te.signal.aborted)return{shortCircuited:!0}}if(Sk(xn)){let Zn;return $t&&$t.replace!=null?Zn=$t.replace:Zn=vDe(xn.response.headers.get("Location"),new URL(Te.url),c,e.history)===j.location.pathname+j.location.search,await se(Te,xn,!0,{submission:Me,replace:Zn}),{shortCircuited:!0}}if(up(xn)){let Zn=sw(Ke,sr.route.id);return($t&&$t.replace)!==!0&&(N="PUSH"),{matches:Ke,pendingActionResult:[Zn.route.id,xn,sr.route.id]}}return{matches:Ke,pendingActionResult:[sr.route.id,xn]}}async function Se(Te,Fe,Me,Ke,nt,Dt,_t,Ft,$t,jt,xn,sr,Zn,jr){let hr=_t||vX(Fe,Me,Ke,Ft),xs=Ft||$t||kDe(hr),Dr=!H&&!xn;if(Dt){if(Dr){let Ta=Ne(Zn);ne({navigation:hr,...Ta!==void 0?{actionData:Ta}:{}},{flushSync:sr})}let Zr=await it(Me,Fe.pathname,Te.signal);if(Zr.type==="aborted")return{shortCircuited:!0};if(Zr.type==="error"){if(Zr.partialMatches.length===0){let{matches:gi,route:Ai}=SL(l.activeRoutes);return{matches:gi,loaderData:{},errors:{[Ai.id]:Zr.error}}}let Ta=sw(Zr.partialMatches).route.id;return{matches:Zr.partialMatches,loaderData:{},errors:{[Ta]:Zr.error}}}else if(Zr.matches)Me=Zr.matches;else{let{error:Ta,notFoundMatches:gi,route:Ai}=zt(Fe.pathname);return{matches:gi,loaderData:{},errors:{[Ai.id]:Ta}}}}let fr=l.activeRoutes,{dsMatches:Hs,revalidatingFetchers:va}=dDe(Te,nt,a,i,e.history,j,Me,xs,Fe,xn?[]:r,xn===!0,F,z,X,U,$,fr,c,e.patchRoutesOnNavigation!=null,l.branches,Zn,jr);if(Q=++D,!e.dataStrategy&&!Hs.some(Zr=>Zr.shouldLoad)&&!Hs.some(Zr=>Zr.route.middleware&&Zr.route.middleware.length>0)&&va.length===0){let Zr=new Map(j.fetchers),Ta=Re(Zr);return ue(Fe,{matches:Me,loaderData:{},errors:Zn&&up(Zn[1])?{[Zn[0]]:Zn[1].error}:null,...wDe(Zn),...Ta?{fetchers:Zr}:{}},{flushSync:sr}),{shortCircuited:!0}}if(Dr){let Zr={};if(!Dt){Zr.navigation=hr;let Ta=Ne(Zn);Ta!==void 0&&(Zr.actionData=Ta)}va.length>0&&(Zr.fetchers=ke(va)),ne(Zr,{flushSync:sr})}va.forEach(Zr=>{Ce(Zr.key),Zr.controller&&B.set(Zr.key,Zr.controller)});let ja=()=>va.forEach(Zr=>Ce(Zr.key));P&&P.signal.addEventListener("abort",ja);let{loaderResults:Da,fetcherResults:Uo}=await he(Hs,va,Te,Fe,nt);if(Te.signal.aborted)return{shortCircuited:!0};P&&P.signal.removeEventListener("abort",ja),va.forEach(Zr=>B.delete(Zr.key));let yl=kL(Da);if(yl)return await se(Te,yl.result,!0,{replace:jt}),{shortCircuited:!0};if(yl=kL(Uo),yl)return $.add(yl.key),await se(Te,yl.result,!0,{replace:jt}),{shortCircuited:!0};let ol=new Map(j.fetchers),{loaderData:jm,errors:Zu}=bDe(j,Me,Da,Zn,va,Uo,ol);xn&&j.errors&&(Zu={...j.errors,...Zu});let Df=Re(ol),Tm=qe(Q,ol),Gu=Df||Tm||va.length>0;return{matches:Me,loaderData:jm,errors:Zu,...Gu?{workingFetchers:ol}:{}}}function Ne(Te){if(Te&&!up(Te[1]))return{[Te[0]]:Te[1].data};if(j.actionData)return Object.keys(j.actionData).length===0?null:j.actionData}function ke(Te){let Fe=new Map(j.fetchers);return Te.forEach(Me=>{let Ke=Fe.get(Me.key),nt=RA(void 0,Ke?Ke.data:void 0);Fe.set(Me.key,nt)}),Fe}async function Ie(Te,Fe,Me,Ke){Ce(Te);let nt=(Ke&&Ke.flushSync)===!0,Dt=l.activeRoutes,_t=hfe(j.location,j.matches,c,Me,Fe,Ke?.relative),Ft=Qm(Dt,_t,c,!1,l.branches),$t=lt(Ft,Dt,_t);if($t.active&&$t.matches&&(Ft=$t.matches),!Ft){Pe(Te,Fe,_h(404,{pathname:_t}),{flushSync:nt});return}let{path:jt,submission:xn,error:sr}=uDe(!0,_t,Ke);if(sr){Pe(Te,Fe,sr,{flushSync:nt});return}let Zn=e.getContext?await e.getContext():new sDe,jr=(Ke&&Ke.preventScrollReset)===!0;if(xn&&Su(xn.formMethod)){await ze(Te,Fe,jt,Ft,Zn,$t.active,nt,jr,xn,Ke&&Ke.defaultShouldRevalidate);return}U.set(Te,{routeId:Fe,path:jt}),await oe(Te,Fe,jt,Ft,Zn,$t.active,nt,jr,xn)}async function ze(Te,Fe,Me,Ke,nt,Dt,_t,Ft,$t,jt){xe(),U.delete(Te);let xn=j.fetchers.get(Te);je(Te,Dyn($t,xn),{flushSync:_t});let sr=new AbortController,Zn=yE(e.history,Me,sr.signal,$t);if(Dt){let Ws=await it(Ke,new URL(Zn.url).pathname,Zn.signal,Te);if(Ws.type==="aborted")return;if(Ws.type==="error"){Pe(Te,Fe,Ws.error,{flushSync:_t});return}else if(Ws.matches)Ke=Ws.matches;else{Pe(Te,Fe,_h(404,{pathname:Me}),{flushSync:_t});return}}let jr=IF(Ke,Me);if(!jr.route.action&&!jr.route.lazy){let Ws=_h(405,{method:$t.formMethod,pathname:Me,routeId:Fe});Pe(Te,Fe,Ws,{flushSync:_t});return}B.set(Te,sr);let hr=D,xs=uj(a,i,Zn,Me,Ke,jr,r,nt),Dr=await re(Zn,Me,xs,nt,Te),fr=Dr[jr.route.id];if(!fr){for(let Ws of xs)if(Dr[Ws.route.id]){fr=Dr[Ws.route.id];break}}if(Zn.signal.aborted){B.get(Te)===sr&&B.delete(Te);return}if(X.has(Te)){if(Sk(fr)||up(fr)){je(Te,hv(void 0));return}}else{if(Sk(fr))if(B.delete(Te),Q>hr){je(Te,hv(void 0));return}else return $.add(Te),je(Te,RA($t)),se(Zn,fr,!1,{fetcherSubmission:$t,preventScrollReset:Ft});if(up(fr)){Pe(Te,Fe,fr.error);return}}let Hs=j.navigation.location||j.location,va=yE(e.history,Hs,sr.signal),ja=l.activeRoutes,Da=j.navigation.state!=="idle"?Qm(ja,j.navigation.location,c,!1,l.branches):j.matches;os(Da,"Didn't find any matches after fetcher action");let Uo=++D;V.set(Te,Uo);let{dsMatches:yl,revalidatingFetchers:ol}=dDe(va,nt,a,i,e.history,j,Da,$t,Hs,r,!1,F,z,X,U,$,ja,c,e.patchRoutesOnNavigation!=null,l.branches,[jr.route.id,fr],jt),jm=RA($t,fr.data),Zu=new Map(j.fetchers);Zu.set(Te,jm),ol.filter(Ws=>Ws.key!==Te).forEach(Ws=>{let hu=Ws.key,Gg=Zu.get(hu),qo=RA(void 0,Gg?Gg.data:void 0);Zu.set(hu,qo),Ce(hu),Ws.controller&&B.set(hu,Ws.controller)}),ne({fetchers:Zu});let Df=()=>ol.forEach(Ws=>Ce(Ws.key));sr.signal.addEventListener("abort",Df);let{loaderResults:Tm,fetcherResults:Gu}=await he(yl,ol,va,Hs,nt);if(sr.signal.aborted)return;sr.signal.removeEventListener("abort",Df),V.delete(Te),B.delete(Te),ol.forEach(Ws=>B.delete(Ws.key));let Zr=j.fetchers.has(Te),Ta=Ws=>{if(!Zr)return Ws;let hu=new Map(Ws.fetchers);return hu.set(Te,hv(fr.data)),{...Ws,fetchers:hu}},gi=kL(Tm);if(gi)return j=Ta(j),se(va,gi.result,!1,{preventScrollReset:Ft});if(gi=kL(Gu),gi)return $.add(gi.key),j=Ta(j),se(va,gi.result,!1,{preventScrollReset:Ft});let Ai=new Map(j.fetchers);Zr&&Ai.set(Te,hv(fr.data));let{loaderData:Dl,errors:Qu}=bDe(j,Da,Tm,void 0,ol,Gu,Ai);qe(Uo,Ai),j.navigation.state==="loading"&&Uo>Q?(os(N,"Expected pending action"),P&&P.abort(),ue(j.navigation.location,{matches:Da,loaderData:Dl,errors:Qu,fetchers:Ai})):(ne({errors:Qu,loaderData:xDe(j.loaderData,Dl,Da,Qu),fetchers:Ai}),F=!1)}async function oe(Te,Fe,Me,Ke,nt,Dt,_t,Ft,$t){let jt=j.fetchers.get(Te);je(Te,RA($t,jt?jt.data:void 0),{flushSync:_t});let xn=new AbortController,sr=yE(e.history,Me,xn.signal);if(Dt){let fr=await it(Ke,new URL(sr.url).pathname,sr.signal,Te);if(fr.type==="aborted")return;if(fr.type==="error"){Pe(Te,Fe,fr.error,{flushSync:_t});return}else if(fr.matches)Ke=fr.matches;else{Pe(Te,Fe,_h(404,{pathname:Me}),{flushSync:_t});return}}let Zn=IF(Ke,Me);B.set(Te,xn);let jr=D,hr=uj(a,i,sr,Me,Ke,Zn,r,nt),xs=await re(sr,Me,hr,nt,Te),Dr=xs[Zn.route.id];if(!Dr){for(let fr of Ke)if(xs[fr.route.id]){Dr=xs[fr.route.id];break}}if(B.get(Te)===xn&&B.delete(Te),!sr.signal.aborted){if(X.has(Te)){je(Te,hv(void 0));return}if(Sk(Dr))if(Q>jr){je(Te,hv(void 0));return}else{$.add(Te),await se(sr,Dr,!1,{preventScrollReset:Ft});return}if(up(Dr)){Pe(Te,Fe,Dr.error);return}je(Te,hv(Dr.data))}}async function se(Te,Fe,Me,{submission:Ke,fetcherSubmission:nt,preventScrollReset:Dt,replace:_t}={}){Me||(I?.resolve(),I=null),Fe.response.headers.has("X-Remix-Revalidate")&&(F=!0);let Ft=Fe.response.headers.get("Location");os(Ft,"Expected a Location header on the redirect Response"),Ft=vDe(Ft,new URL(Te.url),c,e.history);let $t=GP(j.location,Ft,{_isRedirect:!0});if(n){let hr=!1;if(Fe.response.headers.has("X-Remix-Reload-Document"))hr=!0;else if($be(Ft)){const xs=Cut(Ft,!0);hr=xs.origin!==t.location.origin||sm(xs.pathname,c)==null}if(hr){_t?t.location.replace(Ft):t.location.assign(Ft);return}}P=null;let jt=_t===!0||Fe.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:xn,formAction:sr,formEncType:Zn}=j.navigation;!Ke&&!nt&&xn&&sr&&Zn&&(Ke=kDe(j.navigation));let jr=Ke||nt;if(dyn.has(Fe.response.status)&&jr&&Su(jr.formMethod))await ve(jt,$t,{submission:{...jr,formAction:Ft},preventScrollReset:Dt||R,enableViewTransition:Me?L:void 0});else{let hr=vX($t,[],jt,Ke);await ve(jt,$t,{overrideNavigation:hr,fetcherSubmission:nt,preventScrollReset:Dt||R,enableViewTransition:Me?L:void 0})}}async function re(Te,Fe,Me,Ke,nt){let Dt,_t={};try{Dt=await Syn(u,Te,Fe,Me,nt,Ke,!1)}catch(Ft){return Me.filter($t=>$t.shouldLoad).forEach($t=>{_t[$t.route.id]={type:"error",error:Ft}}),_t}if(Te.signal.aborted)return _t;if(!Su(Te.method))for(let Ft of Me){if(Dt[Ft.route.id]?.type==="error")break;!Dt.hasOwnProperty(Ft.route.id)&&!j.loaderData.hasOwnProperty(Ft.route.id)&&(!j.errors||!j.errors.hasOwnProperty(Ft.route.id))&&Ft.shouldCallHandler()&&(Dt[Ft.route.id]={type:"error",result:new Error(`No result returned from dataStrategy for route ${Ft.route.id}`)})}for(let[Ft,$t]of Object.entries(Dt))if(Ayn($t)){let jt=$t.result;_t[Ft]={type:"redirect",response:Cyn(jt,Te,Ft,Me,c)}}else _t[Ft]=await _yn($t);return _t}async function he(Te,Fe,Me,Ke,nt){let Dt=re(Me,Ke,Te,nt,null),_t=Promise.all(Fe.map(async jt=>{if(jt.matches&&jt.match&&jt.request&&jt.controller){let sr=(await re(jt.request,jt.path,jt.matches,nt,jt.key))[jt.match.route.id];return{[jt.key]:sr}}else return Promise.resolve({[jt.key]:{type:"error",error:_h(404,{pathname:jt.path})}})})),Ft=await Dt,$t=(await _t).reduce((jt,xn)=>Object.assign(jt,xn),{});return{loaderResults:Ft,fetcherResults:$t}}function xe(){F=!0,U.forEach((Te,Fe)=>{B.has(Fe)&&z.add(Fe),Ce(Fe)})}function je(Te,Fe,Me={}){let Ke=new Map(j.fetchers);Ke.set(Te,Fe),ne({fetchers:Ke},{flushSync:(Me&&Me.flushSync)===!0})}function Pe(Te,Fe,Me,Ke={}){let nt=sw(j.matches,Fe),Dt=new Map(j.fetchers);Ee(Dt,Te),ne({errors:{[nt.route.id]:Me},fetchers:Dt},{flushSync:(Ke&&Ke.flushSync)===!0})}function Ge(Te){return Z.set(Te,(Z.get(Te)||0)+1),X.has(Te)&&X.delete(Te),j.fetchers.get(Te)||fyn}function Ze(Te,Fe){Ce(Te,Fe?.reason),je(Te,hv(null))}function Ee(Te,Fe){let Me=j.fetchers.get(Fe);B.has(Fe)&&!(Me&&Me.state==="loading"&&V.has(Fe))&&Ce(Fe),U.delete(Fe),V.delete(Fe),$.delete(Fe),X.delete(Fe),z.delete(Fe),Te.delete(Fe)}function _e(Te){let Fe=(Z.get(Te)||0)-1;Fe<=0?(Z.delete(Te),X.add(Te)):Z.set(Te,Fe),ne({fetchers:new Map(j.fetchers)})}function Ce(Te,Fe){let Me=B.get(Te);Me&&(Me.abort(Fe),B.delete(Te))}function Oe(Te,Fe){for(let Me of Te){let Ke=Fe.get(Me);os(Ke,`Expected fetcher: ${Me}`);let nt=hv(Ke.data);Fe.set(Me,nt)}}function Re(Te){let Fe=[],Me=!1;for(let Ke of $){let nt=Te.get(Ke);os(nt,`Expected fetcher: ${Ke}`),nt.state==="loading"&&($.delete(Ke),Fe.push(Ke),Me=!0)}return Oe(Fe,Te),Me}function qe(Te,Fe){let Me=[];for(let[Ke,nt]of V)if(nt<Te){let Dt=Fe.get(Ke);os(Dt,`Expected fetcher: ${Ke}`),Dt.state==="loading"&&(Ce(Ke),V.delete(Ke),Me.push(Ke))}return Oe(Me,Fe),Me.length>0}function Ye(Te,Fe){let Me=j.blockers.get(Te)||AA;return te.get(Te)!==Fe&&te.set(Te,Fe),Me}function tt(Te){j.blockers.delete(Te),te.delete(Te)}function At(Te,Fe){let Me=j.blockers.get(Te)||AA;os(Me.state==="unblocked"&&Fe.state==="blocked"||Me.state==="blocked"&&Fe.state==="blocked"||Me.state==="blocked"&&Fe.state==="proceeding"||Me.state==="blocked"&&Fe.state==="unblocked"||Me.state==="proceeding"&&Fe.state==="unblocked",`Invalid blocker state transition: ${Me.state} -> ${Fe.state}`);let Ke=new Map(j.blockers);Ke.set(Te,Fe),ne({blockers:Ke})}function ot({currentLocation:Te,nextLocation:Fe,historyAction:Me}){if(te.size===0)return;te.size>1&&Jo(!1,"A router only supports one blocker at a time");let Ke=Array.from(te.entries()),[nt,Dt]=Ke[Ke.length-1],_t=j.blockers.get(nt);if(!(_t&&_t.state==="proceeding")&&Dt({currentLocation:Te,nextLocation:Fe,historyAction:Me}))return nt}function zt(Te){let Fe=_h(404,{pathname:Te}),Me=l.activeRoutes,{matches:Ke,route:nt}=SL(Me);return{notFoundMatches:Ke,route:nt,error:Fe}}function mt(Te,Fe,Me){if(m=Te,y=Fe,v=Me||null,!b&&j.navigation===gX){b=!0;let Ke=Qe(j.location,j.matches);Ke!=null&&ne({restoreScrollPosition:Ke})}return()=>{m=null,y=null,v=null}}function Pt(Te,Fe){return v&&v(Te,Fe.map(Ke=>jut(Ke,j.loaderData)))||Te.key}function tn(Te,Fe){if(m&&y){let Me=Pt(Te,Fe);m[Me]=y()}}function Qe(Te,Fe){if(m){let Me=Pt(Te,Fe),Ke=m[Me];if(typeof Ke=="number")return Ke}return null}function lt(Te,Fe,Me){if(e.patchRoutesOnNavigation){let Ke=l.branches;if(Te){if(Object.keys(Te[0].params).length>0)return{active:!0,matches:Qm(Fe,Me,c,!0,Ke)}}else return{active:!0,matches:Qm(Fe,Me,c,!0,Ke)||[]}}return{active:!1,matches:null}}async function it(Te,Fe,Me,Ke){if(!e.patchRoutesOnNavigation)return{type:"success",matches:Te};let nt=Te;for(;;){let Dt=i;try{await e.patchRoutesOnNavigation({signal:Me,path:Fe,matches:nt,fetcherKey:Ke,patch:(jt,xn)=>{Me.aborted||fDe(jt,xn,l,Dt,a,!1)}})}catch(jt){return{type:"error",error:jt,partialMatches:nt}}if(Me.aborted)return{type:"aborted"};let _t=l.branches,Ft=Qm(l.activeRoutes,Fe,c,!1,_t),$t=null;if(Ft){if(Object.keys(Ft[0].params).length===0)return{type:"success",matches:Ft};if($t=Qm(l.activeRoutes,Fe,c,!0,_t),!($t&&nt.length<$t.length&&Xt(nt,$t.slice(0,nt.length))))return{type:"success",matches:Ft}}if($t||($t=Qm(l.activeRoutes,Fe,c,!0,_t)),!$t||Xt(nt,$t))return{type:"success",matches:null};nt=$t}}function Xt(Te,Fe){return Te.length===Fe.length&&Te.every((Me,Ke)=>Me.route.id===Fe[Ke].route.id)}function Zt(Te){i={},l.setHmrRoutes(QP(Te,a,void 0,i))}function _n(Te,Fe,Me=!1){fDe(Te,Fe,l,i,a,Me),l.hasHMRRoutes||ne({})}return E={get basename(){return c},get future(){return d},get state(){return j},get routes(){return l.stableRoutes},get branches(){return l.branches},get manifest(){return i},get window(){return t},initialize:ae,subscribe:Y,enableScrollRestoration:mt,navigate:pe,fetch:Ie,revalidate:le,createHref:Te=>e.history.createHref(Te),encodeLocation:Te=>e.history.encodeLocation(Te),getFetcher:Ge,resetFetcher:Ze,deleteFetcher:_e,dispose:ce,getBlocker:Ye,deleteBlocker:tt,patchRoutes:_n,_internalFetchControllers:B,_internalSetRoutes:Zt,_internalSetStateDoNotUseOrYouWillBreakYourApp(Te){ne(Te)}},e.instrumentations&&(E=ryn(E,e.instrumentations.map(Te=>Te.router).filter(Boolean))),E}function gyn(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function hfe(e,t,n,r,s,a){let i,l;if(s){i=[];for(let u of t)if(i.push(u),u.route.id===s){l=u;break}}else i=t,l=t[t.length-1];let c=wD(r||".",_q(i),sm(e.pathname,n)||e.pathname,a==="path");if(r==null&&(c.search=e.search,c.hash=e.hash),(r==null||r===""||r===".")&&l){let u=Fbe(c.search);if(l.route.index&&!u)c.search=c.search?c.search.replace(/^\?/,"?index&"):"?index";else if(!l.route.index&&u){let d=new URLSearchParams(c.search),f=d.getAll("index");d.delete("index"),f.filter(h=>h).forEach(h=>d.append("index",h));let p=d.toString();c.search=p?`?${p}`:""}}return n!=="/"&&(c.pathname=Xvn({basename:n,pathname:c.pathname})),cy(c)}function uDe(e,t,n){if(!n||!gyn(n))return{path:t};if(n.formMethod&&!$yn(n.formMethod))return{path:t,error:_h(405,{method:n.formMethod})};let r=()=>({path:t,error:_h(400,{type:"invalid-body"})}),a=(n.formMethod||"get").toUpperCase(),i=Zut(t);if(n.body!==void 0){if(n.formEncType==="text/plain"){if(!Su(a))return r();let f=typeof n.body=="string"?n.body:n.body instanceof FormData||n.body instanceof URLSearchParams?Array.from(n.body.entries()).reduce((p,[h,m])=>`${p}${h}=${m}
197
197
  `,""):String(n.body);return{path:t,submission:{formMethod:a,formAction:i,formEncType:n.formEncType,formData:void 0,json:void 0,text:f}}}else if(n.formEncType==="application/json"){if(!Su(a))return r();try{let f=typeof n.body=="string"?JSON.parse(n.body):n.body;return{path:t,submission:{formMethod:a,formAction:i,formEncType:n.formEncType,formData:void 0,json:f,text:void 0}}}catch{return r()}}}os(typeof FormData=="function","FormData is not available in this environment");let l,c;if(n.formData)l=gfe(n.formData),c=n.formData;else if(n.body instanceof FormData)l=gfe(n.body),c=n.body;else if(n.body instanceof URLSearchParams)l=n.body,c=yDe(l);else if(n.body==null)l=new URLSearchParams,c=new FormData;else try{l=new URLSearchParams(n.body),c=yDe(l)}catch{return r()}let u={formMethod:a,formAction:i,formEncType:n&&n.formEncType||"application/x-www-form-urlencoded",formData:c,json:void 0,text:void 0};if(Su(u.formMethod))return{path:t,submission:u};let d=_y(t);return e&&d.search&&Fbe(d.search)&&l.append("index",""),d.search=`?${l}`,{path:cy(d),submission:u}}function dDe(e,t,n,r,s,a,i,l,c,u,d,f,p,h,m,v,y,b,S,w,k,_){let C=k?up(k[1])?k[1].error:k[1].data:void 0,E=s.createURL(a.location),j=s.createURL(c),N;if(d&&a.errors){let H=Object.keys(a.errors)[0];N=i.findIndex(F=>F.route.id===H)}else if(k&&up(k[1])){let H=k[0];N=i.findIndex(F=>F.route.id===H)-1}let I=k?k[1].statusCode:void 0,R=I&&I>=400,P={currentUrl:E,currentParams:a.matches[0]?.params||{},nextUrl:j,nextParams:i[0].params,...l,actionResult:C,actionStatus:I},L=kD(i),M=i.map((H,F)=>{let{route:z}=H,B=null;if(N!=null&&F>N)B=!1;else if(z.lazy)B=!0;else if(!Dbe(z))B=!1;else if(d){let{shouldLoad:$}=zut(z,a.loaderData,a.errors);B=$}else vyn(a.loaderData,a.matches[F],H)&&(B=!0);if(B!==null)return mfe(n,r,e,c,L,H,u,t,B);let D=!1;typeof _=="boolean"?D=_:R?D=!1:(f||E.pathname+E.search===j.pathname+j.search||E.search!==j.search||yyn(a.matches[F],H))&&(D=!0);let Q={...P,defaultShouldRevalidate:D},V=A2(H,Q);return mfe(n,r,e,c,L,H,u,t,V,Q,_)}),q=[];return m.forEach((H,F)=>{if(d||!i.some(Z=>Z.route.id===H.routeId)||h.has(F))return;let z=a.fetchers.get(F),B=z&&z.state!=="idle"&&z.data===void 0,D=Qm(y,H.path,b??"/",!1,w);if(!D){if(S&&B)return;q.push({key:F,routeId:H.routeId,path:H.path,matches:null,match:null,request:null,controller:null});return}if(v.has(F))return;let Q=IF(D,H.path),V=new AbortController,$=yE(s,H.path,V.signal),U=null;if(p.has(F))p.delete(F),U=uj(n,r,$,H.path,D,Q,u,t);else if(B)f&&(U=uj(n,r,$,H.path,D,Q,u,t));else{let Z;typeof _=="boolean"?Z=_:R?Z=!1:Z=f;let X={...P,defaultShouldRevalidate:Z};A2(Q,X)&&(U=uj(n,r,$,H.path,D,Q,u,t,X))}U&&q.push({key:F,routeId:H.routeId,path:H.path,matches:U,match:Q,request:$,controller:V})}),{dsMatches:M,revalidatingFetchers:q}}function Dbe(e){return e.loader!=null||e.middleware!=null&&e.middleware.length>0}function zut(e,t,n){if(e.lazy)return{shouldLoad:!0,renderFallback:!0};if(!Dbe(e))return{shouldLoad:!1,renderFallback:!1};let r=t!=null&&e.id in t,s=n!=null&&n[e.id]!==void 0;if(!r&&s)return{shouldLoad:!1,renderFallback:!1};if(typeof e.loader=="function"&&e.loader.hydrate===!0)return{shouldLoad:!0,renderFallback:!r};let a=!r&&!s;return{shouldLoad:a,renderFallback:a}}function vyn(e,t,n){let r=!t||n.route.id!==t.route.id,s=!e.hasOwnProperty(n.route.id);return r||s}function yyn(e,t){let n=e.route.path;return e.pathname!==t.pathname||n!=null&&n.endsWith("*")&&e.params["*"]!==t.params["*"]}function A2(e,t){if(e.route.shouldRevalidate){let n=e.route.shouldRevalidate(t);if(typeof n=="boolean")return n}return t.defaultShouldRevalidate}function fDe(e,t,n,r,s,a){let i;if(e){let u=r[e];os(u,`No route found to patch children into: routeId = ${e}`),u.children||(u.children=[]),i=u.children}else i=n.activeRoutes;let l=[],c=[];if(t.forEach(u=>{let d=i.find(f=>But(u,f));d?c.push({existingRoute:d,newRoute:u}):l.push(u)}),l.length>0){let u=QP(l,s,[e||"_","patch",String(i?.length||"0")],r);i.push(...u)}if(a&&c.length>0)for(let u=0;u<c.length;u++){let{existingRoute:d,newRoute:f}=c[u],p=d,[h]=QP([f],s,[],{},!0);Object.assign(p,{element:h.element?h.element:p.element,errorElement:h.errorElement?h.errorElement:p.errorElement,hydrateFallbackElement:h.hydrateFallbackElement?h.hydrateFallbackElement:p.hydrateFallbackElement})}n.hasHMRRoutes||n.setRoutes([...n.activeRoutes])}function But(e,t){return"id"in e&&"id"in t&&e.id===t.id?!0:e.index===t.index&&e.path===t.path&&e.caseSensitive===t.caseSensitive?(!e.children||e.children.length===0)&&(!t.children||t.children.length===0)?!0:e.children?.every((n,r)=>t.children?.some(s=>But(n,s)))??!1:!1}var pDe=new WeakMap,Uut=({key:e,route:t,manifest:n,mapRouteProperties:r})=>{let s=n[t.id];if(os(s,"No route found in manifest"),!s.lazy||typeof s.lazy!="object")return;let a=s.lazy[e];if(!a)return;let i=pDe.get(s);i||(i={},pDe.set(s,i));let l=i[e];if(l)return l;let c=(async()=>{let u=$vn(e),f=s[e]!==void 0&&e!=="hasErrorBoundary";if(u)Jo(!u,"Route property "+e+" is not a supported lazy route property. This property will be ignored."),i[e]=Promise.resolve();else if(f)Jo(!1,`Route "${s.id}" has a static property "${e}" defined. The lazy property will be ignored.`);else{let p=await a();p!=null&&(Object.assign(s,{[e]:p}),Object.assign(s,r(s)))}typeof s.lazy=="object"&&(s.lazy[e]=void 0,Object.values(s.lazy).every(p=>p===void 0)&&(s.lazy=void 0))})();return i[e]=c,c},hDe=new WeakMap;function byn(e,t,n,r,s){let a=n[e.id];if(os(a,"No route found in manifest"),!e.lazy)return{lazyRoutePromise:void 0,lazyHandlerPromise:void 0};if(typeof e.lazy=="function"){let d=hDe.get(a);if(d)return{lazyRoutePromise:d,lazyHandlerPromise:d};let f=(async()=>{os(typeof e.lazy=="function","No lazy route function found");let p=await e.lazy(),h={};for(let m in p){let v=p[m];if(v===void 0)continue;let y=Dvn(m),S=a[m]!==void 0&&m!=="hasErrorBoundary";y?Jo(!y,"Route property "+m+" is not a supported property to be returned from a lazy route function. This property will be ignored."):S?Jo(!S,`Route "${a.id}" has a static property "${m}" defined but its lazy function is also returning a value for this property. The lazy route property "${m}" will be ignored.`):h[m]=v}Object.assign(a,h),Object.assign(a,{...r(a),lazy:void 0})})();return hDe.set(a,f),f.catch(()=>{}),{lazyRoutePromise:f,lazyHandlerPromise:f}}let i=Object.keys(e.lazy),l=[],c;for(let d of i){if(s&&s.includes(d))continue;let f=Uut({key:d,route:e,manifest:n,mapRouteProperties:r});f&&(l.push(f),d===t&&(c=f))}let u=l.length>0?Promise.all(l).then(()=>{}):void 0;return u?.catch(()=>{}),c?.catch(()=>{}),{lazyRoutePromise:u,lazyHandlerPromise:c}}async function mDe(e){let t=e.matches.filter(s=>s.shouldLoad),n={};return(await Promise.all(t.map(s=>s.resolve()))).forEach((s,a)=>{n[t[a].route.id]=s}),n}async function xyn(e){return e.matches.some(t=>t.route.middleware)?qut(e,()=>mDe(e)):mDe(e)}function qut(e,t){return wyn(e,t,r=>{if(Pyn(r))throw r;return r},Nyn,n);function n(r,s,a){if(a)return Promise.resolve(Object.assign(a.value,{[s]:{type:"error",result:r}}));{let{matches:i}=e,l=Math.min(Math.max(i.findIndex(u=>u.route.id===s),0),Math.max(i.findIndex(u=>u.shouldCallHandler()),0)),c=sw(i,i[l].route.id).route.id;return Promise.resolve({[c]:{type:"error",result:r}})}}}async function wyn(e,t,n,r,s){let{matches:a,...i}=e,l=a.flatMap(u=>u.route.middleware?u.route.middleware.map(d=>[u.route.id,d]):[]);return await Vut(i,l,t,n,r,s)}async function Vut(e,t,n,r,s,a,i=0){let{request:l}=e;if(l.signal.aborted)throw l.signal.reason??new Error(`Request aborted: ${l.method} ${l.url}`);let c=t[i];if(!c)return await n();let[u,d]=c,f,p=async()=>{if(f)throw new Error("You may only call `next()` once per middleware");try{return f={value:await Vut(e,t,n,r,s,a,i+1)},f.value}catch(h){return f={value:await a(h,u,f)},f.value}};try{let h=await d(e,p),m=h!=null?r(h):void 0;return s(m)?m:f?m??f.value:(f={value:await p()},f.value)}catch(h){return await a(h,u,f)}}function Hut(e,t,n,r,s){let a=Uut({key:"middleware",route:r.route,manifest:t,mapRouteProperties:e}),i=byn(r.route,Su(n.method)?"action":"loader",t,e,s);return{middleware:a,route:i.lazyRoutePromise,handler:i.lazyHandlerPromise}}function mfe(e,t,n,r,s,a,i,l,c,u=null,d){let f=!1,p=Hut(e,t,n,a,i);return{...a,_lazyPromises:p,shouldLoad:c,shouldRevalidateArgs:u,shouldCallHandler(h){return f=!0,u?typeof d=="boolean"?A2(a,{...u,defaultShouldRevalidate:d}):typeof h=="boolean"?A2(a,{...u,defaultShouldRevalidate:h}):A2(a,u):c},resolve(h){let{lazy:m,loader:v,middleware:y}=a.route,b=f||c||h&&!Su(n.method)&&(m||v),S=y&&y.length>0&&!v&&!m;return b&&(Su(n.method)||!S)?kyn({request:n,path:r,pattern:s,match:a,lazyHandlerPromise:p?.handler,lazyRoutePromise:p?.route,handlerOverride:h,scopedContext:l}):Promise.resolve({type:"data",result:void 0})}}}function uj(e,t,n,r,s,a,i,l,c=null){return s.map(u=>u.route.id!==a.route.id?{...u,shouldLoad:!1,shouldRevalidateArgs:c,shouldCallHandler:()=>!1,_lazyPromises:Hut(e,t,n,u,i),resolve:()=>Promise.resolve({type:"data",result:void 0})}:mfe(e,t,n,r,kD(s),u,i,l,!0,c))}async function Syn(e,t,n,r,s,a,i){r.some(d=>d._lazyPromises?.middleware)&&await Promise.all(r.map(d=>d._lazyPromises?.middleware));let l={request:t,url:Wut(t,n),pattern:kD(r),params:r[0].params,context:a,matches:r},u=await e({...l,fetcherKey:s,runClientMiddleware:d=>{let f=l;return qut(f,()=>d({...f,fetcherKey:s,runClientMiddleware:()=>{throw new Error("Cannot call `runClientMiddleware()` from within an `runClientMiddleware` handler")}}))}});try{await Promise.all(r.flatMap(d=>[d._lazyPromises?.handler,d._lazyPromises?.route]))}catch{}return u}async function kyn({request:e,path:t,pattern:n,match:r,lazyHandlerPromise:s,lazyRoutePromise:a,handlerOverride:i,scopedContext:l}){let c,u,d=Su(e.method),f=d?"action":"loader",p=h=>{let m,v=new Promise((S,w)=>m=w);u=()=>m(),e.signal.addEventListener("abort",u);let y=S=>typeof h!="function"?Promise.reject(new Error(`You cannot call the handler for a route which defines a boolean "${f}" [routeId: ${r.route.id}]`)):h({request:e,url:Wut(e,t),pattern:n,params:r.params,context:l},...S!==void 0?[S]:[]),b=(async()=>{try{return{type:"data",result:await(i?i(w=>y(w)):y())}}catch(S){return{type:"error",result:S}}})();return Promise.race([b,v])};try{let h=d?r.route.action:r.route.loader;if(s||a)if(h){let m,[v]=await Promise.all([p(h).catch(y=>{m=y}),s,a]);if(m!==void 0)throw m;c=v}else{await s;let m=d?r.route.action:r.route.loader;if(m)[c]=await Promise.all([p(m),a]);else if(f==="action"){let v=new URL(e.url),y=v.pathname+v.search;throw _h(405,{method:e.method,pathname:y,routeId:r.route.id})}else return{type:"data",result:void 0}}else if(h)c=await p(h);else{let m=new URL(e.url),v=m.pathname+m.search;throw _h(404,{pathname:v})}}catch(h){return{type:"error",result:h}}finally{u&&e.signal.removeEventListener("abort",u)}return c}async function Oyn(e){let t=e.headers.get("Content-Type");return t&&/\bapplication\/json\b/.test(t)?e.body==null?null:e.json():e.text()}async function _yn(e){let{result:t,type:n}=e;if(Lbe(t)){let r;try{r=await Oyn(t)}catch(s){return{type:"error",error:s}}return n==="error"?{type:"error",error:new SD(t.status,t.statusText,r),statusCode:t.status,headers:t.headers}:{type:"data",data:r,statusCode:t.status,headers:t.headers}}return n==="error"?SDe(t)?t.data instanceof Error?{type:"error",error:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:"error",error:Tyn(t),statusCode:YP(t)?t.status:void 0,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:"error",error:t,statusCode:YP(t)?t.status:void 0}:SDe(t)?{type:"data",data:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:"data",data:t}}function Cyn(e,t,n,r,s){let a=e.headers.get("Location");if(os(a,"Redirects returned/thrown from loaders/actions must have a Location header"),!$be(a)){let i=r.slice(0,r.findIndex(l=>l.route.id===n)+1);a=hfe(new URL(t.url),i,s,a),e.headers.set("Location",a)}return e}var gDe=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function vDe(e,t,n,r){if($be(e)){let s=e,a=s.startsWith("//")?new URL(t.protocol+s):new URL(s);if(gDe.includes(a.protocol))throw new Error("Invalid redirect location");let i=sm(a.pathname,n)!=null;if(a.origin===t.origin&&i)return Mbe(a.pathname)+a.search+a.hash}try{let s=r.createURL(e);if(gDe.includes(s.protocol))throw new Error("Invalid redirect location")}catch{}return e}function yE(e,t,n,r){let s=e.createURL(Zut(t)).toString(),a={signal:n};if(r&&Su(r.formMethod)){let{formMethod:i,formEncType:l}=r;a.method=i.toUpperCase(),l==="application/json"?(a.headers=new Headers({"Content-Type":l}),a.body=JSON.stringify(r.json)):l==="text/plain"?a.body=r.text:l==="application/x-www-form-urlencoded"&&r.formData?a.body=gfe(r.formData):a.body=r.formData}return new Request(s,a)}function Wut(e,t){let n=new URL(e.url),r=typeof t=="string"?_y(t):t;if(n.pathname=r.pathname||"/",r.search){let s=new URLSearchParams(r.search),a=s.getAll("index");s.delete("index");for(let i of a.filter(Boolean))s.append("index",i);n.search=s.size?`?${s.toString()}`:""}else n.search="";return n.hash=r.hash||"",n}function gfe(e){let t=new URLSearchParams;for(let[n,r]of e.entries())t.append(n,typeof r=="string"?r:r.name);return t}function yDe(e){let t=new FormData;for(let[n,r]of e.entries())t.append(n,r);return t}function Eyn(e,t,n,r=!1,s=!1){let a={},i=null,l,c=!1,u={},d=n&&up(n[1])?n[1].error:void 0;return e.forEach(f=>{if(!(f.route.id in t))return;let p=f.route.id,h=t[p];if(os(!Sk(h),"Cannot handle redirect results in processLoaderData"),up(h)){let m=h.error;if(d!==void 0&&(m=d,d=void 0),i=i||{},s)i[p]=m;else{let v=sw(e,p);i[v.route.id]==null&&(i[v.route.id]=m)}r||(a[p]=Fut),c||(c=!0,l=YP(h.error)?h.error.status:500),h.headers&&(u[p]=h.headers)}else a[p]=h.data,h.statusCode&&h.statusCode!==200&&!c&&(l=h.statusCode),h.headers&&(u[p]=h.headers)}),d!==void 0&&n&&(i={[n[0]]:d},n[2]&&(a[n[2]]=void 0)),{loaderData:a,errors:i,statusCode:l||200,loaderHeaders:u}}function bDe(e,t,n,r,s,a,i){let{loaderData:l,errors:c}=Eyn(t,n,r);return s.filter(u=>!u.matches||u.matches.some(d=>d.shouldLoad)).forEach(u=>{let{key:d,match:f,controller:p}=u;if(p&&p.signal.aborted)return;let h=a[d];if(os(h,"Did not find corresponding fetcher result"),up(h)){let m=sw(e.matches,f?.route.id);c&&c[m.route.id]||(c={...c,[m.route.id]:h.error}),i.delete(d)}else if(Sk(h))os(!1,"Unhandled fetcher revalidation redirect");else{let m=hv(h.data);i.set(d,m)}}),{loaderData:l,errors:c}}function xDe(e,t,n,r){let s=Object.entries(t).filter(([,a])=>a!==Fut).reduce((a,[i,l])=>(a[i]=l,a),{});for(let a of n){let i=a.route.id;if(!t.hasOwnProperty(i)&&e.hasOwnProperty(i)&&a.route.loader&&(s[i]=e[i]),r&&r.hasOwnProperty(i))break}return s}function wDe(e){return e?up(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function sw(e,t){return(t?e.slice(0,e.findIndex(r=>r.route.id===t)+1):[...e]).reverse().find(r=>r.route.hasErrorBoundary===!0)||e[0]}function SL(e){let t=e.length===1?e[0]:e.find(n=>n.index||!n.path||n.path==="/")||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:t}],route:t}}function _h(e,{pathname:t,routeId:n,method:r,type:s,message:a}={}){let i="Unknown Server Error",l="Unknown @remix-run/router error";return e===400?(i="Bad Request",r&&t&&n?l=`You made a ${r} request to "${t}" but did not provide a \`loader\` for route "${n}", so there is no way to handle the request.`:s==="invalid-body"&&(l="Unable to encode submission body")):e===403?(i="Forbidden",l=`Route "${n}" does not match URL "${t}"`):e===404?(i="Not Found",l=`No route matches URL "${t}"`):e===405&&(i="Method Not Allowed",r&&t&&n?l=`You made a ${r.toUpperCase()} request to "${t}" but did not provide an \`action\` for route "${n}", so there is no way to handle the request.`:r&&(l=`Invalid request method "${r.toUpperCase()}"`)),new SD(e||500,i,new Error(l),!0)}function kL(e){let t=Object.entries(e);for(let n=t.length-1;n>=0;n--){let[r,s]=t[n];if(Sk(s))return{key:r,result:s}}}function Zut(e){let t=typeof e=="string"?_y(e):e;return cy({...t,hash:""})}function jyn(e,t){return e.pathname!==t.pathname||e.search!==t.search?!1:e.hash===""?t.hash!=="":e.hash===t.hash?!0:t.hash!==""}function Tyn(e){return new SD(e.init?.status??500,e.init?.statusText??"Internal Server Error",e.data)}function Nyn(e){return e!=null&&typeof e=="object"&&Object.entries(e).every(([t,n])=>typeof t=="string"&&Iyn(n))}function Iyn(e){return e!=null&&typeof e=="object"&&"type"in e&&"result"in e&&(e.type==="data"||e.type==="error")}function Ayn(e){return Lbe(e.result)&&Dut.has(e.result.status)}function up(e){return e.type==="error"}function Sk(e){return(e&&e.type)==="redirect"}function SDe(e){return typeof e=="object"&&e!=null&&"type"in e&&"data"in e&&"init"in e&&e.type==="DataWithResponseInit"}function Lbe(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.headers=="object"&&typeof e.body<"u"}function Ryn(e){return Dut.has(e)}function Pyn(e){return Lbe(e)&&Ryn(e.status)&&e.headers.has("Location")}function $yn(e){return uyn.has(e.toUpperCase())}function Su(e){return lyn.has(e.toUpperCase())}function Fbe(e){return new URLSearchParams(e).getAll("index").some(t=>t==="")}function IF(e,t){let n=typeof t=="string"?_y(t).search:t.search;if(e[e.length-1].route.index&&Fbe(n||""))return e[e.length-1];let r=Aut(e);return r[r.length-1]}function kDe(e){let{formMethod:t,formAction:n,formEncType:r,text:s,formData:a,json:i}=e;if(!(!t||!n||!r)){if(s!=null)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:void 0,text:s};if(a!=null)return{formMethod:t,formAction:n,formEncType:r,formData:a,json:void 0,text:void 0};if(i!==void 0)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:i,text:void 0}}}function vX(e,t,n,r){return r?{state:"loading",location:e,matches:t,historyAction:n,formMethod:r.formMethod,formAction:r.formAction,formEncType:r.formEncType,formData:r.formData,json:r.json,text:r.text}:{state:"loading",location:e,matches:t,historyAction:n,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function Myn(e,t,n,r){return{state:"submitting",location:e,matches:t,historyAction:n,formMethod:r.formMethod,formAction:r.formAction,formEncType:r.formEncType,formData:r.formData,json:r.json,text:r.text}}function RA(e,t){return e?{state:"loading",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t}:{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function Dyn(e,t){return{state:"submitting",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0}}function hv(e){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function Lyn(e,t){try{let n=e.sessionStorage.getItem(Lut);if(n){let r=JSON.parse(n);for(let[s,a]of Object.entries(r||{}))a&&Array.isArray(a)&&t.set(s,new Set(a||[]))}}catch{}}function Fyn(e,t){if(t.size>0){let n={};for(let[r,s]of t)n[r]=[...s];try{e.sessionStorage.setItem(Lut,JSON.stringify(n))}catch(r){Jo(!1,`Failed to save applied view transitions in sessionStorage (${r}).`)}}}function ODe(){let e,t,n=new Promise((r,s)=>{e=async a=>{r(a);try{await n}catch{}},t=async a=>{s(a);try{await n}catch{}}});return{promise:n,resolve:e,reject:t}}var v_=g.createContext(null);v_.displayName="DataRouter";var OD=g.createContext(null);OD.displayName="DataRouterState";var Gut=g.createContext(!1);function Qut(){return g.useContext(Gut)}var zbe=g.createContext({isTransitioning:!1});zbe.displayName="ViewTransition";var Yut=g.createContext(new Map);Yut.displayName="Fetchers";var zyn=g.createContext(null);zyn.displayName="Await";var Yp=g.createContext(null);Yp.displayName="Navigation";var Cq=g.createContext(null);Cq.displayName="Location";var gm=g.createContext({outlet:null,matches:[],isDataRoute:!1});gm.displayName="Route";var Bbe=g.createContext(null);Bbe.displayName="RouteError";var Xut="REACT_ROUTER_ERROR",Byn="REDIRECT",Uyn="ROUTE_ERROR_RESPONSE";function qyn(e){if(e.startsWith(`${Xut}:${Byn}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function Vyn(e){if(e.startsWith(`${Xut}:${Uyn}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new SD(t.status,t.statusText,t.data)}catch{}}function Hyn(e,{relative:t}={}){os(kN(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=g.useContext(Yp),{hash:s,pathname:a,search:i}=_D(e,{relative:t}),l=a;return n!=="/"&&(l=a==="/"?n:Wh([n,a])),r.createHref({pathname:l,search:i,hash:s})}function kN(){return g.useContext(Cq)!=null}function Lo(){return os(kN(),"useLocation() may be used only in the context of a <Router> component."),g.useContext(Cq).location}var Kut="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Jut(e){g.useContext(Yp).static||g.useLayoutEffect(e)}function bs(){let{isDataRoute:e}=g.useContext(gm);return e?ibn():Wyn()}function Wyn(){os(kN(),"useNavigate() may be used only in the context of a <Router> component.");let e=g.useContext(v_),{basename:t,navigator:n}=g.useContext(Yp),{matches:r}=g.useContext(gm),{pathname:s}=Lo(),a=JSON.stringify(_q(r)),i=g.useRef(!1);return Jut(()=>{i.current=!0}),g.useCallback((c,u={})=>{if(Jo(i.current,Kut),!i.current)return;if(typeof c=="number"){n.go(c);return}let d=wD(c,JSON.parse(a),s,u.relative==="path");e==null&&t!=="/"&&(d.pathname=d.pathname==="/"?t:Wh([t,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[t,n,a,s,e])}var Zyn=g.createContext(null);function Gyn(e){let t=g.useContext(gm).outlet;return g.useMemo(()=>t&&g.createElement(Zyn.Provider,{value:e},t),[t,e])}function ur(){let{matches:e}=g.useContext(gm);return e[e.length-1]?.params??{}}function _D(e,{relative:t}={}){let{matches:n}=g.useContext(gm),{pathname:r}=Lo(),s=JSON.stringify(_q(n));return g.useMemo(()=>wD(e,JSON.parse(s),r,t==="path"),[e,s,r,t])}function Qyn(e,t,n){os(kN(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=g.useContext(Yp),{matches:s}=g.useContext(gm),a=s[s.length-1],i=a?a.params:{},l=a?a.pathname:"/",c=a?a.pathnameBase:"/",u=a&&a.route;{let y=u&&u.path||"";ndt(l,!u||y.endsWith("*")||y.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${y}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
@@ -333,7 +333,7 @@ attempted value: ${i}
333
333
  \${}
334
334
  }
335
335
  }`,{label:"class",detail:"definition",type:"keyword"}),zd('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),zd('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],sbt=Wwe.concat([zd("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),zd("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),zd("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),GLe=new lgt,abt=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 j9n=["FunctionDeclaration"],T9n={FunctionDeclaration:ZA("function"),ClassDeclaration:ZA("class"),ClassExpression:()=>!0,EnumDeclaration:ZA("constant"),TypeAliasDeclaration:ZA("type"),NamespaceDeclaration:ZA("namespace"),VariableDefinition(e,t){e.matchContext(j9n)||t(e,"variable")},TypeDefinition(e,t){t(e,"type")},__proto__:null};function ibt(e,t){let n=GLe.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(Fa.IncludeAnonymous).iterate(i=>{if(s)s=!1;else if(i.name){let l=T9n[i.name];if(l&&l(i,a)||abt.has(i.name))return!1}else if(i.to-i.from>8192){for(let l of ibt(e,i.node))r.push(l);return!1}}),GLe.set(t,r),r}const w7=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,Zwe=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function obt(e){let t=hi(e.state).resolveInner(e.pos,-1);if(Zwe.indexOf(t.name)>-1)return null;let n=t.name=="VariableName"||t.to-t.from<20&&w7.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let r=[];for(let s=t;s;s=s.parent)abt.has(s.name)&&(r=r.concat(ibt(e.state.doc,s)));return{options:r,from:n?t.from:e.pos,validFor:w7}}function LK(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 lbt(e){let t=r=>e.state.doc.sliceString(r.from,r.to),n=hi(e.state).resolveInner(e.pos,-1);return n.name=="PropertyName"?LK(t,n.parent,t(n)):(n.name=="."||n.name=="?.")&&n.parent.name=="MemberExpression"?LK(t,n.parent,""):Zwe.indexOf(n.name)>-1?null:n.name=="VariableName"||n.to-n.from<20&&w7.test(t(n))?{path:[],name:t(n)}:n.name=="MemberExpression"?LK(t,n,""):e.explicit?{path:[],name:""}:null}function N9n(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 I9n(e){let t=new Map;return n=>{let r=lbt(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=N9n(s,!r.path.length)),{from:n.pos-r.name.length,options:a,validFor:w7}}}const Zh=jO.define({name:"javascript",parser:E9n.configure({props:[N_.add({IfStatement:Sj({except:/^\s*({|else\b)/}),TryStatement:Sj({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:_4n,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:O4n({closing:"}"}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":Sj({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}}),I_.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":Cwe,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:"$"}}),cbt={test:e=>/^JSX/.test(e.name),facet:xV({commentTokens:{block:{open:"{/*",close:"*/}"}}})},Gwe=Zh.configure({dialect:"ts"},"typescript"),Qwe=Zh.configure({dialect:"jsx",props:[kwe.add(e=>e.isTop?[cbt]:void 0)]}),Ywe=Zh.configure({dialect:"jsx ts",props:[kwe.add(e=>e.isTop?[cbt]:void 0)]},"typescript");let ubt=e=>({label:e,type:"keyword"});const dbt="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(ubt),A9n=dbt.concat(["declare","implements","private","protected","public"].map(ubt));function S7(e={}){let t=e.jsx?e.typescript?Ywe:Qwe:e.typescript?Gwe:Zh,n=e.typescript?sbt.concat(A9n):Wwe.concat(dbt);return new NO(t,[Zh.data.of({autocomplete:u5n(Zwe,cyt(n))}),Zh.data.of({autocomplete:obt}),e.jsx?fbt:[]])}function R9n(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 QLe(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 P9n=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),fbt=It.inputHandler.of((e,t,n,r,s)=>{if((P9n?e.composing:e.compositionStarted)||e.state.readOnly||t!=n||r!=">"&&r!="/"||!Zh.isActiveAt(e.state,t,-1))return!1;let a=s(),{state:i}=a,l=i.changeByRange(c=>{var u;let{head:d}=c,f=hi(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=QLe(i.doc,m.firstChild,d))||((u=m.firstChild)===null||u===void 0?void 0:u.name)=="JSXFragmentTag")){let v=`${p}>`;return{range:xt.cursor(d+v.length,-1),changes:{from:d,insert:v}}}}else if(r==">"){let h=R9n(f);if(h&&h.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(i.doc.sliceString(d,d+2))&&(p=QLe(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 $9n(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 Zh.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(M9n(u,r.doc,c))}return s}}function YLe(e,t,n,r){return n.line(e+r.line).from+t+(e==1?r.col-1:-1)}function M9n(e,t,n){let r=YLe(e.line,e.column,t,n),s={from:r,to:e.endLine!=null&&e.endColumn!=1?YLe(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 b6=Object.freeze(Object.defineProperty({__proto__:null,autoCloseTags:fbt,completionPath:lbt,esLint:$9n,javascript:S7,javascriptLanguage:Zh,jsxLanguage:Qwe,localCompletionSource:obt,scopeCompletionSource:I9n,snippets:Wwe,tsxLanguage:Ywe,typescriptLanguage:Gwe,typescriptSnippets:sbt},Symbol.toStringTag,{value:"Module"})),GA=["_blank","_self","_top","_parent"],FK=["ascii","utf-8","utf-16","latin1","latin1"],zK=["get","post","put","delete"],BK=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],Gf=["true","false"],Jn={},D9n={a:{attrs:{href:null,ping:null,type:null,media:null,target:GA,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:GA}},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:BK,formmethod:zK,formnovalidate:["novalidate"],formtarget:GA,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":FK,autocomplete:["on","off"],enctype:BK,method:zK,novalidate:["novalidate"],target:GA}},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:BK,formmethod:zK,formnovalidate:["novalidate"],formtarget:GA,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:FK,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:FK}},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},pbt={accesskey:null,class:null,contenteditable:Gf,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:Gf,autocorrect:Gf,autocapitalize:Gf,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":Gf,"aria-autocomplete":["inline","list","both","none"],"aria-busy":Gf,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":Gf,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":Gf,"aria-hidden":Gf,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":Gf,"aria-multiselectable":Gf,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":Gf,"aria-relevant":null,"aria-required":Gf,"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},hbt="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 hbt)pbt[e]=null;class Y${constructor(t,n){this.tags={...D9n,...t},this.globalAttrs={...pbt,...n},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}}Y$.default=new Y$;function yT(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 bT(e,t=!1){for(;e;e=e.parent)if(e.name=="Element")if(t)t=!1;else return e;return null}function mbt(e,t,n){let r=n.tags[yT(e,bT(t))];return r?.children||n.allTags}function Xwe(e,t){let n=[];for(let r=bT(t);r&&!r.type.isTop;r=bT(r.parent)){let s=yT(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 gbt=/^[:\-\.\w\u00b7-\uffff]*$/;function XLe(e,t,n,r,s){let a=/\s*>/.test(e.sliceDoc(s,s+5))?"":">",i=bT(n,n.name=="StartTag"||n.name=="TagName");return{from:r,to:s,options:mbt(e.doc,i,t).map(l=>({label:l,type:"type"})).concat(Xwe(e.doc,n).map((l,c)=>({label:"/"+l,apply:"/"+l+a,type:"type",boost:99-c}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function KLe(e,t,n,r){let s=/\s*>/.test(e.sliceDoc(r,r+5))?"":">";return{from:n,to:r,options:Xwe(e.doc,t).map((a,i)=>({label:a,apply:a+s,type:"type",boost:99-i})),validFor:gbt}}function L9n(e,t,n,r){let s=[],a=0;for(let i of mbt(e.doc,n,t))s.push({label:"<"+i,type:"type"});for(let i of Xwe(e.doc,n))s.push({label:"</"+i+">",type:"type",boost:99-a++});return{from:r,to:r,options:s,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function F9n(e,t,n,r,s){let a=bT(n),i=a?t.tags[yT(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:gbt}}function z9n(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=bT(n),p=f?t.tags[yT(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 vbt(e,t){let{state:n,pos:r}=t,s=hi(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)?KLe(n,s,s.from,r):XLe(n,e,s,s.from,r):s.name=="StartTag"||s.name=="IncompleteTag"?XLe(n,e,s,r,r):s.name=="StartCloseTag"||s.name=="IncompleteCloseTag"?KLe(n,s,r,r):s.name=="OpenTag"||s.name=="SelfClosingTag"||s.name=="AttributeName"?F9n(n,e,s,s.name=="AttributeName"?s.from:r,r):s.name=="Is"||s.name=="AttributeValue"||s.name=="UnquotedAttributeValue"?z9n(n,e,s,s.name=="Is"?r:s.from,r):t.explicit&&(a.name=="Element"||a.name=="Text"||a.name=="Document")?L9n(n,e,s,r):null}function B9n(e){return vbt(Y$.default,e)}function U9n(e){let{extraTags:t,extraGlobalAttributes:n}=e,r=n||t?new Y$(t,n):Y$.default;return s=>vbt(r,s)}const q9n=Zh.parser.configure({top:"SingleExpression"}),ybt=[{tag:"script",attrs:e=>e.type=="text/typescript"||e.lang=="ts",parser:Gwe.parser},{tag:"script",attrs:e=>e.type=="text/babel"||e.type=="text/jsx",parser:Qwe.parser},{tag:"script",attrs:e=>e.type=="text/typescript-jsx",parser:Ywe.parser},{tag:"script",attrs(e){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(e.type)},parser:q9n},{tag:"script",attrs(e){return!e.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(e.type)},parser:Zh.parser},{tag:"style",attrs(e){return(!e.lang||e.lang=="css")&&(!e.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(e.type))},parser:x7.parser}],bbt=[{name:"style",parser:x7.parser.configure({top:"Styles"})}].concat(hbt.map(e=>({name:e,parser:Zh.parser}))),xbt=jO.define({name:"html",parser:h6n.configure({props:[N_.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}}),I_.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}}}),nyt.add({"OpenTag CloseTag":e=>e.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),YF=xbt.configure({wrap:Xyt(ybt,bbt)});function V9n(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=Xyt((e.nestedLanguages||[]).concat(ybt),(e.nestedAttributes||[]).concat(bbt)));let r=n?xbt.configure({wrap:n,dialect:t}):t?YF.configure({dialect:t}):YF;return new NO(r,[YF.data.of({autocomplete:U9n(e)}),e.autoCloseTags!==!1?H9n:[],S7().support,Y6n().support])}const JLe=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),H9n=It.inputHandler.of((e,t,n,r,s)=>{if(e.composing||e.state.readOnly||t!=n||r!=">"&&r!="/"||!YF.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=hi(i).resolveInner(h,-1),v;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"&&(v=yT(i.doc,y.parent,h))&&!JLe.has(v)){let b=h+(i.doc.sliceString(h,h+1)===">"?1:0),S=`</${v}>`;return{range:c,changes:{from:h,to:b,insert:S}}}}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"&&(v=yT(i.doc,y,h))&&!JLe.has(v)){let b=h+(i.doc.sliceString(h,h+1)===">"?1:0),S=`${v}>`;return{range:xt.cursor(h+S.length,-1),changes:{from:h,to:b,insert:S}}}}return{range:c}});return l.changes.empty?!1:(e.dispatch([a,i.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),wbt=xV({commentTokens:{block:{open:"<!--",close:"-->"}}}),Sbt=new Pr,kbt=gLn.configure({props:[I_.add(e=>!e.is("Block")||e.is("Document")||ghe(e)!=null||W9n(e)?void 0:(t,n)=>({from:n.doc.lineAt(t.from).to,to:t.to})),Sbt.add(ghe),N_.add({Document:()=>null}),vw.add({Document:wbt})]});function ghe(e){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(e.name);return t?+t[1]:void 0}function W9n(e){return e.name=="OrderedList"||e.name=="BulletList"}function Z9n(e,t){let n=e;for(;;){let r=n.nextSibling,s;if(!r||(s=ghe(r.type))!=null&&s<=t)break;n=r}return n.to}const G9n=Vvt.of((e,t,n)=>{for(let r=hi(e).resolveInner(n,-1);r&&!(r.from<t);r=r.parent){let s=r.type.prop(Sbt);if(s==null)continue;let a=Z9n(r,s);if(a>n)return{from:n,to:a}}return null});function Kwe(e){return new bp(wbt,e,[],"markdown")}const Obt=Kwe(kbt),Q9n=kbt.configure([ELn,TLn,jLn,NLn,{props:[I_.add({Table:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}]),RO=Kwe(Q9n);function Y9n(e,t){return n=>{if(n&&e){let r=null;if(n=/\S*/.exec(n)[0],typeof e=="function"?r=e(n):r=Km.matchLanguageName(e,n,!0),r instanceof Km)return r.support?r.support.language.parser:TO.getSkippingParser(r.load());if(r)return r.parser}return t?t.parser:null}}class UK{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(+Cbt(this.item,t)[2]+n):"";return this.spaceBefore+r+this.type+this.spaceAfter}}function _bt(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 UK(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 UK(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 UK(a.parent,c,c+d,i[1],u,f,a))}}return r}function Cbt(e,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from,e.from+10))}function qK(e,t,n,r=0){for(let s=-1,a=e;;){if(a.name=="ListItem"){let l=Cbt(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 Jwe(e,t){let n=/^[ \t]*/.exec(e)[0].length;if(!n||t.facet(zN)!=" ")return e;let r=Eg(e,4,n),s="";for(let a=r;a>0;)a>=4?(s+=" ",a-=4):(s+=" ",a--);return s+e.slice(n)}const Ebt=(e={})=>({state:t,dispatch:n})=>{let r=hi(t),{doc:s}=t,a=null,i=t.changeByRange(l=>{if(!l.empty||!RO.isActiveAt(t,l.from,-1)&&!RO.isActiveAt(t,l.from,1))return a={range:l};let c=l.from,u=s.lineAt(c),d=_bt(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,S=f.node.getChild("ListItem","ListItem");if(b.to>=c||S&&S.to<c||u.from>0&&!/[^\s>]/.test(s.lineAt(u.from-1).text)||e.nonTightLists===!1){let w=d.length>1?d[d.length-2]:null,k,_="";w&&w.item?(k=u.from+w.from,_=w.marker(s,1)):k=u.from+(w?w.to:0);let C=[{from:k,to:c,insert:_}];return f.node.name=="OrderedList"&&qK(f.item,s,C,-2),w&&w.node.name=="OrderedList"&&qK(w.item,s,C),{range:xt.cursor(k+_.length),changes:C}}else{let w=t6e(d,t,u);return{range:xt.cursor(c+w.length+1),changes:{from:u.from,insert:w+t.lineBreak}}}}if(f.node.name=="Blockquote"&&p&&u.from){let b=s.lineAt(u.from-1),S=/>\s*$/.exec(b.text);if(S&&S.index==f.from){let w=t.changes([{from:b.from+S.index,to:b.to},{from:u.from+f.from,to:u.to}]);return{range:l.map(w),changes:w}}}let h=[];f.node.name=="OrderedList"&&qK(f.item,s,h);let m=f.item&&f.item.from<u.from,v="";if(!m||/^[\s\d.)\-+*>]*/.exec(u.text)[0].length>=f.to)for(let b=0,S=d.length-1;b<=S;b++)v+=b==S&&!m?d[b].marker(s,1):d[b].blank(b<S?Eg(u.text,4,d[b+1].from)-v.length:null);let y=c;for(;y>u.from&&/\s/.test(u.text.charAt(y-u.from-1));)y--;return v=Jwe(v,t),X9n(f.node,t.doc)&&(v=t6e(d,t,u)+t.lineBreak+v),h.push({from:y,to:c,insert:t.lineBreak+v}),{range:xt.cursor(y+v.length+1),changes:h}});return a?!1:(n(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0)},jbt=Ebt();function e6e(e){return e.name=="QuoteMark"||e.name=="ListMark"}function X9n(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 t6e(e,t,n){let r="";for(let s=0,a=e.length-2;s<=a;s++)r+=e[s].blank(s<a?Eg(n.text,4,e[s+1].from)-r.length:null,s<a);return Jwe(r,t)}function K9n(e,t){let n=e.resolveInner(t,-1),r=t;e6e(n)&&(r=n.from,n=n.parent);for(let s;s=n.childBefore(r);)if(e6e(s))r=s.from;else if(s.name=="OrderedList"||s.name=="BulletList")n=s.lastChild,r=n.to;else break;return n}const Tbt=({state:e,dispatch:t})=>{let n=hi(e),r=null,s=e.changeByRange(a=>{let i=a.from,{doc:l}=e;if(a.empty&&RO.isActiveAt(e,a.from)){let c=l.lineAt(i),u=_bt(K9n(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:xt.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(Eg(c.text,4,d.to)-Eg(c.text,4,d.from));return p==c.from&&(h=Jwe(h,e)),{range:xt.cursor(p+h.length),changes:{from:p,to:c.from+d.to,insert:h}}}if(p<i)return{range:xt.cursor(p),changes:{from:p,to:i}}}}}return r={range:a}});return r?!1:(t(e.update(s,{scrollIntoView:!0,userEvent:"delete"})),!0)},Nbt=[{key:"Enter",run:jbt},{key:"Backspace",run:Tbt}],Ibt=V9n({matchClosingTags:!1});function e1e(e={}){let{codeLanguages:t,defaultCodeLanguage:n,addKeymap:r=!0,base:{parser:s}=Obt,completeHTMLTags:a=!0,pasteURLAsLink:i=!0,htmlTagLanguage:l=Ibt}=e;if(!(s instanceof OV))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let c=e.extensions?[e.extensions]:[],u=[l.support,G9n],d;i&&u.push(Abt),n instanceof NO?(u.push(n.support),d=n.language):n&&(d=n);let f=t||d?Y9n(t,d):void 0;c.push(yLn({codeParser:f,htmlParser:l.language.parser})),r&&u.push(Mg.high(FN.of(Nbt)));let p=Kwe(s.configure(c));return a&&u.push(p.data.of({autocomplete:J9n})),new NO(p,u)}function J9n(e){let{state:t,pos:n}=e,r=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(n-25,n));if(!r)return null;let s=hi(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:eFn(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}let VK=null;function eFn(){if(VK)return VK;let e=B9n(new Nwe(is.create({extensions:Ibt}),0,!0));return VK=e?e.options:[]}const tFn=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,Abt=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),!RO.isActiveAt(t.state,r.from,1)))return!1;let a=hi(t.state),i=!1;return a.iterate({from:r.from,to:r.to,enter:l=>{(l.from>r.from||tFn.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)}}),nFn=Object.freeze(Object.defineProperty({__proto__:null,commonmarkLanguage:Obt,deleteMarkupBackward:Tbt,insertNewlineContinueMarkup:jbt,insertNewlineContinueMarkupCommand:Ebt,markdown:e1e,markdownKeymap:Nbt,markdownLanguage:RO,pasteURLAsLink:Abt},Symbol.toStringTag,{value:"Module"}));function PO(){return PO=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},PO.apply(null,arguments)}var rFn=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=Dg.define(a),f=[u,B1(d)];return f},sFn={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)"},aFn=[{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"}],UN=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 rFn({theme:r,settings:PO({},sFn,a),styles:[...aFn,...l]})};UN();function Rbt(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 iFn=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=n1e(e.state,n.from);return r.line?oFn(e):r.block?cFn(e):!1};function t1e(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 oFn=t1e(fFn,0),lFn=t1e(Pbt,0),cFn=t1e((e,t)=>Pbt(e,t,dFn(t)),0);function n1e(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const QA=50;function uFn(e,{open:t,close:n},r,s){let a=e.sliceDoc(r-QA,r),i=e.sliceDoc(s,s+QA),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*QA?d=f=e.sliceDoc(r,s):(d=e.sliceDoc(r,r+QA),f=e.sliceDoc(s-QA,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 dFn(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 Pbt(e,t,n=t.selection.ranges){let r=n.map(a=>n1e(t,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,i)=>uFn(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 fFn(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=n1e(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 vhe=Py.define(),pFn=Py.define(),hFn=On.define(),$bt=On.define({combine(e){return $y(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)})}}),Mbt=gl.define({create(){return zv.empty},update(e,t){let n=t.state.facet($bt),r=t.annotation(vhe);if(r){let c=tf.fromTransaction(t,r.selection),u=r.side,d=u==0?e.undone:e.done;return c?d=k7(d,d.length,n.minDepth,c):d=Fbt(d,t.startState.selection),new zv(u==0?r.rest:d,u==0?d:r.rest)}let s=t.annotation(pFn);if((s=="full"||s=="before")&&(e=e.isolate()),t.annotation(Tl.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=tf.fromTransaction(t),i=t.annotation(Tl.time),l=t.annotation(Tl.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 zv(e.done.map(tf.fromJSON),e.undone.map(tf.fromJSON))}});function mFn(e={}){return[Mbt,$bt.of(e),It.domEventHandlers({beforeinput(t,n){let r=t.inputType=="historyUndo"?Dbt:t.inputType=="historyRedo"?yhe:null;return r?(t.preventDefault(),r(n)):!1}})]}function _V(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let s=n.field(Mbt,!1);if(!s)return!1;let a=s.pop(e,n,t);return a?(r(a),!0):!1}}const Dbt=_V(0,!1),yhe=_V(1,!1),gFn=_V(0,!0),vFn=_V(1,!0);class tf{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 tf(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 tf(t.changes&&El.fromJSON(t.changes),[],t.mapped&&Kv.fromJSON(t.mapped),t.startSelection&&xt.fromJSON(t.startSelection),t.selectionsAfter.map(xt.fromJSON))}static fromTransaction(t,n){let r=Lh;for(let s of t.startState.facet(hFn)){let a=s(t);a.length&&(r=r.concat(a))}return!r.length&&t.changes.empty?null:new tf(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,Lh)}static selection(t){return new tf(void 0,Lh,void 0,void 0,t)}}function k7(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 yFn(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 bFn(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function Lbt(e,t){return e.length?t.length?e.concat(t):e:t}const Lh=[],xFn=200;function Fbt(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-xFn));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),k7(e,e.length-1,1e9,n.setSelAfter(r)))}else return[tf.selection([t])]}function wFn(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 HK(e,t){if(!e.length)return e;let n=e.length,r=Lh;for(;n;){let s=SFn(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?[tf.selection(r)]:Lh}function SFn(e,t,n){let r=Lbt(e.selectionsAfter.length?e.selectionsAfter.map(l=>l.map(t)):Lh,n);if(!e.changes)return tf.selection(r);let s=e.changes.map(t),a=t.mapDesc(e.changes,!0),i=e.mapped?e.mapped.composeDesc(a):a;return new tf(s,vr.mapEffects(e.effects,t),i,e.startSelection.map(a),r)}const kFn=/^(input\.type|delete)($|\.)/;class zv{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 zv(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||kFn.test(r))&&(!l.selectionsAfter.length&&n-this.prevTime<s.newGroupDelay&&s.joinToEvent(a,yFn(l.changes,t.changes))||r=="input.type.compose")?i=k7(i,i.length-1,s.minDepth,new tf(t.changes.compose(l.changes),Lbt(vr.mapEffects(t.effects,l.changes),l.effects),l.mapped,l.startSelection,Lh)):i=k7(i,i.length,s.minDepth,t),new zv(i,Lh,n,r)}addSelection(t,n,r,s){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:Lh;return a.length>0&&n-this.prevTime<s&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&bFn(a[a.length-1],t)?this:new zv(Fbt(this.done,t),this.undone,n,r)}addMapping(t){return new zv(HK(this.done,t),HK(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:vhe.of({side:t,rest:wFn(s),selection:i}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(a.changes){let l=s.length==1?Lh:s.slice(0,s.length-1);return a.mapped&&(l=HK(l,a.mapped)),n.update({changes:a.changes,selection:a.startSelection,effects:a.effects,annotations:vhe.of({side:t,rest:l,selection:i}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}zv.empty=new zv(Lh,Lh);const OFn=[{key:"Mod-z",run:Dbt,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:yhe,preventDefault:!0},{linux:"Ctrl-Shift-z",run:yhe,preventDefault:!0},{key:"Mod-u",run:gFn,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:vFn,preventDefault:!0}];function qN(e,t){return xt.create(e.ranges.map(t),e.mainIndex)}function Lg(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function Fg({state:e,dispatch:t},n){let r=qN(e.selection,n);return r.eq(e.selection,!0)?!1:(t(Lg(e,r)),!0)}function CV(e,t){return xt.cursor(t?e.to:e.from)}function zbt(e,t){return Fg(e,n=>n.empty?e.moveByChar(n,t):CV(n,t))}function Vu(e){return e.textDirectionAt(e.state.selection.main.head)==Si.LTR}const Bbt=e=>zbt(e,!Vu(e)),Ubt=e=>zbt(e,Vu(e));function qbt(e,t){return Fg(e,n=>n.empty?e.moveByGroup(n,t):CV(n,t))}const _Fn=e=>qbt(e,!Vu(e)),CFn=e=>qbt(e,Vu(e));function EFn(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 EV(e,t,n){let r=hi(e).resolveInner(t.head),s=n?Pr.closedBy:Pr.openedBy;for(let c=t.head;;){let u=n?r.childAfter(c):r.childBefore(c);if(!u)break;EFn(e,u,s)?r=u:c=n?u.to:u.from}let a=r.type.prop(s),i,l;return a&&(i=n?Fv(e,r.from,1):Fv(e,r.to,-1))&&i.matched?l=n?i.end.to:i.end.from:l=n?r.to:r.from,xt.cursor(l,n?-1:1)}const jFn=e=>Fg(e,t=>EV(e.state,t,!Vu(e))),TFn=e=>Fg(e,t=>EV(e.state,t,Vu(e)));function Vbt(e,t){return Fg(e,n=>{if(!n.empty)return CV(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}const Hbt=e=>Vbt(e,!1),Wbt=e=>Vbt(e,!0);function Zbt(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 Gbt(e,t){let n=Zbt(e),{state:r}=e,s=qN(r.selection,i=>i.empty?e.moveVertically(i,t,n.height):CV(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(Lg(r,s),{effects:a}),!0}const n6e=e=>Gbt(e,!1),bhe=e=>Gbt(e,!0);function U1(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=xt.cursor(r.from+a))}return s}const NFn=e=>Fg(e,t=>U1(e,t,!0)),IFn=e=>Fg(e,t=>U1(e,t,!1)),AFn=e=>Fg(e,t=>U1(e,t,!Vu(e))),RFn=e=>Fg(e,t=>U1(e,t,Vu(e))),PFn=e=>Fg(e,t=>xt.cursor(e.lineBlockAt(t.head).from,1)),$Fn=e=>Fg(e,t=>xt.cursor(e.lineBlockAt(t.head).to,-1));function MFn(e,t,n){let r=!1,s=qN(e.selection,a=>{let i=Fv(e,a.head,-1)||Fv(e,a.head,1)||a.head>0&&Fv(e,a.head-1,1)||a.head<e.doc.length&&Fv(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 xt.cursor(l)});return r?(t(Lg(e,s)),!0):!1}const DFn=({state:e,dispatch:t})=>MFn(e,t);function xm(e,t){let n=qN(e.state.selection,r=>{let s=t(r);return xt.range(r.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(Lg(e.state,n)),!0)}function Qbt(e,t){return xm(e,n=>e.moveByChar(n,t))}const Ybt=e=>Qbt(e,!Vu(e)),Xbt=e=>Qbt(e,Vu(e));function Kbt(e,t){return xm(e,n=>e.moveByGroup(n,t))}const LFn=e=>Kbt(e,!Vu(e)),FFn=e=>Kbt(e,Vu(e)),zFn=e=>xm(e,t=>EV(e.state,t,!Vu(e))),BFn=e=>xm(e,t=>EV(e.state,t,Vu(e)));function Jbt(e,t){return xm(e,n=>e.moveVertically(n,t))}const ext=e=>Jbt(e,!1),txt=e=>Jbt(e,!0);function nxt(e,t){return xm(e,n=>e.moveVertically(n,t,Zbt(e).height))}const r6e=e=>nxt(e,!1),s6e=e=>nxt(e,!0),UFn=e=>xm(e,t=>U1(e,t,!0)),qFn=e=>xm(e,t=>U1(e,t,!1)),VFn=e=>xm(e,t=>U1(e,t,!Vu(e))),HFn=e=>xm(e,t=>U1(e,t,Vu(e))),WFn=e=>xm(e,t=>xt.cursor(e.lineBlockAt(t.head).from)),ZFn=e=>xm(e,t=>xt.cursor(e.lineBlockAt(t.head).to)),a6e=({state:e,dispatch:t})=>(t(Lg(e,{anchor:0})),!0),i6e=({state:e,dispatch:t})=>(t(Lg(e,{anchor:e.doc.length})),!0),o6e=({state:e,dispatch:t})=>(t(Lg(e,{anchor:e.selection.main.anchor,head:0})),!0),l6e=({state:e,dispatch:t})=>(t(Lg(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),GFn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),QFn=({state:e,dispatch:t})=>{let n=jV(e).map(({from:r,to:s})=>xt.range(r,Math.min(s+1,e.doc.length)));return t(e.update({selection:xt.create(n),userEvent:"select"})),!0},YFn=({state:e,dispatch:t})=>{let n=qN(e.selection,r=>{let s=hi(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 xt.range(l.to,l.from)}return r});return n.eq(e.selection)?!1:(t(Lg(e,n)),!0)};function rxt(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(Lg(n,xt.create(s,s.length-1))),!0)}const XFn=e=>rxt(e,!1),KFn=e=>rxt(e,!0),JFn=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=xt.create([n.main]):n.main.empty||(r=xt.create([xt.cursor(n.main.head)])),r?(t(Lg(e,r)),!0):!1};function d3(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=x6(e,c,!1)):c>i&&(n="delete.forward",c=x6(e,c,!0)),i=Math.min(i,c),l=Math.max(l,c)}else i=x6(e,i,!1),l=x6(e,l,!0);return i==l?{range:a}:{changes:{from:i,to:l},range:xt.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 x6(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 sxt=(e,t,n)=>d3(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=Eg(l,a.tabSize),d=u%IO(a)||IO(a);for(let f=0;f<d&&l[l.length-1-f]==" ";f++)s--;c=s}else c=xc(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=xc(i.text,c-i.from,!1,!1)+i.from);return c}),xhe=e=>sxt(e,!1,!0),axt=e=>sxt(e,!0,!1),ixt=(e,t)=>d3(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=xc(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}),oxt=e=>ixt(e,!1),e8n=e=>ixt(e,!0),t8n=e=>d3(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),n8n=e=>d3(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),r8n=e=>d3(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),s8n=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:ka.of(["",""])},range:xt.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},a8n=({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:xc(a.text,s-a.from,!1)+a.from,l=s==a.to?s+1:xc(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:xt.cursor(l)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function jV(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 lxt(e,t,n){if(e.readOnly)return!1;let r=[],s=[];for(let a of jV(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(xt.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(xt.range(c.anchor-l,c.head-l))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:xt.create(s,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}const i8n=({state:e,dispatch:t})=>lxt(e,t,!1),o8n=({state:e,dispatch:t})=>lxt(e,t,!0);function cxt(e,t,n){if(e.readOnly)return!1;let r=[];for(let a of jV(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 l8n=({state:e,dispatch:t})=>cxt(e,t,!1),c8n=({state:e,dispatch:t})=>cxt(e,t,!0),u8n=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(jV(t).map(({from:s,to:a})=>(s>0?s--:a<t.doc.length&&a++,{from:s,to:a}))),r=qN(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 d8n(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=hi(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(Pr.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 c6e=uxt(!1),f8n=uxt(!0);function uxt(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&&d8n(t,a);e&&(a=i=(i<=l.to?l:t.doc.lineAt(i)).to);let u=new wV(t,{simulateBreak:a,simulateDoubleBreak:!!c}),d=Owe(u,a);for(d==null&&(d=Eg(/^\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=["",U$(t,d)];return c&&f.push(U$(t,u.lineIndent(l.from,-1))),{changes:{from:a,to:i,insert:ka.of(f)},range:xt.cursor(a+1+f[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function r1e(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:xt.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const p8n=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new wV(e,{overrideIndentation:a=>{let i=n[a];return i??-1}}),s=r1e(e,(a,i,l)=>{let c=Owe(r,a.from);if(c==null)return;/\S/.test(a.text)||(c=0);let u=/^\s*/.exec(a.text)[0],d=U$(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},dxt=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(r1e(e,(n,r)=>{r.push({from:n.from,insert:e.facet(zN)})}),{userEvent:"input.indent"})),!0),fxt=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(r1e(e,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=Eg(s,e.tabSize),i=0,l=U$(e,Math.max(0,a-IO(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),h8n=e=>(e.setTabFocusMode(),!0),m8n=[{key:"Ctrl-b",run:Bbt,shift:Ybt,preventDefault:!0},{key:"Ctrl-f",run:Ubt,shift:Xbt},{key:"Ctrl-p",run:Hbt,shift:ext},{key:"Ctrl-n",run:Wbt,shift:txt},{key:"Ctrl-a",run:PFn,shift:WFn},{key:"Ctrl-e",run:$Fn,shift:ZFn},{key:"Ctrl-d",run:axt},{key:"Ctrl-h",run:xhe},{key:"Ctrl-k",run:t8n},{key:"Ctrl-Alt-h",run:oxt},{key:"Ctrl-o",run:s8n},{key:"Ctrl-t",run:a8n},{key:"Ctrl-v",run:bhe}],g8n=[{key:"ArrowLeft",run:Bbt,shift:Ybt,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:_Fn,shift:LFn,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:AFn,shift:VFn,preventDefault:!0},{key:"ArrowRight",run:Ubt,shift:Xbt,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:CFn,shift:FFn,preventDefault:!0},{mac:"Cmd-ArrowRight",run:RFn,shift:HFn,preventDefault:!0},{key:"ArrowUp",run:Hbt,shift:ext,preventDefault:!0},{mac:"Cmd-ArrowUp",run:a6e,shift:o6e},{mac:"Ctrl-ArrowUp",run:n6e,shift:r6e},{key:"ArrowDown",run:Wbt,shift:txt,preventDefault:!0},{mac:"Cmd-ArrowDown",run:i6e,shift:l6e},{mac:"Ctrl-ArrowDown",run:bhe,shift:s6e},{key:"PageUp",run:n6e,shift:r6e},{key:"PageDown",run:bhe,shift:s6e},{key:"Home",run:IFn,shift:qFn,preventDefault:!0},{key:"Mod-Home",run:a6e,shift:o6e},{key:"End",run:NFn,shift:UFn,preventDefault:!0},{key:"Mod-End",run:i6e,shift:l6e},{key:"Enter",run:c6e,shift:c6e},{key:"Mod-a",run:GFn},{key:"Backspace",run:xhe,shift:xhe,preventDefault:!0},{key:"Delete",run:axt,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:oxt,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:e8n,preventDefault:!0},{mac:"Mod-Backspace",run:n8n,preventDefault:!0},{mac:"Mod-Delete",run:r8n,preventDefault:!0}].concat(m8n.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),v8n=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:jFn,shift:zFn},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:TFn,shift:BFn},{key:"Alt-ArrowUp",run:i8n},{key:"Shift-Alt-ArrowUp",run:l8n},{key:"Alt-ArrowDown",run:o8n},{key:"Shift-Alt-ArrowDown",run:c8n},{key:"Mod-Alt-ArrowUp",run:XFn},{key:"Mod-Alt-ArrowDown",run:KFn},{key:"Escape",run:JFn},{key:"Mod-Enter",run:f8n},{key:"Alt-l",mac:"Ctrl-l",run:QFn},{key:"Mod-i",run:YFn,preventDefault:!0},{key:"Mod-[",run:fxt},{key:"Mod-]",run:dxt},{key:"Mod-Alt-\\",run:p8n},{key:"Shift-Mod-k",run:u8n},{key:"Shift-Mod-\\",run:DFn},{key:"Mod-/",run:iFn},{key:"Alt-A",run:lFn},{key:"Ctrl-m",mac:"Shift-Alt-m",run:h8n}].concat(g8n),y8n={key:"Tab",run:dxt,shift:fxt},u6e=typeof String.prototype.normalize=="function"?e=>e.normalize("NFKD"):e=>e;class _x{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(u6e(l)):u6e,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 Wd(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=awe(t),r=this.bufferStart+this.bufferPos;this.bufferPos+=Ev(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"&&(_x.prototype[Symbol.iterator]=function(){return this});const pxt={from:-1,to:-1,match:/.*/.exec(""),precise:!0},s1e="gm"+(/x/.unicode==null?"":"u");class hxt{constructor(t,n,r,s=0,a=t.length){if(this.text=t,this.to=a,this.curLine="",this.done=!1,this.value=pxt,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new mxt(t,n,r,s,a);this.re=new RegExp(n,s1e+(r?.ignoreCase?"i":"")),this.test=r?.test,this.iter=t.iter();let i=t.lineAt(s);this.curLineStart=i.from,this.matchPos=O7(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=O7(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 WK=new WeakMap;class Oj{constructor(t,n){this.from=t,this.text=n}get to(){return this.from+this.text.length}static get(t,n,r){let s=WK.get(t);if(!s||s.from>=r||s.to<=n){let l=new Oj(n,t.sliceString(n,r));return WK.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)),WK.set(t,new Oj(i,a)),new Oj(n,a.slice(n-i,r-i))}}class mxt{constructor(t,n,r,s,a){this.text=t,this.to=a,this.done=!1,this.value=pxt,this.matchPos=O7(t,s),this.re=new RegExp(n,s1e+(r?.ignoreCase?"i":"")),this.test=r?.test,this.flat=Oj.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=O7(this.text,s+(r==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Oj.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(hxt.prototype[Symbol.iterator]=mxt.prototype[Symbol.iterator]=function(){return this});function b8n(e){try{return new RegExp(e,s1e),!0}catch{return!1}}function O7(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 x8n=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:s}=t4n(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))),v=xt.cursor(m.from+Math.max(0,Math.min(p,m.length)));e.dispatch({effects:[r,It.scrollIntoView(v.from,{y:"center"})],selection:v})}),!0},w8n={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},S8n=On.define({combine(e){return $y(e,w8n,{highlightWordAroundCursor:(t,n)=>t||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function k8n(e){return[j8n,E8n]}const O8n=Cn.mark({class:"cm-selectionMatch"}),_8n=Cn.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function d6e(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=po.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=po.Word)}function C8n(e,t,n,r){return e(t.sliceDoc(n,n+1))==po.Word&&e(t.sliceDoc(r-1,r))==po.Word}const E8n=bo.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(S8n),{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),!(d6e(i,n,s.from,s.to)&&C8n(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 _x(n.doc,a,c.from,c.to);for(;!u.next().done;){let{from:d,to:f}=u.value;if((!i||d6e(i,n,d,f))&&(s.empty&&d<=s.from&&f>=s.to?l.push(_8n.range(d,f)):(d>=s.to||f<=s.from)&&l.push(O8n.range(d,f)),l.length>t.maxMatches))return Cn.none}}return Cn.set(l)}},{decorations:e=>e.decorations}),j8n=It.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),T8n=({state:e,dispatch:t})=>{let{selection:n}=e,r=xt.create(n.ranges.map(s=>e.wordAt(s.head)||xt.cursor(s.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function N8n(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 _x(e.doc,t,r[r.length-1].to);;)if(l.next(),l.done){if(i)return null;l=new _x(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 I8n=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(a=>a.from===a.to))return T8n({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=N8n(e,r);return s?(t(e.update({selection:e.selection.addRange(xt.range(s.from,s.to),!1),effects:It.scrollIntoView(s.to)})),!0):!1},VN=On.define({combine(e){return $y(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new H8n(t),scrollToMatch:t=>It.scrollIntoView(t)})}});class gxt{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||b8n(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 D8n(this):new P8n(this)}getCursor(t,n=0,r){let s=t.doc?t:is.create({doc:t});return r==null&&(r=s.doc.length),this.regexp?kE(this,s,n,r):SE(this,s,n,r)}}class vxt{constructor(t){this.spec=t}}function A8n(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 SE(e,t,n,r){let s;return e.wholeWord&&(s=R8n(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(s=A8n(e.test,t,s)),new _x(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:a=>a.toLowerCase(),s)}function R8n(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(_7(s,n-a))!=po.Word||t(C7(s,n-a))!=po.Word)&&(t(C7(s,r-a))!=po.Word||t(_7(s,r-a))!=po.Word))}class P8n extends vxt{constructor(t){super(t)}nextMatch(t,n,r){let s=SE(this.spec,t,r,t.doc.length).nextOverlapping();if(s.done){let a=Math.min(t.doc.length,n+this.spec.unquoted.length);s=SE(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=SE(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=SE(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=SE(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 $8n(e,t,n){return(r,s,a)=>(!n||n(r,s,a))&&e(a[0],t,r,s)}function kE(e,t,n,r){let s;return e.wholeWord&&(s=M8n(t.charCategorizer(t.selection.main.head))),e.test&&(s=$8n(e.test,t,s)),new hxt(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:s},n,r)}function _7(e,t){return e.slice(xc(e,t,!1),t)}function C7(e,t){return e.slice(t,xc(e,t))}function M8n(e){return(t,n,r)=>!r[0].length||(e(_7(r.input,r.index))!=po.Word||e(C7(r.input,r.index))!=po.Word)&&(e(C7(r.input,r.index+r[0].length))!=po.Word||e(_7(r.input,r.index+r[0].length))!=po.Word)}class D8n extends vxt{nextMatch(t,n,r){let s=kE(this.spec,t,r,t.doc.length).next();return s.done&&(s=kE(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=kE(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=kE(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=kE(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 X$=vr.define(),a1e=vr.define(),$w=gl.define({create(e){return new ZK(whe(e).create(),null)},update(e,t){for(let n of t.effects)n.is(X$)?e=new ZK(n.value.create(),e.panel):n.is(a1e)&&(e=new ZK(e.query,n.value?i1e:null));return e},provide:e=>B$.from(e,t=>t.panel)});class ZK{constructor(t,n){this.query=t,this.panel=n}}const L8n=Cn.mark({class:"cm-searchMatch"}),F8n=Cn.mark({class:"cm-searchMatch cm-searchMatch-selected"}),z8n=bo.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field($w))}update(e){let t=e.state.field($w);(t!=e.startState.field($w)||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 kd;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?F8n:L8n)})}return r.finish()}},{decorations:e=>e.decorations});function f3(e){return t=>{let n=t.state.field($w,!1);return n&&n.query.spec.valid?e(t,n):xxt(t)}}const E7=f3((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let s=xt.single(r.from,r.to),a=e.state.facet(VN);return e.dispatch({selection:s,effects:[o1e(e,r),a.scrollToMatch(s.main,e)],userEvent:"select.search"}),bxt(e),!0}),j7=f3((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,s=t.prevMatch(n,r,r);if(!s)return!1;let a=xt.single(s.from,s.to),i=e.state.facet(VN);return e.dispatch({selection:a,effects:[o1e(e,s),i.scrollToMatch(a.main,e)],userEvent:"select.search"}),bxt(e),!0}),B8n=f3((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:xt.create(n.map(r=>xt.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),U8n=({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 _x(e.doc,e.sliceDoc(r,s));!l.next().done;){if(a.length>1e3)return!1;l.value.from==r&&(i=a.length),a.push(xt.range(l.value.from,l.value.to))}return t(e.update({selection:xt.create(a,i),userEvent:"select.search.matches"})),!0},f6e=f3((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=xt.single(i.from,i.to).map(f),d.push(o1e(e,i)),d.push(n.facet(VN).scrollToMatch(c.main,e))),e.dispatch({changes:f,selection:c,effects:d,userEvent:"input.replace"}),!0}),q8n=f3((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 i1e(e){return e.state.facet(VN).createPanel(e)}function whe(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(VN);return new gxt({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 yxt(e){let t=Swe(e,i1e);return t&&t.dom.querySelector("[main-field]")}function bxt(e){let t=yxt(e);t&&t==e.root.activeElement&&t.select()}const xxt=e=>{let t=e.state.field($w,!1);if(t&&t.panel){let n=yxt(e);if(n&&n!=e.root.activeElement){let r=whe(e.state,t.query.spec);r.valid&&e.dispatch({effects:X$.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[a1e.of(!0),t?X$.of(whe(e.state,t.query.spec)):vr.appendConfig.of(Z8n)]});return!0},wxt=e=>{let t=e.state.field($w,!1);if(!t||!t.panel)return!1;let n=Swe(e,i1e);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:a1e.of(!1)}),!0},V8n=[{key:"Mod-f",run:xxt,scope:"editor search-panel"},{key:"F3",run:E7,shift:j7,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:E7,shift:j7,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:wxt,scope:"editor search-panel"},{key:"Mod-Shift-l",run:U8n},{key:"Mod-Alt-g",run:x8n},{key:"Mod-d",run:I8n,preventDefault:!0}];class H8n{constructor(t){this.view=t;let n=this.query=t.state.field($w).query.spec;this.commit=this.commit.bind(this),this.searchField=ci("input",{value:n.search,placeholder:Qf(t,"Find"),"aria-label":Qf(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ci("input",{value:n.replace,placeholder:Qf(t,"Replace"),"aria-label":Qf(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=ci("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=ci("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=ci("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(s,a,i){return ci("button",{class:"cm-button",name:s,onclick:a,type:"button"},i)}this.dom=ci("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,r("next",()=>E7(t),[Qf(t,"next")]),r("prev",()=>j7(t),[Qf(t,"previous")]),r("select",()=>B8n(t),[Qf(t,"all")]),ci("label",null,[this.caseField,Qf(t,"match case")]),ci("label",null,[this.reField,Qf(t,"regexp")]),ci("label",null,[this.wordField,Qf(t,"by word")]),...t.state.readOnly?[]:[ci("br"),this.replaceField,r("replace",()=>f6e(t),[Qf(t,"replace")]),r("replaceAll",()=>q8n(t),[Qf(t,"replace all")])],ci("button",{name:"close",onclick:()=>wxt(t),"aria-label":Qf(t,"close"),type:"button"},["×"])])}commit(){let t=new gxt({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:X$.of(t)}))}keydown(t){d3n(this.view,t,"search-panel")?t.preventDefault():t.keyCode==13&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?j7:E7)(this.view)):t.keyCode==13&&t.target==this.replaceField&&(t.preventDefault(),f6e(this.view))}update(t){for(let n of t.transactions)for(let r of n.effects)r.is(X$)&&!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(VN).top}}function Qf(e,t){return e.state.phrase(t)}const w6=30,S6=/[\s\.,:;?!]/;function o1e(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-w6),i=Math.min(s,n+w6),l=e.state.sliceDoc(a,i);if(a!=r.from){for(let c=0;c<w6;c++)if(!S6.test(l[c+1])&&S6.test(l[c])){l=l.slice(c);break}}if(i!=s){for(let c=l.length-1;c>l.length-w6;c--)if(!S6.test(l[c-1])&&S6.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 W8n=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"}}),Z8n=[$w,Mg.low(z8n),W8n];class p6e{constructor(t,n,r){this.from=t,this.to=n,this.diagnostic=r}}class hk{constructor(t,n,r){this.diagnostics=t,this.panel=n,this.selected=r}static init(t,n,r){let s=r.facet(K$).markerFilter;s&&(t=s(t,r));let a=t.slice().sort((d,f)=>d.from-f.from||d.to-f.to),i=new kd,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((v,y)=>Math.min(v,y.to),f&&f.from>p?f.from:1e8)):(p=f.from,h=f.to,l.push(f),d++);d<a.length;){let v=a[d];if(v.from==p&&(v.to>v.from||v.to==p))l.push(v),d++,h=Math.min(v.to,h);else{h=Math.min(v.from,h);break}}let m=izn(l);if(l.some(v=>v.from==v.to||v.from==v.to-1&&r.doc.lineAt(v.from).to==v.from))i.add(p,p,Cn.widget({widget:new nzn(m),diagnostics:l.slice()}));else{let v=l.reduce((y,b)=>b.markClass?y+" "+b.markClass:y,"");i.add(p,h,Cn.mark({class:"cm-lintRange cm-lintRange-"+m+v,diagnostics:l.slice(),inclusiveEnd:l.some(y=>y.to>h)}))}c=h;for(let v=0;v<l.length;v++)l[v].to<=c&&l.splice(v--,1)}let u=i.finish();return new hk(u,n,xT(u))}}function xT(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 p6e(s,a,t||i.diagnostics[0]);else{if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new p6e(r.from,a,r.diagnostic)}}),r}function G8n(e,t){let n=t.pos,r=t.end||n,s=e.state.facet(K$).hideOn(e,n,r);if(s!=null)return s;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(i=>i.is(Sxt))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function Q8n(e,t){return e.field(xp,!1)?t:t.concat(vr.appendConfig.of(ozn))}const Sxt=vr.define(),l1e=vr.define(),kxt=vr.define(),xp=gl.define({create(){return new hk(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=xT(n,e.selected.diagnostic,a)||xT(n,null,a)}!n.size&&s&&t.state.facet(K$).autoPanel&&(s=null),e=new hk(n,s,r)}for(let n of t.effects)if(n.is(Sxt)){let r=t.state.facet(K$).autoPanel?n.value.length?J$.open:null:e.panel;e=hk.init(n.value,r,t.state)}else n.is(l1e)?e=new hk(e.diagnostics,n.value?J$.open:null,e.selected):n.is(kxt)&&(e=new hk(e.diagnostics,e.panel,n.value));return e},provide:e=>[B$.from(e,t=>t.panel),It.decorations.from(e,t=>t.diagnostics)]}),Y8n=Cn.mark({class:"cm-lintRange cm-lintRange-active"});function X8n(e,t,n){let{diagnostics:r}=e.state.field(xp),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(K$).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:K8n(e,s)}}}:null}function K8n(e,t){return ci("ul",{class:"cm-tooltip-lint"},t.map(n=>_xt(e,n,!1)))}const J8n=e=>{let t=e.state.field(xp,!1);(!t||!t.panel)&&e.dispatch({effects:Q8n(e.state,[l1e.of(!0)])});let n=Swe(e,J$.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},h6e=e=>{let t=e.state.field(xp,!1);return!t||!t.panel?!1:(e.dispatch({effects:l1e.of(!1)}),!0)},ezn=e=>{let t=e.state.field(xp,!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)},tzn=[{key:"Mod-Shift-m",run:J8n,preventDefault:!0},{key:"F8",run:ezn}],K$=On.define({combine(e){return{sources:e.map(t=>t.source).filter(t=>t!=null),...$y(e.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:m6e,tooltipFilter:m6e,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 m6e(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function Oxt(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 _xt(e,t,n){var r;let s=n?Oxt(t.actions):[];return ci("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},ci("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=xT(e.state.field(xp).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),ci("u",u.slice(d,d+1)),u.slice(d+1)],p=a.markClass?" "+a.markClass:"";return ci("button",{type:"button",class:"cm-diagnosticAction"+p,onclick:c,onmousedown:c,"aria-label":` Action: ${u}${d<0?"":` (access key "${s[i]})"`}.`},f)}),t.source&&ci("div",{class:"cm-diagnosticSource"},t.source))}class nzn extends Kp{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return ci("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class g6e{constructor(t,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=_xt(t,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class J${constructor(t){this.view=t,this.items=[];let n=s=>{if(s.keyCode==27)h6e(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=Oxt(a.actions);for(let l=0;l<i.length;l++)if(i[l].toUpperCase().charCodeAt(0)==s.keyCode){let c=xT(this.view.state.field(xp).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=ci("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=ci("div",{class:"cm-panel-lint"},this.list,ci("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>h6e(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(xp).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(xp),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 g6e(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 g6e(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(xp),r=xT(n.diagnostics,this.items[t].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:kxt.of(r)})}static open(t){return new J$(t)}}function rzn(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 k6(e){return rzn(`<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 szn=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:k6("#d11")},".cm-lintRange-warning":{backgroundImage:k6("orange")},".cm-lintRange-info":{backgroundImage:k6("#999")},".cm-lintRange-hint":{backgroundImage:k6("#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 azn(e){return e=="error"?4:e=="warning"?3:e=="info"?2:1}function izn(e){let t="hint",n=1;for(let r of e){let s=azn(r.severity);s>n&&(n=s,t=r.severity)}return t}const ozn=[xp,It.decorations.compute([xp],e=>{let{selected:t,panel:n}=e.field(xp);return!t||!n||t.from==t.to?Cn.none:Cn.set([Y8n.range(t.from,t.to)])}),J3n(X8n,{hideOn:G8n}),szn];var v6e=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(Y5n)),t.defaultKeymap!==!1&&(a=a.concat(v8n)),t.searchKeymap!==!1&&(a=a.concat(V8n)),t.historyKeymap!==!1&&(a=a.concat(OFn)),t.foldKeymap!==!1&&(a=a.concat($4n)),t.completionKeymap!==!1&&(a=a.concat(byt)),t.lintKeymap!==!1&&(a=a.concat(tzn));var i=[];return t.lineNumbers!==!1&&i.push(d4n()),t.highlightActiveLineGutter!==!1&&i.push(h4n()),t.highlightSpecialChars!==!1&&i.push(E3n()),t.history!==!1&&i.push(mFn()),t.foldGutter!==!1&&i.push(F4n()),t.drawSelection!==!1&&i.push(v3n()),t.dropCursor!==!1&&i.push(S3n()),t.allowMultipleSelections!==!1&&i.push(is.allowMultipleSelections.of(!0)),t.indentOnInput!==!1&&i.push(E4n()),t.syntaxHighlighting!==!1&&i.push(B1(q4n,{fallback:!0})),t.bracketMatching!==!1&&i.push(Y4n()),t.closeBrackets!==!1&&i.push(W5n()),t.autocompletion!==!1&&i.push(yyt()),t.rectangularSelection!==!1&&i.push(B3n()),s!==!1&&i.push(V3n()),t.highlightActiveLine!==!1&&i.push(R3n()),t.highlightSelectionMatches!==!1&&i.push(k8n()),t.tabSize&&typeof t.tabSize=="number"&&i.push(zN.of(" ".repeat(t.tabSize))),i.concat([FN.of(a.flat())]).filter(Boolean)};const lzn="#e5c07b",y6e="#e06c75",czn="#56b6c2",uzn="#ffffff",XF="#abb2bf",She="#7d8799",dzn="#61afef",fzn="#98c379",b6e="#d19a66",pzn="#c678dd",hzn="#21252b",x6e="#2c313a",w6e="#282c34",GK="#353a42",mzn="#3E4451",S6e="#528bff",gzn=It.theme({"&":{color:XF,backgroundColor:w6e},".cm-content":{caretColor:S6e},".cm-cursor, .cm-dropCursor":{borderLeftColor:S6e},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:mzn},".cm-panels":{backgroundColor:hzn,color:XF},".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:w6e,color:She,border:"none"},".cm-activeLineGutter":{backgroundColor:x6e},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:GK},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:GK,borderBottomColor:GK},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:x6e,color:XF}}},{dark:!0}),vzn=Dg.define([{tag:fe.keyword,color:pzn},{tag:[fe.name,fe.deleted,fe.character,fe.propertyName,fe.macroName],color:y6e},{tag:[fe.function(fe.variableName),fe.labelName],color:dzn},{tag:[fe.color,fe.constant(fe.name),fe.standard(fe.name)],color:b6e},{tag:[fe.definition(fe.name),fe.separator],color:XF},{tag:[fe.typeName,fe.className,fe.number,fe.changed,fe.annotation,fe.modifier,fe.self,fe.namespace],color:lzn},{tag:[fe.operator,fe.operatorKeyword,fe.url,fe.escape,fe.regexp,fe.link,fe.special(fe.string)],color:czn},{tag:[fe.meta,fe.comment],color:She},{tag:fe.strong,fontWeight:"bold"},{tag:fe.emphasis,fontStyle:"italic"},{tag:fe.strikethrough,textDecoration:"line-through"},{tag:fe.link,color:She,textDecoration:"underline"},{tag:fe.heading,fontWeight:"bold",color:y6e},{tag:[fe.atom,fe.bool,fe.special(fe.variableName)],color:b6e},{tag:[fe.processingInstruction,fe.string,fe.inserted],color:fzn},{tag:fe.invalid,color:uzn}]),yzn=[gzn,B1(vzn)];var bzn=It.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),xzn=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,v=[];switch(s&&v.unshift(FN.of([y8n])),m&&(typeof m=="boolean"?v.unshift(v6e()):v.unshift(v6e(m))),p&&v.unshift(D3n(p)),d){case"light":v.push(bzn);break;case"dark":v.push(yzn);break;case"none":break;default:v.push(d);break}return i===!1&&v.push(It.editable.of(!1)),c&&v.push(is.readOnly.of(!0)),[...v]},wzn=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 Szn{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 k6e{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 QK=null,kzn=()=>typeof window>"u"?new k6e:(QK||(QK=new k6e),QK),O6e=Py.define(),Ozn=200,_zn=[];function Czn(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?_zn: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,v=m===void 0?null:m,y=e.maxHeight,b=y===void 0?null:y,S=e.width,w=S===void 0?null:S,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,P=e.readOnly,L=P===void 0?!1:P,M=e.indentWithTab,q=M===void 0?!0:M,H=e.basicSetup,F=H===void 0?!0:H,z=e.root,B=e.initialState,D=g.useState(),Q=D[0],V=D[1],$=g.useState(),U=$[0],Z=$[1],X=g.useState(),te=X[0],J=X[1],ee=g.useState(()=>({current:null}))[0],ae=g.useState(()=>({current:null}))[0],ce=It.theme({"&":{height:h,minHeight:v,maxHeight:b,width:w,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(O6e))){ee.current?ee.current.reset():(ee.current=new Szn(()=>{if(ae.current){var ye=ae.current;ae.current=null,ye()}ee.current=null},Ozn),kzn().add(ee.current));var le=pe.state.doc,ve=le.toString();r(ve,pe)}s&&s(wzn(pe))}),ne=xzn({theme:f,editable:R,readOnly:L,placeholder:N,indentWithTab:q,basicSetup:F}),ue=[Y,ce,...ne];return i&&typeof i=="function"&&ue.push(It.updateListener.of(i)),ue=ue.concat(c),g.useLayoutEffect(()=>{if(Q&&!te){var pe={doc:t,selection:n,extensions:ue},le=B?is.fromJSON(B.json,pe,B.fields):is.create(pe);if(J(le),!U){var ve=new It({state:le,parent:Q,root:z});Z(ve),a&&a(ve,le)}}return()=>{U&&(J(void 0),Z(void 0))}},[Q,te]),g.useEffect(()=>{e.container&&V(e.container)},[e.container]),g.useEffect(()=>()=>{U&&(U.destroy(),Z(void 0)),ee.current&&(ee.current.cancel(),ee.current=null)},[U]),g.useEffect(()=>{u&&U&&U.focus()},[u,U]),g.useEffect(()=>{U&&U.dispatch({effects:vr.reconfigure.of(ue)})},[f,c,h,v,b,w,_,E,N,R,L,q,F,r,i]),g.useEffect(()=>{if(t!==void 0){var pe=U?U.state.doc.toString():"";if(U&&t!==pe){var le=ee.current&&!ee.current.isDone,ve=()=>{U&&t!==U.state.doc.toString()&&U.dispatch({changes:{from:0,to:U.state.doc.toString().length,insert:t||""},annotations:[O6e.of(!0)]})};le?ae.current=ve:ve()}}},[t,U]),{state:te,setState:J,view:U,setView:Z,container:Q,setContainer:V}}var Ezn=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],ru=g.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,v=e.height,y=e.minHeight,b=e.maxHeight,S=e.width,w=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,P=Rbt(e,Ezn),L=g.useRef(null),M=Czn({root:I,value:s,autoFocus:p,theme:m,height:v,minHeight:y,maxHeight:b,width:S,minWidth:w,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}),q=M.state,H=M.view,F=M.container,z=M.setContainer;g.useImperativeHandle(t,()=>({editor:L.current,state:q,view:H}),[L,F,q,H]);var B=g.useCallback(Q=>{L.current=Q,z(Q)},[z]);if(typeof s!="string")throw new Error("value must be typeof string but got "+typeof s);var D=typeof m=="string"?"cm-theme-"+m:"cm-theme";return o.jsx("div",PO({ref:B,className:""+D+(n?" "+n:"")},P))});ru.displayName="CodeMirror";const jzn={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 YK=null;function Tzn(){return YK||(YK=(async()=>{const[{createHighlighterCore:e},{createJavaScriptRegexEngine:t}]=await Promise.all([jo(()=>import("./core-B6cOHeaZ.js"),__vite__mapDeps([0,1,2]),import.meta.url),jo(()=>import("./engine-javascript-CSIo_1eZ.js"),__vite__mapDeps([3,1]),import.meta.url)]);return e({themes:[jo(()=>import("./github-light-DAi9KRSo.js"),[],import.meta.url),jo(()=>import("./github-dark-DHJKELXO.js"),[],import.meta.url)],langs:[jo(()=>import("./javascript-ySlJ1b_l.js"),[],import.meta.url),jo(()=>import("./typescript-Dj6nwHGl.js"),[],import.meta.url),jo(()=>import("./tsx-B6W0miNI.js"),[],import.meta.url),jo(()=>import("./jsx-BAng5TT0.js"),[],import.meta.url),jo(()=>import("./json-BQoSv7ci.js"),[],import.meta.url),jo(()=>import("./bash-atvbtKCR.js"),[],import.meta.url),jo(()=>import("./markdown-UIAJJxZW.js"),[],import.meta.url),jo(()=>import("./python-DhUJRlN_.js"),[],import.meta.url)],engine:t()})})()),YK}async function Nzn(e,t){const n=jzn[t?.toLowerCase()];if(!n)return null;const r=await Tzn(),{tokens:s}=r.codeToTokens(e,{lang:n,defaultColor:!1,themes:{light:"github-light",dark:"github-dark"}});return s}function Izn(e){return new NO(Ewe.define(e))}const Cxt=[Km.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return jo(()=>Promise.resolve().then(()=>b6),void 0,import.meta.url).then(e=>e.javascript())}}),Km.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return jo(()=>Promise.resolve().then(()=>l5n),void 0,import.meta.url).then(e=>e.json())}}),Km.of({name:"JSX",extensions:["jsx"],load(){return jo(()=>Promise.resolve().then(()=>b6),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),Km.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return jo(()=>Promise.resolve().then(()=>nFn),void 0,import.meta.url).then(e=>e.markdown())}}),Km.of({name:"TSX",extensions:["tsx"],load(){return jo(()=>Promise.resolve().then(()=>b6),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Km.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return jo(()=>Promise.resolve().then(()=>b6),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),Km.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return jo(()=>import("./shell-CjFT_Tl9.js"),[],import.meta.url).then(e=>Izn(e.shell))}})];function Azn(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 Rzn(e){const t=Azn(e);return yyt({override:[Pzn(t)],defaultKeymap:!0,closeOnBlur:!0,icons:!1})}function Pzn(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 v=u.state.sliceDoc(p,p+2)==="}}"?d.label:`${d.label}}}`;u.dispatch({changes:{from:f,to:p,insert:v},selection:{anchor:f+v.length}})}}));return{from:a,options:l,validFor:/^[a-zA-Z0-9_.\[\]]*$/}}}const $zn=/\{\{([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)\}\}/g,Mzn=Cn.mark({class:"cm-variable-highlight"}),_6e=new Avt({regexp:$zn,decoration:()=>Mzn}),Dzn=bo.fromClass(class{decorations;constructor(e){this.decorations=_6e.createDeco(e)}update(e){this.decorations=_6e.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}),Lzn=Dzn;function Fzn(){const e=UN({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 zzn(){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=Dg.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,B1(t)]}const My=()=>{const e=PN().resolvedTheme==="dark";return g.useMemo(()=>e?Fzn():zzn(),[e])},Qr=g.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 v=My(),y=e?JSON.stringify(e,null,2):t??"",b=g.useMemo(()=>{const S=[];return f&&S.push(It.lineWrapping),a==="json"?S.push(ff):a==="markdown"&&S.push(e1e({base:RO,codeLanguages:Cxt})),i&&a==="markdown"&&S.push(Lzn),c&&a==="markdown"&&S.push(Rzn(c)),p===!1&&S.push(is.readOnly.of(!0)),S},[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(Oa,{content:y,className:"absolute top-2 right-2 z-20"}),o.jsx(ru,{ref:m,value:y,theme:v,extensions:b,onChange:n,editable:p,"aria-label":"Code editor",placeholder:l,height:"100%",style:{height:"100%"},autoFocus:u,basicSetup:{lineNumbers:d}})]})}),Bzn=e=>{try{return JSON.stringify(e??{},null,2)}catch{return"{}"}},Uzn=({editorClassName:e="h-[240px] max-h-[40vh]",onSaved:t})=>{const n=My(),{settings:r,setSettings:s}=tV(),a=r?.tracingOptions,i=g.useMemo(()=>Bzn(a),[a]),[l,c]=g.useState(()=>i),u=g.useRef(!1);g.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(ru,{value:l,onChange:d,theme:n,extensions:[ff],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(de,{type:"button",onClick:f,children:"Save"})})]})},qzn=()=>{const[e,t]=g.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx(de,{type:"button",variant:"ghost",size:"icon-md","aria-label":"Run Options",onClick:()=>t(!0),children:o.jsx(Ue,{children:o.jsx(hq,{})})})}),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(Rr,{children:o.jsx(Uzn,{onSaved:()=>t(!1)})})]})})]})};function Vzn({status:e}){switch(e){case"running":return o.jsx(Gt,{});case"failed":return o.jsx(vs,{className:"text-accent2"});case"canceled":return o.jsx(Of,{className:"text-neutral3"});case"pending":case"waiting":return o.jsx(dO,{className:"text-neutral3"});case"suspended":return o.jsx(lq,{className:"text-accent3"});case"success":return o.jsx(Js,{className:"text-accent1"});default:return o.jsx(dO,{className:"text-neutral3"})}}function Ext({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(Vzn,{status:e})})}),o.jsx(Bn,{children:e})]})}var XK,C6e;function c1e(){if(C6e)return XK;C6e=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([v,y]){d(v)&&f.setNode(v,y)}),Object.values(this._edgeObjs).forEach(function(v){f.hasNode(v.v)&&f.hasNode(v.w)&&f.setEdge(v,p.edge(v))});var h={};function m(v){var y=p.parent(v);return y===void 0||f.hasNode(y)?(h[v]=y,y):y in h?h[y]:m(y)}return this._isCompound&&f.nodes().forEach(v=>f.setParent(v,m(v))),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,v){return h.length>1?p.setEdge(m,v,f):p.setEdge(m,v),v}),this}setEdge(){var d,f,p,h,m=!1,v=arguments[0];typeof v=="object"&&v!==null&&"v"in v?(d=v.v,f=v.w,p=v.name,arguments.length===2&&(h=arguments[1],m=!0)):(d=v,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 v=h;h=m,m=v}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 v=h;h=m,m=v}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 XK=r,XK}var KK,E6e;function Hzn(){return E6e||(E6e=1,KK="2.2.4"),KK}var JK,j6e;function Wzn(){return j6e||(j6e=1,JK={Graph:c1e(),version:Hzn()}),JK}var eJ,T6e;function Zzn(){if(T6e)return eJ;T6e=1;var e=c1e();eJ={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 eJ}var tJ,N6e;function Gzn(){if(N6e)return tJ;N6e=1,tJ=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 tJ}var nJ,I6e;function jxt(){if(I6e)return nJ;I6e=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 nJ=e,nJ}var rJ,A6e;function Txt(){if(A6e)return rJ;A6e=1;var e=jxt();rJ=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,v=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<v.distance&&(v.distance=b,v.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 rJ}var sJ,R6e;function Qzn(){if(R6e)return sJ;R6e=1;var e=Txt();sJ=t;function t(n,r,s){return n.nodes().reduce(function(a,i){return a[i]=e(n,i,r,s),a},{})}return sJ}var aJ,P6e;function Nxt(){if(P6e)return aJ;P6e=1,aJ=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 aJ}var iJ,$6e;function Yzn(){if($6e)return iJ;$6e=1;var e=Nxt();iJ=t;function t(n){return e(n).filter(function(r){return r.length>1||r.length===1&&n.hasEdge(r[0],r[0])})}return iJ}var oJ,M6e;function Xzn(){if(M6e)return oJ;M6e=1,oJ=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],v=f[p],y=h.distance+m.distance;y<v.distance&&(v.distance=y,v.predecessor=m.predecessor)})})}),i}return oJ}var lJ,D6e;function Ixt(){if(D6e)return lJ;D6e=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 lJ=e,e.CycleException=t,lJ}var cJ,L6e;function Kzn(){if(L6e)return cJ;L6e=1;var e=Ixt();cJ=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return cJ}var uJ,F6e;function Axt(){if(F6e)return uJ;F6e=1,uJ=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 uJ}var dJ,z6e;function Jzn(){if(z6e)return dJ;z6e=1;var e=Axt();dJ=t;function t(n,r){return e(n,r,"post")}return dJ}var fJ,B6e;function e7n(){if(B6e)return fJ;B6e=1;var e=Axt();fJ=t;function t(n,r){return e(n,r,"pre")}return fJ}var pJ,U6e;function t7n(){if(U6e)return pJ;U6e=1;var e=c1e(),t=jxt();pJ=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 pJ}var hJ,q6e;function n7n(){return q6e||(q6e=1,hJ={components:Gzn(),dijkstra:Txt(),dijkstraAll:Qzn(),findCycles:Yzn(),floydWarshall:Xzn(),isAcyclic:Kzn(),postorder:Jzn(),preorder:e7n(),prim:t7n(),tarjan:Nxt(),topsort:Ixt()}),hJ}var mJ,V6e;function Tg(){if(V6e)return mJ;V6e=1;var e=Wzn();return mJ={Graph:e.Graph,json:Zzn(),alg:n7n(),version:e.version},mJ}var gJ,H6e;function r7n(){if(H6e)return gJ;H6e=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 gJ=e,gJ}var vJ,W6e;function s7n(){if(W6e)return vJ;W6e=1;let e=Tg().Graph,t=r7n();vJ=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],v;for(;u.nodeCount();){for(;v=m.dequeue();)a(u,d,f,v);for(;v=h.dequeue();)a(u,d,f,v);if(u.nodeCount()){for(let y=d.length-2;y>0;--y)if(v=d[y].dequeue(),v){p=p.concat(a(u,d,f,v,!0));break}}}return p}function a(u,d,f,p,h){let m=h?[]:void 0;return u.inEdges(p.v).forEach(v=>{let y=u.edge(v),b=u.node(v.v);h&&m.push({v:v.v,w:v.w}),b.out-=y,l(d,f,b)}),u.outEdges(p.v).forEach(v=>{let y=u.edge(v),b=v.w,S=u.node(b);S.in-=y,l(d,f,S)}),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,S=d(y),w=b+S;f.setEdge(y.v,y.w,w),h=Math.max(h,f.node(y.v).out+=S),p=Math.max(p,f.node(y.w).in+=S)});let m=c(h+p+3).map(()=>new t),v=p+1;return f.nodes().forEach(y=>{l(m,v,f.node(y))}),{graph:f,buckets:m,zeroIdx:v}}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 vJ}var yJ,Z6e;function Nl(){if(Z6e)return yJ;Z6e=1;let e=Tg().Graph;yJ={addBorderNode:d,addDummyNode:t,applyWithChunking:h,asNonCompoundGraph:r,buildLayerMatrix:l,intersectRect:i,mapValues:C,maxRank:m,normalizeRanks:c,notime:b,partition:v,pick:_,predecessorWeights:a,range:k,removeEmptyRanks:u,simplify:n,successorWeights:s,time:y,uniqueId:w,zipObject:E};function t(j,N,I,R){for(var P=R;j.hasNode(P);)P=w(R);return I.dummy=N,j.setNode(P,I),P}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},P=j.edge(I);N.setEdge(I.v,I.w,{weight:R.weight+P.weight,minlen:Math.max(R.minlen,P.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(P=>{R[P.w]=(R[P.w]||0)+j.edge(P).weight}),R});return E(j.nodes(),N)}function a(j){let N=j.nodes().map(I=>{let R={};return j.inEdges(I).forEach(P=>{R[P.v]=(R[P.v]||0)+j.edge(P).weight}),R});return E(j.nodes(),N)}function i(j,N){let I=j.x,R=j.y,P=N.x-I,L=N.y-R,M=j.width/2,q=j.height/2;if(!P&&!L)throw new Error("Not possible to find intersection inside of the rectangle");let H,F;return Math.abs(L)*M>Math.abs(P)*q?(L<0&&(q=-q),H=q*P/L,F=q):(P<0&&(M=-M),H=M,F=M*L/P),{x:I+H,y:R+F}}function l(j){let N=k(m(j)+1).map(()=>[]);return j.nodes().forEach(I=>{let R=j.node(I),P=R.rank;P!==void 0&&(N[P][R.order]=I)}),N}function c(j){let N=j.nodes().map(R=>{let P=j.node(R).rank;return P===void 0?Number.MAX_VALUE:P}),I=h(Math.min,N);j.nodes().forEach(R=>{let P=j.node(R);Object.hasOwn(P,"rank")&&(P.rank-=I)})}function u(j){let N=j.nodes().map(M=>j.node(M).rank),I=h(Math.min,N),R=[];j.nodes().forEach(M=>{let q=j.node(M).rank-I;R[q]||(R[q]=[]),R[q].push(M)});let P=0,L=j.graph().nodeRankFactor;Array.from(R).forEach((M,q)=>{M===void 0&&q%L!==0?--P:M!==void 0&&P&&M.forEach(H=>j.node(H).rank+=P)})}function d(j,N,I,R){let P={width:0,height:0};return arguments.length>=4&&(P.rank=I,P.order=R),t(j,"border",P,N)}function f(j,N=p){const I=[];for(let R=0;R<j.length;R+=N){const P=j.slice(R,R+N);I.push(P)}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 P=j.node(R).rank;return P===void 0?Number.MIN_VALUE:P});return h(Math.max,I)}function v(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 S=0;function w(j){var N=++S;return j+(""+N)}function k(j,N,I=1){N==null&&(N=j,j=0);let R=L=>L<N;I<0&&(R=L=>N<L);const P=[];for(let L=j;R(L);L+=I)P.push(L);return P}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,[P,L])=>(R[P]=I(L,P),R),{})}function E(j,N){return j.reduce((I,R,P)=>(I[R]=N[P],I),{})}return yJ}var bJ,G6e;function a7n(){if(G6e)return bJ;G6e=1;let e=s7n(),t=Nl().uniqueId;bJ={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 bJ}var xJ,Q6e;function i7n(){if(Q6e)return xJ;Q6e=1;let e=Nl();xJ={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,v;for(v=0,++l;l<u;++v,++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),v===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 xJ}var wJ,Y6e;function T7(){if(Y6e)return wJ;Y6e=1;const{applyWithChunking:e}=Nl();wJ={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 wJ}var SJ,X6e;function Rxt(){if(X6e)return SJ;X6e=1;var e=Tg().Graph,t=T7().slack;SJ=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 SJ}var kJ,K6e;function o7n(){if(K6e)return kJ;K6e=1;var e=Rxt(),t=T7().slack,n=T7().longestPath,r=Tg().alg.preorder,s=Tg().alg.postorder,a=Nl().simplify;kJ=i,i.initLowLimValues=d,i.initCutValues=l,i.calcCutValue=u,i.leaveEdge=p,i.enterEdge=h,i.exchangeEdges=m;function i(S){S=a(S),n(S);var w=e(S);d(w),l(w,S);for(var k,_;k=p(w);)_=h(w,S,k),m(w,S,k,_)}function l(S,w){var k=s(S,S.nodes());k=k.slice(0,k.length-1),k.forEach(_=>c(S,w,_))}function c(S,w,k){var _=S.node(k),C=_.parent;S.edge(k,C).cutvalue=u(S,w,k)}function u(S,w,k){var _=S.node(k),C=_.parent,E=!0,j=w.edge(k,C),N=0;return j||(E=!1,j=w.edge(C,k)),N=j.weight,w.nodeEdges(k).forEach(I=>{var R=I.v===k,P=R?I.w:I.v;if(P!==C){var L=R===E,M=w.edge(I).weight;if(N+=L?M:-M,y(S,k,P)){var q=S.edge(k,P).cutvalue;N+=L?-q:q}}}),N}function d(S,w){arguments.length<2&&(w=S.nodes()[0]),f(S,{},1,w)}function f(S,w,k,_,C){var E=k,j=S.node(_);return w[_]=!0,S.neighbors(_).forEach(N=>{Object.hasOwn(w,N)||(k=f(S,w,k,N,_))}),j.low=E,j.lim=k++,C?j.parent=C:delete j.parent,k}function p(S){return S.edges().find(w=>S.edge(w).cutvalue<0)}function h(S,w,k){var _=k.v,C=k.w;w.hasEdge(_,C)||(_=k.w,C=k.v);var E=S.node(_),j=S.node(C),N=E,I=!1;E.lim>j.lim&&(N=j,I=!0);var R=w.edges().filter(P=>I===b(S,S.node(P.v),N)&&I!==b(S,S.node(P.w),N));return R.reduce((P,L)=>t(w,L)<t(w,P)?L:P)}function m(S,w,k,_){var C=k.v,E=k.w;S.removeEdge(C,E),S.setEdge(_.v,_.w,{}),d(S),l(S,w),v(S,w)}function v(S,w){var k=S.nodes().find(C=>!w.node(C).parent),_=r(S,k);_=_.slice(1),_.forEach(C=>{var E=S.node(C).parent,j=w.edge(C,E),N=!1;j||(j=w.edge(E,C),N=!0),w.node(C).rank=w.node(E).rank+(N?j.minlen:-j.minlen)})}function y(S,w,k){return S.hasEdge(w,k)}function b(S,w,k){return k.low<=w.lim&&w.lim<=k.lim}return kJ}var OJ,J6e;function l7n(){if(J6e)return OJ;J6e=1;var e=T7(),t=e.longestPath,n=Rxt(),r=o7n();OJ=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 OJ}var _J,e9e;function c7n(){if(e9e)return _J;e9e=1,_J=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 _J}var CJ,t9e;function u7n(){if(t9e)return CJ;t9e=1;let e=Nl();CJ={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"),v=e.addBorderNode(i,"_bb"),y=i.node(p);i.setParent(m,p),y.borderTop=m,i.setParent(v,p),y.borderBottom=v,h.forEach(b=>{n(i,l,c,u,d,f,b);let S=i.node(b),w=S.borderTop?S.borderTop:b,k=S.borderBottom?S.borderBottom:b,_=S.borderTop?u:2*u,C=w!==k?1:d-f[p]+1;i.setEdge(m,w,{weight:_,minlen:C,nestingEdge:!0}),i.setEdge(k,v,{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 CJ}var EJ,n9e;function d7n(){if(n9e)return EJ;n9e=1;let e=Nl();EJ=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 EJ}var jJ,r9e;function f7n(){if(r9e)return jJ;r9e=1,jJ={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 jJ}var TJ,s9e;function p7n(){if(s9e)return TJ;s9e=1;let e=Nl();TJ=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 TJ}var NJ,a9e;function h7n(){if(a9e)return NJ;a9e=1;let e=Nl().zipObject;NJ=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 NJ}var IJ,i9e;function m7n(){if(i9e)return IJ;i9e=1,IJ=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 IJ}var AJ,o9e;function g7n(){if(o9e)return AJ;o9e=1;let e=Nl();AJ=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 AJ}var RJ,l9e;function v7n(){if(l9e)return RJ;l9e=1;let e=Nl();RJ=t;function t(s,a){let i=e.partition(s,m=>Object.hasOwn(m,"barycenter")),l=i.lhs,c=i.rhs.sort((m,v)=>v.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 RJ}var PJ,c9e;function y7n(){if(c9e)return PJ;c9e=1;let e=m7n(),t=g7n(),n=v7n();PJ=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(S=>S!==p&&S!==h));let v=e(i,d);v.forEach(S=>{if(i.children(S.v).length){let w=r(i,S.v,c,u);m[S.v]=w,Object.hasOwn(w,"barycenter")&&a(S,w)}});let y=t(v,c);s(y,m);let b=n(y,u);if(p&&(b.vs=[p,b.vs,h].flat(!0),i.predecessors(p).length)){let S=i.node(i.predecessors(p)[0]),w=i.node(i.predecessors(h)[0]);Object.hasOwn(b,"barycenter")||(b.barycenter=0,b.weight=0),b.barycenter=(b.barycenter*b.weight+S.order+w.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 PJ}var $J,u9e;function b7n(){if(u9e)return $J;u9e=1;let e=Tg().Graph,t=Nl();$J=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,v=u.edge(m,d),y=v!==void 0?v.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 $J}var MJ,d9e;function x7n(){if(d9e)return MJ;d9e=1,MJ=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 MJ}var DJ,f9e;function w7n(){if(f9e)return DJ;f9e=1;let e=p7n(),t=h7n(),n=y7n(),r=b7n(),s=x7n(),a=Tg().Graph,i=Nl();DJ=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"),v=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,S;for(let w=0,k=0;k<4;++w,++k){u(w%2?m:v,w%4>=2),y=i.buildLayerMatrix(f);let _=t(f,y);_<b&&(k=0,S=Object.assign({},y),b=_)}d(f,S)}function c(f,p,h){const m=new Map,v=(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"&&v(b.rank,y),typeof b.minRank=="number"&&typeof b.maxRank=="number")for(let S=b.minRank;S<=b.maxRank;S++)S!==b.rank&&v(S,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 v=m.graph().root,y=n(m,v,h,p);y.vs.forEach((b,S)=>m.node(b).order=S),s(m,h,y.vs)})}function d(f,p){Object.values(p).forEach(h=>h.forEach((m,v)=>f.node(m).order=v))}return DJ}var LJ,p9e;function S7n(){if(p9e)return LJ;p9e=1;let e=Tg().Graph,t=Nl();LJ={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 S={};function w(k,_){let C=0,E=0,j=k.length,N=_[_.length-1];return _.forEach((I,R)=>{let P=s(y,I),L=P?y.node(P).order:j;(P||I===N)&&(_.slice(E,R+1).forEach(M=>{y.predecessors(M).forEach(q=>{let H=y.node(q),F=H.order;(F<C||L<F)&&!(H.dummy&&y.node(M).dummy)&&a(S,q,M)})}),E=R+1,C=L)}),_}return b.length&&b.reduce(w),S}function r(y,b){let S={};function w(_,C,E,j,N){let I;t.range(C,E).forEach(R=>{I=_[R],y.node(I).dummy&&y.predecessors(I).forEach(P=>{let L=y.node(P);L.dummy&&(L.order<j||L.order>N)&&a(S,P,I)})})}function k(_,C){let E=-1,j,N=0;return C.forEach((I,R)=>{if(y.node(I).dummy==="border"){let P=y.predecessors(I);P.length&&(j=y.node(P[0]).order,w(C,N,R,E,j),N=R,E=j)}w(C,N,C.length,j,_.length)}),C}return b.length&&b.reduce(k),S}function s(y,b){if(y.node(b).dummy)return y.predecessors(b).find(S=>y.node(S).dummy)}function a(y,b,S){if(b>S){let k=b;b=S,S=k}let w=y[b];w||(y[b]=w={}),w[S]=!0}function i(y,b,S){if(b>S){let w=b;b=S,S=w}return!!y[b]&&Object.hasOwn(y[b],S)}function l(y,b,S,w){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=w(N);if(I.length){I=I.sort((P,L)=>C[P]-C[L]);let R=(I.length-1)/2;for(let P=Math.floor(R),L=Math.ceil(R);P<=L;++P){let M=I[P];_[N]===N&&j<C[M]&&!i(S,N,M)&&(_[M]=N,_[N]=k[N]=k[M],j=C[M])}}})}),{root:k,align:_}}function c(y,b,S,w,k){let _={},C=u(y,b,S,k),E=k?"borderLeft":"borderRight";function j(R,P){let L=C.nodes(),M=L.pop(),q={};for(;M;)q[M]?R(M):(q[M]=!0,L.push(M),L=L.concat(P(M))),M=L.pop()}function N(R){_[R]=C.inEdges(R).reduce((P,L)=>Math.max(P,_[L.v]+C.edge(L)),0)}function I(R){let P=C.outEdges(R).reduce((M,q)=>Math.min(M,_[q.w]-C.edge(q)),Number.POSITIVE_INFINITY),L=y.node(R);P!==Number.POSITIVE_INFINITY&&L.borderType!==E&&(_[R]=Math.max(_[R],P))}return j(N,C.predecessors.bind(C)),j(I,C.successors.bind(C)),Object.keys(w).forEach(R=>_[R]=_[S[R]]),_}function u(y,b,S,w){let k=new e,_=y.graph(),C=m(_.nodesep,_.edgesep,w);return b.forEach(E=>{let j;E.forEach(N=>{let I=S[N];if(k.setNode(I),j){var R=S[j],P=k.edge(R,I);k.setEdge(R,I,Math.max(C(y,N,j),P||0))}j=N})}),k}function d(y,b){return Object.values(b).reduce((S,w)=>{let k=Number.NEGATIVE_INFINITY,_=Number.POSITIVE_INFINITY;Object.entries(w).forEach(([E,j])=>{let N=v(y,E)/2;k=Math.max(j+N,k),_=Math.min(j-N,_)});const C=k-_;return C<S[0]&&(S=[C,w]),S},[Number.POSITIVE_INFINITY,null])[1]}function f(y,b){let S=Object.values(b),w=t.applyWithChunking(Math.min,S),k=t.applyWithChunking(Math.max,S);["u","d"].forEach(_=>{["l","r"].forEach(C=>{let E=_+C,j=y[E];if(j===b)return;let N=Object.values(j),I=w-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,(S,w)=>{if(b)return y[b.toLowerCase()][w];{let k=Object.values(y).map(_=>_[w]).sort((_,C)=>_-C);return(k[1]+k[2])/2}})}function h(y){let b=t.buildLayerMatrix(y),S=Object.assign(n(y,b),r(y,b)),w={},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,S,j),I=c(y,k,N.root,N.align,E==="r");E==="r"&&(I=t.mapValues(I,R=>-R)),w[C+E]=I})});let _=d(y,w);return f(w,_),p(w,y.graph().align)}function m(y,b,S){return(w,k,_)=>{let C=w.node(k),E=w.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+=S?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+=S?N:-N),N=0,j}}function v(y,b){return y.node(b).width}return LJ}var FJ,h9e;function k7n(){if(h9e)return FJ;h9e=1;let e=Nl(),t=S7n().positionX;FJ=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 FJ}var zJ,m9e;function O7n(){if(m9e)return zJ;m9e=1;let e=a7n(),t=i7n(),n=l7n(),r=Nl().normalizeRanks,s=c7n(),a=Nl().removeEmptyRanks,i=u7n(),l=d7n(),c=f7n(),u=w7n(),d=k7n(),f=Nl(),p=Tg().Graph;zJ=h;function h($,U){let Z=U&&U.debugTiming?f.time:f.notime;Z("layout",()=>{let X=Z(" buildLayoutGraph",()=>j($));Z(" runLayout",()=>m(X,Z,U)),Z(" updateInputGraph",()=>v($,X))})}function m($,U,Z){U(" makeSpaceForEdgeLabels",()=>N($)),U(" removeSelfEdges",()=>z($)),U(" acyclic",()=>e.run($)),U(" nestingGraph.run",()=>i.run($)),U(" rank",()=>n(f.asNonCompoundGraph($))),U(" injectEdgeLabelProxies",()=>I($)),U(" removeEmptyRanks",()=>a($)),U(" nestingGraph.cleanup",()=>i.cleanup($)),U(" normalizeRanks",()=>r($)),U(" assignRankMinMax",()=>R($)),U(" removeEdgeLabelProxies",()=>P($)),U(" normalize.run",()=>t.run($)),U(" parentDummyChains",()=>s($)),U(" addBorderSegments",()=>l($)),U(" order",()=>u($,Z)),U(" insertSelfEdges",()=>B($)),U(" adjustCoordinateSystem",()=>c.adjust($)),U(" position",()=>d($)),U(" positionSelfEdges",()=>D($)),U(" removeBorderNodes",()=>F($)),U(" normalize.undo",()=>t.undo($)),U(" fixupEdgeLabelCoords",()=>q($)),U(" undoCoordinateSystem",()=>c.undo($)),U(" translateGraph",()=>L($)),U(" assignNodeIntersects",()=>M($)),U(" reversePoints",()=>H($)),U(" acyclic.undo",()=>e.undo($))}function v($,U){$.nodes().forEach(Z=>{let X=$.node(Z),te=U.node(Z);X&&(X.x=te.x,X.y=te.y,X.rank=te.rank,U.children(Z).length&&(X.width=te.width,X.height=te.height))}),$.edges().forEach(Z=>{let X=$.edge(Z),te=U.edge(Z);X.points=te.points,Object.hasOwn(te,"x")&&(X.x=te.x,X.y=te.y)}),$.graph().width=U.graph().width,$.graph().height=U.graph().height}let y=["nodesep","edgesep","ranksep","marginx","marginy"],b={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},S=["acyclicer","ranker","rankdir","align"],w=["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($){let U=new p({multigraph:!0,compound:!0}),Z=V($.graph());return U.setGraph(Object.assign({},b,Q(Z,y),f.pick(Z,S))),$.nodes().forEach(X=>{let te=V($.node(X));const J=Q(te,w);Object.keys(k).forEach(ee=>{J[ee]===void 0&&(J[ee]=k[ee])}),U.setNode(X,J),U.setParent(X,$.parent(X))}),$.edges().forEach(X=>{let te=V($.edge(X));U.setEdge(X,Object.assign({},C,Q(te,_),f.pick(te,E)))}),U}function N($){let U=$.graph();U.ranksep/=2,$.edges().forEach(Z=>{let X=$.edge(Z);X.minlen*=2,X.labelpos.toLowerCase()!=="c"&&(U.rankdir==="TB"||U.rankdir==="BT"?X.width+=X.labeloffset:X.height+=X.labeloffset)})}function I($){$.edges().forEach(U=>{let Z=$.edge(U);if(Z.width&&Z.height){let X=$.node(U.v),J={rank:($.node(U.w).rank-X.rank)/2+X.rank,e:U};f.addDummyNode($,"edge-proxy",J,"_ep")}})}function R($){let U=0;$.nodes().forEach(Z=>{let X=$.node(Z);X.borderTop&&(X.minRank=$.node(X.borderTop).rank,X.maxRank=$.node(X.borderBottom).rank,U=Math.max(U,X.maxRank))}),$.graph().maxRank=U}function P($){$.nodes().forEach(U=>{let Z=$.node(U);Z.dummy==="edge-proxy"&&($.edge(Z.e).labelRank=Z.rank,$.removeNode(U))})}function L($){let U=Number.POSITIVE_INFINITY,Z=0,X=Number.POSITIVE_INFINITY,te=0,J=$.graph(),ee=J.marginx||0,ae=J.marginy||0;function ce(Y){let ne=Y.x,ue=Y.y,pe=Y.width,le=Y.height;U=Math.min(U,ne-pe/2),Z=Math.max(Z,ne+pe/2),X=Math.min(X,ue-le/2),te=Math.max(te,ue+le/2)}$.nodes().forEach(Y=>ce($.node(Y))),$.edges().forEach(Y=>{let ne=$.edge(Y);Object.hasOwn(ne,"x")&&ce(ne)}),U-=ee,X-=ae,$.nodes().forEach(Y=>{let ne=$.node(Y);ne.x-=U,ne.y-=X}),$.edges().forEach(Y=>{let ne=$.edge(Y);ne.points.forEach(ue=>{ue.x-=U,ue.y-=X}),Object.hasOwn(ne,"x")&&(ne.x-=U),Object.hasOwn(ne,"y")&&(ne.y-=X)}),J.width=Z-U+ee,J.height=te-X+ae}function M($){$.edges().forEach(U=>{let Z=$.edge(U),X=$.node(U.v),te=$.node(U.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 q($){$.edges().forEach(U=>{let Z=$.edge(U);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 H($){$.edges().forEach(U=>{let Z=$.edge(U);Z.reversed&&Z.points.reverse()})}function F($){$.nodes().forEach(U=>{if($.children(U).length){let Z=$.node(U),X=$.node(Z.borderTop),te=$.node(Z.borderBottom),J=$.node(Z.borderLeft[Z.borderLeft.length-1]),ee=$.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}}),$.nodes().forEach(U=>{$.node(U).dummy==="border"&&$.removeNode(U)})}function z($){$.edges().forEach(U=>{if(U.v===U.w){var Z=$.node(U.v);Z.selfEdges||(Z.selfEdges=[]),Z.selfEdges.push({e:U,label:$.edge(U)}),$.removeEdge(U)}})}function B($){var U=f.buildLayerMatrix($);U.forEach(Z=>{var X=0;Z.forEach((te,J)=>{var ee=$.node(te);ee.order=J+X,(ee.selfEdges||[]).forEach(ae=>{f.addDummyNode($,"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 D($){$.nodes().forEach(U=>{var Z=$.node(U);if(Z.dummy==="selfedge"){var X=$.node(Z.e.v),te=X.x+X.width/2,J=X.y,ee=Z.x-te,ae=X.height/2;$.setEdge(Z.e,Z.label),$.removeNode(U),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 Q($,U){return f.mapValues(f.pick($,U),Number)}function V($){var U={};return $&&Object.entries($).forEach(([Z,X])=>{typeof Z=="string"&&(Z=Z.toLowerCase()),U[Z]=X}),U}return zJ}var BJ,g9e;function _7n(){if(g9e)return BJ;g9e=1;let e=Nl(),t=Tg().Graph;BJ={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 BJ}var UJ,v9e;function C7n(){return v9e||(v9e=1,UJ="1.1.8"),UJ}var qJ,y9e;function E7n(){return y9e||(y9e=1,qJ={graphlib:Tg(),layout:O7n(),debug:_7n(),util:{time:Nl().time,notime:Nl().notime},version:C7n()}),qJ}var j7n=E7n();const b9e=Tc(j7n);function Ml(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=Ml(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var T7n={value:()=>{}};function TV(){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 KF(n)}function KF(e){this._=e}function N7n(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}})}KF.prototype=TV.prototype={constructor:KF,on:function(e,t){var n=this._,r=N7n(e+"",n),s,a=-1,i=r.length;if(arguments.length<2){for(;++a<i;)if((s=(e=r[a]).type)&&(s=I7n(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]=x9e(n[s],e.name,t);else if(t==null)for(s in n)n[s]=x9e(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 KF(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 I7n(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function x9e(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=T7n,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var khe="http://www.w3.org/1999/xhtml";const w9e={svg:"http://www.w3.org/2000/svg",xhtml:khe,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function NV(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),w9e.hasOwnProperty(t)?{space:w9e[t],local:e}:e}function A7n(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===khe&&t.documentElement.namespaceURI===khe?t.createElement(e):t.createElementNS(n,e)}}function R7n(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Pxt(e){var t=NV(e);return(t.local?R7n:A7n)(t)}function P7n(){}function u1e(e){return e==null?P7n:function(){return this.querySelector(e)}}function $7n(e){typeof e!="function"&&(e=u1e(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 qp(r,this._parents)}function M7n(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function D7n(){return[]}function $xt(e){return e==null?D7n:function(){return this.querySelectorAll(e)}}function L7n(e){return function(){return M7n(e.apply(this,arguments))}}function F7n(e){typeof e=="function"?e=L7n(e):e=$xt(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 qp(r,s)}function Mxt(e){return function(){return this.matches(e)}}function Dxt(e){return function(t){return t.matches(e)}}var z7n=Array.prototype.find;function B7n(e){return function(){return z7n.call(this.children,e)}}function U7n(){return this.firstElementChild}function q7n(e){return this.select(e==null?U7n:B7n(typeof e=="function"?e:Dxt(e)))}var V7n=Array.prototype.filter;function H7n(){return Array.from(this.children)}function W7n(e){return function(){return V7n.call(this.children,e)}}function Z7n(e){return this.selectAll(e==null?H7n:W7n(typeof e=="function"?e:Dxt(e)))}function G7n(e){typeof e!="function"&&(e=Mxt(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 qp(r,this._parents)}function Lxt(e){return new Array(e.length)}function Q7n(){return new qp(this._enter||this._groups.map(Lxt),this._parents)}function N7(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}N7.prototype={constructor:N7,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 Y7n(e){return function(){return e}}function X7n(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 N7(e,a[i]);for(;i<c;++i)(l=t[i])&&(s[i]=l)}function K7n(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 N7(e,a[l]);for(l=0;l<d;++l)(c=t[l])&&u.get(p[l])===c&&(s[l]=c)}function J7n(e){return e.__data__}function eBn(e,t){if(!arguments.length)return Array.from(this,J7n);var n=t?K7n:X7n,r=this._parents,s=this._groups;typeof e!="function"&&(e=Y7n(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=tBn(e.call(d,d&&d.__data__,u,r)),m=h.length,v=l[u]=new Array(m),y=i[u]=new Array(m),b=c[u]=new Array(p);n(d,f,v,y,b,h,t);for(var S=0,w=0,k,_;S<m;++S)if(k=v[S]){for(S>=w&&(w=S+1);!(_=y[w])&&++w<m;);k._next=_||null}}return i=new qp(i,r),i._enter=l,i._exit=c,i}function tBn(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function nBn(){return new qp(this._exit||this._groups.map(Lxt),this._parents)}function rBn(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 sBn(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 qp(l,this._parents)}function aBn(){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 iBn(e){e||(e=oBn);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 qp(s,this._parents).order()}function oBn(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function lBn(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function cBn(){return Array.from(this)}function uBn(){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 dBn(){let e=0;for(const t of this)++e;return e}function fBn(){return!this.node()}function pBn(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 hBn(e){return function(){this.removeAttribute(e)}}function mBn(e){return function(){this.removeAttributeNS(e.space,e.local)}}function gBn(e,t){return function(){this.setAttribute(e,t)}}function vBn(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function yBn(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function bBn(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 xBn(e,t){var n=NV(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?mBn:hBn:typeof t=="function"?n.local?bBn:yBn:n.local?vBn:gBn)(n,t))}function Fxt(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function wBn(e){return function(){this.style.removeProperty(e)}}function SBn(e,t,n){return function(){this.style.setProperty(e,t,n)}}function kBn(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function OBn(e,t,n){return arguments.length>1?this.each((t==null?wBn:typeof t=="function"?kBn:SBn)(e,t,n??"")):wT(this.node(),e)}function wT(e,t){return e.style.getPropertyValue(t)||Fxt(e).getComputedStyle(e,null).getPropertyValue(t)}function _Bn(e){return function(){delete this[e]}}function CBn(e,t){return function(){this[e]=t}}function EBn(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function jBn(e,t){return arguments.length>1?this.each((t==null?_Bn:typeof t=="function"?EBn:CBn)(e,t)):this.node()[e]}function zxt(e){return e.trim().split(/^|\s+/)}function d1e(e){return e.classList||new Bxt(e)}function Bxt(e){this._node=e,this._names=zxt(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 Uxt(e,t){for(var n=d1e(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function qxt(e,t){for(var n=d1e(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function TBn(e){return function(){Uxt(this,e)}}function NBn(e){return function(){qxt(this,e)}}function IBn(e,t){return function(){(t.apply(this,arguments)?Uxt:qxt)(this,e)}}function ABn(e,t){var n=zxt(e+"");if(arguments.length<2){for(var r=d1e(this.node()),s=-1,a=n.length;++s<a;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?IBn:t?TBn:NBn)(n,t))}function RBn(){this.textContent=""}function PBn(e){return function(){this.textContent=e}}function $Bn(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function MBn(e){return arguments.length?this.each(e==null?RBn:(typeof e=="function"?$Bn:PBn)(e)):this.node().textContent}function DBn(){this.innerHTML=""}function LBn(e){return function(){this.innerHTML=e}}function FBn(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function zBn(e){return arguments.length?this.each(e==null?DBn:(typeof e=="function"?FBn:LBn)(e)):this.node().innerHTML}function BBn(){this.nextSibling&&this.parentNode.appendChild(this)}function UBn(){return this.each(BBn)}function qBn(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function VBn(){return this.each(qBn)}function HBn(e){var t=typeof e=="function"?e:Pxt(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function WBn(){return null}function ZBn(e,t){var n=typeof e=="function"?e:Pxt(e),r=t==null?WBn:typeof t=="function"?t:u1e(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function GBn(){var e=this.parentNode;e&&e.removeChild(this)}function QBn(){return this.each(GBn)}function YBn(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function XBn(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function KBn(e){return this.select(e?XBn:YBn)}function JBn(e){return arguments.length?this.property("__data__",e):this.node().__data__}function eUn(e){return function(t){e.call(this,t,this.__data__)}}function tUn(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 nUn(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 rUn(e,t,n){return function(){var r=this.__on,s,a=eUn(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 sUn(e,t,n){var r=tUn(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?rUn:nUn,s=0;s<a;++s)this.each(l(r[s],t,n));return this}function Vxt(e,t,n){var r=Fxt(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 aUn(e,t){return function(){return Vxt(this,e,t)}}function iUn(e,t){return function(){return Vxt(this,e,t.apply(this,arguments))}}function oUn(e,t){return this.each((typeof t=="function"?iUn:aUn)(e,t))}function*lUn(){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 Hxt=[null];function qp(e,t){this._groups=e,this._parents=t}function p3(){return new qp([[document.documentElement]],Hxt)}function cUn(){return this}qp.prototype=p3.prototype={constructor:qp,select:$7n,selectAll:F7n,selectChild:q7n,selectChildren:Z7n,filter:G7n,data:eBn,enter:Q7n,exit:nBn,join:rBn,merge:sBn,selection:cUn,order:aBn,sort:iBn,call:lBn,nodes:cBn,node:uBn,size:dBn,empty:fBn,each:pBn,attr:xBn,style:OBn,property:jBn,classed:ABn,text:MBn,html:zBn,raise:UBn,lower:VBn,append:HBn,insert:ZBn,remove:QBn,clone:KBn,datum:JBn,on:sUn,dispatch:oUn,[Symbol.iterator]:lUn};function gp(e){return typeof e=="string"?new qp([[document.querySelector(e)]],[document.documentElement]):new qp([[e]],Hxt)}function uUn(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Jm(e,t){if(e=uUn(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 dUn={passive:!1},eM={capture:!0,passive:!1};function VJ(e){e.stopImmediatePropagation()}function _j(e){e.preventDefault(),e.stopImmediatePropagation()}function Wxt(e){var t=e.document.documentElement,n=gp(e).on("dragstart.drag",_j,eM);"onselectstart"in t?n.on("selectstart.drag",_j,eM):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Zxt(e,t){var n=e.document.documentElement,r=gp(e).on("dragstart.drag",null);t&&(r.on("click.drag",_j,eM),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 O6=e=>()=>e;function Ohe(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}})}Ohe.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function fUn(e){return!e.ctrlKey&&!e.button}function pUn(){return this.parentNode}function hUn(e,t){return t??{x:e.x,y:e.y}}function mUn(){return navigator.maxTouchPoints||"ontouchstart"in this}function Gxt(){var e=fUn,t=pUn,n=hUn,r=mUn,s={},a=TV("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,dUn).on("touchend.drag touchcancel.drag",S).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=w(this,t.call(this,k,_),k,_,"mouse");C&&(gp(k.view).on("mousemove.drag",m,eM).on("mouseup.drag",v,eM),Wxt(k.view),VJ(k),u=!1,l=k.clientX,c=k.clientY,C("start",k))}}function m(k){if(_j(k),!u){var _=k.clientX-l,C=k.clientY-c;u=_*_+C*C>f}s.mouse("drag",k)}function v(k){gp(k.view).on("mousemove.drag mouseup.drag",null),Zxt(k.view,u),_j(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=w(this,E,k,_,C[N].identifier,C[N]))&&(VJ(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])&&(_j(k),j("drag",k,_[E]))}function S(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])&&(VJ(k),j("end",k,_[E]))}function w(k,_,C,E,j,N){var I=a.copy(),R=Jm(N||C,_),P,L,M;if((M=n.call(k,new Ohe("beforestart",{sourceEvent:C,target:p,identifier:j,active:i,x:R[0],y:R[1],dx:0,dy:0,dispatch:I}),E))!=null)return P=M.x-R[0]||0,L=M.y-R[1]||0,function q(H,F,z){var B=R,D;switch(H){case"start":s[j]=q,D=i++;break;case"end":delete s[j],--i;case"drag":R=Jm(z||F,_),D=i;break}I.call(H,k,new Ohe(H,{sourceEvent:F,subject:M,target:p,identifier:j,active:D,x:R[0]+P,y:R[1]+L,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:O6(!!k),p):e},p.container=function(k){return arguments.length?(t=typeof k=="function"?k:O6(k),p):t},p.subject=function(k){return arguments.length?(n=typeof k=="function"?k:O6(k),p):n},p.touchable=function(k){return arguments.length?(r=typeof k=="function"?k:O6(!!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 f1e(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Qxt(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function h3(){}var tM=.7,I7=1/tM,Cj="\\s*([+-]?\\d+)\\s*",nM="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Jv="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",gUn=/^#([0-9a-f]{3,8})$/,vUn=new RegExp(`^rgb\\(${Cj},${Cj},${Cj}\\)$`),yUn=new RegExp(`^rgb\\(${Jv},${Jv},${Jv}\\)$`),bUn=new RegExp(`^rgba\\(${Cj},${Cj},${Cj},${nM}\\)$`),xUn=new RegExp(`^rgba\\(${Jv},${Jv},${Jv},${nM}\\)$`),wUn=new RegExp(`^hsl\\(${nM},${Jv},${Jv}\\)$`),SUn=new RegExp(`^hsla\\(${nM},${Jv},${Jv},${nM}\\)$`),S9e={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};f1e(h3,$O,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:k9e,formatHex:k9e,formatHex8:kUn,formatHsl:OUn,formatRgb:O9e,toString:O9e});function k9e(){return this.rgb().formatHex()}function kUn(){return this.rgb().formatHex8()}function OUn(){return Yxt(this).formatHsl()}function O9e(){return this.rgb().formatRgb()}function $O(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=gUn.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?_9e(t):n===3?new nf(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?_6(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?_6(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=vUn.exec(e))?new nf(t[1],t[2],t[3],1):(t=yUn.exec(e))?new nf(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=bUn.exec(e))?_6(t[1],t[2],t[3],t[4]):(t=xUn.exec(e))?_6(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=wUn.exec(e))?j9e(t[1],t[2]/100,t[3]/100,1):(t=SUn.exec(e))?j9e(t[1],t[2]/100,t[3]/100,t[4]):S9e.hasOwnProperty(e)?_9e(S9e[e]):e==="transparent"?new nf(NaN,NaN,NaN,0):null}function _9e(e){return new nf(e>>16&255,e>>8&255,e&255,1)}function _6(e,t,n,r){return r<=0&&(e=t=n=NaN),new nf(e,t,n,r)}function _Un(e){return e instanceof h3||(e=$O(e)),e?(e=e.rgb(),new nf(e.r,e.g,e.b,e.opacity)):new nf}function _he(e,t,n,r){return arguments.length===1?_Un(e):new nf(e,t,n,r??1)}function nf(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}f1e(nf,_he,Qxt(h3,{brighter(e){return e=e==null?I7:Math.pow(I7,e),new nf(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?tM:Math.pow(tM,e),new nf(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new nf(Wk(this.r),Wk(this.g),Wk(this.b),A7(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:C9e,formatHex:C9e,formatHex8:CUn,formatRgb:E9e,toString:E9e}));function C9e(){return`#${Nk(this.r)}${Nk(this.g)}${Nk(this.b)}`}function CUn(){return`#${Nk(this.r)}${Nk(this.g)}${Nk(this.b)}${Nk((isNaN(this.opacity)?1:this.opacity)*255)}`}function E9e(){const e=A7(this.opacity);return`${e===1?"rgb(":"rgba("}${Wk(this.r)}, ${Wk(this.g)}, ${Wk(this.b)}${e===1?")":`, ${e})`}`}function A7(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Wk(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Nk(e){return e=Wk(e),(e<16?"0":"")+e.toString(16)}function j9e(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ag(e,t,n,r)}function Yxt(e){if(e instanceof ag)return new ag(e.h,e.s,e.l,e.opacity);if(e instanceof h3||(e=$O(e)),!e)return new ag;if(e instanceof ag)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 ag(i,l,c,e.opacity)}function EUn(e,t,n,r){return arguments.length===1?Yxt(e):new ag(e,t,n,r??1)}function ag(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}f1e(ag,EUn,Qxt(h3,{brighter(e){return e=e==null?I7:Math.pow(I7,e),new ag(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?tM:Math.pow(tM,e),new ag(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 nf(HJ(e>=240?e-240:e+120,s,r),HJ(e,s,r),HJ(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new ag(T9e(this.h),C6(this.s),C6(this.l),A7(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=A7(this.opacity);return`${e===1?"hsl(":"hsla("}${T9e(this.h)}, ${C6(this.s)*100}%, ${C6(this.l)*100}%${e===1?")":`, ${e})`}`}}));function T9e(e){return e=(e||0)%360,e<0?e+360:e}function C6(e){return Math.max(0,Math.min(1,e||0))}function HJ(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 p1e=e=>()=>e;function jUn(e,t){return function(n){return e+n*t}}function TUn(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 NUn(e){return(e=+e)==1?Xxt:function(t,n){return n-t?TUn(t,n,e):p1e(isNaN(t)?n:t)}}function Xxt(e,t){var n=t-e;return n?jUn(e,n):p1e(isNaN(e)?t:e)}const R7=(function e(t){var n=NUn(t);function r(s,a){var i=n((s=_he(s)).r,(a=_he(a)).r),l=n(s.g,a.g),c=n(s.b,a.b),u=Xxt(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 IUn(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 AUn(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function RUn(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]=ix(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 PUn(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function tg(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function $Un(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]=ix(e[s],t[s]):r[s]=t[s];return function(a){for(s in n)r[s]=n[s](a);return r}}var Che=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,WJ=new RegExp(Che.source,"g");function MUn(e){return function(){return e}}function DUn(e){return function(t){return e(t)+""}}function Kxt(e,t){var n=Che.lastIndex=WJ.lastIndex=0,r,s,a,i=-1,l=[],c=[];for(e=e+"",t=t+"";(r=Che.exec(e))&&(s=WJ.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:tg(r,s)})),n=WJ.lastIndex;return n<t.length&&(a=t.slice(n),l[i]?l[i]+=a:l[++i]=a),l.length<2?c[0]?DUn(c[0].x):MUn(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 ix(e,t){var n=typeof t,r;return t==null||n==="boolean"?p1e(t):(n==="number"?tg:n==="string"?(r=$O(t))?(t=r,R7):Kxt:t instanceof $O?R7:t instanceof Date?PUn:AUn(t)?IUn:Array.isArray(t)?RUn:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?$Un:tg)(e,t)}function h1e(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var N9e=180/Math.PI,Ehe={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Jxt(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)*N9e,skewX:Math.atan(c)*N9e,scaleX:i,scaleY:l}}var E6;function LUn(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Ehe:Jxt(t.a,t.b,t.c,t.d,t.e,t.f)}function FUn(e){return e==null||(E6||(E6=document.createElementNS("http://www.w3.org/2000/svg","g")),E6.setAttribute("transform",e),!(e=E6.transform.baseVal.consolidate()))?Ehe:(e=e.matrix,Jxt(e.a,e.b,e.c,e.d,e.e,e.f))}function e0t(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 v=h.push("translate(",null,t,null,n);m.push({i:v-4,x:tg(u,f)},{i:v-2,x:tg(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:tg(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:tg(u,d)}):d&&f.push(s(f)+"skewX("+d+r)}function c(u,d,f,p,h,m){if(u!==f||d!==p){var v=h.push(s(h)+"scale(",null,",",null,")");m.push({i:v-4,x:tg(u,f)},{i:v-2,x:tg(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,v=p.length,y;++m<v;)f[(y=p[m]).i]=y.x(h);return f.join("")}}}var zUn=e0t(LUn,"px, ","px)","deg)"),BUn=e0t(FUn,", ",")",")"),UUn=1e-12;function I9e(e){return((e=Math.exp(e))+1/e)/2}function qUn(e){return((e=Math.exp(e))-1/e)/2}function VUn(e){return((e=Math.exp(2*e))-1)/(e+1)}const JF=(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,v=h*h+m*m,y,b;if(v<UUn)b=Math.log(p/u)/t,y=function(E){return[l+E*h,c+E*m,u*Math.exp(t*E*b)]};else{var S=Math.sqrt(v),w=(p*p-u*u+r*v)/(2*u*n*S),k=(p*p-u*u-r*v)/(2*p*n*S),_=Math.log(Math.sqrt(w*w+1)-w),C=Math.log(Math.sqrt(k*k+1)-k);b=(C-_)/t,y=function(E){var j=E*b,N=I9e(_),I=u/(n*S)*(N*VUn(t*j+_)-qUn(_));return[l+I*h,c+I*m,u*N/I9e(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 HUn(e,t){t===void 0&&(t=e,e=ix);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 ST=0,u2=0,YA=0,t0t=1e3,P7,d2,$7=0,MO=0,IV=0,rM=typeof performance=="object"&&performance.now?performance:Date,n0t=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function m1e(){return MO||(n0t(WUn),MO=rM.now()+IV)}function WUn(){MO=0}function M7(){this._call=this._time=this._next=null}M7.prototype=r0t.prototype={constructor:M7,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?m1e():+n)+(t==null?0:+t),!this._next&&d2!==this&&(d2?d2._next=this:P7=this,d2=this),this._call=e,this._time=n,jhe()},stop:function(){this._call&&(this._call=null,this._time=1/0,jhe())}};function r0t(e,t,n){var r=new M7;return r.restart(e,t,n),r}function ZUn(){m1e(),++ST;for(var e=P7,t;e;)(t=MO-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ST}function A9e(){MO=($7=rM.now())+IV,ST=u2=0;try{ZUn()}finally{ST=0,QUn(),MO=0}}function GUn(){var e=rM.now(),t=e-$7;t>t0t&&(IV-=t,$7=e)}function QUn(){for(var e,t=P7,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:P7=n);d2=e,jhe(r)}function jhe(e){if(!ST){u2&&(u2=clearTimeout(u2));var t=e-MO;t>24?(e<1/0&&(u2=setTimeout(A9e,e-rM.now()-IV)),YA&&(YA=clearInterval(YA))):(YA||($7=rM.now(),YA=setInterval(GUn,t0t)),ST=1,n0t(A9e))}}function R9e(e,t,n){var r=new M7;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var YUn=TV("start","end","cancel","interrupt"),XUn=[],s0t=0,P9e=1,The=2,e8=3,$9e=4,Nhe=5,t8=6;function AV(e,t,n,r,s,a){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;KUn(e,n,{name:t,index:r,group:s,on:YUn,tween:XUn,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:s0t})}function g1e(e,t){var n=zg(e,t);if(n.state>s0t)throw new Error("too late; already scheduled");return n}function Dy(e,t){var n=zg(e,t);if(n.state>e8)throw new Error("too late; already running");return n}function zg(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function KUn(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=r0t(a,0,n.time);function a(u){n.state=P9e,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!==P9e)return c();for(d in r)if(h=r[d],h.name===n.name){if(h.state===e8)return R9e(i);h.state===$9e?(h.state=t8,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[d]):+d<t&&(h.state=t8,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[d])}if(R9e(function(){n.state===e8&&(n.state=$9e,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=The,n.on.call("start",e,e.__data__,n.index,n.group),n.state===The){for(n.state=e8,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=Nhe,1),f=-1,p=s.length;++f<p;)s[f].call(e,d);n.state===Nhe&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=t8,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function n8(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>The&&r.state<Nhe,r.state=t8,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[i]}a&&delete e.__transition}}function JUn(e){return this.each(function(){n8(this,e)})}function eqn(e,t){var n,r;return function(){var s=Dy(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 tqn(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var a=Dy(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 nqn(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=zg(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?eqn:tqn)(n,e,t))}function v1e(e,t,n){var r=e._id;return e.each(function(){var s=Dy(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return zg(s,r).value[t]}}function a0t(e,t){var n;return(typeof t=="number"?tg:t instanceof $O?R7:(n=$O(t))?(t=n,R7):Kxt)(e,t)}function rqn(e){return function(){this.removeAttribute(e)}}function sqn(e){return function(){this.removeAttributeNS(e.space,e.local)}}function aqn(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 iqn(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 oqn(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 lqn(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 cqn(e,t){var n=NV(e),r=n==="transform"?BUn:a0t;return this.attrTween(e,typeof t=="function"?(n.local?lqn:oqn)(n,r,v1e(this,"attr."+e,t)):t==null?(n.local?sqn:rqn)(n):(n.local?iqn:aqn)(n,r,t))}function uqn(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function dqn(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function fqn(e,t){var n,r;function s(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&dqn(e,a)),n}return s._value=t,s}function pqn(e,t){var n,r;function s(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&uqn(e,a)),n}return s._value=t,s}function hqn(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=NV(e);return this.tween(n,(r.local?fqn:pqn)(r,t))}function mqn(e,t){return function(){g1e(this,e).delay=+t.apply(this,arguments)}}function gqn(e,t){return t=+t,function(){g1e(this,e).delay=t}}function vqn(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?mqn:gqn)(t,e)):zg(this.node(),t).delay}function yqn(e,t){return function(){Dy(this,e).duration=+t.apply(this,arguments)}}function bqn(e,t){return t=+t,function(){Dy(this,e).duration=t}}function xqn(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?yqn:bqn)(t,e)):zg(this.node(),t).duration}function wqn(e,t){if(typeof t!="function")throw new Error;return function(){Dy(this,e).ease=t}}function Sqn(e){var t=this._id;return arguments.length?this.each(wqn(t,e)):zg(this.node(),t).ease}function kqn(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Dy(this,e).ease=n}}function Oqn(e){if(typeof e!="function")throw new Error;return this.each(kqn(this._id,e))}function _qn(e){typeof e!="function"&&(e=Mxt(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 Cx(r,this._parents,this._name,this._id)}function Cqn(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 Cx(i,this._parents,this._name,this._id)}function Eqn(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 jqn(e,t,n){var r,s,a=Eqn(t)?g1e:Dy;return function(){var i=a(this,e),l=i.on;l!==r&&(s=(r=l).copy()).on(t,n),i.on=s}}function Tqn(e,t){var n=this._id;return arguments.length<2?zg(this.node(),n).on.on(e):this.each(jqn(n,e,t))}function Nqn(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Iqn(){return this.on("end.remove",Nqn(this._id))}function Aqn(e){var t=this._name,n=this._id;typeof e!="function"&&(e=u1e(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,AV(u[p],t,n,p,u,zg(d,n)));return new Cx(a,this._parents,t,n)}function Rqn(e){var t=this._name,n=this._id;typeof e!="function"&&(e=$xt(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=zg(d,n),v=0,y=p.length;v<y;++v)(h=p[v])&&AV(h,t,n,v,p,m);a.push(p),i.push(d)}return new Cx(a,i,t,n)}var Pqn=p3.prototype.constructor;function $qn(){return new Pqn(this._groups,this._parents)}function Mqn(e,t){var n,r,s;return function(){var a=wT(this,e),i=(this.style.removeProperty(e),wT(this,e));return a===i?null:a===n&&i===r?s:s=t(n=a,r=i)}}function i0t(e){return function(){this.style.removeProperty(e)}}function Dqn(e,t,n){var r,s=n+"",a;return function(){var i=wT(this,e);return i===s?null:i===r?a:a=t(r=i,n)}}function Lqn(e,t,n){var r,s,a;return function(){var i=wT(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),wT(this,e))),i===c?null:i===r&&c===s?a:(s=c,a=t(r=i,l))}}function Fqn(e,t){var n,r,s,a="style."+t,i="end."+a,l;return function(){var c=Dy(this,e),u=c.on,d=c.value[a]==null?l||(l=i0t(t)):void 0;(u!==n||s!==d)&&(r=(n=u).copy()).on(i,s=d),c.on=r}}function zqn(e,t,n){var r=(e+="")=="transform"?zUn:a0t;return t==null?this.styleTween(e,Mqn(e,r)).on("end.style."+e,i0t(e)):typeof t=="function"?this.styleTween(e,Lqn(e,r,v1e(this,"style."+e,t))).each(Fqn(this._id,e)):this.styleTween(e,Dqn(e,r,t),n).on("end.style."+e,null)}function Bqn(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Uqn(e,t,n){var r,s;function a(){var i=t.apply(this,arguments);return i!==s&&(r=(s=i)&&Bqn(e,i,n)),r}return a._value=t,a}function qqn(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,Uqn(e,t,n??""))}function Vqn(e){return function(){this.textContent=e}}function Hqn(e){return function(){var t=e(this);this.textContent=t??""}}function Wqn(e){return this.tween("text",typeof e=="function"?Hqn(v1e(this,"text",e)):Vqn(e==null?"":e+""))}function Zqn(e){return function(t){this.textContent=e.call(this,t)}}function Gqn(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&Zqn(s)),t}return r._value=e,r}function Qqn(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,Gqn(e))}function Yqn(){for(var e=this._name,t=this._id,n=o0t(),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=zg(c,t);AV(c,e,n,u,i,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Cx(r,this._parents,e,n)}function Xqn(){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=Dy(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 Kqn=0;function Cx(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function o0t(){return++Kqn}var gb=p3.prototype;Cx.prototype={constructor:Cx,select:Aqn,selectAll:Rqn,selectChild:gb.selectChild,selectChildren:gb.selectChildren,filter:_qn,merge:Cqn,selection:$qn,transition:Yqn,call:gb.call,nodes:gb.nodes,node:gb.node,size:gb.size,empty:gb.empty,each:gb.each,on:Tqn,attr:cqn,attrTween:hqn,style:zqn,styleTween:qqn,text:Wqn,textTween:Qqn,remove:Iqn,tween:nqn,delay:vqn,duration:xqn,ease:Sqn,easeVarying:Oqn,end:Xqn,[Symbol.iterator]:gb[Symbol.iterator]};function Jqn(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var eVn={time:null,delay:0,duration:250,ease:Jqn};function tVn(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 nVn(e){var t,n;e instanceof Cx?(t=e._id,e=e._name):(t=o0t(),(n=eVn).time=m1e(),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])&&AV(c,e,t,u,i,n||tVn(c,t));return new Cx(r,this._parents,e,t)}p3.prototype.interrupt=JUn;p3.prototype.transition=nVn;const j6=e=>()=>e;function rVn(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 Zb(e,t,n){this.k=e,this.x=t,this.y=n}Zb.prototype={constructor:Zb,scale:function(e){return e===1?this:new Zb(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Zb(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 RV=new Zb(1,0,0);l0t.prototype=Zb.prototype;function l0t(e){for(;!e.__zoom;)if(!(e=e.parentNode))return RV;return e.__zoom}function ZJ(e){e.stopImmediatePropagation()}function XA(e){e.preventDefault(),e.stopImmediatePropagation()}function sVn(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function aVn(){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 M9e(){return this.__zoom||RV}function iVn(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function oVn(){return navigator.maxTouchPoints||"ontouchstart"in this}function lVn(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 c0t(){var e=sVn,t=aVn,n=lVn,r=iVn,s=oVn,a=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,c=JF,u=TV("start","zoom","end"),d,f,p,h=500,m=150,v=0,y=10;function b(M){M.property("__zoom",M9e).on("wheel.zoom",j,{passive:!1}).on("mousedown.zoom",N).on("dblclick.zoom",I).filter(s).on("touchstart.zoom",R).on("touchmove.zoom",P).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(M,q,H,F){var z=M.selection?M.selection():M;z.property("__zoom",M9e),M!==z?_(M,q,H,F):z.interrupt().each(function(){C(this,arguments).event(F).start().zoom(null,typeof q=="function"?q.apply(this,arguments):q).end()})},b.scaleBy=function(M,q,H,F){b.scaleTo(M,function(){var z=this.__zoom.k,B=typeof q=="function"?q.apply(this,arguments):q;return z*B},H,F)},b.scaleTo=function(M,q,H,F){b.transform(M,function(){var z=t.apply(this,arguments),B=this.__zoom,D=H==null?k(z):typeof H=="function"?H.apply(this,arguments):H,Q=B.invert(D),V=typeof q=="function"?q.apply(this,arguments):q;return n(w(S(B,V),D,Q),z,i)},H,F)},b.translateBy=function(M,q,H,F){b.transform(M,function(){return n(this.__zoom.translate(typeof q=="function"?q.apply(this,arguments):q,typeof H=="function"?H.apply(this,arguments):H),t.apply(this,arguments),i)},null,F)},b.translateTo=function(M,q,H,F,z){b.transform(M,function(){var B=t.apply(this,arguments),D=this.__zoom,Q=F==null?k(B):typeof F=="function"?F.apply(this,arguments):F;return n(RV.translate(Q[0],Q[1]).scale(D.k).translate(typeof q=="function"?-q.apply(this,arguments):-q,typeof H=="function"?-H.apply(this,arguments):-H),B,i)},F,z)};function S(M,q){return q=Math.max(a[0],Math.min(a[1],q)),q===M.k?M:new Zb(q,M.x,M.y)}function w(M,q,H){var F=q[0]-H[0]*M.k,z=q[1]-H[1]*M.k;return F===M.x&&z===M.y?M:new Zb(M.k,F,z)}function k(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function _(M,q,H,F){M.on("start.zoom",function(){C(this,arguments).event(F).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(F).end()}).tween("zoom",function(){var z=this,B=arguments,D=C(z,B).event(F),Q=t.apply(z,B),V=H==null?k(Q):typeof H=="function"?H.apply(z,B):H,$=Math.max(Q[1][0]-Q[0][0],Q[1][1]-Q[0][1]),U=z.__zoom,Z=typeof q=="function"?q.apply(z,B):q,X=c(U.invert(V).concat($/U.k),Z.invert(V).concat($/Z.k));return function(te){if(te===1)te=Z;else{var J=X(te),ee=$/J[2];te=new Zb(ee,V[0]-J[0]*ee,V[1]-J[1]*ee)}D.zoom(null,te)}})}function C(M,q,H){return!H&&M.__zooming||new E(M,q)}function E(M,q){this.that=M,this.args=q,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,q),this.taps=0}E.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,q){return this.mouse&&M!=="mouse"&&(this.mouse[1]=q.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=q.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=q.invert(this.touch1[0])),this.that.__zoom=q,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var q=gp(this.that).datum();u.call(M,this.that,new rVn(M,{sourceEvent:this.sourceEvent,target:b,transform:this.that.__zoom,dispatch:u}),q)}};function j(M,...q){if(!e.apply(this,arguments))return;var H=C(this,q).event(M),F=this.__zoom,z=Math.max(a[0],Math.min(a[1],F.k*Math.pow(2,r.apply(this,arguments)))),B=Jm(M);if(H.wheel)(H.mouse[0][0]!==B[0]||H.mouse[0][1]!==B[1])&&(H.mouse[1]=F.invert(H.mouse[0]=B)),clearTimeout(H.wheel);else{if(F.k===z)return;H.mouse=[B,F.invert(B)],n8(this),H.start()}XA(M),H.wheel=setTimeout(D,m),H.zoom("mouse",n(w(S(F,z),H.mouse[0],H.mouse[1]),H.extent,i));function D(){H.wheel=null,H.end()}}function N(M,...q){if(p||!e.apply(this,arguments))return;var H=M.currentTarget,F=C(this,q,!0).event(M),z=gp(M.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",$,!0),B=Jm(M,H),D=M.clientX,Q=M.clientY;Wxt(M.view),ZJ(M),F.mouse=[B,this.__zoom.invert(B)],n8(this),F.start();function V(U){if(XA(U),!F.moved){var Z=U.clientX-D,X=U.clientY-Q;F.moved=Z*Z+X*X>v}F.event(U).zoom("mouse",n(w(F.that.__zoom,F.mouse[0]=Jm(U,H),F.mouse[1]),F.extent,i))}function $(U){z.on("mousemove.zoom mouseup.zoom",null),Zxt(U.view,F.moved),XA(U),F.event(U).end()}}function I(M,...q){if(e.apply(this,arguments)){var H=this.__zoom,F=Jm(M.changedTouches?M.changedTouches[0]:M,this),z=H.invert(F),B=H.k*(M.shiftKey?.5:2),D=n(w(S(H,B),F,z),t.apply(this,q),i);XA(M),l>0?gp(this).transition().duration(l).call(_,D,F,M):gp(this).call(b.transform,D,F,M)}}function R(M,...q){if(e.apply(this,arguments)){var H=M.touches,F=H.length,z=C(this,q,M.changedTouches.length===F).event(M),B,D,Q,V;for(ZJ(M),D=0;D<F;++D)Q=H[D],V=Jm(Q,this),V=[V,this.__zoom.invert(V),Q.identifier],z.touch0?!z.touch1&&z.touch0[2]!==V[2]&&(z.touch1=V,z.taps=0):(z.touch0=V,B=!0,z.taps=1+!!d);d&&(d=clearTimeout(d)),B&&(z.taps<2&&(f=V[0],d=setTimeout(function(){d=null},h)),n8(this),z.start())}}function P(M,...q){if(this.__zooming){var H=C(this,q).event(M),F=M.changedTouches,z=F.length,B,D,Q,V;for(XA(M),B=0;B<z;++B)D=F[B],Q=Jm(D,this),H.touch0&&H.touch0[2]===D.identifier?H.touch0[0]=Q:H.touch1&&H.touch1[2]===D.identifier&&(H.touch1[0]=Q);if(D=H.that.__zoom,H.touch1){var $=H.touch0[0],U=H.touch0[1],Z=H.touch1[0],X=H.touch1[1],te=(te=Z[0]-$[0])*te+(te=Z[1]-$[1])*te,J=(J=X[0]-U[0])*J+(J=X[1]-U[1])*J;D=S(D,Math.sqrt(te/J)),Q=[($[0]+Z[0])/2,($[1]+Z[1])/2],V=[(U[0]+X[0])/2,(U[1]+X[1])/2]}else if(H.touch0)Q=H.touch0[0],V=H.touch0[1];else return;H.zoom("touch",n(w(D,Q,V),H.extent,i))}}function L(M,...q){if(this.__zooming){var H=C(this,q).event(M),F=M.changedTouches,z=F.length,B,D;for(ZJ(M),p&&clearTimeout(p),p=setTimeout(function(){p=null},h),B=0;B<z;++B)D=F[B],H.touch0&&H.touch0[2]===D.identifier?delete H.touch0:H.touch1&&H.touch1[2]===D.identifier&&delete H.touch1;if(H.touch1&&!H.touch0&&(H.touch0=H.touch1,delete H.touch1),H.touch0)H.touch0[1]=this.__zoom.invert(H.touch0[0]);else if(H.end(),H.taps===2&&(D=Jm(D,this),Math.hypot(f[0]-D[0],f[1]-D[1])<y)){var Q=gp(this).on("dblclick.zoom");Q&&Q.apply(this,arguments)}}}return b.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:j6(+M),b):r},b.filter=function(M){return arguments.length?(e=typeof M=="function"?M:j6(!!M),b):e},b.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:j6(!!M),b):s},b.extent=function(M){return arguments.length?(t=typeof M=="function"?M:j6([[+M[0][0],+M[0][1]],[+M[1][0],+M[1][1]]]),b):t},b.scaleExtent=function(M){return arguments.length?(a[0]=+M[0],a[1]=+M[1],b):[a[0],a[1]]},b.translateExtent=function(M){return arguments.length?(i[0][0]=+M[0][0],i[1][0]=+M[1][0],i[0][1]=+M[0][1],i[1][1]=+M[1][1],b):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},b.constrain=function(M){return arguments.length?(n=M,b):n},b.duration=function(M){return arguments.length?(l=+M,b):l},b.interpolate=function(M){return arguments.length?(c=M,b):c},b.on=function(){var M=u.on.apply(u,arguments);return M===u?b:M},b.clickDistance=function(M){return arguments.length?(v=(M=+M)*M,b):Math.sqrt(v)},b.tapDistance=function(M){return arguments.length?(y=+M,b):y},b}const hy={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."},sM=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],u0t=["Enter"," ","Escape"],d0t={"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 kT;(function(e){e.Strict="strict",e.Loose="loose"})(kT||(kT={}));var Zk;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Zk||(Zk={}));var aM;(function(e){e.Partial="partial",e.Full="full"})(aM||(aM={}));const f0t={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var iw;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(iw||(iw={}));var iM;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(iM||(iM={}));var nr;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(nr||(nr={}));const D9e={[nr.Left]:nr.Right,[nr.Right]:nr.Left,[nr.Top]:nr.Bottom,[nr.Bottom]:nr.Top};function p0t(e){return e===null?null:e?"valid":"invalid"}const h0t=e=>"id"in e&&"source"in e&&"target"in e,cVn=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),y1e=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),m3=(e,t=[0,0])=>{const{width:n,height:r}=Gx(e),s=e.origin??t,a=n*s[0],i=r*s[1];return{x:e.position.x-a,y:e.position.y-i}},uVn=(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):y1e(s)?s:t.nodeLookup.get(s.id));const l=i?D7(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return PV(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return $V(n)},g3=(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=PV(n,D7(s)),r=!0)}),r?$V(n):{x:0,y:0,width:0,height:0}},b1e=(e,t,[n,r,s]=[0,0,1],a=!1,i=!1)=>{const l={...y3(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,v=oM(l,_T(u)),y=(h??0)*(m??0),b=a&&v>0;(!u.internals.handleBounds||b||v>=y||u.dragging)&&c.push(u)}return c},dVn=(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 fVn(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 pVn({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:a},i){if(e.size===0)return Promise.resolve(!0);const l=fVn(e,i),c=g3(l),u=x1e(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 m0t({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",hy.error005());else{const h=l.measured.width,m=l.measured.height;h&&m&&(f=[[c,u],[c+h,u+m]])}else l&&CT(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=CT(f)?DO(t,f,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&a?.("015",hy.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 hVn({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(v=>v.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=dVn(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 OT=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),DO=(e={x:0,y:0},t,n)=>({x:OT(e.x,t[0][0],t[1][0]-(n?.width??0)),y:OT(e.y,t[0][1],t[1][1]-(n?.height??0))});function g0t(e,t,n){const{width:r,height:s}=Gx(n),{x:a,y:i}=n.internals.positionAbsolute;return DO(e,[[a,i],[a+r,i+s]],t)}const L9e=(e,t,n)=>e<t?OT(Math.abs(e-t),1,t)/t:e>n?-OT(Math.abs(e-n),1,t)/t:0,v0t=(e,t,n=15,r=40)=>{const s=L9e(e.x,r,t.width-r)*n,a=L9e(e.y,r,t.height-r)*n;return[s,a]},PV=(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)}),Ihe=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),$V=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),_T=(e,t=[0,0])=>{const{x:n,y:r}=y1e(e)?e.internals.positionAbsolute:m3(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}},D7=(e,t=[0,0])=>{const{x:n,y:r}=y1e(e)?e.internals.positionAbsolute:m3(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)}},y0t=(e,t)=>$V(PV(Ihe(e),Ihe(t))),oM=(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)},F9e=e=>dg(e.width)&&dg(e.height)&&dg(e.x)&&dg(e.y),dg=e=>!isNaN(e)&&isFinite(e),mVn=(e,t)=>{},v3=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),y3=({x:e,y:t},[n,r,s],a=!1,i=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return a?v3(l,i):l},L7=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function UC(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 gVn(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=UC(e,n),s=UC(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=UC(e.top??e.y??0,n),s=UC(e.bottom??e.y??0,n),a=UC(e.left??e.x??0,t),i=UC(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 vVn(e,t,n,r,s,a){const{x:i,y:l}=L7(e,[t,n,r]),{x:c,y:u}=L7({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 x1e=(e,t,n,r,s,a)=>{const i=gVn(a,t,n),l=(t-i.x)/e.width,c=(n-i.y)/e.height,u=Math.min(l,c),d=OT(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,v=vVn(e,h,m,d,t,n),y={left:Math.min(v.left-i.left,0),top:Math.min(v.top-i.top,0),right:Math.min(v.right-i.right,0),bottom:Math.min(v.bottom-i.bottom,0)};return{x:h-y.left+y.right,y:m-y.top+y.bottom,zoom:d}},lM=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function CT(e){return e!=null&&e!=="parent"}function Gx(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function b0t(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function x0t(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 z9e(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function yVn(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function bVn(e){return{...d0t,...e||{}}}function V2(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:a,y:i}=fg(e),l=y3({x:a-(s?.left??0),y:i-(s?.top??0)},r),{x:c,y:u}=n?v3(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const w1e=e=>({width:e.offsetWidth,height:e.offsetHeight}),w0t=e=>e?.getRootNode?.()||window?.document,xVn=["INPUT","SELECT","TEXTAREA"];function S0t(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:xVn.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const k0t=e=>"clientX"in e,fg=(e,t)=>{const n=k0t(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)}},B9e=(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,...w1e(i)}})};function O0t({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 T6(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function U9e({pos:e,x1:t,y1:n,x2:r,y2:s,c:a}){switch(e){case nr.Left:return[t-T6(t-r,a),n];case nr.Right:return[t+T6(r-t,a),n];case nr.Top:return[t,n-T6(n-s,a)];case nr.Bottom:return[t,n+T6(s-n,a)]}}function S1e({sourceX:e,sourceY:t,sourcePosition:n=nr.Bottom,targetX:r,targetY:s,targetPosition:a=nr.Top,curvature:i=.25}){const[l,c]=U9e({pos:n,x1:e,y1:t,x2:r,y2:s,c:i}),[u,d]=U9e({pos:a,x1:r,y1:s,x2:e,y2:t,c:i}),[f,p,h,m]=O0t({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 _0t({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 wVn({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 SVn({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const a=PV(D7(e),D7(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 oM(i,$V(a))>0}const kVn=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,OVn=(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)),_Vn=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||kVn;let s;return h0t(e)?s={...e}:s={...e,id:r(e)},OVn(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function C0t({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,a,i,l]=_0t({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,a,i,l]}const q9e={[nr.Left]:{x:-1,y:0},[nr.Right]:{x:1,y:0},[nr.Top]:{x:0,y:-1},[nr.Bottom]:{x:0,y:1}},CVn=({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},V9e=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function EVn({source:e,sourcePosition:t=nr.Bottom,target:n,targetPosition:r=nr.Top,center:s,offset:a,stepPosition:i}){const l=q9e[t],c=q9e[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=CVn({source:u,sourcePosition:t,target:d}),p=f.x!==0?"x":"y",h=f[p];let m=[],v,y;const b={x:0,y:0},S={x:0,y:0},[,,w,k]=_0t({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){p==="x"?(v=s.x??u.x+(d.x-u.x)*i,y=s.y??(u.y+d.y)/2):(v=s.x??(u.x+d.x)/2,y=s.y??u.y+(d.y-u.y)*i);const j=[{x:v,y:u.y},{x:v,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 M=Math.abs(e[p]-n[p]);if(M<=a){const q=Math.min(a-1,a-M);l[p]===h?b[p]=(u[p]>e[p]?-1:1)*q:S[p]=(d[p]>n[p]?-1:1)*q}}if(t!==r){const M=p==="x"?"y":"x",q=l[p]===c[M],H=u[M]>d[M],F=u[M]<d[M];(l[p]===1&&(!q&&H||q&&F)||l[p]!==1&&(!q&&F||q&&H))&&(m=p==="x"?j:N)}const I={x:u.x+b.x,y:u.y+b.y},R={x:d.x+S.x,y:d.y+S.y},P=Math.max(Math.abs(I.x-m[0].x),Math.abs(R.x-m[0].x)),L=Math.max(Math.abs(I.y-m[0].y),Math.abs(R.y-m[0].y));P>=L?(v=(I.x+R.x)/2,y=m[0].y):(v=m[0].x,y=(I.y+R.y)/2)}const _={x:u.x+b.x,y:u.y+b.y},C={x:d.x+S.x,y:d.y+S.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],v,y,w,k]}function jVn(e,t,n,r){const s=Math.min(V9e(e,t)/2,V9e(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 Ahe({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,v]=EVn({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+=jVn(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,v]}function H9e(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function TVn(e){const{sourceNode:t,targetNode:n}=e;if(!H9e(t)||!H9e(n))return null;const r=t.internals.handleBounds||W9e(t.handles),s=n.internals.handleBounds||W9e(n.handles),a=Z9e(r?.source??[],e.sourceHandle),i=Z9e(e.connectionMode===kT.Strict?s?.target??[]:(s?.target??[]).concat(s?.source??[]),e.targetHandle);if(!a||!i)return e.onError?.("008",hy.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=LO(t,a,l),d=LO(n,i,c);return{sourceX:u.x,sourceY:u.y,targetX:d.x,targetY:d.y,sourcePosition:l,targetPosition:c}}function W9e(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 LO(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??Gx(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 Z9e(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Rhe(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function NVn(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=Rhe(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 E0t=1e3,IVn=10,k1e={nodeOrigin:[0,0],nodeExtent:sM,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},AVn={...k1e,checkEquality:!0};function O1e(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function RVn(e,t,n){const r=O1e(k1e,n);for(const s of e.values())if(s.parentId)C1e(s,e,t,r);else{const a=m3(s,r.nodeOrigin),i=CT(s.extent)?s.extent:r.nodeExtent,l=DO(a,i,Gx(s));s.internals.positionAbsolute=l}}function PVn(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 _1e(e){return e==="manual"}function Phe(e,t,n,r={}){const s=O1e(AVn,r),a={i:0},i=new Map(t),l=s?.elevateNodesOnSelect&&!_1e(s.zIndexMode)?E0t: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=m3(d,s.nodeOrigin),h=CT(d.extent)?d.extent:s.nodeExtent,m=DO(p,h,Gx(d));f={...s.defaults,...d,measured:{width:d.measured?.width,height:d.measured?.height},internals:{positionAbsolute:m,handleBounds:PVn(d,f),z:j0t(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&&C1e(f,t,n,r,a),u||=d.selected??!1}return{nodesInitialized:c,hasSelectedNodes:u}}function $Vn(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 C1e(e,t,n,r,s){const{elevateNodesOnSelect:a,nodeOrigin:i,nodeExtent:l,zIndexMode:c}=O1e(k1e,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}$Vn(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*IVn),s&&d.internals.rootParentIndex!==void 0&&(s.i=d.internals.rootParentIndex);const f=a&&!_1e(c)?E0t:0,{x:p,y:h,z:m}=MVn(e,d,i,l,f,c),{positionAbsolute:v}=e.internals,y=p!==v.x||h!==v.y;(y||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:p,y:h}:v,z:m}})}function j0t(e,t,n){const r=dg(e.zIndex)?e.zIndex:0;return _1e(n)?r:r+(e.selected?t:0)}function MVn(e,t,n,r,s,a){const{x:i,y:l}=t.internals.positionAbsolute,c=Gx(e),u=m3(e,n),d=CT(e.extent)?DO(u,e.extent,c):u;let f=DO({x:i+d.x,y:l+d.y},r,c);e.extent==="parent"&&(f=g0t(f,c,t));const p=j0t(e,s,a),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=p?h+1:p}}function E1e(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??_T(l),u=y0t(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=Gx(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)),v=Math.max(d.height,Math.round(i.height)),y=(m-d.width)*f[0],b=(v-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(S=>{e.some(w=>w.id===S.id)||s.push({id:S.id,type:"position",position:{x:S.position.x+p,y:S.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:v+(h?f[1]*h-b:0)}})}),s}function DVn(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 v=w1e(h.nodeElement),y=m.measured.width!==v.width||m.measured.height!==v.height;if(!!(v.width&&v.height&&(y||!m.internals.handleBounds||h.force))){const S=h.nodeElement.getBoundingClientRect(),w=CT(m.extent)?m.extent:a;let{positionAbsolute:k}=m.internals;m.parentId&&m.extent==="parent"?k=g0t(k,v,t.get(m.parentId)):w&&(k=DO(k,w,v));const _={...m,measured:v,internals:{...m.internals,positionAbsolute:k,handleBounds:{source:B9e("source",h.nodeElement,S,f,m.id),target:B9e("target",h.nodeElement,S,f,m.id)}}};t.set(m.id,_),m.parentId&&C1e(_,t,n,{nodeOrigin:s,zIndexMode:i}),c=!0,y&&(u.push({id:m.id,type:"dimensions",dimensions:v}),m.expandParent&&m.parentId&&p.push({id:m.id,parentId:m.parentId,rect:_T(_,s)}))}}if(p.length>0){const h=E1e(p,t,n,s);u.push(...h)}return{changes:u,updatedInternals:c}}async function LVn({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 G9e(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 T0t(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}`;G9e("source",c,d,e,s,i),G9e("target",c,u,e,a,l),t.set(r.id,r)}}function N0t(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:N0t(n,t):!1}function Q9e(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 FVn(e,t,n,r){const s=new Map;for(const[a,i]of e)if((i.selected||i.id===r)&&(!i.parentId||!N0t(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 GJ({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 zVn({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=v3(a,t);return{x:i.x-a.x,y:i.y-a.y}}function BVn({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,v=null;function y({noDragClassName:S,handleSelector:w,domNode:k,isSelectable:_,nodeId:C,nodeClickDistance:E=0}){p=gp(k);function j({x:P,y:L}){const{nodeLookup:M,nodeExtent:q,snapGrid:H,snapToGrid:F,nodeOrigin:z,onNodeDrag:B,onSelectionDrag:D,onError:Q,updateNodePositions:V}=t();a={x:P,y:L};let $=!1;const U=l.size>1,Z=U&&q?Ihe(g3(l)):null,X=U&&F?zVn({dragItems:l,snapGrid:H,x:P,y:L}):null;for(const[te,J]of l){if(!M.has(te))continue;let ee={x:P-J.distance.x,y:L-J.distance.y};F&&(ee=X?{x:Math.round(ee.x+X.x),y:Math.round(ee.y+X.y)}:v3(ee,H));let ae=null;if(U&&q&&!J.extent&&Z){const{positionAbsolute:ne}=J.internals,ue=ne.x-Z.x+q[0][0],pe=ne.x+J.measured.width-Z.x2+q[1][0],le=ne.y-Z.y+q[0][1],ve=ne.y+J.measured.height-Z.y2+q[1][1];ae=[[ue,le],[pe,ve]]}const{position:ce,positionAbsolute:Y}=m0t({nodeId:te,nextPosition:ee,nodeLookup:M,nodeExtent:ae||q,nodeOrigin:z,onError:Q});$=$||J.position.x!==ce.x||J.position.y!==ce.y,J.position=ce,J.internals.positionAbsolute=Y}if(m=m||$,!!$&&(V(l,!0),v&&(r||B||!C&&D))){const[te,J]=GJ({nodeId:C,dragItems:l,nodeLookup:M});r?.(v,l,te,J),B?.(v,te,J),C||D?.(v,J)}}async function N(){if(!d)return;const{transform:P,panBy:L,autoPanSpeed:M,autoPanOnNodeDrag:q}=t();if(!q){c=!1,cancelAnimationFrame(i);return}const[H,F]=v0t(u,d,M);(H!==0||F!==0)&&(a.x=(a.x??0)-H/P[2],a.y=(a.y??0)-F/P[2],await L({x:H,y:F})&&j(a)),i=requestAnimationFrame(N)}function I(P){const{nodeLookup:L,multiSelectionActive:M,nodesDraggable:q,transform:H,snapGrid:F,snapToGrid:z,selectNodesOnDrag:B,onNodeDragStart:D,onSelectionDragStart:Q,unselectNodesAndEdges:V}=t();f=!0,(!B||!_)&&!M&&C&&(L.get(C)?.selected||V()),_&&B&&C&&e?.(C);const $=V2(P.sourceEvent,{transform:H,snapGrid:F,snapToGrid:z,containerBounds:d});if(a=$,l=FVn(L,q,$,C),l.size>0&&(n||D||!C&&Q)){const[U,Z]=GJ({nodeId:C,dragItems:l,nodeLookup:L});n?.(P.sourceEvent,l,U,Z),D?.(P.sourceEvent,U,Z),C||Q?.(P.sourceEvent,Z)}}const R=Gxt().clickDistance(E).on("start",P=>{const{domNode:L,nodeDragThreshold:M,transform:q,snapGrid:H,snapToGrid:F}=t();d=L?.getBoundingClientRect()||null,h=!1,m=!1,v=P.sourceEvent,M===0&&I(P),a=V2(P.sourceEvent,{transform:q,snapGrid:H,snapToGrid:F,containerBounds:d}),u=fg(P.sourceEvent,d)}).on("drag",P=>{const{autoPanOnNodeDrag:L,transform:M,snapGrid:q,snapToGrid:H,nodeDragThreshold:F,nodeLookup:z}=t(),B=V2(P.sourceEvent,{transform:M,snapGrid:q,snapToGrid:H,containerBounds:d});if(v=P.sourceEvent,(P.sourceEvent.type==="touchmove"&&P.sourceEvent.touches.length>1||C&&!z.has(C))&&(h=!0),!h){if(!c&&L&&f&&(c=!0,N()),!f){const D=fg(P.sourceEvent,d),Q=D.x-u.x,V=D.y-u.y;Math.sqrt(Q*Q+V*V)>F&&I(P)}(a.x!==B.xSnapped||a.y!==B.ySnapped)&&l&&f&&(u=fg(P.sourceEvent,d),j(B))}}).on("end",P=>{if(!(!f||h)&&(c=!1,f=!1,cancelAnimationFrame(i),l.size>0)){const{nodeLookup:L,updateNodePositions:M,onNodeDragStop:q,onSelectionDragStop:H}=t();if(m&&(M(l,!1),m=!1),s||q||!C&&H){const[F,z]=GJ({nodeId:C,dragItems:l,nodeLookup:L,dragging:!1});s?.(P.sourceEvent,l,F,z),q?.(P.sourceEvent,F,z),C||H?.(P.sourceEvent,z)}}}).filter(P=>{const L=P.target;return!P.button&&(!S||!Q9e(L,`.${S}`,k))&&(!w||Q9e(L,w,k))});p.call(R)}function b(){p?.on(".drag",null)}return{update:y,destroy:b}}function UVn(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())oM(s,_T(a))>0&&r.push(a);return r}const qVn=250;function VVn(e,t,n,r){let s=[],a=1/0;const i=UVn(e,n,t+qVn);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}=LO(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 I0t(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,...LO(i,c,c.position,!0)}:c}function A0t(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function HVn(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const R0t=()=>!0;function WVn(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:v,onConnectEnd:y,isValidConnection:b=R0t,onReconnectEnd:S,updateConnection:w,getTransform:k,getFromHandle:_,autoPanSpeed:C,dragThreshold:E=1,handleDomNode:j}){const N=w0t(e.target);let I=0,R;const{x:P,y:L}=fg(e),M=A0t(a,j),q=l?.getBoundingClientRect();let H=!1;if(!q||!M)return;const F=I0t(s,M,r,c,t);if(!F)return;let z=fg(e,q),B=!1,D=null,Q=!1,V=null;function $(){if(!d||!q)return;const[ce,Y]=v0t(z,q,C);p({x:ce,y:Y}),I=requestAnimationFrame($)}const U={...F,nodeId:s,type:M,position:F.position},Z=c.get(s);let te={inProgress:!0,isValid:null,from:LO(Z,U,nr.Left,!0),fromHandle:U,fromPosition:U.position,fromNode:Z,to:z,toHandle:null,toPosition:D9e[U.position],toNode:null,pointer:z};function J(){H=!0,w(te),m?.(e,{nodeId:s,handleId:r,handleType:M})}E===0&&J();function ee(ce){if(!H){const{x:ve,y:ye}=fg(ce),Se=ve-P,Ne=ye-L;if(!(Se*Se+Ne*Ne>E*E))return;J()}if(!_()||!U){ae(ce);return}const Y=k();z=fg(ce,q),R=VVn(y3(z,Y,!1,[1,1]),n,c,U),B||($(),B=!0);const ne=P0t(ce,{handle:R,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:i?"target":"source",isValidConnection:b,doc:N,lib:u,flowId:f,nodeLookup:c});V=ne.handleDomNode,D=ne.connection,Q=HVn(!!R,ne.isValid);const ue=c.get(s),pe=ue?LO(ue,U,nr.Left,!0):te.from,le={...te,from:pe,isValid:Q,to:ne.toHandle&&Q?L7({x:ne.toHandle.x,y:ne.toHandle.y},Y):z,toHandle:ne.toHandle,toPosition:Q&&ne.toHandle?ne.toHandle.position:D9e[U.position],toNode:ne.toHandle?c.get(ne.toHandle.nodeId):null,pointer:z};w(le),te=le}function ae(ce){if(!("touches"in ce&&ce.touches.length>0)){if(H){(R||V)&&D&&Q&&v?.(D);const{inProgress:Y,...ne}=te,ue={...ne,toPosition:te.toHandle?te.toPosition:null};y?.(ce,ue),a&&S?.(ce,ue)}h(),cancelAnimationFrame(I),B=!1,Q=!1,D=null,V=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 P0t(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:a,doc:i,lib:l,flowId:c,isValidConnection:u=R0t,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}=fg(e),v=i.elementFromPoint(h,m),y=v?.classList.contains(`${l}-flow__handle`)?v:p,b={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const S=A0t(void 0,y),w=y.getAttribute("data-nodeid"),k=y.getAttribute("data-handleid"),_=y.classList.contains("connectable"),C=y.classList.contains("connectableend");if(!w||!S)return b;const E={source:f?w:r,sourceHandle:f?k:s,target:f?r:w,targetHandle:f?s:k};b.connection=E;const N=_&&C&&(n===kT.Strict?f&&S==="source"||!f&&S==="target":w!==r||k!==s);b.isValid=N&&u(E),b.toHandle=I0t(w,S,k,d,n,!0)}return b}const $he={onPointerDown:WVn,isValid:P0t};function ZVn({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=gp(e);function a({translateExtent:l,width:c,height:u,zoomStep:d=1,pannable:f=!0,zoomable:p=!0,inversePan:h=!1}){const m=w=>{if(w.sourceEvent.type!=="wheel"||!t)return;const k=n(),_=w.sourceEvent.ctrlKey&&lM()?10:1,C=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*d,E=k[2]*Math.pow(2,C*_);t.scaleTo(E)};let v=[0,0];const y=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(v=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},b=w=>{const k=n();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!t)return;const _=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],C=[_[0]-v[0],_[1]-v[1]];v=_;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)},S=c0t().on("start",y).on("zoom",f?b:null).on("zoom.wheel",p?m:null);s.call(S,{})}function i(){s.on("zoom",null)}return{update:a,destroy:i,pointer:Jm}}const MV=e=>({x:e.x,y:e.y,zoom:e.k}),QJ=({x:e,y:t,zoom:n})=>RV.translate(e,t).scale(n),HE=(e,t)=>e.target.closest(`.${t}`),$0t=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),GVn=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,YJ=(e,t=0,n=GVn,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},M0t=e=>{const t=e.ctrlKey&&lM()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function QVn({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:a,zoomOnPinch:i,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(HE(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=Jm(d),b=M0t(d),S=f*Math.pow(2,b);r.scaleTo(n,S,y,d);return}const p=d.deltaMode===1?20:1;let h=s===Zk.Vertical?0:d.deltaX*p,m=s===Zk.Horizontal?0:d.deltaY*p;!lM()&&d.shiftKey&&s!==Zk.Vertical&&(h=d.deltaY*p,m=0),r.translateBy(n,-(h/f)*a,-(m/f)*a,{internal:!0});const v=MV(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(d,v),e.panScrollTimeout=setTimeout(()=>{u?.(d,v),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l?.(d,v))}}function YVn({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const a=r.type==="wheel",i=!t&&a&&!r.ctrlKey,l=HE(r,e);if(r.ctrlKey&&a&&l&&r.preventDefault(),i||l)return null;r.preventDefault(),n.call(this,r,s)}}function XVn({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;const s=MV(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 KVn({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return a=>{e.usedRightMouseButton=!!(n&&$0t(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),s&&!a.sourceEvent?.internal&&s?.(a.sourceEvent,MV(a.transform))}}function JVn({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:a}){return i=>{if(!i.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&$0t(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&a(i.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const l=MV(i.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s?.(i.sourceEvent,l)},n?150:0)}}}function eHn({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"&&(HE(f,`${u}-flow__node`)||HE(f,`${u}-flow__edge`)))return!0;if(!r&&!p&&!s&&!a&&!n||i||d&&!m||HE(f,l)&&m||HE(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 v=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||m)&&v}}function tHn({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=c0t().scaleExtent([t,n]).translateExtent(r),p=gp(e).call(f);S({x:s.x,y:s.y,zoom:OT(s.zoom,t,n)},[[0,0],[d.width,d.height]],r);const h=p.on("wheel.zoom"),m=p.on("dblclick.zoom");f.wheelDelta(M0t);function v(R,P){return p?new Promise(L=>{f?.interpolate(P?.interpolate==="linear"?ix:JF).transform(YJ(p,P?.duration,P?.ease,()=>L(!0)),R)}):Promise.resolve(!1)}function y({noWheelClassName:R,noPanClassName:P,onPaneContextMenu:L,userSelectionActive:M,panOnScroll:q,panOnDrag:H,panOnScrollMode:F,panOnScrollSpeed:z,preventScrolling:B,zoomOnPinch:D,zoomOnScroll:Q,zoomOnDoubleClick:V,zoomActivationKeyPressed:$,lib:U,onTransformChange:Z,connectionInProgress:X,paneClickDistance:te,selectionOnDrag:J}){M&&!u.isZoomingOrPanning&&b();const ee=q&&!$&&!M;f.clickDistance(J?1/0:!dg(te)||te<0?0:te);const ae=ee?QVn({zoomPanValues:u,noWheelClassName:R,d3Selection:p,d3Zoom:f,panOnScrollMode:F,panOnScrollSpeed:z,zoomOnPinch:D,onPanZoomStart:i,onPanZoom:a,onPanZoomEnd:l}):YVn({noWheelClassName:R,preventScrolling:B,d3ZoomHandler:h});if(p.on("wheel.zoom",ae,{passive:!1}),!M){const Y=XVn({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:i});f.on("start",Y);const ne=KVn({zoomPanValues:u,panOnDrag:H,onPaneContextMenu:!!L,onPanZoom:a,onTransformChange:Z});f.on("zoom",ne);const ue=JVn({zoomPanValues:u,panOnDrag:H,panOnScroll:q,onPaneContextMenu:L,onPanZoomEnd:l,onDraggingChange:c});f.on("end",ue)}const ce=eHn({zoomActivationKeyPressed:$,panOnDrag:H,zoomOnScroll:Q,panOnScroll:q,zoomOnDoubleClick:V,zoomOnPinch:D,userSelectionActive:M,noPanClassName:P,noWheelClassName:R,lib:U,connectionInProgress:X});f.filter(ce),V?p.on("dblclick.zoom",m):p.on("dblclick.zoom",null)}function b(){f.on("zoom",null)}async function S(R,P,L){const M=QJ(R),q=f?.constrain()(M,P,L);return q&&await v(q),new Promise(H=>H(q))}async function w(R,P){const L=QJ(R);return await v(L,P),new Promise(M=>M(L))}function k(R){if(p){const P=QJ(R),L=p.property("__zoom");(L.k!==R.zoom||L.x!==R.x||L.y!==R.y)&&f?.transform(p,P,null,{sync:!0})}}function _(){const R=p?l0t(p.node()):{x:0,y:0,k:1};return{x:R.x,y:R.y,zoom:R.k}}function C(R,P){return p?new Promise(L=>{f?.interpolate(P?.interpolate==="linear"?ix:JF).scaleTo(YJ(p,P?.duration,P?.ease,()=>L(!0)),R)}):Promise.resolve(!1)}function E(R,P){return p?new Promise(L=>{f?.interpolate(P?.interpolate==="linear"?ix:JF).scaleBy(YJ(p,P?.duration,P?.ease,()=>L(!0)),R)}):Promise.resolve(!1)}function j(R){f?.scaleExtent(R)}function N(R){f?.translateExtent(R)}function I(R){const P=!dg(R)||R<0?0:R;f?.clickDistance(P)}return{update:y,destroy:b,setViewport:w,setViewportConstrained:S,getViewport:_,scaleTo:C,scaleBy:E,setScaleExtent:j,setTranslateExtent:N,syncViewport:k,setClickDistance:I}}var ET;(function(e){e.Line="line",e.Handle="handle"})(ET||(ET={}));function nHn({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 Y9e(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 F0(e,t){return Math.max(0,t-e)}function z0(e,t){return Math.max(0,e-t)}function N6(e,t,n){return Math.max(0,t-e,e-n)}function X9e(e,t){return e?!t:t}function rHn(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:v,maxWidth:y,minHeight:b,maxHeight:S}=r,{x:w,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),P=-a[0]*_,L=-a[1]*C;let M=N6(I,v,y),q=N6(R,b,S);if(i){let z=0,B=0;c&&j<0?z=F0(w+j+P,i[0][0]):!c&&j>0&&(z=z0(w+I+P,i[1][0])),u&&N<0?B=F0(k+N+L,i[0][1]):!u&&N>0&&(B=z0(k+R+L,i[1][1])),M=Math.max(M,z),q=Math.max(q,B)}if(l){let z=0,B=0;c&&j>0?z=z0(w+j,l[0][0]):!c&&j<0&&(z=F0(w+I,l[1][0])),u&&N>0?B=z0(k+N,l[0][1]):!u&&N<0&&(B=F0(k+R,l[1][1])),M=Math.max(M,z),q=Math.max(q,B)}if(s){if(d){const z=N6(I/E,b,S)*E;if(M=Math.max(M,z),i){let B=0;!c&&!u||c&&!u&&p?B=z0(k+L+I/E,i[1][1])*E:B=F0(k+L+(c?j:-j)/E,i[0][1])*E,M=Math.max(M,B)}if(l){let B=0;!c&&!u||c&&!u&&p?B=F0(k+I/E,l[1][1])*E:B=z0(k+(c?j:-j)/E,l[0][1])*E,M=Math.max(M,B)}}if(f){const z=N6(R*E,v,y)/E;if(q=Math.max(q,z),i){let B=0;!c&&!u||u&&!c&&p?B=z0(w+R*E+P,i[1][0])/E:B=F0(w+(u?N:-N)*E+P,i[0][0])/E,q=Math.max(q,B)}if(l){let B=0;!c&&!u||u&&!c&&p?B=F0(w+R*E,l[1][0])/E:B=z0(w+(u?N:-N)*E,l[0][0])/E,q=Math.max(q,B)}}}N=N+(N<0?q:-q),j=j+(j<0?M:-M),s&&(p?I>R*E?N=(X9e(c,u)?-j:j)/E:j=(X9e(c,u)?-N:N)*E:d?(N=j/E,u=c):(j=N*E,c=u));const H=c?w+j:w,F=u?k+N:k;return{width:_+(c?-j:j),height:C+(u?-N:N),x:a[0]*j*(c?-1:1)+H,y:a[1]*N*(u?-1:1)+F}}const D0t={width:0,height:0,x:0,y:0},sHn={...D0t,pointerX:0,pointerY:0,aspectRatio:1};function aHn(e){return[[0,0],[e.measured.width,e.measured.height]]}function iHn(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 oHn({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const a=gp(e);let i={controlDirection:Y9e("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:v,shouldResize:y}){let b={...D0t},S={...sHn};i={boundaries:d,resizeDirection:p,keepAspectRatio:f,controlDirection:Y9e(u)};let w,k=null,_=[],C,E,j,N=!1;const I=Gxt().on("start",R=>{const{nodeLookup:P,transform:L,snapGrid:M,snapToGrid:q,nodeOrigin:H,paneDomNode:F}=n();if(w=P.get(t),!w)return;k=F?.getBoundingClientRect()??null;const{xSnapped:z,ySnapped:B}=V2(R.sourceEvent,{transform:L,snapGrid:M,snapToGrid:q,containerBounds:k});b={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},S={...b,pointerX:z,pointerY:B,aspectRatio:b.width/b.height},C=void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&(C=P.get(w.parentId),E=C&&w.extent==="parent"?aHn(C):void 0),_=[],j=void 0;for(const[D,Q]of P)if(Q.parentId===t&&(_.push({id:D,position:{...Q.position},extent:Q.extent}),Q.extent==="parent"||Q.expandParent)){const V=iHn(Q,w,Q.origin??H);j?j=[[Math.min(V[0][0],j[0][0]),Math.min(V[0][1],j[0][1])],[Math.max(V[1][0],j[1][0]),Math.max(V[1][1],j[1][1])]]:j=V}h?.(R,{...b})}).on("drag",R=>{const{transform:P,snapGrid:L,snapToGrid:M,nodeOrigin:q}=n(),H=V2(R.sourceEvent,{transform:P,snapGrid:L,snapToGrid:M,containerBounds:k}),F=[];if(!w)return;const{x:z,y:B,width:D,height:Q}=b,V={},$=w.origin??q,{width:U,height:Z,x:X,y:te}=rHn(S,i.controlDirection,H,i.boundaries,i.keepAspectRatio,$,E,j),J=U!==D,ee=Z!==Q,ae=X!==z&&J,ce=te!==B&&ee;if(!ae&&!ce&&!J&&!ee)return;if((ae||ce||$[0]===1||$[1]===1)&&(V.x=ae?X:b.x,V.y=ce?te:b.y,b.x=V.x,b.y=V.y,_.length>0)){const pe=X-z,le=te-B;for(const ve of _)ve.position={x:ve.position.x-pe+$[0]*(U-D),y:ve.position.y-le+$[1]*(Z-Q)},F.push(ve)}if((J||ee)&&(V.width=J&&(!i.resizeDirection||i.resizeDirection==="horizontal")?U:b.width,V.height=ee&&(!i.resizeDirection||i.resizeDirection==="vertical")?Z:b.height,b.width=V.width,b.height=V.height),C&&w.expandParent){const pe=$[0]*(V.width??0);V.x&&V.x<pe&&(b.x=pe,S.x=S.x-(V.x-pe));const le=$[1]*(V.height??0);V.y&&V.y<le&&(b.y=le,S.y=S.y-(V.y-le))}const Y=nHn({width:b.width,prevWidth:D,height:b.height,prevHeight:Q,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),ne={...b,direction:Y};y?.(R,ne)!==!1&&(N=!0,m?.(R,ne),r(V,F))}).on("end",R=>{N&&(v?.(R,{...b}),s?.({...b}),N=!1)});a.call(I)}function c(){a.on(".drag",null)}return{update:l,destroy:c}}const lHn={},K9e=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:()=>{(lHn?"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},cHn=e=>e?K9e(e):K9e,{useDebugValue:uHn}=Le,{useSyncExternalStoreWithSelector:dHn}=$wn,fHn=e=>e;function L0t(e,t=fHn,n){const r=dHn(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return uHn(r),r}const J9e=(e,t)=>{const n=cHn(e),r=(s,a=t)=>L0t(n,s,a);return Object.assign(r,n),r},pHn=(e,t)=>e?J9e(e,t):J9e;function no(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 DV=g.createContext(null),hHn=DV.Provider,F0t=hy.error001();function Us(e,t){const n=g.useContext(DV);if(n===null)throw new Error(F0t);return L0t(n,e,t)}function So(){const e=g.useContext(DV);if(e===null)throw new Error(F0t);return g.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const eFe={display:"none"},mHn={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},z0t="react-flow__node-desc",B0t="react-flow__edge-desc",gHn="react-flow__aria-live",vHn=e=>e.ariaLiveMessage,yHn=e=>e.ariaLabelConfig;function bHn({rfId:e}){const t=Us(vHn);return o.jsx("div",{id:`${gHn}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:mHn,children:t})}function xHn({rfId:e,disableKeyboardA11y:t}){const n=Us(yHn);return o.jsxs(o.Fragment,{children:[o.jsx("div",{id:`${z0t}-${e}`,style:eFe,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),o.jsx("div",{id:`${B0t}-${e}`,style:eFe,children:n["edge.a11yDescription.default"]}),!t&&o.jsx(bHn,{rfId:e})]})}const b3=g.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},a)=>{const i=`${e}`.split("-");return o.jsx("div",{className:Ml(["react-flow__panel",n,...i]),style:r,ref:a,...s,children:t})});b3.displayName="Panel";function wHn({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:o.jsx(b3,{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 SHn=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}},I6=e=>e.id;function kHn(e,t){return no(e.selectedNodes.map(I6),t.selectedNodes.map(I6))&&no(e.selectedEdges.map(I6),t.selectedEdges.map(I6))}function OHn({onSelectionChange:e}){const t=So(),{selectedNodes:n,selectedEdges:r}=Us(SHn,kHn);return g.useEffect(()=>{const s={nodes:n,edges:r};e?.(s),t.getState().onSelectionChangeHandlers.forEach(a=>a(s))},[n,r,e]),null}const _Hn=e=>!!e.onSelectionChangeHandlers;function CHn({onSelectionChange:e}){const t=Us(_Hn);return e||t?o.jsx(OHn,{onSelectionChange:e}):null}const Mhe=typeof window<"u"?g.useLayoutEffect:g.useEffect,U0t=[0,0],EHn={x:0,y:0,zoom:1},jHn=["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"],tFe=[...jHn,"rfId"],THn=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}),nFe={translateExtent:sM,nodeOrigin:U0t,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function NHn(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:a,setNodeExtent:i,reset:l,setDefaultNodesAndEdges:c}=Us(THn,no),u=So();Mhe(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=nFe,l()}),[]);const d=g.useRef(nFe);return Mhe(()=>{for(const f of tFe){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:bVn(p)}):f==="fitView"?u.setState({fitViewQueued:p}):f==="fitViewOptions"?u.setState({fitViewOptions:p}):u.setState({[f]:p})))}d.current=e},tFe.map(f=>e[f])),null}function rFe(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function IHn(e){const[t,n]=g.useState(e==="system"?null:e);return g.useEffect(()=>{if(e!=="system"){n(e);return}const r=rFe(),s=()=>n(r?.matches?"dark":"light");return s(),r?.addEventListener("change",s),()=>{r?.removeEventListener("change",s)}},[e]),t!==null?t:rFe()?.matches?"dark":"light"}const sFe=typeof document<"u"?document:null;function cM(e=null,t={target:sFe,actInsideInputWithModifier:!0}){const[n,r]=g.useState(!1),s=g.useRef(!1),a=g.useRef(new Set([])),[i,l]=g.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 D8n(this):new P8n(this)}getCursor(t,n=0,r){let s=t.doc?t:is.create({doc:t});return r==null&&(r=s.doc.length),this.regexp?kE(this,s,n,r):SE(this,s,n,r)}}class vxt{constructor(t){this.spec=t}}function A8n(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 SE(e,t,n,r){let s;return e.wholeWord&&(s=R8n(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(s=A8n(e.test,t,s)),new _x(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:a=>a.toLowerCase(),s)}function R8n(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(_7(s,n-a))!=po.Word||t(C7(s,n-a))!=po.Word)&&(t(C7(s,r-a))!=po.Word||t(_7(s,r-a))!=po.Word))}class P8n extends vxt{constructor(t){super(t)}nextMatch(t,n,r){let s=SE(this.spec,t,r,t.doc.length).nextOverlapping();if(s.done){let a=Math.min(t.doc.length,n+this.spec.unquoted.length);s=SE(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=SE(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=SE(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=SE(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 $8n(e,t,n){return(r,s,a)=>(!n||n(r,s,a))&&e(a[0],t,r,s)}function kE(e,t,n,r){let s;return e.wholeWord&&(s=M8n(t.charCategorizer(t.selection.main.head))),e.test&&(s=$8n(e.test,t,s)),new hxt(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:s},n,r)}function _7(e,t){return e.slice(xc(e,t,!1),t)}function C7(e,t){return e.slice(t,xc(e,t))}function M8n(e){return(t,n,r)=>!r[0].length||(e(_7(r.input,r.index))!=po.Word||e(C7(r.input,r.index))!=po.Word)&&(e(C7(r.input,r.index+r[0].length))!=po.Word||e(_7(r.input,r.index+r[0].length))!=po.Word)}class D8n extends vxt{nextMatch(t,n,r){let s=kE(this.spec,t,r,t.doc.length).next();return s.done&&(s=kE(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=kE(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=kE(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=kE(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 X$=vr.define(),a1e=vr.define(),$w=gl.define({create(e){return new ZK(whe(e).create(),null)},update(e,t){for(let n of t.effects)n.is(X$)?e=new ZK(n.value.create(),e.panel):n.is(a1e)&&(e=new ZK(e.query,n.value?i1e:null));return e},provide:e=>B$.from(e,t=>t.panel)});class ZK{constructor(t,n){this.query=t,this.panel=n}}const L8n=Cn.mark({class:"cm-searchMatch"}),F8n=Cn.mark({class:"cm-searchMatch cm-searchMatch-selected"}),z8n=bo.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field($w))}update(e){let t=e.state.field($w);(t!=e.startState.field($w)||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 kd;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?F8n:L8n)})}return r.finish()}},{decorations:e=>e.decorations});function f3(e){return t=>{let n=t.state.field($w,!1);return n&&n.query.spec.valid?e(t,n):xxt(t)}}const E7=f3((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let s=xt.single(r.from,r.to),a=e.state.facet(VN);return e.dispatch({selection:s,effects:[o1e(e,r),a.scrollToMatch(s.main,e)],userEvent:"select.search"}),bxt(e),!0}),j7=f3((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,s=t.prevMatch(n,r,r);if(!s)return!1;let a=xt.single(s.from,s.to),i=e.state.facet(VN);return e.dispatch({selection:a,effects:[o1e(e,s),i.scrollToMatch(a.main,e)],userEvent:"select.search"}),bxt(e),!0}),B8n=f3((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:xt.create(n.map(r=>xt.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),U8n=({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 _x(e.doc,e.sliceDoc(r,s));!l.next().done;){if(a.length>1e3)return!1;l.value.from==r&&(i=a.length),a.push(xt.range(l.value.from,l.value.to))}return t(e.update({selection:xt.create(a,i),userEvent:"select.search.matches"})),!0},f6e=f3((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=xt.single(i.from,i.to).map(f),d.push(o1e(e,i)),d.push(n.facet(VN).scrollToMatch(c.main,e))),e.dispatch({changes:f,selection:c,effects:d,userEvent:"input.replace"}),!0}),q8n=f3((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 i1e(e){return e.state.facet(VN).createPanel(e)}function whe(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(VN);return new gxt({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 yxt(e){let t=Swe(e,i1e);return t&&t.dom.querySelector("[main-field]")}function bxt(e){let t=yxt(e);t&&t==e.root.activeElement&&t.select()}const xxt=e=>{let t=e.state.field($w,!1);if(t&&t.panel){let n=yxt(e);if(n&&n!=e.root.activeElement){let r=whe(e.state,t.query.spec);r.valid&&e.dispatch({effects:X$.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[a1e.of(!0),t?X$.of(whe(e.state,t.query.spec)):vr.appendConfig.of(Z8n)]});return!0},wxt=e=>{let t=e.state.field($w,!1);if(!t||!t.panel)return!1;let n=Swe(e,i1e);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:a1e.of(!1)}),!0},V8n=[{key:"Mod-f",run:xxt,scope:"editor search-panel"},{key:"F3",run:E7,shift:j7,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:E7,shift:j7,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:wxt,scope:"editor search-panel"},{key:"Mod-Shift-l",run:U8n},{key:"Mod-Alt-g",run:x8n},{key:"Mod-d",run:I8n,preventDefault:!0}];class H8n{constructor(t){this.view=t;let n=this.query=t.state.field($w).query.spec;this.commit=this.commit.bind(this),this.searchField=ci("input",{value:n.search,placeholder:Qf(t,"Find"),"aria-label":Qf(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ci("input",{value:n.replace,placeholder:Qf(t,"Replace"),"aria-label":Qf(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=ci("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=ci("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=ci("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(s,a,i){return ci("button",{class:"cm-button",name:s,onclick:a,type:"button"},i)}this.dom=ci("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,r("next",()=>E7(t),[Qf(t,"next")]),r("prev",()=>j7(t),[Qf(t,"previous")]),r("select",()=>B8n(t),[Qf(t,"all")]),ci("label",null,[this.caseField,Qf(t,"match case")]),ci("label",null,[this.reField,Qf(t,"regexp")]),ci("label",null,[this.wordField,Qf(t,"by word")]),...t.state.readOnly?[]:[ci("br"),this.replaceField,r("replace",()=>f6e(t),[Qf(t,"replace")]),r("replaceAll",()=>q8n(t),[Qf(t,"replace all")])],ci("button",{name:"close",onclick:()=>wxt(t),"aria-label":Qf(t,"close"),type:"button"},["×"])])}commit(){let t=new gxt({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:X$.of(t)}))}keydown(t){d3n(this.view,t,"search-panel")?t.preventDefault():t.keyCode==13&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?j7:E7)(this.view)):t.keyCode==13&&t.target==this.replaceField&&(t.preventDefault(),f6e(this.view))}update(t){for(let n of t.transactions)for(let r of n.effects)r.is(X$)&&!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(VN).top}}function Qf(e,t){return e.state.phrase(t)}const w6=30,S6=/[\s\.,:;?!]/;function o1e(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-w6),i=Math.min(s,n+w6),l=e.state.sliceDoc(a,i);if(a!=r.from){for(let c=0;c<w6;c++)if(!S6.test(l[c+1])&&S6.test(l[c])){l=l.slice(c);break}}if(i!=s){for(let c=l.length-1;c>l.length-w6;c--)if(!S6.test(l[c-1])&&S6.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 W8n=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"}}),Z8n=[$w,Mg.low(z8n),W8n];class p6e{constructor(t,n,r){this.from=t,this.to=n,this.diagnostic=r}}class hk{constructor(t,n,r){this.diagnostics=t,this.panel=n,this.selected=r}static init(t,n,r){let s=r.facet(K$).markerFilter;s&&(t=s(t,r));let a=t.slice().sort((d,f)=>d.from-f.from||d.to-f.to),i=new kd,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((v,y)=>Math.min(v,y.to),f&&f.from>p?f.from:1e8)):(p=f.from,h=f.to,l.push(f),d++);d<a.length;){let v=a[d];if(v.from==p&&(v.to>v.from||v.to==p))l.push(v),d++,h=Math.min(v.to,h);else{h=Math.min(v.from,h);break}}let m=izn(l);if(l.some(v=>v.from==v.to||v.from==v.to-1&&r.doc.lineAt(v.from).to==v.from))i.add(p,p,Cn.widget({widget:new nzn(m),diagnostics:l.slice()}));else{let v=l.reduce((y,b)=>b.markClass?y+" "+b.markClass:y,"");i.add(p,h,Cn.mark({class:"cm-lintRange cm-lintRange-"+m+v,diagnostics:l.slice(),inclusiveEnd:l.some(y=>y.to>h)}))}c=h;for(let v=0;v<l.length;v++)l[v].to<=c&&l.splice(v--,1)}let u=i.finish();return new hk(u,n,xT(u))}}function xT(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 p6e(s,a,t||i.diagnostics[0]);else{if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new p6e(r.from,a,r.diagnostic)}}),r}function G8n(e,t){let n=t.pos,r=t.end||n,s=e.state.facet(K$).hideOn(e,n,r);if(s!=null)return s;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(i=>i.is(Sxt))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function Q8n(e,t){return e.field(xp,!1)?t:t.concat(vr.appendConfig.of(ozn))}const Sxt=vr.define(),l1e=vr.define(),kxt=vr.define(),xp=gl.define({create(){return new hk(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=xT(n,e.selected.diagnostic,a)||xT(n,null,a)}!n.size&&s&&t.state.facet(K$).autoPanel&&(s=null),e=new hk(n,s,r)}for(let n of t.effects)if(n.is(Sxt)){let r=t.state.facet(K$).autoPanel?n.value.length?J$.open:null:e.panel;e=hk.init(n.value,r,t.state)}else n.is(l1e)?e=new hk(e.diagnostics,n.value?J$.open:null,e.selected):n.is(kxt)&&(e=new hk(e.diagnostics,e.panel,n.value));return e},provide:e=>[B$.from(e,t=>t.panel),It.decorations.from(e,t=>t.diagnostics)]}),Y8n=Cn.mark({class:"cm-lintRange cm-lintRange-active"});function X8n(e,t,n){let{diagnostics:r}=e.state.field(xp),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(K$).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:K8n(e,s)}}}:null}function K8n(e,t){return ci("ul",{class:"cm-tooltip-lint"},t.map(n=>_xt(e,n,!1)))}const J8n=e=>{let t=e.state.field(xp,!1);(!t||!t.panel)&&e.dispatch({effects:Q8n(e.state,[l1e.of(!0)])});let n=Swe(e,J$.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},h6e=e=>{let t=e.state.field(xp,!1);return!t||!t.panel?!1:(e.dispatch({effects:l1e.of(!1)}),!0)},ezn=e=>{let t=e.state.field(xp,!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)},tzn=[{key:"Mod-Shift-m",run:J8n,preventDefault:!0},{key:"F8",run:ezn}],K$=On.define({combine(e){return{sources:e.map(t=>t.source).filter(t=>t!=null),...$y(e.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:m6e,tooltipFilter:m6e,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 m6e(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function Oxt(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 _xt(e,t,n){var r;let s=n?Oxt(t.actions):[];return ci("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},ci("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=xT(e.state.field(xp).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),ci("u",u.slice(d,d+1)),u.slice(d+1)],p=a.markClass?" "+a.markClass:"";return ci("button",{type:"button",class:"cm-diagnosticAction"+p,onclick:c,onmousedown:c,"aria-label":` Action: ${u}${d<0?"":` (access key "${s[i]})"`}.`},f)}),t.source&&ci("div",{class:"cm-diagnosticSource"},t.source))}class nzn extends Kp{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return ci("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class g6e{constructor(t,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=_xt(t,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class J${constructor(t){this.view=t,this.items=[];let n=s=>{if(s.keyCode==27)h6e(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=Oxt(a.actions);for(let l=0;l<i.length;l++)if(i[l].toUpperCase().charCodeAt(0)==s.keyCode){let c=xT(this.view.state.field(xp).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=ci("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=ci("div",{class:"cm-panel-lint"},this.list,ci("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>h6e(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(xp).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(xp),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 g6e(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 g6e(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(xp),r=xT(n.diagnostics,this.items[t].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:kxt.of(r)})}static open(t){return new J$(t)}}function rzn(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 k6(e){return rzn(`<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 szn=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:k6("#d11")},".cm-lintRange-warning":{backgroundImage:k6("orange")},".cm-lintRange-info":{backgroundImage:k6("#999")},".cm-lintRange-hint":{backgroundImage:k6("#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 azn(e){return e=="error"?4:e=="warning"?3:e=="info"?2:1}function izn(e){let t="hint",n=1;for(let r of e){let s=azn(r.severity);s>n&&(n=s,t=r.severity)}return t}const ozn=[xp,It.decorations.compute([xp],e=>{let{selected:t,panel:n}=e.field(xp);return!t||!n||t.from==t.to?Cn.none:Cn.set([Y8n.range(t.from,t.to)])}),J3n(X8n,{hideOn:G8n}),szn];var v6e=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(Y5n)),t.defaultKeymap!==!1&&(a=a.concat(v8n)),t.searchKeymap!==!1&&(a=a.concat(V8n)),t.historyKeymap!==!1&&(a=a.concat(OFn)),t.foldKeymap!==!1&&(a=a.concat($4n)),t.completionKeymap!==!1&&(a=a.concat(byt)),t.lintKeymap!==!1&&(a=a.concat(tzn));var i=[];return t.lineNumbers!==!1&&i.push(d4n()),t.highlightActiveLineGutter!==!1&&i.push(h4n()),t.highlightSpecialChars!==!1&&i.push(E3n()),t.history!==!1&&i.push(mFn()),t.foldGutter!==!1&&i.push(F4n()),t.drawSelection!==!1&&i.push(v3n()),t.dropCursor!==!1&&i.push(S3n()),t.allowMultipleSelections!==!1&&i.push(is.allowMultipleSelections.of(!0)),t.indentOnInput!==!1&&i.push(E4n()),t.syntaxHighlighting!==!1&&i.push(B1(q4n,{fallback:!0})),t.bracketMatching!==!1&&i.push(Y4n()),t.closeBrackets!==!1&&i.push(W5n()),t.autocompletion!==!1&&i.push(yyt()),t.rectangularSelection!==!1&&i.push(B3n()),s!==!1&&i.push(V3n()),t.highlightActiveLine!==!1&&i.push(R3n()),t.highlightSelectionMatches!==!1&&i.push(k8n()),t.tabSize&&typeof t.tabSize=="number"&&i.push(zN.of(" ".repeat(t.tabSize))),i.concat([FN.of(a.flat())]).filter(Boolean)};const lzn="#e5c07b",y6e="#e06c75",czn="#56b6c2",uzn="#ffffff",XF="#abb2bf",She="#7d8799",dzn="#61afef",fzn="#98c379",b6e="#d19a66",pzn="#c678dd",hzn="#21252b",x6e="#2c313a",w6e="#282c34",GK="#353a42",mzn="#3E4451",S6e="#528bff",gzn=It.theme({"&":{color:XF,backgroundColor:w6e},".cm-content":{caretColor:S6e},".cm-cursor, .cm-dropCursor":{borderLeftColor:S6e},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:mzn},".cm-panels":{backgroundColor:hzn,color:XF},".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:w6e,color:She,border:"none"},".cm-activeLineGutter":{backgroundColor:x6e},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:GK},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:GK,borderBottomColor:GK},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:x6e,color:XF}}},{dark:!0}),vzn=Dg.define([{tag:fe.keyword,color:pzn},{tag:[fe.name,fe.deleted,fe.character,fe.propertyName,fe.macroName],color:y6e},{tag:[fe.function(fe.variableName),fe.labelName],color:dzn},{tag:[fe.color,fe.constant(fe.name),fe.standard(fe.name)],color:b6e},{tag:[fe.definition(fe.name),fe.separator],color:XF},{tag:[fe.typeName,fe.className,fe.number,fe.changed,fe.annotation,fe.modifier,fe.self,fe.namespace],color:lzn},{tag:[fe.operator,fe.operatorKeyword,fe.url,fe.escape,fe.regexp,fe.link,fe.special(fe.string)],color:czn},{tag:[fe.meta,fe.comment],color:She},{tag:fe.strong,fontWeight:"bold"},{tag:fe.emphasis,fontStyle:"italic"},{tag:fe.strikethrough,textDecoration:"line-through"},{tag:fe.link,color:She,textDecoration:"underline"},{tag:fe.heading,fontWeight:"bold",color:y6e},{tag:[fe.atom,fe.bool,fe.special(fe.variableName)],color:b6e},{tag:[fe.processingInstruction,fe.string,fe.inserted],color:fzn},{tag:fe.invalid,color:uzn}]),yzn=[gzn,B1(vzn)];var bzn=It.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),xzn=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,v=[];switch(s&&v.unshift(FN.of([y8n])),m&&(typeof m=="boolean"?v.unshift(v6e()):v.unshift(v6e(m))),p&&v.unshift(D3n(p)),d){case"light":v.push(bzn);break;case"dark":v.push(yzn);break;case"none":break;default:v.push(d);break}return i===!1&&v.push(It.editable.of(!1)),c&&v.push(is.readOnly.of(!0)),[...v]},wzn=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 Szn{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 k6e{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 QK=null,kzn=()=>typeof window>"u"?new k6e:(QK||(QK=new k6e),QK),O6e=Py.define(),Ozn=200,_zn=[];function Czn(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?_zn: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,v=m===void 0?null:m,y=e.maxHeight,b=y===void 0?null:y,S=e.width,w=S===void 0?null:S,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,P=e.readOnly,L=P===void 0?!1:P,M=e.indentWithTab,q=M===void 0?!0:M,H=e.basicSetup,F=H===void 0?!0:H,z=e.root,B=e.initialState,D=g.useState(),Q=D[0],V=D[1],$=g.useState(),U=$[0],Z=$[1],X=g.useState(),te=X[0],J=X[1],ee=g.useState(()=>({current:null}))[0],ae=g.useState(()=>({current:null}))[0],ce=It.theme({"&":{height:h,minHeight:v,maxHeight:b,width:w,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(O6e))){ee.current?ee.current.reset():(ee.current=new Szn(()=>{if(ae.current){var ye=ae.current;ae.current=null,ye()}ee.current=null},Ozn),kzn().add(ee.current));var le=pe.state.doc,ve=le.toString();r(ve,pe)}s&&s(wzn(pe))}),ne=xzn({theme:f,editable:R,readOnly:L,placeholder:N,indentWithTab:q,basicSetup:F}),ue=[Y,ce,...ne];return i&&typeof i=="function"&&ue.push(It.updateListener.of(i)),ue=ue.concat(c),g.useLayoutEffect(()=>{if(Q&&!te){var pe={doc:t,selection:n,extensions:ue},le=B?is.fromJSON(B.json,pe,B.fields):is.create(pe);if(J(le),!U){var ve=new It({state:le,parent:Q,root:z});Z(ve),a&&a(ve,le)}}return()=>{U&&(J(void 0),Z(void 0))}},[Q,te]),g.useEffect(()=>{e.container&&V(e.container)},[e.container]),g.useEffect(()=>()=>{U&&(U.destroy(),Z(void 0)),ee.current&&(ee.current.cancel(),ee.current=null)},[U]),g.useEffect(()=>{u&&U&&U.focus()},[u,U]),g.useEffect(()=>{U&&U.dispatch({effects:vr.reconfigure.of(ue)})},[f,c,h,v,b,w,_,E,N,R,L,q,F,r,i]),g.useEffect(()=>{if(t!==void 0){var pe=U?U.state.doc.toString():"";if(U&&t!==pe){var le=ee.current&&!ee.current.isDone,ve=()=>{U&&t!==U.state.doc.toString()&&U.dispatch({changes:{from:0,to:U.state.doc.toString().length,insert:t||""},annotations:[O6e.of(!0)]})};le?ae.current=ve:ve()}}},[t,U]),{state:te,setState:J,view:U,setView:Z,container:Q,setContainer:V}}var Ezn=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],ru=g.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,v=e.height,y=e.minHeight,b=e.maxHeight,S=e.width,w=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,P=Rbt(e,Ezn),L=g.useRef(null),M=Czn({root:I,value:s,autoFocus:p,theme:m,height:v,minHeight:y,maxHeight:b,width:S,minWidth:w,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}),q=M.state,H=M.view,F=M.container,z=M.setContainer;g.useImperativeHandle(t,()=>({editor:L.current,state:q,view:H}),[L,F,q,H]);var B=g.useCallback(Q=>{L.current=Q,z(Q)},[z]);if(typeof s!="string")throw new Error("value must be typeof string but got "+typeof s);var D=typeof m=="string"?"cm-theme-"+m:"cm-theme";return o.jsx("div",PO({ref:B,className:""+D+(n?" "+n:"")},P))});ru.displayName="CodeMirror";const jzn={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 YK=null;function Tzn(){return YK||(YK=(async()=>{const[{createHighlighterCore:e},{createJavaScriptRegexEngine:t}]=await Promise.all([jo(()=>import("./core-DsIK9rAU.js"),__vite__mapDeps([0,1,2]),import.meta.url),jo(()=>import("./engine-javascript-CSIo_1eZ.js"),__vite__mapDeps([3,1]),import.meta.url)]);return e({themes:[jo(()=>import("./github-light-DAi9KRSo.js"),[],import.meta.url),jo(()=>import("./github-dark-DHJKELXO.js"),[],import.meta.url)],langs:[jo(()=>import("./javascript-ySlJ1b_l.js"),[],import.meta.url),jo(()=>import("./typescript-Dj6nwHGl.js"),[],import.meta.url),jo(()=>import("./tsx-B6W0miNI.js"),[],import.meta.url),jo(()=>import("./jsx-BAng5TT0.js"),[],import.meta.url),jo(()=>import("./json-BQoSv7ci.js"),[],import.meta.url),jo(()=>import("./bash-atvbtKCR.js"),[],import.meta.url),jo(()=>import("./markdown-UIAJJxZW.js"),[],import.meta.url),jo(()=>import("./python-DhUJRlN_.js"),[],import.meta.url)],engine:t()})})()),YK}async function Nzn(e,t){const n=jzn[t?.toLowerCase()];if(!n)return null;const r=await Tzn(),{tokens:s}=r.codeToTokens(e,{lang:n,defaultColor:!1,themes:{light:"github-light",dark:"github-dark"}});return s}function Izn(e){return new NO(Ewe.define(e))}const Cxt=[Km.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return jo(()=>Promise.resolve().then(()=>b6),void 0,import.meta.url).then(e=>e.javascript())}}),Km.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return jo(()=>Promise.resolve().then(()=>l5n),void 0,import.meta.url).then(e=>e.json())}}),Km.of({name:"JSX",extensions:["jsx"],load(){return jo(()=>Promise.resolve().then(()=>b6),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),Km.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return jo(()=>Promise.resolve().then(()=>nFn),void 0,import.meta.url).then(e=>e.markdown())}}),Km.of({name:"TSX",extensions:["tsx"],load(){return jo(()=>Promise.resolve().then(()=>b6),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Km.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return jo(()=>Promise.resolve().then(()=>b6),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),Km.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return jo(()=>import("./shell-CjFT_Tl9.js"),[],import.meta.url).then(e=>Izn(e.shell))}})];function Azn(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 Rzn(e){const t=Azn(e);return yyt({override:[Pzn(t)],defaultKeymap:!0,closeOnBlur:!0,icons:!1})}function Pzn(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 v=u.state.sliceDoc(p,p+2)==="}}"?d.label:`${d.label}}}`;u.dispatch({changes:{from:f,to:p,insert:v},selection:{anchor:f+v.length}})}}));return{from:a,options:l,validFor:/^[a-zA-Z0-9_.\[\]]*$/}}}const $zn=/\{\{([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)\}\}/g,Mzn=Cn.mark({class:"cm-variable-highlight"}),_6e=new Avt({regexp:$zn,decoration:()=>Mzn}),Dzn=bo.fromClass(class{decorations;constructor(e){this.decorations=_6e.createDeco(e)}update(e){this.decorations=_6e.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}),Lzn=Dzn;function Fzn(){const e=UN({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 zzn(){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=Dg.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,B1(t)]}const My=()=>{const e=PN().resolvedTheme==="dark";return g.useMemo(()=>e?Fzn():zzn(),[e])},Qr=g.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 v=My(),y=e?JSON.stringify(e,null,2):t??"",b=g.useMemo(()=>{const S=[];return f&&S.push(It.lineWrapping),a==="json"?S.push(ff):a==="markdown"&&S.push(e1e({base:RO,codeLanguages:Cxt})),i&&a==="markdown"&&S.push(Lzn),c&&a==="markdown"&&S.push(Rzn(c)),p===!1&&S.push(is.readOnly.of(!0)),S},[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(Oa,{content:y,className:"absolute top-2 right-2 z-20"}),o.jsx(ru,{ref:m,value:y,theme:v,extensions:b,onChange:n,editable:p,"aria-label":"Code editor",placeholder:l,height:"100%",style:{height:"100%"},autoFocus:u,basicSetup:{lineNumbers:d}})]})}),Bzn=e=>{try{return JSON.stringify(e??{},null,2)}catch{return"{}"}},Uzn=({editorClassName:e="h-[240px] max-h-[40vh]",onSaved:t})=>{const n=My(),{settings:r,setSettings:s}=tV(),a=r?.tracingOptions,i=g.useMemo(()=>Bzn(a),[a]),[l,c]=g.useState(()=>i),u=g.useRef(!1);g.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(ru,{value:l,onChange:d,theme:n,extensions:[ff],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(de,{type:"button",onClick:f,children:"Save"})})]})},qzn=()=>{const[e,t]=g.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx(de,{type:"button",variant:"ghost",size:"icon-md","aria-label":"Run Options",onClick:()=>t(!0),children:o.jsx(Ue,{children:o.jsx(hq,{})})})}),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(Rr,{children:o.jsx(Uzn,{onSaved:()=>t(!1)})})]})})]})};function Vzn({status:e}){switch(e){case"running":return o.jsx(Gt,{});case"failed":return o.jsx(vs,{className:"text-accent2"});case"canceled":return o.jsx(Of,{className:"text-neutral3"});case"pending":case"waiting":return o.jsx(dO,{className:"text-neutral3"});case"suspended":return o.jsx(lq,{className:"text-accent3"});case"success":return o.jsx(Js,{className:"text-accent1"});default:return o.jsx(dO,{className:"text-neutral3"})}}function Ext({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(Vzn,{status:e})})}),o.jsx(Bn,{children:e})]})}var XK,C6e;function c1e(){if(C6e)return XK;C6e=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([v,y]){d(v)&&f.setNode(v,y)}),Object.values(this._edgeObjs).forEach(function(v){f.hasNode(v.v)&&f.hasNode(v.w)&&f.setEdge(v,p.edge(v))});var h={};function m(v){var y=p.parent(v);return y===void 0||f.hasNode(y)?(h[v]=y,y):y in h?h[y]:m(y)}return this._isCompound&&f.nodes().forEach(v=>f.setParent(v,m(v))),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,v){return h.length>1?p.setEdge(m,v,f):p.setEdge(m,v),v}),this}setEdge(){var d,f,p,h,m=!1,v=arguments[0];typeof v=="object"&&v!==null&&"v"in v?(d=v.v,f=v.w,p=v.name,arguments.length===2&&(h=arguments[1],m=!0)):(d=v,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 v=h;h=m,m=v}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 v=h;h=m,m=v}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 XK=r,XK}var KK,E6e;function Hzn(){return E6e||(E6e=1,KK="2.2.4"),KK}var JK,j6e;function Wzn(){return j6e||(j6e=1,JK={Graph:c1e(),version:Hzn()}),JK}var eJ,T6e;function Zzn(){if(T6e)return eJ;T6e=1;var e=c1e();eJ={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 eJ}var tJ,N6e;function Gzn(){if(N6e)return tJ;N6e=1,tJ=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 tJ}var nJ,I6e;function jxt(){if(I6e)return nJ;I6e=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 nJ=e,nJ}var rJ,A6e;function Txt(){if(A6e)return rJ;A6e=1;var e=jxt();rJ=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,v=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<v.distance&&(v.distance=b,v.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 rJ}var sJ,R6e;function Qzn(){if(R6e)return sJ;R6e=1;var e=Txt();sJ=t;function t(n,r,s){return n.nodes().reduce(function(a,i){return a[i]=e(n,i,r,s),a},{})}return sJ}var aJ,P6e;function Nxt(){if(P6e)return aJ;P6e=1,aJ=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 aJ}var iJ,$6e;function Yzn(){if($6e)return iJ;$6e=1;var e=Nxt();iJ=t;function t(n){return e(n).filter(function(r){return r.length>1||r.length===1&&n.hasEdge(r[0],r[0])})}return iJ}var oJ,M6e;function Xzn(){if(M6e)return oJ;M6e=1,oJ=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],v=f[p],y=h.distance+m.distance;y<v.distance&&(v.distance=y,v.predecessor=m.predecessor)})})}),i}return oJ}var lJ,D6e;function Ixt(){if(D6e)return lJ;D6e=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 lJ=e,e.CycleException=t,lJ}var cJ,L6e;function Kzn(){if(L6e)return cJ;L6e=1;var e=Ixt();cJ=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return cJ}var uJ,F6e;function Axt(){if(F6e)return uJ;F6e=1,uJ=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 uJ}var dJ,z6e;function Jzn(){if(z6e)return dJ;z6e=1;var e=Axt();dJ=t;function t(n,r){return e(n,r,"post")}return dJ}var fJ,B6e;function e7n(){if(B6e)return fJ;B6e=1;var e=Axt();fJ=t;function t(n,r){return e(n,r,"pre")}return fJ}var pJ,U6e;function t7n(){if(U6e)return pJ;U6e=1;var e=c1e(),t=jxt();pJ=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 pJ}var hJ,q6e;function n7n(){return q6e||(q6e=1,hJ={components:Gzn(),dijkstra:Txt(),dijkstraAll:Qzn(),findCycles:Yzn(),floydWarshall:Xzn(),isAcyclic:Kzn(),postorder:Jzn(),preorder:e7n(),prim:t7n(),tarjan:Nxt(),topsort:Ixt()}),hJ}var mJ,V6e;function Tg(){if(V6e)return mJ;V6e=1;var e=Wzn();return mJ={Graph:e.Graph,json:Zzn(),alg:n7n(),version:e.version},mJ}var gJ,H6e;function r7n(){if(H6e)return gJ;H6e=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 gJ=e,gJ}var vJ,W6e;function s7n(){if(W6e)return vJ;W6e=1;let e=Tg().Graph,t=r7n();vJ=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],v;for(;u.nodeCount();){for(;v=m.dequeue();)a(u,d,f,v);for(;v=h.dequeue();)a(u,d,f,v);if(u.nodeCount()){for(let y=d.length-2;y>0;--y)if(v=d[y].dequeue(),v){p=p.concat(a(u,d,f,v,!0));break}}}return p}function a(u,d,f,p,h){let m=h?[]:void 0;return u.inEdges(p.v).forEach(v=>{let y=u.edge(v),b=u.node(v.v);h&&m.push({v:v.v,w:v.w}),b.out-=y,l(d,f,b)}),u.outEdges(p.v).forEach(v=>{let y=u.edge(v),b=v.w,S=u.node(b);S.in-=y,l(d,f,S)}),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,S=d(y),w=b+S;f.setEdge(y.v,y.w,w),h=Math.max(h,f.node(y.v).out+=S),p=Math.max(p,f.node(y.w).in+=S)});let m=c(h+p+3).map(()=>new t),v=p+1;return f.nodes().forEach(y=>{l(m,v,f.node(y))}),{graph:f,buckets:m,zeroIdx:v}}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 vJ}var yJ,Z6e;function Nl(){if(Z6e)return yJ;Z6e=1;let e=Tg().Graph;yJ={addBorderNode:d,addDummyNode:t,applyWithChunking:h,asNonCompoundGraph:r,buildLayerMatrix:l,intersectRect:i,mapValues:C,maxRank:m,normalizeRanks:c,notime:b,partition:v,pick:_,predecessorWeights:a,range:k,removeEmptyRanks:u,simplify:n,successorWeights:s,time:y,uniqueId:w,zipObject:E};function t(j,N,I,R){for(var P=R;j.hasNode(P);)P=w(R);return I.dummy=N,j.setNode(P,I),P}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},P=j.edge(I);N.setEdge(I.v,I.w,{weight:R.weight+P.weight,minlen:Math.max(R.minlen,P.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(P=>{R[P.w]=(R[P.w]||0)+j.edge(P).weight}),R});return E(j.nodes(),N)}function a(j){let N=j.nodes().map(I=>{let R={};return j.inEdges(I).forEach(P=>{R[P.v]=(R[P.v]||0)+j.edge(P).weight}),R});return E(j.nodes(),N)}function i(j,N){let I=j.x,R=j.y,P=N.x-I,L=N.y-R,M=j.width/2,q=j.height/2;if(!P&&!L)throw new Error("Not possible to find intersection inside of the rectangle");let H,F;return Math.abs(L)*M>Math.abs(P)*q?(L<0&&(q=-q),H=q*P/L,F=q):(P<0&&(M=-M),H=M,F=M*L/P),{x:I+H,y:R+F}}function l(j){let N=k(m(j)+1).map(()=>[]);return j.nodes().forEach(I=>{let R=j.node(I),P=R.rank;P!==void 0&&(N[P][R.order]=I)}),N}function c(j){let N=j.nodes().map(R=>{let P=j.node(R).rank;return P===void 0?Number.MAX_VALUE:P}),I=h(Math.min,N);j.nodes().forEach(R=>{let P=j.node(R);Object.hasOwn(P,"rank")&&(P.rank-=I)})}function u(j){let N=j.nodes().map(M=>j.node(M).rank),I=h(Math.min,N),R=[];j.nodes().forEach(M=>{let q=j.node(M).rank-I;R[q]||(R[q]=[]),R[q].push(M)});let P=0,L=j.graph().nodeRankFactor;Array.from(R).forEach((M,q)=>{M===void 0&&q%L!==0?--P:M!==void 0&&P&&M.forEach(H=>j.node(H).rank+=P)})}function d(j,N,I,R){let P={width:0,height:0};return arguments.length>=4&&(P.rank=I,P.order=R),t(j,"border",P,N)}function f(j,N=p){const I=[];for(let R=0;R<j.length;R+=N){const P=j.slice(R,R+N);I.push(P)}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 P=j.node(R).rank;return P===void 0?Number.MIN_VALUE:P});return h(Math.max,I)}function v(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 S=0;function w(j){var N=++S;return j+(""+N)}function k(j,N,I=1){N==null&&(N=j,j=0);let R=L=>L<N;I<0&&(R=L=>N<L);const P=[];for(let L=j;R(L);L+=I)P.push(L);return P}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,[P,L])=>(R[P]=I(L,P),R),{})}function E(j,N){return j.reduce((I,R,P)=>(I[R]=N[P],I),{})}return yJ}var bJ,G6e;function a7n(){if(G6e)return bJ;G6e=1;let e=s7n(),t=Nl().uniqueId;bJ={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 bJ}var xJ,Q6e;function i7n(){if(Q6e)return xJ;Q6e=1;let e=Nl();xJ={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,v;for(v=0,++l;l<u;++v,++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),v===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 xJ}var wJ,Y6e;function T7(){if(Y6e)return wJ;Y6e=1;const{applyWithChunking:e}=Nl();wJ={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 wJ}var SJ,X6e;function Rxt(){if(X6e)return SJ;X6e=1;var e=Tg().Graph,t=T7().slack;SJ=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 SJ}var kJ,K6e;function o7n(){if(K6e)return kJ;K6e=1;var e=Rxt(),t=T7().slack,n=T7().longestPath,r=Tg().alg.preorder,s=Tg().alg.postorder,a=Nl().simplify;kJ=i,i.initLowLimValues=d,i.initCutValues=l,i.calcCutValue=u,i.leaveEdge=p,i.enterEdge=h,i.exchangeEdges=m;function i(S){S=a(S),n(S);var w=e(S);d(w),l(w,S);for(var k,_;k=p(w);)_=h(w,S,k),m(w,S,k,_)}function l(S,w){var k=s(S,S.nodes());k=k.slice(0,k.length-1),k.forEach(_=>c(S,w,_))}function c(S,w,k){var _=S.node(k),C=_.parent;S.edge(k,C).cutvalue=u(S,w,k)}function u(S,w,k){var _=S.node(k),C=_.parent,E=!0,j=w.edge(k,C),N=0;return j||(E=!1,j=w.edge(C,k)),N=j.weight,w.nodeEdges(k).forEach(I=>{var R=I.v===k,P=R?I.w:I.v;if(P!==C){var L=R===E,M=w.edge(I).weight;if(N+=L?M:-M,y(S,k,P)){var q=S.edge(k,P).cutvalue;N+=L?-q:q}}}),N}function d(S,w){arguments.length<2&&(w=S.nodes()[0]),f(S,{},1,w)}function f(S,w,k,_,C){var E=k,j=S.node(_);return w[_]=!0,S.neighbors(_).forEach(N=>{Object.hasOwn(w,N)||(k=f(S,w,k,N,_))}),j.low=E,j.lim=k++,C?j.parent=C:delete j.parent,k}function p(S){return S.edges().find(w=>S.edge(w).cutvalue<0)}function h(S,w,k){var _=k.v,C=k.w;w.hasEdge(_,C)||(_=k.w,C=k.v);var E=S.node(_),j=S.node(C),N=E,I=!1;E.lim>j.lim&&(N=j,I=!0);var R=w.edges().filter(P=>I===b(S,S.node(P.v),N)&&I!==b(S,S.node(P.w),N));return R.reduce((P,L)=>t(w,L)<t(w,P)?L:P)}function m(S,w,k,_){var C=k.v,E=k.w;S.removeEdge(C,E),S.setEdge(_.v,_.w,{}),d(S),l(S,w),v(S,w)}function v(S,w){var k=S.nodes().find(C=>!w.node(C).parent),_=r(S,k);_=_.slice(1),_.forEach(C=>{var E=S.node(C).parent,j=w.edge(C,E),N=!1;j||(j=w.edge(E,C),N=!0),w.node(C).rank=w.node(E).rank+(N?j.minlen:-j.minlen)})}function y(S,w,k){return S.hasEdge(w,k)}function b(S,w,k){return k.low<=w.lim&&w.lim<=k.lim}return kJ}var OJ,J6e;function l7n(){if(J6e)return OJ;J6e=1;var e=T7(),t=e.longestPath,n=Rxt(),r=o7n();OJ=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 OJ}var _J,e9e;function c7n(){if(e9e)return _J;e9e=1,_J=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 _J}var CJ,t9e;function u7n(){if(t9e)return CJ;t9e=1;let e=Nl();CJ={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"),v=e.addBorderNode(i,"_bb"),y=i.node(p);i.setParent(m,p),y.borderTop=m,i.setParent(v,p),y.borderBottom=v,h.forEach(b=>{n(i,l,c,u,d,f,b);let S=i.node(b),w=S.borderTop?S.borderTop:b,k=S.borderBottom?S.borderBottom:b,_=S.borderTop?u:2*u,C=w!==k?1:d-f[p]+1;i.setEdge(m,w,{weight:_,minlen:C,nestingEdge:!0}),i.setEdge(k,v,{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 CJ}var EJ,n9e;function d7n(){if(n9e)return EJ;n9e=1;let e=Nl();EJ=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 EJ}var jJ,r9e;function f7n(){if(r9e)return jJ;r9e=1,jJ={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 jJ}var TJ,s9e;function p7n(){if(s9e)return TJ;s9e=1;let e=Nl();TJ=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 TJ}var NJ,a9e;function h7n(){if(a9e)return NJ;a9e=1;let e=Nl().zipObject;NJ=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 NJ}var IJ,i9e;function m7n(){if(i9e)return IJ;i9e=1,IJ=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 IJ}var AJ,o9e;function g7n(){if(o9e)return AJ;o9e=1;let e=Nl();AJ=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 AJ}var RJ,l9e;function v7n(){if(l9e)return RJ;l9e=1;let e=Nl();RJ=t;function t(s,a){let i=e.partition(s,m=>Object.hasOwn(m,"barycenter")),l=i.lhs,c=i.rhs.sort((m,v)=>v.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 RJ}var PJ,c9e;function y7n(){if(c9e)return PJ;c9e=1;let e=m7n(),t=g7n(),n=v7n();PJ=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(S=>S!==p&&S!==h));let v=e(i,d);v.forEach(S=>{if(i.children(S.v).length){let w=r(i,S.v,c,u);m[S.v]=w,Object.hasOwn(w,"barycenter")&&a(S,w)}});let y=t(v,c);s(y,m);let b=n(y,u);if(p&&(b.vs=[p,b.vs,h].flat(!0),i.predecessors(p).length)){let S=i.node(i.predecessors(p)[0]),w=i.node(i.predecessors(h)[0]);Object.hasOwn(b,"barycenter")||(b.barycenter=0,b.weight=0),b.barycenter=(b.barycenter*b.weight+S.order+w.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 PJ}var $J,u9e;function b7n(){if(u9e)return $J;u9e=1;let e=Tg().Graph,t=Nl();$J=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,v=u.edge(m,d),y=v!==void 0?v.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 $J}var MJ,d9e;function x7n(){if(d9e)return MJ;d9e=1,MJ=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 MJ}var DJ,f9e;function w7n(){if(f9e)return DJ;f9e=1;let e=p7n(),t=h7n(),n=y7n(),r=b7n(),s=x7n(),a=Tg().Graph,i=Nl();DJ=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"),v=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,S;for(let w=0,k=0;k<4;++w,++k){u(w%2?m:v,w%4>=2),y=i.buildLayerMatrix(f);let _=t(f,y);_<b&&(k=0,S=Object.assign({},y),b=_)}d(f,S)}function c(f,p,h){const m=new Map,v=(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"&&v(b.rank,y),typeof b.minRank=="number"&&typeof b.maxRank=="number")for(let S=b.minRank;S<=b.maxRank;S++)S!==b.rank&&v(S,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 v=m.graph().root,y=n(m,v,h,p);y.vs.forEach((b,S)=>m.node(b).order=S),s(m,h,y.vs)})}function d(f,p){Object.values(p).forEach(h=>h.forEach((m,v)=>f.node(m).order=v))}return DJ}var LJ,p9e;function S7n(){if(p9e)return LJ;p9e=1;let e=Tg().Graph,t=Nl();LJ={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 S={};function w(k,_){let C=0,E=0,j=k.length,N=_[_.length-1];return _.forEach((I,R)=>{let P=s(y,I),L=P?y.node(P).order:j;(P||I===N)&&(_.slice(E,R+1).forEach(M=>{y.predecessors(M).forEach(q=>{let H=y.node(q),F=H.order;(F<C||L<F)&&!(H.dummy&&y.node(M).dummy)&&a(S,q,M)})}),E=R+1,C=L)}),_}return b.length&&b.reduce(w),S}function r(y,b){let S={};function w(_,C,E,j,N){let I;t.range(C,E).forEach(R=>{I=_[R],y.node(I).dummy&&y.predecessors(I).forEach(P=>{let L=y.node(P);L.dummy&&(L.order<j||L.order>N)&&a(S,P,I)})})}function k(_,C){let E=-1,j,N=0;return C.forEach((I,R)=>{if(y.node(I).dummy==="border"){let P=y.predecessors(I);P.length&&(j=y.node(P[0]).order,w(C,N,R,E,j),N=R,E=j)}w(C,N,C.length,j,_.length)}),C}return b.length&&b.reduce(k),S}function s(y,b){if(y.node(b).dummy)return y.predecessors(b).find(S=>y.node(S).dummy)}function a(y,b,S){if(b>S){let k=b;b=S,S=k}let w=y[b];w||(y[b]=w={}),w[S]=!0}function i(y,b,S){if(b>S){let w=b;b=S,S=w}return!!y[b]&&Object.hasOwn(y[b],S)}function l(y,b,S,w){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=w(N);if(I.length){I=I.sort((P,L)=>C[P]-C[L]);let R=(I.length-1)/2;for(let P=Math.floor(R),L=Math.ceil(R);P<=L;++P){let M=I[P];_[N]===N&&j<C[M]&&!i(S,N,M)&&(_[M]=N,_[N]=k[N]=k[M],j=C[M])}}})}),{root:k,align:_}}function c(y,b,S,w,k){let _={},C=u(y,b,S,k),E=k?"borderLeft":"borderRight";function j(R,P){let L=C.nodes(),M=L.pop(),q={};for(;M;)q[M]?R(M):(q[M]=!0,L.push(M),L=L.concat(P(M))),M=L.pop()}function N(R){_[R]=C.inEdges(R).reduce((P,L)=>Math.max(P,_[L.v]+C.edge(L)),0)}function I(R){let P=C.outEdges(R).reduce((M,q)=>Math.min(M,_[q.w]-C.edge(q)),Number.POSITIVE_INFINITY),L=y.node(R);P!==Number.POSITIVE_INFINITY&&L.borderType!==E&&(_[R]=Math.max(_[R],P))}return j(N,C.predecessors.bind(C)),j(I,C.successors.bind(C)),Object.keys(w).forEach(R=>_[R]=_[S[R]]),_}function u(y,b,S,w){let k=new e,_=y.graph(),C=m(_.nodesep,_.edgesep,w);return b.forEach(E=>{let j;E.forEach(N=>{let I=S[N];if(k.setNode(I),j){var R=S[j],P=k.edge(R,I);k.setEdge(R,I,Math.max(C(y,N,j),P||0))}j=N})}),k}function d(y,b){return Object.values(b).reduce((S,w)=>{let k=Number.NEGATIVE_INFINITY,_=Number.POSITIVE_INFINITY;Object.entries(w).forEach(([E,j])=>{let N=v(y,E)/2;k=Math.max(j+N,k),_=Math.min(j-N,_)});const C=k-_;return C<S[0]&&(S=[C,w]),S},[Number.POSITIVE_INFINITY,null])[1]}function f(y,b){let S=Object.values(b),w=t.applyWithChunking(Math.min,S),k=t.applyWithChunking(Math.max,S);["u","d"].forEach(_=>{["l","r"].forEach(C=>{let E=_+C,j=y[E];if(j===b)return;let N=Object.values(j),I=w-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,(S,w)=>{if(b)return y[b.toLowerCase()][w];{let k=Object.values(y).map(_=>_[w]).sort((_,C)=>_-C);return(k[1]+k[2])/2}})}function h(y){let b=t.buildLayerMatrix(y),S=Object.assign(n(y,b),r(y,b)),w={},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,S,j),I=c(y,k,N.root,N.align,E==="r");E==="r"&&(I=t.mapValues(I,R=>-R)),w[C+E]=I})});let _=d(y,w);return f(w,_),p(w,y.graph().align)}function m(y,b,S){return(w,k,_)=>{let C=w.node(k),E=w.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+=S?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+=S?N:-N),N=0,j}}function v(y,b){return y.node(b).width}return LJ}var FJ,h9e;function k7n(){if(h9e)return FJ;h9e=1;let e=Nl(),t=S7n().positionX;FJ=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 FJ}var zJ,m9e;function O7n(){if(m9e)return zJ;m9e=1;let e=a7n(),t=i7n(),n=l7n(),r=Nl().normalizeRanks,s=c7n(),a=Nl().removeEmptyRanks,i=u7n(),l=d7n(),c=f7n(),u=w7n(),d=k7n(),f=Nl(),p=Tg().Graph;zJ=h;function h($,U){let Z=U&&U.debugTiming?f.time:f.notime;Z("layout",()=>{let X=Z(" buildLayoutGraph",()=>j($));Z(" runLayout",()=>m(X,Z,U)),Z(" updateInputGraph",()=>v($,X))})}function m($,U,Z){U(" makeSpaceForEdgeLabels",()=>N($)),U(" removeSelfEdges",()=>z($)),U(" acyclic",()=>e.run($)),U(" nestingGraph.run",()=>i.run($)),U(" rank",()=>n(f.asNonCompoundGraph($))),U(" injectEdgeLabelProxies",()=>I($)),U(" removeEmptyRanks",()=>a($)),U(" nestingGraph.cleanup",()=>i.cleanup($)),U(" normalizeRanks",()=>r($)),U(" assignRankMinMax",()=>R($)),U(" removeEdgeLabelProxies",()=>P($)),U(" normalize.run",()=>t.run($)),U(" parentDummyChains",()=>s($)),U(" addBorderSegments",()=>l($)),U(" order",()=>u($,Z)),U(" insertSelfEdges",()=>B($)),U(" adjustCoordinateSystem",()=>c.adjust($)),U(" position",()=>d($)),U(" positionSelfEdges",()=>D($)),U(" removeBorderNodes",()=>F($)),U(" normalize.undo",()=>t.undo($)),U(" fixupEdgeLabelCoords",()=>q($)),U(" undoCoordinateSystem",()=>c.undo($)),U(" translateGraph",()=>L($)),U(" assignNodeIntersects",()=>M($)),U(" reversePoints",()=>H($)),U(" acyclic.undo",()=>e.undo($))}function v($,U){$.nodes().forEach(Z=>{let X=$.node(Z),te=U.node(Z);X&&(X.x=te.x,X.y=te.y,X.rank=te.rank,U.children(Z).length&&(X.width=te.width,X.height=te.height))}),$.edges().forEach(Z=>{let X=$.edge(Z),te=U.edge(Z);X.points=te.points,Object.hasOwn(te,"x")&&(X.x=te.x,X.y=te.y)}),$.graph().width=U.graph().width,$.graph().height=U.graph().height}let y=["nodesep","edgesep","ranksep","marginx","marginy"],b={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},S=["acyclicer","ranker","rankdir","align"],w=["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($){let U=new p({multigraph:!0,compound:!0}),Z=V($.graph());return U.setGraph(Object.assign({},b,Q(Z,y),f.pick(Z,S))),$.nodes().forEach(X=>{let te=V($.node(X));const J=Q(te,w);Object.keys(k).forEach(ee=>{J[ee]===void 0&&(J[ee]=k[ee])}),U.setNode(X,J),U.setParent(X,$.parent(X))}),$.edges().forEach(X=>{let te=V($.edge(X));U.setEdge(X,Object.assign({},C,Q(te,_),f.pick(te,E)))}),U}function N($){let U=$.graph();U.ranksep/=2,$.edges().forEach(Z=>{let X=$.edge(Z);X.minlen*=2,X.labelpos.toLowerCase()!=="c"&&(U.rankdir==="TB"||U.rankdir==="BT"?X.width+=X.labeloffset:X.height+=X.labeloffset)})}function I($){$.edges().forEach(U=>{let Z=$.edge(U);if(Z.width&&Z.height){let X=$.node(U.v),J={rank:($.node(U.w).rank-X.rank)/2+X.rank,e:U};f.addDummyNode($,"edge-proxy",J,"_ep")}})}function R($){let U=0;$.nodes().forEach(Z=>{let X=$.node(Z);X.borderTop&&(X.minRank=$.node(X.borderTop).rank,X.maxRank=$.node(X.borderBottom).rank,U=Math.max(U,X.maxRank))}),$.graph().maxRank=U}function P($){$.nodes().forEach(U=>{let Z=$.node(U);Z.dummy==="edge-proxy"&&($.edge(Z.e).labelRank=Z.rank,$.removeNode(U))})}function L($){let U=Number.POSITIVE_INFINITY,Z=0,X=Number.POSITIVE_INFINITY,te=0,J=$.graph(),ee=J.marginx||0,ae=J.marginy||0;function ce(Y){let ne=Y.x,ue=Y.y,pe=Y.width,le=Y.height;U=Math.min(U,ne-pe/2),Z=Math.max(Z,ne+pe/2),X=Math.min(X,ue-le/2),te=Math.max(te,ue+le/2)}$.nodes().forEach(Y=>ce($.node(Y))),$.edges().forEach(Y=>{let ne=$.edge(Y);Object.hasOwn(ne,"x")&&ce(ne)}),U-=ee,X-=ae,$.nodes().forEach(Y=>{let ne=$.node(Y);ne.x-=U,ne.y-=X}),$.edges().forEach(Y=>{let ne=$.edge(Y);ne.points.forEach(ue=>{ue.x-=U,ue.y-=X}),Object.hasOwn(ne,"x")&&(ne.x-=U),Object.hasOwn(ne,"y")&&(ne.y-=X)}),J.width=Z-U+ee,J.height=te-X+ae}function M($){$.edges().forEach(U=>{let Z=$.edge(U),X=$.node(U.v),te=$.node(U.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 q($){$.edges().forEach(U=>{let Z=$.edge(U);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 H($){$.edges().forEach(U=>{let Z=$.edge(U);Z.reversed&&Z.points.reverse()})}function F($){$.nodes().forEach(U=>{if($.children(U).length){let Z=$.node(U),X=$.node(Z.borderTop),te=$.node(Z.borderBottom),J=$.node(Z.borderLeft[Z.borderLeft.length-1]),ee=$.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}}),$.nodes().forEach(U=>{$.node(U).dummy==="border"&&$.removeNode(U)})}function z($){$.edges().forEach(U=>{if(U.v===U.w){var Z=$.node(U.v);Z.selfEdges||(Z.selfEdges=[]),Z.selfEdges.push({e:U,label:$.edge(U)}),$.removeEdge(U)}})}function B($){var U=f.buildLayerMatrix($);U.forEach(Z=>{var X=0;Z.forEach((te,J)=>{var ee=$.node(te);ee.order=J+X,(ee.selfEdges||[]).forEach(ae=>{f.addDummyNode($,"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 D($){$.nodes().forEach(U=>{var Z=$.node(U);if(Z.dummy==="selfedge"){var X=$.node(Z.e.v),te=X.x+X.width/2,J=X.y,ee=Z.x-te,ae=X.height/2;$.setEdge(Z.e,Z.label),$.removeNode(U),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 Q($,U){return f.mapValues(f.pick($,U),Number)}function V($){var U={};return $&&Object.entries($).forEach(([Z,X])=>{typeof Z=="string"&&(Z=Z.toLowerCase()),U[Z]=X}),U}return zJ}var BJ,g9e;function _7n(){if(g9e)return BJ;g9e=1;let e=Nl(),t=Tg().Graph;BJ={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 BJ}var UJ,v9e;function C7n(){return v9e||(v9e=1,UJ="1.1.8"),UJ}var qJ,y9e;function E7n(){return y9e||(y9e=1,qJ={graphlib:Tg(),layout:O7n(),debug:_7n(),util:{time:Nl().time,notime:Nl().notime},version:C7n()}),qJ}var j7n=E7n();const b9e=Tc(j7n);function Ml(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=Ml(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var T7n={value:()=>{}};function TV(){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 KF(n)}function KF(e){this._=e}function N7n(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}})}KF.prototype=TV.prototype={constructor:KF,on:function(e,t){var n=this._,r=N7n(e+"",n),s,a=-1,i=r.length;if(arguments.length<2){for(;++a<i;)if((s=(e=r[a]).type)&&(s=I7n(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]=x9e(n[s],e.name,t);else if(t==null)for(s in n)n[s]=x9e(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 KF(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 I7n(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function x9e(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=T7n,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var khe="http://www.w3.org/1999/xhtml";const w9e={svg:"http://www.w3.org/2000/svg",xhtml:khe,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function NV(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),w9e.hasOwnProperty(t)?{space:w9e[t],local:e}:e}function A7n(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===khe&&t.documentElement.namespaceURI===khe?t.createElement(e):t.createElementNS(n,e)}}function R7n(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Pxt(e){var t=NV(e);return(t.local?R7n:A7n)(t)}function P7n(){}function u1e(e){return e==null?P7n:function(){return this.querySelector(e)}}function $7n(e){typeof e!="function"&&(e=u1e(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 qp(r,this._parents)}function M7n(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function D7n(){return[]}function $xt(e){return e==null?D7n:function(){return this.querySelectorAll(e)}}function L7n(e){return function(){return M7n(e.apply(this,arguments))}}function F7n(e){typeof e=="function"?e=L7n(e):e=$xt(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 qp(r,s)}function Mxt(e){return function(){return this.matches(e)}}function Dxt(e){return function(t){return t.matches(e)}}var z7n=Array.prototype.find;function B7n(e){return function(){return z7n.call(this.children,e)}}function U7n(){return this.firstElementChild}function q7n(e){return this.select(e==null?U7n:B7n(typeof e=="function"?e:Dxt(e)))}var V7n=Array.prototype.filter;function H7n(){return Array.from(this.children)}function W7n(e){return function(){return V7n.call(this.children,e)}}function Z7n(e){return this.selectAll(e==null?H7n:W7n(typeof e=="function"?e:Dxt(e)))}function G7n(e){typeof e!="function"&&(e=Mxt(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 qp(r,this._parents)}function Lxt(e){return new Array(e.length)}function Q7n(){return new qp(this._enter||this._groups.map(Lxt),this._parents)}function N7(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}N7.prototype={constructor:N7,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 Y7n(e){return function(){return e}}function X7n(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 N7(e,a[i]);for(;i<c;++i)(l=t[i])&&(s[i]=l)}function K7n(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 N7(e,a[l]);for(l=0;l<d;++l)(c=t[l])&&u.get(p[l])===c&&(s[l]=c)}function J7n(e){return e.__data__}function eBn(e,t){if(!arguments.length)return Array.from(this,J7n);var n=t?K7n:X7n,r=this._parents,s=this._groups;typeof e!="function"&&(e=Y7n(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=tBn(e.call(d,d&&d.__data__,u,r)),m=h.length,v=l[u]=new Array(m),y=i[u]=new Array(m),b=c[u]=new Array(p);n(d,f,v,y,b,h,t);for(var S=0,w=0,k,_;S<m;++S)if(k=v[S]){for(S>=w&&(w=S+1);!(_=y[w])&&++w<m;);k._next=_||null}}return i=new qp(i,r),i._enter=l,i._exit=c,i}function tBn(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function nBn(){return new qp(this._exit||this._groups.map(Lxt),this._parents)}function rBn(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 sBn(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 qp(l,this._parents)}function aBn(){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 iBn(e){e||(e=oBn);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 qp(s,this._parents).order()}function oBn(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function lBn(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function cBn(){return Array.from(this)}function uBn(){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 dBn(){let e=0;for(const t of this)++e;return e}function fBn(){return!this.node()}function pBn(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 hBn(e){return function(){this.removeAttribute(e)}}function mBn(e){return function(){this.removeAttributeNS(e.space,e.local)}}function gBn(e,t){return function(){this.setAttribute(e,t)}}function vBn(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function yBn(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function bBn(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 xBn(e,t){var n=NV(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?mBn:hBn:typeof t=="function"?n.local?bBn:yBn:n.local?vBn:gBn)(n,t))}function Fxt(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function wBn(e){return function(){this.style.removeProperty(e)}}function SBn(e,t,n){return function(){this.style.setProperty(e,t,n)}}function kBn(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function OBn(e,t,n){return arguments.length>1?this.each((t==null?wBn:typeof t=="function"?kBn:SBn)(e,t,n??"")):wT(this.node(),e)}function wT(e,t){return e.style.getPropertyValue(t)||Fxt(e).getComputedStyle(e,null).getPropertyValue(t)}function _Bn(e){return function(){delete this[e]}}function CBn(e,t){return function(){this[e]=t}}function EBn(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function jBn(e,t){return arguments.length>1?this.each((t==null?_Bn:typeof t=="function"?EBn:CBn)(e,t)):this.node()[e]}function zxt(e){return e.trim().split(/^|\s+/)}function d1e(e){return e.classList||new Bxt(e)}function Bxt(e){this._node=e,this._names=zxt(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 Uxt(e,t){for(var n=d1e(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function qxt(e,t){for(var n=d1e(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function TBn(e){return function(){Uxt(this,e)}}function NBn(e){return function(){qxt(this,e)}}function IBn(e,t){return function(){(t.apply(this,arguments)?Uxt:qxt)(this,e)}}function ABn(e,t){var n=zxt(e+"");if(arguments.length<2){for(var r=d1e(this.node()),s=-1,a=n.length;++s<a;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?IBn:t?TBn:NBn)(n,t))}function RBn(){this.textContent=""}function PBn(e){return function(){this.textContent=e}}function $Bn(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function MBn(e){return arguments.length?this.each(e==null?RBn:(typeof e=="function"?$Bn:PBn)(e)):this.node().textContent}function DBn(){this.innerHTML=""}function LBn(e){return function(){this.innerHTML=e}}function FBn(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function zBn(e){return arguments.length?this.each(e==null?DBn:(typeof e=="function"?FBn:LBn)(e)):this.node().innerHTML}function BBn(){this.nextSibling&&this.parentNode.appendChild(this)}function UBn(){return this.each(BBn)}function qBn(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function VBn(){return this.each(qBn)}function HBn(e){var t=typeof e=="function"?e:Pxt(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function WBn(){return null}function ZBn(e,t){var n=typeof e=="function"?e:Pxt(e),r=t==null?WBn:typeof t=="function"?t:u1e(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function GBn(){var e=this.parentNode;e&&e.removeChild(this)}function QBn(){return this.each(GBn)}function YBn(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function XBn(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function KBn(e){return this.select(e?XBn:YBn)}function JBn(e){return arguments.length?this.property("__data__",e):this.node().__data__}function eUn(e){return function(t){e.call(this,t,this.__data__)}}function tUn(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 nUn(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 rUn(e,t,n){return function(){var r=this.__on,s,a=eUn(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 sUn(e,t,n){var r=tUn(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?rUn:nUn,s=0;s<a;++s)this.each(l(r[s],t,n));return this}function Vxt(e,t,n){var r=Fxt(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 aUn(e,t){return function(){return Vxt(this,e,t)}}function iUn(e,t){return function(){return Vxt(this,e,t.apply(this,arguments))}}function oUn(e,t){return this.each((typeof t=="function"?iUn:aUn)(e,t))}function*lUn(){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 Hxt=[null];function qp(e,t){this._groups=e,this._parents=t}function p3(){return new qp([[document.documentElement]],Hxt)}function cUn(){return this}qp.prototype=p3.prototype={constructor:qp,select:$7n,selectAll:F7n,selectChild:q7n,selectChildren:Z7n,filter:G7n,data:eBn,enter:Q7n,exit:nBn,join:rBn,merge:sBn,selection:cUn,order:aBn,sort:iBn,call:lBn,nodes:cBn,node:uBn,size:dBn,empty:fBn,each:pBn,attr:xBn,style:OBn,property:jBn,classed:ABn,text:MBn,html:zBn,raise:UBn,lower:VBn,append:HBn,insert:ZBn,remove:QBn,clone:KBn,datum:JBn,on:sUn,dispatch:oUn,[Symbol.iterator]:lUn};function gp(e){return typeof e=="string"?new qp([[document.querySelector(e)]],[document.documentElement]):new qp([[e]],Hxt)}function uUn(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Jm(e,t){if(e=uUn(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 dUn={passive:!1},eM={capture:!0,passive:!1};function VJ(e){e.stopImmediatePropagation()}function _j(e){e.preventDefault(),e.stopImmediatePropagation()}function Wxt(e){var t=e.document.documentElement,n=gp(e).on("dragstart.drag",_j,eM);"onselectstart"in t?n.on("selectstart.drag",_j,eM):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Zxt(e,t){var n=e.document.documentElement,r=gp(e).on("dragstart.drag",null);t&&(r.on("click.drag",_j,eM),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 O6=e=>()=>e;function Ohe(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}})}Ohe.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function fUn(e){return!e.ctrlKey&&!e.button}function pUn(){return this.parentNode}function hUn(e,t){return t??{x:e.x,y:e.y}}function mUn(){return navigator.maxTouchPoints||"ontouchstart"in this}function Gxt(){var e=fUn,t=pUn,n=hUn,r=mUn,s={},a=TV("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,dUn).on("touchend.drag touchcancel.drag",S).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=w(this,t.call(this,k,_),k,_,"mouse");C&&(gp(k.view).on("mousemove.drag",m,eM).on("mouseup.drag",v,eM),Wxt(k.view),VJ(k),u=!1,l=k.clientX,c=k.clientY,C("start",k))}}function m(k){if(_j(k),!u){var _=k.clientX-l,C=k.clientY-c;u=_*_+C*C>f}s.mouse("drag",k)}function v(k){gp(k.view).on("mousemove.drag mouseup.drag",null),Zxt(k.view,u),_j(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=w(this,E,k,_,C[N].identifier,C[N]))&&(VJ(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])&&(_j(k),j("drag",k,_[E]))}function S(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])&&(VJ(k),j("end",k,_[E]))}function w(k,_,C,E,j,N){var I=a.copy(),R=Jm(N||C,_),P,L,M;if((M=n.call(k,new Ohe("beforestart",{sourceEvent:C,target:p,identifier:j,active:i,x:R[0],y:R[1],dx:0,dy:0,dispatch:I}),E))!=null)return P=M.x-R[0]||0,L=M.y-R[1]||0,function q(H,F,z){var B=R,D;switch(H){case"start":s[j]=q,D=i++;break;case"end":delete s[j],--i;case"drag":R=Jm(z||F,_),D=i;break}I.call(H,k,new Ohe(H,{sourceEvent:F,subject:M,target:p,identifier:j,active:D,x:R[0]+P,y:R[1]+L,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:O6(!!k),p):e},p.container=function(k){return arguments.length?(t=typeof k=="function"?k:O6(k),p):t},p.subject=function(k){return arguments.length?(n=typeof k=="function"?k:O6(k),p):n},p.touchable=function(k){return arguments.length?(r=typeof k=="function"?k:O6(!!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 f1e(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Qxt(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function h3(){}var tM=.7,I7=1/tM,Cj="\\s*([+-]?\\d+)\\s*",nM="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Jv="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",gUn=/^#([0-9a-f]{3,8})$/,vUn=new RegExp(`^rgb\\(${Cj},${Cj},${Cj}\\)$`),yUn=new RegExp(`^rgb\\(${Jv},${Jv},${Jv}\\)$`),bUn=new RegExp(`^rgba\\(${Cj},${Cj},${Cj},${nM}\\)$`),xUn=new RegExp(`^rgba\\(${Jv},${Jv},${Jv},${nM}\\)$`),wUn=new RegExp(`^hsl\\(${nM},${Jv},${Jv}\\)$`),SUn=new RegExp(`^hsla\\(${nM},${Jv},${Jv},${nM}\\)$`),S9e={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};f1e(h3,$O,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:k9e,formatHex:k9e,formatHex8:kUn,formatHsl:OUn,formatRgb:O9e,toString:O9e});function k9e(){return this.rgb().formatHex()}function kUn(){return this.rgb().formatHex8()}function OUn(){return Yxt(this).formatHsl()}function O9e(){return this.rgb().formatRgb()}function $O(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=gUn.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?_9e(t):n===3?new nf(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?_6(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?_6(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=vUn.exec(e))?new nf(t[1],t[2],t[3],1):(t=yUn.exec(e))?new nf(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=bUn.exec(e))?_6(t[1],t[2],t[3],t[4]):(t=xUn.exec(e))?_6(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=wUn.exec(e))?j9e(t[1],t[2]/100,t[3]/100,1):(t=SUn.exec(e))?j9e(t[1],t[2]/100,t[3]/100,t[4]):S9e.hasOwnProperty(e)?_9e(S9e[e]):e==="transparent"?new nf(NaN,NaN,NaN,0):null}function _9e(e){return new nf(e>>16&255,e>>8&255,e&255,1)}function _6(e,t,n,r){return r<=0&&(e=t=n=NaN),new nf(e,t,n,r)}function _Un(e){return e instanceof h3||(e=$O(e)),e?(e=e.rgb(),new nf(e.r,e.g,e.b,e.opacity)):new nf}function _he(e,t,n,r){return arguments.length===1?_Un(e):new nf(e,t,n,r??1)}function nf(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}f1e(nf,_he,Qxt(h3,{brighter(e){return e=e==null?I7:Math.pow(I7,e),new nf(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?tM:Math.pow(tM,e),new nf(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new nf(Wk(this.r),Wk(this.g),Wk(this.b),A7(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:C9e,formatHex:C9e,formatHex8:CUn,formatRgb:E9e,toString:E9e}));function C9e(){return`#${Nk(this.r)}${Nk(this.g)}${Nk(this.b)}`}function CUn(){return`#${Nk(this.r)}${Nk(this.g)}${Nk(this.b)}${Nk((isNaN(this.opacity)?1:this.opacity)*255)}`}function E9e(){const e=A7(this.opacity);return`${e===1?"rgb(":"rgba("}${Wk(this.r)}, ${Wk(this.g)}, ${Wk(this.b)}${e===1?")":`, ${e})`}`}function A7(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Wk(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Nk(e){return e=Wk(e),(e<16?"0":"")+e.toString(16)}function j9e(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ag(e,t,n,r)}function Yxt(e){if(e instanceof ag)return new ag(e.h,e.s,e.l,e.opacity);if(e instanceof h3||(e=$O(e)),!e)return new ag;if(e instanceof ag)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 ag(i,l,c,e.opacity)}function EUn(e,t,n,r){return arguments.length===1?Yxt(e):new ag(e,t,n,r??1)}function ag(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}f1e(ag,EUn,Qxt(h3,{brighter(e){return e=e==null?I7:Math.pow(I7,e),new ag(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?tM:Math.pow(tM,e),new ag(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 nf(HJ(e>=240?e-240:e+120,s,r),HJ(e,s,r),HJ(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new ag(T9e(this.h),C6(this.s),C6(this.l),A7(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=A7(this.opacity);return`${e===1?"hsl(":"hsla("}${T9e(this.h)}, ${C6(this.s)*100}%, ${C6(this.l)*100}%${e===1?")":`, ${e})`}`}}));function T9e(e){return e=(e||0)%360,e<0?e+360:e}function C6(e){return Math.max(0,Math.min(1,e||0))}function HJ(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 p1e=e=>()=>e;function jUn(e,t){return function(n){return e+n*t}}function TUn(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 NUn(e){return(e=+e)==1?Xxt:function(t,n){return n-t?TUn(t,n,e):p1e(isNaN(t)?n:t)}}function Xxt(e,t){var n=t-e;return n?jUn(e,n):p1e(isNaN(e)?t:e)}const R7=(function e(t){var n=NUn(t);function r(s,a){var i=n((s=_he(s)).r,(a=_he(a)).r),l=n(s.g,a.g),c=n(s.b,a.b),u=Xxt(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 IUn(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 AUn(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function RUn(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]=ix(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 PUn(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function tg(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function $Un(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]=ix(e[s],t[s]):r[s]=t[s];return function(a){for(s in n)r[s]=n[s](a);return r}}var Che=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,WJ=new RegExp(Che.source,"g");function MUn(e){return function(){return e}}function DUn(e){return function(t){return e(t)+""}}function Kxt(e,t){var n=Che.lastIndex=WJ.lastIndex=0,r,s,a,i=-1,l=[],c=[];for(e=e+"",t=t+"";(r=Che.exec(e))&&(s=WJ.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:tg(r,s)})),n=WJ.lastIndex;return n<t.length&&(a=t.slice(n),l[i]?l[i]+=a:l[++i]=a),l.length<2?c[0]?DUn(c[0].x):MUn(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 ix(e,t){var n=typeof t,r;return t==null||n==="boolean"?p1e(t):(n==="number"?tg:n==="string"?(r=$O(t))?(t=r,R7):Kxt:t instanceof $O?R7:t instanceof Date?PUn:AUn(t)?IUn:Array.isArray(t)?RUn:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?$Un:tg)(e,t)}function h1e(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var N9e=180/Math.PI,Ehe={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Jxt(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)*N9e,skewX:Math.atan(c)*N9e,scaleX:i,scaleY:l}}var E6;function LUn(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Ehe:Jxt(t.a,t.b,t.c,t.d,t.e,t.f)}function FUn(e){return e==null||(E6||(E6=document.createElementNS("http://www.w3.org/2000/svg","g")),E6.setAttribute("transform",e),!(e=E6.transform.baseVal.consolidate()))?Ehe:(e=e.matrix,Jxt(e.a,e.b,e.c,e.d,e.e,e.f))}function e0t(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 v=h.push("translate(",null,t,null,n);m.push({i:v-4,x:tg(u,f)},{i:v-2,x:tg(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:tg(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:tg(u,d)}):d&&f.push(s(f)+"skewX("+d+r)}function c(u,d,f,p,h,m){if(u!==f||d!==p){var v=h.push(s(h)+"scale(",null,",",null,")");m.push({i:v-4,x:tg(u,f)},{i:v-2,x:tg(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,v=p.length,y;++m<v;)f[(y=p[m]).i]=y.x(h);return f.join("")}}}var zUn=e0t(LUn,"px, ","px)","deg)"),BUn=e0t(FUn,", ",")",")"),UUn=1e-12;function I9e(e){return((e=Math.exp(e))+1/e)/2}function qUn(e){return((e=Math.exp(e))-1/e)/2}function VUn(e){return((e=Math.exp(2*e))-1)/(e+1)}const JF=(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,v=h*h+m*m,y,b;if(v<UUn)b=Math.log(p/u)/t,y=function(E){return[l+E*h,c+E*m,u*Math.exp(t*E*b)]};else{var S=Math.sqrt(v),w=(p*p-u*u+r*v)/(2*u*n*S),k=(p*p-u*u-r*v)/(2*p*n*S),_=Math.log(Math.sqrt(w*w+1)-w),C=Math.log(Math.sqrt(k*k+1)-k);b=(C-_)/t,y=function(E){var j=E*b,N=I9e(_),I=u/(n*S)*(N*VUn(t*j+_)-qUn(_));return[l+I*h,c+I*m,u*N/I9e(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 HUn(e,t){t===void 0&&(t=e,e=ix);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 ST=0,u2=0,YA=0,t0t=1e3,P7,d2,$7=0,MO=0,IV=0,rM=typeof performance=="object"&&performance.now?performance:Date,n0t=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function m1e(){return MO||(n0t(WUn),MO=rM.now()+IV)}function WUn(){MO=0}function M7(){this._call=this._time=this._next=null}M7.prototype=r0t.prototype={constructor:M7,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?m1e():+n)+(t==null?0:+t),!this._next&&d2!==this&&(d2?d2._next=this:P7=this,d2=this),this._call=e,this._time=n,jhe()},stop:function(){this._call&&(this._call=null,this._time=1/0,jhe())}};function r0t(e,t,n){var r=new M7;return r.restart(e,t,n),r}function ZUn(){m1e(),++ST;for(var e=P7,t;e;)(t=MO-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ST}function A9e(){MO=($7=rM.now())+IV,ST=u2=0;try{ZUn()}finally{ST=0,QUn(),MO=0}}function GUn(){var e=rM.now(),t=e-$7;t>t0t&&(IV-=t,$7=e)}function QUn(){for(var e,t=P7,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:P7=n);d2=e,jhe(r)}function jhe(e){if(!ST){u2&&(u2=clearTimeout(u2));var t=e-MO;t>24?(e<1/0&&(u2=setTimeout(A9e,e-rM.now()-IV)),YA&&(YA=clearInterval(YA))):(YA||($7=rM.now(),YA=setInterval(GUn,t0t)),ST=1,n0t(A9e))}}function R9e(e,t,n){var r=new M7;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var YUn=TV("start","end","cancel","interrupt"),XUn=[],s0t=0,P9e=1,The=2,e8=3,$9e=4,Nhe=5,t8=6;function AV(e,t,n,r,s,a){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;KUn(e,n,{name:t,index:r,group:s,on:YUn,tween:XUn,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:s0t})}function g1e(e,t){var n=zg(e,t);if(n.state>s0t)throw new Error("too late; already scheduled");return n}function Dy(e,t){var n=zg(e,t);if(n.state>e8)throw new Error("too late; already running");return n}function zg(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function KUn(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=r0t(a,0,n.time);function a(u){n.state=P9e,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!==P9e)return c();for(d in r)if(h=r[d],h.name===n.name){if(h.state===e8)return R9e(i);h.state===$9e?(h.state=t8,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[d]):+d<t&&(h.state=t8,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[d])}if(R9e(function(){n.state===e8&&(n.state=$9e,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=The,n.on.call("start",e,e.__data__,n.index,n.group),n.state===The){for(n.state=e8,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=Nhe,1),f=-1,p=s.length;++f<p;)s[f].call(e,d);n.state===Nhe&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=t8,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function n8(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>The&&r.state<Nhe,r.state=t8,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[i]}a&&delete e.__transition}}function JUn(e){return this.each(function(){n8(this,e)})}function eqn(e,t){var n,r;return function(){var s=Dy(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 tqn(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var a=Dy(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 nqn(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=zg(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?eqn:tqn)(n,e,t))}function v1e(e,t,n){var r=e._id;return e.each(function(){var s=Dy(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return zg(s,r).value[t]}}function a0t(e,t){var n;return(typeof t=="number"?tg:t instanceof $O?R7:(n=$O(t))?(t=n,R7):Kxt)(e,t)}function rqn(e){return function(){this.removeAttribute(e)}}function sqn(e){return function(){this.removeAttributeNS(e.space,e.local)}}function aqn(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 iqn(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 oqn(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 lqn(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 cqn(e,t){var n=NV(e),r=n==="transform"?BUn:a0t;return this.attrTween(e,typeof t=="function"?(n.local?lqn:oqn)(n,r,v1e(this,"attr."+e,t)):t==null?(n.local?sqn:rqn)(n):(n.local?iqn:aqn)(n,r,t))}function uqn(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function dqn(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function fqn(e,t){var n,r;function s(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&dqn(e,a)),n}return s._value=t,s}function pqn(e,t){var n,r;function s(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&uqn(e,a)),n}return s._value=t,s}function hqn(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=NV(e);return this.tween(n,(r.local?fqn:pqn)(r,t))}function mqn(e,t){return function(){g1e(this,e).delay=+t.apply(this,arguments)}}function gqn(e,t){return t=+t,function(){g1e(this,e).delay=t}}function vqn(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?mqn:gqn)(t,e)):zg(this.node(),t).delay}function yqn(e,t){return function(){Dy(this,e).duration=+t.apply(this,arguments)}}function bqn(e,t){return t=+t,function(){Dy(this,e).duration=t}}function xqn(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?yqn:bqn)(t,e)):zg(this.node(),t).duration}function wqn(e,t){if(typeof t!="function")throw new Error;return function(){Dy(this,e).ease=t}}function Sqn(e){var t=this._id;return arguments.length?this.each(wqn(t,e)):zg(this.node(),t).ease}function kqn(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Dy(this,e).ease=n}}function Oqn(e){if(typeof e!="function")throw new Error;return this.each(kqn(this._id,e))}function _qn(e){typeof e!="function"&&(e=Mxt(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 Cx(r,this._parents,this._name,this._id)}function Cqn(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 Cx(i,this._parents,this._name,this._id)}function Eqn(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 jqn(e,t,n){var r,s,a=Eqn(t)?g1e:Dy;return function(){var i=a(this,e),l=i.on;l!==r&&(s=(r=l).copy()).on(t,n),i.on=s}}function Tqn(e,t){var n=this._id;return arguments.length<2?zg(this.node(),n).on.on(e):this.each(jqn(n,e,t))}function Nqn(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Iqn(){return this.on("end.remove",Nqn(this._id))}function Aqn(e){var t=this._name,n=this._id;typeof e!="function"&&(e=u1e(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,AV(u[p],t,n,p,u,zg(d,n)));return new Cx(a,this._parents,t,n)}function Rqn(e){var t=this._name,n=this._id;typeof e!="function"&&(e=$xt(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=zg(d,n),v=0,y=p.length;v<y;++v)(h=p[v])&&AV(h,t,n,v,p,m);a.push(p),i.push(d)}return new Cx(a,i,t,n)}var Pqn=p3.prototype.constructor;function $qn(){return new Pqn(this._groups,this._parents)}function Mqn(e,t){var n,r,s;return function(){var a=wT(this,e),i=(this.style.removeProperty(e),wT(this,e));return a===i?null:a===n&&i===r?s:s=t(n=a,r=i)}}function i0t(e){return function(){this.style.removeProperty(e)}}function Dqn(e,t,n){var r,s=n+"",a;return function(){var i=wT(this,e);return i===s?null:i===r?a:a=t(r=i,n)}}function Lqn(e,t,n){var r,s,a;return function(){var i=wT(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),wT(this,e))),i===c?null:i===r&&c===s?a:(s=c,a=t(r=i,l))}}function Fqn(e,t){var n,r,s,a="style."+t,i="end."+a,l;return function(){var c=Dy(this,e),u=c.on,d=c.value[a]==null?l||(l=i0t(t)):void 0;(u!==n||s!==d)&&(r=(n=u).copy()).on(i,s=d),c.on=r}}function zqn(e,t,n){var r=(e+="")=="transform"?zUn:a0t;return t==null?this.styleTween(e,Mqn(e,r)).on("end.style."+e,i0t(e)):typeof t=="function"?this.styleTween(e,Lqn(e,r,v1e(this,"style."+e,t))).each(Fqn(this._id,e)):this.styleTween(e,Dqn(e,r,t),n).on("end.style."+e,null)}function Bqn(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Uqn(e,t,n){var r,s;function a(){var i=t.apply(this,arguments);return i!==s&&(r=(s=i)&&Bqn(e,i,n)),r}return a._value=t,a}function qqn(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,Uqn(e,t,n??""))}function Vqn(e){return function(){this.textContent=e}}function Hqn(e){return function(){var t=e(this);this.textContent=t??""}}function Wqn(e){return this.tween("text",typeof e=="function"?Hqn(v1e(this,"text",e)):Vqn(e==null?"":e+""))}function Zqn(e){return function(t){this.textContent=e.call(this,t)}}function Gqn(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&Zqn(s)),t}return r._value=e,r}function Qqn(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,Gqn(e))}function Yqn(){for(var e=this._name,t=this._id,n=o0t(),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=zg(c,t);AV(c,e,n,u,i,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Cx(r,this._parents,e,n)}function Xqn(){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=Dy(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 Kqn=0;function Cx(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function o0t(){return++Kqn}var gb=p3.prototype;Cx.prototype={constructor:Cx,select:Aqn,selectAll:Rqn,selectChild:gb.selectChild,selectChildren:gb.selectChildren,filter:_qn,merge:Cqn,selection:$qn,transition:Yqn,call:gb.call,nodes:gb.nodes,node:gb.node,size:gb.size,empty:gb.empty,each:gb.each,on:Tqn,attr:cqn,attrTween:hqn,style:zqn,styleTween:qqn,text:Wqn,textTween:Qqn,remove:Iqn,tween:nqn,delay:vqn,duration:xqn,ease:Sqn,easeVarying:Oqn,end:Xqn,[Symbol.iterator]:gb[Symbol.iterator]};function Jqn(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var eVn={time:null,delay:0,duration:250,ease:Jqn};function tVn(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 nVn(e){var t,n;e instanceof Cx?(t=e._id,e=e._name):(t=o0t(),(n=eVn).time=m1e(),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])&&AV(c,e,t,u,i,n||tVn(c,t));return new Cx(r,this._parents,e,t)}p3.prototype.interrupt=JUn;p3.prototype.transition=nVn;const j6=e=>()=>e;function rVn(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 Zb(e,t,n){this.k=e,this.x=t,this.y=n}Zb.prototype={constructor:Zb,scale:function(e){return e===1?this:new Zb(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Zb(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 RV=new Zb(1,0,0);l0t.prototype=Zb.prototype;function l0t(e){for(;!e.__zoom;)if(!(e=e.parentNode))return RV;return e.__zoom}function ZJ(e){e.stopImmediatePropagation()}function XA(e){e.preventDefault(),e.stopImmediatePropagation()}function sVn(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function aVn(){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 M9e(){return this.__zoom||RV}function iVn(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function oVn(){return navigator.maxTouchPoints||"ontouchstart"in this}function lVn(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 c0t(){var e=sVn,t=aVn,n=lVn,r=iVn,s=oVn,a=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,c=JF,u=TV("start","zoom","end"),d,f,p,h=500,m=150,v=0,y=10;function b(M){M.property("__zoom",M9e).on("wheel.zoom",j,{passive:!1}).on("mousedown.zoom",N).on("dblclick.zoom",I).filter(s).on("touchstart.zoom",R).on("touchmove.zoom",P).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(M,q,H,F){var z=M.selection?M.selection():M;z.property("__zoom",M9e),M!==z?_(M,q,H,F):z.interrupt().each(function(){C(this,arguments).event(F).start().zoom(null,typeof q=="function"?q.apply(this,arguments):q).end()})},b.scaleBy=function(M,q,H,F){b.scaleTo(M,function(){var z=this.__zoom.k,B=typeof q=="function"?q.apply(this,arguments):q;return z*B},H,F)},b.scaleTo=function(M,q,H,F){b.transform(M,function(){var z=t.apply(this,arguments),B=this.__zoom,D=H==null?k(z):typeof H=="function"?H.apply(this,arguments):H,Q=B.invert(D),V=typeof q=="function"?q.apply(this,arguments):q;return n(w(S(B,V),D,Q),z,i)},H,F)},b.translateBy=function(M,q,H,F){b.transform(M,function(){return n(this.__zoom.translate(typeof q=="function"?q.apply(this,arguments):q,typeof H=="function"?H.apply(this,arguments):H),t.apply(this,arguments),i)},null,F)},b.translateTo=function(M,q,H,F,z){b.transform(M,function(){var B=t.apply(this,arguments),D=this.__zoom,Q=F==null?k(B):typeof F=="function"?F.apply(this,arguments):F;return n(RV.translate(Q[0],Q[1]).scale(D.k).translate(typeof q=="function"?-q.apply(this,arguments):-q,typeof H=="function"?-H.apply(this,arguments):-H),B,i)},F,z)};function S(M,q){return q=Math.max(a[0],Math.min(a[1],q)),q===M.k?M:new Zb(q,M.x,M.y)}function w(M,q,H){var F=q[0]-H[0]*M.k,z=q[1]-H[1]*M.k;return F===M.x&&z===M.y?M:new Zb(M.k,F,z)}function k(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function _(M,q,H,F){M.on("start.zoom",function(){C(this,arguments).event(F).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(F).end()}).tween("zoom",function(){var z=this,B=arguments,D=C(z,B).event(F),Q=t.apply(z,B),V=H==null?k(Q):typeof H=="function"?H.apply(z,B):H,$=Math.max(Q[1][0]-Q[0][0],Q[1][1]-Q[0][1]),U=z.__zoom,Z=typeof q=="function"?q.apply(z,B):q,X=c(U.invert(V).concat($/U.k),Z.invert(V).concat($/Z.k));return function(te){if(te===1)te=Z;else{var J=X(te),ee=$/J[2];te=new Zb(ee,V[0]-J[0]*ee,V[1]-J[1]*ee)}D.zoom(null,te)}})}function C(M,q,H){return!H&&M.__zooming||new E(M,q)}function E(M,q){this.that=M,this.args=q,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,q),this.taps=0}E.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,q){return this.mouse&&M!=="mouse"&&(this.mouse[1]=q.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=q.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=q.invert(this.touch1[0])),this.that.__zoom=q,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var q=gp(this.that).datum();u.call(M,this.that,new rVn(M,{sourceEvent:this.sourceEvent,target:b,transform:this.that.__zoom,dispatch:u}),q)}};function j(M,...q){if(!e.apply(this,arguments))return;var H=C(this,q).event(M),F=this.__zoom,z=Math.max(a[0],Math.min(a[1],F.k*Math.pow(2,r.apply(this,arguments)))),B=Jm(M);if(H.wheel)(H.mouse[0][0]!==B[0]||H.mouse[0][1]!==B[1])&&(H.mouse[1]=F.invert(H.mouse[0]=B)),clearTimeout(H.wheel);else{if(F.k===z)return;H.mouse=[B,F.invert(B)],n8(this),H.start()}XA(M),H.wheel=setTimeout(D,m),H.zoom("mouse",n(w(S(F,z),H.mouse[0],H.mouse[1]),H.extent,i));function D(){H.wheel=null,H.end()}}function N(M,...q){if(p||!e.apply(this,arguments))return;var H=M.currentTarget,F=C(this,q,!0).event(M),z=gp(M.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",$,!0),B=Jm(M,H),D=M.clientX,Q=M.clientY;Wxt(M.view),ZJ(M),F.mouse=[B,this.__zoom.invert(B)],n8(this),F.start();function V(U){if(XA(U),!F.moved){var Z=U.clientX-D,X=U.clientY-Q;F.moved=Z*Z+X*X>v}F.event(U).zoom("mouse",n(w(F.that.__zoom,F.mouse[0]=Jm(U,H),F.mouse[1]),F.extent,i))}function $(U){z.on("mousemove.zoom mouseup.zoom",null),Zxt(U.view,F.moved),XA(U),F.event(U).end()}}function I(M,...q){if(e.apply(this,arguments)){var H=this.__zoom,F=Jm(M.changedTouches?M.changedTouches[0]:M,this),z=H.invert(F),B=H.k*(M.shiftKey?.5:2),D=n(w(S(H,B),F,z),t.apply(this,q),i);XA(M),l>0?gp(this).transition().duration(l).call(_,D,F,M):gp(this).call(b.transform,D,F,M)}}function R(M,...q){if(e.apply(this,arguments)){var H=M.touches,F=H.length,z=C(this,q,M.changedTouches.length===F).event(M),B,D,Q,V;for(ZJ(M),D=0;D<F;++D)Q=H[D],V=Jm(Q,this),V=[V,this.__zoom.invert(V),Q.identifier],z.touch0?!z.touch1&&z.touch0[2]!==V[2]&&(z.touch1=V,z.taps=0):(z.touch0=V,B=!0,z.taps=1+!!d);d&&(d=clearTimeout(d)),B&&(z.taps<2&&(f=V[0],d=setTimeout(function(){d=null},h)),n8(this),z.start())}}function P(M,...q){if(this.__zooming){var H=C(this,q).event(M),F=M.changedTouches,z=F.length,B,D,Q,V;for(XA(M),B=0;B<z;++B)D=F[B],Q=Jm(D,this),H.touch0&&H.touch0[2]===D.identifier?H.touch0[0]=Q:H.touch1&&H.touch1[2]===D.identifier&&(H.touch1[0]=Q);if(D=H.that.__zoom,H.touch1){var $=H.touch0[0],U=H.touch0[1],Z=H.touch1[0],X=H.touch1[1],te=(te=Z[0]-$[0])*te+(te=Z[1]-$[1])*te,J=(J=X[0]-U[0])*J+(J=X[1]-U[1])*J;D=S(D,Math.sqrt(te/J)),Q=[($[0]+Z[0])/2,($[1]+Z[1])/2],V=[(U[0]+X[0])/2,(U[1]+X[1])/2]}else if(H.touch0)Q=H.touch0[0],V=H.touch0[1];else return;H.zoom("touch",n(w(D,Q,V),H.extent,i))}}function L(M,...q){if(this.__zooming){var H=C(this,q).event(M),F=M.changedTouches,z=F.length,B,D;for(ZJ(M),p&&clearTimeout(p),p=setTimeout(function(){p=null},h),B=0;B<z;++B)D=F[B],H.touch0&&H.touch0[2]===D.identifier?delete H.touch0:H.touch1&&H.touch1[2]===D.identifier&&delete H.touch1;if(H.touch1&&!H.touch0&&(H.touch0=H.touch1,delete H.touch1),H.touch0)H.touch0[1]=this.__zoom.invert(H.touch0[0]);else if(H.end(),H.taps===2&&(D=Jm(D,this),Math.hypot(f[0]-D[0],f[1]-D[1])<y)){var Q=gp(this).on("dblclick.zoom");Q&&Q.apply(this,arguments)}}}return b.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:j6(+M),b):r},b.filter=function(M){return arguments.length?(e=typeof M=="function"?M:j6(!!M),b):e},b.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:j6(!!M),b):s},b.extent=function(M){return arguments.length?(t=typeof M=="function"?M:j6([[+M[0][0],+M[0][1]],[+M[1][0],+M[1][1]]]),b):t},b.scaleExtent=function(M){return arguments.length?(a[0]=+M[0],a[1]=+M[1],b):[a[0],a[1]]},b.translateExtent=function(M){return arguments.length?(i[0][0]=+M[0][0],i[1][0]=+M[1][0],i[0][1]=+M[0][1],i[1][1]=+M[1][1],b):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},b.constrain=function(M){return arguments.length?(n=M,b):n},b.duration=function(M){return arguments.length?(l=+M,b):l},b.interpolate=function(M){return arguments.length?(c=M,b):c},b.on=function(){var M=u.on.apply(u,arguments);return M===u?b:M},b.clickDistance=function(M){return arguments.length?(v=(M=+M)*M,b):Math.sqrt(v)},b.tapDistance=function(M){return arguments.length?(y=+M,b):y},b}const hy={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."},sM=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],u0t=["Enter"," ","Escape"],d0t={"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 kT;(function(e){e.Strict="strict",e.Loose="loose"})(kT||(kT={}));var Zk;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Zk||(Zk={}));var aM;(function(e){e.Partial="partial",e.Full="full"})(aM||(aM={}));const f0t={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var iw;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(iw||(iw={}));var iM;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(iM||(iM={}));var nr;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(nr||(nr={}));const D9e={[nr.Left]:nr.Right,[nr.Right]:nr.Left,[nr.Top]:nr.Bottom,[nr.Bottom]:nr.Top};function p0t(e){return e===null?null:e?"valid":"invalid"}const h0t=e=>"id"in e&&"source"in e&&"target"in e,cVn=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),y1e=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),m3=(e,t=[0,0])=>{const{width:n,height:r}=Gx(e),s=e.origin??t,a=n*s[0],i=r*s[1];return{x:e.position.x-a,y:e.position.y-i}},uVn=(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):y1e(s)?s:t.nodeLookup.get(s.id));const l=i?D7(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return PV(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return $V(n)},g3=(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=PV(n,D7(s)),r=!0)}),r?$V(n):{x:0,y:0,width:0,height:0}},b1e=(e,t,[n,r,s]=[0,0,1],a=!1,i=!1)=>{const l={...y3(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,v=oM(l,_T(u)),y=(h??0)*(m??0),b=a&&v>0;(!u.internals.handleBounds||b||v>=y||u.dragging)&&c.push(u)}return c},dVn=(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 fVn(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 pVn({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:a},i){if(e.size===0)return Promise.resolve(!0);const l=fVn(e,i),c=g3(l),u=x1e(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 m0t({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",hy.error005());else{const h=l.measured.width,m=l.measured.height;h&&m&&(f=[[c,u],[c+h,u+m]])}else l&&CT(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=CT(f)?DO(t,f,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&a?.("015",hy.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 hVn({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(v=>v.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=dVn(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 OT=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),DO=(e={x:0,y:0},t,n)=>({x:OT(e.x,t[0][0],t[1][0]-(n?.width??0)),y:OT(e.y,t[0][1],t[1][1]-(n?.height??0))});function g0t(e,t,n){const{width:r,height:s}=Gx(n),{x:a,y:i}=n.internals.positionAbsolute;return DO(e,[[a,i],[a+r,i+s]],t)}const L9e=(e,t,n)=>e<t?OT(Math.abs(e-t),1,t)/t:e>n?-OT(Math.abs(e-n),1,t)/t:0,v0t=(e,t,n=15,r=40)=>{const s=L9e(e.x,r,t.width-r)*n,a=L9e(e.y,r,t.height-r)*n;return[s,a]},PV=(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)}),Ihe=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),$V=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),_T=(e,t=[0,0])=>{const{x:n,y:r}=y1e(e)?e.internals.positionAbsolute:m3(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}},D7=(e,t=[0,0])=>{const{x:n,y:r}=y1e(e)?e.internals.positionAbsolute:m3(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)}},y0t=(e,t)=>$V(PV(Ihe(e),Ihe(t))),oM=(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)},F9e=e=>dg(e.width)&&dg(e.height)&&dg(e.x)&&dg(e.y),dg=e=>!isNaN(e)&&isFinite(e),mVn=(e,t)=>{},v3=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),y3=({x:e,y:t},[n,r,s],a=!1,i=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return a?v3(l,i):l},L7=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function UC(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 gVn(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=UC(e,n),s=UC(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=UC(e.top??e.y??0,n),s=UC(e.bottom??e.y??0,n),a=UC(e.left??e.x??0,t),i=UC(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 vVn(e,t,n,r,s,a){const{x:i,y:l}=L7(e,[t,n,r]),{x:c,y:u}=L7({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 x1e=(e,t,n,r,s,a)=>{const i=gVn(a,t,n),l=(t-i.x)/e.width,c=(n-i.y)/e.height,u=Math.min(l,c),d=OT(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,v=vVn(e,h,m,d,t,n),y={left:Math.min(v.left-i.left,0),top:Math.min(v.top-i.top,0),right:Math.min(v.right-i.right,0),bottom:Math.min(v.bottom-i.bottom,0)};return{x:h-y.left+y.right,y:m-y.top+y.bottom,zoom:d}},lM=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function CT(e){return e!=null&&e!=="parent"}function Gx(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function b0t(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function x0t(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 z9e(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function yVn(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function bVn(e){return{...d0t,...e||{}}}function V2(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:a,y:i}=fg(e),l=y3({x:a-(s?.left??0),y:i-(s?.top??0)},r),{x:c,y:u}=n?v3(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const w1e=e=>({width:e.offsetWidth,height:e.offsetHeight}),w0t=e=>e?.getRootNode?.()||window?.document,xVn=["INPUT","SELECT","TEXTAREA"];function S0t(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:xVn.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const k0t=e=>"clientX"in e,fg=(e,t)=>{const n=k0t(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)}},B9e=(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,...w1e(i)}})};function O0t({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 T6(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function U9e({pos:e,x1:t,y1:n,x2:r,y2:s,c:a}){switch(e){case nr.Left:return[t-T6(t-r,a),n];case nr.Right:return[t+T6(r-t,a),n];case nr.Top:return[t,n-T6(n-s,a)];case nr.Bottom:return[t,n+T6(s-n,a)]}}function S1e({sourceX:e,sourceY:t,sourcePosition:n=nr.Bottom,targetX:r,targetY:s,targetPosition:a=nr.Top,curvature:i=.25}){const[l,c]=U9e({pos:n,x1:e,y1:t,x2:r,y2:s,c:i}),[u,d]=U9e({pos:a,x1:r,y1:s,x2:e,y2:t,c:i}),[f,p,h,m]=O0t({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 _0t({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 wVn({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 SVn({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const a=PV(D7(e),D7(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 oM(i,$V(a))>0}const kVn=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,OVn=(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)),_Vn=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||kVn;let s;return h0t(e)?s={...e}:s={...e,id:r(e)},OVn(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function C0t({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,a,i,l]=_0t({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,a,i,l]}const q9e={[nr.Left]:{x:-1,y:0},[nr.Right]:{x:1,y:0},[nr.Top]:{x:0,y:-1},[nr.Bottom]:{x:0,y:1}},CVn=({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},V9e=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function EVn({source:e,sourcePosition:t=nr.Bottom,target:n,targetPosition:r=nr.Top,center:s,offset:a,stepPosition:i}){const l=q9e[t],c=q9e[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=CVn({source:u,sourcePosition:t,target:d}),p=f.x!==0?"x":"y",h=f[p];let m=[],v,y;const b={x:0,y:0},S={x:0,y:0},[,,w,k]=_0t({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){p==="x"?(v=s.x??u.x+(d.x-u.x)*i,y=s.y??(u.y+d.y)/2):(v=s.x??(u.x+d.x)/2,y=s.y??u.y+(d.y-u.y)*i);const j=[{x:v,y:u.y},{x:v,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 M=Math.abs(e[p]-n[p]);if(M<=a){const q=Math.min(a-1,a-M);l[p]===h?b[p]=(u[p]>e[p]?-1:1)*q:S[p]=(d[p]>n[p]?-1:1)*q}}if(t!==r){const M=p==="x"?"y":"x",q=l[p]===c[M],H=u[M]>d[M],F=u[M]<d[M];(l[p]===1&&(!q&&H||q&&F)||l[p]!==1&&(!q&&F||q&&H))&&(m=p==="x"?j:N)}const I={x:u.x+b.x,y:u.y+b.y},R={x:d.x+S.x,y:d.y+S.y},P=Math.max(Math.abs(I.x-m[0].x),Math.abs(R.x-m[0].x)),L=Math.max(Math.abs(I.y-m[0].y),Math.abs(R.y-m[0].y));P>=L?(v=(I.x+R.x)/2,y=m[0].y):(v=m[0].x,y=(I.y+R.y)/2)}const _={x:u.x+b.x,y:u.y+b.y},C={x:d.x+S.x,y:d.y+S.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],v,y,w,k]}function jVn(e,t,n,r){const s=Math.min(V9e(e,t)/2,V9e(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 Ahe({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,v]=EVn({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+=jVn(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,v]}function H9e(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function TVn(e){const{sourceNode:t,targetNode:n}=e;if(!H9e(t)||!H9e(n))return null;const r=t.internals.handleBounds||W9e(t.handles),s=n.internals.handleBounds||W9e(n.handles),a=Z9e(r?.source??[],e.sourceHandle),i=Z9e(e.connectionMode===kT.Strict?s?.target??[]:(s?.target??[]).concat(s?.source??[]),e.targetHandle);if(!a||!i)return e.onError?.("008",hy.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=LO(t,a,l),d=LO(n,i,c);return{sourceX:u.x,sourceY:u.y,targetX:d.x,targetY:d.y,sourcePosition:l,targetPosition:c}}function W9e(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 LO(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??Gx(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 Z9e(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Rhe(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function NVn(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=Rhe(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 E0t=1e3,IVn=10,k1e={nodeOrigin:[0,0],nodeExtent:sM,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},AVn={...k1e,checkEquality:!0};function O1e(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function RVn(e,t,n){const r=O1e(k1e,n);for(const s of e.values())if(s.parentId)C1e(s,e,t,r);else{const a=m3(s,r.nodeOrigin),i=CT(s.extent)?s.extent:r.nodeExtent,l=DO(a,i,Gx(s));s.internals.positionAbsolute=l}}function PVn(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 _1e(e){return e==="manual"}function Phe(e,t,n,r={}){const s=O1e(AVn,r),a={i:0},i=new Map(t),l=s?.elevateNodesOnSelect&&!_1e(s.zIndexMode)?E0t: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=m3(d,s.nodeOrigin),h=CT(d.extent)?d.extent:s.nodeExtent,m=DO(p,h,Gx(d));f={...s.defaults,...d,measured:{width:d.measured?.width,height:d.measured?.height},internals:{positionAbsolute:m,handleBounds:PVn(d,f),z:j0t(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&&C1e(f,t,n,r,a),u||=d.selected??!1}return{nodesInitialized:c,hasSelectedNodes:u}}function $Vn(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 C1e(e,t,n,r,s){const{elevateNodesOnSelect:a,nodeOrigin:i,nodeExtent:l,zIndexMode:c}=O1e(k1e,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}$Vn(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*IVn),s&&d.internals.rootParentIndex!==void 0&&(s.i=d.internals.rootParentIndex);const f=a&&!_1e(c)?E0t:0,{x:p,y:h,z:m}=MVn(e,d,i,l,f,c),{positionAbsolute:v}=e.internals,y=p!==v.x||h!==v.y;(y||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:p,y:h}:v,z:m}})}function j0t(e,t,n){const r=dg(e.zIndex)?e.zIndex:0;return _1e(n)?r:r+(e.selected?t:0)}function MVn(e,t,n,r,s,a){const{x:i,y:l}=t.internals.positionAbsolute,c=Gx(e),u=m3(e,n),d=CT(e.extent)?DO(u,e.extent,c):u;let f=DO({x:i+d.x,y:l+d.y},r,c);e.extent==="parent"&&(f=g0t(f,c,t));const p=j0t(e,s,a),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=p?h+1:p}}function E1e(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??_T(l),u=y0t(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=Gx(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)),v=Math.max(d.height,Math.round(i.height)),y=(m-d.width)*f[0],b=(v-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(S=>{e.some(w=>w.id===S.id)||s.push({id:S.id,type:"position",position:{x:S.position.x+p,y:S.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:v+(h?f[1]*h-b:0)}})}),s}function DVn(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 v=w1e(h.nodeElement),y=m.measured.width!==v.width||m.measured.height!==v.height;if(!!(v.width&&v.height&&(y||!m.internals.handleBounds||h.force))){const S=h.nodeElement.getBoundingClientRect(),w=CT(m.extent)?m.extent:a;let{positionAbsolute:k}=m.internals;m.parentId&&m.extent==="parent"?k=g0t(k,v,t.get(m.parentId)):w&&(k=DO(k,w,v));const _={...m,measured:v,internals:{...m.internals,positionAbsolute:k,handleBounds:{source:B9e("source",h.nodeElement,S,f,m.id),target:B9e("target",h.nodeElement,S,f,m.id)}}};t.set(m.id,_),m.parentId&&C1e(_,t,n,{nodeOrigin:s,zIndexMode:i}),c=!0,y&&(u.push({id:m.id,type:"dimensions",dimensions:v}),m.expandParent&&m.parentId&&p.push({id:m.id,parentId:m.parentId,rect:_T(_,s)}))}}if(p.length>0){const h=E1e(p,t,n,s);u.push(...h)}return{changes:u,updatedInternals:c}}async function LVn({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 G9e(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 T0t(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}`;G9e("source",c,d,e,s,i),G9e("target",c,u,e,a,l),t.set(r.id,r)}}function N0t(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:N0t(n,t):!1}function Q9e(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 FVn(e,t,n,r){const s=new Map;for(const[a,i]of e)if((i.selected||i.id===r)&&(!i.parentId||!N0t(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 GJ({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 zVn({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=v3(a,t);return{x:i.x-a.x,y:i.y-a.y}}function BVn({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,v=null;function y({noDragClassName:S,handleSelector:w,domNode:k,isSelectable:_,nodeId:C,nodeClickDistance:E=0}){p=gp(k);function j({x:P,y:L}){const{nodeLookup:M,nodeExtent:q,snapGrid:H,snapToGrid:F,nodeOrigin:z,onNodeDrag:B,onSelectionDrag:D,onError:Q,updateNodePositions:V}=t();a={x:P,y:L};let $=!1;const U=l.size>1,Z=U&&q?Ihe(g3(l)):null,X=U&&F?zVn({dragItems:l,snapGrid:H,x:P,y:L}):null;for(const[te,J]of l){if(!M.has(te))continue;let ee={x:P-J.distance.x,y:L-J.distance.y};F&&(ee=X?{x:Math.round(ee.x+X.x),y:Math.round(ee.y+X.y)}:v3(ee,H));let ae=null;if(U&&q&&!J.extent&&Z){const{positionAbsolute:ne}=J.internals,ue=ne.x-Z.x+q[0][0],pe=ne.x+J.measured.width-Z.x2+q[1][0],le=ne.y-Z.y+q[0][1],ve=ne.y+J.measured.height-Z.y2+q[1][1];ae=[[ue,le],[pe,ve]]}const{position:ce,positionAbsolute:Y}=m0t({nodeId:te,nextPosition:ee,nodeLookup:M,nodeExtent:ae||q,nodeOrigin:z,onError:Q});$=$||J.position.x!==ce.x||J.position.y!==ce.y,J.position=ce,J.internals.positionAbsolute=Y}if(m=m||$,!!$&&(V(l,!0),v&&(r||B||!C&&D))){const[te,J]=GJ({nodeId:C,dragItems:l,nodeLookup:M});r?.(v,l,te,J),B?.(v,te,J),C||D?.(v,J)}}async function N(){if(!d)return;const{transform:P,panBy:L,autoPanSpeed:M,autoPanOnNodeDrag:q}=t();if(!q){c=!1,cancelAnimationFrame(i);return}const[H,F]=v0t(u,d,M);(H!==0||F!==0)&&(a.x=(a.x??0)-H/P[2],a.y=(a.y??0)-F/P[2],await L({x:H,y:F})&&j(a)),i=requestAnimationFrame(N)}function I(P){const{nodeLookup:L,multiSelectionActive:M,nodesDraggable:q,transform:H,snapGrid:F,snapToGrid:z,selectNodesOnDrag:B,onNodeDragStart:D,onSelectionDragStart:Q,unselectNodesAndEdges:V}=t();f=!0,(!B||!_)&&!M&&C&&(L.get(C)?.selected||V()),_&&B&&C&&e?.(C);const $=V2(P.sourceEvent,{transform:H,snapGrid:F,snapToGrid:z,containerBounds:d});if(a=$,l=FVn(L,q,$,C),l.size>0&&(n||D||!C&&Q)){const[U,Z]=GJ({nodeId:C,dragItems:l,nodeLookup:L});n?.(P.sourceEvent,l,U,Z),D?.(P.sourceEvent,U,Z),C||Q?.(P.sourceEvent,Z)}}const R=Gxt().clickDistance(E).on("start",P=>{const{domNode:L,nodeDragThreshold:M,transform:q,snapGrid:H,snapToGrid:F}=t();d=L?.getBoundingClientRect()||null,h=!1,m=!1,v=P.sourceEvent,M===0&&I(P),a=V2(P.sourceEvent,{transform:q,snapGrid:H,snapToGrid:F,containerBounds:d}),u=fg(P.sourceEvent,d)}).on("drag",P=>{const{autoPanOnNodeDrag:L,transform:M,snapGrid:q,snapToGrid:H,nodeDragThreshold:F,nodeLookup:z}=t(),B=V2(P.sourceEvent,{transform:M,snapGrid:q,snapToGrid:H,containerBounds:d});if(v=P.sourceEvent,(P.sourceEvent.type==="touchmove"&&P.sourceEvent.touches.length>1||C&&!z.has(C))&&(h=!0),!h){if(!c&&L&&f&&(c=!0,N()),!f){const D=fg(P.sourceEvent,d),Q=D.x-u.x,V=D.y-u.y;Math.sqrt(Q*Q+V*V)>F&&I(P)}(a.x!==B.xSnapped||a.y!==B.ySnapped)&&l&&f&&(u=fg(P.sourceEvent,d),j(B))}}).on("end",P=>{if(!(!f||h)&&(c=!1,f=!1,cancelAnimationFrame(i),l.size>0)){const{nodeLookup:L,updateNodePositions:M,onNodeDragStop:q,onSelectionDragStop:H}=t();if(m&&(M(l,!1),m=!1),s||q||!C&&H){const[F,z]=GJ({nodeId:C,dragItems:l,nodeLookup:L,dragging:!1});s?.(P.sourceEvent,l,F,z),q?.(P.sourceEvent,F,z),C||H?.(P.sourceEvent,z)}}}).filter(P=>{const L=P.target;return!P.button&&(!S||!Q9e(L,`.${S}`,k))&&(!w||Q9e(L,w,k))});p.call(R)}function b(){p?.on(".drag",null)}return{update:y,destroy:b}}function UVn(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())oM(s,_T(a))>0&&r.push(a);return r}const qVn=250;function VVn(e,t,n,r){let s=[],a=1/0;const i=UVn(e,n,t+qVn);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}=LO(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 I0t(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,...LO(i,c,c.position,!0)}:c}function A0t(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function HVn(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const R0t=()=>!0;function WVn(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:v,onConnectEnd:y,isValidConnection:b=R0t,onReconnectEnd:S,updateConnection:w,getTransform:k,getFromHandle:_,autoPanSpeed:C,dragThreshold:E=1,handleDomNode:j}){const N=w0t(e.target);let I=0,R;const{x:P,y:L}=fg(e),M=A0t(a,j),q=l?.getBoundingClientRect();let H=!1;if(!q||!M)return;const F=I0t(s,M,r,c,t);if(!F)return;let z=fg(e,q),B=!1,D=null,Q=!1,V=null;function $(){if(!d||!q)return;const[ce,Y]=v0t(z,q,C);p({x:ce,y:Y}),I=requestAnimationFrame($)}const U={...F,nodeId:s,type:M,position:F.position},Z=c.get(s);let te={inProgress:!0,isValid:null,from:LO(Z,U,nr.Left,!0),fromHandle:U,fromPosition:U.position,fromNode:Z,to:z,toHandle:null,toPosition:D9e[U.position],toNode:null,pointer:z};function J(){H=!0,w(te),m?.(e,{nodeId:s,handleId:r,handleType:M})}E===0&&J();function ee(ce){if(!H){const{x:ve,y:ye}=fg(ce),Se=ve-P,Ne=ye-L;if(!(Se*Se+Ne*Ne>E*E))return;J()}if(!_()||!U){ae(ce);return}const Y=k();z=fg(ce,q),R=VVn(y3(z,Y,!1,[1,1]),n,c,U),B||($(),B=!0);const ne=P0t(ce,{handle:R,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:i?"target":"source",isValidConnection:b,doc:N,lib:u,flowId:f,nodeLookup:c});V=ne.handleDomNode,D=ne.connection,Q=HVn(!!R,ne.isValid);const ue=c.get(s),pe=ue?LO(ue,U,nr.Left,!0):te.from,le={...te,from:pe,isValid:Q,to:ne.toHandle&&Q?L7({x:ne.toHandle.x,y:ne.toHandle.y},Y):z,toHandle:ne.toHandle,toPosition:Q&&ne.toHandle?ne.toHandle.position:D9e[U.position],toNode:ne.toHandle?c.get(ne.toHandle.nodeId):null,pointer:z};w(le),te=le}function ae(ce){if(!("touches"in ce&&ce.touches.length>0)){if(H){(R||V)&&D&&Q&&v?.(D);const{inProgress:Y,...ne}=te,ue={...ne,toPosition:te.toHandle?te.toPosition:null};y?.(ce,ue),a&&S?.(ce,ue)}h(),cancelAnimationFrame(I),B=!1,Q=!1,D=null,V=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 P0t(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:a,doc:i,lib:l,flowId:c,isValidConnection:u=R0t,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}=fg(e),v=i.elementFromPoint(h,m),y=v?.classList.contains(`${l}-flow__handle`)?v:p,b={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const S=A0t(void 0,y),w=y.getAttribute("data-nodeid"),k=y.getAttribute("data-handleid"),_=y.classList.contains("connectable"),C=y.classList.contains("connectableend");if(!w||!S)return b;const E={source:f?w:r,sourceHandle:f?k:s,target:f?r:w,targetHandle:f?s:k};b.connection=E;const N=_&&C&&(n===kT.Strict?f&&S==="source"||!f&&S==="target":w!==r||k!==s);b.isValid=N&&u(E),b.toHandle=I0t(w,S,k,d,n,!0)}return b}const $he={onPointerDown:WVn,isValid:P0t};function ZVn({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=gp(e);function a({translateExtent:l,width:c,height:u,zoomStep:d=1,pannable:f=!0,zoomable:p=!0,inversePan:h=!1}){const m=w=>{if(w.sourceEvent.type!=="wheel"||!t)return;const k=n(),_=w.sourceEvent.ctrlKey&&lM()?10:1,C=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*d,E=k[2]*Math.pow(2,C*_);t.scaleTo(E)};let v=[0,0];const y=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(v=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},b=w=>{const k=n();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!t)return;const _=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],C=[_[0]-v[0],_[1]-v[1]];v=_;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)},S=c0t().on("start",y).on("zoom",f?b:null).on("zoom.wheel",p?m:null);s.call(S,{})}function i(){s.on("zoom",null)}return{update:a,destroy:i,pointer:Jm}}const MV=e=>({x:e.x,y:e.y,zoom:e.k}),QJ=({x:e,y:t,zoom:n})=>RV.translate(e,t).scale(n),HE=(e,t)=>e.target.closest(`.${t}`),$0t=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),GVn=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,YJ=(e,t=0,n=GVn,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},M0t=e=>{const t=e.ctrlKey&&lM()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function QVn({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:a,zoomOnPinch:i,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(HE(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=Jm(d),b=M0t(d),S=f*Math.pow(2,b);r.scaleTo(n,S,y,d);return}const p=d.deltaMode===1?20:1;let h=s===Zk.Vertical?0:d.deltaX*p,m=s===Zk.Horizontal?0:d.deltaY*p;!lM()&&d.shiftKey&&s!==Zk.Vertical&&(h=d.deltaY*p,m=0),r.translateBy(n,-(h/f)*a,-(m/f)*a,{internal:!0});const v=MV(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(d,v),e.panScrollTimeout=setTimeout(()=>{u?.(d,v),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l?.(d,v))}}function YVn({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const a=r.type==="wheel",i=!t&&a&&!r.ctrlKey,l=HE(r,e);if(r.ctrlKey&&a&&l&&r.preventDefault(),i||l)return null;r.preventDefault(),n.call(this,r,s)}}function XVn({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;const s=MV(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 KVn({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return a=>{e.usedRightMouseButton=!!(n&&$0t(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),s&&!a.sourceEvent?.internal&&s?.(a.sourceEvent,MV(a.transform))}}function JVn({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:a}){return i=>{if(!i.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&$0t(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&a(i.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const l=MV(i.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s?.(i.sourceEvent,l)},n?150:0)}}}function eHn({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"&&(HE(f,`${u}-flow__node`)||HE(f,`${u}-flow__edge`)))return!0;if(!r&&!p&&!s&&!a&&!n||i||d&&!m||HE(f,l)&&m||HE(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 v=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||m)&&v}}function tHn({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=c0t().scaleExtent([t,n]).translateExtent(r),p=gp(e).call(f);S({x:s.x,y:s.y,zoom:OT(s.zoom,t,n)},[[0,0],[d.width,d.height]],r);const h=p.on("wheel.zoom"),m=p.on("dblclick.zoom");f.wheelDelta(M0t);function v(R,P){return p?new Promise(L=>{f?.interpolate(P?.interpolate==="linear"?ix:JF).transform(YJ(p,P?.duration,P?.ease,()=>L(!0)),R)}):Promise.resolve(!1)}function y({noWheelClassName:R,noPanClassName:P,onPaneContextMenu:L,userSelectionActive:M,panOnScroll:q,panOnDrag:H,panOnScrollMode:F,panOnScrollSpeed:z,preventScrolling:B,zoomOnPinch:D,zoomOnScroll:Q,zoomOnDoubleClick:V,zoomActivationKeyPressed:$,lib:U,onTransformChange:Z,connectionInProgress:X,paneClickDistance:te,selectionOnDrag:J}){M&&!u.isZoomingOrPanning&&b();const ee=q&&!$&&!M;f.clickDistance(J?1/0:!dg(te)||te<0?0:te);const ae=ee?QVn({zoomPanValues:u,noWheelClassName:R,d3Selection:p,d3Zoom:f,panOnScrollMode:F,panOnScrollSpeed:z,zoomOnPinch:D,onPanZoomStart:i,onPanZoom:a,onPanZoomEnd:l}):YVn({noWheelClassName:R,preventScrolling:B,d3ZoomHandler:h});if(p.on("wheel.zoom",ae,{passive:!1}),!M){const Y=XVn({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:i});f.on("start",Y);const ne=KVn({zoomPanValues:u,panOnDrag:H,onPaneContextMenu:!!L,onPanZoom:a,onTransformChange:Z});f.on("zoom",ne);const ue=JVn({zoomPanValues:u,panOnDrag:H,panOnScroll:q,onPaneContextMenu:L,onPanZoomEnd:l,onDraggingChange:c});f.on("end",ue)}const ce=eHn({zoomActivationKeyPressed:$,panOnDrag:H,zoomOnScroll:Q,panOnScroll:q,zoomOnDoubleClick:V,zoomOnPinch:D,userSelectionActive:M,noPanClassName:P,noWheelClassName:R,lib:U,connectionInProgress:X});f.filter(ce),V?p.on("dblclick.zoom",m):p.on("dblclick.zoom",null)}function b(){f.on("zoom",null)}async function S(R,P,L){const M=QJ(R),q=f?.constrain()(M,P,L);return q&&await v(q),new Promise(H=>H(q))}async function w(R,P){const L=QJ(R);return await v(L,P),new Promise(M=>M(L))}function k(R){if(p){const P=QJ(R),L=p.property("__zoom");(L.k!==R.zoom||L.x!==R.x||L.y!==R.y)&&f?.transform(p,P,null,{sync:!0})}}function _(){const R=p?l0t(p.node()):{x:0,y:0,k:1};return{x:R.x,y:R.y,zoom:R.k}}function C(R,P){return p?new Promise(L=>{f?.interpolate(P?.interpolate==="linear"?ix:JF).scaleTo(YJ(p,P?.duration,P?.ease,()=>L(!0)),R)}):Promise.resolve(!1)}function E(R,P){return p?new Promise(L=>{f?.interpolate(P?.interpolate==="linear"?ix:JF).scaleBy(YJ(p,P?.duration,P?.ease,()=>L(!0)),R)}):Promise.resolve(!1)}function j(R){f?.scaleExtent(R)}function N(R){f?.translateExtent(R)}function I(R){const P=!dg(R)||R<0?0:R;f?.clickDistance(P)}return{update:y,destroy:b,setViewport:w,setViewportConstrained:S,getViewport:_,scaleTo:C,scaleBy:E,setScaleExtent:j,setTranslateExtent:N,syncViewport:k,setClickDistance:I}}var ET;(function(e){e.Line="line",e.Handle="handle"})(ET||(ET={}));function nHn({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 Y9e(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 F0(e,t){return Math.max(0,t-e)}function z0(e,t){return Math.max(0,e-t)}function N6(e,t,n){return Math.max(0,t-e,e-n)}function X9e(e,t){return e?!t:t}function rHn(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:v,maxWidth:y,minHeight:b,maxHeight:S}=r,{x:w,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),P=-a[0]*_,L=-a[1]*C;let M=N6(I,v,y),q=N6(R,b,S);if(i){let z=0,B=0;c&&j<0?z=F0(w+j+P,i[0][0]):!c&&j>0&&(z=z0(w+I+P,i[1][0])),u&&N<0?B=F0(k+N+L,i[0][1]):!u&&N>0&&(B=z0(k+R+L,i[1][1])),M=Math.max(M,z),q=Math.max(q,B)}if(l){let z=0,B=0;c&&j>0?z=z0(w+j,l[0][0]):!c&&j<0&&(z=F0(w+I,l[1][0])),u&&N>0?B=z0(k+N,l[0][1]):!u&&N<0&&(B=F0(k+R,l[1][1])),M=Math.max(M,z),q=Math.max(q,B)}if(s){if(d){const z=N6(I/E,b,S)*E;if(M=Math.max(M,z),i){let B=0;!c&&!u||c&&!u&&p?B=z0(k+L+I/E,i[1][1])*E:B=F0(k+L+(c?j:-j)/E,i[0][1])*E,M=Math.max(M,B)}if(l){let B=0;!c&&!u||c&&!u&&p?B=F0(k+I/E,l[1][1])*E:B=z0(k+(c?j:-j)/E,l[0][1])*E,M=Math.max(M,B)}}if(f){const z=N6(R*E,v,y)/E;if(q=Math.max(q,z),i){let B=0;!c&&!u||u&&!c&&p?B=z0(w+R*E+P,i[1][0])/E:B=F0(w+(u?N:-N)*E+P,i[0][0])/E,q=Math.max(q,B)}if(l){let B=0;!c&&!u||u&&!c&&p?B=F0(w+R*E,l[1][0])/E:B=z0(w+(u?N:-N)*E,l[0][0])/E,q=Math.max(q,B)}}}N=N+(N<0?q:-q),j=j+(j<0?M:-M),s&&(p?I>R*E?N=(X9e(c,u)?-j:j)/E:j=(X9e(c,u)?-N:N)*E:d?(N=j/E,u=c):(j=N*E,c=u));const H=c?w+j:w,F=u?k+N:k;return{width:_+(c?-j:j),height:C+(u?-N:N),x:a[0]*j*(c?-1:1)+H,y:a[1]*N*(u?-1:1)+F}}const D0t={width:0,height:0,x:0,y:0},sHn={...D0t,pointerX:0,pointerY:0,aspectRatio:1};function aHn(e){return[[0,0],[e.measured.width,e.measured.height]]}function iHn(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 oHn({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const a=gp(e);let i={controlDirection:Y9e("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:v,shouldResize:y}){let b={...D0t},S={...sHn};i={boundaries:d,resizeDirection:p,keepAspectRatio:f,controlDirection:Y9e(u)};let w,k=null,_=[],C,E,j,N=!1;const I=Gxt().on("start",R=>{const{nodeLookup:P,transform:L,snapGrid:M,snapToGrid:q,nodeOrigin:H,paneDomNode:F}=n();if(w=P.get(t),!w)return;k=F?.getBoundingClientRect()??null;const{xSnapped:z,ySnapped:B}=V2(R.sourceEvent,{transform:L,snapGrid:M,snapToGrid:q,containerBounds:k});b={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},S={...b,pointerX:z,pointerY:B,aspectRatio:b.width/b.height},C=void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&(C=P.get(w.parentId),E=C&&w.extent==="parent"?aHn(C):void 0),_=[],j=void 0;for(const[D,Q]of P)if(Q.parentId===t&&(_.push({id:D,position:{...Q.position},extent:Q.extent}),Q.extent==="parent"||Q.expandParent)){const V=iHn(Q,w,Q.origin??H);j?j=[[Math.min(V[0][0],j[0][0]),Math.min(V[0][1],j[0][1])],[Math.max(V[1][0],j[1][0]),Math.max(V[1][1],j[1][1])]]:j=V}h?.(R,{...b})}).on("drag",R=>{const{transform:P,snapGrid:L,snapToGrid:M,nodeOrigin:q}=n(),H=V2(R.sourceEvent,{transform:P,snapGrid:L,snapToGrid:M,containerBounds:k}),F=[];if(!w)return;const{x:z,y:B,width:D,height:Q}=b,V={},$=w.origin??q,{width:U,height:Z,x:X,y:te}=rHn(S,i.controlDirection,H,i.boundaries,i.keepAspectRatio,$,E,j),J=U!==D,ee=Z!==Q,ae=X!==z&&J,ce=te!==B&&ee;if(!ae&&!ce&&!J&&!ee)return;if((ae||ce||$[0]===1||$[1]===1)&&(V.x=ae?X:b.x,V.y=ce?te:b.y,b.x=V.x,b.y=V.y,_.length>0)){const pe=X-z,le=te-B;for(const ve of _)ve.position={x:ve.position.x-pe+$[0]*(U-D),y:ve.position.y-le+$[1]*(Z-Q)},F.push(ve)}if((J||ee)&&(V.width=J&&(!i.resizeDirection||i.resizeDirection==="horizontal")?U:b.width,V.height=ee&&(!i.resizeDirection||i.resizeDirection==="vertical")?Z:b.height,b.width=V.width,b.height=V.height),C&&w.expandParent){const pe=$[0]*(V.width??0);V.x&&V.x<pe&&(b.x=pe,S.x=S.x-(V.x-pe));const le=$[1]*(V.height??0);V.y&&V.y<le&&(b.y=le,S.y=S.y-(V.y-le))}const Y=nHn({width:b.width,prevWidth:D,height:b.height,prevHeight:Q,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),ne={...b,direction:Y};y?.(R,ne)!==!1&&(N=!0,m?.(R,ne),r(V,F))}).on("end",R=>{N&&(v?.(R,{...b}),s?.({...b}),N=!1)});a.call(I)}function c(){a.on(".drag",null)}return{update:l,destroy:c}}const lHn={},K9e=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:()=>{(lHn?"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},cHn=e=>e?K9e(e):K9e,{useDebugValue:uHn}=Le,{useSyncExternalStoreWithSelector:dHn}=$wn,fHn=e=>e;function L0t(e,t=fHn,n){const r=dHn(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return uHn(r),r}const J9e=(e,t)=>{const n=cHn(e),r=(s,a=t)=>L0t(n,s,a);return Object.assign(r,n),r},pHn=(e,t)=>e?J9e(e,t):J9e;function no(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 DV=g.createContext(null),hHn=DV.Provider,F0t=hy.error001();function Us(e,t){const n=g.useContext(DV);if(n===null)throw new Error(F0t);return L0t(n,e,t)}function So(){const e=g.useContext(DV);if(e===null)throw new Error(F0t);return g.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const eFe={display:"none"},mHn={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},z0t="react-flow__node-desc",B0t="react-flow__edge-desc",gHn="react-flow__aria-live",vHn=e=>e.ariaLiveMessage,yHn=e=>e.ariaLabelConfig;function bHn({rfId:e}){const t=Us(vHn);return o.jsx("div",{id:`${gHn}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:mHn,children:t})}function xHn({rfId:e,disableKeyboardA11y:t}){const n=Us(yHn);return o.jsxs(o.Fragment,{children:[o.jsx("div",{id:`${z0t}-${e}`,style:eFe,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),o.jsx("div",{id:`${B0t}-${e}`,style:eFe,children:n["edge.a11yDescription.default"]}),!t&&o.jsx(bHn,{rfId:e})]})}const b3=g.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},a)=>{const i=`${e}`.split("-");return o.jsx("div",{className:Ml(["react-flow__panel",n,...i]),style:r,ref:a,...s,children:t})});b3.displayName="Panel";function wHn({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:o.jsx(b3,{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 SHn=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}},I6=e=>e.id;function kHn(e,t){return no(e.selectedNodes.map(I6),t.selectedNodes.map(I6))&&no(e.selectedEdges.map(I6),t.selectedEdges.map(I6))}function OHn({onSelectionChange:e}){const t=So(),{selectedNodes:n,selectedEdges:r}=Us(SHn,kHn);return g.useEffect(()=>{const s={nodes:n,edges:r};e?.(s),t.getState().onSelectionChangeHandlers.forEach(a=>a(s))},[n,r,e]),null}const _Hn=e=>!!e.onSelectionChangeHandlers;function CHn({onSelectionChange:e}){const t=Us(_Hn);return e||t?o.jsx(OHn,{onSelectionChange:e}):null}const Mhe=typeof window<"u"?g.useLayoutEffect:g.useEffect,U0t=[0,0],EHn={x:0,y:0,zoom:1},jHn=["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"],tFe=[...jHn,"rfId"],THn=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}),nFe={translateExtent:sM,nodeOrigin:U0t,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function NHn(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:a,setNodeExtent:i,reset:l,setDefaultNodesAndEdges:c}=Us(THn,no),u=So();Mhe(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=nFe,l()}),[]);const d=g.useRef(nFe);return Mhe(()=>{for(const f of tFe){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:bVn(p)}):f==="fitView"?u.setState({fitViewQueued:p}):f==="fitViewOptions"?u.setState({fitViewOptions:p}):u.setState({[f]:p})))}d.current=e},tFe.map(f=>e[f])),null}function rFe(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function IHn(e){const[t,n]=g.useState(e==="system"?null:e);return g.useEffect(()=>{if(e!=="system"){n(e);return}const r=rFe(),s=()=>n(r?.matches?"dark":"light");return s(),r?.addEventListener("change",s),()=>{r?.removeEventListener("change",s)}},[e]),t!==null?t:rFe()?.matches?"dark":"light"}const sFe=typeof document<"u"?document:null;function cM(e=null,t={target:sFe,actInsideInputWithModifier:!0}){const[n,r]=g.useState(!1),s=g.useRef(!1),a=g.useRef(new Set([])),[i,l]=g.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 Ses({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(Ep,{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 kes({datasetId:e,open:t,onOpenChange:n,onSuccess:r}){const[s,a]=g.useState("upload"),[i,l]=g.useState(null),[c,u]=g.useState({current:0,total:0}),[d,f]=g.useState(null),[p,h]=g.useState(!1),{parseFile:m,isParsing:v,error:y}=QKr(),{batchInsertItems:b}=Ei(),S=g.useCallback(async I=>{try{const R=await m(I);l(R),a("preview")}catch{}},[m]),w=g.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=g.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]),_=g.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(wes,{onFileSelect:S,isParsing:v,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(Ses,{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(xes,{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(de,{onClick:_,children:"Cancel"});case"preview":return o.jsxs(o.Fragment,{children:[o.jsx(de,{onClick:()=>a("upload"),children:"Back"}),o.jsxs(de,{variant:"primary",onClick:w,disabled:!C,children:["Import ",i?.items.length??0," Item",i?.items.length!==1?"s":""]})]});case"importing":return null;case"complete":return o.jsx(de,{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(Rr,{className:"min-h-[200px] max-h-[50vh] overflow-y-auto",children:E()}),o.jsx(Cc,{className:"px-6 pt-4 flex justify-end gap-2",children:j()})]})})}const xTe=e=>{const t=We(),{data:n}=tD(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})},Oes=e=>{const t=We(),{data:n}=tD(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 _es(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 A9t({datasetId:e,experimentId:t,featuredItemId:n}){const r=We(),{data:s}=Hx(e),{data:a,isLoading:i}=xTe(e),{data:l,isLoading:c}=Oes(e),u=g.useMemo(()=>t?(a??[]).filter(Ee=>Ee.experimentId===t):a,[a,t]),d=g.useMemo(()=>t?(l??[]).filter(Ee=>Ee.experimentId===t):l,[l,t]),{updateExperimentResult:f}=Ei(),[p,h]=g.useState(n??null);g.useEffect(()=>{n!==void 0&&h(n)},[n]);const[m,v]=g.useState(null),[y,b]=g.useState(new Set),[S,w]=g.useState(!1),[k,_]=g.useState(!1),[C,E]=g.useState(!1),[j,N]=g.useState(""),[I,R]=g.useState(""),[P,L]=g.useState(""),[M,q]=g.useState([]),[H,F]=g.useState(!1),[z,B]=g.useState(null),D=g.useMemo(()=>z??u??[],[z,u]);g.useEffect(()=>{B(null)},[e,t]),g.useEffect(()=>{u&&z===null&&B(u)},[u,z]);const Q=g.useMemo(()=>{const Ee=new Set;if(s?.tags)for(const _e of s.tags)Ee.add(_e);for(const _e of D)for(const Ce of _e.tags)Ee.add(Ce);return[...Ee].sort()},[s,D]),V=g.useCallback(Ee=>{!s||!e||(s.tags??[]).includes(Ee)},[s,e]),$=g.useMemo(()=>m?m==="__untagged__"?D.filter(Ee=>Ee.tags.length===0):D.filter(Ee=>Ee.tags.includes(m)):D,[D,m]),U=g.useMemo(()=>{const Ee=new Map;for(const _e of D)for(const Ce of _e.tags)Ee.set(Ce,(Ee.get(Ce)??0)+1);return[...Ee.entries()].sort((_e,Ce)=>Ce[1]-_e[1])},[D]),Z=g.useMemo(()=>D.filter(Ee=>Ee.tags.length===0).length,[D]),X=g.useMemo(()=>{let Ee=0;return m&&Ee++,S&&Ee++,Ee},[m,S]),te=g.useCallback((Ee,_e)=>{B(Oe=>(Oe??[]).map(Re=>Re.id===Ee?{...Re,tags:_e}:Re));const Ce=D.find(Oe=>Oe.id===Ee);Ce?.experimentId&&Ce?.datasetId&&f.mutate({datasetId:Ce.datasetId,experimentId:Ce.experimentId,resultId:Ce.id,tags:_e})},[D,f]),J=g.useCallback((Ee,_e)=>{const Ce=D.find(Oe=>Oe.id===Ee);Ce?.traceId&&_e!==void 0&&r.createFeedback({feedback:{traceId:Ce.traceId,source:"studio",feedbackSource:"studio",feedbackType:"rating",value:_e==="positive"?1:-1,experimentId:Ce.experimentId??void 0,sourceId:Ce.id}}).catch(()=>{}),B(Oe=>(Oe??[]).map(Re=>Re.id===Ee?{...Re,rating:_e}:Re))},[D,r]),ee=g.useCallback((Ee,_e)=>{const Ce=D.find(Oe=>Oe.id===Ee);Ce?.traceId&&r.createFeedback({feedback:{traceId:Ce.traceId,source:"studio",feedbackSource:"studio",feedbackType:"comment",value:_e,comment:_e,experimentId:Ce.experimentId??void 0,sourceId:Ce.id}}).catch(()=>{}),B(Oe=>(Oe??[]).map(Re=>Re.id===Ee?{...Re,comment:_e}:Re))},[D,r]),ae=g.useCallback(Ee=>{const _e=D.find(Ce=>Ce.id===Ee);B(Ce=>(Ce??[]).filter(Oe=>Oe.id!==Ee)),b(Ce=>{const Oe=new Set(Ce);return Oe.delete(Ee),Oe}),p===Ee&&h(null),_e?.experimentId&&_e?.datasetId&&f.mutate({datasetId:_e.datasetId,experimentId:_e.experimentId,resultId:_e.id,status:null})},[D,f,p]),ce=g.useCallback(Ee=>{const _e=D.find(Ce=>Ce.id===Ee);B(Ce=>(Ce??[]).filter(Oe=>Oe.id!==Ee)),b(Ce=>{const Oe=new Set(Ce);return Oe.delete(Ee),Oe}),p===Ee&&h(null),_e?.experimentId&&_e?.datasetId&&f.mutate({datasetId:_e.datasetId,experimentId:_e.experimentId,resultId:_e.id,status:"complete"})},[D,f,p]),Y=g.useMemo(()=>{const Ee=S?d??[]:$;return!S||!m?Ee:m==="__untagged__"?Ee.filter(_e=>_e.tags.length===0):Ee.filter(_e=>_e.tags.includes(m))},[S,d,$,m]),ne=S?c:!1,ue=g.useMemo(()=>new Set(Y.map(Ee=>Ee.id)),[Y]),pe=g.useMemo(()=>[...y].filter(Ee=>ue.has(Ee)).length,[y,ue]),le=Y.length>0&&pe===Y.length,ve=pe>0&&!le,ye=g.useCallback(Ee=>{b(_e=>{const Ce=new Set(_e);return Ce.has(Ee)?Ce.delete(Ee):Ce.add(Ee),Ce})},[]),Se=g.useCallback(()=>{b(le?new Set:new Set(Y.map(Ee=>Ee.id)))},[le,Y]),Ne=g.useCallback(Ee=>{for(const _e of y){const Ce=D.find(Oe=>Oe.id===_e);Ce&&!Ce.tags.includes(Ee)&&te(_e,[...Ce.tags,Ee])}},[D,y,te]),ke=g.useCallback(Ee=>{for(const _e of y){const Ce=D.find(Oe=>Oe.id===_e);Ce&&Ce.tags.includes(Ee)&&te(_e,Ce.tags.filter(Oe=>Oe!==Ee))}},[D,y,te]),Ie=g.useCallback(()=>{for(const Ee of y)ce(Ee);b(new Set)},[y,ce]),ze=g.useCallback(()=>{for(const Ee of y)ae(Ee);b(new Set)},[y,ae]),oe=g.useCallback(()=>{N(""),E(!0)},[]),se=g.useCallback(async()=>{if(!(!I||!P)){_(!0),E(!1);try{const Ee=D.filter(Ce=>y.has(Ce.id));if(Ee.length===0){_(!1);return}const _e=await r.clusterFailures({modelId:`${I}/${P}`,items:Ee.map(Ce=>({id:Ce.id,input:Ce.input,output:Ce.output??void 0,error:typeof Ce.error=="string"?Ce.error:Ce.error?String(Ce.error):void 0,scores:Ce.scores,existingTags:Ce.tags.length>0?Ce.tags:void 0})),availableTags:Q.length>0?Q:void 0,prompt:j||void 0});_e.proposedTags&&_e.proposedTags.length>0&&(q(_e.proposedTags.map(Ce=>({...Ce,accepted:!0}))),F(!0))}catch(Ee){console.error("Analysis failed:",Ee)}finally{_(!1)}}},[I,P,D,y,r,Q,j]),re=g.useCallback(()=>{for(const Ee of M){if(!Ee.accepted)continue;const _e=D.find(Ce=>Ce.id===Ee.itemId);if(_e){const Ce=[...new Set([..._e.tags,...Ee.tags])];te(_e.id,Ce)}}F(!1)},[M,D,te]),he=g.useCallback(Ee=>{h(_e=>_e===Ee?null:Ee)},[]),xe=g.useMemo(()=>p?Y.find(Ee=>Ee.id===p)??null:null,[p,Y]),je=p?Y.findIndex(Ee=>Ee.id===p):-1,Pe=je>0?()=>h(Y[je-1].id):void 0,Ge=je>=0&&je<Y.length-1?()=>h(Y[je+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(zy,{value:I,onValueChange:R})]}),o.jsxs("div",{children:[o.jsx(Rt,{className:"text-xs mb-1 block",children:"Model"}),o.jsx(By,{llmId:I,value:P,onValueChange:L})]})]}),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(Kl,{value:j,onChange:Ee=>N(Ee.target.value),placeholder:"E.g., Focus on safety issues and factual errors...",rows:3,className:"text-xs mt-1"})]})]}),o.jsxs(Cc,{children:[o.jsx(de,{variant:"outline",onClick:()=>E(!1),children:"Cancel"}),o.jsxs(de,{onClick:se,disabled:!I||!P||k,children:[k?o.jsx(Gt,{className:"w-4 h-4 mr-1"}):null,"Analyze"]})]})]})}),o.jsx(br,{open:H,onOpenChange:F,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:[M.filter(Ee=>Ee.accepted).length," of ",M.length," proposals selected"]})]}),o.jsx("div",{className:"space-y-3 py-2",children:M.map((Ee,_e)=>{const Ce=D.find(Oe=>Oe.id===Ee.itemId);return o.jsx("div",{className:K("p-3 border rounded-lg",!Ee.accepted&&"opacity-50"),children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(Mo,{checked:Ee.accepted,onCheckedChange:Oe=>q(Re=>Re.map((qe,Ye)=>Ye===_e?{...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:Ce?typeof Ce.input=="string"?Ce.input.slice(0,100):JSON.stringify(Ce.input).slice(0,100):Ee.itemId}),o.jsx("div",{className:"flex gap-1 flex-wrap mt-1.5",children:Ee.tags.map((Oe,Re)=>o.jsx(c9t,{tag:Oe,onRename:qe=>q(Ye=>Ye.map((tt,At)=>At===_e?{...tt,tags:tt.tags.map((ot,zt)=>zt===Re?qe:ot)}:tt)),onRemove:()=>q(qe=>qe.map((Ye,tt)=>tt===_e?{...Ye,tags:Ye.tags.filter((At,ot)=>ot!==Re)}:Ye))},`${Oe}-${Re}`))}),Ee.reason&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-1 block italic",children:Ee.reason})]})]})},Ee.itemId)})}),o.jsxs(Cc,{children:[o.jsx(de,{variant:"outline",onClick:()=>F(!1),children:"Cancel"}),o.jsxs(de,{onClick:re,disabled:M.filter(Ee=>Ee.accepted).length===0,children:["Accept ",M.filter(Ee=>Ee.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(pt,{children:[o.jsx(pt.Trigger,{asChild:!0,children:o.jsxs(de,{variant:"outline",size:"md",children:[o.jsx(Flt,{}),"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(pt.Content,{align:"start",className:K("min-w-48"),children:[o.jsxs(pt.Sub,{children:[o.jsxs(pt.SubTrigger,{children:["Status",S&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(pt.SubContent,{children:[o.jsx(pt.CheckboxItem,{checked:!S,onCheckedChange:()=>{w(!1),h(null)},onSelect:Ee=>Ee.preventDefault(),children:"Review Queue"}),o.jsx(pt.CheckboxItem,{checked:S,onCheckedChange:()=>{w(!0),h(null)},onSelect:Ee=>Ee.preventDefault(),children:"Completed"})]})]}),o.jsxs(pt.Sub,{children:[o.jsxs(pt.SubTrigger,{children:["Tags",m&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(pt.SubContent,{children:[o.jsx(pt.CheckboxItem,{checked:!m,onCheckedChange:()=>v(null),onSelect:Ee=>Ee.preventDefault(),children:"All"}),Z>0&&o.jsx(pt.CheckboxItem,{checked:m==="__untagged__",onCheckedChange:()=>v(m==="__untagged__"?null:"__untagged__"),onSelect:Ee=>Ee.preventDefault(),children:"Untagged"}),U.length>0&&o.jsx(pt.Separator,{}),U.map(([Ee])=>o.jsx(pt.CheckboxItem,{checked:m===Ee,onCheckedChange:()=>v(m===Ee?null:Ee),onSelect:_e=>_e.preventDefault(),children:Ee},Ee))]})]}),X>0&&o.jsxs(o.Fragment,{children:[o.jsx(pt.Separator,{}),o.jsxs(pt.Item,{onSelect:()=>{v(null),w(!1),h(null)},children:[o.jsx(vs,{}),"Clear all filters"]})]})]})]}),X>0&&o.jsxs(de,{variant:"outline",size:"md",onClick:()=>{v(null),w(!1),h(null)},children:[o.jsx(vs,{}),"Reset"]})]}),!S&&y.size>0&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(l9t,{selectedCount:y.size,vocabulary:Q,onApplyTag:Ne,onRemoveTag:ke,onNewTag:Ee=>Ne(Ee)}),o.jsxs(pt,{children:[o.jsx(pt.Trigger,{asChild:!0,children:o.jsxs(de,{disabled:k,children:[k?o.jsx(Gt,{className:"w-4 h-4"}):o.jsx(Ue,{size:"sm",children:o.jsx(Sa,{})}),"Actions"]})}),o.jsxs(pt.Content,{align:"end",children:[o.jsxs(pt.Item,{onSelect:Ie,children:[o.jsx(Ue,{size:"sm",children:o.jsx(uO,{})}),"Complete"]}),o.jsxs(pt.Item,{onSelect:ze,children:[o.jsx(Ue,{size:"sm",children:o.jsx(au,{})}),"Remove"]}),o.jsx(pt.Separator,{}),o.jsxs(pt.Item,{onSelect:oe,children:[o.jsx(Ue,{size:"sm",children:o.jsx(wg,{})}),"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:S?"No completed reviews yet":"No items to review"}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-2 block",children:S?"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:[S?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(Ee=>{const _e=Ee.scores?Object.entries(Ee.scores):[],Ce=p===Ee.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:_es(Ee.input,200)})}),o.jsx(me.Cell,{height:"compact",className:"min-w-0",children:Ee.comment?o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 truncate",children:Ee.comment}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsx(me.Cell,{height:"compact",className:"min-w-0",children:Ee.tags.length>0?o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 truncate",children:Ee.tags.join(", ")}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsxs(me.Cell,{height:"compact",children:[Ee.rating==="positive"&&o.jsx(Ue,{size:"sm",className:"text-positive1",children:o.jsx(fbe,{})}),Ee.rating==="negative"&&o.jsx(Ue,{size:"sm",className:"text-negative1",children:o.jsx(dbe,{})}),!Ee.rating&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})]}),o.jsx(me.Cell,{height:"compact",children:_e.length>0?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(Ue,{size:"sm",className:"text-neutral3",children:o.jsx(rm,{})}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 font-mono",children:_e[0][1].toFixed(2)}),_e.length>1&&o.jsxs(dn,{variant:"default",children:["+",_e.length-1]})]}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})})]});return o.jsxs(me.RowWrapper,{children:[S?o.jsx(me.Cell,{height:"compact",className:"justify-items-center px-4",children:o.jsx("div",{role:"img","aria-label":Ee.error?"Error":"Success",title:Ee.error?"Error":"Success",className:K("w-2 h-2 rounded-full",Ee.error?"bg-red-700":"bg-green-600")})}):o.jsx(me.SelectCell,{checked:y.has(Ee.id),onToggle:()=>ye(Ee.id),"aria-label":`Select item ${Ee.id}`}),o.jsx(me.RowButton,{flushLeft:!0,colStart:2,featured:Ce,onClick:()=>he(Ee.id),children:Oe})]},Ee.id)})]})]}),xe&&o.jsx(o9t,{item:xe,isCompleted:S,tagVocabulary:Q,onRate:Ee=>J(xe.id,Ee),onSetTags:Ee=>{te(xe.id,Ee);for(const _e of Ee)Q.includes(_e)||V(_e)},onComment:Ee=>ee(xe.id,Ee),onRemove:()=>ae(xe.id),onComplete:S?void 0:()=>ce(xe.id),onPrevious:Pe,onNext:Ge,onClose:()=>h(null)})]})]})}function Ces({datasetId:e,onAddItemClick:t,onNavigateToDataset:n}){const{navigate:r}=yn(),[s,a]=ga(),{tab:i,activeVersion:l,handleTabChange:c}=yTe(s,a),[u,d]=g.useState(!1),[f,p]=g.useState(!1),[h,m]=g.useState(!1),[v,y]=g.useState([]),[b,S]=g.useState(!1),[w,k]=g.useState([]),[_,C]=g.useState(!1),[E,j]=g.useState([]),[N,I]=g.useState(0),[R,P]=g.useState(null),[L,M]=g.useState(""),[q]=A0e(L,300),{data:H}=Hx(e),{data:F=[],total:z,isLoading:B,setEndOfListElement:D,isFetchingNextPage:Q,hasNextPage:V}=E1(e,q||void 0,l),{total:$}=E1(e,void 0,l),[U,Z]=g.useState({}),{data:X,isLoading:te}=tD(e,void 0,U),{data:J}=tD(e),{deleteItems:ee}=Ei(),ae=X?.experiments??[],ce=J?.experiments??[],Y=EJr({hasSearchQuery:!!q,filteredItemsLength:F.length,unfilteredItemsTotal:$,itemsTotal:z}),{data:ne}=xTe(e),ue=ne?.length??0,pe=re=>{P(re)},le=()=>{P(null)},ve=re=>{y(re),m(!0)},ye=re=>{k(re),S(!0)},Se=re=>{S(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(cu,{defaultTab:"items",value:i,onValueChange:c,className:"grid grid-rows-[auto_1fr] h-full",children:[o.jsxs(uu,{children:[o.jsxs(qr,{value:"items",children:["Items ",o.jsx(Xs,{color:"gray",children:Y})]}),o.jsxs(qr,{value:"experiments",children:["Experiments",o.jsx(Xs,{color:"gray",children:ae.length})]}),o.jsxs(qr,{value:"review",children:["Review",ue>0&&o.jsx(Xs,{color:"orange",children:ue})]})]}),o.jsx(fs,{value:"items",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(bes,{datasetId:e,items:F,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:H?.name,clearSelectionTrigger:N,setEndOfListElement:D,isFetchingNextPage:Q,hasNextPage:V,searchQuery:L,activeSearchQuery:q,onSearchChange:M,currentDatasetVersion:H?.version,onCompareVersionsClick:ke})}),o.jsx(fs,{value:"experiments",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(VJr,{experiments:ae,allExperiments:ce,isLoading:te,datasetId:e,filters:U,onFiltersChange:Z})}),o.jsx(fs,{value:"review",className:"overflow-auto mt-2 pb-0",children:o.jsx(A9t,{datasetId:e})})]}),o.jsx(MJr,{datasetId:e,open:u,onOpenChange:d}),o.jsx(kes,{datasetId:e,open:f,onOpenChange:p}),o.jsx(fJr,{open:h,onOpenChange:se,items:v,onSuccess:oe}),o.jsx(pJr,{open:b,onOpenChange:Se,items:w,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 Ees(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 Kre({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 jes({datasetId:e,open:t,onOpenChange:n,onSuccess:r}){const[s,a]=g.useState("{}"),[i,l]=g.useState(""),[c,u]=g.useState(""),[d,f]=g.useState(""),[p,h]=g.useState(""),[m,v]=g.useState(null),{addItem:y}=Ei(),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 P=JSON.parse(d);if(!Array.isArray(P)){De.error("Tool Mocks must be a JSON array");return}I=P}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"),v(null),a("{}"),l(""),u(""),f(""),h(""),n(!1),r?.()}catch(P){const L=Ees(P);L?v(L):De.error(`Failed to add item: ${P instanceof Error?P.message:"Unknown error"}`)}},S=C=>{a(C),m?.field==="input"&&v(null)},w=C=>{l(C),m?.field==="groundTruth"&&v(null)},k=C=>{f(C),m?.field==="toolMocks"&&v(null)},_=()=>{a("{}"),l(""),u(""),f(""),h(""),v(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(Rr,{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:S,showCopyButton:!1,className:"min-h-[120px]"}),m?.field==="input"&&o.jsx(Kre,{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:w,showCopyButton:!1,className:"min-h-[80px]"}),m?.field==="groundTruth"&&o.jsx(Kre,{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(Kre,{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(de,{type:"button",onClick:_,children:"Cancel"}),o.jsx(de,{type:"submit",variant:"primary",disabled:y.isPending,children:y.isPending?"Adding...":"Add Item"})]})]})})]})})}function Tes({item:e}){return o.jsx(ua,{withMargins:!1,children:o.jsxs(ua.Column,{children:[o.jsxs(ua.Title,{size:"smaller",children:[o.jsx(yN,{}),o.jsx("span",{className:"truncate",children:e.id}),o.jsx(Oa,{content:e.id,tooltip:`Copy item ID: ${e.id}`})]}),o.jsxs(ua.Description,{children:[o.jsxs(Al,{children:[o.jsx(Nlt,{})," Created ",er(new Date(e.createdAt),"MMM d, yyyy h:mm aaa")]}),e.datasetVersion!=null&&o.jsxs(Al,{children:[o.jsx(p_,{})," Version v",e.datasetVersion]})]})]})})}function wTe({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(Uje,{children:[o.jsx(Ps.CodeSection,{title:"Input",icon:o.jsx(fO,{}),codeStr:t}),o.jsx(Ps.CodeSection,{title:"Ground Truth",icon:o.jsx(gg,{}),codeStr:n}),s&&o.jsx(Ps.CodeSection,{title:"Expected Trajectory",icon:o.jsx(lbe,{}),codeStr:s}),o.jsx(Ps.CodeSection,{title:"Metadata",icon:o.jsx(wN,{}),codeStr:r})]})}function Nes({selectedScorers:e,setSelectedScorers:t,disabled:n=!1,container:r}){const{data:s,isLoading:a}=ih(),i=g.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(Jl,{multiple:!0,options:i,value:e,onValueChange:t,placeholder:"Select scorers...",searchPlaceholder:"Search scorers...",emptyText:"No scorers available",disabled:n||a,container:r})]})}const Ies=[{value:"agent",label:"Agent"},{value:"workflow",label:"Workflow"},{value:"scorer",label:"Scorer"}];function Aes({targetType:e,setTargetType:t,targetId:n,setTargetId:r,container:s}){const{data:a,isLoading:i}=km(),{data:l,isLoading:c}=Uy(),{data:u,isLoading:d}=ih(),f=e==="agent"?Object.entries(a??{}).map(([v,y])=>({value:v,label:y.name??v})):e==="workflow"?Object.entries(l??{}).map(([v,y])=>({value:v,label:y.name??v})):e==="scorer"?Object.entries(u??{}).map(([v,y])=>({value:v,label:y.scorer?.config?.name??v})):[],p=e==="agent"&&i||e==="workflow"&&c||e==="scorer"&&d,h=v=>{t(v),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(Jl,{options:Ies,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(Jl,{options:f,value:n,onValueChange:r,placeholder:`Select ${e}`,searchPlaceholder:"Search...",emptyText:"No targets available",disabled:p,container:s})]})]})}function Res({requestContextSchema:e,onChange:t}){const n=g.useMemo(()=>{try{return lm(im(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(a3,{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 Pes({datasetId:e,version:t,requestContextSchema:n,open:r,onOpenChange:s,onSuccess:a}){const i=g.useRef(null),[l,c]=g.useState(""),[u,d]=g.useState(""),[f,p]=g.useState([]),[h,m]=g.useState({}),[v,y]=g.useState(""),{triggerExperiment:b}=Ei(),S=!!(n&&Object.keys(n).length>0),w=l&&u,k=b.isPending,_=()=>{c(""),d(""),p([]),m({}),y("")},C=()=>{if(S){const N=Object.entries(h).filter(([,I])=>I!==void 0&&I!=="");return N.length>0?Object.fromEntries(N):void 0}if(v.trim()){let N;try{N=JSON.parse(v)}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(!w)return;let N;try{N=C()}catch(I){const R=I instanceof Error?I.message:"Request Context must be valid JSON";Ru.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});Ru.success("Experiment triggered successfully"),s(!1),a?.(I.experimentId),_()}catch(I){const R=I instanceof Error?I.message:"Failed to trigger experiment";Ru.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(Rr,{className:"grid gap-6",children:[o.jsx(Aes,{targetType:l,setTargetType:c,targetId:u,setTargetId:d,container:i}),l&&l!=="scorer"&&o.jsx(Nes,{selectedScorers:f,setSelectedScorers:p,disabled:k,container:i}),S?o.jsx(Res,{requestContextSchema:n,onChange:m}):o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{children:"Request Context (JSON, optional)"}),o.jsx(Qr,{value:v,onChange:y,showCopyButton:!1,className:"min-h-[80px]"})]})]}),o.jsxs(Cc,{className:"px-6 pt-4",children:[o.jsx(de,{onClick:j,disabled:k,children:"Cancel"}),o.jsx(de,{variant:"primary",onClick:E,disabled:!w||k,children:k?o.jsxs(o.Fragment,{children:[o.jsx(Gt,{className:"w-4 h-4"}),"Running..."]}):"Run"})]})]})})}const $es=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})},STe=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 Jre(e){try{return JSON.stringify(e??{})}catch{return String(e)}}function Mes({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(zp,{}),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: ",Jre(s.args)]}),n.length>0&&o.jsxs("span",{className:"mt-1 block font-mono text-xs",children:["Unconsumed mocks: ",n.map(i=>Jre(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:Jre(i.args)})]}),o.jsx("span",{className:`shrink-0 text-xs px-2 py-0.5 rounded ${Des(i.outcome)}`,children:i.outcome})]},`${i.outcome}-${i.toolName}-${l}`))})]})}function Des(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 Les({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]=g.useState(!1),m=d??p,v=f??h,y=!!e?.error,b=tF(e?.input),S=tF(e?.output),w=tF(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(Mr,{className:"ml-auto shrink-0",children:[f&&o.jsx(de,{size:"md",tooltip:m?"Expand panel":"Collapse panel",onClick:()=>v(!m),children:m?o.jsx(Plt,{}):o.jsx(Rlt,{})}),o.jsx(bn.NextPrevNav,{onPrevious:n,onNext:r,previousLabel:"Previous result",nextLabel:"Next result"}),o.jsxs(de,{size:"md",onClick:a,disabled:!e.traceId,children:[o.jsx(STe,{}),"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(Bt,{children:[o.jsx(Bt.Key,{children:"Item Id"}),o.jsx(Bt.ValueWithCopyBtn,{copyTooltip:"Copy Item Id to clipboard",copyValue:e.itemId,children:e.itemId}),o.jsx(Bt.Key,{children:"Created"}),o.jsx(Bt.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:tF(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(Mes,{report:e.toolMockReport}),(e.status||_.length>0||k)&&o.jsxs("div",{className:"grid gap-2",children:[o.jsx(bn.SectionHeading,{icon:o.jsx(wN,{}),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(de,{size:"sm",onClick:()=>u(e.id),children:[o.jsx(cq,{}),"Flag for Review"]})}),e.status==="needs-review"&&i&&o.jsx("div",{children:o.jsxs(de,{size:"sm",onClick:i,children:[o.jsx(_a,{}),"Review"]})})]})]}),o.jsxs("div",{className:"grid gap-3",children:[o.jsx(bn.CodeSection,{title:"Input",icon:o.jsx(yN,{}),codeStr:b}),o.jsx(bn.CodeSection,{title:"Output",icon:o.jsx(gg,{}),codeStr:S}),o.jsx(bn.CodeSection,{title:"Ground Truth",icon:o.jsx(ube,{}),codeStr:w})]})]})]})}function tF(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function Fes({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(v=>v.size)].filter(Boolean).join(" "),m=s.some(v=>v.name==="input");return t?o.jsx(tl,{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(v=>o.jsx(me.TopCell,{children:v.label},v.name))}):s.map(v=>o.jsx(me.TopCell,{children:v.label},v.name))]}),e.length===0?o.jsx(me.NoMatch,{message:"No results yet"}):o.jsxs(o.Fragment,{children:[e.map(v=>{const y=!!v.error,b=v.id===n,S=o.jsxs(o.Fragment,{children:[o.jsx(me.IdCell,{id:v.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:Bes(zes(v.input),200)}),i?.map(w=>{const _=a?.[v.itemId]?.find(C=>C.scorerId===w);return o.jsx(me.Cell,{height:"compact",className:"font-mono text-neutral3 text-ui-smd",children:_!=null?_.score.toFixed(3):"-"},w)})]});return p?o.jsxs(me.RowWrapper,{children:[o.jsx(me.SelectCell,{checked:d.has(v.id),onToggle:()=>f(v.id),"aria-label":`Select result ${v.itemId}`}),o.jsx(me.RowButton,{flushLeft:!0,colStart:2,featured:b,onClick:()=>r(v.id),children:S})]},v.id):o.jsx(me.RowButton,{featured:b,onClick:()=>r(v.id),children:S},v.id)}),o.jsx(me.NextPageLoading,{isLoading:c,hasMore:u,setEndOfListElement:l})]})]})}function zes(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function Bes(e,t){return e.length<=t?e:e.slice(0,t-1)+"..."}function Ues(e){const t=e.scorer;return t?.hasJudge===!1?!0:t?.hasJudge===!0?!1:!e.preprocessPrompt&&!e.analyzePrompt&&!e.generateScorePrompt&&!e.generateReasonPrompt}function qes({score:e,onNext:t,onPrevious:n,onClose:r,onShowTrace:s,collapsed:a,onCollapsedChange:i}){const[l,c]=g.useState(!1),u=a??l,d=i??c,f=Ues(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(Mr,{className:"ml-auto shrink-0",children:[i&&o.jsx(de,{size:"md",tooltip:u?"Expand panel":"Collapse panel",onClick:()=>d(!u),children:u?o.jsx(Plt,{}):o.jsx(Rlt,{})}),(n||t)&&o.jsx(bn.NextPrevNav,{onPrevious:n,onNext:t,previousLabel:"Previous score",nextLabel:"Next score"}),s&&o.jsxs(de,{size:"md",onClick:s,disabled:!e.traceId,children:[o.jsx(STe,{}),"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(rm,{}),codeStr:e.reason||p,simplified:!0}),!f&&o.jsxs(o.Fragment,{children:[o.jsx(bn.CodeSection,{title:"Preprocess Prompt",icon:o.jsx(Oh,{}),codeStr:e.preprocessPrompt||p,simplified:!0}),o.jsx(bn.CodeSection,{title:"Analyze Prompt",icon:o.jsx(Oh,{}),codeStr:e.analyzePrompt||p,simplified:!0}),o.jsx(bn.CodeSection,{title:"Generate Score Prompt",icon:o.jsx(Oh,{}),codeStr:e.generateScorePrompt||p,simplified:!0}),o.jsx(bn.CodeSection,{title:"Generate Reason Prompt",icon:o.jsx(Oh,{}),codeStr:e.generateReasonPrompt||p,simplified:!0})]})]})})]})}const RQe=[{name:"scorer",label:"Scorer",size:"1fr"},{name:"avg",label:"Avg Score",size:"1fr"},{name:"count",label:"Items Scored",size:"1fr"}];function Ves({scoresByItemId:e,experimentStatus:t}){const n=g.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(Cr,{iconSlot:o.jsx(rm,{className:"w-8 h-8 text-neutral3"}),titleSlot:a,descriptionSlot:i})})}return o.jsxs(gn,{children:[o.jsxs(gn.Header,{columns:RQe,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:RQe,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 R9t({experimentId:e,datasetId:t,experimentStatus:n,results:r,isLoading:s,setEndOfListElement:a,isFetchingNextPage:i,hasNextPage:l}){const[c,u]=g.useState(null),[d,f]=g.useState(null),[p,h]=g.useState(void 0),[m,v]=g.useState(null),[y,b]=g.useState(new Set),[S,w]=g.useState(!1),[k,_]=g.useState(!1),[C,E]=g.useState(!1),[j,N]=g.useState(!1),{updateExperimentResult:I}=Ei(),R=g.useCallback(se=>{b(re=>{const he=new Set(re);return he.has(se)?he.delete(se):he.add(se),he})},[]),P=g.useCallback(()=>b(new Set),[]),L=g.useCallback(()=>{const se=r.filter(re=>!!re.error).map(re=>re.id);b(new Set(se))},[r]),M=g.useCallback(async se=>{if(S||se.length===0)return;w(!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{w(!1)}he.size>0&&b(xe=>{const je=new Set(xe);for(const Pe of he)je.delete(Pe);return je}),re>0&&De(`${re} result${re>1?"s":""} flagged for review`)},[t,e,S,I]),q=r.find(se=>se.id===c)??null,[H,F]=g.useState("summary"),[z,B]=g.useState(null),D=se=>{F(se),se!=="reviews"&&B(null)},{data:Q}=xTe(t),V=(Q??[]).filter(se=>se.experimentId===e).length,{data:$}=r9t(e,n),U=g.useMemo(()=>{if(!$)return[];const se=new Set;for(const re of Object.values($))for(const he of re)se.add(he.scorerId);return[...se].sort()},[$]),Z=se=>{u(se),f(null),h(void 0),v(null)},X=se=>{Z(se===c?null:se)},te=()=>{Z(null)},J=()=>{if(!q)return;const se=r.findIndex(re=>re.id===q.id);if(se>=0&&se<r.length-1)return()=>Z(r[se+1].id)},ee=()=>{if(!q)return;const se=r.findIndex(re=>re.id===q.id);if(se>0)return()=>Z(r[se-1].id)},ae=q?$?.[q.itemId]:void 0,ce=ae?.find(se=>se.id===m)??null,Y=se=>{v(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()=>v(ae[se+1].id)},ue=()=>{if(!m||!ae)return;const se=ae.findIndex(re=>re.id===m);if(se>0)return()=>v(ae[se-1].id)},{data:pe,isLoading:le}=$es(d),ve=pe?.spans,{data:ye,isLoading:Se}=oI(d,p),Ne=ye?.span,{handlePreviousSpan:ke,handleNextSpan:Ie}=GH(ve,p??null,h),ze=(()=>{const se=[],re=!!ce,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=g.useMemo(()=>[{name:"itemId",label:"Item ID",size:"7rem"},{name:"status",label:"Status",size:"5rem"},{name:"input",label:"Input",size:"minmax(15rem,1fr)"},...U.map(se=>({name:se,label:se,size:"12rem"}))],[U]);return o.jsxs(cu,{defaultTab:"summary",value:H,onValueChange:D,className:"grid grid-rows-[auto_1fr] h-full overflow-hidden",children:[o.jsxs(uu,{children:[o.jsx(qr,{value:"summary",children:"Summary"}),o.jsx(qr,{value:"results",children:"Results"}),o.jsxs(qr,{value:"reviews",children:["Reviews",V>0&&o.jsx(Xs,{color:"orange",children:V})]})]}),o.jsx(fs,{value:"summary",className:"overflow-y-auto mt-5",children:o.jsx(Ves,{scoresByItemId:$,experimentStatus:n})}),o.jsx(fs,{value:"reviews",className:"overflow-auto mt-2 pb-0",children:o.jsx(A9t,{datasetId:t,experimentId:e,featuredItemId:z})}),o.jsxs(fs,{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(de,{variant:"outline",size:"sm",disabled:S,onClick:()=>M([...y]),children:[o.jsx(Ue,{size:"sm",children:o.jsx(cq,{})}),"Flag for Review"]}),o.jsx(de,{variant:"ghost",size:"sm",onClick:P,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(de,{variant:"ghost",size:"sm",onClick:L,children:"Select loaded failures"})})]}),o.jsxs("div",{className:K("grid w-full h-full grid-cols-1 gap-4 overflow-y-auto",q&&"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(Fes,{results:r,isLoading:s,featuredResultId:c,onResultClick:X,columns:oe,scoresByItemId:$,scorerIds:U,setEndOfListElement:a,isFetchingNextPage:i,hasNextPage:l,selectedIds:y,onToggleSelect:R})})}),q&&o.jsxs("div",{className:"grid gap-4 max-h-full min-h-0 overflow-auto content-start",style:{gridTemplateRows:ze},children:[o.jsx(Les,{result:q,scores:ae,onPrevious:ee(),onNext:J(),onClose:te,onScoreClick:Y,featuredScoreId:m,onShowTrace:()=>{q.traceId&&(f(q.traceId),h(void 0),v(null),_(!0),E(!1))},onOpenInReview:()=>{B(q.id),F("reviews")},onFlagForReview:se=>M([se]),collapsed:k,onCollapsedChange:_}),ce&&o.jsx(qes,{score:ce,onNext:ne(),onPrevious:ue(),onClose:()=>v(null),onShowTrace:()=>{ce.traceId&&(f(ce.traceId),h(void 0),_(!0),N(!0),E(!1))},collapsed:j,onCollapsedChange:N}),d&&o.jsxs(o.Fragment,{children:[o.jsx(uTe,{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:BD,traceHref:`/traces/${d}`}),p&&o.jsx(WH,{traceId:d,spanId:p,span:Ne,isLoading:Se,onPrevious:ke,onNext:Ie,onClose:()=>h(void 0)})]})]})]})]})]})}const Hes={pending:o.jsx(dO,{}),running:o.jsx(tfe,{}),completed:o.jsx(Js,{}),failed:o.jsx(vs,{})};function Wes({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:Hes[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 Zes({onPrevious:e,onNext:t,previousAriaLabel:n="Previous",nextAriaLabel:r="Next"}){return o.jsxs(Mr,{spacing:"close",children:[o.jsxs(de,{onClick:e,disabled:!e,"aria-label":n,children:[o.jsx(Gq,{})," Prev"]}),o.jsxs(de,{onClick:t,disabled:!t,"aria-label":r,children:["Next",o.jsx(Wq,{})]})]})}function kTe({delta:e}){const t=e>0?o.jsx(Xs,{size:"small",color:"green",intensity:"muted",children:o.jsx(pD,{})}):e<0?o.jsx(Xs,{size:"small",color:"red",intensity:"muted",children:o.jsx(Cln,{})}):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 nF(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function Ges({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(Zes,{onPrevious:a,onNext:i,previousAriaLabel:"Previous comparison item",nextAriaLabel:"Next comparison item"}),o.jsx(Mr,{children:o.jsx(de,{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(yN,{})," ",e.itemId]})})}),d?o.jsx(o.Fragment,{children:o.jsxs(Uje,{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,v=u?.scores[h]??null,y=m!=null&&v!=null?v-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):"-"," →"," ",v!=null?v.toFixed(3):"-"]}),y!=null&&o.jsx(kTe,{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(gg,{}),codeStr:nF(c?.output)}),o.jsx(Ps.CodeSection,{title:o.jsxs(o.Fragment,{children:[o.jsx(Xs,{color:"cyan",children:"Contender "})," Experiment Output"]}),icon:o.jsx(gg,{}),codeStr:nF(u?.output)}),o.jsx(Ps.CodeSection,{title:"Item Input",icon:o.jsx(fO,{}),codeStr:nF(e.input)}),o.jsx(Ps.CodeSection,{title:"Item Ground Truth",icon:o.jsx(ube,{}),codeStr:nF(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 Qes({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(kTe,{delta:m})]}):o.jsx("span",{className:"text-neutral1",children:"-"})},f)})})]})},l.itemId)})})})]})})}const Yes={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 PQe({datasetId:e,experiment:t,type:n}){const{Link:r}=yn(),{label:s,color:a,customStyle:i}=Yes[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(mm,{})]}),o.jsx(de,{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(Nc,{})," ",s]})]}),o.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-ui-sm text-neutral3",children:[o.jsxs(Al,{children:[o.jsx(ube,{})," ",t.targetType," / ",t.targetId]}),o.jsxs(Al,{children:[o.jsx(fq,{})," v",t.datasetVersion??"—"]}),l&&o.jsxs(Al,{children:[o.jsx(Ilt,{})," ",er(l,"MMM d, yyyy HH:mm")]})]})]})}function Xes({datasetId:e,experimentIdA:t,experimentIdB:n,onSwap:r}){const[s,a]=g.useState(null),{data:i,isLoading:l,error:c}=FKr(e,t,n),{data:u}=zU(e,t),{data:d}=zU(e,n),f=u&&d&&u.datasetVersion!==d.datasetVersion,p=g.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=g.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,P=0,L=0;for(const F of i.items){const z=F.results[E]?.scores[N],B=F.results[j]?.scores[N];z!=null&&(I+=z,P++),B!=null&&(R+=B,L++)}const M=P>0?I/P:null,q=L>0?R/L:null,H=M!=null&&q!=null?q-M:null;return{scorerId:N,avgA:M,avgB:q,delta:H}})},[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"}],v=g.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)},S=()=>{a(null)},w=()=>{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(PQe,{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(de,{onClick:r,children:"VS"})}),o.jsx(Bn,{children:"Switch the order"})]})})}),o.jsx(PQe,{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(MGe,{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(MGe,{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(kTe,{delta:I}):"-"})]},E))})})]}),o.jsxs(sy,{className:K({"grid-cols-[1fr_2fr]":!!y}),children:[o.jsx(Qes,{items:i.items,baselineId:_,contenderId:C,scorerIds:p,featuredItemId:s,columns:v,onItemClick:b}),!!y&&o.jsx(Ges,{item:y,baselineId:_,contenderId:C,baselineVersion:u?.datasetVersion,contenderVersion:d?.datasetVersion,onPrevious:k(),onNext:w(),onClose:S})]})]})}function Kes({datasetId:e,itemId:t,onVersionSelect:n,onCompareVersionsClick:r,activeVersion:s}){const{data:a,isLoading:i}=vTe(e,t),[l,c]=g.useState(!1),[u,d]=g.useState(new Set),f=b=>{n?.(b)},p=b=>s==null?b.isLatest:b.datasetVersion===s,h=b=>{d(S=>{const w=new Set(S);if(w.has(b))w.delete(b);else if(w.size>=2){const[k]=Array.from(w);return new Set([k,b])}else w.add(b);return w})},m=()=>{c(!1),d(new Set)},v=()=>{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(Mr,{children:[o.jsx(de,{onClick:m,children:"Cancel"}),o.jsx(de,{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(de,{onClick:v,className:"w-full",children:[o.jsx(Xw,{})," Compare Ver."]})})}),i?o.jsx(Jes,{}):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 S=String(b.datasetVersion),w=typeof b.updatedAt=="string"?new Date(b.updatedAt):b.updatedAt;return o.jsxs(gn.Row,{isSelected:l&&u.has(S),children:[l&&o.jsx(gn.LabelCell,{children:o.jsx(Mo,{checked:u.has(S),disabled:b.isDeleted,onCheckedChange:()=>{},onClick:k=>{k.stopPropagation(),b.isDeleted||h(S)},"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:w,isLatest:b.isLatest,isDeleted:b.isDeleted})})]},String(b.datasetVersion))})})})]})]})}function Jes(){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 ets(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 tts({datasetId:e,versionA:t,versionB:n,onVersionChange:r}){const{data:s}=nTe(e),a=(s??[]).map(i=>({value:String(i.version),label:`${ets(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(Sc,{label:"Version A",labelIsHidden:!0,name:"version-a",placeholder:"Select version",options:a,value:t??"",onValueChange:i=>r?.(i,n??"")}),o.jsx(Sc,{label:"Version B",labelIsHidden:!0,name:"version-b",options:a,value:n??"",onValueChange:i=>r?.(t??"",i)}),o.jsx("div",{})]})}const nts=[{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"}],rts={added:{color:"blue",borderColor:"border-blue-900",icon:o.jsx(Vr,{}),tooltip:"Added in this version"},changed:{color:"orange",borderColor:"border-yellow-900",icon:o.jsx(Ylt,{}),tooltip:"Changed in this version"},same:{color:"green",borderColor:"border-green-900",icon:o.jsx(Qcn,{}),tooltip:"Same in both versions"}};function ese({red:e=!1,tooltip:t}){return o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx(Mln,{className:K("text-neutral3/40 w-5 h-5 ",{"text-red-900":e})})}),t&&o.jsx(Bn,{children:t})]})}function QS({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}=rts[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 sts(e,t){return e&&t&&e.datasetVersion===t.datasetVersion?"same":e&&t&&e.datasetVersion!==t.datasetVersion?"changed":e?"added":"removed"}function ats({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=sts(u,d);return o.jsxs(gn.Row,{columns:nts,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(QS,{variant:"added",version:u.datasetVersion}):f==="changed"&&l?o.jsx(QS,{variant:"changed",version:u.datasetVersion}):o.jsx(QS,{version:u.datasetVersion})}):o.jsx(gn.Cell,{className:"justify-center flex items-center",children:o.jsx(ese,{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(QS,{variant:"added",version:d.datasetVersion}):f==="changed"&&!l?o.jsx(QS,{variant:"changed",version:d.datasetVersion}):o.jsx(QS,{version:d.datasetVersion})}):o.jsx(gn.Cell,{className:"justify-center flex items-center",children:o.jsx(ese,{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(QS,{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(ese,{tooltip:o.jsxs(o.Fragment,{children:["Comparing is available",o.jsx("br",{})," only for changed items"]})})})]},c)})})})})}const $Qe={needsReview:"#facc15",complete:"#22c55e"},its=[{label:"Needs Review",color:$Qe.needsReview},{label:"Reviewed",color:$Qe.complete}];function ots({reviewSummary:e,experiments:t,datasets:n,isLoading:r,isError:s}){const{data:a,maxVal:i,totalInPipeline:l}=g.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 v=m.needsReview+m.complete;if(v===0)continue;p+=v,v>f&&(f=v);const y=u.get(m.experimentId),b=y?.datasetId?d.get(y.datasetId):void 0,S=b?`${b} · ${m.experimentId.slice(0,8)}`:m.experimentId.slice(0,8);h.push({name:S,values:[m.needsReview,m.complete]})}return{data:h,maxVal:f,totalInPipeline:p}},[e,t,n]),c=a.length>0;return o.jsxs(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.TitleAndDescription,{title:"Review Pipeline",description:"Items in review across experiments."}),c&&o.jsx(Ut.Summary,{value:String(l),label:"Items in pipeline"})]}),r?o.jsx(Ut.Loading,{}):s?o.jsx(Ut.Error,{message:"Failed to load review data"}):o.jsx(Ut.Content,{children:c?o.jsx(uN,{data:a,segments:its,maxVal:i,fmt:u=>String(u)}):o.jsx(Ut.NoData,{message:"No items have been sent to review yet"})})]})}function OTe(){const e=We();return wt({queryKey:["experiment-review-summary"],queryFn:()=>e.getExperimentReviewSummary()})}function P9t(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 lts(e,t){const n=new Map,r=P9t(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 cts(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 uts=10;function dts(){const[e,t]=g.useState(!1),[n,r]=g.useState(""),[s,a]=g.useState("all"),[i,l]=g.useState("all"),[c,u]=g.useState("all"),[d,f]=g.useState(0),{data:p,isLoading:h,error:m}=$g({page:d,perPage:uts}),{data:v,isLoading:y,error:b}=JZ(),{data:S}=OTe(),w=g.useMemo(()=>p?.datasets??[],[p?.datasets]),k=p?.pagination?.hasMore??!1,_=g.useMemo(()=>v?.experiments??[],[v?.experiments]),C=g.useMemo(()=>rJr(w),[w]),E=g.useMemo(()=>lts(S,_),[S,_]),j=h||y,N=m||b,I=()=>t(!0),R=g.useCallback(()=>f(B=>B+1),[]),P=g.useCallback(()=>f(B=>Math.max(0,B-1)),[]),L=g.useCallback(B=>{r(B),f(0)},[]),M=g.useCallback(B=>{a(B),f(0)},[]),q=g.useCallback(B=>{l(B),f(0)},[]),H=g.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(zi,{title:"Failed to load datasets",message:N.message})});if(w.length===0&&!j&&d===0)return o.jsxs(o.Fragment,{children:[o.jsx(lr,{children:o.jsx(lJr,{onCreateClick:I})}),o.jsx(Fve,{open:e,onOpenChange:t})]});const F=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(dJr,{search:n,onSearchChange:L,targetFilter:s,onTargetFilterChange:M,experimentFilter:i,onExperimentFilterChange:q,tagFilter:c,onTagFilterChange:H,tagOptions:C,onReset:z,hasActiveFilters:F,onCreateClick:I})}),o.jsx(oJr,{datasets:w,experiments:_,reviewByDataset:E,isLoading:j,search:n,targetFilter:s,experimentFilter:i,tagFilter:c,currentPage:d,hasMore:k,onNextPage:R,onPrevPage:P}),o.jsx(Fve,{open:e,onOpenChange:t})]})}function rF({children:e}){return o.jsxs(Lt,{height:"full",children:[o.jsx("div",{}),o.jsx(Lt.MainArea,{isCentered:!0,children:e})]})}function fts(){const{datasetId:e}=ur(),t=bs(),[n,r]=ga(),{activeVersion:s}=yTe(n,r),[a,i]=g.useState(!1),[l,c]=g.useState(!1),[u,d]=g.useState(!1),[f,p]=g.useState(!1),[h,m]=g.useState(!1),{data:v,error:y,isLoading:b}=Hx(e),{data:S=[],isLoading:w}=E1(e,void 0,s),k=!w&&S.length===0;if(b)return null;if(y&&gs(y))return o.jsx(rF,{children:o.jsx(Vs,{})});if(y&&ys(y))return o.jsx(rF,{children:o.jsx(Ds,{resource:"datasets"})});if(y&&vOe(y)||!b&&!y&&!v)return o.jsx(rF,{children:o.jsx(Cr,{iconSlot:o.jsx(iy,{}),titleSlot:"Dataset not found",descriptionSlot:`No dataset with id "${e}".`,actionSlot:o.jsxs(de,{as:Ba,to:"/datasets",children:[o.jsx(Nc,{}),"Back to Datasets"]})})});if(y)return o.jsx(rF,{children:o.jsx(zi,{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:[v?.description&&o.jsx("p",{className:"text-ui-smd text-neutral3 mb-1",children:v.description}),o.jsxs(Bt,{numOfCol:2,children:[o.jsx(Bt.Key,{children:"Created at"}),o.jsx(Bt.Value,{children:v?.createdAt?er(new Date(v.createdAt),"MMM d, yyyy"):""}),o.jsx(Bt.Key,{children:"Latest version"}),o.jsxs(Bt.Value,{children:["v",v?.version??""]})]})]}),o.jsx(Lt.Column,{children:o.jsxs(Mr,{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(de,{variant:"primary",children:[o.jsx(Fp,{}),s!=null?`Run on v${s}`:"Run Experiment"]})})})}),o.jsx(Bn,{children:"Add items to the dataset before running an experiment"})]}):o.jsxs(de,{variant:"primary",onClick:()=>i(!0),children:[o.jsx(Fp,{}),s!=null?`Run on v${s}`:"Run Experiment"]}),o.jsxs(pt,{children:[o.jsx(pt.Trigger,{asChild:!0,children:o.jsx(de,{size:"lg","aria-label":"Dataset actions menu",children:o.jsx(mD,{})})}),o.jsxs(pt.Content,{align:"end",className:"w-48",children:[o.jsxs(pt.Item,{onSelect:()=>d(!0),children:[o.jsx(Lp,{})," Edit Dataset"]}),o.jsxs(pt.Item,{onSelect:()=>m(!0),children:[o.jsx(Dp,{})," Duplicate Dataset"]}),o.jsxs(pt.Item,{onSelect:()=>p(!0),className:"text-red-500 focus:text-red-400",children:[o.jsx(au,{})," Delete Dataset"]})]})]})]})})]})}),o.jsx(Lt.MainArea,{children:o.jsx(Ces,{datasetId:e,onAddItemClick:()=>c(!0)})})]}),o.jsx(Pes,{datasetId:e,version:s??void 0,requestContextSchema:v?.requestContextSchema,open:a,onOpenChange:i,onSuccess:_}),o.jsx(jes,{datasetId:e,open:l,onOpenChange:c}),v&&o.jsx(vJr,{open:u,onOpenChange:d,dataset:{id:v.id,name:v.name,description:v?.description||"",targetType:v.targetType,inputSchema:v.inputSchema,groundTruthSchema:v.groundTruthSchema,requestContextSchema:v.requestContextSchema}}),v&&o.jsx(hJr,{open:h,onOpenChange:m,sourceDatasetId:v.id,sourceDatasetName:v.name,sourceDatasetDescription:v.description,sourceDatasetTargetType:v.targetType}),v&&o.jsx(bJr,{open:f,onOpenChange:p,datasetId:v.id,datasetName:v.name,onSuccess:C})]})}function $9t({experiment:e}){const{Link:t,paths:n}=yn(),{data:r}=km(),{data:s}=Uy(),{data:a}=ih(),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(Bt,{numOfCol:2,children:[o.jsx(Bt.Key,{children:"Created at"}),o.jsx(Bt.Value,{children:er(new Date(e.createdAt),"MMM d, yyyy 'at' h:mm a")}),e.completedAt&&o.jsxs(o.Fragment,{children:[o.jsx(Bt.Key,{children:"Completed at"}),o.jsx(Bt.Value,{children:er(new Date(e.completedAt),"MMM d, yyyy 'at' h:mm a")})]}),o.jsx(Bt.Key,{children:"Target"}),o.jsx(Bt.ValueLink,{href:i(),as:t,children:l()}),e.agentVersion&&o.jsxs(o.Fragment,{children:[o.jsx(Bt.Key,{children:"Version"}),c?o.jsx(Bt.ValueLink,{href:c,as:t,children:e.agentVersion}):o.jsx(Bt.Value,{children:e.agentVersion})]})]})}),o.jsx(Lt.Column,{children:o.jsx(Wes,{experiment:e})})]})})}function sF({children:e}){return o.jsxs(Lt,{height:"full",children:[o.jsx("div",{}),o.jsx(Lt.MainArea,{isCentered:!0,children:e})]})}function pts(){const{datasetId:e,experimentId:t}=ur(),{data:n,isLoading:r,error:s}=zU(e,t),{data:a,isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u}=YZ({datasetId:e,experimentId:t,experimentStatus:n?.status});return!e||!t||r?null:s&&gs(s)?o.jsx(sF,{children:o.jsx(Vs,{})}):s&&ys(s)?o.jsx(sF,{children:o.jsx(Ds,{resource:"datasets"})}):s&&vOe(s)||!r&&!s&&!n?o.jsx(sF,{children:o.jsx(Cr,{iconSlot:o.jsx(tbe,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${t}".`,actionSlot:o.jsxs(de,{as:Ba,to:`/datasets/${e}?tab=experiments`,children:[o.jsx(Nc,{}),"Back to Dataset"]})})}):s?o.jsx(sF,{children:o.jsx(zi,{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($9t,{experiment:n}),o.jsx(Lt.MainArea,{children:o.jsx(R9t,{experimentId:t,datasetId:e,experimentStatus:n.status,results:a??[],isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u})})]})}function hts(){const{datasetId:e}=ur(),[t,n]=ga(),{error:r}=Hx(e??""),s=t.get("baseline")??"",a=t.get("contender")??"";return r&&gs(r)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):r&&ys(r)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ds,{resource:"datasets"})})}):!e||!s||!a?o.jsx(ls,{children:o.jsx(wy,{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(ls,{children:o.jsx(wy,{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(Xw,{})," Dataset Experiments Comparison"]}),o.jsxs(ua.Description,{children:["Comparing"," ",o.jsx(Ba,{to:`/datasets/${e}/experiments/${s}`,children:s.slice(0,8)})," vs"," ",o.jsx(Ba,{to:`/datasets/${e}/experiments/${a}`,children:a.slice(0,8)})]})]}),o.jsx(ua.Column,{children:o.jsxs(de,{as:Ba,to:`/datasets/${e}`,children:[o.jsx(Nc,{}),"Back to Dataset"]})})]}),o.jsx(Xes,{datasetId:e,experimentIdA:s,experimentIdB:a,onSwap:()=>{n({baseline:a,contender:s})}})]})})})}function mts(){const{datasetId:e,itemId:t}=ur(),{Link:n}=yn(),r=bs(),{data:s,isLoading:a,error:i}=vTe(e??"",t??""),{updateItem:l,deleteItem:c}=Ei(),{data:u}=Hx(e??""),d=s?.[0]??null,f=d?.isDeleted??!1,[p,h]=g.useState(null),m=g.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]),v=d?.datasetVersion??0,[y,b]=g.useState(!1),[S,w]=g.useState(m.input),[k,_]=g.useState(m.groundTruth),[C,E]=g.useState(m.metadata),[j,N]=g.useState(m.trajectory),[I,R]=g.useState(m.toolMocks),[P,L]=g.useState(m.requestContext),[M,q]=g.useState(v);v!==M&&(q(v),w(m.input),_(m.groundTruth),E(m.metadata),N(m.trajectory),R(m.toolMocks),L(m.requestContext));const[H,F]=g.useState(!1),z=J=>{h(f?J:J.isLatest?null:J)},B=()=>{h(null)},D=!f&&p!=null,Q=()=>{D||b(!0)},V=()=>{D||F(!0)},$=async()=>{if(!e||!t)return;let J;try{J=JSON.parse(S)}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 ce;const Y=j!==m.trajectory;if(Y&&j.trim())try{ce=JSON.parse(j)}catch{De.error("Expected Trajectory must be valid JSON");return}let ne;const ue=I!==m.toolMocks;if(ue&&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=P!==m.requestContext;if(le&&P.trim())try{pe=JSON.parse(P)}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:ce??null}:{},...ue?{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"}`)}},U=()=>{d&&(w(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):""),L(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"),F(!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(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):i&&ys(i)?o.jsx(ls,{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(ls,{children:o.jsx(wy,{children:o.jsx("div",{className:"text-neutral3 p-4",children:"Item not found"})})}):o.jsxs(o.Fragment,{children:[o.jsx(ls,{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(yN,{}),t," ",o.jsx(Oa,{content:t})]}),o.jsx(ua.Description,{children:o.jsxs(Al,{children:["Item of ",o.jsx(iy,{})," ",u?.name]})}),o.jsxs(ua.Description,{children:[o.jsxs(Al,{children:[o.jsx(Nlt,{})," Created at"," ",d?.createdAt?er(new Date(d.createdAt),"MMM d, yyyy"):""]}),o.jsxs(Al,{children:[o.jsx(p_,{})," Latest version v",d?.datasetVersion??""]})]})]}),o.jsx(ua.Column,{children:!y&&!f&&o.jsxs(Mr,{children:[o.jsxs(de,{onClick:Q,disabled:D,title:D?"Return to latest version to edit":void 0,children:[o.jsx(Ylt,{})," Edit"]}),o.jsxs(de,{onClick:V,disabled:D,title:D?"Return to latest version to delete":void 0,children:[o.jsx(au,{})," Delete"]})]})})]}),o.jsxs(sy,{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&&D&&p&&o.jsx(In,{variant:"warning",title:"Previous version",action:o.jsxs(In.Button,{onClick:B,children:[o.jsx(_lt,{})," Return to the latest version"]}),children:o.jsxs(In.Message,{children:["Viewing version v",p.datasetVersion]})}),y?o.jsx(N9t,{inputValue:S,setInputValue:w,groundTruthValue:k,setGroundTruthValue:_,metadataValue:C,setMetadataValue:E,trajectoryValue:j,setTrajectoryValue:N,toolMocksValue:I,setToolMocksValue:R,requestContextValue:P,setRequestContextValue:L,validationErrors:null,onSave:$,onCancel:U,isSaving:l.isPending}):te?o.jsx(wTe,{item:te,Link:n}):o.jsx("div",{className:"text-neutral4 text-sm",children:"Item data not available"})]}),!y&&o.jsx(Gr,{children:o.jsx(Kes,{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:H,onOpenChange:F,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 MQe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function gts(){const{datasetId:e}=ur(),[t,n]=ga(),r=t.get("items")?.split(",").filter(Boolean)??[],{data:s,error:a}=Hx(e??""),{Link:i}=yn(),[l,c]=g.useState(!1),{data:u}=BU(e??"",r[0]??""),{data:d}=BU(e??"",r[1]??"");return a&&gs(a)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):a&&ys(a)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ds,{resource:"datasets"})})}):!e||r.length<2?o.jsx(ls,{children:o.jsx(wy,{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(ls,{children:[o.jsx(Iy,{owner:"dataset-items-compare",children:o.jsxs(de,{as:Ba,to:`/datasets/${e}`,variant:"outline",children:[o.jsx(Nc,{}),"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(Xw,{}),"Compare Dataset Items"]}),o.jsx(ua.Description,{children:o.jsxs(Al,{children:["Comparing ",r.length," items of"," ",o.jsx(Ba,{to:`/datasets/${e}`,className:"text-info1 hover:underline",children:s?.name||e?.slice(0,8)})]})})]}),o.jsx(ua.Column,{children:o.jsx(Mr,{children:o.jsx(de,{variant:"primary",onClick:()=>c(f=>!f),children:l?o.jsxs(o.Fragment,{children:[o.jsx(Dlt,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx(Bcn,{})," Diff View"]})})})})]}),o.jsx(sy,{className:"grid-cols-[1fr_3vw_1fr]",children:r.map((f,p)=>o.jsxs(g.Fragment,{children:[o.jsx(vts,{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($_e,{codeA:MQe(u),codeB:MQe(d)})]})})]})}function vts({datasetId:e,itemId:t,Link:n,idx:r,itemIds:s,onItemChange:a,showContent:i=!0}){const{data:l,isLoading:c}=BU(e,t),{data:u}=E1(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(da,{name:`compare-item-${r}`,value:t,onValueChange:a,children:[o.jsx(pa,{"aria-label":"Item",children:o.jsx(fa,{placeholder:"Select item"})}),o.jsx(ha,{children:f.map(p=>o.jsx(Lr,{value:p.value,disabled:p.disabled,children:p.label},p.value))})]}),o.jsxs(de,{as:n,to:`/datasets/${e}/items/${t}`,children:[o.jsx(p_,{}),"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(Tes,{item:l}),o.jsx(wTe,{item:l,Link:n})]}):o.jsxs("div",{className:"text-neutral4 text-sm",children:["Item ",t.slice(0,8)," not found"]})})]})}function DQe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function yts(){const{datasetId:e,itemId:t}=ur(),[n,r]=ga(),[s,a]=g.useState(!1),i=n.get("ids")?.split(",").map(Number).filter(h=>!isNaN(h)&&h>0)??[],{data:l,error:c}=Hx(e??""),{Link:u}=yn(),{data:d}=vTe(e??"",t??""),{data:f}=Bve(e??"",t??"",i[0]??0,l?.version),{data:p}=Bve(e??"",t??"",i[1]??0,l?.version);return c&&gs(c)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):c&&ys(c)?o.jsx(ls,{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(ls,{children:o.jsx(wy,{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(ls,{children:[o.jsx(Iy,{owner:"dataset-item-versions-compare",children:o.jsxs(de,{as:Ba,to:`/datasets/${e}/items/${t}`,variant:"outline",children:[o.jsx(Nc,{}),"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(Xw,{}),"Compare Dataset Item Versions"]}),o.jsx(ua.Description,{children:o.jsxs(Al,{children:["Comparing ",i.length," versions of"," ",o.jsx(Ba,{to:`/datasets/${e}/items/${t}`,className:"text-info1 hover:underline",children:t})]})})]}),o.jsx(ua.Column,{children:o.jsx(Mr,{children:o.jsx(de,{variant:"primary",onClick:()=>a(h=>!h),children:s?o.jsxs(o.Fragment,{children:[o.jsx(Dlt,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx(Cun,{})," Diff View"]})})})})]}),o.jsx(sy,{className:"grid-cols-[1fr_3vw_1fr]",children:i.map((h,m)=>o.jsxs(g.Fragment,{children:[o.jsx(bts,{datasetId:e,itemId:t,datasetVersion:h,latestVersion:l?.version,allVersions:d??[],versionNumbers:i,Link:u,idx:m,showContent:!s,onVersionChange:v=>{const y=[...i];y[m]=v,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($_e,{codeA:DQe(f),codeB:DQe(p)})]})})]})}function bts({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}=Bve(e,t,n,r),p=new Set(a.filter((v,y)=>y!==l)),h=s.map(v=>{const y=typeof v.updatedAt=="string"?new Date(v.updatedAt):v.updatedAt;return{value:String(v.datasetVersion),label:o.jsxs(o.Fragment,{children:[o.jsxs("b",{children:["v. ",v.datasetVersion]})," - ",er(y,"MMM d, yyyy h:mm a"),v.isLatest?o.jsx(Xs,{color:"blue",size:"small",children:"Latest"}):null]}),disabled:p.has(v.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(p_,{className:"w-6 h-6 opacity-50"}),o.jsxs(da,{name:`compare-version-${l}`,value:String(n),onValueChange:v=>u(Number(v)),children:[o.jsx(pa,{"aria-label":"Version",className:"w-full",children:o.jsx(fa,{placeholder:"Select version"})}),o.jsx(ha,{children:h.map(v=>o.jsx(Lr,{value:v.value,disabled:v.disabled,children:v.label},v.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(wTe,{item:m,Link:i})})]})}function xts(){const{datasetId:e}=ur(),[t]=ga(),n=t.get("ids")?.split(",").map(Number).filter(v=>!isNaN(v)&&v>0)??[],r=bs(),{data:s,error:a}=Hx(e??""),i=E1(e??"",void 0,n[0]??null),l=E1(e??"",void 0,n[1]??null),c=g.useMemo(()=>i.data??[],[i.data]),u=g.useMemo(()=>l.data??[],[l.data]),d=g.useMemo(()=>{const v=new Map;for(const y of[...c,...u])v.has(y.id)||v.set(y.id,{id:y.id,createdAt:new Date(y.createdAt)});return[...v.values()].sort((y,b)=>b.createdAt.getTime()-y.createdAt.getTime())},[c,u]),f=g.useMemo(()=>new Map(c.map(v=>[v.id,v])),[c]),p=g.useMemo(()=>new Map(u.map(v=>[v.id,v])),[u]);if(a&&gs(a))return o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})});if(a&&ys(a))return o.jsx(ls,{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(ls,{children:o.jsx(wy,{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=(v,y,b)=>{r(`/datasets/${e}/items/${v}/versions?ids=${y?.datasetVersion??""},${b?.datasetVersion??""}`)},m=(v,y)=>{r(`/datasets/${e}/versions?ids=${v},${y}`,{replace:!0})};return o.jsx(ls,{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(lfn,{})," Compare Dataset Versions"]}),o.jsx(ua.Description,{children:o.jsxs(Al,{children:[o.jsx(p_,{})," Comparing ",n.length," versions of"," ",s?.name||e?.slice(0,8)]})})]}),o.jsx(ua.Column,{children:o.jsxs(de,{as:Ba,to:`/datasets/${e}`,children:[o.jsx(Nc,{}),"Back to Dataset"]})})]}),o.jsx(sy,{children:o.jsxs(Gr,{children:[o.jsx(tts,{datasetId:e,versionA:String(n[0]),versionB:String(n[1]),onVersionChange:m}),o.jsx(ats,{datasetId:e,versionA:n[0],versionB:n[1],allItems:d,itemsAMap:f,itemsBMap:p,onItemClick:h})]})})]})})})}function qve({children:e,className:t}){return o.jsx("div",{className:K("flex flex-wrap gap-8",t),children:e})}function wts(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 Sts({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,v=wts(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)}),v?o.jsx(Kr.Change,{changePct:v.changePct,prevValue:v.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 LQe="auto 1fr auto auto auto auto auto auto auto";function kts(e){return e?(typeof e=="string"?new Date(e):e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}const Ots={completed:"success",running:"warning",failed:"error",pending:"neutral"};function _ts({experiments:e,datasets:t,reviewByExperiment:n,isLoading:r,search:s="",statusFilter:a="all",datasetFilter:i="all"}){const{paths:l,Link:c}=yn(),u=g.useMemo(()=>{const p=new Map;return t?.forEach(h=>p.set(h.id,h.name)),p},[t]),d=g.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=g.useMemo(()=>{const p=s.toLowerCase();return d.filter(h=>{const m=h.datasetId?u.get(h.datasetId)??"":"",v=!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 v&&y&&b})},[d,s,u,a,i]);return r?o.jsx(tl,{columns:LQe}):o.jsxs(me,{columns:LQe,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",v=p.succeededCount??0,y=p.failedCount??0,b=p.totalItems??0,S=b>0?Math.round(v/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(pg,{variant:Ots[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:v>0?"text-accent1":"",children:[v," (",S,"%)"]})}),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 w=n?.get(p.id);if(!w)return o.jsx("span",{className:"text-neutral2",children:"—"});const k=w.needsReview+w.complete;return k===0?o.jsx("span",{className:"text-neutral2",children:"—"}):w.needsReview>0?o.jsxs(Xs,{size:"small",color:"yellow",children:[w.needsReview," pending"]}):o.jsxs(Xs,{size:"small",color:"green",children:[w.complete,"/",k," reviewed"]})})()}),o.jsx(me.TextCell,{children:kts(p.createdAt)})]},p.id)})]})}const Cts=[{value:"all",label:"All statuses"},{value:"completed",label:"Completed"},{value:"running",label:"Running"},{value:"failed",label:"Failed"},{value:"pending",label:"Pending"}];function Ets(e){return[{value:"all",label:"All datasets"},...(e??[]).map(t=>({value:t.id,label:t.name}))]}const aF={completed:"#22c55e",running:"#facc15",pending:"#fb923c",failed:"#f87171"},jts=[{label:"Completed",color:aF.completed},{label:"Running",color:aF.running},{label:"Pending",color:aF.pending},{label:"Failed",color:aF.failed}];function Tts({experiments:e,datasets:t,isLoading:n,isError:r}){const{data:s,maxVal:a}=g.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(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.TitleAndDescription,{title:"Experiments by Dataset",description:"Experiment status breakdown per dataset."}),i&&o.jsx(Ut.Summary,{value:String(e?.length??0),label:"Total experiments"})]}),n?o.jsx(Ut.Loading,{}):r?o.jsx(Ut.Error,{message:"Failed to load experiments data"}):o.jsx(Ut.Content,{children:i?o.jsx(uN,{data:s,segments:jts,maxVal:a,fmt:l=>String(l)}):o.jsx(Ut.NoData,{message:"No experiments have been run yet"})})]})}const Nts=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Cr,{iconSlot:o.jsx(Of,{}),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(de,{variant:"ghost",as:"a",href:"https://mastra.ai/en/docs/evals/datasets/running-experiments",target:"_blank",rel:"noopener noreferrer",children:["Experiments Documentation ",o.jsx(_a,{})]})})})});function Its({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(jf,{label:"Search experiments",placeholder:"Filter by experiment, dataset, or target",value:e,onSearch:t}),o.jsxs(Mr,{children:[o.jsx(Sc,{label:"Status",labelIsHidden:!0,name:"filter-status",options:[...Cts],value:n,onValueChange:r,className:"whitespace-nowrap"}),o.jsx(Sc,{label:"Dataset",labelIsHidden:!0,name:"filter-dataset",options:i,value:s,onValueChange:a,className:"whitespace-nowrap"}),l&&c&&o.jsxs(de,{onClick:l,size:"sm",variant:"default",children:[o.jsx(vs,{className:"size-3"})," Reset"]})]})]})}function Ats(){const{data:e,isLoading:t,error:n}=ih(),{data:r,isLoading:s,error:a}=$g(),{data:i,isLoading:l,error:c}=JZ(),{data:u,isLoading:d,isError:f,error:p}=UWr(),{data:h,isLoading:m,isError:v,error:y}=OTe(),b=r?.datasets,S=i?.experiments,w=g.useMemo(()=>cts(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(zi,{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(qve,{children:o.jsx(Sts,{scorers:e,datasets:b,experiments:S,avgScore:u?.avgScore??null,prevAvgScore:u?.prevAvgScore??null,totalNeedsReview:w.needsReview,isLoadingScorers:t,isLoadingDatasets:s,isLoadingExperiments:l,isLoadingScores:d,isLoadingReview:m})}),o.jsx(eWr,{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(uJr,{experiments:S,isLoading:l,isError:!!c}),o.jsx(Tts,{experiments:S,datasets:b,isLoading:l,isError:!!c})]}),o.jsx(ots,{reviewSummary:h,experiments:S,datasets:b,isLoading:m,isError:!!v})]})})}function Rts(){const[e,t]=g.useState(""),[n,r]=g.useState("all"),[s,a]=g.useState("all"),{data:i,isLoading:l,error:c}=$g(),{data:u,isLoading:d,error:f}=JZ(),{data:p}=OTe(),h=g.useMemo(()=>i?.datasets??[],[i?.datasets]),m=g.useMemo(()=>u?.experiments??[],[u?.experiments]),v=g.useMemo(()=>Ets(h),[h]),y=g.useMemo(()=>P9t(p),[p]),b=l||d,S=f||c;if(S&&gs(S))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(S)return o.jsx(lr,{children:o.jsx(zi,{title:"Failed to load experiments",message:S.message})});if(m.length===0&&!b)return o.jsx(lr,{children:o.jsx(Nts,{})});const w=n!=="all"||s!=="all"||e!=="",k=()=>{t(""),r("all"),a("all")};return o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx(Its,{search:e,onSearchChange:t,statusFilter:n,onStatusFilterChange:r,datasetFilter:s,onDatasetFilterChange:a,datasetOptions:v,onReset:k,hasActiveFilters:w})}),o.jsx(_ts,{experiments:m,datasets:h,reviewByExperiment:y,isLoading:b,search:e,statusFilter:n,datasetFilter:s})]})}function iF({children:e}){return o.jsxs(Lt,{height:"full",children:[o.jsx("div",{}),o.jsx(Lt.MainArea,{isCentered:!0,children:e})]})}function Pts(){const{experimentId:e}=ur(),{data:t,isLoading:n}=JZ(),s=t?.experiments?.find(h=>h.id===e)?.datasetId??"",{data:a,isLoading:i,error:l}=zU(s,e??""),{data:c,isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p}=YZ({datasetId:s,experimentId:e??"",experimentStatus:a?.status});return!e||n||i?null:l&&gs(l)?o.jsx(iF,{children:o.jsx(Vs,{})}):l&&ys(l)?o.jsx(iF,{children:o.jsx(Ds,{resource:"datasets"})}):l&&vOe(l)||!n&&!s||!i&&!l&&!a?o.jsx(iF,{children:o.jsx(Cr,{iconSlot:o.jsx(tbe,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${e}".`,actionSlot:o.jsxs(de,{as:Ba,to:"/experiments",children:[o.jsx(Nc,{}),"Back to Experiments"]})})}):l?o.jsx(iF,{children:o.jsx(zi,{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($9t,{experiment:a}),o.jsx(Lt.MainArea,{children:o.jsx(R9t,{experimentId:e,datasetId:s,experimentStatus:a.status,results:c??[],isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p})})]})}function $ts({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 M9t({connections:e,isAdmin:t,disconnectPending:n,onDisconnect:r}){return o.jsx("ul",{className:"space-y-1",children:e.map(s=>o.jsx($ts,{connection:s,isAdmin:t,disconnectPending:n,onDisconnect:()=>r(s.connectionId)},s.connectionId))})}function Mts({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(M9t,{connections:a,isAdmin:t,disconnectPending:n,onDisconnect:r})]},s))})}function Dts({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(Mts,{groups:r,isAdmin:s,disconnectPending:l,onDisconnect:u}):o.jsx(M9t,{connections:n,isAdmin:s,disconnectPending:l,onDisconnect:u}),c?o.jsx("p",{className:"text-red-600",children:String(c)}):null]})}function Lts({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:v}){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:v,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 FQe=e=>e.authorId?.trim()||"shared",Fts=(e,t)=>{if(!t||new Set(e.map(FQe)).size<=1)return null;const r=new Map;for(const a of e){const i=FQe(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},zts=["*","tool-providers:*","tool-providers:admin"];function Bts(){const{data:e}=Sm();return e?.permissions?.some(t=>zts.includes(t))??!1}function Uts(){const[e,t]=g.useState(""),[n,r]=g.useState(""),[s,a]=g.useState(""),i=dI(),l=cW(e||null),c=XIt(e||null,n||null),u=YIt(),d=ZIt(),f=Bts(),p=i.data?.providers??[],h=l.data?.data??[],m=g.useMemo(()=>c.data?.items??[],[c.data?.items]),v=g.useMemo(()=>Fts(m,f),[m,f]),y=w=>{t(w),r("")},b=()=>{!e||!n||u.mutate({providerId:e,toolkit:n,label:s.trim()||null},{onSuccess:()=>{a(""),c.refetch()}})},S=w=>{d.mutate({providerId:e,connectionId:w})};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(Lts,{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(Dts,{providerId:e,toolkit:n,connections:m,groupedByAuthor:v,isAdmin:f,isLoading:c.isLoading,error:c.error,disconnectPending:d.isPending,disconnectError:d.error,onDisconnect:S})]})}function qts({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(Qh,{className:"h-10 w-10"}),o.jsx("h1",{className:"text-xl font-semibold text-neutral6",children:e})]}),t,n,r]})})}function D9t({redirectUri:e,onSuccess:t,initialMode:n="signin",errorMessage:r}){const{data:s,isLoading:a}=ac(),{mutate:i,isPending:l,error:c}=u1r(),{mutate:u,isPending:d,error:f}=f1r(),{mutate:p,isPending:h}=xNt(),[m,v]=g.useState(n),[y,b]=g.useState(""),[S,w]=g.useState(""),[k,_]=g.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,P=R?l:d,L=R?c:f,M=()=>{t?t():e?window.location.href=e:window.location.href="/"},q=D=>{D.preventDefault(),R?i({email:S,password:k},{onSuccess:M}):u({email:S,password:k,name:y||void 0},{onSuccess:M})},H=()=>{p({redirectUri:e},{onSuccess:D=>{window.location.href=D.url}})},F=()=>{v(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(yf,{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(qts,{title:R?"Sign in to Mastra Studio":"Create your account",description:z,errorBanner:B,children:[j&&o.jsxs("form",{onSubmit:q,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:D=>b(D.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:S,onChange:D=>w(D.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:D=>_(D.target.value),placeholder:R?"Enter your password":"Create a password",required:!0,variant:"default",size:"lg"})]}),L&&o.jsx("div",{className:"rounded-md bg-red-500/10 p-3 text-sm text-red-400",children:L.message}),o.jsx(de,{type:"submit",disabled:P,className:"w-full",size:"lg",children:P?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:F,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(de,{onClick:H,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 Vts(){const[e]=ga(),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(D9t,{redirectUri:n,onSuccess:i,initialMode:s,errorMessage:a})}const Kf=Mi.KeyValueList;function Hts(e){return e instanceof Date?e:new Date(e)}function Wts({log:e,onClose:t,onTraceClick:n,onSpanClick:r,onPrevious:s,onNext:a,collapsed:i,onCollapsedChange:l}){const[c,u]=g.useState(!1),d=i??c,f=l??u,p=Hts(e.timestamp),h=e.traceId,m=e.spanId;return o.jsxs(Mi,{collapsed:d,children:[o.jsxs(Mi.Header,{children:[o.jsxs(Mi.Heading,{children:["Log ",o.jsx("b",{children:er(p,"MMM dd, HH:mm:ss.SSS")})]}),o.jsxs(Mr,{className:"ml-auto shrink-0",children:[l&&o.jsx(de,{size:"md",tooltip:d?"Expand panel":"Collapse panel",onClick:()=>f(!d),children:d?o.jsx(Qq,{}):o.jsx(Mxe,{})}),o.jsxs(Mr,{spacing:"close",children:[o.jsx(de,{size:"md",tooltip:"Previous log",onClick:s,disabled:!s,children:o.jsx(Gq,{})}),o.jsx(de,{size:"md",tooltip:"Next log",onClick:a,disabled:!a,children:o.jsx(Wq,{})})]}),o.jsx(Mi.CloseButton,{onClick:t})]})]}),!d&&o.jsxs(Mi.Content,{children:[o.jsx("p",{className:"text-ui-md text-neutral4 font-mono wrap-break-word whitespace-pre-wrap",children:e.message}),(h||m)&&o.jsxs("div",{className:K("grid gap-2 my-8","[&>button]:justify-between [&>button]:overflow-hidden"),children:[h&&o.jsxs(Mr,{spacing:"close",className:"min-w-0 w-full",children:[o.jsxs(de,{size:"md",className:"min-w-0 flex-1 overflow-hidden",onClick:()=>n?.(h),children:[o.jsx($z,{}),o.jsx("span",{children:"Trace"}),o.jsxs("span",{className:" ml-auto text-ui-sm text-neutral2 min-w-0 truncate",children:["# ",h]})]}),o.jsx(Oa,{content:h,size:"md",tooltip:"Copy Trace ID to clipboard"})]}),m&&o.jsxs(Mr,{spacing:"close",className:"min-w-0 w-full",children:[o.jsxs(de,{size:"md",className:"min-w-0 flex-1 overflow-hidden",disabled:!h||!r,onClick:()=>h&&r?.(h,m),children:[o.jsx($z,{}),o.jsx("span",{children:"Span"}),o.jsxs("span",{className:" ml-auto text-ui-sm text-neutral2 min-w-0 truncate",children:["# ",m]})]}),o.jsx(Oa,{content:m,size:"md",tooltip:"Copy Span ID to clipboard"})]})]}),o.jsxs(Kf,{className:"mb-6",children:[e.entityType&&o.jsxs(o.Fragment,{children:[o.jsx(Kf.Key,{children:"Entity Type"}),o.jsx(Kf.Value,{children:e.entityType})]}),e.entityName&&o.jsxs(o.Fragment,{children:[o.jsx(Kf.Key,{children:"Entity Name"}),o.jsx(Kf.Value,{children:e.entityName})]}),e.serviceName&&o.jsxs(o.Fragment,{children:[o.jsx(Kf.Key,{children:"Service"}),o.jsx(Kf.Value,{children:e.serviceName})]}),e.environment&&o.jsxs(o.Fragment,{children:[o.jsx(Kf.Key,{children:"Environment"}),o.jsx(Kf.Value,{children:e.environment})]}),e.source&&o.jsxs(o.Fragment,{children:[o.jsx(Kf.Key,{children:"Source"}),o.jsx(Kf.Value,{children:e.source})]}),e.metadata&&Object.keys(e.metadata).length>0&&o.jsx(o.Fragment,{children:Object.entries(e.metadata).map(([v,y])=>o.jsxs(g.Fragment,{children:[o.jsx(Kf.Key,{children:v}),o.jsx(Kf.Value,{children:String(y)})]},v))})]}),e.data&&Object.keys(e.data).length>0&&o.jsx(Mi.CodeSection,{title:"Data",codeStr:JSON.stringify(e.data,null,2),className:"mt-6"})]})]})}function Zts({error:e,resource:t,errorTitle:n}){if(gs(e))return o.jsx(Vs,{});if(ys(e))return o.jsx(Ds,{resource:t});if(hTt(e,"logs"))return o.jsx(Cr,{iconSlot:o.jsx(Yq,{}),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(zi,{title:n,message:r??"Unknown error"})}function Gts({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 Qts={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 Yts({level:e}){const t=Qts[e];return o.jsx(ko,{height:"compact",children:o.jsx("span",{className:"uppercase text-ui-sm font-semibold",style:{color:t.color},children:t.label})})}function Xts({entityType:e,className:t}){const n=K("size-3.5 shrink-0 text-neutral2",t);switch(e.toLowerCase()){case Os.AGENT:return o.jsx(sl,{className:n,"aria-hidden":!0});case"workflow":case Os.WORKFLOW_RUN:return o.jsx(jd,{className:n,"aria-hidden":!0});case Os.TOOL:return o.jsx(eh,{className:n,"aria-hidden":!0});default:return null}}function Kts({entityType:e,entityName:t}){const n=e??"";return o.jsxs(ko,{height:"compact",className:"flex min-w-0 items-center gap-2",children:[o.jsx(Xts,{entityType:n}),t?o.jsx("span",{className:"min-w-0 text-ui-smd truncate",children:t}):"-"]})}function Jts({message:e}){return o.jsx(ko,{height:"compact",className:"text-neutral4 text-ui-smd min-w-0 truncate font-mono",children:e})}function ens({data:e}){if(!e||Object.keys(e).length===0)return o.jsx(ko,{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(X1e,{children:t})}const Ul=Object.assign(k3,{Top:tH,TopCell:$_,TopCellWithTooltip:nH,TopCellSmart:G1t,RowWrapper:nSe,RowButton:O3,RowLink:Q1t,Spacer:tSe,NoMatch:eH,DateCell:K1e,TimeCell:J1e,LevelCell:Yts,EntityCell:Kts,MessageCell:Jts,DataCell:ens,NextPageLoading:JV}),zQe="6rem 9rem 5rem 10rem minmax(8rem,1fr) minmax(8rem,1fr)",tns=36,nns=8;function rns({logs:e,isLoading:t,isFetchingNextPage:n,hasNextPage:r,setEndOfListElement:s,logIdMap:a,featuredLogId:i,onLogClick:l}){const c=g.useRef(null),u=y9t({count:e.length,getScrollElement:()=>c.current,estimateSize:()=>tns,overscan:nns}),d=g.useRef(t);if(g.useEffect(()=>{d.current&&!t&&c.current?.dispatchEvent(new Event("scroll")),d.current=t},[t]),t)return o.jsx(tl,{columns:zQe});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(Ul,{columns:zQe,variant:"striped",scrollRef:c,className:"min-w-0",children:[o.jsxs(Ul.Top,{children:[o.jsx(Ul.TopCell,{children:"Date"}),o.jsx(Ul.TopCell,{children:"Time"}),o.jsx(Ul.TopCell,{children:"Level"}),o.jsx(Ul.TopCell,{children:"Entity"}),o.jsx(Ul.TopCell,{children:"Message"}),o.jsx(Ul.TopCell,{children:"Data"})]}),e.length===0?o.jsx(Ul.NoMatch,{message:"No logs match your search"}):o.jsxs(o.Fragment,{children:[o.jsx(Ul.Spacer,{height:h}),f.map(v=>{const y=e[v.index];if(!y)return null;const b=a.get(y);if(!b)return null;const S=b===i;return o.jsxs(Ul.RowButton,{ref:u.measureElement,"data-index":v.index,onClick:()=>l(y),featured:S,variant:y.level==="error"||y.level==="fatal"?"error":"default",children:[o.jsx(Ul.DateCell,{timestamp:y.timestamp}),o.jsx(Ul.TimeCell,{timestamp:y.timestamp}),o.jsx(Ul.LevelCell,{level:y.level}),o.jsx(Ul.EntityCell,{entityType:y.entityType,entityName:y.entityName}),o.jsx(Ul.MessageCell,{message:y.message}),o.jsx(Ul.DataCell,{data:y.data})]},b)}),o.jsx(Ul.Spacer,{height:m})]}),o.jsx(Ul.NextPageLoading,{isLoading:n,hasMore:r,setEndOfListElement:s})]})}function sns({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=>ans(f,a));return o.jsxs("div",{className:K("grid grid-cols-[1fr_auto] gap-3 items-start"),children:[o.jsx(lTe,{fields:a,tokens:i,onTokensChange:l,disabled:s,autoFocusFieldId:c}),u&&o.jsx(iTe,{disabled:s,onClear:d?e:void 0,onRemoveAll:t,onSave:n,onRemoveSaved:r})]})}function ans(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 ins={"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"},tse="MMM d, yyyy HH:mm",nse="Pick a wider range or lower the logging level — verbose entries (debug, info) may be filtered out.";function ons({datePreset:e,dateFrom:t,dateTo:n}){return e&&e!=="all"&&e!=="custom"?{title:`No logs for ${ins[e]}`,description:nse}:t&&n?{title:`No logs between ${er(t,tse)} and ${er(n,tse)}`,description:nse}:t?{title:`No logs since ${er(t,tse)}`,description:nse}:{title:"No logs yet",description:"Logs will appear here once agents, workflows, or tools are executed."}}const lns=({datePreset:e,dateFrom:t,dateTo:n}={})=>{const{title:r,description:s}=ons({datePreset:e,dateFrom:t,dateTo:n});return o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Cr,{iconSlot:o.jsx(Yq,{}),titleSlot:r,descriptionSlot:s,actionSlot:o.jsxs(de,{variant:"ghost",as:"a",href:"https://mastra.ai/en/docs/observability/logging",target:"_blank",rel:"noopener noreferrer",children:["Logging Documentation ",o.jsx(Dxe,{})]})})})},cns=20,uns=1e4;function dns(e,t,n){if(e?.pagination?.hasMore)return n+1}function fns(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 pns(e){return hTt(e.state.error,"logs")?!1:uns}const hns=({filters:e}={})=>{const t=We(),{inView:n,setRef:r}=A_(),s=$1({queryKey:["logs",e],queryFn:({pageParam:p})=>t.listLogsVNext({pagination:{page:p,perPage:cns},filters:e,orderBy:{field:"timestamp",direction:"DESC"}}),initialPageParam:0,getNextPageParam:dns,select:fns,retry:!1,refetchInterval:pns}),{hasNextPage:a,isFetchingNextPage:i,fetchNextPage:l,data:c,isLoading:u,isError:d,error:f}=s;return g.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}},oF={AGENT:Os.AGENT,WORKFLOW:Os.WORKFLOW_RUN,SCORER:Os.SCORER,INGEST:Os.RAG_INGESTION},L9t=[{label:"Agent",entityType:oF.AGENT},{label:"Workflow",entityType:oF.WORKFLOW},{label:"Scorer",entityType:oF.SCORER},{label:"Ingest",entityType:oF.INGEST}],mns=[{label:"Debug",value:"debug"},{label:"Info",value:"info"},{label:"Warn",value:"warn"},{label:"Error",value:"error"},{label:"Fatal",value:"fatal"}],Dx="rootEntityType",qb="datePreset",Vb="dateFrom",Hb="dateTo",gns=new Set(["all","last-24h","last-3d","last-7d","last-14d","last-30d","custom"]),_l={level:"filterLevel",tags:"filterTags",entityName:"filterEntityName",traceId:"filterTraceId",spanId:"filterSpanId",runId:"filterRunId",threadId:"filterThreadId",sessionId:"filterSessionId",requestId:"filterRequestId",resourceId:"filterResourceId",userId:"filterUserId",organizationId:"filterOrganizationId",serviceName:"filterServiceName",environment:"filterEnvironment",experimentId:"filterExperimentId"},X4=Object.keys(_l),_Te=new Set(["tags"]),CTe="mastra:logs:saved-filters";function vns(e,t=CTe){const n=Sns(e),r=e.get(qb);r&&n.set(qb,r);const s=e.get(Vb);s&&n.set(Vb,s);const a=e.get(Hb);a&&n.set(Hb,a);try{localStorage.setItem(t,n.toString())}catch{}}function yns(e=CTe){try{localStorage.removeItem(e)}catch{}}function BQe(e=CTe){try{const t=localStorage.getItem(e);if(!t)return null;const n=new URLSearchParams(t);return n.toString()?n:null}catch{return null}}function bns(e){if(e.has(qb)||e.has(Vb)||e.has(Hb)||e.has(Dx))return!0;for(const t of X4)if(e.has(_l[t]))return!0;return!1}function xns({availableTags:e,availableRootEntityNames:t,availableServiceNames:n,availableEnvironments:r,loading:s}){const a=[{id:"rootEntityType",label:"Primitive Type",kind:"pick-multi",searchable:!1,options:L9t.map(u=>({label:u.label,value:u.entityType})),placeholder:"Choose entity type",emptyText:"No entity types."},{id:"entityName",label:"Primitive Name",kind:"pick-multi",options:t.map(u=>({label:u,value:u})),placeholder:"Choose entity names",emptyText:"No entity names found.",isLoading:s?.entityNames},{id:"level",label:"Level",kind:"pick-multi",searchable:!1,options:mns.map(u=>({label:u.label,value:u.value})),placeholder:"Choose level",emptyText:"No levels."},{id:"tags",label:"Tags",kind:"pick-multi",multi:!0,options:e.map(u=>({label:u,value:u})),placeholder:"Choose tags",emptyText:"No tags found.",isLoading:s?.tags},{id:"serviceName",label:"Service Name",kind:"pick-multi",options:n.map(u=>({label:u,value:u})),placeholder:"Choose service names",emptyText:"No service names found.",isLoading:s?.serviceNames},{id:"environment",label:"Environment",kind:"pick-multi",options:r.map(u=>({label:u,value:u})),placeholder:"Choose environments",emptyText:"No environments found.",isLoading:s?.environments},{id:"traceId",label:"Trace ID",kind:"text"},{id:"spanId",label:"Span ID",kind:"text"},{id:"runId",label:"Run ID",kind:"text"},{id:"threadId",label:"Thread ID",kind:"text"},{id:"sessionId",label:"Session ID",kind:"text"},{id:"requestId",label:"Request ID",kind:"text"},{id:"resourceId",label:"Resource ID",kind:"text"},{id:"userId",label:"User ID",kind:"text"},{id:"organizationId",label:"Organization ID",kind:"text"},{id:"experimentId",label:"Experiment ID",kind:"text"}],i=(u,d)=>u.label.localeCompare(d.label),l=a.filter(u=>u.kind==="pick-multi").sort(i),c=a.filter(u=>u.kind==="text").sort(i);return[...l,...c]}function wns(e){const t=[],n=new Map([[Dx,"rootEntityType"]]);for(const s of X4)n.set(_l[s],s);const r=new Set;for(const[s]of e.entries()){const a=n.get(s);if(!a||r.has(a))continue;if(r.add(a),_Te.has(a)){const l=e.getAll(s);if(l.length===0)continue;t.push({fieldId:a,value:l.filter(Boolean)});continue}const i=e.get(s);i!==null&&t.push({fieldId:a,value:i})}return t}function Sns(e){const t=new URLSearchParams,n=e.get(Dx);n&&t.set(Dx,n);for(const r of X4){const s=_l[r];if(_Te.has(r)){for(const i of e.getAll(s))t.append(s,i);continue}const a=e.get(s);a&&t.set(s,a)}return t}function kns(e,t){e.delete(Dx);for(const n of X4)e.delete(_l[n]);for(const n of t){if(n.fieldId==="rootEntityType"&&typeof n.value=="string"){e.set(Dx,n.value);continue}const r=_l[n.fieldId];if(r){if(_Te.has(n.fieldId)&&Array.isArray(n.value)){if(n.value.length===0)e.append(r,"");else for(const s of n.value)e.append(r,s);continue}typeof n.value=="string"&&e.set(r,n.value.trim())}}}function Ons({rootEntityType:e,dateFrom:t,dateTo:n,tokens:r}){const s={};e&&(s.rootEntityType=e),(t||n)&&(s.timestamp={...t?{start:t}:{},...n?{end:n}:{}});for(const a of r){if(a.fieldId==="tags"){Array.isArray(a.value)&&a.value.length>0?s.tags=a.value:typeof a.value=="string"&&a.value.trim()&&(s.tags=[a.value.trim()]);continue}if(a.fieldId==="level"){typeof a.value=="string"&&a.value.trim()&&a.value!=="Any"&&(s.level=a.value);continue}if(typeof a.value=="string"&&a.value.trim()&&a.value!=="Any")switch(a.fieldId){case"entityName":s.rootEntityName=a.value;break;case"traceId":s.traceId=a.value;break;case"spanId":s.spanId=a.value;break;case"runId":s.runId=a.value;break;case"threadId":s.threadId=a.value;break;case"sessionId":s.sessionId=a.value;break;case"requestId":s.requestId=a.value;break;case"resourceId":s.resourceId=a.value;break;case"userId":s.userId=a.value;break;case"organizationId":s.organizationId=a.value;break;case"serviceName":s.serviceName=a.value;break;case"environment":s.environment=a.value;break;case"experimentId":s.experimentId=a.value;break}}return s}function _ns(e,t){return t.map(n=>{const r=e.find(s=>s.id===n.fieldId);return r?r.kind==="text"?{fieldId:n.fieldId,value:""}:r.kind==="pick-multi"?r.multi?{fieldId:n.fieldId,value:[]}:{fieldId:n.fieldId,value:"Any"}:n:n})}const Cns="Filters setting for Logs saved",Ens="Filters setting for Logs cleared up";function jns(e,t,n){const{storageKey:r,messages:s,skipHydration:a}={},[i,l]=g.useState(()=>BQe(r)!==null),c=g.useCallback(()=>{vns(e,r),l(!0);const f=s?.saved??Cns;f!==!1&&De.success(f)},[e,r,s?.saved]),u=g.useCallback(()=>{yns(r),l(!1);const f=s?.cleared??Ens;f!==!1&&De.success(f)},[r,s?.cleared]),d=g.useRef(!1);return g.useEffect(()=>{if(a||d.current||(d.current=!0,bns(e)))return;const f=BQe(r);f&&t(p=>{const h=new URLSearchParams(p);for(const[m,v]of f)h.append(m,v);return h},{replace:!0})},[]),{hasSavedFilters:i,handleSave:c,handleRemoveSaved:u}}function Tns(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 Nns(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,Tns(`${r}${n.message??""}${n.data?JSON.stringify(n.data):""}`))}return t}function Ins(e,t,n,r){const s=g.useMemo(()=>Nns(e),[e]),a=g.useMemo(()=>{const h=new Map;for(let m=0;m<e.length;m++){const v=s.get(e[m]);v&&h.set(v,{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=g.useCallback(h=>s.get(h),[s]),d=g.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);m&&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);m&&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 Vve="logId",Hve="traceId",Wve="spanId",DR=1440*60*1e3,Ans={"last-24h":DR,"last-3d":3*DR,"last-7d":7*DR,"last-14d":14*DR,"last-30d":30*DR};function lF(e){e.delete(Vve),e.delete(Hve),e.delete(Wve)}function Rns(e,t,n){const{onRemoveAll:r}={},s=g.useMemo(()=>{const _=e.get(qb);return _&&gns.has(_)?_:"last-24h"},[e]),a=e.get(Vb),i=e.get(Hb),l=g.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 _=Ans[s];return _?new Date(Date.now()-_):void 0},[s,a]),c=g.useMemo(()=>{if(s!=="custom"||!i)return;const _=new Date(i);return Number.isNaN(_.getTime())?void 0:_},[s,i]),u=g.useRef(s);u.current=s;const d=e.get(Vve),f=e.get(Hve),p=e.get(Wve),h=g.useMemo(()=>L9t.find(_=>_.entityType===e.get(Dx)),[e]),m=g.useMemo(()=>wns(e),[e]),v=g.useCallback(_=>{t(C=>{const E=new URLSearchParams(C);for(const[j,N]of Object.entries(_)){const I=j==="logId"?Vve:j==="traceId"?Hve:Wve;N?E.set(I,N):E.delete(I)}return E},{replace:!0})},[t]),y=g.useCallback(_=>{t(C=>{const E=new URLSearchParams(C);return kns(E,_),lF(E),E},{replace:!0})},[t]),b=y,S=g.useCallback((_,C)=>{if(u.current!=="custom")return;const E=C==="from"?Vb:Hb;t(j=>{const N=new URLSearchParams(j);return _?N.set(E,_.toISOString()):N.delete(E),lF(N),N},{replace:!0})},[t]),w=g.useCallback(_=>{u.current=_,t(C=>{const E=new URLSearchParams(C);return _==="last-24h"?(E.delete(qb),E.delete(Vb),E.delete(Hb)):_==="custom"?E.set(qb,"custom"):(E.set(qb,_),E.delete(Vb),E.delete(Hb)),lF(E),E},{replace:!0})},[t]),k=g.useCallback(()=>{t(_=>{const C=new URLSearchParams(_);C.delete(Dx);for(const E of X4)C.delete(_l[E]);return C.delete(qb),C.delete(Vb),C.delete(Hb),lF(C),C},{replace:!0}),r?.()},[t,r]);return g.useMemo(()=>({searchParams:e,setSearchParams:t,datePreset:s,selectedDateFrom:l,selectedDateTo:c,datePresetRef:u,featuredLogId:d,featuredTraceId:f,featuredSpanId:p,selectedEntityOption:h,filterTokens:m,handleFeaturedChange:v,handleFilterTokensChange:b,handleDateChange:S,handleDatePresetChange:w,handleRemoveAll:k,applyFilterTokens:y}),[e,t,s,l,c,u,d,f,p,h,m,v,b,S,w,k,y])}const wb=Mi.KeyValueList;function Pns({spanId:e,span:t,isLoading:n,onClose:r}){const s=t?.startedAt&&t?.endedAt?new Date(t.endedAt).getTime()-new Date(t.startedAt).getTime():null;return o.jsxs(Mi,{children:[o.jsxs(Mi.Header,{children:[o.jsxs(Mi.Heading,{children:["Span ",o.jsxs("b",{children:["# ",e]})]}),o.jsx(Mi.CloseButton,{onClick:r})]}),n?o.jsx(Mi.LoadingData,{children:"Loading span..."}):t?o.jsxs(Mi.Content,{children:[o.jsxs(wb,{children:[t.spanType&&o.jsxs(o.Fragment,{children:[o.jsx(wb.Key,{children:"Type"}),o.jsx(wb.Value,{children:t.spanType})]}),t.startedAt&&o.jsxs(o.Fragment,{children:[o.jsx(wb.Key,{children:"Started"}),o.jsx(wb.Value,{children:er(new Date(t.startedAt),"MMM dd, HH:mm:ss.SSS")})]}),t.endedAt&&o.jsxs(o.Fragment,{children:[o.jsx(wb.Key,{children:"Ended"}),o.jsx(wb.Value,{children:er(new Date(t.endedAt),"MMM dd, HH:mm:ss.SSS")})]}),s!=null&&o.jsxs(o.Fragment,{children:[o.jsx(wb.Key,{children:"Duration"}),o.jsx(wb.Value,{children:s<1e3?`${s}ms`:`${(s/1e3).toFixed(2)}s`})]})]}),o.jsx("br",{}),o.jsx(Mi.CodeSection,{title:"Input",icon:o.jsx(Dfe,{}),codeStr:JSON.stringify(t.input??null,null,2)}),o.jsx(Mi.CodeSection,{title:"Output",icon:o.jsx(Lfe,{}),codeStr:JSON.stringify(t.output??null,null,2)}),o.jsx(Mi.CodeSection,{title:"Metadata",icon:o.jsx(hw,{}),codeStr:JSON.stringify(t.metadata??null,null,2)}),o.jsx(Mi.CodeSection,{title:"Attributes",icon:o.jsx(hw,{}),codeStr:JSON.stringify(t.attributes??null,null,2)})]}):o.jsx(Mi.NoData,{children:"Span not found."})]})}function $ns(){const[e,t]=ga(),n=Rns(e,t),r=jns(e,t),[s,a]=g.useState(),[i,l]=g.useState(!1),{data:c=[],isPending:u}=gTe(),{data:d=[],isPending:f}=pTe({entityType:n.selectedEntityOption?.entityType,rootOnly:!0}),{data:p=[],isPending:h}=hTe(),{data:m=[],isPending:v}=mTe(),y=g.useMemo(()=>xns({availableTags:c,availableRootEntityNames:d,availableServiceNames:m,availableEnvironments:p,loading:{tags:u,entityNames:f,serviceNames:v,environments:h}}),[c,d,m,p,u,f,v,h]),b=g.useMemo(()=>Ons({rootEntityType:n.selectedEntityOption?.entityType,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,tokens:n.filterTokens}),[n.filterTokens,n.selectedDateFrom,n.selectedDateTo,n.selectedEntityOption]),{data:S=[],isLoading:w,error:k,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:E}=hns({filters:b}),{logIdMap:j,featuredLog:N,handleLogClick:I,handlePreviousLog:R,handleNextLog:P}=Ins(S,n.featuredLogId,n.handleFeaturedChange,n.featuredTraceId),{data:L,isLoading:M}=ZH(n.featuredTraceId??null),{data:q,isLoading:H}=oI(n.featuredTraceId??"",n.featuredSpanId??""),F=g.useCallback(()=>n.applyFilterTokens(_ns(y,n.filterTokens)),[y,n]),z=g.useCallback(()=>n.handleFeaturedChange({logId:null}),[n]),B=g.useCallback(X=>n.handleFeaturedChange({traceId:X,spanId:null}),[n]),D=g.useCallback((X,te)=>n.handleFeaturedChange({traceId:X,spanId:te}),[n]),Q=g.useCallback(()=>{n.handleFeaturedChange({traceId:null,spanId:null}),l(!1)},[n]),V=g.useCallback(()=>n.handleFeaturedChange({spanId:null}),[n]),$=g.useCallback(X=>n.handleFeaturedChange({spanId:X??null}),[n]),U=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(aTe,{preset:n.datePreset,onPresetChange:n.handleDatePresetChange,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,onDateChange:n.handleDateChange,disabled:w,presets:["last-24h","last-3d","last-7d","last-14d","last-30d","custom"]}),o.jsx(cTe,{fields:y,tokens:n.filterTokens,onTokensChange:n.handleFilterTokensChange,disabled:w,onStartTextFilter:a})]})}),o.jsx(sns,{isLoading:w,filterFields:y,filterTokens:n.filterTokens,onFilterTokensChange:n.handleFilterTokensChange,onClear:F,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:[U,o.jsx(Lt.MainArea,{isCentered:!0,children:o.jsx(Zts,{error:k,resource:"logs",errorTitle:"Failed to load logs"})})]});const Z=!!n.selectedEntityOption||n.filterTokens.length>0;return S.length===0&&!w&&!Z?o.jsxs(Lt,{width:"wide",height:"full",children:[U,o.jsx(Lt.MainArea,{isCentered:!0,children:o.jsx(lns,{datePreset:n.datePreset,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo})})]}):o.jsxs(Lt,{width:"wide",height:"full",children:[U,o.jsx(Gts,{logCollapsed:i,listSlot:o.jsx(rns,{logs:S,isLoading:w,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:E,logIdMap:j,featuredLogId:n.featuredLogId,onLogClick:I}),logPanelSlot:N?o.jsx(Wts,{log:N,onClose:z,onTraceClick:B,onSpanClick:D,onPrevious:R,onNext:P,collapsed:i,onCollapsedChange:l}):null,tracePanelSlot:n.featuredTraceId?o.jsx($Et,{traceId:n.featuredTraceId,spans:L?.spans,isLoading:M,onClose:Q,onSpanSelect:$,selectedSpanId:n.featuredSpanId}):null,spanPanelSlot:n.featuredTraceId&&n.featuredSpanId?o.jsx(Pns,{spanId:n.featuredSpanId,span:q?.span,isLoading:H,onClose:V}):null})]})}function Mns({server:e}){const{paths:t,Link:n}=yn(),s=We().options.baseUrl,a=s?`${s}/api/mcp/${e.id}/sse`:"",{data:i}=M5t(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=fm(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 Dns({mcpServers:e,isLoading:t,search:n=""}){const r=g.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(tl,{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(sl,{}),tooltip:"Agent Tools",className:"text-center"}),o.jsx(me.TopCellSmart,{long:"Tools",short:o.jsx(eh,{}),tooltip:"Tools",className:"text-center"}),o.jsx(me.TopCellSmart,{long:"Workflows",short:o.jsx(jd,{}),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(Mns,{server:s},s.id))]})}const Lns=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Cr,{iconSlot:o.jsx(Of,{}),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(de,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/tools-mcp/mcp-overview",target:"_blank",rel:"noopener noreferrer",children:["MCP Documentation ",o.jsx(_a,{})]})})}),Fns=()=>{const{data:e=[],isLoading:t,error:n}=MZ(),[r,s]=g.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(zi,{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(jf,{onSearch:s,label:"Filter MCP servers",placeholder:"Filter by name"})})}),o.jsx(Dns,{mcpServers:e,isLoading:t,search:r})]})},zns=(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 Bns({tools:e,agents:t,isLoading:n,search:r=""}){const{paths:s,Link:a}=yn(),i=g.useMemo(()=>zns(e,t),[e,t]),l=g.useMemo(()=>i.filter(c=>c.id.toLowerCase().includes(r.toLowerCase())),[i,r]);return n?o.jsx(tl,{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(sl,{}),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=fm(c.id,50),d=fm(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 Uns=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Cr,{iconSlot:o.jsx(Of,{}),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(de,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/agents/using-tools-and-mcp",target:"_blank",rel:"noopener noreferrer",children:["Tools Documentation ",o.jsx(_a,{})]})})}),qns=()=>{const e=We();return Rn({mutationFn:async({toolId:t,input:n,requestContext:r})=>{const s=new u_;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}}})},Vns=({toolId:e})=>{const{canExecute:t}=il(),n=t("tools"),{data:r={}}=km(),s=g.useMemo(()=>{for(const v of Object.values(r))if(v.tools){const y=Object.values(v.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}=qns(),{requestContext:p}=_s();g.useEffect(()=>{if(l){const v=l instanceof Error?l.message:"Failed to load tool";De.error(`Error loading tool: ${v}`)}},[l]);const h=async(v,y)=>{if(!c)return;const b={...p??{},...y??{}};return u({toolId:c.id,input:v,requestContext:b})},m=c?.inputSchema?lm(im(yx(c?.inputSchema))):Ss({});return i?o.jsxs("div",{className:"p-6",children:[o.jsx(bt,{className:"h-8 w-48 mb-4"}),o.jsx(bt,{className:"h-32 w-full"})]}):l?null:c?n?o.jsx(Hje,{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 Hns({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}=cI(),{data:p={},isLoading:h,isError:m,error:v}=km(),{navigate:y,paths:b}=yn();g.useEffect(()=>{if(d){const _=f instanceof Error?f.message:"Failed to load tools";De.error(`Error loading tools: ${_}`)}},[d,f]),g.useEffect(()=>{if(m){const _=v instanceof Error?v.message:"Failed to load agents";De.error(`Error loading agents: ${_}`)}},[m,v]);const S=new Map;Object.values(p).forEach(_=>{_.tools&&Object.values(_.tools).forEach(C=>{S.has(C.id)||S.set(C.id,C)})}),Object.values(c).forEach(_=>{S.has(_.id)||S.set(_.id,_)});const w=Array.from(S.values()).map(_=>({label:_.id,value:_.id})),k=_=>{t?t(_):_&&_!==e&&y(b.toolLink(_))};return o.jsx(Jl,{options:w,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 Wns=({isLoading:e,server:t})=>{const[{sseUrl:n,httpStreamUrl:r},s]=g.useState({sseUrl:"",httpStreamUrl:""});if(g.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(wy,{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(wy,{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(dn,{icon:o.jsx(_Et,{className:"text-neutral6"}),className:"rounded-r-sm text-neutral4!",children:"Version"}),o.jsx(dn,{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(dn,{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(Oa,{tooltip:"Copy HTTP Stream URL",content:r})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(dn,{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(Oa,{tooltip:"Copy SSE URL",content:n})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(dn,{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(Oa,{tooltip:"Copy Command Line Config",content:a})})]})]})]})]}),o.jsx("div",{className:"h-full overflow-y-scroll border-l border-border1",children:o.jsx(Zns,{server:t})})]})},Zns=({server:e})=>{const{data:t={},isLoading:n}=M5t(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(B_,{})}),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(Qns,{tool:a,serverId:e.id},s)})})]})};function Gns(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 Qns=({tool:e,serverId:t})=>{const n=g.useRef(null),{Link:r,paths:s}=yn(),a=o6t[e.toolType||"tool"],i=Gns(e._meta);return o.jsxs(Nf,{onClick:()=>n.current?.click(),children:[o.jsx(QIt,{children:o.jsx(a,{className:"group-hover/entity:text-accent6"})}),o.jsxs(Af,{children:[o.jsx(If,{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(dn,{className:"text-[10px] py-0",children:"App"})]})}),o.jsx(th,{children:e.description})]})]})},Yns=()=>{const{serverId:e}=ur(),{data:t=[],isLoading:n}=MZ(),r=t.find(s=>s.id===e);return o.jsx("div",{className:"h-full w-full overflow-hidden",children:o.jsx(Wns,{isLoading:n,server:r})})};function Xns(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 Kns=({toolId:e,serverId:t})=>{const{canExecute:n}=il(),r=n("tools"),s=We(),{data:a,isLoading:i,error:l}=mje(t,e),{mutateAsync:c,isPending:u,data:d}=g7r(t,e),f=a?Xns(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=g.useCallback(async(y,b)=>await c(b),[c]);g.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(bt,{className:"h-8 w-48 mb-4"}),o.jsx(bt,{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 v;try{v=lm(im(a.inputSchema))}catch(y){console.error("Error processing input schema:",y),De.error("Failed to process tool input schema."),v=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($5t,{html:p,toolName:a.name??a.id,onToolCall:h})}),o.jsx(Hje,{executionResult:d,isExecutingTool:u,zodInputSchema:v,handleExecuteTool:m,toolDescription:a.description||"",toolId:a.id})]})},Jns=()=>{const{serverId:e,toolId:t}=ur(),{data:n,isLoading:r}=mje(e,t);return r||!n?null:o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(Kns,{toolId:t,serverId:e})})},F9t=[{label:"Agent",entityType:Os.AGENT},{label:"Workflow",entityType:Os.WORKFLOW_RUN},{label:"Scorer",entityType:Os.SCORER},{label:"Ingest",entityType:Os.RAG_INGESTION}],dN="rootEntityType",fN={tags:"filterTags",entityId:"filterEntityId",entityName:"filterEntityName",runId:"filterRunId",threadId:"filterThreadId",sessionId:"filterSessionId",requestId:"filterRequestId",resourceId:"filterResourceId",userId:"filterUserId",organizationId:"filterOrganizationId",serviceName:"filterServiceName",environment:"filterEnvironment",experimentId:"filterExperimentId",provider:"filterProvider",model:"filterModel"},eG=Object.keys(fN),ETe="mastra:metrics:saved-filters";function ers(e){const t=ars(e);try{localStorage.setItem(ETe,t.toString())}catch{}}function trs(){try{localStorage.removeItem(ETe)}catch{}}function z9t(){try{const e=localStorage.getItem(ETe);if(!e)return null;const t=new URLSearchParams(e);return t.toString()?t:null}catch{return null}}function nrs(e){if(e.has(dN))return!0;for(const t of eG)if(e.has(fN[t]))return!0;return!1}function rrs({availableTags:e,availableEntityNames:t,availableServiceNames:n,availableEnvironments:r,loading:s}){const a=[{id:"rootEntityType",label:"Primitive Type",kind:"pick-multi",searchable:!1,options:F9t.map(u=>({label:u.label,value:u.entityType})),placeholder:"Choose entity type",emptyText:"No entity types."},{id:"entityName",label:"Primitive Name",kind:"pick-multi",options:t.map(u=>({label:u,value:u})),placeholder:"Choose entity names",emptyText:"No entity names found.",isLoading:s?.entityNames},{id:"entityId",label:"Primitive ID",kind:"text"},{id:"tags",label:"Tags",kind:"pick-multi",multi:!0,options:e.map(u=>({label:u,value:u})),placeholder:"Choose tags",emptyText:"No tags found.",isLoading:s?.tags},{id:"serviceName",label:"Service Name",kind:"pick-multi",options:n.map(u=>({label:u,value:u})),placeholder:"Choose service names",emptyText:"No service names found.",isLoading:s?.serviceNames},{id:"environment",label:"Environment",kind:"pick-multi",options:r.map(u=>({label:u,value:u})),placeholder:"Choose environments",emptyText:"No environments found.",isLoading:s?.environments},{id:"threadId",label:"Thread ID",kind:"text"},{id:"resourceId",label:"Resource ID",kind:"text"},{id:"userId",label:"User ID",kind:"text"},{id:"organizationId",label:"Organization ID",kind:"text"},{id:"runId",label:"Run ID",kind:"text"},{id:"sessionId",label:"Session ID",kind:"text"},{id:"requestId",label:"Request ID",kind:"text"},{id:"experimentId",label:"Experiment ID",kind:"text"}],i=(u,d)=>u.label.localeCompare(d.label),l=a.filter(u=>u.kind==="pick-multi").sort(i),c=a.filter(u=>u.kind==="text").sort(i);return[...l,...c]}function srs(e){const t=[],n=new Map([[dN,"rootEntityType"]]);for(const s of eG)n.set(fN[s],s);const r=new Set;for(const[s]of e.entries()){const a=n.get(s);if(!a||r.has(a))continue;if(r.add(a),a==="tags"){const l=e.getAll(s);if(l.length===0)continue;t.push({fieldId:a,value:l.filter(Boolean)});continue}if(a==="rootEntityType"||a==="entityName"||a==="serviceName"||a==="environment"||a==="provider"||a==="model"){const l=e.getAll(s);if(l.length>1){t.push({fieldId:a,value:l});continue}}const i=e.get(s);i!==null&&t.push({fieldId:a,value:i})}return t}function ars(e){const t=new URLSearchParams,n=e.getAll(dN);for(const r of n)t.append(dN,r);for(const r of eG){const s=fN[r],a=e.getAll(s);for(const i of a)t.append(s,i)}return t}function irs(e,t){e.delete(dN);for(const n of eG)e.delete(fN[n]);for(const n of t){const r=n.fieldId==="rootEntityType"?dN:fN[n.fieldId];if(r)if(Array.isArray(n.value)){const s=n.value.filter(a=>typeof a=="string"&&a!=="");if(s.length===0){n.fieldId==="tags"&&e.append(r,"");continue}for(const a of s)e.append(r,a)}else typeof n.value=="string"&&e.set(r,n.value.trim())}}const ors="Any";function UQe(e){const t=e.trim();return t===""||t===ors}const lrs=new Set(F9t.map(e=>e.entityType));function qQe(e){const t=e.trim();return lrs.has(t)?t:void 0}function crs(e){const t={};for(const n of e){const r=n.fieldId;if(Array.isArray(n.value)){const s=n.value.filter(a=>typeof a=="string").map(a=>a.trim()).filter(a=>!UQe(a));if(s.length===0)continue;if(r==="tags")t.tags=s;else if(r==="rootEntityType"){const a=qQe(s[0]);a&&(t.rootEntityType=a)}else t[r]=s[0]}else if(typeof n.value=="string"){if(UQe(n.value))continue;const s=n.value.trim();if(r==="rootEntityType"){const a=qQe(s);a&&(t.rootEntityType=a)}else t[r]=s}}return t}const B9t=[{label:"Last 24 hours",value:"24h"},{label:"Last 3 days",value:"3d"},{label:"Last 7 days",value:"7d"},{label:"Last 14 days",value:"14d"},{label:"Last 30 days",value:"30d"}],urs=new Set(B9t.map(e=>e.value));function drs(e){return typeof e=="string"&&(urs.has(e)||e==="custom")}const U9t=g.createContext({datePreset:"24h",setDatePreset:()=>{},customRange:void 0,setCustomRange:()=>{},dateRangeLabel:"Last 24 hours",filterTokens:[],setFilterTokens:()=>{},dimensionalFilter:{},dimensionalFilterKey:"{}",tracesBasePath:void 0,logsBasePath:void 0});function tG(){return g.useContext(U9t)}function frs(e,t){return e!=="custom"?B9t.find(n=>n.value===e)?.label??e:t?.from?t.to?`${er(t.from,"MMM d, yyyy")} – ${er(t.to,"MMM d, yyyy")}`:er(t.from,"MMM d, yyyy"):"Custom range"}function prs({children:e,preset:t,filterTokens:n,onPresetChange:r,onFilterTokensChange:s,customRange:a,onCustomRangeChange:i,tracesBasePath:l,logsBasePath:c}){const u=g.useMemo(()=>JSON.stringify(n),[n]),d=g.useMemo(()=>n,[u]),f=g.useMemo(()=>crs(d),[d]),p=g.useMemo(()=>JSON.stringify(f),[f]),h=frs(t,a),m=g.useMemo(()=>({datePreset:t,setDatePreset:r,customRange:a,setCustomRange:i??(()=>{}),dateRangeLabel:h,filterTokens:d,setFilterTokens:s,dimensionalFilter:f,dimensionalFilterKey:p,tracesBasePath:l,logsBasePath:c}),[t,r,a,i,h,d,s,f,p,l,c]);return o.jsx(U9t.Provider,{value:m,children:e})}const hrs=["last-24h","last-3d","last-7d","last-14d","last-30d","custom"];function mrs(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 grs(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 vrs(){const{datePreset:e,setDatePreset:t,customRange:n,setCustomRange:r}=tG(),s=g.useRef(e);s.current=e;const a=g.useRef(n);return a.current=n,o.jsx(aTe,{preset:mrs(e),onPresetChange:i=>{const l=grs(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:hrs})}const rse={"24h":1440*60*1e3,"3d":4320*60*1e3,"7d":10080*60*1e3,"14d":336*60*60*1e3,"30d":720*60*60*1e3};function yrs(e,t,n){if(e!=="custom"){const r=rse[e]??rse["24h"];return{start:new Date(n-r),end:new Date(n)}}return{start:t?.from??new Date(n-rse["24h"]),end:t?.to??new Date(n)}}function Em(){const{datePreset:e,customRange:t,dimensionalFilter:n,dimensionalFilterKey:r}=tG(),s=g.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=g.useMemo(()=>yrs(e,t,i),[e,t,i]),c=g.useMemo(()=>({timestamp:l,...n}),[l,r]),u=g.useMemo(()=>`${a}|${r}`,[a,r]);return{datePreset:e,customRange:t,timestamp:l,filters:c,dimensionalFilter:n,filterKey:u}}function q9t(){const e=We(),{filters:t,filterKey:n}=Em();return wt({queryKey:["metrics","agent-runs-kpi",n],queryFn:()=>e.getMetricAggregate({name:["mastra_agent_duration_ms"],aggregation:"count",filters:t,comparePeriod:"previous_period"})})}function K4({href:e,LinkComponent:t="a"}){return o.jsx(de,{as:t,href:e,variant:"ghost",size:"icon-md",tooltip:"View in Traces","aria-label":"View in Traces",children:o.jsx(Kkn,{})})}function brs({href:e,LinkComponent:t="a"}){return o.jsx(de,{as:t,href:e,variant:"ghost",size:"icon-md",tooltip:"View errors in Logs","aria-label":"View errors in Logs",children:o.jsx($On,{})})}const xrs=[{dataKey:"p50",label:"p50",color:Pp.blue,aggregate:e=>({value:e.length>0?`${Math.round(e.reduce((t,n)=>t+n.p50,0)/e.length)}`:"0",suffix:"avg ms"})},{dataKey:"p95",label:"p95",color:Pp.yellow,aggregate:e=>({value:e.length>0?`${Math.round(e.reduce((t,n)=>t+n.p95,0)/e.length)}`:"0",suffix:"avg ms"})}];function sse({data:e,onPointClick:t}){return e.length===0?o.jsx(Ut.NoData,{message:"No latency data yet"}):o.jsx(LU,{data:e,series:xrs,onPointClick:t?n=>{const r=n;typeof r?.tsMs=="number"&&Number.isFinite(r.tsMs)&&t(r)}:void 0})}function wrs({data:e,isLoading:t,isError:n,onPointClick:r,actions:s}){const a=e?e.agentData.length>0?"agents":e.workflowData.length>0?"workflows":e.toolData.length>0?"tools":"agents":"agents",[i,l]=g.useState(a);g.useEffect(()=>{if(!e)return;const p={agents:e.agentData.length>0,workflows:e.workflowData.length>0,tools:e.toolData.length>0};!p[i]&&p[a]&&l(a)},[e,i,a]);const c=typeof s=="function"?s(i):s,u=!!e&&(e.agentData.length>0||e.workflowData.length>0||e.toolData.length>0),d=e?Object.values(e).filter(Array.isArray).flat().map(p=>p.p50).filter(p=>typeof p=="number"):[],f=d.length>0?`${Math.round(d.reduce((p,h)=>p+h,0)/d.length)}ms`:"—";return o.jsxs(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.TitleAndDescription,{title:"Latency",description:"Hourly p50 and p95 latency."}),u&&o.jsx(Ut.Summary,{value:f,label:"Avg p50"}),c?o.jsx(Ut.Actions,{children:c}):null]}),t?o.jsx(Ut.Loading,{}):n?o.jsx(Ut.Error,{message:"Failed to load latency data"}):o.jsx(Ut.Content,{children:u?o.jsxs(cu,{value:i,onValueChange:l,defaultTab:a,className:"overflow-visible",children:[o.jsxs(uu,{children:[o.jsx(qr,{value:"agents",children:"Agents"}),o.jsx(qr,{value:"workflows",children:"Workflows"}),o.jsx(qr,{value:"tools",children:"Tools"})]}),o.jsx(fs,{value:"agents",children:o.jsx(sse,{data:e.agentData,onPointClick:r?p=>r("agents",p):void 0})}),o.jsx(fs,{value:"workflows",children:o.jsx(sse,{data:e.workflowData,onPointClick:r?p=>r("workflows",p):void 0})}),o.jsx(fs,{value:"tools",children:o.jsx(sse,{data:e.toolData,onPointClick:r?p=>r("tools",p):void 0})})]}):o.jsx(Ut.NoData,{message:"No latency data yet"})})]})}function Srs(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 krs(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 V9t(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=Srs(s);l&&e.set(t,l)}function To(e,t,n){typeof n=="string"&&n.length>0&&e.set(t,n)}function H9t(e,t,n){if(!(!Array.isArray(n)||n.length===0))for(const r of n)r&&e.append(t,r)}function VQe({preset:e,customRange:t,dashboardFilter:n,scope:r,tracesBasePath:s="/observability"}){const a=new URLSearchParams;a.set(xw,"branches"),V9t(a,ww,Sw,kw,e,t,r.window);const i=r.rootEntityType??n.rootEntityType;i&&a.set($x,i),r.status&&a.set(Mx,r.status),To(a,Ol.entityName,r.entityName??n.entityName),To(a,Ol.threadId,r.threadId??n.threadId),To(a,Ol.resourceId,r.resourceId??n.resourceId),To(a,Ol.entityId,n.entityId),To(a,Ol.runId,n.runId),To(a,Ol.sessionId,n.sessionId),To(a,Ol.requestId,n.requestId),To(a,Ol.userId,n.userId),To(a,Ol.organizationId,n.organizationId),To(a,Ol.experimentId,n.experimentId),To(a,Ol.serviceName,n.serviceName),To(a,Ol.environment,n.environment),H9t(a,Ol.tags,n.tags);const l=a.toString();return l?`${s}?${l}`:s}function Ors({preset:e,customRange:t,dashboardFilter:n,scope:r,logsBasePath:s="/logs"}){const a=new URLSearchParams;V9t(a,qb,Vb,Hb,e,t,r.window);const i=r.rootEntityType??n.rootEntityType;i&&a.set(Dx,i),To(a,_l.entityName,r.entityName??n.entityName),To(a,_l.threadId,r.threadId??n.threadId),To(a,_l.resourceId,r.resourceId??n.resourceId),To(a,_l.runId,n.runId),To(a,_l.sessionId,n.sessionId),To(a,_l.requestId,n.requestId),To(a,_l.userId,n.userId),To(a,_l.organizationId,n.organizationId),To(a,_l.experimentId,n.experimentId),To(a,_l.serviceName,n.serviceName),To(a,_l.environment,n.environment),H9t(a,_l.tags,n.tags),r.status==="error"&&a.append(_l.level,"error");const l=a.toString();return l?`${s}?${l}`:s}function jI(){const{datePreset:e,customRange:t,dimensionalFilter:n,tracesBasePath:r,logsBasePath:s}=tG(),a=g.useCallback((c={})=>VQe({preset:e,customRange:t,dashboardFilter:n,scope:c,tracesBasePath:r}),[e,t,n,r]),i=g.useCallback((c={})=>Ors({preset:e,customRange:t,dashboardFilter:n,scope:c,logsBasePath:s}),[e,t,n,s]),l=g.useCallback((c,u,d)=>{const f=krs(u,d);return VQe({preset:e,customRange:t,dashboardFilter:n,scope:{...c,window:f},tracesBasePath:r})},[e,t,n,r]);return{getTracesHref:a,getLogsHref:i,getBucketTracesHref:l}}const W9t="1h";async function ase(e,t,n){const r=await e.getMetricPercentiles({name:t,percentiles:[.5,.95],interval:W9t,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 _rs(){const e=We(),{filters:t,filterKey:n}=Em();return wt({queryKey:["metrics","latency",n],queryFn:async()=>{const[r,s,a]=await Promise.all([ase(e,"mastra_agent_duration_ms",t),ase(e,"mastra_workflow_duration_ms",t),ase(e,"mastra_tool_duration_ms",t)]);return{agentData:r,workflowData:s,toolData:a,interval:W9t}}})}const HQe={agents:Os.AGENT,workflows:Os.WORKFLOW_RUN,tools:Os.TOOL};function Crs(){const{data:e,isLoading:t,isError:n}=_rs(),{getTracesHref:r,getBucketTracesHref:s}=jI(),{Link:a}=yn(),i=bs();return o.jsx(wrs,{data:e,isLoading:t,isError:n,onPointClick:(l,c)=>{Number.isFinite(c.tsMs)&&i(s({rootEntityType:HQe[l]},c.tsMs,"1h"))},actions:l=>o.jsx(K4,{href:r({rootEntityType:HQe[l]}),LinkComponent:a})})}function Ers(e){return e==="threads"||e==="resources"}function ise(e){return e.length<=12?e:`${e.slice(0,6)}…${e.slice(-4)}`}function jrs({threads:e,resources:t,getThreadRowHref:n,getResourceRowHref:r,actions:s,LinkComponent:a}){const[i,l]=g.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,v=typeof s=="function"?s(i):s;return o.jsxs(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.TitleAndDescription,{title:"Memory",description:"Resource and Thread consumption"}),i==="threads"&&d&&o.jsx(Ut.Summary,{value:p.toLocaleString(),label:"Total runs"}),i==="resources"&&f&&o.jsx(Ut.Summary,{value:h.toLocaleString(),label:"Total threads"}),v?o.jsx(Ut.Actions,{children:v}):null]}),m.isLoading?o.jsx(Ut.Loading,{}):m.isError?o.jsx(Ut.Error,{message:"Failed to load memory data"}):o.jsx(Ut.Content,{children:o.jsxs(cu,{defaultTab:"threads",value:i,onValueChange:y=>{Ers(y)&&l(y)},className:"grid grid-rows-[auto_1fr] overflow-y-auto h-full",children:[o.jsxs(uu,{children:[o.jsx(qr,{value:"threads",children:"Threads"}),o.jsx(qr,{value:"resources",children:"Resources"})]}),o.jsx(fs,{value:"threads",children:d?o.jsxs(me,{columns:"auto auto auto auto auto",...Uve,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),S=o.jsxs(o.Fragment,{children:[o.jsx(me.RowHeaderCell,{height:"compact",className:"text-ui-sm",children:ise(y.threadId)}),o.jsx(me.NumberCell,{children:y.resourceId?ise(y.resourceId):"—"}),o.jsx(me.NumberCell,{highlight:!0,children:y.runs.toLocaleString()}),o.jsx(me.NumberCell,{children:y.tokens>0?wc(y.tokens):"—"}),o.jsx(me.NumberCell,{children:y.cost!=null?bg(y.cost,y.costUnit):"—"})]});return b?o.jsx(me.RowLink,{to:b,LinkComponent:a,children:S},y.key):o.jsx(me.RowStatic,{children:S},y.key)})]}):o.jsx(Ut.NoData,{message:"No thread activity yet"})}),o.jsx(fs,{value:"resources",children:f?o.jsxs(me,{columns:"auto auto auto auto",...Uve,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),S=o.jsxs(o.Fragment,{children:[o.jsx(me.RowHeaderCell,{height:"compact",className:"text-ui-sm",children:ise(y.resourceId)}),o.jsx(me.NumberCell,{highlight:!0,children:y.threadCount.toLocaleString()}),o.jsx(me.NumberCell,{children:y.tokens>0?wc(y.tokens):"—"}),o.jsx(me.NumberCell,{children:y.cost!=null?bg(y.cost,y.costUnit):"—"})]});return b?o.jsx(me.RowLink,{to:b,LinkComponent:a,children:S},y.key):o.jsx(me.RowStatic,{children:S},y.key)})]}):o.jsx(Ut.NoData,{message:"No resource activity yet"})})]})})]})}function J4(e,t,n){const r=e.get(t);if(r!==void 0)return r;const s=n();return e.set(t,s),s}const ose=20;function Trs(){const e=We(),{filters:t,filterKey:n}=Em();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:ose}),e.getMetricBreakdown({...r,name:["mastra_model_total_input_tokens"],aggregation:"sum",limit:ose}),e.getMetricBreakdown({...r,name:["mastra_model_total_output_tokens"],aggregation:"sum",limit:ose})]),l=new Map,c=d=>J4(l,d,()=>({tokens:0,cost:null,costUnit:null})),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 lse=20;function Nrs(){const e=We(),{filters:t,filterKey:n}=Em();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:lse}),e.getMetricBreakdown({...r,name:["mastra_model_total_input_tokens"],aggregation:"sum",limit:lse}),e.getMetricBreakdown({...r,name:["mastra_model_total_output_tokens"],aggregation:"sum",limit:lse})]),l=new Map,c=d=>J4(l,d,()=>({tokens:0,cost:null,costUnit:null})),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 Irs(){const e=Trs(),t=Nrs(),{getTracesHref:n}=jI(),{Link:r}=yn();return o.jsx(jrs,{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 e5({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 Ars(){const e=We(),{filters:t,filterKey:n}=Em();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 Rrs(){const e=We(),{filters:t,filterKey:n}=Em();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 Prs(){const e=We(),{filters:t,filterKey:n}=Em();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 $rs(){const e=We(),{filters:t,filterKey:n}=Em();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 Mrs(){const{data:e,isLoading:t,isError:n}=q9t();return o.jsx(e5,{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 Drs(){const{data:e,isLoading:t,isError:n}=Prs();return o.jsx(e5,{label:"Total Model Cost",value:e?.cost!=null?bg(e.cost,e.costUnit):null,prevValue:e?.previousCost!=null?bg(e.previousCost,e.costUnit):void 0,changePct:e?.costChangePercent??null,isLoading:t,isError:n})}function Lrs(){const{data:e,isLoading:t,isError:n}=$rs();return o.jsx(e5,{label:"Total Tokens",value:e?.value!=null?wc(e.value):null,prevValue:e?.previousValue!=null?wc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function Frs(){const{data:e,isLoading:t,isError:n}=Rrs();return o.jsx(e5,{label:"Total Threads",value:e?.value!=null?wc(e.value):null,prevValue:e?.previousValue!=null?wc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function zrs(){const{data:e,isLoading:t,isError:n}=Ars();return o.jsx(e5,{label:"Total Resources",value:e?.value!=null?wc(e.value):null,prevValue:e?.previousValue!=null?wc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function Brs({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=>Urs(f,a));return o.jsxs("div",{className:K("grid grid-cols-[1fr_auto] gap-3 items-start"),children:[o.jsx(lTe,{fields:a,tokens:i,onTokensChange:l,disabled:s,autoFocusFieldId:c}),u&&o.jsx(iTe,{disabled:s,onClear:d?e:void 0,onRemoveAll:t,onSave:n,onRemoveSaved:r})]})}function Urs(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 qrs({rows:e,isLoading:t,isError:n,getRowHref:r,actions:s,LinkComponent:a}){const i=!!e&&e.length>0;return o.jsxs(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.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?bg(l):"—":c.size===1?u=l>0?bg(l,[...c][0]):"—":u="Mixed",o.jsx(Ut.Summary,{value:u,label:"Total cost"})})(),s?o.jsx(Ut.Actions,{children:s}):null]}),t?o.jsx(Ut.Loading,{}):n?o.jsx(Ut.Error,{message:"Failed to load model usage data"}):o.jsx(Ut.Content,{children:i?o.jsxs(me,{columns:"auto auto auto auto auto auto",...Uve,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?bg(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(Ut.NoData,{message:"No model usage data yet"})})]})}function Vrs(){const e=We(),{filters:t,filterKey:n}=Em();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=>J4(l,d,()=>({input:0,output:0,cacheRead:0,cacheWrite:0,cost:null,costUnit:null})),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:wc(f.input),output:wc(f.output),cacheRead:wc(f.cacheRead),cacheWrite:wc(f.cacheWrite),cost:f.cost,costUnit:f.costUnit})).sort((d,f)=>d.model.localeCompare(f.model))}})}function Hrs(){const{data:e,isLoading:t,isError:n}=Vrs(),{getTracesHref:r}=jI(),{Link:s}=yn();return o.jsx(qrs,{rows:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:()=>r({rootEntityType:Os.AGENT}),actions:o.jsx(K4,{href:r({rootEntityType:Os.AGENT}),LinkComponent:s})})}function Wrs(e){return e==="tokens"||e==="cost"}function Zrs({data:e,isLoading:t,isError:n,getRowHref:r,actions:s,LinkComponent:a}){const[i,l]=g.useState("tokens"),c=e??[],u=c.length>0,d=c.reduce((b,S)=>b+S.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,v=h?f.reduce((b,S)=>b+(S.cost??0),0):0,y=h&&v>0;return o.jsxs(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.TitleAndDescription,{title:"Token Usage by Agent",description:"Token consumption grouped by agent."}),u&&(i==="cost"&&y?o.jsx(Ut.Summary,{value:bg(v,m),label:"Total cost"}):o.jsx(Ut.Summary,{value:wc(d),label:"Total tokens"})),u&&s?o.jsx(Ut.Actions,{children:s}):null]}),t?o.jsx(Ut.Loading,{}):n?o.jsx(Ut.Error,{message:"Failed to load token usage data"}):o.jsx(Ut.Content,{children:u?o.jsxs(cu,{defaultTab:"tokens",value:i,onValueChange:b=>{Wrs(b)&&l(b)},className:"grid grid-rows-[auto_1fr] overflow-y-auto h-full",children:[o.jsxs(uu,{children:[o.jsx(qr,{value:"tokens",children:"Tokens"}),o.jsx(qr,{value:"cost",children:"Cost"})]}),o.jsx(fs,{value:"tokens",children:o.jsx(uN,{LinkComponent:a,data:c.map(b=>({name:b.name,values:[b.input,b.output],href:r?.(b)})),segments:[{label:"Input",color:Pp.blueDark},{label:"Output",color:Pp.blue}],maxVal:Math.max(...c.map(b=>b.input+b.output)),fmt:wc})}),o.jsx(fs,{value:"cost",children:y?o.jsx(uN,{LinkComponent:a,data:f.slice().sort((b,S)=>(S.cost??0)-(b.cost??0)).map(b=>({name:b.name,values:[b.cost],href:r?.(b)})),segments:[{label:"Cost",color:Pp.purple}],maxVal:Math.max(...f.map(b=>b.cost??0)),fmt:b=>bg(b,m)}):o.jsx(Ut.NoData,{message:"No cost data yet"})})]}):o.jsx(Ut.NoData,{message:"No token usage data yet"})})]})}function Grs(){const e=We(),{filters:t,filterKey:n}=Em();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=>J4(i,u,()=>({input:0,output:0,cost:null,costUnit:null})),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 Qrs(){const{data:e,isLoading:t,isError:n}=Grs(),{getTracesHref:r}=jI(),{Link:s}=yn();return o.jsx(Zrs,{data:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:a=>r({rootEntityType:Os.AGENT,entityName:a.name}),actions:o.jsx(K4,{href:r({rootEntityType:Os.AGENT}),LinkComponent:s})})}function Zve(e,t=wc){return n=>({value:t(n.reduce((r,s)=>r+(typeof s[e]=="number"?s[e]:0),0))})}const Yrs=[{dataKey:"input",label:"Input tokens",color:Pp.blue,aggregate:Zve("input")},{dataKey:"output",label:"Output tokens",color:Pp.yellow,aggregate:Zve("output")}];function Xrs(e){return e==="tokens"||e==="cost"}function Krs({data:e,interval:t="1d",isLoading:n,isError:r,actions:s}){const[a,i]=g.useState("tokens"),l=e??[],c=l.map(k=>({...k})),u=l.length>0,d=l.reduce((k,_)=>k+_.total,0),f=l.filter(k=>k.cost!=null&&k.cost>0),p=f.map(k=>({...k})),h=new Set(f.map(k=>k.costUnit).filter(k=>!!k)),m=h.size===1&&f.every(k=>k.costUnit!=null),v=m?[...h][0]??null:null,y=m?f.reduce((k,_)=>k+(_.cost??0),0):0,b=m&&y>0,S=t==="1h"?"Input and output tokens per hour.":"Input and output tokens per day.",w=[{dataKey:"cost",label:"Cost",color:Pp.purple,aggregate:Zve("cost",k=>bg(k,v))}];return o.jsxs(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.TitleAndDescription,{title:"Token usage over time",description:S}),u&&(a==="cost"&&b?o.jsx(Ut.Summary,{value:bg(y,v),label:"Total cost"}):o.jsx(Ut.Summary,{value:wc(d),label:"Total tokens"})),u&&s?o.jsx(Ut.Actions,{children:s}):null]}),n?o.jsx(Ut.Loading,{}):r?o.jsx(Ut.Error,{message:"Failed to load token usage timeline"}):o.jsx(Ut.Content,{children:u?o.jsxs(cu,{defaultTab:"tokens",value:a,onValueChange:k=>{Xrs(k)&&i(k)},className:"overflow-visible",children:[o.jsxs(uu,{children:[o.jsx(qr,{value:"tokens",children:"Tokens"}),o.jsx(qr,{value:"cost",children:"Cost"})]}),o.jsx(fs,{value:"tokens",children:o.jsx(LU,{data:c,series:Yrs})}),o.jsx(fs,{value:"cost",children:b?o.jsx(LU,{data:p,series:w}):o.jsx(Ut.NoData,{message:"No cost data yet"})})]}):o.jsx(Ut.NoData,{message:"No token usage data yet"})})]})}function Jrs(e){return e==="24h"?"1h":"1d"}function ess(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 WQe(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 tss(e){return e.cost==null||e.hasUnknownCostUnit||e.costUnits.size!==1?null:[...e.costUnits][0]??null}function nss(){const e=We(),{datePreset:t,filters:n,filterKey:r}=Em(),s=Jrs(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 WQe(l,a.series[0],"input"),WQe(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:ess(d,s),tsMs:u.tsMs,input:u.input,output:u.output,total:u.input+u.output,cost:u.cost,costUnit:tss(u)}}),interval:s}}})}function rss(){const{data:e,isLoading:t,isError:n}=nss(),{getTracesHref:r}=jI(),{Link:s}=yn();return o.jsx(Krs,{data:e?.data,interval:e?.interval,isLoading:t,isError:n,actions:o.jsx(K4,{href:r(),LinkComponent:s})})}function cse({data:e,rowHrefs:t,errorHrefs:n,LinkComponent:r}){return o.jsx(uN,{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:Pp.blueDark},{label:"Errors",color:Pp.pink}],maxVal:Math.max(...e.map(s=>s.completed+s.errors)),fmt:wc})}function sss({data:e,isLoading:t,isError:n,getRowHref:r,getErrorSegmentHref:s,actions:a,LinkComponent:i}){const[l,c]=g.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,v)=>m+v.completed+v.errors,0):0,p=m=>r?v=>r(m,v):void 0,h=m=>s?v=>s(m,v):void 0;return o.jsxs(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.TitleAndDescription,{title:"Trace Volume",description:"Runs and call counts."}),d&&o.jsx(Ut.Summary,{value:wc(f),label:"Total runs"}),u?o.jsx(Ut.Actions,{children:u}):null]}),t?o.jsx(Ut.Loading,{}):n?o.jsx(Ut.Error,{message:"Failed to load trace volume data"}):o.jsx(Ut.Content,{children:d?o.jsxs(cu,{value:l,onValueChange:c,defaultTab:"agents",className:"grid grid-rows-[auto_1fr] overflow-y-auto h-full",children:[o.jsxs(uu,{children:[o.jsx(qr,{value:"agents",children:"Agents"}),o.jsx(qr,{value:"workflows",children:"Workflows"}),o.jsx(qr,{value:"tools",children:"Tools"})]}),o.jsx(fs,{value:"agents",children:e.agentData.length>0?o.jsx(cse,{data:e.agentData,rowHrefs:p("agents"),errorHrefs:h("agents"),LinkComponent:i}):o.jsx(Ut.NoData,{message:"No agent data yet"})}),o.jsx(fs,{value:"workflows",children:e.workflowData.length>0?o.jsx(cse,{data:e.workflowData,rowHrefs:p("workflows"),errorHrefs:h("workflows"),LinkComponent:i}):o.jsx(Ut.NoData,{message:"No workflow data yet"})}),o.jsx(fs,{value:"tools",children:e.toolData.length>0?o.jsx(cse,{data:e.toolData,rowHrefs:p("tools"),errorHrefs:h("tools"),LinkComponent:i}):o.jsx(Ut.NoData,{message:"No tool data yet"})})]}):o.jsx(Ut.NoData,{message:"No trace volume data yet"})})]})}async function use(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",c=J4(s,i,()=>({completed:0,errors:0}));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 ass(){const e=We(),{filters:t,filterKey:n}=Em();return wt({queryKey:["metrics","trace-volume",n],queryFn:async()=>{const[r,s,a]=await Promise.all([use(e,"mastra_agent_duration_ms",t),use(e,"mastra_workflow_duration_ms",t),use(e,"mastra_tool_duration_ms",t)]);return{agentData:r,workflowData:s,toolData:a}}})}const cF={agents:Os.AGENT,workflows:Os.WORKFLOW_RUN,tools:Os.TOOL};function iss(){const{data:e,isLoading:t,isError:n}=ass(),{getTracesHref:r,getLogsHref:s}=jI(),{Link:a}=yn();return o.jsx(sss,{data:e,isLoading:t,isError:n,LinkComponent:a,getRowHref:(i,l)=>r({rootEntityType:cF[i],entityName:l.name}),getErrorSegmentHref:(i,l)=>l.errors>0?s({rootEntityType:cF[i],entityName:l.name,status:"error"}):void 0,actions:i=>o.jsxs(o.Fragment,{children:[o.jsx(K4,{href:r({rootEntityType:cF[i]}),LinkComponent:a}),o.jsx(brs,{href:s({rootEntityType:cF[i],status:"error"}),LinkComponent:a})]})})}const oss=new Set(["ObservabilityStorageClickhouseVNext","ObservabilityStorageDuckDB","ObservabilityInMemory","ObservabilitySpanner","ObservabilityStoragePostgresVNext"]),dse="period",uF="dateFrom",dF="dateTo";function lss(){const[e,t]=ga(),n=e.get(dse),r=drs(n)?n:"24h",s=g.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(uF)),p=d(e.get(dF));if(!(!f&&!p))return{from:f,to:p}},[r,e.toString()]),a=g.useMemo(()=>srs(e),[e.toString()]),i=g.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d==="24h"?p.delete(dse):p.set(dse,d),d!=="custom"&&(p.delete(uF),p.delete(dF)),p},{replace:!0})},[t]),l=g.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d?.from?p.set(uF,d.from.toISOString()):p.delete(uF),d?.to?p.set(dF,d.to.toISOString()):p.delete(dF),p},{replace:!0})},[t]),c=g.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return irs(p,d),p},{replace:!0})},[t]),u=g.useRef(!1);return g.useEffect(()=>{if(u.current||(u.current=!0,nrs(e)))return;const d=z9t();d&&t(f=>{const p=new URLSearchParams(f);for(const[h,m]of d)p.append(h,m);return p},{replace:!0})},[]),o.jsx(prs,{preset:r,filterTokens:a,onPresetChange:i,onFilterTokensChange:c,customRange:s,onCustomRangeChange:l,children:o.jsx(css,{})})}function css(){const[e]=ga(),{error:t,isLoading:n}=q9t(),{filterTokens:r,setFilterTokens:s}=tG(),[a,i]=g.useState(),{data:l,isLoading:c}=a4(),u=l?.observabilityStorageType,d=u?oss.has(u):!1,f=u==="ObservabilityInMemory",{data:p,isLoading:h}=gTe(),{data:m,isLoading:v}=pTe(),{data:y,isLoading:b}=mTe(),{data:S,isLoading:w}=hTe(),k=g.useMemo(()=>rrs({availableTags:p??[],availableEntityNames:m??[],availableServiceNames:y??[],availableEnvironments:S??[],loading:{tags:h,entityNames:v,serviceNames:b,environments:w}}),[p,m,y,S,h,v,b,w]),[_,C]=g.useState(()=>z9t()!==null),E=g.useCallback(()=>{ers(e),C(!0),De.success("Filters setting for Metrics saved")},[e]),j=g.useCallback(()=>{trs(),C(!1),De.success("Filters setting for Metrics cleared up")},[]),N=g.useCallback(()=>{s([])},[s]),I=g.useCallback(()=>{const R=r.map(P=>{const L=k.find(M=>M.id===P.fieldId);return L?L.kind==="text"?{fieldId:P.fieldId,value:""}:L.kind==="pick-multi"?L.multi?{fieldId:P.fieldId,value:[]}:{fieldId:P.fieldId,value:"Any"}:L.kind==="multi-select"?{fieldId:P.fieldId,value:[]}:P:P});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(zi,{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(vrs,{}),o.jsx(cTe,{fields:k,tokens:r,onTokensChange:s,disabled:n,onStartTextFilter:i})]})}),o.jsx(Brs,{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(qve,{children:[o.jsx(Mrs,{}),o.jsx(Drs,{}),o.jsx(Lrs,{}),o.jsx(Frs,{}),o.jsx(zrs,{})]}),o.jsxs(qve,{children:[o.jsx(Hrs,{}),o.jsx(Qrs,{}),o.jsx(rss,{}),o.jsx(Irs,{}),o.jsx(iss,{}),o.jsx(Crs,{})]})]}):o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Cr,{iconSlot:o.jsx(Of,{}),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(de,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/observability/metrics/overview",target:"_blank",rel:"noopener noreferrer",children:["Metrics Documentation ",o.jsx(_a,{})]})})})]})}function uss(){const{paths:e}=yn(),{data:t,isLoading:n,error:r}=c6t(),{isCmsAvailable:s}=Y1(),[a,i]=g.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(zi,{title:"Failed to load prompt blocks",message:r.message})}):l.length===0&&!n?o.jsx(lr,{children:o.jsx(WZr,{})}):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(jf,{onSearch:i,label:"Filter prompts",placeholder:"Filter by name or description"})}),s&&o.jsxs(de,{as:Ba,to:e.cmsPromptBlockCreateLink(),variant:"primary",className:"shrink-0",children:[o.jsx(Vr,{}),"Create Prompt"]})]})}),o.jsx(HZr,{promptBlocks:l,isLoading:n,search:a})]})}function dss(){return o.jsx(Lt,{width:"narrow",children:o.jsx(Lt.MainArea,{children:o.jsx(Z7r,{children:o.jsx(mve,{})})})})}const fss=[{title:"Mastra APIs",description:"Explore and test the available REST API endpoints with the interactive Swagger UI.",icon:Wcn,href:"/swagger-ui",external:!1},{title:"Documentation",description:"Read the official Mastra documentation for guides, references, and tutorials.",icon:jlt,href:"https://mastra.ai/en/docs",external:!0},{title:"Github",description:"Browse the source code, report issues, and contribute to the Mastra project.",icon:_a,href:"https://github.com/mastra-ai/mastra",external:!0},{title:"Community",description:"Join the Mastra Discord community for help, discussion, and collaboration.",icon:Yj,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:Mlt,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:Tlt,href:"https://mastra.ai/contact?ref=studio",external:!0}];function pss(){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:fss.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(_a,{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 hss(){const{data:e={},isLoading:t,error:n}=ih(),[r,s]=g.useState(""),[a,i]=g.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(zi,{title:"Failed to load scorers",message:n.message})});if(Object.keys(e).length===0&&!t)return o.jsx(lr,{children:o.jsx(aWr,{})});const l=a!=="all"||r!=="",c=()=>{s(""),i("all")};return o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx(oWr,{search:r,onSearchChange:s,sourceFilter:a,onSourceFilterChange:i,onReset:c,hasActiveFilters:l})}),o.jsx(sWr,{scorers:e,isLoading:t,search:r,sourceFilter:a})]})}function mss(){const{scorerId:e}=ur(),[t,n]=ga(),r=t.get("scoreId")??void 0,[s,a]=g.useState(r),[i,l]=g.useState({value:"all",label:"All Entities",type:"ALL"}),{scorer:c,error:u}=$Hr(e),{data:d={},isLoading:f,error:p}=km(),{isLoading:h,error:m}=Uy(),{data:v=[],isLoading:y,error:b,isFetchingNextPage:S,hasNextPage:w,setEndOfListElement:k}=PHr({scorerId:e,entityId:i?.value==="all"?void 0:i?.value,entityType:i?.type==="ALL"?void 0:i?.type}),_=g.useMemo(()=>c?.agentIds?.filter(B=>d[B]).map(B=>({value:B,label:d[B].name,type:"AGENT"}))||[],[c?.agentIds,d]),C=g.useMemo(()=>c?.workflowIds?.map(B=>({value:B,label:B,type:"WORKFLOW"}))||[],[c?.workflowIds]),E=g.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),g.useEffect(()=>{if(u){const B=u instanceof Error?u.message:"Failed to load scorer";De.error(`Error loading scorer: ${B}`)}},[u]),g.useEffect(()=>{if(p){const B=p instanceof Error?p.message:"Failed to load agents";De.error(`Error loading agents: ${B}`)}},[p]),g.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(D=>{const Q=new URLSearchParams(D);return Q.set("entity",B.value),Q})};g.useEffect(()=>{const B=t.get("scoreId")??void 0;if(B===s)return;if(!B){a(void 0);return}v.find(Q=>Q.id===B)&&a(B)},[t,v]);const R=g.useCallback(B=>{a(B||void 0),n(D=>{const Q=new URLSearchParams(D);return B?Q.set("scoreId",B):Q.delete("scoreId"),Q})},[n]);if(!c)return null;const P=gs(u)||gs(p)||gs(m),L=u&&ys(u),M=!P&&!L&&(u||p||m),q=!y&&v.length===0,H=i?.value!=="all",F=c?.scorer?.source==="stored"?o.jsx(Iy,{owner:"scorer-detail",children:o.jsxs(de,{variant:"default",as:Ba,to:`/cms/scorers/${e}/edit`,size:"sm",children:[o.jsx(Lp,{})," Edit"]})}):null;if(P||L||M||q&&!H){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:[F,o.jsx(Lt.MainArea,{isCentered:!0,children:P?o.jsx(Vs,{}):L?o.jsx(Ds,{resource:"scorers"}):M?o.jsx(zi,{title:"Failed to load scorer",message:B}):o.jsx(THr,{})})]})}return o.jsxs(Lt,{width:"wide",children:[F,o.jsx(Lt.TopArea,{children:o.jsx(NHr,{selectedEntity:i,entityOptions:E,onEntityChange:I,onReset:()=>{n(B=>{const D=new URLSearchParams(B);return D.set("entity","all"),D})},isLoading:y||f||h})}),o.jsx(jHr,{scores:v,isLoading:y,selectedScoreId:s,isFetchingNextPage:S,hasNextPage:w,setEndOfListElement:k,onScoreClick:R,errorMsg:b?.message})]})}function gss({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 Z9t=[{value:"dark",label:"Dark",Icon:wdn},{value:"light",label:"Light",Icon:Nfn},{value:"system",label:"System",Icon:Wlt}],vss=e=>Z9t.some(t=>t.value===e);function yss({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 bss=()=>{const{baseUrl:e,headers:t,apiPrefix:n}=qxe(),{theme:r,setTheme:s}=PN();return o.jsx(Lt,{width:"narrow",children:o.jsxs(Lt.MainArea,{className:"flex flex-col gap-5 mt-6",children:[o.jsx(Yge,{title:"Theme",description:"Customize the appearance of the studio.",children:o.jsx(gss,{label:"Theme mode",htmlFor:"theme",children:o.jsxs(da,{value:r,onValueChange:a=>{vss(a)&&s(a)},children:[o.jsx(pa,{id:"theme",className:"w-full sm:w-48",children:o.jsx(fa,{className:"inline-flex min-w-0 max-w-full items-center"})}),o.jsx(ha,{children:Z9t.map(a=>o.jsx(Lr,{value:a.value,children:o.jsx(yss,{option:a})},a.value))})]})})}),o.jsx(Yge,{title:"Mastra Connection",description:"Configure the Mastra instance URL, API prefix, and request headers used by the studio.",children:o.jsx(lRt,{initialConfig:{baseUrl:e,headers:t,apiPrefix:n}})})]})})};function xss(){const[e]=ga(),t=bs(),n=e.get("redirect")||"/",r=()=>{n.startsWith("http")?window.location.href=n:t(n,{replace:!0})};return o.jsx(D9t,{redirectUri:n,onSuccess:r,initialMode:"signup"})}const G9t=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 wss(e){return e.replace(/\/$/,"").split("/").pop()}function nG({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 Sss({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(sl,{})," ",a.agents.length]}),a?.tools&&a.tools.length>0&&o.jsxs("li",{children:[o.jsx(eh,{})," ",a.tools.length]}),a?.networks&&a.networks.length>0&&o.jsxs("li",{children:[o.jsx(Zlt,{})," ",a.networks.length]}),a?.workflows&&a.workflows.length>0&&o.jsxs("li",{children:[o.jsx(vD,{})," ",a.workflows.length]}),a?.mcp&&a.mcp.length>0&&o.jsxs("li",{children:[o.jsx(B_,{})," ",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(G9t,{})," ",wss(a.githubUrl)]})})]},a.slug)})})}function kss({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(BT,{name:"search-templates",label:"Search templates",labelIsHidden:!0,value:i,onChange:f=>l?.(f.target.value),placeholder:"Search Template"}),o.jsx(Sc,{label:"Filter by tag",labelIsHidden:!0,name:"filter-tag",value:t,onValueChange:s,options:e}),o.jsx(Sc,{label:"Filter by provider",labelIsHidden:!0,name:"filter-provider",value:r,onValueChange:a,options:n}),c&&o.jsxs(de,{onClick:c,children:["Reset ",o.jsx(vs,{})]})]})}function Oss(){const{data:e,isLoading:t}=wYn(),{templates:n,tags:r,providers:s}=e??{templates:[],tags:[],providers:[]},[a,i]=g.useState("all"),[l,c]=g.useState("all"),[u,d]=g.useState(""),f=[{value:"all",label:"Any tag"}];(r||[]).forEach(S=>{f.push({value:S,label:S})});const p=[{value:"all",label:"Any provider"}];(s||[]).forEach(S=>{p.push({value:S,label:S})});const h=(S,w)=>{w==="tag"?i(S):w==="provider"&&c(S)},m=S=>{d(S)},v=()=>{i("all"),c("all"),d("")},y=n.filter(S=>!(u&&!S.title.toLowerCase().includes(u)&&!S.description.toLowerCase().includes(u)||a!=="all"&&!S.tags.includes(a)||l!=="all"&&!S.supportedProviders.includes(l))),b=u||a!=="all"||l!=="all";return o.jsxs(ls,{children:[o.jsx(e0e,{children:o.jsxs(Lpt,{children:[o.jsx(Ue,{children:o.jsx(Zv,{})}),"Templates"]})}),o.jsxs("div",{className:K("overflow-y-auto w-full h-full px-8 pb-12 z-10"),children:[o.jsx(kss,{selectedTag:a,onTagChange:S=>h(S,"tag"),tagOptions:f,selectedProvider:l,onProviderChange:S=>h(S,"provider"),providerOptions:p,searchTerm:u,onSearchChange:m,onReset:b?v:void 0,className:"max-w-[80rem]",isLoading:t}),o.jsx(Sss,{templates:y,linkComponent:Ba,className:"max-w-[80rem] mx-auto",isLoading:t})]})]})}const _ss="1.50.0-alpha.1";function Css({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(Ep,{className:"text-yellow-500"}),title:"Template Installed with Warnings"}:{icon:o.jsx(wun,{}),title:"Template Installation Failed"},{icon:l,title:c}=i();return o.jsxs(nG,{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 Ess({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(nG,{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(Glt,{})]}),o.jsx(Sc,{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(g.Fragment,{children:[o.jsx(yO,{name:`env-${p}`,labelIsHidden:!0,label:"Key",value:p,disabled:!0,className:"w-full"}),o.jsx(yO,{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(zLt,{defaultProvider:u||"",defaultModel:d||"",updateModel:f||(()=>Promise.resolve({message:"Updated"})),closeEditor:()=>{},autoSave:!0,selectProviderPlaceholder:"Provider"})]})]}),t&&!l&&o.jsx(de,{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(mm,{})]})})]})})}function jss({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(Zv,{}),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(Fx,{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(sbe,{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(G9t,{}),n?.split("/")?.pop()]})]}),s&&o.jsx(Bje,{data:s,labelsAreHidden:!0,isLoading:r})]})]})}function Tss(e){switch(e){case"running":return o.jsx(Gt,{});case"success":return o.jsx(vx,{});case"failed":return o.jsx(Fu,{});default:return null}}function Nss({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",ms.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",ms.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",ms.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",ms.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:Tss(t.status)})]})}function Iss({currentStep:e,steps:t=[],className:n}){return o.jsx("div",{className:K(n),children:t.map((r,s)=>o.jsx(Nss,{stepId:r.id,step:r,isActive:e?.id===r.id,position:s+1},r.id))})}function Ass({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]",ms.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",ms.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",ms.colors),children:[n," of ",t," steps completed"]})]})}function Rss({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=v=>v==="input"||v.endsWith(".input")||v.startsWith("Mapping_")&&/[0-9a-f]{8}/.test(v)||/[0-9a-f]{8,}/.test(v)?!1:r?.allSteps?v in r.allSteps:!0,f=Object.entries(c).filter(([v,y])=>d(v)),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(([v,y])=>({id:v,status:y?.status,description:y?.description,title:v.charAt(0).toUpperCase()+v.slice(1).replace(/-/g," "),isActive:i?.id===v}));return o.jsxs(nG,{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(Ass,{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(Idn,{}),l||"Something went wrong"]}),u&&o.jsx(Iss,{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 Pss({name:e,installedEntities:t}){return o.jsxs(nG,{className:K("grid items-center justify-items-center gap-4 content-center","[&>svg]:w-8 [&>svg]:h-8"),children:[o.jsx(Glt,{}),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(Bje,{data:t})]})}function $ss(){const{templateSlug:e}=ur(),[t,n]=ga(),[r,s]=g.useState(""),[a,i]=g.useState(""),[l,c]=g.useState(""),[u,d]=g.useState({}),[f,p]=g.useState([]),[h,m]=g.useState(null),[v,y]=g.useState(!1),[b,S]=g.useState(""),[w,k]=g.useState(!1),[_,C]=g.useState(!1),[E,j]=g.useState([]),{data:N,isLoading:I}=SYn({repoOrSlug:e,owner:"mastra-ai"}),P=_ss?.includes("beta")??!1?"beta":"main",{data:L,isLoading:M}=kYn({repo:N?.githubUrl?new URL(N.githubUrl).pathname.split("/")[2]:`template-${e}`,owner:"mastra-ai",branch:P}),{data:q,isLoading:H}=OYn(),{mutateAsync:F,isPending:z}=_Yn(),{mutateAsync:B}=CYn(),{streamInstall:D,streamResult:Q,isStreaming:V}=jYn(q),{observeInstall:$,streamResult:U,isStreaming:Z}=TYn(q);g.useEffect(()=>{const ne=t.get("runId");ne&&!v&&!h&&!V&&!Z&&(console.info("🔄 Checking completed run after hot reload:",{runId:ne}),S(ne),B({runId:ne}).then(ue=>{const pe=ue.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(ue=>{console.error("❌ Failed to fetch run details:",ue),m("Failed to retrieve installation status after reload")}))},[t,v,h,V,Z,B]),g.useEffect(()=>{const ne=t.get("runId"),ue=t.get("resume"),pe=t.get("provider");if(ne&&ue==="true"&&pe&&!V&&!Z&&!w&&!_&&q){S(ne),k(!0);try{B({runId:ne}).then(le=>{if(le.snapshot?.status==="running")return $.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,V,Z,w,_,q,B,$,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(eh,{})},{key:"agents",label:"Agents",value:N?.agents?.length?N.agents.map(ne=>ne).join(", "):"n/a",icon:o.jsx(sl,{})},{key:"workflows",label:"Workflows",value:N?.workflows?.length?N.workflows.map(ne=>ne).join(", "):"n/a",icon:o.jsx(vD,{})},{key:"providers",label:"Providers",value:N?.supportedProviders?.length?N.supportedProviders.join(", "):"n/a",icon:o.jsx(Rv,{})},{key:"tags",label:"Tags",value:N?.tags?.length?N.tags.join(", "):"n/a",icon:o.jsx(wN,{})}],J=[{...te[0]},{...te[1]},{...te[2]}].filter(ne=>ne.value!=="n/a");g.useEffect(()=>{L&&d(L)},[L]),g.useEffect(()=>{const ne=Q||U;ne?.phase==="error"&&ne?.error&&m(typeof ne.error=="string"?ne.error:String(ne.error))},[Q?.phase,Q?.error,U?.phase,U?.error]);const ee=ne=>{s(ne)},ae=async ne=>(i(ne.provider),c(ne.modelId),{message:"Model updated successfully"}),ce=async()=>{const ne=Object.entries(u).reduce((ue,[pe,le])=>(le===""&&ue.push(pe),ue),[]);if(ne.length>0){p(ne);return}if(N){m(null),y(!1),S(""),C(!0);try{const pe={repo:N.githubUrl||`https://github.com/mastra-ai/template-${N.slug}`,ref:P,slug:N.slug,variables:u},{runId:le}=await F({});S(le),n(ve=>{const ye=new URLSearchParams(ve);return ye.set("runId",le),ye.set("resume","true"),ye.set("provider",r||"openai"),ye}),await D.mutateAsync({inputData:pe,selectedModel:{provider:a,modelId:l},runId:le})}catch(ue){C(!1),m(ue?.message||"Template installation failed"),console.error("Template installation failed",ue)}}},Y=ne=>{const{name:ue,value:pe}=ne.target;pe.trim()===""?p(le=>[...le,ue]):p(le=>le.filter(ve=>ve!==ue)),d(le=>({...le,[ue]:pe}))};return o.jsx(ls,{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(jss,{isLoading:I,title:N?.title,description:N?.longDescription,imageURL:N?.imageURL,githubUrl:N?.githubUrl,infoData:te,templateSlug:e}),N&&o.jsxs(o.Fragment,{children:[(V||Z)&&o.jsx(Rss,{name:N.title,streamResult:Z?U:Q,runId:b,workflowInfo:q}),v&&o.jsx(Pss,{name:N.title,installedEntities:J,linkComponent:Ba}),h&&o.jsx(Css,{errorMsg:h,validationErrors:E.length>0?E:Q?.validationResults?.errors||U?.validationResults?.errors}),!V&&!Z&&!v&&!h&&o.jsx(Ess,{providerOptions:X,selectedProvider:r,onProviderChange:ee,variables:u,setVariables:d,errors:f,setErrors:p,handleInstallTemplate:ce,handleVariableChange:Y,isLoadingEnvVars:M||H,isInstalling:z,defaultModelProvider:a,defaultModelId:l,onModelUpdate:ae})]})]})})})}const Mss=()=>{const{toolId:e,agentId:t}=ur();return o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(cZr,{toolId:e,agentId:t})})},Dss=()=>{const{toolId:e}=ur();return o.jsx("div",{className:"h-full w-full overflow-y-hidden",children:o.jsx(Vns,{toolId:e})})};function Lss(){const{traceId:e}=ur(),[t,n]=ga(),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]=g.useState(s??null),[d,f]=g.useState(),[p,h]=g.useState(i),[m,v]=g.useState(0),[y,b]=g.useState(!1),{data:S,isLoading:w,error:k}=ZH(e),_=g.useMemo(()=>S?.spans??[],[S?.spans]),C=g.useMemo(()=>_.find(ae=>ae.parentSpanId==null),[_]),{data:E,isLoading:j}=oI(e,c??"");g.useEffect(()=>v(0),[e,c]);const{data:N,isLoading:I}=ih(),{data:R,isLoading:P}=s6t({traceId:e,spanId:c??void 0,page:m}),[L,M]=g.useState(0);g.useEffect(()=>M(0),[e,c]);const{data:q,isLoading:H}=C9t({traceId:e,page:L});g.useEffect(()=>{if(l&&R?.scores&&!d){const ae=R.scores.find(ce=>ce.id===l);ae&&f(ae)}},[l,R?.scores,d]);const F=g.useCallback(ae=>{const ce=new URLSearchParams(t);for(const[Y,ne]of Object.entries(ae))ne===null||ne===""?ce.delete(Y):ce.set(Y,ne);n(ce,{replace:!0})},[t,n]),z=g.useCallback(ae=>{const ce=ae??null,Y=ce===c;u(ce),Y||(f(void 0),h("details"),F({spanId:ce,tab:null,scoreId:null}))},[c,F]),B=g.useCallback(()=>{u(null),f(void 0),h("details"),F({spanId:null,tab:null,scoreId:null})},[F]),D=g.useCallback(ae=>{u(ae),f(void 0),h("details"),F({spanId:ae,tab:null,scoreId:null})},[F]),{handlePreviousSpan:Q,handleNextSpan:V}=GH(_,c,D),$=g.useCallback(ae=>{const ce=ae;h(ce),f(void 0),F({tab:ce==="details"?null:ce,scoreId:null})},[F]),U=g.useCallback(ae=>{f(ae),F({scoreId:ae.id})},[F]),Z=g.useCallback(()=>{f(void 0),F({scoreId:null})},[F]),X=g.useCallback(()=>{r("/observability")},[r]),te=g.useCallback(()=>{h("scoring"),C&&c!==C.spanId?(u(C.spanId),f(void 0),F({spanId:C.spanId,tab:"scoring",scoreId:null})):F({tab:"scoring"})},[C,c,F]),J=C?o.jsx(Iy,{owner:"trace-detail",children:o.jsxs(Mr,{children:[o.jsxs(de,{tooltip:"Evaluate Trace","aria-label":"Evaluate Trace",onClick:te,children:[o.jsx(hcn,{}),"Evaluate"]}),o.jsxs(de,{tooltip:"Save as Dataset Item","aria-label":"Save as Dataset Item",onClick:()=>b(!0),children:[o.jsx(gd,{}),"Save"]})]})}):null,ee=C?o.jsx(Lt.Row,{children:o.jsx(Lt.Column,{children:o.jsx(m9t,{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(g9t,{error:k,resource:"traces",errorTitle:"Failed to load trace"})})]}):o.jsxs(Lt,{children:[J,ee&&o.jsx(Lt.TopArea,{children:ee}),o.jsx(w9t,{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(uTe,{traceId:e,spans:_,isLoading:w,onClose:X,onSpanSelect:z,onEvaluateTrace:te,initialSpanId:c,placement:"trace-page",timelineChartWidth:c?"default":"wide"}),c&&!w&&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(WH,{traceId:e,spanId:c,span:E?.span,isLoading:j,onClose:B,onPrevious:Q,onNext:V,activeTab:p,onTabChange:$,feedbackTabBadge:q?.pagination?.total??void 0,feedbackTabSlot:()=>o.jsx(k9t,{feedbackData:q,onPageChange:M,isLoadingFeedbackData:H}),scoringTabBadge:R?.pagination?.total??void 0,scoringTabSlot:({span:ae,traceId:ce,spanId:Y})=>o.jsxs("div",{className:"grid gap-6",children:[o.jsx(_9t,{traceId:ce,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(O9t,{scoresData:R,onPageChange:v,isLoadingScoresData:P,onScoreSelect:U})]})}),d&&o.jsx(zje,{score:d,onClose:Z})]})]})]})}function Fss(){const{data:e,isLoading:t,error:n}=Uy(),[r,s]=g.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(zi,{title:"Failed to load workflows",message:n.message})}):Object.keys(e||{}).length===0&&!t?o.jsx(lr,{children:o.jsx(bDr,{})}):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(jf,{onSearch:s,label:"Filter workflows",placeholder:"Filter by name or description"})}),o.jsxs(de,{as:Ba,to:"/workflows/schedules",variant:"primary",className:"shrink-0",children:[o.jsx(hD,{}),"Schedules"]})]})}),o.jsx(yDr,{workflows:e||{},isLoading:t,search:r})]})}const zss={active:"bg-accent1",paused:"bg-accent3"},Bss={active:"text-accent1",paused:"text-accent3"},Q9t=({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 ${zss[e]}`,"aria-hidden":!0}),o.jsx("span",{className:`text-ui-sm ${Bss[e]}`,children:e})]}),Fj=e=>!e||e<=0?"—":new Date(e).toLocaleString(),dP=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 Y9t({status:e}){const{icon:t,color:n}=Uss(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 Uss(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(lq,{size:14}),color:"text-accent3"};case"canceled":return{icon:o.jsx(Of,{size:14}),color:"text-neutral3"};case"pending":case"waiting":return{icon:o.jsx(dO,{size:14}),color:"text-neutral3"};default:return{icon:null,color:"text-neutral3"}}}const ZQe="auto auto auto auto 1fr";function qss(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 Vss(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 Hss=3e4,Wss=5*6e4;function Zss({triggers:e,isLoading:t,workflowId:n,hasNextPage:r,isFetchingNextPage:s,setEndOfListElement:a}){const{Link:i,paths:l}=yn();return t?o.jsx(tl,{columns:ZQe}):e.length===0?o.jsx(ge,{variant:"ui-md",className:"text-neutral4 p-4",children:"No trigger history yet."}):o.jsxs(me,{columns:ZQe,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=Vss(u),f=`Scheduled ${Fj(c.scheduledFireAt)} — published ${Fj(c.actualFireAt)} (drift ${d})`,p=c.outcome==="failed",h=p?c.error:c.run?.error,m=Math.abs(u),v=!p&&m>Hss&&m<=Wss,y=`${c.scheduleId}-${c.runId}-${c.actualFireAt}`,b=!!(n&&c.runId&&!p),S=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}),w=o.jsxs(o.Fragment,{children:[o.jsx(me.Cell,{height:"compact",children:S}),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(Ep,{size:14}),"publish failed"]}):c.run?o.jsx(Y9t,{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(Ep,{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:dP(c.actualFireAt)}),v?o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx("span",{className:"text-accent3 inline-flex",children:o.jsx(Ep,{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:qss(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:w},y):o.jsx(me.RowStatic,{children:w},y)}),o.jsx(me.NextPageLoading,{isLoading:s,hasMore:r,setEndOfListElement:a})]})}const Gss=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)}})},GQe=25,Qss=e=>{const t=We(),{inView:n,setRef:r}=A_(),s=$1({queryKey:["schedule-triggers",e],enabled:!!e,initialPageParam:void 0,queryFn:async({pageParam:u})=>e?t.listScheduleTriggers(e,{limit:GQe,toActualFireAt:u}):{triggers:[]},getNextPageParam:u=>{if(!(!u?.triggers?.length||u.triggers.length<GQe))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 g.useEffect(()=>{n&&i&&!l&&c()},[n,i,l,c]),{...s,data:a,setEndOfListElement:r}},Yss=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 fF({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 Xss(){const{scheduleId:e}=ur(),{paths:t}=yn(),{data:n,error:r}=Gss(e),{data:s,isLoading:a,error:i,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u}=Qss(e),d=Yss(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(zi,{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(de,{as:Ba,to:t.schedulesLink(),variant:"ghost",children:[o.jsx(Nc,{}),"Back to schedules"]}),f?o.jsx(de,{as:Ba,to:t.workflowLink(f),variant:"ghost",children:"Open workflow"}):null,n?o.jsx(de,{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(Qlt,{}),"Pause"]}):o.jsxs(o.Fragment,{children:[o.jsx(Fp,{}),"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(fF,{label:"Workflow",children:f?o.jsx(Ba,{to:t.workflowLink(f),className:"text-accent1 hover:underline",children:f}):"—"}),o.jsxs(fF,{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(fF,{label:"Status",children:o.jsx(Q9t,{status:n.status})}),o.jsx(fF,{label:"Next fire",children:o.jsx("span",{title:Fj(n.nextFireAt),children:dP(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(zi,{title:"Failed to load trigger history",message:i.message}):o.jsx(Zss,{triggers:s??[],isLoading:a,workflowId:f,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u})]})]}):null]})}const QQe="minmax(0, 1.2fr) minmax(0, 1.4fr) minmax(0, 1fr) auto auto auto";function Kss({schedules:e,isLoading:t,search:n=""}){const{paths:r,Link:s}=yn(),a=g.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(tl,{columns:QQe}):o.jsxs(me,{columns:QQe,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(Q9t,{status:i.status})}),o.jsx(me.Cell,{height:"compact",children:o.jsx("span",{className:"whitespace-nowrap",title:Fj(i.nextFireAt),children:dP(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(Y9t,{status:i.lastRun.status}),o.jsx("span",{className:"text-neutral4 text-ui-sm",title:Fj(i.lastFireAt),children:i.lastFireAt?dP(i.lastFireAt):""})]}):i.lastFireAt?o.jsx("span",{className:"whitespace-nowrap",title:Fj(i.lastFireAt),children:dP(i.lastFireAt)}):o.jsx("span",{className:"text-neutral4",children:"Never"})})]},i.id))]})}function Jss({workflowId:e}={}){const{data:t,isLoading:n,error:r}=Kxe(e?{workflowId:e}:{}),[s,a]=g.useState("");return r?o.jsx(zi,{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(jf,{onSearch:a,label:"Filter schedules",placeholder:"Filter by id or workflow"})}),o.jsx("div",{className:"overflow-y-auto",children:o.jsx(Kss,{schedules:t??[],isLoading:n,search:s})})]})}function eas(){const[e]=ga(),t=e.get("workflowId")??void 0,{error:n}=Kxe(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(Jss,{workflowId:t})})})}function tas({stepGraph:e,open:t,workflowName:n}){const{nodes:r,edges:s}=N1e({stepGraph:e}),[a,i]=g.useState(!1),[l,c,u]=vwt(r),[d]=ywt(s),{edgeTypes:f,nodeTypes:p,styledEdges:h}=R2t({edges:d,workflowName:n,stepGraph:e});return g.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(gwt,{nodes:l,edges:h,edgeTypes:f,fitView:!0,fitViewOptions:{maxZoom:1},minZoom:.01,maxZoom:1,nodeTypes:p,onNodesChange:u,children:[o.jsx(W_e,{position:"bottom-left"}),o.jsx(xwt,{variant:ey.Lines,gap:12,size:.5})]}):o.jsx("div",{className:"w-full h-full flex items-center justify-center",children:o.jsx(Gt,{})})})}function nas(){const{stepDetail:e,closeStepDetail:t}=ZV();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(efe,{className:"w-4 h-4",style:{color:Cu.map}}),e.type==="nested-graph"&&o.jsx(jd,{className:"w-4 h-4",style:{color:Cu.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(iP,{data:e.mapConfig}),e.type==="nested-graph"&&e.nestedGraph&&o.jsx("div",{className:"h-full min-h-[400px]",children:o.jsx(T1e,{children:o.jsx(tas,{stepGraph:e.nestedGraph.stepGraph,open:!0,workflowName:e.nestedGraph.fullStep})},`nested-graph-${e.nestedGraph.fullStep}`)})]})]}):null}function ras(e){const t=new Blob([JSON.stringify(e??null)]).size;return t<1024?`${t} B`:`${(t/1024).toFixed(1)} KB`}function sas(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 aas({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(lq,{})}),"Step suspended"]}),o.jsx(dn,{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?lm(im(yx(i.resumeSchema))):op(dr(),cT());return o.jsx(ias,{step:s,stepSchema:l,description:i.description,isStreaming:n,onResume:r},`${s.runId}-${s.stepId}-${a}`)})]})}function ias({step:e,stepSchema:t,description:n,isStreaming:r,onResume:s}){const[a,i]=g.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(kdn,{})}),"The step is asking"]}),o.jsxs(xf,{open:a,onOpenChange:i,children:[o.jsxs(Od,{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(ta,{className:K("transition-transform text-neutral3",{"transform rotate-90":a})})}),o.jsx(ge,{as:"span",variant:"ui-md",className:"text-neutral6 truncate",children:sas(e.suspendPayload,e.stepId)})]}),o.jsx(ge,{as:"span",variant:"ui-sm",className:"text-neutral3 shrink-0",children:ras(e.suspendPayload)})]}),o.jsx(_d,{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(Cdn,{})}),"Your response"]}),o.jsx("div",{className:"-mx-5",children:o.jsx(B7,{schema:t,isSubmitLoading:r,submitButtonLabel:"Resume",submitButtonIcon:o.jsx(Fp,{}),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 oas(){const{result:e,runSnapshot:t,workflow:n,runId:r,isStreamingWorkflow:s}=g.useContext($l),{runId:a}=ur(),i=Ewt(e,r??""),l=LZn(),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(aas,{suspendedSteps:i,workflow:n,isStreaming:s,onResume:l})},r)}const las=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"})]}),cas=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"})]}),uas=e=>e.includes("."),das=e=>e==="input"||e.endsWith(".input"),fas=1;function pas(e){return`${Number((e/1e3).toPrecision(3))}s`}function has(e,t){const n=Object.entries(e).filter(([i])=>!das(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,fas);return{stepId:i,step:l,status:l.status,offsetPct:f,widthPct:p,durationMs:d,isRunning:c,isNestedEntry:uas(i)}})}const mas=({status:e})=>o.jsxs(Ue,{children:[e==="success"&&o.jsx(las,{className:"text-accent1"}),e==="failed"&&o.jsx(cas,{className:"text-accent2"}),e==="suspended"&&o.jsx(lq,{className:"text-accent3"}),e==="waiting"&&o.jsx(Jde,{className:"text-accent5"}),e==="skipped"&&o.jsx(Jde,{className:"text-icon3"}),e==="running"&&o.jsx(oa,{className:"text-accent6 animate-spin"})]}),gas={success:"bg-accent1",failed:"bg-accent2",suspended:"bg-accent3",waiting:"bg-accent5",skipped:"bg-border1",running:"bg-accent6"};function X9t(e){return e.split(/[-_.\s]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}const YQe=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{value:e},vas=e=>{const t=e;return O2t({duration:t.duration,date:t.date,isForEach:t.isForEach,mapConfig:t.mapConfig,canSuspend:t.canSuspend,isParallel:t.isParallel,stepGraph:t.stepGraph})},yas=({row:e,index:t,isSelected:n,isHovered:r,onSelectStep:s,onHoverStep:a,onOpenInput:i,onOpenOutput:l})=>{const c=vas(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(mas,{status:e.status})}),o.jsx("div",{className:"flex justify-center",children:o.jsx(de,{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(Ofn,{})})}),o.jsx("div",{className:"flex overflow-hidden",children:o.jsx(hU,{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:X9t(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 ${gas[e.status]}`,style:{left:`${e.offsetPct}%`,width:`${e.widthPct}%`}})}),o.jsx("div",{className:"flex justify-center",children:o.jsx(de,{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(Sfn,{})})}),o.jsx(ge,{as:"span",variant:"ui-sm",className:"w-20 justify-self-end text-right text-neutral3 tabular-nums",children:pas(e.durationMs)})]},`timeline-item-${e.stepId}-${t}`)};function bas(){const{steps:e}=u4(),{selectedStepId:t,hoverStepId:n,setSelectedStepId:r,setHoverStepId:s}=sV(),[a,i]=g.useState(()=>Date.now()),[l,c]=g.useState(!1),[u,d]=g.useState(null),f=g.useRef(null);i0e(f,{enabled:!l});const p=has(e,a),h=p.some(m=>m.isRunning);return g.useEffect(()=>{if(!h)return;const m=setInterval(()=>i(Date.now()),100);return()=>clearInterval(m)},[h]),g.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(Sa,{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,v)=>o.jsx(yas,{row:m,index:v,isSelected:t===m.stepId,isHovered:n===m.stepId,onSelectStep:r,onHoverStep:s,onOpenInput:y=>d({type:"input",stepId:y.stepId,data:YQe(y.step.input)}),onOpenOutput:y=>d({type:"output",stepId:y.stepId,data:YQe(y.step.output)})},`timeline-item-${m.stepId}-${v}`))})]})}),o.jsx(br,{open:!!u,onOpenChange:m=>!m&&d(null),children:u&&o.jsx(Twt,{data:u.data,title:`${X9t(u.stepId)} ${u.type==="input"?"input":"output"}`})})]})}const xas=({workflowId:e,workflow:t,isLoading:n})=>{const{stepDetail:r}=ZV();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(B2t,{workflowId:e,workflow:t,isLoading:n}),o.jsx(oas,{}),o.jsx(bas,{})]})}),r&&o.jsx("div",{className:"w-[420px] min-h-0 overflow-hidden border-l border-border1",children:o.jsx(nas,{})})]})},XQe=()=>{const{workflowId:e}=ur(),{data:t,isLoading:n,error:r}=S3(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(Z1e,{children:o.jsx(xas,{workflowId:e,workflow:t??void 0,isLoading:n})})};function was(e,t){if(e==null)return{};var n,r,s=Rbt(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 Gve(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 Sas(e){if(Array.isArray(e))return Gve(e)}function kas(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Oas(e,t){if(e){if(typeof e=="string")return Gve(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)?Gve(e,t):void 0}}function _as(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
727
+ ]`})]})]})}function Ses({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(Ep,{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 kes({datasetId:e,open:t,onOpenChange:n,onSuccess:r}){const[s,a]=g.useState("upload"),[i,l]=g.useState(null),[c,u]=g.useState({current:0,total:0}),[d,f]=g.useState(null),[p,h]=g.useState(!1),{parseFile:m,isParsing:v,error:y}=QKr(),{batchInsertItems:b}=Ei(),S=g.useCallback(async I=>{try{const R=await m(I);l(R),a("preview")}catch{}},[m]),w=g.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=g.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]),_=g.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(wes,{onFileSelect:S,isParsing:v,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(Ses,{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(xes,{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(de,{onClick:_,children:"Cancel"});case"preview":return o.jsxs(o.Fragment,{children:[o.jsx(de,{onClick:()=>a("upload"),children:"Back"}),o.jsxs(de,{variant:"primary",onClick:w,disabled:!C,children:["Import ",i?.items.length??0," Item",i?.items.length!==1?"s":""]})]});case"importing":return null;case"complete":return o.jsx(de,{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(Rr,{className:"min-h-[200px] max-h-[50vh] overflow-y-auto",children:E()}),o.jsx(Cc,{className:"px-6 pt-4 flex justify-end gap-2",children:j()})]})})}const xTe=e=>{const t=We(),{data:n}=tD(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})},Oes=e=>{const t=We(),{data:n}=tD(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 _es(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 A9t({datasetId:e,experimentId:t,featuredItemId:n}){const r=We(),{data:s}=Hx(e),{data:a,isLoading:i}=xTe(e),{data:l,isLoading:c}=Oes(e),u=g.useMemo(()=>t?(a??[]).filter(Ee=>Ee.experimentId===t):a,[a,t]),d=g.useMemo(()=>t?(l??[]).filter(Ee=>Ee.experimentId===t):l,[l,t]),{updateExperimentResult:f}=Ei(),[p,h]=g.useState(n??null);g.useEffect(()=>{n!==void 0&&h(n)},[n]);const[m,v]=g.useState(null),[y,b]=g.useState(new Set),[S,w]=g.useState(!1),[k,_]=g.useState(!1),[C,E]=g.useState(!1),[j,N]=g.useState(""),[I,R]=g.useState(""),[P,L]=g.useState(""),[M,q]=g.useState([]),[H,F]=g.useState(!1),[z,B]=g.useState(null),D=g.useMemo(()=>z??u??[],[z,u]);g.useEffect(()=>{B(null)},[e,t]),g.useEffect(()=>{u&&z===null&&B(u)},[u,z]);const Q=g.useMemo(()=>{const Ee=new Set;if(s?.tags)for(const _e of s.tags)Ee.add(_e);for(const _e of D)for(const Ce of _e.tags)Ee.add(Ce);return[...Ee].sort()},[s,D]),V=g.useCallback(Ee=>{!s||!e||(s.tags??[]).includes(Ee)},[s,e]),$=g.useMemo(()=>m?m==="__untagged__"?D.filter(Ee=>Ee.tags.length===0):D.filter(Ee=>Ee.tags.includes(m)):D,[D,m]),U=g.useMemo(()=>{const Ee=new Map;for(const _e of D)for(const Ce of _e.tags)Ee.set(Ce,(Ee.get(Ce)??0)+1);return[...Ee.entries()].sort((_e,Ce)=>Ce[1]-_e[1])},[D]),Z=g.useMemo(()=>D.filter(Ee=>Ee.tags.length===0).length,[D]),X=g.useMemo(()=>{let Ee=0;return m&&Ee++,S&&Ee++,Ee},[m,S]),te=g.useCallback((Ee,_e)=>{B(Oe=>(Oe??[]).map(Re=>Re.id===Ee?{...Re,tags:_e}:Re));const Ce=D.find(Oe=>Oe.id===Ee);Ce?.experimentId&&Ce?.datasetId&&f.mutate({datasetId:Ce.datasetId,experimentId:Ce.experimentId,resultId:Ce.id,tags:_e})},[D,f]),J=g.useCallback((Ee,_e)=>{const Ce=D.find(Oe=>Oe.id===Ee);Ce?.traceId&&_e!==void 0&&r.createFeedback({feedback:{traceId:Ce.traceId,source:"studio",feedbackSource:"studio",feedbackType:"rating",value:_e==="positive"?1:-1,experimentId:Ce.experimentId??void 0,sourceId:Ce.id}}).catch(()=>{}),B(Oe=>(Oe??[]).map(Re=>Re.id===Ee?{...Re,rating:_e}:Re))},[D,r]),ee=g.useCallback((Ee,_e)=>{const Ce=D.find(Oe=>Oe.id===Ee);Ce?.traceId&&r.createFeedback({feedback:{traceId:Ce.traceId,source:"studio",feedbackSource:"studio",feedbackType:"comment",value:_e,comment:_e,experimentId:Ce.experimentId??void 0,sourceId:Ce.id}}).catch(()=>{}),B(Oe=>(Oe??[]).map(Re=>Re.id===Ee?{...Re,comment:_e}:Re))},[D,r]),ae=g.useCallback(Ee=>{const _e=D.find(Ce=>Ce.id===Ee);B(Ce=>(Ce??[]).filter(Oe=>Oe.id!==Ee)),b(Ce=>{const Oe=new Set(Ce);return Oe.delete(Ee),Oe}),p===Ee&&h(null),_e?.experimentId&&_e?.datasetId&&f.mutate({datasetId:_e.datasetId,experimentId:_e.experimentId,resultId:_e.id,status:null})},[D,f,p]),ce=g.useCallback(Ee=>{const _e=D.find(Ce=>Ce.id===Ee);B(Ce=>(Ce??[]).filter(Oe=>Oe.id!==Ee)),b(Ce=>{const Oe=new Set(Ce);return Oe.delete(Ee),Oe}),p===Ee&&h(null),_e?.experimentId&&_e?.datasetId&&f.mutate({datasetId:_e.datasetId,experimentId:_e.experimentId,resultId:_e.id,status:"complete"})},[D,f,p]),Y=g.useMemo(()=>{const Ee=S?d??[]:$;return!S||!m?Ee:m==="__untagged__"?Ee.filter(_e=>_e.tags.length===0):Ee.filter(_e=>_e.tags.includes(m))},[S,d,$,m]),ne=S?c:!1,ue=g.useMemo(()=>new Set(Y.map(Ee=>Ee.id)),[Y]),pe=g.useMemo(()=>[...y].filter(Ee=>ue.has(Ee)).length,[y,ue]),le=Y.length>0&&pe===Y.length,ve=pe>0&&!le,ye=g.useCallback(Ee=>{b(_e=>{const Ce=new Set(_e);return Ce.has(Ee)?Ce.delete(Ee):Ce.add(Ee),Ce})},[]),Se=g.useCallback(()=>{b(le?new Set:new Set(Y.map(Ee=>Ee.id)))},[le,Y]),Ne=g.useCallback(Ee=>{for(const _e of y){const Ce=D.find(Oe=>Oe.id===_e);Ce&&!Ce.tags.includes(Ee)&&te(_e,[...Ce.tags,Ee])}},[D,y,te]),ke=g.useCallback(Ee=>{for(const _e of y){const Ce=D.find(Oe=>Oe.id===_e);Ce&&Ce.tags.includes(Ee)&&te(_e,Ce.tags.filter(Oe=>Oe!==Ee))}},[D,y,te]),Ie=g.useCallback(()=>{for(const Ee of y)ce(Ee);b(new Set)},[y,ce]),ze=g.useCallback(()=>{for(const Ee of y)ae(Ee);b(new Set)},[y,ae]),oe=g.useCallback(()=>{N(""),E(!0)},[]),se=g.useCallback(async()=>{if(!(!I||!P)){_(!0),E(!1);try{const Ee=D.filter(Ce=>y.has(Ce.id));if(Ee.length===0){_(!1);return}const _e=await r.clusterFailures({modelId:`${I}/${P}`,items:Ee.map(Ce=>({id:Ce.id,input:Ce.input,output:Ce.output??void 0,error:typeof Ce.error=="string"?Ce.error:Ce.error?String(Ce.error):void 0,scores:Ce.scores,existingTags:Ce.tags.length>0?Ce.tags:void 0})),availableTags:Q.length>0?Q:void 0,prompt:j||void 0});_e.proposedTags&&_e.proposedTags.length>0&&(q(_e.proposedTags.map(Ce=>({...Ce,accepted:!0}))),F(!0))}catch(Ee){console.error("Analysis failed:",Ee)}finally{_(!1)}}},[I,P,D,y,r,Q,j]),re=g.useCallback(()=>{for(const Ee of M){if(!Ee.accepted)continue;const _e=D.find(Ce=>Ce.id===Ee.itemId);if(_e){const Ce=[...new Set([..._e.tags,...Ee.tags])];te(_e.id,Ce)}}F(!1)},[M,D,te]),he=g.useCallback(Ee=>{h(_e=>_e===Ee?null:Ee)},[]),xe=g.useMemo(()=>p?Y.find(Ee=>Ee.id===p)??null:null,[p,Y]),je=p?Y.findIndex(Ee=>Ee.id===p):-1,Pe=je>0?()=>h(Y[je-1].id):void 0,Ge=je>=0&&je<Y.length-1?()=>h(Y[je+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(zy,{value:I,onValueChange:R})]}),o.jsxs("div",{children:[o.jsx(Rt,{className:"text-xs mb-1 block",children:"Model"}),o.jsx(By,{llmId:I,value:P,onValueChange:L})]})]}),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(Kl,{value:j,onChange:Ee=>N(Ee.target.value),placeholder:"E.g., Focus on safety issues and factual errors...",rows:3,className:"text-xs mt-1"})]})]}),o.jsxs(Cc,{children:[o.jsx(de,{variant:"outline",onClick:()=>E(!1),children:"Cancel"}),o.jsxs(de,{onClick:se,disabled:!I||!P||k,children:[k?o.jsx(Gt,{className:"w-4 h-4 mr-1"}):null,"Analyze"]})]})]})}),o.jsx(br,{open:H,onOpenChange:F,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:[M.filter(Ee=>Ee.accepted).length," of ",M.length," proposals selected"]})]}),o.jsx("div",{className:"space-y-3 py-2",children:M.map((Ee,_e)=>{const Ce=D.find(Oe=>Oe.id===Ee.itemId);return o.jsx("div",{className:K("p-3 border rounded-lg",!Ee.accepted&&"opacity-50"),children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(Mo,{checked:Ee.accepted,onCheckedChange:Oe=>q(Re=>Re.map((qe,Ye)=>Ye===_e?{...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:Ce?typeof Ce.input=="string"?Ce.input.slice(0,100):JSON.stringify(Ce.input).slice(0,100):Ee.itemId}),o.jsx("div",{className:"flex gap-1 flex-wrap mt-1.5",children:Ee.tags.map((Oe,Re)=>o.jsx(c9t,{tag:Oe,onRename:qe=>q(Ye=>Ye.map((tt,At)=>At===_e?{...tt,tags:tt.tags.map((ot,zt)=>zt===Re?qe:ot)}:tt)),onRemove:()=>q(qe=>qe.map((Ye,tt)=>tt===_e?{...Ye,tags:Ye.tags.filter((At,ot)=>ot!==Re)}:Ye))},`${Oe}-${Re}`))}),Ee.reason&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-1 block italic",children:Ee.reason})]})]})},Ee.itemId)})}),o.jsxs(Cc,{children:[o.jsx(de,{variant:"outline",onClick:()=>F(!1),children:"Cancel"}),o.jsxs(de,{onClick:re,disabled:M.filter(Ee=>Ee.accepted).length===0,children:["Accept ",M.filter(Ee=>Ee.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(pt,{children:[o.jsx(pt.Trigger,{asChild:!0,children:o.jsxs(de,{variant:"outline",size:"md",children:[o.jsx(Flt,{}),"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(pt.Content,{align:"start",className:K("min-w-48"),children:[o.jsxs(pt.Sub,{children:[o.jsxs(pt.SubTrigger,{children:["Status",S&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(pt.SubContent,{children:[o.jsx(pt.CheckboxItem,{checked:!S,onCheckedChange:()=>{w(!1),h(null)},onSelect:Ee=>Ee.preventDefault(),children:"Review Queue"}),o.jsx(pt.CheckboxItem,{checked:S,onCheckedChange:()=>{w(!0),h(null)},onSelect:Ee=>Ee.preventDefault(),children:"Completed"})]})]}),o.jsxs(pt.Sub,{children:[o.jsxs(pt.SubTrigger,{children:["Tags",m&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(pt.SubContent,{children:[o.jsx(pt.CheckboxItem,{checked:!m,onCheckedChange:()=>v(null),onSelect:Ee=>Ee.preventDefault(),children:"All"}),Z>0&&o.jsx(pt.CheckboxItem,{checked:m==="__untagged__",onCheckedChange:()=>v(m==="__untagged__"?null:"__untagged__"),onSelect:Ee=>Ee.preventDefault(),children:"Untagged"}),U.length>0&&o.jsx(pt.Separator,{}),U.map(([Ee])=>o.jsx(pt.CheckboxItem,{checked:m===Ee,onCheckedChange:()=>v(m===Ee?null:Ee),onSelect:_e=>_e.preventDefault(),children:Ee},Ee))]})]}),X>0&&o.jsxs(o.Fragment,{children:[o.jsx(pt.Separator,{}),o.jsxs(pt.Item,{onSelect:()=>{v(null),w(!1),h(null)},children:[o.jsx(vs,{}),"Clear all filters"]})]})]})]}),X>0&&o.jsxs(de,{variant:"outline",size:"md",onClick:()=>{v(null),w(!1),h(null)},children:[o.jsx(vs,{}),"Reset"]})]}),!S&&y.size>0&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(l9t,{selectedCount:y.size,vocabulary:Q,onApplyTag:Ne,onRemoveTag:ke,onNewTag:Ee=>Ne(Ee)}),o.jsxs(pt,{children:[o.jsx(pt.Trigger,{asChild:!0,children:o.jsxs(de,{disabled:k,children:[k?o.jsx(Gt,{className:"w-4 h-4"}):o.jsx(Ue,{size:"sm",children:o.jsx(Sa,{})}),"Actions"]})}),o.jsxs(pt.Content,{align:"end",children:[o.jsxs(pt.Item,{onSelect:Ie,children:[o.jsx(Ue,{size:"sm",children:o.jsx(uO,{})}),"Complete"]}),o.jsxs(pt.Item,{onSelect:ze,children:[o.jsx(Ue,{size:"sm",children:o.jsx(au,{})}),"Remove"]}),o.jsx(pt.Separator,{}),o.jsxs(pt.Item,{onSelect:oe,children:[o.jsx(Ue,{size:"sm",children:o.jsx(wg,{})}),"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:S?"No completed reviews yet":"No items to review"}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-2 block",children:S?"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:[S?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(Ee=>{const _e=Ee.scores?Object.entries(Ee.scores):[],Ce=p===Ee.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:_es(Ee.input,200)})}),o.jsx(me.Cell,{height:"compact",className:"min-w-0",children:Ee.comment?o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 truncate",children:Ee.comment}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsx(me.Cell,{height:"compact",className:"min-w-0",children:Ee.tags.length>0?o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 truncate",children:Ee.tags.join(", ")}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsxs(me.Cell,{height:"compact",children:[Ee.rating==="positive"&&o.jsx(Ue,{size:"sm",className:"text-positive1",children:o.jsx(fbe,{})}),Ee.rating==="negative"&&o.jsx(Ue,{size:"sm",className:"text-negative1",children:o.jsx(dbe,{})}),!Ee.rating&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})]}),o.jsx(me.Cell,{height:"compact",children:_e.length>0?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(Ue,{size:"sm",className:"text-neutral3",children:o.jsx(rm,{})}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 font-mono",children:_e[0][1].toFixed(2)}),_e.length>1&&o.jsxs(dn,{variant:"default",children:["+",_e.length-1]})]}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})})]});return o.jsxs(me.RowWrapper,{children:[S?o.jsx(me.Cell,{height:"compact",className:"justify-items-center px-4",children:o.jsx("div",{role:"img","aria-label":Ee.error?"Error":"Success",title:Ee.error?"Error":"Success",className:K("w-2 h-2 rounded-full",Ee.error?"bg-red-700":"bg-green-600")})}):o.jsx(me.SelectCell,{checked:y.has(Ee.id),onToggle:()=>ye(Ee.id),"aria-label":`Select item ${Ee.id}`}),o.jsx(me.RowButton,{flushLeft:!0,colStart:2,featured:Ce,onClick:()=>he(Ee.id),children:Oe})]},Ee.id)})]})]}),xe&&o.jsx(o9t,{item:xe,isCompleted:S,tagVocabulary:Q,onRate:Ee=>J(xe.id,Ee),onSetTags:Ee=>{te(xe.id,Ee);for(const _e of Ee)Q.includes(_e)||V(_e)},onComment:Ee=>ee(xe.id,Ee),onRemove:()=>ae(xe.id),onComplete:S?void 0:()=>ce(xe.id),onPrevious:Pe,onNext:Ge,onClose:()=>h(null)})]})]})}function Ces({datasetId:e,onAddItemClick:t,onNavigateToDataset:n}){const{navigate:r}=yn(),[s,a]=ga(),{tab:i,activeVersion:l,handleTabChange:c}=yTe(s,a),[u,d]=g.useState(!1),[f,p]=g.useState(!1),[h,m]=g.useState(!1),[v,y]=g.useState([]),[b,S]=g.useState(!1),[w,k]=g.useState([]),[_,C]=g.useState(!1),[E,j]=g.useState([]),[N,I]=g.useState(0),[R,P]=g.useState(null),[L,M]=g.useState(""),[q]=A0e(L,300),{data:H}=Hx(e),{data:F=[],total:z,isLoading:B,setEndOfListElement:D,isFetchingNextPage:Q,hasNextPage:V}=E1(e,q||void 0,l),{total:$}=E1(e,void 0,l),[U,Z]=g.useState({}),{data:X,isLoading:te}=tD(e,void 0,U),{data:J}=tD(e),{deleteItems:ee}=Ei(),ae=X?.experiments??[],ce=J?.experiments??[],Y=EJr({hasSearchQuery:!!q,filteredItemsLength:F.length,unfilteredItemsTotal:$,itemsTotal:z}),{data:ne}=xTe(e),ue=ne?.length??0,pe=re=>{P(re)},le=()=>{P(null)},ve=re=>{y(re),m(!0)},ye=re=>{k(re),S(!0)},Se=re=>{S(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(cu,{defaultTab:"items",value:i,onValueChange:c,className:"grid grid-rows-[auto_1fr] h-full",children:[o.jsxs(uu,{children:[o.jsxs(qr,{value:"items",children:["Items ",o.jsx(Xs,{color:"gray",children:Y})]}),o.jsxs(qr,{value:"experiments",children:["Experiments",o.jsx(Xs,{color:"gray",children:ae.length})]}),o.jsxs(qr,{value:"review",children:["Review",ue>0&&o.jsx(Xs,{color:"orange",children:ue})]})]}),o.jsx(fs,{value:"items",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(bes,{datasetId:e,items:F,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:H?.name,clearSelectionTrigger:N,setEndOfListElement:D,isFetchingNextPage:Q,hasNextPage:V,searchQuery:L,activeSearchQuery:q,onSearchChange:M,currentDatasetVersion:H?.version,onCompareVersionsClick:ke})}),o.jsx(fs,{value:"experiments",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(VJr,{experiments:ae,allExperiments:ce,isLoading:te,datasetId:e,filters:U,onFiltersChange:Z})}),o.jsx(fs,{value:"review",className:"overflow-auto mt-2 pb-0",children:o.jsx(A9t,{datasetId:e})})]}),o.jsx(MJr,{datasetId:e,open:u,onOpenChange:d}),o.jsx(kes,{datasetId:e,open:f,onOpenChange:p}),o.jsx(fJr,{open:h,onOpenChange:se,items:v,onSuccess:oe}),o.jsx(pJr,{open:b,onOpenChange:Se,items:w,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 Ees(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 Kre({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 jes({datasetId:e,open:t,onOpenChange:n,onSuccess:r}){const[s,a]=g.useState("{}"),[i,l]=g.useState(""),[c,u]=g.useState(""),[d,f]=g.useState(""),[p,h]=g.useState(""),[m,v]=g.useState(null),{addItem:y}=Ei(),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 P=JSON.parse(d);if(!Array.isArray(P)){De.error("Tool Mocks must be a JSON array");return}I=P}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"),v(null),a("{}"),l(""),u(""),f(""),h(""),n(!1),r?.()}catch(P){const L=Ees(P);L?v(L):De.error(`Failed to add item: ${P instanceof Error?P.message:"Unknown error"}`)}},S=C=>{a(C),m?.field==="input"&&v(null)},w=C=>{l(C),m?.field==="groundTruth"&&v(null)},k=C=>{f(C),m?.field==="toolMocks"&&v(null)},_=()=>{a("{}"),l(""),u(""),f(""),h(""),v(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(Rr,{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:S,showCopyButton:!1,className:"min-h-[120px]"}),m?.field==="input"&&o.jsx(Kre,{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:w,showCopyButton:!1,className:"min-h-[80px]"}),m?.field==="groundTruth"&&o.jsx(Kre,{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(Kre,{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(de,{type:"button",onClick:_,children:"Cancel"}),o.jsx(de,{type:"submit",variant:"primary",disabled:y.isPending,children:y.isPending?"Adding...":"Add Item"})]})]})})]})})}function Tes({item:e}){return o.jsx(ua,{withMargins:!1,children:o.jsxs(ua.Column,{children:[o.jsxs(ua.Title,{size:"smaller",children:[o.jsx(yN,{}),o.jsx("span",{className:"truncate",children:e.id}),o.jsx(Oa,{content:e.id,tooltip:`Copy item ID: ${e.id}`})]}),o.jsxs(ua.Description,{children:[o.jsxs(Al,{children:[o.jsx(Nlt,{})," Created ",er(new Date(e.createdAt),"MMM d, yyyy h:mm aaa")]}),e.datasetVersion!=null&&o.jsxs(Al,{children:[o.jsx(p_,{})," Version v",e.datasetVersion]})]})]})})}function wTe({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(Uje,{children:[o.jsx(Ps.CodeSection,{title:"Input",icon:o.jsx(fO,{}),codeStr:t}),o.jsx(Ps.CodeSection,{title:"Ground Truth",icon:o.jsx(gg,{}),codeStr:n}),s&&o.jsx(Ps.CodeSection,{title:"Expected Trajectory",icon:o.jsx(lbe,{}),codeStr:s}),o.jsx(Ps.CodeSection,{title:"Metadata",icon:o.jsx(wN,{}),codeStr:r})]})}function Nes({selectedScorers:e,setSelectedScorers:t,disabled:n=!1,container:r}){const{data:s,isLoading:a}=ih(),i=g.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(Jl,{multiple:!0,options:i,value:e,onValueChange:t,placeholder:"Select scorers...",searchPlaceholder:"Search scorers...",emptyText:"No scorers available",disabled:n||a,container:r})]})}const Ies=[{value:"agent",label:"Agent"},{value:"workflow",label:"Workflow"},{value:"scorer",label:"Scorer"}];function Aes({targetType:e,setTargetType:t,targetId:n,setTargetId:r,container:s}){const{data:a,isLoading:i}=km(),{data:l,isLoading:c}=Uy(),{data:u,isLoading:d}=ih(),f=e==="agent"?Object.entries(a??{}).map(([v,y])=>({value:v,label:y.name??v})):e==="workflow"?Object.entries(l??{}).map(([v,y])=>({value:v,label:y.name??v})):e==="scorer"?Object.entries(u??{}).map(([v,y])=>({value:v,label:y.scorer?.config?.name??v})):[],p=e==="agent"&&i||e==="workflow"&&c||e==="scorer"&&d,h=v=>{t(v),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(Jl,{options:Ies,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(Jl,{options:f,value:n,onValueChange:r,placeholder:`Select ${e}`,searchPlaceholder:"Search...",emptyText:"No targets available",disabled:p,container:s})]})]})}function Res({requestContextSchema:e,onChange:t}){const n=g.useMemo(()=>{try{return lm(im(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(a3,{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 Pes({datasetId:e,version:t,requestContextSchema:n,open:r,onOpenChange:s,onSuccess:a}){const i=g.useRef(null),[l,c]=g.useState(""),[u,d]=g.useState(""),[f,p]=g.useState([]),[h,m]=g.useState({}),[v,y]=g.useState(""),{triggerExperiment:b}=Ei(),S=!!(n&&Object.keys(n).length>0),w=l&&u,k=b.isPending,_=()=>{c(""),d(""),p([]),m({}),y("")},C=()=>{if(S){const N=Object.entries(h).filter(([,I])=>I!==void 0&&I!=="");return N.length>0?Object.fromEntries(N):void 0}if(v.trim()){let N;try{N=JSON.parse(v)}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(!w)return;let N;try{N=C()}catch(I){const R=I instanceof Error?I.message:"Request Context must be valid JSON";Ru.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});Ru.success("Experiment triggered successfully"),s(!1),a?.(I.experimentId),_()}catch(I){const R=I instanceof Error?I.message:"Failed to trigger experiment";Ru.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(Rr,{className:"grid gap-6",children:[o.jsx(Aes,{targetType:l,setTargetType:c,targetId:u,setTargetId:d,container:i}),l&&l!=="scorer"&&o.jsx(Nes,{selectedScorers:f,setSelectedScorers:p,disabled:k,container:i}),S?o.jsx(Res,{requestContextSchema:n,onChange:m}):o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{children:"Request Context (JSON, optional)"}),o.jsx(Qr,{value:v,onChange:y,showCopyButton:!1,className:"min-h-[80px]"})]})]}),o.jsxs(Cc,{className:"px-6 pt-4",children:[o.jsx(de,{onClick:j,disabled:k,children:"Cancel"}),o.jsx(de,{variant:"primary",onClick:E,disabled:!w||k,children:k?o.jsxs(o.Fragment,{children:[o.jsx(Gt,{className:"w-4 h-4"}),"Running..."]}):"Run"})]})]})})}const $es=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})},STe=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 Jre(e){try{return JSON.stringify(e??{})}catch{return String(e)}}function Mes({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(zp,{}),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: ",Jre(s.args)]}),n.length>0&&o.jsxs("span",{className:"mt-1 block font-mono text-xs",children:["Unconsumed mocks: ",n.map(i=>Jre(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:Jre(i.args)})]}),o.jsx("span",{className:`shrink-0 text-xs px-2 py-0.5 rounded ${Des(i.outcome)}`,children:i.outcome})]},`${i.outcome}-${i.toolName}-${l}`))})]})}function Des(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 Les({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]=g.useState(!1),m=d??p,v=f??h,y=!!e?.error,b=tF(e?.input),S=tF(e?.output),w=tF(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(Mr,{className:"ml-auto shrink-0",children:[f&&o.jsx(de,{size:"md",tooltip:m?"Expand panel":"Collapse panel",onClick:()=>v(!m),children:m?o.jsx(Plt,{}):o.jsx(Rlt,{})}),o.jsx(bn.NextPrevNav,{onPrevious:n,onNext:r,previousLabel:"Previous result",nextLabel:"Next result"}),o.jsxs(de,{size:"md",onClick:a,disabled:!e.traceId,children:[o.jsx(STe,{}),"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(Bt,{children:[o.jsx(Bt.Key,{children:"Item Id"}),o.jsx(Bt.ValueWithCopyBtn,{copyTooltip:"Copy Item Id to clipboard",copyValue:e.itemId,children:e.itemId}),o.jsx(Bt.Key,{children:"Created"}),o.jsx(Bt.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:tF(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(Mes,{report:e.toolMockReport}),(e.status||_.length>0||k)&&o.jsxs("div",{className:"grid gap-2",children:[o.jsx(bn.SectionHeading,{icon:o.jsx(wN,{}),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(de,{size:"sm",onClick:()=>u(e.id),children:[o.jsx(cq,{}),"Flag for Review"]})}),e.status==="needs-review"&&i&&o.jsx("div",{children:o.jsxs(de,{size:"sm",onClick:i,children:[o.jsx(_a,{}),"Review"]})})]})]}),o.jsxs("div",{className:"grid gap-3",children:[o.jsx(bn.CodeSection,{title:"Input",icon:o.jsx(yN,{}),codeStr:b}),o.jsx(bn.CodeSection,{title:"Output",icon:o.jsx(gg,{}),codeStr:S}),o.jsx(bn.CodeSection,{title:"Ground Truth",icon:o.jsx(ube,{}),codeStr:w})]})]})]})}function tF(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function Fes({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(v=>v.size)].filter(Boolean).join(" "),m=s.some(v=>v.name==="input");return t?o.jsx(tl,{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(v=>o.jsx(me.TopCell,{children:v.label},v.name))}):s.map(v=>o.jsx(me.TopCell,{children:v.label},v.name))]}),e.length===0?o.jsx(me.NoMatch,{message:"No results yet"}):o.jsxs(o.Fragment,{children:[e.map(v=>{const y=!!v.error,b=v.id===n,S=o.jsxs(o.Fragment,{children:[o.jsx(me.IdCell,{id:v.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:Bes(zes(v.input),200)}),i?.map(w=>{const _=a?.[v.itemId]?.find(C=>C.scorerId===w);return o.jsx(me.Cell,{height:"compact",className:"font-mono text-neutral3 text-ui-smd",children:_!=null?_.score.toFixed(3):"-"},w)})]});return p?o.jsxs(me.RowWrapper,{children:[o.jsx(me.SelectCell,{checked:d.has(v.id),onToggle:()=>f(v.id),"aria-label":`Select result ${v.itemId}`}),o.jsx(me.RowButton,{flushLeft:!0,colStart:2,featured:b,onClick:()=>r(v.id),children:S})]},v.id):o.jsx(me.RowButton,{featured:b,onClick:()=>r(v.id),children:S},v.id)}),o.jsx(me.NextPageLoading,{isLoading:c,hasMore:u,setEndOfListElement:l})]})]})}function zes(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function Bes(e,t){return e.length<=t?e:e.slice(0,t-1)+"..."}function Ues(e){const t=e.scorer;return t?.hasJudge===!1?!0:t?.hasJudge===!0?!1:!e.preprocessPrompt&&!e.analyzePrompt&&!e.generateScorePrompt&&!e.generateReasonPrompt}function qes({score:e,onNext:t,onPrevious:n,onClose:r,onShowTrace:s,collapsed:a,onCollapsedChange:i}){const[l,c]=g.useState(!1),u=a??l,d=i??c,f=Ues(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(Mr,{className:"ml-auto shrink-0",children:[i&&o.jsx(de,{size:"md",tooltip:u?"Expand panel":"Collapse panel",onClick:()=>d(!u),children:u?o.jsx(Plt,{}):o.jsx(Rlt,{})}),(n||t)&&o.jsx(bn.NextPrevNav,{onPrevious:n,onNext:t,previousLabel:"Previous score",nextLabel:"Next score"}),s&&o.jsxs(de,{size:"md",onClick:s,disabled:!e.traceId,children:[o.jsx(STe,{}),"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(rm,{}),codeStr:e.reason||p,simplified:!0}),!f&&o.jsxs(o.Fragment,{children:[o.jsx(bn.CodeSection,{title:"Preprocess Prompt",icon:o.jsx(Oh,{}),codeStr:e.preprocessPrompt||p,simplified:!0}),o.jsx(bn.CodeSection,{title:"Analyze Prompt",icon:o.jsx(Oh,{}),codeStr:e.analyzePrompt||p,simplified:!0}),o.jsx(bn.CodeSection,{title:"Generate Score Prompt",icon:o.jsx(Oh,{}),codeStr:e.generateScorePrompt||p,simplified:!0}),o.jsx(bn.CodeSection,{title:"Generate Reason Prompt",icon:o.jsx(Oh,{}),codeStr:e.generateReasonPrompt||p,simplified:!0})]})]})})]})}const RQe=[{name:"scorer",label:"Scorer",size:"1fr"},{name:"avg",label:"Avg Score",size:"1fr"},{name:"count",label:"Items Scored",size:"1fr"}];function Ves({scoresByItemId:e,experimentStatus:t}){const n=g.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(Cr,{iconSlot:o.jsx(rm,{className:"w-8 h-8 text-neutral3"}),titleSlot:a,descriptionSlot:i})})}return o.jsxs(gn,{children:[o.jsxs(gn.Header,{columns:RQe,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:RQe,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 R9t({experimentId:e,datasetId:t,experimentStatus:n,results:r,isLoading:s,setEndOfListElement:a,isFetchingNextPage:i,hasNextPage:l}){const[c,u]=g.useState(null),[d,f]=g.useState(null),[p,h]=g.useState(void 0),[m,v]=g.useState(null),[y,b]=g.useState(new Set),[S,w]=g.useState(!1),[k,_]=g.useState(!1),[C,E]=g.useState(!1),[j,N]=g.useState(!1),{updateExperimentResult:I}=Ei(),R=g.useCallback(se=>{b(re=>{const he=new Set(re);return he.has(se)?he.delete(se):he.add(se),he})},[]),P=g.useCallback(()=>b(new Set),[]),L=g.useCallback(()=>{const se=r.filter(re=>!!re.error).map(re=>re.id);b(new Set(se))},[r]),M=g.useCallback(async se=>{if(S||se.length===0)return;w(!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{w(!1)}he.size>0&&b(xe=>{const je=new Set(xe);for(const Pe of he)je.delete(Pe);return je}),re>0&&De(`${re} result${re>1?"s":""} flagged for review`)},[t,e,S,I]),q=r.find(se=>se.id===c)??null,[H,F]=g.useState("summary"),[z,B]=g.useState(null),D=se=>{F(se),se!=="reviews"&&B(null)},{data:Q}=xTe(t),V=(Q??[]).filter(se=>se.experimentId===e).length,{data:$}=r9t(e,n),U=g.useMemo(()=>{if(!$)return[];const se=new Set;for(const re of Object.values($))for(const he of re)se.add(he.scorerId);return[...se].sort()},[$]),Z=se=>{u(se),f(null),h(void 0),v(null)},X=se=>{Z(se===c?null:se)},te=()=>{Z(null)},J=()=>{if(!q)return;const se=r.findIndex(re=>re.id===q.id);if(se>=0&&se<r.length-1)return()=>Z(r[se+1].id)},ee=()=>{if(!q)return;const se=r.findIndex(re=>re.id===q.id);if(se>0)return()=>Z(r[se-1].id)},ae=q?$?.[q.itemId]:void 0,ce=ae?.find(se=>se.id===m)??null,Y=se=>{v(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()=>v(ae[se+1].id)},ue=()=>{if(!m||!ae)return;const se=ae.findIndex(re=>re.id===m);if(se>0)return()=>v(ae[se-1].id)},{data:pe,isLoading:le}=$es(d),ve=pe?.spans,{data:ye,isLoading:Se}=oI(d,p),Ne=ye?.span,{handlePreviousSpan:ke,handleNextSpan:Ie}=GH(ve,p??null,h),ze=(()=>{const se=[],re=!!ce,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=g.useMemo(()=>[{name:"itemId",label:"Item ID",size:"7rem"},{name:"status",label:"Status",size:"5rem"},{name:"input",label:"Input",size:"minmax(15rem,1fr)"},...U.map(se=>({name:se,label:se,size:"12rem"}))],[U]);return o.jsxs(cu,{defaultTab:"summary",value:H,onValueChange:D,className:"grid grid-rows-[auto_1fr] h-full overflow-hidden",children:[o.jsxs(uu,{children:[o.jsx(qr,{value:"summary",children:"Summary"}),o.jsx(qr,{value:"results",children:"Results"}),o.jsxs(qr,{value:"reviews",children:["Reviews",V>0&&o.jsx(Xs,{color:"orange",children:V})]})]}),o.jsx(fs,{value:"summary",className:"overflow-y-auto mt-5",children:o.jsx(Ves,{scoresByItemId:$,experimentStatus:n})}),o.jsx(fs,{value:"reviews",className:"overflow-auto mt-2 pb-0",children:o.jsx(A9t,{datasetId:t,experimentId:e,featuredItemId:z})}),o.jsxs(fs,{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(de,{variant:"outline",size:"sm",disabled:S,onClick:()=>M([...y]),children:[o.jsx(Ue,{size:"sm",children:o.jsx(cq,{})}),"Flag for Review"]}),o.jsx(de,{variant:"ghost",size:"sm",onClick:P,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(de,{variant:"ghost",size:"sm",onClick:L,children:"Select loaded failures"})})]}),o.jsxs("div",{className:K("grid w-full h-full grid-cols-1 gap-4 overflow-y-auto",q&&"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(Fes,{results:r,isLoading:s,featuredResultId:c,onResultClick:X,columns:oe,scoresByItemId:$,scorerIds:U,setEndOfListElement:a,isFetchingNextPage:i,hasNextPage:l,selectedIds:y,onToggleSelect:R})})}),q&&o.jsxs("div",{className:"grid gap-4 max-h-full min-h-0 overflow-auto content-start",style:{gridTemplateRows:ze},children:[o.jsx(Les,{result:q,scores:ae,onPrevious:ee(),onNext:J(),onClose:te,onScoreClick:Y,featuredScoreId:m,onShowTrace:()=>{q.traceId&&(f(q.traceId),h(void 0),v(null),_(!0),E(!1))},onOpenInReview:()=>{B(q.id),F("reviews")},onFlagForReview:se=>M([se]),collapsed:k,onCollapsedChange:_}),ce&&o.jsx(qes,{score:ce,onNext:ne(),onPrevious:ue(),onClose:()=>v(null),onShowTrace:()=>{ce.traceId&&(f(ce.traceId),h(void 0),_(!0),N(!0),E(!1))},collapsed:j,onCollapsedChange:N}),d&&o.jsxs(o.Fragment,{children:[o.jsx(uTe,{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:BD,traceHref:`/traces/${d}`}),p&&o.jsx(WH,{traceId:d,spanId:p,span:Ne,isLoading:Se,onPrevious:ke,onNext:Ie,onClose:()=>h(void 0)})]})]})]})]})]})}const Hes={pending:o.jsx(dO,{}),running:o.jsx(tfe,{}),completed:o.jsx(Js,{}),failed:o.jsx(vs,{})};function Wes({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:Hes[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 Zes({onPrevious:e,onNext:t,previousAriaLabel:n="Previous",nextAriaLabel:r="Next"}){return o.jsxs(Mr,{spacing:"close",children:[o.jsxs(de,{onClick:e,disabled:!e,"aria-label":n,children:[o.jsx(Gq,{})," Prev"]}),o.jsxs(de,{onClick:t,disabled:!t,"aria-label":r,children:["Next",o.jsx(Wq,{})]})]})}function kTe({delta:e}){const t=e>0?o.jsx(Xs,{size:"small",color:"green",intensity:"muted",children:o.jsx(pD,{})}):e<0?o.jsx(Xs,{size:"small",color:"red",intensity:"muted",children:o.jsx(Cln,{})}):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 nF(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function Ges({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(Zes,{onPrevious:a,onNext:i,previousAriaLabel:"Previous comparison item",nextAriaLabel:"Next comparison item"}),o.jsx(Mr,{children:o.jsx(de,{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(yN,{})," ",e.itemId]})})}),d?o.jsx(o.Fragment,{children:o.jsxs(Uje,{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,v=u?.scores[h]??null,y=m!=null&&v!=null?v-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):"-"," →"," ",v!=null?v.toFixed(3):"-"]}),y!=null&&o.jsx(kTe,{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(gg,{}),codeStr:nF(c?.output)}),o.jsx(Ps.CodeSection,{title:o.jsxs(o.Fragment,{children:[o.jsx(Xs,{color:"cyan",children:"Contender "})," Experiment Output"]}),icon:o.jsx(gg,{}),codeStr:nF(u?.output)}),o.jsx(Ps.CodeSection,{title:"Item Input",icon:o.jsx(fO,{}),codeStr:nF(e.input)}),o.jsx(Ps.CodeSection,{title:"Item Ground Truth",icon:o.jsx(ube,{}),codeStr:nF(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 Qes({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(kTe,{delta:m})]}):o.jsx("span",{className:"text-neutral1",children:"-"})},f)})})]})},l.itemId)})})})]})})}const Yes={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 PQe({datasetId:e,experiment:t,type:n}){const{Link:r}=yn(),{label:s,color:a,customStyle:i}=Yes[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(mm,{})]}),o.jsx(de,{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(Nc,{})," ",s]})]}),o.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-ui-sm text-neutral3",children:[o.jsxs(Al,{children:[o.jsx(ube,{})," ",t.targetType," / ",t.targetId]}),o.jsxs(Al,{children:[o.jsx(fq,{})," v",t.datasetVersion??"—"]}),l&&o.jsxs(Al,{children:[o.jsx(Ilt,{})," ",er(l,"MMM d, yyyy HH:mm")]})]})]})}function Xes({datasetId:e,experimentIdA:t,experimentIdB:n,onSwap:r}){const[s,a]=g.useState(null),{data:i,isLoading:l,error:c}=FKr(e,t,n),{data:u}=zU(e,t),{data:d}=zU(e,n),f=u&&d&&u.datasetVersion!==d.datasetVersion,p=g.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=g.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,P=0,L=0;for(const F of i.items){const z=F.results[E]?.scores[N],B=F.results[j]?.scores[N];z!=null&&(I+=z,P++),B!=null&&(R+=B,L++)}const M=P>0?I/P:null,q=L>0?R/L:null,H=M!=null&&q!=null?q-M:null;return{scorerId:N,avgA:M,avgB:q,delta:H}})},[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"}],v=g.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)},S=()=>{a(null)},w=()=>{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(PQe,{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(de,{onClick:r,children:"VS"})}),o.jsx(Bn,{children:"Switch the order"})]})})}),o.jsx(PQe,{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(MGe,{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(MGe,{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(kTe,{delta:I}):"-"})]},E))})})]}),o.jsxs(sy,{className:K({"grid-cols-[1fr_2fr]":!!y}),children:[o.jsx(Qes,{items:i.items,baselineId:_,contenderId:C,scorerIds:p,featuredItemId:s,columns:v,onItemClick:b}),!!y&&o.jsx(Ges,{item:y,baselineId:_,contenderId:C,baselineVersion:u?.datasetVersion,contenderVersion:d?.datasetVersion,onPrevious:k(),onNext:w(),onClose:S})]})]})}function Kes({datasetId:e,itemId:t,onVersionSelect:n,onCompareVersionsClick:r,activeVersion:s}){const{data:a,isLoading:i}=vTe(e,t),[l,c]=g.useState(!1),[u,d]=g.useState(new Set),f=b=>{n?.(b)},p=b=>s==null?b.isLatest:b.datasetVersion===s,h=b=>{d(S=>{const w=new Set(S);if(w.has(b))w.delete(b);else if(w.size>=2){const[k]=Array.from(w);return new Set([k,b])}else w.add(b);return w})},m=()=>{c(!1),d(new Set)},v=()=>{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(Mr,{children:[o.jsx(de,{onClick:m,children:"Cancel"}),o.jsx(de,{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(de,{onClick:v,className:"w-full",children:[o.jsx(Xw,{})," Compare Ver."]})})}),i?o.jsx(Jes,{}):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 S=String(b.datasetVersion),w=typeof b.updatedAt=="string"?new Date(b.updatedAt):b.updatedAt;return o.jsxs(gn.Row,{isSelected:l&&u.has(S),children:[l&&o.jsx(gn.LabelCell,{children:o.jsx(Mo,{checked:u.has(S),disabled:b.isDeleted,onCheckedChange:()=>{},onClick:k=>{k.stopPropagation(),b.isDeleted||h(S)},"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:w,isLatest:b.isLatest,isDeleted:b.isDeleted})})]},String(b.datasetVersion))})})})]})]})}function Jes(){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 ets(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 tts({datasetId:e,versionA:t,versionB:n,onVersionChange:r}){const{data:s}=nTe(e),a=(s??[]).map(i=>({value:String(i.version),label:`${ets(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(Sc,{label:"Version A",labelIsHidden:!0,name:"version-a",placeholder:"Select version",options:a,value:t??"",onValueChange:i=>r?.(i,n??"")}),o.jsx(Sc,{label:"Version B",labelIsHidden:!0,name:"version-b",options:a,value:n??"",onValueChange:i=>r?.(t??"",i)}),o.jsx("div",{})]})}const nts=[{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"}],rts={added:{color:"blue",borderColor:"border-blue-900",icon:o.jsx(Vr,{}),tooltip:"Added in this version"},changed:{color:"orange",borderColor:"border-yellow-900",icon:o.jsx(Ylt,{}),tooltip:"Changed in this version"},same:{color:"green",borderColor:"border-green-900",icon:o.jsx(Qcn,{}),tooltip:"Same in both versions"}};function ese({red:e=!1,tooltip:t}){return o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx(Mln,{className:K("text-neutral3/40 w-5 h-5 ",{"text-red-900":e})})}),t&&o.jsx(Bn,{children:t})]})}function QS({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}=rts[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 sts(e,t){return e&&t&&e.datasetVersion===t.datasetVersion?"same":e&&t&&e.datasetVersion!==t.datasetVersion?"changed":e?"added":"removed"}function ats({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=sts(u,d);return o.jsxs(gn.Row,{columns:nts,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(QS,{variant:"added",version:u.datasetVersion}):f==="changed"&&l?o.jsx(QS,{variant:"changed",version:u.datasetVersion}):o.jsx(QS,{version:u.datasetVersion})}):o.jsx(gn.Cell,{className:"justify-center flex items-center",children:o.jsx(ese,{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(QS,{variant:"added",version:d.datasetVersion}):f==="changed"&&!l?o.jsx(QS,{variant:"changed",version:d.datasetVersion}):o.jsx(QS,{version:d.datasetVersion})}):o.jsx(gn.Cell,{className:"justify-center flex items-center",children:o.jsx(ese,{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(QS,{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(ese,{tooltip:o.jsxs(o.Fragment,{children:["Comparing is available",o.jsx("br",{})," only for changed items"]})})})]},c)})})})})}const $Qe={needsReview:"#facc15",complete:"#22c55e"},its=[{label:"Needs Review",color:$Qe.needsReview},{label:"Reviewed",color:$Qe.complete}];function ots({reviewSummary:e,experiments:t,datasets:n,isLoading:r,isError:s}){const{data:a,maxVal:i,totalInPipeline:l}=g.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 v=m.needsReview+m.complete;if(v===0)continue;p+=v,v>f&&(f=v);const y=u.get(m.experimentId),b=y?.datasetId?d.get(y.datasetId):void 0,S=b?`${b} · ${m.experimentId.slice(0,8)}`:m.experimentId.slice(0,8);h.push({name:S,values:[m.needsReview,m.complete]})}return{data:h,maxVal:f,totalInPipeline:p}},[e,t,n]),c=a.length>0;return o.jsxs(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.TitleAndDescription,{title:"Review Pipeline",description:"Items in review across experiments."}),c&&o.jsx(Ut.Summary,{value:String(l),label:"Items in pipeline"})]}),r?o.jsx(Ut.Loading,{}):s?o.jsx(Ut.Error,{message:"Failed to load review data"}):o.jsx(Ut.Content,{children:c?o.jsx(uN,{data:a,segments:its,maxVal:i,fmt:u=>String(u)}):o.jsx(Ut.NoData,{message:"No items have been sent to review yet"})})]})}function OTe(){const e=We();return wt({queryKey:["experiment-review-summary"],queryFn:()=>e.getExperimentReviewSummary()})}function P9t(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 lts(e,t){const n=new Map,r=P9t(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 cts(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 uts=10;function dts(){const[e,t]=g.useState(!1),[n,r]=g.useState(""),[s,a]=g.useState("all"),[i,l]=g.useState("all"),[c,u]=g.useState("all"),[d,f]=g.useState(0),{data:p,isLoading:h,error:m}=$g({page:d,perPage:uts}),{data:v,isLoading:y,error:b}=JZ(),{data:S}=OTe(),w=g.useMemo(()=>p?.datasets??[],[p?.datasets]),k=p?.pagination?.hasMore??!1,_=g.useMemo(()=>v?.experiments??[],[v?.experiments]),C=g.useMemo(()=>rJr(w),[w]),E=g.useMemo(()=>lts(S,_),[S,_]),j=h||y,N=m||b,I=()=>t(!0),R=g.useCallback(()=>f(B=>B+1),[]),P=g.useCallback(()=>f(B=>Math.max(0,B-1)),[]),L=g.useCallback(B=>{r(B),f(0)},[]),M=g.useCallback(B=>{a(B),f(0)},[]),q=g.useCallback(B=>{l(B),f(0)},[]),H=g.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(zi,{title:"Failed to load datasets",message:N.message})});if(w.length===0&&!j&&d===0)return o.jsxs(o.Fragment,{children:[o.jsx(lr,{children:o.jsx(lJr,{onCreateClick:I})}),o.jsx(Fve,{open:e,onOpenChange:t})]});const F=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(dJr,{search:n,onSearchChange:L,targetFilter:s,onTargetFilterChange:M,experimentFilter:i,onExperimentFilterChange:q,tagFilter:c,onTagFilterChange:H,tagOptions:C,onReset:z,hasActiveFilters:F,onCreateClick:I})}),o.jsx(oJr,{datasets:w,experiments:_,reviewByDataset:E,isLoading:j,search:n,targetFilter:s,experimentFilter:i,tagFilter:c,currentPage:d,hasMore:k,onNextPage:R,onPrevPage:P}),o.jsx(Fve,{open:e,onOpenChange:t})]})}function rF({children:e}){return o.jsxs(Lt,{height:"full",children:[o.jsx("div",{}),o.jsx(Lt.MainArea,{isCentered:!0,children:e})]})}function fts(){const{datasetId:e}=ur(),t=bs(),[n,r]=ga(),{activeVersion:s}=yTe(n,r),[a,i]=g.useState(!1),[l,c]=g.useState(!1),[u,d]=g.useState(!1),[f,p]=g.useState(!1),[h,m]=g.useState(!1),{data:v,error:y,isLoading:b}=Hx(e),{data:S=[],isLoading:w}=E1(e,void 0,s),k=!w&&S.length===0;if(b)return null;if(y&&gs(y))return o.jsx(rF,{children:o.jsx(Vs,{})});if(y&&ys(y))return o.jsx(rF,{children:o.jsx(Ds,{resource:"datasets"})});if(y&&vOe(y)||!b&&!y&&!v)return o.jsx(rF,{children:o.jsx(Cr,{iconSlot:o.jsx(iy,{}),titleSlot:"Dataset not found",descriptionSlot:`No dataset with id "${e}".`,actionSlot:o.jsxs(de,{as:Ba,to:"/datasets",children:[o.jsx(Nc,{}),"Back to Datasets"]})})});if(y)return o.jsx(rF,{children:o.jsx(zi,{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:[v?.description&&o.jsx("p",{className:"text-ui-smd text-neutral3 mb-1",children:v.description}),o.jsxs(Bt,{numOfCol:2,children:[o.jsx(Bt.Key,{children:"Created at"}),o.jsx(Bt.Value,{children:v?.createdAt?er(new Date(v.createdAt),"MMM d, yyyy"):""}),o.jsx(Bt.Key,{children:"Latest version"}),o.jsxs(Bt.Value,{children:["v",v?.version??""]})]})]}),o.jsx(Lt.Column,{children:o.jsxs(Mr,{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(de,{variant:"primary",children:[o.jsx(Fp,{}),s!=null?`Run on v${s}`:"Run Experiment"]})})})}),o.jsx(Bn,{children:"Add items to the dataset before running an experiment"})]}):o.jsxs(de,{variant:"primary",onClick:()=>i(!0),children:[o.jsx(Fp,{}),s!=null?`Run on v${s}`:"Run Experiment"]}),o.jsxs(pt,{children:[o.jsx(pt.Trigger,{asChild:!0,children:o.jsx(de,{size:"lg","aria-label":"Dataset actions menu",children:o.jsx(mD,{})})}),o.jsxs(pt.Content,{align:"end",className:"w-48",children:[o.jsxs(pt.Item,{onSelect:()=>d(!0),children:[o.jsx(Lp,{})," Edit Dataset"]}),o.jsxs(pt.Item,{onSelect:()=>m(!0),children:[o.jsx(Dp,{})," Duplicate Dataset"]}),o.jsxs(pt.Item,{onSelect:()=>p(!0),className:"text-red-500 focus:text-red-400",children:[o.jsx(au,{})," Delete Dataset"]})]})]})]})})]})}),o.jsx(Lt.MainArea,{children:o.jsx(Ces,{datasetId:e,onAddItemClick:()=>c(!0)})})]}),o.jsx(Pes,{datasetId:e,version:s??void 0,requestContextSchema:v?.requestContextSchema,open:a,onOpenChange:i,onSuccess:_}),o.jsx(jes,{datasetId:e,open:l,onOpenChange:c}),v&&o.jsx(vJr,{open:u,onOpenChange:d,dataset:{id:v.id,name:v.name,description:v?.description||"",targetType:v.targetType,inputSchema:v.inputSchema,groundTruthSchema:v.groundTruthSchema,requestContextSchema:v.requestContextSchema}}),v&&o.jsx(hJr,{open:h,onOpenChange:m,sourceDatasetId:v.id,sourceDatasetName:v.name,sourceDatasetDescription:v.description,sourceDatasetTargetType:v.targetType}),v&&o.jsx(bJr,{open:f,onOpenChange:p,datasetId:v.id,datasetName:v.name,onSuccess:C})]})}function $9t({experiment:e}){const{Link:t,paths:n}=yn(),{data:r}=km(),{data:s}=Uy(),{data:a}=ih(),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(Bt,{numOfCol:2,children:[o.jsx(Bt.Key,{children:"Created at"}),o.jsx(Bt.Value,{children:er(new Date(e.createdAt),"MMM d, yyyy 'at' h:mm a")}),e.completedAt&&o.jsxs(o.Fragment,{children:[o.jsx(Bt.Key,{children:"Completed at"}),o.jsx(Bt.Value,{children:er(new Date(e.completedAt),"MMM d, yyyy 'at' h:mm a")})]}),o.jsx(Bt.Key,{children:"Target"}),o.jsx(Bt.ValueLink,{href:i(),as:t,children:l()}),e.agentVersion&&o.jsxs(o.Fragment,{children:[o.jsx(Bt.Key,{children:"Version"}),c?o.jsx(Bt.ValueLink,{href:c,as:t,children:e.agentVersion}):o.jsx(Bt.Value,{children:e.agentVersion})]})]})}),o.jsx(Lt.Column,{children:o.jsx(Wes,{experiment:e})})]})})}function sF({children:e}){return o.jsxs(Lt,{height:"full",children:[o.jsx("div",{}),o.jsx(Lt.MainArea,{isCentered:!0,children:e})]})}function pts(){const{datasetId:e,experimentId:t}=ur(),{data:n,isLoading:r,error:s}=zU(e,t),{data:a,isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u}=YZ({datasetId:e,experimentId:t,experimentStatus:n?.status});return!e||!t||r?null:s&&gs(s)?o.jsx(sF,{children:o.jsx(Vs,{})}):s&&ys(s)?o.jsx(sF,{children:o.jsx(Ds,{resource:"datasets"})}):s&&vOe(s)||!r&&!s&&!n?o.jsx(sF,{children:o.jsx(Cr,{iconSlot:o.jsx(tbe,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${t}".`,actionSlot:o.jsxs(de,{as:Ba,to:`/datasets/${e}?tab=experiments`,children:[o.jsx(Nc,{}),"Back to Dataset"]})})}):s?o.jsx(sF,{children:o.jsx(zi,{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($9t,{experiment:n}),o.jsx(Lt.MainArea,{children:o.jsx(R9t,{experimentId:t,datasetId:e,experimentStatus:n.status,results:a??[],isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u})})]})}function hts(){const{datasetId:e}=ur(),[t,n]=ga(),{error:r}=Hx(e??""),s=t.get("baseline")??"",a=t.get("contender")??"";return r&&gs(r)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):r&&ys(r)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ds,{resource:"datasets"})})}):!e||!s||!a?o.jsx(ls,{children:o.jsx(wy,{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(ls,{children:o.jsx(wy,{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(Xw,{})," Dataset Experiments Comparison"]}),o.jsxs(ua.Description,{children:["Comparing"," ",o.jsx(Ba,{to:`/datasets/${e}/experiments/${s}`,children:s.slice(0,8)})," vs"," ",o.jsx(Ba,{to:`/datasets/${e}/experiments/${a}`,children:a.slice(0,8)})]})]}),o.jsx(ua.Column,{children:o.jsxs(de,{as:Ba,to:`/datasets/${e}`,children:[o.jsx(Nc,{}),"Back to Dataset"]})})]}),o.jsx(Xes,{datasetId:e,experimentIdA:s,experimentIdB:a,onSwap:()=>{n({baseline:a,contender:s})}})]})})})}function mts(){const{datasetId:e,itemId:t}=ur(),{Link:n}=yn(),r=bs(),{data:s,isLoading:a,error:i}=vTe(e??"",t??""),{updateItem:l,deleteItem:c}=Ei(),{data:u}=Hx(e??""),d=s?.[0]??null,f=d?.isDeleted??!1,[p,h]=g.useState(null),m=g.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]),v=d?.datasetVersion??0,[y,b]=g.useState(!1),[S,w]=g.useState(m.input),[k,_]=g.useState(m.groundTruth),[C,E]=g.useState(m.metadata),[j,N]=g.useState(m.trajectory),[I,R]=g.useState(m.toolMocks),[P,L]=g.useState(m.requestContext),[M,q]=g.useState(v);v!==M&&(q(v),w(m.input),_(m.groundTruth),E(m.metadata),N(m.trajectory),R(m.toolMocks),L(m.requestContext));const[H,F]=g.useState(!1),z=J=>{h(f?J:J.isLatest?null:J)},B=()=>{h(null)},D=!f&&p!=null,Q=()=>{D||b(!0)},V=()=>{D||F(!0)},$=async()=>{if(!e||!t)return;let J;try{J=JSON.parse(S)}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 ce;const Y=j!==m.trajectory;if(Y&&j.trim())try{ce=JSON.parse(j)}catch{De.error("Expected Trajectory must be valid JSON");return}let ne;const ue=I!==m.toolMocks;if(ue&&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=P!==m.requestContext;if(le&&P.trim())try{pe=JSON.parse(P)}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:ce??null}:{},...ue?{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"}`)}},U=()=>{d&&(w(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):""),L(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"),F(!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(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):i&&ys(i)?o.jsx(ls,{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(ls,{children:o.jsx(wy,{children:o.jsx("div",{className:"text-neutral3 p-4",children:"Item not found"})})}):o.jsxs(o.Fragment,{children:[o.jsx(ls,{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(yN,{}),t," ",o.jsx(Oa,{content:t})]}),o.jsx(ua.Description,{children:o.jsxs(Al,{children:["Item of ",o.jsx(iy,{})," ",u?.name]})}),o.jsxs(ua.Description,{children:[o.jsxs(Al,{children:[o.jsx(Nlt,{})," Created at"," ",d?.createdAt?er(new Date(d.createdAt),"MMM d, yyyy"):""]}),o.jsxs(Al,{children:[o.jsx(p_,{})," Latest version v",d?.datasetVersion??""]})]})]}),o.jsx(ua.Column,{children:!y&&!f&&o.jsxs(Mr,{children:[o.jsxs(de,{onClick:Q,disabled:D,title:D?"Return to latest version to edit":void 0,children:[o.jsx(Ylt,{})," Edit"]}),o.jsxs(de,{onClick:V,disabled:D,title:D?"Return to latest version to delete":void 0,children:[o.jsx(au,{})," Delete"]})]})})]}),o.jsxs(sy,{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&&D&&p&&o.jsx(In,{variant:"warning",title:"Previous version",action:o.jsxs(In.Button,{onClick:B,children:[o.jsx(_lt,{})," Return to the latest version"]}),children:o.jsxs(In.Message,{children:["Viewing version v",p.datasetVersion]})}),y?o.jsx(N9t,{inputValue:S,setInputValue:w,groundTruthValue:k,setGroundTruthValue:_,metadataValue:C,setMetadataValue:E,trajectoryValue:j,setTrajectoryValue:N,toolMocksValue:I,setToolMocksValue:R,requestContextValue:P,setRequestContextValue:L,validationErrors:null,onSave:$,onCancel:U,isSaving:l.isPending}):te?o.jsx(wTe,{item:te,Link:n}):o.jsx("div",{className:"text-neutral4 text-sm",children:"Item data not available"})]}),!y&&o.jsx(Gr,{children:o.jsx(Kes,{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:H,onOpenChange:F,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 MQe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function gts(){const{datasetId:e}=ur(),[t,n]=ga(),r=t.get("items")?.split(",").filter(Boolean)??[],{data:s,error:a}=Hx(e??""),{Link:i}=yn(),[l,c]=g.useState(!1),{data:u}=BU(e??"",r[0]??""),{data:d}=BU(e??"",r[1]??"");return a&&gs(a)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):a&&ys(a)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ds,{resource:"datasets"})})}):!e||r.length<2?o.jsx(ls,{children:o.jsx(wy,{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(ls,{children:[o.jsx(Iy,{owner:"dataset-items-compare",children:o.jsxs(de,{as:Ba,to:`/datasets/${e}`,variant:"outline",children:[o.jsx(Nc,{}),"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(Xw,{}),"Compare Dataset Items"]}),o.jsx(ua.Description,{children:o.jsxs(Al,{children:["Comparing ",r.length," items of"," ",o.jsx(Ba,{to:`/datasets/${e}`,className:"text-info1 hover:underline",children:s?.name||e?.slice(0,8)})]})})]}),o.jsx(ua.Column,{children:o.jsx(Mr,{children:o.jsx(de,{variant:"primary",onClick:()=>c(f=>!f),children:l?o.jsxs(o.Fragment,{children:[o.jsx(Dlt,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx(Bcn,{})," Diff View"]})})})})]}),o.jsx(sy,{className:"grid-cols-[1fr_3vw_1fr]",children:r.map((f,p)=>o.jsxs(g.Fragment,{children:[o.jsx(vts,{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($_e,{codeA:MQe(u),codeB:MQe(d)})]})})]})}function vts({datasetId:e,itemId:t,Link:n,idx:r,itemIds:s,onItemChange:a,showContent:i=!0}){const{data:l,isLoading:c}=BU(e,t),{data:u}=E1(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(da,{name:`compare-item-${r}`,value:t,onValueChange:a,children:[o.jsx(pa,{"aria-label":"Item",children:o.jsx(fa,{placeholder:"Select item"})}),o.jsx(ha,{children:f.map(p=>o.jsx(Lr,{value:p.value,disabled:p.disabled,children:p.label},p.value))})]}),o.jsxs(de,{as:n,to:`/datasets/${e}/items/${t}`,children:[o.jsx(p_,{}),"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(Tes,{item:l}),o.jsx(wTe,{item:l,Link:n})]}):o.jsxs("div",{className:"text-neutral4 text-sm",children:["Item ",t.slice(0,8)," not found"]})})]})}function DQe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function yts(){const{datasetId:e,itemId:t}=ur(),[n,r]=ga(),[s,a]=g.useState(!1),i=n.get("ids")?.split(",").map(Number).filter(h=>!isNaN(h)&&h>0)??[],{data:l,error:c}=Hx(e??""),{Link:u}=yn(),{data:d}=vTe(e??"",t??""),{data:f}=Bve(e??"",t??"",i[0]??0,l?.version),{data:p}=Bve(e??"",t??"",i[1]??0,l?.version);return c&&gs(c)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):c&&ys(c)?o.jsx(ls,{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(ls,{children:o.jsx(wy,{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(ls,{children:[o.jsx(Iy,{owner:"dataset-item-versions-compare",children:o.jsxs(de,{as:Ba,to:`/datasets/${e}/items/${t}`,variant:"outline",children:[o.jsx(Nc,{}),"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(Xw,{}),"Compare Dataset Item Versions"]}),o.jsx(ua.Description,{children:o.jsxs(Al,{children:["Comparing ",i.length," versions of"," ",o.jsx(Ba,{to:`/datasets/${e}/items/${t}`,className:"text-info1 hover:underline",children:t})]})})]}),o.jsx(ua.Column,{children:o.jsx(Mr,{children:o.jsx(de,{variant:"primary",onClick:()=>a(h=>!h),children:s?o.jsxs(o.Fragment,{children:[o.jsx(Dlt,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx(Cun,{})," Diff View"]})})})})]}),o.jsx(sy,{className:"grid-cols-[1fr_3vw_1fr]",children:i.map((h,m)=>o.jsxs(g.Fragment,{children:[o.jsx(bts,{datasetId:e,itemId:t,datasetVersion:h,latestVersion:l?.version,allVersions:d??[],versionNumbers:i,Link:u,idx:m,showContent:!s,onVersionChange:v=>{const y=[...i];y[m]=v,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($_e,{codeA:DQe(f),codeB:DQe(p)})]})})]})}function bts({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}=Bve(e,t,n,r),p=new Set(a.filter((v,y)=>y!==l)),h=s.map(v=>{const y=typeof v.updatedAt=="string"?new Date(v.updatedAt):v.updatedAt;return{value:String(v.datasetVersion),label:o.jsxs(o.Fragment,{children:[o.jsxs("b",{children:["v. ",v.datasetVersion]})," - ",er(y,"MMM d, yyyy h:mm a"),v.isLatest?o.jsx(Xs,{color:"blue",size:"small",children:"Latest"}):null]}),disabled:p.has(v.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(p_,{className:"w-6 h-6 opacity-50"}),o.jsxs(da,{name:`compare-version-${l}`,value:String(n),onValueChange:v=>u(Number(v)),children:[o.jsx(pa,{"aria-label":"Version",className:"w-full",children:o.jsx(fa,{placeholder:"Select version"})}),o.jsx(ha,{children:h.map(v=>o.jsx(Lr,{value:v.value,disabled:v.disabled,children:v.label},v.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(wTe,{item:m,Link:i})})]})}function xts(){const{datasetId:e}=ur(),[t]=ga(),n=t.get("ids")?.split(",").map(Number).filter(v=>!isNaN(v)&&v>0)??[],r=bs(),{data:s,error:a}=Hx(e??""),i=E1(e??"",void 0,n[0]??null),l=E1(e??"",void 0,n[1]??null),c=g.useMemo(()=>i.data??[],[i.data]),u=g.useMemo(()=>l.data??[],[l.data]),d=g.useMemo(()=>{const v=new Map;for(const y of[...c,...u])v.has(y.id)||v.set(y.id,{id:y.id,createdAt:new Date(y.createdAt)});return[...v.values()].sort((y,b)=>b.createdAt.getTime()-y.createdAt.getTime())},[c,u]),f=g.useMemo(()=>new Map(c.map(v=>[v.id,v])),[c]),p=g.useMemo(()=>new Map(u.map(v=>[v.id,v])),[u]);if(a&&gs(a))return o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})});if(a&&ys(a))return o.jsx(ls,{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(ls,{children:o.jsx(wy,{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=(v,y,b)=>{r(`/datasets/${e}/items/${v}/versions?ids=${y?.datasetVersion??""},${b?.datasetVersion??""}`)},m=(v,y)=>{r(`/datasets/${e}/versions?ids=${v},${y}`,{replace:!0})};return o.jsx(ls,{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(lfn,{})," Compare Dataset Versions"]}),o.jsx(ua.Description,{children:o.jsxs(Al,{children:[o.jsx(p_,{})," Comparing ",n.length," versions of"," ",s?.name||e?.slice(0,8)]})})]}),o.jsx(ua.Column,{children:o.jsxs(de,{as:Ba,to:`/datasets/${e}`,children:[o.jsx(Nc,{}),"Back to Dataset"]})})]}),o.jsx(sy,{children:o.jsxs(Gr,{children:[o.jsx(tts,{datasetId:e,versionA:String(n[0]),versionB:String(n[1]),onVersionChange:m}),o.jsx(ats,{datasetId:e,versionA:n[0],versionB:n[1],allItems:d,itemsAMap:f,itemsBMap:p,onItemClick:h})]})})]})})})}function qve({children:e,className:t}){return o.jsx("div",{className:K("flex flex-wrap gap-8",t),children:e})}function wts(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 Sts({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,v=wts(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)}),v?o.jsx(Kr.Change,{changePct:v.changePct,prevValue:v.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 LQe="auto 1fr auto auto auto auto auto auto auto";function kts(e){return e?(typeof e=="string"?new Date(e):e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}const Ots={completed:"success",running:"warning",failed:"error",pending:"neutral"};function _ts({experiments:e,datasets:t,reviewByExperiment:n,isLoading:r,search:s="",statusFilter:a="all",datasetFilter:i="all"}){const{paths:l,Link:c}=yn(),u=g.useMemo(()=>{const p=new Map;return t?.forEach(h=>p.set(h.id,h.name)),p},[t]),d=g.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=g.useMemo(()=>{const p=s.toLowerCase();return d.filter(h=>{const m=h.datasetId?u.get(h.datasetId)??"":"",v=!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 v&&y&&b})},[d,s,u,a,i]);return r?o.jsx(tl,{columns:LQe}):o.jsxs(me,{columns:LQe,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",v=p.succeededCount??0,y=p.failedCount??0,b=p.totalItems??0,S=b>0?Math.round(v/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(pg,{variant:Ots[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:v>0?"text-accent1":"",children:[v," (",S,"%)"]})}),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 w=n?.get(p.id);if(!w)return o.jsx("span",{className:"text-neutral2",children:"—"});const k=w.needsReview+w.complete;return k===0?o.jsx("span",{className:"text-neutral2",children:"—"}):w.needsReview>0?o.jsxs(Xs,{size:"small",color:"yellow",children:[w.needsReview," pending"]}):o.jsxs(Xs,{size:"small",color:"green",children:[w.complete,"/",k," reviewed"]})})()}),o.jsx(me.TextCell,{children:kts(p.createdAt)})]},p.id)})]})}const Cts=[{value:"all",label:"All statuses"},{value:"completed",label:"Completed"},{value:"running",label:"Running"},{value:"failed",label:"Failed"},{value:"pending",label:"Pending"}];function Ets(e){return[{value:"all",label:"All datasets"},...(e??[]).map(t=>({value:t.id,label:t.name}))]}const aF={completed:"#22c55e",running:"#facc15",pending:"#fb923c",failed:"#f87171"},jts=[{label:"Completed",color:aF.completed},{label:"Running",color:aF.running},{label:"Pending",color:aF.pending},{label:"Failed",color:aF.failed}];function Tts({experiments:e,datasets:t,isLoading:n,isError:r}){const{data:s,maxVal:a}=g.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(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.TitleAndDescription,{title:"Experiments by Dataset",description:"Experiment status breakdown per dataset."}),i&&o.jsx(Ut.Summary,{value:String(e?.length??0),label:"Total experiments"})]}),n?o.jsx(Ut.Loading,{}):r?o.jsx(Ut.Error,{message:"Failed to load experiments data"}):o.jsx(Ut.Content,{children:i?o.jsx(uN,{data:s,segments:jts,maxVal:a,fmt:l=>String(l)}):o.jsx(Ut.NoData,{message:"No experiments have been run yet"})})]})}const Nts=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Cr,{iconSlot:o.jsx(Of,{}),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(de,{variant:"ghost",as:"a",href:"https://mastra.ai/en/docs/evals/datasets/running-experiments",target:"_blank",rel:"noopener noreferrer",children:["Experiments Documentation ",o.jsx(_a,{})]})})})});function Its({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(jf,{label:"Search experiments",placeholder:"Filter by experiment, dataset, or target",value:e,onSearch:t}),o.jsxs(Mr,{children:[o.jsx(Sc,{label:"Status",labelIsHidden:!0,name:"filter-status",options:[...Cts],value:n,onValueChange:r,className:"whitespace-nowrap"}),o.jsx(Sc,{label:"Dataset",labelIsHidden:!0,name:"filter-dataset",options:i,value:s,onValueChange:a,className:"whitespace-nowrap"}),l&&c&&o.jsxs(de,{onClick:l,size:"sm",variant:"default",children:[o.jsx(vs,{className:"size-3"})," Reset"]})]})]})}function Ats(){const{data:e,isLoading:t,error:n}=ih(),{data:r,isLoading:s,error:a}=$g(),{data:i,isLoading:l,error:c}=JZ(),{data:u,isLoading:d,isError:f,error:p}=UWr(),{data:h,isLoading:m,isError:v,error:y}=OTe(),b=r?.datasets,S=i?.experiments,w=g.useMemo(()=>cts(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(zi,{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(qve,{children:o.jsx(Sts,{scorers:e,datasets:b,experiments:S,avgScore:u?.avgScore??null,prevAvgScore:u?.prevAvgScore??null,totalNeedsReview:w.needsReview,isLoadingScorers:t,isLoadingDatasets:s,isLoadingExperiments:l,isLoadingScores:d,isLoadingReview:m})}),o.jsx(eWr,{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(uJr,{experiments:S,isLoading:l,isError:!!c}),o.jsx(Tts,{experiments:S,datasets:b,isLoading:l,isError:!!c})]}),o.jsx(ots,{reviewSummary:h,experiments:S,datasets:b,isLoading:m,isError:!!v})]})})}function Rts(){const[e,t]=g.useState(""),[n,r]=g.useState("all"),[s,a]=g.useState("all"),{data:i,isLoading:l,error:c}=$g(),{data:u,isLoading:d,error:f}=JZ(),{data:p}=OTe(),h=g.useMemo(()=>i?.datasets??[],[i?.datasets]),m=g.useMemo(()=>u?.experiments??[],[u?.experiments]),v=g.useMemo(()=>Ets(h),[h]),y=g.useMemo(()=>P9t(p),[p]),b=l||d,S=f||c;if(S&&gs(S))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(S)return o.jsx(lr,{children:o.jsx(zi,{title:"Failed to load experiments",message:S.message})});if(m.length===0&&!b)return o.jsx(lr,{children:o.jsx(Nts,{})});const w=n!=="all"||s!=="all"||e!=="",k=()=>{t(""),r("all"),a("all")};return o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx(Its,{search:e,onSearchChange:t,statusFilter:n,onStatusFilterChange:r,datasetFilter:s,onDatasetFilterChange:a,datasetOptions:v,onReset:k,hasActiveFilters:w})}),o.jsx(_ts,{experiments:m,datasets:h,reviewByExperiment:y,isLoading:b,search:e,statusFilter:n,datasetFilter:s})]})}function iF({children:e}){return o.jsxs(Lt,{height:"full",children:[o.jsx("div",{}),o.jsx(Lt.MainArea,{isCentered:!0,children:e})]})}function Pts(){const{experimentId:e}=ur(),{data:t,isLoading:n}=JZ(),s=t?.experiments?.find(h=>h.id===e)?.datasetId??"",{data:a,isLoading:i,error:l}=zU(s,e??""),{data:c,isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p}=YZ({datasetId:s,experimentId:e??"",experimentStatus:a?.status});return!e||n||i?null:l&&gs(l)?o.jsx(iF,{children:o.jsx(Vs,{})}):l&&ys(l)?o.jsx(iF,{children:o.jsx(Ds,{resource:"datasets"})}):l&&vOe(l)||!n&&!s||!i&&!l&&!a?o.jsx(iF,{children:o.jsx(Cr,{iconSlot:o.jsx(tbe,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${e}".`,actionSlot:o.jsxs(de,{as:Ba,to:"/experiments",children:[o.jsx(Nc,{}),"Back to Experiments"]})})}):l?o.jsx(iF,{children:o.jsx(zi,{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($9t,{experiment:a}),o.jsx(Lt.MainArea,{children:o.jsx(R9t,{experimentId:e,datasetId:s,experimentStatus:a.status,results:c??[],isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p})})]})}function $ts({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 M9t({connections:e,isAdmin:t,disconnectPending:n,onDisconnect:r}){return o.jsx("ul",{className:"space-y-1",children:e.map(s=>o.jsx($ts,{connection:s,isAdmin:t,disconnectPending:n,onDisconnect:()=>r(s.connectionId)},s.connectionId))})}function Mts({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(M9t,{connections:a,isAdmin:t,disconnectPending:n,onDisconnect:r})]},s))})}function Dts({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(Mts,{groups:r,isAdmin:s,disconnectPending:l,onDisconnect:u}):o.jsx(M9t,{connections:n,isAdmin:s,disconnectPending:l,onDisconnect:u}),c?o.jsx("p",{className:"text-red-600",children:String(c)}):null]})}function Lts({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:v}){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:v,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 FQe=e=>e.authorId?.trim()||"shared",Fts=(e,t)=>{if(!t||new Set(e.map(FQe)).size<=1)return null;const r=new Map;for(const a of e){const i=FQe(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},zts=["*","tool-providers:*","tool-providers:admin"];function Bts(){const{data:e}=Sm();return e?.permissions?.some(t=>zts.includes(t))??!1}function Uts(){const[e,t]=g.useState(""),[n,r]=g.useState(""),[s,a]=g.useState(""),i=dI(),l=cW(e||null),c=XIt(e||null,n||null),u=YIt(),d=ZIt(),f=Bts(),p=i.data?.providers??[],h=l.data?.data??[],m=g.useMemo(()=>c.data?.items??[],[c.data?.items]),v=g.useMemo(()=>Fts(m,f),[m,f]),y=w=>{t(w),r("")},b=()=>{!e||!n||u.mutate({providerId:e,toolkit:n,label:s.trim()||null},{onSuccess:()=>{a(""),c.refetch()}})},S=w=>{d.mutate({providerId:e,connectionId:w})};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(Lts,{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(Dts,{providerId:e,toolkit:n,connections:m,groupedByAuthor:v,isAdmin:f,isLoading:c.isLoading,error:c.error,disconnectPending:d.isPending,disconnectError:d.error,onDisconnect:S})]})}function qts({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(Qh,{className:"h-10 w-10"}),o.jsx("h1",{className:"text-xl font-semibold text-neutral6",children:e})]}),t,n,r]})})}function D9t({redirectUri:e,onSuccess:t,initialMode:n="signin",errorMessage:r}){const{data:s,isLoading:a}=ac(),{mutate:i,isPending:l,error:c}=u1r(),{mutate:u,isPending:d,error:f}=f1r(),{mutate:p,isPending:h}=xNt(),[m,v]=g.useState(n),[y,b]=g.useState(""),[S,w]=g.useState(""),[k,_]=g.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,P=R?l:d,L=R?c:f,M=()=>{t?t():e?window.location.href=e:window.location.href="/"},q=D=>{D.preventDefault(),R?i({email:S,password:k},{onSuccess:M}):u({email:S,password:k,name:y||void 0},{onSuccess:M})},H=()=>{p({redirectUri:e},{onSuccess:D=>{window.location.href=D.url}})},F=()=>{v(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(yf,{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(qts,{title:R?"Sign in to Mastra Studio":"Create your account",description:z,errorBanner:B,children:[j&&o.jsxs("form",{onSubmit:q,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:D=>b(D.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:S,onChange:D=>w(D.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:D=>_(D.target.value),placeholder:R?"Enter your password":"Create a password",required:!0,variant:"default",size:"lg"})]}),L&&o.jsx("div",{className:"rounded-md bg-red-500/10 p-3 text-sm text-red-400",children:L.message}),o.jsx(de,{type:"submit",disabled:P,className:"w-full",size:"lg",children:P?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:F,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(de,{onClick:H,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 Vts(){const[e]=ga(),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(D9t,{redirectUri:n,onSuccess:i,initialMode:s,errorMessage:a})}const Kf=Mi.KeyValueList;function Hts(e){return e instanceof Date?e:new Date(e)}function Wts({log:e,onClose:t,onTraceClick:n,onSpanClick:r,onPrevious:s,onNext:a,collapsed:i,onCollapsedChange:l}){const[c,u]=g.useState(!1),d=i??c,f=l??u,p=Hts(e.timestamp),h=e.traceId,m=e.spanId;return o.jsxs(Mi,{collapsed:d,children:[o.jsxs(Mi.Header,{children:[o.jsxs(Mi.Heading,{children:["Log ",o.jsx("b",{children:er(p,"MMM dd, HH:mm:ss.SSS")})]}),o.jsxs(Mr,{className:"ml-auto shrink-0",children:[l&&o.jsx(de,{size:"md",tooltip:d?"Expand panel":"Collapse panel",onClick:()=>f(!d),children:d?o.jsx(Qq,{}):o.jsx(Mxe,{})}),o.jsxs(Mr,{spacing:"close",children:[o.jsx(de,{size:"md",tooltip:"Previous log",onClick:s,disabled:!s,children:o.jsx(Gq,{})}),o.jsx(de,{size:"md",tooltip:"Next log",onClick:a,disabled:!a,children:o.jsx(Wq,{})})]}),o.jsx(Mi.CloseButton,{onClick:t})]})]}),!d&&o.jsxs(Mi.Content,{children:[o.jsx("p",{className:"text-ui-md text-neutral4 font-mono wrap-break-word whitespace-pre-wrap",children:e.message}),(h||m)&&o.jsxs("div",{className:K("grid gap-2 my-8","[&>button]:justify-between [&>button]:overflow-hidden"),children:[h&&o.jsxs(Mr,{spacing:"close",className:"min-w-0 w-full",children:[o.jsxs(de,{size:"md",className:"min-w-0 flex-1 overflow-hidden",onClick:()=>n?.(h),children:[o.jsx($z,{}),o.jsx("span",{children:"Trace"}),o.jsxs("span",{className:" ml-auto text-ui-sm text-neutral2 min-w-0 truncate",children:["# ",h]})]}),o.jsx(Oa,{content:h,size:"md",tooltip:"Copy Trace ID to clipboard"})]}),m&&o.jsxs(Mr,{spacing:"close",className:"min-w-0 w-full",children:[o.jsxs(de,{size:"md",className:"min-w-0 flex-1 overflow-hidden",disabled:!h||!r,onClick:()=>h&&r?.(h,m),children:[o.jsx($z,{}),o.jsx("span",{children:"Span"}),o.jsxs("span",{className:" ml-auto text-ui-sm text-neutral2 min-w-0 truncate",children:["# ",m]})]}),o.jsx(Oa,{content:m,size:"md",tooltip:"Copy Span ID to clipboard"})]})]}),o.jsxs(Kf,{className:"mb-6",children:[e.entityType&&o.jsxs(o.Fragment,{children:[o.jsx(Kf.Key,{children:"Entity Type"}),o.jsx(Kf.Value,{children:e.entityType})]}),e.entityName&&o.jsxs(o.Fragment,{children:[o.jsx(Kf.Key,{children:"Entity Name"}),o.jsx(Kf.Value,{children:e.entityName})]}),e.serviceName&&o.jsxs(o.Fragment,{children:[o.jsx(Kf.Key,{children:"Service"}),o.jsx(Kf.Value,{children:e.serviceName})]}),e.environment&&o.jsxs(o.Fragment,{children:[o.jsx(Kf.Key,{children:"Environment"}),o.jsx(Kf.Value,{children:e.environment})]}),e.source&&o.jsxs(o.Fragment,{children:[o.jsx(Kf.Key,{children:"Source"}),o.jsx(Kf.Value,{children:e.source})]}),e.metadata&&Object.keys(e.metadata).length>0&&o.jsx(o.Fragment,{children:Object.entries(e.metadata).map(([v,y])=>o.jsxs(g.Fragment,{children:[o.jsx(Kf.Key,{children:v}),o.jsx(Kf.Value,{children:String(y)})]},v))})]}),e.data&&Object.keys(e.data).length>0&&o.jsx(Mi.CodeSection,{title:"Data",codeStr:JSON.stringify(e.data,null,2),className:"mt-6"})]})]})}function Zts({error:e,resource:t,errorTitle:n}){if(gs(e))return o.jsx(Vs,{});if(ys(e))return o.jsx(Ds,{resource:t});if(hTt(e,"logs"))return o.jsx(Cr,{iconSlot:o.jsx(Yq,{}),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(zi,{title:n,message:r??"Unknown error"})}function Gts({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 Qts={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 Yts({level:e}){const t=Qts[e];return o.jsx(ko,{height:"compact",children:o.jsx("span",{className:"uppercase text-ui-sm font-semibold",style:{color:t.color},children:t.label})})}function Xts({entityType:e,className:t}){const n=K("size-3.5 shrink-0 text-neutral2",t);switch(e.toLowerCase()){case Os.AGENT:return o.jsx(sl,{className:n,"aria-hidden":!0});case"workflow":case Os.WORKFLOW_RUN:return o.jsx(jd,{className:n,"aria-hidden":!0});case Os.TOOL:return o.jsx(eh,{className:n,"aria-hidden":!0});default:return null}}function Kts({entityType:e,entityName:t}){const n=e??"";return o.jsxs(ko,{height:"compact",className:"flex min-w-0 items-center gap-2",children:[o.jsx(Xts,{entityType:n}),t?o.jsx("span",{className:"min-w-0 text-ui-smd truncate",children:t}):"-"]})}function Jts({message:e}){return o.jsx(ko,{height:"compact",className:"text-neutral4 text-ui-smd min-w-0 truncate font-mono",children:e})}function ens({data:e}){if(!e||Object.keys(e).length===0)return o.jsx(ko,{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(X1e,{children:t})}const Ul=Object.assign(k3,{Top:tH,TopCell:$_,TopCellWithTooltip:nH,TopCellSmart:G1t,RowWrapper:nSe,RowButton:O3,RowLink:Q1t,Spacer:tSe,NoMatch:eH,DateCell:K1e,TimeCell:J1e,LevelCell:Yts,EntityCell:Kts,MessageCell:Jts,DataCell:ens,NextPageLoading:JV}),zQe="6rem 9rem 5rem 10rem minmax(8rem,1fr) minmax(8rem,1fr)",tns=36,nns=8;function rns({logs:e,isLoading:t,isFetchingNextPage:n,hasNextPage:r,setEndOfListElement:s,logIdMap:a,featuredLogId:i,onLogClick:l}){const c=g.useRef(null),u=y9t({count:e.length,getScrollElement:()=>c.current,estimateSize:()=>tns,overscan:nns}),d=g.useRef(t);if(g.useEffect(()=>{d.current&&!t&&c.current?.dispatchEvent(new Event("scroll")),d.current=t},[t]),t)return o.jsx(tl,{columns:zQe});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(Ul,{columns:zQe,variant:"striped",scrollRef:c,className:"min-w-0",children:[o.jsxs(Ul.Top,{children:[o.jsx(Ul.TopCell,{children:"Date"}),o.jsx(Ul.TopCell,{children:"Time"}),o.jsx(Ul.TopCell,{children:"Level"}),o.jsx(Ul.TopCell,{children:"Entity"}),o.jsx(Ul.TopCell,{children:"Message"}),o.jsx(Ul.TopCell,{children:"Data"})]}),e.length===0?o.jsx(Ul.NoMatch,{message:"No logs match your search"}):o.jsxs(o.Fragment,{children:[o.jsx(Ul.Spacer,{height:h}),f.map(v=>{const y=e[v.index];if(!y)return null;const b=a.get(y);if(!b)return null;const S=b===i;return o.jsxs(Ul.RowButton,{ref:u.measureElement,"data-index":v.index,onClick:()=>l(y),featured:S,variant:y.level==="error"||y.level==="fatal"?"error":"default",children:[o.jsx(Ul.DateCell,{timestamp:y.timestamp}),o.jsx(Ul.TimeCell,{timestamp:y.timestamp}),o.jsx(Ul.LevelCell,{level:y.level}),o.jsx(Ul.EntityCell,{entityType:y.entityType,entityName:y.entityName}),o.jsx(Ul.MessageCell,{message:y.message}),o.jsx(Ul.DataCell,{data:y.data})]},b)}),o.jsx(Ul.Spacer,{height:m})]}),o.jsx(Ul.NextPageLoading,{isLoading:n,hasMore:r,setEndOfListElement:s})]})}function sns({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=>ans(f,a));return o.jsxs("div",{className:K("grid grid-cols-[1fr_auto] gap-3 items-start"),children:[o.jsx(lTe,{fields:a,tokens:i,onTokensChange:l,disabled:s,autoFocusFieldId:c}),u&&o.jsx(iTe,{disabled:s,onClear:d?e:void 0,onRemoveAll:t,onSave:n,onRemoveSaved:r})]})}function ans(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 ins={"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"},tse="MMM d, yyyy HH:mm",nse="Pick a wider range or lower the logging level — verbose entries (debug, info) may be filtered out.";function ons({datePreset:e,dateFrom:t,dateTo:n}){return e&&e!=="all"&&e!=="custom"?{title:`No logs for ${ins[e]}`,description:nse}:t&&n?{title:`No logs between ${er(t,tse)} and ${er(n,tse)}`,description:nse}:t?{title:`No logs since ${er(t,tse)}`,description:nse}:{title:"No logs yet",description:"Logs will appear here once agents, workflows, or tools are executed."}}const lns=({datePreset:e,dateFrom:t,dateTo:n}={})=>{const{title:r,description:s}=ons({datePreset:e,dateFrom:t,dateTo:n});return o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Cr,{iconSlot:o.jsx(Yq,{}),titleSlot:r,descriptionSlot:s,actionSlot:o.jsxs(de,{variant:"ghost",as:"a",href:"https://mastra.ai/en/docs/observability/logging",target:"_blank",rel:"noopener noreferrer",children:["Logging Documentation ",o.jsx(Dxe,{})]})})})},cns=20,uns=1e4;function dns(e,t,n){if(e?.pagination?.hasMore)return n+1}function fns(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 pns(e){return hTt(e.state.error,"logs")?!1:uns}const hns=({filters:e}={})=>{const t=We(),{inView:n,setRef:r}=A_(),s=$1({queryKey:["logs",e],queryFn:({pageParam:p})=>t.listLogsVNext({pagination:{page:p,perPage:cns},filters:e,orderBy:{field:"timestamp",direction:"DESC"}}),initialPageParam:0,getNextPageParam:dns,select:fns,retry:!1,refetchInterval:pns}),{hasNextPage:a,isFetchingNextPage:i,fetchNextPage:l,data:c,isLoading:u,isError:d,error:f}=s;return g.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}},oF={AGENT:Os.AGENT,WORKFLOW:Os.WORKFLOW_RUN,SCORER:Os.SCORER,INGEST:Os.RAG_INGESTION},L9t=[{label:"Agent",entityType:oF.AGENT},{label:"Workflow",entityType:oF.WORKFLOW},{label:"Scorer",entityType:oF.SCORER},{label:"Ingest",entityType:oF.INGEST}],mns=[{label:"Debug",value:"debug"},{label:"Info",value:"info"},{label:"Warn",value:"warn"},{label:"Error",value:"error"},{label:"Fatal",value:"fatal"}],Dx="rootEntityType",qb="datePreset",Vb="dateFrom",Hb="dateTo",gns=new Set(["all","last-24h","last-3d","last-7d","last-14d","last-30d","custom"]),_l={level:"filterLevel",tags:"filterTags",entityName:"filterEntityName",traceId:"filterTraceId",spanId:"filterSpanId",runId:"filterRunId",threadId:"filterThreadId",sessionId:"filterSessionId",requestId:"filterRequestId",resourceId:"filterResourceId",userId:"filterUserId",organizationId:"filterOrganizationId",serviceName:"filterServiceName",environment:"filterEnvironment",experimentId:"filterExperimentId"},X4=Object.keys(_l),_Te=new Set(["tags"]),CTe="mastra:logs:saved-filters";function vns(e,t=CTe){const n=Sns(e),r=e.get(qb);r&&n.set(qb,r);const s=e.get(Vb);s&&n.set(Vb,s);const a=e.get(Hb);a&&n.set(Hb,a);try{localStorage.setItem(t,n.toString())}catch{}}function yns(e=CTe){try{localStorage.removeItem(e)}catch{}}function BQe(e=CTe){try{const t=localStorage.getItem(e);if(!t)return null;const n=new URLSearchParams(t);return n.toString()?n:null}catch{return null}}function bns(e){if(e.has(qb)||e.has(Vb)||e.has(Hb)||e.has(Dx))return!0;for(const t of X4)if(e.has(_l[t]))return!0;return!1}function xns({availableTags:e,availableRootEntityNames:t,availableServiceNames:n,availableEnvironments:r,loading:s}){const a=[{id:"rootEntityType",label:"Primitive Type",kind:"pick-multi",searchable:!1,options:L9t.map(u=>({label:u.label,value:u.entityType})),placeholder:"Choose entity type",emptyText:"No entity types."},{id:"entityName",label:"Primitive Name",kind:"pick-multi",options:t.map(u=>({label:u,value:u})),placeholder:"Choose entity names",emptyText:"No entity names found.",isLoading:s?.entityNames},{id:"level",label:"Level",kind:"pick-multi",searchable:!1,options:mns.map(u=>({label:u.label,value:u.value})),placeholder:"Choose level",emptyText:"No levels."},{id:"tags",label:"Tags",kind:"pick-multi",multi:!0,options:e.map(u=>({label:u,value:u})),placeholder:"Choose tags",emptyText:"No tags found.",isLoading:s?.tags},{id:"serviceName",label:"Service Name",kind:"pick-multi",options:n.map(u=>({label:u,value:u})),placeholder:"Choose service names",emptyText:"No service names found.",isLoading:s?.serviceNames},{id:"environment",label:"Environment",kind:"pick-multi",options:r.map(u=>({label:u,value:u})),placeholder:"Choose environments",emptyText:"No environments found.",isLoading:s?.environments},{id:"traceId",label:"Trace ID",kind:"text"},{id:"spanId",label:"Span ID",kind:"text"},{id:"runId",label:"Run ID",kind:"text"},{id:"threadId",label:"Thread ID",kind:"text"},{id:"sessionId",label:"Session ID",kind:"text"},{id:"requestId",label:"Request ID",kind:"text"},{id:"resourceId",label:"Resource ID",kind:"text"},{id:"userId",label:"User ID",kind:"text"},{id:"organizationId",label:"Organization ID",kind:"text"},{id:"experimentId",label:"Experiment ID",kind:"text"}],i=(u,d)=>u.label.localeCompare(d.label),l=a.filter(u=>u.kind==="pick-multi").sort(i),c=a.filter(u=>u.kind==="text").sort(i);return[...l,...c]}function wns(e){const t=[],n=new Map([[Dx,"rootEntityType"]]);for(const s of X4)n.set(_l[s],s);const r=new Set;for(const[s]of e.entries()){const a=n.get(s);if(!a||r.has(a))continue;if(r.add(a),_Te.has(a)){const l=e.getAll(s);if(l.length===0)continue;t.push({fieldId:a,value:l.filter(Boolean)});continue}const i=e.get(s);i!==null&&t.push({fieldId:a,value:i})}return t}function Sns(e){const t=new URLSearchParams,n=e.get(Dx);n&&t.set(Dx,n);for(const r of X4){const s=_l[r];if(_Te.has(r)){for(const i of e.getAll(s))t.append(s,i);continue}const a=e.get(s);a&&t.set(s,a)}return t}function kns(e,t){e.delete(Dx);for(const n of X4)e.delete(_l[n]);for(const n of t){if(n.fieldId==="rootEntityType"&&typeof n.value=="string"){e.set(Dx,n.value);continue}const r=_l[n.fieldId];if(r){if(_Te.has(n.fieldId)&&Array.isArray(n.value)){if(n.value.length===0)e.append(r,"");else for(const s of n.value)e.append(r,s);continue}typeof n.value=="string"&&e.set(r,n.value.trim())}}}function Ons({rootEntityType:e,dateFrom:t,dateTo:n,tokens:r}){const s={};e&&(s.rootEntityType=e),(t||n)&&(s.timestamp={...t?{start:t}:{},...n?{end:n}:{}});for(const a of r){if(a.fieldId==="tags"){Array.isArray(a.value)&&a.value.length>0?s.tags=a.value:typeof a.value=="string"&&a.value.trim()&&(s.tags=[a.value.trim()]);continue}if(a.fieldId==="level"){typeof a.value=="string"&&a.value.trim()&&a.value!=="Any"&&(s.level=a.value);continue}if(typeof a.value=="string"&&a.value.trim()&&a.value!=="Any")switch(a.fieldId){case"entityName":s.rootEntityName=a.value;break;case"traceId":s.traceId=a.value;break;case"spanId":s.spanId=a.value;break;case"runId":s.runId=a.value;break;case"threadId":s.threadId=a.value;break;case"sessionId":s.sessionId=a.value;break;case"requestId":s.requestId=a.value;break;case"resourceId":s.resourceId=a.value;break;case"userId":s.userId=a.value;break;case"organizationId":s.organizationId=a.value;break;case"serviceName":s.serviceName=a.value;break;case"environment":s.environment=a.value;break;case"experimentId":s.experimentId=a.value;break}}return s}function _ns(e,t){return t.map(n=>{const r=e.find(s=>s.id===n.fieldId);return r?r.kind==="text"?{fieldId:n.fieldId,value:""}:r.kind==="pick-multi"?r.multi?{fieldId:n.fieldId,value:[]}:{fieldId:n.fieldId,value:"Any"}:n:n})}const Cns="Filters setting for Logs saved",Ens="Filters setting for Logs cleared up";function jns(e,t,n){const{storageKey:r,messages:s,skipHydration:a}={},[i,l]=g.useState(()=>BQe(r)!==null),c=g.useCallback(()=>{vns(e,r),l(!0);const f=s?.saved??Cns;f!==!1&&De.success(f)},[e,r,s?.saved]),u=g.useCallback(()=>{yns(r),l(!1);const f=s?.cleared??Ens;f!==!1&&De.success(f)},[r,s?.cleared]),d=g.useRef(!1);return g.useEffect(()=>{if(a||d.current||(d.current=!0,bns(e)))return;const f=BQe(r);f&&t(p=>{const h=new URLSearchParams(p);for(const[m,v]of f)h.append(m,v);return h},{replace:!0})},[]),{hasSavedFilters:i,handleSave:c,handleRemoveSaved:u}}function Tns(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 Nns(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,Tns(`${r}${n.message??""}${n.data?JSON.stringify(n.data):""}`))}return t}function Ins(e,t,n,r){const s=g.useMemo(()=>Nns(e),[e]),a=g.useMemo(()=>{const h=new Map;for(let m=0;m<e.length;m++){const v=s.get(e[m]);v&&h.set(v,{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=g.useCallback(h=>s.get(h),[s]),d=g.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);m&&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);m&&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 Vve="logId",Hve="traceId",Wve="spanId",DR=1440*60*1e3,Ans={"last-24h":DR,"last-3d":3*DR,"last-7d":7*DR,"last-14d":14*DR,"last-30d":30*DR};function lF(e){e.delete(Vve),e.delete(Hve),e.delete(Wve)}function Rns(e,t,n){const{onRemoveAll:r}={},s=g.useMemo(()=>{const _=e.get(qb);return _&&gns.has(_)?_:"last-24h"},[e]),a=e.get(Vb),i=e.get(Hb),l=g.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 _=Ans[s];return _?new Date(Date.now()-_):void 0},[s,a]),c=g.useMemo(()=>{if(s!=="custom"||!i)return;const _=new Date(i);return Number.isNaN(_.getTime())?void 0:_},[s,i]),u=g.useRef(s);u.current=s;const d=e.get(Vve),f=e.get(Hve),p=e.get(Wve),h=g.useMemo(()=>L9t.find(_=>_.entityType===e.get(Dx)),[e]),m=g.useMemo(()=>wns(e),[e]),v=g.useCallback(_=>{t(C=>{const E=new URLSearchParams(C);for(const[j,N]of Object.entries(_)){const I=j==="logId"?Vve:j==="traceId"?Hve:Wve;N?E.set(I,N):E.delete(I)}return E},{replace:!0})},[t]),y=g.useCallback(_=>{t(C=>{const E=new URLSearchParams(C);return kns(E,_),lF(E),E},{replace:!0})},[t]),b=y,S=g.useCallback((_,C)=>{if(u.current!=="custom")return;const E=C==="from"?Vb:Hb;t(j=>{const N=new URLSearchParams(j);return _?N.set(E,_.toISOString()):N.delete(E),lF(N),N},{replace:!0})},[t]),w=g.useCallback(_=>{u.current=_,t(C=>{const E=new URLSearchParams(C);return _==="last-24h"?(E.delete(qb),E.delete(Vb),E.delete(Hb)):_==="custom"?E.set(qb,"custom"):(E.set(qb,_),E.delete(Vb),E.delete(Hb)),lF(E),E},{replace:!0})},[t]),k=g.useCallback(()=>{t(_=>{const C=new URLSearchParams(_);C.delete(Dx);for(const E of X4)C.delete(_l[E]);return C.delete(qb),C.delete(Vb),C.delete(Hb),lF(C),C},{replace:!0}),r?.()},[t,r]);return g.useMemo(()=>({searchParams:e,setSearchParams:t,datePreset:s,selectedDateFrom:l,selectedDateTo:c,datePresetRef:u,featuredLogId:d,featuredTraceId:f,featuredSpanId:p,selectedEntityOption:h,filterTokens:m,handleFeaturedChange:v,handleFilterTokensChange:b,handleDateChange:S,handleDatePresetChange:w,handleRemoveAll:k,applyFilterTokens:y}),[e,t,s,l,c,u,d,f,p,h,m,v,b,S,w,k,y])}const wb=Mi.KeyValueList;function Pns({spanId:e,span:t,isLoading:n,onClose:r}){const s=t?.startedAt&&t?.endedAt?new Date(t.endedAt).getTime()-new Date(t.startedAt).getTime():null;return o.jsxs(Mi,{children:[o.jsxs(Mi.Header,{children:[o.jsxs(Mi.Heading,{children:["Span ",o.jsxs("b",{children:["# ",e]})]}),o.jsx(Mi.CloseButton,{onClick:r})]}),n?o.jsx(Mi.LoadingData,{children:"Loading span..."}):t?o.jsxs(Mi.Content,{children:[o.jsxs(wb,{children:[t.spanType&&o.jsxs(o.Fragment,{children:[o.jsx(wb.Key,{children:"Type"}),o.jsx(wb.Value,{children:t.spanType})]}),t.startedAt&&o.jsxs(o.Fragment,{children:[o.jsx(wb.Key,{children:"Started"}),o.jsx(wb.Value,{children:er(new Date(t.startedAt),"MMM dd, HH:mm:ss.SSS")})]}),t.endedAt&&o.jsxs(o.Fragment,{children:[o.jsx(wb.Key,{children:"Ended"}),o.jsx(wb.Value,{children:er(new Date(t.endedAt),"MMM dd, HH:mm:ss.SSS")})]}),s!=null&&o.jsxs(o.Fragment,{children:[o.jsx(wb.Key,{children:"Duration"}),o.jsx(wb.Value,{children:s<1e3?`${s}ms`:`${(s/1e3).toFixed(2)}s`})]})]}),o.jsx("br",{}),o.jsx(Mi.CodeSection,{title:"Input",icon:o.jsx(Dfe,{}),codeStr:JSON.stringify(t.input??null,null,2)}),o.jsx(Mi.CodeSection,{title:"Output",icon:o.jsx(Lfe,{}),codeStr:JSON.stringify(t.output??null,null,2)}),o.jsx(Mi.CodeSection,{title:"Metadata",icon:o.jsx(hw,{}),codeStr:JSON.stringify(t.metadata??null,null,2)}),o.jsx(Mi.CodeSection,{title:"Attributes",icon:o.jsx(hw,{}),codeStr:JSON.stringify(t.attributes??null,null,2)})]}):o.jsx(Mi.NoData,{children:"Span not found."})]})}function $ns(){const[e,t]=ga(),n=Rns(e,t),r=jns(e,t),[s,a]=g.useState(),[i,l]=g.useState(!1),{data:c=[],isPending:u}=gTe(),{data:d=[],isPending:f}=pTe({entityType:n.selectedEntityOption?.entityType,rootOnly:!0}),{data:p=[],isPending:h}=hTe(),{data:m=[],isPending:v}=mTe(),y=g.useMemo(()=>xns({availableTags:c,availableRootEntityNames:d,availableServiceNames:m,availableEnvironments:p,loading:{tags:u,entityNames:f,serviceNames:v,environments:h}}),[c,d,m,p,u,f,v,h]),b=g.useMemo(()=>Ons({rootEntityType:n.selectedEntityOption?.entityType,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,tokens:n.filterTokens}),[n.filterTokens,n.selectedDateFrom,n.selectedDateTo,n.selectedEntityOption]),{data:S=[],isLoading:w,error:k,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:E}=hns({filters:b}),{logIdMap:j,featuredLog:N,handleLogClick:I,handlePreviousLog:R,handleNextLog:P}=Ins(S,n.featuredLogId,n.handleFeaturedChange,n.featuredTraceId),{data:L,isLoading:M}=ZH(n.featuredTraceId??null),{data:q,isLoading:H}=oI(n.featuredTraceId??"",n.featuredSpanId??""),F=g.useCallback(()=>n.applyFilterTokens(_ns(y,n.filterTokens)),[y,n]),z=g.useCallback(()=>n.handleFeaturedChange({logId:null}),[n]),B=g.useCallback(X=>n.handleFeaturedChange({traceId:X,spanId:null}),[n]),D=g.useCallback((X,te)=>n.handleFeaturedChange({traceId:X,spanId:te}),[n]),Q=g.useCallback(()=>{n.handleFeaturedChange({traceId:null,spanId:null}),l(!1)},[n]),V=g.useCallback(()=>n.handleFeaturedChange({spanId:null}),[n]),$=g.useCallback(X=>n.handleFeaturedChange({spanId:X??null}),[n]),U=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(aTe,{preset:n.datePreset,onPresetChange:n.handleDatePresetChange,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,onDateChange:n.handleDateChange,disabled:w,presets:["last-24h","last-3d","last-7d","last-14d","last-30d","custom"]}),o.jsx(cTe,{fields:y,tokens:n.filterTokens,onTokensChange:n.handleFilterTokensChange,disabled:w,onStartTextFilter:a})]})}),o.jsx(sns,{isLoading:w,filterFields:y,filterTokens:n.filterTokens,onFilterTokensChange:n.handleFilterTokensChange,onClear:F,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:[U,o.jsx(Lt.MainArea,{isCentered:!0,children:o.jsx(Zts,{error:k,resource:"logs",errorTitle:"Failed to load logs"})})]});const Z=!!n.selectedEntityOption||n.filterTokens.length>0;return S.length===0&&!w&&!Z?o.jsxs(Lt,{width:"wide",height:"full",children:[U,o.jsx(Lt.MainArea,{isCentered:!0,children:o.jsx(lns,{datePreset:n.datePreset,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo})})]}):o.jsxs(Lt,{width:"wide",height:"full",children:[U,o.jsx(Gts,{logCollapsed:i,listSlot:o.jsx(rns,{logs:S,isLoading:w,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:E,logIdMap:j,featuredLogId:n.featuredLogId,onLogClick:I}),logPanelSlot:N?o.jsx(Wts,{log:N,onClose:z,onTraceClick:B,onSpanClick:D,onPrevious:R,onNext:P,collapsed:i,onCollapsedChange:l}):null,tracePanelSlot:n.featuredTraceId?o.jsx($Et,{traceId:n.featuredTraceId,spans:L?.spans,isLoading:M,onClose:Q,onSpanSelect:$,selectedSpanId:n.featuredSpanId}):null,spanPanelSlot:n.featuredTraceId&&n.featuredSpanId?o.jsx(Pns,{spanId:n.featuredSpanId,span:q?.span,isLoading:H,onClose:V}):null})]})}function Mns({server:e}){const{paths:t,Link:n}=yn(),s=We().options.baseUrl,a=s?`${s}/api/mcp/${e.id}/sse`:"",{data:i}=M5t(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=fm(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 Dns({mcpServers:e,isLoading:t,search:n=""}){const r=g.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(tl,{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(sl,{}),tooltip:"Agent Tools",className:"text-center"}),o.jsx(me.TopCellSmart,{long:"Tools",short:o.jsx(eh,{}),tooltip:"Tools",className:"text-center"}),o.jsx(me.TopCellSmart,{long:"Workflows",short:o.jsx(jd,{}),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(Mns,{server:s},s.id))]})}const Lns=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Cr,{iconSlot:o.jsx(Of,{}),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(de,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/tools-mcp/mcp-overview",target:"_blank",rel:"noopener noreferrer",children:["MCP Documentation ",o.jsx(_a,{})]})})}),Fns=()=>{const{data:e=[],isLoading:t,error:n}=MZ(),[r,s]=g.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(zi,{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(jf,{onSearch:s,label:"Filter MCP servers",placeholder:"Filter by name"})})}),o.jsx(Dns,{mcpServers:e,isLoading:t,search:r})]})},zns=(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 Bns({tools:e,agents:t,isLoading:n,search:r=""}){const{paths:s,Link:a}=yn(),i=g.useMemo(()=>zns(e,t),[e,t]),l=g.useMemo(()=>i.filter(c=>c.id.toLowerCase().includes(r.toLowerCase())),[i,r]);return n?o.jsx(tl,{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(sl,{}),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=fm(c.id,50),d=fm(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 Uns=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Cr,{iconSlot:o.jsx(Of,{}),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(de,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/agents/using-tools-and-mcp",target:"_blank",rel:"noopener noreferrer",children:["Tools Documentation ",o.jsx(_a,{})]})})}),qns=()=>{const e=We();return Rn({mutationFn:async({toolId:t,input:n,requestContext:r})=>{const s=new u_;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}}})},Vns=({toolId:e})=>{const{canExecute:t}=il(),n=t("tools"),{data:r={}}=km(),s=g.useMemo(()=>{for(const v of Object.values(r))if(v.tools){const y=Object.values(v.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}=qns(),{requestContext:p}=_s();g.useEffect(()=>{if(l){const v=l instanceof Error?l.message:"Failed to load tool";De.error(`Error loading tool: ${v}`)}},[l]);const h=async(v,y)=>{if(!c)return;const b={...p??{},...y??{}};return u({toolId:c.id,input:v,requestContext:b})},m=c?.inputSchema?lm(im(yx(c?.inputSchema))):Ss({});return i?o.jsxs("div",{className:"p-6",children:[o.jsx(bt,{className:"h-8 w-48 mb-4"}),o.jsx(bt,{className:"h-32 w-full"})]}):l?null:c?n?o.jsx(Hje,{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 Hns({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}=cI(),{data:p={},isLoading:h,isError:m,error:v}=km(),{navigate:y,paths:b}=yn();g.useEffect(()=>{if(d){const _=f instanceof Error?f.message:"Failed to load tools";De.error(`Error loading tools: ${_}`)}},[d,f]),g.useEffect(()=>{if(m){const _=v instanceof Error?v.message:"Failed to load agents";De.error(`Error loading agents: ${_}`)}},[m,v]);const S=new Map;Object.values(p).forEach(_=>{_.tools&&Object.values(_.tools).forEach(C=>{S.has(C.id)||S.set(C.id,C)})}),Object.values(c).forEach(_=>{S.has(_.id)||S.set(_.id,_)});const w=Array.from(S.values()).map(_=>({label:_.id,value:_.id})),k=_=>{t?t(_):_&&_!==e&&y(b.toolLink(_))};return o.jsx(Jl,{options:w,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 Wns=({isLoading:e,server:t})=>{const[{sseUrl:n,httpStreamUrl:r},s]=g.useState({sseUrl:"",httpStreamUrl:""});if(g.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(wy,{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(wy,{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(dn,{icon:o.jsx(_Et,{className:"text-neutral6"}),className:"rounded-r-sm text-neutral4!",children:"Version"}),o.jsx(dn,{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(dn,{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(Oa,{tooltip:"Copy HTTP Stream URL",content:r})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(dn,{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(Oa,{tooltip:"Copy SSE URL",content:n})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(dn,{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(Oa,{tooltip:"Copy Command Line Config",content:a})})]})]})]})]}),o.jsx("div",{className:"h-full overflow-y-scroll border-l border-border1",children:o.jsx(Zns,{server:t})})]})},Zns=({server:e})=>{const{data:t={},isLoading:n}=M5t(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(B_,{})}),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(Qns,{tool:a,serverId:e.id},s)})})]})};function Gns(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 Qns=({tool:e,serverId:t})=>{const n=g.useRef(null),{Link:r,paths:s}=yn(),a=o6t[e.toolType||"tool"],i=Gns(e._meta);return o.jsxs(Nf,{onClick:()=>n.current?.click(),children:[o.jsx(QIt,{children:o.jsx(a,{className:"group-hover/entity:text-accent6"})}),o.jsxs(Af,{children:[o.jsx(If,{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(dn,{className:"text-[10px] py-0",children:"App"})]})}),o.jsx(th,{children:e.description})]})]})},Yns=()=>{const{serverId:e}=ur(),{data:t=[],isLoading:n}=MZ(),r=t.find(s=>s.id===e);return o.jsx("div",{className:"h-full w-full overflow-hidden",children:o.jsx(Wns,{isLoading:n,server:r})})};function Xns(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 Kns=({toolId:e,serverId:t})=>{const{canExecute:n}=il(),r=n("tools"),s=We(),{data:a,isLoading:i,error:l}=mje(t,e),{mutateAsync:c,isPending:u,data:d}=g7r(t,e),f=a?Xns(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=g.useCallback(async(y,b)=>await c(b),[c]);g.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(bt,{className:"h-8 w-48 mb-4"}),o.jsx(bt,{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 v;try{v=lm(im(a.inputSchema))}catch(y){console.error("Error processing input schema:",y),De.error("Failed to process tool input schema."),v=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($5t,{html:p,toolName:a.name??a.id,onToolCall:h})}),o.jsx(Hje,{executionResult:d,isExecutingTool:u,zodInputSchema:v,handleExecuteTool:m,toolDescription:a.description||"",toolId:a.id})]})},Jns=()=>{const{serverId:e,toolId:t}=ur(),{data:n,isLoading:r}=mje(e,t);return r||!n?null:o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(Kns,{toolId:t,serverId:e})})},F9t=[{label:"Agent",entityType:Os.AGENT},{label:"Workflow",entityType:Os.WORKFLOW_RUN},{label:"Scorer",entityType:Os.SCORER},{label:"Ingest",entityType:Os.RAG_INGESTION}],dN="rootEntityType",fN={tags:"filterTags",entityId:"filterEntityId",entityName:"filterEntityName",runId:"filterRunId",threadId:"filterThreadId",sessionId:"filterSessionId",requestId:"filterRequestId",resourceId:"filterResourceId",userId:"filterUserId",organizationId:"filterOrganizationId",serviceName:"filterServiceName",environment:"filterEnvironment",experimentId:"filterExperimentId",provider:"filterProvider",model:"filterModel"},eG=Object.keys(fN),ETe="mastra:metrics:saved-filters";function ers(e){const t=ars(e);try{localStorage.setItem(ETe,t.toString())}catch{}}function trs(){try{localStorage.removeItem(ETe)}catch{}}function z9t(){try{const e=localStorage.getItem(ETe);if(!e)return null;const t=new URLSearchParams(e);return t.toString()?t:null}catch{return null}}function nrs(e){if(e.has(dN))return!0;for(const t of eG)if(e.has(fN[t]))return!0;return!1}function rrs({availableTags:e,availableEntityNames:t,availableServiceNames:n,availableEnvironments:r,loading:s}){const a=[{id:"rootEntityType",label:"Primitive Type",kind:"pick-multi",searchable:!1,options:F9t.map(u=>({label:u.label,value:u.entityType})),placeholder:"Choose entity type",emptyText:"No entity types."},{id:"entityName",label:"Primitive Name",kind:"pick-multi",options:t.map(u=>({label:u,value:u})),placeholder:"Choose entity names",emptyText:"No entity names found.",isLoading:s?.entityNames},{id:"entityId",label:"Primitive ID",kind:"text"},{id:"tags",label:"Tags",kind:"pick-multi",multi:!0,options:e.map(u=>({label:u,value:u})),placeholder:"Choose tags",emptyText:"No tags found.",isLoading:s?.tags},{id:"serviceName",label:"Service Name",kind:"pick-multi",options:n.map(u=>({label:u,value:u})),placeholder:"Choose service names",emptyText:"No service names found.",isLoading:s?.serviceNames},{id:"environment",label:"Environment",kind:"pick-multi",options:r.map(u=>({label:u,value:u})),placeholder:"Choose environments",emptyText:"No environments found.",isLoading:s?.environments},{id:"threadId",label:"Thread ID",kind:"text"},{id:"resourceId",label:"Resource ID",kind:"text"},{id:"userId",label:"User ID",kind:"text"},{id:"organizationId",label:"Organization ID",kind:"text"},{id:"runId",label:"Run ID",kind:"text"},{id:"sessionId",label:"Session ID",kind:"text"},{id:"requestId",label:"Request ID",kind:"text"},{id:"experimentId",label:"Experiment ID",kind:"text"}],i=(u,d)=>u.label.localeCompare(d.label),l=a.filter(u=>u.kind==="pick-multi").sort(i),c=a.filter(u=>u.kind==="text").sort(i);return[...l,...c]}function srs(e){const t=[],n=new Map([[dN,"rootEntityType"]]);for(const s of eG)n.set(fN[s],s);const r=new Set;for(const[s]of e.entries()){const a=n.get(s);if(!a||r.has(a))continue;if(r.add(a),a==="tags"){const l=e.getAll(s);if(l.length===0)continue;t.push({fieldId:a,value:l.filter(Boolean)});continue}if(a==="rootEntityType"||a==="entityName"||a==="serviceName"||a==="environment"||a==="provider"||a==="model"){const l=e.getAll(s);if(l.length>1){t.push({fieldId:a,value:l});continue}}const i=e.get(s);i!==null&&t.push({fieldId:a,value:i})}return t}function ars(e){const t=new URLSearchParams,n=e.getAll(dN);for(const r of n)t.append(dN,r);for(const r of eG){const s=fN[r],a=e.getAll(s);for(const i of a)t.append(s,i)}return t}function irs(e,t){e.delete(dN);for(const n of eG)e.delete(fN[n]);for(const n of t){const r=n.fieldId==="rootEntityType"?dN:fN[n.fieldId];if(r)if(Array.isArray(n.value)){const s=n.value.filter(a=>typeof a=="string"&&a!=="");if(s.length===0){n.fieldId==="tags"&&e.append(r,"");continue}for(const a of s)e.append(r,a)}else typeof n.value=="string"&&e.set(r,n.value.trim())}}const ors="Any";function UQe(e){const t=e.trim();return t===""||t===ors}const lrs=new Set(F9t.map(e=>e.entityType));function qQe(e){const t=e.trim();return lrs.has(t)?t:void 0}function crs(e){const t={};for(const n of e){const r=n.fieldId;if(Array.isArray(n.value)){const s=n.value.filter(a=>typeof a=="string").map(a=>a.trim()).filter(a=>!UQe(a));if(s.length===0)continue;if(r==="tags")t.tags=s;else if(r==="rootEntityType"){const a=qQe(s[0]);a&&(t.rootEntityType=a)}else t[r]=s[0]}else if(typeof n.value=="string"){if(UQe(n.value))continue;const s=n.value.trim();if(r==="rootEntityType"){const a=qQe(s);a&&(t.rootEntityType=a)}else t[r]=s}}return t}const B9t=[{label:"Last 24 hours",value:"24h"},{label:"Last 3 days",value:"3d"},{label:"Last 7 days",value:"7d"},{label:"Last 14 days",value:"14d"},{label:"Last 30 days",value:"30d"}],urs=new Set(B9t.map(e=>e.value));function drs(e){return typeof e=="string"&&(urs.has(e)||e==="custom")}const U9t=g.createContext({datePreset:"24h",setDatePreset:()=>{},customRange:void 0,setCustomRange:()=>{},dateRangeLabel:"Last 24 hours",filterTokens:[],setFilterTokens:()=>{},dimensionalFilter:{},dimensionalFilterKey:"{}",tracesBasePath:void 0,logsBasePath:void 0});function tG(){return g.useContext(U9t)}function frs(e,t){return e!=="custom"?B9t.find(n=>n.value===e)?.label??e:t?.from?t.to?`${er(t.from,"MMM d, yyyy")} – ${er(t.to,"MMM d, yyyy")}`:er(t.from,"MMM d, yyyy"):"Custom range"}function prs({children:e,preset:t,filterTokens:n,onPresetChange:r,onFilterTokensChange:s,customRange:a,onCustomRangeChange:i,tracesBasePath:l,logsBasePath:c}){const u=g.useMemo(()=>JSON.stringify(n),[n]),d=g.useMemo(()=>n,[u]),f=g.useMemo(()=>crs(d),[d]),p=g.useMemo(()=>JSON.stringify(f),[f]),h=frs(t,a),m=g.useMemo(()=>({datePreset:t,setDatePreset:r,customRange:a,setCustomRange:i??(()=>{}),dateRangeLabel:h,filterTokens:d,setFilterTokens:s,dimensionalFilter:f,dimensionalFilterKey:p,tracesBasePath:l,logsBasePath:c}),[t,r,a,i,h,d,s,f,p,l,c]);return o.jsx(U9t.Provider,{value:m,children:e})}const hrs=["last-24h","last-3d","last-7d","last-14d","last-30d","custom"];function mrs(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 grs(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 vrs(){const{datePreset:e,setDatePreset:t,customRange:n,setCustomRange:r}=tG(),s=g.useRef(e);s.current=e;const a=g.useRef(n);return a.current=n,o.jsx(aTe,{preset:mrs(e),onPresetChange:i=>{const l=grs(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:hrs})}const rse={"24h":1440*60*1e3,"3d":4320*60*1e3,"7d":10080*60*1e3,"14d":336*60*60*1e3,"30d":720*60*60*1e3};function yrs(e,t,n){if(e!=="custom"){const r=rse[e]??rse["24h"];return{start:new Date(n-r),end:new Date(n)}}return{start:t?.from??new Date(n-rse["24h"]),end:t?.to??new Date(n)}}function Em(){const{datePreset:e,customRange:t,dimensionalFilter:n,dimensionalFilterKey:r}=tG(),s=g.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=g.useMemo(()=>yrs(e,t,i),[e,t,i]),c=g.useMemo(()=>({timestamp:l,...n}),[l,r]),u=g.useMemo(()=>`${a}|${r}`,[a,r]);return{datePreset:e,customRange:t,timestamp:l,filters:c,dimensionalFilter:n,filterKey:u}}function q9t(){const e=We(),{filters:t,filterKey:n}=Em();return wt({queryKey:["metrics","agent-runs-kpi",n],queryFn:()=>e.getMetricAggregate({name:["mastra_agent_duration_ms"],aggregation:"count",filters:t,comparePeriod:"previous_period"})})}function K4({href:e,LinkComponent:t="a"}){return o.jsx(de,{as:t,href:e,variant:"ghost",size:"icon-md",tooltip:"View in Traces","aria-label":"View in Traces",children:o.jsx(Kkn,{})})}function brs({href:e,LinkComponent:t="a"}){return o.jsx(de,{as:t,href:e,variant:"ghost",size:"icon-md",tooltip:"View errors in Logs","aria-label":"View errors in Logs",children:o.jsx($On,{})})}const xrs=[{dataKey:"p50",label:"p50",color:Pp.blue,aggregate:e=>({value:e.length>0?`${Math.round(e.reduce((t,n)=>t+n.p50,0)/e.length)}`:"0",suffix:"avg ms"})},{dataKey:"p95",label:"p95",color:Pp.yellow,aggregate:e=>({value:e.length>0?`${Math.round(e.reduce((t,n)=>t+n.p95,0)/e.length)}`:"0",suffix:"avg ms"})}];function sse({data:e,onPointClick:t}){return e.length===0?o.jsx(Ut.NoData,{message:"No latency data yet"}):o.jsx(LU,{data:e,series:xrs,onPointClick:t?n=>{const r=n;typeof r?.tsMs=="number"&&Number.isFinite(r.tsMs)&&t(r)}:void 0})}function wrs({data:e,isLoading:t,isError:n,onPointClick:r,actions:s}){const a=e?e.agentData.length>0?"agents":e.workflowData.length>0?"workflows":e.toolData.length>0?"tools":"agents":"agents",[i,l]=g.useState(a);g.useEffect(()=>{if(!e)return;const p={agents:e.agentData.length>0,workflows:e.workflowData.length>0,tools:e.toolData.length>0};!p[i]&&p[a]&&l(a)},[e,i,a]);const c=typeof s=="function"?s(i):s,u=!!e&&(e.agentData.length>0||e.workflowData.length>0||e.toolData.length>0),d=e?Object.values(e).filter(Array.isArray).flat().map(p=>p.p50).filter(p=>typeof p=="number"):[],f=d.length>0?`${Math.round(d.reduce((p,h)=>p+h,0)/d.length)}ms`:"—";return o.jsxs(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.TitleAndDescription,{title:"Latency",description:"Hourly p50 and p95 latency."}),u&&o.jsx(Ut.Summary,{value:f,label:"Avg p50"}),c?o.jsx(Ut.Actions,{children:c}):null]}),t?o.jsx(Ut.Loading,{}):n?o.jsx(Ut.Error,{message:"Failed to load latency data"}):o.jsx(Ut.Content,{children:u?o.jsxs(cu,{value:i,onValueChange:l,defaultTab:a,className:"overflow-visible",children:[o.jsxs(uu,{children:[o.jsx(qr,{value:"agents",children:"Agents"}),o.jsx(qr,{value:"workflows",children:"Workflows"}),o.jsx(qr,{value:"tools",children:"Tools"})]}),o.jsx(fs,{value:"agents",children:o.jsx(sse,{data:e.agentData,onPointClick:r?p=>r("agents",p):void 0})}),o.jsx(fs,{value:"workflows",children:o.jsx(sse,{data:e.workflowData,onPointClick:r?p=>r("workflows",p):void 0})}),o.jsx(fs,{value:"tools",children:o.jsx(sse,{data:e.toolData,onPointClick:r?p=>r("tools",p):void 0})})]}):o.jsx(Ut.NoData,{message:"No latency data yet"})})]})}function Srs(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 krs(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 V9t(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=Srs(s);l&&e.set(t,l)}function To(e,t,n){typeof n=="string"&&n.length>0&&e.set(t,n)}function H9t(e,t,n){if(!(!Array.isArray(n)||n.length===0))for(const r of n)r&&e.append(t,r)}function VQe({preset:e,customRange:t,dashboardFilter:n,scope:r,tracesBasePath:s="/observability"}){const a=new URLSearchParams;a.set(xw,"branches"),V9t(a,ww,Sw,kw,e,t,r.window);const i=r.rootEntityType??n.rootEntityType;i&&a.set($x,i),r.status&&a.set(Mx,r.status),To(a,Ol.entityName,r.entityName??n.entityName),To(a,Ol.threadId,r.threadId??n.threadId),To(a,Ol.resourceId,r.resourceId??n.resourceId),To(a,Ol.entityId,n.entityId),To(a,Ol.runId,n.runId),To(a,Ol.sessionId,n.sessionId),To(a,Ol.requestId,n.requestId),To(a,Ol.userId,n.userId),To(a,Ol.organizationId,n.organizationId),To(a,Ol.experimentId,n.experimentId),To(a,Ol.serviceName,n.serviceName),To(a,Ol.environment,n.environment),H9t(a,Ol.tags,n.tags);const l=a.toString();return l?`${s}?${l}`:s}function Ors({preset:e,customRange:t,dashboardFilter:n,scope:r,logsBasePath:s="/logs"}){const a=new URLSearchParams;V9t(a,qb,Vb,Hb,e,t,r.window);const i=r.rootEntityType??n.rootEntityType;i&&a.set(Dx,i),To(a,_l.entityName,r.entityName??n.entityName),To(a,_l.threadId,r.threadId??n.threadId),To(a,_l.resourceId,r.resourceId??n.resourceId),To(a,_l.runId,n.runId),To(a,_l.sessionId,n.sessionId),To(a,_l.requestId,n.requestId),To(a,_l.userId,n.userId),To(a,_l.organizationId,n.organizationId),To(a,_l.experimentId,n.experimentId),To(a,_l.serviceName,n.serviceName),To(a,_l.environment,n.environment),H9t(a,_l.tags,n.tags),r.status==="error"&&a.append(_l.level,"error");const l=a.toString();return l?`${s}?${l}`:s}function jI(){const{datePreset:e,customRange:t,dimensionalFilter:n,tracesBasePath:r,logsBasePath:s}=tG(),a=g.useCallback((c={})=>VQe({preset:e,customRange:t,dashboardFilter:n,scope:c,tracesBasePath:r}),[e,t,n,r]),i=g.useCallback((c={})=>Ors({preset:e,customRange:t,dashboardFilter:n,scope:c,logsBasePath:s}),[e,t,n,s]),l=g.useCallback((c,u,d)=>{const f=krs(u,d);return VQe({preset:e,customRange:t,dashboardFilter:n,scope:{...c,window:f},tracesBasePath:r})},[e,t,n,r]);return{getTracesHref:a,getLogsHref:i,getBucketTracesHref:l}}const W9t="1h";async function ase(e,t,n){const r=await e.getMetricPercentiles({name:t,percentiles:[.5,.95],interval:W9t,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 _rs(){const e=We(),{filters:t,filterKey:n}=Em();return wt({queryKey:["metrics","latency",n],queryFn:async()=>{const[r,s,a]=await Promise.all([ase(e,"mastra_agent_duration_ms",t),ase(e,"mastra_workflow_duration_ms",t),ase(e,"mastra_tool_duration_ms",t)]);return{agentData:r,workflowData:s,toolData:a,interval:W9t}}})}const HQe={agents:Os.AGENT,workflows:Os.WORKFLOW_RUN,tools:Os.TOOL};function Crs(){const{data:e,isLoading:t,isError:n}=_rs(),{getTracesHref:r,getBucketTracesHref:s}=jI(),{Link:a}=yn(),i=bs();return o.jsx(wrs,{data:e,isLoading:t,isError:n,onPointClick:(l,c)=>{Number.isFinite(c.tsMs)&&i(s({rootEntityType:HQe[l]},c.tsMs,"1h"))},actions:l=>o.jsx(K4,{href:r({rootEntityType:HQe[l]}),LinkComponent:a})})}function Ers(e){return e==="threads"||e==="resources"}function ise(e){return e.length<=12?e:`${e.slice(0,6)}…${e.slice(-4)}`}function jrs({threads:e,resources:t,getThreadRowHref:n,getResourceRowHref:r,actions:s,LinkComponent:a}){const[i,l]=g.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,v=typeof s=="function"?s(i):s;return o.jsxs(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.TitleAndDescription,{title:"Memory",description:"Resource and Thread consumption"}),i==="threads"&&d&&o.jsx(Ut.Summary,{value:p.toLocaleString(),label:"Total runs"}),i==="resources"&&f&&o.jsx(Ut.Summary,{value:h.toLocaleString(),label:"Total threads"}),v?o.jsx(Ut.Actions,{children:v}):null]}),m.isLoading?o.jsx(Ut.Loading,{}):m.isError?o.jsx(Ut.Error,{message:"Failed to load memory data"}):o.jsx(Ut.Content,{children:o.jsxs(cu,{defaultTab:"threads",value:i,onValueChange:y=>{Ers(y)&&l(y)},className:"grid grid-rows-[auto_1fr] overflow-y-auto h-full",children:[o.jsxs(uu,{children:[o.jsx(qr,{value:"threads",children:"Threads"}),o.jsx(qr,{value:"resources",children:"Resources"})]}),o.jsx(fs,{value:"threads",children:d?o.jsxs(me,{columns:"auto auto auto auto auto",...Uve,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),S=o.jsxs(o.Fragment,{children:[o.jsx(me.RowHeaderCell,{height:"compact",className:"text-ui-sm",children:ise(y.threadId)}),o.jsx(me.NumberCell,{children:y.resourceId?ise(y.resourceId):"—"}),o.jsx(me.NumberCell,{highlight:!0,children:y.runs.toLocaleString()}),o.jsx(me.NumberCell,{children:y.tokens>0?wc(y.tokens):"—"}),o.jsx(me.NumberCell,{children:y.cost!=null?bg(y.cost,y.costUnit):"—"})]});return b?o.jsx(me.RowLink,{to:b,LinkComponent:a,children:S},y.key):o.jsx(me.RowStatic,{children:S},y.key)})]}):o.jsx(Ut.NoData,{message:"No thread activity yet"})}),o.jsx(fs,{value:"resources",children:f?o.jsxs(me,{columns:"auto auto auto auto",...Uve,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),S=o.jsxs(o.Fragment,{children:[o.jsx(me.RowHeaderCell,{height:"compact",className:"text-ui-sm",children:ise(y.resourceId)}),o.jsx(me.NumberCell,{highlight:!0,children:y.threadCount.toLocaleString()}),o.jsx(me.NumberCell,{children:y.tokens>0?wc(y.tokens):"—"}),o.jsx(me.NumberCell,{children:y.cost!=null?bg(y.cost,y.costUnit):"—"})]});return b?o.jsx(me.RowLink,{to:b,LinkComponent:a,children:S},y.key):o.jsx(me.RowStatic,{children:S},y.key)})]}):o.jsx(Ut.NoData,{message:"No resource activity yet"})})]})})]})}function J4(e,t,n){const r=e.get(t);if(r!==void 0)return r;const s=n();return e.set(t,s),s}const ose=20;function Trs(){const e=We(),{filters:t,filterKey:n}=Em();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:ose}),e.getMetricBreakdown({...r,name:["mastra_model_total_input_tokens"],aggregation:"sum",limit:ose}),e.getMetricBreakdown({...r,name:["mastra_model_total_output_tokens"],aggregation:"sum",limit:ose})]),l=new Map,c=d=>J4(l,d,()=>({tokens:0,cost:null,costUnit:null})),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 lse=20;function Nrs(){const e=We(),{filters:t,filterKey:n}=Em();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:lse}),e.getMetricBreakdown({...r,name:["mastra_model_total_input_tokens"],aggregation:"sum",limit:lse}),e.getMetricBreakdown({...r,name:["mastra_model_total_output_tokens"],aggregation:"sum",limit:lse})]),l=new Map,c=d=>J4(l,d,()=>({tokens:0,cost:null,costUnit:null})),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 Irs(){const e=Trs(),t=Nrs(),{getTracesHref:n}=jI(),{Link:r}=yn();return o.jsx(jrs,{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 e5({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 Ars(){const e=We(),{filters:t,filterKey:n}=Em();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 Rrs(){const e=We(),{filters:t,filterKey:n}=Em();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 Prs(){const e=We(),{filters:t,filterKey:n}=Em();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 $rs(){const e=We(),{filters:t,filterKey:n}=Em();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 Mrs(){const{data:e,isLoading:t,isError:n}=q9t();return o.jsx(e5,{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 Drs(){const{data:e,isLoading:t,isError:n}=Prs();return o.jsx(e5,{label:"Total Model Cost",value:e?.cost!=null?bg(e.cost,e.costUnit):null,prevValue:e?.previousCost!=null?bg(e.previousCost,e.costUnit):void 0,changePct:e?.costChangePercent??null,isLoading:t,isError:n})}function Lrs(){const{data:e,isLoading:t,isError:n}=$rs();return o.jsx(e5,{label:"Total Tokens",value:e?.value!=null?wc(e.value):null,prevValue:e?.previousValue!=null?wc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function Frs(){const{data:e,isLoading:t,isError:n}=Rrs();return o.jsx(e5,{label:"Total Threads",value:e?.value!=null?wc(e.value):null,prevValue:e?.previousValue!=null?wc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function zrs(){const{data:e,isLoading:t,isError:n}=Ars();return o.jsx(e5,{label:"Total Resources",value:e?.value!=null?wc(e.value):null,prevValue:e?.previousValue!=null?wc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function Brs({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=>Urs(f,a));return o.jsxs("div",{className:K("grid grid-cols-[1fr_auto] gap-3 items-start"),children:[o.jsx(lTe,{fields:a,tokens:i,onTokensChange:l,disabled:s,autoFocusFieldId:c}),u&&o.jsx(iTe,{disabled:s,onClear:d?e:void 0,onRemoveAll:t,onSave:n,onRemoveSaved:r})]})}function Urs(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 qrs({rows:e,isLoading:t,isError:n,getRowHref:r,actions:s,LinkComponent:a}){const i=!!e&&e.length>0;return o.jsxs(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.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?bg(l):"—":c.size===1?u=l>0?bg(l,[...c][0]):"—":u="Mixed",o.jsx(Ut.Summary,{value:u,label:"Total cost"})})(),s?o.jsx(Ut.Actions,{children:s}):null]}),t?o.jsx(Ut.Loading,{}):n?o.jsx(Ut.Error,{message:"Failed to load model usage data"}):o.jsx(Ut.Content,{children:i?o.jsxs(me,{columns:"auto auto auto auto auto auto",...Uve,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?bg(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(Ut.NoData,{message:"No model usage data yet"})})]})}function Vrs(){const e=We(),{filters:t,filterKey:n}=Em();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=>J4(l,d,()=>({input:0,output:0,cacheRead:0,cacheWrite:0,cost:null,costUnit:null})),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:wc(f.input),output:wc(f.output),cacheRead:wc(f.cacheRead),cacheWrite:wc(f.cacheWrite),cost:f.cost,costUnit:f.costUnit})).sort((d,f)=>d.model.localeCompare(f.model))}})}function Hrs(){const{data:e,isLoading:t,isError:n}=Vrs(),{getTracesHref:r}=jI(),{Link:s}=yn();return o.jsx(qrs,{rows:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:()=>r({rootEntityType:Os.AGENT}),actions:o.jsx(K4,{href:r({rootEntityType:Os.AGENT}),LinkComponent:s})})}function Wrs(e){return e==="tokens"||e==="cost"}function Zrs({data:e,isLoading:t,isError:n,getRowHref:r,actions:s,LinkComponent:a}){const[i,l]=g.useState("tokens"),c=e??[],u=c.length>0,d=c.reduce((b,S)=>b+S.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,v=h?f.reduce((b,S)=>b+(S.cost??0),0):0,y=h&&v>0;return o.jsxs(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.TitleAndDescription,{title:"Token Usage by Agent",description:"Token consumption grouped by agent."}),u&&(i==="cost"&&y?o.jsx(Ut.Summary,{value:bg(v,m),label:"Total cost"}):o.jsx(Ut.Summary,{value:wc(d),label:"Total tokens"})),u&&s?o.jsx(Ut.Actions,{children:s}):null]}),t?o.jsx(Ut.Loading,{}):n?o.jsx(Ut.Error,{message:"Failed to load token usage data"}):o.jsx(Ut.Content,{children:u?o.jsxs(cu,{defaultTab:"tokens",value:i,onValueChange:b=>{Wrs(b)&&l(b)},className:"grid grid-rows-[auto_1fr] overflow-y-auto h-full",children:[o.jsxs(uu,{children:[o.jsx(qr,{value:"tokens",children:"Tokens"}),o.jsx(qr,{value:"cost",children:"Cost"})]}),o.jsx(fs,{value:"tokens",children:o.jsx(uN,{LinkComponent:a,data:c.map(b=>({name:b.name,values:[b.input,b.output],href:r?.(b)})),segments:[{label:"Input",color:Pp.blueDark},{label:"Output",color:Pp.blue}],maxVal:Math.max(...c.map(b=>b.input+b.output)),fmt:wc})}),o.jsx(fs,{value:"cost",children:y?o.jsx(uN,{LinkComponent:a,data:f.slice().sort((b,S)=>(S.cost??0)-(b.cost??0)).map(b=>({name:b.name,values:[b.cost],href:r?.(b)})),segments:[{label:"Cost",color:Pp.purple}],maxVal:Math.max(...f.map(b=>b.cost??0)),fmt:b=>bg(b,m)}):o.jsx(Ut.NoData,{message:"No cost data yet"})})]}):o.jsx(Ut.NoData,{message:"No token usage data yet"})})]})}function Grs(){const e=We(),{filters:t,filterKey:n}=Em();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=>J4(i,u,()=>({input:0,output:0,cost:null,costUnit:null})),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 Qrs(){const{data:e,isLoading:t,isError:n}=Grs(),{getTracesHref:r}=jI(),{Link:s}=yn();return o.jsx(Zrs,{data:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:a=>r({rootEntityType:Os.AGENT,entityName:a.name}),actions:o.jsx(K4,{href:r({rootEntityType:Os.AGENT}),LinkComponent:s})})}function Zve(e,t=wc){return n=>({value:t(n.reduce((r,s)=>r+(typeof s[e]=="number"?s[e]:0),0))})}const Yrs=[{dataKey:"input",label:"Input tokens",color:Pp.blue,aggregate:Zve("input")},{dataKey:"output",label:"Output tokens",color:Pp.yellow,aggregate:Zve("output")}];function Xrs(e){return e==="tokens"||e==="cost"}function Krs({data:e,interval:t="1d",isLoading:n,isError:r,actions:s}){const[a,i]=g.useState("tokens"),l=e??[],c=l.map(k=>({...k})),u=l.length>0,d=l.reduce((k,_)=>k+_.total,0),f=l.filter(k=>k.cost!=null&&k.cost>0),p=f.map(k=>({...k})),h=new Set(f.map(k=>k.costUnit).filter(k=>!!k)),m=h.size===1&&f.every(k=>k.costUnit!=null),v=m?[...h][0]??null:null,y=m?f.reduce((k,_)=>k+(_.cost??0),0):0,b=m&&y>0,S=t==="1h"?"Input and output tokens per hour.":"Input and output tokens per day.",w=[{dataKey:"cost",label:"Cost",color:Pp.purple,aggregate:Zve("cost",k=>bg(k,v))}];return o.jsxs(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.TitleAndDescription,{title:"Token usage over time",description:S}),u&&(a==="cost"&&b?o.jsx(Ut.Summary,{value:bg(y,v),label:"Total cost"}):o.jsx(Ut.Summary,{value:wc(d),label:"Total tokens"})),u&&s?o.jsx(Ut.Actions,{children:s}):null]}),n?o.jsx(Ut.Loading,{}):r?o.jsx(Ut.Error,{message:"Failed to load token usage timeline"}):o.jsx(Ut.Content,{children:u?o.jsxs(cu,{defaultTab:"tokens",value:a,onValueChange:k=>{Xrs(k)&&i(k)},className:"overflow-visible",children:[o.jsxs(uu,{children:[o.jsx(qr,{value:"tokens",children:"Tokens"}),o.jsx(qr,{value:"cost",children:"Cost"})]}),o.jsx(fs,{value:"tokens",children:o.jsx(LU,{data:c,series:Yrs})}),o.jsx(fs,{value:"cost",children:b?o.jsx(LU,{data:p,series:w}):o.jsx(Ut.NoData,{message:"No cost data yet"})})]}):o.jsx(Ut.NoData,{message:"No token usage data yet"})})]})}function Jrs(e){return e==="24h"?"1h":"1d"}function ess(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 WQe(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 tss(e){return e.cost==null||e.hasUnknownCostUnit||e.costUnits.size!==1?null:[...e.costUnits][0]??null}function nss(){const e=We(),{datePreset:t,filters:n,filterKey:r}=Em(),s=Jrs(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 WQe(l,a.series[0],"input"),WQe(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:ess(d,s),tsMs:u.tsMs,input:u.input,output:u.output,total:u.input+u.output,cost:u.cost,costUnit:tss(u)}}),interval:s}}})}function rss(){const{data:e,isLoading:t,isError:n}=nss(),{getTracesHref:r}=jI(),{Link:s}=yn();return o.jsx(Krs,{data:e?.data,interval:e?.interval,isLoading:t,isError:n,actions:o.jsx(K4,{href:r(),LinkComponent:s})})}function cse({data:e,rowHrefs:t,errorHrefs:n,LinkComponent:r}){return o.jsx(uN,{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:Pp.blueDark},{label:"Errors",color:Pp.pink}],maxVal:Math.max(...e.map(s=>s.completed+s.errors)),fmt:wc})}function sss({data:e,isLoading:t,isError:n,getRowHref:r,getErrorSegmentHref:s,actions:a,LinkComponent:i}){const[l,c]=g.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,v)=>m+v.completed+v.errors,0):0,p=m=>r?v=>r(m,v):void 0,h=m=>s?v=>s(m,v):void 0;return o.jsxs(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.TitleAndDescription,{title:"Trace Volume",description:"Runs and call counts."}),d&&o.jsx(Ut.Summary,{value:wc(f),label:"Total runs"}),u?o.jsx(Ut.Actions,{children:u}):null]}),t?o.jsx(Ut.Loading,{}):n?o.jsx(Ut.Error,{message:"Failed to load trace volume data"}):o.jsx(Ut.Content,{children:d?o.jsxs(cu,{value:l,onValueChange:c,defaultTab:"agents",className:"grid grid-rows-[auto_1fr] overflow-y-auto h-full",children:[o.jsxs(uu,{children:[o.jsx(qr,{value:"agents",children:"Agents"}),o.jsx(qr,{value:"workflows",children:"Workflows"}),o.jsx(qr,{value:"tools",children:"Tools"})]}),o.jsx(fs,{value:"agents",children:e.agentData.length>0?o.jsx(cse,{data:e.agentData,rowHrefs:p("agents"),errorHrefs:h("agents"),LinkComponent:i}):o.jsx(Ut.NoData,{message:"No agent data yet"})}),o.jsx(fs,{value:"workflows",children:e.workflowData.length>0?o.jsx(cse,{data:e.workflowData,rowHrefs:p("workflows"),errorHrefs:h("workflows"),LinkComponent:i}):o.jsx(Ut.NoData,{message:"No workflow data yet"})}),o.jsx(fs,{value:"tools",children:e.toolData.length>0?o.jsx(cse,{data:e.toolData,rowHrefs:p("tools"),errorHrefs:h("tools"),LinkComponent:i}):o.jsx(Ut.NoData,{message:"No tool data yet"})})]}):o.jsx(Ut.NoData,{message:"No trace volume data yet"})})]})}async function use(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",c=J4(s,i,()=>({completed:0,errors:0}));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 ass(){const e=We(),{filters:t,filterKey:n}=Em();return wt({queryKey:["metrics","trace-volume",n],queryFn:async()=>{const[r,s,a]=await Promise.all([use(e,"mastra_agent_duration_ms",t),use(e,"mastra_workflow_duration_ms",t),use(e,"mastra_tool_duration_ms",t)]);return{agentData:r,workflowData:s,toolData:a}}})}const cF={agents:Os.AGENT,workflows:Os.WORKFLOW_RUN,tools:Os.TOOL};function iss(){const{data:e,isLoading:t,isError:n}=ass(),{getTracesHref:r,getLogsHref:s}=jI(),{Link:a}=yn();return o.jsx(sss,{data:e,isLoading:t,isError:n,LinkComponent:a,getRowHref:(i,l)=>r({rootEntityType:cF[i],entityName:l.name}),getErrorSegmentHref:(i,l)=>l.errors>0?s({rootEntityType:cF[i],entityName:l.name,status:"error"}):void 0,actions:i=>o.jsxs(o.Fragment,{children:[o.jsx(K4,{href:r({rootEntityType:cF[i]}),LinkComponent:a}),o.jsx(brs,{href:s({rootEntityType:cF[i],status:"error"}),LinkComponent:a})]})})}const oss=new Set(["ObservabilityStorageClickhouseVNext","ObservabilityStorageDuckDB","ObservabilityInMemory","ObservabilitySpanner","ObservabilityStoragePostgresVNext"]),dse="period",uF="dateFrom",dF="dateTo";function lss(){const[e,t]=ga(),n=e.get(dse),r=drs(n)?n:"24h",s=g.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(uF)),p=d(e.get(dF));if(!(!f&&!p))return{from:f,to:p}},[r,e.toString()]),a=g.useMemo(()=>srs(e),[e.toString()]),i=g.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d==="24h"?p.delete(dse):p.set(dse,d),d!=="custom"&&(p.delete(uF),p.delete(dF)),p},{replace:!0})},[t]),l=g.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d?.from?p.set(uF,d.from.toISOString()):p.delete(uF),d?.to?p.set(dF,d.to.toISOString()):p.delete(dF),p},{replace:!0})},[t]),c=g.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return irs(p,d),p},{replace:!0})},[t]),u=g.useRef(!1);return g.useEffect(()=>{if(u.current||(u.current=!0,nrs(e)))return;const d=z9t();d&&t(f=>{const p=new URLSearchParams(f);for(const[h,m]of d)p.append(h,m);return p},{replace:!0})},[]),o.jsx(prs,{preset:r,filterTokens:a,onPresetChange:i,onFilterTokensChange:c,customRange:s,onCustomRangeChange:l,children:o.jsx(css,{})})}function css(){const[e]=ga(),{error:t,isLoading:n}=q9t(),{filterTokens:r,setFilterTokens:s}=tG(),[a,i]=g.useState(),{data:l,isLoading:c}=a4(),u=l?.observabilityStorageType,d=u?oss.has(u):!1,f=u==="ObservabilityInMemory",{data:p,isLoading:h}=gTe(),{data:m,isLoading:v}=pTe(),{data:y,isLoading:b}=mTe(),{data:S,isLoading:w}=hTe(),k=g.useMemo(()=>rrs({availableTags:p??[],availableEntityNames:m??[],availableServiceNames:y??[],availableEnvironments:S??[],loading:{tags:h,entityNames:v,serviceNames:b,environments:w}}),[p,m,y,S,h,v,b,w]),[_,C]=g.useState(()=>z9t()!==null),E=g.useCallback(()=>{ers(e),C(!0),De.success("Filters setting for Metrics saved")},[e]),j=g.useCallback(()=>{trs(),C(!1),De.success("Filters setting for Metrics cleared up")},[]),N=g.useCallback(()=>{s([])},[s]),I=g.useCallback(()=>{const R=r.map(P=>{const L=k.find(M=>M.id===P.fieldId);return L?L.kind==="text"?{fieldId:P.fieldId,value:""}:L.kind==="pick-multi"?L.multi?{fieldId:P.fieldId,value:[]}:{fieldId:P.fieldId,value:"Any"}:L.kind==="multi-select"?{fieldId:P.fieldId,value:[]}:P:P});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(zi,{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(vrs,{}),o.jsx(cTe,{fields:k,tokens:r,onTokensChange:s,disabled:n,onStartTextFilter:i})]})}),o.jsx(Brs,{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(qve,{children:[o.jsx(Mrs,{}),o.jsx(Drs,{}),o.jsx(Lrs,{}),o.jsx(Frs,{}),o.jsx(zrs,{})]}),o.jsxs(qve,{children:[o.jsx(Hrs,{}),o.jsx(Qrs,{}),o.jsx(rss,{}),o.jsx(Irs,{}),o.jsx(iss,{}),o.jsx(Crs,{})]})]}):o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Cr,{iconSlot:o.jsx(Of,{}),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(de,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/observability/metrics/overview",target:"_blank",rel:"noopener noreferrer",children:["Metrics Documentation ",o.jsx(_a,{})]})})})]})}function uss(){const{paths:e}=yn(),{data:t,isLoading:n,error:r}=c6t(),{isCmsAvailable:s}=Y1(),[a,i]=g.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(zi,{title:"Failed to load prompt blocks",message:r.message})}):l.length===0&&!n?o.jsx(lr,{children:o.jsx(WZr,{})}):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(jf,{onSearch:i,label:"Filter prompts",placeholder:"Filter by name or description"})}),s&&o.jsxs(de,{as:Ba,to:e.cmsPromptBlockCreateLink(),variant:"primary",className:"shrink-0",children:[o.jsx(Vr,{}),"Create Prompt"]})]})}),o.jsx(HZr,{promptBlocks:l,isLoading:n,search:a})]})}function dss(){return o.jsx(Lt,{width:"narrow",children:o.jsx(Lt.MainArea,{children:o.jsx(Z7r,{children:o.jsx(mve,{})})})})}const fss=[{title:"Mastra APIs",description:"Explore and test the available REST API endpoints with the interactive Swagger UI.",icon:Wcn,href:"/swagger-ui",external:!1},{title:"Documentation",description:"Read the official Mastra documentation for guides, references, and tutorials.",icon:jlt,href:"https://mastra.ai/en/docs",external:!0},{title:"Github",description:"Browse the source code, report issues, and contribute to the Mastra project.",icon:_a,href:"https://github.com/mastra-ai/mastra",external:!0},{title:"Community",description:"Join the Mastra Discord community for help, discussion, and collaboration.",icon:Yj,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:Mlt,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:Tlt,href:"https://mastra.ai/contact?ref=studio",external:!0}];function pss(){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:fss.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(_a,{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 hss(){const{data:e={},isLoading:t,error:n}=ih(),[r,s]=g.useState(""),[a,i]=g.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(zi,{title:"Failed to load scorers",message:n.message})});if(Object.keys(e).length===0&&!t)return o.jsx(lr,{children:o.jsx(aWr,{})});const l=a!=="all"||r!=="",c=()=>{s(""),i("all")};return o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx(oWr,{search:r,onSearchChange:s,sourceFilter:a,onSourceFilterChange:i,onReset:c,hasActiveFilters:l})}),o.jsx(sWr,{scorers:e,isLoading:t,search:r,sourceFilter:a})]})}function mss(){const{scorerId:e}=ur(),[t,n]=ga(),r=t.get("scoreId")??void 0,[s,a]=g.useState(r),[i,l]=g.useState({value:"all",label:"All Entities",type:"ALL"}),{scorer:c,error:u}=$Hr(e),{data:d={},isLoading:f,error:p}=km(),{isLoading:h,error:m}=Uy(),{data:v=[],isLoading:y,error:b,isFetchingNextPage:S,hasNextPage:w,setEndOfListElement:k}=PHr({scorerId:e,entityId:i?.value==="all"?void 0:i?.value,entityType:i?.type==="ALL"?void 0:i?.type}),_=g.useMemo(()=>c?.agentIds?.filter(B=>d[B]).map(B=>({value:B,label:d[B].name,type:"AGENT"}))||[],[c?.agentIds,d]),C=g.useMemo(()=>c?.workflowIds?.map(B=>({value:B,label:B,type:"WORKFLOW"}))||[],[c?.workflowIds]),E=g.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),g.useEffect(()=>{if(u){const B=u instanceof Error?u.message:"Failed to load scorer";De.error(`Error loading scorer: ${B}`)}},[u]),g.useEffect(()=>{if(p){const B=p instanceof Error?p.message:"Failed to load agents";De.error(`Error loading agents: ${B}`)}},[p]),g.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(D=>{const Q=new URLSearchParams(D);return Q.set("entity",B.value),Q})};g.useEffect(()=>{const B=t.get("scoreId")??void 0;if(B===s)return;if(!B){a(void 0);return}v.find(Q=>Q.id===B)&&a(B)},[t,v]);const R=g.useCallback(B=>{a(B||void 0),n(D=>{const Q=new URLSearchParams(D);return B?Q.set("scoreId",B):Q.delete("scoreId"),Q})},[n]);if(!c)return null;const P=gs(u)||gs(p)||gs(m),L=u&&ys(u),M=!P&&!L&&(u||p||m),q=!y&&v.length===0,H=i?.value!=="all",F=c?.scorer?.source==="stored"?o.jsx(Iy,{owner:"scorer-detail",children:o.jsxs(de,{variant:"default",as:Ba,to:`/cms/scorers/${e}/edit`,size:"sm",children:[o.jsx(Lp,{})," Edit"]})}):null;if(P||L||M||q&&!H){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:[F,o.jsx(Lt.MainArea,{isCentered:!0,children:P?o.jsx(Vs,{}):L?o.jsx(Ds,{resource:"scorers"}):M?o.jsx(zi,{title:"Failed to load scorer",message:B}):o.jsx(THr,{})})]})}return o.jsxs(Lt,{width:"wide",children:[F,o.jsx(Lt.TopArea,{children:o.jsx(NHr,{selectedEntity:i,entityOptions:E,onEntityChange:I,onReset:()=>{n(B=>{const D=new URLSearchParams(B);return D.set("entity","all"),D})},isLoading:y||f||h})}),o.jsx(jHr,{scores:v,isLoading:y,selectedScoreId:s,isFetchingNextPage:S,hasNextPage:w,setEndOfListElement:k,onScoreClick:R,errorMsg:b?.message})]})}function gss({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 Z9t=[{value:"dark",label:"Dark",Icon:wdn},{value:"light",label:"Light",Icon:Nfn},{value:"system",label:"System",Icon:Wlt}],vss=e=>Z9t.some(t=>t.value===e);function yss({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 bss=()=>{const{baseUrl:e,headers:t,apiPrefix:n}=qxe(),{theme:r,setTheme:s}=PN();return o.jsx(Lt,{width:"narrow",children:o.jsxs(Lt.MainArea,{className:"flex flex-col gap-5 mt-6",children:[o.jsx(Yge,{title:"Theme",description:"Customize the appearance of the studio.",children:o.jsx(gss,{label:"Theme mode",htmlFor:"theme",children:o.jsxs(da,{value:r,onValueChange:a=>{vss(a)&&s(a)},children:[o.jsx(pa,{id:"theme",className:"w-full sm:w-48",children:o.jsx(fa,{className:"inline-flex min-w-0 max-w-full items-center"})}),o.jsx(ha,{children:Z9t.map(a=>o.jsx(Lr,{value:a.value,children:o.jsx(yss,{option:a})},a.value))})]})})}),o.jsx(Yge,{title:"Mastra Connection",description:"Configure the Mastra instance URL, API prefix, and request headers used by the studio.",children:o.jsx(lRt,{initialConfig:{baseUrl:e,headers:t,apiPrefix:n}})})]})})};function xss(){const[e]=ga(),t=bs(),n=e.get("redirect")||"/",r=()=>{n.startsWith("http")?window.location.href=n:t(n,{replace:!0})};return o.jsx(D9t,{redirectUri:n,onSuccess:r,initialMode:"signup"})}const G9t=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 wss(e){return e.replace(/\/$/,"").split("/").pop()}function nG({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 Sss({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(sl,{})," ",a.agents.length]}),a?.tools&&a.tools.length>0&&o.jsxs("li",{children:[o.jsx(eh,{})," ",a.tools.length]}),a?.networks&&a.networks.length>0&&o.jsxs("li",{children:[o.jsx(Zlt,{})," ",a.networks.length]}),a?.workflows&&a.workflows.length>0&&o.jsxs("li",{children:[o.jsx(vD,{})," ",a.workflows.length]}),a?.mcp&&a.mcp.length>0&&o.jsxs("li",{children:[o.jsx(B_,{})," ",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(G9t,{})," ",wss(a.githubUrl)]})})]},a.slug)})})}function kss({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(BT,{name:"search-templates",label:"Search templates",labelIsHidden:!0,value:i,onChange:f=>l?.(f.target.value),placeholder:"Search Template"}),o.jsx(Sc,{label:"Filter by tag",labelIsHidden:!0,name:"filter-tag",value:t,onValueChange:s,options:e}),o.jsx(Sc,{label:"Filter by provider",labelIsHidden:!0,name:"filter-provider",value:r,onValueChange:a,options:n}),c&&o.jsxs(de,{onClick:c,children:["Reset ",o.jsx(vs,{})]})]})}function Oss(){const{data:e,isLoading:t}=wYn(),{templates:n,tags:r,providers:s}=e??{templates:[],tags:[],providers:[]},[a,i]=g.useState("all"),[l,c]=g.useState("all"),[u,d]=g.useState(""),f=[{value:"all",label:"Any tag"}];(r||[]).forEach(S=>{f.push({value:S,label:S})});const p=[{value:"all",label:"Any provider"}];(s||[]).forEach(S=>{p.push({value:S,label:S})});const h=(S,w)=>{w==="tag"?i(S):w==="provider"&&c(S)},m=S=>{d(S)},v=()=>{i("all"),c("all"),d("")},y=n.filter(S=>!(u&&!S.title.toLowerCase().includes(u)&&!S.description.toLowerCase().includes(u)||a!=="all"&&!S.tags.includes(a)||l!=="all"&&!S.supportedProviders.includes(l))),b=u||a!=="all"||l!=="all";return o.jsxs(ls,{children:[o.jsx(e0e,{children:o.jsxs(Lpt,{children:[o.jsx(Ue,{children:o.jsx(Zv,{})}),"Templates"]})}),o.jsxs("div",{className:K("overflow-y-auto w-full h-full px-8 pb-12 z-10"),children:[o.jsx(kss,{selectedTag:a,onTagChange:S=>h(S,"tag"),tagOptions:f,selectedProvider:l,onProviderChange:S=>h(S,"provider"),providerOptions:p,searchTerm:u,onSearchChange:m,onReset:b?v:void 0,className:"max-w-[80rem]",isLoading:t}),o.jsx(Sss,{templates:y,linkComponent:Ba,className:"max-w-[80rem] mx-auto",isLoading:t})]})]})}const _ss="1.50.0-alpha.2";function Css({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(Ep,{className:"text-yellow-500"}),title:"Template Installed with Warnings"}:{icon:o.jsx(wun,{}),title:"Template Installation Failed"},{icon:l,title:c}=i();return o.jsxs(nG,{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 Ess({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(nG,{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(Glt,{})]}),o.jsx(Sc,{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(g.Fragment,{children:[o.jsx(yO,{name:`env-${p}`,labelIsHidden:!0,label:"Key",value:p,disabled:!0,className:"w-full"}),o.jsx(yO,{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(zLt,{defaultProvider:u||"",defaultModel:d||"",updateModel:f||(()=>Promise.resolve({message:"Updated"})),closeEditor:()=>{},autoSave:!0,selectProviderPlaceholder:"Provider"})]})]}),t&&!l&&o.jsx(de,{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(mm,{})]})})]})})}function jss({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(Zv,{}),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(Fx,{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(sbe,{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(G9t,{}),n?.split("/")?.pop()]})]}),s&&o.jsx(Bje,{data:s,labelsAreHidden:!0,isLoading:r})]})]})}function Tss(e){switch(e){case"running":return o.jsx(Gt,{});case"success":return o.jsx(vx,{});case"failed":return o.jsx(Fu,{});default:return null}}function Nss({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",ms.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",ms.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",ms.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",ms.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:Tss(t.status)})]})}function Iss({currentStep:e,steps:t=[],className:n}){return o.jsx("div",{className:K(n),children:t.map((r,s)=>o.jsx(Nss,{stepId:r.id,step:r,isActive:e?.id===r.id,position:s+1},r.id))})}function Ass({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]",ms.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",ms.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",ms.colors),children:[n," of ",t," steps completed"]})]})}function Rss({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=v=>v==="input"||v.endsWith(".input")||v.startsWith("Mapping_")&&/[0-9a-f]{8}/.test(v)||/[0-9a-f]{8,}/.test(v)?!1:r?.allSteps?v in r.allSteps:!0,f=Object.entries(c).filter(([v,y])=>d(v)),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(([v,y])=>({id:v,status:y?.status,description:y?.description,title:v.charAt(0).toUpperCase()+v.slice(1).replace(/-/g," "),isActive:i?.id===v}));return o.jsxs(nG,{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(Ass,{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(Idn,{}),l||"Something went wrong"]}),u&&o.jsx(Iss,{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 Pss({name:e,installedEntities:t}){return o.jsxs(nG,{className:K("grid items-center justify-items-center gap-4 content-center","[&>svg]:w-8 [&>svg]:h-8"),children:[o.jsx(Glt,{}),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(Bje,{data:t})]})}function $ss(){const{templateSlug:e}=ur(),[t,n]=ga(),[r,s]=g.useState(""),[a,i]=g.useState(""),[l,c]=g.useState(""),[u,d]=g.useState({}),[f,p]=g.useState([]),[h,m]=g.useState(null),[v,y]=g.useState(!1),[b,S]=g.useState(""),[w,k]=g.useState(!1),[_,C]=g.useState(!1),[E,j]=g.useState([]),{data:N,isLoading:I}=SYn({repoOrSlug:e,owner:"mastra-ai"}),P=_ss?.includes("beta")??!1?"beta":"main",{data:L,isLoading:M}=kYn({repo:N?.githubUrl?new URL(N.githubUrl).pathname.split("/")[2]:`template-${e}`,owner:"mastra-ai",branch:P}),{data:q,isLoading:H}=OYn(),{mutateAsync:F,isPending:z}=_Yn(),{mutateAsync:B}=CYn(),{streamInstall:D,streamResult:Q,isStreaming:V}=jYn(q),{observeInstall:$,streamResult:U,isStreaming:Z}=TYn(q);g.useEffect(()=>{const ne=t.get("runId");ne&&!v&&!h&&!V&&!Z&&(console.info("🔄 Checking completed run after hot reload:",{runId:ne}),S(ne),B({runId:ne}).then(ue=>{const pe=ue.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(ue=>{console.error("❌ Failed to fetch run details:",ue),m("Failed to retrieve installation status after reload")}))},[t,v,h,V,Z,B]),g.useEffect(()=>{const ne=t.get("runId"),ue=t.get("resume"),pe=t.get("provider");if(ne&&ue==="true"&&pe&&!V&&!Z&&!w&&!_&&q){S(ne),k(!0);try{B({runId:ne}).then(le=>{if(le.snapshot?.status==="running")return $.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,V,Z,w,_,q,B,$,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(eh,{})},{key:"agents",label:"Agents",value:N?.agents?.length?N.agents.map(ne=>ne).join(", "):"n/a",icon:o.jsx(sl,{})},{key:"workflows",label:"Workflows",value:N?.workflows?.length?N.workflows.map(ne=>ne).join(", "):"n/a",icon:o.jsx(vD,{})},{key:"providers",label:"Providers",value:N?.supportedProviders?.length?N.supportedProviders.join(", "):"n/a",icon:o.jsx(Rv,{})},{key:"tags",label:"Tags",value:N?.tags?.length?N.tags.join(", "):"n/a",icon:o.jsx(wN,{})}],J=[{...te[0]},{...te[1]},{...te[2]}].filter(ne=>ne.value!=="n/a");g.useEffect(()=>{L&&d(L)},[L]),g.useEffect(()=>{const ne=Q||U;ne?.phase==="error"&&ne?.error&&m(typeof ne.error=="string"?ne.error:String(ne.error))},[Q?.phase,Q?.error,U?.phase,U?.error]);const ee=ne=>{s(ne)},ae=async ne=>(i(ne.provider),c(ne.modelId),{message:"Model updated successfully"}),ce=async()=>{const ne=Object.entries(u).reduce((ue,[pe,le])=>(le===""&&ue.push(pe),ue),[]);if(ne.length>0){p(ne);return}if(N){m(null),y(!1),S(""),C(!0);try{const pe={repo:N.githubUrl||`https://github.com/mastra-ai/template-${N.slug}`,ref:P,slug:N.slug,variables:u},{runId:le}=await F({});S(le),n(ve=>{const ye=new URLSearchParams(ve);return ye.set("runId",le),ye.set("resume","true"),ye.set("provider",r||"openai"),ye}),await D.mutateAsync({inputData:pe,selectedModel:{provider:a,modelId:l},runId:le})}catch(ue){C(!1),m(ue?.message||"Template installation failed"),console.error("Template installation failed",ue)}}},Y=ne=>{const{name:ue,value:pe}=ne.target;pe.trim()===""?p(le=>[...le,ue]):p(le=>le.filter(ve=>ve!==ue)),d(le=>({...le,[ue]:pe}))};return o.jsx(ls,{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(jss,{isLoading:I,title:N?.title,description:N?.longDescription,imageURL:N?.imageURL,githubUrl:N?.githubUrl,infoData:te,templateSlug:e}),N&&o.jsxs(o.Fragment,{children:[(V||Z)&&o.jsx(Rss,{name:N.title,streamResult:Z?U:Q,runId:b,workflowInfo:q}),v&&o.jsx(Pss,{name:N.title,installedEntities:J,linkComponent:Ba}),h&&o.jsx(Css,{errorMsg:h,validationErrors:E.length>0?E:Q?.validationResults?.errors||U?.validationResults?.errors}),!V&&!Z&&!v&&!h&&o.jsx(Ess,{providerOptions:X,selectedProvider:r,onProviderChange:ee,variables:u,setVariables:d,errors:f,setErrors:p,handleInstallTemplate:ce,handleVariableChange:Y,isLoadingEnvVars:M||H,isInstalling:z,defaultModelProvider:a,defaultModelId:l,onModelUpdate:ae})]})]})})})}const Mss=()=>{const{toolId:e,agentId:t}=ur();return o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(cZr,{toolId:e,agentId:t})})},Dss=()=>{const{toolId:e}=ur();return o.jsx("div",{className:"h-full w-full overflow-y-hidden",children:o.jsx(Vns,{toolId:e})})};function Lss(){const{traceId:e}=ur(),[t,n]=ga(),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]=g.useState(s??null),[d,f]=g.useState(),[p,h]=g.useState(i),[m,v]=g.useState(0),[y,b]=g.useState(!1),{data:S,isLoading:w,error:k}=ZH(e),_=g.useMemo(()=>S?.spans??[],[S?.spans]),C=g.useMemo(()=>_.find(ae=>ae.parentSpanId==null),[_]),{data:E,isLoading:j}=oI(e,c??"");g.useEffect(()=>v(0),[e,c]);const{data:N,isLoading:I}=ih(),{data:R,isLoading:P}=s6t({traceId:e,spanId:c??void 0,page:m}),[L,M]=g.useState(0);g.useEffect(()=>M(0),[e,c]);const{data:q,isLoading:H}=C9t({traceId:e,page:L});g.useEffect(()=>{if(l&&R?.scores&&!d){const ae=R.scores.find(ce=>ce.id===l);ae&&f(ae)}},[l,R?.scores,d]);const F=g.useCallback(ae=>{const ce=new URLSearchParams(t);for(const[Y,ne]of Object.entries(ae))ne===null||ne===""?ce.delete(Y):ce.set(Y,ne);n(ce,{replace:!0})},[t,n]),z=g.useCallback(ae=>{const ce=ae??null,Y=ce===c;u(ce),Y||(f(void 0),h("details"),F({spanId:ce,tab:null,scoreId:null}))},[c,F]),B=g.useCallback(()=>{u(null),f(void 0),h("details"),F({spanId:null,tab:null,scoreId:null})},[F]),D=g.useCallback(ae=>{u(ae),f(void 0),h("details"),F({spanId:ae,tab:null,scoreId:null})},[F]),{handlePreviousSpan:Q,handleNextSpan:V}=GH(_,c,D),$=g.useCallback(ae=>{const ce=ae;h(ce),f(void 0),F({tab:ce==="details"?null:ce,scoreId:null})},[F]),U=g.useCallback(ae=>{f(ae),F({scoreId:ae.id})},[F]),Z=g.useCallback(()=>{f(void 0),F({scoreId:null})},[F]),X=g.useCallback(()=>{r("/observability")},[r]),te=g.useCallback(()=>{h("scoring"),C&&c!==C.spanId?(u(C.spanId),f(void 0),F({spanId:C.spanId,tab:"scoring",scoreId:null})):F({tab:"scoring"})},[C,c,F]),J=C?o.jsx(Iy,{owner:"trace-detail",children:o.jsxs(Mr,{children:[o.jsxs(de,{tooltip:"Evaluate Trace","aria-label":"Evaluate Trace",onClick:te,children:[o.jsx(hcn,{}),"Evaluate"]}),o.jsxs(de,{tooltip:"Save as Dataset Item","aria-label":"Save as Dataset Item",onClick:()=>b(!0),children:[o.jsx(gd,{}),"Save"]})]})}):null,ee=C?o.jsx(Lt.Row,{children:o.jsx(Lt.Column,{children:o.jsx(m9t,{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(g9t,{error:k,resource:"traces",errorTitle:"Failed to load trace"})})]}):o.jsxs(Lt,{children:[J,ee&&o.jsx(Lt.TopArea,{children:ee}),o.jsx(w9t,{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(uTe,{traceId:e,spans:_,isLoading:w,onClose:X,onSpanSelect:z,onEvaluateTrace:te,initialSpanId:c,placement:"trace-page",timelineChartWidth:c?"default":"wide"}),c&&!w&&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(WH,{traceId:e,spanId:c,span:E?.span,isLoading:j,onClose:B,onPrevious:Q,onNext:V,activeTab:p,onTabChange:$,feedbackTabBadge:q?.pagination?.total??void 0,feedbackTabSlot:()=>o.jsx(k9t,{feedbackData:q,onPageChange:M,isLoadingFeedbackData:H}),scoringTabBadge:R?.pagination?.total??void 0,scoringTabSlot:({span:ae,traceId:ce,spanId:Y})=>o.jsxs("div",{className:"grid gap-6",children:[o.jsx(_9t,{traceId:ce,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(O9t,{scoresData:R,onPageChange:v,isLoadingScoresData:P,onScoreSelect:U})]})}),d&&o.jsx(zje,{score:d,onClose:Z})]})]})]})}function Fss(){const{data:e,isLoading:t,error:n}=Uy(),[r,s]=g.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(zi,{title:"Failed to load workflows",message:n.message})}):Object.keys(e||{}).length===0&&!t?o.jsx(lr,{children:o.jsx(bDr,{})}):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(jf,{onSearch:s,label:"Filter workflows",placeholder:"Filter by name or description"})}),o.jsxs(de,{as:Ba,to:"/workflows/schedules",variant:"primary",className:"shrink-0",children:[o.jsx(hD,{}),"Schedules"]})]})}),o.jsx(yDr,{workflows:e||{},isLoading:t,search:r})]})}const zss={active:"bg-accent1",paused:"bg-accent3"},Bss={active:"text-accent1",paused:"text-accent3"},Q9t=({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 ${zss[e]}`,"aria-hidden":!0}),o.jsx("span",{className:`text-ui-sm ${Bss[e]}`,children:e})]}),Fj=e=>!e||e<=0?"—":new Date(e).toLocaleString(),dP=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 Y9t({status:e}){const{icon:t,color:n}=Uss(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 Uss(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(lq,{size:14}),color:"text-accent3"};case"canceled":return{icon:o.jsx(Of,{size:14}),color:"text-neutral3"};case"pending":case"waiting":return{icon:o.jsx(dO,{size:14}),color:"text-neutral3"};default:return{icon:null,color:"text-neutral3"}}}const ZQe="auto auto auto auto 1fr";function qss(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 Vss(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 Hss=3e4,Wss=5*6e4;function Zss({triggers:e,isLoading:t,workflowId:n,hasNextPage:r,isFetchingNextPage:s,setEndOfListElement:a}){const{Link:i,paths:l}=yn();return t?o.jsx(tl,{columns:ZQe}):e.length===0?o.jsx(ge,{variant:"ui-md",className:"text-neutral4 p-4",children:"No trigger history yet."}):o.jsxs(me,{columns:ZQe,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=Vss(u),f=`Scheduled ${Fj(c.scheduledFireAt)} — published ${Fj(c.actualFireAt)} (drift ${d})`,p=c.outcome==="failed",h=p?c.error:c.run?.error,m=Math.abs(u),v=!p&&m>Hss&&m<=Wss,y=`${c.scheduleId}-${c.runId}-${c.actualFireAt}`,b=!!(n&&c.runId&&!p),S=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}),w=o.jsxs(o.Fragment,{children:[o.jsx(me.Cell,{height:"compact",children:S}),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(Ep,{size:14}),"publish failed"]}):c.run?o.jsx(Y9t,{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(Ep,{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:dP(c.actualFireAt)}),v?o.jsxs(Wn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx("span",{className:"text-accent3 inline-flex",children:o.jsx(Ep,{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:qss(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:w},y):o.jsx(me.RowStatic,{children:w},y)}),o.jsx(me.NextPageLoading,{isLoading:s,hasMore:r,setEndOfListElement:a})]})}const Gss=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)}})},GQe=25,Qss=e=>{const t=We(),{inView:n,setRef:r}=A_(),s=$1({queryKey:["schedule-triggers",e],enabled:!!e,initialPageParam:void 0,queryFn:async({pageParam:u})=>e?t.listScheduleTriggers(e,{limit:GQe,toActualFireAt:u}):{triggers:[]},getNextPageParam:u=>{if(!(!u?.triggers?.length||u.triggers.length<GQe))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 g.useEffect(()=>{n&&i&&!l&&c()},[n,i,l,c]),{...s,data:a,setEndOfListElement:r}},Yss=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 fF({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 Xss(){const{scheduleId:e}=ur(),{paths:t}=yn(),{data:n,error:r}=Gss(e),{data:s,isLoading:a,error:i,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u}=Qss(e),d=Yss(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(zi,{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(de,{as:Ba,to:t.schedulesLink(),variant:"ghost",children:[o.jsx(Nc,{}),"Back to schedules"]}),f?o.jsx(de,{as:Ba,to:t.workflowLink(f),variant:"ghost",children:"Open workflow"}):null,n?o.jsx(de,{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(Qlt,{}),"Pause"]}):o.jsxs(o.Fragment,{children:[o.jsx(Fp,{}),"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(fF,{label:"Workflow",children:f?o.jsx(Ba,{to:t.workflowLink(f),className:"text-accent1 hover:underline",children:f}):"—"}),o.jsxs(fF,{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(fF,{label:"Status",children:o.jsx(Q9t,{status:n.status})}),o.jsx(fF,{label:"Next fire",children:o.jsx("span",{title:Fj(n.nextFireAt),children:dP(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(zi,{title:"Failed to load trigger history",message:i.message}):o.jsx(Zss,{triggers:s??[],isLoading:a,workflowId:f,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u})]})]}):null]})}const QQe="minmax(0, 1.2fr) minmax(0, 1.4fr) minmax(0, 1fr) auto auto auto";function Kss({schedules:e,isLoading:t,search:n=""}){const{paths:r,Link:s}=yn(),a=g.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(tl,{columns:QQe}):o.jsxs(me,{columns:QQe,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(Q9t,{status:i.status})}),o.jsx(me.Cell,{height:"compact",children:o.jsx("span",{className:"whitespace-nowrap",title:Fj(i.nextFireAt),children:dP(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(Y9t,{status:i.lastRun.status}),o.jsx("span",{className:"text-neutral4 text-ui-sm",title:Fj(i.lastFireAt),children:i.lastFireAt?dP(i.lastFireAt):""})]}):i.lastFireAt?o.jsx("span",{className:"whitespace-nowrap",title:Fj(i.lastFireAt),children:dP(i.lastFireAt)}):o.jsx("span",{className:"text-neutral4",children:"Never"})})]},i.id))]})}function Jss({workflowId:e}={}){const{data:t,isLoading:n,error:r}=Kxe(e?{workflowId:e}:{}),[s,a]=g.useState("");return r?o.jsx(zi,{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(jf,{onSearch:a,label:"Filter schedules",placeholder:"Filter by id or workflow"})}),o.jsx("div",{className:"overflow-y-auto",children:o.jsx(Kss,{schedules:t??[],isLoading:n,search:s})})]})}function eas(){const[e]=ga(),t=e.get("workflowId")??void 0,{error:n}=Kxe(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(Jss,{workflowId:t})})})}function tas({stepGraph:e,open:t,workflowName:n}){const{nodes:r,edges:s}=N1e({stepGraph:e}),[a,i]=g.useState(!1),[l,c,u]=vwt(r),[d]=ywt(s),{edgeTypes:f,nodeTypes:p,styledEdges:h}=R2t({edges:d,workflowName:n,stepGraph:e});return g.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(gwt,{nodes:l,edges:h,edgeTypes:f,fitView:!0,fitViewOptions:{maxZoom:1},minZoom:.01,maxZoom:1,nodeTypes:p,onNodesChange:u,children:[o.jsx(W_e,{position:"bottom-left"}),o.jsx(xwt,{variant:ey.Lines,gap:12,size:.5})]}):o.jsx("div",{className:"w-full h-full flex items-center justify-center",children:o.jsx(Gt,{})})})}function nas(){const{stepDetail:e,closeStepDetail:t}=ZV();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(efe,{className:"w-4 h-4",style:{color:Cu.map}}),e.type==="nested-graph"&&o.jsx(jd,{className:"w-4 h-4",style:{color:Cu.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(iP,{data:e.mapConfig}),e.type==="nested-graph"&&e.nestedGraph&&o.jsx("div",{className:"h-full min-h-[400px]",children:o.jsx(T1e,{children:o.jsx(tas,{stepGraph:e.nestedGraph.stepGraph,open:!0,workflowName:e.nestedGraph.fullStep})},`nested-graph-${e.nestedGraph.fullStep}`)})]})]}):null}function ras(e){const t=new Blob([JSON.stringify(e??null)]).size;return t<1024?`${t} B`:`${(t/1024).toFixed(1)} KB`}function sas(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 aas({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(lq,{})}),"Step suspended"]}),o.jsx(dn,{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?lm(im(yx(i.resumeSchema))):op(dr(),cT());return o.jsx(ias,{step:s,stepSchema:l,description:i.description,isStreaming:n,onResume:r},`${s.runId}-${s.stepId}-${a}`)})]})}function ias({step:e,stepSchema:t,description:n,isStreaming:r,onResume:s}){const[a,i]=g.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(kdn,{})}),"The step is asking"]}),o.jsxs(xf,{open:a,onOpenChange:i,children:[o.jsxs(Od,{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(ta,{className:K("transition-transform text-neutral3",{"transform rotate-90":a})})}),o.jsx(ge,{as:"span",variant:"ui-md",className:"text-neutral6 truncate",children:sas(e.suspendPayload,e.stepId)})]}),o.jsx(ge,{as:"span",variant:"ui-sm",className:"text-neutral3 shrink-0",children:ras(e.suspendPayload)})]}),o.jsx(_d,{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(Cdn,{})}),"Your response"]}),o.jsx("div",{className:"-mx-5",children:o.jsx(B7,{schema:t,isSubmitLoading:r,submitButtonLabel:"Resume",submitButtonIcon:o.jsx(Fp,{}),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 oas(){const{result:e,runSnapshot:t,workflow:n,runId:r,isStreamingWorkflow:s}=g.useContext($l),{runId:a}=ur(),i=Ewt(e,r??""),l=LZn(),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(aas,{suspendedSteps:i,workflow:n,isStreaming:s,onResume:l})},r)}const las=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"})]}),cas=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"})]}),uas=e=>e.includes("."),das=e=>e==="input"||e.endsWith(".input"),fas=1;function pas(e){return`${Number((e/1e3).toPrecision(3))}s`}function has(e,t){const n=Object.entries(e).filter(([i])=>!das(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,fas);return{stepId:i,step:l,status:l.status,offsetPct:f,widthPct:p,durationMs:d,isRunning:c,isNestedEntry:uas(i)}})}const mas=({status:e})=>o.jsxs(Ue,{children:[e==="success"&&o.jsx(las,{className:"text-accent1"}),e==="failed"&&o.jsx(cas,{className:"text-accent2"}),e==="suspended"&&o.jsx(lq,{className:"text-accent3"}),e==="waiting"&&o.jsx(Jde,{className:"text-accent5"}),e==="skipped"&&o.jsx(Jde,{className:"text-icon3"}),e==="running"&&o.jsx(oa,{className:"text-accent6 animate-spin"})]}),gas={success:"bg-accent1",failed:"bg-accent2",suspended:"bg-accent3",waiting:"bg-accent5",skipped:"bg-border1",running:"bg-accent6"};function X9t(e){return e.split(/[-_.\s]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}const YQe=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{value:e},vas=e=>{const t=e;return O2t({duration:t.duration,date:t.date,isForEach:t.isForEach,mapConfig:t.mapConfig,canSuspend:t.canSuspend,isParallel:t.isParallel,stepGraph:t.stepGraph})},yas=({row:e,index:t,isSelected:n,isHovered:r,onSelectStep:s,onHoverStep:a,onOpenInput:i,onOpenOutput:l})=>{const c=vas(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(mas,{status:e.status})}),o.jsx("div",{className:"flex justify-center",children:o.jsx(de,{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(Ofn,{})})}),o.jsx("div",{className:"flex overflow-hidden",children:o.jsx(hU,{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:X9t(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 ${gas[e.status]}`,style:{left:`${e.offsetPct}%`,width:`${e.widthPct}%`}})}),o.jsx("div",{className:"flex justify-center",children:o.jsx(de,{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(Sfn,{})})}),o.jsx(ge,{as:"span",variant:"ui-sm",className:"w-20 justify-self-end text-right text-neutral3 tabular-nums",children:pas(e.durationMs)})]},`timeline-item-${e.stepId}-${t}`)};function bas(){const{steps:e}=u4(),{selectedStepId:t,hoverStepId:n,setSelectedStepId:r,setHoverStepId:s}=sV(),[a,i]=g.useState(()=>Date.now()),[l,c]=g.useState(!1),[u,d]=g.useState(null),f=g.useRef(null);i0e(f,{enabled:!l});const p=has(e,a),h=p.some(m=>m.isRunning);return g.useEffect(()=>{if(!h)return;const m=setInterval(()=>i(Date.now()),100);return()=>clearInterval(m)},[h]),g.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(Sa,{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,v)=>o.jsx(yas,{row:m,index:v,isSelected:t===m.stepId,isHovered:n===m.stepId,onSelectStep:r,onHoverStep:s,onOpenInput:y=>d({type:"input",stepId:y.stepId,data:YQe(y.step.input)}),onOpenOutput:y=>d({type:"output",stepId:y.stepId,data:YQe(y.step.output)})},`timeline-item-${m.stepId}-${v}`))})]})}),o.jsx(br,{open:!!u,onOpenChange:m=>!m&&d(null),children:u&&o.jsx(Twt,{data:u.data,title:`${X9t(u.stepId)} ${u.type==="input"?"input":"output"}`})})]})}const xas=({workflowId:e,workflow:t,isLoading:n})=>{const{stepDetail:r}=ZV();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(B2t,{workflowId:e,workflow:t,isLoading:n}),o.jsx(oas,{}),o.jsx(bas,{})]})}),r&&o.jsx("div",{className:"w-[420px] min-h-0 overflow-hidden border-l border-border1",children:o.jsx(nas,{})})]})},XQe=()=>{const{workflowId:e}=ur(),{data:t,isLoading:n,error:r}=S3(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(Z1e,{children:o.jsx(xas,{workflowId:e,workflow:t??void 0,isLoading:n})})};function was(e,t){if(e==null)return{};var n,r,s=Rbt(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 Gve(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 Sas(e){if(Array.isArray(e))return Gve(e)}function kas(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Oas(e,t){if(e){if(typeof e=="string")return Gve(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)?Gve(e,t):void 0}}function _as(){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 Qve(e){return Sas(e)||kas(e)||Oas(e)||_as()}function rD(e){"@babel/helpers - typeof";return rD=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},rD(e)}function Cas(e,t){if(rD(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(rD(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Eas(e){var t=Cas(e,"string");return rD(t)=="symbol"?t:t+""}function K9t(e,t,n){return(t=Eas(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function KQe(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 sj(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?KQe(Object(n),!0).forEach(function(r){K9t(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):KQe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function jas(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 fse={};function Tas(e){if(e.length===0||e.length===1)return e;var t=e.join(".");return fse[t]||(fse[t]=jas(e)),fse[t]}function Nas(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=Tas(r);return s.reduce(function(a,i){return sj(sj({},a),n[i])},t)}function JQe(e){return e.join(" ")}function Ias(e,t){var n=0;return function(r){return n+=1,r.map(function(s,a){return J9t({node:s,stylesheet:e,useInlineStyles:t,key:"code-segment-".concat(n,"-").concat(a)})})}}function J9t(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=Ias(n,a),p;if(!a)p=sj(sj({},l),{},{className:JQe(l.className)});else{var h=Object.keys(n).reduce(function(b,S){return S.split(".").forEach(function(w){b.includes(w)||b.push(w)}),b},[]),m=l.className&&l.className.includes("token")?["token"]:[],v=l.className&&m.concat(l.className.filter(function(b){return!h.includes(b)}));p=sj(sj({},l),{},{className:JQe(v)||void 0,style:Nas(l.className,Object.assign({},l.style,s),n)})}var y=f(t.children);return Le.createElement(u,PO({key:i},p),y)}}const Aas=(function(e,t){var n=e.listLanguages();return n.indexOf(t)!==-1});var Ras=["language","children","style","customStyle","codeTagProps","useInlineStyles","showLineNumbers","showInlineLineNumbers","startingLineNumber","lineNumberContainerStyle","lineNumberStyle","wrapLines","wrapLongLines","lineProps","renderer","PreTag","CodeTag","code","astGenerator"];function eYe(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 Ow(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?eYe(Object(n),!0).forEach(function(r){K9t(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):eYe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var Pas=/\n/g;function $as(e){return e.match(Pas)}function Mas(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 Das(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)},Mas({lines:t.replace(/\n$/,"").split(`
730
730
  `),style:i,startingLineNumber:l}))}function Las(e){return"".concat(e.toString().length,".25em")}function eFt(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 tFt(e,t,n){var r={display:"inline-block",minWidth:Las(n),paddingRight:"1em",textAlign:"right",userSelect:"none"},s=typeof e=="function"?e(t):e,a=Ow(Ow({},r),s);return a}function j8(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?Ow({},typeof l=="function"?l(n):l):{};if(m.className=m.className?[].concat(Qve(m.className.trim().split(/\s+/)),Qve(u)):u,n&&a){var v=tFt(r,n,s);t.unshift(eFt(n,v))}return f&d&&(m.style=Ow({display:"flex"},m.style)),{type:"element",tagName:"span",properties:m,children:t}}function nFt(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(j8({children:[s],className:Qve(new Set(t))}));else if(s.children){var a=t.concat(s.properties.className);nFt(s.children,a).forEach(function(i){return n.push(i)})}}return n}function Fas(e,t,n,r,s,a,i,l,c){var u,d=nFt(e.value),f=[],p=-1,h=0;function m(_,C){var E=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return j8({children:_,lineNumber:C,lineNumberStyle:l,largestLineNumber:i,showInlineLineNumbers:s,lineProps:n,className:E,showLineNumbers:r,wrapLongLines:c,wrapLines:t})}function v(_,C){if(r&&C&&s){var E=tFt(l,C,i);_.unshift(eFt(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):v(_,C)}for(var b=function(){var C=d[h],E=C.children[0].value,j=$as(E);if(j){var N=E.split(`