@mastra/deployer-cloud 1.45.0-alpha.0 → 1.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/studio/assets/{core-CPv_0oCn.js → core-mNco33Iy.js} +1 -1
- package/dist/studio/assets/{index-OnvDPExa.js → index-D5hUXRir.js} +2 -2
- package/dist/studio/assets/{main-BFaNDjb2.js → main-BXZpL7GX.js} +3 -3
- package/dist/studio/index.html +1 -1
- package/package.json +7 -7
- package/versions.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./core-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./core-mNco33Iy.js","./engine-compile-BkERmzkH.js","./preload-helper-PPVm8Dsz.js","./engine-javascript-CSIo_1eZ.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{_ as wo}from"./preload-helper-PPVm8Dsz.js";function v9t(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 wj=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function bc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var GG={exports:{}},zI={};var DIe;function y9t(){if(DIe)return zI;DIe=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 zI.Fragment=t,zI.jsx=n,zI.jsxs=n,zI}var LIe;function b9t(){return LIe||(LIe=1,GG.exports=y9t()),GG.exports}var o=b9t(),QG={exports:{}},zr={},FIe;function x9t(){if(FIe)return zr;FIe=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 g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,b={};function w(V,R,U){this.props=V,this.context=R,this.refs=b,this.updater=U||g}w.prototype.isReactComponent={},w.prototype.setState=function(V,R){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,R,"setState")},w.prototype.forceUpdate=function(V){this.updater.enqueueForceUpdate(this,V,"forceUpdate")};function S(){}S.prototype=w.prototype;function O(V,R,U){this.props=V,this.context=R,this.refs=b,this.updater=U||g}var _=O.prototype=new S;_.constructor=O,v(_,w.prototype),_.isPureReactComponent=!0;var C=Array.isArray;function j(){}var E={H:null,A:null,T:null,S:null},N=Object.prototype.hasOwnProperty;function I(V,R,U){var Z=U.ref;return{$$typeof:t,type:V,key:R,ref:Z!==void 0?Z:null,props:U}}function P(V,R){return I(V.type,R,V.props)}function $(V){return typeof V=="object"&&V!==null&&V.$$typeof===t}function z(V){var R={"=":"=0",":":"=2"};return"$"+V.replace(/[=:]/g,function(U){return R[U]})}var D=/\/+/g;function q(V,R){return typeof V=="object"&&V!==null&&V.key!=null?z(""+V.key):R.toString(36)}function W(V){switch(V.status){case"fulfilled":return V.value;case"rejected":throw V.reason;default:switch(typeof V.status=="string"?V.then(j,j):(V.status="pending",V.then(function(R){V.status==="pending"&&(V.status="fulfilled",V.value=R)},function(R){V.status==="pending"&&(V.status="rejected",V.reason=R)})),V.status){case"fulfilled":return V.value;case"rejected":throw V.reason}}throw V}function L(V,R,U,Z,X){var te=typeof V;(te==="undefined"||te==="boolean")&&(V=null);var ee=!1;if(V===null)ee=!0;else switch(te){case"bigint":case"string":case"number":ee=!0;break;case"object":switch(V.$$typeof){case t:case n:ee=!0;break;case f:return ee=V._init,L(ee(V._payload),R,U,Z,X)}}if(ee)return X=X(V),ee=Z===""?"."+q(V,0):Z,C(X)?(U="",ee!=null&&(U=ee.replace(D,"$&/")+"/"),L(X,R,U,"",function(ue){return ue})):X!=null&&($(X)&&(X=P(X,U+(X.key==null||V&&V.key===X.key?"":(""+X.key).replace(D,"$&/")+"/")+ee)),R.push(X)),1;ee=0;var J=Z===""?".":Z+":";if(C(V))for(var ie=0;ie<V.length;ie++)Z=V[ie],te=J+q(Z,ie),ee+=L(Z,R,U,te,X);else if(ie=m(V),typeof ie=="function")for(V=ie.call(V),ie=0;!(Z=V.next()).done;)Z=Z.value,te=J+q(Z,ie++),ee+=L(Z,R,U,te,X);else if(te==="object"){if(typeof V.then=="function")return L(W(V),R,U,Z,X);throw R=String(V),Error("Objects are not valid as a React child (found: "+(R==="[object Object]"?"object with keys {"+Object.keys(V).join(", ")+"}":R)+"). If you meant to render a collection of children, use an array instead.")}return ee}function F(V,R,U){if(V==null)return V;var Z=[],X=0;return L(V,Z,"","",function(te){return R.call(U,te,X++)}),Z}function B(V){if(V._status===-1){var R=V._result;R=R(),R.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=R)}if(V._status===1)return V._result.default;throw V._result}var M=typeof reportError=="function"?reportError:function(V){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var R=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(R))return}else if(typeof e=="object"&&typeof e.emit=="function"){e.emit("uncaughtException",V);return}console.error(V)},Q={map:F,forEach:function(V,R,U){F(V,function(){R.apply(this,arguments)},U)},count:function(V){var R=0;return F(V,function(){R++}),R},toArray:function(V){return F(V,function(R){return R})||[]},only:function(V){if(!$(V))throw Error("React.Children.only expected to receive a single React element child.");return V}};return zr.Activity=p,zr.Children=Q,zr.Component=w,zr.Fragment=r,zr.Profiler=a,zr.PureComponent=O,zr.StrictMode=s,zr.Suspense=u,zr.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=E,zr.__COMPILER_RUNTIME={__proto__:null,c:function(V){return E.H.useMemoCache(V)}},zr.cache=function(V){return function(){return V.apply(null,arguments)}},zr.cacheSignal=function(){return null},zr.cloneElement=function(V,R,U){if(V==null)throw Error("The argument must be a React element, but you passed "+V+".");var Z=v({},V.props),X=V.key;if(R!=null)for(te in R.key!==void 0&&(X=""+R.key),R)!N.call(R,te)||te==="key"||te==="__self"||te==="__source"||te==="ref"&&R.ref===void 0||(Z[te]=R[te]);var te=arguments.length-2;if(te===1)Z.children=U;else if(1<te){for(var ee=Array(te),J=0;J<te;J++)ee[J]=arguments[J+2];Z.children=ee}return I(V.type,X,Z)},zr.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},zr.createElement=function(V,R,U){var Z,X={},te=null;if(R!=null)for(Z in R.key!==void 0&&(te=""+R.key),R)N.call(R,Z)&&Z!=="key"&&Z!=="__self"&&Z!=="__source"&&(X[Z]=R[Z]);var ee=arguments.length-2;if(ee===1)X.children=U;else if(1<ee){for(var J=Array(ee),ie=0;ie<ee;ie++)J[ie]=arguments[ie+2];X.children=J}if(V&&V.defaultProps)for(Z in ee=V.defaultProps,ee)X[Z]===void 0&&(X[Z]=ee[Z]);return I(V,te,X)},zr.createRef=function(){return{current:null}},zr.forwardRef=function(V){return{$$typeof:c,render:V}},zr.isValidElement=$,zr.lazy=function(V){return{$$typeof:f,_payload:{_status:-1,_result:V},_init:B}},zr.memo=function(V,R){return{$$typeof:d,type:V,compare:R===void 0?null:R}},zr.startTransition=function(V){var R=E.T,U={};E.T=U;try{var Z=V(),X=E.S;X!==null&&X(U,Z),typeof Z=="object"&&Z!==null&&typeof Z.then=="function"&&Z.then(j,M)}catch(te){M(te)}finally{R!==null&&U.types!==null&&(R.types=U.types),E.T=R}},zr.unstable_useCacheRefresh=function(){return E.H.useCacheRefresh()},zr.use=function(V){return E.H.use(V)},zr.useActionState=function(V,R,U){return E.H.useActionState(V,R,U)},zr.useCallback=function(V,R){return E.H.useCallback(V,R)},zr.useContext=function(V){return E.H.useContext(V)},zr.useDebugValue=function(){},zr.useDeferredValue=function(V,R){return E.H.useDeferredValue(V,R)},zr.useEffect=function(V,R){return E.H.useEffect(V,R)},zr.useEffectEvent=function(V){return E.H.useEffectEvent(V)},zr.useId=function(){return E.H.useId()},zr.useImperativeHandle=function(V,R,U){return E.H.useImperativeHandle(V,R,U)},zr.useInsertionEffect=function(V,R){return E.H.useInsertionEffect(V,R)},zr.useLayoutEffect=function(V,R){return E.H.useLayoutEffect(V,R)},zr.useMemo=function(V,R){return E.H.useMemo(V,R)},zr.useOptimistic=function(V,R){return E.H.useOptimistic(V,R)},zr.useReducer=function(V,R,U){return E.H.useReducer(V,R,U)},zr.useRef=function(V){return E.H.useRef(V)},zr.useState=function(V){return E.H.useState(V)},zr.useSyncExternalStore=function(V,R,U){return E.H.useSyncExternalStore(V,R,U)},zr.useTransition=function(){return E.H.useTransition()},zr.version="19.2.6",zr}var zIe;function UT(){return zIe||(zIe=1,QG.exports=x9t()),QG.exports}var y=UT();const De=bc(y),qT=v9t({__proto__:null,default:De},[y]);var YG={exports:{}},BI={},XG={exports:{}},KG={};var BIe;function w9t(){return BIe||(BIe=1,(function(e){function t(W,L){var F=W.length;W.push(L);e:for(;0<F;){var B=F-1>>>1,M=W[B];if(0<s(M,L))W[B]=L,W[F]=M,F=B;else break e}}function n(W){return W.length===0?null:W[0]}function r(W){if(W.length===0)return null;var L=W[0],F=W.pop();if(F!==L){W[0]=F;e:for(var B=0,M=W.length,Q=M>>>1;B<Q;){var V=2*(B+1)-1,R=W[V],U=V+1,Z=W[U];if(0>s(R,F))U<M&&0>s(Z,R)?(W[B]=Z,W[U]=F,B=U):(W[B]=R,W[V]=F,B=V);else if(U<M&&0>s(Z,F))W[B]=Z,W[U]=F,B=U;else break e}}return L}function s(W,L){var F=W.sortIndex-L.sortIndex;return F!==0?F:W.id-L.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var i=Date,l=i.now();e.unstable_now=function(){return i.now()-l}}var c=[],u=[],d=1,f=null,p=3,h=!1,m=!1,g=!1,v=!1,b=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function O(W){for(var L=n(u);L!==null;){if(L.callback===null)r(u);else if(L.startTime<=W)r(u),L.sortIndex=L.expirationTime,t(c,L);else break;L=n(u)}}function _(W){if(g=!1,O(W),!m)if(n(c)!==null)m=!0,C||(C=!0,$());else{var L=n(u);L!==null&&q(_,L.startTime-W)}}var C=!1,j=-1,E=5,N=-1;function I(){return v?!0:!(e.unstable_now()-N<E)}function P(){if(v=!1,C){var W=e.unstable_now();N=W;var L=!0;try{e:{m=!1,g&&(g=!1,w(j),j=-1),h=!0;var F=p;try{t:{for(O(W),f=n(c);f!==null&&!(f.expirationTime>W&&I());){var B=f.callback;if(typeof B=="function"){f.callback=null,p=f.priorityLevel;var M=B(f.expirationTime<=W);if(W=e.unstable_now(),typeof M=="function"){f.callback=M,O(W),L=!0;break t}f===n(c)&&r(c),O(W)}else r(c);f=n(c)}if(f!==null)L=!0;else{var Q=n(u);Q!==null&&q(_,Q.startTime-W),L=!1}}break e}finally{f=null,p=F,h=!1}L=void 0}}finally{L?$():C=!1}}}var $;if(typeof S=="function")$=function(){S(P)};else if(typeof MessageChannel<"u"){var z=new MessageChannel,D=z.port2;z.port1.onmessage=P,$=function(){D.postMessage(null)}}else $=function(){b(P,0)};function q(W,L){j=b(function(){W(e.unstable_now())},L)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(W){W.callback=null},e.unstable_forceFrameRate=function(W){0>W||125<W?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):E=0<W?Math.floor(1e3/W):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_next=function(W){switch(p){case 1:case 2:case 3:var L=3;break;default:L=p}var F=p;p=L;try{return W()}finally{p=F}},e.unstable_requestPaint=function(){v=!0},e.unstable_runWithPriority=function(W,L){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var F=p;p=W;try{return L()}finally{p=F}},e.unstable_scheduleCallback=function(W,L,F){var B=e.unstable_now();switch(typeof F=="object"&&F!==null?(F=F.delay,F=typeof F=="number"&&0<F?B+F:B):F=B,W){case 1:var M=-1;break;case 2:M=250;break;case 5:M=1073741823;break;case 4:M=1e4;break;default:M=5e3}return M=F+M,W={id:d++,callback:L,priorityLevel:W,startTime:F,expirationTime:M,sortIndex:-1},F>B?(W.sortIndex=F,t(u,W),n(c)===null&&W===n(u)&&(g?(w(j),j=-1):g=!0,q(_,F-B))):(W.sortIndex=M,t(c,W),m||h||(m=!0,C||(C=!0,$()))),W},e.unstable_shouldYield=I,e.unstable_wrapCallback=function(W){var L=p;return function(){var F=p;p=L;try{return W.apply(this,arguments)}finally{p=F}}}})(KG)),KG}var UIe;function S9t(){return UIe||(UIe=1,XG.exports=w9t()),XG.exports}var JG={exports:{}},tu={};var qIe;function k9t(){if(qIe)return tu;qIe=1;var e=UT();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 tu.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,tu.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)},tu.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()}},tu.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))},tu.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},tu.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})}},tu.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)},tu.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})}},tu.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)},tu.requestFormReset=function(c){r.d.r(c)},tu.unstable_batchedUpdates=function(c,u){return c(u)},tu.useFormState=function(c,u,d){return i.H.useFormState(c,u,d)},tu.useFormStatus=function(){return i.H.useHostTransitionStatus()},tu.version="19.2.6",tu}var VIe;function Let(){if(VIe)return JG.exports;VIe=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(),JG.exports=k9t(),JG.exports}var HIe;function O9t(){if(HIe)return BI;HIe=1;var e={env:{}};var t=S9t(),n=UT(),r=Let();function s(x){var k="https://react.dev/errors/"+x;if(1<arguments.length){k+="?args[]="+encodeURIComponent(arguments[1]);for(var T=2;T<arguments.length;T++)k+="&args[]="+encodeURIComponent(arguments[T])}return"Minified React error #"+x+"; visit "+k+" 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 k=x,T=x;if(x.alternate)for(;k.return;)k=k.return;else{x=k;do k=x,(k.flags&4098)!==0&&(T=k.return),x=k.return;while(x)}return k.tag===3?T:null}function l(x){if(x.tag===13){var k=x.memoizedState;if(k===null&&(x=x.alternate,x!==null&&(k=x.memoizedState)),k!==null)return k.dehydrated}return null}function c(x){if(x.tag===31){var k=x.memoizedState;if(k===null&&(x=x.alternate,x!==null&&(k=x.memoizedState)),k!==null)return k.dehydrated}return null}function u(x){if(i(x)!==x)throw Error(s(188))}function d(x){var k=x.alternate;if(!k){if(k=i(x),k===null)throw Error(s(188));return k!==x?null:x}for(var T=x,A=k;;){var H=T.return;if(H===null)break;var G=H.alternate;if(G===null){if(A=H.return,A!==null){T=A;continue}break}if(H.child===G.child){for(G=H.child;G;){if(G===T)return u(H),x;if(G===A)return u(H),k;G=G.sibling}throw Error(s(188))}if(T.return!==A.return)T=H,A=G;else{for(var oe=!1,we=H.child;we;){if(we===T){oe=!0,T=H,A=G;break}if(we===A){oe=!0,A=H,T=G;break}we=we.sibling}if(!oe){for(we=G.child;we;){if(we===T){oe=!0,T=G,A=H;break}if(we===A){oe=!0,A=G,T=H;break}we=we.sibling}if(!oe)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:k}function f(x){var k=x.tag;if(k===5||k===26||k===27||k===6)return x;for(x=x.child;x!==null;){if(k=f(x),k!==null)return k;x=x.sibling}return null}var p=Object.assign,h=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),O=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),N=Symbol.for("react.lazy"),I=Symbol.for("react.activity"),P=Symbol.for("react.memo_cache_sentinel"),$=Symbol.iterator;function z(x){return x===null||typeof x!="object"?null:(x=$&&x[$]||x["@@iterator"],typeof x=="function"?x:null)}var D=Symbol.for("react.client.reference");function q(x){if(x==null)return null;if(typeof x=="function")return x.$$typeof===D?null:x.displayName||x.name||null;if(typeof x=="string")return x;switch(x){case v:return"Fragment";case w:return"Profiler";case b:return"StrictMode";case C:return"Suspense";case j:return"SuspenseList";case I:return"Activity"}if(typeof x=="object")switch(x.$$typeof){case g:return"Portal";case O:return x.displayName||"Context";case S:return(x._context.displayName||"Context")+".Consumer";case _:var k=x.render;return x=x.displayName,x||(x=k.displayName||k.name||"",x=x!==""?"ForwardRef("+x+")":"ForwardRef"),x;case E:return k=x.displayName||null,k!==null?k:q(x.type)||"Memo";case N:k=x._payload,x=x._init;try{return q(x(k))}catch{}}return null}var W=Array.isArray,L=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B={pending:!1,data:null,method:null,action:null},M=[],Q=-1;function V(x){return{current:x}}function R(x){0>Q||(x.current=M[Q],M[Q]=null,Q--)}function U(x,k){Q++,M[Q]=x.current,x.current=k}var Z=V(null),X=V(null),te=V(null),ee=V(null);function J(x,k){switch(U(te,k),U(X,x),U(Z,null),k.nodeType){case 9:case 11:x=(x=k.documentElement)&&(x=x.namespaceURI)?iIe(x):0;break;default:if(x=k.tagName,k=k.namespaceURI)k=iIe(k),x=oIe(k,x);else switch(x){case"svg":x=1;break;case"math":x=2;break;default:x=0}}R(Z),U(Z,x)}function ie(){R(Z),R(X),R(te)}function ue(x){x.memoizedState!==null&&U(ee,x);var k=Z.current,T=oIe(k,x.type);k!==T&&(U(X,x),U(Z,T))}function Y(x){X.current===x&&(R(Z),R(X)),ee.current===x&&(R(ee),MI._currentValue=B)}var ne,le;function pe(x){if(ne===void 0)try{throw Error()}catch(T){var k=T.stack.trim().match(/\n( *(at )?)/);ne=k&&k[1]||"",le=-1<T.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<T.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
4
|
`+ne+x+le}var se=!1;function he(x,k){if(!x||se)return"";se=!0;var T=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var A={DetermineComponentFrameRoot:function(){try{if(k){var Ot=function(){throw Error()};if(Object.defineProperty(Ot.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ot,[])}catch(dt){var it=dt}Reflect.construct(x,[],Ot)}else{try{Ot.call()}catch(dt){it=dt}x.call(Ot.prototype)}}else{try{throw Error()}catch(dt){it=dt}(Ot=x())&&typeof Ot.catch=="function"&&Ot.catch(function(){})}}catch(dt){if(dt&&it&&typeof dt.stack=="string")return[dt.stack,it.stack]}return[null,null]}};A.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var H=Object.getOwnPropertyDescriptor(A.DetermineComponentFrameRoot,"name");H&&H.configurable&&Object.defineProperty(A.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var G=A.DetermineComponentFrameRoot(),oe=G[0],we=G[1];if(oe&&we){var ze=oe.split(`
|
|
@@ -223,7 +223,7 @@ Please change the parent <Route path="${v}"> to <Route path="${v==="/"?"*":`${v}
|
|
|
223
223
|
\${}
|
|
224
224
|
}
|
|
225
225
|
}`,{label:"class",detail:"definition",type:"keyword"}),Td('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Td('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],apt=Wbe.concat([Td("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Td("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Td("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),MDe=new cut,ipt=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function uA(e){return(t,n)=>{let r=t.node.getChild("VariableDefinition");return r&&n(r,e),!0}}const cCn=["FunctionDeclaration"],uCn={FunctionDeclaration:uA("function"),ClassDeclaration:uA("class"),ClassExpression:()=>!0,EnumDeclaration:uA("constant"),TypeAliasDeclaration:uA("type"),NamespaceDeclaration:uA("namespace"),VariableDefinition(e,t){e.matchContext(cCn)||t(e,"variable")},TypeDefinition(e,t){t(e,"type")},__proto__:null};function opt(e,t){let n=MDe.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(Ra.IncludeAnonymous).iterate(i=>{if(s)s=!1;else if(i.name){let l=uCn[i.name];if(l&&l(i,a)||ipt.has(i.name))return!1}else if(i.to-i.from>8192){for(let l of opt(e,i.node))r.push(l);return!1}}),MDe.set(t,r),r}const ez=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,Zbe=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function lpt(e){let t=pi(e.state).resolveInner(e.pos,-1);if(Zbe.indexOf(t.name)>-1)return null;let n=t.name=="VariableName"||t.to-t.from<20&&ez.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let r=[];for(let s=t;s;s=s.parent)ipt.has(s.name)&&(r=r.concat(opt(e.state.doc,s)));return{options:r,from:n?t.from:e.pos,validFor:ez}}function XY(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 cpt(e){let t=r=>e.state.doc.sliceString(r.from,r.to),n=pi(e.state).resolveInner(e.pos,-1);return n.name=="PropertyName"?XY(t,n.parent,t(n)):(n.name=="."||n.name=="?.")&&n.parent.name=="MemberExpression"?XY(t,n.parent,""):Zbe.indexOf(n.name)>-1?null:n.name=="VariableName"||n.to-n.from<20&&ez.test(t(n))?{path:[],name:t(n)}:n.name=="MemberExpression"?XY(t,n,""):e.explicit?{path:[],name:""}:null}function dCn(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 fCn(e){let t=new Map;return n=>{let r=cpt(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=dCn(s,!r.path.length)),{from:n.pos-r.name.length,options:a,validFor:ez}}}const Ah=sO.define({name:"javascript",parser:lCn.configure({props:[f_.add({IfStatement:ej({except:/^\s*({|else\b)/}),TryStatement:ej({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:iSn,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:aSn({closing:"}"}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":ej({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}}),p_.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":Cbe,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:"$"}}),upt={test:e=>/^JSX/.test(e.name),facet:WU({commentTokens:{block:{open:"{/*",close:"*/}"}}})},Gbe=Ah.configure({dialect:"ts"},"typescript"),Qbe=Ah.configure({dialect:"jsx",props:[kbe.add(e=>e.isTop?[upt]:void 0)]}),Ybe=Ah.configure({dialect:"jsx ts",props:[kbe.add(e=>e.isTop?[upt]:void 0)]},"typescript");let dpt=e=>({label:e,type:"keyword"});const fpt="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(dpt),pCn=fpt.concat(["declare","implements","private","protected","public"].map(dpt));function tz(e={}){let t=e.jsx?e.typescript?Ybe:Qbe:e.typescript?Gbe:Ah,n=e.typescript?apt.concat(pCn):Wbe.concat(fpt);return new iO(t,[Ah.data.of({autocomplete:HSn(Zbe,uft(n))}),Ah.data.of({autocomplete:lpt}),e.jsx?ppt:[]])}function hCn(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 DDe(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 mCn=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),ppt=Nt.inputHandler.of((e,t,n,r,s)=>{if((mCn?e.composing:e.compositionStarted)||e.state.readOnly||t!=n||r!=">"&&r!="/"||!Ah.isActiveAt(e.state,t,-1))return!1;let a=s(),{state:i}=a,l=i.changeByRange(c=>{var u;let{head:d}=c,f=pi(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=DDe(i.doc,m.firstChild,d))||((u=m.firstChild)===null||u===void 0?void 0:u.name)=="JSXFragmentTag")){let g=`${p}>`;return{range:vt.cursor(d+g.length,-1),changes:{from:d,insert:g}}}}else if(r==">"){let h=hCn(f);if(h&&h.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(i.doc.sliceString(d,d+2))&&(p=DDe(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 gCn(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 Ah.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(vCn(u,r.doc,c))}return s}}function LDe(e,t,n,r){return n.line(e+r.line).from+t+(e==1?r.col-1:-1)}function vCn(e,t,n){let r=LDe(e.line,e.column,t,n),s={from:r,to:e.endLine!=null&&e.endColumn!=1?LDe(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 gL=Object.freeze(Object.defineProperty({__proto__:null,autoCloseTags:ppt,completionPath:cpt,esLint:gCn,javascript:tz,javascriptLanguage:Ah,jsxLanguage:Qbe,localCompletionSource:lpt,scopeCompletionSource:fCn,snippets:Wbe,tsxLanguage:Ybe,typescriptLanguage:Gbe,typescriptSnippets:apt},Symbol.toStringTag,{value:"Module"})),dA=["_blank","_self","_top","_parent"],KY=["ascii","utf-8","utf-16","latin1","latin1"],JY=["get","post","put","delete"],eX=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],Bf=["true","false"],Xn={},yCn={a:{attrs:{href:null,ping:null,type:null,media:null,target:dA,hreflang:null}},abbr:Xn,address:Xn,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:Xn,aside:Xn,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:Xn,base:{attrs:{href:null,target:dA}},bdi:Xn,bdo:Xn,blockquote:{attrs:{cite:null}},body:Xn,br:Xn,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:eX,formmethod:JY,formnovalidate:["novalidate"],formtarget:dA,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:Xn,center:Xn,cite:Xn,code:Xn,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:Xn,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:Xn,div:Xn,dl:Xn,dt:Xn,em:Xn,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:Xn,figure:Xn,footer:Xn,form:{attrs:{action:null,name:null,"accept-charset":KY,autocomplete:["on","off"],enctype:eX,method:JY,novalidate:["novalidate"],target:dA}},h1:Xn,h2:Xn,h3:Xn,h4:Xn,h5:Xn,h6:Xn,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:Xn,hgroup:Xn,hr:Xn,html:{attrs:{manifest:null}},i:Xn,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:eX,formmethod:JY,formnovalidate:["novalidate"],formtarget:dA,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:Xn,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:Xn,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:Xn,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:KY,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:Xn,noscript:Xn,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:Xn,param:{attrs:{name:null,value:null}},pre:Xn,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:Xn,rt:Xn,ruby:Xn,samp:Xn,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:KY}},section:Xn,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:Xn,source:{attrs:{src:null,type:null,media:null}},span:Xn,strong:Xn,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:Xn,summary:Xn,sup:Xn,table:Xn,tbody:Xn,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:Xn,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:Xn,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:Xn,time:{attrs:{datetime:null}},title:Xn,tr:Xn,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:Xn,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:Xn},hpt={accesskey:null,class:null,contenteditable:Bf,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:Bf,autocorrect:Bf,autocapitalize:Bf,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":Bf,"aria-autocomplete":["inline","list","both","none"],"aria-busy":Bf,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":Bf,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":Bf,"aria-hidden":Bf,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":Bf,"aria-multiselectable":Bf,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":Bf,"aria-relevant":null,"aria-required":Bf,"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},mpt="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 mpt)hpt[e]=null;let LP=class{constructor(t,n){this.tags={...yCn,...t},this.globalAttrs={...hpt,...n},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}};LP.default=new LP;function Vj(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 Hj(e,t=!1){for(;e;e=e.parent)if(e.name=="Element")if(t)t=!1;else return e;return null}function gpt(e,t,n){let r=n.tags[Vj(e,Hj(t))];return r?.children||n.allTags}function Xbe(e,t){let n=[];for(let r=Hj(t);r&&!r.type.isTop;r=Hj(r.parent)){let s=Vj(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 vpt=/^[:\-\.\w\u00b7-\uffff]*$/;function FDe(e,t,n,r,s){let a=/\s*>/.test(e.sliceDoc(s,s+5))?"":">",i=Hj(n,n.name=="StartTag"||n.name=="TagName");return{from:r,to:s,options:gpt(e.doc,i,t).map(l=>({label:l,type:"type"})).concat(Xbe(e.doc,n).map((l,c)=>({label:"/"+l,apply:"/"+l+a,type:"type",boost:99-c}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function zDe(e,t,n,r){let s=/\s*>/.test(e.sliceDoc(r,r+5))?"":">";return{from:n,to:r,options:Xbe(e.doc,t).map((a,i)=>({label:a,apply:a+s,type:"type",boost:99-i})),validFor:vpt}}function bCn(e,t,n,r){let s=[],a=0;for(let i of gpt(e.doc,n,t))s.push({label:"<"+i,type:"type"});for(let i of Xbe(e.doc,n))s.push({label:"</"+i+">",type:"type",boost:99-a++});return{from:r,to:r,options:s,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function xCn(e,t,n,r,s){let a=Hj(n),i=a?t.tags[Vj(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:vpt}}function wCn(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=Hj(n),p=f?t.tags[Vj(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 ypt(e,t){let{state:n,pos:r}=t,s=pi(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)?zDe(n,s,s.from,r):FDe(n,e,s,s.from,r):s.name=="StartTag"||s.name=="IncompleteTag"?FDe(n,e,s,r,r):s.name=="StartCloseTag"||s.name=="IncompleteCloseTag"?zDe(n,s,r,r):s.name=="OpenTag"||s.name=="SelfClosingTag"||s.name=="AttributeName"?xCn(n,e,s,s.name=="AttributeName"?s.from:r,r):s.name=="Is"||s.name=="AttributeValue"||s.name=="UnquotedAttributeValue"?wCn(n,e,s,s.name=="Is"?r:s.from,r):t.explicit&&(a.name=="Element"||a.name=="Text"||a.name=="Document")?bCn(n,e,s,r):null}function SCn(e){return ypt(LP.default,e)}function kCn(e){let{extraTags:t,extraGlobalAttributes:n}=e,r=n||t?new LP(t,n):LP.default;return s=>ypt(r,s)}const OCn=Ah.parser.configure({top:"SingleExpression"}),bpt=[{tag:"script",attrs:e=>e.type=="text/typescript"||e.lang=="ts",parser:Gbe.parser},{tag:"script",attrs:e=>e.type=="text/babel"||e.type=="text/jsx",parser:Qbe.parser},{tag:"script",attrs:e=>e.type=="text/typescript-jsx",parser:Ybe.parser},{tag:"script",attrs(e){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(e.type)},parser:OCn},{tag:"script",attrs(e){return!e.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(e.type)},parser:Ah.parser},{tag:"style",attrs(e){return(!e.lang||e.lang=="css")&&(!e.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(e.type))},parser:JF.parser}],xpt=[{name:"style",parser:JF.parser.configure({top:"Styles"})}].concat(mpt.map(e=>({name:e,parser:Ah.parser}))),wpt=sO.define({name:"html",parser:QOn.configure({props:[f_.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}}),p_.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}}}),rft.add({"OpenTag CloseTag":e=>e.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),G8=wpt.configure({wrap:Kft(bpt,xpt)});function _Cn(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=Kft((e.nestedLanguages||[]).concat(bpt),(e.nestedAttributes||[]).concat(xpt)));let r=n?wpt.configure({wrap:n,dialect:t}):t?G8.configure({dialect:t}):G8;return new iO(r,[G8.data.of({autocomplete:kCn(e)}),e.autoCloseTags!==!1?CCn:[],tz().support,I_n().support])}const BDe=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),CCn=Nt.inputHandler.of((e,t,n,r,s)=>{if(e.composing||e.state.readOnly||t!=n||r!=">"&&r!="/"||!G8.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=pi(i).resolveInner(h,-1),g;if(p&&r==">"&&m.name=="EndTag"){let v=m.parent;if(((d=(u=v.parent)===null||u===void 0?void 0:u.lastChild)===null||d===void 0?void 0:d.name)!="CloseTag"&&(g=Vj(i.doc,v.parent,h))&&!BDe.has(g)){let b=h+(i.doc.sliceString(h,h+1)===">"?1:0),w=`</${g}>`;return{range:c,changes:{from:h,to:b,insert:w}}}}else if(p&&r=="/"&&m.name=="IncompleteCloseTag"){let v=m.parent;if(m.from==h-2&&((f=v.lastChild)===null||f===void 0?void 0:f.name)!="CloseTag"&&(g=Vj(i.doc,v,h))&&!BDe.has(g)){let b=h+(i.doc.sliceString(h,h+1)===">"?1:0),w=`${g}>`;return{range:vt.cursor(h+w.length,-1),changes:{from:h,to:b,insert:w}}}}return{range:c}});return l.changes.empty?!1:(e.dispatch([a,i.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),Spt=WU({commentTokens:{block:{open:"<!--",close:"-->"}}}),kpt=new Rr,Opt=Xkn.configure({props:[p_.add(e=>!e.is("Block")||e.is("Document")||Kde(e)!=null||ECn(e)?void 0:(t,n)=>({from:n.doc.lineAt(t.from).to,to:t.to})),kpt.add(Kde),f_.add({Document:()=>null}),nw.add({Document:Spt})]});function Kde(e){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(e.name);return t?+t[1]:void 0}function ECn(e){return e.name=="OrderedList"||e.name=="BulletList"}function jCn(e,t){let n=e;for(;;){let r=n.nextSibling,s;if(!r||(s=Kde(r.type))!=null&&s<=t)break;n=r}return n.to}const TCn=Hdt.of((e,t,n)=>{for(let r=pi(e).resolveInner(n,-1);r&&!(r.from<t);r=r.parent){let s=r.type.prop(kpt);if(s==null)continue;let a=jCn(r,s);if(a>n)return{from:n,to:a}}return null});function Kbe(e){return new dp(Spt,e,[],"markdown")}const _pt=Kbe(Opt),NCn=Opt.configure([lOn,uOn,cOn,dOn,{props:[p_.add({Table:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}]),cO=Kbe(NCn);function ICn(e,t){return n=>{if(n&&e){let r=null;if(n=/\S*/.exec(n)[0],typeof e=="function"?r=e(n):r=Mm.matchLanguageName(e,n,!0),r instanceof Mm)return r.support?r.support.language.parser:aO.getSkippingParser(r.load());if(r)return r.parser}return t?t.parser:null}}class tX{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(+Ept(this.item,t)[2]+n):"";return this.spaceBefore+r+this.type+this.spaceAfter}}function Cpt(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 tX(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 tX(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 tX(a.parent,c,c+d,i[1],u,f,a))}}return r}function Ept(e,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from,e.from+10))}function nX(e,t,n,r=0){for(let s=-1,a=e;;){if(a.name=="ListItem"){let l=Ept(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 Jbe(e,t){let n=/^[ \t]*/.exec(e)[0].length;if(!n||t.facet(cN)!=" ")return e;let r=ug(e,4,n),s="";for(let a=r;a>0;)a>=4?(s+=" ",a-=4):(s+=" ",a--);return s+e.slice(n)}const jpt=(e={})=>({state:t,dispatch:n})=>{let r=pi(t),{doc:s}=t,a=null,i=t.changeByRange(l=>{if(!l.empty||!cO.isActiveAt(t,l.from,-1)&&!cO.isActiveAt(t,l.from,1))return a={range:l};let c=l.from,u=s.lineAt(c),d=Cpt(r.resolveInner(c,-1),s);for(;d.length&&d[d.length-1].from>c-u.from;)d.pop();if(!d.length)return a={range:l};let f=d[d.length-1];if(f.to-f.spaceAfter.length>c-u.from)return a={range:l};let p=c>=f.to-f.spaceAfter.length&&!/\S/.test(u.text.slice(f.to));if(f.item&&p){let b=f.node.firstChild,w=f.node.getChild("ListItem","ListItem");if(b.to>=c||w&&w.to<c||u.from>0&&!/[^\s>]/.test(s.lineAt(u.from-1).text)||e.nonTightLists===!1){let S=d.length>1?d[d.length-2]:null,O,_="";S&&S.item?(O=u.from+S.from,_=S.marker(s,1)):O=u.from+(S?S.to:0);let C=[{from:O,to:c,insert:_}];return f.node.name=="OrderedList"&&nX(f.item,s,C,-2),S&&S.node.name=="OrderedList"&&nX(S.item,s,C),{range:vt.cursor(O+_.length),changes:C}}else{let S=qDe(d,t,u);return{range:vt.cursor(c+S.length+1),changes:{from:u.from,insert:S+t.lineBreak}}}}if(f.node.name=="Blockquote"&&p&&u.from){let b=s.lineAt(u.from-1),w=/>\s*$/.exec(b.text);if(w&&w.index==f.from){let S=t.changes([{from:b.from+w.index,to:b.to},{from:u.from+f.from,to:u.to}]);return{range:l.map(S),changes:S}}}let h=[];f.node.name=="OrderedList"&&nX(f.item,s,h);let m=f.item&&f.item.from<u.from,g="";if(!m||/^[\s\d.)\-+*>]*/.exec(u.text)[0].length>=f.to)for(let b=0,w=d.length-1;b<=w;b++)g+=b==w&&!m?d[b].marker(s,1):d[b].blank(b<w?ug(u.text,4,d[b+1].from)-g.length:null);let v=c;for(;v>u.from&&/\s/.test(u.text.charAt(v-u.from-1));)v--;return g=Jbe(g,t),ACn(f.node,t.doc)&&(g=qDe(d,t,u)+t.lineBreak+g),h.push({from:v,to:c,insert:t.lineBreak+g}),{range:vt.cursor(v+g.length+1),changes:h}});return a?!1:(n(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0)},Tpt=jpt();function UDe(e){return e.name=="QuoteMark"||e.name=="ListMark"}function ACn(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 qDe(e,t,n){let r="";for(let s=0,a=e.length-2;s<=a;s++)r+=e[s].blank(s<a?ug(n.text,4,e[s+1].from)-r.length:null,s<a);return Jbe(r,t)}function RCn(e,t){let n=e.resolveInner(t,-1),r=t;UDe(n)&&(r=n.from,n=n.parent);for(let s;s=n.childBefore(r);)if(UDe(s))r=s.from;else if(s.name=="OrderedList"||s.name=="BulletList")n=s.lastChild,r=n.to;else break;return n}const Npt=({state:e,dispatch:t})=>{let n=pi(e),r=null,s=e.changeByRange(a=>{let i=a.from,{doc:l}=e;if(a.empty&&cO.isActiveAt(e,a.from)){let c=l.lineAt(i),u=Cpt(RCn(n,i),l);if(u.length){let d=u[u.length-1],f=d.to-d.spaceAfter.length+(d.spaceAfter?1:0);if(i-c.from>f&&!/\S/.test(c.text.slice(f,i-c.from)))return{range:vt.cursor(c.from+f),changes:{from:c.from+f,to:i}};if(i-c.from==f&&(!d.item||c.from<=d.item.from||!/\S/.test(c.text.slice(0,d.to)))){let p=c.from+d.from;if(d.item&&d.node.from<d.item.from&&/\S/.test(c.text.slice(d.from,d.to))){let h=d.blank(ug(c.text,4,d.to)-ug(c.text,4,d.from));return p==c.from&&(h=Jbe(h,e)),{range:vt.cursor(p+h.length),changes:{from:p,to:c.from+d.to,insert:h}}}if(p<i)return{range:vt.cursor(p),changes:{from:p,to:i}}}}}return r={range:a}});return r?!1:(t(e.update(s,{scrollIntoView:!0,userEvent:"delete"})),!0)},Ipt=[{key:"Enter",run:Tpt},{key:"Backspace",run:Npt}],Apt=_Cn({matchClosingTags:!1});function exe(e={}){let{codeLanguages:t,defaultCodeLanguage:n,addKeymap:r=!0,base:{parser:s}=_pt,completeHTMLTags:a=!0,pasteURLAsLink:i=!0,htmlTagLanguage:l=Apt}=e;if(!(s instanceof YU))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let c=e.extensions?[e.extensions]:[],u=[l.support,TCn],d;i&&u.push(Rpt),n instanceof iO?(u.push(n.support),d=n.language):n&&(d=n);let f=t||d?ICn(t,d):void 0;c.push(Jkn({codeParser:f,htmlParser:l.language.parser})),r&&u.push(Sg.high(lN.of(Ipt)));let p=Kbe(s.configure(c));return a&&u.push(p.data.of({autocomplete:PCn})),new iO(p,u)}function PCn(e){let{state:t,pos:n}=e,r=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(n-25,n));if(!r)return null;let s=pi(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:$Cn(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}let rX=null;function $Cn(){if(rX)return rX;let e=SCn(new Nbe(is.create({extensions:Apt}),0,!0));return rX=e?e.options:[]}const MCn=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,Rpt=Nt.domEventHandlers({paste:(e,t)=>{var n;let{main:r}=t.state.selection;if(r.empty)return!1;let s=(n=e.clipboardData)===null||n===void 0?void 0:n.getData("text/plain");if(!s||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(s)||(/^www\./.test(s)&&(s="https://"+s),!cO.isActiveAt(t.state,r.from,1)))return!1;let a=pi(t.state),i=!1;return a.iterate({from:r.from,to:r.to,enter:l=>{(l.from>r.from||MCn.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)}}),DCn=Object.freeze(Object.defineProperty({__proto__:null,commonmarkLanguage:_pt,deleteMarkupBackward:Npt,insertNewlineContinueMarkup:Tpt,insertNewlineContinueMarkupCommand:jpt,markdown:exe,markdownKeymap:Ipt,markdownLanguage:cO,pasteURLAsLink:Rpt},Symbol.toStringTag,{value:"Module"}));function uO(){return uO=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},uO.apply(null,arguments)}var LCn=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=Nt.theme(i,{dark:t==="dark"}),d=kg.define(a),f=[u,w1(d)];return f},FCn={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)"},zCn=[{tag:de.comment,color:"#6272a4"},{tag:de.string,color:"#f1fa8c"},{tag:de.atom,color:"#bd93f9"},{tag:de.meta,color:"#f8f8f2"},{tag:[de.keyword,de.operator,de.tagName],color:"#ff79c6"},{tag:[de.function(de.propertyName),de.propertyName],color:"#66d9ef"},{tag:[de.definition(de.variableName),de.function(de.variableName),de.className,de.attributeName],color:"#50fa7b"},{tag:de.atom,color:"#bd93f9"}],dN=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 LCn({theme:r,settings:uO({},FCn,a),styles:[...zCn,...l]})};dN();function Ppt(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 BCn=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=nxe(e.state,n.from);return r.line?UCn(e):r.block?VCn(e):!1};function txe(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 UCn=txe(ZCn,0),qCn=txe($pt,0),VCn=txe((e,t)=>$pt(e,t,WCn(t)),0);function nxe(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const fA=50;function HCn(e,{open:t,close:n},r,s){let a=e.sliceDoc(r-fA,r),i=e.sliceDoc(s,s+fA),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*fA?d=f=e.sliceDoc(r,s):(d=e.sliceDoc(r,r+fA),f=e.sliceDoc(s-fA,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 WCn(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 $pt(e,t,n=t.selection.ranges){let r=n.map(a=>nxe(t,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,i)=>HCn(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 ZCn(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=nxe(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 Jde=fy.define(),GCn=fy.define(),QCn=Sn.define(),Mpt=Sn.define({combine(e){return py(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)})}}),Dpt=ul.define({create(){return wv.empty},update(e,t){let n=t.state.facet(Mpt),r=t.annotation(Jde);if(r){let c=Vd.fromTransaction(t,r.selection),u=r.side,d=u==0?e.undone:e.done;return c?d=nz(d,d.length,n.minDepth,c):d=zpt(d,t.startState.selection),new wv(u==0?r.rest:d,u==0?d:r.rest)}let s=t.annotation(GCn);if((s=="full"||s=="before")&&(e=e.isolate()),t.annotation(kl.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=Vd.fromTransaction(t),i=t.annotation(kl.time),l=t.annotation(kl.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 wv(e.done.map(Vd.fromJSON),e.undone.map(Vd.fromJSON))}});function YCn(e={}){return[Dpt,Mpt.of(e),Nt.domEventHandlers({beforeinput(t,n){let r=t.inputType=="historyUndo"?Lpt:t.inputType=="historyRedo"?efe:null;return r?(t.preventDefault(),r(n)):!1}})]}function XU(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let s=n.field(Dpt,!1);if(!s)return!1;let a=s.pop(e,n,t);return a?(r(a),!0):!1}}const Lpt=XU(0,!1),efe=XU(1,!1),XCn=XU(0,!0),KCn=XU(1,!0);class Vd{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 Vd(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 Vd(t.changes&&wl.fromJSON(t.changes),[],t.mapped&&Pv.fromJSON(t.mapped),t.startSelection&&vt.fromJSON(t.startSelection),t.selectionsAfter.map(vt.fromJSON))}static fromTransaction(t,n){let r=kh;for(let s of t.startState.facet(QCn)){let a=s(t);a.length&&(r=r.concat(a))}return!r.length&&t.changes.empty?null:new Vd(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,kh)}static selection(t){return new Vd(void 0,kh,void 0,void 0,t)}}function nz(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 JCn(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 eEn(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function Fpt(e,t){return e.length?t.length?e.concat(t):e:t}const kh=[],tEn=200;function zpt(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-tEn));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),nz(e,e.length-1,1e9,n.setSelAfter(r)))}else return[Vd.selection([t])]}function nEn(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 sX(e,t){if(!e.length)return e;let n=e.length,r=kh;for(;n;){let s=rEn(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?[Vd.selection(r)]:kh}function rEn(e,t,n){let r=Fpt(e.selectionsAfter.length?e.selectionsAfter.map(l=>l.map(t)):kh,n);if(!e.changes)return Vd.selection(r);let s=e.changes.map(t),a=t.mapDesc(e.changes,!0),i=e.mapped?e.mapped.composeDesc(a):a;return new Vd(s,gr.mapEffects(e.effects,t),i,e.startSelection.map(a),r)}const sEn=/^(input\.type|delete)($|\.)/;class wv{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 wv(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||sEn.test(r))&&(!l.selectionsAfter.length&&n-this.prevTime<s.newGroupDelay&&s.joinToEvent(a,JCn(l.changes,t.changes))||r=="input.type.compose")?i=nz(i,i.length-1,s.minDepth,new Vd(t.changes.compose(l.changes),Fpt(gr.mapEffects(t.effects,l.changes),l.effects),l.mapped,l.startSelection,kh)):i=nz(i,i.length,s.minDepth,t),new wv(i,kh,n,r)}addSelection(t,n,r,s){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:kh;return a.length>0&&n-this.prevTime<s&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&eEn(a[a.length-1],t)?this:new wv(zpt(this.done,t),this.undone,n,r)}addMapping(t){return new wv(sX(this.done,t),sX(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:Jde.of({side:t,rest:nEn(s),selection:i}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(a.changes){let l=s.length==1?kh:s.slice(0,s.length-1);return a.mapped&&(l=sX(l,a.mapped)),n.update({changes:a.changes,selection:a.startSelection,effects:a.effects,annotations:Jde.of({side:t,rest:l,selection:i}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}wv.empty=new wv(kh,kh);const aEn=[{key:"Mod-z",run:Lpt,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:efe,preventDefault:!0},{linux:"Ctrl-Shift-z",run:efe,preventDefault:!0},{key:"Mod-u",run:XCn,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:KCn,preventDefault:!0}];function fN(e,t){return vt.create(e.ranges.map(t),e.mainIndex)}function Og(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function _g({state:e,dispatch:t},n){let r=fN(e.selection,n);return r.eq(e.selection,!0)?!1:(t(Og(e,r)),!0)}function KU(e,t){return vt.cursor(t?e.to:e.from)}function Bpt(e,t){return _g(e,n=>n.empty?e.moveByChar(n,t):KU(n,t))}function ju(e){return e.textDirectionAt(e.state.selection.main.head)==xi.LTR}const Upt=e=>Bpt(e,!ju(e)),qpt=e=>Bpt(e,ju(e));function Vpt(e,t){return _g(e,n=>n.empty?e.moveByGroup(n,t):KU(n,t))}const iEn=e=>Vpt(e,!ju(e)),oEn=e=>Vpt(e,ju(e));function lEn(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 JU(e,t,n){let r=pi(e).resolveInner(t.head),s=n?Rr.closedBy:Rr.openedBy;for(let c=t.head;;){let u=n?r.childAfter(c):r.childBefore(c);if(!u)break;lEn(e,u,s)?r=u:c=n?u.to:u.from}let a=r.type.prop(s),i,l;return a&&(i=n?xv(e,r.from,1):xv(e,r.to,-1))&&i.matched?l=n?i.end.to:i.end.from:l=n?r.to:r.from,vt.cursor(l,n?-1:1)}const cEn=e=>_g(e,t=>JU(e.state,t,!ju(e))),uEn=e=>_g(e,t=>JU(e.state,t,ju(e)));function Hpt(e,t){return _g(e,n=>{if(!n.empty)return KU(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}const Wpt=e=>Hpt(e,!1),Zpt=e=>Hpt(e,!0);function Gpt(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,s;if(t){for(let a of e.state.facet(Nt.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 Qpt(e,t){let n=Gpt(e),{state:r}=e,s=fN(r.selection,i=>i.empty?e.moveVertically(i,t,n.height):KU(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=Nt.scrollIntoView(s.main.head,{y:"start",yMargin:i.top-c}))}return e.dispatch(Og(r,s),{effects:a}),!0}const VDe=e=>Qpt(e,!1),tfe=e=>Qpt(e,!0);function S1(e,t,n){let r=e.lineBlockAt(t.head),s=e.moveToLineBoundary(t,n);if(s.head==t.head&&s.head!=(n?r.to:r.from)&&(s=e.moveToLineBoundary(t,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&t.head!=r.from+a&&(s=vt.cursor(r.from+a))}return s}const dEn=e=>_g(e,t=>S1(e,t,!0)),fEn=e=>_g(e,t=>S1(e,t,!1)),pEn=e=>_g(e,t=>S1(e,t,!ju(e))),hEn=e=>_g(e,t=>S1(e,t,ju(e))),mEn=e=>_g(e,t=>vt.cursor(e.lineBlockAt(t.head).from,1)),gEn=e=>_g(e,t=>vt.cursor(e.lineBlockAt(t.head).to,-1));function vEn(e,t,n){let r=!1,s=fN(e.selection,a=>{let i=xv(e,a.head,-1)||xv(e,a.head,1)||a.head>0&&xv(e,a.head-1,1)||a.head<e.doc.length&&xv(e,a.head+1,-1);if(!i||!i.end)return a;r=!0;let l=i.start.from==a.head?i.end.to:i.end.from;return vt.cursor(l)});return r?(t(Og(e,s)),!0):!1}const yEn=({state:e,dispatch:t})=>vEn(e,t);function rm(e,t){let n=fN(e.state.selection,r=>{let s=t(r);return vt.range(r.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(Og(e.state,n)),!0)}function Ypt(e,t){return rm(e,n=>e.moveByChar(n,t))}const Xpt=e=>Ypt(e,!ju(e)),Kpt=e=>Ypt(e,ju(e));function Jpt(e,t){return rm(e,n=>e.moveByGroup(n,t))}const bEn=e=>Jpt(e,!ju(e)),xEn=e=>Jpt(e,ju(e)),wEn=e=>rm(e,t=>JU(e.state,t,!ju(e))),SEn=e=>rm(e,t=>JU(e.state,t,ju(e)));function eht(e,t){return rm(e,n=>e.moveVertically(n,t))}const tht=e=>eht(e,!1),nht=e=>eht(e,!0);function rht(e,t){return rm(e,n=>e.moveVertically(n,t,Gpt(e).height))}const HDe=e=>rht(e,!1),WDe=e=>rht(e,!0),kEn=e=>rm(e,t=>S1(e,t,!0)),OEn=e=>rm(e,t=>S1(e,t,!1)),_En=e=>rm(e,t=>S1(e,t,!ju(e))),CEn=e=>rm(e,t=>S1(e,t,ju(e))),EEn=e=>rm(e,t=>vt.cursor(e.lineBlockAt(t.head).from)),jEn=e=>rm(e,t=>vt.cursor(e.lineBlockAt(t.head).to)),ZDe=({state:e,dispatch:t})=>(t(Og(e,{anchor:0})),!0),GDe=({state:e,dispatch:t})=>(t(Og(e,{anchor:e.doc.length})),!0),QDe=({state:e,dispatch:t})=>(t(Og(e,{anchor:e.selection.main.anchor,head:0})),!0),YDe=({state:e,dispatch:t})=>(t(Og(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),TEn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),NEn=({state:e,dispatch:t})=>{let n=eq(e).map(({from:r,to:s})=>vt.range(r,Math.min(s+1,e.doc.length)));return t(e.update({selection:vt.create(n),userEvent:"select"})),!0},IEn=({state:e,dispatch:t})=>{let n=fN(e.selection,r=>{let s=pi(e),a=s.resolveStack(r.from,1);if(r.empty){let i=s.resolveStack(r.from,-1);i.node.from>=a.node.from&&i.node.to<=a.node.to&&(a=i)}for(let i=a;i;i=i.next){let{node:l}=i;if((l.from<r.from&&l.to>=r.to||l.to>r.to&&l.from<=r.from)&&i.next)return vt.range(l.to,l.from)}return r});return n.eq(e.selection)?!1:(t(Og(e,n)),!0)};function sht(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(Og(n,vt.create(s,s.length-1))),!0)}const AEn=e=>sht(e,!1),REn=e=>sht(e,!0),PEn=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=vt.create([n.main]):n.main.empty||(r=vt.create([vt.cursor(n.main.head)])),r?(t(Og(e,r)),!0):!1};function o3(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=vL(e,c,!1)):c>i&&(n="delete.forward",c=vL(e,c,!0)),i=Math.min(i,c),l=Math.max(l,c)}else i=vL(e,i,!1),l=vL(e,l,!0);return i==l?{range:a}:{changes:{from:i,to:l},range:vt.cursor(i,i<a.head?-1:1)}});return s.changes.empty?!1:(e.dispatch(r.update(s,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?Nt.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function vL(e,t,n){if(e instanceof Nt)for(let r of e.state.facet(Nt.atomicRanges).map(s=>s(e)))r.between(t,t,(s,a)=>{s<t&&a>t&&(t=n?a:s)});return t}const aht=(e,t,n)=>o3(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=ug(l,a.tabSize),d=u%oO(a)||oO(a);for(let f=0;f<d&&l[l.length-1-f]==" ";f++)s--;c=s}else c=lc(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=lc(i.text,c-i.from,!1,!1)+i.from);return c}),nfe=e=>aht(e,!1,!0),iht=e=>aht(e,!0,!1),oht=(e,t)=>o3(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=lc(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}),lht=e=>oht(e,!1),$En=e=>oht(e,!0),MEn=e=>o3(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),DEn=e=>o3(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),LEn=e=>o3(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),FEn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:va.of(["",""])},range:vt.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},zEn=({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:lc(a.text,s-a.from,!1)+a.from,l=s==a.to?s+1:lc(a.text,s-a.from,!0)+a.from;return{changes:{from:i,to:l,insert:e.doc.slice(s,l).append(e.doc.slice(i,s))},range:vt.cursor(l)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function eq(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 cht(e,t,n){if(e.readOnly)return!1;let r=[],s=[];for(let a of eq(e)){if(n?a.to==e.doc.length:a.from==0)continue;let i=e.doc.lineAt(n?a.to+1:a.from-1),l=i.length+1;if(n){r.push({from:a.to,to:i.to},{from:a.from,insert:i.text+e.lineBreak});for(let c of a.ranges)s.push(vt.range(Math.min(e.doc.length,c.anchor+l),Math.min(e.doc.length,c.head+l)))}else{r.push({from:i.from,to:a.from},{from:a.to,insert:e.lineBreak+i.text});for(let c of a.ranges)s.push(vt.range(c.anchor-l,c.head-l))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:vt.create(s,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}const BEn=({state:e,dispatch:t})=>cht(e,t,!1),UEn=({state:e,dispatch:t})=>cht(e,t,!0);function uht(e,t,n){if(e.readOnly)return!1;let r=[];for(let a of eq(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 qEn=({state:e,dispatch:t})=>uht(e,t,!1),VEn=({state:e,dispatch:t})=>uht(e,t,!0),HEn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(eq(t).map(({from:s,to:a})=>(s>0?s--:a<t.doc.length&&a++,{from:s,to:a}))),r=fN(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 WEn(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=pi(e).resolveInner(t),r=n.childBefore(t),s=n.childAfter(t),a;return r&&s&&r.to<=t&&s.from>=t&&(a=r.type.prop(Rr.closedBy))&&a.indexOf(s.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(s.from).from&&!/\S/.test(e.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const XDe=dht(!1),ZEn=dht(!0);function dht(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&&WEn(t,a);e&&(a=i=(i<=l.to?l:t.doc.lineAt(i)).to);let u=new ZU(t,{simulateBreak:a,simulateDoubleBreak:!!c}),d=Obe(u,a);for(d==null&&(d=ug(/^\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=["",NP(t,d)];return c&&f.push(NP(t,u.lineIndent(l.from,-1))),{changes:{from:a,to:i,insert:va.of(f)},range:vt.cursor(a+1+f[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function rxe(e,t){let n=-1;return e.changeByRange(r=>{let s=[];for(let i=r.from;i<=r.to;){let l=e.doc.lineAt(i);l.number>n&&(r.empty||r.to>l.from)&&(t(l,s,r),n=l.number),i=l.to+1}let a=e.changes(s);return{changes:s,range:vt.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const GEn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new ZU(e,{overrideIndentation:a=>{let i=n[a];return i??-1}}),s=rxe(e,(a,i,l)=>{let c=Obe(r,a.from);if(c==null)return;/\S/.test(a.text)||(c=0);let u=/^\s*/.exec(a.text)[0],d=NP(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},fht=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(rxe(e,(n,r)=>{r.push({from:n.from,insert:e.facet(cN)})}),{userEvent:"input.indent"})),!0),pht=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(rxe(e,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=ug(s,e.tabSize),i=0,l=NP(e,Math.max(0,a-oO(e)));for(;i<s.length&&i<l.length&&s.charCodeAt(i)==l.charCodeAt(i);)i++;r.push({from:n.from+i,to:n.from+s.length,insert:l.slice(i)})}),{userEvent:"delete.dedent"})),!0),QEn=e=>(e.setTabFocusMode(),!0),YEn=[{key:"Ctrl-b",run:Upt,shift:Xpt,preventDefault:!0},{key:"Ctrl-f",run:qpt,shift:Kpt},{key:"Ctrl-p",run:Wpt,shift:tht},{key:"Ctrl-n",run:Zpt,shift:nht},{key:"Ctrl-a",run:mEn,shift:EEn},{key:"Ctrl-e",run:gEn,shift:jEn},{key:"Ctrl-d",run:iht},{key:"Ctrl-h",run:nfe},{key:"Ctrl-k",run:MEn},{key:"Ctrl-Alt-h",run:lht},{key:"Ctrl-o",run:FEn},{key:"Ctrl-t",run:zEn},{key:"Ctrl-v",run:tfe}],XEn=[{key:"ArrowLeft",run:Upt,shift:Xpt,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:iEn,shift:bEn,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:pEn,shift:_En,preventDefault:!0},{key:"ArrowRight",run:qpt,shift:Kpt,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:oEn,shift:xEn,preventDefault:!0},{mac:"Cmd-ArrowRight",run:hEn,shift:CEn,preventDefault:!0},{key:"ArrowUp",run:Wpt,shift:tht,preventDefault:!0},{mac:"Cmd-ArrowUp",run:ZDe,shift:QDe},{mac:"Ctrl-ArrowUp",run:VDe,shift:HDe},{key:"ArrowDown",run:Zpt,shift:nht,preventDefault:!0},{mac:"Cmd-ArrowDown",run:GDe,shift:YDe},{mac:"Ctrl-ArrowDown",run:tfe,shift:WDe},{key:"PageUp",run:VDe,shift:HDe},{key:"PageDown",run:tfe,shift:WDe},{key:"Home",run:fEn,shift:OEn,preventDefault:!0},{key:"Mod-Home",run:ZDe,shift:QDe},{key:"End",run:dEn,shift:kEn,preventDefault:!0},{key:"Mod-End",run:GDe,shift:YDe},{key:"Enter",run:XDe,shift:XDe},{key:"Mod-a",run:TEn},{key:"Backspace",run:nfe,shift:nfe,preventDefault:!0},{key:"Delete",run:iht,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:lht,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:$En,preventDefault:!0},{mac:"Mod-Backspace",run:DEn,preventDefault:!0},{mac:"Mod-Delete",run:LEn,preventDefault:!0}].concat(YEn.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),KEn=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:cEn,shift:wEn},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:uEn,shift:SEn},{key:"Alt-ArrowUp",run:BEn},{key:"Shift-Alt-ArrowUp",run:qEn},{key:"Alt-ArrowDown",run:UEn},{key:"Shift-Alt-ArrowDown",run:VEn},{key:"Mod-Alt-ArrowUp",run:AEn},{key:"Mod-Alt-ArrowDown",run:REn},{key:"Escape",run:PEn},{key:"Mod-Enter",run:ZEn},{key:"Alt-l",mac:"Ctrl-l",run:NEn},{key:"Mod-i",run:IEn,preventDefault:!0},{key:"Mod-[",run:pht},{key:"Mod-]",run:fht},{key:"Mod-Alt-\\",run:GEn},{key:"Shift-Mod-k",run:HEn},{key:"Shift-Mod-\\",run:yEn},{key:"Mod-/",run:BCn},{key:"Alt-A",run:qCn},{key:"Ctrl-m",mac:"Shift-Alt-m",run:QEn}].concat(XEn),JEn={key:"Tab",run:fht,shift:pht},KDe=typeof String.prototype.normalize=="function"?e=>e.normalize("NFKD"):e=>e;class ex{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(KDe(l)):KDe,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 Md(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=abe(t),r=this.bufferStart+this.bufferPos;this.bufferPos+=cv(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"&&(ex.prototype[Symbol.iterator]=function(){return this});const hht={from:-1,to:-1,match:/.*/.exec(""),precise:!0},sxe="gm"+(/x/.unicode==null?"":"u");class mht{constructor(t,n,r,s=0,a=t.length){if(this.text=t,this.to=a,this.curLine="",this.done=!1,this.value=hht,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new ght(t,n,r,s,a);this.re=new RegExp(n,sxe+(r?.ignoreCase?"i":"")),this.test=r?.test,this.iter=t.iter();let i=t.lineAt(s);this.curLineStart=i.from,this.matchPos=rz(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=rz(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 aX=new WeakMap;class nj{constructor(t,n){this.from=t,this.text=n}get to(){return this.from+this.text.length}static get(t,n,r){let s=aX.get(t);if(!s||s.from>=r||s.to<=n){let l=new nj(n,t.sliceString(n,r));return aX.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)),aX.set(t,new nj(i,a)),new nj(n,a.slice(n-i,r-i))}}class ght{constructor(t,n,r,s,a){this.text=t,this.to=a,this.done=!1,this.value=hht,this.matchPos=rz(t,s),this.re=new RegExp(n,sxe+(r?.ignoreCase?"i":"")),this.test=r?.test,this.flat=nj.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=rz(this.text,s+(r==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=nj.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(mht.prototype[Symbol.iterator]=ght.prototype[Symbol.iterator]=function(){return this});function ejn(e){try{return new RegExp(e,sxe),!0}catch{return!1}}function rz(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 tjn=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:s}=M1n(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 v=h/100;c&&(v=v*(c=="-"?-1:1)+l.number/t.doc.lines),h=Math.round(t.doc.lines*v)}else u&&c&&(h=h*(c=="-"?-1:1)+l.number);let m=t.doc.line(Math.max(1,Math.min(t.doc.lines,h))),g=vt.cursor(m.from+Math.max(0,Math.min(p,m.length)));e.dispatch({effects:[r,Nt.scrollIntoView(g.from,{y:"center"})],selection:g})}),!0},njn={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},rjn=Sn.define({combine(e){return py(e,njn,{highlightWordAroundCursor:(t,n)=>t||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function sjn(e){return[cjn,ljn]}const ajn=Cn.mark({class:"cm-selectionMatch"}),ijn=Cn.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function JDe(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=oo.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=oo.Word)}function ojn(e,t,n,r){return e(t.sliceDoc(n,n+1))==oo.Word&&e(t.sliceDoc(r-1,r))==oo.Word}const ljn=po.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(rjn),{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),!(JDe(i,n,s.from,s.to)&&ojn(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 ex(n.doc,a,c.from,c.to);for(;!u.next().done;){let{from:d,to:f}=u.value;if((!i||JDe(i,n,d,f))&&(s.empty&&d<=s.from&&f>=s.to?l.push(ijn.range(d,f)):(d>=s.to||f<=s.from)&&l.push(ajn.range(d,f)),l.length>t.maxMatches))return Cn.none}}return Cn.set(l)}},{decorations:e=>e.decorations}),cjn=Nt.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),ujn=({state:e,dispatch:t})=>{let{selection:n}=e,r=vt.create(n.ranges.map(s=>e.wordAt(s.head)||vt.cursor(s.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function djn(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 ex(e.doc,t,r[r.length-1].to);;)if(l.next(),l.done){if(i)return null;l=new ex(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 fjn=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(a=>a.from===a.to))return ujn({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=djn(e,r);return s?(t(e.update({selection:e.selection.addRange(vt.range(s.from,s.to),!1),effects:Nt.scrollIntoView(s.to)})),!0):!1},pN=Sn.define({combine(e){return py(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new Cjn(t),scrollToMatch:t=>Nt.scrollIntoView(t)})}});class vht{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||ejn(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"?`
|
|
226
|
-
`: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 yjn(this):new mjn(this)}getCursor(t,n=0,r){let s=t.doc?t:is.create({doc:t});return r==null&&(r=s.doc.length),this.regexp?sE(this,s,n,r):rE(this,s,n,r)}}class yht{constructor(t){this.spec=t}}function pjn(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 rE(e,t,n,r){let s;return e.wholeWord&&(s=hjn(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(s=pjn(e.test,t,s)),new ex(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:a=>a.toLowerCase(),s)}function hjn(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(sz(s,n-a))!=oo.Word||t(az(s,n-a))!=oo.Word)&&(t(az(s,r-a))!=oo.Word||t(sz(s,r-a))!=oo.Word))}class mjn extends yht{constructor(t){super(t)}nextMatch(t,n,r){let s=rE(this.spec,t,r,t.doc.length).nextOverlapping();if(s.done){let a=Math.min(t.doc.length,n+this.spec.unquoted.length);s=rE(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=rE(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=rE(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=rE(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 gjn(e,t,n){return(r,s,a)=>(!n||n(r,s,a))&&e(a[0],t,r,s)}function sE(e,t,n,r){let s;return e.wholeWord&&(s=vjn(t.charCategorizer(t.selection.main.head))),e.test&&(s=gjn(e.test,t,s)),new mht(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:s},n,r)}function sz(e,t){return e.slice(lc(e,t,!1),t)}function az(e,t){return e.slice(t,lc(e,t))}function vjn(e){return(t,n,r)=>!r[0].length||(e(sz(r.input,r.index))!=oo.Word||e(az(r.input,r.index))!=oo.Word)&&(e(az(r.input,r.index+r[0].length))!=oo.Word||e(sz(r.input,r.index+r[0].length))!=oo.Word)}class yjn extends yht{nextMatch(t,n,r){let s=sE(this.spec,t,r,t.doc.length).next();return s.done&&(s=sE(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=sE(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=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-250),Math.min(r+250,t.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}const FP=gr.define(),axe=gr.define(),yw=ul.define({create(e){return new iX(rfe(e).create(),null)},update(e,t){for(let n of t.effects)n.is(FP)?e=new iX(n.value.create(),e.panel):n.is(axe)&&(e=new iX(e.query,n.value?ixe:null));return e},provide:e=>TP.from(e,t=>t.panel)});class iX{constructor(t,n){this.query=t,this.panel=n}}const bjn=Cn.mark({class:"cm-searchMatch"}),xjn=Cn.mark({class:"cm-searchMatch cm-searchMatch-selected"}),wjn=po.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(yw))}update(e){let t=e.state.field(yw);(t!=e.startState.field(yw)||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 ud;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?xjn:bjn)})}return r.finish()}},{decorations:e=>e.decorations});function l3(e){return t=>{let n=t.state.field(yw,!1);return n&&n.query.spec.valid?e(t,n):wht(t)}}const iz=l3((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let s=vt.single(r.from,r.to),a=e.state.facet(pN);return e.dispatch({selection:s,effects:[oxe(e,r),a.scrollToMatch(s.main,e)],userEvent:"select.search"}),xht(e),!0}),oz=l3((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,s=t.prevMatch(n,r,r);if(!s)return!1;let a=vt.single(s.from,s.to),i=e.state.facet(pN);return e.dispatch({selection:a,effects:[oxe(e,s),i.scrollToMatch(a.main,e)],userEvent:"select.search"}),xht(e),!0}),Sjn=l3((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:vt.create(n.map(r=>vt.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),kjn=({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 ex(e.doc,e.sliceDoc(r,s));!l.next().done;){if(a.length>1e3)return!1;l.value.from==r&&(i=a.length),a.push(vt.range(l.value.from,l.value.to))}return t(e.update({selection:vt.create(a,i),userEvent:"select.search.matches"})),!0},e4e=l3((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(Nt.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."))):i=t.nextMatch(n,i.from,i.to);let f=e.state.changes(l);return i&&(c=vt.single(i.from,i.to).map(f),d.push(oxe(e,i)),d.push(n.facet(pN).scrollToMatch(c.main,e))),e.dispatch({changes:f,selection:c,effects:d,userEvent:"input.replace"}),!0}),Ojn=l3((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:Nt.announce.of(r),userEvent:"input.replace.all"}),!0});function ixe(e){return e.state.facet(pN).createPanel(e)}function rfe(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(pN);return new vht({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 bht(e){let t=Sbe(e,ixe);return t&&t.dom.querySelector("[main-field]")}function xht(e){let t=bht(e);t&&t==e.root.activeElement&&t.select()}const wht=e=>{let t=e.state.field(yw,!1);if(t&&t.panel){let n=bht(e);if(n&&n!=e.root.activeElement){let r=rfe(e.state,t.query.spec);r.valid&&e.dispatch({effects:FP.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[axe.of(!0),t?FP.of(rfe(e.state,t.query.spec)):gr.appendConfig.of(jjn)]});return!0},Sht=e=>{let t=e.state.field(yw,!1);if(!t||!t.panel)return!1;let n=Sbe(e,ixe);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:axe.of(!1)}),!0},_jn=[{key:"Mod-f",run:wht,scope:"editor search-panel"},{key:"F3",run:iz,shift:oz,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:iz,shift:oz,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Sht,scope:"editor search-panel"},{key:"Mod-Shift-l",run:kjn},{key:"Mod-Alt-g",run:tjn},{key:"Mod-d",run:fjn,preventDefault:!0}];class Cjn{constructor(t){this.view=t;let n=this.query=t.state.field(yw).query.spec;this.commit=this.commit.bind(this),this.searchField=oi("input",{value:n.search,placeholder:Uf(t,"Find"),"aria-label":Uf(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=oi("input",{value:n.replace,placeholder:Uf(t,"Replace"),"aria-label":Uf(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=oi("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=oi("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=oi("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(s,a,i){return oi("button",{class:"cm-button",name:s,onclick:a,type:"button"},i)}this.dom=oi("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,r("next",()=>iz(t),[Uf(t,"next")]),r("prev",()=>oz(t),[Uf(t,"previous")]),r("select",()=>Sjn(t),[Uf(t,"all")]),oi("label",null,[this.caseField,Uf(t,"match case")]),oi("label",null,[this.reField,Uf(t,"regexp")]),oi("label",null,[this.wordField,Uf(t,"by word")]),...t.state.readOnly?[]:[oi("br"),this.replaceField,r("replace",()=>e4e(t),[Uf(t,"replace")]),r("replaceAll",()=>Ojn(t),[Uf(t,"replace all")])],oi("button",{name:"close",onclick:()=>Sht(t),"aria-label":Uf(t,"close"),type:"button"},["×"])])}commit(){let t=new vht({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:FP.of(t)}))}keydown(t){Wwn(this.view,t,"search-panel")?t.preventDefault():t.keyCode==13&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?oz:iz)(this.view)):t.keyCode==13&&t.target==this.replaceField&&(t.preventDefault(),e4e(this.view))}update(t){for(let n of t.transactions)for(let r of n.effects)r.is(FP)&&!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(pN).top}}function Uf(e,t){return e.state.phrase(t)}const yL=30,bL=/[\s\.,:;?!]/;function oxe(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-yL),i=Math.min(s,n+yL),l=e.state.sliceDoc(a,i);if(a!=r.from){for(let c=0;c<yL;c++)if(!bL.test(l[c+1])&&bL.test(l[c])){l=l.slice(c);break}}if(i!=s){for(let c=l.length-1;c>l.length-yL;c--)if(!bL.test(l[c-1])&&bL.test(l[c])){l=l.slice(0,c);break}}return Nt.announce.of(`${e.state.phrase("current match")}. ${l} ${e.state.phrase("on line")} ${r.number}.`)}const Ejn=Nt.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"}}),jjn=[yw,Sg.low(wjn),Ejn];class t4e{constructor(t,n,r){this.from=t,this.to=n,this.diagnostic=r}}class KS{constructor(t,n,r){this.diagnostics=t,this.panel=n,this.selected=r}static init(t,n,r){let s=r.facet(zP).markerFilter;s&&(t=s(t,r));let a=t.slice().sort((d,f)=>d.from-f.from||d.to-f.to),i=new ud,l=[],c=0;for(let d=0;;){let f=d==a.length?null:a[d];if(!f&&!l.length)break;let p,h;for(l.length?(p=c,h=l.reduce((g,v)=>Math.min(g,v.to),f&&f.from>p?f.from:1e8)):(p=f.from,h=f.to,l.push(f),d++);d<a.length;){let g=a[d];if(g.from==p&&(g.to>g.from||g.to==p))l.push(g),d++,h=Math.min(g.to,h);else{h=Math.min(g.from,h);break}}let m=Bjn(l);if(l.some(g=>g.from==g.to||g.from==g.to-1&&r.doc.lineAt(g.from).to==g.from))i.add(p,p,Cn.widget({widget:new Djn(m),diagnostics:l.slice()}));else{let g=l.reduce((v,b)=>b.markClass?v+" "+b.markClass:v,"");i.add(p,h,Cn.mark({class:"cm-lintRange cm-lintRange-"+m+g,diagnostics:l.slice(),inclusiveEnd:l.some(v=>v.to>h)}))}c=h;for(let g=0;g<l.length;g++)l[g].to<=c&&l.splice(g--,1)}let u=i.finish();return new KS(u,n,Wj(u))}}function Wj(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 t4e(s,a,t||i.diagnostics[0]);else{if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new t4e(r.from,a,r.diagnostic)}}),r}function Tjn(e,t){let n=t.pos,r=t.end||n,s=e.state.facet(zP).hideOn(e,n,r);if(s!=null)return s;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(i=>i.is(kht))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function Njn(e,t){return e.field(fp,!1)?t:t.concat(gr.appendConfig.of(Ujn))}const kht=gr.define(),lxe=gr.define(),Oht=gr.define(),fp=ul.define({create(){return new KS(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=Wj(n,e.selected.diagnostic,a)||Wj(n,null,a)}!n.size&&s&&t.state.facet(zP).autoPanel&&(s=null),e=new KS(n,s,r)}for(let n of t.effects)if(n.is(kht)){let r=t.state.facet(zP).autoPanel?n.value.length?BP.open:null:e.panel;e=KS.init(n.value,r,t.state)}else n.is(lxe)?e=new KS(e.diagnostics,n.value?BP.open:null,e.selected):n.is(Oht)&&(e=new KS(e.diagnostics,e.panel,n.value));return e},provide:e=>[TP.from(e,t=>t.panel),Nt.decorations.from(e,t=>t.diagnostics)]}),Ijn=Cn.mark({class:"cm-lintRange cm-lintRange-active"});function Ajn(e,t,n){let{diagnostics:r}=e.state.field(fp),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(zP).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:Rjn(e,s)}}}:null}function Rjn(e,t){return oi("ul",{class:"cm-tooltip-lint"},t.map(n=>Cht(e,n,!1)))}const Pjn=e=>{let t=e.state.field(fp,!1);(!t||!t.panel)&&e.dispatch({effects:Njn(e.state,[lxe.of(!0)])});let n=Sbe(e,BP.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},n4e=e=>{let t=e.state.field(fp,!1);return!t||!t.panel?!1:(e.dispatch({effects:lxe.of(!1)}),!0)},$jn=e=>{let t=e.state.field(fp,!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)},Mjn=[{key:"Mod-Shift-m",run:Pjn,preventDefault:!0},{key:"F8",run:$jn}],zP=Sn.define({combine(e){return{sources:e.map(t=>t.source).filter(t=>t!=null),...py(e.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:r4e,tooltipFilter:r4e,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 r4e(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function _ht(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 Cht(e,t,n){var r;let s=n?_ht(t.actions):[];return oi("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},oi("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=Wj(e.state.field(fp).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),oi("u",u.slice(d,d+1)),u.slice(d+1)],p=a.markClass?" "+a.markClass:"";return oi("button",{type:"button",class:"cm-diagnosticAction"+p,onclick:c,onmousedown:c,"aria-label":` Action: ${u}${d<0?"":` (access key "${s[i]})"`}.`},f)}),t.source&&oi("div",{class:"cm-diagnosticSource"},t.source))}class Djn extends Bp{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return oi("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class s4e{constructor(t,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Cht(t,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class BP{constructor(t){this.view=t,this.items=[];let n=s=>{if(s.keyCode==27)n4e(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=_ht(a.actions);for(let l=0;l<i.length;l++)if(i[l].toUpperCase().charCodeAt(0)==s.keyCode){let c=Wj(this.view.state.field(fp).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=oi("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=oi("div",{class:"cm-panel-lint"},this.list,oi("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>n4e(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(fp).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(fp),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 s4e(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 s4e(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(fp),r=Wj(n.diagnostics,this.items[t].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:Oht.of(r)})}static open(t){return new BP(t)}}function Ljn(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 xL(e){return Ljn(`<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 Fjn=Nt.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:xL("#d11")},".cm-lintRange-warning":{backgroundImage:xL("orange")},".cm-lintRange-info":{backgroundImage:xL("#999")},".cm-lintRange-hint":{backgroundImage:xL("#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 zjn(e){return e=="error"?4:e=="warning"?3:e=="info"?2:1}function Bjn(e){let t="hint",n=1;for(let r of e){let s=zjn(r.severity);s>n&&(n=s,t=r.severity)}return t}const Ujn=[fp,Nt.decorations.compute([fp],e=>{let{selected:t,panel:n}=e.field(fp);return!t||!n||t.from==t.to?Cn.none:Cn.set([Ijn.range(t.from,t.to)])}),P1n(Ajn,{hideOn:Tjn}),Fjn];var a4e=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(Ikn)),t.defaultKeymap!==!1&&(a=a.concat(KEn)),t.searchKeymap!==!1&&(a=a.concat(_jn)),t.historyKeymap!==!1&&(a=a.concat(aEn)),t.foldKeymap!==!1&&(a=a.concat(gSn)),t.completionKeymap!==!1&&(a=a.concat(xft)),t.lintKeymap!==!1&&(a=a.concat(Mjn));var i=[];return t.lineNumbers!==!1&&i.push(W1n()),t.highlightActiveLineGutter!==!1&&i.push(Q1n()),t.highlightSpecialChars!==!1&&i.push(l1n()),t.history!==!1&&i.push(YCn()),t.foldGutter!==!1&&i.push(xSn()),t.drawSelection!==!1&&i.push(Kwn()),t.dropCursor!==!1&&i.push(r1n()),t.allowMultipleSelections!==!1&&i.push(is.allowMultipleSelections.of(!0)),t.indentOnInput!==!1&&i.push(lSn()),t.syntaxHighlighting!==!1&&i.push(w1(OSn,{fallback:!0})),t.bracketMatching!==!1&&i.push(ISn()),t.closeBrackets!==!1&&i.push(Ekn()),t.autocompletion!==!1&&i.push(bft()),t.rectangularSelection!==!1&&i.push(S1n()),s!==!1&&i.push(_1n()),t.highlightActiveLine!==!1&&i.push(h1n()),t.highlightSelectionMatches!==!1&&i.push(sjn()),t.tabSize&&typeof t.tabSize=="number"&&i.push(cN.of(" ".repeat(t.tabSize))),i.concat([lN.of(a.flat())]).filter(Boolean)};const qjn="#e5c07b",i4e="#e06c75",Vjn="#56b6c2",Hjn="#ffffff",Q8="#abb2bf",sfe="#7d8799",Wjn="#61afef",Zjn="#98c379",o4e="#d19a66",Gjn="#c678dd",Qjn="#21252b",l4e="#2c313a",c4e="#282c34",oX="#353a42",Yjn="#3E4451",u4e="#528bff",Xjn=Nt.theme({"&":{color:Q8,backgroundColor:c4e},".cm-content":{caretColor:u4e},".cm-cursor, .cm-dropCursor":{borderLeftColor:u4e},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Yjn},".cm-panels":{backgroundColor:Qjn,color:Q8},".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:c4e,color:sfe,border:"none"},".cm-activeLineGutter":{backgroundColor:l4e},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:oX},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:oX,borderBottomColor:oX},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:l4e,color:Q8}}},{dark:!0}),Kjn=kg.define([{tag:de.keyword,color:Gjn},{tag:[de.name,de.deleted,de.character,de.propertyName,de.macroName],color:i4e},{tag:[de.function(de.variableName),de.labelName],color:Wjn},{tag:[de.color,de.constant(de.name),de.standard(de.name)],color:o4e},{tag:[de.definition(de.name),de.separator],color:Q8},{tag:[de.typeName,de.className,de.number,de.changed,de.annotation,de.modifier,de.self,de.namespace],color:qjn},{tag:[de.operator,de.operatorKeyword,de.url,de.escape,de.regexp,de.link,de.special(de.string)],color:Vjn},{tag:[de.meta,de.comment],color:sfe},{tag:de.strong,fontWeight:"bold"},{tag:de.emphasis,fontStyle:"italic"},{tag:de.strikethrough,textDecoration:"line-through"},{tag:de.link,color:sfe,textDecoration:"underline"},{tag:de.heading,fontWeight:"bold",color:i4e},{tag:[de.atom,de.bool,de.special(de.variableName)],color:o4e},{tag:[de.processingInstruction,de.string,de.inserted],color:Zjn},{tag:de.invalid,color:Hjn}]),Jjn=[Xjn,w1(Kjn)];var eTn=Nt.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),tTn=function(t){t===void 0&&(t={});var n=t,r=n.indentWithTab,s=r===void 0?!0:r,a=n.editable,i=a===void 0?!0:a,l=n.readOnly,c=l===void 0?!1:l,u=n.theme,d=u===void 0?"light":u,f=n.placeholder,p=f===void 0?"":f,h=n.basicSetup,m=h===void 0?!0:h,g=[];switch(s&&g.unshift(lN.of([JEn])),m&&(typeof m=="boolean"?g.unshift(a4e()):g.unshift(a4e(m))),p&&g.unshift(y1n(p)),d){case"light":g.push(eTn);break;case"dark":g.push(Jjn);break;case"none":break;default:g.push(d);break}return i===!1&&g.push(Nt.editable.of(!1)),c&&g.push(is.readOnly.of(!0)),[...g]},nTn=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 rTn{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 d4e{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 lX=null,sTn=()=>typeof window>"u"?new d4e:(lX||(lX=new d4e),lX),f4e=fy.define(),aTn=200,iTn=[];function oTn(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?iTn:l,u=e.autoFocus,d=e.theme,f=d===void 0?"light":d,p=e.height,h=p===void 0?null:p,m=e.minHeight,g=m===void 0?null:m,v=e.maxHeight,b=v===void 0?null:v,w=e.width,S=w===void 0?null:w,O=e.minWidth,_=O===void 0?null:O,C=e.maxWidth,j=C===void 0?null:C,E=e.placeholder,N=E===void 0?"":E,I=e.editable,P=I===void 0?!0:I,$=e.readOnly,z=$===void 0?!1:$,D=e.indentWithTab,q=D===void 0?!0:D,W=e.basicSetup,L=W===void 0?!0:W,F=e.root,B=e.initialState,M=y.useState(),Q=M[0],V=M[1],R=y.useState(),U=R[0],Z=R[1],X=y.useState(),te=X[0],ee=X[1],J=y.useState(()=>({current:null}))[0],ie=y.useState(()=>({current:null}))[0],ue=Nt.theme({"&":{height:h,minHeight:g,maxHeight:b,width:S,minWidth:_,maxWidth:j},"& .cm-scroller":{height:"100% !important"}}),Y=Nt.updateListener.of(pe=>{if(pe.docChanged&&typeof r=="function"&&!pe.transactions.some(be=>be.annotation(f4e))){J.current?J.current.reset():(J.current=new rTn(()=>{if(ie.current){var be=ie.current;ie.current=null,be()}J.current=null},aTn),sTn().add(J.current));var se=pe.state.doc,he=se.toString();r(he,pe)}s&&s(nTn(pe))}),ne=tTn({theme:f,editable:P,readOnly:z,placeholder:N,indentWithTab:q,basicSetup:L}),le=[Y,ue,...ne];return i&&typeof i=="function"&&le.push(Nt.updateListener.of(i)),le=le.concat(c),y.useLayoutEffect(()=>{if(Q&&!te){var pe={doc:t,selection:n,extensions:le},se=B?is.fromJSON(B.json,pe,B.fields):is.create(pe);if(ee(se),!U){var he=new Nt({state:se,parent:Q,root:F});Z(he),a&&a(he,se)}}return()=>{U&&(ee(void 0),Z(void 0))}},[Q,te]),y.useEffect(()=>{e.container&&V(e.container)},[e.container]),y.useEffect(()=>()=>{U&&(U.destroy(),Z(void 0)),J.current&&(J.current.cancel(),J.current=null)},[U]),y.useEffect(()=>{u&&U&&U.focus()},[u,U]),y.useEffect(()=>{U&&U.dispatch({effects:gr.reconfigure.of(le)})},[f,c,h,g,b,S,_,j,N,P,z,q,L,r,i]),y.useEffect(()=>{if(t!==void 0){var pe=U?U.state.doc.toString():"";if(U&&t!==pe){var se=J.current&&!J.current.isDone,he=()=>{U&&t!==U.state.doc.toString()&&U.dispatch({changes:{from:0,to:U.state.doc.toString().length,insert:t||""},annotations:[f4e.of(!0)]})};se?ie.current=he:he()}}},[t,U]),{state:te,setState:ee,view:U,setView:Z,container:Q,setContainer:V}}var lTn=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Hc=y.forwardRef((e,t)=>{var n=e.className,r=e.value,s=r===void 0?"":r,a=e.selection,i=e.extensions,l=i===void 0?[]:i,c=e.onChange,u=e.onStatistics,d=e.onCreateEditor,f=e.onUpdate,p=e.autoFocus,h=e.theme,m=h===void 0?"light":h,g=e.height,v=e.minHeight,b=e.maxHeight,w=e.width,S=e.minWidth,O=e.maxWidth,_=e.basicSetup,C=e.placeholder,j=e.indentWithTab,E=e.editable,N=e.readOnly,I=e.root,P=e.initialState,$=Ppt(e,lTn),z=y.useRef(null),D=oTn({root:I,value:s,autoFocus:p,theme:m,height:g,minHeight:v,maxHeight:b,width:w,minWidth:S,maxWidth:O,basicSetup:_,placeholder:C,indentWithTab:j,editable:E,readOnly:N,selection:a,onChange:c,onStatistics:u,onCreateEditor:d,onUpdate:f,extensions:l,initialState:P}),q=D.state,W=D.view,L=D.container,F=D.setContainer;y.useImperativeHandle(t,()=>({editor:z.current,state:q,view:W}),[z,L,q,W]);var B=y.useCallback(Q=>{z.current=Q,F(Q)},[F]);if(typeof s!="string")throw new Error("value must be typeof string but got "+typeof s);var M=typeof m=="string"?"cm-theme-"+m:"cm-theme";return o.jsx("div",uO({ref:B,className:""+M+(n?" "+n:"")},$))});Hc.displayName="CodeMirror";const cTn=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Eht=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();var uTn={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 dTn=y.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:i,...l},c)=>y.createElement("svg",{ref:c,...uTn,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Eht("lucide",s),...l},[...i.map(([u,d])=>y.createElement(u,d)),...Array.isArray(a)?a:[a]]));const yn=(e,t)=>{const n=y.forwardRef(({className:r,...s},a)=>y.createElement(dTn,{ref:a,iconNode:t,className:Eht(`lucide-${cTn(e)}`,r),...s}));return n.displayName=`${e}`,n};const fTn=[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]],lz=yn("AlignJustify",fTn);const pTn=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],UP=yn("AlignLeft",pTn);const hTn=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],tq=yn("ArrowDown",hTn);const mTn=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],cxe=yn("ArrowLeft",mTn);const gTn=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],cz=yn("ArrowRight",gTn);const vTn=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],nq=yn("ArrowUp",vTn);const yTn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]],jht=yn("Ban",yTn);const bTn=[["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"}]],rw=yn("Braces",bTn);const xTn=[["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"}]],wTn=yn("Brain",xTn);const STn=[["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"}]],p4e=yn("Calendar",STn);const kTn=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],kx=yn("Check",kTn);const OTn=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],uxe=yn("ChevronDown",OTn);const _Tn=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Tht=yn("ChevronLeft",_Tn);const CTn=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],dO=yn("ChevronRight",CTn);const ETn=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],jTn=yn("ChevronUp",ETn);const TTn=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],dxe=yn("ChevronsDownUp",TTn);const NTn=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],ITn=yn("ChevronsDown",NTn);const ATn=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],RTn=yn("ChevronsLeft",ATn);const PTn=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],Nht=yn("ChevronsRight",PTn);const $Tn=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],c3=yn("ChevronsUpDown",$Tn);const MTn=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],DTn=yn("ChevronsUp",MTn);const LTn=[["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"}]],FTn=yn("CircleGauge",LTn);const zTn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]],Iht=yn("CircleSlash",zTn);const BTn=[["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"}]],UTn=yn("CircleX",BTn);const qTn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],VTn=yn("Circle",qTn);const HTn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],WTn=yn("Clock",HTn);const ZTn=[["path",{d:"M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1uwlt4"}],["path",{d:"M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z",key:"10291m"}],["path",{d:"M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z",key:"1tqoq1"}],["path",{d:"M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1x6lto"}]],GTn=yn("Component",ZTn);const QTn=[["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"}]],Aht=yn("Copy",QTn);const YTn=[["polyline",{points:"15 10 20 15 15 20",key:"1q7qjw"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],XTn=yn("CornerDownRight",YTn);const KTn=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],JTn=yn("Download",KTn);const eNn=[["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"}]],tNn=yn("EllipsisVertical",eNn);const nNn=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}],["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}]],rNn=yn("EqualNot",nNn);const sNn=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],aNn=yn("Equal",sNn);const iNn=[["path",{d:"m15 15 6 6",key:"1s409w"}],["path",{d:"m15 9 6-6",key:"ko1vev"}],["path",{d:"M21 16.2V21h-4.8",key:"1hrera"}],["path",{d:"M21 7.8V3h-4.8",key:"ul1q53"}],["path",{d:"M3 16.2V21h4.8",key:"1x04uo"}],["path",{d:"m3 21 6-6",key:"wwnumi"}],["path",{d:"M3 7.8V3h4.8",key:"1ijppm"}],["path",{d:"M9 9 3 3",key:"v551iv"}]],oNn=yn("Expand",iNn);const lNn=[["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"}]],fxe=yn("ExternalLink",lNn);const cNn=[["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"}]],uNn=yn("Eye",cNn);const dNn=[["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"}]],afe=yn("FileInput",dNn);const fNn=[["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"}]],ife=yn("FileOutput",fNn);const pNn=[["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"}]],hNn=yn("FileText",pNn);const mNn=[["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"}]],gNn=yn("File",mNn);const vNn=[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]],yNn=yn("Filter",vNn);const bNn=[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3-3-3 3",key:"e37ymu"}],["path",{d:"m15 5-3 3-3-3",key:"19d6lf"}]],xNn=yn("FoldVertical",bNn);const wNn=[["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"}]],SNn=yn("Folder",wNn);const kNn=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],ONn=yn("Gauge",kNn);const _Nn=[["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"}]],pxe=yn("Hash",_Nn);const CNn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Rht=yn("Info",CNn);const ENn=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],jNn=yn("Keyboard",ENn);const TNn=[["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"}]],NNn=yn("Lightbulb",TNn);const INn=[["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"}]],Pht=yn("Link2",INn);const ANn=[["path",{d:"M10 18h4",key:"1ulq68"}],["path",{d:"M11 6H3",key:"1u26ik"}],["path",{d:"M15 6h6",key:"1jlkvy"}],["path",{d:"M18 9V3",key:"xwwp7m"}],["path",{d:"M7 12h8",key:"7a1bxv"}]],RNn=yn("ListFilterPlus",ANn);const PNn=[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]],$Nn=yn("ListTree",PNn);const MNn=[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"m19 10-4 4",key:"1tz659"}],["path",{d:"m15 10 4 4",key:"1n7nei"}]],DNn=yn("ListX",MNn);const LNn=[["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"}]],hxe=yn("List",LNn);const FNn=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],zNn=yn("LoaderCircle",FNn);const BNn=[["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"}]],UNn=yn("Lock",BNn);const qNn=[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]],VNn=yn("LogIn",qNn);const HNn=[["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M3 18h1",key:"1eiwyy"}],["path",{d:"M3 6h1",key:"rgxa97"}],["path",{d:"M8 12h1",key:"1con00"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M8 6h1",key:"tn6mkg"}]],WNn=yn("Logs",HNn);const ZNn=[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]],GNn=yn("Menu",ZNn);const QNn=[["path",{d:"M5 12h14",key:"1ays0h"}]],YNn=yn("Minus",QNn);const XNn=[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 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-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]],KNn=yn("OctagonAlert",XNn);const JNn=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],eIn=yn("PanelRight",JNn);const tIn=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],mxe=yn("Plus",tIn);const nIn=[["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"}]],$ht=yn("Save",nIn);const rIn=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],Zj=yn("Search",rIn);const sIn=[["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:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]],aIn=yn("ShieldX",sIn);const iIn=[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 18H3",key:"13769t"}],["circle",{cx:"17",cy:"15",r:"3",key:"1upz2a"}],["path",{d:"m21 19-1.9-1.9",key:"dwi7p8"}]],oIn=yn("TextSearch",iIn);const lIn=[["path",{d:"M17 6.1H3",key:"wptmhv"}],["path",{d:"M21 12.1H3",key:"1j38uz"}],["path",{d:"M15.1 18H3",key:"1nb16a"}]],cIn=yn("Text",lIn);const uIn=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]],gxe=yn("ToggleLeft",uIn);const dIn=[["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"}]],Mht=yn("Trash2",dIn);const fIn=[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]],pIn=yn("TrendingDown",fIn);const hIn=[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]],mIn=yn("TrendingUp",hIn);const gIn=[["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"}]],rq=yn("TriangleAlert",gIn);const vIn=[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]],vxe=yn("Type",vIn);const yIn=[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m15 5-3-3-3 3",key:"itvq4r"}]],bIn=yn("UnfoldVertical",yIn);const xIn=[["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"}]],wIn=yn("WandSparkles",xIn);const SIn=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],dd=yn("X",SIn);function kIn(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const OIn=e=>{switch(e){case"success":return EIn;case"info":return TIn;case"warning":return jIn;case"error":return NIn;default:return null}},_In=Array(12).fill(0),CIn=({visible:e,className:t})=>De.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},De.createElement("div",{className:"sonner-spinner"},_In.map((n,r)=>De.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),EIn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},De.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),jIn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},De.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),TIn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},De.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),NIn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},De.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),IIn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},De.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),De.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),AIn=()=>{const[e,t]=De.useState(document.hidden);return De.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let ofe=1;class RIn{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:r,...s}=t,a=typeof t?.id=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:ofe++,i=this.toasts.find(c=>c.id===a),l=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),i?this.toasts=this.toasts.map(c=>c.id===a?(this.publish({...c,...t,id:a,title:r}),{...c,...t,id:a,dismissible:l,title:r}):c):this.addToast({title:r,...s,dismissible:l,id:a}),a},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const s=Promise.resolve(t instanceof Function?t():t);let a=r!==void 0,i;const l=s.then(async u=>{if(i=["resolve",u],De.isValidElement(u))a=!1,this.create({id:r,type:"default",message:u});else if($In(u)&&!u.ok){a=!1;const f=typeof n.error=="function"?await n.error(`HTTP error! status: ${u.status}`):n.error,p=typeof n.description=="function"?await n.description(`HTTP error! status: ${u.status}`):n.description,m=typeof f=="object"&&!De.isValidElement(f)?f:{message:f};this.create({id:r,type:"error",description:p,...m})}else if(u instanceof Error){a=!1;const f=typeof n.error=="function"?await n.error(u):n.error,p=typeof n.description=="function"?await n.description(u):n.description,m=typeof f=="object"&&!De.isValidElement(f)?f:{message:f};this.create({id:r,type:"error",description:p,...m})}else if(n.success!==void 0){a=!1;const f=typeof n.success=="function"?await n.success(u):n.success,p=typeof n.description=="function"?await n.description(u):n.description,m=typeof f=="object"&&!De.isValidElement(f)?f:{message:f};this.create({id:r,type:"success",description:p,...m})}}).catch(async u=>{if(i=["reject",u],n.error!==void 0){a=!1;const d=typeof n.error=="function"?await n.error(u):n.error,f=typeof n.description=="function"?await n.description(u):n.description,h=typeof d=="object"&&!De.isValidElement(d)?d:{message:d};this.create({id:r,type:"error",description:f,...h})}}).finally(()=>{a&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),c=()=>new Promise((u,d)=>l.then(()=>i[0]==="reject"?d(i[1]):u(i[1])).catch(d));return typeof r!="string"&&typeof r!="number"?{unwrap:c}:Object.assign(r,{unwrap:c})},this.custom=(t,n)=>{const r=n?.id||ofe++;return this.create({jsx:t(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const Ad=new RIn,PIn=(e,t)=>{const n=t?.id||ofe++;return Ad.addToast({title:e,...t,id:n}),n},$In=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",MIn=PIn,DIn=()=>Ad.toasts,LIn=()=>Ad.getActiveToasts(),bu=Object.assign(MIn,{success:Ad.success,info:Ad.info,warning:Ad.warning,error:Ad.error,custom:Ad.custom,message:Ad.message,promise:Ad.promise,dismiss:Ad.dismiss,loading:Ad.loading},{getHistory:DIn,getToasts:LIn});kIn("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function wL(e){return e.label!==void 0}const FIn=3,zIn="24px",BIn="16px",h4e=4e3,UIn=356,qIn=14,VIn=45,HIn=200;function Hg(...e){return e.filter(Boolean).join(" ")}function WIn(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const ZIn=e=>{var t,n,r,s,a,i,l,c,u;const{invert:d,toast:f,unstyled:p,interacting:h,setHeights:m,visibleToasts:g,heights:v,index:b,toasts:w,expanded:S,removeToast:O,defaultRichColors:_,closeButton:C,style:j,cancelButtonStyle:E,actionButtonStyle:N,className:I="",descriptionClassName:P="",duration:$,position:z,gap:D,expandByDefault:q,classNames:W,icons:L,closeButtonAriaLabel:F="Close toast"}=e,[B,M]=De.useState(null),[Q,V]=De.useState(null),[R,U]=De.useState(!1),[Z,X]=De.useState(!1),[te,ee]=De.useState(!1),[J,ie]=De.useState(!1),[ue,Y]=De.useState(!1),[ne,le]=De.useState(0),[pe,se]=De.useState(0),he=De.useRef(f.duration||$||h4e),be=De.useRef(null),Se=De.useRef(null),Ne=b===0,Oe=b+1<=g,Ae=f.type,Ue=f.dismissible!==!1,ce=f.className||"",ae=f.descriptionClassName||"",re=De.useMemo(()=>v.findIndex(bt=>bt.toastId===f.id)||0,[v,f.id]),me=De.useMemo(()=>{var bt;return(bt=f.closeButton)!=null?bt:C},[f.closeButton,C]),ye=De.useMemo(()=>f.duration||$||h4e,[f.duration,$]),je=De.useRef(0),Re=De.useRef(0),Qe=De.useRef(0),Ze=De.useRef(null),[ke,_e]=z.split("-"),Ce=De.useMemo(()=>v.reduce((bt,It,sn)=>sn>=re?bt:bt+It.height,0),[v,re]),Ee=AIn(),$e=f.invert||d,Fe=Ae==="loading";Re.current=De.useMemo(()=>re*D+Ce,[re,Ce]),De.useEffect(()=>{he.current=ye},[ye]),De.useEffect(()=>{U(!0)},[]),De.useEffect(()=>{const bt=Se.current;if(bt){const It=bt.getBoundingClientRect().height;return se(It),m(sn=>[{toastId:f.id,height:It,position:f.position},...sn]),()=>m(sn=>sn.filter(Ge=>Ge.toastId!==f.id))}},[m,f.id]),De.useLayoutEffect(()=>{if(!R)return;const bt=Se.current,It=bt.style.height;bt.style.height="auto";const sn=bt.getBoundingClientRect().height;bt.style.height=It,se(sn),m(Ge=>Ge.find(ct=>ct.toastId===f.id)?Ge.map(ct=>ct.toastId===f.id?{...ct,height:sn}:ct):[{toastId:f.id,height:sn,position:f.position},...Ge])},[R,f.title,f.description,m,f.id,f.jsx,f.action,f.cancel]);const Ke=De.useCallback(()=>{X(!0),le(Re.current),m(bt=>bt.filter(It=>It.toastId!==f.id)),setTimeout(()=>{O(f)},HIn)},[f,O,m,Re]);De.useEffect(()=>{if(f.promise&&Ae==="loading"||f.duration===1/0||f.type==="loading")return;let bt;return S||h||Ee?(()=>{if(Qe.current<je.current){const Ge=new Date().getTime()-je.current;he.current=he.current-Ge}Qe.current=new Date().getTime()})():he.current!==1/0&&(je.current=new Date().getTime(),bt=setTimeout(()=>{f.onAutoClose==null||f.onAutoClose.call(f,f),Ke()},he.current)),()=>clearTimeout(bt)},[S,h,f,Ae,Ee,Ke]),De.useEffect(()=>{f.delete&&(Ke(),f.onDismiss==null||f.onDismiss.call(f,f))},[Ke,f.delete]);function Ye(){var bt;if(L?.loading){var It;return De.createElement("div",{className:Hg(W?.loader,f==null||(It=f.classNames)==null?void 0:It.loader,"sonner-loader"),"data-visible":Ae==="loading"},L.loading)}return De.createElement(CIn,{className:Hg(W?.loader,f==null||(bt=f.classNames)==null?void 0:bt.loader),visible:Ae==="loading"})}const Rt=f.icon||L?.[Ae]||OIn(Ae);var Ct,en;return De.createElement("li",{tabIndex:0,ref:Se,className:Hg(I,ce,W?.toast,f==null||(t=f.classNames)==null?void 0:t.toast,W?.default,W?.[Ae],f==null||(n=f.classNames)==null?void 0:n[Ae]),"data-sonner-toast":"","data-rich-colors":(Ct=f.richColors)!=null?Ct:_,"data-styled":!(f.jsx||f.unstyled||p),"data-mounted":R,"data-promise":!!f.promise,"data-swiped":ue,"data-removed":Z,"data-visible":Oe,"data-y-position":ke,"data-x-position":_e,"data-index":b,"data-front":Ne,"data-swiping":te,"data-dismissible":Ue,"data-type":Ae,"data-invert":$e,"data-swipe-out":J,"data-swipe-direction":Q,"data-expanded":!!(S||q&&R),"data-testid":f.testId,style:{"--index":b,"--toasts-before":b,"--z-index":w.length-b,"--offset":`${Z?ne:Re.current}px`,"--initial-height":q?"auto":`${pe}px`,...j,...f.style},onDragEnd:()=>{ee(!1),M(null),Ze.current=null},onPointerDown:bt=>{bt.button!==2&&(Fe||!Ue||(be.current=new Date,le(Re.current),bt.target.setPointerCapture(bt.pointerId),bt.target.tagName!=="BUTTON"&&(ee(!0),Ze.current={x:bt.clientX,y:bt.clientY})))},onPointerUp:()=>{var bt,It,sn;if(J||!Ue)return;Ze.current=null;const Ge=Number(((bt=Se.current)==null?void 0:bt.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),at=Number(((It=Se.current)==null?void 0:It.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ct=new Date().getTime()-((sn=be.current)==null?void 0:sn.getTime()),an=B==="x"?Ge:at,Kt=Math.abs(an)/ct;if(Math.abs(an)>=VIn||Kt>.11){le(Re.current),f.onDismiss==null||f.onDismiss.call(f,f),V(B==="x"?Ge>0?"right":"left":at>0?"down":"up"),Ke(),ie(!0);return}else{var _n,Te;(_n=Se.current)==null||_n.style.setProperty("--swipe-amount-x","0px"),(Te=Se.current)==null||Te.style.setProperty("--swipe-amount-y","0px")}Y(!1),ee(!1),M(null)},onPointerMove:bt=>{var It,sn,Ge;if(!Ze.current||!Ue||((It=window.getSelection())==null?void 0:It.toString().length)>0)return;const ct=bt.clientY-Ze.current.y,an=bt.clientX-Ze.current.x;var Kt;const _n=(Kt=e.swipeDirections)!=null?Kt:WIn(z);!B&&(Math.abs(an)>1||Math.abs(ct)>1)&&M(Math.abs(an)>Math.abs(ct)?"x":"y");let Te={x:0,y:0};const Le=Me=>1/(1.5+Math.abs(Me)/20);if(B==="y"){if(_n.includes("top")||_n.includes("bottom"))if(_n.includes("top")&&ct<0||_n.includes("bottom")&&ct>0)Te.y=ct;else{const Me=ct*Le(ct);Te.y=Math.abs(Me)<Math.abs(ct)?Me:ct}}else if(B==="x"&&(_n.includes("left")||_n.includes("right")))if(_n.includes("left")&&an<0||_n.includes("right")&&an>0)Te.x=an;else{const Me=an*Le(an);Te.x=Math.abs(Me)<Math.abs(an)?Me:an}(Math.abs(Te.x)>0||Math.abs(Te.y)>0)&&Y(!0),(sn=Se.current)==null||sn.style.setProperty("--swipe-amount-x",`${Te.x}px`),(Ge=Se.current)==null||Ge.style.setProperty("--swipe-amount-y",`${Te.y}px`)}},me&&!f.jsx&&Ae!=="loading"?De.createElement("button",{"aria-label":F,"data-disabled":Fe,"data-close-button":!0,onClick:Fe||!Ue?()=>{}:()=>{Ke(),f.onDismiss==null||f.onDismiss.call(f,f)},className:Hg(W?.closeButton,f==null||(r=f.classNames)==null?void 0:r.closeButton)},(en=L?.close)!=null?en:IIn):null,(Ae||f.icon||f.promise)&&f.icon!==null&&(L?.[Ae]!==null||f.icon)?De.createElement("div",{"data-icon":"",className:Hg(W?.icon,f==null||(s=f.classNames)==null?void 0:s.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||Ye():null,f.type!=="loading"?Rt:null):null,De.createElement("div",{"data-content":"",className:Hg(W?.content,f==null||(a=f.classNames)==null?void 0:a.content)},De.createElement("div",{"data-title":"",className:Hg(W?.title,f==null||(i=f.classNames)==null?void 0:i.title)},f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title),f.description?De.createElement("div",{"data-description":"",className:Hg(P,ae,W?.description,f==null||(l=f.classNames)==null?void 0:l.description)},typeof f.description=="function"?f.description():f.description):null),De.isValidElement(f.cancel)?f.cancel:f.cancel&&wL(f.cancel)?De.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||E,onClick:bt=>{wL(f.cancel)&&Ue&&(f.cancel.onClick==null||f.cancel.onClick.call(f.cancel,bt),Ke())},className:Hg(W?.cancelButton,f==null||(c=f.classNames)==null?void 0:c.cancelButton)},f.cancel.label):null,De.isValidElement(f.action)?f.action:f.action&&wL(f.action)?De.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||N,onClick:bt=>{wL(f.action)&&(f.action.onClick==null||f.action.onClick.call(f.action,bt),!bt.defaultPrevented&&Ke())},className:Hg(W?.actionButton,f==null||(u=f.classNames)==null?void 0:u.actionButton)},f.action.label):null)};function m4e(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function GIn(e,t){const n={};return[e,t].forEach((r,s)=>{const a=s===1,i=a?"--mobile-offset":"--offset",l=a?BIn:zIn;function c(u){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof u=="number"?`${u}px`:u})}typeof r=="number"||typeof r=="string"?c(r):typeof r=="object"?["top","right","bottom","left"].forEach(u=>{r[u]===void 0?n[`${i}-${u}`]=l:n[`${i}-${u}`]=typeof r[u]=="number"?`${r[u]}px`:r[u]}):c(l)}),n}const QIn=De.forwardRef(function(t,n){const{id:r,invert:s,position:a="bottom-right",hotkey:i=["altKey","KeyT"],expand:l,closeButton:c,className:u,offset:d,mobileOffset:f,theme:p="light",richColors:h,duration:m,style:g,visibleToasts:v=FIn,toastOptions:b,dir:w=m4e(),gap:S=qIn,icons:O,containerAriaLabel:_="Notifications"}=t,[C,j]=De.useState([]),E=De.useMemo(()=>r?C.filter(R=>R.toasterId===r):C.filter(R=>!R.toasterId),[C,r]),N=De.useMemo(()=>Array.from(new Set([a].concat(E.filter(R=>R.position).map(R=>R.position)))),[E,a]),[I,P]=De.useState([]),[$,z]=De.useState(!1),[D,q]=De.useState(!1),[W,L]=De.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),F=De.useRef(null),B=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),M=De.useRef(null),Q=De.useRef(!1),V=De.useCallback(R=>{j(U=>{var Z;return(Z=U.find(X=>X.id===R.id))!=null&&Z.delete||Ad.dismiss(R.id),U.filter(({id:X})=>X!==R.id)})},[]);return De.useEffect(()=>Ad.subscribe(R=>{if(R.dismiss){requestAnimationFrame(()=>{j(U=>U.map(Z=>Z.id===R.id?{...Z,delete:!0}:Z))});return}setTimeout(()=>{Zve.flushSync(()=>{j(U=>{const Z=U.findIndex(X=>X.id===R.id);return Z!==-1?[...U.slice(0,Z),{...U[Z],...R},...U.slice(Z+1)]:[R,...U]})})})}),[C]),De.useEffect(()=>{if(p!=="system"){L(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?L("dark"):L("light")),typeof window>"u")return;const R=window.matchMedia("(prefers-color-scheme: dark)");try{R.addEventListener("change",({matches:U})=>{L(U?"dark":"light")})}catch{R.addListener(({matches:Z})=>{try{L(Z?"dark":"light")}catch(X){console.error(X)}})}},[p]),De.useEffect(()=>{C.length<=1&&z(!1)},[C]),De.useEffect(()=>{const R=U=>{var Z;if(i.every(ee=>U[ee]||U.code===ee)){var te;z(!0),(te=F.current)==null||te.focus()}U.code==="Escape"&&(document.activeElement===F.current||(Z=F.current)!=null&&Z.contains(document.activeElement))&&z(!1)};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[i]),De.useEffect(()=>{if(F.current)return()=>{M.current&&(M.current.focus({preventScroll:!0}),M.current=null,Q.current=!1)}},[F.current]),De.createElement("section",{ref:n,"aria-label":`${_} ${B}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},N.map((R,U)=>{var Z;const[X,te]=R.split("-");return E.length?De.createElement("ol",{key:R,dir:w==="auto"?m4e():w,tabIndex:-1,ref:F,className:u,"data-sonner-toaster":!0,"data-sonner-theme":W,"data-y-position":X,"data-x-position":te,style:{"--front-toast-height":`${((Z=I[0])==null?void 0:Z.height)||0}px`,"--width":`${UIn}px`,"--gap":`${S}px`,...g,...GIn(d,f)},onBlur:ee=>{Q.current&&!ee.currentTarget.contains(ee.relatedTarget)&&(Q.current=!1,M.current&&(M.current.focus({preventScroll:!0}),M.current=null))},onFocus:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||Q.current||(Q.current=!0,M.current=ee.relatedTarget)},onMouseEnter:()=>z(!0),onMouseMove:()=>z(!0),onMouseLeave:()=>{D||z(!1)},onDragEnd:()=>z(!1),onPointerDown:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||q(!0)},onPointerUp:()=>q(!1)},E.filter(ee=>!ee.position&&U===0||ee.position===R).map((ee,J)=>{var ie,ue;return De.createElement(ZIn,{key:ee.id,icons:O,index:J,toast:ee,defaultRichColors:h,duration:(ie=b?.duration)!=null?ie:m,className:b?.className,descriptionClassName:b?.descriptionClassName,invert:s,visibleToasts:v,closeButton:(ue=b?.closeButton)!=null?ue:c,interacting:D,position:R,style:b?.style,unstyled:b?.unstyled,classNames:b?.classNames,cancelButtonStyle:b?.cancelButtonStyle,actionButtonStyle:b?.actionButtonStyle,closeButtonAriaLabel:b?.closeButtonAriaLabel,removeToast:V,toasts:E.filter(Y=>Y.position==ee.position),heights:I.filter(Y=>Y.position==ee.position),setHeights:P,expandByDefault:l,gap:S,expanded:$,swipeDirections:t.swipeDirections})})):null}))}),yxe=({className:e,toastOptions:t,...n})=>o.jsx(QIn,{...n,closeButton:!0,richColors:!0,className:K("mastra-toaster",e),toastOptions:{duration:5e3,...t}}),sq=(e,t)=>Array.isArray(e)?e.map(t):t(e),Be=(e,t={})=>{if(Array.isArray(e))return e.map(n=>bu(n,t));if(De.isValidElement(e)||typeof e=="string")return bu(e,t);throw new Error("Invalid message type")};Be.success=(e,t={})=>sq(e,n=>bu.success(n,t));Be.error=(e,t={})=>sq(e,n=>bu.error(n,t));Be.warning=(e,t={})=>sq(e,n=>bu.warning(n,t));Be.info=(e,t={})=>sq(e,n=>bu.info(n,t));Be.custom=(e,t={})=>bu(e,t);Be.dismiss=e=>bu.dismiss(e);Be.promise=({myPromise:e,loadingMessage:t,successMessage:n,errorMessage:r,onSuccess:s,onError:a,options:i={}})=>bu.promise(e,{loading:t??"Loading...",success:l=>(s?.(l),n),error:l=>(a?.(l),r||(l instanceof Error?l.message:"Error...")),...i});function Zv({text:e,copyMessage:t="Copied to clipboard!"}){const[n,r]=y.useState(!1),s=y.useRef(null),a=y.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{Be.success(t),r(!0),s.current&&(clearTimeout(s.current),s.current=null),s.current=setTimeout(()=>{r(!1)},2e3)}).catch(()=>{Be.error("Failed to copy to clipboard.")})},[e,t]);return{isCopied:n,handleCopy:a}}function xa({content:e,copyMessage:t,tooltip:n="Copy to clipboard",size:r="sm",variant:s,className:a}){const[i,l]=y.useState(!1),{handleCopy:c}=Zv({text:e,copyMessage:t}),u=()=>{c(),l(!0),setTimeout(()=>l(!1),2e3)};return o.jsxs(Hn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx(fe,{onClick:u,type:"button",size:r,variant:s,className:a,"aria-label":i?"Copied!":n,children:i?o.jsx(kx,{}):o.jsx(Aht,{})})}),o.jsx(Bn,{children:i?"Copied!":n})]})}const YIn="mastra-theme",XIn="mastra-playground-store",lfe=e=>e==="dark"||e==="light"||e==="system",KIn=e=>{try{const t=e.getItem(XIn);if(!t)return;const r=JSON.parse(t)?.state?.theme;return lfe(r)?r:void 0}catch{return}},JIn=(e=YIn)=>({get(){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(lfe(t))return t;const n=KIn(window.localStorage);return n?(window.localStorage.setItem(e,n),n):null}catch{return null}},set(t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}},subscribe(t){if(typeof window>"u")return()=>{};const n=r=>{if(r.key===e){if(r.newValue===null){t(null);return}lfe(r.newValue)&&t(r.newValue)}};return window.addEventListener("storage",n),()=>window.removeEventListener("storage",n)}}),Dht=y.createContext(null),Lht="(prefers-color-scheme: dark)",eAn=typeof window>"u"?y.useEffect:y.useLayoutEffect,Fht=()=>typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia(Lht).matches?"dark":"light",zht=e=>{if(typeof window>"u"||typeof window.matchMedia!="function")return()=>{};const t=window.matchMedia(Lht);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},tAn=(e,t)=>{e.classList.remove(t==="dark"?"light":"dark"),e.classList.add(t)},Bht=({children:e,defaultTheme:t="system",storageKey:n,target:r})=>{const s=y.useMemo(()=>JIn(n),[n]),a=y.useRef(null),[i,l]=y.useState(()=>s.get()??t),c=y.useSyncExternalStore(zht,Fht,()=>"dark");y.useEffect(()=>s.subscribe(f=>l(f??t)),[s,t]);const u=i==="system"?c:i;eAn(()=>{const f=r??(typeof window>"u"?null:window.document.documentElement);a.current&&a.current!==f&&a.current.classList.remove("dark","light"),f&&tAn(f,u),a.current=f},[u,r]);const d=y.useMemo(()=>({theme:i,resolvedTheme:u,systemTheme:c,setTheme:f=>{l(f),s.set(f)}}),[i,u,c,s]);return o.jsx(Dht.Provider,{value:d,children:e})},nAn=()=>{},hN=()=>{const e=y.useContext(Dht),t=y.useSyncExternalStore(zht,Fht,()=>"dark");return y.useMemo(()=>e??{theme:"system",resolvedTheme:t,systemTheme:t,setTheme:nAn},[e,t])};function rAn(e){return new iO(Ebe.define(e))}const Uht=[Mm.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return wo(()=>Promise.resolve().then(()=>gL),[],import.meta.url).then(e=>e.javascript())}}),Mm.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return wo(()=>Promise.resolve().then(()=>qSn),void 0,import.meta.url).then(e=>e.json())}}),Mm.of({name:"JSX",extensions:["jsx"],load(){return wo(()=>Promise.resolve().then(()=>gL),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),Mm.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return wo(()=>Promise.resolve().then(()=>DCn),void 0,import.meta.url).then(e=>e.markdown())}}),Mm.of({name:"TSX",extensions:["tsx"],load(){return wo(()=>Promise.resolve().then(()=>gL),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Mm.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return wo(()=>Promise.resolve().then(()=>gL),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),Mm.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return wo(()=>import("./shell-CjFT_Tl9.js"),[],import.meta.url).then(e=>rAn(e.shell))}})];function sAn(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 aAn(e){const t=sAn(e);return bft({override:[iAn(t)],defaultKeymap:!0,closeOnBlur:!0,icons:!1})}function iAn(e){return t=>{const r=t.state.sliceDoc(Math.max(0,t.pos-50),t.pos).match(/\{\{([a-zA-Z0-9_.\[\]]*)?$/);if(!r)return null;const s=r[1]??"",a=t.pos-s.length,i=s?e.filter(c=>c.path.toLowerCase().startsWith(s.toLowerCase())):e;if(i.length===0)return null;const l=i.map(c=>({label:c.path,displayLabel:c.path,detail:c.type,info:c.description,apply:(u,d,f,p)=>{const g=u.state.sliceDoc(p,p+2)==="}}"?d.label:`${d.label}}}`;u.dispatch({changes:{from:f,to:p,insert:g},selection:{anchor:f+g.length}})}}));return{from:a,options:l,validFor:/^[a-zA-Z0-9_.\[\]]*$/}}}const oAn=/\{\{([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)\}\}/g,lAn=Cn.mark({class:"cm-variable-highlight"}),g4e=new Rdt({regexp:oAn,decoration:()=>lAn}),cAn=po.fromClass(class{decorations;constructor(e){this.decorations=g4e.createDeco(e)}update(e){this.decorations=g4e.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}),uAn=cAn;function dAn(){const e=dN({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:[de.className,de.propertyName],color:"var(--neutral6)"},{tag:de.heading,color:"var(--accent3)",fontWeight:"bold"},{tag:[de.heading1,de.heading2,de.heading3,de.heading4,de.heading5,de.heading6],color:"var(--accent3)",fontWeight:"bold"},{tag:de.emphasis,fontStyle:"italic",color:"var(--neutral6)"},{tag:de.strong,fontWeight:"bold",color:"var(--neutral6)"},{tag:de.link,color:"var(--accent3)",textDecoration:"underline"},{tag:de.url,color:"var(--accent3)"},{tag:de.monospace,color:"var(--neutral6)"},{tag:de.strikethrough,textDecoration:"line-through"},{tag:de.quote,fontStyle:"italic",color:"var(--neutral2)"}]}),t=Nt.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 fAn(){const e=Nt.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=kg.define([{tag:[de.comment,de.bracket],color:"var(--neutral2)"},{tag:[de.string,de.meta,de.regexp],color:"var(--accent1)"},{tag:[de.atom,de.bool,de.special(de.variableName)],color:"var(--accent6)"},{tag:[de.keyword,de.operator,de.tagName],color:"var(--accent2)"},{tag:[de.function(de.propertyName),de.propertyName],color:"var(--accent5)"},{tag:[de.definition(de.variableName),de.function(de.variableName),de.className,de.attributeName],color:"var(--accent3)"},{tag:[de.variableName,de.number],color:"var(--accent5)"},{tag:[de.name,de.quote],color:"var(--accent1)"},{tag:de.heading,color:"var(--accent3)",fontWeight:"bold"},{tag:[de.heading1,de.heading2,de.heading3,de.heading4,de.heading5,de.heading6],color:"var(--accent3)",fontWeight:"bold"},{tag:[de.emphasis],fontStyle:"italic",color:"var(--neutral6)"},{tag:[de.strong],fontWeight:"bold",color:"var(--neutral6)"},{tag:de.link,color:"var(--accent3)",textDecoration:"underline"},{tag:de.url,color:"var(--accent3)"},{tag:de.monospace,color:"var(--neutral6)"},{tag:de.strikethrough,textDecoration:"line-through"},{tag:[de.deleted],color:"var(--accent2)"},{tag:de.invalid,color:"var(--error)"},{tag:[de.standard(de.tagName)],color:"var(--accent1)"}]);return[e,w1(t)]}const hy=()=>{const e=hN().resolvedTheme==="dark";return y.useMemo(()=>e?dAn():fAn(),[e])},as=y.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,editable:f,...p},h)=>{const m=hy(),g=e?JSON.stringify(e,null,2):t??"",v=y.useMemo(()=>{const b=[];return a==="json"?b.push(Kd):a==="markdown"&&(b.push(exe({base:cO,codeLanguages:Uht})),b.push(Nt.lineWrapping)),i&&a==="markdown"&&b.push(uAn),c&&a==="markdown"&&b.push(aAn(c)),f===!1&&b.push(is.readOnly.of(!0)),b},[a,i,c,f]);return o.jsxs("div",{className:K("rounded-md bg-surface3 p-1 font-mono relative border border-border1 overflow-hidden",s),...p,children:[r&&o.jsx(xa,{content:g,className:"absolute top-2 right-2 z-20"}),o.jsx(Hc,{ref:h,value:g,theme:m,extensions:v,onChange:n,editable:f,"aria-label":"Code editor",placeholder:l,height:"100%",style:{height:"100%"},autoFocus:u,basicSetup:{lineNumbers:d}})]})}),pAn={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 cX=null;function hAn(){return cX||(cX=(async()=>{const[{createHighlighterCore:e},{createJavaScriptRegexEngine:t}]=await Promise.all([wo(()=>import("./core-CPv_0oCn.js"),__vite__mapDeps([0,1,2]),import.meta.url),wo(()=>import("./engine-javascript-CSIo_1eZ.js"),__vite__mapDeps([3,1]),import.meta.url)]);return e({themes:[wo(()=>import("./github-light-DAi9KRSo.js"),[],import.meta.url),wo(()=>import("./github-dark-DHJKELXO.js"),[],import.meta.url)],langs:[wo(()=>import("./javascript-ySlJ1b_l.js"),[],import.meta.url),wo(()=>import("./typescript-Dj6nwHGl.js"),[],import.meta.url),wo(()=>import("./tsx-B6W0miNI.js"),[],import.meta.url),wo(()=>import("./jsx-BAng5TT0.js"),[],import.meta.url),wo(()=>import("./json-BQoSv7ci.js"),[],import.meta.url),wo(()=>import("./bash-atvbtKCR.js"),[],import.meta.url),wo(()=>import("./markdown-UIAJJxZW.js"),[],import.meta.url),wo(()=>import("./python-DhUJRlN_.js"),[],import.meta.url)],engine:t()})})()),cX}async function mAn(e,t){const n=pAn[t?.toLowerCase()];if(!n)return null;const r=await hAn(),{tokens:s}=r.codeToTokens(e,{lang:n,defaultColor:!1,themes:{light:"github-light",dark:"github-dark"}});return s}function Wr({iconSlot:e,titleSlot:t,descriptionSlot:n,actionSlot:r,className:s,as:a="h3"}){return o.jsxs("div",{className:K("flex flex-col items-center justify-center text-center py-10 px-6","transition-opacity duration-normal ease-out-custom",s),children:[e&&o.jsx("div",{className:"mb-4",children:e}),o.jsx(a,{className:"font-medium text-neutral5 text-ui-md",children:t}),n&&o.jsx("p",{className:"mt-1.5 text-neutral3 text-ui-sm max-w-md",children:n}),r&&o.jsx("div",{className:"mt-5",children:r})]})}const bf=({children:e,className:t,onClick:n})=>o.jsx("div",{tabIndex:n?0:void 0,onKeyDown:r=>{n&&(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),n?.())},className:K("flex gap-3 group/entity bg-surface3 rounded-xl border border-border1 py-3 px-4",n&&"cursor-pointer hover:bg-surface4 transition-all",t),onClick:n,children:e}),qht=({children:e,className:t,style:n})=>o.jsx(Ve,{size:"lg",className:K("text-neutral3 mt-1 shrink-0",t),style:n,children:e}),xf=({children:e,className:t})=>o.jsx(ge,{as:"p",variant:"ui-lg",className:K("text-neutral6 font-medium",t),children:e}),Up=({children:e,className:t})=>o.jsx(ge,{as:"div",variant:"ui-sm",className:K("text-neutral3",t),children:e}),wf=({children:e,className:t})=>o.jsx("div",{className:K("flex-1 w-full",t),children:e});function $s({resource:e,title:t,description:n,actionSlot:r,className:s}){const a="Permission Denied",i=e?`You don't have permission to access ${e}. Contact your administrator for access.`:"You don't have permission to access this resource. Contact your administrator for access.";return o.jsx(Wr,{className:s,iconSlot:o.jsx(Ve,{size:"lg",className:"text-neutral3",children:o.jsx(aIn,{})}),titleSlot:t??a,descriptionSlot:n??i,actionSlot:r})}function Vs({title:e,description:t,className:n}){const[r,s]=y.useState(!1),a=We(),i=y.useCallback(async()=>{try{s(!0);const{baseUrl:l="",apiPrefix:c}=a.options||{},u=(c||"/api").trim(),d=(u.startsWith("/")?u:`/${u}`).replace(/\/$/,""),f=new URLSearchParams({redirect_uri:window.location.href}),p=`${l}${d}/auth/sso/login?${f}`,h=await fetch(p,{credentials:"include",headers:{"Content-Type":"application/json"}});if(h.ok){const m=await h.json();window.location.href=m.url}}finally{s(!1)}},[a]);return o.jsx(Wr,{className:n,iconSlot:o.jsx(Ve,{size:"lg",className:"text-neutral3",children:o.jsx(VNn,{})}),titleSlot:e??"Session Expired",descriptionSlot:t??"Your session has expired. Please log in again to continue.",actionSlot:o.jsx(fe,{variant:"default",onClick:i,disabled:r,children:r?"Redirecting...":"Log in"})})}const bxe=({children:e,border:t=!0,className:n})=>o.jsx("header",{className:K("h-header-default z-50 flex w-full items-center gap-4 bg-transparent px-3",{"border-b border-border1":t},n),children:e}),Vht=({children:e})=>o.jsx(ge,{as:"h1",variant:"ui-md",className:"text-neutral6 flex items-center gap-2",children:e}),gAn=({children:e})=>o.jsx("div",{className:"ml-auto flex items-center gap-3",children:e}),Rh=e=>o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 34 21",fill:"none",...e,children:o.jsx("path",{d:"M4.49805 11.6934C6.98237 11.6934 8.99609 13.7081 8.99609 16.1924C8.9959 18.6765 6.98225 20.6904 4.49805 20.6904C2.01394 20.6903 0.000196352 18.6765 0 16.1924C0 13.7081 2.01382 11.6935 4.49805 11.6934ZM10.3867 0C12.8709 0 14.8846 2.01388 14.8848 4.49805C14.8848 4.8377 14.847 5.16846 14.7755 5.48643C14.4618 6.88139 14.1953 8.4633 14.9928 9.65L16.2575 11.5319C16.3363 11.6491 16.4727 11.7115 16.6137 11.703C16.7369 11.6957 16.8525 11.6343 16.9214 11.5318L18.1876 9.64717C18.9772 8.47198 18.7236 6.90783 18.4205 5.52484C18.3523 5.21392 18.3164 4.89094 18.3164 4.55957C18.3167 2.07546 20.3313 0.0615234 22.8154 0.0615234C25.2994 0.0617476 27.3132 2.0756 27.3135 4.55957C27.3135 4.93883 27.2665 5.30712 27.178 5.65896C26.8547 6.94441 26.5817 8.37932 27.2446 9.52714L28.459 11.6301C28.4819 11.6697 28.5245 11.6934 28.5703 11.6934C31.0545 11.6935 33.0684 13.7081 33.0684 16.1924C33.0682 18.6765 31.0544 20.6903 28.5703 20.6904C26.0861 20.6904 24.0725 18.6765 24.0723 16.1924C24.0723 15.8049 24.1212 15.4288 24.2133 15.0701C24.5458 13.7746 24.8298 12.3251 24.1609 11.1668L23.0044 9.16384C22.9656 9.09659 22.8931 9.05859 22.8154 9.05859C22.7983 9.05859 22.7824 9.06614 22.7728 9.08033L21.4896 10.9895C20.686 12.1851 20.9622 13.781 21.284 15.1851C21.3582 15.5089 21.3975 15.8461 21.3975 16.1924C21.3973 18.6764 19.3834 20.6902 16.8994 20.6904C14.4152 20.6904 12.4006 18.6765 12.4004 16.1924C12.4004 15.932 12.4226 15.6768 12.4651 15.4286C12.6859 14.14 12.8459 12.7122 12.1167 11.6271L11.2419 10.3253C10.6829 9.49347 9.71913 9.05932 8.78286 8.70188C7.0906 8.05584 5.88867 6.41734 5.88867 4.49805C5.88886 2.0139 7.90254 3.29835e-05 10.3867 0Z",fill:"currentColor"})}),vAn={default:"[&>tbody>tr]:h-table-row",small:"[&>tbody>tr]:h-table-row-small"},yAn=({className:e,children:t,size:n="default",style:r})=>o.jsx("table",{className:K("w-full",vAn[n],e),style:r,children:t}),bAn=({className:e,children:t})=>o.jsx("thead",{children:o.jsx("tr",{className:K("h-table-header border-b border-border1 bg-surface2/80",e),children:t})}),xAn=({className:e,children:t,...n})=>o.jsx("th",{className:K("text-neutral2 text-ui-xs h-full whitespace-nowrap text-left font-medium uppercase tracking-wide first:pl-3 last:pr-3",e),...n,children:t}),wAn=({className:e,children:t,...n})=>o.jsx("tbody",{className:K("",e),...n,children:t}),SAn=y.forwardRef(({className:e,children:t,selected:n=!1,style:r,onClick:s,isActive:a=!1,...i},l)=>{const c=y.useRef(null);y.useEffect(()=>{l&&(typeof l=="function"?l(c.current):l.current=c.current)},[l]),y.useEffect(()=>{a&&c.current&&(c.current.focus(),c.current.scrollIntoView({block:"nearest"}))},[a]);const u=d=>{d.key==="Enter"&&s&&s()};return o.jsx("tr",{className:K("border-b border-border1","transition-colors duration-normal ease-out-custom","hover:bg-surface3","focus:bg-surface3 focus:outline-hidden focus:ring-1 focus:ring-inset focus:ring-accent1/50",n&&"bg-surface4",s&&"cursor-pointer",e),style:r,onClick:s,ref:c,tabIndex:s?0:void 0,onKeyDown:u,"data-active":a||void 0,...i,children:t})}),kAn=({className:e,children:t,...n})=>o.jsx("td",{className:K("text-neutral5 first:pl-3 last:pr-3",e),...n,children:o.jsx("div",{className:K("flex h-full w-full shrink-0 items-center"),children:t})}),OAn=cl(K("flex w-full text-neutral6 border bg-transparent","transition-all duration-normal ease-out-custom","placeholder:text-neutral2 placeholder:transition-opacity placeholder:duration-normal","focus:placeholder:opacity-70","min-h-[80px] resize-y"),{variants:{variant:{default:K(NF,"rounded-xl",_k),filled:K(NF,"rounded-xl",_k),outline:K(nut,"rounded-xl",_k),unstyled:rut},size:{sm:"px-2 py-1.5 text-ui-sm",md:"px-3 py-2 text-ui-md",default:"px-3 py-2 text-ui-md",lg:"px-4 py-3 text-ui-lg"}},defaultVariants:{variant:"default",size:"default"}}),ql=y.forwardRef(({className:e,size:t,testId:n,variant:r,error:s,...a},i)=>o.jsx("textarea",{className:K(OAn({variant:r,size:t}),s&&"border-error focus-visible:border-error",e),"data-testid":n,ref:i,"aria-invalid":s,...a}));ql.displayName="Textarea";let v4e={},y4e={},b4e="";function _An(e){if(typeof document>"u")return!1;const t=dr(e);return Ks(t).innerWidth-t.documentElement.clientWidth>0}function CAn(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const n=dr(e),r=n.documentElement,s=n.body,a=y1(r)?r:s,i=a.style.overflowY,l=r.style.scrollbarGutter;r.style.scrollbarGutter="stable",a.style.overflowY="scroll";const c=a.offsetWidth;a.style.overflowY="hidden";const u=a.offsetWidth;return a.style.overflowY=i,r.style.scrollbarGutter=l,c===u}function EAn(e){const t=dr(e),n=t.documentElement,r=t.body,s=y1(n)?n:r,a={overflowY:s.style.overflowY,overflowX:s.style.overflowX};return Object.assign(s.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(s.style,a)}}function jAn(e){const t=dr(e),n=t.documentElement,r=t.body,s=Ks(n);let a=0,i=0,l=!1;const c=$d.create();if(OU&&(s.visualViewport?.scale??1)!==1)return()=>{};function u(){const h=s.getComputedStyle(n),m=s.getComputedStyle(r),b=(h.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";a=n.scrollTop,i=n.scrollLeft,v4e={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},b4e=n.style.scrollBehavior,y4e={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const w=n.scrollHeight>n.clientHeight,S=n.scrollWidth>n.clientWidth,O=h.overflowY==="scroll"||m.overflowY==="scroll",_=h.overflowX==="scroll"||m.overflowX==="scroll",C=Math.max(0,s.innerWidth-r.clientWidth),j=Math.max(0,s.innerHeight-r.clientHeight),E=parseFloat(m.marginTop)+parseFloat(m.marginBottom),N=parseFloat(m.marginLeft)+parseFloat(m.marginRight),I=y1(n)?n:r;if(l=CAn(e),l){n.style.scrollbarGutter=b,I.style.overflowY="hidden",I.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:b,overflowY:"hidden",overflowX:"hidden"}),(w||O)&&(n.style.overflowY="scroll"),(S||_)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:E||j?`calc(100dvh - ${E+j}px)`:"100dvh",width:N||C?`calc(100vw - ${N+C}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=a,r.scrollLeft=i,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function d(){Object.assign(n.style,v4e),Object.assign(r.style,y4e),l||(n.scrollTop=a,n.scrollLeft=i,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=b4e)}function f(){d(),c.request(u)}u();const p=Br(s,"resize",f);return()=>{c.cancel(),d(),typeof s.removeEventListener=="function"&&p()}}class TAn{lockCount=0;restore=null;timeoutLock=Vh.create();timeoutUnlock=Vh.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(t){if(this.lockCount===0||this.restore!==null)return;const r=dr(t).documentElement,s=Ks(r).getComputedStyle(r).overflowY;if(s==="hidden"||s==="clip"){this.restore=ma;return}const a=jye||!_An(t);this.restore=a?EAn(t):jAn(t)}}const NAn=new TAn;function Hht(e=!0,t=null){Tt(()=>{if(e)return NAn.acquire(t)},[e,t])}function IAn(e){const{store:t,parentContext:n,actionsRef:r,isDrawer:s}=e,a=t.useState("open");Vct(t,a),GM(t);const{forceUnmount:i}=QM(a,t),l=y.useCallback(()=>{t.setOpen(!1,Vt(VM))},[t]);return y.useImperativeHandle(r,()=>({unmount:i,close:l}),[i,l]),{parentContext:n,isDrawer:s}}function AAn({store:e,dialogRoot:t}){const{parentContext:n,isDrawer:r}=t,s=e.useState("open"),a=e.useState("disablePointerDismissal"),i=e.useState("modal"),l=e.useState("popupElement"),c=e.useState("floatingRootContext"),[u,d]=y.useState(0),[f,p]=y.useState(0),h=u===0,m=l_(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?"intentional":{mouse:i==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(w){if(!e.context.outsidePressEnabledRef.current||"button"in w&&w.button!==0||"touches"in w&&w.touches.length!==1)return!1;const S=Si(w);if(h&&!a){const O=S;return i&&(e.context.internalBackdropRef.current||e.context.backdropRef.current)?e.context.internalBackdropRef.current===O||e.context.backdropRef.current===O||dn(O,l)&&!O?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:h});Hht(s&&i===!0,l),e.useContextCallback("onNestedDialogOpen",(w,S)=>{d(w),p(S)}),e.useContextCallback("onNestedDialogClose",()=>{d(0),p(0)}),y.useEffect(()=>(n?.onNestedDialogOpen&&s&&n.onNestedDialogOpen(u+1,f+(r?1:0)),n?.onNestedDialogClose&&!s&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&s&&n.onNestedDialogClose()}),[r,s,u,f,n]);const g=m.reference??hs,v=m.trigger??hs,b=y.useMemo(()=>Eo(uy,m.floating),[m.floating]);return YM(e,{activeTriggerProps:g,inactiveTriggerProps:v,popupProps:b,nestedOpenDialogCount:u,nestedOpenDrawerCount:f}),null}const xxe=y.createContext(!1),Wht=y.createContext(void 0);function md(e){const t=y.useContext(Wht);if(e===!1&&t===void 0)throw new Error(Sr(27));return t}const RAn={...KM,modal:lt(e=>e.modal),nested:lt(e=>e.nested),nestedOpenDialogCount:lt(e=>e.nestedOpenDialogCount),nestedOpenDrawerCount:lt(e=>e.nestedOpenDrawerCount),disablePointerDismissal:lt(e=>e.disablePointerDismissal),openMethod:lt(e=>e.openMethod),descriptionElementId:lt(e=>e.descriptionElementId),titleElementId:lt(e=>e.titleElementId),viewportElement:lt(e=>e.viewportElement),role:lt(e=>e.role)};class wxe extends tN{constructor(t,n,r=!1){const s=new c_,a=PAn(t);a.floatingRootContext=RU(s,n,r),super(a,{popupRef:y.createRef(),backdropRef:y.createRef(),internalBackdropRef:y.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:s,onOpenChange:void 0,onOpenChangeComplete:void 0},RAn)}setOpen=(t,n)=>{if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!t&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(t,n),n.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(t,n);const r={open:t};AU(r,t,n.trigger),this.update(r)};static useStore(t,n){return IU(t,(s,a)=>new wxe(n,s,a),!0).store}}function PAn(e={}){return{...XM(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:"dialog",...e}}function Zht(e,t="dialog"){const{children:n,open:r,defaultOpen:s=!1,onOpenChange:a,onOpenChangeComplete:i,disablePointerDismissal:l=!1,modal:c=!0,actionsRef:u,handle:d,triggerId:f,defaultTriggerId:p=null}=e,h=t==="drawer",m=t==="alert-dialog",g=m?!0:c,v=m||l,b=m?"alertdialog":"dialog",w=md(!0),O={modal:g,disablePointerDismissal:v,nested:!!w,role:b},_=wxe.useStore(d?.store,{open:s,openProp:r,activeTriggerId:p,triggerIdProp:f,...O});s_(()=>{const $=r===void 0&&_.state.open===!1&&s===!0?{open:!0,activeTriggerId:p}:null;m?_.update($?{...O,...$}:O):$&&_.update($)}),_.useControlledProp("openProp",r),_.useControlledProp("triggerIdProp",f),_.useSyncedValues(O),_.useContextCallback("onOpenChange",a),_.useContextCallback("onOpenChangeComplete",i);const C=_.useState("open"),j=_.useState("mounted"),E=_.useState("payload"),N=IAn({store:_,actionsRef:u,parentContext:w?.store.context,isDrawer:h}),I=C||j,P=y.useMemo(()=>({store:_}),[_]);return o.jsx(xxe.Provider,{value:!1,children:o.jsxs(Wht.Provider,{value:P,children:[I&&o.jsx(AAn,{store:_,dialogRoot:N}),typeof n=="function"?n({payload:E}):n]})})}function $An(e){return Zht(e,"alert-dialog")}const MAn={...yf,...Hl},Ght=y.forwardRef(function(t,n){const{render:r,className:s,style:a,forceRender:i=!1,...l}=t,{store:c}=md(),u=c.useState("open"),d=c.useState("nested"),f=c.useState("mounted"),p=c.useState("transitionStatus");return En("div",t,{state:{open:u,transitionStatus:p},ref:[c.context.backdropRef,n],stateAttributesMapping:MAn,props:[{role:"presentation",hidden:!f,style:{userSelect:"none",WebkitUserSelect:"none"}},l],enabled:i||!d})}),Qht=y.createContext(void 0);function Sxe(e=!1){const t=y.useContext(Qht);if(t===void 0&&!e)throw new Error(Sr(16));return t}function DAn(e){const{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:s=0,isNativeButton:a}=e,i=r&&t!==!1,l=r&&t===!1;return{props:y.useMemo(()=>{const u={onKeyDown(d){n&&t&&d.key!=="Tab"&&d.preventDefault()}};return r||(u.tabIndex=s,!a&&n&&(u.tabIndex=t?s:-1)),(a&&(t||i)||!a&&n)&&(u["aria-disabled"]=n),a&&(!t||l)&&(u.disabled=n),u},[r,n,t,i,l,a,s])}}function gd(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:s=!0,composite:a}=e,i=y.useRef(null),l=Sxe(!0),c=a??l!==void 0,{props:u}=DAn({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:s}),d=y.useCallback(()=>{const h=i.current;uX(h)&&c&&t&&u.disabled===void 0&&h.disabled&&(h.disabled=!1)},[t,u.disabled,c]);Tt(d,[d]);const f=y.useCallback((h={})=>{const{onClick:m,onMouseDown:g,onKeyUp:v,onKeyDown:b,onPointerDown:w,...S}=h;return Eo({onClick(O){if(t){O.preventDefault();return}m?.(O)},onMouseDown(O){t||g?.(O)},onKeyDown(O){if(t||(_F(O),b?.(O),O.baseUIHandlerPrevented))return;const _=O.target===O.currentTarget,C=O.currentTarget,j=uX(C),E=!s&&LAn(C),N=_&&(s?j:!E),I=O.key==="Enter",P=O.key===" ",$=C.getAttribute("role"),z=$?.startsWith("menuitem")||$==="option"||$==="gridcell";if(_&&c&&P){if(O.defaultPrevented&&z)return;O.preventDefault(),E||s&&j?(C.click(),O.preventBaseUIHandler()):N&&(m?.(O),O.preventBaseUIHandler());return}N&&(!s&&(P||I)&&O.preventDefault(),!s&&I&&m?.(O))},onKeyUp(O){if(!t){if(_F(O),v?.(O),O.target===O.currentTarget&&s&&c&&uX(O.currentTarget)&&O.key===" "){O.preventDefault();return}O.baseUIHandlerPrevented||O.target===O.currentTarget&&!s&&!c&&O.key===" "&&m?.(O)}},onPointerDown(O){if(t){O.preventDefault();return}w?.(O)}},s?{type:"button"}:{role:"button"},u,S)},[t,u,c,s]),p=mt(h=>{i.current=h,d()});return{getButtonProps:f,buttonRef:p}}function uX(e){return Ca(e)&&e.tagName==="BUTTON"}function LAn(e){return!!(e?.tagName==="A"&&e?.href)}const u3=y.forwardRef(function(t,n){const{render:r,className:s,style:a,disabled:i=!1,nativeButton:l=!0,...c}=t,{store:u}=md(),d=u.useState("open"),{getButtonProps:f,buttonRef:p}=gd({disabled:i,native:l}),h={disabled:i};function m(g){d&&u.setOpen(!1,Vt(Iye,g.nativeEvent))}return En("button",t,{state:h,ref:[n,p],props:[{onClick:m},c,f]})}),kxe=y.forwardRef(function(t,n){const{render:r,className:s,style:a,id:i,...l}=t,{store:c}=md(),u=Di(i);return c.useSyncedValueWithCleanup("descriptionElementId",u),En("p",t,{ref:n,props:[{id:u},l]})});let FAn=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),zAn=(function(e){return e[e.open=Ju.open]="open",e[e.closed=Ju.closed]="closed",e[e.startingStyle=Ju.startingStyle]="startingStyle",e[e.endingStyle=Ju.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const Yht=y.createContext(void 0);function Oxe(){const e=y.useContext(Yht);if(e===void 0)throw new Error(Sr(26));return e}const rj="ArrowUp",fk="ArrowDown",qP="ArrowLeft",sj="ArrowRight",d3="Home",f3="End",Xht="PageUp",Kht="PageDown",Jht=new Set([qP,sj]),BAn=new Set([qP,sj,d3,f3]),emt=new Set([rj,fk]),UAn=new Set([rj,fk,d3,f3]),tmt=new Set([...Jht,...emt]),k1=new Set([...tmt,d3,f3]),nmt="Shift",qAn="Control",VAn="Alt",HAn="Meta",WAn=new Set([nmt,qAn,VAn,HAn]);function ZAn(e){return Ca(e)&&e.tagName==="INPUT"}function x4e(e){return!!(ZAn(e)&&e.selectionStart!=null||Ca(e)&&e.tagName==="TEXTAREA")}function w4e(e,t,n,r){if(!e||!t||!t.scrollTo)return;let s=e.scrollLeft,a=e.scrollTop;const i=e.clientWidth<e.scrollWidth,l=e.clientHeight<e.scrollHeight;if(i&&r!=="vertical"){const c=S4e(e,t,"left"),u=SL(e),d=SL(t);n==="ltr"&&(c+t.offsetWidth+d.scrollMarginRight>e.scrollLeft+e.clientWidth-u.scrollPaddingRight?s=c+t.offsetWidth+d.scrollMarginRight-e.clientWidth+u.scrollPaddingRight:c-d.scrollMarginLeft<e.scrollLeft+u.scrollPaddingLeft&&(s=c-d.scrollMarginLeft-u.scrollPaddingLeft)),n==="rtl"&&(c-d.scrollMarginRight<e.scrollLeft+u.scrollPaddingLeft?s=c-d.scrollMarginLeft-u.scrollPaddingLeft:c+t.offsetWidth+d.scrollMarginRight>e.scrollLeft+e.clientWidth-u.scrollPaddingRight&&(s=c+t.offsetWidth+d.scrollMarginRight-e.clientWidth+u.scrollPaddingRight))}if(l&&r!=="horizontal"){const c=S4e(e,t,"top"),u=SL(e),d=SL(t);c-d.scrollMarginTop<e.scrollTop+u.scrollPaddingTop?a=c-d.scrollMarginTop-u.scrollPaddingTop:c+t.offsetHeight+d.scrollMarginBottom>e.scrollTop+e.clientHeight-u.scrollPaddingBottom&&(a=c+t.offsetHeight+d.scrollMarginBottom-e.clientHeight+u.scrollPaddingBottom)}e.scrollTo({left:s,top:a,behavior:"auto"})}function S4e(e,t,n){const r=n==="left"?"offsetLeft":"offsetTop";let s=0;for(;t.offsetParent&&(s+=t[r],t.offsetParent!==e);)t=t.offsetParent;return s}function SL(e){const t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}const GAn={...yf,...Hl,nestedDialogOpen(e){return e?{[zAn.nestedDialogOpen]:""}:null}},rmt=y.forwardRef(function(t,n){const{render:r,className:s,style:a,finalFocus:i,initialFocus:l,...c}=t,{store:u}=md(),d=u.useState("descriptionElementId"),f=u.useState("disablePointerDismissal"),p=u.useState("floatingRootContext"),h=u.useState("popupProps"),m=u.useState("modal"),g=u.useState("mounted"),v=u.useState("nested"),b=u.useState("nestedOpenDialogCount"),w=u.useState("open"),S=u.useState("openMethod"),O=u.useState("titleElementId"),_=u.useState("transitionStatus"),C=u.useState("role"),j=p.useState("floatingId"),E=c.id??j;Oxe(),Wl({open:w,ref:u.context.popupRef,onComplete(){w&&u.context.onOpenChangeComplete?.(!0)}});function N(q){return q==="touch"?u.context.popupRef.current:!0}const I=l===void 0?N:l,P=b>0,$=u.useStateSetter("popupElement"),D=En("div",t,{state:{open:w,nested:v,transitionStatus:_,nestedDialogOpen:P},props:[h,{id:E,"aria-labelledby":O??void 0,"aria-describedby":d??void 0,role:C,...uy,hidden:!g,onKeyDown(q){k1.has(q.key)&&q.stopPropagation()},style:{[FAn.nestedDialogs]:b}},c],ref:[n,u.context.popupRef,$],stateAttributesMapping:GAn});return o.jsx(eN,{context:p,openInteractionType:S,disabled:!g,closeOnFocusOut:!f,initialFocus:I,returnFocus:i,modal:m!==!1,restoreFocus:"popup",children:D})}),p3=y.forwardRef(function(t,n){const{cutout:r,...s}=t;let a;if(r){const i=r.getBoundingClientRect();a=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${i.left}px ${i.top}px,${i.left}px ${i.bottom}px,${i.right}px ${i.bottom}px,${i.right}px ${i.top}px,${i.left}px ${i.top}px)`}return o.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...s,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:a}})}),_xe=y.forwardRef(function(t,n){const{keepMounted:r=!1,...s}=t,{store:a}=md(),i=a.useState("mounted"),l=a.useState("modal"),c=a.useState("open");return i||r?o.jsx(Yht.Provider,{value:r,children:o.jsxs(WM,{ref:n,...s,children:[i&&l===!0&&o.jsx(p3,{ref:a.context.internalBackdropRef,inert:aN(!c)}),t.children]})}):null}),Cxe=y.forwardRef(function(t,n){const{render:r,className:s,style:a,id:i,...l}=t,{store:c}=md(),u=Di(i);return c.useSyncedValueWithCleanup("titleElementId",u),En("h2",t,{ref:n,props:[{id:u},l]})});function QAn(e){const t=y.useRef(""),n=y.useCallback(s=>{s.defaultPrevented||(t.current=s.pointerType,e(s,s.pointerType))},[e]);return{onClick:y.useCallback(s=>{if(s.detail===0){e(s,"keyboard");return}"pointerType"in s?e(s,s.pointerType):e(s,t.current),t.current=""},[e]),onPointerDown:n}}function Sv(e,t){const n=y.useRef(e),r=mt(t);Tt(()=>{n.current!==e&&r(n.current)},[e,r]),Tt(()=>{n.current=e},[e])}function Exe(e,t){const n=mt((a,i)=>{(typeof e=="function"?e():e)||t(i||(jye?"touch":""))}),{onClick:r,onPointerDown:s}=QAn(n);return y.useMemo(()=>({onClick:r,onPointerDown:s}),[r,s])}function jxe(e){const[t,n]=y.useState(null),r=Exe(e,n);return Sv(e,s=>{s&&!e&&n(null)}),y.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}const Txe=y.forwardRef(function(t,n){const{render:r,className:s,style:a,disabled:i=!1,nativeButton:l=!0,id:c,payload:u,handle:d,...f}=t,p=md(!0),h=d?.store??p?.store;if(!h)throw new Error(Sr(79));const m=Di(c),g=h.useState("floatingRootContext"),v=h.useState("isOpenedByTrigger",m),b=h.useState("triggerPopupId",m),w=y.useRef(null),{registerTrigger:S,isMountedByThisTrigger:O}=ZM(m,w,h,{payload:u}),{getButtonProps:_,buttonRef:C}=gd({disabled:i,native:l}),j=o_(g,{enabled:g!=null}),E=Exe(()=>h.select("open"),P=>{h.set("openMethod",P)}),N={disabled:i,open:v},I=h.useState("triggerProps",O);return En("button",t,{state:N,ref:[C,n,S,w],props:[j.reference,I,E,{[Lye]:"",id:m,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":b},f,_],stateAttributesMapping:nN})}),YAn=Txe;let k4e=(function(e){return e[e.open=Ju.open]="open",e[e.closed=Ju.closed]="closed",e[e.startingStyle=Ju.startingStyle]="startingStyle",e[e.endingStyle=Ju.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const XAn={...yf,...Hl,nested(e){return e?{[k4e.nested]:""}:null},nestedDialogOpen(e){return e?{[k4e.nestedDialogOpen]:""}:null}},KAn=y.forwardRef(function(t,n){const{render:r,className:s,style:a,children:i,...l}=t,c=Oxe(),{store:u}=md(),d=u.useState("open"),f=u.useState("nested"),p=u.useState("transitionStatus"),h=u.useState("nestedOpenDialogCount"),m=u.useState("mounted"),g=u.useStateSetter("viewportElement"),v=h>0;return En("div",t,{enabled:c||m,state:{open:d,nested:f,transitionStatus:p,nestedDialogOpen:v},ref:[n,g],stateAttributesMapping:XAn,props:[{role:"presentation",hidden:!m,style:{pointerEvents:d?void 0:"none"},children:i},l]})});function h3(e,t){return e&&y.isValidElement(t)?{render:t}:void 0}const JAn=$An;function jt({open:e,onOpenChange:t,children:n}){return o.jsx(JAn,{open:e,onOpenChange:t,children:n})}const smt=y.forwardRef(({asChild:e,children:t,...n},r)=>o.jsx(YAn,{ref:r,...h3(e,t),...n,children:e?void 0:t}));smt.displayName="AlertDialogTrigger";const amt=_xe,Nxe=y.forwardRef(({className:e,...t},n)=>o.jsx(Ght,{ref:n,className:K("dialog-overlay-anim fixed inset-0 z-50 bg-overlay backdrop-blur-xs",e),...t}));Nxe.displayName="AlertDialogOverlay";const imt=y.forwardRef(({className:e,...t},n)=>o.jsxs(amt,{children:[o.jsx(Nxe,{}),o.jsx(rmt,{ref:n,"data-slot":"alert-dialog-content",className:K("dialog-content-anim","fixed left-[50%] top-[50%] z-50 grid translate-x-[-50%] translate-y-[-50%]","w-full max-w-[calc(100%-2rem)] sm:max-w-lg","rounded-xl border border-border1/40 bg-surface2/96 backdrop-blur-md shadow-dialog",e),...t})]}));imt.displayName="AlertDialogContent";const omt=({className:e,...t})=>o.jsx("div",{className:K("flex flex-col gap-0.5 px-4 py-3 text-left",e),...t});omt.displayName="AlertDialogHeader";const lmt=({className:e,...t})=>o.jsx("div",{className:K("flex flex-col-reverse gap-1.5 px-4 py-2.5 sm:flex-row sm:justify-end",e),...t});lmt.displayName="AlertDialogFooter";const cmt=({className:e,...t})=>o.jsx("div",{className:K("overflow-y-auto px-4 py-3.5 max-h-[50vh]",e),...t});cmt.displayName="AlertDialogBody";const umt=y.forwardRef(({className:e,...t},n)=>o.jsx(Cxe,{ref:n,className:K("text-ui-md font-medium",e),...t}));umt.displayName="AlertDialogTitle";const dmt=y.forwardRef(({className:e,...t},n)=>o.jsx(kxe,{ref:n,className:K("text-ui-sm text-neutral3",e),...t}));dmt.displayName="AlertDialogDescription";const fmt=y.forwardRef(({className:e,...t},n)=>o.jsx(u3,{ref:n,className:K(t3({variant:"primary",size:"lg"}),e),...t}));fmt.displayName="AlertDialogAction";const pmt=y.forwardRef(({className:e,...t},n)=>o.jsx(u3,{ref:n,className:K(t3({variant:"default",size:"lg"}),e),...t}));pmt.displayName="AlertDialogCancel";jt.Trigger=smt;jt.Portal=amt;jt.Overlay=Nxe;jt.Content=imt;jt.Header=omt;jt.Footer=lmt;jt.Body=cmt;jt.Title=umt;jt.Description=dmt;jt.Action=fmt;jt.Cancel=pmt;function Jd({controlled:e,default:t,name:n,state:r="value"}){const{current:s}=y.useRef(e!==void 0),[a,i]=y.useState(t),l=s?e:a,c=y.useCallback(u=>{s||i(u)},[]);return[l,c]}function eRn(e){if(!e)return null;for(const t of e.elements){const n=t.tagName;if(n==="BUTTON"||n==="INPUT"){const r=t;if(r.type==="submit")return r}}return null}let O4e=(function(e){return e.checked="data-checked",e.unchecked="data-unchecked",e.indeterminate="data-indeterminate",e.disabled="data-disabled",e.readonly="data-readonly",e.required="data-required",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({}),_4e=(function(e){return e.disabled="data-disabled",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const tRn={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},SE={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},nRn={disabled:!1,...SE},O1={valid(e){return e===null?null:e?{[_4e.valid]:""}:{[_4e.invalid]:""}}};function hmt(e){return y.useMemo(()=>({checked(t){return e.indeterminate?{}:t?{[O4e.checked]:""}:{[O4e.unchecked]:""}},...O1}),[e.indeterminate])}const mmt={invalid:void 0,name:void 0,validityData:{state:tRn,errors:[],error:"",value:"",initialValue:null},setValidityData:ma,disabled:void 0,touched:SE.touched,setTouched:ma,dirty:SE.dirty,setDirty:ma,filled:SE.filled,setFilled:ma,focused:SE.focused,setFocused:ma,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:nRn,markedDirtyRef:{current:!1},registerFieldControl:ma,validation:{getValidationProps:(e=hs)=>e,getInputValidationProps:(e=hs)=>e,inputRef:{current:null},commit:async()=>{}}},gmt=y.createContext(mmt);function sm(e=!0){const t=y.useContext(gmt);if(t.setValidityData===ma&&!e)throw new Error(Sr(28));return t}function mN(e,t,n,r,s=!0){const{registerFieldControl:a}=sm(),i=y.useRef(null);i.current||(i.current=Symbol()),Tt(()=>{const l=i.current;return!l||!s?void 0:(a(l,{controlRef:e,getValue:r,id:t,value:n}),()=>{a(l,void 0)})},[e,s,r,t,a,n])}const rRn=y.createContext({disabled:!1});function vmt(){return y.useContext(rRn)}const sRn=y.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:ma,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function gN(){return y.useContext(sRn)}const aRn=y.createContext({controlId:void 0,registerControlId:ma,labelId:void 0,setLabelId:ma,messageIds:[],setMessageIds:ma,getDescriptionProps:e=>e});function Ox(){return y.useContext(aRn)}function Ixe(e,t,n,r=!0,s){const[a,i]=y.useState(),l=Di(s?`${s}-label`:void 0),c=e??t??a;return Tt(()=>{const u=e||t||!r?void 0:iRn(n.current,l);a!==u&&i(u)}),c}function iRn(e,t){const n=oRn(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function oRn(e){if(!e)return;const t=e.parentElement;if(t&&t.tagName==="LABEL")return t;const n=e.id;if(n){const s=e.nextElementSibling;if(s&&s.htmlFor===n)return s}const r=e.labels;return r&&r[0]}const lRn=y.createContext(void 0);function cRn(e=!0){const t=y.useContext(lRn);if(t===void 0&&!e)throw new Error(Sr(3));return t}const ymt=y.createContext(void 0);function uRn(){const e=y.useContext(ymt);if(e===void 0)throw new Error(Sr(14));return e}const dRn="data-parent",fRn=y.forwardRef(function(t,n){const{checked:r,className:s,defaultChecked:a=!1,"aria-labelledby":i,disabled:l=!1,form:c,id:u,indeterminate:d=!1,inputRef:f,name:p,onCheckedChange:h,parent:m=!1,readOnly:g=!1,render:v,required:b=!1,uncheckedValue:w,value:S,nativeButton:O=!1,style:_,...C}=t,{clearErrors:j}=gN(),{disabled:E,name:N,setDirty:I,setFilled:P,setFocused:$,setTouched:z,state:D,validationMode:q,validityData:W,shouldValidateOnChange:L,validation:F}=sm(),B=vmt(),{labelId:M,controlId:Q,registerControlId:V,getDescriptionProps:R}=Ox(),U=cRn(),Z=U?.parent,X=Z&&U.allValues,te=E||B.disabled||U?.disabled||l,ee=N??p,J=S??ee,ie=Di(),ue=Di();let Y=Q;X?Y=m?ue:`${Z.id}-${J}`:u&&(Y=u);let ne={};X&&(m?ne=U.parent.getParentProps():J&&(ne=U.parent.getChildProps(J)));const{checked:le=r,indeterminate:pe=d,onCheckedChange:se,...he}=ne,be=U?.value,Se=U?.setValue,Ne=U?.defaultValue,Oe=y.useRef(null),Ae=hc(()=>Symbol("checkbox-control")),Ue=y.useRef(!1),{getButtonProps:ce,buttonRef:ae}=gd({disabled:te,native:O}),re=U?.validation??F,[me,ye]=Jd({controlled:J&&be&&!m?be.includes(J):le,default:J&&Ne&&!m?Ne.includes(J):a,name:"Checkbox",state:"checked"});Tt(()=>{V!==ma&&(Ue.current=!0,V(Ae.current,Y))},[Y,V,Ae]),y.useEffect(()=>{const Fe=Ae.current;return()=>{!Ue.current||V===ma||(Ue.current=!1,V(Fe,void 0))}},[V,Ae]),mN(Oe,ie,me,void 0,!U);const je=y.useRef(null),Re=ku(f,je,re.inputRef),Qe=Ixe(i,M,je,!O,Y??void 0);Tt(()=>{je.current&&(je.current.indeterminate=pe,me&&P(!0))},[me,pe,P]),Sv(me,()=>{U&&!m||(j(ee),P(me),I(me!==W.initialValue),L()?re.commit(me):re.commit(me,!0))});const Ze=Eo({checked:me,disabled:te,form:c,name:m?void 0:ee,id:O?void 0:Y??void 0,required:b,ref:Re,style:ee?JT:qw,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(Fe){if(Fe.nativeEvent.defaultPrevented)return;if(g){Fe.preventDefault();return}const Ke=Fe.currentTarget.checked,Ye=Vt(Oo,Fe.nativeEvent);if(se?.(Ke,Ye),h?.(Ke,Ye),!Ye.isCanceled&&(ye(Ke),J&&be&&Se&&!m&&!X)){const Rt=Ke?[...be,J]:be.filter(Ct=>Ct!==J);Se(Rt,Ye)}},onFocus(){Oe.current?.focus()}},S!==void 0?{value:(U?me&&S:S)||""}:hs,R,U?re.getValidationProps:re.getInputValidationProps),ke=X?!!le:me,_e=X&&pe||d;y.useEffect(()=>{if(!Z||!J)return;const Fe=Z.disabledStatesRef.current;return Fe.set(J,te),()=>{Fe.delete(J)}},[Z,te,J]);const Ce=y.useMemo(()=>({...D,checked:ke,disabled:te,readOnly:g,required:b,indeterminate:_e}),[D,ke,te,g,b,_e]),Ee=hmt(Ce),$e=En("span",t,{state:Ce,ref:[ae,Oe,n,U?.registerControlRef],props:[{id:O?Y??void 0:ie,role:"checkbox","aria-checked":pe?"mixed":me,"aria-readonly":g||void 0,"aria-required":b||void 0,"aria-labelledby":Qe,[dRn]:m?"":void 0,onFocus(){$(!0)},onBlur(){const Fe=je.current;Fe&&(z(!0),$(!1),q==="onBlur"&&re.commit(U?be:Fe.checked))},onKeyDown(Fe){if(Fe.key!=="Enter"||(Fe.preventBaseUIHandler(),Fe.defaultPrevented))return;const Ke=je.current?.form??null,Ye=Fe.currentTarget,Rt=Fe.nativeEvent,Ct=Fe.preventDefault,en=Rt.preventDefault;let bt=!1;Fe.preventDefault=()=>{bt=!0,Ct.call(Fe)},Rt.preventDefault=()=>{bt=!0,en.call(Rt)},en.call(Rt),Ks(Ye).queueMicrotask(()=>{Fe.preventDefault=Ct,Rt.preventDefault=en,bt||eRn(Ke)?.click()})},onClick(Fe){if(g||te)return;Fe.preventDefault();const Ke=je.current;Ke&&Ke.dispatchEvent(new(Ks(Ke)).PointerEvent("click",{bubbles:!0,shiftKey:Fe.shiftKey,ctrlKey:Fe.ctrlKey,altKey:Fe.altKey,metaKey:Fe.metaKey}))}},R,re.getValidationProps,C,he,ce],stateAttributesMapping:Ee});return o.jsxs(ymt.Provider,{value:Ce,children:[$e,!me&&!U&&ee&&!m&&w!==void 0&&o.jsx("input",{type:"hidden",form:c,name:ee,value:w}),o.jsx("input",{...Ze,suppressHydrationWarning:!0})]})}),pRn=y.forwardRef(function(t,n){const{render:r,className:s,style:a,keepMounted:i=!1,...l}=t,c=uRn(),u=c.checked||c.indeterminate,{mounted:d,transitionStatus:f,setMounted:p}=wg(u),h=y.useRef(null),m={...c,transitionStatus:f};Wl({open:u,ref:h,onComplete(){u||p(!1)}});const v={...hmt(c),...Hl,...O1},b=i||d,w=En("span",t,{ref:[n,h],state:m,stateAttributesMapping:v,props:l});return b?w:null}),Yo=y.forwardRef(({className:e,checked:t,indeterminate:n,...r},s)=>{const a=t==="indeterminate";return o.jsx(fRn,{ref:s,checked:a?!1:t,indeterminate:n??a,"data-slot":"checkbox",className:K("peer flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[0.3125rem]","border border-neutral6/[0.06] bg-neutral6/[0.12] text-surface1 outline-hidden",ss.all,"hover:border-neutral6/[0.12] hover:bg-neutral6/[0.16]","active:scale-95 active:border-neutral6/[0.18] active:bg-neutral6/[0.18]","focus-visible:border-neutral5/50 focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-neutral5/55","data-[checked]:border-neutral6 data-[checked]:bg-neutral6 data-[checked]:text-surface1","data-[indeterminate]:border-neutral6 data-[indeterminate]:bg-neutral6 data-[indeterminate]:text-surface1","data-[checked]:hover:border-neutral5 data-[checked]:hover:bg-neutral5","data-[indeterminate]:hover:border-neutral5 data-[indeterminate]:hover:bg-neutral5","data-[checked]:active:border-neutral4 data-[checked]:active:bg-neutral4","data-[indeterminate]:active:border-neutral4 data-[indeterminate]:active:bg-neutral4","data-[disabled]:cursor-not-allowed data-[disabled]:border-neutral6/[0.38] data-[disabled]:bg-neutral6/[0.38] data-[disabled]:hover:border-neutral6/[0.38] data-[disabled]:hover:bg-neutral6/[0.38] data-[disabled]:active:scale-100","data-[disabled]:data-[checked]:border-neutral6/[0.38] data-[disabled]:data-[checked]:bg-neutral6/[0.38] data-[disabled]:data-[checked]:text-neutral6","data-[disabled]:data-[indeterminate]:border-neutral6/[0.38] data-[disabled]:data-[indeterminate]:bg-neutral6/[0.38] data-[disabled]:data-[indeterminate]:text-neutral6",e),...r,children:o.jsx(pRn,{keepMounted:!0,className:K("group/checkbox-indicator flex items-center justify-center text-current","opacity-0 scale-75 transition-[opacity,transform] duration-200 ease-out-custom","data-[checked]:opacity-100 data-[checked]:scale-100","data-[indeterminate]:opacity-100 data-[indeterminate]:scale-100","data-[starting-style]:opacity-0 data-[starting-style]:scale-75","data-[ending-style]:opacity-0 data-[ending-style]:scale-75"),children:o.jsx(hRn,{})})})});Yo.displayName="Checkbox";function hRn(){return o.jsxs(o.Fragment,{children:[o.jsx(kx,{className:K("size-3 scale-95 stroke-[3.25] transition-[stroke-dashoffset,transform] duration-200 ease-out-custom","[stroke-dasharray:28] [stroke-dashoffset:28]","group-data-[checked]/checkbox-indicator:[stroke-dashoffset:0]","group-data-[checked]/checkbox-indicator:scale-100","group-data-[indeterminate]/checkbox-indicator:hidden")}),o.jsx(YNn,{className:K("hidden size-3 scale-95 stroke-[3.25] transition-transform duration-200 ease-out-custom","group-data-[indeterminate]/checkbox-indicator:block","group-data-[indeterminate]/checkbox-indicator:scale-100")})]})}function mRn(e){const{open:t,defaultOpen:n,onOpenChange:r,disabled:s}=e,[a,i]=Jd({controlled:t,default:n,name:"Collapsible",state:"open"}),{mounted:l,setMounted:c,transitionStatus:u}=wg(a,!0,!0),d=Di(),[f,p]=y.useState(),h=f??d,m=mt(g=>{const v=!a,b=Vt(lg,g.nativeEvent);r(v,b),!b.isCanceled&&i(v)});return y.useMemo(()=>({disabled:s,handleTrigger:m,mounted:l,open:a,panelId:h,setMounted:c,setOpen:i,setPanelIdState:p,transitionStatus:u}),[s,m,l,a,h,c,i,p,u])}const bmt=y.createContext(void 0);function xmt(){const e=y.useContext(bmt);if(e===void 0)throw new Error(Sr(15));return e}let Axe=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=cg.startingStyle]="startingStyle",e[e.endingStyle=cg.endingStyle]="endingStyle",e})({}),gRn=(function(e){return e.panelOpen="data-panel-open",e})({});const vRn={[Axe.open]:""},yRn={[Axe.closed]:""},bRn={open(e){return e?{[gRn.panelOpen]:""}:null}},xRn={open(e){return e?vRn:yRn}},wmt={...xRn,...Hl},wRn=y.forwardRef(function(t,n){const{render:r,className:s,defaultOpen:a=!1,disabled:i=!1,onOpenChange:l,open:c,style:u,...d}=t,f=mt(l),p=mRn({open:c,defaultOpen:a,onOpenChange:f,disabled:i}),h=y.useMemo(()=>({open:p.open,disabled:p.disabled,transitionStatus:p.transitionStatus}),[p.open,p.disabled,p.transitionStatus]),m=y.useMemo(()=>({...p,onOpenChange:f,state:h}),[p,f,h]),g=En("div",t,{state:h,ref:n,props:d,stateAttributesMapping:wmt});return o.jsx(bmt.Provider,{value:m,children:g})}),SRn={...bRn,...Hl},kRn=y.forwardRef(function(t,n){const{panelId:r,open:s,handleTrigger:a,state:i,disabled:l}=xmt(),{className:c,disabled:u=l,id:d,render:f,nativeButton:p=!0,style:h,...m}=t,{getButtonProps:g,buttonRef:v}=gd({disabled:u,focusableWhenDisabled:!0,native:p});return En("button",t,{state:i,ref:[n,v],props:[{"aria-controls":s?r:void 0,"aria-expanded":s,onClick:a},m,g],stateAttributesMapping:SRn})}),pA={height:void 0,width:void 0};function ORn(e){const{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:s,mounted:a,onOpenChange:i,open:l,setMounted:c,setOpen:u,transitionStatus:d}=e,f=y.useRef(null),p=y.useRef(null),[h,m]=y.useState(pA),g=y.useRef(pA),v=y.useRef(!1),b=y.useRef(l),w=y.useRef(!1),[S,O]=y.useState(!1),_=y.useRef(null),C=ku(t,f),j=Yi({mounted:a,open:l}),E=NU(f,!1,!1),N=!l&&!a,I=S?"idle":d,P=l&&(b.current||w.current),$=!l&&a&&p.current==="css-animation"&&h.height===void 0&&h.width===void 0?g.current:h,z=n&&N&&p.current!=="css-animation",D=mt((B,M=!0)=>{M&&(g.current=B),m(B)}),q=mt(()=>{_.current?.(),_.current=null}),W=mt(B=>{q(),_.current=()=>{_.current=null,B()}}),L=mt(()=>{l&&a&&p.current==="css-animation"&&(w.current=!0)});Tt(()=>{!S||d==="starting"||O(!1)},[S,d]),y.useEffect(()=>()=>{L(),q()},[L,q]),Tt(()=>{const B=f.current;if(!B)return;!l&&_.current&&q();const M=_Rn(B,P);if(p.current=M,l&&d==="idle"&&b.current&&M==="css-animation"){g.current=xC(B);return}if(l&&d==="starting"){const R=v.current;if(v.current=!1,M==="none"){D(xC(B)),O(!0);return}if(M==="css-transition"){const U=CRn(B);if(D(xC(B)),!R)return U;const Z=hA(B,"transition-duration","0s");return W(Z),O(!0),U}if(M==="css-animation"){if(D(xC(B)),!R){hA(B,"animation-name","none")();return}const U=hA(B,"animation-name","none"),Z=hA(B,"animation-duration","0s");U(),W(Z),O(!0);return}}if(!l&&a&&(d==="idle"||d==="starting")){if(M==="none"){D(pA,!1),c(!1);return}M==="css-animation"&&(b.current=!1,w.current=!1),D(xC(B));return}if(d!=="ending")return;if(M==="none"){c(!1);return}const Q=xC(B);if(!((Q.height??0)>0||(Q.width??0)>0)){c(!1);return}D(Q),M==="css-animation"&&hA(B,"animation-name","none")()},[a,l,q,D,c,W,P,d]),Wl({enabled:l&&a&&I==="idle",open:!0,ref:f,onComplete(){l&&D(pA,!1)}}),y.useEffect(()=>{if(l||!a||I!=="ending"||!f.current)return;const M=new AbortController;let Q=-1;function V(){j.current.open||(c(!1),D(pA,!1))}return Q=$d.request(()=>{M.signal.aborted||E(V,M.signal)}),()=>{$d.cancel(Q),M.abort()}},[j,a,l,I,E,D,c]),Tt(()=>{const B=f.current;!B||!n||!N||B.setAttribute("hidden","until-found")},[N,n]),y.useEffect(function(){const M=f.current;if(!M)return;function Q(V){v.current=!0,u(!0),i(!0,Vt(Oo,V))}return Br(M,"beforematch",Q)},[i,u]);const F=s||n||a||l;return{height:$.height,props:{...z?{[Axe.startingStyle]:""}:void 0,hidden:N,id:r},ref:C,shouldPreventOpenAnimation:P,shouldRender:F,transitionStatus:I,width:$.width}}function xC(e){return{height:e.scrollHeight,width:e.scrollWidth}}function _Rn(e,t=!1){const n=Ks(e).getComputedStyle(e),r=(n.animationName.split(",").map(a=>a.trim()).some(a=>a!==""&&a!=="none")||t)&&C4e(n.animationDuration),s=C4e(n.transitionDuration);return r&&s||s?"css-transition":r?"css-animation":"none"}function C4e(e){return e.split(",").map(t=>t.trim()).some(t=>t!==""&&Number.parseFloat(t)>0)}function hA(e,t,n){const r=e.style.getPropertyValue(t),s=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===""){e.style.removeProperty(t);return}e.style.setProperty(t,r,s)}}function CRn(e){const t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(s=>{e.style.setProperty(s,"initial","important")});function n(){Object.entries(t).forEach(([s,a])=>{if(a===""){e.style.removeProperty(s);return}e.style.setProperty(s,a)})}const r=$d.request(n);return()=>{$d.cancel(r),n()}}let E4e=(function(e){return e.collapsiblePanelHeight="--collapsible-panel-height",e.collapsiblePanelWidth="--collapsible-panel-width",e})({});const ERn=y.forwardRef(function(t,n){const{className:r,hiddenUntilFound:s,keepMounted:a,render:i,id:l,style:c,...u}=t,{mounted:d,onOpenChange:f,open:p,panelId:h,setMounted:m,setPanelIdState:g,setOpen:v,state:b,transitionStatus:w}=xmt(),S=s??!1,O=a??!1;Tt(()=>{if(l)return g(l),()=>{g(void 0)}},[l,g]);const{height:_,props:C,ref:j,shouldPreventOpenAnimation:E,shouldRender:N,transitionStatus:I,width:P}=ORn({externalRef:n,hiddenUntilFound:S,id:h,keepMounted:O,mounted:d,onOpenChange:f,open:p,setMounted:m,setOpen:v,transitionStatus:w}),$={...b,transitionStatus:I},z=Oct(c,$),D=En("div",{...t,style:void 0},{state:$,ref:j,props:[C,{style:{[E4e.collapsiblePanelHeight]:_===void 0?"auto":`${_}px`,[E4e.collapsiblePanelWidth]:P===void 0?"auto":`${P}px`}},u,z?{style:z}:void 0,E?{style:{animationName:"none"}}:void 0],stateAttributesMapping:wmt});return N?D:null}),Ip=wRn,cf=De.forwardRef(({className:e,asChild:t,children:n,...r},s)=>{const a=t&&De.isValidElement(n)?{render:n}:{};return o.jsx(kRn,{ref:s,"data-slot":"collapsible-trigger",className:K("-outline-offset-2",ss.colors,zM.visible,"hover:text-neutral5","[&>svg]:transition-transform [&>svg]:duration-normal [&>svg]:ease-out-custom","[&[data-panel-open]>svg]:rotate-90",e),...a,...r,children:t?void 0:n})});cf.displayName="CollapsibleTrigger";const uf=De.forwardRef(({className:e,children:t,...n},r)=>o.jsx(ERn,{ref:r,"data-slot":"collapsible-content",className:K("overflow-hidden","h-[var(--collapsible-panel-height)] transition-[height] duration-normal ease-out-custom","data-[starting-style]:h-0 data-[ending-style]:h-0"),...n,children:o.jsx("div",{className:e,children:t})}));uf.displayName="CollapsibleContent";const Smt=y.createContext(void 0),kmt=y.createContext(void 0),Omt=y.createContext(void 0),_mt=y.createContext("");function my(){const e=y.useContext(Smt);if(!e)throw new Error(Sr(22));return e}function aq(){const e=y.useContext(kmt);if(!e)throw new Error(Sr(23));return e}function _1(){const e=y.useContext(Omt);if(!e)throw new Error(Sr(24));return e}function Cmt(){return y.useContext(_mt)}const Emt=(e,t)=>Object.is(e,t);function Gv(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function jmt(e,t,n){return!e||e.length===0?!1:e.some(r=>r===void 0?!1:Gv(t,r,n))}function bw(e,t,n){return!e||e.length===0?-1:e.findIndex(r=>r===void 0?!1:Gv(r,t,n))}function Tmt(e,t,n){return e.filter(r=>!Gv(t,r,n))}function uz(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Rxe(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function Nmt(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(Rxe(t)){for(const n of t)for(const r of n.items)if(r&&r.value==null&&r.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function cu(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return uz(e)}function Um(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?uz(e.value):uz(e)}function Pxe(e,t,n){function r(){return cu(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return t[e]??r();if(Array.isArray(t)){const s=t,a=Rxe(s)?s.flatMap(i=>i.items):s;if(e==null||typeof e!="object"){const i=a.find(l=>l.value===e);return i&&i.label!=null?i.label:r()}if("value"in e){const i=a.find(l=>l&&l.value===e.value);if(i&&i.label!=null)return i.label}}return r()}function Imt(e,t,n){return e.reduce((r,s,a)=>(a>0&&r.push(", "),r.push(o.jsx(y.Fragment,{children:Pxe(s,t,n)},a)),r),[])}const on={id:lt(e=>e.id),labelId:lt(e=>e.labelId),items:lt(e=>e.items),selectedValue:lt(e=>e.selectedValue),hasSelectionChips:lt(e=>{const t=e.selectedValue;return Array.isArray(t)&&t.length>0}),hasSelectedValue:lt(e=>{const{selectedValue:t,selectionMode:n}=e;return t==null?!1:n==="multiple"&&Array.isArray(t)?t.length>0:!0}),hasNullItemLabel:lt((e,t)=>t?Nmt(e.items):!1),open:lt(e=>e.open),mounted:lt(e=>e.mounted),forceMounted:lt(e=>e.forceMounted),inline:lt(e=>e.inline),activeIndex:lt(e=>e.activeIndex),selectedIndex:lt(e=>e.selectedIndex),isActive:lt((e,t)=>e.activeIndex===t),isSelected:lt((e,t)=>{const n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(s=>Gv(t,s,n)):Gv(t,r,n)}),transitionStatus:lt(e=>e.transitionStatus),popupProps:lt(e=>e.popupProps),inputProps:lt(e=>e.inputProps),triggerProps:lt(e=>e.triggerProps),itemProps:lt(e=>e.itemProps),positionerElement:lt(e=>e.positionerElement),listElement:lt(e=>e.listElement),triggerElement:lt(e=>e.triggerElement),inputElement:lt(e=>e.inputElement),inputGroupElement:lt(e=>e.inputGroupElement),popupSide:lt(e=>e.popupSide),openMethod:lt(e=>e.openMethod),inputInsidePopup:lt(e=>e.inputInsidePopup),inputOwnsFormValue:lt(e=>e.inputOwnsFormValue),selectionMode:lt(e=>e.selectionMode),name:lt(e=>e.name),form:lt(e=>e.form),disabled:lt(e=>e.disabled),readOnly:lt(e=>e.readOnly),required:lt(e=>e.required),grid:lt(e=>e.grid),virtualized:lt(e=>e.virtualized),itemToStringLabel:lt(e=>e.itemToStringLabel),isItemEqualToValue:lt(e=>e.isItemEqualToValue),modal:lt(e=>e.modal),autoHighlight:lt(e=>e.autoHighlight),submitOnItemClick:lt(e=>e.submitOnItemClick)};function h_(e={}){const{id:t,implicit:n=!1,controlRef:r}=e,{controlId:s,registerControlId:a}=Ox(),i=Di(t),l=n?s:void 0,c=hc(()=>Symbol("labelable-control")),u=y.useRef(!1),d=y.useRef(t!=null),f=mt(()=>{!u.current||a===ma||(u.current=!1,a(c.current,void 0))});return Tt(()=>{if(a===ma)return;let p;if(n){const h=r?.current;_r(h)&&h.closest("label")!=null?p=t??null:p=l??i}else if(t!=null)d.current=!0,p=t;else if(d.current)p=i;else{f();return}if(p===void 0){f();return}u.current=!0,a(c.current,p)},[t,r,l,a,n,i,c,f]),y.useEffect(()=>f,[f]),s??i}function jRn(e,t){return(n,r)=>{if(n==null)return!1;const s=cu(n,t);return e.contains(s,r)}}function TRn(e,t,n){return(r,s)=>{if(r==null)return!1;if(!s)return!0;const a=cu(r,t),i=n!=null?cu(n,t):"";return i&&e.contains(i,s)&&i.length===s.length?!0:e.contains(a,s)}}const j4e=new Map;function NRn(e={}){const t={usage:"search",sensitivity:"base",ignorePunctuation:!0,...e},n=`${Amt(e.locale)}|${JSON.stringify(t)}`,r=j4e.get(n);if(r)return r;const s=new Intl.Collator(e.locale,t),a={contains(i,l,c){if(!l)return!0;const u=cu(i,c);for(let d=0;d<=u.length-l.length;d+=1)if(s.compare(u.slice(d,d+l.length),l)===0)return!0;return!1},startsWith(i,l,c){if(!l)return!0;const u=cu(i,c);return s.compare(u.slice(0,l.length),l)===0},endsWith(i,l,c){if(!l)return!0;const u=cu(i,c),d=l.length;return u.length>=d&&s.compare(u.slice(u.length-d),l)===0}};return j4e.set(n,a),a}function Amt(e){return Array.isArray(e)?e.map(t=>Amt(t)).join(","):e==null?"":String(e)}const IRn=NRn,Rmt=Symbol("none"),gS={value:Rmt,index:-1};function ARn(e){const{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:s,onSelectedValueChange:a,defaultInputValue:i,inputValue:l,open:c,defaultOpen:u=!1,selectionMode:d="none",onItemHighlighted:f,name:p,form:h,disabled:m=!1,readOnly:g=!1,required:v=!1,inputRef:b,grid:w=!1,items:S,filteredItems:O,filter:_,openOnInputClick:C=!0,autoHighlight:j=!1,keepHighlight:E=!1,highlightItemOnHover:N=!0,loopFocus:I=!0,itemToStringLabel:P,itemToStringValue:$,isItemEqualToValue:z=Emt,virtualized:D=!1,inline:q=!1,fillInputOnItemPress:W=!0,modal:L=!1,limit:F=-1,autoComplete:B="list",formAutoComplete:M,locale:Q,submitOnItemClick:V=!1}=e,{clearErrors:R}=gN(),{setDirty:U,validityData:Z,shouldValidateOnChange:X,setFilled:te,name:ee,disabled:J,setTouched:ie,setFocused:ue,validationMode:Y,validation:ne}=sm(),le=dy(),pe=h_({id:t}),se=IRn({locale:Q}),[he,be]=y.useState(!1),[Se,Ne]=y.useState(null),Oe=y.useRef([]),Ae=y.useRef([]),Ue=y.useRef(null),ce=y.useRef(null),ae=y.useRef(null),re=y.useRef(null),me=y.useRef(null),ye=y.useRef(!0),je=y.useRef(!1),Re=y.useRef(null),Qe=y.useRef(null),Ze=y.useRef(null),ke=y.useRef(gS),_e=y.useRef(null),Ce=y.useRef([]),Ee=y.useRef([]),$e=J||m,Fe=ee??p,Ke=d==="multiple",Ye=d==="single",Rt=l!==void 0||i!==void 0,Ct=S!==void 0,en=O!==void 0;let bt;j==="always"?bt="always":bt=j?"input-change":!1;const[It,sn]=Jd({controlled:s,default:Ke?r??bh:r,name:"Combobox",state:"selectedValue"}),Ge=y.useMemo(()=>_===null?()=>!0:_!==void 0?_:Ye&&!he?TRn(se,P,It):jRn(se,P),[_,Ye,It,he,se,P]),at=hc(()=>Rt?i??"":Ye?cu(It,P):"").current,[ct,an]=Jd({controlled:l,default:at,name:"Combobox",state:"inputValue"}),[Kt,_n]=Jd({controlled:c,default:u,name:"Combobox",state:"open"}),Te=Rxe(S),Le=Se??(ct===""?"":String(ct).trim()),Me=Ye?cu(It,P):"",Xe=Ye&&!he&&Le!==""&&Me!==""&&Me.length===Le.length&&se.contains(Me,Le),nt=Xe?"":Le,Dt=Ct&&en&&Xe,kt=y.useMemo(()=>S?Te?S.flatMap(un=>un.items):S:bh,[S,Te]),Ft=y.useMemo(()=>{if(O&&!Dt)return O;if(!S)return bh;if(Te){const Gn=S,ks=[];let Oa=0;for(const no of Gn){if(F>-1&&Oa>=F)break;const za=nt===""?no.items:no.items.filter(If=>Ge(If,nt,P));if(za.length===0)continue;const vm=F>-1?F-Oa:1/0,wd=za.slice(0,vm);if(wd.length>0){const If={...no,items:wd};ks.push(If),Oa+=wd.length}}return ks}if(nt==="")return F>-1?kt.slice(0,F):kt;const un=[];for(const Gn of kt){if(F>-1&&un.length>=F)break;Ge(Gn,nt,P)&&un.push(Gn)}return un},[O,Dt,S,Te,nt,F,Ge,P,kt]),At=y.useMemo(()=>Te?Ft.flatMap(Gn=>Gn.items):Ft,[Ft,Te]),Et=hc(()=>new Wye({id:pe,labelId:void 0,selectedValue:It,open:Kt,filter:Ge,query:Le,items:S,selectionMode:d,listRef:Oe,labelsRef:Ae,popupRef:Ue,emptyRef:me,inputRef:ce,startDismissRef:ae,endDismissRef:re,keyboardActiveRef:ye,chipsContainerRef:Re,clearRef:Qe,valuesRef:Ce,allValuesRef:Ee,selectionEventRef:Ze,name:Fe,form:h,disabled:$e,readOnly:g,required:v,grid:w,isGrouped:Te,virtualized:D,openOnInputClick:C,itemToStringLabel:P,isItemEqualToValue:z,modal:L,autoHighlight:bt,submitOnItemClick:V,hasInputValue:Rt,mounted:!1,forceMounted:!1,transitionStatus:"idle",inline:q,activeIndex:null,selectedIndex:null,popupProps:{},inputProps:{},triggerProps:{},itemProps:hs,positionerElement:null,listElement:null,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:d==="none",onOpenChangeComplete:n||ma,setOpen:ma,setInputValue:ma,setSelectedValue:ma,setIndices:ma,onItemHighlighted:ma,handleSelection:ma,forceMount:ma,requestSubmit:ma})).current,bn=d==="none"?ct:It,nr=y.useMemo(()=>d==="none"?bn:Array.isArray(It)?It.map(un=>Um(un,$)):Um(It,$),[bn,$,d,It]),Wn=mt(f),Er=mt(n),pr=ht(Et,on.activeIndex),ys=ht(Et,on.selectedIndex),Mr=ht(Et,on.positionerElement),ur=ht(Et,on.listElement),Hs=ht(Et,on.triggerElement),da=ht(Et,on.inputElement),Sa=ht(Et,on.inputGroupElement),Ia=ht(Et,on.inline),$o=ht(Et,on.inputInsidePopup),fl=ht(Et,on.inputOwnsFormValue),el=Yi(Hs),{mounted:pm,setMounted:Ru,transitionStatus:Nf}=wg(Kt),{openMethod:hm,triggerProps:Pu}=jxe(Kt),Vr=mt(()=>nr);mN($o?el:ce,pe,bn,Vr);const ka=mt(()=>{S?Ae.current=At.map(un=>cu(un,P)):Et.set("forceMounted",!0)}),hi=y.useRef(It);Tt(()=>{It!==hi.current&&ka()},[ka,It]);const Ni=mt(un=>{Et.update(un);const Gn=un.type||"none";if(un.activeIndex!==void 0)if(un.activeIndex===null)ke.current!==gS&&(ke.current=gS,Wn(void 0,YS(Gn,void 0,{index:-1})));else{const ks=Ce.current[un.activeIndex];ke.current={value:ks,index:un.activeIndex},Wn(ks,YS(Gn,void 0,{index:un.activeIndex}))}}),Tl=mt((un,Gn)=>{if(je.current=Gn.reason===pb,e.onInputValueChange?.(un,Gn),!Gn.isCanceled){if(Gn.reason===lk){const ks=Gn.event,Oa=ks.inputType;if(ks.type==="compositionend"||Oa!=null&&Oa!==""&&Oa!=="insertReplacementText"){const za=un.trim()!=="";za&&be(!0),_e.current={hasQuery:za},za&&bt&&Et.state.activeIndex==null&&Et.set("activeIndex",0)}}an(un)}}),$u=mt((un,Gn)=>{if(Kt!==un&&(Gn.reason==="escape-key"&&Ct&&At.length===0&&!Et.state.emptyRef.current&&Gn.allowPropagation(),e.onOpenChange?.(un,Gn),!Gn.isCanceled&&(un&&Ke&&$o&&!Ia&&Se!==null&&(be(!1),Ne(null),ct!==""&&Tl("",Vt(pb,Gn.event))),!un&&he&&(Ye?(Ia||Ne(Le),Le===""&&be(!1)):Ke&&(Ia||Ne(Le),$o&&Ni({activeIndex:null}),(!$o||Ia)&&Tl("",Vt(pb,Gn.event)))),_n(un),!un&&$o&&(Gn.reason===Xb||Gn.reason===qM)&&(ie(!0),ue(!1),Y==="onBlur")))){const ks=d==="none"?ct:It;ne.commit(ks)}}),Ws=mt((un,Gn)=>{if(a?.(un,Gn),Gn.isCanceled)return;sn(un),(d==="none"&&Ue.current&&W||Ye&&!Et.state.inputInsidePopup)&&Tl(cu(un,P),Vt(Gn.reason,Gn.event)),Ye&&un!=null&&Gn.reason!==lk&&he&&!Ia&&Ne(Le)}),eu=mt((un,Gn)=>{let ks=Gn;if(ks===void 0){if(pr===null)return;ks=Ce.current[pr]}const Oa=Si(un),no=Ze.current??un;Ze.current=null;const za=Vt(vw,no),vm=Oa?.closest("a")?.getAttribute("href");if(vm){vm.startsWith("#")&&$u(!1,za);return}if(Ke){const wd=Array.isArray(It)?It:[],JN=jmt(wd,ks,Et.state.isItemEqualToValue)?Tmt(wd,ks,Et.state.isItemEqualToValue):[...wd,ks];if(Ws(JN,za),!(ce.current?ce.current.value.trim()!=="":!1))return;Et.state.inputInsidePopup?Tl("",Vt(pb,za.event)):$u(!1,za)}else Ws(ks,za),$u(!1,za)}),Ag=mt(()=>{if(!Et.state.submitOnItemClick)return;const un=ne.inputRef.current?.form??Et.state.inputElement?.form;un&&typeof un.requestSubmit=="function"&&un.requestSubmit()}),Mo=mt(()=>{if(Ru(!1),Er?.(!1),be(!1),Ne(null),Ni(d==="none"?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),Ke&&ce.current&&ce.current.value!==""&&!je.current&&Tl("",Vt(pb)),Ye)if(Et.state.inputInsidePopup)ce.current&&ce.current.value!==""&&Tl("",Vt(pb));else{const un=cu(It,P);ce.current&&ce.current.value!==un&&Tl(un,Vt(un===""?pb:Oo))}}),L1=y.useMemo(()=>Ia&&Mr?{current:Mr.closest('[role="dialog"]')}:Ue,[Ia,Mr]);Wl({enabled:!e.actionsRef,open:Kt,ref:L1,onComplete(){Kt||Mo()}}),y.useImperativeHandle(e.actionsRef,()=>({unmount:Mo}),[Mo]),Tt(function(){if(Kt||d==="none")return;const Gn=S?kt:Ee.current;if(Ke){const ks=Array.isArray(It)?It:[],Oa=ks[ks.length-1],no=bw(Gn,Oa,z);Ni({selectedIndex:no===-1?null:no})}else{const ks=bw(Gn,It,z);Ni({selectedIndex:ks===-1?null:ks})}},[Kt,It,S,d,kt,Ke,z,Ni]),Tt(()=>{S&&(Ce.current=At,Oe.current.length=At.length)},[S,At]),Tt(()=>{const un=_e.current;if(un&&(un.hasQuery?bt&&Et.set("activeIndex",0):bt==="always"&&Et.set("activeIndex",0),_e.current=null),!Kt&&!Ia)return;const ks=Ct||en?At:Ce.current,Oa=Et.state.activeIndex;if(Oa==null){if(bt==="always"&&ks.length>0){Et.set("activeIndex",0);return}ke.current!==gS&&(ke.current=gS,Et.state.onItemHighlighted(void 0,YS(Oo,void 0,{index:-1})));return}if(Oa>=ks.length){ke.current!==gS&&(ke.current=gS,Et.state.onItemHighlighted(void 0,YS(Oo,void 0,{index:-1}))),Et.set("activeIndex",null);return}const no=ks[Oa],za=ke.current.value,vm=za!==Rmt&&Gv(no,za,Et.state.isItemEqualToValue);(ke.current.index!==Oa||!vm)&&(ke.current={value:no,index:Oa},Et.state.onItemHighlighted(no,YS(Oo,void 0,{index:Oa})))},[pr,bt,en,Ct,At,Ia,Kt,Et]),Tt(()=>{if(d==="none"){te(String(ct)!=="");return}te(Ke?Array.isArray(It)&&It.length>0:It!=null)},[te,d,ct,It,Ke]),y.useEffect(()=>{Ct&&bt&&At.length===0&&Ni({activeIndex:null})},[Ct,bt,At.length,Ni]),Sv(Le,()=>{!Kt||Le===""||Le===String(at)||be(!0)}),Sv(It,()=>{if(d!=="none"&&(R(Fe),U(It!==Z.initialValue),X()?ne.commit(It):ne.commit(It,!0),Ye&&!Rt&&!$o)){const un=cu(It,P);ct!==un&&Tl(un,Vt(Oo))}}),Sv(ct,()=>{d==="none"&&(R(Fe),U(ct!==Z.initialValue),X()?ne.commit(ct):ne.commit(ct,!0))}),Sv(S,()=>{if(!Ye||Rt||$o||he)return;const un=cu(It,P);ct!==un&&Tl(un,Vt(Oo))});const jy=Gye({open:Ia?!0:Kt,onOpenChange:$u,elements:{reference:$o?Hs:da,floating:Mr}});let Rg,Pg;Ia||(Rg=w?"grid":"listbox",Pg=Kt?"true":"false");const F1=y.useMemo(()=>{const un=da?.tagName==="INPUT",Gn=da==null||un,ks=Gn||Kt,Oa=Gn?{autoComplete:"off",spellCheck:"false",autoCorrect:"off",autoCapitalize:"none"}:{};return ks&&(Oa.role="combobox",Oa["aria-expanded"]=Pg,Oa["aria-haspopup"]=Rg,Oa["aria-controls"]=Kt?ur?.id:void 0,Oa["aria-autocomplete"]=B),{reference:Oa,floating:{role:"presentation"}}},[da,Kt,Pg,Rg,ur?.id,B]),XN=o_(jy,{enabled:!g&&!$e&&C,event:"mousedown-only",toggle:!1,touchOpenDelay:$o?0:100,reason:Qvn}),mm=l_(jy,{enabled:!g&&!$e&&!Ia,outsidePressEvent:{mouse:"sloppy",touch:"intentional"},bubbles:Ia?!0:void 0,outsidePress(un){const Gn=Si(un);return!dn(Hs,Gn)&&!dn(Qe.current,Gn)&&!dn(Re.current,Gn)&&!dn(Sa,Gn)}}),Gx=Kye(jy,{enabled:!g&&!$e,id:pe,listRef:Oe,activeIndex:pr,selectedIndex:ys,virtual:!0,loopFocus:I,allowEscape:I&&!bt,focusItemOnOpen:he||d==="none"&&!bt?!1:"auto",focusItemOnHover:N,resetOnPointerLeave:!E,cols:w?2:1,orientation:w?"horizontal":void 0,rtl:le==="rtl",disabledIndices:bh,onNavigate(un,Gn){!Gn&&!Kt||Nf==="ending"||Ni(Gn?{activeIndex:un,type:ye.current?"keyboard":"pointer"}:{activeIndex:un})}}),M_=y.useMemo(()=>Eo(Gx.reference,mm.reference,XN.reference,F1.reference),[Gx.reference,mm.reference,XN.reference,F1.reference]),D_=y.useMemo(()=>Eo(uy,Gx.floating,mm.floating,F1.floating),[Gx.floating,mm.floating,F1.floating]),z1=y.useMemo(()=>{const un=Gx.item;return un?{...un,onFocus:void 0}:hs},[Gx.item]);s_(()=>{Et.update({inline:q,popupProps:D_,inputProps:M_,triggerProps:Pu,itemProps:z1,setOpen:$u,setInputValue:Tl,setSelectedValue:Ws,setIndices:Ni,onItemHighlighted:Wn,handleSelection:eu,forceMount:ka,requestSubmit:Ag})}),Tt(()=>{Et.update({id:pe,selectedValue:It,open:Kt,mounted:pm,transitionStatus:Nf,items:S,inline:q,popupProps:D_,inputProps:M_,triggerProps:Pu,openMethod:hm,itemProps:z1,selectionMode:d,name:Fe,form:h,disabled:$e,readOnly:g,required:v,grid:w,isGrouped:Te,virtualized:D,onOpenChangeComplete:Er,openOnInputClick:C,itemToStringLabel:P,modal:L,autoHighlight:bt,isItemEqualToValue:z,submitOnItemClick:V,hasInputValue:Rt,requestSubmit:Ag,inputOwnsFormValue:d==="none"&&(q||!Et.state.inputInsidePopup)})},[Et,pe,It,Kt,pm,Nf,S,D_,M_,z1,hm,Pu,d,Fe,$e,g,v,ne,w,Te,D,Er,C,P,L,z,V,Rt,q,Ag,bt,h]);const GW=ku(b,ne.inputRef),QW=y.useMemo(()=>({query:Le,hasItems:Ct,filteredItems:Ft,flatFilteredItems:At}),[Le,Ct,Ft,At]),L_=y.useMemo(()=>Array.isArray(bn)?"":Um(bn,$),[bn,$]),gm=Ke&&Array.isArray(It)&&It.length>0,B1=Ke||d==="none"&&fl?void 0:Fe,KN=y.useMemo(()=>!Ke||!Array.isArray(It)||!Fe?null:It.map(un=>{const Gn=Um(un,$);return o.jsx("input",{type:"hidden",form:h,name:Fe,value:Gn},Gn)}),[Ke,It,h,Fe,$]),Qx=o.jsxs(y.Fragment,{children:[e.children,o.jsx("input",{...ne.getInputValidationProps({onFocus(){if($o){Hs?.focus();return}(ce.current||Hs)?.focus()},onChange(un){if(un.nativeEvent.defaultPrevented||$e||g){un.preventBaseUIHandler?.();return}const Gn=un.currentTarget.value,ks=Vt(Oo,un.nativeEvent);function Oa(){if(Ke)return;if(d==="none"){U(Gn!==Z.initialValue),Tl(Gn,ks),X()&&ne.commit(Gn);return}const no=Ce.current.find(za=>Um(za,$).toLowerCase()===Gn.toLowerCase()||cu(za,P).toLowerCase()===Gn.toLowerCase());no!=null&&(U(no!==Z.initialValue),Ws?.(no,ks),X()&&ne.commit(no))}S?Oa():(ka(),queueMicrotask(Oa))}}),id:pe&&B1==null?`${pe}-hidden-input`:void 0,form:h,name:B1,autoComplete:M,disabled:$e,required:v&&!gm,readOnly:g,value:L_,ref:GW,style:B1?JT:qw,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),KN]});return o.jsx(Smt.Provider,{value:Et,children:o.jsx(kmt.Provider,{value:jy,children:o.jsx(Omt.Provider,{value:QW,children:o.jsx(_mt.Provider,{value:ct,children:Qx})})})})}function Pmt(e){const{multiple:t=!1,defaultValue:n,value:r,onValueChange:s,autoComplete:a,...i}=e;return o.jsx(ARn,{...i,selectionMode:t?"multiple":"single",selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:s,formAutoComplete:a})}function RRn(e){return e==null?void 0:`${e}-label`}function iq(e,t){return e??t}function PRn(e){const{children:t,placeholder:n}=e,r=my(),s=ht(r,on.itemToStringLabel),a=ht(r,on.selectedValue),i=ht(r,on.items),l=ht(r,on.selectionMode)==="multiple",c=ht(r,on.hasSelectedValue),u=!c&&n!=null&&t==null,d=ht(r,on.hasNullItemLabel,u);let f=null;return typeof t=="function"?f=t(a):t!=null?f=t:!c&&n!=null&&!d?f=n:l&&Array.isArray(a)?f=Imt(a,i,s):f=Pxe(a,i,s),o.jsx(y.Fragment,{children:f})}const $mt={...yP,...O1,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":""}:null},$Rn=y.createContext(void 0);function MRn(){return y.useContext($Rn)}const Mmt=y.createContext(void 0);function $xe(e){const t=y.useContext(Mmt);if(t===void 0&&!e)throw new Error(Sr(21));return t}const Dmt=y.forwardRef(function(t,n){const r=my(),{buttonRef:s,getButtonProps:a}=gd({native:!1}),i=ku(n,s);function l(u){r.state.setOpen(!1,Vt(Iye,u.nativeEvent,u.currentTarget))}const c=a({onClick:l});return o.jsx("span",{ref:i,...c,"aria-label":"Dismiss",tabIndex:void 0,style:JT})}),Lmt=y.forwardRef(function(t,n){const{render:r,className:s,disabled:a=!1,id:i,style:l,...c}=t,{state:u,disabled:d,setTouched:f,setFocused:p,validationMode:h,validation:m}=sm(),{labelId:g}=Ox(),v=MRn(),w=!!$xe(!0),S=my(),{filteredItems:O}=_1(),_=Cmt(),C=dy(),j=ht(S,on.required),E=ht(S,on.disabled),N=ht(S,on.readOnly),I=ht(S,on.name),P=ht(S,on.form),$=ht(S,on.selectionMode),z=ht(S,on.autoHighlight),D=ht(S,on.inputProps),q=ht(S,on.triggerProps),W=ht(S,on.open),L=ht(S,on.mounted),F=ht(S,on.selectedValue),B=ht(S,on.popupSide),M=ht(S,on.positionerElement),Q=ht(S,on.id),V=ht(S,on.inline),R=ht(S,on.modal),U=!!z,Z=L&&M?B:null,X=d||E||a,te=O.length===0,ee=w||V,J=!ee||R,ie=Di(i??(ee?void 0:Q)),ue=iq(g,void 0),Y=w?SE:u,[ne,le]=y.useState(null),pe=y.useRef(!1),se=y.useRef(null),he=y.useRef(!1),be=$==="none"&&!w,Se=mt(ae=>{const re=w||S.state.inline;re&&!S.state.hasInputValue&&S.state.setInputValue("",Vt(Oo)),S.update({inputElement:ae,inputInsidePopup:re,inputOwnsFormValue:be})}),Ne=w||!m?c:m.getValidationProps(c),Oe={...Y,open:W,disabled:X,readOnly:N,popupSide:Z,listEmpty:te};function Ae(ae){if(!v)return;let re;const{highlightedChipIndex:me}=v,ye=v.chipsRef.current.length,je=C==="rtl",Re=je?"ArrowRight":"ArrowLeft",Qe=je?"ArrowLeft":"ArrowRight";if(me!==void 0){if(ae.key===Re)ae.preventDefault(),me>0?re=me-1:re=void 0;else if(ae.key===Qe)ae.preventDefault(),me<ye-1?re=me+1:re=void 0;else if(ae.key==="Backspace"||ae.key==="Delete"){ae.preventDefault();const Ze=me>=F.length-1?F.length-2:me;re=Ze>=0?Ze:void 0,S.state.setIndices({activeIndex:null,selectedIndex:null,type:"keyboard"})}return re}return ae.key===Re&&(ae.currentTarget.selectionStart??0)===0&&F.length>0?(ae.preventDefault(),re=ye>0?ye-1:void 0):ae.key==="Backspace"&&ae.currentTarget.value===""&&F.length>0&&(S.state.setIndices({activeIndex:null,selectedIndex:null,type:"keyboard"}),ae.preventDefault()),re}const Ue=En("input",t,{state:Oe,ref:[n,S.state.inputRef,Se],props:[D,q,{type:"text",value:t.value??ne??_,"aria-readonly":N||void 0,"aria-required":j||void 0,"aria-labelledby":ue,disabled:X,readOnly:N,required:$==="none"?j:void 0,form:P,...be&&I&&{name:I},id:ie,onFocus(){if(p(!0),!V||!he.current)return;he.current=!1;const ae=se.current;ae==null||!Object.hasOwn(S.state.valuesRef.current,ae)||S.state.setIndices({activeIndex:ae})},onBlur(){f(!0),p(!1);const ae=S.state.activeIndex;if(V&&ae!==null&&z!=="always"&&(se.current=ae,he.current=!0,S.state.setIndices({activeIndex:null})),h==="onBlur"){const re=$==="none"?_:F;m.commit(re)}},onCompositionStart(ae){mP||(pe.current=!0,le(ae.currentTarget.value))},onCompositionEnd(ae){pe.current=!1;const re=ae.currentTarget.value;le(null),S.state.setInputValue(re,Vt(lk,ae.nativeEvent))},onChange(ae){const re=ae.nativeEvent.inputType,me=!re||re==="insertReplacementText",ye=pe.current||!me;if(pe.current){const Ze=ae.currentTarget.value;le(Ze),Ze===""&&!S.state.openOnInputClick&&!S.state.inputInsidePopup&&S.state.setOpen(!1,Vt(pb,ae.nativeEvent));const ke=Ze.trim(),_e=U&&ke!=="";!N&&!X&&ke&&ye&&(S.state.setOpen(!0,Vt(lk,ae.nativeEvent)),U||S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"})),W&&S.state.activeIndex!==null&&!_e&&S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"});return}S.state.setInputValue(ae.currentTarget.value,Vt(lk,ae.nativeEvent));const je=ae.currentTarget.value==="",Re=Vt(pb,ae.nativeEvent);je&&!S.state.inputInsidePopup&&($==="single"&&S.state.setSelectedValue(null,Re),S.state.openOnInputClick||S.state.setOpen(!1,Re));const Qe=ae.currentTarget.value.trim();!N&&!X&&Qe&&ye&&(S.state.setOpen(!0,Vt(lk,ae.nativeEvent)),U||S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"})),W&&S.state.activeIndex!==null&&!U&&S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"})},onKeyDown(ae){if(X||N||ae.ctrlKey||ae.shiftKey||ae.altKey||ae.metaKey)return;S.state.keyboardActiveRef.current=!0;const re=ae.currentTarget,me=re.scrollWidth-re.clientWidth,ye=C==="rtl";if(ae.key==="Home"){sc(ae);const Qe=X$e&&ye?re.value.length:0;re.setSelectionRange(Qe,Qe),re.scrollLeft=0;return}if(ae.key==="End"){sc(ae);const Qe=X$e&&ye?0:re.value.length;re.setSelectionRange(Qe,Qe),re.scrollLeft=ye?-me:me;return}if(!L&&ae.key==="Escape"){const Qe=$==="multiple"&&Array.isArray(F)?F.length===0:F===null,Ze=Vt(i_,ae.nativeEvent),ke=$==="multiple"?[]:null;S.state.setInputValue("",Ze),S.state.setSelectedValue(ke,Ze),!Qe&&!S.state.inline&&!Ze.isPropagationAllowed&&ae.stopPropagation();return}if(v&&ae.key==="Backspace"&&re.value===""&&v.highlightedChipIndex===void 0&&Array.isArray(F)&&F.length>0){const Qe=v.chipsRef.current.length,Ze=Qe>0?Qe-1:F.length-1,ke=F.filter((_e,Ce)=>Ce!==Ze);S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"}),S.state.setSelectedValue(ke,Vt(Oo,ae.nativeEvent));return}const je=v?.highlightedChipIndex!==void 0,Re=Ae(ae);if(v?.setHighlightedChipIndex(Re),Re!==void 0?v?.chipsRef.current[Re]?.focus():je&&S.state.inputRef.current?.focus(),ae.which!==229&&ae.key==="Enter"&&W){const Qe=S.state.activeIndex,Ze=ae.nativeEvent;if(Qe===null){if(V)return;S.state.setOpen(!1,Vt(Oo,Ze));return}sc(ae);const ke=S.state.listRef.current[Qe];ke&&(S.state.selectionEventRef.current=Ze,ke.click(),S.state.selectionEventRef.current=null)}},onPointerMove(){S.state.keyboardActiveRef.current=!1},onPointerDown(){S.state.keyboardActiveRef.current=!1}},Ne],stateAttributesMapping:$mt}),ce=w?o.jsx(gmt.Provider,{value:mmt,children:Ue}):Ue;return o.jsxs(y.Fragment,{children:[W&&J&&o.jsx(Dmt,{ref:S.state.startDismissRef}),ce]})});function Mxe(e){const t=e.getBoundingClientRect(),n=Ks(e),r=n.getComputedStyle(e,"::before"),s=n.getComputedStyle(e,"::after");if(!(r.content!=="none"||s.content!=="none"))return t;const i=parseFloat(r.width)||0,l=parseFloat(r.height)||0,c=parseFloat(s.width)||0,u=parseFloat(s.height)||0,d=Math.max(t.width,i,c),f=Math.max(t.height,l,u),p=d-t.width,h=f-t.height;return{left:t.left-p/2,right:t.right+p/2,top:t.top-h/2,bottom:t.bottom+h/2}}const kL=2,Fmt=y.forwardRef(function(t,n){const{render:r,className:s,nativeButton:a=!0,disabled:i=!1,id:l,style:c,...u}=t,{state:d,disabled:f,setTouched:p,setFocused:h,validationMode:m,validation:g}=sm(),{labelId:v}=Ox(),b=my(),{filteredItems:w}=_1(),S=ht(b,on.selectionMode),O=ht(b,on.disabled),_=ht(b,on.readOnly),C=ht(b,on.required),j=ht(b,on.mounted),E=ht(b,on.popupSide),N=ht(b,on.positionerElement),I=ht(b,on.listElement),P=ht(b,on.triggerProps),$=ht(b,on.triggerElement),z=ht(b,on.inputInsidePopup),D=ht(b,on.id),q=ht(b,on.labelId),W=ht(b,on.open),L=ht(b,on.selectedValue),F=ht(b,on.activeIndex),B=ht(b,on.selectedIndex),M=ht(b,on.hasSelectedValue),Q=aq(),V=Cmt(),R=co(),U=f||O||i,Z=w.length===0,X=j&&N?E:null;h_({id:z?l:void 0});const te=z?l??D:l,ee=iq(v,q),J=y.useRef("");function ie(Se){J.current=Se.pointerType}const ue=Q.useState("domReferenceElement");y.useEffect(()=>{z&&$&&$!==ue&&Q.set("domReferenceElement",$)},[$,ue,Q,z]);const{reference:Y}=Jye(Q,{enabled:!W&&!_&&!O&&S==="single",listRef:b.state.labelsRef,activeIndex:F,selectedIndex:B,onMatch(Se){const Ne=b.state.valuesRef.current[Se];Ne!==void 0&&b.state.setSelectedValue(Ne,Vt("none"))}}),{reference:ne}=o_(Q,{enabled:!_&&!O,event:"mousedown"}),{buttonRef:le,getButtonProps:pe}=gd({native:a,disabled:U}),se={...d,open:W,disabled:U,popupSide:X,listEmpty:Z,placeholder:S==="none"?!1:!M},he=mt(Se=>{b.set("triggerElement",Se)});return En("button",t,{ref:[n,le,he],state:se,props:[P,ne,Y,{id:te,tabIndex:z?0:-1,role:z?"combobox":void 0,"aria-expanded":W?"true":"false","aria-haspopup":z?"dialog":"listbox","aria-controls":W?I?.id:void 0,"aria-required":z&&C||void 0,"aria-labelledby":ee,onPointerDown:ie,onPointerEnter:ie,onFocus(){h(!0),!(U||_)&&R.start(0,b.state.forceMount)},onBlur(Se){if(!dn(N,Se.relatedTarget)&&(p(!0),h(!1),m==="onBlur")){const Ne=S==="none"?V:L;g.commit(Ne)}},onMouseDown(Se){if(U||_||(z||Q.set("domReferenceElement",Se.currentTarget),b.state.forceMount(),J.current!=="touch"&&(b.state.inputRef.current?.focus(),z||Se.preventDefault()),W))return;const Ne=dr(Se.currentTarget);function Oe(Ae){if(!$)return;const Ue=Si(Ae),ce=b.state.positionerElement,ae=b.state.listElement;if(dn($,Ue)||dn(ce,Ue)||dn(ae,Ue)||Ue===$)return;const re=Mxe($),me=Ae.clientX>=re.left-kL&&Ae.clientX<=re.right+kL,ye=Ae.clientY>=re.top-kL&&Ae.clientY<=re.bottom+kL;me&&ye||b.state.setOpen(!1,Vt("cancel-open",Ae))}z&&Ne.addEventListener("mouseup",Oe,{once:!0})},onKeyDown(Se){U||_||(Se.key==="ArrowDown"||Se.key==="ArrowUp")&&(sc(Se),b.state.setOpen(!0,Vt(kF,Se.nativeEvent)),b.state.inputRef.current?.focus())}},g?g.getValidationProps(u):u,pe],stateAttributesMapping:$mt})}),DRn=y.createContext(null);function LRn(){return y.useContext(DRn)}function FRn(e){const{children:t}=e,{filteredItems:n}=_1(),r=LRn(),s=r?r.items:n;return s?o.jsx(y.Fragment,{children:s.map(t)}):null}const zmt=y.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function zRn(){return y.useContext(zmt)}function vN(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:s}=e,a=mt(s),i=y.useRef(0),l=hc(URn).current,c=hc(BRn).current,[u,d]=y.useState(0),f=y.useRef(u),p=mt((b,w)=>{c.set(b,w??null),f.current+=1,d(f.current)}),h=mt(b=>{c.delete(b),f.current+=1,d(f.current)}),m=y.useMemo(()=>{const b=new Map;return Array.from(c.keys()).filter(S=>S.isConnected).sort(qRn).forEach((S,O)=>{const _=c.get(S)??{};b.set(S,{..._,index:O})}),b},[c,u]);Tt(()=>{if(typeof MutationObserver!="function"||m.size===0)return;const b=new MutationObserver(w=>{const S=new Set,O=_=>S.has(_)?S.delete(_):S.add(_);w.forEach(_=>{_.removedNodes.forEach(O),_.addedNodes.forEach(O)}),S.size===0&&(f.current+=1,d(f.current))});return m.forEach((w,S)=>{S.parentElement&&b.observe(S.parentElement,{childList:!0})}),()=>{b.disconnect()}},[m]),Tt(()=>{f.current===u&&(n.current.length!==m.size&&(n.current.length=m.size),r&&r.current.length!==m.size&&(r.current.length=m.size),i.current=m.size),a(m)},[a,m,n,r,u]),Tt(()=>()=>{n.current=[]},[n]),Tt(()=>()=>{r&&(r.current=[])},[r]);const g=mt(b=>(l.add(b),()=>{l.delete(b)}));Tt(()=>{l.forEach(b=>b(m))},[l,m]);const v=y.useMemo(()=>({register:p,unregister:h,subscribeMapChange:g,elementsRef:n,labelsRef:r,nextIndexRef:i}),[p,h,g,n,r,i]);return o.jsx(zmt.Provider,{value:v,children:t})}function BRn(){return new Map}function URn(){return new Set}function qRn(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const Bmt=y.forwardRef(function(t,n){var r;const{render:s,className:a,style:i,children:l,...c}=t,u=my(),d=aq(),f=!!$xe(!0),{filteredItems:p,hasItems:h}=_1(),m=ht(u,on.selectionMode),g=ht(u,on.grid),v=ht(u,on.popupProps),b=ht(u,on.virtualized),w=m==="multiple",S=p.length===0,O=mt(I=>{u.set("positionerElement",I)}),_=mt(I=>{u.set("listElement",I)}),C=y.useMemo(()=>typeof l=="function"?r||(r=o.jsx(FRn,{children:l})):l,[l]),j={empty:S},E=d.useState("floatingId"),N=En("div",t,{state:j,ref:[n,_,f?null:O],props:[v,{children:C,tabIndex:-1,id:E,role:g?"grid":"listbox","aria-multiselectable":w?"true":void 0,onKeyDown(I){if(!(u.state.disabled||u.state.readOnly)&&I.key==="Enter"){const P=u.state.activeIndex;if(P==null)return;sc(I);const $=I.nativeEvent,z=u.state.listRef.current[P];z&&(u.state.selectionEventRef.current=$,z.click(),u.state.selectionEventRef.current=null)}},onKeyDownCapture(){u.state.keyboardActiveRef.current=!0},onPointerMoveCapture(){u.state.keyboardActiveRef.current=!1}},c]});return b?N:o.jsx(vN,{elementsRef:u.state.listRef,labelsRef:h?void 0:u.state.labelsRef,children:N})}),VRn="",HRn=200;function WRn(e){const t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let n=null;for(;t.nextNode();){const r=t.currentNode;r.nodeValue!==""&&(n=r)}return n}function ZRn(){const e=co(),t=y.useRef(null);return y.useEffect(()=>{if(jye)return;const n=t.current;if(n==null)return;const r=WRn(n);if(r==null)return;const s=r.nodeValue??"",a=`${s}${VRn}`;return r.nodeValue=a,e.start(HRn,()=>{r.nodeValue===a&&(r.nodeValue=s)}),()=>{e.clear(),r.nodeValue===a&&(r.nodeValue=s)}},[t,e]),t}const Umt=y.createContext(void 0);function GRn(){const e=y.useContext(Umt);if(e===void 0)throw new Error(Sr(20));return e}const qmt=y.forwardRef(function(t,n){const{keepMounted:r=!1,...s}=t,a=my(),i=ht(a,on.mounted),l=ht(a,on.forceMounted);return i||r||l?o.jsx(Umt.Provider,{value:r,children:o.jsx(WM,{ref:n,...s})}):null}),QRn=20;function oq(e,t,n,r){const[s,a]=y.useState(!1);Tt(()=>{if(!e||!t||n==null){a(!1);return}const i=dr(n).documentElement.clientWidth,l=n.offsetWidth;a(i>0&&l>0&&l>=i-QRn)},[e,t,n]),Hht(e&&(!t||s),r)}const Vmt=y.forwardRef(function(t,n){const{render:r,className:s,anchor:a,positionMethod:i="absolute",side:l="bottom",align:c="center",sideOffset:u=0,alignOffset:d=0,collisionBoundary:f="clipping-ancestors",collisionPadding:p=5,arrowPadding:h=5,sticky:m=!1,disableAnchorTracking:g=!1,collisionAvoidance:v=Fye,style:b,...w}=t,S=my(),{filteredItems:O}=_1(),_=aq(),C=GRn(),j=ht(S,on.modal),E=ht(S,on.open),N=ht(S,on.mounted),I=ht(S,on.openMethod),P=ht(S,on.positionerElement),$=ht(S,on.triggerElement),z=ht(S,on.inputElement),D=ht(S,on.inputGroupElement),q=ht(S,on.inputInsidePopup),W=ht(S,on.transitionStatus),L=O.length===0,B=rN({anchor:a??(q?$:D??z),floatingRootContext:_,positionMethod:i,mounted:N,side:l,sideOffset:u,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:m,disableAnchorTracking:g,keepMounted:C,collisionAvoidance:v,lazyFlip:!0});oq(E&&j,I==="touch",P,$);const M={open:E,side:B.side,align:B.align,anchorHidden:B.anchorHidden,empty:L};Tt(()=>{S.set("popupSide",B.side)},[S,B.side]);const Q=mt(R=>{S.set("positionerElement",R)}),V=sN(t,M,{styles:B.positionerStyles,transitionStatus:W,props:w,refs:[n,Q],hidden:!N,inert:!E});return o.jsxs(Mmt.Provider,{value:B,children:[N&&j&&o.jsx(p3,{inert:aN(!E),cutout:D??z??$}),V]})}),YRn={...yf,...Hl},Hmt=y.forwardRef(function(t,n){const{render:r,className:s,style:a,initialFocus:i,finalFocus:l,...c}=t,u=my(),d=$xe(),f=aq(),{filteredItems:p}=_1(),h=ht(u,on.mounted),m=ht(u,on.open),g=ht(u,on.openMethod),v=ht(u,on.transitionStatus),b=ht(u,on.inputInsidePopup),w=ht(u,on.inputElement),S=ht(u,on.modal),O=p.length===0;Wl({open:m,ref:u.state.popupRef,onComplete(){m&&u.state.onOpenChangeComplete(!0)}});const _={open:m,side:d.side,align:d.align,anchorHidden:d.anchorHidden,transitionStatus:v,empty:O},C=En("div",t,{state:_,ref:[n,u.state.popupRef],props:[{role:b?"dialog":"presentation",tabIndex:-1,onFocus(P){const $=Si(P.nativeEvent);g!=="touch"&&(dn(u.state.listElement,$)||$===P.currentTarget)&&u.state.inputRef.current?.focus()}},u_(v),c],stateAttributesMapping:YRn}),E=i===void 0?b?P=>P==="touch"?u.state.popupRef.current:w:!1:i;let N;l!=null?N=l:N=b?void 0:!1;const I=!b||S;return o.jsx(eN,{context:f,disabled:!h,modal:I,openInteractionType:g,initialFocus:E,returnFocus:N,getInsideElements:()=>[u.state.startDismissRef.current,u.state.endDismissRef.current],children:o.jsxs(y.Fragment,{children:[C,I&&o.jsx(Dmt,{ref:u.state.endDismissRef})]})})});let Dxe=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function _x(e={}){const{label:t,metadata:n,textRef:r,indexGuessBehavior:s,index:a}=e,{register:i,unregister:l,subscribeMapChange:c,elementsRef:u,labelsRef:d,nextIndexRef:f}=zRn(),p=y.useRef(-1),[h,m]=y.useState(a??(s===Dxe.GuessFromOrder?()=>{if(p.current===-1){const b=f.current;f.current+=1,p.current=b}return p.current}:-1)),g=y.useRef(null),v=y.useCallback(b=>{if(g.current=b,h!==-1&&b!==null&&(u.current[h]=b,d)){const w=t!==void 0;d.current[h]=w?t:r?.current?.textContent??b.textContent}},[h,u,d,t,r]);return Tt(()=>{if(a!=null)return;const b=g.current;if(b)return i(b,n),()=>{l(b)}},[a,i,l,n]),Tt(()=>{if(a==null)return c(b=>{const w=g.current?b.get(g.current)?.index:null;w!=null&&m(w)})},[a,c,m]),y.useMemo(()=>({ref:v,index:h}),[h,v])}const Wmt=y.createContext(void 0);function Zmt(){const e=y.useContext(Wmt);if(!e)throw new Error(Sr(19));return e}const XRn=y.createContext(!1);function KRn(){return y.useContext(XRn)}const Gmt=y.memo(y.forwardRef(function(t,n){const{render:r,className:s,style:a,value:i=null,index:l,disabled:c=!1,nativeButton:u=!1,...d}=t,f=y.useRef(!1),p=y.useRef(null),h=_x({index:l,textRef:p,indexGuessBehavior:Dxe.GuessFromOrder}),m=my(),g=KRn(),{flatFilteredItems:v,hasItems:b}=_1(),w=ht(m,on.open),S=ht(m,on.selectionMode),O=ht(m,on.readOnly),_=ht(m,on.virtualized),C=ht(m,on.isItemEqualToValue),j=S!=="none",E=l??(_?bw(v,i,C):h.index),N=h.index!==-1,I=ht(m,on.id),P=ht(m,on.isActive,E),$=ht(m,on.isSelected,i),z=ht(m,on.itemProps),D=y.useRef(null),q=I!=null&&N?`${I}-${E}`:void 0,W=$&&j;Tt(()=>{if(!(N&&(_||l!=null)))return;const Z=m.state.listRef.current;return Z[E]=D.current,()=>{delete Z[E]}},[N,_,E,l,m]),Tt(()=>{if(!N||b)return;const U=m.state.valuesRef.current;return U[E]=i,S!=="none"&&m.state.allValuesRef.current.push(i),()=>{delete U[E]}},[N,b,E,i,m,S]),Tt(()=>{if(!w){f.current=!1;return}if(!N||b)return;const U=m.state.selectedValue,Z=Array.isArray(U)?U[U.length-1]:U;Gv(i,Z,C)&&m.set("selectedIndex",E)},[N,b,w,m,E,i,C]);const{getButtonProps:L,buttonRef:F}=gd({disabled:c,focusableWhenDisabled:!0,native:u,composite:!0}),B={disabled:c,selected:W,highlighted:P};function M(U){function Z(){m.state.handleSelection(U,i)}m.state.submitOnItemClick?(fo.flushSync(Z),m.state.requestSubmit()):Z()}const Q={id:q,role:g?"gridcell":"option","aria-selected":j?W:void 0,tabIndex:void 0,onPointerDownCapture(U){f.current=!0,U.preventDefault()},onMouseDown(U){U.preventDefault()},onClick(U){c||O||M(U.nativeEvent)},onMouseUp(U){const Z=f.current;f.current=!1,!(c||O||U.button!==0||Z||!P)&&M(U.nativeEvent)}},V=En("div",t,{ref:[F,n,h.ref,D],state:B,props:[z,Q,d,L]}),R=y.useMemo(()=>({selected:W,textRef:p}),[W,p]);return o.jsx(Wmt.Provider,{value:R,children:V})})),JRn=y.forwardRef(function(t,n){const r=t.keepMounted??!1,{selected:s}=Zmt();return r||s?o.jsx(e2n,{...t,ref:n}):null}),e2n=y.memo(y.forwardRef((e,t)=>{const{render:n,className:r,style:s,keepMounted:a,...i}=e,{selected:l}=Zmt(),c=y.useRef(null),{transitionStatus:u,setMounted:d}=wg(l),p=En("span",e,{ref:[t,c],state:{selected:l,transitionStatus:u},props:[{"aria-hidden":!0,children:"✔️"},i],stateAttributesMapping:Hl});return Wl({open:l,ref:c,onComplete(){l||d(!1)}}),p})),Qmt=y.forwardRef(function(t,n){const{render:r,className:s,style:a,children:i,...l}=t,{filteredItems:c}=_1(),u=my(),d=ZRn(),f=c.length===0?i:null;return En("div",t,{ref:[n,u.state.emptyRef,d],props:[{children:f,role:"status","aria-live":"polite","aria-atomic":!0},l]})}),t2n=y.forwardRef(function(t,n){const{className:r,render:s,orientation:a="horizontal",style:i,...l}=t;return En("div",t,{state:{orientation:a},ref:n,props:[{role:"separator","aria-orientation":a},l]})});function n2n(e){return e==="link"?"ghost":e}function Ymt({variant:e,size:t,error:n,className:r}){const s=n2n(e);return K(t3({variant:s,size:t}),"w-full min-w-32 justify-between",eut[s],"data-[placeholder]:text-neutral3",n&&"border-error hover:border-error focus-visible:border-error",r)}const fs={root:"flex flex-col gap-1.5",chevron:"ml-2 h-4 w-4 shrink-0 opacity-60",placeholder:"text-neutral3",popup:K("min-w-(--anchor-width) w-max max-w-(--available-width) rounded-xl border border-border1 bg-surface3 text-neutral4","shadow-dialog","origin-(--transform-origin)","transition-[transform,scale,opacity] duration-150 ease-out","data-starting-style:scale-95 data-starting-style:opacity-0","data-ending-style:scale-95 data-ending-style:opacity-0"),positioner:"z-50 pointer-events-auto",searchContainer:K("flex items-center border-b border-border1 px-2.5 py-1.5",ss.colors),searchIcon:K("mr-2 h-3.5 w-3.5 shrink-0 text-neutral3",ss.colors),searchInput:K("flex h-7 w-full rounded-md bg-transparent py-1 text-ui-smd leading-ui-sm text-neutral6","placeholder:text-neutral3 disabled:cursor-not-allowed disabled:opacity-50","outline-none focus:outline-none focus-visible:outline-none",ss.colors),empty:"not-empty:block hidden py-4 text-center text-ui-smd text-neutral3",list:"max-h-dropdown-max-height overflow-y-auto overflow-x-hidden p-1",item:K("group/item relative flex cursor-pointer select-none items-center gap-2 rounded-md","pl-2.5 pr-2 py-1.5 min-h-8","text-ui-smd leading-ui-sm text-neutral4","outline-none focus:outline-none focus-visible:outline-none",ss.colors,"data-highlighted:bg-surface4 data-highlighted:text-neutral6","data-selected:text-neutral6"),itemMulti:K("relative flex cursor-pointer select-none items-center gap-2.5 rounded-md","pl-2 pr-2.5 py-1.5 min-h-8","text-ui-smd leading-ui-sm text-neutral4","outline-none focus:outline-none focus-visible:outline-none",ss.colors,"data-highlighted:bg-surface4 data-highlighted:text-neutral6","data-selected:text-neutral6"),itemRightSlot:"ml-auto flex items-center gap-2 shrink-0",checkContainer:"flex h-4 w-4 shrink-0 items-center justify-center text-accent1",checkIcon:"h-3.5 w-3.5",checkbox:"flex h-4 w-4 shrink-0 items-center justify-center rounded-[4px] border",checkboxSelected:"bg-accent1 border-accent1",checkboxUnselected:"border-border2",checkboxIcon:"h-3 w-3 text-surface1",optionContent:"flex items-center gap-2 w-full min-w-0",optionText:"flex flex-col gap-0.5 min-w-0",optionLabel:"truncate",optionDescription:"text-ui-sm text-neutral3 truncate",optionEnd:"ml-auto flex items-center shrink-0",error:"text-ui-sm text-accent2"};function Xmt({options:e,value:t=[],onValueChange:n,placeholder:r="Select options...",searchPlaceholder:s="Search...",emptyText:a="No option found.",className:i,disabled:l=!1,variant:c="default",size:u="md",open:d,onOpenChange:f,container:p,error:h}){const m=e.filter(b=>t.includes(b.value)),g=b=>{b&&n?.(b.map(w=>w.value))},v=m.length===0?r:`${m.length} selected`;return o.jsxs("div",{className:fs.root,children:[o.jsxs(Pmt,{multiple:!0,items:e,value:m,onValueChange:g,disabled:l,open:d,onOpenChange:f,children:[o.jsxs(Fmt,{className:Ymt({variant:c,size:u,error:!!h,className:i}),children:[o.jsx("span",{className:K("truncate",m.length===0&&fs.placeholder),children:v}),o.jsx("span",{className:"flex shrink-0 items-center",children:o.jsx(c3,{className:fs.chevron})})]}),o.jsx(qmt,{container:p,children:o.jsx(Vmt,{align:"start",sideOffset:4,className:fs.positioner,children:o.jsxs(Hmt,{className:fs.popup,children:[o.jsxs("div",{className:fs.searchContainer,children:[o.jsx(Zj,{className:fs.searchIcon}),o.jsx(Lmt,{className:fs.searchInput,placeholder:s})]}),o.jsx(Qmt,{className:fs.empty,children:a}),o.jsx(Bmt,{className:fs.list,children:b=>{const w=t.includes(b.value);return o.jsxs(Gmt,{value:b,className:fs.itemMulti,children:[o.jsx("span",{className:K(fs.checkbox,w?fs.checkboxSelected:fs.checkboxUnselected),children:w&&o.jsx(kx,{className:fs.checkboxIcon})}),o.jsxs("span",{className:fs.optionContent,children:[b.start,o.jsxs("span",{className:fs.optionText,children:[o.jsx("span",{className:fs.optionLabel,children:b.label}),b.description&&o.jsx("span",{className:fs.optionDescription,children:b.description})]}),b.end?o.jsx("div",{className:fs.optionEnd,children:b.end}):null]})]},b.value)}})]})})})]}),h&&o.jsx("span",{className:fs.error,children:h})]})}const Kmt=y.createContext(void 0);function r2n({container:e,children:t}){return o.jsx(Kmt.Provider,{value:e??void 0,children:t})}function m3(e){const t=y.useContext(Kmt);return e??t??void 0}function Wc({options:e,value:t,onValueChange:n,placeholder:r="Select option...",searchPlaceholder:s="Search...",emptyText:a="No option found.",className:i,disabled:l=!1,variant:c="default",size:u="md",open:d,onOpenChange:f,container:p,error:h}){const m=e.find(b=>b.value===t)??null,g=m3(p),v=b=>{b&&n?.(b.value)};return o.jsxs("div",{className:fs.root,children:[o.jsxs(Pmt,{autoHighlight:!0,items:e,value:m,onValueChange:v,disabled:l,open:d,onOpenChange:f,children:[o.jsxs(Fmt,{className:Ymt({variant:c,size:u,error:!!h,className:i}),children:[o.jsxs("span",{className:"flex items-center gap-2 min-w-0 flex-1",children:[m?.start,o.jsx("span",{className:"truncate",children:o.jsx(PRn,{placeholder:r})})]}),o.jsx("span",{className:"flex shrink-0 items-center",children:o.jsx(c3,{className:fs.chevron})})]}),o.jsx(qmt,{container:g,children:o.jsx(Vmt,{align:"start",sideOffset:4,className:fs.positioner,children:o.jsxs(Hmt,{className:fs.popup,children:[o.jsxs("div",{className:fs.searchContainer,children:[o.jsx(Zj,{className:fs.searchIcon}),o.jsx(Lmt,{className:fs.searchInput,placeholder:s})]}),o.jsx(Qmt,{className:fs.empty,children:a}),o.jsx(Bmt,{className:fs.list,children:b=>o.jsxs(Gmt,{value:b,className:fs.item,children:[b.start,o.jsxs("span",{className:fs.optionText,children:[o.jsx("span",{className:fs.optionLabel,children:b.label}),b.description&&o.jsx("span",{className:fs.optionDescription,children:b.description})]}),o.jsxs("span",{className:fs.itemRightSlot,children:[b.end?o.jsx("div",{className:fs.optionEnd,children:b.end}):null,o.jsx("span",{className:fs.checkContainer,children:o.jsx(JRn,{children:o.jsx(kx,{className:fs.checkIcon})})})]})]},b.value)})]})})})]}),h&&o.jsx("span",{className:fs.error,children:h})]})}var T4e=1,s2n=.9,a2n=.8,i2n=.17,dX=.1,fX=.999,o2n=.9999,l2n=.99,c2n=/[\\\/_+.#"@\[\(\{&]/,u2n=/[\\\/_+.#"@\[\(\{&]/g,d2n=/[\s-]/,Jmt=/[\s-]/g;function cfe(e,t,n,r,s,a,i){if(a===t.length)return s===e.length?T4e:l2n;var l=`${s},${a}`;if(i[l]!==void 0)return i[l];for(var c=r.charAt(a),u=n.indexOf(c,s),d=0,f,p,h,m;u>=0;)f=cfe(e,t,n,r,u+1,a+1,i),f>d&&(u===s?f*=T4e:c2n.test(e.charAt(u-1))?(f*=a2n,h=e.slice(s,u-1).match(u2n),h&&s>0&&(f*=Math.pow(fX,h.length))):d2n.test(e.charAt(u-1))?(f*=s2n,m=e.slice(s,u-1).match(Jmt),m&&s>0&&(f*=Math.pow(fX,m.length))):(f*=i2n,s>0&&(f*=Math.pow(fX,u-s))),e.charAt(u)!==t.charAt(a)&&(f*=o2n)),(f<dX&&n.charAt(u-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(u-1)!==r.charAt(a))&&(p=cfe(e,t,n,r,u+1,a+2,i),p*dX>f&&(f=p*dX)),f>d&&(d=f),u=n.indexOf(c,u+1);return i[l]=d,d}function N4e(e){return e.toLowerCase().replace(Jmt," ")}function f2n(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,cfe(e,t,N4e(e),N4e(t),0,0,{})}var pX="focusScope.autoFocusOnMount",hX="focusScope.autoFocusOnUnmount",I4e={bubbles:!1,cancelable:!0},p2n="FocusScope",egt=y.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...i}=e,[l,c]=y.useState(null),u=Aj(s),d=Aj(a),f=y.useRef(null),p=xg(t,g=>c(g)),h=y.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;y.useEffect(()=>{if(r){let g=function(S){if(h.paused||!l)return;const O=S.target;l.contains(O)?f.current=O:M0(f.current,{select:!0})},v=function(S){if(h.paused||!l)return;const O=S.relatedTarget;O!==null&&(l.contains(O)||M0(f.current,{select:!0}))},b=function(S){if(document.activeElement===document.body)for(const _ of S)_.removedNodes.length>0&&M0(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",v);const w=new MutationObserver(b);return l&&w.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",v),w.disconnect()}}},[r,l,h.paused]),y.useEffect(()=>{if(l){R4e.add(h);const g=document.activeElement;if(!l.contains(g)){const b=new CustomEvent(pX,I4e);l.addEventListener(pX,u),l.dispatchEvent(b),b.defaultPrevented||(h2n(b2n(tgt(l)),{select:!0}),document.activeElement===g&&M0(l))}return()=>{l.removeEventListener(pX,u),setTimeout(()=>{const b=new CustomEvent(hX,I4e);l.addEventListener(hX,d),l.dispatchEvent(b),b.defaultPrevented||M0(g??document.body,{select:!0}),l.removeEventListener(hX,d),R4e.remove(h)},0)}}},[l,u,d,h]);const m=y.useCallback(g=>{if(!n&&!r||h.paused)return;const v=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,b=document.activeElement;if(v&&b){const w=g.currentTarget,[S,O]=m2n(w);S&&O?!g.shiftKey&&b===O?(g.preventDefault(),n&&M0(S,{select:!0})):g.shiftKey&&b===S&&(g.preventDefault(),n&&M0(O,{select:!0})):b===w&&g.preventDefault()}},[n,r,h.paused]);return o.jsx(gf.div,{tabIndex:-1,...i,ref:p,onKeyDown:m})});egt.displayName=p2n;function h2n(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(M0(r,{select:t}),document.activeElement!==n)return}function m2n(e){const t=tgt(e),n=A4e(t,e),r=A4e(t.reverse(),e);return[n,r]}function tgt(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function A4e(e,t){for(const n of e)if(!g2n(n,{upTo:t}))return n}function g2n(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function v2n(e){return e instanceof HTMLInputElement&&"select"in e}function M0(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&v2n(e)&&t&&e.select()}}var R4e=y2n();function y2n(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=P4e(e,t),e.unshift(t)},remove(t){e=P4e(e,t),e[0]?.resume()}}}function P4e(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function b2n(e){return e.filter(t=>t.tagName!=="A")}var mX=0;function x2n(){y.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??$4e()),document.body.insertAdjacentElement("beforeend",e[1]??$4e()),mX++,()=>{mX===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),mX--}},[])}function $4e(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var dv=function(){return dv=Object.assign||function(t){for(var n,r=1,s=arguments.length;r<s;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},dv.apply(this,arguments)};function ngt(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n}function w2n(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,a;r<s;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Y8="right-scroll-bar-position",X8="width-before-scroll-bar",S2n="with-scroll-bars-hidden",k2n="--removed-body-scroll-bar-size";function gX(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function O2n(e,t){var n=y.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var s=n.value;s!==r&&(n.value=r,n.callback(r,s))}}}})[0];return n.callback=t,n.facade}var _2n=typeof window<"u"?y.useLayoutEffect:y.useEffect,M4e=new WeakMap;function C2n(e,t){var n=O2n(null,function(r){return e.forEach(function(s){return gX(s,r)})});return _2n(function(){var r=M4e.get(n);if(r){var s=new Set(r),a=new Set(e),i=n.current;s.forEach(function(l){a.has(l)||gX(l,null)}),a.forEach(function(l){s.has(l)||gX(l,i)})}M4e.set(n,e)},[e]),n}function E2n(e){return e}function j2n(e,t){t===void 0&&(t=E2n);var n=[],r=!1,s={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var i=t(a,r);return n.push(i),function(){n=n.filter(function(l){return l!==i})}},assignSyncMedium:function(a){for(r=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(l){return a(l)},filter:function(){return n}}},assignMedium:function(a){r=!0;var i=[];if(n.length){var l=n;n=[],l.forEach(a),i=n}var c=function(){var d=i;i=[],d.forEach(a)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return s}function T2n(e){e===void 0&&(e={});var t=j2n(null);return t.options=dv({async:!0,ssr:!1},e),t}var rgt=function(e){var t=e.sideCar,n=ngt(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return y.createElement(r,dv({},n))};rgt.isSideCarExport=!0;function N2n(e,t){return e.useMedium(t),rgt}var sgt=T2n(),vX=function(){},lq=y.forwardRef(function(e,t){var n=y.useRef(null),r=y.useState({onScrollCapture:vX,onWheelCapture:vX,onTouchMoveCapture:vX}),s=r[0],a=r[1],i=e.forwardProps,l=e.children,c=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,h=e.noRelative,m=e.noIsolation,g=e.inert,v=e.allowPinchZoom,b=e.as,w=b===void 0?"div":b,S=e.gapMode,O=ngt(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),_=p,C=C2n([n,t]),j=dv(dv({},O),s);return y.createElement(y.Fragment,null,d&&y.createElement(_,{sideCar:sgt,removeScrollBar:u,shards:f,noRelative:h,noIsolation:m,inert:g,setCallbacks:a,allowPinchZoom:!!v,lockRef:n,gapMode:S}),i?y.cloneElement(y.Children.only(l),dv(dv({},j),{ref:C})):y.createElement(w,dv({},j,{className:c,ref:C}),l))});lq.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};lq.classNames={fullWidth:X8,zeroRight:Y8};var I2n=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function A2n(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=I2n();return t&&e.setAttribute("nonce",t),e}function R2n(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function P2n(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var $2n=function(){var e=0,t=null;return{add:function(n){e==0&&(t=A2n())&&(R2n(t,n),P2n(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},M2n=function(){var e=$2n();return function(t,n){y.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},agt=function(){var e=M2n(),t=function(n){var r=n.styles,s=n.dynamic;return e(r,s),null};return t},D2n={left:0,top:0,right:0,gap:0},yX=function(e){return parseInt(e||"",10)||0},L2n=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],s=t[e==="padding"?"paddingRight":"marginRight"];return[yX(n),yX(r),yX(s)]},F2n=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return D2n;var t=L2n(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},z2n=agt(),aj="data-scroll-locked",B2n=function(e,t,n,r){var s=e.left,a=e.top,i=e.right,l=e.gap;return n===void 0&&(n="margin"),`
|
|
226
|
+
`: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 yjn(this):new mjn(this)}getCursor(t,n=0,r){let s=t.doc?t:is.create({doc:t});return r==null&&(r=s.doc.length),this.regexp?sE(this,s,n,r):rE(this,s,n,r)}}class yht{constructor(t){this.spec=t}}function pjn(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 rE(e,t,n,r){let s;return e.wholeWord&&(s=hjn(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(s=pjn(e.test,t,s)),new ex(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:a=>a.toLowerCase(),s)}function hjn(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(sz(s,n-a))!=oo.Word||t(az(s,n-a))!=oo.Word)&&(t(az(s,r-a))!=oo.Word||t(sz(s,r-a))!=oo.Word))}class mjn extends yht{constructor(t){super(t)}nextMatch(t,n,r){let s=rE(this.spec,t,r,t.doc.length).nextOverlapping();if(s.done){let a=Math.min(t.doc.length,n+this.spec.unquoted.length);s=rE(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=rE(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=rE(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=rE(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 gjn(e,t,n){return(r,s,a)=>(!n||n(r,s,a))&&e(a[0],t,r,s)}function sE(e,t,n,r){let s;return e.wholeWord&&(s=vjn(t.charCategorizer(t.selection.main.head))),e.test&&(s=gjn(e.test,t,s)),new mht(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:s},n,r)}function sz(e,t){return e.slice(lc(e,t,!1),t)}function az(e,t){return e.slice(t,lc(e,t))}function vjn(e){return(t,n,r)=>!r[0].length||(e(sz(r.input,r.index))!=oo.Word||e(az(r.input,r.index))!=oo.Word)&&(e(az(r.input,r.index+r[0].length))!=oo.Word||e(sz(r.input,r.index+r[0].length))!=oo.Word)}class yjn extends yht{nextMatch(t,n,r){let s=sE(this.spec,t,r,t.doc.length).next();return s.done&&(s=sE(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=sE(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=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-250),Math.min(r+250,t.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}const FP=gr.define(),axe=gr.define(),yw=ul.define({create(e){return new iX(rfe(e).create(),null)},update(e,t){for(let n of t.effects)n.is(FP)?e=new iX(n.value.create(),e.panel):n.is(axe)&&(e=new iX(e.query,n.value?ixe:null));return e},provide:e=>TP.from(e,t=>t.panel)});class iX{constructor(t,n){this.query=t,this.panel=n}}const bjn=Cn.mark({class:"cm-searchMatch"}),xjn=Cn.mark({class:"cm-searchMatch cm-searchMatch-selected"}),wjn=po.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(yw))}update(e){let t=e.state.field(yw);(t!=e.startState.field(yw)||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 ud;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?xjn:bjn)})}return r.finish()}},{decorations:e=>e.decorations});function l3(e){return t=>{let n=t.state.field(yw,!1);return n&&n.query.spec.valid?e(t,n):wht(t)}}const iz=l3((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let s=vt.single(r.from,r.to),a=e.state.facet(pN);return e.dispatch({selection:s,effects:[oxe(e,r),a.scrollToMatch(s.main,e)],userEvent:"select.search"}),xht(e),!0}),oz=l3((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,s=t.prevMatch(n,r,r);if(!s)return!1;let a=vt.single(s.from,s.to),i=e.state.facet(pN);return e.dispatch({selection:a,effects:[oxe(e,s),i.scrollToMatch(a.main,e)],userEvent:"select.search"}),xht(e),!0}),Sjn=l3((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:vt.create(n.map(r=>vt.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),kjn=({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 ex(e.doc,e.sliceDoc(r,s));!l.next().done;){if(a.length>1e3)return!1;l.value.from==r&&(i=a.length),a.push(vt.range(l.value.from,l.value.to))}return t(e.update({selection:vt.create(a,i),userEvent:"select.search.matches"})),!0},e4e=l3((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(Nt.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."))):i=t.nextMatch(n,i.from,i.to);let f=e.state.changes(l);return i&&(c=vt.single(i.from,i.to).map(f),d.push(oxe(e,i)),d.push(n.facet(pN).scrollToMatch(c.main,e))),e.dispatch({changes:f,selection:c,effects:d,userEvent:"input.replace"}),!0}),Ojn=l3((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:Nt.announce.of(r),userEvent:"input.replace.all"}),!0});function ixe(e){return e.state.facet(pN).createPanel(e)}function rfe(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(pN);return new vht({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 bht(e){let t=Sbe(e,ixe);return t&&t.dom.querySelector("[main-field]")}function xht(e){let t=bht(e);t&&t==e.root.activeElement&&t.select()}const wht=e=>{let t=e.state.field(yw,!1);if(t&&t.panel){let n=bht(e);if(n&&n!=e.root.activeElement){let r=rfe(e.state,t.query.spec);r.valid&&e.dispatch({effects:FP.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[axe.of(!0),t?FP.of(rfe(e.state,t.query.spec)):gr.appendConfig.of(jjn)]});return!0},Sht=e=>{let t=e.state.field(yw,!1);if(!t||!t.panel)return!1;let n=Sbe(e,ixe);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:axe.of(!1)}),!0},_jn=[{key:"Mod-f",run:wht,scope:"editor search-panel"},{key:"F3",run:iz,shift:oz,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:iz,shift:oz,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Sht,scope:"editor search-panel"},{key:"Mod-Shift-l",run:kjn},{key:"Mod-Alt-g",run:tjn},{key:"Mod-d",run:fjn,preventDefault:!0}];class Cjn{constructor(t){this.view=t;let n=this.query=t.state.field(yw).query.spec;this.commit=this.commit.bind(this),this.searchField=oi("input",{value:n.search,placeholder:Uf(t,"Find"),"aria-label":Uf(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=oi("input",{value:n.replace,placeholder:Uf(t,"Replace"),"aria-label":Uf(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=oi("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=oi("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=oi("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(s,a,i){return oi("button",{class:"cm-button",name:s,onclick:a,type:"button"},i)}this.dom=oi("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,r("next",()=>iz(t),[Uf(t,"next")]),r("prev",()=>oz(t),[Uf(t,"previous")]),r("select",()=>Sjn(t),[Uf(t,"all")]),oi("label",null,[this.caseField,Uf(t,"match case")]),oi("label",null,[this.reField,Uf(t,"regexp")]),oi("label",null,[this.wordField,Uf(t,"by word")]),...t.state.readOnly?[]:[oi("br"),this.replaceField,r("replace",()=>e4e(t),[Uf(t,"replace")]),r("replaceAll",()=>Ojn(t),[Uf(t,"replace all")])],oi("button",{name:"close",onclick:()=>Sht(t),"aria-label":Uf(t,"close"),type:"button"},["×"])])}commit(){let t=new vht({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:FP.of(t)}))}keydown(t){Wwn(this.view,t,"search-panel")?t.preventDefault():t.keyCode==13&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?oz:iz)(this.view)):t.keyCode==13&&t.target==this.replaceField&&(t.preventDefault(),e4e(this.view))}update(t){for(let n of t.transactions)for(let r of n.effects)r.is(FP)&&!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(pN).top}}function Uf(e,t){return e.state.phrase(t)}const yL=30,bL=/[\s\.,:;?!]/;function oxe(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-yL),i=Math.min(s,n+yL),l=e.state.sliceDoc(a,i);if(a!=r.from){for(let c=0;c<yL;c++)if(!bL.test(l[c+1])&&bL.test(l[c])){l=l.slice(c);break}}if(i!=s){for(let c=l.length-1;c>l.length-yL;c--)if(!bL.test(l[c-1])&&bL.test(l[c])){l=l.slice(0,c);break}}return Nt.announce.of(`${e.state.phrase("current match")}. ${l} ${e.state.phrase("on line")} ${r.number}.`)}const Ejn=Nt.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"}}),jjn=[yw,Sg.low(wjn),Ejn];class t4e{constructor(t,n,r){this.from=t,this.to=n,this.diagnostic=r}}class KS{constructor(t,n,r){this.diagnostics=t,this.panel=n,this.selected=r}static init(t,n,r){let s=r.facet(zP).markerFilter;s&&(t=s(t,r));let a=t.slice().sort((d,f)=>d.from-f.from||d.to-f.to),i=new ud,l=[],c=0;for(let d=0;;){let f=d==a.length?null:a[d];if(!f&&!l.length)break;let p,h;for(l.length?(p=c,h=l.reduce((g,v)=>Math.min(g,v.to),f&&f.from>p?f.from:1e8)):(p=f.from,h=f.to,l.push(f),d++);d<a.length;){let g=a[d];if(g.from==p&&(g.to>g.from||g.to==p))l.push(g),d++,h=Math.min(g.to,h);else{h=Math.min(g.from,h);break}}let m=Bjn(l);if(l.some(g=>g.from==g.to||g.from==g.to-1&&r.doc.lineAt(g.from).to==g.from))i.add(p,p,Cn.widget({widget:new Djn(m),diagnostics:l.slice()}));else{let g=l.reduce((v,b)=>b.markClass?v+" "+b.markClass:v,"");i.add(p,h,Cn.mark({class:"cm-lintRange cm-lintRange-"+m+g,diagnostics:l.slice(),inclusiveEnd:l.some(v=>v.to>h)}))}c=h;for(let g=0;g<l.length;g++)l[g].to<=c&&l.splice(g--,1)}let u=i.finish();return new KS(u,n,Wj(u))}}function Wj(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 t4e(s,a,t||i.diagnostics[0]);else{if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new t4e(r.from,a,r.diagnostic)}}),r}function Tjn(e,t){let n=t.pos,r=t.end||n,s=e.state.facet(zP).hideOn(e,n,r);if(s!=null)return s;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(i=>i.is(kht))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function Njn(e,t){return e.field(fp,!1)?t:t.concat(gr.appendConfig.of(Ujn))}const kht=gr.define(),lxe=gr.define(),Oht=gr.define(),fp=ul.define({create(){return new KS(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=Wj(n,e.selected.diagnostic,a)||Wj(n,null,a)}!n.size&&s&&t.state.facet(zP).autoPanel&&(s=null),e=new KS(n,s,r)}for(let n of t.effects)if(n.is(kht)){let r=t.state.facet(zP).autoPanel?n.value.length?BP.open:null:e.panel;e=KS.init(n.value,r,t.state)}else n.is(lxe)?e=new KS(e.diagnostics,n.value?BP.open:null,e.selected):n.is(Oht)&&(e=new KS(e.diagnostics,e.panel,n.value));return e},provide:e=>[TP.from(e,t=>t.panel),Nt.decorations.from(e,t=>t.diagnostics)]}),Ijn=Cn.mark({class:"cm-lintRange cm-lintRange-active"});function Ajn(e,t,n){let{diagnostics:r}=e.state.field(fp),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(zP).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:Rjn(e,s)}}}:null}function Rjn(e,t){return oi("ul",{class:"cm-tooltip-lint"},t.map(n=>Cht(e,n,!1)))}const Pjn=e=>{let t=e.state.field(fp,!1);(!t||!t.panel)&&e.dispatch({effects:Njn(e.state,[lxe.of(!0)])});let n=Sbe(e,BP.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},n4e=e=>{let t=e.state.field(fp,!1);return!t||!t.panel?!1:(e.dispatch({effects:lxe.of(!1)}),!0)},$jn=e=>{let t=e.state.field(fp,!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)},Mjn=[{key:"Mod-Shift-m",run:Pjn,preventDefault:!0},{key:"F8",run:$jn}],zP=Sn.define({combine(e){return{sources:e.map(t=>t.source).filter(t=>t!=null),...py(e.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:r4e,tooltipFilter:r4e,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 r4e(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function _ht(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 Cht(e,t,n){var r;let s=n?_ht(t.actions):[];return oi("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},oi("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=Wj(e.state.field(fp).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),oi("u",u.slice(d,d+1)),u.slice(d+1)],p=a.markClass?" "+a.markClass:"";return oi("button",{type:"button",class:"cm-diagnosticAction"+p,onclick:c,onmousedown:c,"aria-label":` Action: ${u}${d<0?"":` (access key "${s[i]})"`}.`},f)}),t.source&&oi("div",{class:"cm-diagnosticSource"},t.source))}class Djn extends Bp{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return oi("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class s4e{constructor(t,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Cht(t,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class BP{constructor(t){this.view=t,this.items=[];let n=s=>{if(s.keyCode==27)n4e(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=_ht(a.actions);for(let l=0;l<i.length;l++)if(i[l].toUpperCase().charCodeAt(0)==s.keyCode){let c=Wj(this.view.state.field(fp).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=oi("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=oi("div",{class:"cm-panel-lint"},this.list,oi("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>n4e(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(fp).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(fp),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 s4e(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 s4e(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(fp),r=Wj(n.diagnostics,this.items[t].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:Oht.of(r)})}static open(t){return new BP(t)}}function Ljn(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 xL(e){return Ljn(`<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 Fjn=Nt.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:xL("#d11")},".cm-lintRange-warning":{backgroundImage:xL("orange")},".cm-lintRange-info":{backgroundImage:xL("#999")},".cm-lintRange-hint":{backgroundImage:xL("#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 zjn(e){return e=="error"?4:e=="warning"?3:e=="info"?2:1}function Bjn(e){let t="hint",n=1;for(let r of e){let s=zjn(r.severity);s>n&&(n=s,t=r.severity)}return t}const Ujn=[fp,Nt.decorations.compute([fp],e=>{let{selected:t,panel:n}=e.field(fp);return!t||!n||t.from==t.to?Cn.none:Cn.set([Ijn.range(t.from,t.to)])}),P1n(Ajn,{hideOn:Tjn}),Fjn];var a4e=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(Ikn)),t.defaultKeymap!==!1&&(a=a.concat(KEn)),t.searchKeymap!==!1&&(a=a.concat(_jn)),t.historyKeymap!==!1&&(a=a.concat(aEn)),t.foldKeymap!==!1&&(a=a.concat(gSn)),t.completionKeymap!==!1&&(a=a.concat(xft)),t.lintKeymap!==!1&&(a=a.concat(Mjn));var i=[];return t.lineNumbers!==!1&&i.push(W1n()),t.highlightActiveLineGutter!==!1&&i.push(Q1n()),t.highlightSpecialChars!==!1&&i.push(l1n()),t.history!==!1&&i.push(YCn()),t.foldGutter!==!1&&i.push(xSn()),t.drawSelection!==!1&&i.push(Kwn()),t.dropCursor!==!1&&i.push(r1n()),t.allowMultipleSelections!==!1&&i.push(is.allowMultipleSelections.of(!0)),t.indentOnInput!==!1&&i.push(lSn()),t.syntaxHighlighting!==!1&&i.push(w1(OSn,{fallback:!0})),t.bracketMatching!==!1&&i.push(ISn()),t.closeBrackets!==!1&&i.push(Ekn()),t.autocompletion!==!1&&i.push(bft()),t.rectangularSelection!==!1&&i.push(S1n()),s!==!1&&i.push(_1n()),t.highlightActiveLine!==!1&&i.push(h1n()),t.highlightSelectionMatches!==!1&&i.push(sjn()),t.tabSize&&typeof t.tabSize=="number"&&i.push(cN.of(" ".repeat(t.tabSize))),i.concat([lN.of(a.flat())]).filter(Boolean)};const qjn="#e5c07b",i4e="#e06c75",Vjn="#56b6c2",Hjn="#ffffff",Q8="#abb2bf",sfe="#7d8799",Wjn="#61afef",Zjn="#98c379",o4e="#d19a66",Gjn="#c678dd",Qjn="#21252b",l4e="#2c313a",c4e="#282c34",oX="#353a42",Yjn="#3E4451",u4e="#528bff",Xjn=Nt.theme({"&":{color:Q8,backgroundColor:c4e},".cm-content":{caretColor:u4e},".cm-cursor, .cm-dropCursor":{borderLeftColor:u4e},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Yjn},".cm-panels":{backgroundColor:Qjn,color:Q8},".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:c4e,color:sfe,border:"none"},".cm-activeLineGutter":{backgroundColor:l4e},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:oX},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:oX,borderBottomColor:oX},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:l4e,color:Q8}}},{dark:!0}),Kjn=kg.define([{tag:de.keyword,color:Gjn},{tag:[de.name,de.deleted,de.character,de.propertyName,de.macroName],color:i4e},{tag:[de.function(de.variableName),de.labelName],color:Wjn},{tag:[de.color,de.constant(de.name),de.standard(de.name)],color:o4e},{tag:[de.definition(de.name),de.separator],color:Q8},{tag:[de.typeName,de.className,de.number,de.changed,de.annotation,de.modifier,de.self,de.namespace],color:qjn},{tag:[de.operator,de.operatorKeyword,de.url,de.escape,de.regexp,de.link,de.special(de.string)],color:Vjn},{tag:[de.meta,de.comment],color:sfe},{tag:de.strong,fontWeight:"bold"},{tag:de.emphasis,fontStyle:"italic"},{tag:de.strikethrough,textDecoration:"line-through"},{tag:de.link,color:sfe,textDecoration:"underline"},{tag:de.heading,fontWeight:"bold",color:i4e},{tag:[de.atom,de.bool,de.special(de.variableName)],color:o4e},{tag:[de.processingInstruction,de.string,de.inserted],color:Zjn},{tag:de.invalid,color:Hjn}]),Jjn=[Xjn,w1(Kjn)];var eTn=Nt.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),tTn=function(t){t===void 0&&(t={});var n=t,r=n.indentWithTab,s=r===void 0?!0:r,a=n.editable,i=a===void 0?!0:a,l=n.readOnly,c=l===void 0?!1:l,u=n.theme,d=u===void 0?"light":u,f=n.placeholder,p=f===void 0?"":f,h=n.basicSetup,m=h===void 0?!0:h,g=[];switch(s&&g.unshift(lN.of([JEn])),m&&(typeof m=="boolean"?g.unshift(a4e()):g.unshift(a4e(m))),p&&g.unshift(y1n(p)),d){case"light":g.push(eTn);break;case"dark":g.push(Jjn);break;case"none":break;default:g.push(d);break}return i===!1&&g.push(Nt.editable.of(!1)),c&&g.push(is.readOnly.of(!0)),[...g]},nTn=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 rTn{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 d4e{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 lX=null,sTn=()=>typeof window>"u"?new d4e:(lX||(lX=new d4e),lX),f4e=fy.define(),aTn=200,iTn=[];function oTn(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?iTn:l,u=e.autoFocus,d=e.theme,f=d===void 0?"light":d,p=e.height,h=p===void 0?null:p,m=e.minHeight,g=m===void 0?null:m,v=e.maxHeight,b=v===void 0?null:v,w=e.width,S=w===void 0?null:w,O=e.minWidth,_=O===void 0?null:O,C=e.maxWidth,j=C===void 0?null:C,E=e.placeholder,N=E===void 0?"":E,I=e.editable,P=I===void 0?!0:I,$=e.readOnly,z=$===void 0?!1:$,D=e.indentWithTab,q=D===void 0?!0:D,W=e.basicSetup,L=W===void 0?!0:W,F=e.root,B=e.initialState,M=y.useState(),Q=M[0],V=M[1],R=y.useState(),U=R[0],Z=R[1],X=y.useState(),te=X[0],ee=X[1],J=y.useState(()=>({current:null}))[0],ie=y.useState(()=>({current:null}))[0],ue=Nt.theme({"&":{height:h,minHeight:g,maxHeight:b,width:S,minWidth:_,maxWidth:j},"& .cm-scroller":{height:"100% !important"}}),Y=Nt.updateListener.of(pe=>{if(pe.docChanged&&typeof r=="function"&&!pe.transactions.some(be=>be.annotation(f4e))){J.current?J.current.reset():(J.current=new rTn(()=>{if(ie.current){var be=ie.current;ie.current=null,be()}J.current=null},aTn),sTn().add(J.current));var se=pe.state.doc,he=se.toString();r(he,pe)}s&&s(nTn(pe))}),ne=tTn({theme:f,editable:P,readOnly:z,placeholder:N,indentWithTab:q,basicSetup:L}),le=[Y,ue,...ne];return i&&typeof i=="function"&&le.push(Nt.updateListener.of(i)),le=le.concat(c),y.useLayoutEffect(()=>{if(Q&&!te){var pe={doc:t,selection:n,extensions:le},se=B?is.fromJSON(B.json,pe,B.fields):is.create(pe);if(ee(se),!U){var he=new Nt({state:se,parent:Q,root:F});Z(he),a&&a(he,se)}}return()=>{U&&(ee(void 0),Z(void 0))}},[Q,te]),y.useEffect(()=>{e.container&&V(e.container)},[e.container]),y.useEffect(()=>()=>{U&&(U.destroy(),Z(void 0)),J.current&&(J.current.cancel(),J.current=null)},[U]),y.useEffect(()=>{u&&U&&U.focus()},[u,U]),y.useEffect(()=>{U&&U.dispatch({effects:gr.reconfigure.of(le)})},[f,c,h,g,b,S,_,j,N,P,z,q,L,r,i]),y.useEffect(()=>{if(t!==void 0){var pe=U?U.state.doc.toString():"";if(U&&t!==pe){var se=J.current&&!J.current.isDone,he=()=>{U&&t!==U.state.doc.toString()&&U.dispatch({changes:{from:0,to:U.state.doc.toString().length,insert:t||""},annotations:[f4e.of(!0)]})};se?ie.current=he:he()}}},[t,U]),{state:te,setState:ee,view:U,setView:Z,container:Q,setContainer:V}}var lTn=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Hc=y.forwardRef((e,t)=>{var n=e.className,r=e.value,s=r===void 0?"":r,a=e.selection,i=e.extensions,l=i===void 0?[]:i,c=e.onChange,u=e.onStatistics,d=e.onCreateEditor,f=e.onUpdate,p=e.autoFocus,h=e.theme,m=h===void 0?"light":h,g=e.height,v=e.minHeight,b=e.maxHeight,w=e.width,S=e.minWidth,O=e.maxWidth,_=e.basicSetup,C=e.placeholder,j=e.indentWithTab,E=e.editable,N=e.readOnly,I=e.root,P=e.initialState,$=Ppt(e,lTn),z=y.useRef(null),D=oTn({root:I,value:s,autoFocus:p,theme:m,height:g,minHeight:v,maxHeight:b,width:w,minWidth:S,maxWidth:O,basicSetup:_,placeholder:C,indentWithTab:j,editable:E,readOnly:N,selection:a,onChange:c,onStatistics:u,onCreateEditor:d,onUpdate:f,extensions:l,initialState:P}),q=D.state,W=D.view,L=D.container,F=D.setContainer;y.useImperativeHandle(t,()=>({editor:z.current,state:q,view:W}),[z,L,q,W]);var B=y.useCallback(Q=>{z.current=Q,F(Q)},[F]);if(typeof s!="string")throw new Error("value must be typeof string but got "+typeof s);var M=typeof m=="string"?"cm-theme-"+m:"cm-theme";return o.jsx("div",uO({ref:B,className:""+M+(n?" "+n:"")},$))});Hc.displayName="CodeMirror";const cTn=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Eht=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();var uTn={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 dTn=y.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:i,...l},c)=>y.createElement("svg",{ref:c,...uTn,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Eht("lucide",s),...l},[...i.map(([u,d])=>y.createElement(u,d)),...Array.isArray(a)?a:[a]]));const yn=(e,t)=>{const n=y.forwardRef(({className:r,...s},a)=>y.createElement(dTn,{ref:a,iconNode:t,className:Eht(`lucide-${cTn(e)}`,r),...s}));return n.displayName=`${e}`,n};const fTn=[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]],lz=yn("AlignJustify",fTn);const pTn=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],UP=yn("AlignLeft",pTn);const hTn=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],tq=yn("ArrowDown",hTn);const mTn=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],cxe=yn("ArrowLeft",mTn);const gTn=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],cz=yn("ArrowRight",gTn);const vTn=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],nq=yn("ArrowUp",vTn);const yTn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]],jht=yn("Ban",yTn);const bTn=[["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"}]],rw=yn("Braces",bTn);const xTn=[["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"}]],wTn=yn("Brain",xTn);const STn=[["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"}]],p4e=yn("Calendar",STn);const kTn=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],kx=yn("Check",kTn);const OTn=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],uxe=yn("ChevronDown",OTn);const _Tn=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Tht=yn("ChevronLeft",_Tn);const CTn=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],dO=yn("ChevronRight",CTn);const ETn=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],jTn=yn("ChevronUp",ETn);const TTn=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],dxe=yn("ChevronsDownUp",TTn);const NTn=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],ITn=yn("ChevronsDown",NTn);const ATn=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],RTn=yn("ChevronsLeft",ATn);const PTn=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],Nht=yn("ChevronsRight",PTn);const $Tn=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],c3=yn("ChevronsUpDown",$Tn);const MTn=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],DTn=yn("ChevronsUp",MTn);const LTn=[["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"}]],FTn=yn("CircleGauge",LTn);const zTn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]],Iht=yn("CircleSlash",zTn);const BTn=[["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"}]],UTn=yn("CircleX",BTn);const qTn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],VTn=yn("Circle",qTn);const HTn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],WTn=yn("Clock",HTn);const ZTn=[["path",{d:"M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1uwlt4"}],["path",{d:"M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z",key:"10291m"}],["path",{d:"M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z",key:"1tqoq1"}],["path",{d:"M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1x6lto"}]],GTn=yn("Component",ZTn);const QTn=[["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"}]],Aht=yn("Copy",QTn);const YTn=[["polyline",{points:"15 10 20 15 15 20",key:"1q7qjw"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],XTn=yn("CornerDownRight",YTn);const KTn=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],JTn=yn("Download",KTn);const eNn=[["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"}]],tNn=yn("EllipsisVertical",eNn);const nNn=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}],["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}]],rNn=yn("EqualNot",nNn);const sNn=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],aNn=yn("Equal",sNn);const iNn=[["path",{d:"m15 15 6 6",key:"1s409w"}],["path",{d:"m15 9 6-6",key:"ko1vev"}],["path",{d:"M21 16.2V21h-4.8",key:"1hrera"}],["path",{d:"M21 7.8V3h-4.8",key:"ul1q53"}],["path",{d:"M3 16.2V21h4.8",key:"1x04uo"}],["path",{d:"m3 21 6-6",key:"wwnumi"}],["path",{d:"M3 7.8V3h4.8",key:"1ijppm"}],["path",{d:"M9 9 3 3",key:"v551iv"}]],oNn=yn("Expand",iNn);const lNn=[["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"}]],fxe=yn("ExternalLink",lNn);const cNn=[["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"}]],uNn=yn("Eye",cNn);const dNn=[["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"}]],afe=yn("FileInput",dNn);const fNn=[["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"}]],ife=yn("FileOutput",fNn);const pNn=[["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"}]],hNn=yn("FileText",pNn);const mNn=[["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"}]],gNn=yn("File",mNn);const vNn=[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]],yNn=yn("Filter",vNn);const bNn=[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3-3-3 3",key:"e37ymu"}],["path",{d:"m15 5-3 3-3-3",key:"19d6lf"}]],xNn=yn("FoldVertical",bNn);const wNn=[["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"}]],SNn=yn("Folder",wNn);const kNn=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],ONn=yn("Gauge",kNn);const _Nn=[["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"}]],pxe=yn("Hash",_Nn);const CNn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Rht=yn("Info",CNn);const ENn=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],jNn=yn("Keyboard",ENn);const TNn=[["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"}]],NNn=yn("Lightbulb",TNn);const INn=[["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"}]],Pht=yn("Link2",INn);const ANn=[["path",{d:"M10 18h4",key:"1ulq68"}],["path",{d:"M11 6H3",key:"1u26ik"}],["path",{d:"M15 6h6",key:"1jlkvy"}],["path",{d:"M18 9V3",key:"xwwp7m"}],["path",{d:"M7 12h8",key:"7a1bxv"}]],RNn=yn("ListFilterPlus",ANn);const PNn=[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]],$Nn=yn("ListTree",PNn);const MNn=[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"m19 10-4 4",key:"1tz659"}],["path",{d:"m15 10 4 4",key:"1n7nei"}]],DNn=yn("ListX",MNn);const LNn=[["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"}]],hxe=yn("List",LNn);const FNn=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],zNn=yn("LoaderCircle",FNn);const BNn=[["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"}]],UNn=yn("Lock",BNn);const qNn=[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]],VNn=yn("LogIn",qNn);const HNn=[["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M3 18h1",key:"1eiwyy"}],["path",{d:"M3 6h1",key:"rgxa97"}],["path",{d:"M8 12h1",key:"1con00"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M8 6h1",key:"tn6mkg"}]],WNn=yn("Logs",HNn);const ZNn=[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]],GNn=yn("Menu",ZNn);const QNn=[["path",{d:"M5 12h14",key:"1ays0h"}]],YNn=yn("Minus",QNn);const XNn=[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 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-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]],KNn=yn("OctagonAlert",XNn);const JNn=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],eIn=yn("PanelRight",JNn);const tIn=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],mxe=yn("Plus",tIn);const nIn=[["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"}]],$ht=yn("Save",nIn);const rIn=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],Zj=yn("Search",rIn);const sIn=[["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:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]],aIn=yn("ShieldX",sIn);const iIn=[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 18H3",key:"13769t"}],["circle",{cx:"17",cy:"15",r:"3",key:"1upz2a"}],["path",{d:"m21 19-1.9-1.9",key:"dwi7p8"}]],oIn=yn("TextSearch",iIn);const lIn=[["path",{d:"M17 6.1H3",key:"wptmhv"}],["path",{d:"M21 12.1H3",key:"1j38uz"}],["path",{d:"M15.1 18H3",key:"1nb16a"}]],cIn=yn("Text",lIn);const uIn=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]],gxe=yn("ToggleLeft",uIn);const dIn=[["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"}]],Mht=yn("Trash2",dIn);const fIn=[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]],pIn=yn("TrendingDown",fIn);const hIn=[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]],mIn=yn("TrendingUp",hIn);const gIn=[["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"}]],rq=yn("TriangleAlert",gIn);const vIn=[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]],vxe=yn("Type",vIn);const yIn=[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m15 5-3-3-3 3",key:"itvq4r"}]],bIn=yn("UnfoldVertical",yIn);const xIn=[["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"}]],wIn=yn("WandSparkles",xIn);const SIn=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],dd=yn("X",SIn);function kIn(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const OIn=e=>{switch(e){case"success":return EIn;case"info":return TIn;case"warning":return jIn;case"error":return NIn;default:return null}},_In=Array(12).fill(0),CIn=({visible:e,className:t})=>De.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},De.createElement("div",{className:"sonner-spinner"},_In.map((n,r)=>De.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),EIn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},De.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),jIn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},De.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),TIn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},De.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),NIn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},De.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),IIn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},De.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),De.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),AIn=()=>{const[e,t]=De.useState(document.hidden);return De.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let ofe=1;class RIn{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:r,...s}=t,a=typeof t?.id=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:ofe++,i=this.toasts.find(c=>c.id===a),l=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),i?this.toasts=this.toasts.map(c=>c.id===a?(this.publish({...c,...t,id:a,title:r}),{...c,...t,id:a,dismissible:l,title:r}):c):this.addToast({title:r,...s,dismissible:l,id:a}),a},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const s=Promise.resolve(t instanceof Function?t():t);let a=r!==void 0,i;const l=s.then(async u=>{if(i=["resolve",u],De.isValidElement(u))a=!1,this.create({id:r,type:"default",message:u});else if($In(u)&&!u.ok){a=!1;const f=typeof n.error=="function"?await n.error(`HTTP error! status: ${u.status}`):n.error,p=typeof n.description=="function"?await n.description(`HTTP error! status: ${u.status}`):n.description,m=typeof f=="object"&&!De.isValidElement(f)?f:{message:f};this.create({id:r,type:"error",description:p,...m})}else if(u instanceof Error){a=!1;const f=typeof n.error=="function"?await n.error(u):n.error,p=typeof n.description=="function"?await n.description(u):n.description,m=typeof f=="object"&&!De.isValidElement(f)?f:{message:f};this.create({id:r,type:"error",description:p,...m})}else if(n.success!==void 0){a=!1;const f=typeof n.success=="function"?await n.success(u):n.success,p=typeof n.description=="function"?await n.description(u):n.description,m=typeof f=="object"&&!De.isValidElement(f)?f:{message:f};this.create({id:r,type:"success",description:p,...m})}}).catch(async u=>{if(i=["reject",u],n.error!==void 0){a=!1;const d=typeof n.error=="function"?await n.error(u):n.error,f=typeof n.description=="function"?await n.description(u):n.description,h=typeof d=="object"&&!De.isValidElement(d)?d:{message:d};this.create({id:r,type:"error",description:f,...h})}}).finally(()=>{a&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),c=()=>new Promise((u,d)=>l.then(()=>i[0]==="reject"?d(i[1]):u(i[1])).catch(d));return typeof r!="string"&&typeof r!="number"?{unwrap:c}:Object.assign(r,{unwrap:c})},this.custom=(t,n)=>{const r=n?.id||ofe++;return this.create({jsx:t(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const Ad=new RIn,PIn=(e,t)=>{const n=t?.id||ofe++;return Ad.addToast({title:e,...t,id:n}),n},$In=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",MIn=PIn,DIn=()=>Ad.toasts,LIn=()=>Ad.getActiveToasts(),bu=Object.assign(MIn,{success:Ad.success,info:Ad.info,warning:Ad.warning,error:Ad.error,custom:Ad.custom,message:Ad.message,promise:Ad.promise,dismiss:Ad.dismiss,loading:Ad.loading},{getHistory:DIn,getToasts:LIn});kIn("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function wL(e){return e.label!==void 0}const FIn=3,zIn="24px",BIn="16px",h4e=4e3,UIn=356,qIn=14,VIn=45,HIn=200;function Hg(...e){return e.filter(Boolean).join(" ")}function WIn(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const ZIn=e=>{var t,n,r,s,a,i,l,c,u;const{invert:d,toast:f,unstyled:p,interacting:h,setHeights:m,visibleToasts:g,heights:v,index:b,toasts:w,expanded:S,removeToast:O,defaultRichColors:_,closeButton:C,style:j,cancelButtonStyle:E,actionButtonStyle:N,className:I="",descriptionClassName:P="",duration:$,position:z,gap:D,expandByDefault:q,classNames:W,icons:L,closeButtonAriaLabel:F="Close toast"}=e,[B,M]=De.useState(null),[Q,V]=De.useState(null),[R,U]=De.useState(!1),[Z,X]=De.useState(!1),[te,ee]=De.useState(!1),[J,ie]=De.useState(!1),[ue,Y]=De.useState(!1),[ne,le]=De.useState(0),[pe,se]=De.useState(0),he=De.useRef(f.duration||$||h4e),be=De.useRef(null),Se=De.useRef(null),Ne=b===0,Oe=b+1<=g,Ae=f.type,Ue=f.dismissible!==!1,ce=f.className||"",ae=f.descriptionClassName||"",re=De.useMemo(()=>v.findIndex(bt=>bt.toastId===f.id)||0,[v,f.id]),me=De.useMemo(()=>{var bt;return(bt=f.closeButton)!=null?bt:C},[f.closeButton,C]),ye=De.useMemo(()=>f.duration||$||h4e,[f.duration,$]),je=De.useRef(0),Re=De.useRef(0),Qe=De.useRef(0),Ze=De.useRef(null),[ke,_e]=z.split("-"),Ce=De.useMemo(()=>v.reduce((bt,It,sn)=>sn>=re?bt:bt+It.height,0),[v,re]),Ee=AIn(),$e=f.invert||d,Fe=Ae==="loading";Re.current=De.useMemo(()=>re*D+Ce,[re,Ce]),De.useEffect(()=>{he.current=ye},[ye]),De.useEffect(()=>{U(!0)},[]),De.useEffect(()=>{const bt=Se.current;if(bt){const It=bt.getBoundingClientRect().height;return se(It),m(sn=>[{toastId:f.id,height:It,position:f.position},...sn]),()=>m(sn=>sn.filter(Ge=>Ge.toastId!==f.id))}},[m,f.id]),De.useLayoutEffect(()=>{if(!R)return;const bt=Se.current,It=bt.style.height;bt.style.height="auto";const sn=bt.getBoundingClientRect().height;bt.style.height=It,se(sn),m(Ge=>Ge.find(ct=>ct.toastId===f.id)?Ge.map(ct=>ct.toastId===f.id?{...ct,height:sn}:ct):[{toastId:f.id,height:sn,position:f.position},...Ge])},[R,f.title,f.description,m,f.id,f.jsx,f.action,f.cancel]);const Ke=De.useCallback(()=>{X(!0),le(Re.current),m(bt=>bt.filter(It=>It.toastId!==f.id)),setTimeout(()=>{O(f)},HIn)},[f,O,m,Re]);De.useEffect(()=>{if(f.promise&&Ae==="loading"||f.duration===1/0||f.type==="loading")return;let bt;return S||h||Ee?(()=>{if(Qe.current<je.current){const Ge=new Date().getTime()-je.current;he.current=he.current-Ge}Qe.current=new Date().getTime()})():he.current!==1/0&&(je.current=new Date().getTime(),bt=setTimeout(()=>{f.onAutoClose==null||f.onAutoClose.call(f,f),Ke()},he.current)),()=>clearTimeout(bt)},[S,h,f,Ae,Ee,Ke]),De.useEffect(()=>{f.delete&&(Ke(),f.onDismiss==null||f.onDismiss.call(f,f))},[Ke,f.delete]);function Ye(){var bt;if(L?.loading){var It;return De.createElement("div",{className:Hg(W?.loader,f==null||(It=f.classNames)==null?void 0:It.loader,"sonner-loader"),"data-visible":Ae==="loading"},L.loading)}return De.createElement(CIn,{className:Hg(W?.loader,f==null||(bt=f.classNames)==null?void 0:bt.loader),visible:Ae==="loading"})}const Rt=f.icon||L?.[Ae]||OIn(Ae);var Ct,en;return De.createElement("li",{tabIndex:0,ref:Se,className:Hg(I,ce,W?.toast,f==null||(t=f.classNames)==null?void 0:t.toast,W?.default,W?.[Ae],f==null||(n=f.classNames)==null?void 0:n[Ae]),"data-sonner-toast":"","data-rich-colors":(Ct=f.richColors)!=null?Ct:_,"data-styled":!(f.jsx||f.unstyled||p),"data-mounted":R,"data-promise":!!f.promise,"data-swiped":ue,"data-removed":Z,"data-visible":Oe,"data-y-position":ke,"data-x-position":_e,"data-index":b,"data-front":Ne,"data-swiping":te,"data-dismissible":Ue,"data-type":Ae,"data-invert":$e,"data-swipe-out":J,"data-swipe-direction":Q,"data-expanded":!!(S||q&&R),"data-testid":f.testId,style:{"--index":b,"--toasts-before":b,"--z-index":w.length-b,"--offset":`${Z?ne:Re.current}px`,"--initial-height":q?"auto":`${pe}px`,...j,...f.style},onDragEnd:()=>{ee(!1),M(null),Ze.current=null},onPointerDown:bt=>{bt.button!==2&&(Fe||!Ue||(be.current=new Date,le(Re.current),bt.target.setPointerCapture(bt.pointerId),bt.target.tagName!=="BUTTON"&&(ee(!0),Ze.current={x:bt.clientX,y:bt.clientY})))},onPointerUp:()=>{var bt,It,sn;if(J||!Ue)return;Ze.current=null;const Ge=Number(((bt=Se.current)==null?void 0:bt.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),at=Number(((It=Se.current)==null?void 0:It.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ct=new Date().getTime()-((sn=be.current)==null?void 0:sn.getTime()),an=B==="x"?Ge:at,Kt=Math.abs(an)/ct;if(Math.abs(an)>=VIn||Kt>.11){le(Re.current),f.onDismiss==null||f.onDismiss.call(f,f),V(B==="x"?Ge>0?"right":"left":at>0?"down":"up"),Ke(),ie(!0);return}else{var _n,Te;(_n=Se.current)==null||_n.style.setProperty("--swipe-amount-x","0px"),(Te=Se.current)==null||Te.style.setProperty("--swipe-amount-y","0px")}Y(!1),ee(!1),M(null)},onPointerMove:bt=>{var It,sn,Ge;if(!Ze.current||!Ue||((It=window.getSelection())==null?void 0:It.toString().length)>0)return;const ct=bt.clientY-Ze.current.y,an=bt.clientX-Ze.current.x;var Kt;const _n=(Kt=e.swipeDirections)!=null?Kt:WIn(z);!B&&(Math.abs(an)>1||Math.abs(ct)>1)&&M(Math.abs(an)>Math.abs(ct)?"x":"y");let Te={x:0,y:0};const Le=Me=>1/(1.5+Math.abs(Me)/20);if(B==="y"){if(_n.includes("top")||_n.includes("bottom"))if(_n.includes("top")&&ct<0||_n.includes("bottom")&&ct>0)Te.y=ct;else{const Me=ct*Le(ct);Te.y=Math.abs(Me)<Math.abs(ct)?Me:ct}}else if(B==="x"&&(_n.includes("left")||_n.includes("right")))if(_n.includes("left")&&an<0||_n.includes("right")&&an>0)Te.x=an;else{const Me=an*Le(an);Te.x=Math.abs(Me)<Math.abs(an)?Me:an}(Math.abs(Te.x)>0||Math.abs(Te.y)>0)&&Y(!0),(sn=Se.current)==null||sn.style.setProperty("--swipe-amount-x",`${Te.x}px`),(Ge=Se.current)==null||Ge.style.setProperty("--swipe-amount-y",`${Te.y}px`)}},me&&!f.jsx&&Ae!=="loading"?De.createElement("button",{"aria-label":F,"data-disabled":Fe,"data-close-button":!0,onClick:Fe||!Ue?()=>{}:()=>{Ke(),f.onDismiss==null||f.onDismiss.call(f,f)},className:Hg(W?.closeButton,f==null||(r=f.classNames)==null?void 0:r.closeButton)},(en=L?.close)!=null?en:IIn):null,(Ae||f.icon||f.promise)&&f.icon!==null&&(L?.[Ae]!==null||f.icon)?De.createElement("div",{"data-icon":"",className:Hg(W?.icon,f==null||(s=f.classNames)==null?void 0:s.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||Ye():null,f.type!=="loading"?Rt:null):null,De.createElement("div",{"data-content":"",className:Hg(W?.content,f==null||(a=f.classNames)==null?void 0:a.content)},De.createElement("div",{"data-title":"",className:Hg(W?.title,f==null||(i=f.classNames)==null?void 0:i.title)},f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title),f.description?De.createElement("div",{"data-description":"",className:Hg(P,ae,W?.description,f==null||(l=f.classNames)==null?void 0:l.description)},typeof f.description=="function"?f.description():f.description):null),De.isValidElement(f.cancel)?f.cancel:f.cancel&&wL(f.cancel)?De.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||E,onClick:bt=>{wL(f.cancel)&&Ue&&(f.cancel.onClick==null||f.cancel.onClick.call(f.cancel,bt),Ke())},className:Hg(W?.cancelButton,f==null||(c=f.classNames)==null?void 0:c.cancelButton)},f.cancel.label):null,De.isValidElement(f.action)?f.action:f.action&&wL(f.action)?De.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||N,onClick:bt=>{wL(f.action)&&(f.action.onClick==null||f.action.onClick.call(f.action,bt),!bt.defaultPrevented&&Ke())},className:Hg(W?.actionButton,f==null||(u=f.classNames)==null?void 0:u.actionButton)},f.action.label):null)};function m4e(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function GIn(e,t){const n={};return[e,t].forEach((r,s)=>{const a=s===1,i=a?"--mobile-offset":"--offset",l=a?BIn:zIn;function c(u){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof u=="number"?`${u}px`:u})}typeof r=="number"||typeof r=="string"?c(r):typeof r=="object"?["top","right","bottom","left"].forEach(u=>{r[u]===void 0?n[`${i}-${u}`]=l:n[`${i}-${u}`]=typeof r[u]=="number"?`${r[u]}px`:r[u]}):c(l)}),n}const QIn=De.forwardRef(function(t,n){const{id:r,invert:s,position:a="bottom-right",hotkey:i=["altKey","KeyT"],expand:l,closeButton:c,className:u,offset:d,mobileOffset:f,theme:p="light",richColors:h,duration:m,style:g,visibleToasts:v=FIn,toastOptions:b,dir:w=m4e(),gap:S=qIn,icons:O,containerAriaLabel:_="Notifications"}=t,[C,j]=De.useState([]),E=De.useMemo(()=>r?C.filter(R=>R.toasterId===r):C.filter(R=>!R.toasterId),[C,r]),N=De.useMemo(()=>Array.from(new Set([a].concat(E.filter(R=>R.position).map(R=>R.position)))),[E,a]),[I,P]=De.useState([]),[$,z]=De.useState(!1),[D,q]=De.useState(!1),[W,L]=De.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),F=De.useRef(null),B=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),M=De.useRef(null),Q=De.useRef(!1),V=De.useCallback(R=>{j(U=>{var Z;return(Z=U.find(X=>X.id===R.id))!=null&&Z.delete||Ad.dismiss(R.id),U.filter(({id:X})=>X!==R.id)})},[]);return De.useEffect(()=>Ad.subscribe(R=>{if(R.dismiss){requestAnimationFrame(()=>{j(U=>U.map(Z=>Z.id===R.id?{...Z,delete:!0}:Z))});return}setTimeout(()=>{Zve.flushSync(()=>{j(U=>{const Z=U.findIndex(X=>X.id===R.id);return Z!==-1?[...U.slice(0,Z),{...U[Z],...R},...U.slice(Z+1)]:[R,...U]})})})}),[C]),De.useEffect(()=>{if(p!=="system"){L(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?L("dark"):L("light")),typeof window>"u")return;const R=window.matchMedia("(prefers-color-scheme: dark)");try{R.addEventListener("change",({matches:U})=>{L(U?"dark":"light")})}catch{R.addListener(({matches:Z})=>{try{L(Z?"dark":"light")}catch(X){console.error(X)}})}},[p]),De.useEffect(()=>{C.length<=1&&z(!1)},[C]),De.useEffect(()=>{const R=U=>{var Z;if(i.every(ee=>U[ee]||U.code===ee)){var te;z(!0),(te=F.current)==null||te.focus()}U.code==="Escape"&&(document.activeElement===F.current||(Z=F.current)!=null&&Z.contains(document.activeElement))&&z(!1)};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[i]),De.useEffect(()=>{if(F.current)return()=>{M.current&&(M.current.focus({preventScroll:!0}),M.current=null,Q.current=!1)}},[F.current]),De.createElement("section",{ref:n,"aria-label":`${_} ${B}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},N.map((R,U)=>{var Z;const[X,te]=R.split("-");return E.length?De.createElement("ol",{key:R,dir:w==="auto"?m4e():w,tabIndex:-1,ref:F,className:u,"data-sonner-toaster":!0,"data-sonner-theme":W,"data-y-position":X,"data-x-position":te,style:{"--front-toast-height":`${((Z=I[0])==null?void 0:Z.height)||0}px`,"--width":`${UIn}px`,"--gap":`${S}px`,...g,...GIn(d,f)},onBlur:ee=>{Q.current&&!ee.currentTarget.contains(ee.relatedTarget)&&(Q.current=!1,M.current&&(M.current.focus({preventScroll:!0}),M.current=null))},onFocus:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||Q.current||(Q.current=!0,M.current=ee.relatedTarget)},onMouseEnter:()=>z(!0),onMouseMove:()=>z(!0),onMouseLeave:()=>{D||z(!1)},onDragEnd:()=>z(!1),onPointerDown:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||q(!0)},onPointerUp:()=>q(!1)},E.filter(ee=>!ee.position&&U===0||ee.position===R).map((ee,J)=>{var ie,ue;return De.createElement(ZIn,{key:ee.id,icons:O,index:J,toast:ee,defaultRichColors:h,duration:(ie=b?.duration)!=null?ie:m,className:b?.className,descriptionClassName:b?.descriptionClassName,invert:s,visibleToasts:v,closeButton:(ue=b?.closeButton)!=null?ue:c,interacting:D,position:R,style:b?.style,unstyled:b?.unstyled,classNames:b?.classNames,cancelButtonStyle:b?.cancelButtonStyle,actionButtonStyle:b?.actionButtonStyle,closeButtonAriaLabel:b?.closeButtonAriaLabel,removeToast:V,toasts:E.filter(Y=>Y.position==ee.position),heights:I.filter(Y=>Y.position==ee.position),setHeights:P,expandByDefault:l,gap:S,expanded:$,swipeDirections:t.swipeDirections})})):null}))}),yxe=({className:e,toastOptions:t,...n})=>o.jsx(QIn,{...n,closeButton:!0,richColors:!0,className:K("mastra-toaster",e),toastOptions:{duration:5e3,...t}}),sq=(e,t)=>Array.isArray(e)?e.map(t):t(e),Be=(e,t={})=>{if(Array.isArray(e))return e.map(n=>bu(n,t));if(De.isValidElement(e)||typeof e=="string")return bu(e,t);throw new Error("Invalid message type")};Be.success=(e,t={})=>sq(e,n=>bu.success(n,t));Be.error=(e,t={})=>sq(e,n=>bu.error(n,t));Be.warning=(e,t={})=>sq(e,n=>bu.warning(n,t));Be.info=(e,t={})=>sq(e,n=>bu.info(n,t));Be.custom=(e,t={})=>bu(e,t);Be.dismiss=e=>bu.dismiss(e);Be.promise=({myPromise:e,loadingMessage:t,successMessage:n,errorMessage:r,onSuccess:s,onError:a,options:i={}})=>bu.promise(e,{loading:t??"Loading...",success:l=>(s?.(l),n),error:l=>(a?.(l),r||(l instanceof Error?l.message:"Error...")),...i});function Zv({text:e,copyMessage:t="Copied to clipboard!"}){const[n,r]=y.useState(!1),s=y.useRef(null),a=y.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{Be.success(t),r(!0),s.current&&(clearTimeout(s.current),s.current=null),s.current=setTimeout(()=>{r(!1)},2e3)}).catch(()=>{Be.error("Failed to copy to clipboard.")})},[e,t]);return{isCopied:n,handleCopy:a}}function xa({content:e,copyMessage:t,tooltip:n="Copy to clipboard",size:r="sm",variant:s,className:a}){const[i,l]=y.useState(!1),{handleCopy:c}=Zv({text:e,copyMessage:t}),u=()=>{c(),l(!0),setTimeout(()=>l(!1),2e3)};return o.jsxs(Hn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx(fe,{onClick:u,type:"button",size:r,variant:s,className:a,"aria-label":i?"Copied!":n,children:i?o.jsx(kx,{}):o.jsx(Aht,{})})}),o.jsx(Bn,{children:i?"Copied!":n})]})}const YIn="mastra-theme",XIn="mastra-playground-store",lfe=e=>e==="dark"||e==="light"||e==="system",KIn=e=>{try{const t=e.getItem(XIn);if(!t)return;const r=JSON.parse(t)?.state?.theme;return lfe(r)?r:void 0}catch{return}},JIn=(e=YIn)=>({get(){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(lfe(t))return t;const n=KIn(window.localStorage);return n?(window.localStorage.setItem(e,n),n):null}catch{return null}},set(t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}},subscribe(t){if(typeof window>"u")return()=>{};const n=r=>{if(r.key===e){if(r.newValue===null){t(null);return}lfe(r.newValue)&&t(r.newValue)}};return window.addEventListener("storage",n),()=>window.removeEventListener("storage",n)}}),Dht=y.createContext(null),Lht="(prefers-color-scheme: dark)",eAn=typeof window>"u"?y.useEffect:y.useLayoutEffect,Fht=()=>typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia(Lht).matches?"dark":"light",zht=e=>{if(typeof window>"u"||typeof window.matchMedia!="function")return()=>{};const t=window.matchMedia(Lht);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},tAn=(e,t)=>{e.classList.remove(t==="dark"?"light":"dark"),e.classList.add(t)},Bht=({children:e,defaultTheme:t="system",storageKey:n,target:r})=>{const s=y.useMemo(()=>JIn(n),[n]),a=y.useRef(null),[i,l]=y.useState(()=>s.get()??t),c=y.useSyncExternalStore(zht,Fht,()=>"dark");y.useEffect(()=>s.subscribe(f=>l(f??t)),[s,t]);const u=i==="system"?c:i;eAn(()=>{const f=r??(typeof window>"u"?null:window.document.documentElement);a.current&&a.current!==f&&a.current.classList.remove("dark","light"),f&&tAn(f,u),a.current=f},[u,r]);const d=y.useMemo(()=>({theme:i,resolvedTheme:u,systemTheme:c,setTheme:f=>{l(f),s.set(f)}}),[i,u,c,s]);return o.jsx(Dht.Provider,{value:d,children:e})},nAn=()=>{},hN=()=>{const e=y.useContext(Dht),t=y.useSyncExternalStore(zht,Fht,()=>"dark");return y.useMemo(()=>e??{theme:"system",resolvedTheme:t,systemTheme:t,setTheme:nAn},[e,t])};function rAn(e){return new iO(Ebe.define(e))}const Uht=[Mm.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return wo(()=>Promise.resolve().then(()=>gL),[],import.meta.url).then(e=>e.javascript())}}),Mm.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return wo(()=>Promise.resolve().then(()=>qSn),void 0,import.meta.url).then(e=>e.json())}}),Mm.of({name:"JSX",extensions:["jsx"],load(){return wo(()=>Promise.resolve().then(()=>gL),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),Mm.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return wo(()=>Promise.resolve().then(()=>DCn),void 0,import.meta.url).then(e=>e.markdown())}}),Mm.of({name:"TSX",extensions:["tsx"],load(){return wo(()=>Promise.resolve().then(()=>gL),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Mm.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return wo(()=>Promise.resolve().then(()=>gL),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),Mm.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return wo(()=>import("./shell-CjFT_Tl9.js"),[],import.meta.url).then(e=>rAn(e.shell))}})];function sAn(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 aAn(e){const t=sAn(e);return bft({override:[iAn(t)],defaultKeymap:!0,closeOnBlur:!0,icons:!1})}function iAn(e){return t=>{const r=t.state.sliceDoc(Math.max(0,t.pos-50),t.pos).match(/\{\{([a-zA-Z0-9_.\[\]]*)?$/);if(!r)return null;const s=r[1]??"",a=t.pos-s.length,i=s?e.filter(c=>c.path.toLowerCase().startsWith(s.toLowerCase())):e;if(i.length===0)return null;const l=i.map(c=>({label:c.path,displayLabel:c.path,detail:c.type,info:c.description,apply:(u,d,f,p)=>{const g=u.state.sliceDoc(p,p+2)==="}}"?d.label:`${d.label}}}`;u.dispatch({changes:{from:f,to:p,insert:g},selection:{anchor:f+g.length}})}}));return{from:a,options:l,validFor:/^[a-zA-Z0-9_.\[\]]*$/}}}const oAn=/\{\{([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)\}\}/g,lAn=Cn.mark({class:"cm-variable-highlight"}),g4e=new Rdt({regexp:oAn,decoration:()=>lAn}),cAn=po.fromClass(class{decorations;constructor(e){this.decorations=g4e.createDeco(e)}update(e){this.decorations=g4e.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}),uAn=cAn;function dAn(){const e=dN({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:[de.className,de.propertyName],color:"var(--neutral6)"},{tag:de.heading,color:"var(--accent3)",fontWeight:"bold"},{tag:[de.heading1,de.heading2,de.heading3,de.heading4,de.heading5,de.heading6],color:"var(--accent3)",fontWeight:"bold"},{tag:de.emphasis,fontStyle:"italic",color:"var(--neutral6)"},{tag:de.strong,fontWeight:"bold",color:"var(--neutral6)"},{tag:de.link,color:"var(--accent3)",textDecoration:"underline"},{tag:de.url,color:"var(--accent3)"},{tag:de.monospace,color:"var(--neutral6)"},{tag:de.strikethrough,textDecoration:"line-through"},{tag:de.quote,fontStyle:"italic",color:"var(--neutral2)"}]}),t=Nt.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 fAn(){const e=Nt.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=kg.define([{tag:[de.comment,de.bracket],color:"var(--neutral2)"},{tag:[de.string,de.meta,de.regexp],color:"var(--accent1)"},{tag:[de.atom,de.bool,de.special(de.variableName)],color:"var(--accent6)"},{tag:[de.keyword,de.operator,de.tagName],color:"var(--accent2)"},{tag:[de.function(de.propertyName),de.propertyName],color:"var(--accent5)"},{tag:[de.definition(de.variableName),de.function(de.variableName),de.className,de.attributeName],color:"var(--accent3)"},{tag:[de.variableName,de.number],color:"var(--accent5)"},{tag:[de.name,de.quote],color:"var(--accent1)"},{tag:de.heading,color:"var(--accent3)",fontWeight:"bold"},{tag:[de.heading1,de.heading2,de.heading3,de.heading4,de.heading5,de.heading6],color:"var(--accent3)",fontWeight:"bold"},{tag:[de.emphasis],fontStyle:"italic",color:"var(--neutral6)"},{tag:[de.strong],fontWeight:"bold",color:"var(--neutral6)"},{tag:de.link,color:"var(--accent3)",textDecoration:"underline"},{tag:de.url,color:"var(--accent3)"},{tag:de.monospace,color:"var(--neutral6)"},{tag:de.strikethrough,textDecoration:"line-through"},{tag:[de.deleted],color:"var(--accent2)"},{tag:de.invalid,color:"var(--error)"},{tag:[de.standard(de.tagName)],color:"var(--accent1)"}]);return[e,w1(t)]}const hy=()=>{const e=hN().resolvedTheme==="dark";return y.useMemo(()=>e?dAn():fAn(),[e])},as=y.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,editable:f,...p},h)=>{const m=hy(),g=e?JSON.stringify(e,null,2):t??"",v=y.useMemo(()=>{const b=[];return a==="json"?b.push(Kd):a==="markdown"&&(b.push(exe({base:cO,codeLanguages:Uht})),b.push(Nt.lineWrapping)),i&&a==="markdown"&&b.push(uAn),c&&a==="markdown"&&b.push(aAn(c)),f===!1&&b.push(is.readOnly.of(!0)),b},[a,i,c,f]);return o.jsxs("div",{className:K("rounded-md bg-surface3 p-1 font-mono relative border border-border1 overflow-hidden",s),...p,children:[r&&o.jsx(xa,{content:g,className:"absolute top-2 right-2 z-20"}),o.jsx(Hc,{ref:h,value:g,theme:m,extensions:v,onChange:n,editable:f,"aria-label":"Code editor",placeholder:l,height:"100%",style:{height:"100%"},autoFocus:u,basicSetup:{lineNumbers:d}})]})}),pAn={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 cX=null;function hAn(){return cX||(cX=(async()=>{const[{createHighlighterCore:e},{createJavaScriptRegexEngine:t}]=await Promise.all([wo(()=>import("./core-mNco33Iy.js"),__vite__mapDeps([0,1,2]),import.meta.url),wo(()=>import("./engine-javascript-CSIo_1eZ.js"),__vite__mapDeps([3,1]),import.meta.url)]);return e({themes:[wo(()=>import("./github-light-DAi9KRSo.js"),[],import.meta.url),wo(()=>import("./github-dark-DHJKELXO.js"),[],import.meta.url)],langs:[wo(()=>import("./javascript-ySlJ1b_l.js"),[],import.meta.url),wo(()=>import("./typescript-Dj6nwHGl.js"),[],import.meta.url),wo(()=>import("./tsx-B6W0miNI.js"),[],import.meta.url),wo(()=>import("./jsx-BAng5TT0.js"),[],import.meta.url),wo(()=>import("./json-BQoSv7ci.js"),[],import.meta.url),wo(()=>import("./bash-atvbtKCR.js"),[],import.meta.url),wo(()=>import("./markdown-UIAJJxZW.js"),[],import.meta.url),wo(()=>import("./python-DhUJRlN_.js"),[],import.meta.url)],engine:t()})})()),cX}async function mAn(e,t){const n=pAn[t?.toLowerCase()];if(!n)return null;const r=await hAn(),{tokens:s}=r.codeToTokens(e,{lang:n,defaultColor:!1,themes:{light:"github-light",dark:"github-dark"}});return s}function Wr({iconSlot:e,titleSlot:t,descriptionSlot:n,actionSlot:r,className:s,as:a="h3"}){return o.jsxs("div",{className:K("flex flex-col items-center justify-center text-center py-10 px-6","transition-opacity duration-normal ease-out-custom",s),children:[e&&o.jsx("div",{className:"mb-4",children:e}),o.jsx(a,{className:"font-medium text-neutral5 text-ui-md",children:t}),n&&o.jsx("p",{className:"mt-1.5 text-neutral3 text-ui-sm max-w-md",children:n}),r&&o.jsx("div",{className:"mt-5",children:r})]})}const bf=({children:e,className:t,onClick:n})=>o.jsx("div",{tabIndex:n?0:void 0,onKeyDown:r=>{n&&(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),n?.())},className:K("flex gap-3 group/entity bg-surface3 rounded-xl border border-border1 py-3 px-4",n&&"cursor-pointer hover:bg-surface4 transition-all",t),onClick:n,children:e}),qht=({children:e,className:t,style:n})=>o.jsx(Ve,{size:"lg",className:K("text-neutral3 mt-1 shrink-0",t),style:n,children:e}),xf=({children:e,className:t})=>o.jsx(ge,{as:"p",variant:"ui-lg",className:K("text-neutral6 font-medium",t),children:e}),Up=({children:e,className:t})=>o.jsx(ge,{as:"div",variant:"ui-sm",className:K("text-neutral3",t),children:e}),wf=({children:e,className:t})=>o.jsx("div",{className:K("flex-1 w-full",t),children:e});function $s({resource:e,title:t,description:n,actionSlot:r,className:s}){const a="Permission Denied",i=e?`You don't have permission to access ${e}. Contact your administrator for access.`:"You don't have permission to access this resource. Contact your administrator for access.";return o.jsx(Wr,{className:s,iconSlot:o.jsx(Ve,{size:"lg",className:"text-neutral3",children:o.jsx(aIn,{})}),titleSlot:t??a,descriptionSlot:n??i,actionSlot:r})}function Vs({title:e,description:t,className:n}){const[r,s]=y.useState(!1),a=We(),i=y.useCallback(async()=>{try{s(!0);const{baseUrl:l="",apiPrefix:c}=a.options||{},u=(c||"/api").trim(),d=(u.startsWith("/")?u:`/${u}`).replace(/\/$/,""),f=new URLSearchParams({redirect_uri:window.location.href}),p=`${l}${d}/auth/sso/login?${f}`,h=await fetch(p,{credentials:"include",headers:{"Content-Type":"application/json"}});if(h.ok){const m=await h.json();window.location.href=m.url}}finally{s(!1)}},[a]);return o.jsx(Wr,{className:n,iconSlot:o.jsx(Ve,{size:"lg",className:"text-neutral3",children:o.jsx(VNn,{})}),titleSlot:e??"Session Expired",descriptionSlot:t??"Your session has expired. Please log in again to continue.",actionSlot:o.jsx(fe,{variant:"default",onClick:i,disabled:r,children:r?"Redirecting...":"Log in"})})}const bxe=({children:e,border:t=!0,className:n})=>o.jsx("header",{className:K("h-header-default z-50 flex w-full items-center gap-4 bg-transparent px-3",{"border-b border-border1":t},n),children:e}),Vht=({children:e})=>o.jsx(ge,{as:"h1",variant:"ui-md",className:"text-neutral6 flex items-center gap-2",children:e}),gAn=({children:e})=>o.jsx("div",{className:"ml-auto flex items-center gap-3",children:e}),Rh=e=>o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 34 21",fill:"none",...e,children:o.jsx("path",{d:"M4.49805 11.6934C6.98237 11.6934 8.99609 13.7081 8.99609 16.1924C8.9959 18.6765 6.98225 20.6904 4.49805 20.6904C2.01394 20.6903 0.000196352 18.6765 0 16.1924C0 13.7081 2.01382 11.6935 4.49805 11.6934ZM10.3867 0C12.8709 0 14.8846 2.01388 14.8848 4.49805C14.8848 4.8377 14.847 5.16846 14.7755 5.48643C14.4618 6.88139 14.1953 8.4633 14.9928 9.65L16.2575 11.5319C16.3363 11.6491 16.4727 11.7115 16.6137 11.703C16.7369 11.6957 16.8525 11.6343 16.9214 11.5318L18.1876 9.64717C18.9772 8.47198 18.7236 6.90783 18.4205 5.52484C18.3523 5.21392 18.3164 4.89094 18.3164 4.55957C18.3167 2.07546 20.3313 0.0615234 22.8154 0.0615234C25.2994 0.0617476 27.3132 2.0756 27.3135 4.55957C27.3135 4.93883 27.2665 5.30712 27.178 5.65896C26.8547 6.94441 26.5817 8.37932 27.2446 9.52714L28.459 11.6301C28.4819 11.6697 28.5245 11.6934 28.5703 11.6934C31.0545 11.6935 33.0684 13.7081 33.0684 16.1924C33.0682 18.6765 31.0544 20.6903 28.5703 20.6904C26.0861 20.6904 24.0725 18.6765 24.0723 16.1924C24.0723 15.8049 24.1212 15.4288 24.2133 15.0701C24.5458 13.7746 24.8298 12.3251 24.1609 11.1668L23.0044 9.16384C22.9656 9.09659 22.8931 9.05859 22.8154 9.05859C22.7983 9.05859 22.7824 9.06614 22.7728 9.08033L21.4896 10.9895C20.686 12.1851 20.9622 13.781 21.284 15.1851C21.3582 15.5089 21.3975 15.8461 21.3975 16.1924C21.3973 18.6764 19.3834 20.6902 16.8994 20.6904C14.4152 20.6904 12.4006 18.6765 12.4004 16.1924C12.4004 15.932 12.4226 15.6768 12.4651 15.4286C12.6859 14.14 12.8459 12.7122 12.1167 11.6271L11.2419 10.3253C10.6829 9.49347 9.71913 9.05932 8.78286 8.70188C7.0906 8.05584 5.88867 6.41734 5.88867 4.49805C5.88886 2.0139 7.90254 3.29835e-05 10.3867 0Z",fill:"currentColor"})}),vAn={default:"[&>tbody>tr]:h-table-row",small:"[&>tbody>tr]:h-table-row-small"},yAn=({className:e,children:t,size:n="default",style:r})=>o.jsx("table",{className:K("w-full",vAn[n],e),style:r,children:t}),bAn=({className:e,children:t})=>o.jsx("thead",{children:o.jsx("tr",{className:K("h-table-header border-b border-border1 bg-surface2/80",e),children:t})}),xAn=({className:e,children:t,...n})=>o.jsx("th",{className:K("text-neutral2 text-ui-xs h-full whitespace-nowrap text-left font-medium uppercase tracking-wide first:pl-3 last:pr-3",e),...n,children:t}),wAn=({className:e,children:t,...n})=>o.jsx("tbody",{className:K("",e),...n,children:t}),SAn=y.forwardRef(({className:e,children:t,selected:n=!1,style:r,onClick:s,isActive:a=!1,...i},l)=>{const c=y.useRef(null);y.useEffect(()=>{l&&(typeof l=="function"?l(c.current):l.current=c.current)},[l]),y.useEffect(()=>{a&&c.current&&(c.current.focus(),c.current.scrollIntoView({block:"nearest"}))},[a]);const u=d=>{d.key==="Enter"&&s&&s()};return o.jsx("tr",{className:K("border-b border-border1","transition-colors duration-normal ease-out-custom","hover:bg-surface3","focus:bg-surface3 focus:outline-hidden focus:ring-1 focus:ring-inset focus:ring-accent1/50",n&&"bg-surface4",s&&"cursor-pointer",e),style:r,onClick:s,ref:c,tabIndex:s?0:void 0,onKeyDown:u,"data-active":a||void 0,...i,children:t})}),kAn=({className:e,children:t,...n})=>o.jsx("td",{className:K("text-neutral5 first:pl-3 last:pr-3",e),...n,children:o.jsx("div",{className:K("flex h-full w-full shrink-0 items-center"),children:t})}),OAn=cl(K("flex w-full text-neutral6 border bg-transparent","transition-all duration-normal ease-out-custom","placeholder:text-neutral2 placeholder:transition-opacity placeholder:duration-normal","focus:placeholder:opacity-70","min-h-[80px] resize-y"),{variants:{variant:{default:K(NF,"rounded-xl",_k),filled:K(NF,"rounded-xl",_k),outline:K(nut,"rounded-xl",_k),unstyled:rut},size:{sm:"px-2 py-1.5 text-ui-sm",md:"px-3 py-2 text-ui-md",default:"px-3 py-2 text-ui-md",lg:"px-4 py-3 text-ui-lg"}},defaultVariants:{variant:"default",size:"default"}}),ql=y.forwardRef(({className:e,size:t,testId:n,variant:r,error:s,...a},i)=>o.jsx("textarea",{className:K(OAn({variant:r,size:t}),s&&"border-error focus-visible:border-error",e),"data-testid":n,ref:i,"aria-invalid":s,...a}));ql.displayName="Textarea";let v4e={},y4e={},b4e="";function _An(e){if(typeof document>"u")return!1;const t=dr(e);return Ks(t).innerWidth-t.documentElement.clientWidth>0}function CAn(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const n=dr(e),r=n.documentElement,s=n.body,a=y1(r)?r:s,i=a.style.overflowY,l=r.style.scrollbarGutter;r.style.scrollbarGutter="stable",a.style.overflowY="scroll";const c=a.offsetWidth;a.style.overflowY="hidden";const u=a.offsetWidth;return a.style.overflowY=i,r.style.scrollbarGutter=l,c===u}function EAn(e){const t=dr(e),n=t.documentElement,r=t.body,s=y1(n)?n:r,a={overflowY:s.style.overflowY,overflowX:s.style.overflowX};return Object.assign(s.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(s.style,a)}}function jAn(e){const t=dr(e),n=t.documentElement,r=t.body,s=Ks(n);let a=0,i=0,l=!1;const c=$d.create();if(OU&&(s.visualViewport?.scale??1)!==1)return()=>{};function u(){const h=s.getComputedStyle(n),m=s.getComputedStyle(r),b=(h.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";a=n.scrollTop,i=n.scrollLeft,v4e={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},b4e=n.style.scrollBehavior,y4e={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const w=n.scrollHeight>n.clientHeight,S=n.scrollWidth>n.clientWidth,O=h.overflowY==="scroll"||m.overflowY==="scroll",_=h.overflowX==="scroll"||m.overflowX==="scroll",C=Math.max(0,s.innerWidth-r.clientWidth),j=Math.max(0,s.innerHeight-r.clientHeight),E=parseFloat(m.marginTop)+parseFloat(m.marginBottom),N=parseFloat(m.marginLeft)+parseFloat(m.marginRight),I=y1(n)?n:r;if(l=CAn(e),l){n.style.scrollbarGutter=b,I.style.overflowY="hidden",I.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:b,overflowY:"hidden",overflowX:"hidden"}),(w||O)&&(n.style.overflowY="scroll"),(S||_)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:E||j?`calc(100dvh - ${E+j}px)`:"100dvh",width:N||C?`calc(100vw - ${N+C}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=a,r.scrollLeft=i,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function d(){Object.assign(n.style,v4e),Object.assign(r.style,y4e),l||(n.scrollTop=a,n.scrollLeft=i,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=b4e)}function f(){d(),c.request(u)}u();const p=Br(s,"resize",f);return()=>{c.cancel(),d(),typeof s.removeEventListener=="function"&&p()}}class TAn{lockCount=0;restore=null;timeoutLock=Vh.create();timeoutUnlock=Vh.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(t){if(this.lockCount===0||this.restore!==null)return;const r=dr(t).documentElement,s=Ks(r).getComputedStyle(r).overflowY;if(s==="hidden"||s==="clip"){this.restore=ma;return}const a=jye||!_An(t);this.restore=a?EAn(t):jAn(t)}}const NAn=new TAn;function Hht(e=!0,t=null){Tt(()=>{if(e)return NAn.acquire(t)},[e,t])}function IAn(e){const{store:t,parentContext:n,actionsRef:r,isDrawer:s}=e,a=t.useState("open");Vct(t,a),GM(t);const{forceUnmount:i}=QM(a,t),l=y.useCallback(()=>{t.setOpen(!1,Vt(VM))},[t]);return y.useImperativeHandle(r,()=>({unmount:i,close:l}),[i,l]),{parentContext:n,isDrawer:s}}function AAn({store:e,dialogRoot:t}){const{parentContext:n,isDrawer:r}=t,s=e.useState("open"),a=e.useState("disablePointerDismissal"),i=e.useState("modal"),l=e.useState("popupElement"),c=e.useState("floatingRootContext"),[u,d]=y.useState(0),[f,p]=y.useState(0),h=u===0,m=l_(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?"intentional":{mouse:i==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(w){if(!e.context.outsidePressEnabledRef.current||"button"in w&&w.button!==0||"touches"in w&&w.touches.length!==1)return!1;const S=Si(w);if(h&&!a){const O=S;return i&&(e.context.internalBackdropRef.current||e.context.backdropRef.current)?e.context.internalBackdropRef.current===O||e.context.backdropRef.current===O||dn(O,l)&&!O?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:h});Hht(s&&i===!0,l),e.useContextCallback("onNestedDialogOpen",(w,S)=>{d(w),p(S)}),e.useContextCallback("onNestedDialogClose",()=>{d(0),p(0)}),y.useEffect(()=>(n?.onNestedDialogOpen&&s&&n.onNestedDialogOpen(u+1,f+(r?1:0)),n?.onNestedDialogClose&&!s&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&s&&n.onNestedDialogClose()}),[r,s,u,f,n]);const g=m.reference??hs,v=m.trigger??hs,b=y.useMemo(()=>Eo(uy,m.floating),[m.floating]);return YM(e,{activeTriggerProps:g,inactiveTriggerProps:v,popupProps:b,nestedOpenDialogCount:u,nestedOpenDrawerCount:f}),null}const xxe=y.createContext(!1),Wht=y.createContext(void 0);function md(e){const t=y.useContext(Wht);if(e===!1&&t===void 0)throw new Error(Sr(27));return t}const RAn={...KM,modal:lt(e=>e.modal),nested:lt(e=>e.nested),nestedOpenDialogCount:lt(e=>e.nestedOpenDialogCount),nestedOpenDrawerCount:lt(e=>e.nestedOpenDrawerCount),disablePointerDismissal:lt(e=>e.disablePointerDismissal),openMethod:lt(e=>e.openMethod),descriptionElementId:lt(e=>e.descriptionElementId),titleElementId:lt(e=>e.titleElementId),viewportElement:lt(e=>e.viewportElement),role:lt(e=>e.role)};class wxe extends tN{constructor(t,n,r=!1){const s=new c_,a=PAn(t);a.floatingRootContext=RU(s,n,r),super(a,{popupRef:y.createRef(),backdropRef:y.createRef(),internalBackdropRef:y.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:s,onOpenChange:void 0,onOpenChangeComplete:void 0},RAn)}setOpen=(t,n)=>{if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!t&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(t,n),n.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(t,n);const r={open:t};AU(r,t,n.trigger),this.update(r)};static useStore(t,n){return IU(t,(s,a)=>new wxe(n,s,a),!0).store}}function PAn(e={}){return{...XM(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:"dialog",...e}}function Zht(e,t="dialog"){const{children:n,open:r,defaultOpen:s=!1,onOpenChange:a,onOpenChangeComplete:i,disablePointerDismissal:l=!1,modal:c=!0,actionsRef:u,handle:d,triggerId:f,defaultTriggerId:p=null}=e,h=t==="drawer",m=t==="alert-dialog",g=m?!0:c,v=m||l,b=m?"alertdialog":"dialog",w=md(!0),O={modal:g,disablePointerDismissal:v,nested:!!w,role:b},_=wxe.useStore(d?.store,{open:s,openProp:r,activeTriggerId:p,triggerIdProp:f,...O});s_(()=>{const $=r===void 0&&_.state.open===!1&&s===!0?{open:!0,activeTriggerId:p}:null;m?_.update($?{...O,...$}:O):$&&_.update($)}),_.useControlledProp("openProp",r),_.useControlledProp("triggerIdProp",f),_.useSyncedValues(O),_.useContextCallback("onOpenChange",a),_.useContextCallback("onOpenChangeComplete",i);const C=_.useState("open"),j=_.useState("mounted"),E=_.useState("payload"),N=IAn({store:_,actionsRef:u,parentContext:w?.store.context,isDrawer:h}),I=C||j,P=y.useMemo(()=>({store:_}),[_]);return o.jsx(xxe.Provider,{value:!1,children:o.jsxs(Wht.Provider,{value:P,children:[I&&o.jsx(AAn,{store:_,dialogRoot:N}),typeof n=="function"?n({payload:E}):n]})})}function $An(e){return Zht(e,"alert-dialog")}const MAn={...yf,...Hl},Ght=y.forwardRef(function(t,n){const{render:r,className:s,style:a,forceRender:i=!1,...l}=t,{store:c}=md(),u=c.useState("open"),d=c.useState("nested"),f=c.useState("mounted"),p=c.useState("transitionStatus");return En("div",t,{state:{open:u,transitionStatus:p},ref:[c.context.backdropRef,n],stateAttributesMapping:MAn,props:[{role:"presentation",hidden:!f,style:{userSelect:"none",WebkitUserSelect:"none"}},l],enabled:i||!d})}),Qht=y.createContext(void 0);function Sxe(e=!1){const t=y.useContext(Qht);if(t===void 0&&!e)throw new Error(Sr(16));return t}function DAn(e){const{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:s=0,isNativeButton:a}=e,i=r&&t!==!1,l=r&&t===!1;return{props:y.useMemo(()=>{const u={onKeyDown(d){n&&t&&d.key!=="Tab"&&d.preventDefault()}};return r||(u.tabIndex=s,!a&&n&&(u.tabIndex=t?s:-1)),(a&&(t||i)||!a&&n)&&(u["aria-disabled"]=n),a&&(!t||l)&&(u.disabled=n),u},[r,n,t,i,l,a,s])}}function gd(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:s=!0,composite:a}=e,i=y.useRef(null),l=Sxe(!0),c=a??l!==void 0,{props:u}=DAn({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:s}),d=y.useCallback(()=>{const h=i.current;uX(h)&&c&&t&&u.disabled===void 0&&h.disabled&&(h.disabled=!1)},[t,u.disabled,c]);Tt(d,[d]);const f=y.useCallback((h={})=>{const{onClick:m,onMouseDown:g,onKeyUp:v,onKeyDown:b,onPointerDown:w,...S}=h;return Eo({onClick(O){if(t){O.preventDefault();return}m?.(O)},onMouseDown(O){t||g?.(O)},onKeyDown(O){if(t||(_F(O),b?.(O),O.baseUIHandlerPrevented))return;const _=O.target===O.currentTarget,C=O.currentTarget,j=uX(C),E=!s&&LAn(C),N=_&&(s?j:!E),I=O.key==="Enter",P=O.key===" ",$=C.getAttribute("role"),z=$?.startsWith("menuitem")||$==="option"||$==="gridcell";if(_&&c&&P){if(O.defaultPrevented&&z)return;O.preventDefault(),E||s&&j?(C.click(),O.preventBaseUIHandler()):N&&(m?.(O),O.preventBaseUIHandler());return}N&&(!s&&(P||I)&&O.preventDefault(),!s&&I&&m?.(O))},onKeyUp(O){if(!t){if(_F(O),v?.(O),O.target===O.currentTarget&&s&&c&&uX(O.currentTarget)&&O.key===" "){O.preventDefault();return}O.baseUIHandlerPrevented||O.target===O.currentTarget&&!s&&!c&&O.key===" "&&m?.(O)}},onPointerDown(O){if(t){O.preventDefault();return}w?.(O)}},s?{type:"button"}:{role:"button"},u,S)},[t,u,c,s]),p=mt(h=>{i.current=h,d()});return{getButtonProps:f,buttonRef:p}}function uX(e){return Ca(e)&&e.tagName==="BUTTON"}function LAn(e){return!!(e?.tagName==="A"&&e?.href)}const u3=y.forwardRef(function(t,n){const{render:r,className:s,style:a,disabled:i=!1,nativeButton:l=!0,...c}=t,{store:u}=md(),d=u.useState("open"),{getButtonProps:f,buttonRef:p}=gd({disabled:i,native:l}),h={disabled:i};function m(g){d&&u.setOpen(!1,Vt(Iye,g.nativeEvent))}return En("button",t,{state:h,ref:[n,p],props:[{onClick:m},c,f]})}),kxe=y.forwardRef(function(t,n){const{render:r,className:s,style:a,id:i,...l}=t,{store:c}=md(),u=Di(i);return c.useSyncedValueWithCleanup("descriptionElementId",u),En("p",t,{ref:n,props:[{id:u},l]})});let FAn=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),zAn=(function(e){return e[e.open=Ju.open]="open",e[e.closed=Ju.closed]="closed",e[e.startingStyle=Ju.startingStyle]="startingStyle",e[e.endingStyle=Ju.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const Yht=y.createContext(void 0);function Oxe(){const e=y.useContext(Yht);if(e===void 0)throw new Error(Sr(26));return e}const rj="ArrowUp",fk="ArrowDown",qP="ArrowLeft",sj="ArrowRight",d3="Home",f3="End",Xht="PageUp",Kht="PageDown",Jht=new Set([qP,sj]),BAn=new Set([qP,sj,d3,f3]),emt=new Set([rj,fk]),UAn=new Set([rj,fk,d3,f3]),tmt=new Set([...Jht,...emt]),k1=new Set([...tmt,d3,f3]),nmt="Shift",qAn="Control",VAn="Alt",HAn="Meta",WAn=new Set([nmt,qAn,VAn,HAn]);function ZAn(e){return Ca(e)&&e.tagName==="INPUT"}function x4e(e){return!!(ZAn(e)&&e.selectionStart!=null||Ca(e)&&e.tagName==="TEXTAREA")}function w4e(e,t,n,r){if(!e||!t||!t.scrollTo)return;let s=e.scrollLeft,a=e.scrollTop;const i=e.clientWidth<e.scrollWidth,l=e.clientHeight<e.scrollHeight;if(i&&r!=="vertical"){const c=S4e(e,t,"left"),u=SL(e),d=SL(t);n==="ltr"&&(c+t.offsetWidth+d.scrollMarginRight>e.scrollLeft+e.clientWidth-u.scrollPaddingRight?s=c+t.offsetWidth+d.scrollMarginRight-e.clientWidth+u.scrollPaddingRight:c-d.scrollMarginLeft<e.scrollLeft+u.scrollPaddingLeft&&(s=c-d.scrollMarginLeft-u.scrollPaddingLeft)),n==="rtl"&&(c-d.scrollMarginRight<e.scrollLeft+u.scrollPaddingLeft?s=c-d.scrollMarginLeft-u.scrollPaddingLeft:c+t.offsetWidth+d.scrollMarginRight>e.scrollLeft+e.clientWidth-u.scrollPaddingRight&&(s=c+t.offsetWidth+d.scrollMarginRight-e.clientWidth+u.scrollPaddingRight))}if(l&&r!=="horizontal"){const c=S4e(e,t,"top"),u=SL(e),d=SL(t);c-d.scrollMarginTop<e.scrollTop+u.scrollPaddingTop?a=c-d.scrollMarginTop-u.scrollPaddingTop:c+t.offsetHeight+d.scrollMarginBottom>e.scrollTop+e.clientHeight-u.scrollPaddingBottom&&(a=c+t.offsetHeight+d.scrollMarginBottom-e.clientHeight+u.scrollPaddingBottom)}e.scrollTo({left:s,top:a,behavior:"auto"})}function S4e(e,t,n){const r=n==="left"?"offsetLeft":"offsetTop";let s=0;for(;t.offsetParent&&(s+=t[r],t.offsetParent!==e);)t=t.offsetParent;return s}function SL(e){const t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}const GAn={...yf,...Hl,nestedDialogOpen(e){return e?{[zAn.nestedDialogOpen]:""}:null}},rmt=y.forwardRef(function(t,n){const{render:r,className:s,style:a,finalFocus:i,initialFocus:l,...c}=t,{store:u}=md(),d=u.useState("descriptionElementId"),f=u.useState("disablePointerDismissal"),p=u.useState("floatingRootContext"),h=u.useState("popupProps"),m=u.useState("modal"),g=u.useState("mounted"),v=u.useState("nested"),b=u.useState("nestedOpenDialogCount"),w=u.useState("open"),S=u.useState("openMethod"),O=u.useState("titleElementId"),_=u.useState("transitionStatus"),C=u.useState("role"),j=p.useState("floatingId"),E=c.id??j;Oxe(),Wl({open:w,ref:u.context.popupRef,onComplete(){w&&u.context.onOpenChangeComplete?.(!0)}});function N(q){return q==="touch"?u.context.popupRef.current:!0}const I=l===void 0?N:l,P=b>0,$=u.useStateSetter("popupElement"),D=En("div",t,{state:{open:w,nested:v,transitionStatus:_,nestedDialogOpen:P},props:[h,{id:E,"aria-labelledby":O??void 0,"aria-describedby":d??void 0,role:C,...uy,hidden:!g,onKeyDown(q){k1.has(q.key)&&q.stopPropagation()},style:{[FAn.nestedDialogs]:b}},c],ref:[n,u.context.popupRef,$],stateAttributesMapping:GAn});return o.jsx(eN,{context:p,openInteractionType:S,disabled:!g,closeOnFocusOut:!f,initialFocus:I,returnFocus:i,modal:m!==!1,restoreFocus:"popup",children:D})}),p3=y.forwardRef(function(t,n){const{cutout:r,...s}=t;let a;if(r){const i=r.getBoundingClientRect();a=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${i.left}px ${i.top}px,${i.left}px ${i.bottom}px,${i.right}px ${i.bottom}px,${i.right}px ${i.top}px,${i.left}px ${i.top}px)`}return o.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...s,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:a}})}),_xe=y.forwardRef(function(t,n){const{keepMounted:r=!1,...s}=t,{store:a}=md(),i=a.useState("mounted"),l=a.useState("modal"),c=a.useState("open");return i||r?o.jsx(Yht.Provider,{value:r,children:o.jsxs(WM,{ref:n,...s,children:[i&&l===!0&&o.jsx(p3,{ref:a.context.internalBackdropRef,inert:aN(!c)}),t.children]})}):null}),Cxe=y.forwardRef(function(t,n){const{render:r,className:s,style:a,id:i,...l}=t,{store:c}=md(),u=Di(i);return c.useSyncedValueWithCleanup("titleElementId",u),En("h2",t,{ref:n,props:[{id:u},l]})});function QAn(e){const t=y.useRef(""),n=y.useCallback(s=>{s.defaultPrevented||(t.current=s.pointerType,e(s,s.pointerType))},[e]);return{onClick:y.useCallback(s=>{if(s.detail===0){e(s,"keyboard");return}"pointerType"in s?e(s,s.pointerType):e(s,t.current),t.current=""},[e]),onPointerDown:n}}function Sv(e,t){const n=y.useRef(e),r=mt(t);Tt(()=>{n.current!==e&&r(n.current)},[e,r]),Tt(()=>{n.current=e},[e])}function Exe(e,t){const n=mt((a,i)=>{(typeof e=="function"?e():e)||t(i||(jye?"touch":""))}),{onClick:r,onPointerDown:s}=QAn(n);return y.useMemo(()=>({onClick:r,onPointerDown:s}),[r,s])}function jxe(e){const[t,n]=y.useState(null),r=Exe(e,n);return Sv(e,s=>{s&&!e&&n(null)}),y.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}const Txe=y.forwardRef(function(t,n){const{render:r,className:s,style:a,disabled:i=!1,nativeButton:l=!0,id:c,payload:u,handle:d,...f}=t,p=md(!0),h=d?.store??p?.store;if(!h)throw new Error(Sr(79));const m=Di(c),g=h.useState("floatingRootContext"),v=h.useState("isOpenedByTrigger",m),b=h.useState("triggerPopupId",m),w=y.useRef(null),{registerTrigger:S,isMountedByThisTrigger:O}=ZM(m,w,h,{payload:u}),{getButtonProps:_,buttonRef:C}=gd({disabled:i,native:l}),j=o_(g,{enabled:g!=null}),E=Exe(()=>h.select("open"),P=>{h.set("openMethod",P)}),N={disabled:i,open:v},I=h.useState("triggerProps",O);return En("button",t,{state:N,ref:[C,n,S,w],props:[j.reference,I,E,{[Lye]:"",id:m,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":b},f,_],stateAttributesMapping:nN})}),YAn=Txe;let k4e=(function(e){return e[e.open=Ju.open]="open",e[e.closed=Ju.closed]="closed",e[e.startingStyle=Ju.startingStyle]="startingStyle",e[e.endingStyle=Ju.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const XAn={...yf,...Hl,nested(e){return e?{[k4e.nested]:""}:null},nestedDialogOpen(e){return e?{[k4e.nestedDialogOpen]:""}:null}},KAn=y.forwardRef(function(t,n){const{render:r,className:s,style:a,children:i,...l}=t,c=Oxe(),{store:u}=md(),d=u.useState("open"),f=u.useState("nested"),p=u.useState("transitionStatus"),h=u.useState("nestedOpenDialogCount"),m=u.useState("mounted"),g=u.useStateSetter("viewportElement"),v=h>0;return En("div",t,{enabled:c||m,state:{open:d,nested:f,transitionStatus:p,nestedDialogOpen:v},ref:[n,g],stateAttributesMapping:XAn,props:[{role:"presentation",hidden:!m,style:{pointerEvents:d?void 0:"none"},children:i},l]})});function h3(e,t){return e&&y.isValidElement(t)?{render:t}:void 0}const JAn=$An;function jt({open:e,onOpenChange:t,children:n}){return o.jsx(JAn,{open:e,onOpenChange:t,children:n})}const smt=y.forwardRef(({asChild:e,children:t,...n},r)=>o.jsx(YAn,{ref:r,...h3(e,t),...n,children:e?void 0:t}));smt.displayName="AlertDialogTrigger";const amt=_xe,Nxe=y.forwardRef(({className:e,...t},n)=>o.jsx(Ght,{ref:n,className:K("dialog-overlay-anim fixed inset-0 z-50 bg-overlay backdrop-blur-xs",e),...t}));Nxe.displayName="AlertDialogOverlay";const imt=y.forwardRef(({className:e,...t},n)=>o.jsxs(amt,{children:[o.jsx(Nxe,{}),o.jsx(rmt,{ref:n,"data-slot":"alert-dialog-content",className:K("dialog-content-anim","fixed left-[50%] top-[50%] z-50 grid translate-x-[-50%] translate-y-[-50%]","w-full max-w-[calc(100%-2rem)] sm:max-w-lg","rounded-xl border border-border1/40 bg-surface2/96 backdrop-blur-md shadow-dialog",e),...t})]}));imt.displayName="AlertDialogContent";const omt=({className:e,...t})=>o.jsx("div",{className:K("flex flex-col gap-0.5 px-4 py-3 text-left",e),...t});omt.displayName="AlertDialogHeader";const lmt=({className:e,...t})=>o.jsx("div",{className:K("flex flex-col-reverse gap-1.5 px-4 py-2.5 sm:flex-row sm:justify-end",e),...t});lmt.displayName="AlertDialogFooter";const cmt=({className:e,...t})=>o.jsx("div",{className:K("overflow-y-auto px-4 py-3.5 max-h-[50vh]",e),...t});cmt.displayName="AlertDialogBody";const umt=y.forwardRef(({className:e,...t},n)=>o.jsx(Cxe,{ref:n,className:K("text-ui-md font-medium",e),...t}));umt.displayName="AlertDialogTitle";const dmt=y.forwardRef(({className:e,...t},n)=>o.jsx(kxe,{ref:n,className:K("text-ui-sm text-neutral3",e),...t}));dmt.displayName="AlertDialogDescription";const fmt=y.forwardRef(({className:e,...t},n)=>o.jsx(u3,{ref:n,className:K(t3({variant:"primary",size:"lg"}),e),...t}));fmt.displayName="AlertDialogAction";const pmt=y.forwardRef(({className:e,...t},n)=>o.jsx(u3,{ref:n,className:K(t3({variant:"default",size:"lg"}),e),...t}));pmt.displayName="AlertDialogCancel";jt.Trigger=smt;jt.Portal=amt;jt.Overlay=Nxe;jt.Content=imt;jt.Header=omt;jt.Footer=lmt;jt.Body=cmt;jt.Title=umt;jt.Description=dmt;jt.Action=fmt;jt.Cancel=pmt;function Jd({controlled:e,default:t,name:n,state:r="value"}){const{current:s}=y.useRef(e!==void 0),[a,i]=y.useState(t),l=s?e:a,c=y.useCallback(u=>{s||i(u)},[]);return[l,c]}function eRn(e){if(!e)return null;for(const t of e.elements){const n=t.tagName;if(n==="BUTTON"||n==="INPUT"){const r=t;if(r.type==="submit")return r}}return null}let O4e=(function(e){return e.checked="data-checked",e.unchecked="data-unchecked",e.indeterminate="data-indeterminate",e.disabled="data-disabled",e.readonly="data-readonly",e.required="data-required",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({}),_4e=(function(e){return e.disabled="data-disabled",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const tRn={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},SE={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},nRn={disabled:!1,...SE},O1={valid(e){return e===null?null:e?{[_4e.valid]:""}:{[_4e.invalid]:""}}};function hmt(e){return y.useMemo(()=>({checked(t){return e.indeterminate?{}:t?{[O4e.checked]:""}:{[O4e.unchecked]:""}},...O1}),[e.indeterminate])}const mmt={invalid:void 0,name:void 0,validityData:{state:tRn,errors:[],error:"",value:"",initialValue:null},setValidityData:ma,disabled:void 0,touched:SE.touched,setTouched:ma,dirty:SE.dirty,setDirty:ma,filled:SE.filled,setFilled:ma,focused:SE.focused,setFocused:ma,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:nRn,markedDirtyRef:{current:!1},registerFieldControl:ma,validation:{getValidationProps:(e=hs)=>e,getInputValidationProps:(e=hs)=>e,inputRef:{current:null},commit:async()=>{}}},gmt=y.createContext(mmt);function sm(e=!0){const t=y.useContext(gmt);if(t.setValidityData===ma&&!e)throw new Error(Sr(28));return t}function mN(e,t,n,r,s=!0){const{registerFieldControl:a}=sm(),i=y.useRef(null);i.current||(i.current=Symbol()),Tt(()=>{const l=i.current;return!l||!s?void 0:(a(l,{controlRef:e,getValue:r,id:t,value:n}),()=>{a(l,void 0)})},[e,s,r,t,a,n])}const rRn=y.createContext({disabled:!1});function vmt(){return y.useContext(rRn)}const sRn=y.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:ma,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function gN(){return y.useContext(sRn)}const aRn=y.createContext({controlId:void 0,registerControlId:ma,labelId:void 0,setLabelId:ma,messageIds:[],setMessageIds:ma,getDescriptionProps:e=>e});function Ox(){return y.useContext(aRn)}function Ixe(e,t,n,r=!0,s){const[a,i]=y.useState(),l=Di(s?`${s}-label`:void 0),c=e??t??a;return Tt(()=>{const u=e||t||!r?void 0:iRn(n.current,l);a!==u&&i(u)}),c}function iRn(e,t){const n=oRn(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function oRn(e){if(!e)return;const t=e.parentElement;if(t&&t.tagName==="LABEL")return t;const n=e.id;if(n){const s=e.nextElementSibling;if(s&&s.htmlFor===n)return s}const r=e.labels;return r&&r[0]}const lRn=y.createContext(void 0);function cRn(e=!0){const t=y.useContext(lRn);if(t===void 0&&!e)throw new Error(Sr(3));return t}const ymt=y.createContext(void 0);function uRn(){const e=y.useContext(ymt);if(e===void 0)throw new Error(Sr(14));return e}const dRn="data-parent",fRn=y.forwardRef(function(t,n){const{checked:r,className:s,defaultChecked:a=!1,"aria-labelledby":i,disabled:l=!1,form:c,id:u,indeterminate:d=!1,inputRef:f,name:p,onCheckedChange:h,parent:m=!1,readOnly:g=!1,render:v,required:b=!1,uncheckedValue:w,value:S,nativeButton:O=!1,style:_,...C}=t,{clearErrors:j}=gN(),{disabled:E,name:N,setDirty:I,setFilled:P,setFocused:$,setTouched:z,state:D,validationMode:q,validityData:W,shouldValidateOnChange:L,validation:F}=sm(),B=vmt(),{labelId:M,controlId:Q,registerControlId:V,getDescriptionProps:R}=Ox(),U=cRn(),Z=U?.parent,X=Z&&U.allValues,te=E||B.disabled||U?.disabled||l,ee=N??p,J=S??ee,ie=Di(),ue=Di();let Y=Q;X?Y=m?ue:`${Z.id}-${J}`:u&&(Y=u);let ne={};X&&(m?ne=U.parent.getParentProps():J&&(ne=U.parent.getChildProps(J)));const{checked:le=r,indeterminate:pe=d,onCheckedChange:se,...he}=ne,be=U?.value,Se=U?.setValue,Ne=U?.defaultValue,Oe=y.useRef(null),Ae=hc(()=>Symbol("checkbox-control")),Ue=y.useRef(!1),{getButtonProps:ce,buttonRef:ae}=gd({disabled:te,native:O}),re=U?.validation??F,[me,ye]=Jd({controlled:J&&be&&!m?be.includes(J):le,default:J&&Ne&&!m?Ne.includes(J):a,name:"Checkbox",state:"checked"});Tt(()=>{V!==ma&&(Ue.current=!0,V(Ae.current,Y))},[Y,V,Ae]),y.useEffect(()=>{const Fe=Ae.current;return()=>{!Ue.current||V===ma||(Ue.current=!1,V(Fe,void 0))}},[V,Ae]),mN(Oe,ie,me,void 0,!U);const je=y.useRef(null),Re=ku(f,je,re.inputRef),Qe=Ixe(i,M,je,!O,Y??void 0);Tt(()=>{je.current&&(je.current.indeterminate=pe,me&&P(!0))},[me,pe,P]),Sv(me,()=>{U&&!m||(j(ee),P(me),I(me!==W.initialValue),L()?re.commit(me):re.commit(me,!0))});const Ze=Eo({checked:me,disabled:te,form:c,name:m?void 0:ee,id:O?void 0:Y??void 0,required:b,ref:Re,style:ee?JT:qw,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(Fe){if(Fe.nativeEvent.defaultPrevented)return;if(g){Fe.preventDefault();return}const Ke=Fe.currentTarget.checked,Ye=Vt(Oo,Fe.nativeEvent);if(se?.(Ke,Ye),h?.(Ke,Ye),!Ye.isCanceled&&(ye(Ke),J&&be&&Se&&!m&&!X)){const Rt=Ke?[...be,J]:be.filter(Ct=>Ct!==J);Se(Rt,Ye)}},onFocus(){Oe.current?.focus()}},S!==void 0?{value:(U?me&&S:S)||""}:hs,R,U?re.getValidationProps:re.getInputValidationProps),ke=X?!!le:me,_e=X&&pe||d;y.useEffect(()=>{if(!Z||!J)return;const Fe=Z.disabledStatesRef.current;return Fe.set(J,te),()=>{Fe.delete(J)}},[Z,te,J]);const Ce=y.useMemo(()=>({...D,checked:ke,disabled:te,readOnly:g,required:b,indeterminate:_e}),[D,ke,te,g,b,_e]),Ee=hmt(Ce),$e=En("span",t,{state:Ce,ref:[ae,Oe,n,U?.registerControlRef],props:[{id:O?Y??void 0:ie,role:"checkbox","aria-checked":pe?"mixed":me,"aria-readonly":g||void 0,"aria-required":b||void 0,"aria-labelledby":Qe,[dRn]:m?"":void 0,onFocus(){$(!0)},onBlur(){const Fe=je.current;Fe&&(z(!0),$(!1),q==="onBlur"&&re.commit(U?be:Fe.checked))},onKeyDown(Fe){if(Fe.key!=="Enter"||(Fe.preventBaseUIHandler(),Fe.defaultPrevented))return;const Ke=je.current?.form??null,Ye=Fe.currentTarget,Rt=Fe.nativeEvent,Ct=Fe.preventDefault,en=Rt.preventDefault;let bt=!1;Fe.preventDefault=()=>{bt=!0,Ct.call(Fe)},Rt.preventDefault=()=>{bt=!0,en.call(Rt)},en.call(Rt),Ks(Ye).queueMicrotask(()=>{Fe.preventDefault=Ct,Rt.preventDefault=en,bt||eRn(Ke)?.click()})},onClick(Fe){if(g||te)return;Fe.preventDefault();const Ke=je.current;Ke&&Ke.dispatchEvent(new(Ks(Ke)).PointerEvent("click",{bubbles:!0,shiftKey:Fe.shiftKey,ctrlKey:Fe.ctrlKey,altKey:Fe.altKey,metaKey:Fe.metaKey}))}},R,re.getValidationProps,C,he,ce],stateAttributesMapping:Ee});return o.jsxs(ymt.Provider,{value:Ce,children:[$e,!me&&!U&&ee&&!m&&w!==void 0&&o.jsx("input",{type:"hidden",form:c,name:ee,value:w}),o.jsx("input",{...Ze,suppressHydrationWarning:!0})]})}),pRn=y.forwardRef(function(t,n){const{render:r,className:s,style:a,keepMounted:i=!1,...l}=t,c=uRn(),u=c.checked||c.indeterminate,{mounted:d,transitionStatus:f,setMounted:p}=wg(u),h=y.useRef(null),m={...c,transitionStatus:f};Wl({open:u,ref:h,onComplete(){u||p(!1)}});const v={...hmt(c),...Hl,...O1},b=i||d,w=En("span",t,{ref:[n,h],state:m,stateAttributesMapping:v,props:l});return b?w:null}),Yo=y.forwardRef(({className:e,checked:t,indeterminate:n,...r},s)=>{const a=t==="indeterminate";return o.jsx(fRn,{ref:s,checked:a?!1:t,indeterminate:n??a,"data-slot":"checkbox",className:K("peer flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[0.3125rem]","border border-neutral6/[0.06] bg-neutral6/[0.12] text-surface1 outline-hidden",ss.all,"hover:border-neutral6/[0.12] hover:bg-neutral6/[0.16]","active:scale-95 active:border-neutral6/[0.18] active:bg-neutral6/[0.18]","focus-visible:border-neutral5/50 focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-neutral5/55","data-[checked]:border-neutral6 data-[checked]:bg-neutral6 data-[checked]:text-surface1","data-[indeterminate]:border-neutral6 data-[indeterminate]:bg-neutral6 data-[indeterminate]:text-surface1","data-[checked]:hover:border-neutral5 data-[checked]:hover:bg-neutral5","data-[indeterminate]:hover:border-neutral5 data-[indeterminate]:hover:bg-neutral5","data-[checked]:active:border-neutral4 data-[checked]:active:bg-neutral4","data-[indeterminate]:active:border-neutral4 data-[indeterminate]:active:bg-neutral4","data-[disabled]:cursor-not-allowed data-[disabled]:border-neutral6/[0.38] data-[disabled]:bg-neutral6/[0.38] data-[disabled]:hover:border-neutral6/[0.38] data-[disabled]:hover:bg-neutral6/[0.38] data-[disabled]:active:scale-100","data-[disabled]:data-[checked]:border-neutral6/[0.38] data-[disabled]:data-[checked]:bg-neutral6/[0.38] data-[disabled]:data-[checked]:text-neutral6","data-[disabled]:data-[indeterminate]:border-neutral6/[0.38] data-[disabled]:data-[indeterminate]:bg-neutral6/[0.38] data-[disabled]:data-[indeterminate]:text-neutral6",e),...r,children:o.jsx(pRn,{keepMounted:!0,className:K("group/checkbox-indicator flex items-center justify-center text-current","opacity-0 scale-75 transition-[opacity,transform] duration-200 ease-out-custom","data-[checked]:opacity-100 data-[checked]:scale-100","data-[indeterminate]:opacity-100 data-[indeterminate]:scale-100","data-[starting-style]:opacity-0 data-[starting-style]:scale-75","data-[ending-style]:opacity-0 data-[ending-style]:scale-75"),children:o.jsx(hRn,{})})})});Yo.displayName="Checkbox";function hRn(){return o.jsxs(o.Fragment,{children:[o.jsx(kx,{className:K("size-3 scale-95 stroke-[3.25] transition-[stroke-dashoffset,transform] duration-200 ease-out-custom","[stroke-dasharray:28] [stroke-dashoffset:28]","group-data-[checked]/checkbox-indicator:[stroke-dashoffset:0]","group-data-[checked]/checkbox-indicator:scale-100","group-data-[indeterminate]/checkbox-indicator:hidden")}),o.jsx(YNn,{className:K("hidden size-3 scale-95 stroke-[3.25] transition-transform duration-200 ease-out-custom","group-data-[indeterminate]/checkbox-indicator:block","group-data-[indeterminate]/checkbox-indicator:scale-100")})]})}function mRn(e){const{open:t,defaultOpen:n,onOpenChange:r,disabled:s}=e,[a,i]=Jd({controlled:t,default:n,name:"Collapsible",state:"open"}),{mounted:l,setMounted:c,transitionStatus:u}=wg(a,!0,!0),d=Di(),[f,p]=y.useState(),h=f??d,m=mt(g=>{const v=!a,b=Vt(lg,g.nativeEvent);r(v,b),!b.isCanceled&&i(v)});return y.useMemo(()=>({disabled:s,handleTrigger:m,mounted:l,open:a,panelId:h,setMounted:c,setOpen:i,setPanelIdState:p,transitionStatus:u}),[s,m,l,a,h,c,i,p,u])}const bmt=y.createContext(void 0);function xmt(){const e=y.useContext(bmt);if(e===void 0)throw new Error(Sr(15));return e}let Axe=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=cg.startingStyle]="startingStyle",e[e.endingStyle=cg.endingStyle]="endingStyle",e})({}),gRn=(function(e){return e.panelOpen="data-panel-open",e})({});const vRn={[Axe.open]:""},yRn={[Axe.closed]:""},bRn={open(e){return e?{[gRn.panelOpen]:""}:null}},xRn={open(e){return e?vRn:yRn}},wmt={...xRn,...Hl},wRn=y.forwardRef(function(t,n){const{render:r,className:s,defaultOpen:a=!1,disabled:i=!1,onOpenChange:l,open:c,style:u,...d}=t,f=mt(l),p=mRn({open:c,defaultOpen:a,onOpenChange:f,disabled:i}),h=y.useMemo(()=>({open:p.open,disabled:p.disabled,transitionStatus:p.transitionStatus}),[p.open,p.disabled,p.transitionStatus]),m=y.useMemo(()=>({...p,onOpenChange:f,state:h}),[p,f,h]),g=En("div",t,{state:h,ref:n,props:d,stateAttributesMapping:wmt});return o.jsx(bmt.Provider,{value:m,children:g})}),SRn={...bRn,...Hl},kRn=y.forwardRef(function(t,n){const{panelId:r,open:s,handleTrigger:a,state:i,disabled:l}=xmt(),{className:c,disabled:u=l,id:d,render:f,nativeButton:p=!0,style:h,...m}=t,{getButtonProps:g,buttonRef:v}=gd({disabled:u,focusableWhenDisabled:!0,native:p});return En("button",t,{state:i,ref:[n,v],props:[{"aria-controls":s?r:void 0,"aria-expanded":s,onClick:a},m,g],stateAttributesMapping:SRn})}),pA={height:void 0,width:void 0};function ORn(e){const{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:s,mounted:a,onOpenChange:i,open:l,setMounted:c,setOpen:u,transitionStatus:d}=e,f=y.useRef(null),p=y.useRef(null),[h,m]=y.useState(pA),g=y.useRef(pA),v=y.useRef(!1),b=y.useRef(l),w=y.useRef(!1),[S,O]=y.useState(!1),_=y.useRef(null),C=ku(t,f),j=Yi({mounted:a,open:l}),E=NU(f,!1,!1),N=!l&&!a,I=S?"idle":d,P=l&&(b.current||w.current),$=!l&&a&&p.current==="css-animation"&&h.height===void 0&&h.width===void 0?g.current:h,z=n&&N&&p.current!=="css-animation",D=mt((B,M=!0)=>{M&&(g.current=B),m(B)}),q=mt(()=>{_.current?.(),_.current=null}),W=mt(B=>{q(),_.current=()=>{_.current=null,B()}}),L=mt(()=>{l&&a&&p.current==="css-animation"&&(w.current=!0)});Tt(()=>{!S||d==="starting"||O(!1)},[S,d]),y.useEffect(()=>()=>{L(),q()},[L,q]),Tt(()=>{const B=f.current;if(!B)return;!l&&_.current&&q();const M=_Rn(B,P);if(p.current=M,l&&d==="idle"&&b.current&&M==="css-animation"){g.current=xC(B);return}if(l&&d==="starting"){const R=v.current;if(v.current=!1,M==="none"){D(xC(B)),O(!0);return}if(M==="css-transition"){const U=CRn(B);if(D(xC(B)),!R)return U;const Z=hA(B,"transition-duration","0s");return W(Z),O(!0),U}if(M==="css-animation"){if(D(xC(B)),!R){hA(B,"animation-name","none")();return}const U=hA(B,"animation-name","none"),Z=hA(B,"animation-duration","0s");U(),W(Z),O(!0);return}}if(!l&&a&&(d==="idle"||d==="starting")){if(M==="none"){D(pA,!1),c(!1);return}M==="css-animation"&&(b.current=!1,w.current=!1),D(xC(B));return}if(d!=="ending")return;if(M==="none"){c(!1);return}const Q=xC(B);if(!((Q.height??0)>0||(Q.width??0)>0)){c(!1);return}D(Q),M==="css-animation"&&hA(B,"animation-name","none")()},[a,l,q,D,c,W,P,d]),Wl({enabled:l&&a&&I==="idle",open:!0,ref:f,onComplete(){l&&D(pA,!1)}}),y.useEffect(()=>{if(l||!a||I!=="ending"||!f.current)return;const M=new AbortController;let Q=-1;function V(){j.current.open||(c(!1),D(pA,!1))}return Q=$d.request(()=>{M.signal.aborted||E(V,M.signal)}),()=>{$d.cancel(Q),M.abort()}},[j,a,l,I,E,D,c]),Tt(()=>{const B=f.current;!B||!n||!N||B.setAttribute("hidden","until-found")},[N,n]),y.useEffect(function(){const M=f.current;if(!M)return;function Q(V){v.current=!0,u(!0),i(!0,Vt(Oo,V))}return Br(M,"beforematch",Q)},[i,u]);const F=s||n||a||l;return{height:$.height,props:{...z?{[Axe.startingStyle]:""}:void 0,hidden:N,id:r},ref:C,shouldPreventOpenAnimation:P,shouldRender:F,transitionStatus:I,width:$.width}}function xC(e){return{height:e.scrollHeight,width:e.scrollWidth}}function _Rn(e,t=!1){const n=Ks(e).getComputedStyle(e),r=(n.animationName.split(",").map(a=>a.trim()).some(a=>a!==""&&a!=="none")||t)&&C4e(n.animationDuration),s=C4e(n.transitionDuration);return r&&s||s?"css-transition":r?"css-animation":"none"}function C4e(e){return e.split(",").map(t=>t.trim()).some(t=>t!==""&&Number.parseFloat(t)>0)}function hA(e,t,n){const r=e.style.getPropertyValue(t),s=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===""){e.style.removeProperty(t);return}e.style.setProperty(t,r,s)}}function CRn(e){const t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(s=>{e.style.setProperty(s,"initial","important")});function n(){Object.entries(t).forEach(([s,a])=>{if(a===""){e.style.removeProperty(s);return}e.style.setProperty(s,a)})}const r=$d.request(n);return()=>{$d.cancel(r),n()}}let E4e=(function(e){return e.collapsiblePanelHeight="--collapsible-panel-height",e.collapsiblePanelWidth="--collapsible-panel-width",e})({});const ERn=y.forwardRef(function(t,n){const{className:r,hiddenUntilFound:s,keepMounted:a,render:i,id:l,style:c,...u}=t,{mounted:d,onOpenChange:f,open:p,panelId:h,setMounted:m,setPanelIdState:g,setOpen:v,state:b,transitionStatus:w}=xmt(),S=s??!1,O=a??!1;Tt(()=>{if(l)return g(l),()=>{g(void 0)}},[l,g]);const{height:_,props:C,ref:j,shouldPreventOpenAnimation:E,shouldRender:N,transitionStatus:I,width:P}=ORn({externalRef:n,hiddenUntilFound:S,id:h,keepMounted:O,mounted:d,onOpenChange:f,open:p,setMounted:m,setOpen:v,transitionStatus:w}),$={...b,transitionStatus:I},z=Oct(c,$),D=En("div",{...t,style:void 0},{state:$,ref:j,props:[C,{style:{[E4e.collapsiblePanelHeight]:_===void 0?"auto":`${_}px`,[E4e.collapsiblePanelWidth]:P===void 0?"auto":`${P}px`}},u,z?{style:z}:void 0,E?{style:{animationName:"none"}}:void 0],stateAttributesMapping:wmt});return N?D:null}),Ip=wRn,cf=De.forwardRef(({className:e,asChild:t,children:n,...r},s)=>{const a=t&&De.isValidElement(n)?{render:n}:{};return o.jsx(kRn,{ref:s,"data-slot":"collapsible-trigger",className:K("-outline-offset-2",ss.colors,zM.visible,"hover:text-neutral5","[&>svg]:transition-transform [&>svg]:duration-normal [&>svg]:ease-out-custom","[&[data-panel-open]>svg]:rotate-90",e),...a,...r,children:t?void 0:n})});cf.displayName="CollapsibleTrigger";const uf=De.forwardRef(({className:e,children:t,...n},r)=>o.jsx(ERn,{ref:r,"data-slot":"collapsible-content",className:K("overflow-hidden","h-[var(--collapsible-panel-height)] transition-[height] duration-normal ease-out-custom","data-[starting-style]:h-0 data-[ending-style]:h-0"),...n,children:o.jsx("div",{className:e,children:t})}));uf.displayName="CollapsibleContent";const Smt=y.createContext(void 0),kmt=y.createContext(void 0),Omt=y.createContext(void 0),_mt=y.createContext("");function my(){const e=y.useContext(Smt);if(!e)throw new Error(Sr(22));return e}function aq(){const e=y.useContext(kmt);if(!e)throw new Error(Sr(23));return e}function _1(){const e=y.useContext(Omt);if(!e)throw new Error(Sr(24));return e}function Cmt(){return y.useContext(_mt)}const Emt=(e,t)=>Object.is(e,t);function Gv(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function jmt(e,t,n){return!e||e.length===0?!1:e.some(r=>r===void 0?!1:Gv(t,r,n))}function bw(e,t,n){return!e||e.length===0?-1:e.findIndex(r=>r===void 0?!1:Gv(r,t,n))}function Tmt(e,t,n){return e.filter(r=>!Gv(t,r,n))}function uz(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Rxe(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function Nmt(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(Rxe(t)){for(const n of t)for(const r of n.items)if(r&&r.value==null&&r.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function cu(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return uz(e)}function Um(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?uz(e.value):uz(e)}function Pxe(e,t,n){function r(){return cu(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return t[e]??r();if(Array.isArray(t)){const s=t,a=Rxe(s)?s.flatMap(i=>i.items):s;if(e==null||typeof e!="object"){const i=a.find(l=>l.value===e);return i&&i.label!=null?i.label:r()}if("value"in e){const i=a.find(l=>l&&l.value===e.value);if(i&&i.label!=null)return i.label}}return r()}function Imt(e,t,n){return e.reduce((r,s,a)=>(a>0&&r.push(", "),r.push(o.jsx(y.Fragment,{children:Pxe(s,t,n)},a)),r),[])}const on={id:lt(e=>e.id),labelId:lt(e=>e.labelId),items:lt(e=>e.items),selectedValue:lt(e=>e.selectedValue),hasSelectionChips:lt(e=>{const t=e.selectedValue;return Array.isArray(t)&&t.length>0}),hasSelectedValue:lt(e=>{const{selectedValue:t,selectionMode:n}=e;return t==null?!1:n==="multiple"&&Array.isArray(t)?t.length>0:!0}),hasNullItemLabel:lt((e,t)=>t?Nmt(e.items):!1),open:lt(e=>e.open),mounted:lt(e=>e.mounted),forceMounted:lt(e=>e.forceMounted),inline:lt(e=>e.inline),activeIndex:lt(e=>e.activeIndex),selectedIndex:lt(e=>e.selectedIndex),isActive:lt((e,t)=>e.activeIndex===t),isSelected:lt((e,t)=>{const n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(s=>Gv(t,s,n)):Gv(t,r,n)}),transitionStatus:lt(e=>e.transitionStatus),popupProps:lt(e=>e.popupProps),inputProps:lt(e=>e.inputProps),triggerProps:lt(e=>e.triggerProps),itemProps:lt(e=>e.itemProps),positionerElement:lt(e=>e.positionerElement),listElement:lt(e=>e.listElement),triggerElement:lt(e=>e.triggerElement),inputElement:lt(e=>e.inputElement),inputGroupElement:lt(e=>e.inputGroupElement),popupSide:lt(e=>e.popupSide),openMethod:lt(e=>e.openMethod),inputInsidePopup:lt(e=>e.inputInsidePopup),inputOwnsFormValue:lt(e=>e.inputOwnsFormValue),selectionMode:lt(e=>e.selectionMode),name:lt(e=>e.name),form:lt(e=>e.form),disabled:lt(e=>e.disabled),readOnly:lt(e=>e.readOnly),required:lt(e=>e.required),grid:lt(e=>e.grid),virtualized:lt(e=>e.virtualized),itemToStringLabel:lt(e=>e.itemToStringLabel),isItemEqualToValue:lt(e=>e.isItemEqualToValue),modal:lt(e=>e.modal),autoHighlight:lt(e=>e.autoHighlight),submitOnItemClick:lt(e=>e.submitOnItemClick)};function h_(e={}){const{id:t,implicit:n=!1,controlRef:r}=e,{controlId:s,registerControlId:a}=Ox(),i=Di(t),l=n?s:void 0,c=hc(()=>Symbol("labelable-control")),u=y.useRef(!1),d=y.useRef(t!=null),f=mt(()=>{!u.current||a===ma||(u.current=!1,a(c.current,void 0))});return Tt(()=>{if(a===ma)return;let p;if(n){const h=r?.current;_r(h)&&h.closest("label")!=null?p=t??null:p=l??i}else if(t!=null)d.current=!0,p=t;else if(d.current)p=i;else{f();return}if(p===void 0){f();return}u.current=!0,a(c.current,p)},[t,r,l,a,n,i,c,f]),y.useEffect(()=>f,[f]),s??i}function jRn(e,t){return(n,r)=>{if(n==null)return!1;const s=cu(n,t);return e.contains(s,r)}}function TRn(e,t,n){return(r,s)=>{if(r==null)return!1;if(!s)return!0;const a=cu(r,t),i=n!=null?cu(n,t):"";return i&&e.contains(i,s)&&i.length===s.length?!0:e.contains(a,s)}}const j4e=new Map;function NRn(e={}){const t={usage:"search",sensitivity:"base",ignorePunctuation:!0,...e},n=`${Amt(e.locale)}|${JSON.stringify(t)}`,r=j4e.get(n);if(r)return r;const s=new Intl.Collator(e.locale,t),a={contains(i,l,c){if(!l)return!0;const u=cu(i,c);for(let d=0;d<=u.length-l.length;d+=1)if(s.compare(u.slice(d,d+l.length),l)===0)return!0;return!1},startsWith(i,l,c){if(!l)return!0;const u=cu(i,c);return s.compare(u.slice(0,l.length),l)===0},endsWith(i,l,c){if(!l)return!0;const u=cu(i,c),d=l.length;return u.length>=d&&s.compare(u.slice(u.length-d),l)===0}};return j4e.set(n,a),a}function Amt(e){return Array.isArray(e)?e.map(t=>Amt(t)).join(","):e==null?"":String(e)}const IRn=NRn,Rmt=Symbol("none"),gS={value:Rmt,index:-1};function ARn(e){const{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:s,onSelectedValueChange:a,defaultInputValue:i,inputValue:l,open:c,defaultOpen:u=!1,selectionMode:d="none",onItemHighlighted:f,name:p,form:h,disabled:m=!1,readOnly:g=!1,required:v=!1,inputRef:b,grid:w=!1,items:S,filteredItems:O,filter:_,openOnInputClick:C=!0,autoHighlight:j=!1,keepHighlight:E=!1,highlightItemOnHover:N=!0,loopFocus:I=!0,itemToStringLabel:P,itemToStringValue:$,isItemEqualToValue:z=Emt,virtualized:D=!1,inline:q=!1,fillInputOnItemPress:W=!0,modal:L=!1,limit:F=-1,autoComplete:B="list",formAutoComplete:M,locale:Q,submitOnItemClick:V=!1}=e,{clearErrors:R}=gN(),{setDirty:U,validityData:Z,shouldValidateOnChange:X,setFilled:te,name:ee,disabled:J,setTouched:ie,setFocused:ue,validationMode:Y,validation:ne}=sm(),le=dy(),pe=h_({id:t}),se=IRn({locale:Q}),[he,be]=y.useState(!1),[Se,Ne]=y.useState(null),Oe=y.useRef([]),Ae=y.useRef([]),Ue=y.useRef(null),ce=y.useRef(null),ae=y.useRef(null),re=y.useRef(null),me=y.useRef(null),ye=y.useRef(!0),je=y.useRef(!1),Re=y.useRef(null),Qe=y.useRef(null),Ze=y.useRef(null),ke=y.useRef(gS),_e=y.useRef(null),Ce=y.useRef([]),Ee=y.useRef([]),$e=J||m,Fe=ee??p,Ke=d==="multiple",Ye=d==="single",Rt=l!==void 0||i!==void 0,Ct=S!==void 0,en=O!==void 0;let bt;j==="always"?bt="always":bt=j?"input-change":!1;const[It,sn]=Jd({controlled:s,default:Ke?r??bh:r,name:"Combobox",state:"selectedValue"}),Ge=y.useMemo(()=>_===null?()=>!0:_!==void 0?_:Ye&&!he?TRn(se,P,It):jRn(se,P),[_,Ye,It,he,se,P]),at=hc(()=>Rt?i??"":Ye?cu(It,P):"").current,[ct,an]=Jd({controlled:l,default:at,name:"Combobox",state:"inputValue"}),[Kt,_n]=Jd({controlled:c,default:u,name:"Combobox",state:"open"}),Te=Rxe(S),Le=Se??(ct===""?"":String(ct).trim()),Me=Ye?cu(It,P):"",Xe=Ye&&!he&&Le!==""&&Me!==""&&Me.length===Le.length&&se.contains(Me,Le),nt=Xe?"":Le,Dt=Ct&&en&&Xe,kt=y.useMemo(()=>S?Te?S.flatMap(un=>un.items):S:bh,[S,Te]),Ft=y.useMemo(()=>{if(O&&!Dt)return O;if(!S)return bh;if(Te){const Gn=S,ks=[];let Oa=0;for(const no of Gn){if(F>-1&&Oa>=F)break;const za=nt===""?no.items:no.items.filter(If=>Ge(If,nt,P));if(za.length===0)continue;const vm=F>-1?F-Oa:1/0,wd=za.slice(0,vm);if(wd.length>0){const If={...no,items:wd};ks.push(If),Oa+=wd.length}}return ks}if(nt==="")return F>-1?kt.slice(0,F):kt;const un=[];for(const Gn of kt){if(F>-1&&un.length>=F)break;Ge(Gn,nt,P)&&un.push(Gn)}return un},[O,Dt,S,Te,nt,F,Ge,P,kt]),At=y.useMemo(()=>Te?Ft.flatMap(Gn=>Gn.items):Ft,[Ft,Te]),Et=hc(()=>new Wye({id:pe,labelId:void 0,selectedValue:It,open:Kt,filter:Ge,query:Le,items:S,selectionMode:d,listRef:Oe,labelsRef:Ae,popupRef:Ue,emptyRef:me,inputRef:ce,startDismissRef:ae,endDismissRef:re,keyboardActiveRef:ye,chipsContainerRef:Re,clearRef:Qe,valuesRef:Ce,allValuesRef:Ee,selectionEventRef:Ze,name:Fe,form:h,disabled:$e,readOnly:g,required:v,grid:w,isGrouped:Te,virtualized:D,openOnInputClick:C,itemToStringLabel:P,isItemEqualToValue:z,modal:L,autoHighlight:bt,submitOnItemClick:V,hasInputValue:Rt,mounted:!1,forceMounted:!1,transitionStatus:"idle",inline:q,activeIndex:null,selectedIndex:null,popupProps:{},inputProps:{},triggerProps:{},itemProps:hs,positionerElement:null,listElement:null,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:d==="none",onOpenChangeComplete:n||ma,setOpen:ma,setInputValue:ma,setSelectedValue:ma,setIndices:ma,onItemHighlighted:ma,handleSelection:ma,forceMount:ma,requestSubmit:ma})).current,bn=d==="none"?ct:It,nr=y.useMemo(()=>d==="none"?bn:Array.isArray(It)?It.map(un=>Um(un,$)):Um(It,$),[bn,$,d,It]),Wn=mt(f),Er=mt(n),pr=ht(Et,on.activeIndex),ys=ht(Et,on.selectedIndex),Mr=ht(Et,on.positionerElement),ur=ht(Et,on.listElement),Hs=ht(Et,on.triggerElement),da=ht(Et,on.inputElement),Sa=ht(Et,on.inputGroupElement),Ia=ht(Et,on.inline),$o=ht(Et,on.inputInsidePopup),fl=ht(Et,on.inputOwnsFormValue),el=Yi(Hs),{mounted:pm,setMounted:Ru,transitionStatus:Nf}=wg(Kt),{openMethod:hm,triggerProps:Pu}=jxe(Kt),Vr=mt(()=>nr);mN($o?el:ce,pe,bn,Vr);const ka=mt(()=>{S?Ae.current=At.map(un=>cu(un,P)):Et.set("forceMounted",!0)}),hi=y.useRef(It);Tt(()=>{It!==hi.current&&ka()},[ka,It]);const Ni=mt(un=>{Et.update(un);const Gn=un.type||"none";if(un.activeIndex!==void 0)if(un.activeIndex===null)ke.current!==gS&&(ke.current=gS,Wn(void 0,YS(Gn,void 0,{index:-1})));else{const ks=Ce.current[un.activeIndex];ke.current={value:ks,index:un.activeIndex},Wn(ks,YS(Gn,void 0,{index:un.activeIndex}))}}),Tl=mt((un,Gn)=>{if(je.current=Gn.reason===pb,e.onInputValueChange?.(un,Gn),!Gn.isCanceled){if(Gn.reason===lk){const ks=Gn.event,Oa=ks.inputType;if(ks.type==="compositionend"||Oa!=null&&Oa!==""&&Oa!=="insertReplacementText"){const za=un.trim()!=="";za&&be(!0),_e.current={hasQuery:za},za&&bt&&Et.state.activeIndex==null&&Et.set("activeIndex",0)}}an(un)}}),$u=mt((un,Gn)=>{if(Kt!==un&&(Gn.reason==="escape-key"&&Ct&&At.length===0&&!Et.state.emptyRef.current&&Gn.allowPropagation(),e.onOpenChange?.(un,Gn),!Gn.isCanceled&&(un&&Ke&&$o&&!Ia&&Se!==null&&(be(!1),Ne(null),ct!==""&&Tl("",Vt(pb,Gn.event))),!un&&he&&(Ye?(Ia||Ne(Le),Le===""&&be(!1)):Ke&&(Ia||Ne(Le),$o&&Ni({activeIndex:null}),(!$o||Ia)&&Tl("",Vt(pb,Gn.event)))),_n(un),!un&&$o&&(Gn.reason===Xb||Gn.reason===qM)&&(ie(!0),ue(!1),Y==="onBlur")))){const ks=d==="none"?ct:It;ne.commit(ks)}}),Ws=mt((un,Gn)=>{if(a?.(un,Gn),Gn.isCanceled)return;sn(un),(d==="none"&&Ue.current&&W||Ye&&!Et.state.inputInsidePopup)&&Tl(cu(un,P),Vt(Gn.reason,Gn.event)),Ye&&un!=null&&Gn.reason!==lk&&he&&!Ia&&Ne(Le)}),eu=mt((un,Gn)=>{let ks=Gn;if(ks===void 0){if(pr===null)return;ks=Ce.current[pr]}const Oa=Si(un),no=Ze.current??un;Ze.current=null;const za=Vt(vw,no),vm=Oa?.closest("a")?.getAttribute("href");if(vm){vm.startsWith("#")&&$u(!1,za);return}if(Ke){const wd=Array.isArray(It)?It:[],JN=jmt(wd,ks,Et.state.isItemEqualToValue)?Tmt(wd,ks,Et.state.isItemEqualToValue):[...wd,ks];if(Ws(JN,za),!(ce.current?ce.current.value.trim()!=="":!1))return;Et.state.inputInsidePopup?Tl("",Vt(pb,za.event)):$u(!1,za)}else Ws(ks,za),$u(!1,za)}),Ag=mt(()=>{if(!Et.state.submitOnItemClick)return;const un=ne.inputRef.current?.form??Et.state.inputElement?.form;un&&typeof un.requestSubmit=="function"&&un.requestSubmit()}),Mo=mt(()=>{if(Ru(!1),Er?.(!1),be(!1),Ne(null),Ni(d==="none"?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),Ke&&ce.current&&ce.current.value!==""&&!je.current&&Tl("",Vt(pb)),Ye)if(Et.state.inputInsidePopup)ce.current&&ce.current.value!==""&&Tl("",Vt(pb));else{const un=cu(It,P);ce.current&&ce.current.value!==un&&Tl(un,Vt(un===""?pb:Oo))}}),L1=y.useMemo(()=>Ia&&Mr?{current:Mr.closest('[role="dialog"]')}:Ue,[Ia,Mr]);Wl({enabled:!e.actionsRef,open:Kt,ref:L1,onComplete(){Kt||Mo()}}),y.useImperativeHandle(e.actionsRef,()=>({unmount:Mo}),[Mo]),Tt(function(){if(Kt||d==="none")return;const Gn=S?kt:Ee.current;if(Ke){const ks=Array.isArray(It)?It:[],Oa=ks[ks.length-1],no=bw(Gn,Oa,z);Ni({selectedIndex:no===-1?null:no})}else{const ks=bw(Gn,It,z);Ni({selectedIndex:ks===-1?null:ks})}},[Kt,It,S,d,kt,Ke,z,Ni]),Tt(()=>{S&&(Ce.current=At,Oe.current.length=At.length)},[S,At]),Tt(()=>{const un=_e.current;if(un&&(un.hasQuery?bt&&Et.set("activeIndex",0):bt==="always"&&Et.set("activeIndex",0),_e.current=null),!Kt&&!Ia)return;const ks=Ct||en?At:Ce.current,Oa=Et.state.activeIndex;if(Oa==null){if(bt==="always"&&ks.length>0){Et.set("activeIndex",0);return}ke.current!==gS&&(ke.current=gS,Et.state.onItemHighlighted(void 0,YS(Oo,void 0,{index:-1})));return}if(Oa>=ks.length){ke.current!==gS&&(ke.current=gS,Et.state.onItemHighlighted(void 0,YS(Oo,void 0,{index:-1}))),Et.set("activeIndex",null);return}const no=ks[Oa],za=ke.current.value,vm=za!==Rmt&&Gv(no,za,Et.state.isItemEqualToValue);(ke.current.index!==Oa||!vm)&&(ke.current={value:no,index:Oa},Et.state.onItemHighlighted(no,YS(Oo,void 0,{index:Oa})))},[pr,bt,en,Ct,At,Ia,Kt,Et]),Tt(()=>{if(d==="none"){te(String(ct)!=="");return}te(Ke?Array.isArray(It)&&It.length>0:It!=null)},[te,d,ct,It,Ke]),y.useEffect(()=>{Ct&&bt&&At.length===0&&Ni({activeIndex:null})},[Ct,bt,At.length,Ni]),Sv(Le,()=>{!Kt||Le===""||Le===String(at)||be(!0)}),Sv(It,()=>{if(d!=="none"&&(R(Fe),U(It!==Z.initialValue),X()?ne.commit(It):ne.commit(It,!0),Ye&&!Rt&&!$o)){const un=cu(It,P);ct!==un&&Tl(un,Vt(Oo))}}),Sv(ct,()=>{d==="none"&&(R(Fe),U(ct!==Z.initialValue),X()?ne.commit(ct):ne.commit(ct,!0))}),Sv(S,()=>{if(!Ye||Rt||$o||he)return;const un=cu(It,P);ct!==un&&Tl(un,Vt(Oo))});const jy=Gye({open:Ia?!0:Kt,onOpenChange:$u,elements:{reference:$o?Hs:da,floating:Mr}});let Rg,Pg;Ia||(Rg=w?"grid":"listbox",Pg=Kt?"true":"false");const F1=y.useMemo(()=>{const un=da?.tagName==="INPUT",Gn=da==null||un,ks=Gn||Kt,Oa=Gn?{autoComplete:"off",spellCheck:"false",autoCorrect:"off",autoCapitalize:"none"}:{};return ks&&(Oa.role="combobox",Oa["aria-expanded"]=Pg,Oa["aria-haspopup"]=Rg,Oa["aria-controls"]=Kt?ur?.id:void 0,Oa["aria-autocomplete"]=B),{reference:Oa,floating:{role:"presentation"}}},[da,Kt,Pg,Rg,ur?.id,B]),XN=o_(jy,{enabled:!g&&!$e&&C,event:"mousedown-only",toggle:!1,touchOpenDelay:$o?0:100,reason:Qvn}),mm=l_(jy,{enabled:!g&&!$e&&!Ia,outsidePressEvent:{mouse:"sloppy",touch:"intentional"},bubbles:Ia?!0:void 0,outsidePress(un){const Gn=Si(un);return!dn(Hs,Gn)&&!dn(Qe.current,Gn)&&!dn(Re.current,Gn)&&!dn(Sa,Gn)}}),Gx=Kye(jy,{enabled:!g&&!$e,id:pe,listRef:Oe,activeIndex:pr,selectedIndex:ys,virtual:!0,loopFocus:I,allowEscape:I&&!bt,focusItemOnOpen:he||d==="none"&&!bt?!1:"auto",focusItemOnHover:N,resetOnPointerLeave:!E,cols:w?2:1,orientation:w?"horizontal":void 0,rtl:le==="rtl",disabledIndices:bh,onNavigate(un,Gn){!Gn&&!Kt||Nf==="ending"||Ni(Gn?{activeIndex:un,type:ye.current?"keyboard":"pointer"}:{activeIndex:un})}}),M_=y.useMemo(()=>Eo(Gx.reference,mm.reference,XN.reference,F1.reference),[Gx.reference,mm.reference,XN.reference,F1.reference]),D_=y.useMemo(()=>Eo(uy,Gx.floating,mm.floating,F1.floating),[Gx.floating,mm.floating,F1.floating]),z1=y.useMemo(()=>{const un=Gx.item;return un?{...un,onFocus:void 0}:hs},[Gx.item]);s_(()=>{Et.update({inline:q,popupProps:D_,inputProps:M_,triggerProps:Pu,itemProps:z1,setOpen:$u,setInputValue:Tl,setSelectedValue:Ws,setIndices:Ni,onItemHighlighted:Wn,handleSelection:eu,forceMount:ka,requestSubmit:Ag})}),Tt(()=>{Et.update({id:pe,selectedValue:It,open:Kt,mounted:pm,transitionStatus:Nf,items:S,inline:q,popupProps:D_,inputProps:M_,triggerProps:Pu,openMethod:hm,itemProps:z1,selectionMode:d,name:Fe,form:h,disabled:$e,readOnly:g,required:v,grid:w,isGrouped:Te,virtualized:D,onOpenChangeComplete:Er,openOnInputClick:C,itemToStringLabel:P,modal:L,autoHighlight:bt,isItemEqualToValue:z,submitOnItemClick:V,hasInputValue:Rt,requestSubmit:Ag,inputOwnsFormValue:d==="none"&&(q||!Et.state.inputInsidePopup)})},[Et,pe,It,Kt,pm,Nf,S,D_,M_,z1,hm,Pu,d,Fe,$e,g,v,ne,w,Te,D,Er,C,P,L,z,V,Rt,q,Ag,bt,h]);const GW=ku(b,ne.inputRef),QW=y.useMemo(()=>({query:Le,hasItems:Ct,filteredItems:Ft,flatFilteredItems:At}),[Le,Ct,Ft,At]),L_=y.useMemo(()=>Array.isArray(bn)?"":Um(bn,$),[bn,$]),gm=Ke&&Array.isArray(It)&&It.length>0,B1=Ke||d==="none"&&fl?void 0:Fe,KN=y.useMemo(()=>!Ke||!Array.isArray(It)||!Fe?null:It.map(un=>{const Gn=Um(un,$);return o.jsx("input",{type:"hidden",form:h,name:Fe,value:Gn},Gn)}),[Ke,It,h,Fe,$]),Qx=o.jsxs(y.Fragment,{children:[e.children,o.jsx("input",{...ne.getInputValidationProps({onFocus(){if($o){Hs?.focus();return}(ce.current||Hs)?.focus()},onChange(un){if(un.nativeEvent.defaultPrevented||$e||g){un.preventBaseUIHandler?.();return}const Gn=un.currentTarget.value,ks=Vt(Oo,un.nativeEvent);function Oa(){if(Ke)return;if(d==="none"){U(Gn!==Z.initialValue),Tl(Gn,ks),X()&&ne.commit(Gn);return}const no=Ce.current.find(za=>Um(za,$).toLowerCase()===Gn.toLowerCase()||cu(za,P).toLowerCase()===Gn.toLowerCase());no!=null&&(U(no!==Z.initialValue),Ws?.(no,ks),X()&&ne.commit(no))}S?Oa():(ka(),queueMicrotask(Oa))}}),id:pe&&B1==null?`${pe}-hidden-input`:void 0,form:h,name:B1,autoComplete:M,disabled:$e,required:v&&!gm,readOnly:g,value:L_,ref:GW,style:B1?JT:qw,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),KN]});return o.jsx(Smt.Provider,{value:Et,children:o.jsx(kmt.Provider,{value:jy,children:o.jsx(Omt.Provider,{value:QW,children:o.jsx(_mt.Provider,{value:ct,children:Qx})})})})}function Pmt(e){const{multiple:t=!1,defaultValue:n,value:r,onValueChange:s,autoComplete:a,...i}=e;return o.jsx(ARn,{...i,selectionMode:t?"multiple":"single",selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:s,formAutoComplete:a})}function RRn(e){return e==null?void 0:`${e}-label`}function iq(e,t){return e??t}function PRn(e){const{children:t,placeholder:n}=e,r=my(),s=ht(r,on.itemToStringLabel),a=ht(r,on.selectedValue),i=ht(r,on.items),l=ht(r,on.selectionMode)==="multiple",c=ht(r,on.hasSelectedValue),u=!c&&n!=null&&t==null,d=ht(r,on.hasNullItemLabel,u);let f=null;return typeof t=="function"?f=t(a):t!=null?f=t:!c&&n!=null&&!d?f=n:l&&Array.isArray(a)?f=Imt(a,i,s):f=Pxe(a,i,s),o.jsx(y.Fragment,{children:f})}const $mt={...yP,...O1,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":""}:null},$Rn=y.createContext(void 0);function MRn(){return y.useContext($Rn)}const Mmt=y.createContext(void 0);function $xe(e){const t=y.useContext(Mmt);if(t===void 0&&!e)throw new Error(Sr(21));return t}const Dmt=y.forwardRef(function(t,n){const r=my(),{buttonRef:s,getButtonProps:a}=gd({native:!1}),i=ku(n,s);function l(u){r.state.setOpen(!1,Vt(Iye,u.nativeEvent,u.currentTarget))}const c=a({onClick:l});return o.jsx("span",{ref:i,...c,"aria-label":"Dismiss",tabIndex:void 0,style:JT})}),Lmt=y.forwardRef(function(t,n){const{render:r,className:s,disabled:a=!1,id:i,style:l,...c}=t,{state:u,disabled:d,setTouched:f,setFocused:p,validationMode:h,validation:m}=sm(),{labelId:g}=Ox(),v=MRn(),w=!!$xe(!0),S=my(),{filteredItems:O}=_1(),_=Cmt(),C=dy(),j=ht(S,on.required),E=ht(S,on.disabled),N=ht(S,on.readOnly),I=ht(S,on.name),P=ht(S,on.form),$=ht(S,on.selectionMode),z=ht(S,on.autoHighlight),D=ht(S,on.inputProps),q=ht(S,on.triggerProps),W=ht(S,on.open),L=ht(S,on.mounted),F=ht(S,on.selectedValue),B=ht(S,on.popupSide),M=ht(S,on.positionerElement),Q=ht(S,on.id),V=ht(S,on.inline),R=ht(S,on.modal),U=!!z,Z=L&&M?B:null,X=d||E||a,te=O.length===0,ee=w||V,J=!ee||R,ie=Di(i??(ee?void 0:Q)),ue=iq(g,void 0),Y=w?SE:u,[ne,le]=y.useState(null),pe=y.useRef(!1),se=y.useRef(null),he=y.useRef(!1),be=$==="none"&&!w,Se=mt(ae=>{const re=w||S.state.inline;re&&!S.state.hasInputValue&&S.state.setInputValue("",Vt(Oo)),S.update({inputElement:ae,inputInsidePopup:re,inputOwnsFormValue:be})}),Ne=w||!m?c:m.getValidationProps(c),Oe={...Y,open:W,disabled:X,readOnly:N,popupSide:Z,listEmpty:te};function Ae(ae){if(!v)return;let re;const{highlightedChipIndex:me}=v,ye=v.chipsRef.current.length,je=C==="rtl",Re=je?"ArrowRight":"ArrowLeft",Qe=je?"ArrowLeft":"ArrowRight";if(me!==void 0){if(ae.key===Re)ae.preventDefault(),me>0?re=me-1:re=void 0;else if(ae.key===Qe)ae.preventDefault(),me<ye-1?re=me+1:re=void 0;else if(ae.key==="Backspace"||ae.key==="Delete"){ae.preventDefault();const Ze=me>=F.length-1?F.length-2:me;re=Ze>=0?Ze:void 0,S.state.setIndices({activeIndex:null,selectedIndex:null,type:"keyboard"})}return re}return ae.key===Re&&(ae.currentTarget.selectionStart??0)===0&&F.length>0?(ae.preventDefault(),re=ye>0?ye-1:void 0):ae.key==="Backspace"&&ae.currentTarget.value===""&&F.length>0&&(S.state.setIndices({activeIndex:null,selectedIndex:null,type:"keyboard"}),ae.preventDefault()),re}const Ue=En("input",t,{state:Oe,ref:[n,S.state.inputRef,Se],props:[D,q,{type:"text",value:t.value??ne??_,"aria-readonly":N||void 0,"aria-required":j||void 0,"aria-labelledby":ue,disabled:X,readOnly:N,required:$==="none"?j:void 0,form:P,...be&&I&&{name:I},id:ie,onFocus(){if(p(!0),!V||!he.current)return;he.current=!1;const ae=se.current;ae==null||!Object.hasOwn(S.state.valuesRef.current,ae)||S.state.setIndices({activeIndex:ae})},onBlur(){f(!0),p(!1);const ae=S.state.activeIndex;if(V&&ae!==null&&z!=="always"&&(se.current=ae,he.current=!0,S.state.setIndices({activeIndex:null})),h==="onBlur"){const re=$==="none"?_:F;m.commit(re)}},onCompositionStart(ae){mP||(pe.current=!0,le(ae.currentTarget.value))},onCompositionEnd(ae){pe.current=!1;const re=ae.currentTarget.value;le(null),S.state.setInputValue(re,Vt(lk,ae.nativeEvent))},onChange(ae){const re=ae.nativeEvent.inputType,me=!re||re==="insertReplacementText",ye=pe.current||!me;if(pe.current){const Ze=ae.currentTarget.value;le(Ze),Ze===""&&!S.state.openOnInputClick&&!S.state.inputInsidePopup&&S.state.setOpen(!1,Vt(pb,ae.nativeEvent));const ke=Ze.trim(),_e=U&&ke!=="";!N&&!X&&ke&&ye&&(S.state.setOpen(!0,Vt(lk,ae.nativeEvent)),U||S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"})),W&&S.state.activeIndex!==null&&!_e&&S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"});return}S.state.setInputValue(ae.currentTarget.value,Vt(lk,ae.nativeEvent));const je=ae.currentTarget.value==="",Re=Vt(pb,ae.nativeEvent);je&&!S.state.inputInsidePopup&&($==="single"&&S.state.setSelectedValue(null,Re),S.state.openOnInputClick||S.state.setOpen(!1,Re));const Qe=ae.currentTarget.value.trim();!N&&!X&&Qe&&ye&&(S.state.setOpen(!0,Vt(lk,ae.nativeEvent)),U||S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"})),W&&S.state.activeIndex!==null&&!U&&S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"})},onKeyDown(ae){if(X||N||ae.ctrlKey||ae.shiftKey||ae.altKey||ae.metaKey)return;S.state.keyboardActiveRef.current=!0;const re=ae.currentTarget,me=re.scrollWidth-re.clientWidth,ye=C==="rtl";if(ae.key==="Home"){sc(ae);const Qe=X$e&&ye?re.value.length:0;re.setSelectionRange(Qe,Qe),re.scrollLeft=0;return}if(ae.key==="End"){sc(ae);const Qe=X$e&&ye?0:re.value.length;re.setSelectionRange(Qe,Qe),re.scrollLeft=ye?-me:me;return}if(!L&&ae.key==="Escape"){const Qe=$==="multiple"&&Array.isArray(F)?F.length===0:F===null,Ze=Vt(i_,ae.nativeEvent),ke=$==="multiple"?[]:null;S.state.setInputValue("",Ze),S.state.setSelectedValue(ke,Ze),!Qe&&!S.state.inline&&!Ze.isPropagationAllowed&&ae.stopPropagation();return}if(v&&ae.key==="Backspace"&&re.value===""&&v.highlightedChipIndex===void 0&&Array.isArray(F)&&F.length>0){const Qe=v.chipsRef.current.length,Ze=Qe>0?Qe-1:F.length-1,ke=F.filter((_e,Ce)=>Ce!==Ze);S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"}),S.state.setSelectedValue(ke,Vt(Oo,ae.nativeEvent));return}const je=v?.highlightedChipIndex!==void 0,Re=Ae(ae);if(v?.setHighlightedChipIndex(Re),Re!==void 0?v?.chipsRef.current[Re]?.focus():je&&S.state.inputRef.current?.focus(),ae.which!==229&&ae.key==="Enter"&&W){const Qe=S.state.activeIndex,Ze=ae.nativeEvent;if(Qe===null){if(V)return;S.state.setOpen(!1,Vt(Oo,Ze));return}sc(ae);const ke=S.state.listRef.current[Qe];ke&&(S.state.selectionEventRef.current=Ze,ke.click(),S.state.selectionEventRef.current=null)}},onPointerMove(){S.state.keyboardActiveRef.current=!1},onPointerDown(){S.state.keyboardActiveRef.current=!1}},Ne],stateAttributesMapping:$mt}),ce=w?o.jsx(gmt.Provider,{value:mmt,children:Ue}):Ue;return o.jsxs(y.Fragment,{children:[W&&J&&o.jsx(Dmt,{ref:S.state.startDismissRef}),ce]})});function Mxe(e){const t=e.getBoundingClientRect(),n=Ks(e),r=n.getComputedStyle(e,"::before"),s=n.getComputedStyle(e,"::after");if(!(r.content!=="none"||s.content!=="none"))return t;const i=parseFloat(r.width)||0,l=parseFloat(r.height)||0,c=parseFloat(s.width)||0,u=parseFloat(s.height)||0,d=Math.max(t.width,i,c),f=Math.max(t.height,l,u),p=d-t.width,h=f-t.height;return{left:t.left-p/2,right:t.right+p/2,top:t.top-h/2,bottom:t.bottom+h/2}}const kL=2,Fmt=y.forwardRef(function(t,n){const{render:r,className:s,nativeButton:a=!0,disabled:i=!1,id:l,style:c,...u}=t,{state:d,disabled:f,setTouched:p,setFocused:h,validationMode:m,validation:g}=sm(),{labelId:v}=Ox(),b=my(),{filteredItems:w}=_1(),S=ht(b,on.selectionMode),O=ht(b,on.disabled),_=ht(b,on.readOnly),C=ht(b,on.required),j=ht(b,on.mounted),E=ht(b,on.popupSide),N=ht(b,on.positionerElement),I=ht(b,on.listElement),P=ht(b,on.triggerProps),$=ht(b,on.triggerElement),z=ht(b,on.inputInsidePopup),D=ht(b,on.id),q=ht(b,on.labelId),W=ht(b,on.open),L=ht(b,on.selectedValue),F=ht(b,on.activeIndex),B=ht(b,on.selectedIndex),M=ht(b,on.hasSelectedValue),Q=aq(),V=Cmt(),R=co(),U=f||O||i,Z=w.length===0,X=j&&N?E:null;h_({id:z?l:void 0});const te=z?l??D:l,ee=iq(v,q),J=y.useRef("");function ie(Se){J.current=Se.pointerType}const ue=Q.useState("domReferenceElement");y.useEffect(()=>{z&&$&&$!==ue&&Q.set("domReferenceElement",$)},[$,ue,Q,z]);const{reference:Y}=Jye(Q,{enabled:!W&&!_&&!O&&S==="single",listRef:b.state.labelsRef,activeIndex:F,selectedIndex:B,onMatch(Se){const Ne=b.state.valuesRef.current[Se];Ne!==void 0&&b.state.setSelectedValue(Ne,Vt("none"))}}),{reference:ne}=o_(Q,{enabled:!_&&!O,event:"mousedown"}),{buttonRef:le,getButtonProps:pe}=gd({native:a,disabled:U}),se={...d,open:W,disabled:U,popupSide:X,listEmpty:Z,placeholder:S==="none"?!1:!M},he=mt(Se=>{b.set("triggerElement",Se)});return En("button",t,{ref:[n,le,he],state:se,props:[P,ne,Y,{id:te,tabIndex:z?0:-1,role:z?"combobox":void 0,"aria-expanded":W?"true":"false","aria-haspopup":z?"dialog":"listbox","aria-controls":W?I?.id:void 0,"aria-required":z&&C||void 0,"aria-labelledby":ee,onPointerDown:ie,onPointerEnter:ie,onFocus(){h(!0),!(U||_)&&R.start(0,b.state.forceMount)},onBlur(Se){if(!dn(N,Se.relatedTarget)&&(p(!0),h(!1),m==="onBlur")){const Ne=S==="none"?V:L;g.commit(Ne)}},onMouseDown(Se){if(U||_||(z||Q.set("domReferenceElement",Se.currentTarget),b.state.forceMount(),J.current!=="touch"&&(b.state.inputRef.current?.focus(),z||Se.preventDefault()),W))return;const Ne=dr(Se.currentTarget);function Oe(Ae){if(!$)return;const Ue=Si(Ae),ce=b.state.positionerElement,ae=b.state.listElement;if(dn($,Ue)||dn(ce,Ue)||dn(ae,Ue)||Ue===$)return;const re=Mxe($),me=Ae.clientX>=re.left-kL&&Ae.clientX<=re.right+kL,ye=Ae.clientY>=re.top-kL&&Ae.clientY<=re.bottom+kL;me&&ye||b.state.setOpen(!1,Vt("cancel-open",Ae))}z&&Ne.addEventListener("mouseup",Oe,{once:!0})},onKeyDown(Se){U||_||(Se.key==="ArrowDown"||Se.key==="ArrowUp")&&(sc(Se),b.state.setOpen(!0,Vt(kF,Se.nativeEvent)),b.state.inputRef.current?.focus())}},g?g.getValidationProps(u):u,pe],stateAttributesMapping:$mt})}),DRn=y.createContext(null);function LRn(){return y.useContext(DRn)}function FRn(e){const{children:t}=e,{filteredItems:n}=_1(),r=LRn(),s=r?r.items:n;return s?o.jsx(y.Fragment,{children:s.map(t)}):null}const zmt=y.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function zRn(){return y.useContext(zmt)}function vN(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:s}=e,a=mt(s),i=y.useRef(0),l=hc(URn).current,c=hc(BRn).current,[u,d]=y.useState(0),f=y.useRef(u),p=mt((b,w)=>{c.set(b,w??null),f.current+=1,d(f.current)}),h=mt(b=>{c.delete(b),f.current+=1,d(f.current)}),m=y.useMemo(()=>{const b=new Map;return Array.from(c.keys()).filter(S=>S.isConnected).sort(qRn).forEach((S,O)=>{const _=c.get(S)??{};b.set(S,{..._,index:O})}),b},[c,u]);Tt(()=>{if(typeof MutationObserver!="function"||m.size===0)return;const b=new MutationObserver(w=>{const S=new Set,O=_=>S.has(_)?S.delete(_):S.add(_);w.forEach(_=>{_.removedNodes.forEach(O),_.addedNodes.forEach(O)}),S.size===0&&(f.current+=1,d(f.current))});return m.forEach((w,S)=>{S.parentElement&&b.observe(S.parentElement,{childList:!0})}),()=>{b.disconnect()}},[m]),Tt(()=>{f.current===u&&(n.current.length!==m.size&&(n.current.length=m.size),r&&r.current.length!==m.size&&(r.current.length=m.size),i.current=m.size),a(m)},[a,m,n,r,u]),Tt(()=>()=>{n.current=[]},[n]),Tt(()=>()=>{r&&(r.current=[])},[r]);const g=mt(b=>(l.add(b),()=>{l.delete(b)}));Tt(()=>{l.forEach(b=>b(m))},[l,m]);const v=y.useMemo(()=>({register:p,unregister:h,subscribeMapChange:g,elementsRef:n,labelsRef:r,nextIndexRef:i}),[p,h,g,n,r,i]);return o.jsx(zmt.Provider,{value:v,children:t})}function BRn(){return new Map}function URn(){return new Set}function qRn(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const Bmt=y.forwardRef(function(t,n){var r;const{render:s,className:a,style:i,children:l,...c}=t,u=my(),d=aq(),f=!!$xe(!0),{filteredItems:p,hasItems:h}=_1(),m=ht(u,on.selectionMode),g=ht(u,on.grid),v=ht(u,on.popupProps),b=ht(u,on.virtualized),w=m==="multiple",S=p.length===0,O=mt(I=>{u.set("positionerElement",I)}),_=mt(I=>{u.set("listElement",I)}),C=y.useMemo(()=>typeof l=="function"?r||(r=o.jsx(FRn,{children:l})):l,[l]),j={empty:S},E=d.useState("floatingId"),N=En("div",t,{state:j,ref:[n,_,f?null:O],props:[v,{children:C,tabIndex:-1,id:E,role:g?"grid":"listbox","aria-multiselectable":w?"true":void 0,onKeyDown(I){if(!(u.state.disabled||u.state.readOnly)&&I.key==="Enter"){const P=u.state.activeIndex;if(P==null)return;sc(I);const $=I.nativeEvent,z=u.state.listRef.current[P];z&&(u.state.selectionEventRef.current=$,z.click(),u.state.selectionEventRef.current=null)}},onKeyDownCapture(){u.state.keyboardActiveRef.current=!0},onPointerMoveCapture(){u.state.keyboardActiveRef.current=!1}},c]});return b?N:o.jsx(vN,{elementsRef:u.state.listRef,labelsRef:h?void 0:u.state.labelsRef,children:N})}),VRn="",HRn=200;function WRn(e){const t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let n=null;for(;t.nextNode();){const r=t.currentNode;r.nodeValue!==""&&(n=r)}return n}function ZRn(){const e=co(),t=y.useRef(null);return y.useEffect(()=>{if(jye)return;const n=t.current;if(n==null)return;const r=WRn(n);if(r==null)return;const s=r.nodeValue??"",a=`${s}${VRn}`;return r.nodeValue=a,e.start(HRn,()=>{r.nodeValue===a&&(r.nodeValue=s)}),()=>{e.clear(),r.nodeValue===a&&(r.nodeValue=s)}},[t,e]),t}const Umt=y.createContext(void 0);function GRn(){const e=y.useContext(Umt);if(e===void 0)throw new Error(Sr(20));return e}const qmt=y.forwardRef(function(t,n){const{keepMounted:r=!1,...s}=t,a=my(),i=ht(a,on.mounted),l=ht(a,on.forceMounted);return i||r||l?o.jsx(Umt.Provider,{value:r,children:o.jsx(WM,{ref:n,...s})}):null}),QRn=20;function oq(e,t,n,r){const[s,a]=y.useState(!1);Tt(()=>{if(!e||!t||n==null){a(!1);return}const i=dr(n).documentElement.clientWidth,l=n.offsetWidth;a(i>0&&l>0&&l>=i-QRn)},[e,t,n]),Hht(e&&(!t||s),r)}const Vmt=y.forwardRef(function(t,n){const{render:r,className:s,anchor:a,positionMethod:i="absolute",side:l="bottom",align:c="center",sideOffset:u=0,alignOffset:d=0,collisionBoundary:f="clipping-ancestors",collisionPadding:p=5,arrowPadding:h=5,sticky:m=!1,disableAnchorTracking:g=!1,collisionAvoidance:v=Fye,style:b,...w}=t,S=my(),{filteredItems:O}=_1(),_=aq(),C=GRn(),j=ht(S,on.modal),E=ht(S,on.open),N=ht(S,on.mounted),I=ht(S,on.openMethod),P=ht(S,on.positionerElement),$=ht(S,on.triggerElement),z=ht(S,on.inputElement),D=ht(S,on.inputGroupElement),q=ht(S,on.inputInsidePopup),W=ht(S,on.transitionStatus),L=O.length===0,B=rN({anchor:a??(q?$:D??z),floatingRootContext:_,positionMethod:i,mounted:N,side:l,sideOffset:u,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:m,disableAnchorTracking:g,keepMounted:C,collisionAvoidance:v,lazyFlip:!0});oq(E&&j,I==="touch",P,$);const M={open:E,side:B.side,align:B.align,anchorHidden:B.anchorHidden,empty:L};Tt(()=>{S.set("popupSide",B.side)},[S,B.side]);const Q=mt(R=>{S.set("positionerElement",R)}),V=sN(t,M,{styles:B.positionerStyles,transitionStatus:W,props:w,refs:[n,Q],hidden:!N,inert:!E});return o.jsxs(Mmt.Provider,{value:B,children:[N&&j&&o.jsx(p3,{inert:aN(!E),cutout:D??z??$}),V]})}),YRn={...yf,...Hl},Hmt=y.forwardRef(function(t,n){const{render:r,className:s,style:a,initialFocus:i,finalFocus:l,...c}=t,u=my(),d=$xe(),f=aq(),{filteredItems:p}=_1(),h=ht(u,on.mounted),m=ht(u,on.open),g=ht(u,on.openMethod),v=ht(u,on.transitionStatus),b=ht(u,on.inputInsidePopup),w=ht(u,on.inputElement),S=ht(u,on.modal),O=p.length===0;Wl({open:m,ref:u.state.popupRef,onComplete(){m&&u.state.onOpenChangeComplete(!0)}});const _={open:m,side:d.side,align:d.align,anchorHidden:d.anchorHidden,transitionStatus:v,empty:O},C=En("div",t,{state:_,ref:[n,u.state.popupRef],props:[{role:b?"dialog":"presentation",tabIndex:-1,onFocus(P){const $=Si(P.nativeEvent);g!=="touch"&&(dn(u.state.listElement,$)||$===P.currentTarget)&&u.state.inputRef.current?.focus()}},u_(v),c],stateAttributesMapping:YRn}),E=i===void 0?b?P=>P==="touch"?u.state.popupRef.current:w:!1:i;let N;l!=null?N=l:N=b?void 0:!1;const I=!b||S;return o.jsx(eN,{context:f,disabled:!h,modal:I,openInteractionType:g,initialFocus:E,returnFocus:N,getInsideElements:()=>[u.state.startDismissRef.current,u.state.endDismissRef.current],children:o.jsxs(y.Fragment,{children:[C,I&&o.jsx(Dmt,{ref:u.state.endDismissRef})]})})});let Dxe=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function _x(e={}){const{label:t,metadata:n,textRef:r,indexGuessBehavior:s,index:a}=e,{register:i,unregister:l,subscribeMapChange:c,elementsRef:u,labelsRef:d,nextIndexRef:f}=zRn(),p=y.useRef(-1),[h,m]=y.useState(a??(s===Dxe.GuessFromOrder?()=>{if(p.current===-1){const b=f.current;f.current+=1,p.current=b}return p.current}:-1)),g=y.useRef(null),v=y.useCallback(b=>{if(g.current=b,h!==-1&&b!==null&&(u.current[h]=b,d)){const w=t!==void 0;d.current[h]=w?t:r?.current?.textContent??b.textContent}},[h,u,d,t,r]);return Tt(()=>{if(a!=null)return;const b=g.current;if(b)return i(b,n),()=>{l(b)}},[a,i,l,n]),Tt(()=>{if(a==null)return c(b=>{const w=g.current?b.get(g.current)?.index:null;w!=null&&m(w)})},[a,c,m]),y.useMemo(()=>({ref:v,index:h}),[h,v])}const Wmt=y.createContext(void 0);function Zmt(){const e=y.useContext(Wmt);if(!e)throw new Error(Sr(19));return e}const XRn=y.createContext(!1);function KRn(){return y.useContext(XRn)}const Gmt=y.memo(y.forwardRef(function(t,n){const{render:r,className:s,style:a,value:i=null,index:l,disabled:c=!1,nativeButton:u=!1,...d}=t,f=y.useRef(!1),p=y.useRef(null),h=_x({index:l,textRef:p,indexGuessBehavior:Dxe.GuessFromOrder}),m=my(),g=KRn(),{flatFilteredItems:v,hasItems:b}=_1(),w=ht(m,on.open),S=ht(m,on.selectionMode),O=ht(m,on.readOnly),_=ht(m,on.virtualized),C=ht(m,on.isItemEqualToValue),j=S!=="none",E=l??(_?bw(v,i,C):h.index),N=h.index!==-1,I=ht(m,on.id),P=ht(m,on.isActive,E),$=ht(m,on.isSelected,i),z=ht(m,on.itemProps),D=y.useRef(null),q=I!=null&&N?`${I}-${E}`:void 0,W=$&&j;Tt(()=>{if(!(N&&(_||l!=null)))return;const Z=m.state.listRef.current;return Z[E]=D.current,()=>{delete Z[E]}},[N,_,E,l,m]),Tt(()=>{if(!N||b)return;const U=m.state.valuesRef.current;return U[E]=i,S!=="none"&&m.state.allValuesRef.current.push(i),()=>{delete U[E]}},[N,b,E,i,m,S]),Tt(()=>{if(!w){f.current=!1;return}if(!N||b)return;const U=m.state.selectedValue,Z=Array.isArray(U)?U[U.length-1]:U;Gv(i,Z,C)&&m.set("selectedIndex",E)},[N,b,w,m,E,i,C]);const{getButtonProps:L,buttonRef:F}=gd({disabled:c,focusableWhenDisabled:!0,native:u,composite:!0}),B={disabled:c,selected:W,highlighted:P};function M(U){function Z(){m.state.handleSelection(U,i)}m.state.submitOnItemClick?(fo.flushSync(Z),m.state.requestSubmit()):Z()}const Q={id:q,role:g?"gridcell":"option","aria-selected":j?W:void 0,tabIndex:void 0,onPointerDownCapture(U){f.current=!0,U.preventDefault()},onMouseDown(U){U.preventDefault()},onClick(U){c||O||M(U.nativeEvent)},onMouseUp(U){const Z=f.current;f.current=!1,!(c||O||U.button!==0||Z||!P)&&M(U.nativeEvent)}},V=En("div",t,{ref:[F,n,h.ref,D],state:B,props:[z,Q,d,L]}),R=y.useMemo(()=>({selected:W,textRef:p}),[W,p]);return o.jsx(Wmt.Provider,{value:R,children:V})})),JRn=y.forwardRef(function(t,n){const r=t.keepMounted??!1,{selected:s}=Zmt();return r||s?o.jsx(e2n,{...t,ref:n}):null}),e2n=y.memo(y.forwardRef((e,t)=>{const{render:n,className:r,style:s,keepMounted:a,...i}=e,{selected:l}=Zmt(),c=y.useRef(null),{transitionStatus:u,setMounted:d}=wg(l),p=En("span",e,{ref:[t,c],state:{selected:l,transitionStatus:u},props:[{"aria-hidden":!0,children:"✔️"},i],stateAttributesMapping:Hl});return Wl({open:l,ref:c,onComplete(){l||d(!1)}}),p})),Qmt=y.forwardRef(function(t,n){const{render:r,className:s,style:a,children:i,...l}=t,{filteredItems:c}=_1(),u=my(),d=ZRn(),f=c.length===0?i:null;return En("div",t,{ref:[n,u.state.emptyRef,d],props:[{children:f,role:"status","aria-live":"polite","aria-atomic":!0},l]})}),t2n=y.forwardRef(function(t,n){const{className:r,render:s,orientation:a="horizontal",style:i,...l}=t;return En("div",t,{state:{orientation:a},ref:n,props:[{role:"separator","aria-orientation":a},l]})});function n2n(e){return e==="link"?"ghost":e}function Ymt({variant:e,size:t,error:n,className:r}){const s=n2n(e);return K(t3({variant:s,size:t}),"w-full min-w-32 justify-between",eut[s],"data-[placeholder]:text-neutral3",n&&"border-error hover:border-error focus-visible:border-error",r)}const fs={root:"flex flex-col gap-1.5",chevron:"ml-2 h-4 w-4 shrink-0 opacity-60",placeholder:"text-neutral3",popup:K("min-w-(--anchor-width) w-max max-w-(--available-width) rounded-xl border border-border1 bg-surface3 text-neutral4","shadow-dialog","origin-(--transform-origin)","transition-[transform,scale,opacity] duration-150 ease-out","data-starting-style:scale-95 data-starting-style:opacity-0","data-ending-style:scale-95 data-ending-style:opacity-0"),positioner:"z-50 pointer-events-auto",searchContainer:K("flex items-center border-b border-border1 px-2.5 py-1.5",ss.colors),searchIcon:K("mr-2 h-3.5 w-3.5 shrink-0 text-neutral3",ss.colors),searchInput:K("flex h-7 w-full rounded-md bg-transparent py-1 text-ui-smd leading-ui-sm text-neutral6","placeholder:text-neutral3 disabled:cursor-not-allowed disabled:opacity-50","outline-none focus:outline-none focus-visible:outline-none",ss.colors),empty:"not-empty:block hidden py-4 text-center text-ui-smd text-neutral3",list:"max-h-dropdown-max-height overflow-y-auto overflow-x-hidden p-1",item:K("group/item relative flex cursor-pointer select-none items-center gap-2 rounded-md","pl-2.5 pr-2 py-1.5 min-h-8","text-ui-smd leading-ui-sm text-neutral4","outline-none focus:outline-none focus-visible:outline-none",ss.colors,"data-highlighted:bg-surface4 data-highlighted:text-neutral6","data-selected:text-neutral6"),itemMulti:K("relative flex cursor-pointer select-none items-center gap-2.5 rounded-md","pl-2 pr-2.5 py-1.5 min-h-8","text-ui-smd leading-ui-sm text-neutral4","outline-none focus:outline-none focus-visible:outline-none",ss.colors,"data-highlighted:bg-surface4 data-highlighted:text-neutral6","data-selected:text-neutral6"),itemRightSlot:"ml-auto flex items-center gap-2 shrink-0",checkContainer:"flex h-4 w-4 shrink-0 items-center justify-center text-accent1",checkIcon:"h-3.5 w-3.5",checkbox:"flex h-4 w-4 shrink-0 items-center justify-center rounded-[4px] border",checkboxSelected:"bg-accent1 border-accent1",checkboxUnselected:"border-border2",checkboxIcon:"h-3 w-3 text-surface1",optionContent:"flex items-center gap-2 w-full min-w-0",optionText:"flex flex-col gap-0.5 min-w-0",optionLabel:"truncate",optionDescription:"text-ui-sm text-neutral3 truncate",optionEnd:"ml-auto flex items-center shrink-0",error:"text-ui-sm text-accent2"};function Xmt({options:e,value:t=[],onValueChange:n,placeholder:r="Select options...",searchPlaceholder:s="Search...",emptyText:a="No option found.",className:i,disabled:l=!1,variant:c="default",size:u="md",open:d,onOpenChange:f,container:p,error:h}){const m=e.filter(b=>t.includes(b.value)),g=b=>{b&&n?.(b.map(w=>w.value))},v=m.length===0?r:`${m.length} selected`;return o.jsxs("div",{className:fs.root,children:[o.jsxs(Pmt,{multiple:!0,items:e,value:m,onValueChange:g,disabled:l,open:d,onOpenChange:f,children:[o.jsxs(Fmt,{className:Ymt({variant:c,size:u,error:!!h,className:i}),children:[o.jsx("span",{className:K("truncate",m.length===0&&fs.placeholder),children:v}),o.jsx("span",{className:"flex shrink-0 items-center",children:o.jsx(c3,{className:fs.chevron})})]}),o.jsx(qmt,{container:p,children:o.jsx(Vmt,{align:"start",sideOffset:4,className:fs.positioner,children:o.jsxs(Hmt,{className:fs.popup,children:[o.jsxs("div",{className:fs.searchContainer,children:[o.jsx(Zj,{className:fs.searchIcon}),o.jsx(Lmt,{className:fs.searchInput,placeholder:s})]}),o.jsx(Qmt,{className:fs.empty,children:a}),o.jsx(Bmt,{className:fs.list,children:b=>{const w=t.includes(b.value);return o.jsxs(Gmt,{value:b,className:fs.itemMulti,children:[o.jsx("span",{className:K(fs.checkbox,w?fs.checkboxSelected:fs.checkboxUnselected),children:w&&o.jsx(kx,{className:fs.checkboxIcon})}),o.jsxs("span",{className:fs.optionContent,children:[b.start,o.jsxs("span",{className:fs.optionText,children:[o.jsx("span",{className:fs.optionLabel,children:b.label}),b.description&&o.jsx("span",{className:fs.optionDescription,children:b.description})]}),b.end?o.jsx("div",{className:fs.optionEnd,children:b.end}):null]})]},b.value)}})]})})})]}),h&&o.jsx("span",{className:fs.error,children:h})]})}const Kmt=y.createContext(void 0);function r2n({container:e,children:t}){return o.jsx(Kmt.Provider,{value:e??void 0,children:t})}function m3(e){const t=y.useContext(Kmt);return e??t??void 0}function Wc({options:e,value:t,onValueChange:n,placeholder:r="Select option...",searchPlaceholder:s="Search...",emptyText:a="No option found.",className:i,disabled:l=!1,variant:c="default",size:u="md",open:d,onOpenChange:f,container:p,error:h}){const m=e.find(b=>b.value===t)??null,g=m3(p),v=b=>{b&&n?.(b.value)};return o.jsxs("div",{className:fs.root,children:[o.jsxs(Pmt,{autoHighlight:!0,items:e,value:m,onValueChange:v,disabled:l,open:d,onOpenChange:f,children:[o.jsxs(Fmt,{className:Ymt({variant:c,size:u,error:!!h,className:i}),children:[o.jsxs("span",{className:"flex items-center gap-2 min-w-0 flex-1",children:[m?.start,o.jsx("span",{className:"truncate",children:o.jsx(PRn,{placeholder:r})})]}),o.jsx("span",{className:"flex shrink-0 items-center",children:o.jsx(c3,{className:fs.chevron})})]}),o.jsx(qmt,{container:g,children:o.jsx(Vmt,{align:"start",sideOffset:4,className:fs.positioner,children:o.jsxs(Hmt,{className:fs.popup,children:[o.jsxs("div",{className:fs.searchContainer,children:[o.jsx(Zj,{className:fs.searchIcon}),o.jsx(Lmt,{className:fs.searchInput,placeholder:s})]}),o.jsx(Qmt,{className:fs.empty,children:a}),o.jsx(Bmt,{className:fs.list,children:b=>o.jsxs(Gmt,{value:b,className:fs.item,children:[b.start,o.jsxs("span",{className:fs.optionText,children:[o.jsx("span",{className:fs.optionLabel,children:b.label}),b.description&&o.jsx("span",{className:fs.optionDescription,children:b.description})]}),o.jsxs("span",{className:fs.itemRightSlot,children:[b.end?o.jsx("div",{className:fs.optionEnd,children:b.end}):null,o.jsx("span",{className:fs.checkContainer,children:o.jsx(JRn,{children:o.jsx(kx,{className:fs.checkIcon})})})]})]},b.value)})]})})})]}),h&&o.jsx("span",{className:fs.error,children:h})]})}var T4e=1,s2n=.9,a2n=.8,i2n=.17,dX=.1,fX=.999,o2n=.9999,l2n=.99,c2n=/[\\\/_+.#"@\[\(\{&]/,u2n=/[\\\/_+.#"@\[\(\{&]/g,d2n=/[\s-]/,Jmt=/[\s-]/g;function cfe(e,t,n,r,s,a,i){if(a===t.length)return s===e.length?T4e:l2n;var l=`${s},${a}`;if(i[l]!==void 0)return i[l];for(var c=r.charAt(a),u=n.indexOf(c,s),d=0,f,p,h,m;u>=0;)f=cfe(e,t,n,r,u+1,a+1,i),f>d&&(u===s?f*=T4e:c2n.test(e.charAt(u-1))?(f*=a2n,h=e.slice(s,u-1).match(u2n),h&&s>0&&(f*=Math.pow(fX,h.length))):d2n.test(e.charAt(u-1))?(f*=s2n,m=e.slice(s,u-1).match(Jmt),m&&s>0&&(f*=Math.pow(fX,m.length))):(f*=i2n,s>0&&(f*=Math.pow(fX,u-s))),e.charAt(u)!==t.charAt(a)&&(f*=o2n)),(f<dX&&n.charAt(u-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(u-1)!==r.charAt(a))&&(p=cfe(e,t,n,r,u+1,a+2,i),p*dX>f&&(f=p*dX)),f>d&&(d=f),u=n.indexOf(c,u+1);return i[l]=d,d}function N4e(e){return e.toLowerCase().replace(Jmt," ")}function f2n(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,cfe(e,t,N4e(e),N4e(t),0,0,{})}var pX="focusScope.autoFocusOnMount",hX="focusScope.autoFocusOnUnmount",I4e={bubbles:!1,cancelable:!0},p2n="FocusScope",egt=y.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...i}=e,[l,c]=y.useState(null),u=Aj(s),d=Aj(a),f=y.useRef(null),p=xg(t,g=>c(g)),h=y.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;y.useEffect(()=>{if(r){let g=function(S){if(h.paused||!l)return;const O=S.target;l.contains(O)?f.current=O:M0(f.current,{select:!0})},v=function(S){if(h.paused||!l)return;const O=S.relatedTarget;O!==null&&(l.contains(O)||M0(f.current,{select:!0}))},b=function(S){if(document.activeElement===document.body)for(const _ of S)_.removedNodes.length>0&&M0(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",v);const w=new MutationObserver(b);return l&&w.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",v),w.disconnect()}}},[r,l,h.paused]),y.useEffect(()=>{if(l){R4e.add(h);const g=document.activeElement;if(!l.contains(g)){const b=new CustomEvent(pX,I4e);l.addEventListener(pX,u),l.dispatchEvent(b),b.defaultPrevented||(h2n(b2n(tgt(l)),{select:!0}),document.activeElement===g&&M0(l))}return()=>{l.removeEventListener(pX,u),setTimeout(()=>{const b=new CustomEvent(hX,I4e);l.addEventListener(hX,d),l.dispatchEvent(b),b.defaultPrevented||M0(g??document.body,{select:!0}),l.removeEventListener(hX,d),R4e.remove(h)},0)}}},[l,u,d,h]);const m=y.useCallback(g=>{if(!n&&!r||h.paused)return;const v=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,b=document.activeElement;if(v&&b){const w=g.currentTarget,[S,O]=m2n(w);S&&O?!g.shiftKey&&b===O?(g.preventDefault(),n&&M0(S,{select:!0})):g.shiftKey&&b===S&&(g.preventDefault(),n&&M0(O,{select:!0})):b===w&&g.preventDefault()}},[n,r,h.paused]);return o.jsx(gf.div,{tabIndex:-1,...i,ref:p,onKeyDown:m})});egt.displayName=p2n;function h2n(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(M0(r,{select:t}),document.activeElement!==n)return}function m2n(e){const t=tgt(e),n=A4e(t,e),r=A4e(t.reverse(),e);return[n,r]}function tgt(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function A4e(e,t){for(const n of e)if(!g2n(n,{upTo:t}))return n}function g2n(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function v2n(e){return e instanceof HTMLInputElement&&"select"in e}function M0(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&v2n(e)&&t&&e.select()}}var R4e=y2n();function y2n(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=P4e(e,t),e.unshift(t)},remove(t){e=P4e(e,t),e[0]?.resume()}}}function P4e(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function b2n(e){return e.filter(t=>t.tagName!=="A")}var mX=0;function x2n(){y.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??$4e()),document.body.insertAdjacentElement("beforeend",e[1]??$4e()),mX++,()=>{mX===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),mX--}},[])}function $4e(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var dv=function(){return dv=Object.assign||function(t){for(var n,r=1,s=arguments.length;r<s;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},dv.apply(this,arguments)};function ngt(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n}function w2n(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,a;r<s;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Y8="right-scroll-bar-position",X8="width-before-scroll-bar",S2n="with-scroll-bars-hidden",k2n="--removed-body-scroll-bar-size";function gX(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function O2n(e,t){var n=y.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var s=n.value;s!==r&&(n.value=r,n.callback(r,s))}}}})[0];return n.callback=t,n.facade}var _2n=typeof window<"u"?y.useLayoutEffect:y.useEffect,M4e=new WeakMap;function C2n(e,t){var n=O2n(null,function(r){return e.forEach(function(s){return gX(s,r)})});return _2n(function(){var r=M4e.get(n);if(r){var s=new Set(r),a=new Set(e),i=n.current;s.forEach(function(l){a.has(l)||gX(l,null)}),a.forEach(function(l){s.has(l)||gX(l,i)})}M4e.set(n,e)},[e]),n}function E2n(e){return e}function j2n(e,t){t===void 0&&(t=E2n);var n=[],r=!1,s={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var i=t(a,r);return n.push(i),function(){n=n.filter(function(l){return l!==i})}},assignSyncMedium:function(a){for(r=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(l){return a(l)},filter:function(){return n}}},assignMedium:function(a){r=!0;var i=[];if(n.length){var l=n;n=[],l.forEach(a),i=n}var c=function(){var d=i;i=[],d.forEach(a)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return s}function T2n(e){e===void 0&&(e={});var t=j2n(null);return t.options=dv({async:!0,ssr:!1},e),t}var rgt=function(e){var t=e.sideCar,n=ngt(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return y.createElement(r,dv({},n))};rgt.isSideCarExport=!0;function N2n(e,t){return e.useMedium(t),rgt}var sgt=T2n(),vX=function(){},lq=y.forwardRef(function(e,t){var n=y.useRef(null),r=y.useState({onScrollCapture:vX,onWheelCapture:vX,onTouchMoveCapture:vX}),s=r[0],a=r[1],i=e.forwardProps,l=e.children,c=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,h=e.noRelative,m=e.noIsolation,g=e.inert,v=e.allowPinchZoom,b=e.as,w=b===void 0?"div":b,S=e.gapMode,O=ngt(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),_=p,C=C2n([n,t]),j=dv(dv({},O),s);return y.createElement(y.Fragment,null,d&&y.createElement(_,{sideCar:sgt,removeScrollBar:u,shards:f,noRelative:h,noIsolation:m,inert:g,setCallbacks:a,allowPinchZoom:!!v,lockRef:n,gapMode:S}),i?y.cloneElement(y.Children.only(l),dv(dv({},j),{ref:C})):y.createElement(w,dv({},j,{className:c,ref:C}),l))});lq.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};lq.classNames={fullWidth:X8,zeroRight:Y8};var I2n=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function A2n(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=I2n();return t&&e.setAttribute("nonce",t),e}function R2n(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function P2n(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var $2n=function(){var e=0,t=null;return{add:function(n){e==0&&(t=A2n())&&(R2n(t,n),P2n(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},M2n=function(){var e=$2n();return function(t,n){y.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},agt=function(){var e=M2n(),t=function(n){var r=n.styles,s=n.dynamic;return e(r,s),null};return t},D2n={left:0,top:0,right:0,gap:0},yX=function(e){return parseInt(e||"",10)||0},L2n=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],s=t[e==="padding"?"paddingRight":"marginRight"];return[yX(n),yX(r),yX(s)]},F2n=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return D2n;var t=L2n(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},z2n=agt(),aj="data-scroll-locked",B2n=function(e,t,n,r){var s=e.left,a=e.top,i=e.right,l=e.gap;return n===void 0&&(n="margin"),`
|
|
227
227
|
.`.concat(S2n,` {
|
|
228
228
|
overflow: hidden `).concat(r,`;
|
|
229
229
|
padding-right: `).concat(l,"px ").concat(r,`;
|
|
@@ -764,7 +764,7 @@ window.parent.postMessage({jsonrpc:'2.0',method:'ui/notifications/sandbox-proxy-
|
|
|
764
764
|
"groundTruth": "Expected result (optional)",
|
|
765
765
|
"metadata": { "key": "value" } // optional
|
|
766
766
|
}
|
|
767
|
-
]`})]})]})}function tXr({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(Ve,{children:o.jsx(xp,{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 nXr({datasetId:e,open:t,onOpenChange:n,onSuccess:r}){const[s,a]=y.useState("upload"),[i,l]=y.useState(null),[c,u]=y.useState({current:0,total:0}),[d,f]=y.useState(null),[p,h]=y.useState(!1),{parseFile:m,isParsing:g,error:v}=KQr(),{batchInsertItems:b}=Fi(),w=y.useCallback(async I=>{try{const P=await m(I);l(P),a("preview")}catch{}},[m]),S=y.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(P=>({input:P.input,groundTruth:P.groundTruth,metadata:P.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]),O=y.useCallback(()=>{n(!1),r?.(),d&&d.success>0&&Be.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]),_=y.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,j=()=>{switch(s){case"upload":return o.jsx(eXr,{onFileSelect:w,isParsing:g,error:v?.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(tXr,{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(JYr,{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(Qt,{}),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":"",")"]})]})]})]})}},E=()=>{switch(s){case"upload":return o.jsx(fe,{onClick:_,children:"Cancel"});case"preview":return o.jsxs(o.Fragment,{children:[o.jsx(fe,{onClick:()=>a("upload"),children:"Back"}),o.jsxs(fe,{variant:"primary",onClick:S,disabled:!C,children:["Import ",i?.items.length??0," Item",i?.items.length!==1?"s":""]})]});case"importing":return null;case"complete":return o.jsx(fe,{variant:"primary",onClick:O,children:"Done"})}},N={upload:"Import JSON",preview:"Preview Data",importing:"Importing",complete:"Import Complete"};return o.jsx(yr,{open:t,onOpenChange:_,children:o.jsxs(br,{className:"max-w-2xl max-h-[90vh]",children:[o.jsxs(xr,{children:[o.jsx(mr,{children:N[s]}),o.jsx(Qs,{children:"Import dataset items from a JSON file."})]}),o.jsx(Ar,{className:"min-h-[200px] max-h-[50vh] overflow-y-auto",children:j()}),o.jsx(mc,{className:"px-6 pt-4 flex justify-end gap-2",children:E()})]})})}const qEe=e=>{const t=We(),{data:n}=gM(e),r=n?.experiments;return xt({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})},rXr=e=>{const t=We(),{data:n}=gM(e),r=n?.experiments;return xt({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 sXr(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 ELt({datasetId:e,experimentId:t,featuredItemId:n}){const r=We(),{data:s}=Lx(e),{data:a,isLoading:i}=qEe(e),{data:l,isLoading:c}=rXr(e),u=y.useMemo(()=>t?(a??[]).filter(ke=>ke.experimentId===t):a,[a,t]),d=y.useMemo(()=>t?(l??[]).filter(ke=>ke.experimentId===t):l,[l,t]),{updateExperimentResult:f}=Fi(),[p,h]=y.useState(n??null);y.useEffect(()=>{n!==void 0&&h(n)},[n]);const[m,g]=y.useState(null),[v,b]=y.useState(new Set),[w,S]=y.useState(!1),[O,_]=y.useState(!1),[C,j]=y.useState(!1),[E,N]=y.useState(""),[I,P]=y.useState(""),[$,z]=y.useState(""),[D,q]=y.useState([]),[W,L]=y.useState(!1),[F,B]=y.useState(null),M=y.useMemo(()=>F??u??[],[F,u]);y.useEffect(()=>{B(null)},[e,t]),y.useEffect(()=>{u&&F===null&&B(u)},[u,F]);const Q=y.useMemo(()=>{const ke=new Set;if(s?.tags)for(const _e of s.tags)ke.add(_e);for(const _e of M)for(const Ce of _e.tags)ke.add(Ce);return[...ke].sort()},[s,M]),V=y.useCallback(ke=>{!s||!e||(s.tags??[]).includes(ke)},[s,e]),R=y.useMemo(()=>m?m==="__untagged__"?M.filter(ke=>ke.tags.length===0):M.filter(ke=>ke.tags.includes(m)):M,[M,m]),U=y.useMemo(()=>{const ke=new Map;for(const _e of M)for(const Ce of _e.tags)ke.set(Ce,(ke.get(Ce)??0)+1);return[...ke.entries()].sort((_e,Ce)=>Ce[1]-_e[1])},[M]),Z=y.useMemo(()=>M.filter(ke=>ke.tags.length===0).length,[M]),X=y.useMemo(()=>{let ke=0;return m&&ke++,w&&ke++,ke},[m,w]),te=y.useCallback((ke,_e)=>{B(Ee=>(Ee??[]).map($e=>$e.id===ke?{...$e,tags:_e}:$e));const Ce=M.find(Ee=>Ee.id===ke);Ce?.experimentId&&Ce?.datasetId&&f.mutate({datasetId:Ce.datasetId,experimentId:Ce.experimentId,resultId:Ce.id,tags:_e})},[M,f]),ee=y.useCallback((ke,_e)=>{const Ce=M.find(Ee=>Ee.id===ke);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(Ee=>(Ee??[]).map($e=>$e.id===ke?{...$e,rating:_e}:$e))},[M,r]),J=y.useCallback((ke,_e)=>{const Ce=M.find(Ee=>Ee.id===ke);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(Ee=>(Ee??[]).map($e=>$e.id===ke?{...$e,comment:_e}:$e))},[M,r]),ie=y.useCallback(ke=>{const _e=M.find(Ce=>Ce.id===ke);B(Ce=>(Ce??[]).filter(Ee=>Ee.id!==ke)),b(Ce=>{const Ee=new Set(Ce);return Ee.delete(ke),Ee}),p===ke&&h(null),_e?.experimentId&&_e?.datasetId&&f.mutate({datasetId:_e.datasetId,experimentId:_e.experimentId,resultId:_e.id,status:null})},[M,f,p]),ue=y.useCallback(ke=>{const _e=M.find(Ce=>Ce.id===ke);B(Ce=>(Ce??[]).filter(Ee=>Ee.id!==ke)),b(Ce=>{const Ee=new Set(Ce);return Ee.delete(ke),Ee}),p===ke&&h(null),_e?.experimentId&&_e?.datasetId&&f.mutate({datasetId:_e.datasetId,experimentId:_e.experimentId,resultId:_e.id,status:"complete"})},[M,f,p]),Y=y.useMemo(()=>{const ke=w?d??[]:R;return!w||!m?ke:m==="__untagged__"?ke.filter(_e=>_e.tags.length===0):ke.filter(_e=>_e.tags.includes(m))},[w,d,R,m]),ne=w?c:!1,le=y.useMemo(()=>new Set(Y.map(ke=>ke.id)),[Y]),pe=y.useMemo(()=>[...v].filter(ke=>le.has(ke)).length,[v,le]),se=Y.length>0&&pe===Y.length,he=pe>0&&!se,be=y.useCallback(ke=>{b(_e=>{const Ce=new Set(_e);return Ce.has(ke)?Ce.delete(ke):Ce.add(ke),Ce})},[]),Se=y.useCallback(()=>{b(se?new Set:new Set(Y.map(ke=>ke.id)))},[se,Y]),Ne=y.useCallback(ke=>{for(const _e of v){const Ce=M.find(Ee=>Ee.id===_e);Ce&&!Ce.tags.includes(ke)&&te(_e,[...Ce.tags,ke])}},[M,v,te]),Oe=y.useCallback(ke=>{for(const _e of v){const Ce=M.find(Ee=>Ee.id===_e);Ce&&Ce.tags.includes(ke)&&te(_e,Ce.tags.filter(Ee=>Ee!==ke))}},[M,v,te]),Ae=y.useCallback(()=>{for(const ke of v)ue(ke);b(new Set)},[v,ue]),Ue=y.useCallback(()=>{for(const ke of v)ie(ke);b(new Set)},[v,ie]),ce=y.useCallback(()=>{N(""),j(!0)},[]),ae=y.useCallback(async()=>{if(!(!I||!$)){_(!0),j(!1);try{const ke=M.filter(Ce=>v.has(Ce.id));if(ke.length===0){_(!1);return}const _e=await r.clusterFailures({modelId:`${I}/${$}`,items:ke.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:E||void 0});_e.proposedTags&&_e.proposedTags.length>0&&(q(_e.proposedTags.map(Ce=>({...Ce,accepted:!0}))),L(!0))}catch(ke){console.error("Analysis failed:",ke)}finally{_(!1)}}},[I,$,M,v,r,Q,E]),re=y.useCallback(()=>{for(const ke of D){if(!ke.accepted)continue;const _e=M.find(Ce=>Ce.id===ke.itemId);if(_e){const Ce=[...new Set([..._e.tags,...ke.tags])];te(_e.id,Ce)}}L(!1)},[D,M,te]),me=y.useCallback(ke=>{h(_e=>_e===ke?null:ke)},[]),ye=y.useMemo(()=>p?Y.find(ke=>ke.id===p)??null:null,[p,Y]),je=p?Y.findIndex(ke=>ke.id===p):-1,Re=je>0?()=>h(Y[je-1].id):void 0,Qe=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(Qt,{className:"w-6 h-6"})}):o.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[o.jsx(yr,{open:C,onOpenChange:j,children:o.jsxs(br,{children:[o.jsxs(xr,{children:[o.jsx(mr,{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(Mt,{className:"text-xs mb-1 block",children:"Provider"}),o.jsx(Oy,{value:I,onValueChange:P})]}),o.jsxs("div",{children:[o.jsx(Mt,{className:"text-xs mb-1 block",children:"Model"}),o.jsx(_y,{llmId:I,value:$,onValueChange:z})]})]}),o.jsxs(ge,{variant:"ui-xs",className:"text-neutral3",children:[v.size," item",v.size!==1?"s":""," will be analyzed"]}),o.jsxs("div",{children:[o.jsx(Mt,{className:"text-xs",children:"Instructions (optional)"}),o.jsx(ql,{value:E,onChange:ke=>N(ke.target.value),placeholder:"E.g., Focus on safety issues and factual errors...",rows:3,className:"text-xs mt-1"})]})]}),o.jsxs(mc,{children:[o.jsx(fe,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),o.jsxs(fe,{onClick:ae,disabled:!I||!$||O,children:[O?o.jsx(Qt,{className:"w-4 h-4 mr-1"}):null,"Analyze"]})]})]})}),o.jsx(yr,{open:W,onOpenChange:L,children:o.jsxs(br,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[o.jsxs(xr,{children:[o.jsx(mr,{children:"Review Proposed Tags"}),o.jsxs(Qs,{children:[D.filter(ke=>ke.accepted).length," of ",D.length," proposals selected"]})]}),o.jsx("div",{className:"space-y-3 py-2",children:D.map((ke,_e)=>{const Ce=M.find(Ee=>Ee.id===ke.itemId);return o.jsx("div",{className:K("p-3 border rounded-lg",!ke.accepted&&"opacity-50"),children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(Yo,{checked:ke.accepted,onCheckedChange:Ee=>q($e=>$e.map((Fe,Ke)=>Ke===_e?{...Fe,accepted:!!Ee}:Fe))}),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):ke.itemId}),o.jsx("div",{className:"flex gap-1 flex-wrap mt-1.5",children:ke.tags.map((Ee,$e)=>o.jsx(hLt,{tag:Ee,onRename:Fe=>q(Ke=>Ke.map((Ye,Rt)=>Rt===_e?{...Ye,tags:Ye.tags.map((Ct,en)=>en===$e?Fe:Ct)}:Ye)),onRemove:()=>q(Fe=>Fe.map((Ke,Ye)=>Ye===_e?{...Ke,tags:Ke.tags.filter((Rt,Ct)=>Ct!==$e)}:Ke))},`${Ee}-${$e}`))}),ke.reason&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-1 block italic",children:ke.reason})]})]})},ke.itemId)})}),o.jsxs(mc,{children:[o.jsx(fe,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),o.jsxs(fe,{onClick:re,disabled:D.filter(ke=>ke.accepted).length===0,children:["Accept ",D.filter(ke=>ke.accepted).length," proposals"]})]})]})}),o.jsxs("div",{className:K("grid w-full h-full grid-cols-1 gap-4 overflow-y-auto",ye&&"grid-cols-[1fr_1fr]"),children:[o.jsxs("div",{className:"grid gap-8 content-start w-full overflow-y-auto",children:[o.jsxs("div",{className:"flex items-center justify-between w-full flex-wrap gap-4 gap-x-6",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs(ft,{children:[o.jsx(ft.Trigger,{asChild:!0,children:o.jsxs(fe,{variant:"outline",size:"md",children:[o.jsx(fit,{}),"Filter",X>0&&o.jsx("span",{className:K("ml-0.5 inline-flex items-center justify-center rounded-full bg-accent1/50 text-neutral5 text-ui-sm w-5 h-5"),children:X})]})}),o.jsxs(ft.Content,{align:"start",className:K("min-w-48"),children:[o.jsxs(ft.Sub,{children:[o.jsxs(ft.SubTrigger,{children:["Status",w&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(ft.SubContent,{children:[o.jsx(ft.CheckboxItem,{checked:!w,onCheckedChange:()=>{S(!1),h(null)},onSelect:ke=>ke.preventDefault(),children:"Review Queue"}),o.jsx(ft.CheckboxItem,{checked:w,onCheckedChange:()=>{S(!0),h(null)},onSelect:ke=>ke.preventDefault(),children:"Completed"})]})]}),o.jsxs(ft.Sub,{children:[o.jsxs(ft.SubTrigger,{children:["Tags",m&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(ft.SubContent,{children:[o.jsx(ft.CheckboxItem,{checked:!m,onCheckedChange:()=>g(null),onSelect:ke=>ke.preventDefault(),children:"All"}),Z>0&&o.jsx(ft.CheckboxItem,{checked:m==="__untagged__",onCheckedChange:()=>g(m==="__untagged__"?null:"__untagged__"),onSelect:ke=>ke.preventDefault(),children:"Untagged"}),U.length>0&&o.jsx(ft.Separator,{}),U.map(([ke])=>o.jsx(ft.CheckboxItem,{checked:m===ke,onCheckedChange:()=>g(m===ke?null:ke),onSelect:_e=>_e.preventDefault(),children:ke},ke))]})]}),X>0&&o.jsxs(o.Fragment,{children:[o.jsx(ft.Separator,{}),o.jsxs(ft.Item,{onSelect:()=>{g(null),S(!1),h(null)},children:[o.jsx(gs,{}),"Clear all filters"]})]})]})]}),X>0&&o.jsxs(fe,{variant:"outline",size:"md",onClick:()=>{g(null),S(!1),h(null)},children:[o.jsx(gs,{}),"Reset"]})]}),!w&&v.size>0&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(pLt,{selectedCount:v.size,vocabulary:Q,onApplyTag:Ne,onRemoveTag:Oe,onNewTag:ke=>Ne(ke)}),o.jsxs(ft,{children:[o.jsx(ft.Trigger,{asChild:!0,children:o.jsxs(fe,{disabled:O,children:[O?o.jsx(Qt,{className:"w-4 h-4"}):o.jsx(Ve,{size:"sm",children:o.jsx(ea,{})}),"Actions"]})}),o.jsxs(ft.Content,{align:"end",children:[o.jsxs(ft.Item,{onSelect:Ae,children:[o.jsx(Ve,{size:"sm",children:o.jsx(Zk,{})}),"Complete"]}),o.jsxs(ft.Item,{onSelect:Ue,children:[o.jsx(Ve,{size:"sm",children:o.jsx(Zc,{})}),"Remove"]}),o.jsx(ft.Separator,{}),o.jsxs(ft.Item,{onSelect:ce,children:[o.jsx(Ve,{size:"sm",children:o.jsx(og,{})}),"Analyze"]})]})]})]})]}),ne?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Qt,{className:"w-6 h-6"})}):Y.length===0?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsxs("div",{className:"text-center px-8",children:[o.jsx(ge,{variant:"ui-sm",className:"text-neutral3 block",children:w?"No completed reviews yet":"No items to review"}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-2 block",children:w?"Items marked as complete will appear here for auditing.":"When experiment results are flagged for review, they will appear here."})]})}):o.jsxs(xe,{columns:Ze,className:"min-w-0",children:[o.jsxs(xe.Top,{hasLeadingCell:!0,children:[w?o.jsx(xe.TopCell,{children:" "}):o.jsx(xe.TopSelectCell,{checked:se?!0:he?"indeterminate":!1,onToggle:()=>Se(),"aria-label":"Select all"}),o.jsxs(xe.TopCells,{colStart:2,children:[o.jsx(xe.TopCell,{children:"Input"}),o.jsx(xe.TopCell,{children:"Comment"}),o.jsx(xe.TopCell,{children:"Tags"}),o.jsx(xe.TopCell,{children:"Rating"}),o.jsx(xe.TopCell,{children:"Scores"})]})]}),Y.map(ke=>{const _e=ke.scores?Object.entries(ke.scores):[],Ce=p===ke.id,Ee=o.jsxs(o.Fragment,{children:[o.jsx(xe.Cell,{height:"compact",className:"min-w-0 text-neutral4",children:o.jsx("span",{className:"block truncate",children:sXr(ke.input,200)})}),o.jsx(xe.Cell,{height:"compact",className:"min-w-0",children:ke.comment?o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 truncate",children:ke.comment}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsx(xe.Cell,{height:"compact",className:"min-w-0",children:ke.tags.length>0?o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 truncate",children:ke.tags.join(", ")}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsxs(xe.Cell,{height:"compact",children:[ke.rating==="positive"&&o.jsx(Ve,{size:"sm",className:"text-positive1",children:o.jsx(Bve,{})}),ke.rating==="negative"&&o.jsx(Ve,{size:"sm",className:"text-negative1",children:o.jsx(zve,{})}),!ke.rating&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})]}),o.jsx(xe.Cell,{height:"compact",children:_e.length>0?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(Ve,{size:"sm",className:"text-neutral3",children:o.jsx(ig,{})}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 font-mono",children:_e[0][1].toFixed(2)}),_e.length>1&&o.jsxs(gn,{variant:"default",children:["+",_e.length-1]})]}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})})]});return o.jsxs(xe.RowWrapper,{children:[w?o.jsx(xe.Cell,{height:"compact",className:"justify-items-center px-4",children:o.jsx("div",{role:"img","aria-label":ke.error?"Error":"Success",title:ke.error?"Error":"Success",className:K("w-2 h-2 rounded-full",ke.error?"bg-red-700":"bg-green-600")})}):o.jsx(xe.SelectCell,{checked:v.has(ke.id),onToggle:()=>be(ke.id),"aria-label":`Select item ${ke.id}`}),o.jsx(xe.RowButton,{flushLeft:!0,colStart:2,featured:Ce,onClick:()=>me(ke.id),children:Ee})]},ke.id)})]})]}),ye&&o.jsx(fLt,{item:ye,isCompleted:w,tagVocabulary:Q,onRate:ke=>ee(ye.id,ke),onSetTags:ke=>{te(ye.id,ke);for(const _e of ke)Q.includes(_e)||V(_e)},onComment:ke=>J(ye.id,ke),onRemove:()=>ie(ye.id),onComplete:w?void 0:()=>ue(ye.id),onPrevious:Re,onNext:Qe,onClose:()=>h(null)})]})]})}function aXr({datasetId:e,onAddItemClick:t,onNavigateToDataset:n}){const{navigate:r}=vn(),[s,a]=Ei(),{tab:i,activeVersion:l,handleTabChange:c}=UEe(s,a),[u,d]=y.useState(!1),[f,p]=y.useState(!1),[h,m]=y.useState(!1),[g,v]=y.useState([]),[b,w]=y.useState(!1),[S,O]=y.useState([]),[_,C]=y.useState(!1),[j,E]=y.useState([]),[N,I]=y.useState(0),[P,$]=y.useState(null),[z,D]=y.useState(""),[q]=x0e(z,300),{data:W}=Lx(e),{data:L=[],total:F,isLoading:B,setEndOfListElement:M,isFetchingNextPage:Q,hasNextPage:V}=WO(e,q||void 0,l),{total:R}=WO(e,void 0,l),[U,Z]=y.useState({}),{data:X,isLoading:te}=gM(e,void 0,U),{data:ee}=gM(e),{deleteItems:J}=Fi(),ie=X?.experiments??[],ue=ee?.experiments??[],Y=_Yr({hasSearchQuery:!!q,filteredItemsLength:L.length,unfilteredItemsTotal:R,itemsTotal:F}),{data:ne}=qEe(e),le=ne?.length??0,pe=re=>{$(re)},se=()=>{$(null)},he=re=>{v(re),m(!0)},be=re=>{O(re),w(!0)},Se=re=>{w(re),re||(O([]),I(me=>me+1))},Ne=re=>{r(`/datasets/${e}/items?items=${re.join(",")}`)},Oe=re=>{r(`/datasets/${e}/versions?ids=${re.join(",")}`)},Ae=re=>{E(re),C(!0)},Ue=async()=>{await J.mutateAsync({datasetId:e,itemIds:j}),Be.success(`Deleted ${j.length} items`),C(!1),E([]),I(re=>re+1)},ce=re=>{m(!1),v([]),I(me=>me+1),n?.(re)},ae=re=>{m(re),re||(v([]),I(me=>me+1))};return o.jsxs(o.Fragment,{children:[o.jsxs(Nu,{defaultTab:"items",value:i,onValueChange:c,className:"grid grid-rows-[auto_1fr] h-full",children:[o.jsxs(Tu,{children:[o.jsxs(Xr,{value:"items",children:["Items ",o.jsx(Xs,{color:"gray",children:Y})]}),o.jsxs(Xr,{value:"experiments",children:["Experiments",o.jsx(Xs,{color:"gray",children:ie.length})]}),o.jsxs(Xr,{value:"review",children:["Review",le>0&&o.jsx(Xs,{color:"orange",children:le})]})]}),o.jsx(As,{value:"items",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(KYr,{datasetId:e,items:L,isLoading:B,featuredItemId:P,onItemSelect:pe,onItemClose:se,onAddClick:t??(()=>{}),onImportClick:()=>d(!0),onImportJsonClick:()=>p(!0),onBulkDeleteClick:Ae,onCreateDatasetClick:he,onAddToDatasetClick:be,onCompareItemsClick:Ne,datasetName:W?.name,clearSelectionTrigger:N,setEndOfListElement:M,isFetchingNextPage:Q,hasNextPage:V,searchQuery:z,activeSearchQuery:q,onSearchChange:D,currentDatasetVersion:W?.version,onCompareVersionsClick:Oe})}),o.jsx(As,{value:"experiments",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(BYr,{experiments:ie,allExperiments:ue,isLoading:te,datasetId:e,filters:U,onFiltersChange:Z})}),o.jsx(As,{value:"review",className:"overflow-auto mt-2 pb-0",children:o.jsx(ELt,{datasetId:e})})]}),o.jsx(RYr,{datasetId:e,open:u,onOpenChange:d}),o.jsx(nXr,{datasetId:e,open:f,onOpenChange:p}),o.jsx(hYr,{open:h,onOpenChange:ae,items:g,onSuccess:ce}),o.jsx(mYr,{open:b,onOpenChange:Se,items:S,currentDatasetId:e}),o.jsx(jt,{open:_,onOpenChange:C,children:o.jsxs(jt.Content,{children:[o.jsxs(jt.Header,{children:[o.jsx(jt.Title,{children:"Delete Items"}),o.jsxs(jt.Description,{children:["Are you sure you want to delete ",j.length," item",j.length!==1?"s":"","? This action cannot be undone."]})]}),o.jsxs(jt.Footer,{children:[o.jsx(jt.Cancel,{children:"Cancel"}),o.jsx(jt.Action,{onClick:Ue,children:J.isPending?"Deleting...":"Delete"})]})]})})]})}function iXr(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 AZe({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 oXr({datasetId:e,open:t,onOpenChange:n,onSuccess:r}){const[s,a]=y.useState("{}"),[i,l]=y.useState(""),[c,u]=y.useState(""),[d,f]=y.useState(""),[p,h]=y.useState(null),{addItem:m}=Fi(),g=async S=>{S.preventDefault();let O;try{O=JSON.parse(s)}catch{Be.error("Input must be valid JSON");return}let _;if(i.trim())try{_=JSON.parse(i)}catch{Be.error("Ground Truth must be valid JSON");return}let C;if(c.trim())try{C=JSON.parse(c)}catch{Be.error("Expected Trajectory must be valid JSON");return}let j;if(d.trim())try{j=JSON.parse(d)}catch{Be.error("Request Context must be valid JSON");return}try{await m.mutateAsync({datasetId:e,input:O,groundTruth:_,expectedTrajectory:C,requestContext:j}),Be.success("Item added successfully"),h(null),a("{}"),l(""),u(""),f(""),n(!1),r?.()}catch(E){const N=iXr(E);N?h(N):Be.error(`Failed to add item: ${E instanceof Error?E.message:"Unknown error"}`)}},v=S=>{a(S),p?.field==="input"&&h(null)},b=S=>{l(S),p?.field==="groundTruth"&&h(null)},w=()=>{a("{}"),l(""),u(""),f(""),h(null),n(!1)};return o.jsx(yr,{open:t,onOpenChange:n,children:o.jsxs(br,{className:"max-w-lg",children:[o.jsx(xr,{children:o.jsx(mr,{children:"Add Item"})}),o.jsx(Ar,{children:o.jsxs("form",{onSubmit:g,className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Mt,{htmlFor:"item-input",children:"Input (JSON) *"}),o.jsx(as,{value:s,onChange:v,showCopyButton:!1,className:"min-h-[120px]"}),p?.field==="input"&&o.jsx(AZe,{field:"input",errors:p.errors})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Mt,{htmlFor:"item-ground-truth",children:"Ground Truth (JSON, optional)"}),o.jsx(as,{value:i,onChange:b,showCopyButton:!1,className:"min-h-[80px]"}),p?.field==="groundTruth"&&o.jsx(AZe,{field:"groundTruth",errors:p.errors})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Mt,{htmlFor:"item-trajectory",children:"Expected Trajectory (JSON, optional)"}),o.jsx(as,{value:c,onChange:u,showCopyButton:!1,className:"min-h-[80px]"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Mt,{htmlFor:"item-request-context",children:"Request Context (JSON, optional)"}),o.jsx(as,{value:d,onChange:f,showCopyButton:!1,className:"min-h-[80px]"})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[o.jsx(fe,{type:"button",onClick:w,children:"Cancel"}),o.jsx(fe,{type:"submit",variant:"primary",disabled:m.isPending,children:m.isPending?"Adding...":"Add Item"})]})]})})]})})}function lXr({item:e}){return o.jsx(ca,{withMargins:!1,children:o.jsxs(ca.Column,{children:[o.jsxs(ca.Title,{size:"smaller",children:[o.jsx(ZT,{}),o.jsx("span",{className:"truncate",children:e.id}),o.jsx(xa,{content:e.id,tooltip:`Copy item ID: ${e.id}`})]}),o.jsxs(ca.Description,{children:[o.jsxs(dc,{children:[o.jsx(nit,{})," Created ",Kn(new Date(e.createdAt),"MMM d, yyyy h:mm aaa")]}),e.datasetVersion!=null&&o.jsxs(dc,{children:[o.jsx(KO,{})," Version v",e.datasetVersion]})]})]})})}function VEe({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(w0e,{children:[o.jsx(ga.CodeSection,{title:"Input",icon:o.jsx(Qk,{}),codeStr:t}),o.jsx(ga.CodeSection,{title:"Ground Truth",icon:o.jsx(tg,{}),codeStr:n}),s&&o.jsx(ga.CodeSection,{title:"Expected Trajectory",icon:o.jsx(_it,{}),codeStr:s}),o.jsx(ga.CodeSection,{title:"Metadata",icon:o.jsx(YT,{}),codeStr:r})]})}function cXr({selectedScorers:e,setSelectedScorers:t,disabled:n=!1,container:r}){const{data:s,isLoading:a}=Zp(),i=y.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(Mt,{children:"Scorers (Optional)"}),o.jsx(Xmt,{options:i,value:e,onValueChange:t,placeholder:"Select scorers...",searchPlaceholder:"Search scorers...",emptyText:"No scorers available",disabled:n||a,container:r})]})}const uXr=[{value:"agent",label:"Agent"},{value:"workflow",label:"Workflow"},{value:"scorer",label:"Scorer"}];function dXr({targetType:e,setTargetType:t,targetId:n,setTargetId:r,container:s}){const{data:a,isLoading:i}=cm(),{data:l,isLoading:c}=Cy(),{data:u,isLoading:d}=Zp(),f=e==="agent"?Object.entries(a??{}).map(([g,v])=>({value:g,label:v.name??g})):e==="workflow"?Object.entries(l??{}).map(([g,v])=>({value:g,label:v.name??g})):e==="scorer"?Object.entries(u??{}).map(([g,v])=>({value:g,label:v.scorer?.config?.name??g})):[],p=e==="agent"&&i||e==="workflow"&&c||e==="scorer"&&d,h=g=>{t(g),r("")},m=e==="agent"?"Agent":e==="workflow"?"Workflow":"Scorer";return o.jsxs("div",{className:"grid gap-6",children:[o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Mt,{children:"Target Type"}),o.jsx(Wc,{options:uXr,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(Mt,{children:m}),o.jsx(Wc,{options:f,value:n,onValueChange:r,placeholder:`Select ${e}`,searchPlaceholder:"Search...",emptyText:"No targets available",disabled:p,container:s})]})]})}function fXr({requestContextSchema:e,onChange:t}){const n=y.useMemo(()=>{try{return Yh(Gh(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(Mt,{children:"Request Context"}),o.jsx(uD,{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 pXr({datasetId:e,version:t,requestContextSchema:n,open:r,onOpenChange:s,onSuccess:a}){const i=y.useRef(null),[l,c]=y.useState(""),[u,d]=y.useState(""),[f,p]=y.useState([]),[h,m]=y.useState({}),[g,v]=y.useState(""),{triggerExperiment:b}=Fi(),w=!!(n&&Object.keys(n).length>0),S=l&&u,O=b.isPending,_=()=>{c(""),d(""),p([]),m({}),v("")},C=()=>{if(w){const N=Object.entries(h).filter(([,I])=>I!==void 0&&I!=="");return N.length>0?Object.fromEntries(N):void 0}if(g.trim()){let N;try{N=JSON.parse(g)}catch{throw new Error("Request Context must be valid JSON")}if(!N||typeof N!="object"||Array.isArray(N))throw new Error("Request Context must be a JSON object");return N}},j=async()=>{if(!S)return;let N;try{N=C()}catch(I){const P=I instanceof Error?I.message:"Request Context must be valid JSON";bu.error(P);return}try{const I=await b.mutateAsync({datasetId:e,targetType:l,targetId:u,scorerIds:f.length>0?f:void 0,version:t,requestContext:N});bu.success("Experiment triggered successfully"),s(!1),a?.(I.experimentId),_()}catch(I){const P=I instanceof Error?I.message:"Failed to trigger experiment";bu.error(P)}},E=()=>{O||(s(!1),_())};return o.jsx(yr,{open:r,onOpenChange:E,children:o.jsxs(br,{ref:i,children:[o.jsxs(xr,{children:[o.jsx(mr,{children:"Run Experiment"}),o.jsx(Qs,{children:t?`Execute items from ${Kn(new Date(t),"MMM d, yyyy")} version against a target.`:"Execute all items in this dataset against a target."})]}),o.jsxs(Ar,{className:"grid gap-6",children:[o.jsx(dXr,{targetType:l,setTargetType:c,targetId:u,setTargetId:d,container:i}),l&&l!=="scorer"&&o.jsx(cXr,{selectedScorers:f,setSelectedScorers:p,disabled:O,container:i}),w?o.jsx(fXr,{requestContextSchema:n,onChange:m}):o.jsxs("div",{className:"space-y-2",children:[o.jsx(Mt,{children:"Request Context (JSON, optional)"}),o.jsx(as,{value:g,onChange:v,showCopyButton:!1,className:"min-h-[80px]"})]})]}),o.jsxs(mc,{className:"px-6 pt-4",children:[o.jsx(fe,{onClick:E,disabled:O,children:"Cancel"}),o.jsx(fe,{variant:"primary",onClick:j,disabled:!S||O,children:O?o.jsxs(o.Fragment,{children:[o.jsx(Qt,{className:"w-4 h-4"}),"Running..."]}):"Run"})]})]})})}const hXr=e=>{const t=We();return xt({queryKey:["experiment-trace-light",e],queryFn:async()=>{if(!e)throw new Error("Trace ID is required");return t.getTraceLight(e)},enabled:!!e})};function mXr({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]=y.useState(!1),m=d??p,g=f??h,v=!!e?.error,b=u8(e?.input),w=u8(e?.output),S=u8(e?.groundTruth),O=u&&e.status!=="needs-review"&&e.status!=="complete",_=Array.isArray(e.tags)?e.tags:[];return o.jsxs(kn,{collapsed:m,children:[o.jsxs(kn.Header,{children:[o.jsxs(kn.Heading,{children:["Result ",o.jsxs("b",{children:["# ",e.id.length>12?`${e.id.slice(0,12)}…`:e.id]})]}),o.jsxs($r,{className:"ml-auto shrink-0",children:[f&&o.jsx(fe,{size:"md",tooltip:m?"Expand panel":"Collapse panel",onClick:()=>g(!m),children:m?o.jsx(iit,{}):o.jsx(ait,{})}),o.jsx(kn.NextPrevNav,{onPrevious:n,onNext:r,previousLabel:"Previous result",nextLabel:"Next result"}),o.jsxs(fe,{size:"md",onClick:a,disabled:!e.traceId,children:[o.jsx(MSe,{}),"Trace"]}),o.jsx(kn.CloseButton,{onClick:s,tooltip:"Close result panel"})]})]}),!m&&o.jsxs(kn.Content,{children:[o.jsxs("div",{className:"grid gap-4 mb-6",children:[o.jsxs(zt,{children:[o.jsx(zt.Key,{children:"Item Id"}),o.jsx(zt.ValueWithCopyBtn,{copyTooltip:"Copy Item Id to clipboard",copyValue:e.itemId,children:e.itemId}),o.jsx(zt.Key,{children:"Created"}),o.jsx(zt.Value,{children:Kn(new Date(e.createdAt),"MMM d, yyyy 'at' h:mm a")})]}),v&&o.jsx(Rn,{variant:"destructive",title:"Error",children:o.jsx(Rn.Message,{children:u8(e?.error&&typeof e.error=="object"?e.error.message:e?.error)})}),t&&t.length>0&&o.jsxs(xe,{columns:"1fr 1fr",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Scorer"}),o.jsx(xe.TopCell,{children:"Score"})]}),t.map(C=>o.jsxs(xe.RowButton,{featured:c===C.id,onClick:()=>l?.(C.id),children:[o.jsx(xe.Cell,{height:"compact",children:C.scorerId}),o.jsx(xe.MonoCell,{children:C.score.toFixed(3)})]},C.id))]}),(e.status||_.length>0||O)&&o.jsxs("div",{className:"grid gap-2",children:[o.jsx(kn.SectionHeading,{icon:o.jsx(YT,{}),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))]}),O&&o.jsx("div",{children:o.jsxs(fe,{size:"sm",onClick:()=>u(e.id),children:[o.jsx(aU,{}),"Flag for Review"]})}),e.status==="needs-review"&&i&&o.jsx("div",{children:o.jsxs(fe,{size:"sm",onClick:i,children:[o.jsx(Ta,{}),"Review"]})})]})]}),o.jsxs("div",{className:"grid gap-3",children:[o.jsx(kn.CodeSection,{title:"Input",icon:o.jsx(ZT,{}),codeStr:b}),o.jsx(kn.CodeSection,{title:"Output",icon:o.jsx(tg,{}),codeStr:w}),o.jsx(kn.CodeSection,{title:"Ground Truth",icon:o.jsx(Fve,{}),codeStr:S})]})]})]})}function u8(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function gXr({results:e,isLoading:t,featuredResultId:n,onResultClick:r,columns:s,scoresByItemId:a,scorerIds:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u,selectedIds:d,onToggleSelect:f}){const p=!!(d&&f),h=[p?"auto":"",...s.map(g=>g.size)].filter(Boolean).join(" "),m=s.some(g=>g.name==="input");return t?o.jsx(Go,{columns:h}):o.jsxs(xe,{columns:h,className:"min-w-0",children:[o.jsxs(xe.Top,{hasLeadingCell:p,children:[p&&o.jsx(xe.TopCell,{children:" "}),p?o.jsx(xe.TopCells,{colStart:2,children:s.map(g=>o.jsx(xe.TopCell,{children:g.label},g.name))}):s.map(g=>o.jsx(xe.TopCell,{children:g.label},g.name))]}),e.length===0?o.jsx(xe.NoMatch,{message:"No results yet"}):o.jsxs(o.Fragment,{children:[e.map(g=>{const v=!!g.error,b=g.id===n,w=o.jsxs(o.Fragment,{children:[o.jsx(xe.IdCell,{id:g.itemId}),o.jsx(xe.Cell,{height:"compact",children:o.jsxs(Hn,{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":v?"Error":"Success",className:K("w-2 h-2 rounded-full",v?"bg-red-700":"bg-green-600")})})}),o.jsx(Bn,{children:v?"Error":"Success"})]})}),m&&o.jsx(xe.MonoCell,{children:yXr(vXr(g.input),200)}),i?.map(S=>{const _=a?.[g.itemId]?.find(C=>C.scorerId===S);return o.jsx(xe.Cell,{height:"compact",className:"font-mono text-neutral3 text-ui-smd",children:_!=null?_.score.toFixed(3):"-"},S)})]});return p?o.jsxs(xe.RowWrapper,{children:[o.jsx(xe.SelectCell,{checked:d.has(g.id),onToggle:()=>f(g.id),"aria-label":`Select result ${g.itemId}`}),o.jsx(xe.RowButton,{flushLeft:!0,colStart:2,featured:b,onClick:()=>r(g.id),children:w})]},g.id):o.jsx(xe.RowButton,{featured:b,onClick:()=>r(g.id),children:w},g.id)}),o.jsx(xe.NextPageLoading,{isLoading:c,hasMore:u,setEndOfListElement:l})]})]})}function vXr(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function yXr(e,t){return e.length<=t?e:e.slice(0,t-1)+"..."}function bXr(e){const t=e.scorer;return t?.hasJudge===!1?!0:t?.hasJudge===!0?!1:!e.preprocessPrompt&&!e.analyzePrompt&&!e.generateScorePrompt&&!e.generateReasonPrompt}function xXr({score:e,onNext:t,onPrevious:n,onClose:r,onShowTrace:s,collapsed:a,onCollapsedChange:i}){const[l,c]=y.useState(!1),u=a??l,d=i??c,f=bXr(e),p=f?"N/A — code-based scorer":"N/A — step not configured";return o.jsxs(kn,{collapsed:u,children:[o.jsxs(kn.Header,{children:[o.jsxs(kn.Heading,{children:["Score ",o.jsx("b",{children:e.scorerId})]}),o.jsxs($r,{className:"ml-auto shrink-0",children:[i&&o.jsx(fe,{size:"md",tooltip:u?"Expand panel":"Collapse panel",onClick:()=>d(!u),children:u?o.jsx(iit,{}):o.jsx(ait,{})}),(n||t)&&o.jsx(kn.NextPrevNav,{onPrevious:n,onNext:t,previousLabel:"Previous score",nextLabel:"Next score"}),s&&o.jsxs(fe,{size:"md",onClick:s,disabled:!e.traceId,children:[o.jsx(MSe,{}),"Trace"]}),o.jsx(kn.CloseButton,{onClick:r,tooltip:"Close score panel"})]})]}),!u&&o.jsx(kn.Content,{children:o.jsxs("div",{className:"grid gap-3",children:[o.jsx(kn.CodeSection,{title:`Score: ${e.score}`,icon:o.jsx(ig,{}),codeStr:e.reason||p,simplified:!0}),!f&&o.jsxs(o.Fragment,{children:[o.jsx(kn.CodeSection,{title:"Preprocess Prompt",icon:o.jsx(uh,{}),codeStr:e.preprocessPrompt||p,simplified:!0}),o.jsx(kn.CodeSection,{title:"Analyze Prompt",icon:o.jsx(uh,{}),codeStr:e.analyzePrompt||p,simplified:!0}),o.jsx(kn.CodeSection,{title:"Generate Score Prompt",icon:o.jsx(uh,{}),codeStr:e.generateScorePrompt||p,simplified:!0}),o.jsx(kn.CodeSection,{title:"Generate Reason Prompt",icon:o.jsx(uh,{}),codeStr:e.generateReasonPrompt||p,simplified:!0})]})]})})]})}const RZe=[{name:"scorer",label:"Scorer",size:"1fr"},{name:"avg",label:"Avg Score",size:"1fr"},{name:"count",label:"Items Scored",size:"1fr"}];function wXr({scoresByItemId:e,experimentStatus:t}){const n=y.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(Wr,{iconSlot:o.jsx(ig,{className:"w-8 h-8 text-neutral3"}),titleSlot:a,descriptionSlot:i})})}return o.jsxs(hn,{children:[o.jsxs(hn.Header,{columns:RZe,children:[o.jsx(hn.HeaderCol,{children:"Scorer"}),o.jsx(hn.HeaderCol,{children:"Avg Score"}),o.jsx(hn.HeaderCol,{children:"Items Scored"})]}),o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:n.map(({scorerId:r,avg:s,count:a})=>o.jsxs(hn.Row,{columns:RZe,children:[o.jsx(hn.TextCell,{children:r}),o.jsx(hn.TextCell,{className:"font-mono",children:s.toFixed(3)}),o.jsx(hn.TextCell,{className:"font-mono",children:a})]},r))})})]})}function jLt({experimentId:e,datasetId:t,experimentStatus:n,results:r,isLoading:s,setEndOfListElement:a,isFetchingNextPage:i,hasNextPage:l}){const[c,u]=y.useState(null),[d,f]=y.useState(null),[p,h]=y.useState(void 0),[m,g]=y.useState(null),[v,b]=y.useState(new Set),[w,S]=y.useState(!1),[O,_]=y.useState(!1),[C,j]=y.useState(!1),[E,N]=y.useState(!1),{updateExperimentResult:I}=Fi(),P=y.useCallback(ae=>{b(re=>{const me=new Set(re);return me.has(ae)?me.delete(ae):me.add(ae),me})},[]),$=y.useCallback(()=>b(new Set),[]),z=y.useCallback(()=>{const ae=r.filter(re=>!!re.error).map(re=>re.id);b(new Set(ae))},[r]),D=y.useCallback(async ae=>{if(w||ae.length===0)return;S(!0);let re=0;const me=new Set;try{for(const ye of ae)try{await I.mutateAsync({datasetId:t,experimentId:e,resultId:ye,status:"needs-review"}),re++,me.add(ye)}catch{}}finally{S(!1)}me.size>0&&b(ye=>{const je=new Set(ye);for(const Re of me)je.delete(Re);return je}),re>0&&Be(`${re} result${re>1?"s":""} flagged for review`)},[t,e,w,I]),q=r.find(ae=>ae.id===c)??null,[W,L]=y.useState("summary"),[F,B]=y.useState(null),M=ae=>{L(ae),ae!=="reviews"&&B(null)},{data:Q}=qEe(t),V=(Q??[]).filter(ae=>ae.experimentId===e).length,{data:R}=lLt(e,n),U=y.useMemo(()=>{if(!R)return[];const ae=new Set;for(const re of Object.values(R))for(const me of re)ae.add(me.scorerId);return[...ae].sort()},[R]),Z=ae=>{u(ae),f(null),h(void 0),g(null)},X=ae=>{Z(ae===c?null:ae)},te=()=>{Z(null)},ee=()=>{if(!q)return;const ae=r.findIndex(re=>re.id===q.id);if(ae>=0&&ae<r.length-1)return()=>Z(r[ae+1].id)},J=()=>{if(!q)return;const ae=r.findIndex(re=>re.id===q.id);if(ae>0)return()=>Z(r[ae-1].id)},ie=q?R?.[q.itemId]:void 0,ue=ie?.find(ae=>ae.id===m)??null,Y=ae=>{g(ae===m?null:ae),f(null),h(void 0)},ne=()=>{if(!m||!ie)return;const ae=ie.findIndex(re=>re.id===m);if(ae>=0&&ae<ie.length-1)return()=>g(ie[ae+1].id)},le=()=>{if(!m||!ie)return;const ae=ie.findIndex(re=>re.id===m);if(ae>0)return()=>g(ie[ae-1].id)},{data:pe,isLoading:se}=hXr(d),he=pe?.spans,{data:be,isLoading:Se}=rD(d,p),Ne=be?.span,{handlePreviousSpan:Oe,handleNextSpan:Ae}=JSe(he,p??null,h),Ue=(()=>{const ae=[],re=!!ue,me=!!d;return ae.push(O?"auto":re||me?"2fr":"1fr"),re&&ae.push(E?"auto":"3fr"),me&&ae.push(C?"auto":"3fr"),me&&p&&ae.push("3fr"),ae.join(" ")})(),ce=y.useMemo(()=>[{name:"itemId",label:"Item ID",size:"7rem"},{name:"status",label:"Status",size:"5rem"},{name:"input",label:"Input",size:"minmax(15rem,1fr)"},...U.map(ae=>({name:ae,label:ae,size:"12rem"}))],[U]);return o.jsxs(Nu,{defaultTab:"summary",value:W,onValueChange:M,className:"grid grid-rows-[auto_1fr] h-full overflow-hidden",children:[o.jsxs(Tu,{children:[o.jsx(Xr,{value:"summary",children:"Summary"}),o.jsx(Xr,{value:"results",children:"Results"}),o.jsxs(Xr,{value:"reviews",children:["Reviews",V>0&&o.jsx(Xs,{color:"orange",children:V})]})]}),o.jsx(As,{value:"summary",className:"overflow-y-auto mt-5",children:o.jsx(wXr,{scoresByItemId:R,experimentStatus:n})}),o.jsx(As,{value:"reviews",className:"overflow-auto mt-2 pb-0",children:o.jsx(ELt,{datasetId:t,experimentId:e,featuredItemId:F})}),o.jsxs(As,{value:"results",className:"grid grid-rows-[auto_1fr] overflow-hidden mt-2",children:[o.jsxs("div",{className:"mb-4",children:[v.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:[v.size," selected"]}),o.jsx("div",{className:"flex-1"}),o.jsxs(fe,{variant:"outline",size:"sm",disabled:w,onClick:()=>D([...v]),children:[o.jsx(Ve,{size:"sm",children:o.jsx(aU,{})}),"Flag for Review"]}),o.jsx(fe,{variant:"ghost",size:"sm",onClick:$,children:"Clear"})]}),r.length>0&&v.size===0&&!s&&o.jsx("div",{className:"flex items-center gap-2 px-4 py-2",children:o.jsx(fe,{variant:"ghost",size:"sm",onClick:z,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(gXr,{results:r,isLoading:s,featuredResultId:c,onResultClick:X,columns:ce,scoresByItemId:R,scorerIds:U,setEndOfListElement:a,isFetchingNextPage:i,hasNextPage:l,selectedIds:v,onToggleSelect:P})})}),q&&o.jsxs("div",{className:"grid gap-4 max-h-full min-h-0 overflow-auto content-start",style:{gridTemplateRows:Ue},children:[o.jsx(mXr,{result:q,scores:ie,onPrevious:J(),onNext:ee(),onClose:te,onScoreClick:Y,featuredScoreId:m,onShowTrace:()=>{q.traceId&&(f(q.traceId),h(void 0),g(null),_(!0),j(!1))},onOpenInReview:()=>{B(q.id),L("reviews")},onFlagForReview:ae=>D([ae]),collapsed:O,onCollapsedChange:_}),ue&&o.jsx(xXr,{score:ue,onNext:ne(),onPrevious:le(),onClose:()=>g(null),onShowTrace:()=>{ue.traceId&&(f(ue.traceId),h(void 0),_(!0),N(!0),j(!1))},collapsed:E,onCollapsedChange:N}),d&&o.jsxs(o.Fragment,{children:[o.jsx(WSe,{traceId:d,spans:he,isLoading:se,onClose:()=>{f(null),h(void 0),_(!1),N(!1)},onSpanSelect:h,initialSpanId:p??null,placement:"traces-list",showUnavailableFeaturesMsg:!1,collapsed:C,onCollapsedChange:j,LinkComponent:sD,traceHref:`/traces/${d}`}),p&&o.jsx(ZSe,{traceId:d,spanId:p,span:Ne,isLoading:Se,onPrevious:Oe,onNext:Ae,onClose:()=>h(void 0)})]})]})]})]})]})}const SXr={pending:o.jsx(Gk,{}),running:o.jsx(Iue,{}),completed:o.jsx(oa,{}),failed:o.jsx(gs,{})};function kXr({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:SXr[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 OXr({onPrevious:e,onNext:t,previousAriaLabel:n="Previous",nextAriaLabel:r="Next"}){return o.jsxs($r,{spacing:"close",children:[o.jsxs(fe,{onClick:e,disabled:!e,"aria-label":n,children:[o.jsx(nq,{})," Prev"]}),o.jsxs(fe,{onClick:t,disabled:!t,"aria-label":r,children:["Next",o.jsx(tq,{})]})]})}function HEe({delta:e}){const t=e>0?o.jsx(Xs,{size:"small",color:"green",intensity:"muted",children:o.jsx(jM,{})}):e<0?o.jsx(Xs,{size:"small",color:"red",intensity:"muted",children:o.jsx(man,{})}):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 d8(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function _Xr({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(Hr,{withLeftSeparator:!0,children:[o.jsxs(Hr.Toolbar,{children:[o.jsx(OXr,{onPrevious:a,onNext:i,previousAriaLabel:"Previous comparison item",nextAriaLabel:"Next comparison item"}),o.jsx($r,{children:o.jsx(fe,{onClick:l,"aria-label":"Close comparison detail panel",children:o.jsx(gs,{})})})]}),o.jsxs(Hr.Content,{className:"pb-6",children:[o.jsx(ca,{withMargins:!1,children:o.jsx(ca.Column,{children:o.jsxs(ca.Title,{size:"smaller",children:[o.jsx(ZT,{})," ",e.itemId]})})}),d?o.jsx(o.Fragment,{children:o.jsxs(w0e,{children:[p.length>0&&o.jsxs("div",{className:"grid gap-3",children:[o.jsx("h4",{className:"text-sm font-medium text-neutral5",children:"Scores"}),o.jsx("div",{className:"grid gap-2",children:p.map(h=>{const m=c?.scores[h]??null,g=u?.scores[h]??null,v=m!=null&&g!=null?g-m:null;return o.jsxs("div",{className:"flex items-center justify-between gap-4 px-3 py-2 rounded-lg bg-surface2",children:[o.jsx("span",{className:"text-sm text-neutral5 font-medium",children:h}),o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("span",{className:"text-sm text-neutral3",children:[m!=null?m.toFixed(3):"-"," →"," ",g!=null?g.toFixed(3):"-"]}),v!=null&&o.jsx(HEe,{delta:v})]})]},h)})})]}),o.jsx(ga.CodeSection,{title:o.jsxs(o.Fragment,{children:[o.jsx(Xs,{color:"purple",children:"Baseline "})," Experiment Output"]}),icon:o.jsx(tg,{}),codeStr:d8(c?.output)}),o.jsx(ga.CodeSection,{title:o.jsxs(o.Fragment,{children:[o.jsx(Xs,{color:"cyan",children:"Contender "})," Experiment Output"]}),icon:o.jsx(tg,{}),codeStr:d8(u?.output)}),o.jsx(ga.CodeSection,{title:"Item Input",icon:o.jsx(Qk,{}),codeStr:d8(e.input)}),o.jsx(ga.CodeSection,{title:"Item Ground Truth",icon:o.jsx(Fve,{}),codeStr:d8(e.groundTruth)})]})}):o.jsx(Rn,{variant:"warning",title:"Comparison not available",children:o.jsx(Rn.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 CXr({items:e,baselineId:t,contenderId:n,scorerIds:r,featuredItemId:s,columns:a,onItemClick:i}){return o.jsx(Hr,{children:o.jsxs(hn,{children:[o.jsxs(hn.Header,{columns:a,children:[o.jsx(hn.HeaderCol,{children:"Item ID"}),!s&&r.map(l=>o.jsx(hn.HeaderCol,{className:"flex justify-center",children:l},l))]}),o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:e.map(l=>{const c=l.results[t],u=l.results[n],d=!!(c&&u);return o.jsx(hn.Row,{children:o.jsxs(hn.RowButton,{item:{id:l.itemId},columns:a,isFeatured:s===l.itemId,onClick:i,children:[o.jsx(hn.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(hn.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(HEe,{delta:m})]}):o.jsx("span",{className:"text-neutral1",children:"-"})},f)})})]})},l.itemId)})})})]})})}const EXr={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 PZe({datasetId:e,experiment:t,type:n}){const{Link:r}=vn(),{label:s,color:a,customStyle:i}=EXr[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(em,{})]}),o.jsx(fe,{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(xc,{})," ",s]})]}),o.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-ui-sm text-neutral3",children:[o.jsxs(dc,{children:[o.jsx(Fve,{})," ",t.targetType," / ",t.targetId]}),o.jsxs(dc,{children:[o.jsx($ve,{})," v",t.datasetVersion??"—"]}),l&&o.jsxs(dc,{children:[o.jsx(rit,{})," ",Kn(l,"MMM d, yyyy HH:mm")]})]})]})}function jXr({datasetId:e,experimentIdA:t,experimentIdB:n,onSwap:r}){const[s,a]=y.useState(null),{data:i,isLoading:l,error:c}=UQr(e,t,n),{data:u}=zB(e,t),{data:d}=zB(e,n),f=u&&d&&u.datasetVersion!==d.datasetVersion,p=y.useMemo(()=>{if(!i)return[];const j=new Set;for(const E of i.items)for(const N of Object.values(E.results))if(N)for(const I of Object.keys(N.scores))j.add(I);return[...j].sort()},[i]),h=y.useMemo(()=>{if(!i||p.length===0)return[];const j=i.baselineId,E=t===j?n:t;return p.map(N=>{let I=0,P=0,$=0,z=0;for(const L of i.items){const F=L.results[j]?.scores[N],B=L.results[E]?.scores[N];F!=null&&(I+=F,$++),B!=null&&(P+=B,z++)}const D=$>0?I/$:null,q=z>0?P/z:null,W=D!=null&&q!=null?q-D:null;return{scorerId:N,avgA:D,avgB:q,delta:W}})},[i,p,t,n]),m=[{name:"scorer",label:"Scorer",size:"1fr"},{name:"baselineAvg",label:"Baseline Avg",size:"1fr"},{name:"comparisonAvg",label:"Comparison Avg",size:"1fr"},{name:"delta",label:"Delta",size:"1fr"}],g=y.useMemo(()=>[{name:"itemId",label:"Item ID",size:"8rem"},...s?[]:p.map(j=>({name:j,label:j,size:"1fr"}))],[p,s]),v=i?.items.find(j=>j.itemId===s)??null,b=j=>{a(j===s?null:j)},w=()=>{a(null)},S=()=>{if(!i||!s)return;const j=i.items.findIndex(E=>E.itemId===s);if(j>=0&&j<i.items.length-1)return()=>a(i.items[j+1].itemId)},O=()=>{if(!i||!s)return;const j=i.items.findIndex(E=>E.itemId===s);if(j>0)return()=>a(i.items[j-1].itemId)};if(l)return o.jsx("div",{className:"flex items-center justify-center h-64",children:o.jsx(Qt,{})});if(c)return o.jsx(Rn,{variant:"warning",title:"Error loading comparison",children:o.jsx(Rn.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(PZe,{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(Hn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx(fe,{onClick:r,children:"VS"})}),o.jsx(Bn,{children:"Switch the order"})]})})}),o.jsx(PZe,{datasetId:e,experiment:d,type:"contender"})]}),f&&o.jsx(Rn,{variant:"warning",title:"Version mismatch",children:o.jsxs(Rn.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(hn,{children:[o.jsxs(hn.Header,{columns:m,children:[o.jsx(hn.HeaderCol,{children:"Scorer"}),o.jsx(hn.HeaderCol,{className:"flex justify-center",children:o.jsxs(b6e,{children:[o.jsx(Xs,{color:"purple",size:"small",intensity:"muted",children:"Baseline"}),o.jsx(Xs,{color:"purple",size:"small",children:"Avg"})]})}),o.jsx(hn.HeaderCol,{className:"flex justify-center",children:o.jsxs(b6e,{children:[o.jsx(Xs,{color:"cyan",size:"small",intensity:"muted",children:"Contender"}),o.jsx(Xs,{color:"cyan",size:"small",children:"Avg"})]})}),o.jsx(hn.HeaderCol,{className:"flex justify-center",children:"Delta"})]}),o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:h.map(({scorerId:j,avgA:E,avgB:N,delta:I})=>o.jsxs(hn.Row,{columns:m,children:[o.jsx(hn.TextCell,{children:j}),o.jsx(hn.TextCell,{className:"text-center font-mono",children:E!=null?E.toFixed(3):"-"}),o.jsx(hn.TextCell,{className:"text-center font-mono",children:N!=null?N.toFixed(3):"-"}),o.jsx(hn.TextCell,{className:"flex justify-center",children:I!=null?o.jsx(HEe,{delta:I}):"-"})]},j))})})]}),o.jsxs($v,{className:K({"grid-cols-[1fr_2fr]":!!v}),children:[o.jsx(CXr,{items:i.items,baselineId:_,contenderId:C,scorerIds:p,featuredItemId:s,columns:g,onItemClick:b}),!!v&&o.jsx(_Xr,{item:v,baselineId:_,contenderId:C,baselineVersion:u?.datasetVersion,contenderVersion:d?.datasetVersion,onPrevious:O(),onNext:S(),onClose:w})]})]})}function TXr({datasetId:e,itemId:t,onVersionSelect:n,onCompareVersionsClick:r,activeVersion:s}){const{data:a,isLoading:i}=BEe(e,t),[l,c]=y.useState(!1),[u,d]=y.useState(new Set),f=b=>{n?.(b)},p=b=>s==null?b.isLatest:b.datasetVersion===s,h=b=>{d(w=>{const S=new Set(w);if(S.has(b))S.delete(b);else if(S.size>=2){const[O]=Array.from(S);return new Set([O,b])}else S.add(b);return S})},m=()=>{c(!1),d(new Set)},g=()=>{c(!0)},v=()=>{u.size===2&&r?.([...u])};return o.jsxs(Hr,{className:"min-w-56",children:[l?o.jsx(Hr.Toolbar,{className:"grid justify-stretch gap-3 w-full",children:o.jsxs($r,{children:[o.jsx(fe,{onClick:m,children:"Cancel"}),o.jsx(fe,{variant:"primary",disabled:u.size!==2,onClick:v,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(Hr.Toolbar,{children:o.jsxs(fe,{onClick:g,className:"w-full",children:[o.jsx(Dw,{})," Compare Ver."]})})}),i?o.jsx(NXr,{}):o.jsxs(hn,{children:[o.jsx(hn.Header,{children:o.jsx(hn.HeaderCol,{children:"Item Version History"})}),o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:a?.map(b=>{const w=String(b.datasetVersion),S=typeof b.updatedAt=="string"?new Date(b.updatedAt):b.updatedAt;return o.jsxs(hn.Row,{isSelected:l&&u.has(w),children:[l&&o.jsx(hn.LabelCell,{children:o.jsx(Yo,{checked:u.has(w),disabled:b.isDeleted,onCheckedChange:()=>{},onClick:O=>{O.stopPropagation(),b.isDeleted||h(w)},"aria-label":`Select version ${b.datasetVersion}`})}),o.jsx(hn.RowButton,{item:b,columns:[{name:"version",label:"Item Version History",size:"1fr"}],isFeatured:p(b),onClick:()=>f(b),className:"py-2",children:o.jsx(hn.VersionCell,{version:b.datasetVersion,date:S,isLatest:b.isLatest,isDeleted:b.isDeleted})})]},String(b.datasetVersion))})})})]})]})}function NXr(){return o.jsxs(hn,{children:[o.jsx(hn.Header,{columns:[{name:"version",label:"Item Version History",size:"1fr"}],children:o.jsx(hn.HeaderCol,{children:"Item Version History"})}),o.jsx(hn.Items,{children:Array.from({length:3}).map((e,t)=>o.jsx(hn.Row,{children:o.jsx(hn.RowButton,{columns:[{name:"version",label:"Item Version History",size:"1fr"}],children:o.jsx(hn.TextCell,{isLoading:!0,children:"Loading..."})})},t))})]})}function IXr(e,t){if(t){const n=typeof t=="string"?new Date(t):t;return`v${e} ${Kn(n,"MMM dd 'at' H:mm:ss a")}`}return`v${e}`}function AXr({datasetId:e,versionA:t,versionB:n,onVersionChange:r}){const{data:s}=LEe(e),a=(s??[]).map(i=>({value:String(i.version),label:`${IXr(i.version,i.createdAt)}${i.isCurrent?" (current)":""}`}));return o.jsxs(Hr.Toolbar,{className:"grid grid-cols-[1fr_1fr_1fr_10rem] gap-4 w-full",children:[o.jsx("div",{}),o.jsx(uc,{label:"Version A",labelIsHidden:!0,name:"version-a",placeholder:"Select version",options:a,value:t??"",onValueChange:i=>r?.(i,n??"")}),o.jsx(uc,{label:"Version B",labelIsHidden:!0,name:"version-b",options:a,value:n??"",onValueChange:i=>r?.(t??"",i)}),o.jsx("div",{})]})}const RXr=[{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"}],PXr={added:{color:"blue",borderColor:"border-blue-900",icon:o.jsx(Lr,{}),tooltip:"Added in this version"},changed:{color:"orange",borderColor:"border-yellow-900",icon:o.jsx(Sit,{}),tooltip:"Changed in this version"},same:{color:"green",borderColor:"border-green-900",icon:o.jsx(Din,{}),tooltip:"Same in both versions"}};function Jne({red:e=!1,tooltip:t}){return o.jsxs(Hn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx(_an,{className:K("text-neutral3/40 w-5 h-5 ",{"text-red-900":e})})}),t&&o.jsx(Bn,{children:t})]})}function AS({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}=PXr[e];return o.jsxs(Hn,{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 $Xr(e,t){return e&&t&&e.datasetVersion===t.datasetVersion?"same":e&&t&&e.datasetVersion!==t.datasetVersion?"changed":e?"added":"removed"}function MXr({datasetId:e,versionA:t,versionB:n,allItems:r,itemsAMap:s,itemsBMap:a}){const{Link:i}=vn(),l=t>n;return o.jsx(hn,{children:o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:r.map(({id:c})=>{const u=s.get(c),d=a.get(c),f=$Xr(u,d);return o.jsxs(hn.Row,{columns:RXr,children:[o.jsx(hn.IdCell,{id:c,isShortened:!1}),f!=="same"?o.jsxs(o.Fragment,{children:[u?.datasetVersion?o.jsx(hn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}`,className:"gap-2",children:!d&&l?o.jsx(AS,{variant:"added",version:u.datasetVersion}):f==="changed"&&l?o.jsx(AS,{variant:"changed",version:u.datasetVersion}):o.jsx(AS,{version:u.datasetVersion})}):o.jsx(hn.Cell,{className:"justify-center flex items-center",children:o.jsx(Jne,{red:l,tooltip:l?"Deleted in this version":"Not present in this version"})}),d?.datasetVersion?o.jsx(hn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}`,className:"gap-2",children:!u&&!l?o.jsx(AS,{variant:"added",version:d.datasetVersion}):f==="changed"&&!l?o.jsx(AS,{variant:"changed",version:d.datasetVersion}):o.jsx(AS,{version:d.datasetVersion})}):o.jsx(hn.Cell,{className:"justify-center flex items-center",children:o.jsx(Jne,{red:!l,tooltip:l?"Not present in this version":"Deleted in this version"})})]}):o.jsx(hn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}`,className:"col-span-2 gap-2",children:o.jsx(AS,{variant:"same",version:d?.datasetVersion})}),f==="changed"?o.jsx(hn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}/versions?ids=${u?.datasetVersion},${d?.datasetVersion}`,children:"Compare"}):o.jsx(hn.Cell,{children:o.jsx(Jne,{tooltip:o.jsxs(o.Fragment,{children:["Comparing is available",o.jsx("br",{})," only for changed items"]})})})]},c)})})})})}const $Ze={needsReview:"#facc15",complete:"#22c55e"},DXr=[{label:"Needs Review",color:$Ze.needsReview},{label:"Reviewed",color:$Ze.complete}];function LXr({reviewSummary:e,experiments:t,datasets:n,isLoading:r,isError:s}){const{data:a,maxVal:i,totalInPipeline:l}=y.useMemo(()=>{if(!e?.counts||!t)return{data:[],maxVal:0,totalInPipeline:0};const u=new Map;for(const m of t)u.set(m.id,m);const d=new Map;if(n)for(const m of n)d.set(m.id,m.name);let f=0,p=0;const h=[];for(const m of e.counts){const g=m.needsReview+m.complete;if(g===0)continue;p+=g,g>f&&(f=g);const v=u.get(m.experimentId),b=v?.datasetId?d.get(v.datasetId):void 0,w=b?`${b} · ${m.experimentId.slice(0,8)}`:m.experimentId.slice(0,8);h.push({name:w,values:[m.needsReview,m.complete]})}return{data:h,maxVal:f,totalInPipeline:p}},[e,t,n]),c=a.length>0;return o.jsxs(Bt,{children:[o.jsxs(Bt.TopBar,{children:[o.jsx(Bt.TitleAndDescription,{title:"Review Pipeline",description:"Items in review across experiments."}),c&&o.jsx(Bt.Summary,{value:String(l),label:"Items in pipeline"})]}),r?o.jsx(Bt.Loading,{}):s?o.jsx(Bt.Error,{message:"Failed to load review data"}):o.jsx(Bt.Content,{children:c?o.jsx(rT,{data:a,segments:DXr,maxVal:i,fmt:u=>String(u)}):o.jsx(Bt.NoData,{message:"No items have been sent to review yet"})})]})}function WEe(){const e=We();return xt({queryKey:["experiment-review-summary"],queryFn:()=>e.getExperimentReviewSummary()})}function TLt(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 FXr(e,t){const n=new Map,r=TLt(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 zXr(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 BXr=10;function UXr(){const[e,t]=y.useState(!1),[n,r]=y.useState(""),[s,a]=y.useState("all"),[i,l]=y.useState("all"),[c,u]=y.useState("all"),[d,f]=y.useState(0),{data:p,isLoading:h,error:m}=wy({page:d,perPage:BXr}),{data:g,isLoading:v,error:b}=UW(),{data:w}=WEe(),S=y.useMemo(()=>p?.datasets??[],[p?.datasets]),O=p?.pagination?.hasMore??!1,_=y.useMemo(()=>g?.experiments??[],[g?.experiments]),C=y.useMemo(()=>iYr(S),[S]),j=y.useMemo(()=>FXr(w,_),[w,_]),E=h||v,N=m||b,I=()=>t(!0),P=y.useCallback(()=>f(B=>B+1),[]),$=y.useCallback(()=>f(B=>Math.max(0,B-1)),[]),z=y.useCallback(B=>{r(B),f(0)},[]),D=y.useCallback(B=>{a(B),f(0)},[]),q=y.useCallback(B=>{l(B),f(0)},[]),W=y.useCallback(B=>{u(B),f(0)},[]);if(N&&ms(N))return o.jsx(or,{children:o.jsx(Vs,{})});if(N&&vs(N))return o.jsx(or,{children:o.jsx($s,{resource:"datasets"})});if(N)return o.jsx(or,{children:o.jsx(Li,{title:"Failed to load datasets",message:N.message})});if(S.length===0&&!E&&d===0)return o.jsxs(o.Fragment,{children:[o.jsx(or,{children:o.jsx(dYr,{onCreateClick:I})}),o.jsx(Oge,{open:e,onOpenChange:t})]});const L=s!=="all"||i!=="all"||c!=="all"||n!=="",F=()=>{r(""),a("all"),l("all"),u("all"),f(0)};return o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx(pYr,{search:n,onSearchChange:z,targetFilter:s,onTargetFilterChange:D,experimentFilter:i,onExperimentFilterChange:q,tagFilter:c,onTagFilterChange:W,tagOptions:C,onReset:F,hasActiveFilters:L,onCreateClick:I})}),o.jsx(uYr,{datasets:S,experiments:_,reviewByDataset:j,isLoading:E,search:n,targetFilter:s,experimentFilter:i,tagFilter:c,currentPage:d,hasMore:O,onNextPage:P,onPrevPage:$}),o.jsx(Oge,{open:e,onOpenChange:t})]})}function f8({children:e}){return o.jsxs(Lt,{height:"full",children:[o.jsx("div",{}),o.jsx(Lt.MainArea,{isCentered:!0,children:e})]})}function qXr(){const{datasetId:e}=wr(),t=qs(),[n,r]=Ei(),{activeVersion:s}=UEe(n,r),[a,i]=y.useState(!1),[l,c]=y.useState(!1),[u,d]=y.useState(!1),[f,p]=y.useState(!1),[h,m]=y.useState(!1),{data:g,error:v,isLoading:b}=Lx(e),{data:w=[],isLoading:S}=WO(e,void 0,s),O=!S&&w.length===0;if(b)return null;if(v&&ms(v))return o.jsx(f8,{children:o.jsx(Vs,{})});if(v&&vs(v))return o.jsx(f8,{children:o.jsx($s,{resource:"datasets"})});if(v&&DSe(v)||!b&&!v&&!g)return o.jsx(f8,{children:o.jsx(Wr,{iconSlot:o.jsx(Uv,{}),titleSlot:"Dataset not found",descriptionSlot:`No dataset with id "${e}".`,actionSlot:o.jsxs(fe,{as:ui,to:"/datasets",children:[o.jsx(xc,{}),"Back to Datasets"]})})});if(v)return o.jsx(f8,{children:o.jsx(Li,{title:"Failed to load dataset",message:v instanceof Error?v.message:"An unexpected error occurred. Please try again."})});const _=j=>{t(`/datasets/${e}/experiments/${j}`)},C=()=>{t("/datasets")};return o.jsxs(o.Fragment,{children:[o.jsxs(Lt,{height:"full",children:[o.jsx(Lt.TopArea,{children:o.jsxs(Lt.Row,{children:[o.jsxs(Lt.Column,{children:[g?.description&&o.jsx("p",{className:"text-ui-smd text-neutral3 mb-1",children:g.description}),o.jsxs(zt,{numOfCol:2,children:[o.jsx(zt.Key,{children:"Created at"}),o.jsx(zt.Value,{children:g?.createdAt?Kn(new Date(g.createdAt),"MMM d, yyyy"):""}),o.jsx(zt.Key,{children:"Latest version"}),o.jsxs(zt.Value,{children:["v",g?.version??""]})]})]}),o.jsx(Lt.Column,{children:o.jsxs($r,{children:[O?o.jsxs(Hn,{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(fe,{variant:"primary",children:[o.jsx(Uh,{}),s!=null?`Run on v${s}`:"Run Experiment"]})})})}),o.jsx(Bn,{children:"Add items to the dataset before running an experiment"})]}):o.jsxs(fe,{variant:"primary",onClick:()=>i(!0),children:[o.jsx(Uh,{}),s!=null?`Run on v${s}`:"Run Experiment"]}),o.jsxs(ft,{children:[o.jsx(ft.Trigger,{asChild:!0,children:o.jsx(fe,{size:"lg","aria-label":"Dataset actions menu",children:o.jsx(NM,{})})}),o.jsxs(ft.Content,{align:"end",className:"w-48",children:[o.jsxs(ft.Item,{onSelect:()=>d(!0),children:[o.jsx(Bh,{})," Edit Dataset"]}),o.jsxs(ft.Item,{onSelect:()=>m(!0),children:[o.jsx(Np,{})," Duplicate Dataset"]}),o.jsxs(ft.Item,{onSelect:()=>p(!0),className:"text-red-500 focus:text-red-400",children:[o.jsx(Zc,{})," Delete Dataset"]})]})]})]})})]})}),o.jsx(Lt.MainArea,{children:o.jsx(aXr,{datasetId:e,onAddItemClick:()=>c(!0)})})]}),o.jsx(pXr,{datasetId:e,version:s??void 0,requestContextSchema:g?.requestContextSchema,open:a,onOpenChange:i,onSuccess:_}),o.jsx(oXr,{datasetId:e,open:l,onOpenChange:c}),g&&o.jsx(bYr,{open:u,onOpenChange:d,dataset:{id:g.id,name:g.name,description:g?.description||"",targetType:g.targetType,inputSchema:g.inputSchema,groundTruthSchema:g.groundTruthSchema,requestContextSchema:g.requestContextSchema}}),g&&o.jsx(gYr,{open:h,onOpenChange:m,sourceDatasetId:g.id,sourceDatasetName:g.name,sourceDatasetDescription:g.description,sourceDatasetTargetType:g.targetType}),g&&o.jsx(wYr,{open:f,onOpenChange:p,datasetId:g.id,datasetName:g.name,onSuccess:C})]})}function NLt({experiment:e}){const{Link:t,paths:n}=vn(),{data:r}=cm(),{data:s}=Cy(),{data:a}=Zp(),i=()=>{switch(e.targetType){case"agent":return n.agentLink(e.targetId);case"workflow":return n.workflowLink(e.targetId);case"scorer":return n.scorerLink(e.targetId);default:return"#"}},l=()=>{const u=e.targetId;if(!u)return u;switch(e.targetType){case"agent":return r?.[u]?.name??u;case"workflow":return s?.[u]?.name??u;case"scorer":return a?.[u]?.scorer?.config?.name??u;default:return u}},c=e.agentVersion&&e.targetType==="agent"&&e.targetId?`${n.agentLink(e.targetId)}/editor?version=${encodeURIComponent(e.agentVersion)}`:null;return o.jsx(Lt.TopArea,{children:o.jsxs(Lt.Row,{children:[o.jsx(Lt.Column,{children:o.jsxs(zt,{numOfCol:2,children:[o.jsx(zt.Key,{children:"Created at"}),o.jsx(zt.Value,{children:Kn(new Date(e.createdAt),"MMM d, yyyy 'at' h:mm a")}),e.completedAt&&o.jsxs(o.Fragment,{children:[o.jsx(zt.Key,{children:"Completed at"}),o.jsx(zt.Value,{children:Kn(new Date(e.completedAt),"MMM d, yyyy 'at' h:mm a")})]}),o.jsx(zt.Key,{children:"Target"}),o.jsx(zt.ValueLink,{href:i(),as:t,children:l()}),e.agentVersion&&o.jsxs(o.Fragment,{children:[o.jsx(zt.Key,{children:"Version"}),c?o.jsx(zt.ValueLink,{href:c,as:t,children:e.agentVersion}):o.jsx(zt.Value,{children:e.agentVersion})]})]})}),o.jsx(Lt.Column,{children:o.jsx(kXr,{experiment:e})})]})})}function p8({children:e}){return o.jsxs(Lt,{height:"full",children:[o.jsx("div",{}),o.jsx(Lt.MainArea,{isCentered:!0,children:e})]})}function VXr(){const{datasetId:e,experimentId:t}=wr(),{data:n,isLoading:r,error:s}=zB(e,t),{data:a,isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u}=FW({datasetId:e,experimentId:t,experimentStatus:n?.status});return!e||!t||r?null:s&&ms(s)?o.jsx(p8,{children:o.jsx(Vs,{})}):s&&vs(s)?o.jsx(p8,{children:o.jsx($s,{resource:"datasets"})}):s&&DSe(s)||!r&&!s&&!n?o.jsx(p8,{children:o.jsx(Wr,{iconSlot:o.jsx(Ave,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${t}".`,actionSlot:o.jsxs(fe,{as:ui,to:`/datasets/${e}?tab=experiments`,children:[o.jsx(xc,{}),"Back to Dataset"]})})}):s?o.jsx(p8,{children:o.jsx(Li,{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(NLt,{experiment:n}),o.jsx(Lt.MainArea,{children:o.jsx(jLt,{experimentId:t,datasetId:e,experimentStatus:n.status,results:a??[],isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u})})]})}function HXr(){const{datasetId:e}=wr(),[t,n]=Ei(),{error:r}=Lx(e??""),s=t.get("baseline")??"",a=t.get("contender")??"";return r&&ms(r)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):r&&vs(r)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx($s,{resource:"datasets"})})}):!e||!s||!a?o.jsx(ls,{children:o.jsx(Qv,{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(Qv,{children:o.jsxs("div",{className:"max-w-[100rem] w-full px-12 mx-auto grid content-start ",children:[o.jsxs(ca,{children:[o.jsxs(ca.Column,{children:[o.jsxs(ca.Title,{children:[o.jsx(Dw,{})," Dataset Experiments Comparison"]}),o.jsxs(ca.Description,{children:["Comparing"," ",o.jsx(ui,{to:`/datasets/${e}/experiments/${s}`,children:s.slice(0,8)})," vs"," ",o.jsx(ui,{to:`/datasets/${e}/experiments/${a}`,children:a.slice(0,8)})]})]}),o.jsx(ca.Column,{children:o.jsxs(fe,{as:ui,to:`/datasets/${e}`,children:[o.jsx(xc,{}),"Back to Dataset"]})})]}),o.jsx(jXr,{datasetId:e,experimentIdA:s,experimentIdB:a,onSwap:()=>{n({baseline:a,contender:s})}})]})})})}function WXr(){const{datasetId:e,itemId:t}=wr(),{Link:n}=vn(),r=qs(),{data:s,isLoading:a,error:i}=BEe(e??"",t??""),{updateItem:l,deleteItem:c}=Fi(),{data:u}=Lx(e??""),d=s?.[0]??null,f=d?.isDeleted??!1,[p,h]=y.useState(null),m=y.useMemo(()=>!d||f?{input:"",groundTruth:"",metadata:"",trajectory:"",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):"",requestContext:d.requestContext?JSON.stringify(d.requestContext,null,2):""},[d,f]),g=d?.datasetVersion??0,[v,b]=y.useState(!1),[w,S]=y.useState(m.input),[O,_]=y.useState(m.groundTruth),[C,j]=y.useState(m.metadata),[E,N]=y.useState(m.trajectory),[I,P]=y.useState(m.requestContext),[$,z]=y.useState(g);g!==$&&(z(g),S(m.input),_(m.groundTruth),j(m.metadata),N(m.trajectory),P(m.requestContext));const[D,q]=y.useState(!1),W=X=>{h(f?X:X.isLatest?null:X)},L=()=>{h(null)},F=!f&&p!=null,B=()=>{F||b(!0)},M=()=>{F||q(!0)},Q=async()=>{if(!e||!t)return;let X;try{X=JSON.parse(w)}catch{Be.error("Input must be valid JSON");return}let te;if(O.trim())try{te=JSON.parse(O)}catch{Be.error("Ground Truth must be valid JSON");return}let ee;if(C.trim())try{ee=JSON.parse(C)}catch{Be.error("Metadata must be valid JSON");return}let J;const ie=E!==m.trajectory;if(ie&&E.trim())try{J=JSON.parse(E)}catch{Be.error("Expected Trajectory must be valid JSON");return}let ue;const Y=I!==m.requestContext;if(Y&&I.trim())try{ue=JSON.parse(I)}catch{Be.error("Request Context must be valid JSON");return}try{await l.mutateAsync({datasetId:e,itemId:t,input:X,groundTruth:te,metadata:ee,...ie?{expectedTrajectory:J??null}:{},...Y?{requestContext:ue}:{}}),Be.success("Item updated successfully"),b(!1)}catch(ne){Be.error(`Failed to update item: ${ne instanceof Error?ne.message:"Unknown error"}`)}},V=()=>{d&&(S(JSON.stringify(d.input,null,2)),_(d.groundTruth?JSON.stringify(d.groundTruth,null,2):""),j(d.metadata?JSON.stringify(d.metadata,null,2):""),N(d.expectedTrajectory!=null?JSON.stringify(d.expectedTrajectory,null,2):""),P(d.requestContext?JSON.stringify(d.requestContext,null,2):"")),b(!1)},R=async()=>{if(!(!e||!t))try{await c.mutateAsync({datasetId:e,itemId:t}),Be.success("Item deleted successfully"),q(!1),r(`/datasets/${e}`)}catch(X){Be.error(`Failed to delete item: ${X instanceof Error?X.message:"Unknown error"}`)}},U=p??d,Z=U?{id:t??"",datasetId:e??"",datasetVersion:U.datasetVersion,input:U.input,groundTruth:U.groundTruth,expectedTrajectory:U.expectedTrajectory,metadata:U.metadata,createdAt:U.createdAt,updatedAt:U.updatedAt}:null;return i&&ms(i)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):i&&vs(i)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx($s,{resource:"datasets"})})}):a?null:!e||!t||!s||s.length===0?o.jsx(ls,{children:o.jsx(Qv,{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(ca,{children:[o.jsxs(ca.Column,{children:[o.jsxs(ca.Title,{children:[o.jsx(ZT,{}),t," ",o.jsx(xa,{content:t})]}),o.jsx(ca.Description,{children:o.jsxs(dc,{children:["Item of ",o.jsx(Uv,{})," ",u?.name]})}),o.jsxs(ca.Description,{children:[o.jsxs(dc,{children:[o.jsx(nit,{})," Created at"," ",d?.createdAt?Kn(new Date(d.createdAt),"MMM d, yyyy"):""]}),o.jsxs(dc,{children:[o.jsx(KO,{})," Latest version v",d?.datasetVersion??""]})]})]}),o.jsx(ca.Column,{children:!v&&!f&&o.jsxs($r,{children:[o.jsxs(fe,{onClick:B,disabled:F,title:F?"Return to latest version to edit":void 0,children:[o.jsx(Sit,{})," Edit"]}),o.jsxs(fe,{onClick:M,disabled:F,title:F?"Return to latest version to delete":void 0,children:[o.jsx(Zc,{})," Delete"]})]})})]}),o.jsxs($v,{className:v?"grid-cols-1":"grid-cols-[1fr_auto]",children:[o.jsxs(Hr,{withRightSeparator:!v,children:[f&&d&&o.jsx(Rn,{variant:"destructive",title:"Item deleted",children:o.jsxs(Rn.Message,{children:["This item was deleted at version v",d.datasetVersion]})}),!f&&F&&p&&o.jsx(Rn,{variant:"warning",title:"Previous version",action:o.jsxs(Rn.Button,{onClick:L,children:[o.jsx(Xat,{})," Return to the latest version"]}),children:o.jsxs(Rn.Message,{children:["Viewing version v",p.datasetVersion]})}),v?o.jsx(CLt,{inputValue:w,setInputValue:S,groundTruthValue:O,setGroundTruthValue:_,metadataValue:C,setMetadataValue:j,trajectoryValue:E,setTrajectoryValue:N,requestContextValue:I,setRequestContextValue:P,validationErrors:null,onSave:Q,onCancel:V,isSaving:l.isPending}):Z?o.jsx(VEe,{item:Z,Link:n}):o.jsx("div",{className:"text-neutral4 text-sm",children:"Item data not available"})]}),!v&&o.jsx(Hr,{children:o.jsx(TXr,{datasetId:e,itemId:t,onClose:()=>{},onVersionSelect:W,onCompareVersionsClick:X=>{r(`/datasets/${e}/items/${t}/versions?ids=${X.join(",")}`)},activeVersion:p?.datasetVersion??null})})]})]})})}),o.jsx(jt,{open:D,onOpenChange:q,children:o.jsxs(jt.Content,{children:[o.jsxs(jt.Header,{children:[o.jsx(jt.Title,{children:"Delete Item"}),o.jsx(jt.Description,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),o.jsxs(jt.Footer,{children:[o.jsx(jt.Cancel,{children:"Cancel"}),o.jsx(jt.Action,{onClick:R,children:c.isPending?"Deleting...":"Delete"})]})]})})]})}function MZe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function ZXr(){const{datasetId:e}=wr(),[t,n]=Ei(),r=t.get("items")?.split(",").filter(Boolean)??[],{data:s,error:a}=Lx(e??""),{Link:i}=vn(),[l,c]=y.useState(!1),{data:u}=wge(e??"",r[0]??""),{data:d}=wge(e??"",r[1]??"");return a&&ms(a)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):a&&vs(a)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx($s,{resource:"datasets"})})}):!e||r.length<2?o.jsx(ls,{children:o.jsx(Qv,{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(Sy,{owner:"dataset-items-compare",children:o.jsxs(fe,{as:ui,to:`/datasets/${e}`,variant:"outline",children:[o.jsx(xc,{}),"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(ca,{children:[o.jsxs(ca.Column,{children:[o.jsxs(ca.Title,{children:[o.jsx(Dw,{}),"Compare Dataset Items"]}),o.jsx(ca.Description,{children:o.jsxs(dc,{children:["Comparing ",r.length," items of"," ",o.jsx(ui,{to:`/datasets/${e}`,className:"text-info1 hover:underline",children:s?.name||e?.slice(0,8)})]})})]}),o.jsx(ca.Column,{children:o.jsx($r,{children:o.jsx(fe,{variant:"primary",onClick:()=>c(f=>!f),children:l?o.jsxs(o.Fragment,{children:[o.jsx(cit,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx(Tin,{})," Diff View"]})})})})]}),o.jsx($v,{className:"grid-cols-[1fr_3vw_1fr]",children:r.map((f,p)=>o.jsxs(y.Fragment,{children:[o.jsx(GXr,{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(D0t,{codeA:MZe(u),codeB:MZe(d)})]})})]})}function GXr({datasetId:e,itemId:t,Link:n,idx:r,itemIds:s,onItemChange:a,showContent:i=!0}){const{data:l,isLoading:c}=wge(e,t),{data:u}=WO(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(Hr,{children:[o.jsxs(Hr.Toolbar,{className:"flex gap-4",children:[o.jsxs($a,{name:`compare-item-${r}`,value:t,onValueChange:a,children:[o.jsx(Da,{"aria-label":"Item",children:o.jsx(Ma,{placeholder:"Select item"})}),o.jsx(La,{children:f.map(p=>o.jsx(Yr,{value:p.value,disabled:p.disabled,children:p.label},p.value))})]}),o.jsxs(fe,{as:n,to:`/datasets/${e}/items/${t}`,children:[o.jsx(KO,{}),"Versions"]})]}),i&&o.jsx(Hr.Content,{children:c?o.jsx("div",{className:"text-neutral4 text-sm",children:"Loading..."}):l?o.jsxs(o.Fragment,{children:[o.jsx(lXr,{item:l}),o.jsx(VEe,{item:l,Link:n})]}):o.jsxs("div",{className:"text-neutral4 text-sm",children:["Item ",t.slice(0,8)," not found"]})})]})}function DZe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function QXr(){const{datasetId:e,itemId:t}=wr(),[n,r]=Ei(),[s,a]=y.useState(!1),i=n.get("ids")?.split(",").map(Number).filter(h=>!isNaN(h)&&h>0)??[],{data:l,error:c}=Lx(e??""),{Link:u}=vn(),{data:d}=BEe(e??"",t??""),{data:f}=Cge(e??"",t??"",i[0]??0,l?.version),{data:p}=Cge(e??"",t??"",i[1]??0,l?.version);return c&&ms(c)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):c&&vs(c)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx($s,{resource:"datasets"})})}):!e||!t||i.length<2?o.jsx(ls,{children:o.jsx(Qv,{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(Sy,{owner:"dataset-item-versions-compare",children:o.jsxs(fe,{as:ui,to:`/datasets/${e}/items/${t}`,variant:"outline",children:[o.jsx(xc,{}),"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(ca,{children:[o.jsxs(ca.Column,{children:[o.jsxs(ca.Title,{children:[o.jsx(Dw,{}),"Compare Dataset Item Versions"]}),o.jsx(ca.Description,{children:o.jsxs(dc,{children:["Comparing ",i.length," versions of"," ",o.jsx(ui,{to:`/datasets/${e}/items/${t}`,className:"text-info1 hover:underline",children:t})]})})]}),o.jsx(ca.Column,{children:o.jsx($r,{children:o.jsx(fe,{variant:"primary",onClick:()=>a(h=>!h),children:s?o.jsxs(o.Fragment,{children:[o.jsx(cit,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx(uon,{})," Diff View"]})})})})]}),o.jsx($v,{className:"grid-cols-[1fr_3vw_1fr]",children:i.map((h,m)=>o.jsxs(y.Fragment,{children:[o.jsx(YXr,{datasetId:e,itemId:t,datasetVersion:h,latestVersion:l?.version,allVersions:d??[],versionNumbers:i,Link:u,idx:m,showContent:!s,onVersionChange:g=>{const v=[...i];v[m]=g,r({ids:v.join(",")})}}),m===0&&o.jsx("div",{className:K("bg-surface5 w-[3px] shrink-0 mx-[1.5vw]")})]},h))}),s&&f&&p&&o.jsx(D0t,{codeA:DZe(f),codeB:DZe(p)})]})})]})}function YXr({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}=Cge(e,t,n,r),p=new Set(a.filter((g,v)=>v!==l)),h=s.map(g=>{const v=typeof g.updatedAt=="string"?new Date(g.updatedAt):g.updatedAt;return{value:String(g.datasetVersion),label:o.jsxs(o.Fragment,{children:[o.jsxs("b",{children:["v. ",g.datasetVersion]})," - ",Kn(v,"MMM d, yyyy h:mm a"),g.isLatest?o.jsx(Xs,{color:"blue",size:"small",children:"Latest"}):null]}),disabled:p.has(g.datasetVersion)}}),m=d?{id:d.id,datasetId:e,datasetVersion:d.datasetVersion,input:d.input,groundTruth:d.groundTruth,metadata:d.metadata,createdAt:d.createdAt,updatedAt:d.updatedAt}:null;return o.jsxs(Hr,{children:[o.jsxs(Hr.Toolbar,{className:"grid gap-4 grid-cols-[auto_1fr]",children:[o.jsx(KO,{className:"w-6 h-6 opacity-50"}),o.jsxs($a,{name:`compare-version-${l}`,value:String(n),onValueChange:g=>u(Number(g)),children:[o.jsx(Da,{"aria-label":"Version",className:"w-full",children:o.jsx(Ma,{placeholder:"Select version"})}),o.jsx(La,{children:h.map(g=>o.jsx(Yr,{value:g.value,disabled:g.disabled,children:g.label},g.value))})]})]}),c&&o.jsx(Hr.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(VEe,{item:m,Link:i})})]})}function XXr(){const{datasetId:e}=wr(),[t]=Ei(),n=t.get("ids")?.split(",").map(Number).filter(g=>!isNaN(g)&&g>0)??[],r=qs(),{data:s,error:a}=Lx(e??""),i=WO(e??"",void 0,n[0]??null),l=WO(e??"",void 0,n[1]??null),c=y.useMemo(()=>i.data??[],[i.data]),u=y.useMemo(()=>l.data??[],[l.data]),d=y.useMemo(()=>{const g=new Map;for(const v of[...c,...u])g.has(v.id)||g.set(v.id,{id:v.id,createdAt:new Date(v.createdAt)});return[...g.values()].sort((v,b)=>b.createdAt.getTime()-v.createdAt.getTime())},[c,u]),f=y.useMemo(()=>new Map(c.map(g=>[g.id,g])),[c]),p=y.useMemo(()=>new Map(u.map(g=>[g.id,g])),[u]);if(a&&ms(a))return o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})});if(a&&vs(a))return o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx($s,{resource:"datasets"})})});if(!e||n.length<2)return o.jsx(ls,{children:o.jsx(Qv,{children:o.jsx("div",{className:"text-neutral4 text-center py-8",children:o.jsx("p",{children:"Select at least two versions to compare."})})})});const h=(g,v,b)=>{r(`/datasets/${e}/items/${g}/versions?ids=${v?.datasetVersion??""},${b?.datasetVersion??""}`)},m=(g,v)=>{r(`/datasets/${e}/versions?ids=${g},${v}`,{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(ca,{children:[o.jsxs(ca.Column,{children:[o.jsxs(ca.Title,{children:[o.jsx(Wln,{})," Compare Dataset Versions"]}),o.jsx(ca.Description,{children:o.jsxs(dc,{children:[o.jsx(KO,{})," Comparing ",n.length," versions of"," ",s?.name||e?.slice(0,8)]})})]}),o.jsx(ca.Column,{children:o.jsxs(fe,{as:ui,to:`/datasets/${e}`,children:[o.jsx(xc,{}),"Back to Dataset"]})})]}),o.jsx($v,{children:o.jsxs(Hr,{children:[o.jsx(AXr,{datasetId:e,versionA:String(n[0]),versionB:String(n[1]),onVersionChange:m}),o.jsx(MXr,{datasetId:e,versionA:n[0],versionB:n[1],allItems:d,itemsAMap:f,itemsBMap:p,onItemClick:h})]})})]})})})}function KXr(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 JXr({scorers:e,datasets:t,experiments:n,avgScore:r,prevAvgScore:s,totalNeedsReview:a,isLoadingScorers:i,isLoadingDatasets:l,isLoadingExperiments:c,isLoadingScores:u,isLoadingReview:d}){const f=e?Object.keys(e).length:void 0,p=t?.length,h=n?.length,m=r!=null&&s!=null&&s!==0?{changePct:Math.round((r-s)/s*100*10)/10,prevValue:String(s)}:null,g=KXr(n);return o.jsxs(o.Fragment,{children:[o.jsxs(Qr,{children:[o.jsx(Qr.Label,{children:"Total Scorers"}),i?o.jsx(Qr.Loading,{}):f!=null?o.jsxs(o.Fragment,{children:[o.jsx(Qr.Value,{children:String(f)}),o.jsx(Qr.NoChange,{message:"Static count"})]}):o.jsx(Qr.NoData,{})]}),o.jsxs(Qr,{children:[o.jsx(Qr.Label,{children:"Total Datasets"}),l?o.jsx(Qr.Loading,{}):p!=null?o.jsxs(o.Fragment,{children:[o.jsx(Qr.Value,{children:String(p)}),o.jsx(Qr.NoChange,{message:"Static count"})]}):o.jsx(Qr.NoData,{})]}),o.jsxs(Qr,{children:[o.jsx(Qr.Label,{children:"Avg Score"}),u?o.jsx(Qr.Loading,{}):r!=null?o.jsxs(o.Fragment,{children:[o.jsx(Qr.Value,{children:String(r)}),m?o.jsx(Qr.Change,{changePct:m.changePct,prevValue:m.prevValue}):o.jsx(Qr.NoChange,{})]}):o.jsx(Qr.NoData,{})]}),o.jsxs(Qr,{children:[o.jsx(Qr.Label,{children:"Total Experiments"}),c?o.jsx(Qr.Loading,{}):h!=null?o.jsxs(o.Fragment,{children:[o.jsx(Qr.Value,{children:String(h)}),g?o.jsx(Qr.Change,{changePct:g.changePct,prevValue:g.prevValue}):o.jsx(Qr.NoChange,{})]}):o.jsx(Qr.NoData,{})]}),o.jsxs(Qr,{children:[o.jsx(Qr.Label,{children:"Needs Review"}),d?o.jsx(Qr.Loading,{}):a!=null?o.jsxs(o.Fragment,{children:[o.jsx(Qr.Value,{children:String(a)}),a>0?o.jsx(Qr.NoChange,{message:"items pending review"}):o.jsx(Qr.NoChange,{message:"All caught up"})]}):o.jsx(Qr.NoData,{})]})]})}const LZe="auto 1fr auto auto auto auto auto auto auto";function eKr(e){return e?(typeof e=="string"?new Date(e):e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}const tKr={completed:"success",running:"warning",failed:"error",pending:"neutral"};function nKr({experiments:e,datasets:t,reviewByExperiment:n,isLoading:r,search:s="",statusFilter:a="all",datasetFilter:i="all"}){const{paths:l,Link:c}=vn(),u=y.useMemo(()=>{const p=new Map;return t?.forEach(h=>p.set(h.id,h.name)),p},[t]),d=y.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=y.useMemo(()=>{const p=s.toLowerCase();return d.filter(h=>{const m=h.datasetId?u.get(h.datasetId)??"":"",g=!p||h.id.toLowerCase().includes(p)||m.toLowerCase().includes(p)||(h.targetId??"").toLowerCase().includes(p),v=a==="all"||h.status===a,b=i==="all"||h.datasetId===i;return g&&v&&b})},[d,s,u,a,i]);return r?o.jsx(Go,{columns:LZe}):o.jsxs(xe,{columns:LZe,variant:"striped",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Experiment"}),o.jsx(xe.TopCell,{children:"Dataset"}),o.jsx(xe.TopCell,{children:"Target"}),o.jsx(xe.TopCell,{children:"Status"}),o.jsx(xe.TopCell,{className:"text-center",children:"Items"}),o.jsx(xe.TopCell,{className:"text-center",children:"Succeeded"}),o.jsx(xe.TopCell,{className:"text-center",children:"Failed"}),o.jsx(xe.TopCell,{className:"text-center",children:"Review"}),o.jsx(xe.TopCell,{children:"Date"})]}),f.map(p=>{const h=p.datasetId?u.get(p.datasetId)??p.datasetId.slice(0,8):"—",m=p.status??"pending",g=p.succeededCount??0,v=p.failedCount??0,b=p.totalItems??0,w=b>0?Math.round(g/b*100):0;return o.jsxs(xe.RowLink,{to:l.experimentLink(p.id),LinkComponent:c,children:[o.jsx(xe.NameCell,{className:"font-mono",children:p.id.slice(0,8)}),o.jsx(xe.TextCell,{children:h}),o.jsx(xe.Cell,{children:o.jsxs("span",{className:"truncate",children:[p.targetType," ",p.targetId]})}),o.jsx(xe.Cell,{children:o.jsx(Xm,{variant:tKr[m]??"neutral",withDot:!0,children:m})}),o.jsx(xe.TextCell,{className:"text-center",children:b}),o.jsx(xe.TextCell,{className:"text-center",children:o.jsxs("span",{className:g>0?"text-accent1":"",children:[g," (",w,"%)"]})}),o.jsx(xe.TextCell,{className:"text-center",children:o.jsx("span",{className:v>0?"text-accent2":"",children:v})}),o.jsx(xe.Cell,{className:"text-center",children:(()=>{const S=n?.get(p.id);if(!S)return o.jsx("span",{className:"text-neutral2",children:"—"});const O=S.needsReview+S.complete;return O===0?o.jsx("span",{className:"text-neutral2",children:"—"}):S.needsReview>0?o.jsxs(Xs,{size:"small",color:"yellow",children:[S.needsReview," pending"]}):o.jsxs(Xs,{size:"small",color:"green",children:[S.complete,"/",O," reviewed"]})})()}),o.jsx(xe.TextCell,{children:eKr(p.createdAt)})]},p.id)})]})}const rKr=[{value:"all",label:"All statuses"},{value:"completed",label:"Completed"},{value:"running",label:"Running"},{value:"failed",label:"Failed"},{value:"pending",label:"Pending"}];function sKr(e){return[{value:"all",label:"All datasets"},...(e??[]).map(t=>({value:t.id,label:t.name}))]}const h8={completed:"#22c55e",running:"#facc15",pending:"#fb923c",failed:"#f87171"},aKr=[{label:"Completed",color:h8.completed},{label:"Running",color:h8.running},{label:"Pending",color:h8.pending},{label:"Failed",color:h8.failed}];function iKr({experiments:e,datasets:t,isLoading:n,isError:r}){const{data:s,maxVal:a}=y.useMemo(()=>{if(!e||e.length===0)return{data:[],maxVal:0};const l=new Map;if(t)for(const f of t)l.set(f.id,f.name);const c=new Map;for(const f of e){const p=f.datasetId??"unknown";c.has(p)||c.set(p,{completed:0,running:0,pending:0,failed:0});const h=c.get(p),m=f.status;m in h&&h[m]++}let u=0;return{data:Array.from(c.entries()).map(([f,p])=>{const h=p.completed+p.running+p.pending+p.failed;return h>u&&(u=h),{name:l.get(f)??f.slice(0,12),values:[p.completed,p.running,p.pending,p.failed]}}),maxVal:u}},[e,t]),i=s.length>0;return o.jsxs(Bt,{children:[o.jsxs(Bt.TopBar,{children:[o.jsx(Bt.TitleAndDescription,{title:"Experiments by Dataset",description:"Experiment status breakdown per dataset."}),i&&o.jsx(Bt.Summary,{value:String(e?.length??0),label:"Total experiments"})]}),n?o.jsx(Bt.Loading,{}):r?o.jsx(Bt.Error,{message:"Failed to load experiments data"}):o.jsx(Bt.Content,{children:i?o.jsx(rT,{data:s,segments:aKr,maxVal:a,fmt:l=>String(l)}):o.jsx(Bt.NoData,{message:"No experiments have been run yet"})})]})}const oKr=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Wr,{iconSlot:o.jsx(mf,{}),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(fe,{variant:"ghost",as:"a",href:"https://mastra.ai/en/docs/evals/datasets/running-experiments",target:"_blank",rel:"noopener noreferrer",children:["Experiments Documentation ",o.jsx(Ta,{})]})})})});function lKr({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(kf,{label:"Search experiments",placeholder:"Filter by experiment, dataset, or target",value:e,onSearch:t}),o.jsxs($r,{children:[o.jsx(uc,{label:"Status",labelIsHidden:!0,name:"filter-status",options:[...rKr],value:n,onValueChange:r,className:"whitespace-nowrap"}),o.jsx(uc,{label:"Dataset",labelIsHidden:!0,name:"filter-dataset",options:i,value:s,onValueChange:a,className:"whitespace-nowrap"}),l&&c&&o.jsxs(fe,{onClick:l,size:"sm",variant:"default",children:[o.jsx(gs,{className:"size-3"})," Reset"]})]})]})}function cKr(){const{data:e,isLoading:t,error:n}=Zp(),{data:r,isLoading:s,error:a}=wy(),{data:i,isLoading:l,error:c}=UW(),{data:u,isLoading:d,isError:f,error:p}=LHr(),{data:h,isLoading:m,isError:g,error:v}=WEe(),b=r?.datasets,w=i?.experiments,S=y.useMemo(()=>zXr(h),[h]),O=n||a||c||p||v;return O&&ms(O)?o.jsx(or,{children:o.jsx(Vs,{})}):O&&vs(O)?o.jsx(or,{children:o.jsx($s,{resource:"evaluation"})}):O?o.jsx(or,{children:o.jsx(Li,{title:"Failed to load evaluation data",message:O.message})}):o.jsx(Lt,{width:"wide",height:"full",children:o.jsxs("div",{className:"flex flex-col gap-6",children:[o.jsx(_fe,{children:o.jsx(JXr,{scorers:e,datasets:b,experiments:w,avgScore:u?.avgScore??null,prevAvgScore:u?.prevAvgScore??null,totalNeedsReview:S.needsReview,isLoadingScorers:t,isLoadingDatasets:s,isLoadingExperiments:l,isLoadingScores:d,isLoadingReview:m})}),o.jsx(jHr,{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(fYr,{experiments:w,isLoading:l,isError:!!c}),o.jsx(iKr,{experiments:w,datasets:b,isLoading:l,isError:!!c})]}),o.jsx(LXr,{reviewSummary:h,experiments:w,datasets:b,isLoading:m,isError:!!g})]})})}function uKr(){const[e,t]=y.useState(""),[n,r]=y.useState("all"),[s,a]=y.useState("all"),{data:i,isLoading:l,error:c}=wy(),{data:u,isLoading:d,error:f}=UW(),{data:p}=WEe(),h=y.useMemo(()=>i?.datasets??[],[i?.datasets]),m=y.useMemo(()=>u?.experiments??[],[u?.experiments]),g=y.useMemo(()=>sKr(h),[h]),v=y.useMemo(()=>TLt(p),[p]),b=l||d,w=f||c;if(w&&ms(w))return o.jsx(or,{children:o.jsx(Vs,{})});if(f&&vs(f))return o.jsx(or,{children:o.jsx($s,{resource:"experiments"})});if(c&&vs(c))return o.jsx(or,{children:o.jsx($s,{resource:"datasets"})});if(w)return o.jsx(or,{children:o.jsx(Li,{title:"Failed to load experiments",message:w.message})});if(m.length===0&&!b)return o.jsx(or,{children:o.jsx(oKr,{})});const S=n!=="all"||s!=="all"||e!=="",O=()=>{t(""),r("all"),a("all")};return o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx(lKr,{search:e,onSearchChange:t,statusFilter:n,onStatusFilterChange:r,datasetFilter:s,onDatasetFilterChange:a,datasetOptions:g,onReset:O,hasActiveFilters:S})}),o.jsx(nKr,{experiments:m,datasets:h,reviewByExperiment:v,isLoading:b,search:e,statusFilter:n,datasetFilter:s})]})}function m8({children:e}){return o.jsxs(Lt,{height:"full",children:[o.jsx("div",{}),o.jsx(Lt.MainArea,{isCentered:!0,children:e})]})}function dKr(){const{experimentId:e}=wr(),{data:t,isLoading:n}=UW(),s=t?.experiments?.find(h=>h.id===e)?.datasetId??"",{data:a,isLoading:i,error:l}=zB(s,e??""),{data:c,isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p}=FW({datasetId:s,experimentId:e??"",experimentStatus:a?.status});return!e||n||i?null:l&&ms(l)?o.jsx(m8,{children:o.jsx(Vs,{})}):l&&vs(l)?o.jsx(m8,{children:o.jsx($s,{resource:"datasets"})}):l&&DSe(l)||!n&&!s||!i&&!l&&!a?o.jsx(m8,{children:o.jsx(Wr,{iconSlot:o.jsx(Ave,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${e}".`,actionSlot:o.jsxs(fe,{as:ui,to:"/experiments",children:[o.jsx(xc,{}),"Back to Experiments"]})})}):l?o.jsx(m8,{children:o.jsx(Li,{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(NLt,{experiment:a}),o.jsx(Lt.MainArea,{children:o.jsx(jLt,{experimentId:e,datasetId:s,experimentStatus:a.status,results:c??[],isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p})})]})}function fKr({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 ILt({connections:e,isAdmin:t,disconnectPending:n,onDisconnect:r}){return o.jsx("ul",{className:"space-y-1",children:e.map(s=>o.jsx(fKr,{connection:s,isAdmin:t,disconnectPending:n,onDisconnect:()=>r(s.connectionId)},s.connectionId))})}function pKr({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(ILt,{connections:a,isAdmin:t,disconnectPending:n,onDisconnect:r})]},s))})}function hKr({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(pKr,{groups:r,isAdmin:s,disconnectPending:l,onDisconnect:u}):o.jsx(ILt,{connections:n,isAdmin:s,disconnectPending:l,onDisconnect:u}),c?o.jsx("p",{className:"text-red-600",children:String(c)}):null]})}function mKr({providers:e,toolkits:t,providerId:n,toolkit:r,label:s,providersLoading:a,providersError:i,toolkitsLoading:l,toolkitsError:c,authorizePending:u,authorizeError:d,authorizedConnection:f,onProviderChange:p,onToolkitChange:h,onLabelChange:m,onConnect:g}){return o.jsxs("div",{className:"space-y-4 border rounded p-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"block font-medium",htmlFor:"provider-select",children:"Provider"}),o.jsxs("select",{id:"provider-select",className:"border rounded px-2 py-1 w-full",value:n,onChange:v=>p(v.target.value),disabled:a,children:[o.jsx("option",{value:"",children:"— select provider —"}),e.map(v=>o.jsxs("option",{value:v.id,children:[v.displayName??v.name," (",v.id,")"]},v.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:v=>h(v.target.value),disabled:!n||l,children:[o.jsx("option",{value:"",children:"— select toolkit —"}),t.map(v=>o.jsxs("option",{value:v.slug,children:[v.name," (",v.slug,")"]},v.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:v=>m(v.target.value),disabled:!n||!r})]}),o.jsx("button",{type:"button",className:"bg-blue-600 text-white rounded px-4 py-2 disabled:opacity-50",onClick:g,disabled:!n||!r||u,children:u?"Authorizing…":"Connect"}),d?o.jsx("p",{className:"text-red-600",children:String(d)}):null,f&&o.jsxs("p",{className:"text-green-700",children:["Authorized: ",f.connectionId," (status: ",f.status,")"]})]})}const FZe=e=>e.authorId?.trim()||"shared",gKr=(e,t)=>{if(!t||new Set(e.map(FZe)).size<=1)return null;const r=new Map;for(const a of e){const i=FZe(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},vKr=["*","tool-providers:*","tool-providers:admin"];function yKr(){const{data:e}=lm();return e?.permissions?.some(t=>vKr.includes(t))??!1}function bKr(){const[e,t]=y.useState(""),[n,r]=y.useState(""),[s,a]=y.useState(""),i=VN(),l=mH(e||null),c=CIt(e||null,n||null),u=_It(),d=kIt(),f=yKr(),p=i.data?.providers??[],h=l.data?.data??[],m=y.useMemo(()=>c.data?.items??[],[c.data?.items]),g=y.useMemo(()=>gKr(m,f),[m,f]),v=S=>{t(S),r("")},b=()=>{!e||!n||u.mutate({providerId:e,toolkit:n,label:s.trim()||null},{onSuccess:()=>{a(""),c.refetch()}})},w=S=>{d.mutate({providerId:e,connectionId:S})};return o.jsxs("div",{className:"p-6 max-w-3xl space-y-6 text-sm",children:[o.jsx("h1",{className:"text-2xl font-semibold",children:"Integrations"}),o.jsx("p",{className:"text-gray-500",children:"Minimal page to verify the ToolProvider backend. Pick a provider and toolkit, then connect."}),o.jsx(mKr,{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:v,onToolkitChange:r,onLabelChange:a,onConnect:b}),o.jsx(hKr,{providerId:e,toolkit:n,connections:m,groupedByAuthor:g,isAdmin:f,isLoading:c.isLoading,error:c.error,disconnectPending:d.isPending,disconnectError:d.error,onDisconnect:w})]})}function xKr({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(Rh,{className:"h-10 w-10"}),o.jsx("h1",{className:"text-xl font-semibold text-neutral6",children:e})]}),t,n,r]})})}function ALt({redirectUri:e,onSuccess:t,initialMode:n="signin",errorMessage:r}){const{data:s,isLoading:a}=Yl(),{mutate:i,isPending:l,error:c}=TCr(),{mutate:u,isPending:d,error:f}=ICr(),{mutate:p,isPending:h}=HNt(),[m,g]=y.useState(n),[v,b]=y.useState(""),[w,S]=y.useState(""),[O,_]=y.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,j=C.type==="sso"||C.type==="both",E=C.type==="credentials"||C.type==="both",N=C.sso,I=C.signUpEnabled!==!1,P=m==="signin"||!I,$=P?l:d,z=P?c:f,D=()=>{t?t():e?window.location.href=e:window.location.href="/"},q=M=>{M.preventDefault(),P?i({email:w,password:O},{onSuccess:D}):u({email:w,password:O,name:v||void 0},{onSuccess:D})},W=()=>{p({redirectUri:e},{onSuccess:M=>{window.location.href=M.url}})},L=()=>{g(P?"signup":"signin")},F=C.description?o.jsxs("div",{className:"flex items-start gap-2.5 rounded-md border border-border1 bg-surface1 p-3",children:[o.jsx(of,{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(xKr,{title:P?"Sign in to Mastra Studio":"Create your account",description:F,errorBanner:B,children:[E&&o.jsxs("form",{onSubmit:q,className:"space-y-4",children:[!P&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"name",className:"block text-sm text-neutral4",children:"Name"}),o.jsx(On,{id:"name",type:"text",value:v,onChange:M=>b(M.target.value),placeholder:"Your name",variant:"default",size:"lg"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"email",className:"block text-sm text-neutral4",children:"Email"}),o.jsx(On,{id:"email",type:"email",value:w,onChange:M=>S(M.target.value),placeholder:"you@example.com",required:!0,variant:"default",size:"lg"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"password",className:"block text-sm text-neutral4",children:"Password"}),o.jsx(On,{id:"password",type:"password",value:O,onChange:M=>_(M.target.value),placeholder:P?"Enter your password":"Create a password",required:!0,variant:"default",size:"lg"})]}),z&&o.jsx("div",{className:"rounded-md bg-red-500/10 p-3 text-sm text-red-400",children:z.message}),o.jsx(fe,{type:"submit",disabled:$,className:"w-full",size:"lg",children:$?P?"Signing in...":"Creating account...":P?"Sign in":"Create account"}),I&&o.jsxs("div",{className:"text-center text-sm",children:[o.jsx("span",{className:"text-neutral3",children:P?"Don't have an account? ":"Already have an account? "}),o.jsx("button",{type:"button",onClick:L,className:"text-neutral6 hover:underline",children:P?"Sign up":"Sign in"})]})]}),j&&E&&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"})})]}),j&&N&&o.jsxs(fe,{onClick:W,disabled:h,className:"w-full",size:"lg",variant:"outline",children:[N.icon&&o.jsx("span",{className:"mr-2",children:N.icon}),h?"Redirecting...":N.text||"Sign in"]})]})}function wKr(){const[e]=Ei(),t=qs(),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(ALt,{redirectUri:n,onSuccess:i,initialMode:s,errorMessage:a})}function SKr(){const[e,t]=Ei(),n=Obr(e,t),r=Ebr(e,t),[s,a]=y.useState(),[i,l]=y.useState(!1),{data:c=[],isPending:u}=QSe(),{data:d=[],isPending:f}=YSe({entityType:n.selectedEntityOption?.entityType,rootOnly:!0}),{data:p=[],isPending:h}=XSe(),{data:m=[],isPending:g}=KSe(),v=y.useMemo(()=>Zvr({availableTags:c,availableRootEntityNames:d,availableServiceNames:m,availableEnvironments:p,loading:{tags:u,entityNames:f,serviceNames:g,environments:h}}),[c,d,m,p,u,f,g,h]),b=y.useMemo(()=>Xvr({rootEntityType:n.selectedEntityOption?.entityType,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,tokens:n.filterTokens}),[n.filterTokens,n.selectedDateFrom,n.selectedDateTo,n.selectedEntityOption]),{data:w=[],isLoading:S,error:O,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:j}=Sbr({filters:b}),{logIdMap:E,featuredLog:N,handleLogClick:I,handlePreviousLog:P,handleNextLog:$}=Nbr(w,n.featuredLogId,n.handleFeaturedChange,n.featuredTraceId),{data:z,isLoading:D}=GSe(n.featuredTraceId??null),{data:q,isLoading:W}=rD(n.featuredTraceId??"",n.featuredSpanId??""),L=y.useCallback(()=>n.applyFilterTokens(Kvr(v,n.filterTokens)),[v,n]),F=y.useCallback(()=>n.handleFeaturedChange({logId:null}),[n]),B=y.useCallback(X=>n.handleFeaturedChange({traceId:X,spanId:null}),[n]),M=y.useCallback((X,te)=>n.handleFeaturedChange({traceId:X,spanId:te}),[n]),Q=y.useCallback(()=>{n.handleFeaturedChange({traceId:null,spanId:null}),l(!1)},[n]),V=y.useCallback(()=>n.handleFeaturedChange({spanId:null}),[n]),R=y.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(Zwe,{preset:n.datePreset,onPresetChange:n.handleDatePresetChange,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,onDateChange:n.handleDateChange,disabled:S,presets:["last-24h","last-3d","last-7d","last-14d","last-30d","custom"]}),o.jsx(y0e,{fields:v,tokens:n.filterTokens,onTokensChange:n.handleFilterTokensChange,disabled:S,onStartTextFilter:a})]})}),o.jsx(hbr,{isLoading:S,filterFields:v,filterTokens:n.filterTokens,onFilterTokensChange:n.handleFilterTokensChange,onClear:L,onRemoveAll:n.handleRemoveAll,onSave:r.handleSave,onRemoveSaved:r.hasSavedFilters?r.handleRemoveSaved:void 0,autoFocusFilterFieldId:s})]});if(O)return o.jsxs(Lt,{width:"wide",height:"full",children:[U,o.jsx(Lt.MainArea,{isCentered:!0,children:o.jsx(cbr,{error:O,resource:"logs",errorTitle:"Failed to load logs"})})]});const Z=!!n.selectedEntityOption||n.filterTokens.length>0;return w.length===0&&!S&&!Z?o.jsxs(Lt,{width:"wide",height:"full",children:[U,o.jsx(Lt.MainArea,{isCentered:!0,children:o.jsx(ybr,{datePreset:n.datePreset,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo})})]}):o.jsxs(Lt,{width:"wide",height:"full",children:[U,o.jsx(ubr,{logCollapsed:i,listSlot:o.jsx(pbr,{logs:w,isLoading:S,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:j,logIdMap:E,featuredLogId:n.featuredLogId,onLogClick:I}),logPanelSlot:N?o.jsx(lbr,{log:N,onClose:F,onTraceClick:B,onSpanClick:M,onPrevious:P,onNext:$,collapsed:i,onCollapsedChange:l}):null,tracePanelSlot:n.featuredTraceId?o.jsx(Pyr,{traceId:n.featuredTraceId,spans:z?.spans,isLoading:D,onClose:Q,onSpanSelect:R,selectedSpanId:n.featuredSpanId}):null,spanPanelSlot:n.featuredTraceId&&n.featuredSpanId?o.jsx(Ryr,{spanId:n.featuredSpanId,span:q?.span,isLoading:W,onClose:V}):null})]})}function kKr({server:e}){const{paths:t,Link:n}=vn(),s=We().options.baseUrl,a=s?`${s}/api/mcp/${e.id}/sse`:"",{data:i}=O5t(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=Zh(e.name,50);return o.jsxs(xe.RowLink,{to:t.mcpServerLink(e.id),LinkComponent:n,children:[o.jsx(xe.NameCell,{children:f}),o.jsx(xe.DescriptionCell,{children:a}),o.jsx(xe.TextCell,{className:"text-center",children:u||""}),o.jsx(xe.TextCell,{className:"text-center",children:c||""}),o.jsx(xe.TextCell,{className:"text-center",children:d||""})]})}function OKr({mcpServers:e,isLoading:t,search:n=""}){const r=y.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(Go,{columns:"auto 1fr auto auto auto"}):o.jsxs(xe,{columns:"auto 1fr auto auto auto",variant:"striped",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Name"}),o.jsx(xe.TopCell,{children:"URL"}),o.jsx(xe.TopCellSmart,{long:"Agents",short:o.jsx(Ko,{}),tooltip:"Agent Tools",className:"text-center"}),o.jsx(xe.TopCellSmart,{long:"Tools",short:o.jsx(ff,{}),tooltip:"Tools",className:"text-center"}),o.jsx(xe.TopCellSmart,{long:"Workflows",short:o.jsx(df,{}),tooltip:"Workflow Tools",className:"text-center"})]}),r.length===0&&n?o.jsx(xe.NoMatch,{message:"No MCP Servers match your search"}):null,r.map(s=>o.jsx(kKr,{server:s},s.id))]})}const _Kr=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Wr,{iconSlot:o.jsx(mf,{}),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(fe,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/tools-mcp/mcp-overview",target:"_blank",rel:"noopener noreferrer",children:["MCP Documentation ",o.jsx(Ta,{})]})})}),CKr=()=>{const{data:e=[],isLoading:t,error:n}=AW(),[r,s]=y.useState("");return n&&ms(n)?o.jsx(or,{children:o.jsx(Vs,{})}):n&&vs(n)?o.jsx(or,{children:o.jsx($s,{resource:"MCP servers"})}):n?o.jsx(or,{children:o.jsx(Li,{title:"Failed to load MCP servers",message:n.message})}):e.length===0&&!t?o.jsx(or,{children:o.jsx(_Kr,{})}):o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx("div",{className:"max-w-120",children:o.jsx(kf,{onSearch:s,label:"Filter MCP servers",placeholder:"Filter by name"})})}),o.jsx(OKr,{mcpServers:e,isLoading:t,search:r})]})},EKr=(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 jKr({tools:e,agents:t,isLoading:n,search:r=""}){const{paths:s,Link:a}=vn(),i=y.useMemo(()=>EKr(e,t),[e,t]),l=y.useMemo(()=>i.filter(c=>c.id.toLowerCase().includes(r.toLowerCase())),[i,r]);return n?o.jsx(Go,{columns:"auto 1fr auto"}):o.jsxs(xe,{columns:"auto 1fr auto",variant:"striped",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Name"}),o.jsx(xe.TopCell,{children:"Description"}),o.jsx(xe.TopCellSmart,{long:"Agents",short:o.jsx(Ko,{}),tooltip:"Attached Agents",className:"text-center"})]}),l.length===0&&r?o.jsx(xe.NoMatch,{message:"No Tools match your search"}):null,l.map(c=>{const u=Zh(c.id,50),d=Zh(c.description??"",200),f=c.agents.length;return o.jsxs(xe.RowLink,{to:s.toolLink(c.id),LinkComponent:a,children:[o.jsx(xe.NameCell,{children:u}),o.jsx(xe.DescriptionCell,{children:d}),o.jsx(xe.TextCell,{className:"text-center",children:f||""})]},c.id)})]})}const TKr=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Wr,{iconSlot:o.jsx(mf,{}),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(fe,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/agents/using-tools-and-mcp",target:"_blank",rel:"noopener noreferrer",children:["Tools Documentation ",o.jsx(Ta,{})]})})}),NKr=()=>{const e=We();return An({mutationFn:async({toolId:t,input:n,requestContext:r})=>{const s=new QO;Object.entries(r??{}).forEach(([a,i])=>{s.set(a,i)});try{return await e.getTool(t).execute({data:n,requestContext:s})}catch(a){throw Be.error("Error executing dev tool"),console.error("Error executing dev tool:",a),a}}})},IKr=({toolId:e})=>{const{canExecute:t}=dl(),n=t("tools"),{data:r={}}=cm(),s=y.useMemo(()=>{for(const g of Object.values(r))if(g.tools){const v=Object.values(g.tools).find(b=>b.id===e);if(v)return v}return null},[r,e]),{data:a,isLoading:i,error:l}=B_r(e,{enabled:!s}),c=s||a,{mutateAsync:u,isPending:d,data:f}=NKr(),{requestContext:p}=Ss();y.useEffect(()=>{if(l){const g=l instanceof Error?l.message:"Failed to load tool";Be.error(`Error loading tool: ${g}`)}},[l]);const h=async(g,v)=>{if(!c)return;const b={...p??{},...v??{}};return u({toolId:c.id,input:g,requestContext:b})},m=c?.inputSchema?Yh(Gh(px(c?.inputSchema))):xs({});return i?o.jsxs("div",{className:"p-6",children:[o.jsx(Pt,{className:"h-8 w-48 mb-4"}),o.jsx(Pt,{className:"h-32 w-full"})]}):l?null:c?n?o.jsx(TEe,{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 AKr({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}=qN(),{data:p={},isLoading:h,isError:m,error:g}=cm(),{navigate:v,paths:b}=vn();y.useEffect(()=>{if(d){const _=f instanceof Error?f.message:"Failed to load tools";Be.error(`Error loading tools: ${_}`)}},[d,f]),y.useEffect(()=>{if(m){const _=g instanceof Error?g.message:"Failed to load agents";Be.error(`Error loading agents: ${_}`)}},[m,g]);const w=new Map;Object.values(p).forEach(_=>{_.tools&&Object.values(_.tools).forEach(C=>{w.has(C.id)||w.set(C.id,C)})}),Object.values(c).forEach(_=>{w.has(_.id)||w.set(_.id,_)});const S=Array.from(w.values()).map(_=>({label:_.id,value:_.id})),O=_=>{t?t(_):_&&_!==e&&v(b.toolLink(_))};return o.jsx(Wc,{options:S,value:e,onValueChange:O,placeholder:u||h?"Loading tools...":n,searchPlaceholder:r,emptyText:s,className:a,disabled:i||u||h||d||m,variant:l})}const RKr=({isLoading:e,server:t})=>{const[{sseUrl:n,httpStreamUrl:r},s]=y.useState({sseUrl:"",httpStreamUrl:""});if(y.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(Qv,{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(Qv,{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(gn,{icon:o.jsx($Ct,{className:"text-neutral6"}),className:"rounded-r-sm text-neutral4!",children:"Version"}),o.jsx(gn,{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(gn,{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(xa,{tooltip:"Copy HTTP Stream URL",content:r})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(gn,{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(xa,{tooltip:"Copy SSE URL",content:n})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(gn,{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(xa,{tooltip:"Copy Command Line Config",content:a})})]})]})]})]}),o.jsx("div",{className:"h-full overflow-y-scroll border-l border-border1",children:o.jsx(PKr,{server:t})})]})},PKr=({server:e})=>{const{data:t={},isLoading:n}=O5t(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(Ve,{size:"lg",className:"bg-surface4 rounded-md p-1",children:o.jsx(t1,{})}),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(MKr,{tool:a,serverId:e.id},s)})})]})};function $Kr(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 MKr=({tool:e,serverId:t})=>{const n=y.useRef(null),{Link:r,paths:s}=vn(),a=z5t[e.toolType||"tool"],i=$Kr(e._meta);return o.jsxs(bf,{onClick:()=>n.current?.click(),children:[o.jsx(qht,{children:o.jsx(a,{className:"group-hover/entity:text-accent6"})}),o.jsxs(wf,{children:[o.jsx(xf,{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(gn,{className:"text-[10px] py-0",children:"App"})]})}),o.jsx(Up,{children:e.description})]})]})},DKr=()=>{const{serverId:e}=wr(),{data:t=[],isLoading:n}=AW(),r=t.find(s=>s.id===e);return o.jsx("div",{className:"h-full w-full overflow-hidden",children:o.jsx(RKr,{isLoading:n,server:r})})};function LKr(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 FKr=({toolId:e,serverId:t})=>{const{canExecute:n}=dl(),r=n("tools"),s=We(),{data:a,isLoading:i,error:l}=bEe(t,e),{mutateAsync:c,isPending:u,data:d}=Fqr(t,e),f=a?LKr(a._meta):void 0,{data:p}=xt({queryKey:["mcp-app-resource",t,f],queryFn:async()=>f?(await s.readMcpServerResource(t,f)).contents[0]?.text??null:null,enabled:!!f}),h=y.useCallback(async(v,b)=>await c(b),[c]);y.useEffect(()=>{if(l){const v=l instanceof Error?l.message:"Failed to load tool";Be.error(`Error loading tool: ${v}`)}},[l]);const m=async v=>{if(a)return await c(v)};if(i)return o.jsxs("div",{className:"p-6",children:[o.jsx(Pt,{className:"h-8 w-48 mb-4"}),o.jsx(Pt,{className:"h-32 w-full"})]});if(l)return null;if(!a)return o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"header-md",className:"text-neutral3",children:"Tool not found"})});if(!r)return o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"ui-sm",className:"text-neutral3",children:"You don't have permission to execute tools."})});let g;try{g=Yh(Gh(a.inputSchema))}catch(v){console.error("Error processing input schema:",v),Be.error("Failed to process tool input schema."),g=xs({})}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(k5t,{html:p,toolName:a.name??a.id,onToolCall:h})}),o.jsx(TEe,{executionResult:d,isExecutingTool:u,zodInputSchema:g,handleExecuteTool:m,toolDescription:a.description||"",toolId:a.id})]})},zKr=()=>{const{serverId:e,toolId:t}=wr(),{data:n,isLoading:r}=bEe(e,t);return r||!n?null:o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(FKr,{toolId:t,serverId:e})})},zZe={agents:Rs.AGENT,workflows:Rs.WORKFLOW_RUN,tools:Rs.TOOL};function BKr(){const{data:e,isLoading:t,isError:n}=Ivr(),{getTracesHref:r,getBucketTracesHref:s}=BN(),{Link:a}=vn(),i=qs();return o.jsx(vvr,{data:e,isLoading:t,isError:n,onPointClick:(l,c)=>{Number.isFinite(c.tsMs)&&i(s({rootEntityType:zZe[l]},c.tsMs,"1h"))},actions:l=>o.jsx(J3,{href:r({rootEntityType:zZe[l]}),LinkComponent:a})})}function UKr(){const e=zvr(),t=Bvr(),{getTracesHref:n}=BN(),{Link:r}=vn();return o.jsx(bvr,{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 qKr(){const{data:e,isLoading:t,isError:n}=nEt();return o.jsx(eD,{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 VKr(){const{data:e,isLoading:t,isError:n}=jvr();return o.jsx(eD,{label:"Total Model Cost",value:e?.cost!=null?rg(e.cost,e.costUnit):null,prevValue:e?.previousCost!=null?rg(e.previousCost,e.costUnit):void 0,changePct:e?.costChangePercent??null,isLoading:t,isError:n})}function HKr(){const{data:e,isLoading:t,isError:n}=Tvr();return o.jsx(eD,{label:"Total Tokens",value:e?.value!=null?cc(e.value):null,prevValue:e?.previousValue!=null?cc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function WKr(){const{data:e,isLoading:t,isError:n}=Lvr();return o.jsx(eD,{label:"Total Threads",value:e?.value!=null?cc(e.value):null,prevValue:e?.previousValue!=null?cc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function ZKr(){const{data:e,isLoading:t,isError:n}=Fvr();return o.jsx(eD,{label:"Total Resources",value:e?.value!=null?cc(e.value):null,prevValue:e?.previousValue!=null?cc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function GKr({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=>QKr(f,a));return o.jsxs("div",{className:K("grid grid-cols-[1fr_auto] gap-3 items-start"),children:[o.jsx(v0e,{fields:a,tokens:i,onTokensChange:l,disabled:s,autoFocusFieldId:c}),u&&o.jsx(m0e,{disabled:s,onClear:d?e:void 0,onRemoveAll:t,onSave:n,onRemoveSaved:r})]})}function QKr(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 YKr(){const{data:e,isLoading:t,isError:n}=Nvr(),{getTracesHref:r}=BN(),{Link:s}=vn();return o.jsx(xvr,{rows:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:()=>r({rootEntityType:Rs.AGENT}),actions:o.jsx(J3,{href:r({rootEntityType:Rs.AGENT}),LinkComponent:s})})}function XKr(){const{data:e,isLoading:t,isError:n}=Rvr(),{getTracesHref:r}=BN(),{Link:s}=vn();return o.jsx(Svr,{data:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:a=>r({rootEntityType:Rs.AGENT,entityName:a.name}),actions:o.jsx(J3,{href:r({rootEntityType:Rs.AGENT}),LinkComponent:s})})}function KKr(){const{data:e,isLoading:t,isError:n}=Dvr(),{getTracesHref:r}=BN(),{Link:s}=vn();return o.jsx(_vr,{data:e?.data,interval:e?.interval,isLoading:t,isError:n,actions:o.jsx(J3,{href:r(),LinkComponent:s})})}const g8={agents:Rs.AGENT,workflows:Rs.WORKFLOW_RUN,tools:Rs.TOOL};function JKr(){const{data:e,isLoading:t,isError:n}=Avr(),{getTracesHref:r,getLogsHref:s}=BN(),{Link:a}=vn();return o.jsx(Cvr,{data:e,isLoading:t,isError:n,LinkComponent:a,getRowHref:(i,l)=>r({rootEntityType:g8[i],entityName:l.name}),getErrorSegmentHref:(i,l)=>l.errors>0?s({rootEntityType:g8[i],entityName:l.name,status:"error"}):void 0,actions:i=>o.jsxs(o.Fragment,{children:[o.jsx(J3,{href:r({rootEntityType:g8[i]}),LinkComponent:a}),o.jsx(mvr,{href:s({rootEntityType:g8[i],status:"error"}),LinkComponent:a})]})})}const eJr=new Set(["ObservabilityStorageClickhouseVNext","ObservabilityStorageDuckDB","ObservabilityInMemory","ObservabilitySpanner"]),ere="period",v8="dateFrom",y8="dateTo";function tJr(){const[e,t]=Ei(),n=e.get(ere),r=lvr(n)?n:"24h",s=y.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(v8)),p=d(e.get(y8));if(!(!f&&!p))return{from:f,to:p}},[r,e.toString()]),a=y.useMemo(()=>tvr(e),[e.toString()]),i=y.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d==="24h"?p.delete(ere):p.set(ere,d),d!=="custom"&&(p.delete(v8),p.delete(y8)),p},{replace:!0})},[t]),l=y.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d?.from?p.set(v8,d.from.toISOString()):p.delete(v8),d?.to?p.set(y8,d.to.toISOString()):p.delete(y8),p},{replace:!0})},[t]),c=y.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return rvr(p,d),p},{replace:!0})},[t]),u=y.useRef(!1);return y.useEffect(()=>{if(u.current||(u.current=!0,Jgr(e)))return;const d=JCt();d&&t(f=>{const p=new URLSearchParams(f);for(const[h,m]of d)p.append(h,m);return p},{replace:!0})},[]),o.jsx(uvr,{preset:r,filterTokens:a,onPresetChange:i,onFilterTokensChange:c,customRange:s,onCustomRangeChange:l,children:o.jsx(nJr,{})})}function nJr(){const[e]=Ei(),{error:t,isLoading:n}=nEt(),{filterTokens:r,setFilterTokens:s}=XV(),[a,i]=y.useState(),{data:l,isLoading:c}=i4(),u=l?.observabilityStorageType,d=u?eJr.has(u):!1,f=u==="ObservabilityInMemory",{data:p,isLoading:h}=QSe(),{data:m,isLoading:g}=YSe(),{data:v,isLoading:b}=KSe(),{data:w,isLoading:S}=XSe(),O=y.useMemo(()=>evr({availableTags:p??[],availableEntityNames:m??[],availableServiceNames:v??[],availableEnvironments:w??[],loading:{tags:h,entityNames:g,serviceNames:b,environments:S}}),[p,m,v,w,h,g,b,S]),[_,C]=y.useState(()=>JCt()!==null),j=y.useCallback(()=>{Xgr(e),C(!0),Be.success("Filters setting for Metrics saved")},[e]),E=y.useCallback(()=>{Kgr(),C(!1),Be.success("Filters setting for Metrics cleared up")},[]),N=y.useCallback(()=>{s([])},[s]),I=y.useCallback(()=>{const P=r.map($=>{const z=O.find(D=>D.id===$.fieldId);return z?z.kind==="text"?{fieldId:$.fieldId,value:""}:z.kind==="pick-multi"?z.multi?{fieldId:$.fieldId,value:[]}:{fieldId:$.fieldId,value:"Any"}:z.kind==="multi-select"?{fieldId:$.fieldId,value:[]}:$:$});s(P)},[O,r,s]);return t&&ms(t)?o.jsx(or,{children:o.jsx(Vs,{})}):t&&vs(t)?o.jsx(or,{children:o.jsx($s,{resource:"metrics"})}):t?o.jsx(or,{children:o.jsx(Li,{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(hvr,{}),o.jsx(y0e,{fields:O,tokens:r,onTokensChange:s,disabled:n,onStartTextFilter:i})]})}),o.jsx(GKr,{isLoading:n,filterFields:O,filterTokens:r,onFilterTokensChange:s,onClear:I,onRemoveAll:N,onSave:j,onRemoveSaved:_?E:void 0,autoFocusFilterFieldId:a})]}),c?null:d?o.jsxs("div",{className:"grid gap-8 content-start pb-10",children:[f&&o.jsx(Rn,{variant:"info",title:"Metrics are not persisted",children:o.jsx(Rn.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, or Spanner."})}),o.jsxs(_fe,{children:[o.jsx(qKr,{}),o.jsx(VKr,{}),o.jsx(HKr,{}),o.jsx(WKr,{}),o.jsx(ZKr,{})]}),o.jsxs(_fe,{children:[o.jsx(YKr,{}),o.jsx(XKr,{}),o.jsx(KKr,{}),o.jsx(UKr,{}),o.jsx(JKr,{}),o.jsx(BKr,{})]})]}):o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Wr,{iconSlot:o.jsx(mf,{}),titleSlot:"Metrics are not available with your current storage",descriptionSlot:"Metrics require ClickHouse, DuckDB, Spanner, or in-memory storage for observability. Relational databases (PostgreSQL, LibSQL) do not support metrics collection. To enable metrics on an existing project, switch the observability storage in the Mastra configuration.",actionSlot:o.jsxs(fe,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/observability/metrics/overview",target:"_blank",rel:"noopener noreferrer",children:["Metrics Documentation ",o.jsx(Ta,{})]})})})]})}function rJr(){const{paths:e}=vn(),{data:t,isLoading:n,error:r}=B5t(),{isCmsAvailable:s}=c4(),[a,i]=y.useState(""),l=t?.promptBlocks??[];return r&&ms(r)?o.jsx(or,{children:o.jsx(Vs,{})}):r&&vs(r)?o.jsx(or,{children:o.jsx($s,{resource:"prompt blocks"})}):r?o.jsx(or,{children:o.jsx(Li,{title:"Failed to load prompt blocks",message:r.message})}):l.length===0&&!n?o.jsx(or,{children:o.jsx(SWr,{})}):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(kf,{onSearch:i,label:"Filter prompts",placeholder:"Filter by name or description"})}),s&&o.jsxs(fe,{as:ui,to:e.cmsPromptBlockCreateLink(),variant:"primary",className:"shrink-0",children:[o.jsx(Lr,{}),"Create Prompt"]})]})}),o.jsx(wWr,{promptBlocks:l,isLoading:n,search:a})]})}function sJr(){return o.jsx(Lt,{width:"narrow",children:o.jsx(Lt.MainArea,{children:o.jsx(fVr,{children:o.jsx(hge,{})})})})}const aJr=[{title:"Mastra APIs",description:"Explore and test the available REST API endpoints with the interactive Swagger UI.",icon:Pin,href:"/swagger-ui",external:!1},{title:"Documentation",description:"Read the official Mastra documentation for guides, references, and tutorials.",icon:eit,href:"https://mastra.ai/en/docs",external:!0},{title:"Github",description:"Browse the source code, report issues, and contribute to the Mastra project.",icon:Ta,href:"https://github.com/mastra-ai/mastra",external:!0},{title:"Community",description:"Join the Mastra Discord community for help, discussion, and collaboration.",icon:Nj,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:lit,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:tit,href:"https://mastra.ai/contact?ref=studio",external:!0}];function iJr(){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:aJr.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(Ta,{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 oJr(){const{data:e={},isLoading:t,error:n}=Zp(),[r,s]=y.useState(""),[a,i]=y.useState("all");if(n&&ms(n))return o.jsx(or,{children:o.jsx(Vs,{})});if(n&&vs(n))return o.jsx(or,{children:o.jsx($s,{resource:"scorers"})});if(n)return o.jsx(or,{children:o.jsx(Li,{title:"Failed to load scorers",message:n.message})});if(Object.keys(e).length===0&&!t)return o.jsx(or,{children:o.jsx(NHr,{})});const l=a!=="all"||r!=="",c=()=>{s(""),i("all")};return o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx(AHr,{search:r,onSearchChange:s,sourceFilter:a,onSourceFilterChange:i,onReset:c,hasActiveFilters:l})}),o.jsx(THr,{scorers:e,isLoading:t,search:r,sourceFilter:a})]})}function lJr(){const{scorerId:e}=wr(),[t,n]=Ei(),r=t.get("scoreId")??void 0,[s,a]=y.useState(r),[i,l]=y.useState({value:"all",label:"All Entities",type:"ALL"}),{scorer:c,error:u}=CHr(e),{data:d={},isLoading:f,error:p}=cm(),{isLoading:h,error:m}=Cy(),{data:g=[],isLoading:v,error:b,isFetchingNextPage:w,hasNextPage:S,setEndOfListElement:O}=_Hr({scorerId:e,entityId:i?.value==="all"?void 0:i?.value,entityType:i?.type==="ALL"?void 0:i?.type}),_=y.useMemo(()=>c?.agentIds?.filter(B=>d[B]).map(B=>({value:B,label:d[B].name,type:"AGENT"}))||[],[c?.agentIds,d]),C=y.useMemo(()=>c?.workflowIds?.map(B=>({value:B,label:B,type:"WORKFLOW"}))||[],[c?.workflowIds]),j=y.useMemo(()=>[{value:"all",label:"All Entities",type:"ALL"},..._,...C],[_,C]),E=t.get("entity")??"all",N=j.find(B=>B.value===E);N&&N.value!==i?.value&&l(N),y.useEffect(()=>{if(u){const B=u instanceof Error?u.message:"Failed to load scorer";Be.error(`Error loading scorer: ${B}`)}},[u]),y.useEffect(()=>{if(p){const B=p instanceof Error?p.message:"Failed to load agents";Be.error(`Error loading agents: ${B}`)}},[p]),y.useEffect(()=>{if(m){const B=m instanceof Error?m.message:"Failed to load workflows";Be.error(`Error loading workflows: ${B}`)}},[m]);const I=B=>{B?.value&&n(M=>{const Q=new URLSearchParams(M);return Q.set("entity",B.value),Q})};y.useEffect(()=>{const B=t.get("scoreId")??void 0;if(B===s)return;if(!B){a(void 0);return}g.find(Q=>Q.id===B)&&a(B)},[t,g]);const P=y.useCallback(B=>{a(B||void 0),n(M=>{const Q=new URLSearchParams(M);return B?Q.set("scoreId",B):Q.delete("scoreId"),Q})},[n]);if(!c)return null;const $=ms(u)||ms(p)||ms(m),z=u&&vs(u),D=!$&&!z&&(u||p||m),q=!v&&g.length===0,W=i?.value!=="all",L=c?.scorer?.source==="stored"?o.jsx(Sy,{owner:"scorer-detail",children:o.jsxs(fe,{variant:"default",as:ui,to:`/cms/scorers/${e}/edit`,size:"sm",children:[o.jsx(Bh,{})," Edit"]})}):null;if($||z||D||q&&!W){const B=(u instanceof Error?u.message:void 0)??(p instanceof Error?p.message:void 0)??(m instanceof Error?m.message:void 0)??"An unexpected error occurred";return o.jsxs(Lt,{width:"wide",height:"full",children:[L,o.jsx(Lt.MainArea,{isCentered:!0,children:$?o.jsx(Vs,{}):z?o.jsx($s,{resource:"scorers"}):D?o.jsx(Li,{title:"Failed to load scorer",message:B}):o.jsx(xHr,{})})]})}return o.jsxs(Lt,{width:"wide",children:[L,o.jsx(Lt.TopArea,{children:o.jsx(wHr,{selectedEntity:i,entityOptions:j,onEntityChange:I,onReset:()=>{n(B=>{const M=new URLSearchParams(B);return M.set("entity","all"),M})},isLoading:v||f||h})}),o.jsx(bHr,{scores:g,isLoading:v,selectedScoreId:s,isFetchingNextPage:w,hasNextPage:S,setEndOfListElement:O,onScoreClick:P,errorMsg:b?.message})]})}function cJr({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(Mt,{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 RLt=[{value:"dark",label:"Dark",Icon:aln},{value:"light",label:"Light",Icon:hcn},{value:"system",label:"System",Icon:yit}],uJr=e=>RLt.some(t=>t.value===e);function dJr({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 fJr=()=>{const{baseUrl:e,headers:t,apiPrefix:n}=nke(),{theme:r,setTheme:s}=hN();return o.jsx(Lt,{width:"narrow",children:o.jsxs(Lt.MainArea,{className:"flex flex-col gap-5 mt-6",children:[o.jsx(Lfe,{title:"Theme",description:"Customize the appearance of the studio.",children:o.jsx(cJr,{label:"Theme mode",htmlFor:"theme",children:o.jsxs($a,{value:r,onValueChange:a=>{uJr(a)&&s(a)},children:[o.jsx(Da,{id:"theme",className:"w-full sm:w-48",children:o.jsx(Ma,{className:"inline-flex min-w-0 max-w-full items-center"})}),o.jsx(La,{children:RLt.map(a=>o.jsx(Yr,{value:a.value,children:o.jsx(dJr,{option:a})},a.value))})]})})}),o.jsx(Lfe,{title:"Mastra Connection",description:"Configure the Mastra instance URL, API prefix, and request headers used by the studio.",children:o.jsx(E5t,{initialConfig:{baseUrl:e,headers:t,apiPrefix:n}})})]})})};function pJr(){const[e]=Ei(),t=qs(),n=e.get("redirect")||"/",r=()=>{n.startsWith("http")?window.location.href=n:t(n,{replace:!0})};return o.jsx(ALt,{redirectUri:n,onSuccess:r,initialMode:"signup"})}function hJr(e){return e.replace(/\/$/,"").split("/").pop()}function qW({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 mJr({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(Ko,{})," ",a.agents.length]}),a?.tools&&a.tools.length>0&&o.jsxs("li",{children:[o.jsx(ff,{})," ",a.tools.length]}),a?.networks&&a.networks.length>0&&o.jsxs("li",{children:[o.jsx(bit,{})," ",a.networks.length]}),a?.workflows&&a.workflows.length>0&&o.jsxs("li",{children:[o.jsx(uU,{})," ",a.workflows.length]}),a?.mcp&&a.mcp.length>0&&o.jsxs("li",{children:[o.jsx(t1,{})," ",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(ACt,{})," ",hJr(a.githubUrl)]})})]},a.slug)})})}function gJr({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(Gj,{name:"search-templates",label:"Search templates",labelIsHidden:!0,value:i,onChange:f=>l?.(f.target.value),placeholder:"Search Template"}),o.jsx(uc,{label:"Filter by tag",labelIsHidden:!0,name:"filter-tag",value:t,onValueChange:s,options:e}),o.jsx(uc,{label:"Filter by provider",labelIsHidden:!0,name:"filter-provider",value:r,onValueChange:a,options:n}),c&&o.jsxs(fe,{onClick:c,children:["Reset ",o.jsx(gs,{})]})]})}function vJr(){const{data:e,isLoading:t}=ESr(),{templates:n,tags:r,providers:s}=e??{templates:[],tags:[],providers:[]},[a,i]=y.useState("all"),[l,c]=y.useState("all"),[u,d]=y.useState(""),f=[{value:"all",label:"Any tag"}];(r||[]).forEach(w=>{f.push({value:w,label:w})});const p=[{value:"all",label:"Any provider"}];(s||[]).forEach(w=>{p.push({value:w,label:w})});const h=(w,S)=>{S==="tag"?i(w):S==="provider"&&c(w)},m=w=>{d(w)},g=()=>{i("all"),c("all"),d("")},v=n.filter(w=>!(u&&!w.title.toLowerCase().includes(u)&&!w.description.toLowerCase().includes(u)||a!=="all"&&!w.tags.includes(a)||l!=="all"&&!w.supportedProviders.includes(l))),b=u||a!=="all"||l!=="all";return o.jsxs(ls,{children:[o.jsx(bxe,{children:o.jsxs(Vht,{children:[o.jsx(Ve,{children:o.jsx(Nv,{})}),"Templates"]})}),o.jsxs("div",{className:K("overflow-y-auto w-full h-full px-8 pb-12 z-10"),children:[o.jsx(gJr,{selectedTag:a,onTagChange:w=>h(w,"tag"),tagOptions:f,selectedProvider:l,onProviderChange:w=>h(w,"provider"),providerOptions:p,searchTerm:u,onSearchChange:m,onReset:b?g:void 0,className:"max-w-[80rem]",isLoading:t}),o.jsx(mJr,{templates:v,linkComponent:ui,className:"max-w-[80rem] mx-auto",isLoading:t})]})]})}const yJr="1.45.0-alpha.0";function bJr({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(xp,{className:"text-yellow-500"}),title:"Template Installed with Warnings"}:{icon:o.jsx(aon,{}),title:"Template Installation Failed"},{icon:l,title:c}=i();return o.jsxs(qW,{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 xJr({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(qW,{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(xit,{})]}),o.jsx(uc,{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(Qt,{})," Loading variables..."]}):Object.entries(r).map(([p,h])=>o.jsxs(y.Fragment,{children:[o.jsx(hO,{name:`env-${p}`,labelIsHidden:!0,label:"Key",value:p,disabled:!0,className:"w-full"}),o.jsx(hO,{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(C5t,{defaultProvider:u||"",defaultModel:d||"",updateModel:f||(()=>Promise.resolve({message:"Updated"})),closeEditor:()=>{},autoSave:!0,selectProviderPlaceholder:"Provider"})]})]}),t&&!l&&o.jsx(fe,{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(Qt,{className:"w-4 h-4"})," Installing..."]}):o.jsxs(o.Fragment,{children:["Install ",o.jsx(em,{})]})})]})})}function wJr({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(Nv,{}),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(xx,{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(Rve,{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(ACt,{}),n?.split("/")?.pop()]})]}),s&&o.jsx(U0e,{data:s,labelsAreHidden:!0,isLoading:r})]})]})}function SJr({name:e,streamResult:t,runId:n,workflowInfo:r}){const s=t?.phase||"initializing",a=t?.payload?.workflowState,i=t?.payload?.currentStep,l=t?.error,c=a?.steps||{},u=Object.keys(c).length>0,d=g=>g==="input"||g.endsWith(".input")||g.startsWith("Mapping_")&&/[0-9a-f]{8}/.test(g)||/[0-9a-f]{8,}/.test(g)?!1:r?.allSteps?g in r.allSteps:!0,f=Object.entries(c).filter(([g,v])=>d(g)),p=f.length,h=()=>{switch(s){case"initializing":return"Preparing template installation...";case"processing":return`Installing ${e} template`;case"completed":return"Template installation completed!";case"error":return"Template installation failed";default:return"Installing template..."}},m=f.map(([g,v])=>({id:g,status:v?.status,description:v?.description,title:g.charAt(0).toUpperCase()+g.slice(1).replace(/-/g," "),isActive:i?.id===g}));return o.jsxs(qW,{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(vUn,{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(mln,{}),l||"Something went wrong"]}),u&&o.jsx(gUn,{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(Qt,{}),o.jsx("p",{children:"This may take some time..."})]})]})}function kJr({name:e,installedEntities:t}){return o.jsxs(qW,{className:K("grid items-center justify-items-center gap-4 content-center","[&>svg]:w-8 [&>svg]:h-8"),children:[o.jsx(xit,{}),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(U0e,{data:t})]})}function OJr(){const{templateSlug:e}=wr(),[t,n]=Ei(),[r,s]=y.useState(""),[a,i]=y.useState(""),[l,c]=y.useState(""),[u,d]=y.useState({}),[f,p]=y.useState([]),[h,m]=y.useState(null),[g,v]=y.useState(!1),[b,w]=y.useState(""),[S,O]=y.useState(!1),[_,C]=y.useState(!1),[j,E]=y.useState([]),{data:N,isLoading:I}=jSr({repoOrSlug:e,owner:"mastra-ai"}),$=yJr?.includes("beta")??!1?"beta":"main",{data:z,isLoading:D}=TSr({repo:N?.githubUrl?new URL(N.githubUrl).pathname.split("/")[2]:`template-${e}`,owner:"mastra-ai",branch:$}),{data:q,isLoading:W}=NSr(),{mutateAsync:L,isPending:F}=ISr(),{mutateAsync:B}=ASr(),{streamInstall:M,streamResult:Q,isStreaming:V}=PSr(q),{observeInstall:R,streamResult:U,isStreaming:Z}=$Sr(q);y.useEffect(()=>{const ne=t.get("runId");ne&&!g&&!h&&!V&&!Z&&(console.info("🔄 Checking completed run after hot reload:",{runId:ne}),w(ne),B({runId:ne}).then(le=>{const pe=le.snapshot;if(pe?.status==="success"&&pe?.result?.success)v(!0);else if(pe?.result?.success===!1)if(pe?.result?.validationResults&&!pe?.result?.validationResults?.valid&&pe?.result?.validationResults?.remainingErrors>0){const{remainingErrors:he,errors:be}=pe.result.validationResults,Se=`Template installation completed but ${he} validation issue${he>1?"s":""} remain unresolved.`;m(Se),E(be||[])}else{const he=pe?.result?.message||pe?.result?.error||"Template installation failed";m(typeof he=="string"?he:String(he))}}).catch(le=>{console.error("❌ Failed to fetch run details:",le),m("Failed to retrieve installation status after reload")}))},[t,g,h,V,Z,B]),y.useEffect(()=>{const ne=t.get("runId"),le=t.get("resume"),pe=t.get("provider");if(ne&&le==="true"&&pe&&!V&&!Z&&!S&&!_&&q){w(ne),O(!0);try{B({runId:ne}).then(se=>{if(se.snapshot?.status==="running")return R.mutateAsync({runId:ne})}).then(()=>{n(se=>{const he=new URLSearchParams(se);return he.delete("resume"),he})}).catch(se=>{console.error("❌ Failed to resume template installation:",se),se.message?.includes("404")||se.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(se){console.error("❌ Auto-resume failed with error:",se),m("Failed to resume template installation. Please refresh and try again.")}}},[t,e,V,Z,S,_,q,B,R,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(ff,{})},{key:"agents",label:"Agents",value:N?.agents?.length?N.agents.map(ne=>ne).join(", "):"n/a",icon:o.jsx(Ko,{})},{key:"workflows",label:"Workflows",value:N?.workflows?.length?N.workflows.map(ne=>ne).join(", "):"n/a",icon:o.jsx(uU,{})},{key:"providers",label:"Providers",value:N?.supportedProviders?.length?N.supportedProviders.join(", "):"n/a",icon:o.jsx(Eb,{})},{key:"tags",label:"Tags",value:N?.tags?.length?N.tags.join(", "):"n/a",icon:o.jsx(YT,{})}],ee=[{...te[0]},{...te[1]},{...te[2]}].filter(ne=>ne.value!=="n/a");y.useEffect(()=>{z&&d(z)},[z]),y.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 J=ne=>{s(ne)},ie=async ne=>(i(ne.provider),c(ne.modelId),{message:"Model updated successfully"}),ue=async()=>{const ne=Object.entries(u).reduce((le,[pe,se])=>(se===""&&le.push(pe),le),[]);if(ne.length>0){p(ne);return}if(N){m(null),v(!1),w(""),C(!0);try{const pe={repo:N.githubUrl||`https://github.com/mastra-ai/template-${N.slug}`,ref:$,slug:N.slug,variables:u},{runId:se}=await L({});w(se),n(he=>{const be=new URLSearchParams(he);return be.set("runId",se),be.set("resume","true"),be.set("provider",r||"openai"),be}),await M.mutateAsync({inputData:pe,selectedModel:{provider:a,modelId:l},runId:se})}catch(le){C(!1),m(le?.message||"Template installation failed"),console.error("Template installation failed",le)}}},Y=ne=>{const{name:le,value:pe}=ne.target;pe.trim()===""?p(se=>[...se,le]):p(se=>se.filter(he=>he!==le)),d(se=>({...se,[le]: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(wJr,{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(SJr,{name:N.title,streamResult:Z?U:Q,runId:b,workflowInfo:q}),g&&o.jsx(kJr,{name:N.title,installedEntities:ee,linkComponent:ui}),h&&o.jsx(bJr,{errorMsg:h,validationErrors:j.length>0?j:Q?.validationResults?.errors||U?.validationResults?.errors}),!V&&!Z&&!g&&!h&&o.jsx(xJr,{providerOptions:X,selectedProvider:r,onProviderChange:J,variables:u,setVariables:d,errors:f,setErrors:p,handleInstallTemplate:ue,handleVariableChange:Y,isLoadingEnvVars:D||W,isInstalling:F,defaultModelProvider:a,defaultModelId:l,onModelUpdate:ie})]})]})})})}const _Jr=()=>{const{toolId:e,agentId:t}=wr();return o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(aWr,{toolId:e,agentId:t})})},CJr=()=>{const{toolId:e}=wr();return o.jsx("div",{className:"h-full w-full overflow-y-hidden",children:o.jsx(IKr,{toolId:e})})};function EJr(){const{traceId:e}=wr(),[t,n]=Ei(),r=qs(),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]=y.useState(s??null),[d,f]=y.useState(),[p,h]=y.useState(i),[m,g]=y.useState(0),[v,b]=y.useState(!1),{data:w,isLoading:S,error:O}=GSe(e),_=y.useMemo(()=>w?.spans??[],[w?.spans]),C=y.useMemo(()=>_.find(ie=>ie.parentSpanId==null),[_]),{data:j,isLoading:E}=rD(e,c??"");y.useEffect(()=>g(0),[e,c]);const{data:N,isLoading:I}=Zp(),{data:P,isLoading:$}=D5t({traceId:e,spanId:c??void 0,page:m}),[z,D]=y.useState(0);y.useEffect(()=>D(0),[e,c]);const{data:q,isLoading:W}=kLt({traceId:e,page:z});y.useEffect(()=>{if(l&&P?.scores&&!d){const ie=P.scores.find(ue=>ue.id===l);ie&&f(ie)}},[l,P?.scores,d]);const L=y.useCallback(ie=>{const ue=new URLSearchParams(t);for(const[Y,ne]of Object.entries(ie))ne===null||ne===""?ue.delete(Y):ue.set(Y,ne);n(ue,{replace:!0})},[t,n]),F=y.useCallback(ie=>{const ue=ie??null,Y=ue===c;u(ue),Y||(f(void 0),h("details"),L({spanId:ue,tab:null,scoreId:null}))},[c,L]),B=y.useCallback(()=>{u(null),f(void 0),h("details"),L({spanId:null,tab:null,scoreId:null})},[L]),M=y.useCallback(ie=>{u(ie),f(void 0),h("details"),L({spanId:ie,tab:null,scoreId:null})},[L]),{handlePreviousSpan:Q,handleNextSpan:V}=JSe(_,c,M),R=y.useCallback(ie=>{const ue=ie;h(ue),f(void 0),L({tab:ue==="details"?null:ue,scoreId:null})},[L]),U=y.useCallback(ie=>{f(ie),L({scoreId:ie.id})},[L]),Z=y.useCallback(()=>{f(void 0),L({scoreId:null})},[L]),X=y.useCallback(()=>{r("/observability")},[r]),te=y.useCallback(()=>{h("scoring"),C&&c!==C.spanId?(u(C.spanId),f(void 0),L({spanId:C.spanId,tab:"scoring",scoreId:null})):L({tab:"scoring"})},[C,c,L]),ee=C?o.jsx(Sy,{owner:"trace-detail",children:o.jsxs($r,{children:[o.jsxs(fe,{tooltip:"Evaluate Trace","aria-label":"Evaluate Trace",onClick:te,children:[o.jsx(rin,{}),"Evaluate"]}),o.jsxs(fe,{tooltip:"Save as Dataset Item","aria-label":"Save as Dataset Item",onClick:()=>b(!0),children:[o.jsx(sd,{}),"Save"]})]})}):null,J=C?o.jsx(Lt.Row,{children:o.jsx(Lt.Column,{children:o.jsx(lEt,{rootSpan:C,numOfCol:3})})}):null;return O?o.jsxs(Lt,{height:"full",children:[ee,J&&o.jsx(Lt.TopArea,{children:J}),o.jsx(Lt.MainArea,{isCentered:!0,children:o.jsx(dEt,{error:O,resource:"traces",errorTitle:"Failed to load trace"})})]}):o.jsxs(Lt,{children:[ee,J&&o.jsx(Lt.TopArea,{children:J}),o.jsx(yLt,{rootSpanId:C?.spanId,traceId:e,isOpen:v,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(WSe,{traceId:e,spans:_,isLoading:S,onClose:X,onSpanSelect:F,onEvaluateTrace:te,initialSpanId:c,placement:"trace-page",timelineChartWidth:c?"default":"wide"}),c&&!S&&o.jsxs("div",{className:K("grid gap-4 max-h-full min-h-0 overflow-auto",d?"grid-rows-[1fr_1fr]":"grid-rows-[1fr]"),children:[o.jsx(ZSe,{traceId:e,spanId:c,span:j?.span,isLoading:E,onClose:B,onPrevious:Q,onNext:V,activeTab:p,onTabChange:R,feedbackTabBadge:q?.pagination?.total??void 0,feedbackTabSlot:()=>o.jsx(xLt,{feedbackData:q,onPageChange:D,isLoadingFeedbackData:W}),scoringTabBadge:P?.pagination?.total??void 0,scoringTabSlot:({span:ie,traceId:ue,spanId:Y})=>o.jsxs("div",{className:"grid gap-6",children:[o.jsx(SLt,{traceId:ue,isTopLevelSpan:!ie.parentSpanId,spanId:Y,entityType:ie.attributes?.agentId||ie.entityType===Rs.AGENT?"Agent":ie.attributes?.workflowId||ie.entityType===Rs.WORKFLOW_RUN?"Workflow":void 0,scorers:N,isLoadingScorers:I}),o.jsx(wLt,{scoresData:P,onPageChange:g,isLoadingScoresData:$,onScoreSelect:U})]})}),d&&o.jsx(EEe,{score:d,onClose:Z})]})]})]})}function jJr(){const{data:e,isLoading:t,error:n}=Cy(),[r,s]=y.useState("");return n&&ms(n)?o.jsx(or,{children:o.jsx(Vs,{})}):n&&vs(n)?o.jsx(or,{children:o.jsx($s,{resource:"workflows"})}):n?o.jsx(or,{children:o.jsx(Li,{title:"Failed to load workflows",message:n.message})}):Object.keys(e||{}).length===0&&!t?o.jsx(or,{children:o.jsx(U5r,{})}):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(kf,{onSearch:s,label:"Filter workflows",placeholder:"Filter by name or description"})}),o.jsxs(fe,{as:ui,to:"/workflows/schedules",variant:"primary",className:"shrink-0",children:[o.jsx(TM,{}),"Schedules"]})]})}),o.jsx(B5r,{workflows:e||{},isLoading:t,search:r})]})}const TJr={active:"bg-accent1",paused:"bg-accent3"},NJr={active:"text-accent1",paused:"text-accent3"},PLt=({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 ${TJr[e]}`,"aria-hidden":!0}),o.jsx("span",{className:`text-ui-sm ${NJr[e]}`,children:e})]}),xj=e=>!e||e<=0?"—":new Date(e).toLocaleString(),j2=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 $Lt({status:e}){const{icon:t,color:n}=IJr(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 IJr(e){switch(e){case"success":return{icon:o.jsx(oa,{size:14}),color:"text-accent1"};case"failed":return{icon:o.jsx(gs,{size:14}),color:"text-accent2"};case"running":return{icon:o.jsx(Qt,{}),color:"text-neutral3"};case"suspended":return{icon:o.jsx(sU,{size:14}),color:"text-accent3"};case"canceled":return{icon:o.jsx(mf,{size:14}),color:"text-neutral3"};case"pending":case"waiting":return{icon:o.jsx(Gk,{size:14}),color:"text-neutral3"};default:return{icon:null,color:"text-neutral3"}}}const BZe="auto auto auto auto 1fr";function AJr(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 RJr(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 PJr=3e4,$Jr=5*6e4;function MJr({triggers:e,isLoading:t,workflowId:n,hasNextPage:r,isFetchingNextPage:s,setEndOfListElement:a}){const{Link:i,paths:l}=vn();return t?o.jsx(Go,{columns:BZe}):e.length===0?o.jsx(ge,{variant:"ui-md",className:"text-neutral4 p-4",children:"No trigger history yet."}):o.jsxs(xe,{columns:BZe,className:"min-w-0",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Run"}),o.jsx(xe.TopCell,{children:"Status"}),o.jsx(xe.TopCell,{children:"Started"}),o.jsx(xe.TopCell,{children:"Duration"}),o.jsx(xe.TopCell,{children:" "})]}),e.map(c=>{const u=c.actualFireAt-c.scheduledFireAt,d=RJr(u),f=`Scheduled ${xj(c.scheduledFireAt)} — published ${xj(c.actualFireAt)} (drift ${d})`,p=c.outcome==="failed",h=p?c.error:c.run?.error,m=Math.abs(u),g=!p&&m>PJr&&m<=$Jr,v=`${c.scheduleId}-${c.runId}-${c.actualFireAt}`,b=!!(n&&c.runId&&!p),w=o.jsx("span",{className:b?"text-accent1 font-mono text-ui-sm whitespace-nowrap":"text-neutral3 font-mono text-ui-sm whitespace-nowrap",children:c.runId}),S=o.jsxs(o.Fragment,{children:[o.jsx(xe.Cell,{height:"compact",children:w}),o.jsx(xe.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(xp,{size:14}),"publish failed"]}):c.run?o.jsx($Lt,{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(Hn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx("span",{className:"text-accent2 inline-flex",children:o.jsx(xp,{size:14})})}),o.jsx(Bn,{children:h})]}):null]})}),o.jsx(xe.Cell,{height:"compact",children:o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx("span",{title:f,children:j2(c.actualFireAt)}),g?o.jsxs(Hn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx("span",{className:"text-accent3 inline-flex",children:o.jsx(xp,{size:14})})}),o.jsxs(Bn,{children:["Published ",d," after the scheduled fire time"]})]}):null]})}),o.jsx(xe.Cell,{height:"compact",children:c.run?o.jsx("span",{children:AJr(c.run.durationMs)}):o.jsx("span",{className:"text-neutral4",children:"—"})}),o.jsx(xe.Cell,{height:"compact",children:" "})]});return b?o.jsx(xe.RowLink,{to:l.workflowRunLink(n,c.runId),LinkComponent:i,children:S},v):o.jsx(xe.RowStatic,{children:S},v)}),o.jsx(xe.NextPageLoading,{isLoading:s,hasMore:r,setEndOfListElement:a})]})}const DJr=e=>{const t=We();return xt({queryKey:["schedule",e],enabled:!!e,queryFn:async()=>{if(!e)throw new Error("scheduleId is required");return t.getSchedule(e)}})},UZe=25,LJr=e=>{const t=We(),{inView:n,setRef:r}=C_(),s=N1({queryKey:["schedule-triggers",e],enabled:!!e,initialPageParam:void 0,queryFn:async({pageParam:u})=>e?t.listScheduleTriggers(e,{limit:UZe,toActualFireAt:u}):{triggers:[]},getNextPageParam:u=>{if(!(!u?.triggers?.length||u.triggers.length<UZe))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 y.useEffect(()=>{n&&i&&!l&&c()},[n,i,l,c]),{...s,data:a,setEndOfListElement:r}},FJr=e=>{const t=We(),n=Ur();return An({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"]}),Be.success(s==="pause"?"Schedule paused":"Schedule resumed")},onError:r=>{Be.error(r.message)}})};function b8({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 zJr(){const{scheduleId:e}=wr(),{paths:t}=vn(),{data:n,error:r}=DJr(e),{data:s,isLoading:a,error:i,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u}=LJr(e),d=FJr(e);if(r&&ms(r))return o.jsx(or,{children:o.jsx(Vs,{})});if(r&&vs(r))return o.jsx(or,{children:o.jsx($s,{resource:"schedules"})});if(r)return o.jsx(or,{children:o.jsx(Li,{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(fe,{as:ui,to:t.schedulesLink(),variant:"ghost",children:[o.jsx(xc,{}),"Back to schedules"]}),f?o.jsx(fe,{as:ui,to:t.workflowLink(f),variant:"ghost",children:"Open workflow"}):null,n?o.jsx(fe,{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(wit,{}),"Pause"]}):o.jsxs(o.Fragment,{children:[o.jsx(Uh,{}),"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(b8,{label:"Workflow",children:f?o.jsx(ui,{to:t.workflowLink(f),className:"text-accent1 hover:underline",children:f}):"—"}),o.jsxs(b8,{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(b8,{label:"Status",children:o.jsx(PLt,{status:n.status})}),o.jsx(b8,{label:"Next fire",children:o.jsx("span",{title:xj(n.nextFireAt),children:j2(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(Li,{title:"Failed to load trigger history",message:i.message}):o.jsx(MJr,{triggers:s??[],isLoading:a,workflowId:f,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u})]})]}):null]})}const qZe="minmax(0, 1.2fr) minmax(0, 1.4fr) minmax(0, 1fr) auto auto auto";function BJr({schedules:e,isLoading:t,search:n=""}){const{paths:r,Link:s}=vn(),a=y.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(Go,{columns:qZe}):o.jsxs(xe,{columns:qZe,variant:"striped",className:"min-w-0",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Workflow"}),o.jsx(xe.TopCell,{children:"Schedule ID"}),o.jsx(xe.TopCell,{children:"Cron"}),o.jsx(xe.TopCell,{children:"Status"}),o.jsx(xe.TopCell,{children:"Next fire"}),o.jsx(xe.TopCell,{children:"Last run"})]}),a.length===0&&n?o.jsx(xe.NoMatch,{message:"No schedules match your search"}):null,a.length===0&&!n?o.jsx(xe.NoMatch,{message:"No schedules configured"}):null,a.map(i=>o.jsxs(xe.RowLink,{to:r.scheduleLink(i.id),LinkComponent:s,children:[o.jsx(xe.NameCell,{children:i.target.workflowId}),o.jsx(xe.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(xe.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(xe.Cell,{height:"compact",children:o.jsx(PLt,{status:i.status})}),o.jsx(xe.Cell,{height:"compact",children:o.jsx("span",{className:"whitespace-nowrap",title:xj(i.nextFireAt),children:j2(i.nextFireAt)})}),o.jsx(xe.Cell,{height:"compact",children:i.lastRun?o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx($Lt,{status:i.lastRun.status}),o.jsx("span",{className:"text-neutral4 text-ui-sm",title:xj(i.lastFireAt),children:i.lastFireAt?j2(i.lastFireAt):""})]}):i.lastFireAt?o.jsx("span",{className:"whitespace-nowrap",title:xj(i.lastFireAt),children:j2(i.lastFireAt)}):o.jsx("span",{className:"text-neutral4",children:"Never"})})]},i.id))]})}function UJr({workflowId:e}={}){const{data:t,isLoading:n,error:r}=rke(e?{workflowId:e}:{}),[s,a]=y.useState("");return r?o.jsx(Li,{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(kf,{onSearch:a,label:"Filter schedules",placeholder:"Filter by id or workflow"})}),o.jsx("div",{className:"overflow-y-auto",children:o.jsx(BJr,{schedules:t??[],isLoading:n,search:s})})]})}function qJr(){const[e]=Ei(),t=e.get("workflowId")??void 0,{error:n}=rke(t?{workflowId:t}:{});return n&&ms(n)?o.jsx(or,{children:o.jsx(Vs,{})}):n&&vs(n)?o.jsx(or,{children:o.jsx($s,{resource:"schedules"})}):o.jsx(Lt,{children:o.jsx("div",{className:"h-full",children:o.jsx(UJr,{workflowId:t})})})}function VJr(e){const t=new Blob([JSON.stringify(e??null)]).size;return t<1024?`${t} B`:`${(t/1024).toFixed(1)} KB`}function HJr(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 WJr({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(Ve,{children:o.jsx(sU,{})}),"Step suspended"]}),o.jsx(gn,{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?Yh(Gh(px(i.resumeSchema))):Jf(cr(),xT());return o.jsx(ZJr,{step:s,stepSchema:l,description:i.description,isStreaming:n,onResume:r},`${s.runId}-${s.stepId}-${a}`)})]})}function ZJr({step:e,stepSchema:t,description:n,isStreaming:r,onResume:s}){const[a,i]=y.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(Ve,{children:o.jsx(oln,{})}),"The step is asking"]}),o.jsxs(Ip,{open:a,onOpenChange:i,children:[o.jsxs(cf,{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(Ve,{children:o.jsx(Fs,{className:K("transition-transform text-neutral3",{"transform rotate-90":a})})}),o.jsx(ge,{as:"span",variant:"ui-md",className:"text-neutral6 truncate",children:HJr(e.suspendPayload,e.stepId)})]}),o.jsx(ge,{as:"span",variant:"ui-sm",className:"text-neutral3 shrink-0",children:VJr(e.suspendPayload)})]}),o.jsx(uf,{children:o.jsx("div",{"data-testid":"suspended-payload",className:"pt-2",children:o.jsx(as,{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(Ve,{children:o.jsx(uln,{})}),"Your response"]}),o.jsx("div",{className:"-mx-5",children:o.jsx(V7,{schema:t,isSubmitLoading:r,submitButtonLabel:"Resume",submitButtonIcon:o.jsx(Uh,{}),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 GJr(){const{result:e,runSnapshot:t,workflow:n,runId:r,isStreamingWorkflow:s}=y.useContext(bd),{runId:a}=wr(),i=Cjt(e,r??""),l=V1r(),c=!!a,u=t?.status==="suspended";return s||!n||i.length===0||c&&!u?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(WJr,{suspendedSteps:i,workflow:n,isStreaming:s,onResume:l})},r)}const QJr=e=>e.includes("."),YJr=e=>e==="input"||e.endsWith(".input"),XJr=1;function KJr(e){return`${Number((e/1e3).toPrecision(3))}s`}function JJr(e,t){const n=Object.entries(e).filter(([i])=>!YJr(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,XJr);return{stepId:i,step:l,status:l.status,offsetPct:f,widthPct:p,durationMs:d,isRunning:c,isNestedEntry:QJr(i)}})}const ees=({status:e})=>o.jsxs(Ve,{children:[e==="success"&&o.jsx(Ymr,{className:"text-accent1"}),e==="failed"&&o.jsx(Xmr,{className:"text-accent2"}),e==="suspended"&&o.jsx(sU,{className:"text-accent3"}),e==="waiting"&&o.jsx(git,{className:"text-accent5"}),e==="running"&&o.jsx(ba,{className:"text-accent6 animate-spin"})]}),tes={success:"bg-accent1",failed:"bg-accent2",suspended:"bg-accent3",waiting:"bg-accent5",running:"bg-accent6"};function MLt(e){return e.split(/[-_.\s]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}const VZe=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{value:e},nes=e=>{const t=e;return p2t({duration:t.duration,date:t.date,isForEach:t.isForEach,mapConfig:t.mapConfig,canSuspend:t.canSuspend,isParallel:t.isParallel,stepGraph:t.stepGraph})},res=({row:e,index:t,isSelected:n,isHovered:r,onSelectStep:s,onHoverStep:a,onOpenInput:i,onOpenOutput:l})=>{const c=nes(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(ees,{status:e.status})}),o.jsx("div",{className:"flex justify-center",children:o.jsx(fe,{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(ocn,{})})}),o.jsx("div",{className:"flex overflow-hidden",children:o.jsx(SB,{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:MLt(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 ${tes[e.status]}`,style:{left:`${e.offsetPct}%`,width:`${e.widthPct}%`}})}),o.jsx("div",{className:"flex justify-center",children:o.jsx(fe,{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(acn,{})})}),o.jsx(ge,{as:"span",variant:"ui-sm",className:"w-20 justify-self-end text-right text-neutral3 tabular-nums",children:KJr(e.durationMs)})]},`timeline-item-${e.stepId}-${t}`)};function ses(){const{steps:e}=CD(),{selectedStepId:t,hoverStepId:n,setSelectedStepId:r,setHoverStepId:s}=f2t(),[a,i]=y.useState(()=>Date.now()),[l,c]=y.useState(!1),[u,d]=y.useState(null),f=y.useRef(null);b0e(f,{enabled:!l});const p=JJr(e,a),h=p.some(m=>m.isRunning);return y.useEffect(()=>{if(!h)return;const m=setInterval(()=>i(Date.now()),100);return()=>clearInterval(m)},[h]),y.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(ea,{className:K("h-4 w-4 transition-transform",l&&"-rotate-90")})})]}),!l&&o.jsx("div",{ref:f,"data-testid":"workflow-timeline-list",className:"flex min-h-0 flex-col gap-2 overflow-y-auto",children:p.map((m,g)=>o.jsx(res,{row:m,index:g,isSelected:t===m.stepId,isHovered:n===m.stepId,onSelectStep:r,onHoverStep:s,onOpenInput:v=>d({type:"input",stepId:v.stepId,data:VZe(v.step.input)}),onOpenOutput:v=>d({type:"output",stepId:v.stepId,data:VZe(v.step.output)})},`timeline-item-${m.stepId}-${g}`))})]})}),o.jsx(yr,{open:!!u,onOpenChange:m=>!m&&d(null),children:u&&o.jsx(Ejt,{data:u.data,title:`${MLt(u.stepId)} ${u.type==="input"?"input":"output"}`})})]})}const HZe=()=>{const{workflowId:e}=wr(),{data:t,isLoading:n,error:r}=dD(e);return r&&ms(r)?o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})}):r&&vs(r)?o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx($s,{resource:"workflows"})}):o.jsx(d2t,{children:o.jsx(jke,{children:o.jsx("div",{className:"flex h-full min-h-0 flex-col",children:o.jsxs("div",{className:"relative min-h-0 flex-1 p-2 pb-0",children:[o.jsx(T2t,{workflowId:e,workflow:t??void 0,isLoading:n}),o.jsx(GJr,{}),o.jsx(ses,{})]})})})})};function aes(e,t){if(e==null)return{};var n,r,s=Ppt(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 Ege(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 ies(e){if(Array.isArray(e))return Ege(e)}function oes(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function les(e,t){if(e){if(typeof e=="string")return Ege(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)?Ege(e,t):void 0}}function ces(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
767
|
+
]`})]})]})}function tXr({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(Ve,{children:o.jsx(xp,{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 nXr({datasetId:e,open:t,onOpenChange:n,onSuccess:r}){const[s,a]=y.useState("upload"),[i,l]=y.useState(null),[c,u]=y.useState({current:0,total:0}),[d,f]=y.useState(null),[p,h]=y.useState(!1),{parseFile:m,isParsing:g,error:v}=KQr(),{batchInsertItems:b}=Fi(),w=y.useCallback(async I=>{try{const P=await m(I);l(P),a("preview")}catch{}},[m]),S=y.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(P=>({input:P.input,groundTruth:P.groundTruth,metadata:P.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]),O=y.useCallback(()=>{n(!1),r?.(),d&&d.success>0&&Be.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]),_=y.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,j=()=>{switch(s){case"upload":return o.jsx(eXr,{onFileSelect:w,isParsing:g,error:v?.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(tXr,{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(JYr,{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(Qt,{}),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":"",")"]})]})]})]})}},E=()=>{switch(s){case"upload":return o.jsx(fe,{onClick:_,children:"Cancel"});case"preview":return o.jsxs(o.Fragment,{children:[o.jsx(fe,{onClick:()=>a("upload"),children:"Back"}),o.jsxs(fe,{variant:"primary",onClick:S,disabled:!C,children:["Import ",i?.items.length??0," Item",i?.items.length!==1?"s":""]})]});case"importing":return null;case"complete":return o.jsx(fe,{variant:"primary",onClick:O,children:"Done"})}},N={upload:"Import JSON",preview:"Preview Data",importing:"Importing",complete:"Import Complete"};return o.jsx(yr,{open:t,onOpenChange:_,children:o.jsxs(br,{className:"max-w-2xl max-h-[90vh]",children:[o.jsxs(xr,{children:[o.jsx(mr,{children:N[s]}),o.jsx(Qs,{children:"Import dataset items from a JSON file."})]}),o.jsx(Ar,{className:"min-h-[200px] max-h-[50vh] overflow-y-auto",children:j()}),o.jsx(mc,{className:"px-6 pt-4 flex justify-end gap-2",children:E()})]})})}const qEe=e=>{const t=We(),{data:n}=gM(e),r=n?.experiments;return xt({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})},rXr=e=>{const t=We(),{data:n}=gM(e),r=n?.experiments;return xt({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 sXr(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 ELt({datasetId:e,experimentId:t,featuredItemId:n}){const r=We(),{data:s}=Lx(e),{data:a,isLoading:i}=qEe(e),{data:l,isLoading:c}=rXr(e),u=y.useMemo(()=>t?(a??[]).filter(ke=>ke.experimentId===t):a,[a,t]),d=y.useMemo(()=>t?(l??[]).filter(ke=>ke.experimentId===t):l,[l,t]),{updateExperimentResult:f}=Fi(),[p,h]=y.useState(n??null);y.useEffect(()=>{n!==void 0&&h(n)},[n]);const[m,g]=y.useState(null),[v,b]=y.useState(new Set),[w,S]=y.useState(!1),[O,_]=y.useState(!1),[C,j]=y.useState(!1),[E,N]=y.useState(""),[I,P]=y.useState(""),[$,z]=y.useState(""),[D,q]=y.useState([]),[W,L]=y.useState(!1),[F,B]=y.useState(null),M=y.useMemo(()=>F??u??[],[F,u]);y.useEffect(()=>{B(null)},[e,t]),y.useEffect(()=>{u&&F===null&&B(u)},[u,F]);const Q=y.useMemo(()=>{const ke=new Set;if(s?.tags)for(const _e of s.tags)ke.add(_e);for(const _e of M)for(const Ce of _e.tags)ke.add(Ce);return[...ke].sort()},[s,M]),V=y.useCallback(ke=>{!s||!e||(s.tags??[]).includes(ke)},[s,e]),R=y.useMemo(()=>m?m==="__untagged__"?M.filter(ke=>ke.tags.length===0):M.filter(ke=>ke.tags.includes(m)):M,[M,m]),U=y.useMemo(()=>{const ke=new Map;for(const _e of M)for(const Ce of _e.tags)ke.set(Ce,(ke.get(Ce)??0)+1);return[...ke.entries()].sort((_e,Ce)=>Ce[1]-_e[1])},[M]),Z=y.useMemo(()=>M.filter(ke=>ke.tags.length===0).length,[M]),X=y.useMemo(()=>{let ke=0;return m&&ke++,w&&ke++,ke},[m,w]),te=y.useCallback((ke,_e)=>{B(Ee=>(Ee??[]).map($e=>$e.id===ke?{...$e,tags:_e}:$e));const Ce=M.find(Ee=>Ee.id===ke);Ce?.experimentId&&Ce?.datasetId&&f.mutate({datasetId:Ce.datasetId,experimentId:Ce.experimentId,resultId:Ce.id,tags:_e})},[M,f]),ee=y.useCallback((ke,_e)=>{const Ce=M.find(Ee=>Ee.id===ke);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(Ee=>(Ee??[]).map($e=>$e.id===ke?{...$e,rating:_e}:$e))},[M,r]),J=y.useCallback((ke,_e)=>{const Ce=M.find(Ee=>Ee.id===ke);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(Ee=>(Ee??[]).map($e=>$e.id===ke?{...$e,comment:_e}:$e))},[M,r]),ie=y.useCallback(ke=>{const _e=M.find(Ce=>Ce.id===ke);B(Ce=>(Ce??[]).filter(Ee=>Ee.id!==ke)),b(Ce=>{const Ee=new Set(Ce);return Ee.delete(ke),Ee}),p===ke&&h(null),_e?.experimentId&&_e?.datasetId&&f.mutate({datasetId:_e.datasetId,experimentId:_e.experimentId,resultId:_e.id,status:null})},[M,f,p]),ue=y.useCallback(ke=>{const _e=M.find(Ce=>Ce.id===ke);B(Ce=>(Ce??[]).filter(Ee=>Ee.id!==ke)),b(Ce=>{const Ee=new Set(Ce);return Ee.delete(ke),Ee}),p===ke&&h(null),_e?.experimentId&&_e?.datasetId&&f.mutate({datasetId:_e.datasetId,experimentId:_e.experimentId,resultId:_e.id,status:"complete"})},[M,f,p]),Y=y.useMemo(()=>{const ke=w?d??[]:R;return!w||!m?ke:m==="__untagged__"?ke.filter(_e=>_e.tags.length===0):ke.filter(_e=>_e.tags.includes(m))},[w,d,R,m]),ne=w?c:!1,le=y.useMemo(()=>new Set(Y.map(ke=>ke.id)),[Y]),pe=y.useMemo(()=>[...v].filter(ke=>le.has(ke)).length,[v,le]),se=Y.length>0&&pe===Y.length,he=pe>0&&!se,be=y.useCallback(ke=>{b(_e=>{const Ce=new Set(_e);return Ce.has(ke)?Ce.delete(ke):Ce.add(ke),Ce})},[]),Se=y.useCallback(()=>{b(se?new Set:new Set(Y.map(ke=>ke.id)))},[se,Y]),Ne=y.useCallback(ke=>{for(const _e of v){const Ce=M.find(Ee=>Ee.id===_e);Ce&&!Ce.tags.includes(ke)&&te(_e,[...Ce.tags,ke])}},[M,v,te]),Oe=y.useCallback(ke=>{for(const _e of v){const Ce=M.find(Ee=>Ee.id===_e);Ce&&Ce.tags.includes(ke)&&te(_e,Ce.tags.filter(Ee=>Ee!==ke))}},[M,v,te]),Ae=y.useCallback(()=>{for(const ke of v)ue(ke);b(new Set)},[v,ue]),Ue=y.useCallback(()=>{for(const ke of v)ie(ke);b(new Set)},[v,ie]),ce=y.useCallback(()=>{N(""),j(!0)},[]),ae=y.useCallback(async()=>{if(!(!I||!$)){_(!0),j(!1);try{const ke=M.filter(Ce=>v.has(Ce.id));if(ke.length===0){_(!1);return}const _e=await r.clusterFailures({modelId:`${I}/${$}`,items:ke.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:E||void 0});_e.proposedTags&&_e.proposedTags.length>0&&(q(_e.proposedTags.map(Ce=>({...Ce,accepted:!0}))),L(!0))}catch(ke){console.error("Analysis failed:",ke)}finally{_(!1)}}},[I,$,M,v,r,Q,E]),re=y.useCallback(()=>{for(const ke of D){if(!ke.accepted)continue;const _e=M.find(Ce=>Ce.id===ke.itemId);if(_e){const Ce=[...new Set([..._e.tags,...ke.tags])];te(_e.id,Ce)}}L(!1)},[D,M,te]),me=y.useCallback(ke=>{h(_e=>_e===ke?null:ke)},[]),ye=y.useMemo(()=>p?Y.find(ke=>ke.id===p)??null:null,[p,Y]),je=p?Y.findIndex(ke=>ke.id===p):-1,Re=je>0?()=>h(Y[je-1].id):void 0,Qe=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(Qt,{className:"w-6 h-6"})}):o.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[o.jsx(yr,{open:C,onOpenChange:j,children:o.jsxs(br,{children:[o.jsxs(xr,{children:[o.jsx(mr,{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(Mt,{className:"text-xs mb-1 block",children:"Provider"}),o.jsx(Oy,{value:I,onValueChange:P})]}),o.jsxs("div",{children:[o.jsx(Mt,{className:"text-xs mb-1 block",children:"Model"}),o.jsx(_y,{llmId:I,value:$,onValueChange:z})]})]}),o.jsxs(ge,{variant:"ui-xs",className:"text-neutral3",children:[v.size," item",v.size!==1?"s":""," will be analyzed"]}),o.jsxs("div",{children:[o.jsx(Mt,{className:"text-xs",children:"Instructions (optional)"}),o.jsx(ql,{value:E,onChange:ke=>N(ke.target.value),placeholder:"E.g., Focus on safety issues and factual errors...",rows:3,className:"text-xs mt-1"})]})]}),o.jsxs(mc,{children:[o.jsx(fe,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),o.jsxs(fe,{onClick:ae,disabled:!I||!$||O,children:[O?o.jsx(Qt,{className:"w-4 h-4 mr-1"}):null,"Analyze"]})]})]})}),o.jsx(yr,{open:W,onOpenChange:L,children:o.jsxs(br,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[o.jsxs(xr,{children:[o.jsx(mr,{children:"Review Proposed Tags"}),o.jsxs(Qs,{children:[D.filter(ke=>ke.accepted).length," of ",D.length," proposals selected"]})]}),o.jsx("div",{className:"space-y-3 py-2",children:D.map((ke,_e)=>{const Ce=M.find(Ee=>Ee.id===ke.itemId);return o.jsx("div",{className:K("p-3 border rounded-lg",!ke.accepted&&"opacity-50"),children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(Yo,{checked:ke.accepted,onCheckedChange:Ee=>q($e=>$e.map((Fe,Ke)=>Ke===_e?{...Fe,accepted:!!Ee}:Fe))}),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):ke.itemId}),o.jsx("div",{className:"flex gap-1 flex-wrap mt-1.5",children:ke.tags.map((Ee,$e)=>o.jsx(hLt,{tag:Ee,onRename:Fe=>q(Ke=>Ke.map((Ye,Rt)=>Rt===_e?{...Ye,tags:Ye.tags.map((Ct,en)=>en===$e?Fe:Ct)}:Ye)),onRemove:()=>q(Fe=>Fe.map((Ke,Ye)=>Ye===_e?{...Ke,tags:Ke.tags.filter((Rt,Ct)=>Ct!==$e)}:Ke))},`${Ee}-${$e}`))}),ke.reason&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-1 block italic",children:ke.reason})]})]})},ke.itemId)})}),o.jsxs(mc,{children:[o.jsx(fe,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),o.jsxs(fe,{onClick:re,disabled:D.filter(ke=>ke.accepted).length===0,children:["Accept ",D.filter(ke=>ke.accepted).length," proposals"]})]})]})}),o.jsxs("div",{className:K("grid w-full h-full grid-cols-1 gap-4 overflow-y-auto",ye&&"grid-cols-[1fr_1fr]"),children:[o.jsxs("div",{className:"grid gap-8 content-start w-full overflow-y-auto",children:[o.jsxs("div",{className:"flex items-center justify-between w-full flex-wrap gap-4 gap-x-6",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs(ft,{children:[o.jsx(ft.Trigger,{asChild:!0,children:o.jsxs(fe,{variant:"outline",size:"md",children:[o.jsx(fit,{}),"Filter",X>0&&o.jsx("span",{className:K("ml-0.5 inline-flex items-center justify-center rounded-full bg-accent1/50 text-neutral5 text-ui-sm w-5 h-5"),children:X})]})}),o.jsxs(ft.Content,{align:"start",className:K("min-w-48"),children:[o.jsxs(ft.Sub,{children:[o.jsxs(ft.SubTrigger,{children:["Status",w&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(ft.SubContent,{children:[o.jsx(ft.CheckboxItem,{checked:!w,onCheckedChange:()=>{S(!1),h(null)},onSelect:ke=>ke.preventDefault(),children:"Review Queue"}),o.jsx(ft.CheckboxItem,{checked:w,onCheckedChange:()=>{S(!0),h(null)},onSelect:ke=>ke.preventDefault(),children:"Completed"})]})]}),o.jsxs(ft.Sub,{children:[o.jsxs(ft.SubTrigger,{children:["Tags",m&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(ft.SubContent,{children:[o.jsx(ft.CheckboxItem,{checked:!m,onCheckedChange:()=>g(null),onSelect:ke=>ke.preventDefault(),children:"All"}),Z>0&&o.jsx(ft.CheckboxItem,{checked:m==="__untagged__",onCheckedChange:()=>g(m==="__untagged__"?null:"__untagged__"),onSelect:ke=>ke.preventDefault(),children:"Untagged"}),U.length>0&&o.jsx(ft.Separator,{}),U.map(([ke])=>o.jsx(ft.CheckboxItem,{checked:m===ke,onCheckedChange:()=>g(m===ke?null:ke),onSelect:_e=>_e.preventDefault(),children:ke},ke))]})]}),X>0&&o.jsxs(o.Fragment,{children:[o.jsx(ft.Separator,{}),o.jsxs(ft.Item,{onSelect:()=>{g(null),S(!1),h(null)},children:[o.jsx(gs,{}),"Clear all filters"]})]})]})]}),X>0&&o.jsxs(fe,{variant:"outline",size:"md",onClick:()=>{g(null),S(!1),h(null)},children:[o.jsx(gs,{}),"Reset"]})]}),!w&&v.size>0&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(pLt,{selectedCount:v.size,vocabulary:Q,onApplyTag:Ne,onRemoveTag:Oe,onNewTag:ke=>Ne(ke)}),o.jsxs(ft,{children:[o.jsx(ft.Trigger,{asChild:!0,children:o.jsxs(fe,{disabled:O,children:[O?o.jsx(Qt,{className:"w-4 h-4"}):o.jsx(Ve,{size:"sm",children:o.jsx(ea,{})}),"Actions"]})}),o.jsxs(ft.Content,{align:"end",children:[o.jsxs(ft.Item,{onSelect:Ae,children:[o.jsx(Ve,{size:"sm",children:o.jsx(Zk,{})}),"Complete"]}),o.jsxs(ft.Item,{onSelect:Ue,children:[o.jsx(Ve,{size:"sm",children:o.jsx(Zc,{})}),"Remove"]}),o.jsx(ft.Separator,{}),o.jsxs(ft.Item,{onSelect:ce,children:[o.jsx(Ve,{size:"sm",children:o.jsx(og,{})}),"Analyze"]})]})]})]})]}),ne?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Qt,{className:"w-6 h-6"})}):Y.length===0?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsxs("div",{className:"text-center px-8",children:[o.jsx(ge,{variant:"ui-sm",className:"text-neutral3 block",children:w?"No completed reviews yet":"No items to review"}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-2 block",children:w?"Items marked as complete will appear here for auditing.":"When experiment results are flagged for review, they will appear here."})]})}):o.jsxs(xe,{columns:Ze,className:"min-w-0",children:[o.jsxs(xe.Top,{hasLeadingCell:!0,children:[w?o.jsx(xe.TopCell,{children:" "}):o.jsx(xe.TopSelectCell,{checked:se?!0:he?"indeterminate":!1,onToggle:()=>Se(),"aria-label":"Select all"}),o.jsxs(xe.TopCells,{colStart:2,children:[o.jsx(xe.TopCell,{children:"Input"}),o.jsx(xe.TopCell,{children:"Comment"}),o.jsx(xe.TopCell,{children:"Tags"}),o.jsx(xe.TopCell,{children:"Rating"}),o.jsx(xe.TopCell,{children:"Scores"})]})]}),Y.map(ke=>{const _e=ke.scores?Object.entries(ke.scores):[],Ce=p===ke.id,Ee=o.jsxs(o.Fragment,{children:[o.jsx(xe.Cell,{height:"compact",className:"min-w-0 text-neutral4",children:o.jsx("span",{className:"block truncate",children:sXr(ke.input,200)})}),o.jsx(xe.Cell,{height:"compact",className:"min-w-0",children:ke.comment?o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 truncate",children:ke.comment}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsx(xe.Cell,{height:"compact",className:"min-w-0",children:ke.tags.length>0?o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 truncate",children:ke.tags.join(", ")}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsxs(xe.Cell,{height:"compact",children:[ke.rating==="positive"&&o.jsx(Ve,{size:"sm",className:"text-positive1",children:o.jsx(Bve,{})}),ke.rating==="negative"&&o.jsx(Ve,{size:"sm",className:"text-negative1",children:o.jsx(zve,{})}),!ke.rating&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})]}),o.jsx(xe.Cell,{height:"compact",children:_e.length>0?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(Ve,{size:"sm",className:"text-neutral3",children:o.jsx(ig,{})}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 font-mono",children:_e[0][1].toFixed(2)}),_e.length>1&&o.jsxs(gn,{variant:"default",children:["+",_e.length-1]})]}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})})]});return o.jsxs(xe.RowWrapper,{children:[w?o.jsx(xe.Cell,{height:"compact",className:"justify-items-center px-4",children:o.jsx("div",{role:"img","aria-label":ke.error?"Error":"Success",title:ke.error?"Error":"Success",className:K("w-2 h-2 rounded-full",ke.error?"bg-red-700":"bg-green-600")})}):o.jsx(xe.SelectCell,{checked:v.has(ke.id),onToggle:()=>be(ke.id),"aria-label":`Select item ${ke.id}`}),o.jsx(xe.RowButton,{flushLeft:!0,colStart:2,featured:Ce,onClick:()=>me(ke.id),children:Ee})]},ke.id)})]})]}),ye&&o.jsx(fLt,{item:ye,isCompleted:w,tagVocabulary:Q,onRate:ke=>ee(ye.id,ke),onSetTags:ke=>{te(ye.id,ke);for(const _e of ke)Q.includes(_e)||V(_e)},onComment:ke=>J(ye.id,ke),onRemove:()=>ie(ye.id),onComplete:w?void 0:()=>ue(ye.id),onPrevious:Re,onNext:Qe,onClose:()=>h(null)})]})]})}function aXr({datasetId:e,onAddItemClick:t,onNavigateToDataset:n}){const{navigate:r}=vn(),[s,a]=Ei(),{tab:i,activeVersion:l,handleTabChange:c}=UEe(s,a),[u,d]=y.useState(!1),[f,p]=y.useState(!1),[h,m]=y.useState(!1),[g,v]=y.useState([]),[b,w]=y.useState(!1),[S,O]=y.useState([]),[_,C]=y.useState(!1),[j,E]=y.useState([]),[N,I]=y.useState(0),[P,$]=y.useState(null),[z,D]=y.useState(""),[q]=x0e(z,300),{data:W}=Lx(e),{data:L=[],total:F,isLoading:B,setEndOfListElement:M,isFetchingNextPage:Q,hasNextPage:V}=WO(e,q||void 0,l),{total:R}=WO(e,void 0,l),[U,Z]=y.useState({}),{data:X,isLoading:te}=gM(e,void 0,U),{data:ee}=gM(e),{deleteItems:J}=Fi(),ie=X?.experiments??[],ue=ee?.experiments??[],Y=_Yr({hasSearchQuery:!!q,filteredItemsLength:L.length,unfilteredItemsTotal:R,itemsTotal:F}),{data:ne}=qEe(e),le=ne?.length??0,pe=re=>{$(re)},se=()=>{$(null)},he=re=>{v(re),m(!0)},be=re=>{O(re),w(!0)},Se=re=>{w(re),re||(O([]),I(me=>me+1))},Ne=re=>{r(`/datasets/${e}/items?items=${re.join(",")}`)},Oe=re=>{r(`/datasets/${e}/versions?ids=${re.join(",")}`)},Ae=re=>{E(re),C(!0)},Ue=async()=>{await J.mutateAsync({datasetId:e,itemIds:j}),Be.success(`Deleted ${j.length} items`),C(!1),E([]),I(re=>re+1)},ce=re=>{m(!1),v([]),I(me=>me+1),n?.(re)},ae=re=>{m(re),re||(v([]),I(me=>me+1))};return o.jsxs(o.Fragment,{children:[o.jsxs(Nu,{defaultTab:"items",value:i,onValueChange:c,className:"grid grid-rows-[auto_1fr] h-full",children:[o.jsxs(Tu,{children:[o.jsxs(Xr,{value:"items",children:["Items ",o.jsx(Xs,{color:"gray",children:Y})]}),o.jsxs(Xr,{value:"experiments",children:["Experiments",o.jsx(Xs,{color:"gray",children:ie.length})]}),o.jsxs(Xr,{value:"review",children:["Review",le>0&&o.jsx(Xs,{color:"orange",children:le})]})]}),o.jsx(As,{value:"items",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(KYr,{datasetId:e,items:L,isLoading:B,featuredItemId:P,onItemSelect:pe,onItemClose:se,onAddClick:t??(()=>{}),onImportClick:()=>d(!0),onImportJsonClick:()=>p(!0),onBulkDeleteClick:Ae,onCreateDatasetClick:he,onAddToDatasetClick:be,onCompareItemsClick:Ne,datasetName:W?.name,clearSelectionTrigger:N,setEndOfListElement:M,isFetchingNextPage:Q,hasNextPage:V,searchQuery:z,activeSearchQuery:q,onSearchChange:D,currentDatasetVersion:W?.version,onCompareVersionsClick:Oe})}),o.jsx(As,{value:"experiments",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(BYr,{experiments:ie,allExperiments:ue,isLoading:te,datasetId:e,filters:U,onFiltersChange:Z})}),o.jsx(As,{value:"review",className:"overflow-auto mt-2 pb-0",children:o.jsx(ELt,{datasetId:e})})]}),o.jsx(RYr,{datasetId:e,open:u,onOpenChange:d}),o.jsx(nXr,{datasetId:e,open:f,onOpenChange:p}),o.jsx(hYr,{open:h,onOpenChange:ae,items:g,onSuccess:ce}),o.jsx(mYr,{open:b,onOpenChange:Se,items:S,currentDatasetId:e}),o.jsx(jt,{open:_,onOpenChange:C,children:o.jsxs(jt.Content,{children:[o.jsxs(jt.Header,{children:[o.jsx(jt.Title,{children:"Delete Items"}),o.jsxs(jt.Description,{children:["Are you sure you want to delete ",j.length," item",j.length!==1?"s":"","? This action cannot be undone."]})]}),o.jsxs(jt.Footer,{children:[o.jsx(jt.Cancel,{children:"Cancel"}),o.jsx(jt.Action,{onClick:Ue,children:J.isPending?"Deleting...":"Delete"})]})]})})]})}function iXr(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 AZe({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 oXr({datasetId:e,open:t,onOpenChange:n,onSuccess:r}){const[s,a]=y.useState("{}"),[i,l]=y.useState(""),[c,u]=y.useState(""),[d,f]=y.useState(""),[p,h]=y.useState(null),{addItem:m}=Fi(),g=async S=>{S.preventDefault();let O;try{O=JSON.parse(s)}catch{Be.error("Input must be valid JSON");return}let _;if(i.trim())try{_=JSON.parse(i)}catch{Be.error("Ground Truth must be valid JSON");return}let C;if(c.trim())try{C=JSON.parse(c)}catch{Be.error("Expected Trajectory must be valid JSON");return}let j;if(d.trim())try{j=JSON.parse(d)}catch{Be.error("Request Context must be valid JSON");return}try{await m.mutateAsync({datasetId:e,input:O,groundTruth:_,expectedTrajectory:C,requestContext:j}),Be.success("Item added successfully"),h(null),a("{}"),l(""),u(""),f(""),n(!1),r?.()}catch(E){const N=iXr(E);N?h(N):Be.error(`Failed to add item: ${E instanceof Error?E.message:"Unknown error"}`)}},v=S=>{a(S),p?.field==="input"&&h(null)},b=S=>{l(S),p?.field==="groundTruth"&&h(null)},w=()=>{a("{}"),l(""),u(""),f(""),h(null),n(!1)};return o.jsx(yr,{open:t,onOpenChange:n,children:o.jsxs(br,{className:"max-w-lg",children:[o.jsx(xr,{children:o.jsx(mr,{children:"Add Item"})}),o.jsx(Ar,{children:o.jsxs("form",{onSubmit:g,className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Mt,{htmlFor:"item-input",children:"Input (JSON) *"}),o.jsx(as,{value:s,onChange:v,showCopyButton:!1,className:"min-h-[120px]"}),p?.field==="input"&&o.jsx(AZe,{field:"input",errors:p.errors})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Mt,{htmlFor:"item-ground-truth",children:"Ground Truth (JSON, optional)"}),o.jsx(as,{value:i,onChange:b,showCopyButton:!1,className:"min-h-[80px]"}),p?.field==="groundTruth"&&o.jsx(AZe,{field:"groundTruth",errors:p.errors})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Mt,{htmlFor:"item-trajectory",children:"Expected Trajectory (JSON, optional)"}),o.jsx(as,{value:c,onChange:u,showCopyButton:!1,className:"min-h-[80px]"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Mt,{htmlFor:"item-request-context",children:"Request Context (JSON, optional)"}),o.jsx(as,{value:d,onChange:f,showCopyButton:!1,className:"min-h-[80px]"})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[o.jsx(fe,{type:"button",onClick:w,children:"Cancel"}),o.jsx(fe,{type:"submit",variant:"primary",disabled:m.isPending,children:m.isPending?"Adding...":"Add Item"})]})]})})]})})}function lXr({item:e}){return o.jsx(ca,{withMargins:!1,children:o.jsxs(ca.Column,{children:[o.jsxs(ca.Title,{size:"smaller",children:[o.jsx(ZT,{}),o.jsx("span",{className:"truncate",children:e.id}),o.jsx(xa,{content:e.id,tooltip:`Copy item ID: ${e.id}`})]}),o.jsxs(ca.Description,{children:[o.jsxs(dc,{children:[o.jsx(nit,{})," Created ",Kn(new Date(e.createdAt),"MMM d, yyyy h:mm aaa")]}),e.datasetVersion!=null&&o.jsxs(dc,{children:[o.jsx(KO,{})," Version v",e.datasetVersion]})]})]})})}function VEe({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(w0e,{children:[o.jsx(ga.CodeSection,{title:"Input",icon:o.jsx(Qk,{}),codeStr:t}),o.jsx(ga.CodeSection,{title:"Ground Truth",icon:o.jsx(tg,{}),codeStr:n}),s&&o.jsx(ga.CodeSection,{title:"Expected Trajectory",icon:o.jsx(_it,{}),codeStr:s}),o.jsx(ga.CodeSection,{title:"Metadata",icon:o.jsx(YT,{}),codeStr:r})]})}function cXr({selectedScorers:e,setSelectedScorers:t,disabled:n=!1,container:r}){const{data:s,isLoading:a}=Zp(),i=y.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(Mt,{children:"Scorers (Optional)"}),o.jsx(Xmt,{options:i,value:e,onValueChange:t,placeholder:"Select scorers...",searchPlaceholder:"Search scorers...",emptyText:"No scorers available",disabled:n||a,container:r})]})}const uXr=[{value:"agent",label:"Agent"},{value:"workflow",label:"Workflow"},{value:"scorer",label:"Scorer"}];function dXr({targetType:e,setTargetType:t,targetId:n,setTargetId:r,container:s}){const{data:a,isLoading:i}=cm(),{data:l,isLoading:c}=Cy(),{data:u,isLoading:d}=Zp(),f=e==="agent"?Object.entries(a??{}).map(([g,v])=>({value:g,label:v.name??g})):e==="workflow"?Object.entries(l??{}).map(([g,v])=>({value:g,label:v.name??g})):e==="scorer"?Object.entries(u??{}).map(([g,v])=>({value:g,label:v.scorer?.config?.name??g})):[],p=e==="agent"&&i||e==="workflow"&&c||e==="scorer"&&d,h=g=>{t(g),r("")},m=e==="agent"?"Agent":e==="workflow"?"Workflow":"Scorer";return o.jsxs("div",{className:"grid gap-6",children:[o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Mt,{children:"Target Type"}),o.jsx(Wc,{options:uXr,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(Mt,{children:m}),o.jsx(Wc,{options:f,value:n,onValueChange:r,placeholder:`Select ${e}`,searchPlaceholder:"Search...",emptyText:"No targets available",disabled:p,container:s})]})]})}function fXr({requestContextSchema:e,onChange:t}){const n=y.useMemo(()=>{try{return Yh(Gh(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(Mt,{children:"Request Context"}),o.jsx(uD,{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 pXr({datasetId:e,version:t,requestContextSchema:n,open:r,onOpenChange:s,onSuccess:a}){const i=y.useRef(null),[l,c]=y.useState(""),[u,d]=y.useState(""),[f,p]=y.useState([]),[h,m]=y.useState({}),[g,v]=y.useState(""),{triggerExperiment:b}=Fi(),w=!!(n&&Object.keys(n).length>0),S=l&&u,O=b.isPending,_=()=>{c(""),d(""),p([]),m({}),v("")},C=()=>{if(w){const N=Object.entries(h).filter(([,I])=>I!==void 0&&I!=="");return N.length>0?Object.fromEntries(N):void 0}if(g.trim()){let N;try{N=JSON.parse(g)}catch{throw new Error("Request Context must be valid JSON")}if(!N||typeof N!="object"||Array.isArray(N))throw new Error("Request Context must be a JSON object");return N}},j=async()=>{if(!S)return;let N;try{N=C()}catch(I){const P=I instanceof Error?I.message:"Request Context must be valid JSON";bu.error(P);return}try{const I=await b.mutateAsync({datasetId:e,targetType:l,targetId:u,scorerIds:f.length>0?f:void 0,version:t,requestContext:N});bu.success("Experiment triggered successfully"),s(!1),a?.(I.experimentId),_()}catch(I){const P=I instanceof Error?I.message:"Failed to trigger experiment";bu.error(P)}},E=()=>{O||(s(!1),_())};return o.jsx(yr,{open:r,onOpenChange:E,children:o.jsxs(br,{ref:i,children:[o.jsxs(xr,{children:[o.jsx(mr,{children:"Run Experiment"}),o.jsx(Qs,{children:t?`Execute items from ${Kn(new Date(t),"MMM d, yyyy")} version against a target.`:"Execute all items in this dataset against a target."})]}),o.jsxs(Ar,{className:"grid gap-6",children:[o.jsx(dXr,{targetType:l,setTargetType:c,targetId:u,setTargetId:d,container:i}),l&&l!=="scorer"&&o.jsx(cXr,{selectedScorers:f,setSelectedScorers:p,disabled:O,container:i}),w?o.jsx(fXr,{requestContextSchema:n,onChange:m}):o.jsxs("div",{className:"space-y-2",children:[o.jsx(Mt,{children:"Request Context (JSON, optional)"}),o.jsx(as,{value:g,onChange:v,showCopyButton:!1,className:"min-h-[80px]"})]})]}),o.jsxs(mc,{className:"px-6 pt-4",children:[o.jsx(fe,{onClick:E,disabled:O,children:"Cancel"}),o.jsx(fe,{variant:"primary",onClick:j,disabled:!S||O,children:O?o.jsxs(o.Fragment,{children:[o.jsx(Qt,{className:"w-4 h-4"}),"Running..."]}):"Run"})]})]})})}const hXr=e=>{const t=We();return xt({queryKey:["experiment-trace-light",e],queryFn:async()=>{if(!e)throw new Error("Trace ID is required");return t.getTraceLight(e)},enabled:!!e})};function mXr({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]=y.useState(!1),m=d??p,g=f??h,v=!!e?.error,b=u8(e?.input),w=u8(e?.output),S=u8(e?.groundTruth),O=u&&e.status!=="needs-review"&&e.status!=="complete",_=Array.isArray(e.tags)?e.tags:[];return o.jsxs(kn,{collapsed:m,children:[o.jsxs(kn.Header,{children:[o.jsxs(kn.Heading,{children:["Result ",o.jsxs("b",{children:["# ",e.id.length>12?`${e.id.slice(0,12)}…`:e.id]})]}),o.jsxs($r,{className:"ml-auto shrink-0",children:[f&&o.jsx(fe,{size:"md",tooltip:m?"Expand panel":"Collapse panel",onClick:()=>g(!m),children:m?o.jsx(iit,{}):o.jsx(ait,{})}),o.jsx(kn.NextPrevNav,{onPrevious:n,onNext:r,previousLabel:"Previous result",nextLabel:"Next result"}),o.jsxs(fe,{size:"md",onClick:a,disabled:!e.traceId,children:[o.jsx(MSe,{}),"Trace"]}),o.jsx(kn.CloseButton,{onClick:s,tooltip:"Close result panel"})]})]}),!m&&o.jsxs(kn.Content,{children:[o.jsxs("div",{className:"grid gap-4 mb-6",children:[o.jsxs(zt,{children:[o.jsx(zt.Key,{children:"Item Id"}),o.jsx(zt.ValueWithCopyBtn,{copyTooltip:"Copy Item Id to clipboard",copyValue:e.itemId,children:e.itemId}),o.jsx(zt.Key,{children:"Created"}),o.jsx(zt.Value,{children:Kn(new Date(e.createdAt),"MMM d, yyyy 'at' h:mm a")})]}),v&&o.jsx(Rn,{variant:"destructive",title:"Error",children:o.jsx(Rn.Message,{children:u8(e?.error&&typeof e.error=="object"?e.error.message:e?.error)})}),t&&t.length>0&&o.jsxs(xe,{columns:"1fr 1fr",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Scorer"}),o.jsx(xe.TopCell,{children:"Score"})]}),t.map(C=>o.jsxs(xe.RowButton,{featured:c===C.id,onClick:()=>l?.(C.id),children:[o.jsx(xe.Cell,{height:"compact",children:C.scorerId}),o.jsx(xe.MonoCell,{children:C.score.toFixed(3)})]},C.id))]}),(e.status||_.length>0||O)&&o.jsxs("div",{className:"grid gap-2",children:[o.jsx(kn.SectionHeading,{icon:o.jsx(YT,{}),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))]}),O&&o.jsx("div",{children:o.jsxs(fe,{size:"sm",onClick:()=>u(e.id),children:[o.jsx(aU,{}),"Flag for Review"]})}),e.status==="needs-review"&&i&&o.jsx("div",{children:o.jsxs(fe,{size:"sm",onClick:i,children:[o.jsx(Ta,{}),"Review"]})})]})]}),o.jsxs("div",{className:"grid gap-3",children:[o.jsx(kn.CodeSection,{title:"Input",icon:o.jsx(ZT,{}),codeStr:b}),o.jsx(kn.CodeSection,{title:"Output",icon:o.jsx(tg,{}),codeStr:w}),o.jsx(kn.CodeSection,{title:"Ground Truth",icon:o.jsx(Fve,{}),codeStr:S})]})]})]})}function u8(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function gXr({results:e,isLoading:t,featuredResultId:n,onResultClick:r,columns:s,scoresByItemId:a,scorerIds:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u,selectedIds:d,onToggleSelect:f}){const p=!!(d&&f),h=[p?"auto":"",...s.map(g=>g.size)].filter(Boolean).join(" "),m=s.some(g=>g.name==="input");return t?o.jsx(Go,{columns:h}):o.jsxs(xe,{columns:h,className:"min-w-0",children:[o.jsxs(xe.Top,{hasLeadingCell:p,children:[p&&o.jsx(xe.TopCell,{children:" "}),p?o.jsx(xe.TopCells,{colStart:2,children:s.map(g=>o.jsx(xe.TopCell,{children:g.label},g.name))}):s.map(g=>o.jsx(xe.TopCell,{children:g.label},g.name))]}),e.length===0?o.jsx(xe.NoMatch,{message:"No results yet"}):o.jsxs(o.Fragment,{children:[e.map(g=>{const v=!!g.error,b=g.id===n,w=o.jsxs(o.Fragment,{children:[o.jsx(xe.IdCell,{id:g.itemId}),o.jsx(xe.Cell,{height:"compact",children:o.jsxs(Hn,{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":v?"Error":"Success",className:K("w-2 h-2 rounded-full",v?"bg-red-700":"bg-green-600")})})}),o.jsx(Bn,{children:v?"Error":"Success"})]})}),m&&o.jsx(xe.MonoCell,{children:yXr(vXr(g.input),200)}),i?.map(S=>{const _=a?.[g.itemId]?.find(C=>C.scorerId===S);return o.jsx(xe.Cell,{height:"compact",className:"font-mono text-neutral3 text-ui-smd",children:_!=null?_.score.toFixed(3):"-"},S)})]});return p?o.jsxs(xe.RowWrapper,{children:[o.jsx(xe.SelectCell,{checked:d.has(g.id),onToggle:()=>f(g.id),"aria-label":`Select result ${g.itemId}`}),o.jsx(xe.RowButton,{flushLeft:!0,colStart:2,featured:b,onClick:()=>r(g.id),children:w})]},g.id):o.jsx(xe.RowButton,{featured:b,onClick:()=>r(g.id),children:w},g.id)}),o.jsx(xe.NextPageLoading,{isLoading:c,hasMore:u,setEndOfListElement:l})]})]})}function vXr(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function yXr(e,t){return e.length<=t?e:e.slice(0,t-1)+"..."}function bXr(e){const t=e.scorer;return t?.hasJudge===!1?!0:t?.hasJudge===!0?!1:!e.preprocessPrompt&&!e.analyzePrompt&&!e.generateScorePrompt&&!e.generateReasonPrompt}function xXr({score:e,onNext:t,onPrevious:n,onClose:r,onShowTrace:s,collapsed:a,onCollapsedChange:i}){const[l,c]=y.useState(!1),u=a??l,d=i??c,f=bXr(e),p=f?"N/A — code-based scorer":"N/A — step not configured";return o.jsxs(kn,{collapsed:u,children:[o.jsxs(kn.Header,{children:[o.jsxs(kn.Heading,{children:["Score ",o.jsx("b",{children:e.scorerId})]}),o.jsxs($r,{className:"ml-auto shrink-0",children:[i&&o.jsx(fe,{size:"md",tooltip:u?"Expand panel":"Collapse panel",onClick:()=>d(!u),children:u?o.jsx(iit,{}):o.jsx(ait,{})}),(n||t)&&o.jsx(kn.NextPrevNav,{onPrevious:n,onNext:t,previousLabel:"Previous score",nextLabel:"Next score"}),s&&o.jsxs(fe,{size:"md",onClick:s,disabled:!e.traceId,children:[o.jsx(MSe,{}),"Trace"]}),o.jsx(kn.CloseButton,{onClick:r,tooltip:"Close score panel"})]})]}),!u&&o.jsx(kn.Content,{children:o.jsxs("div",{className:"grid gap-3",children:[o.jsx(kn.CodeSection,{title:`Score: ${e.score}`,icon:o.jsx(ig,{}),codeStr:e.reason||p,simplified:!0}),!f&&o.jsxs(o.Fragment,{children:[o.jsx(kn.CodeSection,{title:"Preprocess Prompt",icon:o.jsx(uh,{}),codeStr:e.preprocessPrompt||p,simplified:!0}),o.jsx(kn.CodeSection,{title:"Analyze Prompt",icon:o.jsx(uh,{}),codeStr:e.analyzePrompt||p,simplified:!0}),o.jsx(kn.CodeSection,{title:"Generate Score Prompt",icon:o.jsx(uh,{}),codeStr:e.generateScorePrompt||p,simplified:!0}),o.jsx(kn.CodeSection,{title:"Generate Reason Prompt",icon:o.jsx(uh,{}),codeStr:e.generateReasonPrompt||p,simplified:!0})]})]})})]})}const RZe=[{name:"scorer",label:"Scorer",size:"1fr"},{name:"avg",label:"Avg Score",size:"1fr"},{name:"count",label:"Items Scored",size:"1fr"}];function wXr({scoresByItemId:e,experimentStatus:t}){const n=y.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(Wr,{iconSlot:o.jsx(ig,{className:"w-8 h-8 text-neutral3"}),titleSlot:a,descriptionSlot:i})})}return o.jsxs(hn,{children:[o.jsxs(hn.Header,{columns:RZe,children:[o.jsx(hn.HeaderCol,{children:"Scorer"}),o.jsx(hn.HeaderCol,{children:"Avg Score"}),o.jsx(hn.HeaderCol,{children:"Items Scored"})]}),o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:n.map(({scorerId:r,avg:s,count:a})=>o.jsxs(hn.Row,{columns:RZe,children:[o.jsx(hn.TextCell,{children:r}),o.jsx(hn.TextCell,{className:"font-mono",children:s.toFixed(3)}),o.jsx(hn.TextCell,{className:"font-mono",children:a})]},r))})})]})}function jLt({experimentId:e,datasetId:t,experimentStatus:n,results:r,isLoading:s,setEndOfListElement:a,isFetchingNextPage:i,hasNextPage:l}){const[c,u]=y.useState(null),[d,f]=y.useState(null),[p,h]=y.useState(void 0),[m,g]=y.useState(null),[v,b]=y.useState(new Set),[w,S]=y.useState(!1),[O,_]=y.useState(!1),[C,j]=y.useState(!1),[E,N]=y.useState(!1),{updateExperimentResult:I}=Fi(),P=y.useCallback(ae=>{b(re=>{const me=new Set(re);return me.has(ae)?me.delete(ae):me.add(ae),me})},[]),$=y.useCallback(()=>b(new Set),[]),z=y.useCallback(()=>{const ae=r.filter(re=>!!re.error).map(re=>re.id);b(new Set(ae))},[r]),D=y.useCallback(async ae=>{if(w||ae.length===0)return;S(!0);let re=0;const me=new Set;try{for(const ye of ae)try{await I.mutateAsync({datasetId:t,experimentId:e,resultId:ye,status:"needs-review"}),re++,me.add(ye)}catch{}}finally{S(!1)}me.size>0&&b(ye=>{const je=new Set(ye);for(const Re of me)je.delete(Re);return je}),re>0&&Be(`${re} result${re>1?"s":""} flagged for review`)},[t,e,w,I]),q=r.find(ae=>ae.id===c)??null,[W,L]=y.useState("summary"),[F,B]=y.useState(null),M=ae=>{L(ae),ae!=="reviews"&&B(null)},{data:Q}=qEe(t),V=(Q??[]).filter(ae=>ae.experimentId===e).length,{data:R}=lLt(e,n),U=y.useMemo(()=>{if(!R)return[];const ae=new Set;for(const re of Object.values(R))for(const me of re)ae.add(me.scorerId);return[...ae].sort()},[R]),Z=ae=>{u(ae),f(null),h(void 0),g(null)},X=ae=>{Z(ae===c?null:ae)},te=()=>{Z(null)},ee=()=>{if(!q)return;const ae=r.findIndex(re=>re.id===q.id);if(ae>=0&&ae<r.length-1)return()=>Z(r[ae+1].id)},J=()=>{if(!q)return;const ae=r.findIndex(re=>re.id===q.id);if(ae>0)return()=>Z(r[ae-1].id)},ie=q?R?.[q.itemId]:void 0,ue=ie?.find(ae=>ae.id===m)??null,Y=ae=>{g(ae===m?null:ae),f(null),h(void 0)},ne=()=>{if(!m||!ie)return;const ae=ie.findIndex(re=>re.id===m);if(ae>=0&&ae<ie.length-1)return()=>g(ie[ae+1].id)},le=()=>{if(!m||!ie)return;const ae=ie.findIndex(re=>re.id===m);if(ae>0)return()=>g(ie[ae-1].id)},{data:pe,isLoading:se}=hXr(d),he=pe?.spans,{data:be,isLoading:Se}=rD(d,p),Ne=be?.span,{handlePreviousSpan:Oe,handleNextSpan:Ae}=JSe(he,p??null,h),Ue=(()=>{const ae=[],re=!!ue,me=!!d;return ae.push(O?"auto":re||me?"2fr":"1fr"),re&&ae.push(E?"auto":"3fr"),me&&ae.push(C?"auto":"3fr"),me&&p&&ae.push("3fr"),ae.join(" ")})(),ce=y.useMemo(()=>[{name:"itemId",label:"Item ID",size:"7rem"},{name:"status",label:"Status",size:"5rem"},{name:"input",label:"Input",size:"minmax(15rem,1fr)"},...U.map(ae=>({name:ae,label:ae,size:"12rem"}))],[U]);return o.jsxs(Nu,{defaultTab:"summary",value:W,onValueChange:M,className:"grid grid-rows-[auto_1fr] h-full overflow-hidden",children:[o.jsxs(Tu,{children:[o.jsx(Xr,{value:"summary",children:"Summary"}),o.jsx(Xr,{value:"results",children:"Results"}),o.jsxs(Xr,{value:"reviews",children:["Reviews",V>0&&o.jsx(Xs,{color:"orange",children:V})]})]}),o.jsx(As,{value:"summary",className:"overflow-y-auto mt-5",children:o.jsx(wXr,{scoresByItemId:R,experimentStatus:n})}),o.jsx(As,{value:"reviews",className:"overflow-auto mt-2 pb-0",children:o.jsx(ELt,{datasetId:t,experimentId:e,featuredItemId:F})}),o.jsxs(As,{value:"results",className:"grid grid-rows-[auto_1fr] overflow-hidden mt-2",children:[o.jsxs("div",{className:"mb-4",children:[v.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:[v.size," selected"]}),o.jsx("div",{className:"flex-1"}),o.jsxs(fe,{variant:"outline",size:"sm",disabled:w,onClick:()=>D([...v]),children:[o.jsx(Ve,{size:"sm",children:o.jsx(aU,{})}),"Flag for Review"]}),o.jsx(fe,{variant:"ghost",size:"sm",onClick:$,children:"Clear"})]}),r.length>0&&v.size===0&&!s&&o.jsx("div",{className:"flex items-center gap-2 px-4 py-2",children:o.jsx(fe,{variant:"ghost",size:"sm",onClick:z,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(gXr,{results:r,isLoading:s,featuredResultId:c,onResultClick:X,columns:ce,scoresByItemId:R,scorerIds:U,setEndOfListElement:a,isFetchingNextPage:i,hasNextPage:l,selectedIds:v,onToggleSelect:P})})}),q&&o.jsxs("div",{className:"grid gap-4 max-h-full min-h-0 overflow-auto content-start",style:{gridTemplateRows:Ue},children:[o.jsx(mXr,{result:q,scores:ie,onPrevious:J(),onNext:ee(),onClose:te,onScoreClick:Y,featuredScoreId:m,onShowTrace:()=>{q.traceId&&(f(q.traceId),h(void 0),g(null),_(!0),j(!1))},onOpenInReview:()=>{B(q.id),L("reviews")},onFlagForReview:ae=>D([ae]),collapsed:O,onCollapsedChange:_}),ue&&o.jsx(xXr,{score:ue,onNext:ne(),onPrevious:le(),onClose:()=>g(null),onShowTrace:()=>{ue.traceId&&(f(ue.traceId),h(void 0),_(!0),N(!0),j(!1))},collapsed:E,onCollapsedChange:N}),d&&o.jsxs(o.Fragment,{children:[o.jsx(WSe,{traceId:d,spans:he,isLoading:se,onClose:()=>{f(null),h(void 0),_(!1),N(!1)},onSpanSelect:h,initialSpanId:p??null,placement:"traces-list",showUnavailableFeaturesMsg:!1,collapsed:C,onCollapsedChange:j,LinkComponent:sD,traceHref:`/traces/${d}`}),p&&o.jsx(ZSe,{traceId:d,spanId:p,span:Ne,isLoading:Se,onPrevious:Oe,onNext:Ae,onClose:()=>h(void 0)})]})]})]})]})]})}const SXr={pending:o.jsx(Gk,{}),running:o.jsx(Iue,{}),completed:o.jsx(oa,{}),failed:o.jsx(gs,{})};function kXr({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:SXr[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 OXr({onPrevious:e,onNext:t,previousAriaLabel:n="Previous",nextAriaLabel:r="Next"}){return o.jsxs($r,{spacing:"close",children:[o.jsxs(fe,{onClick:e,disabled:!e,"aria-label":n,children:[o.jsx(nq,{})," Prev"]}),o.jsxs(fe,{onClick:t,disabled:!t,"aria-label":r,children:["Next",o.jsx(tq,{})]})]})}function HEe({delta:e}){const t=e>0?o.jsx(Xs,{size:"small",color:"green",intensity:"muted",children:o.jsx(jM,{})}):e<0?o.jsx(Xs,{size:"small",color:"red",intensity:"muted",children:o.jsx(man,{})}):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 d8(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function _Xr({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(Hr,{withLeftSeparator:!0,children:[o.jsxs(Hr.Toolbar,{children:[o.jsx(OXr,{onPrevious:a,onNext:i,previousAriaLabel:"Previous comparison item",nextAriaLabel:"Next comparison item"}),o.jsx($r,{children:o.jsx(fe,{onClick:l,"aria-label":"Close comparison detail panel",children:o.jsx(gs,{})})})]}),o.jsxs(Hr.Content,{className:"pb-6",children:[o.jsx(ca,{withMargins:!1,children:o.jsx(ca.Column,{children:o.jsxs(ca.Title,{size:"smaller",children:[o.jsx(ZT,{})," ",e.itemId]})})}),d?o.jsx(o.Fragment,{children:o.jsxs(w0e,{children:[p.length>0&&o.jsxs("div",{className:"grid gap-3",children:[o.jsx("h4",{className:"text-sm font-medium text-neutral5",children:"Scores"}),o.jsx("div",{className:"grid gap-2",children:p.map(h=>{const m=c?.scores[h]??null,g=u?.scores[h]??null,v=m!=null&&g!=null?g-m:null;return o.jsxs("div",{className:"flex items-center justify-between gap-4 px-3 py-2 rounded-lg bg-surface2",children:[o.jsx("span",{className:"text-sm text-neutral5 font-medium",children:h}),o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("span",{className:"text-sm text-neutral3",children:[m!=null?m.toFixed(3):"-"," →"," ",g!=null?g.toFixed(3):"-"]}),v!=null&&o.jsx(HEe,{delta:v})]})]},h)})})]}),o.jsx(ga.CodeSection,{title:o.jsxs(o.Fragment,{children:[o.jsx(Xs,{color:"purple",children:"Baseline "})," Experiment Output"]}),icon:o.jsx(tg,{}),codeStr:d8(c?.output)}),o.jsx(ga.CodeSection,{title:o.jsxs(o.Fragment,{children:[o.jsx(Xs,{color:"cyan",children:"Contender "})," Experiment Output"]}),icon:o.jsx(tg,{}),codeStr:d8(u?.output)}),o.jsx(ga.CodeSection,{title:"Item Input",icon:o.jsx(Qk,{}),codeStr:d8(e.input)}),o.jsx(ga.CodeSection,{title:"Item Ground Truth",icon:o.jsx(Fve,{}),codeStr:d8(e.groundTruth)})]})}):o.jsx(Rn,{variant:"warning",title:"Comparison not available",children:o.jsx(Rn.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 CXr({items:e,baselineId:t,contenderId:n,scorerIds:r,featuredItemId:s,columns:a,onItemClick:i}){return o.jsx(Hr,{children:o.jsxs(hn,{children:[o.jsxs(hn.Header,{columns:a,children:[o.jsx(hn.HeaderCol,{children:"Item ID"}),!s&&r.map(l=>o.jsx(hn.HeaderCol,{className:"flex justify-center",children:l},l))]}),o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:e.map(l=>{const c=l.results[t],u=l.results[n],d=!!(c&&u);return o.jsx(hn.Row,{children:o.jsxs(hn.RowButton,{item:{id:l.itemId},columns:a,isFeatured:s===l.itemId,onClick:i,children:[o.jsx(hn.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(hn.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(HEe,{delta:m})]}):o.jsx("span",{className:"text-neutral1",children:"-"})},f)})})]})},l.itemId)})})})]})})}const EXr={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 PZe({datasetId:e,experiment:t,type:n}){const{Link:r}=vn(),{label:s,color:a,customStyle:i}=EXr[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(em,{})]}),o.jsx(fe,{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(xc,{})," ",s]})]}),o.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-ui-sm text-neutral3",children:[o.jsxs(dc,{children:[o.jsx(Fve,{})," ",t.targetType," / ",t.targetId]}),o.jsxs(dc,{children:[o.jsx($ve,{})," v",t.datasetVersion??"—"]}),l&&o.jsxs(dc,{children:[o.jsx(rit,{})," ",Kn(l,"MMM d, yyyy HH:mm")]})]})]})}function jXr({datasetId:e,experimentIdA:t,experimentIdB:n,onSwap:r}){const[s,a]=y.useState(null),{data:i,isLoading:l,error:c}=UQr(e,t,n),{data:u}=zB(e,t),{data:d}=zB(e,n),f=u&&d&&u.datasetVersion!==d.datasetVersion,p=y.useMemo(()=>{if(!i)return[];const j=new Set;for(const E of i.items)for(const N of Object.values(E.results))if(N)for(const I of Object.keys(N.scores))j.add(I);return[...j].sort()},[i]),h=y.useMemo(()=>{if(!i||p.length===0)return[];const j=i.baselineId,E=t===j?n:t;return p.map(N=>{let I=0,P=0,$=0,z=0;for(const L of i.items){const F=L.results[j]?.scores[N],B=L.results[E]?.scores[N];F!=null&&(I+=F,$++),B!=null&&(P+=B,z++)}const D=$>0?I/$:null,q=z>0?P/z:null,W=D!=null&&q!=null?q-D:null;return{scorerId:N,avgA:D,avgB:q,delta:W}})},[i,p,t,n]),m=[{name:"scorer",label:"Scorer",size:"1fr"},{name:"baselineAvg",label:"Baseline Avg",size:"1fr"},{name:"comparisonAvg",label:"Comparison Avg",size:"1fr"},{name:"delta",label:"Delta",size:"1fr"}],g=y.useMemo(()=>[{name:"itemId",label:"Item ID",size:"8rem"},...s?[]:p.map(j=>({name:j,label:j,size:"1fr"}))],[p,s]),v=i?.items.find(j=>j.itemId===s)??null,b=j=>{a(j===s?null:j)},w=()=>{a(null)},S=()=>{if(!i||!s)return;const j=i.items.findIndex(E=>E.itemId===s);if(j>=0&&j<i.items.length-1)return()=>a(i.items[j+1].itemId)},O=()=>{if(!i||!s)return;const j=i.items.findIndex(E=>E.itemId===s);if(j>0)return()=>a(i.items[j-1].itemId)};if(l)return o.jsx("div",{className:"flex items-center justify-center h-64",children:o.jsx(Qt,{})});if(c)return o.jsx(Rn,{variant:"warning",title:"Error loading comparison",children:o.jsx(Rn.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(PZe,{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(Hn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx(fe,{onClick:r,children:"VS"})}),o.jsx(Bn,{children:"Switch the order"})]})})}),o.jsx(PZe,{datasetId:e,experiment:d,type:"contender"})]}),f&&o.jsx(Rn,{variant:"warning",title:"Version mismatch",children:o.jsxs(Rn.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(hn,{children:[o.jsxs(hn.Header,{columns:m,children:[o.jsx(hn.HeaderCol,{children:"Scorer"}),o.jsx(hn.HeaderCol,{className:"flex justify-center",children:o.jsxs(b6e,{children:[o.jsx(Xs,{color:"purple",size:"small",intensity:"muted",children:"Baseline"}),o.jsx(Xs,{color:"purple",size:"small",children:"Avg"})]})}),o.jsx(hn.HeaderCol,{className:"flex justify-center",children:o.jsxs(b6e,{children:[o.jsx(Xs,{color:"cyan",size:"small",intensity:"muted",children:"Contender"}),o.jsx(Xs,{color:"cyan",size:"small",children:"Avg"})]})}),o.jsx(hn.HeaderCol,{className:"flex justify-center",children:"Delta"})]}),o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:h.map(({scorerId:j,avgA:E,avgB:N,delta:I})=>o.jsxs(hn.Row,{columns:m,children:[o.jsx(hn.TextCell,{children:j}),o.jsx(hn.TextCell,{className:"text-center font-mono",children:E!=null?E.toFixed(3):"-"}),o.jsx(hn.TextCell,{className:"text-center font-mono",children:N!=null?N.toFixed(3):"-"}),o.jsx(hn.TextCell,{className:"flex justify-center",children:I!=null?o.jsx(HEe,{delta:I}):"-"})]},j))})})]}),o.jsxs($v,{className:K({"grid-cols-[1fr_2fr]":!!v}),children:[o.jsx(CXr,{items:i.items,baselineId:_,contenderId:C,scorerIds:p,featuredItemId:s,columns:g,onItemClick:b}),!!v&&o.jsx(_Xr,{item:v,baselineId:_,contenderId:C,baselineVersion:u?.datasetVersion,contenderVersion:d?.datasetVersion,onPrevious:O(),onNext:S(),onClose:w})]})]})}function TXr({datasetId:e,itemId:t,onVersionSelect:n,onCompareVersionsClick:r,activeVersion:s}){const{data:a,isLoading:i}=BEe(e,t),[l,c]=y.useState(!1),[u,d]=y.useState(new Set),f=b=>{n?.(b)},p=b=>s==null?b.isLatest:b.datasetVersion===s,h=b=>{d(w=>{const S=new Set(w);if(S.has(b))S.delete(b);else if(S.size>=2){const[O]=Array.from(S);return new Set([O,b])}else S.add(b);return S})},m=()=>{c(!1),d(new Set)},g=()=>{c(!0)},v=()=>{u.size===2&&r?.([...u])};return o.jsxs(Hr,{className:"min-w-56",children:[l?o.jsx(Hr.Toolbar,{className:"grid justify-stretch gap-3 w-full",children:o.jsxs($r,{children:[o.jsx(fe,{onClick:m,children:"Cancel"}),o.jsx(fe,{variant:"primary",disabled:u.size!==2,onClick:v,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(Hr.Toolbar,{children:o.jsxs(fe,{onClick:g,className:"w-full",children:[o.jsx(Dw,{})," Compare Ver."]})})}),i?o.jsx(NXr,{}):o.jsxs(hn,{children:[o.jsx(hn.Header,{children:o.jsx(hn.HeaderCol,{children:"Item Version History"})}),o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:a?.map(b=>{const w=String(b.datasetVersion),S=typeof b.updatedAt=="string"?new Date(b.updatedAt):b.updatedAt;return o.jsxs(hn.Row,{isSelected:l&&u.has(w),children:[l&&o.jsx(hn.LabelCell,{children:o.jsx(Yo,{checked:u.has(w),disabled:b.isDeleted,onCheckedChange:()=>{},onClick:O=>{O.stopPropagation(),b.isDeleted||h(w)},"aria-label":`Select version ${b.datasetVersion}`})}),o.jsx(hn.RowButton,{item:b,columns:[{name:"version",label:"Item Version History",size:"1fr"}],isFeatured:p(b),onClick:()=>f(b),className:"py-2",children:o.jsx(hn.VersionCell,{version:b.datasetVersion,date:S,isLatest:b.isLatest,isDeleted:b.isDeleted})})]},String(b.datasetVersion))})})})]})]})}function NXr(){return o.jsxs(hn,{children:[o.jsx(hn.Header,{columns:[{name:"version",label:"Item Version History",size:"1fr"}],children:o.jsx(hn.HeaderCol,{children:"Item Version History"})}),o.jsx(hn.Items,{children:Array.from({length:3}).map((e,t)=>o.jsx(hn.Row,{children:o.jsx(hn.RowButton,{columns:[{name:"version",label:"Item Version History",size:"1fr"}],children:o.jsx(hn.TextCell,{isLoading:!0,children:"Loading..."})})},t))})]})}function IXr(e,t){if(t){const n=typeof t=="string"?new Date(t):t;return`v${e} ${Kn(n,"MMM dd 'at' H:mm:ss a")}`}return`v${e}`}function AXr({datasetId:e,versionA:t,versionB:n,onVersionChange:r}){const{data:s}=LEe(e),a=(s??[]).map(i=>({value:String(i.version),label:`${IXr(i.version,i.createdAt)}${i.isCurrent?" (current)":""}`}));return o.jsxs(Hr.Toolbar,{className:"grid grid-cols-[1fr_1fr_1fr_10rem] gap-4 w-full",children:[o.jsx("div",{}),o.jsx(uc,{label:"Version A",labelIsHidden:!0,name:"version-a",placeholder:"Select version",options:a,value:t??"",onValueChange:i=>r?.(i,n??"")}),o.jsx(uc,{label:"Version B",labelIsHidden:!0,name:"version-b",options:a,value:n??"",onValueChange:i=>r?.(t??"",i)}),o.jsx("div",{})]})}const RXr=[{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"}],PXr={added:{color:"blue",borderColor:"border-blue-900",icon:o.jsx(Lr,{}),tooltip:"Added in this version"},changed:{color:"orange",borderColor:"border-yellow-900",icon:o.jsx(Sit,{}),tooltip:"Changed in this version"},same:{color:"green",borderColor:"border-green-900",icon:o.jsx(Din,{}),tooltip:"Same in both versions"}};function Jne({red:e=!1,tooltip:t}){return o.jsxs(Hn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx(_an,{className:K("text-neutral3/40 w-5 h-5 ",{"text-red-900":e})})}),t&&o.jsx(Bn,{children:t})]})}function AS({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}=PXr[e];return o.jsxs(Hn,{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 $Xr(e,t){return e&&t&&e.datasetVersion===t.datasetVersion?"same":e&&t&&e.datasetVersion!==t.datasetVersion?"changed":e?"added":"removed"}function MXr({datasetId:e,versionA:t,versionB:n,allItems:r,itemsAMap:s,itemsBMap:a}){const{Link:i}=vn(),l=t>n;return o.jsx(hn,{children:o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:r.map(({id:c})=>{const u=s.get(c),d=a.get(c),f=$Xr(u,d);return o.jsxs(hn.Row,{columns:RXr,children:[o.jsx(hn.IdCell,{id:c,isShortened:!1}),f!=="same"?o.jsxs(o.Fragment,{children:[u?.datasetVersion?o.jsx(hn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}`,className:"gap-2",children:!d&&l?o.jsx(AS,{variant:"added",version:u.datasetVersion}):f==="changed"&&l?o.jsx(AS,{variant:"changed",version:u.datasetVersion}):o.jsx(AS,{version:u.datasetVersion})}):o.jsx(hn.Cell,{className:"justify-center flex items-center",children:o.jsx(Jne,{red:l,tooltip:l?"Deleted in this version":"Not present in this version"})}),d?.datasetVersion?o.jsx(hn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}`,className:"gap-2",children:!u&&!l?o.jsx(AS,{variant:"added",version:d.datasetVersion}):f==="changed"&&!l?o.jsx(AS,{variant:"changed",version:d.datasetVersion}):o.jsx(AS,{version:d.datasetVersion})}):o.jsx(hn.Cell,{className:"justify-center flex items-center",children:o.jsx(Jne,{red:!l,tooltip:l?"Not present in this version":"Deleted in this version"})})]}):o.jsx(hn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}`,className:"col-span-2 gap-2",children:o.jsx(AS,{variant:"same",version:d?.datasetVersion})}),f==="changed"?o.jsx(hn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}/versions?ids=${u?.datasetVersion},${d?.datasetVersion}`,children:"Compare"}):o.jsx(hn.Cell,{children:o.jsx(Jne,{tooltip:o.jsxs(o.Fragment,{children:["Comparing is available",o.jsx("br",{})," only for changed items"]})})})]},c)})})})})}const $Ze={needsReview:"#facc15",complete:"#22c55e"},DXr=[{label:"Needs Review",color:$Ze.needsReview},{label:"Reviewed",color:$Ze.complete}];function LXr({reviewSummary:e,experiments:t,datasets:n,isLoading:r,isError:s}){const{data:a,maxVal:i,totalInPipeline:l}=y.useMemo(()=>{if(!e?.counts||!t)return{data:[],maxVal:0,totalInPipeline:0};const u=new Map;for(const m of t)u.set(m.id,m);const d=new Map;if(n)for(const m of n)d.set(m.id,m.name);let f=0,p=0;const h=[];for(const m of e.counts){const g=m.needsReview+m.complete;if(g===0)continue;p+=g,g>f&&(f=g);const v=u.get(m.experimentId),b=v?.datasetId?d.get(v.datasetId):void 0,w=b?`${b} · ${m.experimentId.slice(0,8)}`:m.experimentId.slice(0,8);h.push({name:w,values:[m.needsReview,m.complete]})}return{data:h,maxVal:f,totalInPipeline:p}},[e,t,n]),c=a.length>0;return o.jsxs(Bt,{children:[o.jsxs(Bt.TopBar,{children:[o.jsx(Bt.TitleAndDescription,{title:"Review Pipeline",description:"Items in review across experiments."}),c&&o.jsx(Bt.Summary,{value:String(l),label:"Items in pipeline"})]}),r?o.jsx(Bt.Loading,{}):s?o.jsx(Bt.Error,{message:"Failed to load review data"}):o.jsx(Bt.Content,{children:c?o.jsx(rT,{data:a,segments:DXr,maxVal:i,fmt:u=>String(u)}):o.jsx(Bt.NoData,{message:"No items have been sent to review yet"})})]})}function WEe(){const e=We();return xt({queryKey:["experiment-review-summary"],queryFn:()=>e.getExperimentReviewSummary()})}function TLt(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 FXr(e,t){const n=new Map,r=TLt(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 zXr(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 BXr=10;function UXr(){const[e,t]=y.useState(!1),[n,r]=y.useState(""),[s,a]=y.useState("all"),[i,l]=y.useState("all"),[c,u]=y.useState("all"),[d,f]=y.useState(0),{data:p,isLoading:h,error:m}=wy({page:d,perPage:BXr}),{data:g,isLoading:v,error:b}=UW(),{data:w}=WEe(),S=y.useMemo(()=>p?.datasets??[],[p?.datasets]),O=p?.pagination?.hasMore??!1,_=y.useMemo(()=>g?.experiments??[],[g?.experiments]),C=y.useMemo(()=>iYr(S),[S]),j=y.useMemo(()=>FXr(w,_),[w,_]),E=h||v,N=m||b,I=()=>t(!0),P=y.useCallback(()=>f(B=>B+1),[]),$=y.useCallback(()=>f(B=>Math.max(0,B-1)),[]),z=y.useCallback(B=>{r(B),f(0)},[]),D=y.useCallback(B=>{a(B),f(0)},[]),q=y.useCallback(B=>{l(B),f(0)},[]),W=y.useCallback(B=>{u(B),f(0)},[]);if(N&&ms(N))return o.jsx(or,{children:o.jsx(Vs,{})});if(N&&vs(N))return o.jsx(or,{children:o.jsx($s,{resource:"datasets"})});if(N)return o.jsx(or,{children:o.jsx(Li,{title:"Failed to load datasets",message:N.message})});if(S.length===0&&!E&&d===0)return o.jsxs(o.Fragment,{children:[o.jsx(or,{children:o.jsx(dYr,{onCreateClick:I})}),o.jsx(Oge,{open:e,onOpenChange:t})]});const L=s!=="all"||i!=="all"||c!=="all"||n!=="",F=()=>{r(""),a("all"),l("all"),u("all"),f(0)};return o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx(pYr,{search:n,onSearchChange:z,targetFilter:s,onTargetFilterChange:D,experimentFilter:i,onExperimentFilterChange:q,tagFilter:c,onTagFilterChange:W,tagOptions:C,onReset:F,hasActiveFilters:L,onCreateClick:I})}),o.jsx(uYr,{datasets:S,experiments:_,reviewByDataset:j,isLoading:E,search:n,targetFilter:s,experimentFilter:i,tagFilter:c,currentPage:d,hasMore:O,onNextPage:P,onPrevPage:$}),o.jsx(Oge,{open:e,onOpenChange:t})]})}function f8({children:e}){return o.jsxs(Lt,{height:"full",children:[o.jsx("div",{}),o.jsx(Lt.MainArea,{isCentered:!0,children:e})]})}function qXr(){const{datasetId:e}=wr(),t=qs(),[n,r]=Ei(),{activeVersion:s}=UEe(n,r),[a,i]=y.useState(!1),[l,c]=y.useState(!1),[u,d]=y.useState(!1),[f,p]=y.useState(!1),[h,m]=y.useState(!1),{data:g,error:v,isLoading:b}=Lx(e),{data:w=[],isLoading:S}=WO(e,void 0,s),O=!S&&w.length===0;if(b)return null;if(v&&ms(v))return o.jsx(f8,{children:o.jsx(Vs,{})});if(v&&vs(v))return o.jsx(f8,{children:o.jsx($s,{resource:"datasets"})});if(v&&DSe(v)||!b&&!v&&!g)return o.jsx(f8,{children:o.jsx(Wr,{iconSlot:o.jsx(Uv,{}),titleSlot:"Dataset not found",descriptionSlot:`No dataset with id "${e}".`,actionSlot:o.jsxs(fe,{as:ui,to:"/datasets",children:[o.jsx(xc,{}),"Back to Datasets"]})})});if(v)return o.jsx(f8,{children:o.jsx(Li,{title:"Failed to load dataset",message:v instanceof Error?v.message:"An unexpected error occurred. Please try again."})});const _=j=>{t(`/datasets/${e}/experiments/${j}`)},C=()=>{t("/datasets")};return o.jsxs(o.Fragment,{children:[o.jsxs(Lt,{height:"full",children:[o.jsx(Lt.TopArea,{children:o.jsxs(Lt.Row,{children:[o.jsxs(Lt.Column,{children:[g?.description&&o.jsx("p",{className:"text-ui-smd text-neutral3 mb-1",children:g.description}),o.jsxs(zt,{numOfCol:2,children:[o.jsx(zt.Key,{children:"Created at"}),o.jsx(zt.Value,{children:g?.createdAt?Kn(new Date(g.createdAt),"MMM d, yyyy"):""}),o.jsx(zt.Key,{children:"Latest version"}),o.jsxs(zt.Value,{children:["v",g?.version??""]})]})]}),o.jsx(Lt.Column,{children:o.jsxs($r,{children:[O?o.jsxs(Hn,{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(fe,{variant:"primary",children:[o.jsx(Uh,{}),s!=null?`Run on v${s}`:"Run Experiment"]})})})}),o.jsx(Bn,{children:"Add items to the dataset before running an experiment"})]}):o.jsxs(fe,{variant:"primary",onClick:()=>i(!0),children:[o.jsx(Uh,{}),s!=null?`Run on v${s}`:"Run Experiment"]}),o.jsxs(ft,{children:[o.jsx(ft.Trigger,{asChild:!0,children:o.jsx(fe,{size:"lg","aria-label":"Dataset actions menu",children:o.jsx(NM,{})})}),o.jsxs(ft.Content,{align:"end",className:"w-48",children:[o.jsxs(ft.Item,{onSelect:()=>d(!0),children:[o.jsx(Bh,{})," Edit Dataset"]}),o.jsxs(ft.Item,{onSelect:()=>m(!0),children:[o.jsx(Np,{})," Duplicate Dataset"]}),o.jsxs(ft.Item,{onSelect:()=>p(!0),className:"text-red-500 focus:text-red-400",children:[o.jsx(Zc,{})," Delete Dataset"]})]})]})]})})]})}),o.jsx(Lt.MainArea,{children:o.jsx(aXr,{datasetId:e,onAddItemClick:()=>c(!0)})})]}),o.jsx(pXr,{datasetId:e,version:s??void 0,requestContextSchema:g?.requestContextSchema,open:a,onOpenChange:i,onSuccess:_}),o.jsx(oXr,{datasetId:e,open:l,onOpenChange:c}),g&&o.jsx(bYr,{open:u,onOpenChange:d,dataset:{id:g.id,name:g.name,description:g?.description||"",targetType:g.targetType,inputSchema:g.inputSchema,groundTruthSchema:g.groundTruthSchema,requestContextSchema:g.requestContextSchema}}),g&&o.jsx(gYr,{open:h,onOpenChange:m,sourceDatasetId:g.id,sourceDatasetName:g.name,sourceDatasetDescription:g.description,sourceDatasetTargetType:g.targetType}),g&&o.jsx(wYr,{open:f,onOpenChange:p,datasetId:g.id,datasetName:g.name,onSuccess:C})]})}function NLt({experiment:e}){const{Link:t,paths:n}=vn(),{data:r}=cm(),{data:s}=Cy(),{data:a}=Zp(),i=()=>{switch(e.targetType){case"agent":return n.agentLink(e.targetId);case"workflow":return n.workflowLink(e.targetId);case"scorer":return n.scorerLink(e.targetId);default:return"#"}},l=()=>{const u=e.targetId;if(!u)return u;switch(e.targetType){case"agent":return r?.[u]?.name??u;case"workflow":return s?.[u]?.name??u;case"scorer":return a?.[u]?.scorer?.config?.name??u;default:return u}},c=e.agentVersion&&e.targetType==="agent"&&e.targetId?`${n.agentLink(e.targetId)}/editor?version=${encodeURIComponent(e.agentVersion)}`:null;return o.jsx(Lt.TopArea,{children:o.jsxs(Lt.Row,{children:[o.jsx(Lt.Column,{children:o.jsxs(zt,{numOfCol:2,children:[o.jsx(zt.Key,{children:"Created at"}),o.jsx(zt.Value,{children:Kn(new Date(e.createdAt),"MMM d, yyyy 'at' h:mm a")}),e.completedAt&&o.jsxs(o.Fragment,{children:[o.jsx(zt.Key,{children:"Completed at"}),o.jsx(zt.Value,{children:Kn(new Date(e.completedAt),"MMM d, yyyy 'at' h:mm a")})]}),o.jsx(zt.Key,{children:"Target"}),o.jsx(zt.ValueLink,{href:i(),as:t,children:l()}),e.agentVersion&&o.jsxs(o.Fragment,{children:[o.jsx(zt.Key,{children:"Version"}),c?o.jsx(zt.ValueLink,{href:c,as:t,children:e.agentVersion}):o.jsx(zt.Value,{children:e.agentVersion})]})]})}),o.jsx(Lt.Column,{children:o.jsx(kXr,{experiment:e})})]})})}function p8({children:e}){return o.jsxs(Lt,{height:"full",children:[o.jsx("div",{}),o.jsx(Lt.MainArea,{isCentered:!0,children:e})]})}function VXr(){const{datasetId:e,experimentId:t}=wr(),{data:n,isLoading:r,error:s}=zB(e,t),{data:a,isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u}=FW({datasetId:e,experimentId:t,experimentStatus:n?.status});return!e||!t||r?null:s&&ms(s)?o.jsx(p8,{children:o.jsx(Vs,{})}):s&&vs(s)?o.jsx(p8,{children:o.jsx($s,{resource:"datasets"})}):s&&DSe(s)||!r&&!s&&!n?o.jsx(p8,{children:o.jsx(Wr,{iconSlot:o.jsx(Ave,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${t}".`,actionSlot:o.jsxs(fe,{as:ui,to:`/datasets/${e}?tab=experiments`,children:[o.jsx(xc,{}),"Back to Dataset"]})})}):s?o.jsx(p8,{children:o.jsx(Li,{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(NLt,{experiment:n}),o.jsx(Lt.MainArea,{children:o.jsx(jLt,{experimentId:t,datasetId:e,experimentStatus:n.status,results:a??[],isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u})})]})}function HXr(){const{datasetId:e}=wr(),[t,n]=Ei(),{error:r}=Lx(e??""),s=t.get("baseline")??"",a=t.get("contender")??"";return r&&ms(r)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):r&&vs(r)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx($s,{resource:"datasets"})})}):!e||!s||!a?o.jsx(ls,{children:o.jsx(Qv,{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(Qv,{children:o.jsxs("div",{className:"max-w-[100rem] w-full px-12 mx-auto grid content-start ",children:[o.jsxs(ca,{children:[o.jsxs(ca.Column,{children:[o.jsxs(ca.Title,{children:[o.jsx(Dw,{})," Dataset Experiments Comparison"]}),o.jsxs(ca.Description,{children:["Comparing"," ",o.jsx(ui,{to:`/datasets/${e}/experiments/${s}`,children:s.slice(0,8)})," vs"," ",o.jsx(ui,{to:`/datasets/${e}/experiments/${a}`,children:a.slice(0,8)})]})]}),o.jsx(ca.Column,{children:o.jsxs(fe,{as:ui,to:`/datasets/${e}`,children:[o.jsx(xc,{}),"Back to Dataset"]})})]}),o.jsx(jXr,{datasetId:e,experimentIdA:s,experimentIdB:a,onSwap:()=>{n({baseline:a,contender:s})}})]})})})}function WXr(){const{datasetId:e,itemId:t}=wr(),{Link:n}=vn(),r=qs(),{data:s,isLoading:a,error:i}=BEe(e??"",t??""),{updateItem:l,deleteItem:c}=Fi(),{data:u}=Lx(e??""),d=s?.[0]??null,f=d?.isDeleted??!1,[p,h]=y.useState(null),m=y.useMemo(()=>!d||f?{input:"",groundTruth:"",metadata:"",trajectory:"",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):"",requestContext:d.requestContext?JSON.stringify(d.requestContext,null,2):""},[d,f]),g=d?.datasetVersion??0,[v,b]=y.useState(!1),[w,S]=y.useState(m.input),[O,_]=y.useState(m.groundTruth),[C,j]=y.useState(m.metadata),[E,N]=y.useState(m.trajectory),[I,P]=y.useState(m.requestContext),[$,z]=y.useState(g);g!==$&&(z(g),S(m.input),_(m.groundTruth),j(m.metadata),N(m.trajectory),P(m.requestContext));const[D,q]=y.useState(!1),W=X=>{h(f?X:X.isLatest?null:X)},L=()=>{h(null)},F=!f&&p!=null,B=()=>{F||b(!0)},M=()=>{F||q(!0)},Q=async()=>{if(!e||!t)return;let X;try{X=JSON.parse(w)}catch{Be.error("Input must be valid JSON");return}let te;if(O.trim())try{te=JSON.parse(O)}catch{Be.error("Ground Truth must be valid JSON");return}let ee;if(C.trim())try{ee=JSON.parse(C)}catch{Be.error("Metadata must be valid JSON");return}let J;const ie=E!==m.trajectory;if(ie&&E.trim())try{J=JSON.parse(E)}catch{Be.error("Expected Trajectory must be valid JSON");return}let ue;const Y=I!==m.requestContext;if(Y&&I.trim())try{ue=JSON.parse(I)}catch{Be.error("Request Context must be valid JSON");return}try{await l.mutateAsync({datasetId:e,itemId:t,input:X,groundTruth:te,metadata:ee,...ie?{expectedTrajectory:J??null}:{},...Y?{requestContext:ue}:{}}),Be.success("Item updated successfully"),b(!1)}catch(ne){Be.error(`Failed to update item: ${ne instanceof Error?ne.message:"Unknown error"}`)}},V=()=>{d&&(S(JSON.stringify(d.input,null,2)),_(d.groundTruth?JSON.stringify(d.groundTruth,null,2):""),j(d.metadata?JSON.stringify(d.metadata,null,2):""),N(d.expectedTrajectory!=null?JSON.stringify(d.expectedTrajectory,null,2):""),P(d.requestContext?JSON.stringify(d.requestContext,null,2):"")),b(!1)},R=async()=>{if(!(!e||!t))try{await c.mutateAsync({datasetId:e,itemId:t}),Be.success("Item deleted successfully"),q(!1),r(`/datasets/${e}`)}catch(X){Be.error(`Failed to delete item: ${X instanceof Error?X.message:"Unknown error"}`)}},U=p??d,Z=U?{id:t??"",datasetId:e??"",datasetVersion:U.datasetVersion,input:U.input,groundTruth:U.groundTruth,expectedTrajectory:U.expectedTrajectory,metadata:U.metadata,createdAt:U.createdAt,updatedAt:U.updatedAt}:null;return i&&ms(i)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):i&&vs(i)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx($s,{resource:"datasets"})})}):a?null:!e||!t||!s||s.length===0?o.jsx(ls,{children:o.jsx(Qv,{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(ca,{children:[o.jsxs(ca.Column,{children:[o.jsxs(ca.Title,{children:[o.jsx(ZT,{}),t," ",o.jsx(xa,{content:t})]}),o.jsx(ca.Description,{children:o.jsxs(dc,{children:["Item of ",o.jsx(Uv,{})," ",u?.name]})}),o.jsxs(ca.Description,{children:[o.jsxs(dc,{children:[o.jsx(nit,{})," Created at"," ",d?.createdAt?Kn(new Date(d.createdAt),"MMM d, yyyy"):""]}),o.jsxs(dc,{children:[o.jsx(KO,{})," Latest version v",d?.datasetVersion??""]})]})]}),o.jsx(ca.Column,{children:!v&&!f&&o.jsxs($r,{children:[o.jsxs(fe,{onClick:B,disabled:F,title:F?"Return to latest version to edit":void 0,children:[o.jsx(Sit,{})," Edit"]}),o.jsxs(fe,{onClick:M,disabled:F,title:F?"Return to latest version to delete":void 0,children:[o.jsx(Zc,{})," Delete"]})]})})]}),o.jsxs($v,{className:v?"grid-cols-1":"grid-cols-[1fr_auto]",children:[o.jsxs(Hr,{withRightSeparator:!v,children:[f&&d&&o.jsx(Rn,{variant:"destructive",title:"Item deleted",children:o.jsxs(Rn.Message,{children:["This item was deleted at version v",d.datasetVersion]})}),!f&&F&&p&&o.jsx(Rn,{variant:"warning",title:"Previous version",action:o.jsxs(Rn.Button,{onClick:L,children:[o.jsx(Xat,{})," Return to the latest version"]}),children:o.jsxs(Rn.Message,{children:["Viewing version v",p.datasetVersion]})}),v?o.jsx(CLt,{inputValue:w,setInputValue:S,groundTruthValue:O,setGroundTruthValue:_,metadataValue:C,setMetadataValue:j,trajectoryValue:E,setTrajectoryValue:N,requestContextValue:I,setRequestContextValue:P,validationErrors:null,onSave:Q,onCancel:V,isSaving:l.isPending}):Z?o.jsx(VEe,{item:Z,Link:n}):o.jsx("div",{className:"text-neutral4 text-sm",children:"Item data not available"})]}),!v&&o.jsx(Hr,{children:o.jsx(TXr,{datasetId:e,itemId:t,onClose:()=>{},onVersionSelect:W,onCompareVersionsClick:X=>{r(`/datasets/${e}/items/${t}/versions?ids=${X.join(",")}`)},activeVersion:p?.datasetVersion??null})})]})]})})}),o.jsx(jt,{open:D,onOpenChange:q,children:o.jsxs(jt.Content,{children:[o.jsxs(jt.Header,{children:[o.jsx(jt.Title,{children:"Delete Item"}),o.jsx(jt.Description,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),o.jsxs(jt.Footer,{children:[o.jsx(jt.Cancel,{children:"Cancel"}),o.jsx(jt.Action,{onClick:R,children:c.isPending?"Deleting...":"Delete"})]})]})})]})}function MZe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function ZXr(){const{datasetId:e}=wr(),[t,n]=Ei(),r=t.get("items")?.split(",").filter(Boolean)??[],{data:s,error:a}=Lx(e??""),{Link:i}=vn(),[l,c]=y.useState(!1),{data:u}=wge(e??"",r[0]??""),{data:d}=wge(e??"",r[1]??"");return a&&ms(a)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):a&&vs(a)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx($s,{resource:"datasets"})})}):!e||r.length<2?o.jsx(ls,{children:o.jsx(Qv,{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(Sy,{owner:"dataset-items-compare",children:o.jsxs(fe,{as:ui,to:`/datasets/${e}`,variant:"outline",children:[o.jsx(xc,{}),"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(ca,{children:[o.jsxs(ca.Column,{children:[o.jsxs(ca.Title,{children:[o.jsx(Dw,{}),"Compare Dataset Items"]}),o.jsx(ca.Description,{children:o.jsxs(dc,{children:["Comparing ",r.length," items of"," ",o.jsx(ui,{to:`/datasets/${e}`,className:"text-info1 hover:underline",children:s?.name||e?.slice(0,8)})]})})]}),o.jsx(ca.Column,{children:o.jsx($r,{children:o.jsx(fe,{variant:"primary",onClick:()=>c(f=>!f),children:l?o.jsxs(o.Fragment,{children:[o.jsx(cit,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx(Tin,{})," Diff View"]})})})})]}),o.jsx($v,{className:"grid-cols-[1fr_3vw_1fr]",children:r.map((f,p)=>o.jsxs(y.Fragment,{children:[o.jsx(GXr,{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(D0t,{codeA:MZe(u),codeB:MZe(d)})]})})]})}function GXr({datasetId:e,itemId:t,Link:n,idx:r,itemIds:s,onItemChange:a,showContent:i=!0}){const{data:l,isLoading:c}=wge(e,t),{data:u}=WO(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(Hr,{children:[o.jsxs(Hr.Toolbar,{className:"flex gap-4",children:[o.jsxs($a,{name:`compare-item-${r}`,value:t,onValueChange:a,children:[o.jsx(Da,{"aria-label":"Item",children:o.jsx(Ma,{placeholder:"Select item"})}),o.jsx(La,{children:f.map(p=>o.jsx(Yr,{value:p.value,disabled:p.disabled,children:p.label},p.value))})]}),o.jsxs(fe,{as:n,to:`/datasets/${e}/items/${t}`,children:[o.jsx(KO,{}),"Versions"]})]}),i&&o.jsx(Hr.Content,{children:c?o.jsx("div",{className:"text-neutral4 text-sm",children:"Loading..."}):l?o.jsxs(o.Fragment,{children:[o.jsx(lXr,{item:l}),o.jsx(VEe,{item:l,Link:n})]}):o.jsxs("div",{className:"text-neutral4 text-sm",children:["Item ",t.slice(0,8)," not found"]})})]})}function DZe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function QXr(){const{datasetId:e,itemId:t}=wr(),[n,r]=Ei(),[s,a]=y.useState(!1),i=n.get("ids")?.split(",").map(Number).filter(h=>!isNaN(h)&&h>0)??[],{data:l,error:c}=Lx(e??""),{Link:u}=vn(),{data:d}=BEe(e??"",t??""),{data:f}=Cge(e??"",t??"",i[0]??0,l?.version),{data:p}=Cge(e??"",t??"",i[1]??0,l?.version);return c&&ms(c)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})}):c&&vs(c)?o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx($s,{resource:"datasets"})})}):!e||!t||i.length<2?o.jsx(ls,{children:o.jsx(Qv,{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(Sy,{owner:"dataset-item-versions-compare",children:o.jsxs(fe,{as:ui,to:`/datasets/${e}/items/${t}`,variant:"outline",children:[o.jsx(xc,{}),"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(ca,{children:[o.jsxs(ca.Column,{children:[o.jsxs(ca.Title,{children:[o.jsx(Dw,{}),"Compare Dataset Item Versions"]}),o.jsx(ca.Description,{children:o.jsxs(dc,{children:["Comparing ",i.length," versions of"," ",o.jsx(ui,{to:`/datasets/${e}/items/${t}`,className:"text-info1 hover:underline",children:t})]})})]}),o.jsx(ca.Column,{children:o.jsx($r,{children:o.jsx(fe,{variant:"primary",onClick:()=>a(h=>!h),children:s?o.jsxs(o.Fragment,{children:[o.jsx(cit,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx(uon,{})," Diff View"]})})})})]}),o.jsx($v,{className:"grid-cols-[1fr_3vw_1fr]",children:i.map((h,m)=>o.jsxs(y.Fragment,{children:[o.jsx(YXr,{datasetId:e,itemId:t,datasetVersion:h,latestVersion:l?.version,allVersions:d??[],versionNumbers:i,Link:u,idx:m,showContent:!s,onVersionChange:g=>{const v=[...i];v[m]=g,r({ids:v.join(",")})}}),m===0&&o.jsx("div",{className:K("bg-surface5 w-[3px] shrink-0 mx-[1.5vw]")})]},h))}),s&&f&&p&&o.jsx(D0t,{codeA:DZe(f),codeB:DZe(p)})]})})]})}function YXr({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}=Cge(e,t,n,r),p=new Set(a.filter((g,v)=>v!==l)),h=s.map(g=>{const v=typeof g.updatedAt=="string"?new Date(g.updatedAt):g.updatedAt;return{value:String(g.datasetVersion),label:o.jsxs(o.Fragment,{children:[o.jsxs("b",{children:["v. ",g.datasetVersion]})," - ",Kn(v,"MMM d, yyyy h:mm a"),g.isLatest?o.jsx(Xs,{color:"blue",size:"small",children:"Latest"}):null]}),disabled:p.has(g.datasetVersion)}}),m=d?{id:d.id,datasetId:e,datasetVersion:d.datasetVersion,input:d.input,groundTruth:d.groundTruth,metadata:d.metadata,createdAt:d.createdAt,updatedAt:d.updatedAt}:null;return o.jsxs(Hr,{children:[o.jsxs(Hr.Toolbar,{className:"grid gap-4 grid-cols-[auto_1fr]",children:[o.jsx(KO,{className:"w-6 h-6 opacity-50"}),o.jsxs($a,{name:`compare-version-${l}`,value:String(n),onValueChange:g=>u(Number(g)),children:[o.jsx(Da,{"aria-label":"Version",className:"w-full",children:o.jsx(Ma,{placeholder:"Select version"})}),o.jsx(La,{children:h.map(g=>o.jsx(Yr,{value:g.value,disabled:g.disabled,children:g.label},g.value))})]})]}),c&&o.jsx(Hr.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(VEe,{item:m,Link:i})})]})}function XXr(){const{datasetId:e}=wr(),[t]=Ei(),n=t.get("ids")?.split(",").map(Number).filter(g=>!isNaN(g)&&g>0)??[],r=qs(),{data:s,error:a}=Lx(e??""),i=WO(e??"",void 0,n[0]??null),l=WO(e??"",void 0,n[1]??null),c=y.useMemo(()=>i.data??[],[i.data]),u=y.useMemo(()=>l.data??[],[l.data]),d=y.useMemo(()=>{const g=new Map;for(const v of[...c,...u])g.has(v.id)||g.set(v.id,{id:v.id,createdAt:new Date(v.createdAt)});return[...g.values()].sort((v,b)=>b.createdAt.getTime()-v.createdAt.getTime())},[c,u]),f=y.useMemo(()=>new Map(c.map(g=>[g.id,g])),[c]),p=y.useMemo(()=>new Map(u.map(g=>[g.id,g])),[u]);if(a&&ms(a))return o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})})});if(a&&vs(a))return o.jsx(ls,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx($s,{resource:"datasets"})})});if(!e||n.length<2)return o.jsx(ls,{children:o.jsx(Qv,{children:o.jsx("div",{className:"text-neutral4 text-center py-8",children:o.jsx("p",{children:"Select at least two versions to compare."})})})});const h=(g,v,b)=>{r(`/datasets/${e}/items/${g}/versions?ids=${v?.datasetVersion??""},${b?.datasetVersion??""}`)},m=(g,v)=>{r(`/datasets/${e}/versions?ids=${g},${v}`,{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(ca,{children:[o.jsxs(ca.Column,{children:[o.jsxs(ca.Title,{children:[o.jsx(Wln,{})," Compare Dataset Versions"]}),o.jsx(ca.Description,{children:o.jsxs(dc,{children:[o.jsx(KO,{})," Comparing ",n.length," versions of"," ",s?.name||e?.slice(0,8)]})})]}),o.jsx(ca.Column,{children:o.jsxs(fe,{as:ui,to:`/datasets/${e}`,children:[o.jsx(xc,{}),"Back to Dataset"]})})]}),o.jsx($v,{children:o.jsxs(Hr,{children:[o.jsx(AXr,{datasetId:e,versionA:String(n[0]),versionB:String(n[1]),onVersionChange:m}),o.jsx(MXr,{datasetId:e,versionA:n[0],versionB:n[1],allItems:d,itemsAMap:f,itemsBMap:p,onItemClick:h})]})})]})})})}function KXr(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 JXr({scorers:e,datasets:t,experiments:n,avgScore:r,prevAvgScore:s,totalNeedsReview:a,isLoadingScorers:i,isLoadingDatasets:l,isLoadingExperiments:c,isLoadingScores:u,isLoadingReview:d}){const f=e?Object.keys(e).length:void 0,p=t?.length,h=n?.length,m=r!=null&&s!=null&&s!==0?{changePct:Math.round((r-s)/s*100*10)/10,prevValue:String(s)}:null,g=KXr(n);return o.jsxs(o.Fragment,{children:[o.jsxs(Qr,{children:[o.jsx(Qr.Label,{children:"Total Scorers"}),i?o.jsx(Qr.Loading,{}):f!=null?o.jsxs(o.Fragment,{children:[o.jsx(Qr.Value,{children:String(f)}),o.jsx(Qr.NoChange,{message:"Static count"})]}):o.jsx(Qr.NoData,{})]}),o.jsxs(Qr,{children:[o.jsx(Qr.Label,{children:"Total Datasets"}),l?o.jsx(Qr.Loading,{}):p!=null?o.jsxs(o.Fragment,{children:[o.jsx(Qr.Value,{children:String(p)}),o.jsx(Qr.NoChange,{message:"Static count"})]}):o.jsx(Qr.NoData,{})]}),o.jsxs(Qr,{children:[o.jsx(Qr.Label,{children:"Avg Score"}),u?o.jsx(Qr.Loading,{}):r!=null?o.jsxs(o.Fragment,{children:[o.jsx(Qr.Value,{children:String(r)}),m?o.jsx(Qr.Change,{changePct:m.changePct,prevValue:m.prevValue}):o.jsx(Qr.NoChange,{})]}):o.jsx(Qr.NoData,{})]}),o.jsxs(Qr,{children:[o.jsx(Qr.Label,{children:"Total Experiments"}),c?o.jsx(Qr.Loading,{}):h!=null?o.jsxs(o.Fragment,{children:[o.jsx(Qr.Value,{children:String(h)}),g?o.jsx(Qr.Change,{changePct:g.changePct,prevValue:g.prevValue}):o.jsx(Qr.NoChange,{})]}):o.jsx(Qr.NoData,{})]}),o.jsxs(Qr,{children:[o.jsx(Qr.Label,{children:"Needs Review"}),d?o.jsx(Qr.Loading,{}):a!=null?o.jsxs(o.Fragment,{children:[o.jsx(Qr.Value,{children:String(a)}),a>0?o.jsx(Qr.NoChange,{message:"items pending review"}):o.jsx(Qr.NoChange,{message:"All caught up"})]}):o.jsx(Qr.NoData,{})]})]})}const LZe="auto 1fr auto auto auto auto auto auto auto";function eKr(e){return e?(typeof e=="string"?new Date(e):e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}const tKr={completed:"success",running:"warning",failed:"error",pending:"neutral"};function nKr({experiments:e,datasets:t,reviewByExperiment:n,isLoading:r,search:s="",statusFilter:a="all",datasetFilter:i="all"}){const{paths:l,Link:c}=vn(),u=y.useMemo(()=>{const p=new Map;return t?.forEach(h=>p.set(h.id,h.name)),p},[t]),d=y.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=y.useMemo(()=>{const p=s.toLowerCase();return d.filter(h=>{const m=h.datasetId?u.get(h.datasetId)??"":"",g=!p||h.id.toLowerCase().includes(p)||m.toLowerCase().includes(p)||(h.targetId??"").toLowerCase().includes(p),v=a==="all"||h.status===a,b=i==="all"||h.datasetId===i;return g&&v&&b})},[d,s,u,a,i]);return r?o.jsx(Go,{columns:LZe}):o.jsxs(xe,{columns:LZe,variant:"striped",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Experiment"}),o.jsx(xe.TopCell,{children:"Dataset"}),o.jsx(xe.TopCell,{children:"Target"}),o.jsx(xe.TopCell,{children:"Status"}),o.jsx(xe.TopCell,{className:"text-center",children:"Items"}),o.jsx(xe.TopCell,{className:"text-center",children:"Succeeded"}),o.jsx(xe.TopCell,{className:"text-center",children:"Failed"}),o.jsx(xe.TopCell,{className:"text-center",children:"Review"}),o.jsx(xe.TopCell,{children:"Date"})]}),f.map(p=>{const h=p.datasetId?u.get(p.datasetId)??p.datasetId.slice(0,8):"—",m=p.status??"pending",g=p.succeededCount??0,v=p.failedCount??0,b=p.totalItems??0,w=b>0?Math.round(g/b*100):0;return o.jsxs(xe.RowLink,{to:l.experimentLink(p.id),LinkComponent:c,children:[o.jsx(xe.NameCell,{className:"font-mono",children:p.id.slice(0,8)}),o.jsx(xe.TextCell,{children:h}),o.jsx(xe.Cell,{children:o.jsxs("span",{className:"truncate",children:[p.targetType," ",p.targetId]})}),o.jsx(xe.Cell,{children:o.jsx(Xm,{variant:tKr[m]??"neutral",withDot:!0,children:m})}),o.jsx(xe.TextCell,{className:"text-center",children:b}),o.jsx(xe.TextCell,{className:"text-center",children:o.jsxs("span",{className:g>0?"text-accent1":"",children:[g," (",w,"%)"]})}),o.jsx(xe.TextCell,{className:"text-center",children:o.jsx("span",{className:v>0?"text-accent2":"",children:v})}),o.jsx(xe.Cell,{className:"text-center",children:(()=>{const S=n?.get(p.id);if(!S)return o.jsx("span",{className:"text-neutral2",children:"—"});const O=S.needsReview+S.complete;return O===0?o.jsx("span",{className:"text-neutral2",children:"—"}):S.needsReview>0?o.jsxs(Xs,{size:"small",color:"yellow",children:[S.needsReview," pending"]}):o.jsxs(Xs,{size:"small",color:"green",children:[S.complete,"/",O," reviewed"]})})()}),o.jsx(xe.TextCell,{children:eKr(p.createdAt)})]},p.id)})]})}const rKr=[{value:"all",label:"All statuses"},{value:"completed",label:"Completed"},{value:"running",label:"Running"},{value:"failed",label:"Failed"},{value:"pending",label:"Pending"}];function sKr(e){return[{value:"all",label:"All datasets"},...(e??[]).map(t=>({value:t.id,label:t.name}))]}const h8={completed:"#22c55e",running:"#facc15",pending:"#fb923c",failed:"#f87171"},aKr=[{label:"Completed",color:h8.completed},{label:"Running",color:h8.running},{label:"Pending",color:h8.pending},{label:"Failed",color:h8.failed}];function iKr({experiments:e,datasets:t,isLoading:n,isError:r}){const{data:s,maxVal:a}=y.useMemo(()=>{if(!e||e.length===0)return{data:[],maxVal:0};const l=new Map;if(t)for(const f of t)l.set(f.id,f.name);const c=new Map;for(const f of e){const p=f.datasetId??"unknown";c.has(p)||c.set(p,{completed:0,running:0,pending:0,failed:0});const h=c.get(p),m=f.status;m in h&&h[m]++}let u=0;return{data:Array.from(c.entries()).map(([f,p])=>{const h=p.completed+p.running+p.pending+p.failed;return h>u&&(u=h),{name:l.get(f)??f.slice(0,12),values:[p.completed,p.running,p.pending,p.failed]}}),maxVal:u}},[e,t]),i=s.length>0;return o.jsxs(Bt,{children:[o.jsxs(Bt.TopBar,{children:[o.jsx(Bt.TitleAndDescription,{title:"Experiments by Dataset",description:"Experiment status breakdown per dataset."}),i&&o.jsx(Bt.Summary,{value:String(e?.length??0),label:"Total experiments"})]}),n?o.jsx(Bt.Loading,{}):r?o.jsx(Bt.Error,{message:"Failed to load experiments data"}):o.jsx(Bt.Content,{children:i?o.jsx(rT,{data:s,segments:aKr,maxVal:a,fmt:l=>String(l)}):o.jsx(Bt.NoData,{message:"No experiments have been run yet"})})]})}const oKr=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Wr,{iconSlot:o.jsx(mf,{}),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(fe,{variant:"ghost",as:"a",href:"https://mastra.ai/en/docs/evals/datasets/running-experiments",target:"_blank",rel:"noopener noreferrer",children:["Experiments Documentation ",o.jsx(Ta,{})]})})})});function lKr({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(kf,{label:"Search experiments",placeholder:"Filter by experiment, dataset, or target",value:e,onSearch:t}),o.jsxs($r,{children:[o.jsx(uc,{label:"Status",labelIsHidden:!0,name:"filter-status",options:[...rKr],value:n,onValueChange:r,className:"whitespace-nowrap"}),o.jsx(uc,{label:"Dataset",labelIsHidden:!0,name:"filter-dataset",options:i,value:s,onValueChange:a,className:"whitespace-nowrap"}),l&&c&&o.jsxs(fe,{onClick:l,size:"sm",variant:"default",children:[o.jsx(gs,{className:"size-3"})," Reset"]})]})]})}function cKr(){const{data:e,isLoading:t,error:n}=Zp(),{data:r,isLoading:s,error:a}=wy(),{data:i,isLoading:l,error:c}=UW(),{data:u,isLoading:d,isError:f,error:p}=LHr(),{data:h,isLoading:m,isError:g,error:v}=WEe(),b=r?.datasets,w=i?.experiments,S=y.useMemo(()=>zXr(h),[h]),O=n||a||c||p||v;return O&&ms(O)?o.jsx(or,{children:o.jsx(Vs,{})}):O&&vs(O)?o.jsx(or,{children:o.jsx($s,{resource:"evaluation"})}):O?o.jsx(or,{children:o.jsx(Li,{title:"Failed to load evaluation data",message:O.message})}):o.jsx(Lt,{width:"wide",height:"full",children:o.jsxs("div",{className:"flex flex-col gap-6",children:[o.jsx(_fe,{children:o.jsx(JXr,{scorers:e,datasets:b,experiments:w,avgScore:u?.avgScore??null,prevAvgScore:u?.prevAvgScore??null,totalNeedsReview:S.needsReview,isLoadingScorers:t,isLoadingDatasets:s,isLoadingExperiments:l,isLoadingScores:d,isLoadingReview:m})}),o.jsx(jHr,{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(fYr,{experiments:w,isLoading:l,isError:!!c}),o.jsx(iKr,{experiments:w,datasets:b,isLoading:l,isError:!!c})]}),o.jsx(LXr,{reviewSummary:h,experiments:w,datasets:b,isLoading:m,isError:!!g})]})})}function uKr(){const[e,t]=y.useState(""),[n,r]=y.useState("all"),[s,a]=y.useState("all"),{data:i,isLoading:l,error:c}=wy(),{data:u,isLoading:d,error:f}=UW(),{data:p}=WEe(),h=y.useMemo(()=>i?.datasets??[],[i?.datasets]),m=y.useMemo(()=>u?.experiments??[],[u?.experiments]),g=y.useMemo(()=>sKr(h),[h]),v=y.useMemo(()=>TLt(p),[p]),b=l||d,w=f||c;if(w&&ms(w))return o.jsx(or,{children:o.jsx(Vs,{})});if(f&&vs(f))return o.jsx(or,{children:o.jsx($s,{resource:"experiments"})});if(c&&vs(c))return o.jsx(or,{children:o.jsx($s,{resource:"datasets"})});if(w)return o.jsx(or,{children:o.jsx(Li,{title:"Failed to load experiments",message:w.message})});if(m.length===0&&!b)return o.jsx(or,{children:o.jsx(oKr,{})});const S=n!=="all"||s!=="all"||e!=="",O=()=>{t(""),r("all"),a("all")};return o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx(lKr,{search:e,onSearchChange:t,statusFilter:n,onStatusFilterChange:r,datasetFilter:s,onDatasetFilterChange:a,datasetOptions:g,onReset:O,hasActiveFilters:S})}),o.jsx(nKr,{experiments:m,datasets:h,reviewByExperiment:v,isLoading:b,search:e,statusFilter:n,datasetFilter:s})]})}function m8({children:e}){return o.jsxs(Lt,{height:"full",children:[o.jsx("div",{}),o.jsx(Lt.MainArea,{isCentered:!0,children:e})]})}function dKr(){const{experimentId:e}=wr(),{data:t,isLoading:n}=UW(),s=t?.experiments?.find(h=>h.id===e)?.datasetId??"",{data:a,isLoading:i,error:l}=zB(s,e??""),{data:c,isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p}=FW({datasetId:s,experimentId:e??"",experimentStatus:a?.status});return!e||n||i?null:l&&ms(l)?o.jsx(m8,{children:o.jsx(Vs,{})}):l&&vs(l)?o.jsx(m8,{children:o.jsx($s,{resource:"datasets"})}):l&&DSe(l)||!n&&!s||!i&&!l&&!a?o.jsx(m8,{children:o.jsx(Wr,{iconSlot:o.jsx(Ave,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${e}".`,actionSlot:o.jsxs(fe,{as:ui,to:"/experiments",children:[o.jsx(xc,{}),"Back to Experiments"]})})}):l?o.jsx(m8,{children:o.jsx(Li,{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(NLt,{experiment:a}),o.jsx(Lt.MainArea,{children:o.jsx(jLt,{experimentId:e,datasetId:s,experimentStatus:a.status,results:c??[],isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p})})]})}function fKr({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 ILt({connections:e,isAdmin:t,disconnectPending:n,onDisconnect:r}){return o.jsx("ul",{className:"space-y-1",children:e.map(s=>o.jsx(fKr,{connection:s,isAdmin:t,disconnectPending:n,onDisconnect:()=>r(s.connectionId)},s.connectionId))})}function pKr({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(ILt,{connections:a,isAdmin:t,disconnectPending:n,onDisconnect:r})]},s))})}function hKr({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(pKr,{groups:r,isAdmin:s,disconnectPending:l,onDisconnect:u}):o.jsx(ILt,{connections:n,isAdmin:s,disconnectPending:l,onDisconnect:u}),c?o.jsx("p",{className:"text-red-600",children:String(c)}):null]})}function mKr({providers:e,toolkits:t,providerId:n,toolkit:r,label:s,providersLoading:a,providersError:i,toolkitsLoading:l,toolkitsError:c,authorizePending:u,authorizeError:d,authorizedConnection:f,onProviderChange:p,onToolkitChange:h,onLabelChange:m,onConnect:g}){return o.jsxs("div",{className:"space-y-4 border rounded p-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"block font-medium",htmlFor:"provider-select",children:"Provider"}),o.jsxs("select",{id:"provider-select",className:"border rounded px-2 py-1 w-full",value:n,onChange:v=>p(v.target.value),disabled:a,children:[o.jsx("option",{value:"",children:"— select provider —"}),e.map(v=>o.jsxs("option",{value:v.id,children:[v.displayName??v.name," (",v.id,")"]},v.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:v=>h(v.target.value),disabled:!n||l,children:[o.jsx("option",{value:"",children:"— select toolkit —"}),t.map(v=>o.jsxs("option",{value:v.slug,children:[v.name," (",v.slug,")"]},v.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:v=>m(v.target.value),disabled:!n||!r})]}),o.jsx("button",{type:"button",className:"bg-blue-600 text-white rounded px-4 py-2 disabled:opacity-50",onClick:g,disabled:!n||!r||u,children:u?"Authorizing…":"Connect"}),d?o.jsx("p",{className:"text-red-600",children:String(d)}):null,f&&o.jsxs("p",{className:"text-green-700",children:["Authorized: ",f.connectionId," (status: ",f.status,")"]})]})}const FZe=e=>e.authorId?.trim()||"shared",gKr=(e,t)=>{if(!t||new Set(e.map(FZe)).size<=1)return null;const r=new Map;for(const a of e){const i=FZe(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},vKr=["*","tool-providers:*","tool-providers:admin"];function yKr(){const{data:e}=lm();return e?.permissions?.some(t=>vKr.includes(t))??!1}function bKr(){const[e,t]=y.useState(""),[n,r]=y.useState(""),[s,a]=y.useState(""),i=VN(),l=mH(e||null),c=CIt(e||null,n||null),u=_It(),d=kIt(),f=yKr(),p=i.data?.providers??[],h=l.data?.data??[],m=y.useMemo(()=>c.data?.items??[],[c.data?.items]),g=y.useMemo(()=>gKr(m,f),[m,f]),v=S=>{t(S),r("")},b=()=>{!e||!n||u.mutate({providerId:e,toolkit:n,label:s.trim()||null},{onSuccess:()=>{a(""),c.refetch()}})},w=S=>{d.mutate({providerId:e,connectionId:S})};return o.jsxs("div",{className:"p-6 max-w-3xl space-y-6 text-sm",children:[o.jsx("h1",{className:"text-2xl font-semibold",children:"Integrations"}),o.jsx("p",{className:"text-gray-500",children:"Minimal page to verify the ToolProvider backend. Pick a provider and toolkit, then connect."}),o.jsx(mKr,{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:v,onToolkitChange:r,onLabelChange:a,onConnect:b}),o.jsx(hKr,{providerId:e,toolkit:n,connections:m,groupedByAuthor:g,isAdmin:f,isLoading:c.isLoading,error:c.error,disconnectPending:d.isPending,disconnectError:d.error,onDisconnect:w})]})}function xKr({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(Rh,{className:"h-10 w-10"}),o.jsx("h1",{className:"text-xl font-semibold text-neutral6",children:e})]}),t,n,r]})})}function ALt({redirectUri:e,onSuccess:t,initialMode:n="signin",errorMessage:r}){const{data:s,isLoading:a}=Yl(),{mutate:i,isPending:l,error:c}=TCr(),{mutate:u,isPending:d,error:f}=ICr(),{mutate:p,isPending:h}=HNt(),[m,g]=y.useState(n),[v,b]=y.useState(""),[w,S]=y.useState(""),[O,_]=y.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,j=C.type==="sso"||C.type==="both",E=C.type==="credentials"||C.type==="both",N=C.sso,I=C.signUpEnabled!==!1,P=m==="signin"||!I,$=P?l:d,z=P?c:f,D=()=>{t?t():e?window.location.href=e:window.location.href="/"},q=M=>{M.preventDefault(),P?i({email:w,password:O},{onSuccess:D}):u({email:w,password:O,name:v||void 0},{onSuccess:D})},W=()=>{p({redirectUri:e},{onSuccess:M=>{window.location.href=M.url}})},L=()=>{g(P?"signup":"signin")},F=C.description?o.jsxs("div",{className:"flex items-start gap-2.5 rounded-md border border-border1 bg-surface1 p-3",children:[o.jsx(of,{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(xKr,{title:P?"Sign in to Mastra Studio":"Create your account",description:F,errorBanner:B,children:[E&&o.jsxs("form",{onSubmit:q,className:"space-y-4",children:[!P&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"name",className:"block text-sm text-neutral4",children:"Name"}),o.jsx(On,{id:"name",type:"text",value:v,onChange:M=>b(M.target.value),placeholder:"Your name",variant:"default",size:"lg"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"email",className:"block text-sm text-neutral4",children:"Email"}),o.jsx(On,{id:"email",type:"email",value:w,onChange:M=>S(M.target.value),placeholder:"you@example.com",required:!0,variant:"default",size:"lg"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"password",className:"block text-sm text-neutral4",children:"Password"}),o.jsx(On,{id:"password",type:"password",value:O,onChange:M=>_(M.target.value),placeholder:P?"Enter your password":"Create a password",required:!0,variant:"default",size:"lg"})]}),z&&o.jsx("div",{className:"rounded-md bg-red-500/10 p-3 text-sm text-red-400",children:z.message}),o.jsx(fe,{type:"submit",disabled:$,className:"w-full",size:"lg",children:$?P?"Signing in...":"Creating account...":P?"Sign in":"Create account"}),I&&o.jsxs("div",{className:"text-center text-sm",children:[o.jsx("span",{className:"text-neutral3",children:P?"Don't have an account? ":"Already have an account? "}),o.jsx("button",{type:"button",onClick:L,className:"text-neutral6 hover:underline",children:P?"Sign up":"Sign in"})]})]}),j&&E&&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"})})]}),j&&N&&o.jsxs(fe,{onClick:W,disabled:h,className:"w-full",size:"lg",variant:"outline",children:[N.icon&&o.jsx("span",{className:"mr-2",children:N.icon}),h?"Redirecting...":N.text||"Sign in"]})]})}function wKr(){const[e]=Ei(),t=qs(),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(ALt,{redirectUri:n,onSuccess:i,initialMode:s,errorMessage:a})}function SKr(){const[e,t]=Ei(),n=Obr(e,t),r=Ebr(e,t),[s,a]=y.useState(),[i,l]=y.useState(!1),{data:c=[],isPending:u}=QSe(),{data:d=[],isPending:f}=YSe({entityType:n.selectedEntityOption?.entityType,rootOnly:!0}),{data:p=[],isPending:h}=XSe(),{data:m=[],isPending:g}=KSe(),v=y.useMemo(()=>Zvr({availableTags:c,availableRootEntityNames:d,availableServiceNames:m,availableEnvironments:p,loading:{tags:u,entityNames:f,serviceNames:g,environments:h}}),[c,d,m,p,u,f,g,h]),b=y.useMemo(()=>Xvr({rootEntityType:n.selectedEntityOption?.entityType,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,tokens:n.filterTokens}),[n.filterTokens,n.selectedDateFrom,n.selectedDateTo,n.selectedEntityOption]),{data:w=[],isLoading:S,error:O,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:j}=Sbr({filters:b}),{logIdMap:E,featuredLog:N,handleLogClick:I,handlePreviousLog:P,handleNextLog:$}=Nbr(w,n.featuredLogId,n.handleFeaturedChange,n.featuredTraceId),{data:z,isLoading:D}=GSe(n.featuredTraceId??null),{data:q,isLoading:W}=rD(n.featuredTraceId??"",n.featuredSpanId??""),L=y.useCallback(()=>n.applyFilterTokens(Kvr(v,n.filterTokens)),[v,n]),F=y.useCallback(()=>n.handleFeaturedChange({logId:null}),[n]),B=y.useCallback(X=>n.handleFeaturedChange({traceId:X,spanId:null}),[n]),M=y.useCallback((X,te)=>n.handleFeaturedChange({traceId:X,spanId:te}),[n]),Q=y.useCallback(()=>{n.handleFeaturedChange({traceId:null,spanId:null}),l(!1)},[n]),V=y.useCallback(()=>n.handleFeaturedChange({spanId:null}),[n]),R=y.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(Zwe,{preset:n.datePreset,onPresetChange:n.handleDatePresetChange,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,onDateChange:n.handleDateChange,disabled:S,presets:["last-24h","last-3d","last-7d","last-14d","last-30d","custom"]}),o.jsx(y0e,{fields:v,tokens:n.filterTokens,onTokensChange:n.handleFilterTokensChange,disabled:S,onStartTextFilter:a})]})}),o.jsx(hbr,{isLoading:S,filterFields:v,filterTokens:n.filterTokens,onFilterTokensChange:n.handleFilterTokensChange,onClear:L,onRemoveAll:n.handleRemoveAll,onSave:r.handleSave,onRemoveSaved:r.hasSavedFilters?r.handleRemoveSaved:void 0,autoFocusFilterFieldId:s})]});if(O)return o.jsxs(Lt,{width:"wide",height:"full",children:[U,o.jsx(Lt.MainArea,{isCentered:!0,children:o.jsx(cbr,{error:O,resource:"logs",errorTitle:"Failed to load logs"})})]});const Z=!!n.selectedEntityOption||n.filterTokens.length>0;return w.length===0&&!S&&!Z?o.jsxs(Lt,{width:"wide",height:"full",children:[U,o.jsx(Lt.MainArea,{isCentered:!0,children:o.jsx(ybr,{datePreset:n.datePreset,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo})})]}):o.jsxs(Lt,{width:"wide",height:"full",children:[U,o.jsx(ubr,{logCollapsed:i,listSlot:o.jsx(pbr,{logs:w,isLoading:S,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:j,logIdMap:E,featuredLogId:n.featuredLogId,onLogClick:I}),logPanelSlot:N?o.jsx(lbr,{log:N,onClose:F,onTraceClick:B,onSpanClick:M,onPrevious:P,onNext:$,collapsed:i,onCollapsedChange:l}):null,tracePanelSlot:n.featuredTraceId?o.jsx(Pyr,{traceId:n.featuredTraceId,spans:z?.spans,isLoading:D,onClose:Q,onSpanSelect:R,selectedSpanId:n.featuredSpanId}):null,spanPanelSlot:n.featuredTraceId&&n.featuredSpanId?o.jsx(Ryr,{spanId:n.featuredSpanId,span:q?.span,isLoading:W,onClose:V}):null})]})}function kKr({server:e}){const{paths:t,Link:n}=vn(),s=We().options.baseUrl,a=s?`${s}/api/mcp/${e.id}/sse`:"",{data:i}=O5t(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=Zh(e.name,50);return o.jsxs(xe.RowLink,{to:t.mcpServerLink(e.id),LinkComponent:n,children:[o.jsx(xe.NameCell,{children:f}),o.jsx(xe.DescriptionCell,{children:a}),o.jsx(xe.TextCell,{className:"text-center",children:u||""}),o.jsx(xe.TextCell,{className:"text-center",children:c||""}),o.jsx(xe.TextCell,{className:"text-center",children:d||""})]})}function OKr({mcpServers:e,isLoading:t,search:n=""}){const r=y.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(Go,{columns:"auto 1fr auto auto auto"}):o.jsxs(xe,{columns:"auto 1fr auto auto auto",variant:"striped",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Name"}),o.jsx(xe.TopCell,{children:"URL"}),o.jsx(xe.TopCellSmart,{long:"Agents",short:o.jsx(Ko,{}),tooltip:"Agent Tools",className:"text-center"}),o.jsx(xe.TopCellSmart,{long:"Tools",short:o.jsx(ff,{}),tooltip:"Tools",className:"text-center"}),o.jsx(xe.TopCellSmart,{long:"Workflows",short:o.jsx(df,{}),tooltip:"Workflow Tools",className:"text-center"})]}),r.length===0&&n?o.jsx(xe.NoMatch,{message:"No MCP Servers match your search"}):null,r.map(s=>o.jsx(kKr,{server:s},s.id))]})}const _Kr=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Wr,{iconSlot:o.jsx(mf,{}),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(fe,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/tools-mcp/mcp-overview",target:"_blank",rel:"noopener noreferrer",children:["MCP Documentation ",o.jsx(Ta,{})]})})}),CKr=()=>{const{data:e=[],isLoading:t,error:n}=AW(),[r,s]=y.useState("");return n&&ms(n)?o.jsx(or,{children:o.jsx(Vs,{})}):n&&vs(n)?o.jsx(or,{children:o.jsx($s,{resource:"MCP servers"})}):n?o.jsx(or,{children:o.jsx(Li,{title:"Failed to load MCP servers",message:n.message})}):e.length===0&&!t?o.jsx(or,{children:o.jsx(_Kr,{})}):o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx("div",{className:"max-w-120",children:o.jsx(kf,{onSearch:s,label:"Filter MCP servers",placeholder:"Filter by name"})})}),o.jsx(OKr,{mcpServers:e,isLoading:t,search:r})]})},EKr=(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 jKr({tools:e,agents:t,isLoading:n,search:r=""}){const{paths:s,Link:a}=vn(),i=y.useMemo(()=>EKr(e,t),[e,t]),l=y.useMemo(()=>i.filter(c=>c.id.toLowerCase().includes(r.toLowerCase())),[i,r]);return n?o.jsx(Go,{columns:"auto 1fr auto"}):o.jsxs(xe,{columns:"auto 1fr auto",variant:"striped",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Name"}),o.jsx(xe.TopCell,{children:"Description"}),o.jsx(xe.TopCellSmart,{long:"Agents",short:o.jsx(Ko,{}),tooltip:"Attached Agents",className:"text-center"})]}),l.length===0&&r?o.jsx(xe.NoMatch,{message:"No Tools match your search"}):null,l.map(c=>{const u=Zh(c.id,50),d=Zh(c.description??"",200),f=c.agents.length;return o.jsxs(xe.RowLink,{to:s.toolLink(c.id),LinkComponent:a,children:[o.jsx(xe.NameCell,{children:u}),o.jsx(xe.DescriptionCell,{children:d}),o.jsx(xe.TextCell,{className:"text-center",children:f||""})]},c.id)})]})}const TKr=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Wr,{iconSlot:o.jsx(mf,{}),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(fe,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/agents/using-tools-and-mcp",target:"_blank",rel:"noopener noreferrer",children:["Tools Documentation ",o.jsx(Ta,{})]})})}),NKr=()=>{const e=We();return An({mutationFn:async({toolId:t,input:n,requestContext:r})=>{const s=new QO;Object.entries(r??{}).forEach(([a,i])=>{s.set(a,i)});try{return await e.getTool(t).execute({data:n,requestContext:s})}catch(a){throw Be.error("Error executing dev tool"),console.error("Error executing dev tool:",a),a}}})},IKr=({toolId:e})=>{const{canExecute:t}=dl(),n=t("tools"),{data:r={}}=cm(),s=y.useMemo(()=>{for(const g of Object.values(r))if(g.tools){const v=Object.values(g.tools).find(b=>b.id===e);if(v)return v}return null},[r,e]),{data:a,isLoading:i,error:l}=B_r(e,{enabled:!s}),c=s||a,{mutateAsync:u,isPending:d,data:f}=NKr(),{requestContext:p}=Ss();y.useEffect(()=>{if(l){const g=l instanceof Error?l.message:"Failed to load tool";Be.error(`Error loading tool: ${g}`)}},[l]);const h=async(g,v)=>{if(!c)return;const b={...p??{},...v??{}};return u({toolId:c.id,input:g,requestContext:b})},m=c?.inputSchema?Yh(Gh(px(c?.inputSchema))):xs({});return i?o.jsxs("div",{className:"p-6",children:[o.jsx(Pt,{className:"h-8 w-48 mb-4"}),o.jsx(Pt,{className:"h-32 w-full"})]}):l?null:c?n?o.jsx(TEe,{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 AKr({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}=qN(),{data:p={},isLoading:h,isError:m,error:g}=cm(),{navigate:v,paths:b}=vn();y.useEffect(()=>{if(d){const _=f instanceof Error?f.message:"Failed to load tools";Be.error(`Error loading tools: ${_}`)}},[d,f]),y.useEffect(()=>{if(m){const _=g instanceof Error?g.message:"Failed to load agents";Be.error(`Error loading agents: ${_}`)}},[m,g]);const w=new Map;Object.values(p).forEach(_=>{_.tools&&Object.values(_.tools).forEach(C=>{w.has(C.id)||w.set(C.id,C)})}),Object.values(c).forEach(_=>{w.has(_.id)||w.set(_.id,_)});const S=Array.from(w.values()).map(_=>({label:_.id,value:_.id})),O=_=>{t?t(_):_&&_!==e&&v(b.toolLink(_))};return o.jsx(Wc,{options:S,value:e,onValueChange:O,placeholder:u||h?"Loading tools...":n,searchPlaceholder:r,emptyText:s,className:a,disabled:i||u||h||d||m,variant:l})}const RKr=({isLoading:e,server:t})=>{const[{sseUrl:n,httpStreamUrl:r},s]=y.useState({sseUrl:"",httpStreamUrl:""});if(y.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(Qv,{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(Qv,{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(gn,{icon:o.jsx($Ct,{className:"text-neutral6"}),className:"rounded-r-sm text-neutral4!",children:"Version"}),o.jsx(gn,{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(gn,{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(xa,{tooltip:"Copy HTTP Stream URL",content:r})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(gn,{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(xa,{tooltip:"Copy SSE URL",content:n})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(gn,{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(xa,{tooltip:"Copy Command Line Config",content:a})})]})]})]})]}),o.jsx("div",{className:"h-full overflow-y-scroll border-l border-border1",children:o.jsx(PKr,{server:t})})]})},PKr=({server:e})=>{const{data:t={},isLoading:n}=O5t(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(Ve,{size:"lg",className:"bg-surface4 rounded-md p-1",children:o.jsx(t1,{})}),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(MKr,{tool:a,serverId:e.id},s)})})]})};function $Kr(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 MKr=({tool:e,serverId:t})=>{const n=y.useRef(null),{Link:r,paths:s}=vn(),a=z5t[e.toolType||"tool"],i=$Kr(e._meta);return o.jsxs(bf,{onClick:()=>n.current?.click(),children:[o.jsx(qht,{children:o.jsx(a,{className:"group-hover/entity:text-accent6"})}),o.jsxs(wf,{children:[o.jsx(xf,{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(gn,{className:"text-[10px] py-0",children:"App"})]})}),o.jsx(Up,{children:e.description})]})]})},DKr=()=>{const{serverId:e}=wr(),{data:t=[],isLoading:n}=AW(),r=t.find(s=>s.id===e);return o.jsx("div",{className:"h-full w-full overflow-hidden",children:o.jsx(RKr,{isLoading:n,server:r})})};function LKr(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 FKr=({toolId:e,serverId:t})=>{const{canExecute:n}=dl(),r=n("tools"),s=We(),{data:a,isLoading:i,error:l}=bEe(t,e),{mutateAsync:c,isPending:u,data:d}=Fqr(t,e),f=a?LKr(a._meta):void 0,{data:p}=xt({queryKey:["mcp-app-resource",t,f],queryFn:async()=>f?(await s.readMcpServerResource(t,f)).contents[0]?.text??null:null,enabled:!!f}),h=y.useCallback(async(v,b)=>await c(b),[c]);y.useEffect(()=>{if(l){const v=l instanceof Error?l.message:"Failed to load tool";Be.error(`Error loading tool: ${v}`)}},[l]);const m=async v=>{if(a)return await c(v)};if(i)return o.jsxs("div",{className:"p-6",children:[o.jsx(Pt,{className:"h-8 w-48 mb-4"}),o.jsx(Pt,{className:"h-32 w-full"})]});if(l)return null;if(!a)return o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"header-md",className:"text-neutral3",children:"Tool not found"})});if(!r)return o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"ui-sm",className:"text-neutral3",children:"You don't have permission to execute tools."})});let g;try{g=Yh(Gh(a.inputSchema))}catch(v){console.error("Error processing input schema:",v),Be.error("Failed to process tool input schema."),g=xs({})}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(k5t,{html:p,toolName:a.name??a.id,onToolCall:h})}),o.jsx(TEe,{executionResult:d,isExecutingTool:u,zodInputSchema:g,handleExecuteTool:m,toolDescription:a.description||"",toolId:a.id})]})},zKr=()=>{const{serverId:e,toolId:t}=wr(),{data:n,isLoading:r}=bEe(e,t);return r||!n?null:o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(FKr,{toolId:t,serverId:e})})},zZe={agents:Rs.AGENT,workflows:Rs.WORKFLOW_RUN,tools:Rs.TOOL};function BKr(){const{data:e,isLoading:t,isError:n}=Ivr(),{getTracesHref:r,getBucketTracesHref:s}=BN(),{Link:a}=vn(),i=qs();return o.jsx(vvr,{data:e,isLoading:t,isError:n,onPointClick:(l,c)=>{Number.isFinite(c.tsMs)&&i(s({rootEntityType:zZe[l]},c.tsMs,"1h"))},actions:l=>o.jsx(J3,{href:r({rootEntityType:zZe[l]}),LinkComponent:a})})}function UKr(){const e=zvr(),t=Bvr(),{getTracesHref:n}=BN(),{Link:r}=vn();return o.jsx(bvr,{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 qKr(){const{data:e,isLoading:t,isError:n}=nEt();return o.jsx(eD,{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 VKr(){const{data:e,isLoading:t,isError:n}=jvr();return o.jsx(eD,{label:"Total Model Cost",value:e?.cost!=null?rg(e.cost,e.costUnit):null,prevValue:e?.previousCost!=null?rg(e.previousCost,e.costUnit):void 0,changePct:e?.costChangePercent??null,isLoading:t,isError:n})}function HKr(){const{data:e,isLoading:t,isError:n}=Tvr();return o.jsx(eD,{label:"Total Tokens",value:e?.value!=null?cc(e.value):null,prevValue:e?.previousValue!=null?cc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function WKr(){const{data:e,isLoading:t,isError:n}=Lvr();return o.jsx(eD,{label:"Total Threads",value:e?.value!=null?cc(e.value):null,prevValue:e?.previousValue!=null?cc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function ZKr(){const{data:e,isLoading:t,isError:n}=Fvr();return o.jsx(eD,{label:"Total Resources",value:e?.value!=null?cc(e.value):null,prevValue:e?.previousValue!=null?cc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function GKr({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=>QKr(f,a));return o.jsxs("div",{className:K("grid grid-cols-[1fr_auto] gap-3 items-start"),children:[o.jsx(v0e,{fields:a,tokens:i,onTokensChange:l,disabled:s,autoFocusFieldId:c}),u&&o.jsx(m0e,{disabled:s,onClear:d?e:void 0,onRemoveAll:t,onSave:n,onRemoveSaved:r})]})}function QKr(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 YKr(){const{data:e,isLoading:t,isError:n}=Nvr(),{getTracesHref:r}=BN(),{Link:s}=vn();return o.jsx(xvr,{rows:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:()=>r({rootEntityType:Rs.AGENT}),actions:o.jsx(J3,{href:r({rootEntityType:Rs.AGENT}),LinkComponent:s})})}function XKr(){const{data:e,isLoading:t,isError:n}=Rvr(),{getTracesHref:r}=BN(),{Link:s}=vn();return o.jsx(Svr,{data:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:a=>r({rootEntityType:Rs.AGENT,entityName:a.name}),actions:o.jsx(J3,{href:r({rootEntityType:Rs.AGENT}),LinkComponent:s})})}function KKr(){const{data:e,isLoading:t,isError:n}=Dvr(),{getTracesHref:r}=BN(),{Link:s}=vn();return o.jsx(_vr,{data:e?.data,interval:e?.interval,isLoading:t,isError:n,actions:o.jsx(J3,{href:r(),LinkComponent:s})})}const g8={agents:Rs.AGENT,workflows:Rs.WORKFLOW_RUN,tools:Rs.TOOL};function JKr(){const{data:e,isLoading:t,isError:n}=Avr(),{getTracesHref:r,getLogsHref:s}=BN(),{Link:a}=vn();return o.jsx(Cvr,{data:e,isLoading:t,isError:n,LinkComponent:a,getRowHref:(i,l)=>r({rootEntityType:g8[i],entityName:l.name}),getErrorSegmentHref:(i,l)=>l.errors>0?s({rootEntityType:g8[i],entityName:l.name,status:"error"}):void 0,actions:i=>o.jsxs(o.Fragment,{children:[o.jsx(J3,{href:r({rootEntityType:g8[i]}),LinkComponent:a}),o.jsx(mvr,{href:s({rootEntityType:g8[i],status:"error"}),LinkComponent:a})]})})}const eJr=new Set(["ObservabilityStorageClickhouseVNext","ObservabilityStorageDuckDB","ObservabilityInMemory","ObservabilitySpanner"]),ere="period",v8="dateFrom",y8="dateTo";function tJr(){const[e,t]=Ei(),n=e.get(ere),r=lvr(n)?n:"24h",s=y.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(v8)),p=d(e.get(y8));if(!(!f&&!p))return{from:f,to:p}},[r,e.toString()]),a=y.useMemo(()=>tvr(e),[e.toString()]),i=y.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d==="24h"?p.delete(ere):p.set(ere,d),d!=="custom"&&(p.delete(v8),p.delete(y8)),p},{replace:!0})},[t]),l=y.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d?.from?p.set(v8,d.from.toISOString()):p.delete(v8),d?.to?p.set(y8,d.to.toISOString()):p.delete(y8),p},{replace:!0})},[t]),c=y.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return rvr(p,d),p},{replace:!0})},[t]),u=y.useRef(!1);return y.useEffect(()=>{if(u.current||(u.current=!0,Jgr(e)))return;const d=JCt();d&&t(f=>{const p=new URLSearchParams(f);for(const[h,m]of d)p.append(h,m);return p},{replace:!0})},[]),o.jsx(uvr,{preset:r,filterTokens:a,onPresetChange:i,onFilterTokensChange:c,customRange:s,onCustomRangeChange:l,children:o.jsx(nJr,{})})}function nJr(){const[e]=Ei(),{error:t,isLoading:n}=nEt(),{filterTokens:r,setFilterTokens:s}=XV(),[a,i]=y.useState(),{data:l,isLoading:c}=i4(),u=l?.observabilityStorageType,d=u?eJr.has(u):!1,f=u==="ObservabilityInMemory",{data:p,isLoading:h}=QSe(),{data:m,isLoading:g}=YSe(),{data:v,isLoading:b}=KSe(),{data:w,isLoading:S}=XSe(),O=y.useMemo(()=>evr({availableTags:p??[],availableEntityNames:m??[],availableServiceNames:v??[],availableEnvironments:w??[],loading:{tags:h,entityNames:g,serviceNames:b,environments:S}}),[p,m,v,w,h,g,b,S]),[_,C]=y.useState(()=>JCt()!==null),j=y.useCallback(()=>{Xgr(e),C(!0),Be.success("Filters setting for Metrics saved")},[e]),E=y.useCallback(()=>{Kgr(),C(!1),Be.success("Filters setting for Metrics cleared up")},[]),N=y.useCallback(()=>{s([])},[s]),I=y.useCallback(()=>{const P=r.map($=>{const z=O.find(D=>D.id===$.fieldId);return z?z.kind==="text"?{fieldId:$.fieldId,value:""}:z.kind==="pick-multi"?z.multi?{fieldId:$.fieldId,value:[]}:{fieldId:$.fieldId,value:"Any"}:z.kind==="multi-select"?{fieldId:$.fieldId,value:[]}:$:$});s(P)},[O,r,s]);return t&&ms(t)?o.jsx(or,{children:o.jsx(Vs,{})}):t&&vs(t)?o.jsx(or,{children:o.jsx($s,{resource:"metrics"})}):t?o.jsx(or,{children:o.jsx(Li,{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(hvr,{}),o.jsx(y0e,{fields:O,tokens:r,onTokensChange:s,disabled:n,onStartTextFilter:i})]})}),o.jsx(GKr,{isLoading:n,filterFields:O,filterTokens:r,onFilterTokensChange:s,onClear:I,onRemoveAll:N,onSave:j,onRemoveSaved:_?E:void 0,autoFocusFilterFieldId:a})]}),c?null:d?o.jsxs("div",{className:"grid gap-8 content-start pb-10",children:[f&&o.jsx(Rn,{variant:"info",title:"Metrics are not persisted",children:o.jsx(Rn.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, or Spanner."})}),o.jsxs(_fe,{children:[o.jsx(qKr,{}),o.jsx(VKr,{}),o.jsx(HKr,{}),o.jsx(WKr,{}),o.jsx(ZKr,{})]}),o.jsxs(_fe,{children:[o.jsx(YKr,{}),o.jsx(XKr,{}),o.jsx(KKr,{}),o.jsx(UKr,{}),o.jsx(JKr,{}),o.jsx(BKr,{})]})]}):o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Wr,{iconSlot:o.jsx(mf,{}),titleSlot:"Metrics are not available with your current storage",descriptionSlot:"Metrics require ClickHouse, DuckDB, Spanner, or in-memory storage for observability. Relational databases (PostgreSQL, LibSQL) do not support metrics collection. To enable metrics on an existing project, switch the observability storage in the Mastra configuration.",actionSlot:o.jsxs(fe,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/observability/metrics/overview",target:"_blank",rel:"noopener noreferrer",children:["Metrics Documentation ",o.jsx(Ta,{})]})})})]})}function rJr(){const{paths:e}=vn(),{data:t,isLoading:n,error:r}=B5t(),{isCmsAvailable:s}=c4(),[a,i]=y.useState(""),l=t?.promptBlocks??[];return r&&ms(r)?o.jsx(or,{children:o.jsx(Vs,{})}):r&&vs(r)?o.jsx(or,{children:o.jsx($s,{resource:"prompt blocks"})}):r?o.jsx(or,{children:o.jsx(Li,{title:"Failed to load prompt blocks",message:r.message})}):l.length===0&&!n?o.jsx(or,{children:o.jsx(SWr,{})}):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(kf,{onSearch:i,label:"Filter prompts",placeholder:"Filter by name or description"})}),s&&o.jsxs(fe,{as:ui,to:e.cmsPromptBlockCreateLink(),variant:"primary",className:"shrink-0",children:[o.jsx(Lr,{}),"Create Prompt"]})]})}),o.jsx(wWr,{promptBlocks:l,isLoading:n,search:a})]})}function sJr(){return o.jsx(Lt,{width:"narrow",children:o.jsx(Lt.MainArea,{children:o.jsx(fVr,{children:o.jsx(hge,{})})})})}const aJr=[{title:"Mastra APIs",description:"Explore and test the available REST API endpoints with the interactive Swagger UI.",icon:Pin,href:"/swagger-ui",external:!1},{title:"Documentation",description:"Read the official Mastra documentation for guides, references, and tutorials.",icon:eit,href:"https://mastra.ai/en/docs",external:!0},{title:"Github",description:"Browse the source code, report issues, and contribute to the Mastra project.",icon:Ta,href:"https://github.com/mastra-ai/mastra",external:!0},{title:"Community",description:"Join the Mastra Discord community for help, discussion, and collaboration.",icon:Nj,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:lit,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:tit,href:"https://mastra.ai/contact?ref=studio",external:!0}];function iJr(){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:aJr.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(Ta,{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 oJr(){const{data:e={},isLoading:t,error:n}=Zp(),[r,s]=y.useState(""),[a,i]=y.useState("all");if(n&&ms(n))return o.jsx(or,{children:o.jsx(Vs,{})});if(n&&vs(n))return o.jsx(or,{children:o.jsx($s,{resource:"scorers"})});if(n)return o.jsx(or,{children:o.jsx(Li,{title:"Failed to load scorers",message:n.message})});if(Object.keys(e).length===0&&!t)return o.jsx(or,{children:o.jsx(NHr,{})});const l=a!=="all"||r!=="",c=()=>{s(""),i("all")};return o.jsxs(Lt,{children:[o.jsx(Lt.TopArea,{children:o.jsx(AHr,{search:r,onSearchChange:s,sourceFilter:a,onSourceFilterChange:i,onReset:c,hasActiveFilters:l})}),o.jsx(THr,{scorers:e,isLoading:t,search:r,sourceFilter:a})]})}function lJr(){const{scorerId:e}=wr(),[t,n]=Ei(),r=t.get("scoreId")??void 0,[s,a]=y.useState(r),[i,l]=y.useState({value:"all",label:"All Entities",type:"ALL"}),{scorer:c,error:u}=CHr(e),{data:d={},isLoading:f,error:p}=cm(),{isLoading:h,error:m}=Cy(),{data:g=[],isLoading:v,error:b,isFetchingNextPage:w,hasNextPage:S,setEndOfListElement:O}=_Hr({scorerId:e,entityId:i?.value==="all"?void 0:i?.value,entityType:i?.type==="ALL"?void 0:i?.type}),_=y.useMemo(()=>c?.agentIds?.filter(B=>d[B]).map(B=>({value:B,label:d[B].name,type:"AGENT"}))||[],[c?.agentIds,d]),C=y.useMemo(()=>c?.workflowIds?.map(B=>({value:B,label:B,type:"WORKFLOW"}))||[],[c?.workflowIds]),j=y.useMemo(()=>[{value:"all",label:"All Entities",type:"ALL"},..._,...C],[_,C]),E=t.get("entity")??"all",N=j.find(B=>B.value===E);N&&N.value!==i?.value&&l(N),y.useEffect(()=>{if(u){const B=u instanceof Error?u.message:"Failed to load scorer";Be.error(`Error loading scorer: ${B}`)}},[u]),y.useEffect(()=>{if(p){const B=p instanceof Error?p.message:"Failed to load agents";Be.error(`Error loading agents: ${B}`)}},[p]),y.useEffect(()=>{if(m){const B=m instanceof Error?m.message:"Failed to load workflows";Be.error(`Error loading workflows: ${B}`)}},[m]);const I=B=>{B?.value&&n(M=>{const Q=new URLSearchParams(M);return Q.set("entity",B.value),Q})};y.useEffect(()=>{const B=t.get("scoreId")??void 0;if(B===s)return;if(!B){a(void 0);return}g.find(Q=>Q.id===B)&&a(B)},[t,g]);const P=y.useCallback(B=>{a(B||void 0),n(M=>{const Q=new URLSearchParams(M);return B?Q.set("scoreId",B):Q.delete("scoreId"),Q})},[n]);if(!c)return null;const $=ms(u)||ms(p)||ms(m),z=u&&vs(u),D=!$&&!z&&(u||p||m),q=!v&&g.length===0,W=i?.value!=="all",L=c?.scorer?.source==="stored"?o.jsx(Sy,{owner:"scorer-detail",children:o.jsxs(fe,{variant:"default",as:ui,to:`/cms/scorers/${e}/edit`,size:"sm",children:[o.jsx(Bh,{})," Edit"]})}):null;if($||z||D||q&&!W){const B=(u instanceof Error?u.message:void 0)??(p instanceof Error?p.message:void 0)??(m instanceof Error?m.message:void 0)??"An unexpected error occurred";return o.jsxs(Lt,{width:"wide",height:"full",children:[L,o.jsx(Lt.MainArea,{isCentered:!0,children:$?o.jsx(Vs,{}):z?o.jsx($s,{resource:"scorers"}):D?o.jsx(Li,{title:"Failed to load scorer",message:B}):o.jsx(xHr,{})})]})}return o.jsxs(Lt,{width:"wide",children:[L,o.jsx(Lt.TopArea,{children:o.jsx(wHr,{selectedEntity:i,entityOptions:j,onEntityChange:I,onReset:()=>{n(B=>{const M=new URLSearchParams(B);return M.set("entity","all"),M})},isLoading:v||f||h})}),o.jsx(bHr,{scores:g,isLoading:v,selectedScoreId:s,isFetchingNextPage:w,hasNextPage:S,setEndOfListElement:O,onScoreClick:P,errorMsg:b?.message})]})}function cJr({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(Mt,{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 RLt=[{value:"dark",label:"Dark",Icon:aln},{value:"light",label:"Light",Icon:hcn},{value:"system",label:"System",Icon:yit}],uJr=e=>RLt.some(t=>t.value===e);function dJr({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 fJr=()=>{const{baseUrl:e,headers:t,apiPrefix:n}=nke(),{theme:r,setTheme:s}=hN();return o.jsx(Lt,{width:"narrow",children:o.jsxs(Lt.MainArea,{className:"flex flex-col gap-5 mt-6",children:[o.jsx(Lfe,{title:"Theme",description:"Customize the appearance of the studio.",children:o.jsx(cJr,{label:"Theme mode",htmlFor:"theme",children:o.jsxs($a,{value:r,onValueChange:a=>{uJr(a)&&s(a)},children:[o.jsx(Da,{id:"theme",className:"w-full sm:w-48",children:o.jsx(Ma,{className:"inline-flex min-w-0 max-w-full items-center"})}),o.jsx(La,{children:RLt.map(a=>o.jsx(Yr,{value:a.value,children:o.jsx(dJr,{option:a})},a.value))})]})})}),o.jsx(Lfe,{title:"Mastra Connection",description:"Configure the Mastra instance URL, API prefix, and request headers used by the studio.",children:o.jsx(E5t,{initialConfig:{baseUrl:e,headers:t,apiPrefix:n}})})]})})};function pJr(){const[e]=Ei(),t=qs(),n=e.get("redirect")||"/",r=()=>{n.startsWith("http")?window.location.href=n:t(n,{replace:!0})};return o.jsx(ALt,{redirectUri:n,onSuccess:r,initialMode:"signup"})}function hJr(e){return e.replace(/\/$/,"").split("/").pop()}function qW({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 mJr({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(Ko,{})," ",a.agents.length]}),a?.tools&&a.tools.length>0&&o.jsxs("li",{children:[o.jsx(ff,{})," ",a.tools.length]}),a?.networks&&a.networks.length>0&&o.jsxs("li",{children:[o.jsx(bit,{})," ",a.networks.length]}),a?.workflows&&a.workflows.length>0&&o.jsxs("li",{children:[o.jsx(uU,{})," ",a.workflows.length]}),a?.mcp&&a.mcp.length>0&&o.jsxs("li",{children:[o.jsx(t1,{})," ",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(ACt,{})," ",hJr(a.githubUrl)]})})]},a.slug)})})}function gJr({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(Gj,{name:"search-templates",label:"Search templates",labelIsHidden:!0,value:i,onChange:f=>l?.(f.target.value),placeholder:"Search Template"}),o.jsx(uc,{label:"Filter by tag",labelIsHidden:!0,name:"filter-tag",value:t,onValueChange:s,options:e}),o.jsx(uc,{label:"Filter by provider",labelIsHidden:!0,name:"filter-provider",value:r,onValueChange:a,options:n}),c&&o.jsxs(fe,{onClick:c,children:["Reset ",o.jsx(gs,{})]})]})}function vJr(){const{data:e,isLoading:t}=ESr(),{templates:n,tags:r,providers:s}=e??{templates:[],tags:[],providers:[]},[a,i]=y.useState("all"),[l,c]=y.useState("all"),[u,d]=y.useState(""),f=[{value:"all",label:"Any tag"}];(r||[]).forEach(w=>{f.push({value:w,label:w})});const p=[{value:"all",label:"Any provider"}];(s||[]).forEach(w=>{p.push({value:w,label:w})});const h=(w,S)=>{S==="tag"?i(w):S==="provider"&&c(w)},m=w=>{d(w)},g=()=>{i("all"),c("all"),d("")},v=n.filter(w=>!(u&&!w.title.toLowerCase().includes(u)&&!w.description.toLowerCase().includes(u)||a!=="all"&&!w.tags.includes(a)||l!=="all"&&!w.supportedProviders.includes(l))),b=u||a!=="all"||l!=="all";return o.jsxs(ls,{children:[o.jsx(bxe,{children:o.jsxs(Vht,{children:[o.jsx(Ve,{children:o.jsx(Nv,{})}),"Templates"]})}),o.jsxs("div",{className:K("overflow-y-auto w-full h-full px-8 pb-12 z-10"),children:[o.jsx(gJr,{selectedTag:a,onTagChange:w=>h(w,"tag"),tagOptions:f,selectedProvider:l,onProviderChange:w=>h(w,"provider"),providerOptions:p,searchTerm:u,onSearchChange:m,onReset:b?g:void 0,className:"max-w-[80rem]",isLoading:t}),o.jsx(mJr,{templates:v,linkComponent:ui,className:"max-w-[80rem] mx-auto",isLoading:t})]})]})}const yJr="1.45.0";function bJr({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(xp,{className:"text-yellow-500"}),title:"Template Installed with Warnings"}:{icon:o.jsx(aon,{}),title:"Template Installation Failed"},{icon:l,title:c}=i();return o.jsxs(qW,{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 xJr({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(qW,{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(xit,{})]}),o.jsx(uc,{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(Qt,{})," Loading variables..."]}):Object.entries(r).map(([p,h])=>o.jsxs(y.Fragment,{children:[o.jsx(hO,{name:`env-${p}`,labelIsHidden:!0,label:"Key",value:p,disabled:!0,className:"w-full"}),o.jsx(hO,{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(C5t,{defaultProvider:u||"",defaultModel:d||"",updateModel:f||(()=>Promise.resolve({message:"Updated"})),closeEditor:()=>{},autoSave:!0,selectProviderPlaceholder:"Provider"})]})]}),t&&!l&&o.jsx(fe,{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(Qt,{className:"w-4 h-4"})," Installing..."]}):o.jsxs(o.Fragment,{children:["Install ",o.jsx(em,{})]})})]})})}function wJr({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(Nv,{}),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(xx,{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(Rve,{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(ACt,{}),n?.split("/")?.pop()]})]}),s&&o.jsx(U0e,{data:s,labelsAreHidden:!0,isLoading:r})]})]})}function SJr({name:e,streamResult:t,runId:n,workflowInfo:r}){const s=t?.phase||"initializing",a=t?.payload?.workflowState,i=t?.payload?.currentStep,l=t?.error,c=a?.steps||{},u=Object.keys(c).length>0,d=g=>g==="input"||g.endsWith(".input")||g.startsWith("Mapping_")&&/[0-9a-f]{8}/.test(g)||/[0-9a-f]{8,}/.test(g)?!1:r?.allSteps?g in r.allSteps:!0,f=Object.entries(c).filter(([g,v])=>d(g)),p=f.length,h=()=>{switch(s){case"initializing":return"Preparing template installation...";case"processing":return`Installing ${e} template`;case"completed":return"Template installation completed!";case"error":return"Template installation failed";default:return"Installing template..."}},m=f.map(([g,v])=>({id:g,status:v?.status,description:v?.description,title:g.charAt(0).toUpperCase()+g.slice(1).replace(/-/g," "),isActive:i?.id===g}));return o.jsxs(qW,{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(vUn,{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(mln,{}),l||"Something went wrong"]}),u&&o.jsx(gUn,{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(Qt,{}),o.jsx("p",{children:"This may take some time..."})]})]})}function kJr({name:e,installedEntities:t}){return o.jsxs(qW,{className:K("grid items-center justify-items-center gap-4 content-center","[&>svg]:w-8 [&>svg]:h-8"),children:[o.jsx(xit,{}),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(U0e,{data:t})]})}function OJr(){const{templateSlug:e}=wr(),[t,n]=Ei(),[r,s]=y.useState(""),[a,i]=y.useState(""),[l,c]=y.useState(""),[u,d]=y.useState({}),[f,p]=y.useState([]),[h,m]=y.useState(null),[g,v]=y.useState(!1),[b,w]=y.useState(""),[S,O]=y.useState(!1),[_,C]=y.useState(!1),[j,E]=y.useState([]),{data:N,isLoading:I}=jSr({repoOrSlug:e,owner:"mastra-ai"}),$=yJr?.includes("beta")??!1?"beta":"main",{data:z,isLoading:D}=TSr({repo:N?.githubUrl?new URL(N.githubUrl).pathname.split("/")[2]:`template-${e}`,owner:"mastra-ai",branch:$}),{data:q,isLoading:W}=NSr(),{mutateAsync:L,isPending:F}=ISr(),{mutateAsync:B}=ASr(),{streamInstall:M,streamResult:Q,isStreaming:V}=PSr(q),{observeInstall:R,streamResult:U,isStreaming:Z}=$Sr(q);y.useEffect(()=>{const ne=t.get("runId");ne&&!g&&!h&&!V&&!Z&&(console.info("🔄 Checking completed run after hot reload:",{runId:ne}),w(ne),B({runId:ne}).then(le=>{const pe=le.snapshot;if(pe?.status==="success"&&pe?.result?.success)v(!0);else if(pe?.result?.success===!1)if(pe?.result?.validationResults&&!pe?.result?.validationResults?.valid&&pe?.result?.validationResults?.remainingErrors>0){const{remainingErrors:he,errors:be}=pe.result.validationResults,Se=`Template installation completed but ${he} validation issue${he>1?"s":""} remain unresolved.`;m(Se),E(be||[])}else{const he=pe?.result?.message||pe?.result?.error||"Template installation failed";m(typeof he=="string"?he:String(he))}}).catch(le=>{console.error("❌ Failed to fetch run details:",le),m("Failed to retrieve installation status after reload")}))},[t,g,h,V,Z,B]),y.useEffect(()=>{const ne=t.get("runId"),le=t.get("resume"),pe=t.get("provider");if(ne&&le==="true"&&pe&&!V&&!Z&&!S&&!_&&q){w(ne),O(!0);try{B({runId:ne}).then(se=>{if(se.snapshot?.status==="running")return R.mutateAsync({runId:ne})}).then(()=>{n(se=>{const he=new URLSearchParams(se);return he.delete("resume"),he})}).catch(se=>{console.error("❌ Failed to resume template installation:",se),se.message?.includes("404")||se.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(se){console.error("❌ Auto-resume failed with error:",se),m("Failed to resume template installation. Please refresh and try again.")}}},[t,e,V,Z,S,_,q,B,R,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(ff,{})},{key:"agents",label:"Agents",value:N?.agents?.length?N.agents.map(ne=>ne).join(", "):"n/a",icon:o.jsx(Ko,{})},{key:"workflows",label:"Workflows",value:N?.workflows?.length?N.workflows.map(ne=>ne).join(", "):"n/a",icon:o.jsx(uU,{})},{key:"providers",label:"Providers",value:N?.supportedProviders?.length?N.supportedProviders.join(", "):"n/a",icon:o.jsx(Eb,{})},{key:"tags",label:"Tags",value:N?.tags?.length?N.tags.join(", "):"n/a",icon:o.jsx(YT,{})}],ee=[{...te[0]},{...te[1]},{...te[2]}].filter(ne=>ne.value!=="n/a");y.useEffect(()=>{z&&d(z)},[z]),y.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 J=ne=>{s(ne)},ie=async ne=>(i(ne.provider),c(ne.modelId),{message:"Model updated successfully"}),ue=async()=>{const ne=Object.entries(u).reduce((le,[pe,se])=>(se===""&&le.push(pe),le),[]);if(ne.length>0){p(ne);return}if(N){m(null),v(!1),w(""),C(!0);try{const pe={repo:N.githubUrl||`https://github.com/mastra-ai/template-${N.slug}`,ref:$,slug:N.slug,variables:u},{runId:se}=await L({});w(se),n(he=>{const be=new URLSearchParams(he);return be.set("runId",se),be.set("resume","true"),be.set("provider",r||"openai"),be}),await M.mutateAsync({inputData:pe,selectedModel:{provider:a,modelId:l},runId:se})}catch(le){C(!1),m(le?.message||"Template installation failed"),console.error("Template installation failed",le)}}},Y=ne=>{const{name:le,value:pe}=ne.target;pe.trim()===""?p(se=>[...se,le]):p(se=>se.filter(he=>he!==le)),d(se=>({...se,[le]: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(wJr,{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(SJr,{name:N.title,streamResult:Z?U:Q,runId:b,workflowInfo:q}),g&&o.jsx(kJr,{name:N.title,installedEntities:ee,linkComponent:ui}),h&&o.jsx(bJr,{errorMsg:h,validationErrors:j.length>0?j:Q?.validationResults?.errors||U?.validationResults?.errors}),!V&&!Z&&!g&&!h&&o.jsx(xJr,{providerOptions:X,selectedProvider:r,onProviderChange:J,variables:u,setVariables:d,errors:f,setErrors:p,handleInstallTemplate:ue,handleVariableChange:Y,isLoadingEnvVars:D||W,isInstalling:F,defaultModelProvider:a,defaultModelId:l,onModelUpdate:ie})]})]})})})}const _Jr=()=>{const{toolId:e,agentId:t}=wr();return o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(aWr,{toolId:e,agentId:t})})},CJr=()=>{const{toolId:e}=wr();return o.jsx("div",{className:"h-full w-full overflow-y-hidden",children:o.jsx(IKr,{toolId:e})})};function EJr(){const{traceId:e}=wr(),[t,n]=Ei(),r=qs(),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]=y.useState(s??null),[d,f]=y.useState(),[p,h]=y.useState(i),[m,g]=y.useState(0),[v,b]=y.useState(!1),{data:w,isLoading:S,error:O}=GSe(e),_=y.useMemo(()=>w?.spans??[],[w?.spans]),C=y.useMemo(()=>_.find(ie=>ie.parentSpanId==null),[_]),{data:j,isLoading:E}=rD(e,c??"");y.useEffect(()=>g(0),[e,c]);const{data:N,isLoading:I}=Zp(),{data:P,isLoading:$}=D5t({traceId:e,spanId:c??void 0,page:m}),[z,D]=y.useState(0);y.useEffect(()=>D(0),[e,c]);const{data:q,isLoading:W}=kLt({traceId:e,page:z});y.useEffect(()=>{if(l&&P?.scores&&!d){const ie=P.scores.find(ue=>ue.id===l);ie&&f(ie)}},[l,P?.scores,d]);const L=y.useCallback(ie=>{const ue=new URLSearchParams(t);for(const[Y,ne]of Object.entries(ie))ne===null||ne===""?ue.delete(Y):ue.set(Y,ne);n(ue,{replace:!0})},[t,n]),F=y.useCallback(ie=>{const ue=ie??null,Y=ue===c;u(ue),Y||(f(void 0),h("details"),L({spanId:ue,tab:null,scoreId:null}))},[c,L]),B=y.useCallback(()=>{u(null),f(void 0),h("details"),L({spanId:null,tab:null,scoreId:null})},[L]),M=y.useCallback(ie=>{u(ie),f(void 0),h("details"),L({spanId:ie,tab:null,scoreId:null})},[L]),{handlePreviousSpan:Q,handleNextSpan:V}=JSe(_,c,M),R=y.useCallback(ie=>{const ue=ie;h(ue),f(void 0),L({tab:ue==="details"?null:ue,scoreId:null})},[L]),U=y.useCallback(ie=>{f(ie),L({scoreId:ie.id})},[L]),Z=y.useCallback(()=>{f(void 0),L({scoreId:null})},[L]),X=y.useCallback(()=>{r("/observability")},[r]),te=y.useCallback(()=>{h("scoring"),C&&c!==C.spanId?(u(C.spanId),f(void 0),L({spanId:C.spanId,tab:"scoring",scoreId:null})):L({tab:"scoring"})},[C,c,L]),ee=C?o.jsx(Sy,{owner:"trace-detail",children:o.jsxs($r,{children:[o.jsxs(fe,{tooltip:"Evaluate Trace","aria-label":"Evaluate Trace",onClick:te,children:[o.jsx(rin,{}),"Evaluate"]}),o.jsxs(fe,{tooltip:"Save as Dataset Item","aria-label":"Save as Dataset Item",onClick:()=>b(!0),children:[o.jsx(sd,{}),"Save"]})]})}):null,J=C?o.jsx(Lt.Row,{children:o.jsx(Lt.Column,{children:o.jsx(lEt,{rootSpan:C,numOfCol:3})})}):null;return O?o.jsxs(Lt,{height:"full",children:[ee,J&&o.jsx(Lt.TopArea,{children:J}),o.jsx(Lt.MainArea,{isCentered:!0,children:o.jsx(dEt,{error:O,resource:"traces",errorTitle:"Failed to load trace"})})]}):o.jsxs(Lt,{children:[ee,J&&o.jsx(Lt.TopArea,{children:J}),o.jsx(yLt,{rootSpanId:C?.spanId,traceId:e,isOpen:v,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(WSe,{traceId:e,spans:_,isLoading:S,onClose:X,onSpanSelect:F,onEvaluateTrace:te,initialSpanId:c,placement:"trace-page",timelineChartWidth:c?"default":"wide"}),c&&!S&&o.jsxs("div",{className:K("grid gap-4 max-h-full min-h-0 overflow-auto",d?"grid-rows-[1fr_1fr]":"grid-rows-[1fr]"),children:[o.jsx(ZSe,{traceId:e,spanId:c,span:j?.span,isLoading:E,onClose:B,onPrevious:Q,onNext:V,activeTab:p,onTabChange:R,feedbackTabBadge:q?.pagination?.total??void 0,feedbackTabSlot:()=>o.jsx(xLt,{feedbackData:q,onPageChange:D,isLoadingFeedbackData:W}),scoringTabBadge:P?.pagination?.total??void 0,scoringTabSlot:({span:ie,traceId:ue,spanId:Y})=>o.jsxs("div",{className:"grid gap-6",children:[o.jsx(SLt,{traceId:ue,isTopLevelSpan:!ie.parentSpanId,spanId:Y,entityType:ie.attributes?.agentId||ie.entityType===Rs.AGENT?"Agent":ie.attributes?.workflowId||ie.entityType===Rs.WORKFLOW_RUN?"Workflow":void 0,scorers:N,isLoadingScorers:I}),o.jsx(wLt,{scoresData:P,onPageChange:g,isLoadingScoresData:$,onScoreSelect:U})]})}),d&&o.jsx(EEe,{score:d,onClose:Z})]})]})]})}function jJr(){const{data:e,isLoading:t,error:n}=Cy(),[r,s]=y.useState("");return n&&ms(n)?o.jsx(or,{children:o.jsx(Vs,{})}):n&&vs(n)?o.jsx(or,{children:o.jsx($s,{resource:"workflows"})}):n?o.jsx(or,{children:o.jsx(Li,{title:"Failed to load workflows",message:n.message})}):Object.keys(e||{}).length===0&&!t?o.jsx(or,{children:o.jsx(U5r,{})}):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(kf,{onSearch:s,label:"Filter workflows",placeholder:"Filter by name or description"})}),o.jsxs(fe,{as:ui,to:"/workflows/schedules",variant:"primary",className:"shrink-0",children:[o.jsx(TM,{}),"Schedules"]})]})}),o.jsx(B5r,{workflows:e||{},isLoading:t,search:r})]})}const TJr={active:"bg-accent1",paused:"bg-accent3"},NJr={active:"text-accent1",paused:"text-accent3"},PLt=({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 ${TJr[e]}`,"aria-hidden":!0}),o.jsx("span",{className:`text-ui-sm ${NJr[e]}`,children:e})]}),xj=e=>!e||e<=0?"—":new Date(e).toLocaleString(),j2=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 $Lt({status:e}){const{icon:t,color:n}=IJr(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 IJr(e){switch(e){case"success":return{icon:o.jsx(oa,{size:14}),color:"text-accent1"};case"failed":return{icon:o.jsx(gs,{size:14}),color:"text-accent2"};case"running":return{icon:o.jsx(Qt,{}),color:"text-neutral3"};case"suspended":return{icon:o.jsx(sU,{size:14}),color:"text-accent3"};case"canceled":return{icon:o.jsx(mf,{size:14}),color:"text-neutral3"};case"pending":case"waiting":return{icon:o.jsx(Gk,{size:14}),color:"text-neutral3"};default:return{icon:null,color:"text-neutral3"}}}const BZe="auto auto auto auto 1fr";function AJr(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 RJr(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 PJr=3e4,$Jr=5*6e4;function MJr({triggers:e,isLoading:t,workflowId:n,hasNextPage:r,isFetchingNextPage:s,setEndOfListElement:a}){const{Link:i,paths:l}=vn();return t?o.jsx(Go,{columns:BZe}):e.length===0?o.jsx(ge,{variant:"ui-md",className:"text-neutral4 p-4",children:"No trigger history yet."}):o.jsxs(xe,{columns:BZe,className:"min-w-0",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Run"}),o.jsx(xe.TopCell,{children:"Status"}),o.jsx(xe.TopCell,{children:"Started"}),o.jsx(xe.TopCell,{children:"Duration"}),o.jsx(xe.TopCell,{children:" "})]}),e.map(c=>{const u=c.actualFireAt-c.scheduledFireAt,d=RJr(u),f=`Scheduled ${xj(c.scheduledFireAt)} — published ${xj(c.actualFireAt)} (drift ${d})`,p=c.outcome==="failed",h=p?c.error:c.run?.error,m=Math.abs(u),g=!p&&m>PJr&&m<=$Jr,v=`${c.scheduleId}-${c.runId}-${c.actualFireAt}`,b=!!(n&&c.runId&&!p),w=o.jsx("span",{className:b?"text-accent1 font-mono text-ui-sm whitespace-nowrap":"text-neutral3 font-mono text-ui-sm whitespace-nowrap",children:c.runId}),S=o.jsxs(o.Fragment,{children:[o.jsx(xe.Cell,{height:"compact",children:w}),o.jsx(xe.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(xp,{size:14}),"publish failed"]}):c.run?o.jsx($Lt,{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(Hn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx("span",{className:"text-accent2 inline-flex",children:o.jsx(xp,{size:14})})}),o.jsx(Bn,{children:h})]}):null]})}),o.jsx(xe.Cell,{height:"compact",children:o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx("span",{title:f,children:j2(c.actualFireAt)}),g?o.jsxs(Hn,{children:[o.jsx(zn,{asChild:!0,children:o.jsx("span",{className:"text-accent3 inline-flex",children:o.jsx(xp,{size:14})})}),o.jsxs(Bn,{children:["Published ",d," after the scheduled fire time"]})]}):null]})}),o.jsx(xe.Cell,{height:"compact",children:c.run?o.jsx("span",{children:AJr(c.run.durationMs)}):o.jsx("span",{className:"text-neutral4",children:"—"})}),o.jsx(xe.Cell,{height:"compact",children:" "})]});return b?o.jsx(xe.RowLink,{to:l.workflowRunLink(n,c.runId),LinkComponent:i,children:S},v):o.jsx(xe.RowStatic,{children:S},v)}),o.jsx(xe.NextPageLoading,{isLoading:s,hasMore:r,setEndOfListElement:a})]})}const DJr=e=>{const t=We();return xt({queryKey:["schedule",e],enabled:!!e,queryFn:async()=>{if(!e)throw new Error("scheduleId is required");return t.getSchedule(e)}})},UZe=25,LJr=e=>{const t=We(),{inView:n,setRef:r}=C_(),s=N1({queryKey:["schedule-triggers",e],enabled:!!e,initialPageParam:void 0,queryFn:async({pageParam:u})=>e?t.listScheduleTriggers(e,{limit:UZe,toActualFireAt:u}):{triggers:[]},getNextPageParam:u=>{if(!(!u?.triggers?.length||u.triggers.length<UZe))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 y.useEffect(()=>{n&&i&&!l&&c()},[n,i,l,c]),{...s,data:a,setEndOfListElement:r}},FJr=e=>{const t=We(),n=Ur();return An({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"]}),Be.success(s==="pause"?"Schedule paused":"Schedule resumed")},onError:r=>{Be.error(r.message)}})};function b8({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 zJr(){const{scheduleId:e}=wr(),{paths:t}=vn(),{data:n,error:r}=DJr(e),{data:s,isLoading:a,error:i,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u}=LJr(e),d=FJr(e);if(r&&ms(r))return o.jsx(or,{children:o.jsx(Vs,{})});if(r&&vs(r))return o.jsx(or,{children:o.jsx($s,{resource:"schedules"})});if(r)return o.jsx(or,{children:o.jsx(Li,{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(fe,{as:ui,to:t.schedulesLink(),variant:"ghost",children:[o.jsx(xc,{}),"Back to schedules"]}),f?o.jsx(fe,{as:ui,to:t.workflowLink(f),variant:"ghost",children:"Open workflow"}):null,n?o.jsx(fe,{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(wit,{}),"Pause"]}):o.jsxs(o.Fragment,{children:[o.jsx(Uh,{}),"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(b8,{label:"Workflow",children:f?o.jsx(ui,{to:t.workflowLink(f),className:"text-accent1 hover:underline",children:f}):"—"}),o.jsxs(b8,{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(b8,{label:"Status",children:o.jsx(PLt,{status:n.status})}),o.jsx(b8,{label:"Next fire",children:o.jsx("span",{title:xj(n.nextFireAt),children:j2(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(Li,{title:"Failed to load trigger history",message:i.message}):o.jsx(MJr,{triggers:s??[],isLoading:a,workflowId:f,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u})]})]}):null]})}const qZe="minmax(0, 1.2fr) minmax(0, 1.4fr) minmax(0, 1fr) auto auto auto";function BJr({schedules:e,isLoading:t,search:n=""}){const{paths:r,Link:s}=vn(),a=y.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(Go,{columns:qZe}):o.jsxs(xe,{columns:qZe,variant:"striped",className:"min-w-0",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Workflow"}),o.jsx(xe.TopCell,{children:"Schedule ID"}),o.jsx(xe.TopCell,{children:"Cron"}),o.jsx(xe.TopCell,{children:"Status"}),o.jsx(xe.TopCell,{children:"Next fire"}),o.jsx(xe.TopCell,{children:"Last run"})]}),a.length===0&&n?o.jsx(xe.NoMatch,{message:"No schedules match your search"}):null,a.length===0&&!n?o.jsx(xe.NoMatch,{message:"No schedules configured"}):null,a.map(i=>o.jsxs(xe.RowLink,{to:r.scheduleLink(i.id),LinkComponent:s,children:[o.jsx(xe.NameCell,{children:i.target.workflowId}),o.jsx(xe.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(xe.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(xe.Cell,{height:"compact",children:o.jsx(PLt,{status:i.status})}),o.jsx(xe.Cell,{height:"compact",children:o.jsx("span",{className:"whitespace-nowrap",title:xj(i.nextFireAt),children:j2(i.nextFireAt)})}),o.jsx(xe.Cell,{height:"compact",children:i.lastRun?o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx($Lt,{status:i.lastRun.status}),o.jsx("span",{className:"text-neutral4 text-ui-sm",title:xj(i.lastFireAt),children:i.lastFireAt?j2(i.lastFireAt):""})]}):i.lastFireAt?o.jsx("span",{className:"whitespace-nowrap",title:xj(i.lastFireAt),children:j2(i.lastFireAt)}):o.jsx("span",{className:"text-neutral4",children:"Never"})})]},i.id))]})}function UJr({workflowId:e}={}){const{data:t,isLoading:n,error:r}=rke(e?{workflowId:e}:{}),[s,a]=y.useState("");return r?o.jsx(Li,{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(kf,{onSearch:a,label:"Filter schedules",placeholder:"Filter by id or workflow"})}),o.jsx("div",{className:"overflow-y-auto",children:o.jsx(BJr,{schedules:t??[],isLoading:n,search:s})})]})}function qJr(){const[e]=Ei(),t=e.get("workflowId")??void 0,{error:n}=rke(t?{workflowId:t}:{});return n&&ms(n)?o.jsx(or,{children:o.jsx(Vs,{})}):n&&vs(n)?o.jsx(or,{children:o.jsx($s,{resource:"schedules"})}):o.jsx(Lt,{children:o.jsx("div",{className:"h-full",children:o.jsx(UJr,{workflowId:t})})})}function VJr(e){const t=new Blob([JSON.stringify(e??null)]).size;return t<1024?`${t} B`:`${(t/1024).toFixed(1)} KB`}function HJr(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 WJr({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(Ve,{children:o.jsx(sU,{})}),"Step suspended"]}),o.jsx(gn,{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?Yh(Gh(px(i.resumeSchema))):Jf(cr(),xT());return o.jsx(ZJr,{step:s,stepSchema:l,description:i.description,isStreaming:n,onResume:r},`${s.runId}-${s.stepId}-${a}`)})]})}function ZJr({step:e,stepSchema:t,description:n,isStreaming:r,onResume:s}){const[a,i]=y.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(Ve,{children:o.jsx(oln,{})}),"The step is asking"]}),o.jsxs(Ip,{open:a,onOpenChange:i,children:[o.jsxs(cf,{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(Ve,{children:o.jsx(Fs,{className:K("transition-transform text-neutral3",{"transform rotate-90":a})})}),o.jsx(ge,{as:"span",variant:"ui-md",className:"text-neutral6 truncate",children:HJr(e.suspendPayload,e.stepId)})]}),o.jsx(ge,{as:"span",variant:"ui-sm",className:"text-neutral3 shrink-0",children:VJr(e.suspendPayload)})]}),o.jsx(uf,{children:o.jsx("div",{"data-testid":"suspended-payload",className:"pt-2",children:o.jsx(as,{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(Ve,{children:o.jsx(uln,{})}),"Your response"]}),o.jsx("div",{className:"-mx-5",children:o.jsx(V7,{schema:t,isSubmitLoading:r,submitButtonLabel:"Resume",submitButtonIcon:o.jsx(Uh,{}),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 GJr(){const{result:e,runSnapshot:t,workflow:n,runId:r,isStreamingWorkflow:s}=y.useContext(bd),{runId:a}=wr(),i=Cjt(e,r??""),l=V1r(),c=!!a,u=t?.status==="suspended";return s||!n||i.length===0||c&&!u?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(WJr,{suspendedSteps:i,workflow:n,isStreaming:s,onResume:l})},r)}const QJr=e=>e.includes("."),YJr=e=>e==="input"||e.endsWith(".input"),XJr=1;function KJr(e){return`${Number((e/1e3).toPrecision(3))}s`}function JJr(e,t){const n=Object.entries(e).filter(([i])=>!YJr(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,XJr);return{stepId:i,step:l,status:l.status,offsetPct:f,widthPct:p,durationMs:d,isRunning:c,isNestedEntry:QJr(i)}})}const ees=({status:e})=>o.jsxs(Ve,{children:[e==="success"&&o.jsx(Ymr,{className:"text-accent1"}),e==="failed"&&o.jsx(Xmr,{className:"text-accent2"}),e==="suspended"&&o.jsx(sU,{className:"text-accent3"}),e==="waiting"&&o.jsx(git,{className:"text-accent5"}),e==="running"&&o.jsx(ba,{className:"text-accent6 animate-spin"})]}),tes={success:"bg-accent1",failed:"bg-accent2",suspended:"bg-accent3",waiting:"bg-accent5",running:"bg-accent6"};function MLt(e){return e.split(/[-_.\s]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}const VZe=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{value:e},nes=e=>{const t=e;return p2t({duration:t.duration,date:t.date,isForEach:t.isForEach,mapConfig:t.mapConfig,canSuspend:t.canSuspend,isParallel:t.isParallel,stepGraph:t.stepGraph})},res=({row:e,index:t,isSelected:n,isHovered:r,onSelectStep:s,onHoverStep:a,onOpenInput:i,onOpenOutput:l})=>{const c=nes(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(ees,{status:e.status})}),o.jsx("div",{className:"flex justify-center",children:o.jsx(fe,{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(ocn,{})})}),o.jsx("div",{className:"flex overflow-hidden",children:o.jsx(SB,{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:MLt(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 ${tes[e.status]}`,style:{left:`${e.offsetPct}%`,width:`${e.widthPct}%`}})}),o.jsx("div",{className:"flex justify-center",children:o.jsx(fe,{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(acn,{})})}),o.jsx(ge,{as:"span",variant:"ui-sm",className:"w-20 justify-self-end text-right text-neutral3 tabular-nums",children:KJr(e.durationMs)})]},`timeline-item-${e.stepId}-${t}`)};function ses(){const{steps:e}=CD(),{selectedStepId:t,hoverStepId:n,setSelectedStepId:r,setHoverStepId:s}=f2t(),[a,i]=y.useState(()=>Date.now()),[l,c]=y.useState(!1),[u,d]=y.useState(null),f=y.useRef(null);b0e(f,{enabled:!l});const p=JJr(e,a),h=p.some(m=>m.isRunning);return y.useEffect(()=>{if(!h)return;const m=setInterval(()=>i(Date.now()),100);return()=>clearInterval(m)},[h]),y.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(ea,{className:K("h-4 w-4 transition-transform",l&&"-rotate-90")})})]}),!l&&o.jsx("div",{ref:f,"data-testid":"workflow-timeline-list",className:"flex min-h-0 flex-col gap-2 overflow-y-auto",children:p.map((m,g)=>o.jsx(res,{row:m,index:g,isSelected:t===m.stepId,isHovered:n===m.stepId,onSelectStep:r,onHoverStep:s,onOpenInput:v=>d({type:"input",stepId:v.stepId,data:VZe(v.step.input)}),onOpenOutput:v=>d({type:"output",stepId:v.stepId,data:VZe(v.step.output)})},`timeline-item-${m.stepId}-${g}`))})]})}),o.jsx(yr,{open:!!u,onOpenChange:m=>!m&&d(null),children:u&&o.jsx(Ejt,{data:u.data,title:`${MLt(u.stepId)} ${u.type==="input"?"input":"output"}`})})]})}const HZe=()=>{const{workflowId:e}=wr(),{data:t,isLoading:n,error:r}=dD(e);return r&&ms(r)?o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vs,{})}):r&&vs(r)?o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx($s,{resource:"workflows"})}):o.jsx(d2t,{children:o.jsx(jke,{children:o.jsx("div",{className:"flex h-full min-h-0 flex-col",children:o.jsxs("div",{className:"relative min-h-0 flex-1 p-2 pb-0",children:[o.jsx(T2t,{workflowId:e,workflow:t??void 0,isLoading:n}),o.jsx(GJr,{}),o.jsx(ses,{})]})})})})};function aes(e,t){if(e==null)return{};var n,r,s=Ppt(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 Ege(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 ies(e){if(Array.isArray(e))return Ege(e)}function oes(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function les(e,t){if(e){if(typeof e=="string")return Ege(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)?Ege(e,t):void 0}}function ces(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
768
768
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function jge(e){return ies(e)||oes(e)||les(e)||ces()}function yM(e){"@babel/helpers - typeof";return yM=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yM(e)}function ues(e,t){if(yM(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(yM(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function des(e){var t=ues(e,"string");return yM(t)=="symbol"?t:t+""}function DLt(e,t,n){return(t=des(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function WZe(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 zE(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?WZe(Object(n),!0).forEach(function(r){DLt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):WZe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function fes(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 tre={};function pes(e){if(e.length===0||e.length===1)return e;var t=e.join(".");return tre[t]||(tre[t]=fes(e)),tre[t]}function hes(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=pes(r);return s.reduce(function(a,i){return zE(zE({},a),n[i])},t)}function ZZe(e){return e.join(" ")}function mes(e,t){var n=0;return function(r){return n+=1,r.map(function(s,a){return LLt({node:s,stylesheet:e,useInlineStyles:t,key:"code-segment-".concat(n,"-").concat(a)})})}}function LLt(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=mes(n,a),p;if(!a)p=zE(zE({},l),{},{className:ZZe(l.className)});else{var h=Object.keys(n).reduce(function(b,w){return w.split(".").forEach(function(S){b.includes(S)||b.push(S)}),b},[]),m=l.className&&l.className.includes("token")?["token"]:[],g=l.className&&m.concat(l.className.filter(function(b){return!h.includes(b)}));p=zE(zE({},l),{},{className:ZZe(g)||void 0,style:hes(l.className,Object.assign({},l.style,s),n)})}var v=f(t.children);return De.createElement(u,uO({key:i},p),v)}}const ges=(function(e,t){var n=e.listLanguages();return n.indexOf(t)!==-1});var ves=["language","children","style","customStyle","codeTagProps","useInlineStyles","showLineNumbers","showInlineLineNumbers","startingLineNumber","lineNumberContainerStyle","lineNumberStyle","wrapLines","wrapLongLines","lineProps","renderer","PreTag","CodeTag","code","astGenerator"];function GZe(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 dw(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?GZe(Object(n),!0).forEach(function(r){DLt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):GZe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var yes=/\n/g;function bes(e){return e.match(yes)}function xes(e){var t=e.lines,n=e.startingLineNumber,r=e.style;return t.map(function(s,a){var i=a+n;return De.createElement("span",{key:"line-".concat(a),className:"react-syntax-highlighter-line-number",style:typeof r=="function"?r(i):r},"".concat(i,`
|
|
769
769
|
`))})}function wes(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 De.createElement("code",{style:Object.assign({},n,s)},xes({lines:t.replace(/\n$/,"").split(`
|
|
770
770
|
`),style:i,startingLineNumber:l}))}function Ses(e){return"".concat(e.toString().length,".25em")}function FLt(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 zLt(e,t,n){var r={display:"inline-block",minWidth:Ses(n),paddingRight:"1em",textAlign:"right",userSelect:"none"},s=typeof e=="function"?e(t):e,a=dw(dw({},r),s);return a}function I9(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?dw({},typeof l=="function"?l(n):l):{};if(m.className=m.className?[].concat(jge(m.className.trim().split(/\s+/)),jge(u)):u,n&&a){var g=zLt(r,n,s);t.unshift(FLt(n,g))}return f&d&&(m.style=dw({display:"flex"},m.style)),{type:"element",tagName:"span",properties:m,children:t}}function BLt(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(I9({children:[s],className:jge(new Set(t))}));else if(s.children){var a=t.concat(s.properties.className);BLt(s.children,a).forEach(function(i){return n.push(i)})}}return n}function kes(e,t,n,r,s,a,i,l,c){var u,d=BLt(e.value),f=[],p=-1,h=0;function m(_,C){var j=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return I9({children:_,lineNumber:C,lineNumberStyle:l,largestLineNumber:i,showInlineLineNumbers:s,lineProps:n,className:j,showLineNumbers:r,wrapLongLines:c,wrapLines:t})}function g(_,C){if(r&&C&&s){var j=zLt(l,C,i);_.unshift(FLt(C,j))}return _}function v(_,C){var j=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return t||j.length>0?m(_,C,j):g(_,C)}for(var b=function(){var C=d[h],j=C.children[0].value,E=bes(j);if(E){var N=j.split(`
|