@mastra/deployer-cloud 1.42.0-alpha.4 → 1.42.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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./core-BzYMe5yj.js","./engine-compile-BkERmzkH.js","./preload-helper-PPVm8Dsz.js","./engine-javascript-CSIo_1eZ.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./core-Cp2Ep0UF.js","./engine-compile-BkERmzkH.js","./preload-helper-PPVm8Dsz.js","./engine-javascript-CSIo_1eZ.js"])))=>i.map(i=>d[i]);
2
2
  import{_ as ho}from"./preload-helper-PPVm8Dsz.js";function V6t(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 vj=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function hc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var TQ={exports:{}},MI={};var HNe;function H6t(){if(HNe)return MI;HNe=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 MI.Fragment=t,MI.jsx=n,MI.jsxs=n,MI}var ZNe;function Z6t(){return ZNe||(ZNe=1,TQ.exports=H6t()),TQ.exports}var o=Z6t(),NQ={exports:{}},Dr={},WNe;function W6t(){if(WNe)return Dr;WNe=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(q){return q===null||typeof q!="object"?null:(q=h&&q[h]||q["@@iterator"],typeof q=="function"?q:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,b={};function S(q,P,H){this.props=q,this.context=P,this.refs=b,this.updater=H||g}S.prototype.isReactComponent={},S.prototype.setState=function(q,P){if(typeof q!="object"&&typeof q!="function"&&q!=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,q,P,"setState")},S.prototype.forceUpdate=function(q){this.updater.enqueueForceUpdate(this,q,"forceUpdate")};function w(){}w.prototype=S.prototype;function O(q,P,H){this.props=q,this.context=P,this.refs=b,this.updater=H||g}var _=O.prototype=new w;_.constructor=O,v(_,S.prototype),_.isPureReactComponent=!0;var C=Array.isArray;function E(){}var T={H:null,A:null,T:null,S:null},N=Object.prototype.hasOwnProperty;function I(q,P,H){var W=H.ref;return{$$typeof:t,type:q,key:P,ref:W!==void 0?W:null,props:H}}function R(q,P){return I(q.type,P,q.props)}function $(q){return typeof q=="object"&&q!==null&&q.$$typeof===t}function B(q){var P={"=":"=0",":":"=2"};return"$"+q.replace(/[=:]/g,function(H){return P[H]})}var M=/\/+/g;function F(q,P){return typeof q=="object"&&q!==null&&q.key!=null?B(""+q.key):P.toString(36)}function V(q){switch(q.status){case"fulfilled":return q.value;case"rejected":throw q.reason;default:switch(typeof q.status=="string"?q.then(E,E):(q.status="pending",q.then(function(P){q.status==="pending"&&(q.status="fulfilled",q.value=P)},function(P){q.status==="pending"&&(q.status="rejected",q.reason=P)})),q.status){case"fulfilled":return q.value;case"rejected":throw q.reason}}throw q}function L(q,P,H,W,X){var ae=typeof q;(ae==="undefined"||ae==="boolean")&&(q=null);var ee=!1;if(q===null)ee=!0;else switch(ae){case"bigint":case"string":case"number":ee=!0;break;case"object":switch(q.$$typeof){case t:case n:ee=!0;break;case f:return ee=q._init,L(ee(q._payload),P,H,W,X)}}if(ee)return X=X(q),ee=W===""?"."+F(q,0):W,C(X)?(H="",ee!=null&&(H=ee.replace(M,"$&/")+"/"),L(X,P,H,"",function(ce){return ce})):X!=null&&($(X)&&(X=R(X,H+(X.key==null||q&&q.key===X.key?"":(""+X.key).replace(M,"$&/")+"/")+ee)),P.push(X)),1;ee=0;var J=W===""?".":W+":";if(C(q))for(var ie=0;ie<q.length;ie++)W=q[ie],ae=J+F(W,ie),ee+=L(W,P,H,ae,X);else if(ie=m(q),typeof ie=="function")for(q=ie.call(q),ie=0;!(W=q.next()).done;)W=W.value,ae=J+F(W,ie++),ee+=L(W,P,H,ae,X);else if(ae==="object"){if(typeof q.then=="function")return L(V(q),P,H,W,X);throw P=String(q),Error("Objects are not valid as a React child (found: "+(P==="[object Object]"?"object with keys {"+Object.keys(q).join(", ")+"}":P)+"). If you meant to render a collection of children, use an array instead.")}return ee}function z(q,P,H){if(q==null)return q;var W=[],X=0;return L(q,W,"","",function(ae){return P.call(H,ae,X++)}),W}function U(q){if(q._status===-1){var P=q._result;P=P(),P.then(function(H){(q._status===0||q._status===-1)&&(q._status=1,q._result=H)},function(H){(q._status===0||q._status===-1)&&(q._status=2,q._result=H)}),q._status===-1&&(q._status=0,q._result=P)}if(q._status===1)return q._result.default;throw q._result}var D=typeof reportError=="function"?reportError:function(q){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var P=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof q=="object"&&q!==null&&typeof q.message=="string"?String(q.message):String(q),error:q});if(!window.dispatchEvent(P))return}else if(typeof e=="object"&&typeof e.emit=="function"){e.emit("uncaughtException",q);return}console.error(q)},G={map:z,forEach:function(q,P,H){z(q,function(){P.apply(this,arguments)},H)},count:function(q){var P=0;return z(q,function(){P++}),P},toArray:function(q){return z(q,function(P){return P})||[]},only:function(q){if(!$(q))throw Error("React.Children.only expected to receive a single React element child.");return q}};return Dr.Activity=p,Dr.Children=G,Dr.Component=S,Dr.Fragment=r,Dr.Profiler=a,Dr.PureComponent=O,Dr.StrictMode=s,Dr.Suspense=u,Dr.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,Dr.__COMPILER_RUNTIME={__proto__:null,c:function(q){return T.H.useMemoCache(q)}},Dr.cache=function(q){return function(){return q.apply(null,arguments)}},Dr.cacheSignal=function(){return null},Dr.cloneElement=function(q,P,H){if(q==null)throw Error("The argument must be a React element, but you passed "+q+".");var W=v({},q.props),X=q.key;if(P!=null)for(ae in P.key!==void 0&&(X=""+P.key),P)!N.call(P,ae)||ae==="key"||ae==="__self"||ae==="__source"||ae==="ref"&&P.ref===void 0||(W[ae]=P[ae]);var ae=arguments.length-2;if(ae===1)W.children=H;else if(1<ae){for(var ee=Array(ae),J=0;J<ae;J++)ee[J]=arguments[J+2];W.children=ee}return I(q.type,X,W)},Dr.createContext=function(q){return q={$$typeof:l,_currentValue:q,_currentValue2:q,_threadCount:0,Provider:null,Consumer:null},q.Provider=q,q.Consumer={$$typeof:i,_context:q},q},Dr.createElement=function(q,P,H){var W,X={},ae=null;if(P!=null)for(W in P.key!==void 0&&(ae=""+P.key),P)N.call(P,W)&&W!=="key"&&W!=="__self"&&W!=="__source"&&(X[W]=P[W]);var ee=arguments.length-2;if(ee===1)X.children=H;else if(1<ee){for(var J=Array(ee),ie=0;ie<ee;ie++)J[ie]=arguments[ie+2];X.children=J}if(q&&q.defaultProps)for(W in ee=q.defaultProps,ee)X[W]===void 0&&(X[W]=ee[W]);return I(q,ae,X)},Dr.createRef=function(){return{current:null}},Dr.forwardRef=function(q){return{$$typeof:c,render:q}},Dr.isValidElement=$,Dr.lazy=function(q){return{$$typeof:f,_payload:{_status:-1,_result:q},_init:U}},Dr.memo=function(q,P){return{$$typeof:d,type:q,compare:P===void 0?null:P}},Dr.startTransition=function(q){var P=T.T,H={};T.T=H;try{var W=q(),X=T.S;X!==null&&X(H,W),typeof W=="object"&&W!==null&&typeof W.then=="function"&&W.then(E,D)}catch(ae){D(ae)}finally{P!==null&&H.types!==null&&(P.types=H.types),T.T=P}},Dr.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},Dr.use=function(q){return T.H.use(q)},Dr.useActionState=function(q,P,H){return T.H.useActionState(q,P,H)},Dr.useCallback=function(q,P){return T.H.useCallback(q,P)},Dr.useContext=function(q){return T.H.useContext(q)},Dr.useDebugValue=function(){},Dr.useDeferredValue=function(q,P){return T.H.useDeferredValue(q,P)},Dr.useEffect=function(q,P){return T.H.useEffect(q,P)},Dr.useEffectEvent=function(q){return T.H.useEffectEvent(q)},Dr.useId=function(){return T.H.useId()},Dr.useImperativeHandle=function(q,P,H){return T.H.useImperativeHandle(q,P,H)},Dr.useInsertionEffect=function(q,P){return T.H.useInsertionEffect(q,P)},Dr.useLayoutEffect=function(q,P){return T.H.useLayoutEffect(q,P)},Dr.useMemo=function(q,P){return T.H.useMemo(q,P)},Dr.useOptimistic=function(q,P){return T.H.useOptimistic(q,P)},Dr.useReducer=function(q,P,H){return T.H.useReducer(q,P,H)},Dr.useRef=function(q){return T.H.useRef(q)},Dr.useState=function(q){return T.H.useState(q)},Dr.useSyncExternalStore=function(q,P,H){return T.H.useSyncExternalStore(q,P,H)},Dr.useTransition=function(){return T.H.useTransition()},Dr.version="19.2.6",Dr}var QNe;function LT(){return QNe||(QNe=1,NQ.exports=W6t()),NQ.exports}var y=LT();const De=hc(y),FT=V6t({__proto__:null,default:De},[y]);var IQ={exports:{}},DI={},AQ={exports:{}},RQ={};var GNe;function Q6t(){return GNe||(GNe=1,(function(e){function t(V,L){var z=V.length;V.push(L);e:for(;0<z;){var U=z-1>>>1,D=V[U];if(0<s(D,L))V[U]=L,V[z]=D,z=U;else break e}}function n(V){return V.length===0?null:V[0]}function r(V){if(V.length===0)return null;var L=V[0],z=V.pop();if(z!==L){V[0]=z;e:for(var U=0,D=V.length,G=D>>>1;U<G;){var q=2*(U+1)-1,P=V[q],H=q+1,W=V[H];if(0>s(P,z))H<D&&0>s(W,P)?(V[U]=W,V[H]=z,U=H):(V[U]=P,V[q]=z,U=q);else if(H<D&&0>s(W,z))V[U]=W,V[H]=z,U=H;else break e}}return L}function s(V,L){var z=V.sortIndex-L.sortIndex;return z!==0?z:V.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,S=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;function O(V){for(var L=n(u);L!==null;){if(L.callback===null)r(u);else if(L.startTime<=V)r(u),L.sortIndex=L.expirationTime,t(c,L);else break;L=n(u)}}function _(V){if(g=!1,O(V),!m)if(n(c)!==null)m=!0,C||(C=!0,$());else{var L=n(u);L!==null&&F(_,L.startTime-V)}}var C=!1,E=-1,T=5,N=-1;function I(){return v?!0:!(e.unstable_now()-N<T)}function R(){if(v=!1,C){var V=e.unstable_now();N=V;var L=!0;try{e:{m=!1,g&&(g=!1,S(E),E=-1),h=!0;var z=p;try{t:{for(O(V),f=n(c);f!==null&&!(f.expirationTime>V&&I());){var U=f.callback;if(typeof U=="function"){f.callback=null,p=f.priorityLevel;var D=U(f.expirationTime<=V);if(V=e.unstable_now(),typeof D=="function"){f.callback=D,O(V),L=!0;break t}f===n(c)&&r(c),O(V)}else r(c);f=n(c)}if(f!==null)L=!0;else{var G=n(u);G!==null&&F(_,G.startTime-V),L=!1}}break e}finally{f=null,p=z,h=!1}L=void 0}}finally{L?$():C=!1}}}var $;if(typeof w=="function")$=function(){w(R)};else if(typeof MessageChannel<"u"){var B=new MessageChannel,M=B.port2;B.port1.onmessage=R,$=function(){M.postMessage(null)}}else $=function(){b(R,0)};function F(V,L){E=b(function(){V(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(V){V.callback=null},e.unstable_forceFrameRate=function(V){0>V||125<V?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):T=0<V?Math.floor(1e3/V):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_next=function(V){switch(p){case 1:case 2:case 3:var L=3;break;default:L=p}var z=p;p=L;try{return V()}finally{p=z}},e.unstable_requestPaint=function(){v=!0},e.unstable_runWithPriority=function(V,L){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var z=p;p=V;try{return L()}finally{p=z}},e.unstable_scheduleCallback=function(V,L,z){var U=e.unstable_now();switch(typeof z=="object"&&z!==null?(z=z.delay,z=typeof z=="number"&&0<z?U+z:U):z=U,V){case 1:var D=-1;break;case 2:D=250;break;case 5:D=1073741823;break;case 4:D=1e4;break;default:D=5e3}return D=z+D,V={id:d++,callback:L,priorityLevel:V,startTime:z,expirationTime:D,sortIndex:-1},z>U?(V.sortIndex=z,t(u,V),n(c)===null&&V===n(u)&&(g?(S(E),E=-1):g=!0,F(_,z-U))):(V.sortIndex=D,t(c,V),m||h||(m=!0,C||(C=!0,$()))),V},e.unstable_shouldYield=I,e.unstable_wrapCallback=function(V){var L=p;return function(){var z=p;p=L;try{return V.apply(this,arguments)}finally{p=z}}}})(RQ)),RQ}var YNe;function G6t(){return YNe||(YNe=1,AQ.exports=Q6t()),AQ.exports}var PQ={exports:{}},Kc={};var XNe;function Y6t(){if(XNe)return Kc;XNe=1;var e=LT();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 Kc.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Kc.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)},Kc.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()}},Kc.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))},Kc.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},Kc.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})}},Kc.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)},Kc.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})}},Kc.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)},Kc.requestFormReset=function(c){r.d.r(c)},Kc.unstable_batchedUpdates=function(c,u){return c(u)},Kc.useFormState=function(c,u,d){return i.H.useFormState(c,u,d)},Kc.useFormStatus=function(){return i.H.useHostTransitionStatus()},Kc.version="19.2.6",Kc}var KNe;function AJe(){if(KNe)return PQ.exports;KNe=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(),PQ.exports=Y6t(),PQ.exports}var JNe;function X6t(){if(JNe)return DI;JNe=1;var e={env:{}};var t=G6t(),n=LT(),r=AJe();function s(x){var k="https://react.dev/errors/"+x;if(1<arguments.length){k+="?args[]="+encodeURIComponent(arguments[1]);for(var j=2;j<arguments.length;j++)k+="&args[]="+encodeURIComponent(arguments[j])}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,j=x;if(x.alternate)for(;k.return;)k=k.return;else{x=k;do k=x,(k.flags&4098)!==0&&(j=k.return),x=k.return;while(x)}return k.tag===3?j: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 j=x,A=k;;){var Z=j.return;if(Z===null)break;var Q=Z.alternate;if(Q===null){if(A=Z.return,A!==null){j=A;continue}break}if(Z.child===Q.child){for(Q=Z.child;Q;){if(Q===j)return u(Z),x;if(Q===A)return u(Z),k;Q=Q.sibling}throw Error(s(188))}if(j.return!==A.return)j=Z,A=Q;else{for(var oe=!1,Se=Z.child;Se;){if(Se===j){oe=!0,j=Z,A=Q;break}if(Se===A){oe=!0,A=Z,j=Q;break}Se=Se.sibling}if(!oe){for(Se=Q.child;Se;){if(Se===j){oe=!0,j=Q,A=Z;break}if(Se===A){oe=!0,A=Q,j=Z;break}Se=Se.sibling}if(!oe)throw Error(s(189))}}if(j.alternate!==A)throw Error(s(190))}if(j.tag!==3)throw Error(s(188));return j.stateNode.current===j?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"),S=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),O=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),N=Symbol.for("react.lazy"),I=Symbol.for("react.activity"),R=Symbol.for("react.memo_cache_sentinel"),$=Symbol.iterator;function B(x){return x===null||typeof x!="object"?null:(x=$&&x[$]||x["@@iterator"],typeof x=="function"?x:null)}var M=Symbol.for("react.client.reference");function F(x){if(x==null)return null;if(typeof x=="function")return x.$$typeof===M?null:x.displayName||x.name||null;if(typeof x=="string")return x;switch(x){case v:return"Fragment";case S:return"Profiler";case b:return"StrictMode";case C:return"Suspense";case E:return"SuspenseList";case I:return"Activity"}if(typeof x=="object")switch(x.$$typeof){case g:return"Portal";case O:return x.displayName||"Context";case w: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 T:return k=x.displayName||null,k!==null?k:F(x.type)||"Memo";case N:k=x._payload,x=x._init;try{return F(x(k))}catch{}}return null}var V=Array.isArray,L=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U={pending:!1,data:null,method:null,action:null},D=[],G=-1;function q(x){return{current:x}}function P(x){0>G||(x.current=D[G],D[G]=null,G--)}function H(x,k){G++,D[G]=x.current,x.current=k}var W=q(null),X=q(null),ae=q(null),ee=q(null);function J(x,k){switch(H(ae,k),H(X,x),H(W,null),k.nodeType){case 9:case 11:x=(x=k.documentElement)&&(x=x.namespaceURI)?hNe(x):0;break;default:if(x=k.tagName,k=k.namespaceURI)k=hNe(k),x=mNe(k,x);else switch(x){case"svg":x=1;break;case"math":x=2;break;default:x=0}}P(W),H(W,x)}function ie(){P(W),P(X),P(ae)}function ce(x){x.memoizedState!==null&&H(ee,x);var k=W.current,j=mNe(k,x.type);k!==j&&(H(X,x),H(W,j))}function Y(x){X.current===x&&(P(W),P(X)),ee.current===x&&(P(ee),AI._currentValue=U)}var ne,ue;function pe(x){if(ne===void 0)try{throw Error()}catch(j){var k=j.stack.trim().match(/\n( *(at )?)/);ne=k&&k[1]||"",ue=-1<j.stack.indexOf(`
3
3
  at`)?" (<anonymous>)":-1<j.stack.indexOf("@")?"@unknown:0:0":""}return`
4
4
  `+ne+x+ue}var re=!1;function he(x,k){if(!x||re)return"";re=!0;var j=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var A={DetermineComponentFrameRoot:function(){try{if(k){var Ct=function(){throw Error()};if(Object.defineProperty(Ct.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ct,[])}catch(dt){var it=dt}Reflect.construct(x,[],Ct)}else{try{Ct.call()}catch(dt){it=dt}x.call(Ct.prototype)}}else{try{throw Error()}catch(dt){it=dt}(Ct=x())&&typeof Ct.catch=="function"&&Ct.catch(function(){})}}catch(dt){if(dt&&it&&typeof dt.stack=="string")return[dt.stack,it.stack]}return[null,null]}};A.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var Z=Object.getOwnPropertyDescriptor(A.DetermineComponentFrameRoot,"name");Z&&Z.configurable&&Object.defineProperty(A.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var Q=A.DetermineComponentFrameRoot(),oe=Q[0],Se=Q[1];if(oe&&Se){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"}),Cd('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Cd('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],tft=fbe.concat([Cd("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Cd("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Cd("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),qDe=new act,nft=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function aA(e){return(t,n)=>{let r=t.node.getChild("VariableDefinition");return r&&n(r,e),!0}}const mOn=["FunctionDeclaration"],gOn={FunctionDeclaration:aA("function"),ClassDeclaration:aA("class"),ClassExpression:()=>!0,EnumDeclaration:aA("constant"),TypeAliasDeclaration:aA("type"),NamespaceDeclaration:aA("namespace"),VariableDefinition(e,t){e.matchContext(mOn)||t(e,"variable")},TypeDefinition(e,t){t(e,"type")},__proto__:null};function rft(e,t){let n=qDe.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(Ta.IncludeAnonymous).iterate(i=>{if(s)s=!1;else if(i.name){let l=gOn[i.name];if(l&&l(i,a)||nft.has(i.name))return!1}else if(i.to-i.from>8192){for(let l of rft(e,i.node))r.push(l);return!1}}),qDe.set(t,r),r}const Mz=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,pbe=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function sft(e){let t=di(e.state).resolveInner(e.pos,-1);if(pbe.indexOf(t.name)>-1)return null;let n=t.name=="VariableName"||t.to-t.from<20&&Mz.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let r=[];for(let s=t;s;s=s.parent)nft.has(s.name)&&(r=r.concat(rft(e.state.doc,s)));return{options:r,from:n?t.from:e.pos,validFor:Mz}}function AY(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 aft(e){let t=r=>e.state.doc.sliceString(r.from,r.to),n=di(e.state).resolveInner(e.pos,-1);return n.name=="PropertyName"?AY(t,n.parent,t(n)):(n.name=="."||n.name=="?.")&&n.parent.name=="MemberExpression"?AY(t,n.parent,""):pbe.indexOf(n.name)>-1?null:n.name=="VariableName"||n.to-n.from<20&&Mz.test(t(n))?{path:[],name:t(n)}:n.name=="MemberExpression"?AY(t,n,""):e.explicit?{path:[],name:""}:null}function vOn(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 yOn(e){let t=new Map;return n=>{let r=aft(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=vOn(s,!r.path.length)),{from:n.pos-r.name.length,options:a,validFor:Mz}}}const _h=Yk.define({name:"javascript",parser:hOn.configure({props:[a_.add({IfStatement:YE({except:/^\s*({|else\b)/}),TryStatement:YE({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:fwn,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:dwn({closing:"}"}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":YE({except:/^\s*{/}),JSXElement(e){let t=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},JSXEscape(e){let t=/\s*\}/.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},"JSXOpenTag JSXSelfClosingTag"(e){return e.column(e.node.from)+e.unit}}),i_.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":Zye,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:"$"}}),ift={test:e=>/^JSX/.test(e.name),facet:OU({commentTokens:{block:{open:"{/*",close:"*/}"}}})},hbe=_h.configure({dialect:"ts"},"typescript"),mbe=_h.configure({dialect:"jsx",props:[qye.add(e=>e.isTop?[ift]:void 0)]}),gbe=_h.configure({dialect:"jsx ts",props:[qye.add(e=>e.isTop?[ift]:void 0)]},"typescript");let oft=e=>({label:e,type:"keyword"});const lft="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(oft),bOn=lft.concat(["declare","implements","private","protected","public"].map(oft));function Dz(e={}){let t=e.jsx?e.typescript?gbe:mbe:e.typescript?hbe:_h,n=e.typescript?tft.concat(bOn):fbe.concat(lft);return new Kk(t,[_h.data.of({autocomplete:Xwn(pbe,idt(n))}),_h.data.of({autocomplete:sft}),e.jsx?cft:[]])}function xOn(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 VDe(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 wOn=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),cft=It.inputHandler.of((e,t,n,r,s)=>{if((wOn?e.composing:e.compositionStarted)||e.state.readOnly||t!=n||r!=">"&&r!="/"||!_h.isActiveAt(e.state,t,-1))return!1;let a=s(),{state:i}=a,l=i.changeByRange(c=>{var u;let{head:d}=c,f=di(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=VDe(i.doc,m.firstChild,d))||((u=m.firstChild)===null||u===void 0?void 0:u.name)=="JSXFragmentTag")){let g=`${p}>`;return{range:gt.cursor(d+g.length,-1),changes:{from:d,insert:g}}}}else if(r==">"){let h=xOn(f);if(h&&h.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(i.doc.sliceString(d,d+2))&&(p=VDe(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 SOn(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 _h.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(kOn(u,r.doc,c))}return s}}function HDe(e,t,n,r){return n.line(e+r.line).from+t+(e==1?r.col-1:-1)}function kOn(e,t,n){let r=HDe(e.line,e.column,t,n),s={from:r,to:e.endLine!=null&&e.endColumn!=1?HDe(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 sL=Object.freeze(Object.defineProperty({__proto__:null,autoCloseTags:cft,completionPath:aft,esLint:SOn,javascript:Dz,javascriptLanguage:_h,jsxLanguage:mbe,localCompletionSource:sft,scopeCompletionSource:yOn,snippets:fbe,tsxLanguage:gbe,typescriptLanguage:hbe,typescriptSnippets:tft},Symbol.toStringTag,{value:"Module"})),iA=["_blank","_self","_top","_parent"],RY=["ascii","utf-8","utf-16","latin1","latin1"],PY=["get","post","put","delete"],$Y=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],Pf=["true","false"],Xn={},OOn={a:{attrs:{href:null,ping:null,type:null,media:null,target:iA,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:iA}},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:$Y,formmethod:PY,formnovalidate:["novalidate"],formtarget:iA,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":RY,autocomplete:["on","off"],enctype:$Y,method:PY,novalidate:["novalidate"],target:iA}},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:$Y,formmethod:PY,formnovalidate:["novalidate"],formtarget:iA,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:RY,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:RY}},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},uft={accesskey:null,class:null,contenteditable:Pf,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:Pf,autocorrect:Pf,autocapitalize:Pf,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":Pf,"aria-autocomplete":["inline","list","both","none"],"aria-busy":Pf,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":Pf,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":Pf,"aria-hidden":Pf,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":Pf,"aria-multiselectable":Pf,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":Pf,"aria-relevant":null,"aria-required":Pf,"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},dft="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 dft)uft[e]=null;let IP=class{constructor(t,n){this.tags={...OOn,...t},this.globalAttrs={...uft,...n},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}};IP.default=new IP;function Lj(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 Fj(e,t=!1){for(;e;e=e.parent)if(e.name=="Element")if(t)t=!1;else return e;return null}function fft(e,t,n){let r=n.tags[Lj(e,Fj(t))];return r?.children||n.allTags}function vbe(e,t){let n=[];for(let r=Fj(t);r&&!r.type.isTop;r=Fj(r.parent)){let s=Lj(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 pft=/^[:\-\.\w\u00b7-\uffff]*$/;function ZDe(e,t,n,r,s){let a=/\s*>/.test(e.sliceDoc(s,s+5))?"":">",i=Fj(n,n.name=="StartTag"||n.name=="TagName");return{from:r,to:s,options:fft(e.doc,i,t).map(l=>({label:l,type:"type"})).concat(vbe(e.doc,n).map((l,c)=>({label:"/"+l,apply:"/"+l+a,type:"type",boost:99-c}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function WDe(e,t,n,r){let s=/\s*>/.test(e.sliceDoc(r,r+5))?"":">";return{from:n,to:r,options:vbe(e.doc,t).map((a,i)=>({label:a,apply:a+s,type:"type",boost:99-i})),validFor:pft}}function _On(e,t,n,r){let s=[],a=0;for(let i of fft(e.doc,n,t))s.push({label:"<"+i,type:"type"});for(let i of vbe(e.doc,n))s.push({label:"</"+i+">",type:"type",boost:99-a++});return{from:r,to:r,options:s,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function COn(e,t,n,r,s){let a=Fj(n),i=a?t.tags[Lj(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:pft}}function EOn(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=Fj(n),p=f?t.tags[Lj(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 hft(e,t){let{state:n,pos:r}=t,s=di(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)?WDe(n,s,s.from,r):ZDe(n,e,s,s.from,r):s.name=="StartTag"||s.name=="IncompleteTag"?ZDe(n,e,s,r,r):s.name=="StartCloseTag"||s.name=="IncompleteCloseTag"?WDe(n,s,r,r):s.name=="OpenTag"||s.name=="SelfClosingTag"||s.name=="AttributeName"?COn(n,e,s,s.name=="AttributeName"?s.from:r,r):s.name=="Is"||s.name=="AttributeValue"||s.name=="UnquotedAttributeValue"?EOn(n,e,s,s.name=="Is"?r:s.from,r):t.explicit&&(a.name=="Element"||a.name=="Text"||a.name=="Document")?_On(n,e,s,r):null}function jOn(e){return hft(IP.default,e)}function TOn(e){let{extraTags:t,extraGlobalAttributes:n}=e,r=n||t?new IP(t,n):IP.default;return s=>hft(r,s)}const NOn=_h.parser.configure({top:"SingleExpression"}),mft=[{tag:"script",attrs:e=>e.type=="text/typescript"||e.lang=="ts",parser:hbe.parser},{tag:"script",attrs:e=>e.type=="text/babel"||e.type=="text/jsx",parser:mbe.parser},{tag:"script",attrs:e=>e.type=="text/typescript-jsx",parser:gbe.parser},{tag:"script",attrs(e){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(e.type)},parser:NOn},{tag:"script",attrs(e){return!e.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(e.type)},parser:_h.parser},{tag:"style",attrs(e){return(!e.lang||e.lang=="css")&&(!e.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(e.type))},parser:$z.parser}],gft=[{name:"style",parser:$z.parser.configure({top:"Styles"})}].concat(dft.map(e=>({name:e,parser:_h.parser}))),vft=Yk.define({name:"html",parser:tkn.configure({props:[a_.add({Element(e){let t=/^(\s*)(<\/)?/.exec(e.textAfter);return e.node.to<=e.pos+t[0].length?e.continue():e.lineIndent(e.node.from)+(t[2]?0:e.unit)},"OpenTag CloseTag SelfClosingTag"(e){return e.column(e.node.from)+e.unit},Document(e){if(e.pos+/\s*/.exec(e.textAfter)[0].length<e.node.to)return e.continue();let t=null,n;for(let r=e.node;;){let s=r.lastChild;if(!s||s.name!="Element"||s.to!=r.to)break;t=r=s}return t&&!((n=t.lastChild)&&(n.name=="CloseTag"||n.name=="SelfClosingTag"))?e.lineIndent(t.from)+e.unit:null}}),i_.add({Element(e){let t=e.firstChild,n=e.lastChild;return!t||t.name!="OpenTag"?null:{from:t.to,to:n.name=="CloseTag"?n.from:e.to}}}),Jut.add({"OpenTag CloseTag":e=>e.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),R8=vft.configure({wrap:Qdt(mft,gft)});function IOn(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=Qdt((e.nestedLanguages||[]).concat(mft),(e.nestedAttributes||[]).concat(gft)));let r=n?vft.configure({wrap:n,dialect:t}):t?R8.configure({dialect:t}):R8;return new Kk(r,[R8.data.of({autocomplete:TOn(e)}),e.autoCloseTags!==!1?AOn:[],Dz().support,Dkn().support])}const QDe=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),AOn=It.inputHandler.of((e,t,n,r,s)=>{if(e.composing||e.state.readOnly||t!=n||r!=">"&&r!="/"||!R8.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=di(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=Lj(i.doc,v.parent,h))&&!QDe.has(g)){let b=h+(i.doc.sliceString(h,h+1)===">"?1:0),S=`</${g}>`;return{range:c,changes:{from:h,to:b,insert:S}}}}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=Lj(i.doc,v,h))&&!QDe.has(g)){let b=h+(i.doc.sliceString(h,h+1)===">"?1:0),S=`${g}>`;return{range:gt.cursor(h+S.length,-1),changes:{from:h,to:b,insert:S}}}}return{range:c}});return l.changes.empty?!1:(e.dispatch([a,i.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),yft=OU({commentTokens:{block:{open:"<!--",close:"-->"}}}),bft=new Tr,xft=rSn.configure({props:[i_.add(e=>!e.is("Block")||e.is("Document")||_de(e)!=null||ROn(e)?void 0:(t,n)=>({from:n.doc.lineAt(t.from).to,to:t.to})),bft.add(_de),a_.add({Document:()=>null}),J0.add({Document:yft})]});function _de(e){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(e.name);return t?+t[1]:void 0}function ROn(e){return e.name=="OrderedList"||e.name=="BulletList"}function POn(e,t){let n=e;for(;;){let r=n.nextSibling,s;if(!r||(s=_de(r.type))!=null&&s<=t)break;n=r}return n.to}const $On=But.of((e,t,n)=>{for(let r=di(e).resolveInner(n,-1);r&&!(r.from<t);r=r.parent){let s=r.type.prop(bft);if(s==null)continue;let a=POn(r,s);if(a>n)return{from:n,to:a}}return null});function ybe(e){return new np(yft,e,[],"markdown")}const wft=ybe(xft),MOn=xft.configure([hSn,gSn,mSn,vSn,{props:[i_.add({Table:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}]),tO=ybe(MOn);function DOn(e,t){return n=>{if(n&&e){let r=null;if(n=/\S*/.exec(n)[0],typeof e=="function"?r=e(n):r=Tm.matchLanguageName(e,n,!0),r instanceof Tm)return r.support?r.support.language.parser:Xk.getSkippingParser(r.load());if(r)return r.parser}return t?t.parser:null}}class MY{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(+kft(this.item,t)[2]+n):"";return this.spaceBefore+r+this.type+this.spaceAfter}}function Sft(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 MY(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 MY(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 MY(a.parent,c,c+d,i[1],u,f,a))}}return r}function kft(e,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from,e.from+10))}function DY(e,t,n,r=0){for(let s=-1,a=e;;){if(a.name=="ListItem"){let l=kft(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 bbe(e,t){let n=/^[ \t]*/.exec(e)[0].length;if(!n||t.facet(sN)!=" ")return e;let r=rg(e,4,n),s="";for(let a=r;a>0;)a>=4?(s+=" ",a-=4):(s+=" ",a--);return s+e.slice(n)}const Oft=(e={})=>({state:t,dispatch:n})=>{let r=di(t),{doc:s}=t,a=null,i=t.changeByRange(l=>{if(!l.empty||!tO.isActiveAt(t,l.from,-1)&&!tO.isActiveAt(t,l.from,1))return a={range:l};let c=l.from,u=s.lineAt(c),d=Sft(r.resolveInner(c,-1),s);for(;d.length&&d[d.length-1].from>c-u.from;)d.pop();if(!d.length)return a={range:l};let f=d[d.length-1];if(f.to-f.spaceAfter.length>c-u.from)return a={range:l};let p=c>=f.to-f.spaceAfter.length&&!/\S/.test(u.text.slice(f.to));if(f.item&&p){let b=f.node.firstChild,S=f.node.getChild("ListItem","ListItem");if(b.to>=c||S&&S.to<c||u.from>0&&!/[^\s>]/.test(s.lineAt(u.from-1).text)||e.nonTightLists===!1){let w=d.length>1?d[d.length-2]:null,O,_="";w&&w.item?(O=u.from+w.from,_=w.marker(s,1)):O=u.from+(w?w.to:0);let C=[{from:O,to:c,insert:_}];return f.node.name=="OrderedList"&&DY(f.item,s,C,-2),w&&w.node.name=="OrderedList"&&DY(w.item,s,C),{range:gt.cursor(O+_.length),changes:C}}else{let w=YDe(d,t,u);return{range:gt.cursor(c+w.length+1),changes:{from:u.from,insert:w+t.lineBreak}}}}if(f.node.name=="Blockquote"&&p&&u.from){let b=s.lineAt(u.from-1),S=/>\s*$/.exec(b.text);if(S&&S.index==f.from){let w=t.changes([{from:b.from+S.index,to:b.to},{from:u.from+f.from,to:u.to}]);return{range:l.map(w),changes:w}}}let h=[];f.node.name=="OrderedList"&&DY(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,S=d.length-1;b<=S;b++)g+=b==S&&!m?d[b].marker(s,1):d[b].blank(b<S?rg(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=bbe(g,t),LOn(f.node,t.doc)&&(g=YDe(d,t,u)+t.lineBreak+g),h.push({from:v,to:c,insert:t.lineBreak+g}),{range:gt.cursor(v+g.length+1),changes:h}});return a?!1:(n(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0)},_ft=Oft();function GDe(e){return e.name=="QuoteMark"||e.name=="ListMark"}function LOn(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 YDe(e,t,n){let r="";for(let s=0,a=e.length-2;s<=a;s++)r+=e[s].blank(s<a?rg(n.text,4,e[s+1].from)-r.length:null,s<a);return bbe(r,t)}function FOn(e,t){let n=e.resolveInner(t,-1),r=t;GDe(n)&&(r=n.from,n=n.parent);for(let s;s=n.childBefore(r);)if(GDe(s))r=s.from;else if(s.name=="OrderedList"||s.name=="BulletList")n=s.lastChild,r=n.to;else break;return n}const Cft=({state:e,dispatch:t})=>{let n=di(e),r=null,s=e.changeByRange(a=>{let i=a.from,{doc:l}=e;if(a.empty&&tO.isActiveAt(e,a.from)){let c=l.lineAt(i),u=Sft(FOn(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:gt.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(rg(c.text,4,d.to)-rg(c.text,4,d.from));return p==c.from&&(h=bbe(h,e)),{range:gt.cursor(p+h.length),changes:{from:p,to:c.from+d.to,insert:h}}}if(p<i)return{range:gt.cursor(p),changes:{from:p,to:i}}}}}return r={range:a}});return r?!1:(t(e.update(s,{scrollIntoView:!0,userEvent:"delete"})),!0)},Eft=[{key:"Enter",run:_ft},{key:"Backspace",run:Cft}],jft=IOn({matchClosingTags:!1});function xbe(e={}){let{codeLanguages:t,defaultCodeLanguage:n,addKeymap:r=!0,base:{parser:s}=wft,completeHTMLTags:a=!0,pasteURLAsLink:i=!0,htmlTagLanguage:l=jft}=e;if(!(s instanceof jU))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let c=e.extensions?[e.extensions]:[],u=[l.support,$On],d;i&&u.push(Tft),n instanceof Kk?(u.push(n.support),d=n.language):n&&(d=n);let f=t||d?DOn(t,d):void 0;c.push(aSn({codeParser:f,htmlParser:l.language.parser})),r&&u.push(vg.high(rN.of(Eft)));let p=ybe(s.configure(c));return a&&u.push(p.data.of({autocomplete:zOn})),new Kk(p,u)}function zOn(e){let{state:t,pos:n}=e,r=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(n-25,n));if(!r)return null;let s=di(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:BOn(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}let LY=null;function BOn(){if(LY)return LY;let e=jOn(new Yye(as.create({extensions:jft}),0,!0));return LY=e?e.options:[]}const UOn=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,Tft=It.domEventHandlers({paste:(e,t)=>{var n;let{main:r}=t.state.selection;if(r.empty)return!1;let s=(n=e.clipboardData)===null||n===void 0?void 0:n.getData("text/plain");if(!s||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(s)||(/^www\./.test(s)&&(s="https://"+s),!tO.isActiveAt(t.state,r.from,1)))return!1;let a=di(t.state),i=!1;return a.iterate({from:r.from,to:r.to,enter:l=>{(l.from>r.from||UOn.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)}}),qOn=Object.freeze(Object.defineProperty({__proto__:null,commonmarkLanguage:wft,deleteMarkupBackward:Cft,insertNewlineContinueMarkup:_ft,insertNewlineContinueMarkupCommand:Oft,markdown:xbe,markdownKeymap:Eft,markdownLanguage:tO,pasteURLAsLink:Tft},Symbol.toStringTag,{value:"Module"}));function nO(){return nO=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},nO.apply(null,arguments)}var VOn=e=>{var{theme:t,settings:n={},styles:r=[]}=e,s={".cm-gutters":{}},a={};n.background&&(a.backgroundColor=n.background),n.backgroundImage&&(a.backgroundImage=n.backgroundImage),n.foreground&&(a.color=n.foreground),n.fontSize&&(a.fontSize=n.fontSize),(n.background||n.foreground)&&(s["&"]=a),n.fontFamily&&(s["&.cm-editor .cm-scroller"]={fontFamily:n.fontFamily}),n.gutterBackground&&(s[".cm-gutters"].backgroundColor=n.gutterBackground),n.gutterForeground&&(s[".cm-gutters"].color=n.gutterForeground),n.gutterBorder&&(s[".cm-gutters"].borderRightColor=n.gutterBorder),n.caret&&(s[".cm-content"]={caretColor:n.caret},s[".cm-cursor, .cm-dropCursor"]={borderLeftColor:n.caret});var i={};n.gutterActiveForeground&&(i.color=n.gutterActiveForeground),n.lineHighlight&&(s[".cm-activeLine"]={backgroundColor:n.lineHighlight},i.backgroundColor=n.lineHighlight),s[".cm-activeLineGutter"]=i,n.selection&&(s["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:n.selection+" !important"}),n.selectionMatch&&(s["& .cm-selectionMatch"]={backgroundColor:n.selectionMatch});var l=It.theme(s,{dark:t==="dark"}),c=yg.define(r),u=[l,m1(c)];return u},HOn={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)"},ZOn=[{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"}],iN=e=>{var{theme:t="dark",settings:n={},styles:r=[]}=e||{};return VOn({theme:t,settings:nO({},HOn,n),styles:[...ZOn,...r]})};iN();function Nft(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 WOn=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Sbe(e.state,n.from);return r.line?QOn(e):r.block?YOn(e):!1};function wbe(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 QOn=wbe(JOn,0),GOn=wbe(Ift,0),YOn=wbe((e,t)=>Ift(e,t,KOn(t)),0);function Sbe(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const oA=50;function XOn(e,{open:t,close:n},r,s){let a=e.sliceDoc(r-oA,r),i=e.sliceDoc(s,s+oA),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*oA?d=f=e.sliceDoc(r,s):(d=e.sliceDoc(r,r+oA),f=e.sliceDoc(s-oA,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 KOn(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 Ift(e,t,n=t.selection.ranges){let r=n.map(a=>Sbe(t,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,i)=>XOn(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 JOn(e,t,n=t.selection.ranges){let r=[],s=-1;for(let{from:a,to:i}of n){let l=r.length,c=1e9,u=Sbe(t,a).line;if(u){for(let d=a;d<=i;){let f=t.doc.lineAt(d);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 Cde=iy.define(),e_n=iy.define(),t_n=wn.define(),Aft=wn.define({combine(e){return oy(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)})}}),Rft=sl.define({create(){return mv.empty},update(e,t){let n=t.state.facet(Aft),r=t.annotation(Cde);if(r){let c=zd.fromTransaction(t,r.selection),u=r.side,d=u==0?e.undone:e.done;return c?d=Lz(d,d.length,n.minDepth,c):d=Mft(d,t.startState.selection),new mv(u==0?r.rest:d,u==0?d:r.rest)}let s=t.annotation(e_n);if((s=="full"||s=="before")&&(e=e.isolate()),t.annotation(yl.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=zd.fromTransaction(t),i=t.annotation(yl.time),l=t.annotation(yl.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 mv(e.done.map(zd.fromJSON),e.undone.map(zd.fromJSON))}});function n_n(e={}){return[Rft,Aft.of(e),It.domEventHandlers({beforeinput(t,n){let r=t.inputType=="historyUndo"?Pft:t.inputType=="historyRedo"?Ede:null;return r?(t.preventDefault(),r(n)):!1}})]}function TU(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let s=n.field(Rft,!1);if(!s)return!1;let a=s.pop(e,n,t);return a?(r(a),!0):!1}}const Pft=TU(0,!1),Ede=TU(1,!1),r_n=TU(0,!0),s_n=TU(1,!0);class zd{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 zd(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 zd(t.changes&&gl.fromJSON(t.changes),[],t.mapped&&Tv.fromJSON(t.mapped),t.startSelection&&gt.fromJSON(t.startSelection),t.selectionsAfter.map(gt.fromJSON))}static fromTransaction(t,n){let r=mh;for(let s of t.startState.facet(t_n)){let a=s(t);a.length&&(r=r.concat(a))}return!r.length&&t.changes.empty?null:new zd(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,mh)}static selection(t){return new zd(void 0,mh,void 0,void 0,t)}}function Lz(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 a_n(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 i_n(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function $ft(e,t){return e.length?t.length?e.concat(t):e:t}const mh=[],o_n=200;function Mft(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-o_n));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),Lz(e,e.length-1,1e9,n.setSelAfter(r)))}else return[zd.selection([t])]}function l_n(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 FY(e,t){if(!e.length)return e;let n=e.length,r=mh;for(;n;){let s=c_n(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?[zd.selection(r)]:mh}function c_n(e,t,n){let r=$ft(e.selectionsAfter.length?e.selectionsAfter.map(l=>l.map(t)):mh,n);if(!e.changes)return zd.selection(r);let s=e.changes.map(t),a=t.mapDesc(e.changes,!0),i=e.mapped?e.mapped.composeDesc(a):a;return new zd(s,fr.mapEffects(e.effects,t),i,e.startSelection.map(a),r)}const u_n=/^(input\.type|delete)($|\.)/;class mv{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 mv(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||u_n.test(r))&&(!l.selectionsAfter.length&&n-this.prevTime<s.newGroupDelay&&s.joinToEvent(a,a_n(l.changes,t.changes))||r=="input.type.compose")?i=Lz(i,i.length-1,s.minDepth,new zd(t.changes.compose(l.changes),$ft(fr.mapEffects(t.effects,l.changes),l.effects),l.mapped,l.startSelection,mh)):i=Lz(i,i.length,s.minDepth,t),new mv(i,mh,n,r)}addSelection(t,n,r,s){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:mh;return a.length>0&&n-this.prevTime<s&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&i_n(a[a.length-1],t)?this:new mv(Mft(this.done,t),this.undone,n,r)}addMapping(t){return new mv(FY(this.done,t),FY(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]||n.selection;if(r&&a.selectionsAfter.length)return n.update({selection:a.selectionsAfter[a.selectionsAfter.length-1],annotations:Cde.of({side:t,rest:l_n(s),selection:i}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(a.changes){let l=s.length==1?mh:s.slice(0,s.length-1);return a.mapped&&(l=FY(l,a.mapped)),n.update({changes:a.changes,selection:a.startSelection,effects:a.effects,annotations:Cde.of({side:t,rest:l,selection:i}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}mv.empty=new mv(mh,mh);const d_n=[{key:"Mod-z",run:Pft,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Ede,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Ede,preventDefault:!0},{key:"Mod-u",run:r_n,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:s_n,preventDefault:!0}];function oN(e,t){return gt.create(e.ranges.map(t),e.mainIndex)}function bg(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function xg({state:e,dispatch:t},n){let r=oN(e.selection,n);return r.eq(e.selection,!0)?!1:(t(bg(e,r)),!0)}function NU(e,t){return gt.cursor(t?e.to:e.from)}function Dft(e,t){return xg(e,n=>n.empty?e.moveByChar(n,t):NU(n,t))}function Tu(e){return e.textDirectionAt(e.state.selection.main.head)==gi.LTR}const Lft=e=>Dft(e,!Tu(e)),Fft=e=>Dft(e,Tu(e));function zft(e,t){return xg(e,n=>n.empty?e.moveByGroup(n,t):NU(n,t))}const f_n=e=>zft(e,!Tu(e)),p_n=e=>zft(e,Tu(e));function h_n(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 IU(e,t,n){let r=di(e).resolveInner(t.head),s=n?Tr.closedBy:Tr.openedBy;for(let c=t.head;;){let u=n?r.childAfter(c):r.childBefore(c);if(!u)break;h_n(e,u,s)?r=u:c=n?u.to:u.from}let a=r.type.prop(s),i,l;return a&&(i=n?hv(e,r.from,1):hv(e,r.to,-1))&&i.matched?l=n?i.end.to:i.end.from:l=n?r.to:r.from,gt.cursor(l,n?-1:1)}const m_n=e=>xg(e,t=>IU(e.state,t,!Tu(e))),g_n=e=>xg(e,t=>IU(e.state,t,Tu(e)));function Bft(e,t){return xg(e,n=>{if(!n.empty)return NU(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}const Uft=e=>Bft(e,!1),qft=e=>Bft(e,!0);function Vft(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,s;if(t){for(let a of e.state.facet(It.scrollMargins)){let i=a(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}s=e.scrollDOM.clientHeight-n-r}else s=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,s-5)}}function Hft(e,t){let n=Vft(e),{state:r}=e,s=oN(r.selection,i=>i.empty?e.moveVertically(i,t,n.height):NU(i,t));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let i=e.coordsAtPos(r.selection.main.head),l=e.scrollDOM.getBoundingClientRect(),c=l.top+n.marginTop,u=l.bottom-n.marginBottom;i&&i.top>c&&i.bottom<u&&(a=It.scrollIntoView(s.main.head,{y:"start",yMargin:i.top-c}))}return e.dispatch(bg(r,s),{effects:a}),!0}const XDe=e=>Hft(e,!1),jde=e=>Hft(e,!0);function g1(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=gt.cursor(r.from+a))}return s}const v_n=e=>xg(e,t=>g1(e,t,!0)),y_n=e=>xg(e,t=>g1(e,t,!1)),b_n=e=>xg(e,t=>g1(e,t,!Tu(e))),x_n=e=>xg(e,t=>g1(e,t,Tu(e))),w_n=e=>xg(e,t=>gt.cursor(e.lineBlockAt(t.head).from,1)),S_n=e=>xg(e,t=>gt.cursor(e.lineBlockAt(t.head).to,-1));function k_n(e,t,n){let r=!1,s=oN(e.selection,a=>{let i=hv(e,a.head,-1)||hv(e,a.head,1)||a.head>0&&hv(e,a.head-1,1)||a.head<e.doc.length&&hv(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 gt.cursor(l)});return r?(t(bg(e,s)),!0):!1}const O_n=({state:e,dispatch:t})=>k_n(e,t);function Gh(e,t){let n=oN(e.state.selection,r=>{let s=t(r);return gt.range(r.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return n.eq(e.state.selection)?!1:(e.dispatch(bg(e.state,n)),!0)}function Zft(e,t){return Gh(e,n=>e.moveByChar(n,t))}const Wft=e=>Zft(e,!Tu(e)),Qft=e=>Zft(e,Tu(e));function Gft(e,t){return Gh(e,n=>e.moveByGroup(n,t))}const __n=e=>Gft(e,!Tu(e)),C_n=e=>Gft(e,Tu(e)),E_n=e=>Gh(e,t=>IU(e.state,t,!Tu(e))),j_n=e=>Gh(e,t=>IU(e.state,t,Tu(e)));function Yft(e,t){return Gh(e,n=>e.moveVertically(n,t))}const Xft=e=>Yft(e,!1),Kft=e=>Yft(e,!0);function Jft(e,t){return Gh(e,n=>e.moveVertically(n,t,Vft(e).height))}const KDe=e=>Jft(e,!1),JDe=e=>Jft(e,!0),T_n=e=>Gh(e,t=>g1(e,t,!0)),N_n=e=>Gh(e,t=>g1(e,t,!1)),I_n=e=>Gh(e,t=>g1(e,t,!Tu(e))),A_n=e=>Gh(e,t=>g1(e,t,Tu(e))),R_n=e=>Gh(e,t=>gt.cursor(e.lineBlockAt(t.head).from)),P_n=e=>Gh(e,t=>gt.cursor(e.lineBlockAt(t.head).to)),e4e=({state:e,dispatch:t})=>(t(bg(e,{anchor:0})),!0),t4e=({state:e,dispatch:t})=>(t(bg(e,{anchor:e.doc.length})),!0),n4e=({state:e,dispatch:t})=>(t(bg(e,{anchor:e.selection.main.anchor,head:0})),!0),r4e=({state:e,dispatch:t})=>(t(bg(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),$_n=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),M_n=({state:e,dispatch:t})=>{let n=AU(e).map(({from:r,to:s})=>gt.range(r,Math.min(s+1,e.doc.length)));return t(e.update({selection:gt.create(n),userEvent:"select"})),!0},D_n=({state:e,dispatch:t})=>{let n=oN(e.selection,r=>{let s=di(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 gt.range(l.to,l.from)}return r});return n.eq(e.selection)?!1:(t(bg(e,n)),!0)};function ept(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(bg(n,gt.create(s,s.length-1))),!0)}const L_n=e=>ept(e,!1),F_n=e=>ept(e,!0),z_n=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=gt.create([n.main]):n.main.empty||(r=gt.create([gt.cursor(n.main.head)])),r?(t(bg(e,r)),!0):!1};function eD(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=aL(e,c,!1)):c>i&&(n="delete.forward",c=aL(e,c,!0)),i=Math.min(i,c),l=Math.max(l,c)}else i=aL(e,i,!1),l=aL(e,l,!0);return i==l?{range:a}:{changes:{from:i,to:l},range:gt.cursor(i,i<a.head?-1:1)}});return s.changes.empty?!1:(e.dispatch(r.update(s,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?It.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function aL(e,t,n){if(e instanceof It)for(let r of e.state.facet(It.atomicRanges).map(s=>s(e)))r.between(t,t,(s,a)=>{s<t&&a>t&&(t=n?a:s)});return t}const tpt=(e,t,n)=>eD(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=rg(l,a.tabSize),d=u%Jk(a)||Jk(a);for(let f=0;f<d&&l[l.length-1-f]==" ";f++)s--;c=s}else c=nc(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=nc(i.text,c-i.from,!1,!1)+i.from);return c}),Tde=e=>tpt(e,!1,!0),npt=e=>tpt(e,!0,!1),rpt=(e,t)=>eD(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=nc(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}),spt=e=>rpt(e,!1),B_n=e=>rpt(e,!0),U_n=e=>eD(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),q_n=e=>eD(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),V_n=e=>eD(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),H_n=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:ya.of(["",""])},range:gt.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},Z_n=({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:nc(a.text,s-a.from,!1)+a.from,l=s==a.to?s+1:nc(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:gt.cursor(l)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function AU(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 apt(e,t,n){if(e.readOnly)return!1;let r=[],s=[];for(let a of AU(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(gt.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(gt.range(c.anchor-l,c.head-l))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:gt.create(s,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}const W_n=({state:e,dispatch:t})=>apt(e,t,!1),Q_n=({state:e,dispatch:t})=>apt(e,t,!0);function ipt(e,t,n){if(e.readOnly)return!1;let r=[];for(let a of AU(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 G_n=({state:e,dispatch:t})=>ipt(e,t,!1),Y_n=({state:e,dispatch:t})=>ipt(e,t,!0),X_n=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(AU(t).map(({from:s,to:a})=>(s>0?s--:a<t.doc.length&&a++,{from:s,to:a}))),r=oN(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 K_n(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=di(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(Tr.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 s4e=opt(!1),J_n=opt(!0);function opt(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&&K_n(t,a);e&&(a=i=(i<=l.to?l:t.doc.lineAt(i)).to);let u=new _U(t,{simulateBreak:a,simulateDoubleBreak:!!c}),d=Vye(u,a);for(d==null&&(d=rg(/^\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=["",kP(t,d)];return c&&f.push(kP(t,u.lineIndent(l.from,-1))),{changes:{from:a,to:i,insert:ya.of(f)},range:gt.cursor(a+1+f[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function kbe(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:gt.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const eCn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new _U(e,{overrideIndentation:a=>{let i=n[a];return i??-1}}),s=kbe(e,(a,i,l)=>{let c=Vye(r,a.from);if(c==null)return;/\S/.test(a.text)||(c=0);let u=/^\s*/.exec(a.text)[0],d=kP(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},lpt=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(kbe(e,(n,r)=>{r.push({from:n.from,insert:e.facet(sN)})}),{userEvent:"input.indent"})),!0),cpt=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(kbe(e,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=rg(s,e.tabSize),i=0,l=kP(e,Math.max(0,a-Jk(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),tCn=e=>(e.setTabFocusMode(),!0),nCn=[{key:"Ctrl-b",run:Lft,shift:Wft,preventDefault:!0},{key:"Ctrl-f",run:Fft,shift:Qft},{key:"Ctrl-p",run:Uft,shift:Xft},{key:"Ctrl-n",run:qft,shift:Kft},{key:"Ctrl-a",run:w_n,shift:R_n},{key:"Ctrl-e",run:S_n,shift:P_n},{key:"Ctrl-d",run:npt},{key:"Ctrl-h",run:Tde},{key:"Ctrl-k",run:U_n},{key:"Ctrl-Alt-h",run:spt},{key:"Ctrl-o",run:H_n},{key:"Ctrl-t",run:Z_n},{key:"Ctrl-v",run:jde}],rCn=[{key:"ArrowLeft",run:Lft,shift:Wft,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:f_n,shift:__n,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:b_n,shift:I_n,preventDefault:!0},{key:"ArrowRight",run:Fft,shift:Qft,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:p_n,shift:C_n,preventDefault:!0},{mac:"Cmd-ArrowRight",run:x_n,shift:A_n,preventDefault:!0},{key:"ArrowUp",run:Uft,shift:Xft,preventDefault:!0},{mac:"Cmd-ArrowUp",run:e4e,shift:n4e},{mac:"Ctrl-ArrowUp",run:XDe,shift:KDe},{key:"ArrowDown",run:qft,shift:Kft,preventDefault:!0},{mac:"Cmd-ArrowDown",run:t4e,shift:r4e},{mac:"Ctrl-ArrowDown",run:jde,shift:JDe},{key:"PageUp",run:XDe,shift:KDe},{key:"PageDown",run:jde,shift:JDe},{key:"Home",run:y_n,shift:N_n,preventDefault:!0},{key:"Mod-Home",run:e4e,shift:n4e},{key:"End",run:v_n,shift:T_n,preventDefault:!0},{key:"Mod-End",run:t4e,shift:r4e},{key:"Enter",run:s4e,shift:s4e},{key:"Mod-a",run:$_n},{key:"Backspace",run:Tde,shift:Tde,preventDefault:!0},{key:"Delete",run:npt,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:spt,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:B_n,preventDefault:!0},{mac:"Mod-Backspace",run:q_n,preventDefault:!0},{mac:"Mod-Delete",run:V_n,preventDefault:!0}].concat(nCn.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),sCn=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:m_n,shift:E_n},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:g_n,shift:j_n},{key:"Alt-ArrowUp",run:W_n},{key:"Shift-Alt-ArrowUp",run:G_n},{key:"Alt-ArrowDown",run:Q_n},{key:"Shift-Alt-ArrowDown",run:Y_n},{key:"Mod-Alt-ArrowUp",run:L_n},{key:"Mod-Alt-ArrowDown",run:F_n},{key:"Escape",run:z_n},{key:"Mod-Enter",run:J_n},{key:"Alt-l",mac:"Ctrl-l",run:M_n},{key:"Mod-i",run:D_n,preventDefault:!0},{key:"Mod-[",run:cpt},{key:"Mod-]",run:lpt},{key:"Mod-Alt-\\",run:eCn},{key:"Shift-Mod-k",run:X_n},{key:"Shift-Mod-\\",run:O_n},{key:"Mod-/",run:WOn},{key:"Alt-A",run:GOn},{key:"Ctrl-m",mac:"Shift-Alt-m",run:tCn}].concat(rCn),aCn={key:"Tab",run:lpt,shift:cpt},a4e=typeof String.prototype.normalize=="function"?e=>e.normalize("NFKD"):e=>e;class Zb{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(a4e(l)):a4e,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 Ad(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=_ye(t),r=this.bufferStart+this.bufferPos;this.bufferPos+=nv(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"&&(Zb.prototype[Symbol.iterator]=function(){return this});const upt={from:-1,to:-1,match:/.*/.exec(""),precise:!0},Obe="gm"+(/x/.unicode==null?"":"u");class dpt{constructor(t,n,r,s=0,a=t.length){if(this.text=t,this.to=a,this.curLine="",this.done=!1,this.value=upt,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new fpt(t,n,r,s,a);this.re=new RegExp(n,Obe+(r?.ignoreCase?"i":"")),this.test=r?.test,this.iter=t.iter();let i=t.lineAt(s);this.curLineStart=i.from,this.matchPos=Fz(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=Fz(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 zY=new WeakMap;class KE{constructor(t,n){this.from=t,this.text=n}get to(){return this.from+this.text.length}static get(t,n,r){let s=zY.get(t);if(!s||s.from>=r||s.to<=n){let l=new KE(n,t.sliceString(n,r));return zY.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)),zY.set(t,new KE(i,a)),new KE(n,a.slice(n-i,r-i))}}class fpt{constructor(t,n,r,s,a){this.text=t,this.to=a,this.done=!1,this.value=upt,this.matchPos=Fz(t,s),this.re=new RegExp(n,Obe+(r?.ignoreCase?"i":"")),this.test=r?.test,this.flat=KE.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=Fz(this.text,s+(r==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=KE.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(dpt.prototype[Symbol.iterator]=fpt.prototype[Symbol.iterator]=function(){return this});function iCn(e){try{return new RegExp(e,Obe),!0}catch{return!1}}function Fz(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 oCn=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:s}=U0n(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=gt.cursor(m.from+Math.max(0,Math.min(p,m.length)));e.dispatch({effects:[r,It.scrollIntoView(g.from,{y:"center"})],selection:g})}),!0},lCn={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},cCn=wn.define({combine(e){return oy(e,lCn,{highlightWordAroundCursor:(t,n)=>t||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function uCn(e){return[mCn,hCn]}const dCn=_n.mark({class:"cm-selectionMatch"}),fCn=_n.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function i4e(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=Ji.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=Ji.Word)}function pCn(e,t,n,r){return e(t.sliceDoc(n,n+1))==Ji.Word&&e(t.sliceDoc(r-1,r))==Ji.Word}const hCn=ro.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(cCn),{state:n}=e,r=n.selection;if(r.ranges.length>1)return _n.none;let s=r.main,a,i=null;if(s.empty){if(!t.highlightWordAroundCursor)return _n.none;let c=n.wordAt(s.head);if(!c)return _n.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 _n.none;if(t.wholeWords){if(a=n.sliceDoc(s.from,s.to),i=n.charCategorizer(s.head),!(i4e(i,n,s.from,s.to)&&pCn(i,n,s.from,s.to)))return _n.none}else if(a=n.sliceDoc(s.from,s.to),!a)return _n.none}let l=[];for(let c of e.visibleRanges){let u=new Zb(n.doc,a,c.from,c.to);for(;!u.next().done;){let{from:d,to:f}=u.value;if((!i||i4e(i,n,d,f))&&(s.empty&&d<=s.from&&f>=s.to?l.push(fCn.range(d,f)):(d>=s.to||f<=s.from)&&l.push(dCn.range(d,f)),l.length>t.maxMatches))return _n.none}}return _n.set(l)}},{decorations:e=>e.decorations}),mCn=It.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),gCn=({state:e,dispatch:t})=>{let{selection:n}=e,r=gt.create(n.ranges.map(s=>e.wordAt(s.head)||gt.cursor(s.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function vCn(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 Zb(e.doc,t,r[r.length-1].to);;)if(l.next(),l.done){if(i)return null;l=new Zb(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 yCn=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(a=>a.from===a.to))return gCn({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=vCn(e,r);return s?(t(e.update({selection:e.selection.addRange(gt.range(s.from,s.to),!1),effects:It.scrollIntoView(s.to)})),!0):!1},lN=wn.define({combine(e){return oy(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new ACn(t),scrollToMatch:t=>It.scrollIntoView(t)})}});class ppt{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||iCn(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 OCn(this):new wCn(this)}getCursor(t,n=0,r){let s=t.doc?t:as.create({doc:t});return r==null&&(r=s.doc.length),this.regexp?KC(this,s,n,r):XC(this,s,n,r)}}class hpt{constructor(t){this.spec=t}}function bCn(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 XC(e,t,n,r){let s;return e.wholeWord&&(s=xCn(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(s=bCn(e.test,t,s)),new Zb(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:a=>a.toLowerCase(),s)}function xCn(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(zz(s,n-a))!=Ji.Word||t(Bz(s,n-a))!=Ji.Word)&&(t(Bz(s,r-a))!=Ji.Word||t(zz(s,r-a))!=Ji.Word))}class wCn extends hpt{constructor(t){super(t)}nextMatch(t,n,r){let s=XC(this.spec,t,r,t.doc.length).nextOverlapping();if(s.done){let a=Math.min(t.doc.length,n+this.spec.unquoted.length);s=XC(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=XC(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=XC(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=XC(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 SCn(e,t,n){return(r,s,a)=>(!n||n(r,s,a))&&e(a[0],t,r,s)}function KC(e,t,n,r){let s;return e.wholeWord&&(s=kCn(t.charCategorizer(t.selection.main.head))),e.test&&(s=SCn(e.test,t,s)),new dpt(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:s},n,r)}function zz(e,t){return e.slice(nc(e,t,!1),t)}function Bz(e,t){return e.slice(t,nc(e,t))}function kCn(e){return(t,n,r)=>!r[0].length||(e(zz(r.input,r.index))!=Ji.Word||e(Bz(r.input,r.index))!=Ji.Word)&&(e(Bz(r.input,r.index+r[0].length))!=Ji.Word||e(zz(r.input,r.index+r[0].length))!=Ji.Word)}class OCn extends hpt{nextMatch(t,n,r){let s=KC(this.spec,t,r,t.doc.length).next();return s.done&&(s=KC(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=KC(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=KC(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=KC(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 AP=fr.define(),_be=fr.define(),hw=sl.define({create(e){return new BY(Nde(e).create(),null)},update(e,t){for(let n of t.effects)n.is(AP)?e=new BY(n.value.create(),e.panel):n.is(_be)&&(e=new BY(e.query,n.value?Cbe:null));return e},provide:e=>SP.from(e,t=>t.panel)});class BY{constructor(t,n){this.query=t,this.panel=n}}const _Cn=_n.mark({class:"cm-searchMatch"}),CCn=_n.mark({class:"cm-searchMatch cm-searchMatch-selected"}),ECn=ro.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(hw))}update(e){let t=e.state.field(hw);(t!=e.startState.field(hw)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return _n.none;let{view:n}=this,r=new od;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?CCn:_Cn)})}return r.finish()}},{decorations:e=>e.decorations});function tD(e){return t=>{let n=t.state.field(hw,!1);return n&&n.query.spec.valid?e(t,n):vpt(t)}}const Uz=tD((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let s=gt.single(r.from,r.to),a=e.state.facet(lN);return e.dispatch({selection:s,effects:[Ebe(e,r),a.scrollToMatch(s.main,e)],userEvent:"select.search"}),gpt(e),!0}),qz=tD((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,s=t.prevMatch(n,r,r);if(!s)return!1;let a=gt.single(s.from,s.to),i=e.state.facet(lN);return e.dispatch({selection:a,effects:[Ebe(e,s),i.scrollToMatch(a.main,e)],userEvent:"select.search"}),gpt(e),!0}),jCn=tD((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:gt.create(n.map(r=>gt.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),TCn=({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 Zb(e.doc,e.sliceDoc(r,s));!l.next().done;){if(a.length>1e3)return!1;l.value.from==r&&(i=a.length),a.push(gt.range(l.value.from,l.value.to))}return t(e.update({selection:gt.create(a,i),userEvent:"select.search.matches"})),!0},o4e=tD((e,{query:t})=>{let{state:n}=e,{from:r,to:s}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let i=a,l=[],c,u,d=[];i.precise?i.from==r&&i.to==s&&(u=n.toText(t.getReplacement(i)),l.push({from:i.from,to:i.to,insert:u}),d.push(It.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."))):i=t.nextMatch(n,i.from,i.to);let f=e.state.changes(l);return i&&(c=gt.single(i.from,i.to).map(f),d.push(Ebe(e,i)),d.push(n.facet(lN).scrollToMatch(c.main,e))),e.dispatch({changes:f,selection:c,effects:d,userEvent:"input.replace"}),!0}),NCn=tD((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let s of t.matchAll(e.state,1e9)){let{from:a,to:i,precise:l}=s;l&&n.push({from:a,to:i,insert:t.getReplacement(s)})}if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:It.announce.of(r),userEvent:"input.replace.all"}),!0});function Cbe(e){return e.state.facet(lN).createPanel(e)}function Nde(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(lN);return new ppt({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 mpt(e){let t=Uye(e,Cbe);return t&&t.dom.querySelector("[main-field]")}function gpt(e){let t=mpt(e);t&&t==e.root.activeElement&&t.select()}const vpt=e=>{let t=e.state.field(hw,!1);if(t&&t.panel){let n=mpt(e);if(n&&n!=e.root.activeElement){let r=Nde(e.state,t.query.spec);r.valid&&e.dispatch({effects:AP.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[_be.of(!0),t?AP.of(Nde(e.state,t.query.spec)):fr.appendConfig.of(PCn)]});return!0},ypt=e=>{let t=e.state.field(hw,!1);if(!t||!t.panel)return!1;let n=Uye(e,Cbe);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:_be.of(!1)}),!0},ICn=[{key:"Mod-f",run:vpt,scope:"editor search-panel"},{key:"F3",run:Uz,shift:qz,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Uz,shift:qz,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:ypt,scope:"editor search-panel"},{key:"Mod-Shift-l",run:TCn},{key:"Mod-Alt-g",run:oCn},{key:"Mod-d",run:yCn,preventDefault:!0}];class ACn{constructor(t){this.view=t;let n=this.query=t.state.field(hw).query.spec;this.commit=this.commit.bind(this),this.searchField=ai("input",{value:n.search,placeholder:$f(t,"Find"),"aria-label":$f(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ai("input",{value:n.replace,placeholder:$f(t,"Replace"),"aria-label":$f(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=ai("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=ai("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=ai("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(s,a,i){return ai("button",{class:"cm-button",name:s,onclick:a,type:"button"},i)}this.dom=ai("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,r("next",()=>Uz(t),[$f(t,"next")]),r("prev",()=>qz(t),[$f(t,"previous")]),r("select",()=>jCn(t),[$f(t,"all")]),ai("label",null,[this.caseField,$f(t,"match case")]),ai("label",null,[this.reField,$f(t,"regexp")]),ai("label",null,[this.wordField,$f(t,"by word")]),...t.state.readOnly?[]:[ai("br"),this.replaceField,r("replace",()=>o4e(t),[$f(t,"replace")]),r("replaceAll",()=>NCn(t),[$f(t,"replace all")])],ai("button",{name:"close",onclick:()=>ypt(t),"aria-label":$f(t,"close"),type:"button"},["×"])])}commit(){let t=new ppt({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:AP.of(t)}))}keydown(t){Kxn(this.view,t,"search-panel")?t.preventDefault():t.keyCode==13&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?qz:Uz)(this.view)):t.keyCode==13&&t.target==this.replaceField&&(t.preventDefault(),o4e(this.view))}update(t){for(let n of t.transactions)for(let r of n.effects)r.is(AP)&&!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(lN).top}}function $f(e,t){return e.state.phrase(t)}const iL=30,oL=/[\s\.,:;?!]/;function Ebe(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-iL),i=Math.min(s,n+iL),l=e.state.sliceDoc(a,i);if(a!=r.from){for(let c=0;c<iL;c++)if(!oL.test(l[c+1])&&oL.test(l[c])){l=l.slice(c);break}}if(i!=s){for(let c=l.length-1;c>l.length-iL;c--)if(!oL.test(l[c-1])&&oL.test(l[c])){l=l.slice(0,c);break}}return It.announce.of(`${e.state.phrase("current match")}. ${l} ${e.state.phrase("on line")} ${r.number}.`)}const RCn=It.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),PCn=[hw,vg.low(ECn),RCn];class l4e{constructor(t,n,r){this.from=t,this.to=n,this.diagnostic=r}}class HS{constructor(t,n,r){this.diagnostics=t,this.panel=n,this.selected=r}static init(t,n,r){let s=r.facet(RP).markerFilter;s&&(t=s(t,r));let a=t.slice().sort((d,f)=>d.from-f.from||d.to-f.to),i=new od,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=WCn(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,_n.widget({widget:new qCn(m),diagnostics:l.slice()}));else{let g=l.reduce((v,b)=>b.markClass?v+" "+b.markClass:v,"");i.add(p,h,_n.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 HS(u,n,zj(u))}}function zj(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 l4e(s,a,t||i.diagnostics[0]);else{if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new l4e(r.from,a,r.diagnostic)}}),r}function $Cn(e,t){let n=t.pos,r=t.end||n,s=e.state.facet(RP).hideOn(e,n,r);if(s!=null)return s;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(i=>i.is(bpt))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function MCn(e,t){return e.field(rp,!1)?t:t.concat(fr.appendConfig.of(QCn))}const bpt=fr.define(),jbe=fr.define(),xpt=fr.define(),rp=sl.define({create(){return new HS(_n.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=zj(n,e.selected.diagnostic,a)||zj(n,null,a)}!n.size&&s&&t.state.facet(RP).autoPanel&&(s=null),e=new HS(n,s,r)}for(let n of t.effects)if(n.is(bpt)){let r=t.state.facet(RP).autoPanel?n.value.length?PP.open:null:e.panel;e=HS.init(n.value,r,t.state)}else n.is(jbe)?e=new HS(e.diagnostics,n.value?PP.open:null,e.selected):n.is(xpt)&&(e=new HS(e.diagnostics,e.panel,n.value));return e},provide:e=>[SP.from(e,t=>t.panel),It.decorations.from(e,t=>t.diagnostics)]}),DCn=_n.mark({class:"cm-lintRange cm-lintRange-active"});function LCn(e,t,n){let{diagnostics:r}=e.state.field(rp),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(RP).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:FCn(e,s)}}}:null}function FCn(e,t){return ai("ul",{class:"cm-tooltip-lint"},t.map(n=>Spt(e,n,!1)))}const zCn=e=>{let t=e.state.field(rp,!1);(!t||!t.panel)&&e.dispatch({effects:MCn(e.state,[jbe.of(!0)])});let n=Uye(e,PP.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},c4e=e=>{let t=e.state.field(rp,!1);return!t||!t.panel?!1:(e.dispatch({effects:jbe.of(!1)}),!0)},BCn=e=>{let t=e.state.field(rp,!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)},UCn=[{key:"Mod-Shift-m",run:zCn,preventDefault:!0},{key:"F8",run:BCn}],RP=wn.define({combine(e){return{sources:e.map(t=>t.source).filter(t=>t!=null),...oy(e.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:u4e,tooltipFilter:u4e,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 u4e(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function wpt(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 Spt(e,t,n){var r;let s=n?wpt(t.actions):[];return ai("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},ai("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=zj(e.state.field(rp).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),ai("u",u.slice(d,d+1)),u.slice(d+1)],p=a.markClass?" "+a.markClass:"";return ai("button",{type:"button",class:"cm-diagnosticAction"+p,onclick:c,onmousedown:c,"aria-label":` Action: ${u}${d<0?"":` (access key "${s[i]})"`}.`},f)}),t.source&&ai("div",{class:"cm-diagnosticSource"},t.source))}class qCn extends Np{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return ai("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class d4e{constructor(t,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Spt(t,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class PP{constructor(t){this.view=t,this.items=[];let n=s=>{if(s.keyCode==27)c4e(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=wpt(a.actions);for(let l=0;l<i.length;l++)if(i[l].toUpperCase().charCodeAt(0)==s.keyCode){let c=zj(this.view.state.field(rp).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=ai("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=ai("div",{class:"cm-panel-lint"},this.list,ai("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>c4e(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(rp).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(rp),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 d4e(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 d4e(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(rp),r=zj(n.diagnostics,this.items[t].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:xpt.of(r)})}static open(t){return new PP(t)}}function VCn(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 lL(e){return VCn(`<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 HCn=It.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:lL("#d11")},".cm-lintRange-warning":{backgroundImage:lL("orange")},".cm-lintRange-info":{backgroundImage:lL("#999")},".cm-lintRange-hint":{backgroundImage:lL("#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 ZCn(e){return e=="error"?4:e=="warning"?3:e=="info"?2:1}function WCn(e){let t="hint",n=1;for(let r of e){let s=ZCn(r.severity);s>n&&(n=s,t=r.severity)}return t}const QCn=[rp,It.decorations.compute([rp],e=>{let{selected:t,panel:n}=e.field(rp);return!t||!n||t.from==t.to?_n.none:_n.set([DCn.range(t.from,t.to)])}),z0n(LCn,{hideOn:$Cn}),HCn];var f4e=function(t){t===void 0&&(t={});var{crosshairCursor:n=!1}=t,r=[];t.closeBracketsKeymap!==!1&&(r=r.concat(D1n)),t.defaultKeymap!==!1&&(r=r.concat(sCn)),t.searchKeymap!==!1&&(r=r.concat(ICn)),t.historyKeymap!==!1&&(r=r.concat(d_n)),t.foldKeymap!==!1&&(r=r.concat(Swn)),t.completionKeymap!==!1&&(r=r.concat(gdt)),t.lintKeymap!==!1&&(r=r.concat(UCn));var s=[];return t.lineNumbers!==!1&&s.push(K0n()),t.highlightActiveLineGutter!==!1&&s.push(twn()),t.highlightSpecialChars!==!1&&s.push(h0n()),t.history!==!1&&s.push(n_n()),t.foldGutter!==!1&&s.push(Cwn()),t.drawSelection!==!1&&s.push(s0n()),t.dropCursor!==!1&&s.push(c0n()),t.allowMultipleSelections!==!1&&s.push(as.allowMultipleSelections.of(!0)),t.indentOnInput!==!1&&s.push(hwn()),t.syntaxHighlighting!==!1&&s.push(m1(Nwn,{fallback:!0})),t.bracketMatching!==!1&&s.push(Dwn()),t.closeBrackets!==!1&&s.push(R1n()),t.autocompletion!==!1&&s.push(mdt()),t.rectangularSelection!==!1&&s.push(j0n()),n!==!1&&s.push(I0n()),t.highlightActiveLine!==!1&&s.push(x0n()),t.highlightSelectionMatches!==!1&&s.push(uCn()),t.tabSize&&typeof t.tabSize=="number"&&s.push(sN.of(" ".repeat(t.tabSize))),s.concat([rN.of(r.flat())]).filter(Boolean)};const GCn="#e5c07b",p4e="#e06c75",YCn="#56b6c2",XCn="#ffffff",P8="#abb2bf",Ide="#7d8799",KCn="#61afef",JCn="#98c379",h4e="#d19a66",eEn="#c678dd",tEn="#21252b",m4e="#2c313a",g4e="#282c34",UY="#353a42",nEn="#3E4451",v4e="#528bff",rEn=It.theme({"&":{color:P8,backgroundColor:g4e},".cm-content":{caretColor:v4e},".cm-cursor, .cm-dropCursor":{borderLeftColor:v4e},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:nEn},".cm-panels":{backgroundColor:tEn,color:P8},".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:g4e,color:Ide,border:"none"},".cm-activeLineGutter":{backgroundColor:m4e},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:UY},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:UY,borderBottomColor:UY},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:m4e,color:P8}}},{dark:!0}),sEn=yg.define([{tag:de.keyword,color:eEn},{tag:[de.name,de.deleted,de.character,de.propertyName,de.macroName],color:p4e},{tag:[de.function(de.variableName),de.labelName],color:KCn},{tag:[de.color,de.constant(de.name),de.standard(de.name)],color:h4e},{tag:[de.definition(de.name),de.separator],color:P8},{tag:[de.typeName,de.className,de.number,de.changed,de.annotation,de.modifier,de.self,de.namespace],color:GCn},{tag:[de.operator,de.operatorKeyword,de.url,de.escape,de.regexp,de.link,de.special(de.string)],color:YCn},{tag:[de.meta,de.comment],color:Ide},{tag:de.strong,fontWeight:"bold"},{tag:de.emphasis,fontStyle:"italic"},{tag:de.strikethrough,textDecoration:"line-through"},{tag:de.link,color:Ide,textDecoration:"underline"},{tag:de.heading,fontWeight:"bold",color:p4e},{tag:[de.atom,de.bool,de.special(de.variableName)],color:h4e},{tag:[de.processingInstruction,de.string,de.inserted],color:JCn},{tag:de.invalid,color:XCn}]),aEn=[rEn,m1(sEn)];var iEn=It.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),oEn=function(t){t===void 0&&(t={});var{indentWithTab:n=!0,editable:r=!0,readOnly:s=!1,theme:a="light",placeholder:i="",basicSetup:l=!0}=t,c=[];switch(n&&c.unshift(rN.of([aCn])),l&&(typeof l=="boolean"?c.unshift(f4e()):c.unshift(f4e(l))),i&&c.unshift(O0n(i)),a){case"light":c.push(iEn);break;case"dark":c.push(aEn);break;case"none":break;default:c.push(a);break}return r===!1&&c.push(It.editable.of(!1)),s&&c.push(as.readOnly.of(!0)),[...c]},lEn=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 cEn{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 y4e{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 qY=null,uEn=()=>typeof window>"u"?new y4e:(qY||(qY=new y4e),qY),b4e=iy.define(),dEn=200,fEn=[];function pEn(e){var{value:t,selection:n,onChange:r,onStatistics:s,onCreateEditor:a,onUpdate:i,extensions:l=fEn,autoFocus:c,theme:u="light",height:d=null,minHeight:f=null,maxHeight:p=null,width:h=null,minWidth:m=null,maxWidth:g=null,placeholder:v="",editable:b=!0,readOnly:S=!1,indentWithTab:w=!0,basicSetup:O=!0,root:_,initialState:C}=e,[E,T]=y.useState(),[N,I]=y.useState(),[R,$]=y.useState(),B=y.useState(()=>({current:null}))[0],M=y.useState(()=>({current:null}))[0],F=It.theme({"&":{height:d,minHeight:f,maxHeight:p,width:h,minWidth:m,maxWidth:g},"& .cm-scroller":{height:"100% !important"}}),V=It.updateListener.of(U=>{if(U.docChanged&&typeof r=="function"&&!U.transactions.some(q=>q.annotation(b4e))){B.current?B.current.reset():(B.current=new cEn(()=>{if(M.current){var q=M.current;M.current=null,q()}B.current=null},dEn),uEn().add(B.current));var D=U.state.doc,G=D.toString();r(G,U)}s&&s(lEn(U))}),L=oEn({theme:u,editable:b,readOnly:S,placeholder:v,indentWithTab:w,basicSetup:O}),z=[V,F,...L];return i&&typeof i=="function"&&z.push(It.updateListener.of(i)),z=z.concat(l),y.useLayoutEffect(()=>{if(E&&!R){var U={doc:t,selection:n,extensions:z},D=C?as.fromJSON(C.json,U,C.fields):as.create(U);if($(D),!N){var G=new It({state:D,parent:E,root:_});I(G),a&&a(G,D)}}return()=>{N&&($(void 0),I(void 0))}},[E,R]),y.useEffect(()=>{e.container&&T(e.container)},[e.container]),y.useEffect(()=>()=>{N&&(N.destroy(),I(void 0)),B.current&&(B.current.cancel(),B.current=null)},[N]),y.useEffect(()=>{c&&N&&N.focus()},[c,N]),y.useEffect(()=>{N&&N.dispatch({effects:fr.reconfigure.of(z)})},[u,l,d,f,p,h,m,g,v,b,S,w,O,r,i]),y.useEffect(()=>{if(t!==void 0){var U=N?N.state.doc.toString():"";if(N&&t!==U){var D=B.current&&!B.current.isDone,G=()=>{N&&t!==N.state.doc.toString()&&N.dispatch({changes:{from:0,to:N.state.doc.toString().length,insert:t||""},annotations:[b4e.of(!0)]})};D?M.current=G:G()}}},[t,N]),{state:R,setState:$,view:N,setView:I,container:E,setContainer:T}}var hEn=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],ku=y.forwardRef((e,t)=>{var{className:n,value:r="",selection:s,extensions:a=[],onChange:i,onStatistics:l,onCreateEditor:c,onUpdate:u,autoFocus:d,theme:f="light",height:p,minHeight:h,maxHeight:m,width:g,minWidth:v,maxWidth:b,basicSetup:S,placeholder:w,indentWithTab:O,editable:_,readOnly:C,root:E,initialState:T}=e,N=Nft(e,hEn),I=y.useRef(null),{state:R,view:$,container:B,setContainer:M}=pEn({root:E,value:r,autoFocus:d,theme:f,height:p,minHeight:h,maxHeight:m,width:g,minWidth:v,maxWidth:b,basicSetup:S,placeholder:w,indentWithTab:O,editable:_,readOnly:C,selection:s,onChange:i,onStatistics:l,onCreateEditor:c,onUpdate:u,extensions:a,initialState:T});y.useImperativeHandle(t,()=>({editor:I.current,state:R,view:$}),[I,B,R,$]);var F=y.useCallback(L=>{I.current=L,M(L)},[M]);if(typeof r!="string")throw new Error("value must be typeof string but got "+typeof r);var V=typeof f=="string"?"cm-theme-"+f:"cm-theme";return o.jsx("div",nO({ref:F,className:""+V+(n?" "+n:"")},N))});ku.displayName="CodeMirror";const mEn=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),kpt=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();var gEn={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 vEn=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,...gEn,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:kpt("lucide",s),...l},[...i.map(([u,d])=>y.createElement(u,d)),...Array.isArray(a)?a:[a]]));const gn=(e,t)=>{const n=y.forwardRef(({className:r,...s},a)=>y.createElement(vEn,{ref:a,iconNode:t,className:kpt(`lucide-${mEn(e)}`,r),...s}));return n.displayName=`${e}`,n};const yEn=[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]],Vz=gn("AlignJustify",yEn);const bEn=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],$P=gn("AlignLeft",bEn);const xEn=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],RU=gn("ArrowDown",xEn);const wEn=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],PU=gn("ArrowLeft",wEn);const SEn=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],MP=gn("ArrowRight",SEn);const kEn=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],$U=gn("ArrowUp",kEn);const OEn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]],Opt=gn("Ban",OEn);const _En=[["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"}]],ew=gn("Braces",_En);const CEn=[["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"}]],EEn=gn("Brain",CEn);const jEn=[["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"}]],x4e=gn("Calendar",jEn);const TEn=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],hx=gn("Check",TEn);const NEn=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Tbe=gn("ChevronDown",NEn);const IEn=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],AEn=gn("ChevronLeft",IEn);const REn=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Bj=gn("ChevronRight",REn);const PEn=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],$En=gn("ChevronUp",PEn);const MEn=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],Nbe=gn("ChevronsDownUp",MEn);const DEn=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],LEn=gn("ChevronsDown",DEn);const FEn=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],zEn=gn("ChevronsLeft",FEn);const BEn=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],_pt=gn("ChevronsRight",BEn);const UEn=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],nD=gn("ChevronsUpDown",UEn);const qEn=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],VEn=gn("ChevronsUp",qEn);const HEn=[["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"}]],ZEn=gn("CircleGauge",HEn);const WEn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]],Cpt=gn("CircleSlash",WEn);const QEn=[["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"}]],GEn=gn("CircleX",QEn);const YEn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],XEn=gn("Circle",YEn);const KEn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],JEn=gn("Clock",KEn);const ejn=[["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"}]],tjn=gn("Component",ejn);const njn=[["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"}]],Ept=gn("Copy",njn);const rjn=[["polyline",{points:"15 10 20 15 15 20",key:"1q7qjw"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],sjn=gn("CornerDownRight",rjn);const ajn=[["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"}]],ijn=gn("Download",ajn);const ojn=[["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"}]],ljn=gn("EllipsisVertical",ojn);const cjn=[["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"}]],ujn=gn("EqualNot",cjn);const djn=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],fjn=gn("Equal",djn);const pjn=[["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"}]],hjn=gn("Expand",pjn);const mjn=[["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"}]],Ibe=gn("ExternalLink",mjn);const gjn=[["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"}]],vjn=gn("Eye",gjn);const yjn=[["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"}]],Ade=gn("FileInput",yjn);const bjn=[["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"}]],Rde=gn("FileOutput",bjn);const xjn=[["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"}]],wjn=gn("FileText",xjn);const Sjn=[["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"}]],kjn=gn("File",Sjn);const Ojn=[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]],_jn=gn("Filter",Ojn);const Cjn=[["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"}]],Ejn=gn("FoldVertical",Cjn);const jjn=[["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"}]],Tjn=gn("Folder",jjn);const Njn=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ijn=gn("Gauge",Njn);const Ajn=[["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"}]],Abe=gn("Hash",Ajn);const Rjn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],jpt=gn("Info",Rjn);const Pjn=[["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"}]],$jn=gn("Keyboard",Pjn);const Mjn=[["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"}]],Djn=gn("Lightbulb",Mjn);const Ljn=[["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"}]],Tpt=gn("Link2",Ljn);const Fjn=[["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"}]],zjn=gn("ListFilterPlus",Fjn);const Bjn=[["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"}]],Ujn=gn("ListTree",Bjn);const qjn=[["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"}]],Vjn=gn("ListX",qjn);const Hjn=[["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"}]],Rbe=gn("List",Hjn);const Zjn=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Wjn=gn("LoaderCircle",Zjn);const Qjn=[["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"}]],Gjn=gn("Lock",Qjn);const Yjn=[["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"}]],Xjn=gn("LogIn",Yjn);const Kjn=[["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"}]],Jjn=gn("Logs",Kjn);const eTn=[["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"}]],tTn=gn("Menu",eTn);const nTn=[["path",{d:"M5 12h14",key:"1ays0h"}]],rTn=gn("Minus",nTn);const sTn=[["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"}]],aTn=gn("OctagonAlert",sTn);const iTn=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],oTn=gn("PanelRight",iTn);const lTn=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Pbe=gn("Plus",lTn);const cTn=[["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"}]],Npt=gn("Save",cTn);const uTn=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],Uj=gn("Search",uTn);const dTn=[["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"}]],fTn=gn("ShieldX",dTn);const pTn=[["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"}]],hTn=gn("TextSearch",pTn);const mTn=[["path",{d:"M17 6.1H3",key:"wptmhv"}],["path",{d:"M21 12.1H3",key:"1j38uz"}],["path",{d:"M15.1 18H3",key:"1nb16a"}]],gTn=gn("Text",mTn);const vTn=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]],$be=gn("ToggleLeft",vTn);const yTn=[["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"}]],Ipt=gn("Trash2",yTn);const bTn=[["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"}]],xTn=gn("TrendingDown",bTn);const wTn=[["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"}]],STn=gn("TrendingUp",wTn);const kTn=[["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"}]],MU=gn("TriangleAlert",kTn);const OTn=[["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"}]],Mbe=gn("Type",OTn);const _Tn=[["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"}]],CTn=gn("UnfoldVertical",_Tn);const ETn=[["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"}]],jTn=gn("WandSparkles",ETn);const TTn=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],rf=gn("X",TTn);function NTn(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 ITn=e=>{switch(e){case"success":return PTn;case"info":return MTn;case"warning":return $Tn;case"error":return DTn;default:return null}},ATn=Array(12).fill(0),RTn=({visible:e,className:t})=>De.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},De.createElement("div",{className:"sonner-spinner"},ATn.map((n,r)=>De.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),PTn=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"})),$Tn=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"})),MTn=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"})),DTn=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"})),LTn=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"})),FTn=()=>{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 Pde=1;class zTn{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:Pde++,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(UTn(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||Pde++;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 Td=new zTn,BTn=(e,t)=>{const n=t?.id||Pde++;return Td.addToast({title:e,...t,id:n}),n},UTn=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",qTn=BTn,VTn=()=>Td.toasts,HTn=()=>Td.getActiveToasts(),yu=Object.assign(qTn,{success:Td.success,info:Td.info,warning:Td.warning,error:Td.error,custom:Td.custom,message:Td.message,promise:Td.promise,dismiss:Td.dismiss,loading:Td.loading},{getHistory:VTn,getToasts:HTn});NTn("[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 cL(e){return e.label!==void 0}const ZTn=3,WTn="24px",QTn="16px",w4e=4e3,GTn=356,YTn=14,XTn=45,KTn=200;function Fg(...e){return e.filter(Boolean).join(" ")}function JTn(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const eNn=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:S,expanded:w,removeToast:O,defaultRichColors:_,closeButton:C,style:E,cancelButtonStyle:T,actionButtonStyle:N,className:I="",descriptionClassName:R="",duration:$,position:B,gap:M,expandByDefault:F,classNames:V,icons:L,closeButtonAriaLabel:z="Close toast"}=e,[U,D]=De.useState(null),[G,q]=De.useState(null),[P,H]=De.useState(!1),[W,X]=De.useState(!1),[ae,ee]=De.useState(!1),[J,ie]=De.useState(!1),[ce,Y]=De.useState(!1),[ne,ue]=De.useState(0),[pe,re]=De.useState(0),he=De.useRef(f.duration||$||w4e),xe=De.useRef(null),be=De.useRef(null),Ie=b===0,ke=b+1<=g,Te=f.type,Le=f.dismissible!==!1,le=f.className||"",se=f.descriptionClassName||"",te=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||$||w4e,[f.duration,$]),Ne=De.useRef(0),Re=De.useRef(0),Ge=De.useRef(0),He=De.useRef(null),[Oe,_e]=B.split("-"),Ee=De.useMemo(()=>v.reduce((bt,At,rn)=>rn>=te?bt:bt+At.height,0),[v,te]),je=FTn(),$e=f.invert||d,Fe=Te==="loading";Re.current=De.useMemo(()=>te*M+Ee,[te,Ee]),De.useEffect(()=>{he.current=ye},[ye]),De.useEffect(()=>{H(!0)},[]),De.useEffect(()=>{const bt=be.current;if(bt){const At=bt.getBoundingClientRect().height;return re(At),m(rn=>[{toastId:f.id,height:At,position:f.position},...rn]),()=>m(rn=>rn.filter(We=>We.toastId!==f.id))}},[m,f.id]),De.useLayoutEffect(()=>{if(!P)return;const bt=be.current,At=bt.style.height;bt.style.height="auto";const rn=bt.getBoundingClientRect().height;bt.style.height=At,re(rn),m(We=>We.find(ct=>ct.toastId===f.id)?We.map(ct=>ct.toastId===f.id?{...ct,height:rn}:ct):[{toastId:f.id,height:rn,position:f.position},...We])},[P,f.title,f.description,m,f.id,f.jsx,f.action,f.cancel]);const Ke=De.useCallback(()=>{X(!0),ue(Re.current),m(bt=>bt.filter(At=>At.toastId!==f.id)),setTimeout(()=>{O(f)},KTn)},[f,O,m,Re]);De.useEffect(()=>{if(f.promise&&Te==="loading"||f.duration===1/0||f.type==="loading")return;let bt;return w||h||je?(()=>{if(Ge.current<Ne.current){const We=new Date().getTime()-Ne.current;he.current=he.current-We}Ge.current=new Date().getTime()})():he.current!==1/0&&(Ne.current=new Date().getTime(),bt=setTimeout(()=>{f.onAutoClose==null||f.onAutoClose.call(f,f),Ke()},he.current)),()=>clearTimeout(bt)},[w,h,f,Te,je,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 At;return De.createElement("div",{className:Fg(V?.loader,f==null||(At=f.classNames)==null?void 0:At.loader,"sonner-loader"),"data-visible":Te==="loading"},L.loading)}return De.createElement(RTn,{className:Fg(V?.loader,f==null||(bt=f.classNames)==null?void 0:bt.loader),visible:Te==="loading"})}const Pt=f.icon||L?.[Te]||ITn(Te);var _t,an;return De.createElement("li",{tabIndex:0,ref:be,className:Fg(I,le,V?.toast,f==null||(t=f.classNames)==null?void 0:t.toast,V?.default,V?.[Te],f==null||(n=f.classNames)==null?void 0:n[Te]),"data-sonner-toast":"","data-rich-colors":(_t=f.richColors)!=null?_t:_,"data-styled":!(f.jsx||f.unstyled||p),"data-mounted":P,"data-promise":!!f.promise,"data-swiped":ce,"data-removed":W,"data-visible":ke,"data-y-position":Oe,"data-x-position":_e,"data-index":b,"data-front":Ie,"data-swiping":ae,"data-dismissible":Le,"data-type":Te,"data-invert":$e,"data-swipe-out":J,"data-swipe-direction":G,"data-expanded":!!(w||F&&P),"data-testid":f.testId,style:{"--index":b,"--toasts-before":b,"--z-index":S.length-b,"--offset":`${W?ne:Re.current}px`,"--initial-height":F?"auto":`${pe}px`,...E,...f.style},onDragEnd:()=>{ee(!1),D(null),He.current=null},onPointerDown:bt=>{bt.button!==2&&(Fe||!Le||(xe.current=new Date,ue(Re.current),bt.target.setPointerCapture(bt.pointerId),bt.target.tagName!=="BUTTON"&&(ee(!0),He.current={x:bt.clientX,y:bt.clientY})))},onPointerUp:()=>{var bt,At,rn;if(J||!Le)return;He.current=null;const We=Number(((bt=be.current)==null?void 0:bt.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),at=Number(((At=be.current)==null?void 0:At.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ct=new Date().getTime()-((rn=xe.current)==null?void 0:rn.getTime()),ln=U==="x"?We:at,Jt=Math.abs(ln)/ct;if(Math.abs(ln)>=XTn||Jt>.11){ue(Re.current),f.onDismiss==null||f.onDismiss.call(f,f),q(U==="x"?We>0?"right":"left":at>0?"down":"up"),Ke(),ie(!0);return}else{var Ce,Me;(Ce=be.current)==null||Ce.style.setProperty("--swipe-amount-x","0px"),(Me=be.current)==null||Me.style.setProperty("--swipe-amount-y","0px")}Y(!1),ee(!1),D(null)},onPointerMove:bt=>{var At,rn,We;if(!He.current||!Le||((At=window.getSelection())==null?void 0:At.toString().length)>0)return;const ct=bt.clientY-He.current.y,ln=bt.clientX-He.current.x;var Jt;const Ce=(Jt=e.swipeDirections)!=null?Jt:JTn(B);!U&&(Math.abs(ln)>1||Math.abs(ct)>1)&&D(Math.abs(ln)>Math.abs(ct)?"x":"y");let Me={x:0,y:0};const Ve=Xe=>1/(1.5+Math.abs(Xe)/20);if(U==="y"){if(Ce.includes("top")||Ce.includes("bottom"))if(Ce.includes("top")&&ct<0||Ce.includes("bottom")&&ct>0)Me.y=ct;else{const Xe=ct*Ve(ct);Me.y=Math.abs(Xe)<Math.abs(ct)?Xe:ct}}else if(U==="x"&&(Ce.includes("left")||Ce.includes("right")))if(Ce.includes("left")&&ln<0||Ce.includes("right")&&ln>0)Me.x=ln;else{const Xe=ln*Ve(ln);Me.x=Math.abs(Xe)<Math.abs(ln)?Xe:ln}(Math.abs(Me.x)>0||Math.abs(Me.y)>0)&&Y(!0),(rn=be.current)==null||rn.style.setProperty("--swipe-amount-x",`${Me.x}px`),(We=be.current)==null||We.style.setProperty("--swipe-amount-y",`${Me.y}px`)}},me&&!f.jsx&&Te!=="loading"?De.createElement("button",{"aria-label":z,"data-disabled":Fe,"data-close-button":!0,onClick:Fe||!Le?()=>{}:()=>{Ke(),f.onDismiss==null||f.onDismiss.call(f,f)},className:Fg(V?.closeButton,f==null||(r=f.classNames)==null?void 0:r.closeButton)},(an=L?.close)!=null?an:LTn):null,(Te||f.icon||f.promise)&&f.icon!==null&&(L?.[Te]!==null||f.icon)?De.createElement("div",{"data-icon":"",className:Fg(V?.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"?Pt:null):null,De.createElement("div",{"data-content":"",className:Fg(V?.content,f==null||(a=f.classNames)==null?void 0:a.content)},De.createElement("div",{"data-title":"",className:Fg(V?.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:Fg(R,se,V?.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&&cL(f.cancel)?De.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||T,onClick:bt=>{cL(f.cancel)&&Le&&(f.cancel.onClick==null||f.cancel.onClick.call(f.cancel,bt),Ke())},className:Fg(V?.cancelButton,f==null||(c=f.classNames)==null?void 0:c.cancelButton)},f.cancel.label):null,De.isValidElement(f.action)?f.action:f.action&&cL(f.action)?De.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||N,onClick:bt=>{cL(f.action)&&(f.action.onClick==null||f.action.onClick.call(f.action,bt),!bt.defaultPrevented&&Ke())},className:Fg(V?.actionButton,f==null||(u=f.classNames)==null?void 0:u.actionButton)},f.action.label):null)};function S4e(){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 tNn(e,t){const n={};return[e,t].forEach((r,s)=>{const a=s===1,i=a?"--mobile-offset":"--offset",l=a?QTn:WTn;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 nNn=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=ZTn,toastOptions:b,dir:S=S4e(),gap:w=YTn,icons:O,containerAriaLabel:_="Notifications"}=t,[C,E]=De.useState([]),T=De.useMemo(()=>r?C.filter(P=>P.toasterId===r):C.filter(P=>!P.toasterId),[C,r]),N=De.useMemo(()=>Array.from(new Set([a].concat(T.filter(P=>P.position).map(P=>P.position)))),[T,a]),[I,R]=De.useState([]),[$,B]=De.useState(!1),[M,F]=De.useState(!1),[V,L]=De.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),z=De.useRef(null),U=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),D=De.useRef(null),G=De.useRef(!1),q=De.useCallback(P=>{E(H=>{var W;return(W=H.find(X=>X.id===P.id))!=null&&W.delete||Td.dismiss(P.id),H.filter(({id:X})=>X!==P.id)})},[]);return De.useEffect(()=>Td.subscribe(P=>{if(P.dismiss){requestAnimationFrame(()=>{E(H=>H.map(W=>W.id===P.id?{...W,delete:!0}:W))});return}setTimeout(()=>{pve.flushSync(()=>{E(H=>{const W=H.findIndex(X=>X.id===P.id);return W!==-1?[...H.slice(0,W),{...H[W],...P},...H.slice(W+1)]:[P,...H]})})})}),[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 P=window.matchMedia("(prefers-color-scheme: dark)");try{P.addEventListener("change",({matches:H})=>{L(H?"dark":"light")})}catch{P.addListener(({matches:W})=>{try{L(W?"dark":"light")}catch(X){console.error(X)}})}},[p]),De.useEffect(()=>{C.length<=1&&B(!1)},[C]),De.useEffect(()=>{const P=H=>{var W;if(i.every(ee=>H[ee]||H.code===ee)){var ae;B(!0),(ae=z.current)==null||ae.focus()}H.code==="Escape"&&(document.activeElement===z.current||(W=z.current)!=null&&W.contains(document.activeElement))&&B(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[i]),De.useEffect(()=>{if(z.current)return()=>{D.current&&(D.current.focus({preventScroll:!0}),D.current=null,G.current=!1)}},[z.current]),De.createElement("section",{ref:n,"aria-label":`${_} ${U}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},N.map((P,H)=>{var W;const[X,ae]=P.split("-");return T.length?De.createElement("ol",{key:P,dir:S==="auto"?S4e():S,tabIndex:-1,ref:z,className:u,"data-sonner-toaster":!0,"data-sonner-theme":V,"data-y-position":X,"data-x-position":ae,style:{"--front-toast-height":`${((W=I[0])==null?void 0:W.height)||0}px`,"--width":`${GTn}px`,"--gap":`${w}px`,...g,...tNn(d,f)},onBlur:ee=>{G.current&&!ee.currentTarget.contains(ee.relatedTarget)&&(G.current=!1,D.current&&(D.current.focus({preventScroll:!0}),D.current=null))},onFocus:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||G.current||(G.current=!0,D.current=ee.relatedTarget)},onMouseEnter:()=>B(!0),onMouseMove:()=>B(!0),onMouseLeave:()=>{M||B(!1)},onDragEnd:()=>B(!1),onPointerDown:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||F(!0)},onPointerUp:()=>F(!1)},T.filter(ee=>!ee.position&&H===0||ee.position===P).map((ee,J)=>{var ie,ce;return De.createElement(eNn,{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:(ce=b?.closeButton)!=null?ce:c,interacting:M,position:P,style:b?.style,unstyled:b?.unstyled,classNames:b?.classNames,cancelButtonStyle:b?.cancelButtonStyle,actionButtonStyle:b?.actionButtonStyle,closeButtonAriaLabel:b?.closeButtonAriaLabel,removeToast:q,toasts:T.filter(Y=>Y.position==ee.position),heights:I.filter(Y=>Y.position==ee.position),setHeights:R,expandByDefault:l,gap:w,expanded:$,swipeDirections:t.swipeDirections})})):null}))}),Dbe=({className:e,toastOptions:t,...n})=>o.jsx(nNn,{...n,closeButton:!0,richColors:!0,className:K("mastra-toaster",e),toastOptions:{duration:5e3,...t}}),DU=(e,t)=>Array.isArray(e)?e.map(t):t(e),Be=(e,t={})=>{if(Array.isArray(e))return e.map(n=>yu(n,t));if(De.isValidElement(e)||typeof e=="string")return yu(e,t);throw new Error("Invalid message type")};Be.success=(e,t={})=>DU(e,n=>yu.success(n,t));Be.error=(e,t={})=>DU(e,n=>yu.error(n,t));Be.warning=(e,t={})=>DU(e,n=>yu.warning(n,t));Be.info=(e,t={})=>DU(e,n=>yu.info(n,t));Be.custom=(e,t={})=>yu(e,t);Be.dismiss=e=>yu.dismiss(e);Be.promise=({myPromise:e,loadingMessage:t,successMessage:n,errorMessage:r,onSuccess:s,onError:a,options:i={}})=>yu.promise(e,{loading:t??"Loading...",success:l=>(s?.(l),n),error:l=>(a?.(l),r||(l instanceof Error?l.message:"Error...")),...i});function ag({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 Ia({content:e,copyMessage:t,tooltip:n="Copy to clipboard",size:r="sm",className:s}){const[a,i]=y.useState(!1),{handleCopy:l}=ag({text:e,copyMessage:t}),c=()=>{l(),i(!0),setTimeout(()=>i(!1),2e3)};return o.jsxs(Yn,{children:[o.jsx(Hn,{asChild:!0,children:o.jsx(fe,{onClick:c,type:"button",size:r,className:s,"aria-label":a?"Copied!":n,children:a?o.jsx(hx,{}):o.jsx(Ept,{})})}),o.jsx(Zn,{children:a?"Copied!":n})]})}const rNn="mastra-theme",sNn="mastra-playground-store",$de=e=>e==="dark"||e==="light"||e==="system",aNn=e=>{try{const t=e.getItem(sNn);if(!t)return;const r=JSON.parse(t)?.state?.theme;return $de(r)?r:void 0}catch{return}},iNn=(e=rNn)=>({get(){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if($de(t))return t;const n=aNn(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}$de(r.newValue)&&t(r.newValue)}};return window.addEventListener("storage",n),()=>window.removeEventListener("storage",n)}}),Apt=y.createContext(null),Rpt="(prefers-color-scheme: dark)",oNn=typeof window>"u"?y.useEffect:y.useLayoutEffect,Ppt=()=>typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia(Rpt).matches?"dark":"light",$pt=e=>{if(typeof window>"u"||typeof window.matchMedia!="function")return()=>{};const t=window.matchMedia(Rpt);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},lNn=(e,t)=>{e.classList.remove(t==="dark"?"light":"dark"),e.classList.add(t)},Mpt=({children:e,defaultTheme:t="system",storageKey:n,target:r})=>{const s=y.useMemo(()=>iNn(n),[n]),a=y.useRef(null),[i,l]=y.useState(()=>s.get()??t),c=y.useSyncExternalStore($pt,Ppt,()=>"dark");y.useEffect(()=>s.subscribe(f=>l(f??t)),[s,t]);const u=i==="system"?c:i;oNn(()=>{const f=r??(typeof window>"u"?null:window.document.documentElement);a.current&&a.current!==f&&a.current.classList.remove("dark","light"),f&&lNn(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(Apt.Provider,{value:d,children:e})},cNn=()=>{},cN=()=>{const e=y.useContext(Apt),t=y.useSyncExternalStore($pt,Ppt,()=>"dark");return y.useMemo(()=>e??{theme:"system",resolvedTheme:t,systemTheme:t,setTheme:cNn},[e,t])};function uNn(e){return new Kk(Wye.define(e))}const Dpt=[Tm.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return ho(()=>Promise.resolve().then(()=>sL),[],import.meta.url).then(e=>e.javascript())}}),Tm.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return ho(()=>Promise.resolve().then(()=>Gwn),void 0,import.meta.url).then(e=>e.json())}}),Tm.of({name:"JSX",extensions:["jsx"],load(){return ho(()=>Promise.resolve().then(()=>sL),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),Tm.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return ho(()=>Promise.resolve().then(()=>qOn),void 0,import.meta.url).then(e=>e.markdown())}}),Tm.of({name:"TSX",extensions:["tsx"],load(){return ho(()=>Promise.resolve().then(()=>sL),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Tm.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return ho(()=>Promise.resolve().then(()=>sL),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),Tm.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return ho(()=>import("./shell-CjFT_Tl9.js"),[],import.meta.url).then(e=>uNn(e.shell))}})];function dNn(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 fNn(e){const t=dNn(e);return mdt({override:[pNn(t)],defaultKeymap:!0,closeOnBlur:!0,icons:!1})}function pNn(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 hNn=/\{\{([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)\}\}/g,mNn=_n.mark({class:"cm-variable-highlight"}),k4e=new Tut({regexp:hNn,decoration:()=>mNn}),gNn=ro.fromClass(class{decorations;constructor(e){this.decorations=k4e.createDeco(e)}update(e){this.decorations=k4e.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}),vNn=gNn;function yNn(){const e=iN({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=It.theme({".cm-editor":{backgroundColor:"transparent"},".cm-content":{color:"var(--neutral6)",caretColor:"var(--neutral6)"},".cm-lineNumbers .cm-gutterElement":{color:"var(--neutral2)"},".cm-activeLineGutter":{color:"var(--neutral3)"},".cm-cursor":{borderLeftColor:"var(--neutral6)"},".cm-selectionBackground, .cm-content ::selection":{backgroundColor:"color-mix(in srgb, var(--accent3) 22%, transparent)"},".cm-tooltip-autocomplete":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",borderRadius:"6px",boxShadow:"0 8px 16px rgba(0, 0, 0, 0.2)"},".cm-tooltip-autocomplete > ul":{fontFamily:"var(--font-mono)"},".cm-completionLabel":{color:"var(--neutral6)"},".cm-completionDetail":{color:"var(--neutral3)",fontSize:"0.7rem",marginLeft:"auto",paddingLeft:"12px"},".cm-completionInfo":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",color:"var(--neutral3)",padding:"8px 12px"},".cm-completionIcon":{display:"none"},"ul.cm-completionList li[aria-selected]":{backgroundColor:"var(--surface4)",color:"var(--neutral6)"},".cm-line .cm-variable-highlight":{color:"var(--accent6) !important",fontWeight:"500"}});return[e,t]}function bNn(){const e=It.theme({"&":{backgroundColor:"transparent",color:"var(--neutral6)",fontSize:"0.8rem"},"&.cm-editor .cm-scroller":{fontFamily:"var(--font-mono)"},".cm-gutters":{backgroundColor:"transparent",color:"var(--neutral2)",borderRight:"none"},".cm-content":{color:"var(--neutral6)",caretColor:"var(--neutral6)"},".cm-activeLine":{backgroundColor:"transparent"},".cm-lineNumbers .cm-gutterElement":{color:"var(--neutral2)"},".cm-activeLineGutter":{backgroundColor:"transparent",color:"var(--neutral3)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--neutral6)"},"&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection":{background:"color-mix(in srgb, var(--accent3) 22%, transparent) !important"},".cm-tooltip-autocomplete":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",borderRadius:"6px",boxShadow:"0 8px 16px rgba(0, 0, 0, 0.2)"},".cm-tooltip-autocomplete > ul":{fontFamily:"var(--font-mono)"},".cm-completionLabel":{color:"var(--neutral6)"},".cm-completionDetail":{color:"var(--neutral3)",fontSize:"0.7rem",marginLeft:"auto",paddingLeft:"12px"},".cm-completionInfo":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",color:"var(--neutral3)",padding:"8px 12px"},".cm-completionIcon":{display:"none"},"ul.cm-completionList li[aria-selected]":{backgroundColor:"var(--surface4)",color:"var(--neutral6)"},".cm-line .cm-variable-highlight":{color:"var(--accent6) !important",fontWeight:"500"}}),t=yg.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,m1(t)]}const mx=()=>{const e=cN().resolvedTheme==="dark";return y.useMemo(()=>e?yNn():bNn(),[e])},Gr=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=mx(),g=e?JSON.stringify(e,null,2):t??"",v=y.useMemo(()=>{const b=[];return a==="json"?b.push(up):a==="markdown"&&(b.push(xbe({base:tO,codeLanguages:Dpt})),b.push(It.lineWrapping)),i&&a==="markdown"&&b.push(vNn),c&&a==="markdown"&&b.push(fNn(c)),f===!1&&b.push(as.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(Ia,{content:g,className:"absolute top-2 right-2 z-20"}),o.jsx(ku,{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}})]})}),xNn={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 VY=null;function wNn(){return VY||(VY=(async()=>{const[{createHighlighterCore:e},{createJavaScriptRegexEngine:t}]=await Promise.all([ho(()=>import("./core-BzYMe5yj.js"),__vite__mapDeps([0,1,2]),import.meta.url),ho(()=>import("./engine-javascript-CSIo_1eZ.js"),__vite__mapDeps([3,1]),import.meta.url)]);return e({themes:[ho(()=>import("./github-light-DAi9KRSo.js"),[],import.meta.url),ho(()=>import("./github-dark-DHJKELXO.js"),[],import.meta.url)],langs:[ho(()=>import("./javascript-ySlJ1b_l.js"),[],import.meta.url),ho(()=>import("./typescript-Dj6nwHGl.js"),[],import.meta.url),ho(()=>import("./tsx-B6W0miNI.js"),[],import.meta.url),ho(()=>import("./jsx-BAng5TT0.js"),[],import.meta.url),ho(()=>import("./json-BQoSv7ci.js"),[],import.meta.url),ho(()=>import("./bash-atvbtKCR.js"),[],import.meta.url),ho(()=>import("./markdown-UIAJJxZW.js"),[],import.meta.url),ho(()=>import("./python-DhUJRlN_.js"),[],import.meta.url)],engine:t()})})()),VY}async function SNn(e,t){const n=xNn[t?.toLowerCase()];if(!n)return null;const r=await wNn(),{tokens:s}=r.codeToTokens(e,{lang:n,defaultColor:!1,themes:{light:"github-light",dark:"github-dark"}});return s}function Vr({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 pf=({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}),Lpt=({children:e,className:t,style:n})=>o.jsx(Qe,{size:"lg",className:K("text-neutral3 mt-1 shrink-0",t),style:n,children:e}),hf=({children:e,className:t})=>o.jsx(ge,{as:"p",variant:"ui-lg",className:K("text-neutral6 font-medium",t),children:e}),Ip=({children:e,className:t})=>o.jsx(ge,{as:"div",variant:"ui-sm",className:K("text-neutral3",t),children:e}),mf=({children:e,className:t})=>o.jsx("div",{className:K("flex-1 w-full",t),children:e});function Ss({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(Vr,{className:s,iconSlot:o.jsx(Qe,{size:"lg",className:"text-neutral3",children:o.jsx(fTn,{})}),titleSlot:t??a,descriptionSlot:n??i,actionSlot:r})}function Ms({title:e,description:t,className:n}){const[r,s]=y.useState(!1),a=Ze(),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(Vr,{className:n,iconSlot:o.jsx(Qe,{size:"lg",className:"text-neutral3",children:o.jsx(Xjn,{})}),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 Lbe=({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}),Fpt=({children:e})=>o.jsx(ge,{as:"h1",variant:"ui-md",className:"text-neutral6 flex items-center gap-2",children:e}),kNn=({children:e})=>o.jsx("div",{className:"ml-auto flex items-center gap-3",children:e}),Ch=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"})}),ONn={default:"[&>tbody>tr]:h-table-row",small:"[&>tbody>tr]:h-table-row-small"},_Nn=({className:e,children:t,size:n="default",style:r})=>o.jsx("table",{className:K("w-full",ONn[n],e),style:r,children:t}),CNn=({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})}),ENn=({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}),jNn=({className:e,children:t,...n})=>o.jsx("tbody",{className:K("",e),...n,children:t}),TNn=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})}),NNn=({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})}),INn=fd(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(fz,"rounded-xl",vk),filled:K(fz,"rounded-xl",vk),outline:K(Klt,"rounded-xl",vk),unstyled:Jlt},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"}}),zl=y.forwardRef(({className:e,size:t,testId:n,variant:r,error:s,...a},i)=>o.jsx("textarea",{className:K(INn({variant:r,size:t}),s&&"border-error focus-visible:border-error",e),"data-testid":n,ref:i,"aria-invalid":s,...a}));zl.displayName="Textarea";let O4e={},_4e={},C4e="";function ANn(e){if(typeof document>"u")return!1;const t=cr(e);return Gs(t).innerWidth-t.documentElement.clientWidth>0}function RNn(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const n=cr(e),r=n.documentElement,s=n.body,a=f1(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 PNn(e){const t=cr(e),n=t.documentElement,r=t.body,s=f1(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 $Nn(e){const t=cr(e),n=t.documentElement,r=t.body,s=Gs(n);let a=0,i=0,l=!1;const c=Id.create();if(nU&&(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,O4e={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},C4e=n.style.scrollBehavior,_4e={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 S=n.scrollHeight>n.clientHeight,w=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),E=Math.max(0,s.innerHeight-r.clientHeight),T=parseFloat(m.marginTop)+parseFloat(m.marginBottom),N=parseFloat(m.marginLeft)+parseFloat(m.marginRight),I=f1(n)?n:r;if(l=RNn(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"}),(S||O)&&(n.style.overflowY="scroll"),(w||_)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:T||E?`calc(100dvh - ${T+E}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,O4e),Object.assign(r.style,_4e),l||(n.scrollTop=a,n.scrollLeft=i,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=C4e)}function f(){d(),c.request(u)}u();const p=Lr(s,"resize",f);return()=>{c.cancel(),d(),typeof s.removeEventListener=="function"&&p()}}class MNn{lockCount=0;restore=null;timeoutLock=Mh.create();timeoutUnlock=Mh.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=cr(t).documentElement,s=Gs(r).getComputedStyle(r).overflowY;if(s==="hidden"||s==="clip"){this.restore=ga;return}const a=Qve||!ANn(t);this.restore=a?PNn(t):$Nn(t)}}const DNn=new MNn;function zpt(e=!0,t=null){Nt(()=>{if(e)return DNn.acquire(t)},[e,t])}function LNn(e){const{store:t,parentContext:n,actionsRef:r,isDrawer:s}=e,a=t.useState("open");zlt(t,a),BM(t);const{forceUnmount:i}=UM(a,t),l=y.useCallback(()=>{t.setOpen(!1,Ht(DM))},[t]);return y.useImperativeHandle(r,()=>({unmount:i,close:l}),[i,l]),{parentContext:n,isDrawer:s}}function FNn({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=t_(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?"intentional":{mouse:i==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(S){if(!e.context.outsidePressEnabledRef.current||"button"in S&&S.button!==0||"touches"in S&&S.touches.length!==1)return!1;const w=yi(S);if(h&&!a){const O=w;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});zpt(s&&i===!0,l),e.useContextCallback("onNestedDialogOpen",(S,w)=>{d(S),p(w)}),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??vs,v=m.trigger??vs,b=y.useMemo(()=>wo(sy,m.floating),[m.floating]);return qM(e,{activeTriggerProps:g,inactiveTriggerProps:v,popupProps:b,nestedOpenDialogCount:u,nestedOpenDrawerCount:f}),null}const Fbe=y.createContext(!1),Bpt=y.createContext(void 0);function pd(e){const t=y.useContext(Bpt);if(e===!1&&t===void 0)throw new Error(gr(27));return t}const zNn={...HM,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 zbe extends YT{constructor(t,n,r=!1){const s=new n_,a=BNn(t);a.floatingRootContext=dU(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},zNn)}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};uU(r,t,n.trigger),this.update(r)};static useStore(t,n){return cU(t,(s,a)=>new zbe(n,s,a),!0).store}}function BNn(e={}){return{...VM(),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 Upt(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",S=pd(!0),O={modal:g,disablePointerDismissal:v,nested:!!S,role:b},_=zbe.useStore(d?.store,{open:s,openProp:r,activeTriggerId:p,triggerIdProp:f,...O});XO(()=>{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"),E=_.useState("mounted"),T=_.useState("payload"),N=LNn({store:_,actionsRef:u,parentContext:S?.store.context,isDrawer:h}),I=C||E,R=y.useMemo(()=>({store:_}),[_]);return o.jsx(Fbe.Provider,{value:!1,children:o.jsxs(Bpt.Provider,{value:R,children:[I&&o.jsx(FNn,{store:_,dialogRoot:N}),typeof n=="function"?n({payload:T}):n]})})}function UNn(e){return Upt(e,"alert-dialog")}const qNn={...ff,...Bl},Bbe=y.forwardRef(function(t,n){const{render:r,className:s,style:a,forceRender:i=!1,...l}=t,{store:c}=pd(),u=c.useState("open"),d=c.useState("nested"),f=c.useState("mounted"),p=c.useState("transitionStatus");return Cn("div",t,{state:{open:u,transitionStatus:p},ref:[c.context.backdropRef,n],stateAttributesMapping:qNn,props:[{role:"presentation",hidden:!f,style:{userSelect:"none",WebkitUserSelect:"none"}},l],enabled:i||!d})}),qpt=y.createContext(void 0);function Ube(e=!1){const t=y.useContext(qpt);if(t===void 0&&!e)throw new Error(gr(16));return t}function VNn(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 hd(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:s=!0,composite:a}=e,i=y.useRef(null),l=Ube(!0),c=a??l!==void 0,{props:u}=VNn({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:s}),d=y.useCallback(()=>{const h=i.current;HY(h)&&c&&t&&u.disabled===void 0&&h.disabled&&(h.disabled=!1)},[t,u.disabled,c]);Nt(d,[d]);const f=y.useCallback((h={})=>{const{onClick:m,onMouseDown:g,onKeyUp:v,onKeyDown:b,onPointerDown:S,...w}=h;return wo({onClick(O){if(t){O.preventDefault();return}m?.(O)},onMouseDown(O){t||g?.(O)},onKeyDown(O){if(t||(oz(O),b?.(O),O.baseUIHandlerPrevented))return;const _=O.target===O.currentTarget,C=O.currentTarget,E=HY(C),T=!s&&HNn(C),N=_&&(s?E:!T),I=O.key==="Enter",R=O.key===" ",$=C.getAttribute("role"),B=$?.startsWith("menuitem")||$==="option"||$==="gridcell";if(_&&c&&R){if(O.defaultPrevented&&B)return;O.preventDefault(),T||s&&E?(C.click(),O.preventBaseUIHandler()):N&&(m?.(O),O.preventBaseUIHandler());return}N&&(!s&&(R||I)&&O.preventDefault(),!s&&I&&m?.(O))},onKeyUp(O){if(!t){if(oz(O),v?.(O),O.target===O.currentTarget&&s&&c&&HY(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}S?.(O)}},s?{type:"button"}:{role:"button"},u,w)},[t,u,c,s]),p=ht(h=>{i.current=h,d()});return{getButtonProps:f,buttonRef:p}}function HY(e){return ka(e)&&e.tagName==="BUTTON"}function HNn(e){return!!(e?.tagName==="A"&&e?.href)}const rD=y.forwardRef(function(t,n){const{render:r,className:s,style:a,disabled:i=!1,nativeButton:l=!0,...c}=t,{store:u}=pd(),d=u.useState("open"),{getButtonProps:f,buttonRef:p}=hd({disabled:i,native:l}),h={disabled:i};function m(g){d&&u.setOpen(!1,Ht(Xve,g.nativeEvent))}return Cn("button",t,{state:h,ref:[n,p],props:[{onClick:m},c,f]})}),LU=y.forwardRef(function(t,n){const{render:r,className:s,style:a,id:i,...l}=t,{store:c}=pd(),u=Ni(i);return c.useSyncedValueWithCleanup("descriptionElementId",u),Cn("p",t,{ref:n,props:[{id:u},l]})});let ZNn=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),WNn=(function(e){return e[e.open=Xu.open]="open",e[e.closed=Xu.closed]="closed",e[e.startingStyle=Xu.startingStyle]="startingStyle",e[e.endingStyle=Xu.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const Vpt=y.createContext(void 0);function qbe(){const e=y.useContext(Vpt);if(e===void 0)throw new Error(gr(26));return e}const JE="ArrowUp",ak="ArrowDown",DP="ArrowLeft",ej="ArrowRight",sD="Home",aD="End",Hpt="PageUp",Zpt="PageDown",Wpt=new Set([DP,ej]),QNn=new Set([DP,ej,sD,aD]),Qpt=new Set([JE,ak]),GNn=new Set([JE,ak,sD,aD]),Gpt=new Set([...Wpt,...Qpt]),v1=new Set([...Gpt,sD,aD]),Ypt="Shift",YNn="Control",XNn="Alt",KNn="Meta",JNn=new Set([Ypt,YNn,XNn,KNn]);function eIn(e){return ka(e)&&e.tagName==="INPUT"}function E4e(e){return!!(eIn(e)&&e.selectionStart!=null||ka(e)&&e.tagName==="TEXTAREA")}function j4e(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=T4e(e,t,"left"),u=uL(e),d=uL(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=T4e(e,t,"top"),u=uL(e),d=uL(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 T4e(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 uL(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 tIn={...ff,...Bl,nestedDialogOpen(e){return e?{[WNn.nestedDialogOpen]:""}:null}},Vbe=y.forwardRef(function(t,n){const{render:r,className:s,style:a,finalFocus:i,initialFocus:l,...c}=t,{store:u}=pd(),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"),S=u.useState("open"),w=u.useState("openMethod"),O=u.useState("titleElementId"),_=u.useState("transitionStatus"),C=u.useState("role"),E=p.useState("floatingId"),T=c.id??E;qbe(),Ul({open:S,ref:u.context.popupRef,onComplete(){S&&u.context.onOpenChangeComplete?.(!0)}});function N(F){return F==="touch"?u.context.popupRef.current:!0}const I=l===void 0?N:l,R=b>0,$=u.useStateSetter("popupElement"),M=Cn("div",t,{state:{open:S,nested:v,transitionStatus:_,nestedDialogOpen:R},props:[h,{id:T,"aria-labelledby":O??void 0,"aria-describedby":d??void 0,role:C,...sy,hidden:!g,onKeyDown(F){v1.has(F.key)&&F.stopPropagation()},style:{[ZNn.nestedDialogs]:b}},c],ref:[n,u.context.popupRef,$],stateAttributesMapping:tIn});return o.jsx(GT,{context:p,openInteractionType:w,disabled:!g,closeOnFocusOut:!f,initialFocus:I,returnFocus:i,modal:m!==!1,restoreFocus:"popup",children:M})}),iD=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}})}),FU=y.forwardRef(function(t,n){const{keepMounted:r=!1,...s}=t,{store:a}=pd(),i=a.useState("mounted"),l=a.useState("modal"),c=a.useState("open");return i||r?o.jsx(Vpt.Provider,{value:r,children:o.jsxs(FM,{ref:n,...s,children:[i&&l===!0&&o.jsx(iD,{ref:a.context.internalBackdropRef,inert:eN(!c)}),t.children]})}):null}),zU=y.forwardRef(function(t,n){const{render:r,className:s,style:a,id:i,...l}=t,{store:c}=pd(),u=Ni(i);return c.useSyncedValueWithCleanup("titleElementId",u),Cn("h2",t,{ref:n,props:[{id:u},l]})});function nIn(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 gv(e,t){const n=y.useRef(e),r=ht(t);Nt(()=>{n.current!==e&&r(n.current)},[e,r]),Nt(()=>{n.current=e},[e])}function Hbe(e,t){const n=ht((a,i)=>{(typeof e=="function"?e():e)||t(i||(Qve?"touch":""))}),{onClick:r,onPointerDown:s}=nIn(n);return y.useMemo(()=>({onClick:r,onPointerDown:s}),[r,s])}function Zbe(e){const[t,n]=y.useState(null),r=Hbe(e,n);return gv(e,s=>{s&&!e&&n(null)}),y.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}const Xpt=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=pd(!0),h=d?.store??p?.store;if(!h)throw new Error(gr(79));const m=Ni(c),g=h.useState("floatingRootContext"),v=h.useState("isOpenedByTrigger",m),b=h.useState("triggerPopupId",m),S=y.useRef(null),{registerTrigger:w,isMountedByThisTrigger:O}=zM(m,S,h,{payload:u}),{getButtonProps:_,buttonRef:C}=hd({disabled:i,native:l}),E=e_(g,{enabled:g!=null}),T=Hbe(()=>h.select("open"),R=>{h.set("openMethod",R)}),N={disabled:i,open:v},I=h.useState("triggerProps",O);return Cn("button",t,{state:N,ref:[C,n,w,S],props:[E.reference,I,T,{[sye]:"",id:m,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":b},f,_],stateAttributesMapping:XT})}),rIn=Xpt;let N4e=(function(e){return e[e.open=Xu.open]="open",e[e.closed=Xu.closed]="closed",e[e.startingStyle=Xu.startingStyle]="startingStyle",e[e.endingStyle=Xu.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const sIn={...ff,...Bl,nested(e){return e?{[N4e.nested]:""}:null},nestedDialogOpen(e){return e?{[N4e.nestedDialogOpen]:""}:null}},aIn=y.forwardRef(function(t,n){const{render:r,className:s,style:a,children:i,...l}=t,c=qbe(),{store:u}=pd(),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 Cn("div",t,{enabled:c||m,state:{open:d,nested:f,transitionStatus:p,nestedDialogOpen:v},ref:[n,g],stateAttributesMapping:sIn,props:[{role:"presentation",hidden:!m,style:{pointerEvents:d?void 0:"none"},children:i},l]})});function oD(e,t){return e&&y.isValidElement(t)?{render:t}:void 0}const iIn=UNn;function jt({open:e,onOpenChange:t,children:n}){return o.jsx(iIn,{open:e,onOpenChange:t,children:n})}const Kpt=y.forwardRef(({asChild:e,children:t,...n},r)=>o.jsx(rIn,{ref:r,...oD(e,t),...n,children:e?void 0:t}));Kpt.displayName="AlertDialogTrigger";const Jpt=FU,Wbe=y.forwardRef(({className:e,...t},n)=>o.jsx(Bbe,{ref:n,className:K("dialog-overlay-anim fixed inset-0 z-50 bg-overlay backdrop-blur-xs",e),...t}));Wbe.displayName="AlertDialogOverlay";const eht=y.forwardRef(({className:e,...t},n)=>o.jsxs(Jpt,{children:[o.jsx(Wbe,{}),o.jsx(Vbe,{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})]}));eht.displayName="AlertDialogContent";const tht=({className:e,...t})=>o.jsx("div",{className:K("flex flex-col gap-0.5 px-4 py-3 text-left",e),...t});tht.displayName="AlertDialogHeader";const nht=({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});nht.displayName="AlertDialogFooter";const rht=({className:e,...t})=>o.jsx("div",{className:K("overflow-y-auto px-4 py-3.5 max-h-[50vh]",e),...t});rht.displayName="AlertDialogBody";const sht=y.forwardRef(({className:e,...t},n)=>o.jsx(zU,{ref:n,className:K("text-ui-md font-medium",e),...t}));sht.displayName="AlertDialogTitle";const aht=y.forwardRef(({className:e,...t},n)=>o.jsx(LU,{ref:n,className:K("text-ui-sm text-neutral3",e),...t}));aht.displayName="AlertDialogDescription";const iht=y.forwardRef(({className:e,...t},n)=>o.jsx(rD,{ref:n,className:K(QM({variant:"primary",size:"lg"}),e),...t}));iht.displayName="AlertDialogAction";const oht=y.forwardRef(({className:e,...t},n)=>o.jsx(rD,{ref:n,className:K(QM({variant:"default",size:"lg"}),e),...t}));oht.displayName="AlertDialogCancel";jt.Trigger=Kpt;jt.Portal=Jpt;jt.Overlay=Wbe;jt.Content=eht;jt.Header=tht;jt.Footer=nht;jt.Body=rht;jt.Title=sht;jt.Description=aht;jt.Action=iht;jt.Cancel=oht;function Qd({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 oIn(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 I4e=(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})({}),A4e=(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 lIn={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},yE={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},cIn={disabled:!1,...yE},y1={valid(e){return e===null?null:e?{[A4e.valid]:""}:{[A4e.invalid]:""}}};function lht(e){return y.useMemo(()=>({checked(t){return e.indeterminate?{}:t?{[I4e.checked]:""}:{[I4e.unchecked]:""}},...y1}),[e.indeterminate])}const cht={invalid:void 0,name:void 0,validityData:{state:lIn,errors:[],error:"",value:"",initialValue:null},setValidityData:ga,disabled:void 0,touched:yE.touched,setTouched:ga,dirty:yE.dirty,setDirty:ga,filled:yE.filled,setFilled:ga,focused:yE.focused,setFocused:ga,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:cIn,markedDirtyRef:{current:!1},registerFieldControl:ga,validation:{getValidationProps:(e=vs)=>e,getInputValidationProps:(e=vs)=>e,inputRef:{current:null},commit:async()=>{}}},uht=y.createContext(cht);function Yh(e=!0){const t=y.useContext(uht);if(t.setValidityData===ga&&!e)throw new Error(gr(28));return t}function uN(e,t,n,r,s=!0){const{registerFieldControl:a}=Yh(),i=y.useRef(null);i.current||(i.current=Symbol()),Nt(()=>{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 uIn=y.createContext({disabled:!1});function dht(){return y.useContext(uIn)}const dIn=y.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:ga,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function dN(){return y.useContext(dIn)}const fIn=y.createContext({controlId:void 0,registerControlId:ga,labelId:void 0,setLabelId:ga,messageIds:[],setMessageIds:ga,getDescriptionProps:e=>e});function gx(){return y.useContext(fIn)}function Qbe(e,t,n,r=!0,s){const[a,i]=y.useState(),l=Ni(s?`${s}-label`:void 0),c=e??t??a;return Nt(()=>{const u=e||t||!r?void 0:pIn(n.current,l);a!==u&&i(u)}),c}function pIn(e,t){const n=hIn(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function hIn(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 mIn=y.createContext(void 0);function gIn(e=!0){const t=y.useContext(mIn);if(t===void 0&&!e)throw new Error(gr(3));return t}const fht=y.createContext(void 0);function vIn(){const e=y.useContext(fht);if(e===void 0)throw new Error(gr(14));return e}const yIn="data-parent",bIn=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:S,value:w,nativeButton:O=!1,style:_,...C}=t,{clearErrors:E}=dN(),{disabled:T,name:N,setDirty:I,setFilled:R,setFocused:$,setTouched:B,state:M,validationMode:F,validityData:V,shouldValidateOnChange:L,validation:z}=Yh(),U=dht(),{labelId:D,controlId:G,registerControlId:q,getDescriptionProps:P}=gx(),H=gIn(),W=H?.parent,X=W&&H.allValues,ae=T||U.disabled||H?.disabled||l,ee=N??p,J=w??ee,ie=Ni(),ce=Ni();let Y=G;X?Y=m?ce:`${W.id}-${J}`:u&&(Y=u);let ne={};X&&(m?ne=H.parent.getParentProps():J&&(ne=H.parent.getChildProps(J)));const{checked:ue=r,indeterminate:pe=d,onCheckedChange:re,...he}=ne,xe=H?.value,be=H?.setValue,Ie=H?.defaultValue,ke=y.useRef(null),Te=lc(()=>Symbol("checkbox-control")),Le=y.useRef(!1),{getButtonProps:le,buttonRef:se}=hd({disabled:ae,native:O}),te=H?.validation??z,[me,ye]=Qd({controlled:J&&xe&&!m?xe.includes(J):ue,default:J&&Ie&&!m?Ie.includes(J):a,name:"Checkbox",state:"checked"});Nt(()=>{q!==ga&&(Le.current=!0,q(Te.current,Y))},[Y,q,Te]),y.useEffect(()=>{const Fe=Te.current;return()=>{!Le.current||q===ga||(Le.current=!1,q(Fe,void 0))}},[q,Te]),uN(ke,ie,me,void 0,!H);const Ne=y.useRef(null),Re=Su(f,Ne,te.inputRef),Ge=Qbe(i,D,Ne,!O,Y??void 0);Nt(()=>{Ne.current&&(Ne.current.indeterminate=pe,me&&R(!0))},[me,pe,R]),gv(me,()=>{H&&!m||(E(ee),R(me),I(me!==V.initialValue),L()?te.commit(me):te.commit(me,!0))});const He=wo({checked:me,disabled:ae,form:c,name:m?void 0:ee,id:O?void 0:Y??void 0,required:b,ref:Re,style:ee?QT:Lw,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=Ht(vo,Fe.nativeEvent);if(re?.(Ke,Ye),h?.(Ke,Ye),!Ye.isCanceled&&(ye(Ke),J&&xe&&be&&!m&&!X)){const Pt=Ke?[...xe,J]:xe.filter(_t=>_t!==J);be(Pt,Ye)}},onFocus(){ke.current?.focus()}},w!==void 0?{value:(H?me&&w:w)||""}:vs,P,H?te.getValidationProps:te.getInputValidationProps),Oe=X?!!ue:me,_e=X&&pe||d;y.useEffect(()=>{if(!W||!J)return;const Fe=W.disabledStatesRef.current;return Fe.set(J,ae),()=>{Fe.delete(J)}},[W,ae,J]);const Ee=y.useMemo(()=>({...M,checked:Oe,disabled:ae,readOnly:g,required:b,indeterminate:_e}),[M,Oe,ae,g,b,_e]),je=lht(Ee),$e=Cn("span",t,{state:Ee,ref:[se,ke,n,H?.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":Ge,[yIn]:m?"":void 0,onFocus(){$(!0)},onBlur(){const Fe=Ne.current;Fe&&(B(!0),$(!1),F==="onBlur"&&te.commit(H?xe:Fe.checked))},onKeyDown(Fe){if(Fe.key!=="Enter"||(Fe.preventBaseUIHandler(),Fe.defaultPrevented))return;const Ke=Ne.current?.form??null,Ye=Fe.currentTarget,Pt=Fe.nativeEvent,_t=Fe.preventDefault,an=Pt.preventDefault;let bt=!1;Fe.preventDefault=()=>{bt=!0,_t.call(Fe)},Pt.preventDefault=()=>{bt=!0,an.call(Pt)},an.call(Pt),Gs(Ye).queueMicrotask(()=>{Fe.preventDefault=_t,Pt.preventDefault=an,bt||oIn(Ke)?.click()})},onClick(Fe){if(g||ae)return;Fe.preventDefault();const Ke=Ne.current;Ke&&Ke.dispatchEvent(new(Gs(Ke)).PointerEvent("click",{bubbles:!0,shiftKey:Fe.shiftKey,ctrlKey:Fe.ctrlKey,altKey:Fe.altKey,metaKey:Fe.metaKey}))}},P,te.getValidationProps,C,he,le],stateAttributesMapping:je});return o.jsxs(fht.Provider,{value:Ee,children:[$e,!me&&!H&&ee&&!m&&S!==void 0&&o.jsx("input",{type:"hidden",form:c,name:ee,value:S}),o.jsx("input",{...He,suppressHydrationWarning:!0})]})}),xIn=y.forwardRef(function(t,n){const{render:r,className:s,style:a,keepMounted:i=!1,...l}=t,c=vIn(),u=c.checked||c.indeterminate,{mounted:d,transitionStatus:f,setMounted:p}=gg(u),h=y.useRef(null),m={...c,transitionStatus:f};Ul({open:u,ref:h,onComplete(){u||p(!1)}});const v={...lht(c),...Bl,...y1},b=i||d,S=Cn("span",t,{ref:[n,h],state:m,stateAttributesMapping:v,props:l});return b?S:null}),Uo=y.forwardRef(({className:e,checked:t,indeterminate:n,...r},s)=>{const a=t==="indeterminate";return o.jsx(bIn,{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",ns.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(xIn,{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(wIn,{})})})});Uo.displayName="Checkbox";function wIn(){return o.jsxs(o.Fragment,{children:[o.jsx(hx,{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(rTn,{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 SIn(e){const{open:t,defaultOpen:n,onOpenChange:r,disabled:s}=e,[a,i]=Qd({controlled:t,default:n,name:"Collapsible",state:"open"}),{mounted:l,setMounted:c,transitionStatus:u}=gg(a,!0,!0),d=Ni(),[f,p]=y.useState(),h=f??d,m=ht(g=>{const v=!a,b=Ht(tg,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 pht=y.createContext(void 0);function hht(){const e=y.useContext(pht);if(e===void 0)throw new Error(gr(15));return e}let Gbe=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=ng.startingStyle]="startingStyle",e[e.endingStyle=ng.endingStyle]="endingStyle",e})({}),kIn=(function(e){return e.panelOpen="data-panel-open",e})({});const OIn={[Gbe.open]:""},_In={[Gbe.closed]:""},CIn={open(e){return e?{[kIn.panelOpen]:""}:null}},EIn={open(e){return e?OIn:_In}},mht={...EIn,...Bl},jIn=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=ht(l),p=SIn({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=Cn("div",t,{state:h,ref:n,props:d,stateAttributesMapping:mht});return o.jsx(pht.Provider,{value:m,children:g})}),TIn={...CIn,...Bl},NIn=y.forwardRef(function(t,n){const{panelId:r,open:s,handleTrigger:a,state:i,disabled:l}=hht(),{className:c,disabled:u=l,id:d,render:f,nativeButton:p=!0,style:h,...m}=t,{getButtonProps:g,buttonRef:v}=hd({disabled:u,focusableWhenDisabled:!0,native:p});return Cn("button",t,{state:i,ref:[n,v],props:[{"aria-controls":s?r:void 0,"aria-expanded":s,onClick:a},m,g],stateAttributesMapping:TIn})}),lA={height:void 0,width:void 0};function IIn(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(lA),g=y.useRef(lA),v=y.useRef(!1),b=y.useRef(l),S=y.useRef(!1),[w,O]=y.useState(!1),_=y.useRef(null),C=Su(t,f),E=qi({mounted:a,open:l}),T=lU(f,!1,!1),N=!l&&!a,I=w?"idle":d,R=l&&(b.current||S.current),$=!l&&a&&p.current==="css-animation"&&h.height===void 0&&h.width===void 0?g.current:h,B=n&&N&&p.current!=="css-animation",M=ht((U,D=!0)=>{D&&(g.current=U),m(U)}),F=ht(()=>{_.current?.(),_.current=null}),V=ht(U=>{F(),_.current=()=>{_.current=null,U()}}),L=ht(()=>{l&&a&&p.current==="css-animation"&&(S.current=!0)});Nt(()=>{!w||d==="starting"||O(!1)},[w,d]),y.useEffect(()=>()=>{L(),F()},[L,F]),Nt(()=>{const U=f.current;if(!U)return;!l&&_.current&&F();const D=AIn(U,R);if(p.current=D,l&&d==="idle"&&b.current&&D==="css-animation"){g.current=hC(U);return}if(l&&d==="starting"){const P=v.current;if(v.current=!1,D==="none"){M(hC(U)),O(!0);return}if(D==="css-transition"){const H=RIn(U);if(M(hC(U)),!P)return H;const W=cA(U,"transition-duration","0s");return V(W),O(!0),H}if(D==="css-animation"){if(M(hC(U)),!P){cA(U,"animation-name","none")();return}const H=cA(U,"animation-name","none"),W=cA(U,"animation-duration","0s");H(),V(W),O(!0);return}}if(!l&&a&&(d==="idle"||d==="starting")){if(D==="none"){M(lA,!1),c(!1);return}D==="css-animation"&&(b.current=!1,S.current=!1),M(hC(U));return}if(d!=="ending")return;if(D==="none"){c(!1);return}const G=hC(U);if(!((G.height??0)>0||(G.width??0)>0)){c(!1);return}M(G),D==="css-animation"&&cA(U,"animation-name","none")()},[a,l,F,M,c,V,R,d]),Ul({enabled:l&&a&&I==="idle",open:!0,ref:f,onComplete(){l&&M(lA,!1)}}),y.useEffect(()=>{if(l||!a||I!=="ending"||!f.current)return;const D=new AbortController;let G=-1;function q(){E.current.open||(c(!1),M(lA,!1))}return G=Id.request(()=>{D.signal.aborted||T(q,D.signal)}),()=>{Id.cancel(G),D.abort()}},[E,a,l,I,T,M,c]),Nt(()=>{const U=f.current;!U||!n||!N||U.setAttribute("hidden","until-found")},[N,n]),y.useEffect(function(){const D=f.current;if(!D)return;function G(q){v.current=!0,u(!0),i(!0,Ht(vo,q))}return Lr(D,"beforematch",G)},[i,u]);const z=s||n||a||l;return{height:$.height,props:{...B?{[Gbe.startingStyle]:""}:void 0,hidden:N,id:r},ref:C,shouldPreventOpenAnimation:R,shouldRender:z,transitionStatus:I,width:$.width}}function hC(e){return{height:e.scrollHeight,width:e.scrollWidth}}function AIn(e,t=!1){const n=Gs(e).getComputedStyle(e),r=(n.animationName.split(",").map(a=>a.trim()).some(a=>a!==""&&a!=="none")||t)&&R4e(n.animationDuration),s=R4e(n.transitionDuration);return r&&s||s?"css-transition":r?"css-animation":"none"}function R4e(e){return e.split(",").map(t=>t.trim()).some(t=>t!==""&&Number.parseFloat(t)>0)}function cA(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 RIn(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=Id.request(n);return()=>{Id.cancel(r),n()}}let P4e=(function(e){return e.collapsiblePanelHeight="--collapsible-panel-height",e.collapsiblePanelWidth="--collapsible-panel-width",e})({});const PIn=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:S}=hht(),w=s??!1,O=a??!1;Nt(()=>{if(l)return g(l),()=>{g(void 0)}},[l,g]);const{height:_,props:C,ref:E,shouldPreventOpenAnimation:T,shouldRender:N,transitionStatus:I,width:R}=IIn({externalRef:n,hiddenUntilFound:w,id:h,keepMounted:O,mounted:d,onOpenChange:f,open:p,setMounted:m,setOpen:v,transitionStatus:S}),$={...b,transitionStatus:I},B=xlt(c,$),M=Cn("div",{...t,style:void 0},{state:$,ref:E,props:[C,{style:{[P4e.collapsiblePanelHeight]:_===void 0?"auto":`${_}px`,[P4e.collapsiblePanelWidth]:R===void 0?"auto":`${R}px`}},u,B?{style:B}:void 0,T?{style:{animationName:"none"}}:void 0],stateAttributesMapping:mht});return N?M:null}),Dh=jIn,bp=De.forwardRef(({className:e,asChild:t,children:n,...r},s)=>{const a=t&&De.isValidElement(n)?{render:n}:{};return o.jsx(NIn,{ref:s,"data-slot":"collapsible-trigger",className:K("-outline-offset-2",ns.colors,YO.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})});bp.displayName="CollapsibleTrigger";const xp=De.forwardRef(({className:e,children:t,...n},r)=>o.jsx(PIn,{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})}));xp.displayName="CollapsibleContent";const ght=y.createContext(void 0),vht=y.createContext(void 0),yht=y.createContext(void 0),bht=y.createContext("");function ly(){const e=y.useContext(ght);if(!e)throw new Error(gr(22));return e}function BU(){const e=y.useContext(vht);if(!e)throw new Error(gr(23));return e}function b1(){const e=y.useContext(yht);if(!e)throw new Error(gr(24));return e}function xht(){return y.useContext(bht)}const wht=(e,t)=>Object.is(e,t);function Bv(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Sht(e,t,n){return!e||e.length===0?!1:e.some(r=>r===void 0?!1:Bv(t,r,n))}function mw(e,t,n){return!e||e.length===0?-1:e.findIndex(r=>r===void 0?!1:Bv(r,t,n))}function kht(e,t,n){return e.filter(r=>!Bv(t,r,n))}function Hz(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Ybe(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function Oht(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(Ybe(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 ou(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 Hz(e)}function $m(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?Hz(e.value):Hz(e)}function Xbe(e,t,n){function r(){return ou(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=Ybe(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 _ht(e,t,n){return e.reduce((r,s,a)=>(a>0&&r.push(", "),r.push(o.jsx(y.Fragment,{children:Xbe(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?Oht(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=>Bv(t,s,n)):Bv(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 o_(e={}){const{id:t,implicit:n=!1,controlRef:r}=e,{controlId:s,registerControlId:a}=gx(),i=Ni(t),l=n?s:void 0,c=lc(()=>Symbol("labelable-control")),u=y.useRef(!1),d=y.useRef(t!=null),f=ht(()=>{!u.current||a===ga||(u.current=!1,a(c.current,void 0))});return Nt(()=>{if(a===ga)return;let p;if(n){const h=r?.current;wr(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 $In(e,t){return(n,r)=>{if(n==null)return!1;const s=ou(n,t);return e.contains(s,r)}}function MIn(e,t,n){return(r,s)=>{if(r==null)return!1;if(!s)return!0;const a=ou(r,t),i=n!=null?ou(n,t):"";return i&&e.contains(i,s)&&i.length===s.length?!0:e.contains(a,s)}}const $4e=new Map;function DIn(e={}){const t={usage:"search",sensitivity:"base",ignorePunctuation:!0,...e},n=`${Cht(e.locale)}|${JSON.stringify(t)}`,r=$4e.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=ou(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=ou(i,c);return s.compare(u.slice(0,l.length),l)===0},endsWith(i,l,c){if(!l)return!0;const u=ou(i,c),d=l.length;return u.length>=d&&s.compare(u.slice(u.length-d),l)===0}};return $4e.set(n,a),a}function Cht(e){return Array.isArray(e)?e.map(t=>Cht(t)).join(","):e==null?"":String(e)}const LIn=DIn,Eht=Symbol("none"),dS={value:Eht,index:-1};function FIn(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:S=!1,items:w,filteredItems:O,filter:_,openOnInputClick:C=!0,autoHighlight:E=!1,keepHighlight:T=!1,highlightItemOnHover:N=!0,loopFocus:I=!0,itemToStringLabel:R,itemToStringValue:$,isItemEqualToValue:B=wht,virtualized:M=!1,inline:F=!1,fillInputOnItemPress:V=!0,modal:L=!1,limit:z=-1,autoComplete:U="list",formAutoComplete:D,locale:G,submitOnItemClick:q=!1}=e,{clearErrors:P}=dN(),{setDirty:H,validityData:W,shouldValidateOnChange:X,setFilled:ae,name:ee,disabled:J,setTouched:ie,setFocused:ce,validationMode:Y,validation:ne}=Yh(),ue=ay(),pe=o_({id:t}),re=LIn({locale:G}),[he,xe]=y.useState(!1),[be,Ie]=y.useState(null),ke=y.useRef([]),Te=y.useRef([]),Le=y.useRef(null),le=y.useRef(null),se=y.useRef(null),te=y.useRef(null),me=y.useRef(null),ye=y.useRef(!0),Ne=y.useRef(!1),Re=y.useRef(null),Ge=y.useRef(null),He=y.useRef(null),Oe=y.useRef(dS),_e=y.useRef(null),Ee=y.useRef([]),je=y.useRef([]),$e=J||m,Fe=ee??p,Ke=d==="multiple",Ye=d==="single",Pt=l!==void 0||i!==void 0,_t=w!==void 0,an=O!==void 0;let bt;E==="always"?bt="always":bt=E?"input-change":!1;const[At,rn]=Qd({controlled:s,default:Ke?r??dh:r,name:"Combobox",state:"selectedValue"}),We=y.useMemo(()=>_===null?()=>!0:_!==void 0?_:Ye&&!he?MIn(re,R,At):$In(re,R),[_,Ye,At,he,re,R]),at=lc(()=>Pt?i??"":Ye?ou(At,R):"").current,[ct,ln]=Qd({controlled:l,default:at,name:"Combobox",state:"inputValue"}),[Jt,Ce]=Qd({controlled:c,default:u,name:"Combobox",state:"open"}),Me=Ybe(w),Ve=be??(ct===""?"":String(ct).trim()),Xe=Ye?ou(At,R):"",nt=Ye&&!he&&Ve!==""&&Xe!==""&&Xe.length===Ve.length&&re.contains(Xe,Ve),wt=nt?"":Ve,Lt=_t&&an&&nt,xt=y.useMemo(()=>w?Me?w.flatMap(un=>un.items):w:dh,[w,Me]),Mt=y.useMemo(()=>{if(O&&!Lt)return O;if(!w)return dh;if(Me){const Wn=w,_s=[];let wa=0;for(const Gi of Wn){if(z>-1&&wa>=z)break;const Da=wt===""?Gi.items:Gi.items.filter(Of=>We(Of,wt,R));if(Da.length===0)continue;const cm=z>-1?z-wa:1/0,yd=Da.slice(0,cm);if(yd.length>0){const Of={...Gi,items:yd};_s.push(Of),wa+=yd.length}}return _s}if(wt==="")return z>-1?xt.slice(0,z):xt;const un=[];for(const Wn of xt){if(z>-1&&un.length>=z)break;We(Wn,wt,R)&&un.push(Wn)}return un},[O,Lt,w,Me,wt,z,We,R,xt]),Dt=y.useMemo(()=>Me?Mt.flatMap(Wn=>Wn.items):Mt,[Mt,Me]),Tt=lc(()=>new fye({id:pe,labelId:void 0,selectedValue:At,open:Jt,filter:We,query:Ve,items:w,selectionMode:d,listRef:ke,labelsRef:Te,popupRef:Le,emptyRef:me,inputRef:le,startDismissRef:se,endDismissRef:te,keyboardActiveRef:ye,chipsContainerRef:Re,clearRef:Ge,valuesRef:Ee,allValuesRef:je,selectionEventRef:He,name:Fe,form:h,disabled:$e,readOnly:g,required:v,grid:S,isGrouped:Me,virtualized:M,openOnInputClick:C,itemToStringLabel:R,isItemEqualToValue:B,modal:L,autoHighlight:bt,submitOnItemClick:q,hasInputValue:Pt,mounted:!1,forceMounted:!1,transitionStatus:"idle",inline:F,activeIndex:null,selectedIndex:null,popupProps:{},inputProps:{},triggerProps:{},itemProps:vs,positionerElement:null,listElement:null,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:d==="none",onOpenChangeComplete:n||ga,setOpen:ga,setInputValue:ga,setSelectedValue:ga,setIndices:ga,onItemHighlighted:ga,handleSelection:ga,forceMount:ga,requestSubmit:ga})).current,fn=d==="none"?ct:At,Nr=y.useMemo(()=>d==="none"?fn:Array.isArray(At)?At.map(un=>$m(un,$)):$m(At,$),[fn,$,d,At]),_r=ht(f),ss=ht(n),Pr=pt(Tt,on.activeIndex),Os=pt(Tt,on.selectedIndex),lr=pt(Tt,on.positionerElement),cs=pt(Tt,on.listElement),Ya=pt(Tt,on.triggerElement),uo=pt(Tt,on.inputElement),Ks=pt(Tt,on.inputGroupElement),fa=pt(Tt,on.inline),Ol=pt(Tt,on.inputInsidePopup),kc=pt(Tt,on.inputOwnsFormValue),Hl=qi(Ya),{mounted:Lp,setMounted:am,transitionStatus:Hr}=gg(Jt),{openMethod:fo,triggerProps:Oc}=Zbe(Jt),Xc=ht(()=>Nr);uN(Ol?Hl:le,pe,fn,Xc);const us=ht(()=>{w?Te.current=Dt.map(un=>ou(un,R)):Tt.set("forceMounted",!0)}),Wo=y.useRef(At);Nt(()=>{At!==Wo.current&&us()},[us,At]);const _l=ht(un=>{Tt.update(un);const Wn=un.type||"none";if(un.activeIndex!==void 0)if(un.activeIndex===null)Oe.current!==dS&&(Oe.current=dS,_r(void 0,qS(Wn,void 0,{index:-1})));else{const _s=Ee.current[un.activeIndex];Oe.current={value:_s,index:un.activeIndex},_r(_s,qS(Wn,void 0,{index:un.activeIndex}))}}),Zl=ht((un,Wn)=>{if(Ne.current=Wn.reason===ib,e.onInputValueChange?.(un,Wn),!Wn.isCanceled){if(Wn.reason===tk){const _s=Wn.event,wa=_s.inputType;if(_s.type==="compositionend"||wa!=null&&wa!==""&&wa!=="insertReplacementText"){const Da=un.trim()!=="";Da&&xe(!0),_e.current={hasQuery:Da},Da&&bt&&Tt.state.activeIndex==null&&Tt.set("activeIndex",0)}}ln(un)}}),im=ht((un,Wn)=>{if(Jt!==un&&(Wn.reason==="escape-key"&&_t&&Dt.length===0&&!Tt.state.emptyRef.current&&Wn.allowPropagation(),e.onOpenChange?.(un,Wn),!Wn.isCanceled&&(un&&Ke&&Ol&&!fa&&be!==null&&(xe(!1),Ie(null),ct!==""&&Zl("",Ht(ib,Wn.event))),!un&&he&&(Ye?(fa||Ie(Ve),Ve===""&&xe(!1)):Ke&&(fa||Ie(Ve),Ol&&_l({activeIndex:null}),(!Ol||fa)&&Zl("",Ht(ib,Wn.event)))),Ce(un),!un&&Ol&&(Wn.reason===qb||Wn.reason===MM)&&(ie(!0),ce(!1),Y==="onBlur")))){const _s=d==="none"?ct:At;ne.commit(_s)}}),Eg=ht((un,Wn)=>{if(a?.(un,Wn),Wn.isCanceled)return;rn(un),(d==="none"&&Le.current&&V||Ye&&!Tt.state.inputInsidePopup)&&Zl(ou(un,R),Ht(Wn.reason,Wn.event)),Ye&&un!=null&&Wn.reason!==tk&&he&&!fa&&Ie(Ve)}),Bx=ht((un,Wn)=>{let _s=Wn;if(_s===void 0){if(Pr===null)return;_s=Ee.current[Pr]}const wa=yi(un),Gi=He.current??un;He.current=null;const Da=Ht(pw,Gi),cm=wa?.closest("a")?.getAttribute("href");if(cm){cm.startsWith("#")&&im(!1,Da);return}if(Ke){const yd=Array.isArray(At)?At:[],GN=Sht(yd,_s,Tt.state.isItemEqualToValue)?kht(yd,_s,Tt.state.isItemEqualToValue):[...yd,_s];if(Eg(GN,Da),!(le.current?le.current.value.trim()!=="":!1))return;Tt.state.inputInsidePopup?Zl("",Ht(ib,Da.event)):im(!1,Da)}else Eg(_s,Da),im(!1,Da)}),A1=ht(()=>{if(!Tt.state.submitOnItemClick)return;const un=ne.inputRef.current?.form??Tt.state.inputElement?.form;un&&typeof un.requestSubmit=="function"&&un.requestSubmit()}),il=ht(()=>{if(am(!1),ss?.(!1),xe(!1),Ie(null),_l(d==="none"?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),Ke&&le.current&&le.current.value!==""&&!Ne.current&&Zl("",Ht(ib)),Ye)if(Tt.state.inputInsidePopup)le.current&&le.current.value!==""&&Zl("",Ht(ib));else{const un=ou(At,R);le.current&&le.current.value!==un&&Zl(un,Ht(un===""?ib:vo))}}),R1=y.useMemo(()=>fa&&lr?{current:lr.closest('[role="dialog"]')}:Le,[fa,lr]);Ul({enabled:!e.actionsRef,open:Jt,ref:R1,onComplete(){Jt||il()}}),y.useImperativeHandle(e.actionsRef,()=>({unmount:il}),[il]),Nt(function(){if(Jt||d==="none")return;const Wn=w?xt:je.current;if(Ke){const _s=Array.isArray(At)?At:[],wa=_s[_s.length-1],Gi=mw(Wn,wa,B);_l({selectedIndex:Gi===-1?null:Gi})}else{const _s=mw(Wn,At,B);_l({selectedIndex:_s===-1?null:_s})}},[Jt,At,w,d,xt,Ke,B,_l]),Nt(()=>{w&&(Ee.current=Dt,ke.current.length=Dt.length)},[w,Dt]),Nt(()=>{const un=_e.current;if(un&&(un.hasQuery?bt&&Tt.set("activeIndex",0):bt==="always"&&Tt.set("activeIndex",0),_e.current=null),!Jt&&!fa)return;const _s=_t||an?Dt:Ee.current,wa=Tt.state.activeIndex;if(wa==null){if(bt==="always"&&_s.length>0){Tt.set("activeIndex",0);return}Oe.current!==dS&&(Oe.current=dS,Tt.state.onItemHighlighted(void 0,qS(vo,void 0,{index:-1})));return}if(wa>=_s.length){Oe.current!==dS&&(Oe.current=dS,Tt.state.onItemHighlighted(void 0,qS(vo,void 0,{index:-1}))),Tt.set("activeIndex",null);return}const Gi=_s[wa],Da=Oe.current.value,cm=Da!==Eht&&Bv(Gi,Da,Tt.state.isItemEqualToValue);(Oe.current.index!==wa||!cm)&&(Oe.current={value:Gi,index:wa},Tt.state.onItemHighlighted(Gi,qS(vo,void 0,{index:wa})))},[Pr,bt,an,_t,Dt,fa,Jt,Tt]),Nt(()=>{if(d==="none"){ae(String(ct)!=="");return}ae(Ke?Array.isArray(At)&&At.length>0:At!=null)},[ae,d,ct,At,Ke]),y.useEffect(()=>{_t&&bt&&Dt.length===0&&_l({activeIndex:null})},[_t,bt,Dt.length,_l]),gv(Ve,()=>{!Jt||Ve===""||Ve===String(at)||xe(!0)}),gv(At,()=>{if(d!=="none"&&(P(Fe),H(At!==W.initialValue),X()?ne.commit(At):ne.commit(At,!0),Ye&&!Pt&&!Ol)){const un=ou(At,R);ct!==un&&Zl(un,Ht(vo))}}),gv(ct,()=>{d==="none"&&(P(Fe),H(ct!==W.initialValue),X()?ne.commit(ct):ne.commit(ct,!0))}),gv(w,()=>{if(!Ye||Pt||Ol||he)return;const un=ou(At,R);ct!==un&&Zl(un,Ht(vo))});const Sy=hye({open:fa?!0:Jt,onOpenChange:im,elements:{reference:Ol?Ya:uo,floating:lr}});let jg,Tg;fa||(jg=S?"grid":"listbox",Tg=Jt?"true":"false");const P1=y.useMemo(()=>{const un=uo?.tagName==="INPUT",Wn=uo==null||un,_s=Wn||Jt,wa=Wn?{autoComplete:"off",spellCheck:"false",autoCorrect:"off",autoCapitalize:"none"}:{};return _s&&(wa.role="combobox",wa["aria-expanded"]=Tg,wa["aria-haspopup"]=jg,wa["aria-controls"]=Jt?cs?.id:void 0,wa["aria-autocomplete"]=U),{reference:wa,floating:{role:"presentation"}}},[uo,Jt,Tg,jg,cs?.id,U]),WN=e_(Sy,{enabled:!g&&!$e&&C,event:"mousedown-only",toggle:!1,touchOpenDelay:Ol?0:100,reason:tgn}),om=t_(Sy,{enabled:!g&&!$e&&!fa,outsidePressEvent:{mouse:"sloppy",touch:"intentional"},bubbles:fa?!0:void 0,outsidePress(un){const Wn=yi(un);return!dn(Ya,Wn)&&!dn(Ge.current,Wn)&&!dn(Re.current,Wn)&&!dn(Ks,Wn)}}),Ux=yye(Sy,{enabled:!g&&!$e,id:pe,listRef:ke,activeIndex:Pr,selectedIndex:Os,virtual:!0,loopFocus:I,allowEscape:I&&!bt,focusItemOnOpen:he||d==="none"&&!bt?!1:"auto",focusItemOnHover:N,resetOnPointerLeave:!T,cols:S?2:1,orientation:S?"horizontal":void 0,rtl:ue==="rtl",disabledIndices:dh,onNavigate(un,Wn){!Wn&&!Jt||Hr==="ending"||_l(Wn?{activeIndex:un,type:ye.current?"keyboard":"pointer"}:{activeIndex:un})}}),N_=y.useMemo(()=>wo(Ux.reference,om.reference,WN.reference,P1.reference),[Ux.reference,om.reference,WN.reference,P1.reference]),I_=y.useMemo(()=>wo(sy,Ux.floating,om.floating,P1.floating),[Ux.floating,om.floating,P1.floating]),$1=y.useMemo(()=>{const un=Ux.item;return un?{...un,onFocus:void 0}:vs},[Ux.item]);XO(()=>{Tt.update({inline:F,popupProps:I_,inputProps:N_,triggerProps:Oc,itemProps:$1,setOpen:im,setInputValue:Zl,setSelectedValue:Eg,setIndices:_l,onItemHighlighted:_r,handleSelection:Bx,forceMount:us,requestSubmit:A1})}),Nt(()=>{Tt.update({id:pe,selectedValue:At,open:Jt,mounted:Lp,transitionStatus:Hr,items:w,inline:F,popupProps:I_,inputProps:N_,triggerProps:Oc,openMethod:fo,itemProps:$1,selectionMode:d,name:Fe,form:h,disabled:$e,readOnly:g,required:v,grid:S,isGrouped:Me,virtualized:M,onOpenChangeComplete:ss,openOnInputClick:C,itemToStringLabel:R,modal:L,autoHighlight:bt,isItemEqualToValue:B,submitOnItemClick:q,hasInputValue:Pt,requestSubmit:A1,inputOwnsFormValue:d==="none"&&(F||!Tt.state.inputInsidePopup)})},[Tt,pe,At,Jt,Lp,Hr,w,I_,N_,$1,fo,Oc,d,Fe,$e,g,v,ne,S,Me,M,ss,C,R,L,B,q,Pt,F,A1,bt,h]);const TZ=Su(b,ne.inputRef),NZ=y.useMemo(()=>({query:Ve,hasItems:_t,filteredItems:Mt,flatFilteredItems:Dt}),[Ve,_t,Mt,Dt]),A_=y.useMemo(()=>Array.isArray(fn)?"":$m(fn,$),[fn,$]),lm=Ke&&Array.isArray(At)&&At.length>0,M1=Ke||d==="none"&&kc?void 0:Fe,QN=y.useMemo(()=>!Ke||!Array.isArray(At)||!Fe?null:At.map(un=>{const Wn=$m(un,$);return o.jsx("input",{type:"hidden",form:h,name:Fe,value:Wn},Wn)}),[Ke,At,h,Fe,$]),qx=o.jsxs(y.Fragment,{children:[e.children,o.jsx("input",{...ne.getInputValidationProps({onFocus(){if(Ol){Ya?.focus();return}(le.current||Ya)?.focus()},onChange(un){if(un.nativeEvent.defaultPrevented||$e||g){un.preventBaseUIHandler?.();return}const Wn=un.currentTarget.value,_s=Ht(vo,un.nativeEvent);function wa(){if(Ke)return;if(d==="none"){H(Wn!==W.initialValue),Zl(Wn,_s),X()&&ne.commit(Wn);return}const Gi=Ee.current.find(Da=>$m(Da,$).toLowerCase()===Wn.toLowerCase()||ou(Da,R).toLowerCase()===Wn.toLowerCase());Gi!=null&&(H(Gi!==W.initialValue),Eg?.(Gi,_s),X()&&ne.commit(Gi))}w?wa():(us(),queueMicrotask(wa))}}),id:pe&&M1==null?`${pe}-hidden-input`:void 0,form:h,name:M1,autoComplete:D,disabled:$e,required:v&&!lm,readOnly:g,value:A_,ref:TZ,style:M1?QT:Lw,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),QN]});return o.jsx(ght.Provider,{value:Tt,children:o.jsx(vht.Provider,{value:Sy,children:o.jsx(yht.Provider,{value:NZ,children:o.jsx(bht.Provider,{value:ct,children:qx})})})})}function jht(e){const{multiple:t=!1,defaultValue:n,value:r,onValueChange:s,autoComplete:a,...i}=e;return o.jsx(FIn,{...i,selectionMode:t?"multiple":"single",selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:s,formAutoComplete:a})}function zIn(e){return e==null?void 0:`${e}-label`}function UU(e,t){return e??t}function BIn(e){const{children:t,placeholder:n}=e,r=ly(),s=pt(r,on.itemToStringLabel),a=pt(r,on.selectedValue),i=pt(r,on.items),l=pt(r,on.selectionMode)==="multiple",c=pt(r,on.hasSelectedValue),u=!c&&n!=null&&t==null,d=pt(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=_ht(a,i,s):f=Xbe(a,i,s),o.jsx(y.Fragment,{children:f})}const Tht={...dP,...y1,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":""}:null},UIn=y.createContext(void 0);function qIn(){return y.useContext(UIn)}const Nht=y.createContext(void 0);function Kbe(e){const t=y.useContext(Nht);if(t===void 0&&!e)throw new Error(gr(21));return t}const Iht=y.forwardRef(function(t,n){const r=ly(),{buttonRef:s,getButtonProps:a}=hd({native:!1}),i=Su(n,s);function l(u){r.state.setOpen(!1,Ht(Xve,u.nativeEvent,u.currentTarget))}const c=a({onClick:l});return o.jsx("span",{ref:i,...c,"aria-label":"Dismiss",tabIndex:void 0,style:QT})}),Aht=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}=Yh(),{labelId:g}=gx(),v=qIn(),S=!!Kbe(!0),w=ly(),{filteredItems:O}=b1(),_=xht(),C=ay(),E=pt(w,on.required),T=pt(w,on.disabled),N=pt(w,on.readOnly),I=pt(w,on.name),R=pt(w,on.form),$=pt(w,on.selectionMode),B=pt(w,on.autoHighlight),M=pt(w,on.inputProps),F=pt(w,on.triggerProps),V=pt(w,on.open),L=pt(w,on.mounted),z=pt(w,on.selectedValue),U=pt(w,on.popupSide),D=pt(w,on.positionerElement),G=pt(w,on.id),q=pt(w,on.inline),P=pt(w,on.modal),H=!!B,W=L&&D?U:null,X=d||T||a,ae=O.length===0,ee=S||q,J=!ee||P,ie=Ni(i??(ee?void 0:G)),ce=UU(g,void 0),Y=S?yE:u,[ne,ue]=y.useState(null),pe=y.useRef(!1),re=y.useRef(null),he=y.useRef(!1),xe=$==="none"&&!S,be=ht(se=>{const te=S||w.state.inline;te&&!w.state.hasInputValue&&w.state.setInputValue("",Ht(vo)),w.update({inputElement:se,inputInsidePopup:te,inputOwnsFormValue:xe})}),Ie=S||!m?c:m.getValidationProps(c),ke={...Y,open:V,disabled:X,readOnly:N,popupSide:W,listEmpty:ae};function Te(se){if(!v)return;let te;const{highlightedChipIndex:me}=v,ye=v.chipsRef.current.length,Ne=C==="rtl",Re=Ne?"ArrowRight":"ArrowLeft",Ge=Ne?"ArrowLeft":"ArrowRight";if(me!==void 0){if(se.key===Re)se.preventDefault(),me>0?te=me-1:te=void 0;else if(se.key===Ge)se.preventDefault(),me<ye-1?te=me+1:te=void 0;else if(se.key==="Backspace"||se.key==="Delete"){se.preventDefault();const He=me>=z.length-1?z.length-2:me;te=He>=0?He:void 0,w.state.setIndices({activeIndex:null,selectedIndex:null,type:"keyboard"})}return te}return se.key===Re&&(se.currentTarget.selectionStart??0)===0&&z.length>0?(se.preventDefault(),te=ye>0?ye-1:void 0):se.key==="Backspace"&&se.currentTarget.value===""&&z.length>0&&(w.state.setIndices({activeIndex:null,selectedIndex:null,type:"keyboard"}),se.preventDefault()),te}const Le=Cn("input",t,{state:ke,ref:[n,w.state.inputRef,be],props:[M,F,{type:"text",value:t.value??ne??_,"aria-readonly":N||void 0,"aria-required":E||void 0,"aria-labelledby":ce,disabled:X,readOnly:N,required:$==="none"?E:void 0,form:R,...xe&&I&&{name:I},id:ie,onFocus(){if(p(!0),!q||!he.current)return;he.current=!1;const se=re.current;se==null||!Object.hasOwn(w.state.valuesRef.current,se)||w.state.setIndices({activeIndex:se})},onBlur(){f(!0),p(!1);const se=w.state.activeIndex;if(q&&se!==null&&B!=="always"&&(re.current=se,he.current=!0,w.state.setIndices({activeIndex:null})),h==="onBlur"){const te=$==="none"?_:z;m.commit(te)}},onCompositionStart(se){lP||(pe.current=!0,ue(se.currentTarget.value))},onCompositionEnd(se){pe.current=!1;const te=se.currentTarget.value;ue(null),w.state.setInputValue(te,Ht(tk,se.nativeEvent))},onChange(se){const te=se.nativeEvent.inputType,me=!te||te==="insertReplacementText",ye=pe.current||!me;if(pe.current){const He=se.currentTarget.value;ue(He),He===""&&!w.state.openOnInputClick&&!w.state.inputInsidePopup&&w.state.setOpen(!1,Ht(ib,se.nativeEvent));const Oe=He.trim(),_e=H&&Oe!=="";!N&&!X&&Oe&&ye&&(w.state.setOpen(!0,Ht(tk,se.nativeEvent)),H||w.state.setIndices({activeIndex:null,selectedIndex:null,type:w.state.keyboardActiveRef.current?"keyboard":"pointer"})),V&&w.state.activeIndex!==null&&!_e&&w.state.setIndices({activeIndex:null,selectedIndex:null,type:w.state.keyboardActiveRef.current?"keyboard":"pointer"});return}w.state.setInputValue(se.currentTarget.value,Ht(tk,se.nativeEvent));const Ne=se.currentTarget.value==="",Re=Ht(ib,se.nativeEvent);Ne&&!w.state.inputInsidePopup&&($==="single"&&w.state.setSelectedValue(null,Re),w.state.openOnInputClick||w.state.setOpen(!1,Re));const Ge=se.currentTarget.value.trim();!N&&!X&&Ge&&ye&&(w.state.setOpen(!0,Ht(tk,se.nativeEvent)),H||w.state.setIndices({activeIndex:null,selectedIndex:null,type:w.state.keyboardActiveRef.current?"keyboard":"pointer"})),V&&w.state.activeIndex!==null&&!H&&w.state.setIndices({activeIndex:null,selectedIndex:null,type:w.state.keyboardActiveRef.current?"keyboard":"pointer"})},onKeyDown(se){if(X||N||se.ctrlKey||se.shiftKey||se.altKey||se.metaKey)return;w.state.keyboardActiveRef.current=!0;const te=se.currentTarget,me=te.scrollWidth-te.clientWidth,ye=C==="rtl";if(se.key==="Home"){Kl(se);const Ge=s$e&&ye?te.value.length:0;te.setSelectionRange(Ge,Ge),te.scrollLeft=0;return}if(se.key==="End"){Kl(se);const Ge=s$e&&ye?0:te.value.length;te.setSelectionRange(Ge,Ge),te.scrollLeft=ye?-me:me;return}if(!L&&se.key==="Escape"){const Ge=$==="multiple"&&Array.isArray(z)?z.length===0:z===null,He=Ht(JO,se.nativeEvent),Oe=$==="multiple"?[]:null;w.state.setInputValue("",He),w.state.setSelectedValue(Oe,He),!Ge&&!w.state.inline&&!He.isPropagationAllowed&&se.stopPropagation();return}if(v&&se.key==="Backspace"&&te.value===""&&v.highlightedChipIndex===void 0&&Array.isArray(z)&&z.length>0){const Ge=v.chipsRef.current.length,He=Ge>0?Ge-1:z.length-1,Oe=z.filter((_e,Ee)=>Ee!==He);w.state.setIndices({activeIndex:null,selectedIndex:null,type:w.state.keyboardActiveRef.current?"keyboard":"pointer"}),w.state.setSelectedValue(Oe,Ht(vo,se.nativeEvent));return}const Ne=v?.highlightedChipIndex!==void 0,Re=Te(se);if(v?.setHighlightedChipIndex(Re),Re!==void 0?v?.chipsRef.current[Re]?.focus():Ne&&w.state.inputRef.current?.focus(),se.which!==229&&se.key==="Enter"&&V){const Ge=w.state.activeIndex,He=se.nativeEvent;if(Ge===null){if(q)return;w.state.setOpen(!1,Ht(vo,He));return}Kl(se);const Oe=w.state.listRef.current[Ge];Oe&&(w.state.selectionEventRef.current=He,Oe.click(),w.state.selectionEventRef.current=null)}},onPointerMove(){w.state.keyboardActiveRef.current=!1},onPointerDown(){w.state.keyboardActiveRef.current=!1}},Ie],stateAttributesMapping:Tht}),le=S?o.jsx(uht.Provider,{value:cht,children:Le}):Le;return o.jsxs(y.Fragment,{children:[V&&J&&o.jsx(Iht,{ref:w.state.startDismissRef}),le]})});function Jbe(e){const t=e.getBoundingClientRect(),n=Gs(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 dL=2,Rht=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}=Yh(),{labelId:v}=gx(),b=ly(),{filteredItems:S}=b1(),w=pt(b,on.selectionMode),O=pt(b,on.disabled),_=pt(b,on.readOnly),C=pt(b,on.required),E=pt(b,on.mounted),T=pt(b,on.popupSide),N=pt(b,on.positionerElement),I=pt(b,on.listElement),R=pt(b,on.triggerProps),$=pt(b,on.triggerElement),B=pt(b,on.inputInsidePopup),M=pt(b,on.id),F=pt(b,on.labelId),V=pt(b,on.open),L=pt(b,on.selectedValue),z=pt(b,on.activeIndex),U=pt(b,on.selectedIndex),D=pt(b,on.hasSelectedValue),G=BU(),q=xht(),P=to(),H=f||O||i,W=S.length===0,X=E&&N?T:null;o_({id:B?l:void 0});const ae=B?l??M:l,ee=UU(v,F),J=y.useRef("");function ie(be){J.current=be.pointerType}const ce=G.useState("domReferenceElement");y.useEffect(()=>{B&&$&&$!==ce&&G.set("domReferenceElement",$)},[$,ce,G,B]);const{reference:Y}=bye(G,{enabled:!V&&!_&&!O&&w==="single",listRef:b.state.labelsRef,activeIndex:z,selectedIndex:U,onMatch(be){const Ie=b.state.valuesRef.current[be];Ie!==void 0&&b.state.setSelectedValue(Ie,Ht("none"))}}),{reference:ne}=e_(G,{enabled:!_&&!O,event:"mousedown"}),{buttonRef:ue,getButtonProps:pe}=hd({native:a,disabled:H}),re={...d,open:V,disabled:H,popupSide:X,listEmpty:W,placeholder:w==="none"?!1:!D},he=ht(be=>{b.set("triggerElement",be)});return Cn("button",t,{ref:[n,ue,he],state:re,props:[R,ne,Y,{id:ae,tabIndex:B?0:-1,role:B?"combobox":void 0,"aria-expanded":V?"true":"false","aria-haspopup":B?"dialog":"listbox","aria-controls":V?I?.id:void 0,"aria-required":B&&C||void 0,"aria-labelledby":ee,onPointerDown:ie,onPointerEnter:ie,onFocus(){h(!0),!(H||_)&&P.start(0,b.state.forceMount)},onBlur(be){if(!dn(N,be.relatedTarget)&&(p(!0),h(!1),m==="onBlur")){const Ie=w==="none"?q:L;g.commit(Ie)}},onMouseDown(be){if(H||_||(B||G.set("domReferenceElement",be.currentTarget),b.state.forceMount(),J.current!=="touch"&&(b.state.inputRef.current?.focus(),B||be.preventDefault()),V))return;const Ie=cr(be.currentTarget);function ke(Te){if(!$)return;const Le=yi(Te),le=b.state.positionerElement,se=b.state.listElement;if(dn($,Le)||dn(le,Le)||dn(se,Le)||Le===$)return;const te=Jbe($),me=Te.clientX>=te.left-dL&&Te.clientX<=te.right+dL,ye=Te.clientY>=te.top-dL&&Te.clientY<=te.bottom+dL;me&&ye||b.state.setOpen(!1,Ht("cancel-open",Te))}B&&Ie.addEventListener("mouseup",ke,{once:!0})},onKeyDown(be){H||_||(be.key==="ArrowDown"||be.key==="ArrowUp")&&(Kl(be),b.state.setOpen(!0,Ht(az,be.nativeEvent)),b.state.inputRef.current?.focus())}},g?g.getValidationProps(u):u,pe],stateAttributesMapping:Tht})}),VIn=y.createContext(null);function HIn(){return y.useContext(VIn)}function ZIn(e){const{children:t}=e,{filteredItems:n}=b1(),r=HIn(),s=r?r.items:n;return s?o.jsx(y.Fragment,{children:s.map(t)}):null}const Pht=y.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function WIn(){return y.useContext(Pht)}function fN(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:s}=e,a=ht(s),i=y.useRef(0),l=lc(GIn).current,c=lc(QIn).current,[u,d]=y.useState(0),f=y.useRef(u),p=ht((b,S)=>{c.set(b,S??null),f.current+=1,d(f.current)}),h=ht(b=>{c.delete(b),f.current+=1,d(f.current)}),m=y.useMemo(()=>{const b=new Map;return Array.from(c.keys()).filter(w=>w.isConnected).sort(YIn).forEach((w,O)=>{const _=c.get(w)??{};b.set(w,{..._,index:O})}),b},[c,u]);Nt(()=>{if(typeof MutationObserver!="function"||m.size===0)return;const b=new MutationObserver(S=>{const w=new Set,O=_=>w.has(_)?w.delete(_):w.add(_);S.forEach(_=>{_.removedNodes.forEach(O),_.addedNodes.forEach(O)}),w.size===0&&(f.current+=1,d(f.current))});return m.forEach((S,w)=>{w.parentElement&&b.observe(w.parentElement,{childList:!0})}),()=>{b.disconnect()}},[m]),Nt(()=>{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]),Nt(()=>()=>{n.current=[]},[n]),Nt(()=>()=>{r&&(r.current=[])},[r]);const g=ht(b=>(l.add(b),()=>{l.delete(b)}));Nt(()=>{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(Pht.Provider,{value:v,children:t})}function QIn(){return new Map}function GIn(){return new Set}function YIn(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 $ht=y.forwardRef(function(t,n){var r;const{render:s,className:a,style:i,children:l,...c}=t,u=ly(),d=BU(),f=!!Kbe(!0),{filteredItems:p,hasItems:h}=b1(),m=pt(u,on.selectionMode),g=pt(u,on.grid),v=pt(u,on.popupProps),b=pt(u,on.virtualized),S=m==="multiple",w=p.length===0,O=ht(I=>{u.set("positionerElement",I)}),_=ht(I=>{u.set("listElement",I)}),C=y.useMemo(()=>typeof l=="function"?r||(r=o.jsx(ZIn,{children:l})):l,[l]),E={empty:w},T=d.useState("floatingId"),N=Cn("div",t,{state:E,ref:[n,_,f?null:O],props:[v,{children:C,tabIndex:-1,id:T,role:g?"grid":"listbox","aria-multiselectable":S?"true":void 0,onKeyDown(I){if(!(u.state.disabled||u.state.readOnly)&&I.key==="Enter"){const R=u.state.activeIndex;if(R==null)return;Kl(I);const $=I.nativeEvent,B=u.state.listRef.current[R];B&&(u.state.selectionEventRef.current=$,B.click(),u.state.selectionEventRef.current=null)}},onKeyDownCapture(){u.state.keyboardActiveRef.current=!0},onPointerMoveCapture(){u.state.keyboardActiveRef.current=!1}},c]});return b?N:o.jsx(fN,{elementsRef:u.state.listRef,labelsRef:h?void 0:u.state.labelsRef,children:N})}),XIn="⁠",KIn=200;function JIn(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 eAn(){const e=to(),t=y.useRef(null);return y.useEffect(()=>{if(Qve)return;const n=t.current;if(n==null)return;const r=JIn(n);if(r==null)return;const s=r.nodeValue??"",a=`${s}${XIn}`;return r.nodeValue=a,e.start(KIn,()=>{r.nodeValue===a&&(r.nodeValue=s)}),()=>{e.clear(),r.nodeValue===a&&(r.nodeValue=s)}},[t,e]),t}const Mht=y.createContext(void 0);function tAn(){const e=y.useContext(Mht);if(e===void 0)throw new Error(gr(20));return e}const Dht=y.forwardRef(function(t,n){const{keepMounted:r=!1,...s}=t,a=ly(),i=pt(a,on.mounted),l=pt(a,on.forceMounted);return i||r||l?o.jsx(Mht.Provider,{value:r,children:o.jsx(FM,{ref:n,...s})}):null}),nAn=20;function qU(e,t,n,r){const[s,a]=y.useState(!1);Nt(()=>{if(!e||!t||n==null){a(!1);return}const i=cr(n).documentElement.clientWidth,l=n.offsetWidth;a(i>0&&l>0&&l>=i-nAn)},[e,t,n]),zpt(e&&(!t||s),r)}const Lht=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=aye,style:b,...S}=t,w=ly(),{filteredItems:O}=b1(),_=BU(),C=tAn(),E=pt(w,on.modal),T=pt(w,on.open),N=pt(w,on.mounted),I=pt(w,on.openMethod),R=pt(w,on.positionerElement),$=pt(w,on.triggerElement),B=pt(w,on.inputElement),M=pt(w,on.inputGroupElement),F=pt(w,on.inputInsidePopup),V=pt(w,on.transitionStatus),L=O.length===0,U=KT({anchor:a??(F?$:M??B),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});qU(T&&E,I==="touch",R,$);const D={open:T,side:U.side,align:U.align,anchorHidden:U.anchorHidden,empty:L};Nt(()=>{w.set("popupSide",U.side)},[w,U.side]);const G=ht(P=>{w.set("positionerElement",P)}),q=JT(t,D,{styles:U.positionerStyles,transitionStatus:V,props:S,refs:[n,G],hidden:!N,inert:!T});return o.jsxs(Nht.Provider,{value:U,children:[N&&E&&o.jsx(iD,{inert:eN(!T),cutout:M??B??$}),q]})}),rAn={...ff,...Bl},Fht=y.forwardRef(function(t,n){const{render:r,className:s,style:a,initialFocus:i,finalFocus:l,...c}=t,u=ly(),d=Kbe(),f=BU(),{filteredItems:p}=b1(),h=pt(u,on.mounted),m=pt(u,on.open),g=pt(u,on.openMethod),v=pt(u,on.transitionStatus),b=pt(u,on.inputInsidePopup),S=pt(u,on.inputElement),w=pt(u,on.modal),O=p.length===0;Ul({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=Cn("div",t,{state:_,ref:[n,u.state.popupRef],props:[{role:b?"dialog":"presentation",tabIndex:-1,onFocus(R){const $=yi(R.nativeEvent);g!=="touch"&&(dn(u.state.listElement,$)||$===R.currentTarget)&&u.state.inputRef.current?.focus()}},r_(v),c],stateAttributesMapping:rAn}),T=i===void 0?b?R=>R==="touch"?u.state.popupRef.current:S:!1:i;let N;l!=null?N=l:N=b?void 0:!1;const I=!b||w;return o.jsx(GT,{context:f,disabled:!h,modal:I,openInteractionType:g,initialFocus:T,returnFocus:N,getInsideElements:()=>[u.state.startDismissRef.current,u.state.endDismissRef.current],children:o.jsxs(y.Fragment,{children:[C,I&&o.jsx(Iht,{ref:u.state.endDismissRef})]})})});let exe=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function vx(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}=WIn(),p=y.useRef(-1),[h,m]=y.useState(a??(s===exe.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 S=t!==void 0;d.current[h]=S?t:r?.current?.textContent??b.textContent}},[h,u,d,t,r]);return Nt(()=>{if(a!=null)return;const b=g.current;if(b)return i(b,n),()=>{l(b)}},[a,i,l,n]),Nt(()=>{if(a==null)return c(b=>{const S=g.current?b.get(g.current)?.index:null;S!=null&&m(S)})},[a,c,m]),y.useMemo(()=>({ref:v,index:h}),[h,v])}const zht=y.createContext(void 0);function Bht(){const e=y.useContext(zht);if(!e)throw new Error(gr(19));return e}const sAn=y.createContext(!1);function aAn(){return y.useContext(sAn)}const Uht=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=vx({index:l,textRef:p,indexGuessBehavior:exe.GuessFromOrder}),m=ly(),g=aAn(),{flatFilteredItems:v,hasItems:b}=b1(),S=pt(m,on.open),w=pt(m,on.selectionMode),O=pt(m,on.readOnly),_=pt(m,on.virtualized),C=pt(m,on.isItemEqualToValue),E=w!=="none",T=l??(_?mw(v,i,C):h.index),N=h.index!==-1,I=pt(m,on.id),R=pt(m,on.isActive,T),$=pt(m,on.isSelected,i),B=pt(m,on.itemProps),M=y.useRef(null),F=I!=null&&N?`${I}-${T}`:void 0,V=$&&E;Nt(()=>{if(!(N&&(_||l!=null)))return;const W=m.state.listRef.current;return W[T]=M.current,()=>{delete W[T]}},[N,_,T,l,m]),Nt(()=>{if(!N||b)return;const H=m.state.valuesRef.current;return H[T]=i,w!=="none"&&m.state.allValuesRef.current.push(i),()=>{delete H[T]}},[N,b,T,i,m,w]),Nt(()=>{if(!S){f.current=!1;return}if(!N||b)return;const H=m.state.selectedValue,W=Array.isArray(H)?H[H.length-1]:H;Bv(i,W,C)&&m.set("selectedIndex",T)},[N,b,S,m,T,i,C]);const{getButtonProps:L,buttonRef:z}=hd({disabled:c,focusableWhenDisabled:!0,native:u,composite:!0}),U={disabled:c,selected:V,highlighted:R};function D(H){function W(){m.state.handleSelection(H,i)}m.state.submitOnItemClick?(ko.flushSync(W),m.state.requestSubmit()):W()}const G={id:F,role:g?"gridcell":"option","aria-selected":E?V:void 0,tabIndex:void 0,onPointerDownCapture(H){f.current=!0,H.preventDefault()},onMouseDown(H){H.preventDefault()},onClick(H){c||O||D(H.nativeEvent)},onMouseUp(H){const W=f.current;f.current=!1,!(c||O||H.button!==0||W||!R)&&D(H.nativeEvent)}},q=Cn("div",t,{ref:[z,n,h.ref,M],state:U,props:[B,G,d,L]}),P=y.useMemo(()=>({selected:V,textRef:p}),[V,p]);return o.jsx(zht.Provider,{value:P,children:q})})),iAn=y.forwardRef(function(t,n){const r=t.keepMounted??!1,{selected:s}=Bht();return r||s?o.jsx(oAn,{...t,ref:n}):null}),oAn=y.memo(y.forwardRef((e,t)=>{const{render:n,className:r,style:s,keepMounted:a,...i}=e,{selected:l}=Bht(),c=y.useRef(null),{transitionStatus:u,setMounted:d}=gg(l),p=Cn("span",e,{ref:[t,c],state:{selected:l,transitionStatus:u},props:[{"aria-hidden":!0,children:"✔️"},i],stateAttributesMapping:Bl});return Ul({open:l,ref:c,onComplete(){l||d(!1)}}),p})),qht=y.forwardRef(function(t,n){const{render:r,className:s,style:a,children:i,...l}=t,{filteredItems:c}=b1(),u=ly(),d=eAn(),f=c.length===0?i:null;return Cn("div",t,{ref:[n,u.state.emptyRef,d],props:[{children:f,role:"status","aria-live":"polite","aria-atomic":!0},l]})}),lAn=y.forwardRef(function(t,n){const{className:r,render:s,orientation:a="horizontal",style:i,...l}=t;return Cn("div",t,{state:{orientation:a},ref:n,props:[{role:"separator","aria-orientation":a},l]})});function cAn(e){return e==="link"?"ghost":e}function Vht({variant:e,size:t,error:n,className:r}){const s=cAn(e);return K(QM({variant:s,size:t}),"w-full min-w-32 justify-between",Ylt[s],"data-[placeholder]:text-neutral3",n&&"border-error hover:border-error focus-visible:border-error",r)}const ps={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",ns.colors),searchIcon:K("mr-2 h-3.5 w-3.5 shrink-0 text-neutral3",ns.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",ns.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",ns.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",ns.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 Hht({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(S=>S.value))},v=m.length===0?r:`${m.length} selected`;return o.jsxs("div",{className:ps.root,children:[o.jsxs(jht,{multiple:!0,items:e,value:m,onValueChange:g,disabled:l,open:d,onOpenChange:f,children:[o.jsxs(Rht,{className:Vht({variant:c,size:u,error:!!h,className:i}),children:[o.jsx("span",{className:K("truncate",m.length===0&&ps.placeholder),children:v}),o.jsx("span",{className:"flex shrink-0 items-center",children:o.jsx(nD,{className:ps.chevron})})]}),o.jsx(Dht,{container:p,children:o.jsx(Lht,{align:"start",sideOffset:4,className:ps.positioner,children:o.jsxs(Fht,{className:ps.popup,children:[o.jsxs("div",{className:ps.searchContainer,children:[o.jsx(Uj,{className:ps.searchIcon}),o.jsx(Aht,{className:ps.searchInput,placeholder:s})]}),o.jsx(qht,{className:ps.empty,children:a}),o.jsx($ht,{className:ps.list,children:b=>{const S=t.includes(b.value);return o.jsxs(Uht,{value:b,className:ps.itemMulti,children:[o.jsx("span",{className:K(ps.checkbox,S?ps.checkboxSelected:ps.checkboxUnselected),children:S&&o.jsx(hx,{className:ps.checkboxIcon})}),o.jsxs("span",{className:ps.optionContent,children:[b.start,o.jsxs("span",{className:ps.optionText,children:[o.jsx("span",{className:ps.optionLabel,children:b.label}),b.description&&o.jsx("span",{className:ps.optionDescription,children:b.description})]}),b.end?o.jsx("div",{className:ps.optionEnd,children:b.end}):null]})]},b.value)}})]})})})]}),h&&o.jsx("span",{className:ps.error,children:h})]})}const Zht=y.createContext(void 0);function uAn({container:e,children:t}){return o.jsx(Zht.Provider,{value:e??void 0,children:t})}function lD(e){const t=y.useContext(Zht);return e??t??void 0}function Hc({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=lD(p),v=b=>{b&&n?.(b.value)};return o.jsxs("div",{className:ps.root,children:[o.jsxs(jht,{autoHighlight:!0,items:e,value:m,onValueChange:v,disabled:l,open:d,onOpenChange:f,children:[o.jsxs(Rht,{className:Vht({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(BIn,{placeholder:r})})]}),o.jsx("span",{className:"flex shrink-0 items-center",children:o.jsx(nD,{className:ps.chevron})})]}),o.jsx(Dht,{container:g,children:o.jsx(Lht,{align:"start",sideOffset:4,className:ps.positioner,children:o.jsxs(Fht,{className:ps.popup,children:[o.jsxs("div",{className:ps.searchContainer,children:[o.jsx(Uj,{className:ps.searchIcon}),o.jsx(Aht,{className:ps.searchInput,placeholder:s})]}),o.jsx(qht,{className:ps.empty,children:a}),o.jsx($ht,{className:ps.list,children:b=>o.jsxs(Uht,{value:b,className:ps.item,children:[b.start,o.jsxs("span",{className:ps.optionText,children:[o.jsx("span",{className:ps.optionLabel,children:b.label}),b.description&&o.jsx("span",{className:ps.optionDescription,children:b.description})]}),o.jsxs("span",{className:ps.itemRightSlot,children:[b.end?o.jsx("div",{className:ps.optionEnd,children:b.end}):null,o.jsx("span",{className:ps.checkContainer,children:o.jsx(iAn,{children:o.jsx(hx,{className:ps.checkIcon})})})]})]},b.value)})]})})})]}),h&&o.jsx("span",{className:ps.error,children:h})]})}var M4e=1,dAn=.9,fAn=.8,pAn=.17,ZY=.1,WY=.999,hAn=.9999,mAn=.99,gAn=/[\\\/_+.#"@\[\(\{&]/,vAn=/[\\\/_+.#"@\[\(\{&]/g,yAn=/[\s-]/,Wht=/[\s-]/g;function Mde(e,t,n,r,s,a,i){if(a===t.length)return s===e.length?M4e:mAn;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=Mde(e,t,n,r,u+1,a+1,i),f>d&&(u===s?f*=M4e:gAn.test(e.charAt(u-1))?(f*=fAn,h=e.slice(s,u-1).match(vAn),h&&s>0&&(f*=Math.pow(WY,h.length))):yAn.test(e.charAt(u-1))?(f*=dAn,m=e.slice(s,u-1).match(Wht),m&&s>0&&(f*=Math.pow(WY,m.length))):(f*=pAn,s>0&&(f*=Math.pow(WY,u-s))),e.charAt(u)!==t.charAt(a)&&(f*=hAn)),(f<ZY&&n.charAt(u-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(u-1)!==r.charAt(a))&&(p=Mde(e,t,n,r,u+1,a+2,i),p*ZY>f&&(f=p*ZY)),f>d&&(d=f),u=n.indexOf(c,u+1);return i[l]=d,d}function D4e(e){return e.toLowerCase().replace(Wht," ")}function bAn(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Mde(e,t,D4e(e),D4e(t),0,0,{})}var QY="focusScope.autoFocusOnMount",GY="focusScope.autoFocusOnUnmount",L4e={bubbles:!1,cancelable:!0},xAn="FocusScope",Qht=y.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...i}=e,[l,c]=y.useState(null),u=Cj(s),d=Cj(a),f=y.useRef(null),p=mg(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(w){if(h.paused||!l)return;const O=w.target;l.contains(O)?f.current=O:A0(f.current,{select:!0})},v=function(w){if(h.paused||!l)return;const O=w.relatedTarget;O!==null&&(l.contains(O)||A0(f.current,{select:!0}))},b=function(w){if(document.activeElement===document.body)for(const _ of w)_.removedNodes.length>0&&A0(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",v);const S=new MutationObserver(b);return l&&S.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",v),S.disconnect()}}},[r,l,h.paused]),y.useEffect(()=>{if(l){z4e.add(h);const g=document.activeElement;if(!l.contains(g)){const b=new CustomEvent(QY,L4e);l.addEventListener(QY,u),l.dispatchEvent(b),b.defaultPrevented||(wAn(CAn(Ght(l)),{select:!0}),document.activeElement===g&&A0(l))}return()=>{l.removeEventListener(QY,u),setTimeout(()=>{const b=new CustomEvent(GY,L4e);l.addEventListener(GY,d),l.dispatchEvent(b),b.defaultPrevented||A0(g??document.body,{select:!0}),l.removeEventListener(GY,d),z4e.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 S=g.currentTarget,[w,O]=SAn(S);w&&O?!g.shiftKey&&b===O?(g.preventDefault(),n&&A0(w,{select:!0})):g.shiftKey&&b===w&&(g.preventDefault(),n&&A0(O,{select:!0})):b===S&&g.preventDefault()}},[n,r,h.paused]);return o.jsx(uf.div,{tabIndex:-1,...i,ref:p,onKeyDown:m})});Qht.displayName=xAn;function wAn(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(A0(r,{select:t}),document.activeElement!==n)return}function SAn(e){const t=Ght(e),n=F4e(t,e),r=F4e(t.reverse(),e);return[n,r]}function Ght(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 F4e(e,t){for(const n of e)if(!kAn(n,{upTo:t}))return n}function kAn(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 OAn(e){return e instanceof HTMLInputElement&&"select"in e}function A0(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&OAn(e)&&t&&e.select()}}var z4e=_An();function _An(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=B4e(e,t),e.unshift(t)},remove(t){e=B4e(e,t),e[0]?.resume()}}}function B4e(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function CAn(e){return e.filter(t=>t.tagName!=="A")}var YY=0;function EAn(){y.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??U4e()),document.body.insertAdjacentElement("beforeend",e[1]??U4e()),YY++,()=>{YY===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),YY--}},[])}function U4e(){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 sv=function(){return sv=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},sv.apply(this,arguments)};function Yht(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 jAn(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 $8="right-scroll-bar-position",M8="width-before-scroll-bar",TAn="with-scroll-bars-hidden",NAn="--removed-body-scroll-bar-size";function XY(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function IAn(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 AAn=typeof window<"u"?y.useLayoutEffect:y.useEffect,q4e=new WeakMap;function RAn(e,t){var n=IAn(null,function(r){return e.forEach(function(s){return XY(s,r)})});return AAn(function(){var r=q4e.get(n);if(r){var s=new Set(r),a=new Set(e),i=n.current;s.forEach(function(l){a.has(l)||XY(l,null)}),a.forEach(function(l){s.has(l)||XY(l,i)})}q4e.set(n,e)},[e]),n}function PAn(e){return e}function $An(e,t){t===void 0&&(t=PAn);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 MAn(e){e===void 0&&(e={});var t=$An(null);return t.options=sv({async:!0,ssr:!1},e),t}var Xht=function(e){var t=e.sideCar,n=Yht(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,sv({},n))};Xht.isSideCarExport=!0;function DAn(e,t){return e.useMedium(t),Xht}var Kht=MAn(),KY=function(){},VU=y.forwardRef(function(e,t){var n=y.useRef(null),r=y.useState({onScrollCapture:KY,onWheelCapture:KY,onTouchMoveCapture:KY}),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,S=b===void 0?"div":b,w=e.gapMode,O=Yht(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),_=p,C=RAn([n,t]),E=sv(sv({},O),s);return y.createElement(y.Fragment,null,d&&y.createElement(_,{sideCar:Kht,removeScrollBar:u,shards:f,noRelative:h,noIsolation:m,inert:g,setCallbacks:a,allowPinchZoom:!!v,lockRef:n,gapMode:w}),i?y.cloneElement(y.Children.only(l),sv(sv({},E),{ref:C})):y.createElement(S,sv({},E,{className:c,ref:C}),l))});VU.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};VU.classNames={fullWidth:M8,zeroRight:$8};var LAn=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function FAn(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=LAn();return t&&e.setAttribute("nonce",t),e}function zAn(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function BAn(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var UAn=function(){var e=0,t=null;return{add:function(n){e==0&&(t=FAn())&&(zAn(t,n),BAn(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},qAn=function(){var e=UAn();return function(t,n){y.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Jht=function(){var e=qAn(),t=function(n){var r=n.styles,s=n.dynamic;return e(r,s),null};return t},VAn={left:0,top:0,right:0,gap:0},JY=function(e){return parseInt(e||"",10)||0},HAn=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[JY(n),JY(r),JY(s)]},ZAn=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return VAn;var t=HAn(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])}},WAn=Jht(),tj="data-scroll-locked",QAn=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 OCn(this):new wCn(this)}getCursor(t,n=0,r){let s=t.doc?t:as.create({doc:t});return r==null&&(r=s.doc.length),this.regexp?KC(this,s,n,r):XC(this,s,n,r)}}class hpt{constructor(t){this.spec=t}}function bCn(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 XC(e,t,n,r){let s;return e.wholeWord&&(s=xCn(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(s=bCn(e.test,t,s)),new Zb(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:a=>a.toLowerCase(),s)}function xCn(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(zz(s,n-a))!=Ji.Word||t(Bz(s,n-a))!=Ji.Word)&&(t(Bz(s,r-a))!=Ji.Word||t(zz(s,r-a))!=Ji.Word))}class wCn extends hpt{constructor(t){super(t)}nextMatch(t,n,r){let s=XC(this.spec,t,r,t.doc.length).nextOverlapping();if(s.done){let a=Math.min(t.doc.length,n+this.spec.unquoted.length);s=XC(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=XC(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=XC(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=XC(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 SCn(e,t,n){return(r,s,a)=>(!n||n(r,s,a))&&e(a[0],t,r,s)}function KC(e,t,n,r){let s;return e.wholeWord&&(s=kCn(t.charCategorizer(t.selection.main.head))),e.test&&(s=SCn(e.test,t,s)),new dpt(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:s},n,r)}function zz(e,t){return e.slice(nc(e,t,!1),t)}function Bz(e,t){return e.slice(t,nc(e,t))}function kCn(e){return(t,n,r)=>!r[0].length||(e(zz(r.input,r.index))!=Ji.Word||e(Bz(r.input,r.index))!=Ji.Word)&&(e(Bz(r.input,r.index+r[0].length))!=Ji.Word||e(zz(r.input,r.index+r[0].length))!=Ji.Word)}class OCn extends hpt{nextMatch(t,n,r){let s=KC(this.spec,t,r,t.doc.length).next();return s.done&&(s=KC(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=KC(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=KC(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=KC(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 AP=fr.define(),_be=fr.define(),hw=sl.define({create(e){return new BY(Nde(e).create(),null)},update(e,t){for(let n of t.effects)n.is(AP)?e=new BY(n.value.create(),e.panel):n.is(_be)&&(e=new BY(e.query,n.value?Cbe:null));return e},provide:e=>SP.from(e,t=>t.panel)});class BY{constructor(t,n){this.query=t,this.panel=n}}const _Cn=_n.mark({class:"cm-searchMatch"}),CCn=_n.mark({class:"cm-searchMatch cm-searchMatch-selected"}),ECn=ro.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(hw))}update(e){let t=e.state.field(hw);(t!=e.startState.field(hw)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return _n.none;let{view:n}=this,r=new od;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?CCn:_Cn)})}return r.finish()}},{decorations:e=>e.decorations});function tD(e){return t=>{let n=t.state.field(hw,!1);return n&&n.query.spec.valid?e(t,n):vpt(t)}}const Uz=tD((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let s=gt.single(r.from,r.to),a=e.state.facet(lN);return e.dispatch({selection:s,effects:[Ebe(e,r),a.scrollToMatch(s.main,e)],userEvent:"select.search"}),gpt(e),!0}),qz=tD((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,s=t.prevMatch(n,r,r);if(!s)return!1;let a=gt.single(s.from,s.to),i=e.state.facet(lN);return e.dispatch({selection:a,effects:[Ebe(e,s),i.scrollToMatch(a.main,e)],userEvent:"select.search"}),gpt(e),!0}),jCn=tD((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:gt.create(n.map(r=>gt.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),TCn=({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 Zb(e.doc,e.sliceDoc(r,s));!l.next().done;){if(a.length>1e3)return!1;l.value.from==r&&(i=a.length),a.push(gt.range(l.value.from,l.value.to))}return t(e.update({selection:gt.create(a,i),userEvent:"select.search.matches"})),!0},o4e=tD((e,{query:t})=>{let{state:n}=e,{from:r,to:s}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let i=a,l=[],c,u,d=[];i.precise?i.from==r&&i.to==s&&(u=n.toText(t.getReplacement(i)),l.push({from:i.from,to:i.to,insert:u}),d.push(It.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."))):i=t.nextMatch(n,i.from,i.to);let f=e.state.changes(l);return i&&(c=gt.single(i.from,i.to).map(f),d.push(Ebe(e,i)),d.push(n.facet(lN).scrollToMatch(c.main,e))),e.dispatch({changes:f,selection:c,effects:d,userEvent:"input.replace"}),!0}),NCn=tD((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let s of t.matchAll(e.state,1e9)){let{from:a,to:i,precise:l}=s;l&&n.push({from:a,to:i,insert:t.getReplacement(s)})}if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:It.announce.of(r),userEvent:"input.replace.all"}),!0});function Cbe(e){return e.state.facet(lN).createPanel(e)}function Nde(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(lN);return new ppt({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 mpt(e){let t=Uye(e,Cbe);return t&&t.dom.querySelector("[main-field]")}function gpt(e){let t=mpt(e);t&&t==e.root.activeElement&&t.select()}const vpt=e=>{let t=e.state.field(hw,!1);if(t&&t.panel){let n=mpt(e);if(n&&n!=e.root.activeElement){let r=Nde(e.state,t.query.spec);r.valid&&e.dispatch({effects:AP.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[_be.of(!0),t?AP.of(Nde(e.state,t.query.spec)):fr.appendConfig.of(PCn)]});return!0},ypt=e=>{let t=e.state.field(hw,!1);if(!t||!t.panel)return!1;let n=Uye(e,Cbe);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:_be.of(!1)}),!0},ICn=[{key:"Mod-f",run:vpt,scope:"editor search-panel"},{key:"F3",run:Uz,shift:qz,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Uz,shift:qz,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:ypt,scope:"editor search-panel"},{key:"Mod-Shift-l",run:TCn},{key:"Mod-Alt-g",run:oCn},{key:"Mod-d",run:yCn,preventDefault:!0}];class ACn{constructor(t){this.view=t;let n=this.query=t.state.field(hw).query.spec;this.commit=this.commit.bind(this),this.searchField=ai("input",{value:n.search,placeholder:$f(t,"Find"),"aria-label":$f(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ai("input",{value:n.replace,placeholder:$f(t,"Replace"),"aria-label":$f(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=ai("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=ai("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=ai("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(s,a,i){return ai("button",{class:"cm-button",name:s,onclick:a,type:"button"},i)}this.dom=ai("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,r("next",()=>Uz(t),[$f(t,"next")]),r("prev",()=>qz(t),[$f(t,"previous")]),r("select",()=>jCn(t),[$f(t,"all")]),ai("label",null,[this.caseField,$f(t,"match case")]),ai("label",null,[this.reField,$f(t,"regexp")]),ai("label",null,[this.wordField,$f(t,"by word")]),...t.state.readOnly?[]:[ai("br"),this.replaceField,r("replace",()=>o4e(t),[$f(t,"replace")]),r("replaceAll",()=>NCn(t),[$f(t,"replace all")])],ai("button",{name:"close",onclick:()=>ypt(t),"aria-label":$f(t,"close"),type:"button"},["×"])])}commit(){let t=new ppt({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:AP.of(t)}))}keydown(t){Kxn(this.view,t,"search-panel")?t.preventDefault():t.keyCode==13&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?qz:Uz)(this.view)):t.keyCode==13&&t.target==this.replaceField&&(t.preventDefault(),o4e(this.view))}update(t){for(let n of t.transactions)for(let r of n.effects)r.is(AP)&&!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(lN).top}}function $f(e,t){return e.state.phrase(t)}const iL=30,oL=/[\s\.,:;?!]/;function Ebe(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-iL),i=Math.min(s,n+iL),l=e.state.sliceDoc(a,i);if(a!=r.from){for(let c=0;c<iL;c++)if(!oL.test(l[c+1])&&oL.test(l[c])){l=l.slice(c);break}}if(i!=s){for(let c=l.length-1;c>l.length-iL;c--)if(!oL.test(l[c-1])&&oL.test(l[c])){l=l.slice(0,c);break}}return It.announce.of(`${e.state.phrase("current match")}. ${l} ${e.state.phrase("on line")} ${r.number}.`)}const RCn=It.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),PCn=[hw,vg.low(ECn),RCn];class l4e{constructor(t,n,r){this.from=t,this.to=n,this.diagnostic=r}}class HS{constructor(t,n,r){this.diagnostics=t,this.panel=n,this.selected=r}static init(t,n,r){let s=r.facet(RP).markerFilter;s&&(t=s(t,r));let a=t.slice().sort((d,f)=>d.from-f.from||d.to-f.to),i=new od,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=WCn(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,_n.widget({widget:new qCn(m),diagnostics:l.slice()}));else{let g=l.reduce((v,b)=>b.markClass?v+" "+b.markClass:v,"");i.add(p,h,_n.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 HS(u,n,zj(u))}}function zj(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 l4e(s,a,t||i.diagnostics[0]);else{if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new l4e(r.from,a,r.diagnostic)}}),r}function $Cn(e,t){let n=t.pos,r=t.end||n,s=e.state.facet(RP).hideOn(e,n,r);if(s!=null)return s;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(i=>i.is(bpt))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function MCn(e,t){return e.field(rp,!1)?t:t.concat(fr.appendConfig.of(QCn))}const bpt=fr.define(),jbe=fr.define(),xpt=fr.define(),rp=sl.define({create(){return new HS(_n.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=zj(n,e.selected.diagnostic,a)||zj(n,null,a)}!n.size&&s&&t.state.facet(RP).autoPanel&&(s=null),e=new HS(n,s,r)}for(let n of t.effects)if(n.is(bpt)){let r=t.state.facet(RP).autoPanel?n.value.length?PP.open:null:e.panel;e=HS.init(n.value,r,t.state)}else n.is(jbe)?e=new HS(e.diagnostics,n.value?PP.open:null,e.selected):n.is(xpt)&&(e=new HS(e.diagnostics,e.panel,n.value));return e},provide:e=>[SP.from(e,t=>t.panel),It.decorations.from(e,t=>t.diagnostics)]}),DCn=_n.mark({class:"cm-lintRange cm-lintRange-active"});function LCn(e,t,n){let{diagnostics:r}=e.state.field(rp),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(RP).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:FCn(e,s)}}}:null}function FCn(e,t){return ai("ul",{class:"cm-tooltip-lint"},t.map(n=>Spt(e,n,!1)))}const zCn=e=>{let t=e.state.field(rp,!1);(!t||!t.panel)&&e.dispatch({effects:MCn(e.state,[jbe.of(!0)])});let n=Uye(e,PP.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},c4e=e=>{let t=e.state.field(rp,!1);return!t||!t.panel?!1:(e.dispatch({effects:jbe.of(!1)}),!0)},BCn=e=>{let t=e.state.field(rp,!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)},UCn=[{key:"Mod-Shift-m",run:zCn,preventDefault:!0},{key:"F8",run:BCn}],RP=wn.define({combine(e){return{sources:e.map(t=>t.source).filter(t=>t!=null),...oy(e.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:u4e,tooltipFilter:u4e,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 u4e(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function wpt(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 Spt(e,t,n){var r;let s=n?wpt(t.actions):[];return ai("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},ai("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=zj(e.state.field(rp).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),ai("u",u.slice(d,d+1)),u.slice(d+1)],p=a.markClass?" "+a.markClass:"";return ai("button",{type:"button",class:"cm-diagnosticAction"+p,onclick:c,onmousedown:c,"aria-label":` Action: ${u}${d<0?"":` (access key "${s[i]})"`}.`},f)}),t.source&&ai("div",{class:"cm-diagnosticSource"},t.source))}class qCn extends Np{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return ai("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class d4e{constructor(t,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Spt(t,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class PP{constructor(t){this.view=t,this.items=[];let n=s=>{if(s.keyCode==27)c4e(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=wpt(a.actions);for(let l=0;l<i.length;l++)if(i[l].toUpperCase().charCodeAt(0)==s.keyCode){let c=zj(this.view.state.field(rp).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=ai("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=ai("div",{class:"cm-panel-lint"},this.list,ai("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>c4e(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(rp).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(rp),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 d4e(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 d4e(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(rp),r=zj(n.diagnostics,this.items[t].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:xpt.of(r)})}static open(t){return new PP(t)}}function VCn(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 lL(e){return VCn(`<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 HCn=It.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:lL("#d11")},".cm-lintRange-warning":{backgroundImage:lL("orange")},".cm-lintRange-info":{backgroundImage:lL("#999")},".cm-lintRange-hint":{backgroundImage:lL("#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 ZCn(e){return e=="error"?4:e=="warning"?3:e=="info"?2:1}function WCn(e){let t="hint",n=1;for(let r of e){let s=ZCn(r.severity);s>n&&(n=s,t=r.severity)}return t}const QCn=[rp,It.decorations.compute([rp],e=>{let{selected:t,panel:n}=e.field(rp);return!t||!n||t.from==t.to?_n.none:_n.set([DCn.range(t.from,t.to)])}),z0n(LCn,{hideOn:$Cn}),HCn];var f4e=function(t){t===void 0&&(t={});var{crosshairCursor:n=!1}=t,r=[];t.closeBracketsKeymap!==!1&&(r=r.concat(D1n)),t.defaultKeymap!==!1&&(r=r.concat(sCn)),t.searchKeymap!==!1&&(r=r.concat(ICn)),t.historyKeymap!==!1&&(r=r.concat(d_n)),t.foldKeymap!==!1&&(r=r.concat(Swn)),t.completionKeymap!==!1&&(r=r.concat(gdt)),t.lintKeymap!==!1&&(r=r.concat(UCn));var s=[];return t.lineNumbers!==!1&&s.push(K0n()),t.highlightActiveLineGutter!==!1&&s.push(twn()),t.highlightSpecialChars!==!1&&s.push(h0n()),t.history!==!1&&s.push(n_n()),t.foldGutter!==!1&&s.push(Cwn()),t.drawSelection!==!1&&s.push(s0n()),t.dropCursor!==!1&&s.push(c0n()),t.allowMultipleSelections!==!1&&s.push(as.allowMultipleSelections.of(!0)),t.indentOnInput!==!1&&s.push(hwn()),t.syntaxHighlighting!==!1&&s.push(m1(Nwn,{fallback:!0})),t.bracketMatching!==!1&&s.push(Dwn()),t.closeBrackets!==!1&&s.push(R1n()),t.autocompletion!==!1&&s.push(mdt()),t.rectangularSelection!==!1&&s.push(j0n()),n!==!1&&s.push(I0n()),t.highlightActiveLine!==!1&&s.push(x0n()),t.highlightSelectionMatches!==!1&&s.push(uCn()),t.tabSize&&typeof t.tabSize=="number"&&s.push(sN.of(" ".repeat(t.tabSize))),s.concat([rN.of(r.flat())]).filter(Boolean)};const GCn="#e5c07b",p4e="#e06c75",YCn="#56b6c2",XCn="#ffffff",P8="#abb2bf",Ide="#7d8799",KCn="#61afef",JCn="#98c379",h4e="#d19a66",eEn="#c678dd",tEn="#21252b",m4e="#2c313a",g4e="#282c34",UY="#353a42",nEn="#3E4451",v4e="#528bff",rEn=It.theme({"&":{color:P8,backgroundColor:g4e},".cm-content":{caretColor:v4e},".cm-cursor, .cm-dropCursor":{borderLeftColor:v4e},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:nEn},".cm-panels":{backgroundColor:tEn,color:P8},".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:g4e,color:Ide,border:"none"},".cm-activeLineGutter":{backgroundColor:m4e},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:UY},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:UY,borderBottomColor:UY},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:m4e,color:P8}}},{dark:!0}),sEn=yg.define([{tag:de.keyword,color:eEn},{tag:[de.name,de.deleted,de.character,de.propertyName,de.macroName],color:p4e},{tag:[de.function(de.variableName),de.labelName],color:KCn},{tag:[de.color,de.constant(de.name),de.standard(de.name)],color:h4e},{tag:[de.definition(de.name),de.separator],color:P8},{tag:[de.typeName,de.className,de.number,de.changed,de.annotation,de.modifier,de.self,de.namespace],color:GCn},{tag:[de.operator,de.operatorKeyword,de.url,de.escape,de.regexp,de.link,de.special(de.string)],color:YCn},{tag:[de.meta,de.comment],color:Ide},{tag:de.strong,fontWeight:"bold"},{tag:de.emphasis,fontStyle:"italic"},{tag:de.strikethrough,textDecoration:"line-through"},{tag:de.link,color:Ide,textDecoration:"underline"},{tag:de.heading,fontWeight:"bold",color:p4e},{tag:[de.atom,de.bool,de.special(de.variableName)],color:h4e},{tag:[de.processingInstruction,de.string,de.inserted],color:JCn},{tag:de.invalid,color:XCn}]),aEn=[rEn,m1(sEn)];var iEn=It.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),oEn=function(t){t===void 0&&(t={});var{indentWithTab:n=!0,editable:r=!0,readOnly:s=!1,theme:a="light",placeholder:i="",basicSetup:l=!0}=t,c=[];switch(n&&c.unshift(rN.of([aCn])),l&&(typeof l=="boolean"?c.unshift(f4e()):c.unshift(f4e(l))),i&&c.unshift(O0n(i)),a){case"light":c.push(iEn);break;case"dark":c.push(aEn);break;case"none":break;default:c.push(a);break}return r===!1&&c.push(It.editable.of(!1)),s&&c.push(as.readOnly.of(!0)),[...c]},lEn=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 cEn{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 y4e{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 qY=null,uEn=()=>typeof window>"u"?new y4e:(qY||(qY=new y4e),qY),b4e=iy.define(),dEn=200,fEn=[];function pEn(e){var{value:t,selection:n,onChange:r,onStatistics:s,onCreateEditor:a,onUpdate:i,extensions:l=fEn,autoFocus:c,theme:u="light",height:d=null,minHeight:f=null,maxHeight:p=null,width:h=null,minWidth:m=null,maxWidth:g=null,placeholder:v="",editable:b=!0,readOnly:S=!1,indentWithTab:w=!0,basicSetup:O=!0,root:_,initialState:C}=e,[E,T]=y.useState(),[N,I]=y.useState(),[R,$]=y.useState(),B=y.useState(()=>({current:null}))[0],M=y.useState(()=>({current:null}))[0],F=It.theme({"&":{height:d,minHeight:f,maxHeight:p,width:h,minWidth:m,maxWidth:g},"& .cm-scroller":{height:"100% !important"}}),V=It.updateListener.of(U=>{if(U.docChanged&&typeof r=="function"&&!U.transactions.some(q=>q.annotation(b4e))){B.current?B.current.reset():(B.current=new cEn(()=>{if(M.current){var q=M.current;M.current=null,q()}B.current=null},dEn),uEn().add(B.current));var D=U.state.doc,G=D.toString();r(G,U)}s&&s(lEn(U))}),L=oEn({theme:u,editable:b,readOnly:S,placeholder:v,indentWithTab:w,basicSetup:O}),z=[V,F,...L];return i&&typeof i=="function"&&z.push(It.updateListener.of(i)),z=z.concat(l),y.useLayoutEffect(()=>{if(E&&!R){var U={doc:t,selection:n,extensions:z},D=C?as.fromJSON(C.json,U,C.fields):as.create(U);if($(D),!N){var G=new It({state:D,parent:E,root:_});I(G),a&&a(G,D)}}return()=>{N&&($(void 0),I(void 0))}},[E,R]),y.useEffect(()=>{e.container&&T(e.container)},[e.container]),y.useEffect(()=>()=>{N&&(N.destroy(),I(void 0)),B.current&&(B.current.cancel(),B.current=null)},[N]),y.useEffect(()=>{c&&N&&N.focus()},[c,N]),y.useEffect(()=>{N&&N.dispatch({effects:fr.reconfigure.of(z)})},[u,l,d,f,p,h,m,g,v,b,S,w,O,r,i]),y.useEffect(()=>{if(t!==void 0){var U=N?N.state.doc.toString():"";if(N&&t!==U){var D=B.current&&!B.current.isDone,G=()=>{N&&t!==N.state.doc.toString()&&N.dispatch({changes:{from:0,to:N.state.doc.toString().length,insert:t||""},annotations:[b4e.of(!0)]})};D?M.current=G:G()}}},[t,N]),{state:R,setState:$,view:N,setView:I,container:E,setContainer:T}}var hEn=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],ku=y.forwardRef((e,t)=>{var{className:n,value:r="",selection:s,extensions:a=[],onChange:i,onStatistics:l,onCreateEditor:c,onUpdate:u,autoFocus:d,theme:f="light",height:p,minHeight:h,maxHeight:m,width:g,minWidth:v,maxWidth:b,basicSetup:S,placeholder:w,indentWithTab:O,editable:_,readOnly:C,root:E,initialState:T}=e,N=Nft(e,hEn),I=y.useRef(null),{state:R,view:$,container:B,setContainer:M}=pEn({root:E,value:r,autoFocus:d,theme:f,height:p,minHeight:h,maxHeight:m,width:g,minWidth:v,maxWidth:b,basicSetup:S,placeholder:w,indentWithTab:O,editable:_,readOnly:C,selection:s,onChange:i,onStatistics:l,onCreateEditor:c,onUpdate:u,extensions:a,initialState:T});y.useImperativeHandle(t,()=>({editor:I.current,state:R,view:$}),[I,B,R,$]);var F=y.useCallback(L=>{I.current=L,M(L)},[M]);if(typeof r!="string")throw new Error("value must be typeof string but got "+typeof r);var V=typeof f=="string"?"cm-theme-"+f:"cm-theme";return o.jsx("div",nO({ref:F,className:""+V+(n?" "+n:"")},N))});ku.displayName="CodeMirror";const mEn=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),kpt=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();var gEn={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 vEn=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,...gEn,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:kpt("lucide",s),...l},[...i.map(([u,d])=>y.createElement(u,d)),...Array.isArray(a)?a:[a]]));const gn=(e,t)=>{const n=y.forwardRef(({className:r,...s},a)=>y.createElement(vEn,{ref:a,iconNode:t,className:kpt(`lucide-${mEn(e)}`,r),...s}));return n.displayName=`${e}`,n};const yEn=[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]],Vz=gn("AlignJustify",yEn);const bEn=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],$P=gn("AlignLeft",bEn);const xEn=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],RU=gn("ArrowDown",xEn);const wEn=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],PU=gn("ArrowLeft",wEn);const SEn=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],MP=gn("ArrowRight",SEn);const kEn=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],$U=gn("ArrowUp",kEn);const OEn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]],Opt=gn("Ban",OEn);const _En=[["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"}]],ew=gn("Braces",_En);const CEn=[["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"}]],EEn=gn("Brain",CEn);const jEn=[["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"}]],x4e=gn("Calendar",jEn);const TEn=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],hx=gn("Check",TEn);const NEn=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Tbe=gn("ChevronDown",NEn);const IEn=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],AEn=gn("ChevronLeft",IEn);const REn=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Bj=gn("ChevronRight",REn);const PEn=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],$En=gn("ChevronUp",PEn);const MEn=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],Nbe=gn("ChevronsDownUp",MEn);const DEn=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],LEn=gn("ChevronsDown",DEn);const FEn=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],zEn=gn("ChevronsLeft",FEn);const BEn=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],_pt=gn("ChevronsRight",BEn);const UEn=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],nD=gn("ChevronsUpDown",UEn);const qEn=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],VEn=gn("ChevronsUp",qEn);const HEn=[["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"}]],ZEn=gn("CircleGauge",HEn);const WEn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]],Cpt=gn("CircleSlash",WEn);const QEn=[["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"}]],GEn=gn("CircleX",QEn);const YEn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],XEn=gn("Circle",YEn);const KEn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],JEn=gn("Clock",KEn);const ejn=[["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"}]],tjn=gn("Component",ejn);const njn=[["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"}]],Ept=gn("Copy",njn);const rjn=[["polyline",{points:"15 10 20 15 15 20",key:"1q7qjw"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],sjn=gn("CornerDownRight",rjn);const ajn=[["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"}]],ijn=gn("Download",ajn);const ojn=[["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"}]],ljn=gn("EllipsisVertical",ojn);const cjn=[["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"}]],ujn=gn("EqualNot",cjn);const djn=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],fjn=gn("Equal",djn);const pjn=[["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"}]],hjn=gn("Expand",pjn);const mjn=[["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"}]],Ibe=gn("ExternalLink",mjn);const gjn=[["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"}]],vjn=gn("Eye",gjn);const yjn=[["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"}]],Ade=gn("FileInput",yjn);const bjn=[["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"}]],Rde=gn("FileOutput",bjn);const xjn=[["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"}]],wjn=gn("FileText",xjn);const Sjn=[["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"}]],kjn=gn("File",Sjn);const Ojn=[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]],_jn=gn("Filter",Ojn);const Cjn=[["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"}]],Ejn=gn("FoldVertical",Cjn);const jjn=[["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"}]],Tjn=gn("Folder",jjn);const Njn=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ijn=gn("Gauge",Njn);const Ajn=[["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"}]],Abe=gn("Hash",Ajn);const Rjn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],jpt=gn("Info",Rjn);const Pjn=[["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"}]],$jn=gn("Keyboard",Pjn);const Mjn=[["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"}]],Djn=gn("Lightbulb",Mjn);const Ljn=[["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"}]],Tpt=gn("Link2",Ljn);const Fjn=[["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"}]],zjn=gn("ListFilterPlus",Fjn);const Bjn=[["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"}]],Ujn=gn("ListTree",Bjn);const qjn=[["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"}]],Vjn=gn("ListX",qjn);const Hjn=[["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"}]],Rbe=gn("List",Hjn);const Zjn=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Wjn=gn("LoaderCircle",Zjn);const Qjn=[["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"}]],Gjn=gn("Lock",Qjn);const Yjn=[["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"}]],Xjn=gn("LogIn",Yjn);const Kjn=[["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"}]],Jjn=gn("Logs",Kjn);const eTn=[["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"}]],tTn=gn("Menu",eTn);const nTn=[["path",{d:"M5 12h14",key:"1ays0h"}]],rTn=gn("Minus",nTn);const sTn=[["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"}]],aTn=gn("OctagonAlert",sTn);const iTn=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],oTn=gn("PanelRight",iTn);const lTn=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Pbe=gn("Plus",lTn);const cTn=[["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"}]],Npt=gn("Save",cTn);const uTn=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],Uj=gn("Search",uTn);const dTn=[["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"}]],fTn=gn("ShieldX",dTn);const pTn=[["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"}]],hTn=gn("TextSearch",pTn);const mTn=[["path",{d:"M17 6.1H3",key:"wptmhv"}],["path",{d:"M21 12.1H3",key:"1j38uz"}],["path",{d:"M15.1 18H3",key:"1nb16a"}]],gTn=gn("Text",mTn);const vTn=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]],$be=gn("ToggleLeft",vTn);const yTn=[["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"}]],Ipt=gn("Trash2",yTn);const bTn=[["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"}]],xTn=gn("TrendingDown",bTn);const wTn=[["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"}]],STn=gn("TrendingUp",wTn);const kTn=[["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"}]],MU=gn("TriangleAlert",kTn);const OTn=[["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"}]],Mbe=gn("Type",OTn);const _Tn=[["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"}]],CTn=gn("UnfoldVertical",_Tn);const ETn=[["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"}]],jTn=gn("WandSparkles",ETn);const TTn=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],rf=gn("X",TTn);function NTn(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 ITn=e=>{switch(e){case"success":return PTn;case"info":return MTn;case"warning":return $Tn;case"error":return DTn;default:return null}},ATn=Array(12).fill(0),RTn=({visible:e,className:t})=>De.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},De.createElement("div",{className:"sonner-spinner"},ATn.map((n,r)=>De.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),PTn=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"})),$Tn=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"})),MTn=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"})),DTn=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"})),LTn=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"})),FTn=()=>{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 Pde=1;class zTn{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:Pde++,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(UTn(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||Pde++;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 Td=new zTn,BTn=(e,t)=>{const n=t?.id||Pde++;return Td.addToast({title:e,...t,id:n}),n},UTn=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",qTn=BTn,VTn=()=>Td.toasts,HTn=()=>Td.getActiveToasts(),yu=Object.assign(qTn,{success:Td.success,info:Td.info,warning:Td.warning,error:Td.error,custom:Td.custom,message:Td.message,promise:Td.promise,dismiss:Td.dismiss,loading:Td.loading},{getHistory:VTn,getToasts:HTn});NTn("[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 cL(e){return e.label!==void 0}const ZTn=3,WTn="24px",QTn="16px",w4e=4e3,GTn=356,YTn=14,XTn=45,KTn=200;function Fg(...e){return e.filter(Boolean).join(" ")}function JTn(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const eNn=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:S,expanded:w,removeToast:O,defaultRichColors:_,closeButton:C,style:E,cancelButtonStyle:T,actionButtonStyle:N,className:I="",descriptionClassName:R="",duration:$,position:B,gap:M,expandByDefault:F,classNames:V,icons:L,closeButtonAriaLabel:z="Close toast"}=e,[U,D]=De.useState(null),[G,q]=De.useState(null),[P,H]=De.useState(!1),[W,X]=De.useState(!1),[ae,ee]=De.useState(!1),[J,ie]=De.useState(!1),[ce,Y]=De.useState(!1),[ne,ue]=De.useState(0),[pe,re]=De.useState(0),he=De.useRef(f.duration||$||w4e),xe=De.useRef(null),be=De.useRef(null),Ie=b===0,ke=b+1<=g,Te=f.type,Le=f.dismissible!==!1,le=f.className||"",se=f.descriptionClassName||"",te=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||$||w4e,[f.duration,$]),Ne=De.useRef(0),Re=De.useRef(0),Ge=De.useRef(0),He=De.useRef(null),[Oe,_e]=B.split("-"),Ee=De.useMemo(()=>v.reduce((bt,At,rn)=>rn>=te?bt:bt+At.height,0),[v,te]),je=FTn(),$e=f.invert||d,Fe=Te==="loading";Re.current=De.useMemo(()=>te*M+Ee,[te,Ee]),De.useEffect(()=>{he.current=ye},[ye]),De.useEffect(()=>{H(!0)},[]),De.useEffect(()=>{const bt=be.current;if(bt){const At=bt.getBoundingClientRect().height;return re(At),m(rn=>[{toastId:f.id,height:At,position:f.position},...rn]),()=>m(rn=>rn.filter(We=>We.toastId!==f.id))}},[m,f.id]),De.useLayoutEffect(()=>{if(!P)return;const bt=be.current,At=bt.style.height;bt.style.height="auto";const rn=bt.getBoundingClientRect().height;bt.style.height=At,re(rn),m(We=>We.find(ct=>ct.toastId===f.id)?We.map(ct=>ct.toastId===f.id?{...ct,height:rn}:ct):[{toastId:f.id,height:rn,position:f.position},...We])},[P,f.title,f.description,m,f.id,f.jsx,f.action,f.cancel]);const Ke=De.useCallback(()=>{X(!0),ue(Re.current),m(bt=>bt.filter(At=>At.toastId!==f.id)),setTimeout(()=>{O(f)},KTn)},[f,O,m,Re]);De.useEffect(()=>{if(f.promise&&Te==="loading"||f.duration===1/0||f.type==="loading")return;let bt;return w||h||je?(()=>{if(Ge.current<Ne.current){const We=new Date().getTime()-Ne.current;he.current=he.current-We}Ge.current=new Date().getTime()})():he.current!==1/0&&(Ne.current=new Date().getTime(),bt=setTimeout(()=>{f.onAutoClose==null||f.onAutoClose.call(f,f),Ke()},he.current)),()=>clearTimeout(bt)},[w,h,f,Te,je,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 At;return De.createElement("div",{className:Fg(V?.loader,f==null||(At=f.classNames)==null?void 0:At.loader,"sonner-loader"),"data-visible":Te==="loading"},L.loading)}return De.createElement(RTn,{className:Fg(V?.loader,f==null||(bt=f.classNames)==null?void 0:bt.loader),visible:Te==="loading"})}const Pt=f.icon||L?.[Te]||ITn(Te);var _t,an;return De.createElement("li",{tabIndex:0,ref:be,className:Fg(I,le,V?.toast,f==null||(t=f.classNames)==null?void 0:t.toast,V?.default,V?.[Te],f==null||(n=f.classNames)==null?void 0:n[Te]),"data-sonner-toast":"","data-rich-colors":(_t=f.richColors)!=null?_t:_,"data-styled":!(f.jsx||f.unstyled||p),"data-mounted":P,"data-promise":!!f.promise,"data-swiped":ce,"data-removed":W,"data-visible":ke,"data-y-position":Oe,"data-x-position":_e,"data-index":b,"data-front":Ie,"data-swiping":ae,"data-dismissible":Le,"data-type":Te,"data-invert":$e,"data-swipe-out":J,"data-swipe-direction":G,"data-expanded":!!(w||F&&P),"data-testid":f.testId,style:{"--index":b,"--toasts-before":b,"--z-index":S.length-b,"--offset":`${W?ne:Re.current}px`,"--initial-height":F?"auto":`${pe}px`,...E,...f.style},onDragEnd:()=>{ee(!1),D(null),He.current=null},onPointerDown:bt=>{bt.button!==2&&(Fe||!Le||(xe.current=new Date,ue(Re.current),bt.target.setPointerCapture(bt.pointerId),bt.target.tagName!=="BUTTON"&&(ee(!0),He.current={x:bt.clientX,y:bt.clientY})))},onPointerUp:()=>{var bt,At,rn;if(J||!Le)return;He.current=null;const We=Number(((bt=be.current)==null?void 0:bt.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),at=Number(((At=be.current)==null?void 0:At.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ct=new Date().getTime()-((rn=xe.current)==null?void 0:rn.getTime()),ln=U==="x"?We:at,Jt=Math.abs(ln)/ct;if(Math.abs(ln)>=XTn||Jt>.11){ue(Re.current),f.onDismiss==null||f.onDismiss.call(f,f),q(U==="x"?We>0?"right":"left":at>0?"down":"up"),Ke(),ie(!0);return}else{var Ce,Me;(Ce=be.current)==null||Ce.style.setProperty("--swipe-amount-x","0px"),(Me=be.current)==null||Me.style.setProperty("--swipe-amount-y","0px")}Y(!1),ee(!1),D(null)},onPointerMove:bt=>{var At,rn,We;if(!He.current||!Le||((At=window.getSelection())==null?void 0:At.toString().length)>0)return;const ct=bt.clientY-He.current.y,ln=bt.clientX-He.current.x;var Jt;const Ce=(Jt=e.swipeDirections)!=null?Jt:JTn(B);!U&&(Math.abs(ln)>1||Math.abs(ct)>1)&&D(Math.abs(ln)>Math.abs(ct)?"x":"y");let Me={x:0,y:0};const Ve=Xe=>1/(1.5+Math.abs(Xe)/20);if(U==="y"){if(Ce.includes("top")||Ce.includes("bottom"))if(Ce.includes("top")&&ct<0||Ce.includes("bottom")&&ct>0)Me.y=ct;else{const Xe=ct*Ve(ct);Me.y=Math.abs(Xe)<Math.abs(ct)?Xe:ct}}else if(U==="x"&&(Ce.includes("left")||Ce.includes("right")))if(Ce.includes("left")&&ln<0||Ce.includes("right")&&ln>0)Me.x=ln;else{const Xe=ln*Ve(ln);Me.x=Math.abs(Xe)<Math.abs(ln)?Xe:ln}(Math.abs(Me.x)>0||Math.abs(Me.y)>0)&&Y(!0),(rn=be.current)==null||rn.style.setProperty("--swipe-amount-x",`${Me.x}px`),(We=be.current)==null||We.style.setProperty("--swipe-amount-y",`${Me.y}px`)}},me&&!f.jsx&&Te!=="loading"?De.createElement("button",{"aria-label":z,"data-disabled":Fe,"data-close-button":!0,onClick:Fe||!Le?()=>{}:()=>{Ke(),f.onDismiss==null||f.onDismiss.call(f,f)},className:Fg(V?.closeButton,f==null||(r=f.classNames)==null?void 0:r.closeButton)},(an=L?.close)!=null?an:LTn):null,(Te||f.icon||f.promise)&&f.icon!==null&&(L?.[Te]!==null||f.icon)?De.createElement("div",{"data-icon":"",className:Fg(V?.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"?Pt:null):null,De.createElement("div",{"data-content":"",className:Fg(V?.content,f==null||(a=f.classNames)==null?void 0:a.content)},De.createElement("div",{"data-title":"",className:Fg(V?.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:Fg(R,se,V?.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&&cL(f.cancel)?De.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||T,onClick:bt=>{cL(f.cancel)&&Le&&(f.cancel.onClick==null||f.cancel.onClick.call(f.cancel,bt),Ke())},className:Fg(V?.cancelButton,f==null||(c=f.classNames)==null?void 0:c.cancelButton)},f.cancel.label):null,De.isValidElement(f.action)?f.action:f.action&&cL(f.action)?De.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||N,onClick:bt=>{cL(f.action)&&(f.action.onClick==null||f.action.onClick.call(f.action,bt),!bt.defaultPrevented&&Ke())},className:Fg(V?.actionButton,f==null||(u=f.classNames)==null?void 0:u.actionButton)},f.action.label):null)};function S4e(){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 tNn(e,t){const n={};return[e,t].forEach((r,s)=>{const a=s===1,i=a?"--mobile-offset":"--offset",l=a?QTn:WTn;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 nNn=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=ZTn,toastOptions:b,dir:S=S4e(),gap:w=YTn,icons:O,containerAriaLabel:_="Notifications"}=t,[C,E]=De.useState([]),T=De.useMemo(()=>r?C.filter(P=>P.toasterId===r):C.filter(P=>!P.toasterId),[C,r]),N=De.useMemo(()=>Array.from(new Set([a].concat(T.filter(P=>P.position).map(P=>P.position)))),[T,a]),[I,R]=De.useState([]),[$,B]=De.useState(!1),[M,F]=De.useState(!1),[V,L]=De.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),z=De.useRef(null),U=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),D=De.useRef(null),G=De.useRef(!1),q=De.useCallback(P=>{E(H=>{var W;return(W=H.find(X=>X.id===P.id))!=null&&W.delete||Td.dismiss(P.id),H.filter(({id:X})=>X!==P.id)})},[]);return De.useEffect(()=>Td.subscribe(P=>{if(P.dismiss){requestAnimationFrame(()=>{E(H=>H.map(W=>W.id===P.id?{...W,delete:!0}:W))});return}setTimeout(()=>{pve.flushSync(()=>{E(H=>{const W=H.findIndex(X=>X.id===P.id);return W!==-1?[...H.slice(0,W),{...H[W],...P},...H.slice(W+1)]:[P,...H]})})})}),[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 P=window.matchMedia("(prefers-color-scheme: dark)");try{P.addEventListener("change",({matches:H})=>{L(H?"dark":"light")})}catch{P.addListener(({matches:W})=>{try{L(W?"dark":"light")}catch(X){console.error(X)}})}},[p]),De.useEffect(()=>{C.length<=1&&B(!1)},[C]),De.useEffect(()=>{const P=H=>{var W;if(i.every(ee=>H[ee]||H.code===ee)){var ae;B(!0),(ae=z.current)==null||ae.focus()}H.code==="Escape"&&(document.activeElement===z.current||(W=z.current)!=null&&W.contains(document.activeElement))&&B(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[i]),De.useEffect(()=>{if(z.current)return()=>{D.current&&(D.current.focus({preventScroll:!0}),D.current=null,G.current=!1)}},[z.current]),De.createElement("section",{ref:n,"aria-label":`${_} ${U}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},N.map((P,H)=>{var W;const[X,ae]=P.split("-");return T.length?De.createElement("ol",{key:P,dir:S==="auto"?S4e():S,tabIndex:-1,ref:z,className:u,"data-sonner-toaster":!0,"data-sonner-theme":V,"data-y-position":X,"data-x-position":ae,style:{"--front-toast-height":`${((W=I[0])==null?void 0:W.height)||0}px`,"--width":`${GTn}px`,"--gap":`${w}px`,...g,...tNn(d,f)},onBlur:ee=>{G.current&&!ee.currentTarget.contains(ee.relatedTarget)&&(G.current=!1,D.current&&(D.current.focus({preventScroll:!0}),D.current=null))},onFocus:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||G.current||(G.current=!0,D.current=ee.relatedTarget)},onMouseEnter:()=>B(!0),onMouseMove:()=>B(!0),onMouseLeave:()=>{M||B(!1)},onDragEnd:()=>B(!1),onPointerDown:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||F(!0)},onPointerUp:()=>F(!1)},T.filter(ee=>!ee.position&&H===0||ee.position===P).map((ee,J)=>{var ie,ce;return De.createElement(eNn,{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:(ce=b?.closeButton)!=null?ce:c,interacting:M,position:P,style:b?.style,unstyled:b?.unstyled,classNames:b?.classNames,cancelButtonStyle:b?.cancelButtonStyle,actionButtonStyle:b?.actionButtonStyle,closeButtonAriaLabel:b?.closeButtonAriaLabel,removeToast:q,toasts:T.filter(Y=>Y.position==ee.position),heights:I.filter(Y=>Y.position==ee.position),setHeights:R,expandByDefault:l,gap:w,expanded:$,swipeDirections:t.swipeDirections})})):null}))}),Dbe=({className:e,toastOptions:t,...n})=>o.jsx(nNn,{...n,closeButton:!0,richColors:!0,className:K("mastra-toaster",e),toastOptions:{duration:5e3,...t}}),DU=(e,t)=>Array.isArray(e)?e.map(t):t(e),Be=(e,t={})=>{if(Array.isArray(e))return e.map(n=>yu(n,t));if(De.isValidElement(e)||typeof e=="string")return yu(e,t);throw new Error("Invalid message type")};Be.success=(e,t={})=>DU(e,n=>yu.success(n,t));Be.error=(e,t={})=>DU(e,n=>yu.error(n,t));Be.warning=(e,t={})=>DU(e,n=>yu.warning(n,t));Be.info=(e,t={})=>DU(e,n=>yu.info(n,t));Be.custom=(e,t={})=>yu(e,t);Be.dismiss=e=>yu.dismiss(e);Be.promise=({myPromise:e,loadingMessage:t,successMessage:n,errorMessage:r,onSuccess:s,onError:a,options:i={}})=>yu.promise(e,{loading:t??"Loading...",success:l=>(s?.(l),n),error:l=>(a?.(l),r||(l instanceof Error?l.message:"Error...")),...i});function ag({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 Ia({content:e,copyMessage:t,tooltip:n="Copy to clipboard",size:r="sm",className:s}){const[a,i]=y.useState(!1),{handleCopy:l}=ag({text:e,copyMessage:t}),c=()=>{l(),i(!0),setTimeout(()=>i(!1),2e3)};return o.jsxs(Yn,{children:[o.jsx(Hn,{asChild:!0,children:o.jsx(fe,{onClick:c,type:"button",size:r,className:s,"aria-label":a?"Copied!":n,children:a?o.jsx(hx,{}):o.jsx(Ept,{})})}),o.jsx(Zn,{children:a?"Copied!":n})]})}const rNn="mastra-theme",sNn="mastra-playground-store",$de=e=>e==="dark"||e==="light"||e==="system",aNn=e=>{try{const t=e.getItem(sNn);if(!t)return;const r=JSON.parse(t)?.state?.theme;return $de(r)?r:void 0}catch{return}},iNn=(e=rNn)=>({get(){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if($de(t))return t;const n=aNn(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}$de(r.newValue)&&t(r.newValue)}};return window.addEventListener("storage",n),()=>window.removeEventListener("storage",n)}}),Apt=y.createContext(null),Rpt="(prefers-color-scheme: dark)",oNn=typeof window>"u"?y.useEffect:y.useLayoutEffect,Ppt=()=>typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia(Rpt).matches?"dark":"light",$pt=e=>{if(typeof window>"u"||typeof window.matchMedia!="function")return()=>{};const t=window.matchMedia(Rpt);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},lNn=(e,t)=>{e.classList.remove(t==="dark"?"light":"dark"),e.classList.add(t)},Mpt=({children:e,defaultTheme:t="system",storageKey:n,target:r})=>{const s=y.useMemo(()=>iNn(n),[n]),a=y.useRef(null),[i,l]=y.useState(()=>s.get()??t),c=y.useSyncExternalStore($pt,Ppt,()=>"dark");y.useEffect(()=>s.subscribe(f=>l(f??t)),[s,t]);const u=i==="system"?c:i;oNn(()=>{const f=r??(typeof window>"u"?null:window.document.documentElement);a.current&&a.current!==f&&a.current.classList.remove("dark","light"),f&&lNn(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(Apt.Provider,{value:d,children:e})},cNn=()=>{},cN=()=>{const e=y.useContext(Apt),t=y.useSyncExternalStore($pt,Ppt,()=>"dark");return y.useMemo(()=>e??{theme:"system",resolvedTheme:t,systemTheme:t,setTheme:cNn},[e,t])};function uNn(e){return new Kk(Wye.define(e))}const Dpt=[Tm.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return ho(()=>Promise.resolve().then(()=>sL),[],import.meta.url).then(e=>e.javascript())}}),Tm.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return ho(()=>Promise.resolve().then(()=>Gwn),void 0,import.meta.url).then(e=>e.json())}}),Tm.of({name:"JSX",extensions:["jsx"],load(){return ho(()=>Promise.resolve().then(()=>sL),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),Tm.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return ho(()=>Promise.resolve().then(()=>qOn),void 0,import.meta.url).then(e=>e.markdown())}}),Tm.of({name:"TSX",extensions:["tsx"],load(){return ho(()=>Promise.resolve().then(()=>sL),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Tm.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return ho(()=>Promise.resolve().then(()=>sL),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),Tm.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return ho(()=>import("./shell-CjFT_Tl9.js"),[],import.meta.url).then(e=>uNn(e.shell))}})];function dNn(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 fNn(e){const t=dNn(e);return mdt({override:[pNn(t)],defaultKeymap:!0,closeOnBlur:!0,icons:!1})}function pNn(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 hNn=/\{\{([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)\}\}/g,mNn=_n.mark({class:"cm-variable-highlight"}),k4e=new Tut({regexp:hNn,decoration:()=>mNn}),gNn=ro.fromClass(class{decorations;constructor(e){this.decorations=k4e.createDeco(e)}update(e){this.decorations=k4e.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}),vNn=gNn;function yNn(){const e=iN({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=It.theme({".cm-editor":{backgroundColor:"transparent"},".cm-content":{color:"var(--neutral6)",caretColor:"var(--neutral6)"},".cm-lineNumbers .cm-gutterElement":{color:"var(--neutral2)"},".cm-activeLineGutter":{color:"var(--neutral3)"},".cm-cursor":{borderLeftColor:"var(--neutral6)"},".cm-selectionBackground, .cm-content ::selection":{backgroundColor:"color-mix(in srgb, var(--accent3) 22%, transparent)"},".cm-tooltip-autocomplete":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",borderRadius:"6px",boxShadow:"0 8px 16px rgba(0, 0, 0, 0.2)"},".cm-tooltip-autocomplete > ul":{fontFamily:"var(--font-mono)"},".cm-completionLabel":{color:"var(--neutral6)"},".cm-completionDetail":{color:"var(--neutral3)",fontSize:"0.7rem",marginLeft:"auto",paddingLeft:"12px"},".cm-completionInfo":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",color:"var(--neutral3)",padding:"8px 12px"},".cm-completionIcon":{display:"none"},"ul.cm-completionList li[aria-selected]":{backgroundColor:"var(--surface4)",color:"var(--neutral6)"},".cm-line .cm-variable-highlight":{color:"var(--accent6) !important",fontWeight:"500"}});return[e,t]}function bNn(){const e=It.theme({"&":{backgroundColor:"transparent",color:"var(--neutral6)",fontSize:"0.8rem"},"&.cm-editor .cm-scroller":{fontFamily:"var(--font-mono)"},".cm-gutters":{backgroundColor:"transparent",color:"var(--neutral2)",borderRight:"none"},".cm-content":{color:"var(--neutral6)",caretColor:"var(--neutral6)"},".cm-activeLine":{backgroundColor:"transparent"},".cm-lineNumbers .cm-gutterElement":{color:"var(--neutral2)"},".cm-activeLineGutter":{backgroundColor:"transparent",color:"var(--neutral3)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--neutral6)"},"&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection":{background:"color-mix(in srgb, var(--accent3) 22%, transparent) !important"},".cm-tooltip-autocomplete":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",borderRadius:"6px",boxShadow:"0 8px 16px rgba(0, 0, 0, 0.2)"},".cm-tooltip-autocomplete > ul":{fontFamily:"var(--font-mono)"},".cm-completionLabel":{color:"var(--neutral6)"},".cm-completionDetail":{color:"var(--neutral3)",fontSize:"0.7rem",marginLeft:"auto",paddingLeft:"12px"},".cm-completionInfo":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",color:"var(--neutral3)",padding:"8px 12px"},".cm-completionIcon":{display:"none"},"ul.cm-completionList li[aria-selected]":{backgroundColor:"var(--surface4)",color:"var(--neutral6)"},".cm-line .cm-variable-highlight":{color:"var(--accent6) !important",fontWeight:"500"}}),t=yg.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,m1(t)]}const mx=()=>{const e=cN().resolvedTheme==="dark";return y.useMemo(()=>e?yNn():bNn(),[e])},Gr=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=mx(),g=e?JSON.stringify(e,null,2):t??"",v=y.useMemo(()=>{const b=[];return a==="json"?b.push(up):a==="markdown"&&(b.push(xbe({base:tO,codeLanguages:Dpt})),b.push(It.lineWrapping)),i&&a==="markdown"&&b.push(vNn),c&&a==="markdown"&&b.push(fNn(c)),f===!1&&b.push(as.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(Ia,{content:g,className:"absolute top-2 right-2 z-20"}),o.jsx(ku,{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}})]})}),xNn={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 VY=null;function wNn(){return VY||(VY=(async()=>{const[{createHighlighterCore:e},{createJavaScriptRegexEngine:t}]=await Promise.all([ho(()=>import("./core-Cp2Ep0UF.js"),__vite__mapDeps([0,1,2]),import.meta.url),ho(()=>import("./engine-javascript-CSIo_1eZ.js"),__vite__mapDeps([3,1]),import.meta.url)]);return e({themes:[ho(()=>import("./github-light-DAi9KRSo.js"),[],import.meta.url),ho(()=>import("./github-dark-DHJKELXO.js"),[],import.meta.url)],langs:[ho(()=>import("./javascript-ySlJ1b_l.js"),[],import.meta.url),ho(()=>import("./typescript-Dj6nwHGl.js"),[],import.meta.url),ho(()=>import("./tsx-B6W0miNI.js"),[],import.meta.url),ho(()=>import("./jsx-BAng5TT0.js"),[],import.meta.url),ho(()=>import("./json-BQoSv7ci.js"),[],import.meta.url),ho(()=>import("./bash-atvbtKCR.js"),[],import.meta.url),ho(()=>import("./markdown-UIAJJxZW.js"),[],import.meta.url),ho(()=>import("./python-DhUJRlN_.js"),[],import.meta.url)],engine:t()})})()),VY}async function SNn(e,t){const n=xNn[t?.toLowerCase()];if(!n)return null;const r=await wNn(),{tokens:s}=r.codeToTokens(e,{lang:n,defaultColor:!1,themes:{light:"github-light",dark:"github-dark"}});return s}function Vr({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 pf=({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}),Lpt=({children:e,className:t,style:n})=>o.jsx(Qe,{size:"lg",className:K("text-neutral3 mt-1 shrink-0",t),style:n,children:e}),hf=({children:e,className:t})=>o.jsx(ge,{as:"p",variant:"ui-lg",className:K("text-neutral6 font-medium",t),children:e}),Ip=({children:e,className:t})=>o.jsx(ge,{as:"div",variant:"ui-sm",className:K("text-neutral3",t),children:e}),mf=({children:e,className:t})=>o.jsx("div",{className:K("flex-1 w-full",t),children:e});function Ss({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(Vr,{className:s,iconSlot:o.jsx(Qe,{size:"lg",className:"text-neutral3",children:o.jsx(fTn,{})}),titleSlot:t??a,descriptionSlot:n??i,actionSlot:r})}function Ms({title:e,description:t,className:n}){const[r,s]=y.useState(!1),a=Ze(),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(Vr,{className:n,iconSlot:o.jsx(Qe,{size:"lg",className:"text-neutral3",children:o.jsx(Xjn,{})}),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 Lbe=({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}),Fpt=({children:e})=>o.jsx(ge,{as:"h1",variant:"ui-md",className:"text-neutral6 flex items-center gap-2",children:e}),kNn=({children:e})=>o.jsx("div",{className:"ml-auto flex items-center gap-3",children:e}),Ch=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"})}),ONn={default:"[&>tbody>tr]:h-table-row",small:"[&>tbody>tr]:h-table-row-small"},_Nn=({className:e,children:t,size:n="default",style:r})=>o.jsx("table",{className:K("w-full",ONn[n],e),style:r,children:t}),CNn=({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})}),ENn=({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}),jNn=({className:e,children:t,...n})=>o.jsx("tbody",{className:K("",e),...n,children:t}),TNn=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})}),NNn=({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})}),INn=fd(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(fz,"rounded-xl",vk),filled:K(fz,"rounded-xl",vk),outline:K(Klt,"rounded-xl",vk),unstyled:Jlt},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"}}),zl=y.forwardRef(({className:e,size:t,testId:n,variant:r,error:s,...a},i)=>o.jsx("textarea",{className:K(INn({variant:r,size:t}),s&&"border-error focus-visible:border-error",e),"data-testid":n,ref:i,"aria-invalid":s,...a}));zl.displayName="Textarea";let O4e={},_4e={},C4e="";function ANn(e){if(typeof document>"u")return!1;const t=cr(e);return Gs(t).innerWidth-t.documentElement.clientWidth>0}function RNn(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const n=cr(e),r=n.documentElement,s=n.body,a=f1(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 PNn(e){const t=cr(e),n=t.documentElement,r=t.body,s=f1(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 $Nn(e){const t=cr(e),n=t.documentElement,r=t.body,s=Gs(n);let a=0,i=0,l=!1;const c=Id.create();if(nU&&(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,O4e={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},C4e=n.style.scrollBehavior,_4e={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 S=n.scrollHeight>n.clientHeight,w=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),E=Math.max(0,s.innerHeight-r.clientHeight),T=parseFloat(m.marginTop)+parseFloat(m.marginBottom),N=parseFloat(m.marginLeft)+parseFloat(m.marginRight),I=f1(n)?n:r;if(l=RNn(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"}),(S||O)&&(n.style.overflowY="scroll"),(w||_)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:T||E?`calc(100dvh - ${T+E}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,O4e),Object.assign(r.style,_4e),l||(n.scrollTop=a,n.scrollLeft=i,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=C4e)}function f(){d(),c.request(u)}u();const p=Lr(s,"resize",f);return()=>{c.cancel(),d(),typeof s.removeEventListener=="function"&&p()}}class MNn{lockCount=0;restore=null;timeoutLock=Mh.create();timeoutUnlock=Mh.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=cr(t).documentElement,s=Gs(r).getComputedStyle(r).overflowY;if(s==="hidden"||s==="clip"){this.restore=ga;return}const a=Qve||!ANn(t);this.restore=a?PNn(t):$Nn(t)}}const DNn=new MNn;function zpt(e=!0,t=null){Nt(()=>{if(e)return DNn.acquire(t)},[e,t])}function LNn(e){const{store:t,parentContext:n,actionsRef:r,isDrawer:s}=e,a=t.useState("open");zlt(t,a),BM(t);const{forceUnmount:i}=UM(a,t),l=y.useCallback(()=>{t.setOpen(!1,Ht(DM))},[t]);return y.useImperativeHandle(r,()=>({unmount:i,close:l}),[i,l]),{parentContext:n,isDrawer:s}}function FNn({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=t_(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?"intentional":{mouse:i==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(S){if(!e.context.outsidePressEnabledRef.current||"button"in S&&S.button!==0||"touches"in S&&S.touches.length!==1)return!1;const w=yi(S);if(h&&!a){const O=w;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});zpt(s&&i===!0,l),e.useContextCallback("onNestedDialogOpen",(S,w)=>{d(S),p(w)}),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??vs,v=m.trigger??vs,b=y.useMemo(()=>wo(sy,m.floating),[m.floating]);return qM(e,{activeTriggerProps:g,inactiveTriggerProps:v,popupProps:b,nestedOpenDialogCount:u,nestedOpenDrawerCount:f}),null}const Fbe=y.createContext(!1),Bpt=y.createContext(void 0);function pd(e){const t=y.useContext(Bpt);if(e===!1&&t===void 0)throw new Error(gr(27));return t}const zNn={...HM,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 zbe extends YT{constructor(t,n,r=!1){const s=new n_,a=BNn(t);a.floatingRootContext=dU(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},zNn)}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};uU(r,t,n.trigger),this.update(r)};static useStore(t,n){return cU(t,(s,a)=>new zbe(n,s,a),!0).store}}function BNn(e={}){return{...VM(),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 Upt(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",S=pd(!0),O={modal:g,disablePointerDismissal:v,nested:!!S,role:b},_=zbe.useStore(d?.store,{open:s,openProp:r,activeTriggerId:p,triggerIdProp:f,...O});XO(()=>{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"),E=_.useState("mounted"),T=_.useState("payload"),N=LNn({store:_,actionsRef:u,parentContext:S?.store.context,isDrawer:h}),I=C||E,R=y.useMemo(()=>({store:_}),[_]);return o.jsx(Fbe.Provider,{value:!1,children:o.jsxs(Bpt.Provider,{value:R,children:[I&&o.jsx(FNn,{store:_,dialogRoot:N}),typeof n=="function"?n({payload:T}):n]})})}function UNn(e){return Upt(e,"alert-dialog")}const qNn={...ff,...Bl},Bbe=y.forwardRef(function(t,n){const{render:r,className:s,style:a,forceRender:i=!1,...l}=t,{store:c}=pd(),u=c.useState("open"),d=c.useState("nested"),f=c.useState("mounted"),p=c.useState("transitionStatus");return Cn("div",t,{state:{open:u,transitionStatus:p},ref:[c.context.backdropRef,n],stateAttributesMapping:qNn,props:[{role:"presentation",hidden:!f,style:{userSelect:"none",WebkitUserSelect:"none"}},l],enabled:i||!d})}),qpt=y.createContext(void 0);function Ube(e=!1){const t=y.useContext(qpt);if(t===void 0&&!e)throw new Error(gr(16));return t}function VNn(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 hd(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:s=!0,composite:a}=e,i=y.useRef(null),l=Ube(!0),c=a??l!==void 0,{props:u}=VNn({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:s}),d=y.useCallback(()=>{const h=i.current;HY(h)&&c&&t&&u.disabled===void 0&&h.disabled&&(h.disabled=!1)},[t,u.disabled,c]);Nt(d,[d]);const f=y.useCallback((h={})=>{const{onClick:m,onMouseDown:g,onKeyUp:v,onKeyDown:b,onPointerDown:S,...w}=h;return wo({onClick(O){if(t){O.preventDefault();return}m?.(O)},onMouseDown(O){t||g?.(O)},onKeyDown(O){if(t||(oz(O),b?.(O),O.baseUIHandlerPrevented))return;const _=O.target===O.currentTarget,C=O.currentTarget,E=HY(C),T=!s&&HNn(C),N=_&&(s?E:!T),I=O.key==="Enter",R=O.key===" ",$=C.getAttribute("role"),B=$?.startsWith("menuitem")||$==="option"||$==="gridcell";if(_&&c&&R){if(O.defaultPrevented&&B)return;O.preventDefault(),T||s&&E?(C.click(),O.preventBaseUIHandler()):N&&(m?.(O),O.preventBaseUIHandler());return}N&&(!s&&(R||I)&&O.preventDefault(),!s&&I&&m?.(O))},onKeyUp(O){if(!t){if(oz(O),v?.(O),O.target===O.currentTarget&&s&&c&&HY(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}S?.(O)}},s?{type:"button"}:{role:"button"},u,w)},[t,u,c,s]),p=ht(h=>{i.current=h,d()});return{getButtonProps:f,buttonRef:p}}function HY(e){return ka(e)&&e.tagName==="BUTTON"}function HNn(e){return!!(e?.tagName==="A"&&e?.href)}const rD=y.forwardRef(function(t,n){const{render:r,className:s,style:a,disabled:i=!1,nativeButton:l=!0,...c}=t,{store:u}=pd(),d=u.useState("open"),{getButtonProps:f,buttonRef:p}=hd({disabled:i,native:l}),h={disabled:i};function m(g){d&&u.setOpen(!1,Ht(Xve,g.nativeEvent))}return Cn("button",t,{state:h,ref:[n,p],props:[{onClick:m},c,f]})}),LU=y.forwardRef(function(t,n){const{render:r,className:s,style:a,id:i,...l}=t,{store:c}=pd(),u=Ni(i);return c.useSyncedValueWithCleanup("descriptionElementId",u),Cn("p",t,{ref:n,props:[{id:u},l]})});let ZNn=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),WNn=(function(e){return e[e.open=Xu.open]="open",e[e.closed=Xu.closed]="closed",e[e.startingStyle=Xu.startingStyle]="startingStyle",e[e.endingStyle=Xu.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const Vpt=y.createContext(void 0);function qbe(){const e=y.useContext(Vpt);if(e===void 0)throw new Error(gr(26));return e}const JE="ArrowUp",ak="ArrowDown",DP="ArrowLeft",ej="ArrowRight",sD="Home",aD="End",Hpt="PageUp",Zpt="PageDown",Wpt=new Set([DP,ej]),QNn=new Set([DP,ej,sD,aD]),Qpt=new Set([JE,ak]),GNn=new Set([JE,ak,sD,aD]),Gpt=new Set([...Wpt,...Qpt]),v1=new Set([...Gpt,sD,aD]),Ypt="Shift",YNn="Control",XNn="Alt",KNn="Meta",JNn=new Set([Ypt,YNn,XNn,KNn]);function eIn(e){return ka(e)&&e.tagName==="INPUT"}function E4e(e){return!!(eIn(e)&&e.selectionStart!=null||ka(e)&&e.tagName==="TEXTAREA")}function j4e(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=T4e(e,t,"left"),u=uL(e),d=uL(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=T4e(e,t,"top"),u=uL(e),d=uL(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 T4e(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 uL(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 tIn={...ff,...Bl,nestedDialogOpen(e){return e?{[WNn.nestedDialogOpen]:""}:null}},Vbe=y.forwardRef(function(t,n){const{render:r,className:s,style:a,finalFocus:i,initialFocus:l,...c}=t,{store:u}=pd(),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"),S=u.useState("open"),w=u.useState("openMethod"),O=u.useState("titleElementId"),_=u.useState("transitionStatus"),C=u.useState("role"),E=p.useState("floatingId"),T=c.id??E;qbe(),Ul({open:S,ref:u.context.popupRef,onComplete(){S&&u.context.onOpenChangeComplete?.(!0)}});function N(F){return F==="touch"?u.context.popupRef.current:!0}const I=l===void 0?N:l,R=b>0,$=u.useStateSetter("popupElement"),M=Cn("div",t,{state:{open:S,nested:v,transitionStatus:_,nestedDialogOpen:R},props:[h,{id:T,"aria-labelledby":O??void 0,"aria-describedby":d??void 0,role:C,...sy,hidden:!g,onKeyDown(F){v1.has(F.key)&&F.stopPropagation()},style:{[ZNn.nestedDialogs]:b}},c],ref:[n,u.context.popupRef,$],stateAttributesMapping:tIn});return o.jsx(GT,{context:p,openInteractionType:w,disabled:!g,closeOnFocusOut:!f,initialFocus:I,returnFocus:i,modal:m!==!1,restoreFocus:"popup",children:M})}),iD=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}})}),FU=y.forwardRef(function(t,n){const{keepMounted:r=!1,...s}=t,{store:a}=pd(),i=a.useState("mounted"),l=a.useState("modal"),c=a.useState("open");return i||r?o.jsx(Vpt.Provider,{value:r,children:o.jsxs(FM,{ref:n,...s,children:[i&&l===!0&&o.jsx(iD,{ref:a.context.internalBackdropRef,inert:eN(!c)}),t.children]})}):null}),zU=y.forwardRef(function(t,n){const{render:r,className:s,style:a,id:i,...l}=t,{store:c}=pd(),u=Ni(i);return c.useSyncedValueWithCleanup("titleElementId",u),Cn("h2",t,{ref:n,props:[{id:u},l]})});function nIn(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 gv(e,t){const n=y.useRef(e),r=ht(t);Nt(()=>{n.current!==e&&r(n.current)},[e,r]),Nt(()=>{n.current=e},[e])}function Hbe(e,t){const n=ht((a,i)=>{(typeof e=="function"?e():e)||t(i||(Qve?"touch":""))}),{onClick:r,onPointerDown:s}=nIn(n);return y.useMemo(()=>({onClick:r,onPointerDown:s}),[r,s])}function Zbe(e){const[t,n]=y.useState(null),r=Hbe(e,n);return gv(e,s=>{s&&!e&&n(null)}),y.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}const Xpt=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=pd(!0),h=d?.store??p?.store;if(!h)throw new Error(gr(79));const m=Ni(c),g=h.useState("floatingRootContext"),v=h.useState("isOpenedByTrigger",m),b=h.useState("triggerPopupId",m),S=y.useRef(null),{registerTrigger:w,isMountedByThisTrigger:O}=zM(m,S,h,{payload:u}),{getButtonProps:_,buttonRef:C}=hd({disabled:i,native:l}),E=e_(g,{enabled:g!=null}),T=Hbe(()=>h.select("open"),R=>{h.set("openMethod",R)}),N={disabled:i,open:v},I=h.useState("triggerProps",O);return Cn("button",t,{state:N,ref:[C,n,w,S],props:[E.reference,I,T,{[sye]:"",id:m,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":b},f,_],stateAttributesMapping:XT})}),rIn=Xpt;let N4e=(function(e){return e[e.open=Xu.open]="open",e[e.closed=Xu.closed]="closed",e[e.startingStyle=Xu.startingStyle]="startingStyle",e[e.endingStyle=Xu.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const sIn={...ff,...Bl,nested(e){return e?{[N4e.nested]:""}:null},nestedDialogOpen(e){return e?{[N4e.nestedDialogOpen]:""}:null}},aIn=y.forwardRef(function(t,n){const{render:r,className:s,style:a,children:i,...l}=t,c=qbe(),{store:u}=pd(),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 Cn("div",t,{enabled:c||m,state:{open:d,nested:f,transitionStatus:p,nestedDialogOpen:v},ref:[n,g],stateAttributesMapping:sIn,props:[{role:"presentation",hidden:!m,style:{pointerEvents:d?void 0:"none"},children:i},l]})});function oD(e,t){return e&&y.isValidElement(t)?{render:t}:void 0}const iIn=UNn;function jt({open:e,onOpenChange:t,children:n}){return o.jsx(iIn,{open:e,onOpenChange:t,children:n})}const Kpt=y.forwardRef(({asChild:e,children:t,...n},r)=>o.jsx(rIn,{ref:r,...oD(e,t),...n,children:e?void 0:t}));Kpt.displayName="AlertDialogTrigger";const Jpt=FU,Wbe=y.forwardRef(({className:e,...t},n)=>o.jsx(Bbe,{ref:n,className:K("dialog-overlay-anim fixed inset-0 z-50 bg-overlay backdrop-blur-xs",e),...t}));Wbe.displayName="AlertDialogOverlay";const eht=y.forwardRef(({className:e,...t},n)=>o.jsxs(Jpt,{children:[o.jsx(Wbe,{}),o.jsx(Vbe,{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})]}));eht.displayName="AlertDialogContent";const tht=({className:e,...t})=>o.jsx("div",{className:K("flex flex-col gap-0.5 px-4 py-3 text-left",e),...t});tht.displayName="AlertDialogHeader";const nht=({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});nht.displayName="AlertDialogFooter";const rht=({className:e,...t})=>o.jsx("div",{className:K("overflow-y-auto px-4 py-3.5 max-h-[50vh]",e),...t});rht.displayName="AlertDialogBody";const sht=y.forwardRef(({className:e,...t},n)=>o.jsx(zU,{ref:n,className:K("text-ui-md font-medium",e),...t}));sht.displayName="AlertDialogTitle";const aht=y.forwardRef(({className:e,...t},n)=>o.jsx(LU,{ref:n,className:K("text-ui-sm text-neutral3",e),...t}));aht.displayName="AlertDialogDescription";const iht=y.forwardRef(({className:e,...t},n)=>o.jsx(rD,{ref:n,className:K(QM({variant:"primary",size:"lg"}),e),...t}));iht.displayName="AlertDialogAction";const oht=y.forwardRef(({className:e,...t},n)=>o.jsx(rD,{ref:n,className:K(QM({variant:"default",size:"lg"}),e),...t}));oht.displayName="AlertDialogCancel";jt.Trigger=Kpt;jt.Portal=Jpt;jt.Overlay=Wbe;jt.Content=eht;jt.Header=tht;jt.Footer=nht;jt.Body=rht;jt.Title=sht;jt.Description=aht;jt.Action=iht;jt.Cancel=oht;function Qd({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 oIn(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 I4e=(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})({}),A4e=(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 lIn={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},yE={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},cIn={disabled:!1,...yE},y1={valid(e){return e===null?null:e?{[A4e.valid]:""}:{[A4e.invalid]:""}}};function lht(e){return y.useMemo(()=>({checked(t){return e.indeterminate?{}:t?{[I4e.checked]:""}:{[I4e.unchecked]:""}},...y1}),[e.indeterminate])}const cht={invalid:void 0,name:void 0,validityData:{state:lIn,errors:[],error:"",value:"",initialValue:null},setValidityData:ga,disabled:void 0,touched:yE.touched,setTouched:ga,dirty:yE.dirty,setDirty:ga,filled:yE.filled,setFilled:ga,focused:yE.focused,setFocused:ga,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:cIn,markedDirtyRef:{current:!1},registerFieldControl:ga,validation:{getValidationProps:(e=vs)=>e,getInputValidationProps:(e=vs)=>e,inputRef:{current:null},commit:async()=>{}}},uht=y.createContext(cht);function Yh(e=!0){const t=y.useContext(uht);if(t.setValidityData===ga&&!e)throw new Error(gr(28));return t}function uN(e,t,n,r,s=!0){const{registerFieldControl:a}=Yh(),i=y.useRef(null);i.current||(i.current=Symbol()),Nt(()=>{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 uIn=y.createContext({disabled:!1});function dht(){return y.useContext(uIn)}const dIn=y.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:ga,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function dN(){return y.useContext(dIn)}const fIn=y.createContext({controlId:void 0,registerControlId:ga,labelId:void 0,setLabelId:ga,messageIds:[],setMessageIds:ga,getDescriptionProps:e=>e});function gx(){return y.useContext(fIn)}function Qbe(e,t,n,r=!0,s){const[a,i]=y.useState(),l=Ni(s?`${s}-label`:void 0),c=e??t??a;return Nt(()=>{const u=e||t||!r?void 0:pIn(n.current,l);a!==u&&i(u)}),c}function pIn(e,t){const n=hIn(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function hIn(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 mIn=y.createContext(void 0);function gIn(e=!0){const t=y.useContext(mIn);if(t===void 0&&!e)throw new Error(gr(3));return t}const fht=y.createContext(void 0);function vIn(){const e=y.useContext(fht);if(e===void 0)throw new Error(gr(14));return e}const yIn="data-parent",bIn=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:S,value:w,nativeButton:O=!1,style:_,...C}=t,{clearErrors:E}=dN(),{disabled:T,name:N,setDirty:I,setFilled:R,setFocused:$,setTouched:B,state:M,validationMode:F,validityData:V,shouldValidateOnChange:L,validation:z}=Yh(),U=dht(),{labelId:D,controlId:G,registerControlId:q,getDescriptionProps:P}=gx(),H=gIn(),W=H?.parent,X=W&&H.allValues,ae=T||U.disabled||H?.disabled||l,ee=N??p,J=w??ee,ie=Ni(),ce=Ni();let Y=G;X?Y=m?ce:`${W.id}-${J}`:u&&(Y=u);let ne={};X&&(m?ne=H.parent.getParentProps():J&&(ne=H.parent.getChildProps(J)));const{checked:ue=r,indeterminate:pe=d,onCheckedChange:re,...he}=ne,xe=H?.value,be=H?.setValue,Ie=H?.defaultValue,ke=y.useRef(null),Te=lc(()=>Symbol("checkbox-control")),Le=y.useRef(!1),{getButtonProps:le,buttonRef:se}=hd({disabled:ae,native:O}),te=H?.validation??z,[me,ye]=Qd({controlled:J&&xe&&!m?xe.includes(J):ue,default:J&&Ie&&!m?Ie.includes(J):a,name:"Checkbox",state:"checked"});Nt(()=>{q!==ga&&(Le.current=!0,q(Te.current,Y))},[Y,q,Te]),y.useEffect(()=>{const Fe=Te.current;return()=>{!Le.current||q===ga||(Le.current=!1,q(Fe,void 0))}},[q,Te]),uN(ke,ie,me,void 0,!H);const Ne=y.useRef(null),Re=Su(f,Ne,te.inputRef),Ge=Qbe(i,D,Ne,!O,Y??void 0);Nt(()=>{Ne.current&&(Ne.current.indeterminate=pe,me&&R(!0))},[me,pe,R]),gv(me,()=>{H&&!m||(E(ee),R(me),I(me!==V.initialValue),L()?te.commit(me):te.commit(me,!0))});const He=wo({checked:me,disabled:ae,form:c,name:m?void 0:ee,id:O?void 0:Y??void 0,required:b,ref:Re,style:ee?QT:Lw,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=Ht(vo,Fe.nativeEvent);if(re?.(Ke,Ye),h?.(Ke,Ye),!Ye.isCanceled&&(ye(Ke),J&&xe&&be&&!m&&!X)){const Pt=Ke?[...xe,J]:xe.filter(_t=>_t!==J);be(Pt,Ye)}},onFocus(){ke.current?.focus()}},w!==void 0?{value:(H?me&&w:w)||""}:vs,P,H?te.getValidationProps:te.getInputValidationProps),Oe=X?!!ue:me,_e=X&&pe||d;y.useEffect(()=>{if(!W||!J)return;const Fe=W.disabledStatesRef.current;return Fe.set(J,ae),()=>{Fe.delete(J)}},[W,ae,J]);const Ee=y.useMemo(()=>({...M,checked:Oe,disabled:ae,readOnly:g,required:b,indeterminate:_e}),[M,Oe,ae,g,b,_e]),je=lht(Ee),$e=Cn("span",t,{state:Ee,ref:[se,ke,n,H?.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":Ge,[yIn]:m?"":void 0,onFocus(){$(!0)},onBlur(){const Fe=Ne.current;Fe&&(B(!0),$(!1),F==="onBlur"&&te.commit(H?xe:Fe.checked))},onKeyDown(Fe){if(Fe.key!=="Enter"||(Fe.preventBaseUIHandler(),Fe.defaultPrevented))return;const Ke=Ne.current?.form??null,Ye=Fe.currentTarget,Pt=Fe.nativeEvent,_t=Fe.preventDefault,an=Pt.preventDefault;let bt=!1;Fe.preventDefault=()=>{bt=!0,_t.call(Fe)},Pt.preventDefault=()=>{bt=!0,an.call(Pt)},an.call(Pt),Gs(Ye).queueMicrotask(()=>{Fe.preventDefault=_t,Pt.preventDefault=an,bt||oIn(Ke)?.click()})},onClick(Fe){if(g||ae)return;Fe.preventDefault();const Ke=Ne.current;Ke&&Ke.dispatchEvent(new(Gs(Ke)).PointerEvent("click",{bubbles:!0,shiftKey:Fe.shiftKey,ctrlKey:Fe.ctrlKey,altKey:Fe.altKey,metaKey:Fe.metaKey}))}},P,te.getValidationProps,C,he,le],stateAttributesMapping:je});return o.jsxs(fht.Provider,{value:Ee,children:[$e,!me&&!H&&ee&&!m&&S!==void 0&&o.jsx("input",{type:"hidden",form:c,name:ee,value:S}),o.jsx("input",{...He,suppressHydrationWarning:!0})]})}),xIn=y.forwardRef(function(t,n){const{render:r,className:s,style:a,keepMounted:i=!1,...l}=t,c=vIn(),u=c.checked||c.indeterminate,{mounted:d,transitionStatus:f,setMounted:p}=gg(u),h=y.useRef(null),m={...c,transitionStatus:f};Ul({open:u,ref:h,onComplete(){u||p(!1)}});const v={...lht(c),...Bl,...y1},b=i||d,S=Cn("span",t,{ref:[n,h],state:m,stateAttributesMapping:v,props:l});return b?S:null}),Uo=y.forwardRef(({className:e,checked:t,indeterminate:n,...r},s)=>{const a=t==="indeterminate";return o.jsx(bIn,{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",ns.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(xIn,{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(wIn,{})})})});Uo.displayName="Checkbox";function wIn(){return o.jsxs(o.Fragment,{children:[o.jsx(hx,{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(rTn,{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 SIn(e){const{open:t,defaultOpen:n,onOpenChange:r,disabled:s}=e,[a,i]=Qd({controlled:t,default:n,name:"Collapsible",state:"open"}),{mounted:l,setMounted:c,transitionStatus:u}=gg(a,!0,!0),d=Ni(),[f,p]=y.useState(),h=f??d,m=ht(g=>{const v=!a,b=Ht(tg,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 pht=y.createContext(void 0);function hht(){const e=y.useContext(pht);if(e===void 0)throw new Error(gr(15));return e}let Gbe=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=ng.startingStyle]="startingStyle",e[e.endingStyle=ng.endingStyle]="endingStyle",e})({}),kIn=(function(e){return e.panelOpen="data-panel-open",e})({});const OIn={[Gbe.open]:""},_In={[Gbe.closed]:""},CIn={open(e){return e?{[kIn.panelOpen]:""}:null}},EIn={open(e){return e?OIn:_In}},mht={...EIn,...Bl},jIn=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=ht(l),p=SIn({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=Cn("div",t,{state:h,ref:n,props:d,stateAttributesMapping:mht});return o.jsx(pht.Provider,{value:m,children:g})}),TIn={...CIn,...Bl},NIn=y.forwardRef(function(t,n){const{panelId:r,open:s,handleTrigger:a,state:i,disabled:l}=hht(),{className:c,disabled:u=l,id:d,render:f,nativeButton:p=!0,style:h,...m}=t,{getButtonProps:g,buttonRef:v}=hd({disabled:u,focusableWhenDisabled:!0,native:p});return Cn("button",t,{state:i,ref:[n,v],props:[{"aria-controls":s?r:void 0,"aria-expanded":s,onClick:a},m,g],stateAttributesMapping:TIn})}),lA={height:void 0,width:void 0};function IIn(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(lA),g=y.useRef(lA),v=y.useRef(!1),b=y.useRef(l),S=y.useRef(!1),[w,O]=y.useState(!1),_=y.useRef(null),C=Su(t,f),E=qi({mounted:a,open:l}),T=lU(f,!1,!1),N=!l&&!a,I=w?"idle":d,R=l&&(b.current||S.current),$=!l&&a&&p.current==="css-animation"&&h.height===void 0&&h.width===void 0?g.current:h,B=n&&N&&p.current!=="css-animation",M=ht((U,D=!0)=>{D&&(g.current=U),m(U)}),F=ht(()=>{_.current?.(),_.current=null}),V=ht(U=>{F(),_.current=()=>{_.current=null,U()}}),L=ht(()=>{l&&a&&p.current==="css-animation"&&(S.current=!0)});Nt(()=>{!w||d==="starting"||O(!1)},[w,d]),y.useEffect(()=>()=>{L(),F()},[L,F]),Nt(()=>{const U=f.current;if(!U)return;!l&&_.current&&F();const D=AIn(U,R);if(p.current=D,l&&d==="idle"&&b.current&&D==="css-animation"){g.current=hC(U);return}if(l&&d==="starting"){const P=v.current;if(v.current=!1,D==="none"){M(hC(U)),O(!0);return}if(D==="css-transition"){const H=RIn(U);if(M(hC(U)),!P)return H;const W=cA(U,"transition-duration","0s");return V(W),O(!0),H}if(D==="css-animation"){if(M(hC(U)),!P){cA(U,"animation-name","none")();return}const H=cA(U,"animation-name","none"),W=cA(U,"animation-duration","0s");H(),V(W),O(!0);return}}if(!l&&a&&(d==="idle"||d==="starting")){if(D==="none"){M(lA,!1),c(!1);return}D==="css-animation"&&(b.current=!1,S.current=!1),M(hC(U));return}if(d!=="ending")return;if(D==="none"){c(!1);return}const G=hC(U);if(!((G.height??0)>0||(G.width??0)>0)){c(!1);return}M(G),D==="css-animation"&&cA(U,"animation-name","none")()},[a,l,F,M,c,V,R,d]),Ul({enabled:l&&a&&I==="idle",open:!0,ref:f,onComplete(){l&&M(lA,!1)}}),y.useEffect(()=>{if(l||!a||I!=="ending"||!f.current)return;const D=new AbortController;let G=-1;function q(){E.current.open||(c(!1),M(lA,!1))}return G=Id.request(()=>{D.signal.aborted||T(q,D.signal)}),()=>{Id.cancel(G),D.abort()}},[E,a,l,I,T,M,c]),Nt(()=>{const U=f.current;!U||!n||!N||U.setAttribute("hidden","until-found")},[N,n]),y.useEffect(function(){const D=f.current;if(!D)return;function G(q){v.current=!0,u(!0),i(!0,Ht(vo,q))}return Lr(D,"beforematch",G)},[i,u]);const z=s||n||a||l;return{height:$.height,props:{...B?{[Gbe.startingStyle]:""}:void 0,hidden:N,id:r},ref:C,shouldPreventOpenAnimation:R,shouldRender:z,transitionStatus:I,width:$.width}}function hC(e){return{height:e.scrollHeight,width:e.scrollWidth}}function AIn(e,t=!1){const n=Gs(e).getComputedStyle(e),r=(n.animationName.split(",").map(a=>a.trim()).some(a=>a!==""&&a!=="none")||t)&&R4e(n.animationDuration),s=R4e(n.transitionDuration);return r&&s||s?"css-transition":r?"css-animation":"none"}function R4e(e){return e.split(",").map(t=>t.trim()).some(t=>t!==""&&Number.parseFloat(t)>0)}function cA(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 RIn(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=Id.request(n);return()=>{Id.cancel(r),n()}}let P4e=(function(e){return e.collapsiblePanelHeight="--collapsible-panel-height",e.collapsiblePanelWidth="--collapsible-panel-width",e})({});const PIn=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:S}=hht(),w=s??!1,O=a??!1;Nt(()=>{if(l)return g(l),()=>{g(void 0)}},[l,g]);const{height:_,props:C,ref:E,shouldPreventOpenAnimation:T,shouldRender:N,transitionStatus:I,width:R}=IIn({externalRef:n,hiddenUntilFound:w,id:h,keepMounted:O,mounted:d,onOpenChange:f,open:p,setMounted:m,setOpen:v,transitionStatus:S}),$={...b,transitionStatus:I},B=xlt(c,$),M=Cn("div",{...t,style:void 0},{state:$,ref:E,props:[C,{style:{[P4e.collapsiblePanelHeight]:_===void 0?"auto":`${_}px`,[P4e.collapsiblePanelWidth]:R===void 0?"auto":`${R}px`}},u,B?{style:B}:void 0,T?{style:{animationName:"none"}}:void 0],stateAttributesMapping:mht});return N?M:null}),Dh=jIn,bp=De.forwardRef(({className:e,asChild:t,children:n,...r},s)=>{const a=t&&De.isValidElement(n)?{render:n}:{};return o.jsx(NIn,{ref:s,"data-slot":"collapsible-trigger",className:K("-outline-offset-2",ns.colors,YO.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})});bp.displayName="CollapsibleTrigger";const xp=De.forwardRef(({className:e,children:t,...n},r)=>o.jsx(PIn,{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})}));xp.displayName="CollapsibleContent";const ght=y.createContext(void 0),vht=y.createContext(void 0),yht=y.createContext(void 0),bht=y.createContext("");function ly(){const e=y.useContext(ght);if(!e)throw new Error(gr(22));return e}function BU(){const e=y.useContext(vht);if(!e)throw new Error(gr(23));return e}function b1(){const e=y.useContext(yht);if(!e)throw new Error(gr(24));return e}function xht(){return y.useContext(bht)}const wht=(e,t)=>Object.is(e,t);function Bv(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Sht(e,t,n){return!e||e.length===0?!1:e.some(r=>r===void 0?!1:Bv(t,r,n))}function mw(e,t,n){return!e||e.length===0?-1:e.findIndex(r=>r===void 0?!1:Bv(r,t,n))}function kht(e,t,n){return e.filter(r=>!Bv(t,r,n))}function Hz(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Ybe(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function Oht(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(Ybe(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 ou(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 Hz(e)}function $m(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?Hz(e.value):Hz(e)}function Xbe(e,t,n){function r(){return ou(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=Ybe(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 _ht(e,t,n){return e.reduce((r,s,a)=>(a>0&&r.push(", "),r.push(o.jsx(y.Fragment,{children:Xbe(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?Oht(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=>Bv(t,s,n)):Bv(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 o_(e={}){const{id:t,implicit:n=!1,controlRef:r}=e,{controlId:s,registerControlId:a}=gx(),i=Ni(t),l=n?s:void 0,c=lc(()=>Symbol("labelable-control")),u=y.useRef(!1),d=y.useRef(t!=null),f=ht(()=>{!u.current||a===ga||(u.current=!1,a(c.current,void 0))});return Nt(()=>{if(a===ga)return;let p;if(n){const h=r?.current;wr(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 $In(e,t){return(n,r)=>{if(n==null)return!1;const s=ou(n,t);return e.contains(s,r)}}function MIn(e,t,n){return(r,s)=>{if(r==null)return!1;if(!s)return!0;const a=ou(r,t),i=n!=null?ou(n,t):"";return i&&e.contains(i,s)&&i.length===s.length?!0:e.contains(a,s)}}const $4e=new Map;function DIn(e={}){const t={usage:"search",sensitivity:"base",ignorePunctuation:!0,...e},n=`${Cht(e.locale)}|${JSON.stringify(t)}`,r=$4e.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=ou(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=ou(i,c);return s.compare(u.slice(0,l.length),l)===0},endsWith(i,l,c){if(!l)return!0;const u=ou(i,c),d=l.length;return u.length>=d&&s.compare(u.slice(u.length-d),l)===0}};return $4e.set(n,a),a}function Cht(e){return Array.isArray(e)?e.map(t=>Cht(t)).join(","):e==null?"":String(e)}const LIn=DIn,Eht=Symbol("none"),dS={value:Eht,index:-1};function FIn(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:S=!1,items:w,filteredItems:O,filter:_,openOnInputClick:C=!0,autoHighlight:E=!1,keepHighlight:T=!1,highlightItemOnHover:N=!0,loopFocus:I=!0,itemToStringLabel:R,itemToStringValue:$,isItemEqualToValue:B=wht,virtualized:M=!1,inline:F=!1,fillInputOnItemPress:V=!0,modal:L=!1,limit:z=-1,autoComplete:U="list",formAutoComplete:D,locale:G,submitOnItemClick:q=!1}=e,{clearErrors:P}=dN(),{setDirty:H,validityData:W,shouldValidateOnChange:X,setFilled:ae,name:ee,disabled:J,setTouched:ie,setFocused:ce,validationMode:Y,validation:ne}=Yh(),ue=ay(),pe=o_({id:t}),re=LIn({locale:G}),[he,xe]=y.useState(!1),[be,Ie]=y.useState(null),ke=y.useRef([]),Te=y.useRef([]),Le=y.useRef(null),le=y.useRef(null),se=y.useRef(null),te=y.useRef(null),me=y.useRef(null),ye=y.useRef(!0),Ne=y.useRef(!1),Re=y.useRef(null),Ge=y.useRef(null),He=y.useRef(null),Oe=y.useRef(dS),_e=y.useRef(null),Ee=y.useRef([]),je=y.useRef([]),$e=J||m,Fe=ee??p,Ke=d==="multiple",Ye=d==="single",Pt=l!==void 0||i!==void 0,_t=w!==void 0,an=O!==void 0;let bt;E==="always"?bt="always":bt=E?"input-change":!1;const[At,rn]=Qd({controlled:s,default:Ke?r??dh:r,name:"Combobox",state:"selectedValue"}),We=y.useMemo(()=>_===null?()=>!0:_!==void 0?_:Ye&&!he?MIn(re,R,At):$In(re,R),[_,Ye,At,he,re,R]),at=lc(()=>Pt?i??"":Ye?ou(At,R):"").current,[ct,ln]=Qd({controlled:l,default:at,name:"Combobox",state:"inputValue"}),[Jt,Ce]=Qd({controlled:c,default:u,name:"Combobox",state:"open"}),Me=Ybe(w),Ve=be??(ct===""?"":String(ct).trim()),Xe=Ye?ou(At,R):"",nt=Ye&&!he&&Ve!==""&&Xe!==""&&Xe.length===Ve.length&&re.contains(Xe,Ve),wt=nt?"":Ve,Lt=_t&&an&&nt,xt=y.useMemo(()=>w?Me?w.flatMap(un=>un.items):w:dh,[w,Me]),Mt=y.useMemo(()=>{if(O&&!Lt)return O;if(!w)return dh;if(Me){const Wn=w,_s=[];let wa=0;for(const Gi of Wn){if(z>-1&&wa>=z)break;const Da=wt===""?Gi.items:Gi.items.filter(Of=>We(Of,wt,R));if(Da.length===0)continue;const cm=z>-1?z-wa:1/0,yd=Da.slice(0,cm);if(yd.length>0){const Of={...Gi,items:yd};_s.push(Of),wa+=yd.length}}return _s}if(wt==="")return z>-1?xt.slice(0,z):xt;const un=[];for(const Wn of xt){if(z>-1&&un.length>=z)break;We(Wn,wt,R)&&un.push(Wn)}return un},[O,Lt,w,Me,wt,z,We,R,xt]),Dt=y.useMemo(()=>Me?Mt.flatMap(Wn=>Wn.items):Mt,[Mt,Me]),Tt=lc(()=>new fye({id:pe,labelId:void 0,selectedValue:At,open:Jt,filter:We,query:Ve,items:w,selectionMode:d,listRef:ke,labelsRef:Te,popupRef:Le,emptyRef:me,inputRef:le,startDismissRef:se,endDismissRef:te,keyboardActiveRef:ye,chipsContainerRef:Re,clearRef:Ge,valuesRef:Ee,allValuesRef:je,selectionEventRef:He,name:Fe,form:h,disabled:$e,readOnly:g,required:v,grid:S,isGrouped:Me,virtualized:M,openOnInputClick:C,itemToStringLabel:R,isItemEqualToValue:B,modal:L,autoHighlight:bt,submitOnItemClick:q,hasInputValue:Pt,mounted:!1,forceMounted:!1,transitionStatus:"idle",inline:F,activeIndex:null,selectedIndex:null,popupProps:{},inputProps:{},triggerProps:{},itemProps:vs,positionerElement:null,listElement:null,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:d==="none",onOpenChangeComplete:n||ga,setOpen:ga,setInputValue:ga,setSelectedValue:ga,setIndices:ga,onItemHighlighted:ga,handleSelection:ga,forceMount:ga,requestSubmit:ga})).current,fn=d==="none"?ct:At,Nr=y.useMemo(()=>d==="none"?fn:Array.isArray(At)?At.map(un=>$m(un,$)):$m(At,$),[fn,$,d,At]),_r=ht(f),ss=ht(n),Pr=pt(Tt,on.activeIndex),Os=pt(Tt,on.selectedIndex),lr=pt(Tt,on.positionerElement),cs=pt(Tt,on.listElement),Ya=pt(Tt,on.triggerElement),uo=pt(Tt,on.inputElement),Ks=pt(Tt,on.inputGroupElement),fa=pt(Tt,on.inline),Ol=pt(Tt,on.inputInsidePopup),kc=pt(Tt,on.inputOwnsFormValue),Hl=qi(Ya),{mounted:Lp,setMounted:am,transitionStatus:Hr}=gg(Jt),{openMethod:fo,triggerProps:Oc}=Zbe(Jt),Xc=ht(()=>Nr);uN(Ol?Hl:le,pe,fn,Xc);const us=ht(()=>{w?Te.current=Dt.map(un=>ou(un,R)):Tt.set("forceMounted",!0)}),Wo=y.useRef(At);Nt(()=>{At!==Wo.current&&us()},[us,At]);const _l=ht(un=>{Tt.update(un);const Wn=un.type||"none";if(un.activeIndex!==void 0)if(un.activeIndex===null)Oe.current!==dS&&(Oe.current=dS,_r(void 0,qS(Wn,void 0,{index:-1})));else{const _s=Ee.current[un.activeIndex];Oe.current={value:_s,index:un.activeIndex},_r(_s,qS(Wn,void 0,{index:un.activeIndex}))}}),Zl=ht((un,Wn)=>{if(Ne.current=Wn.reason===ib,e.onInputValueChange?.(un,Wn),!Wn.isCanceled){if(Wn.reason===tk){const _s=Wn.event,wa=_s.inputType;if(_s.type==="compositionend"||wa!=null&&wa!==""&&wa!=="insertReplacementText"){const Da=un.trim()!=="";Da&&xe(!0),_e.current={hasQuery:Da},Da&&bt&&Tt.state.activeIndex==null&&Tt.set("activeIndex",0)}}ln(un)}}),im=ht((un,Wn)=>{if(Jt!==un&&(Wn.reason==="escape-key"&&_t&&Dt.length===0&&!Tt.state.emptyRef.current&&Wn.allowPropagation(),e.onOpenChange?.(un,Wn),!Wn.isCanceled&&(un&&Ke&&Ol&&!fa&&be!==null&&(xe(!1),Ie(null),ct!==""&&Zl("",Ht(ib,Wn.event))),!un&&he&&(Ye?(fa||Ie(Ve),Ve===""&&xe(!1)):Ke&&(fa||Ie(Ve),Ol&&_l({activeIndex:null}),(!Ol||fa)&&Zl("",Ht(ib,Wn.event)))),Ce(un),!un&&Ol&&(Wn.reason===qb||Wn.reason===MM)&&(ie(!0),ce(!1),Y==="onBlur")))){const _s=d==="none"?ct:At;ne.commit(_s)}}),Eg=ht((un,Wn)=>{if(a?.(un,Wn),Wn.isCanceled)return;rn(un),(d==="none"&&Le.current&&V||Ye&&!Tt.state.inputInsidePopup)&&Zl(ou(un,R),Ht(Wn.reason,Wn.event)),Ye&&un!=null&&Wn.reason!==tk&&he&&!fa&&Ie(Ve)}),Bx=ht((un,Wn)=>{let _s=Wn;if(_s===void 0){if(Pr===null)return;_s=Ee.current[Pr]}const wa=yi(un),Gi=He.current??un;He.current=null;const Da=Ht(pw,Gi),cm=wa?.closest("a")?.getAttribute("href");if(cm){cm.startsWith("#")&&im(!1,Da);return}if(Ke){const yd=Array.isArray(At)?At:[],GN=Sht(yd,_s,Tt.state.isItemEqualToValue)?kht(yd,_s,Tt.state.isItemEqualToValue):[...yd,_s];if(Eg(GN,Da),!(le.current?le.current.value.trim()!=="":!1))return;Tt.state.inputInsidePopup?Zl("",Ht(ib,Da.event)):im(!1,Da)}else Eg(_s,Da),im(!1,Da)}),A1=ht(()=>{if(!Tt.state.submitOnItemClick)return;const un=ne.inputRef.current?.form??Tt.state.inputElement?.form;un&&typeof un.requestSubmit=="function"&&un.requestSubmit()}),il=ht(()=>{if(am(!1),ss?.(!1),xe(!1),Ie(null),_l(d==="none"?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),Ke&&le.current&&le.current.value!==""&&!Ne.current&&Zl("",Ht(ib)),Ye)if(Tt.state.inputInsidePopup)le.current&&le.current.value!==""&&Zl("",Ht(ib));else{const un=ou(At,R);le.current&&le.current.value!==un&&Zl(un,Ht(un===""?ib:vo))}}),R1=y.useMemo(()=>fa&&lr?{current:lr.closest('[role="dialog"]')}:Le,[fa,lr]);Ul({enabled:!e.actionsRef,open:Jt,ref:R1,onComplete(){Jt||il()}}),y.useImperativeHandle(e.actionsRef,()=>({unmount:il}),[il]),Nt(function(){if(Jt||d==="none")return;const Wn=w?xt:je.current;if(Ke){const _s=Array.isArray(At)?At:[],wa=_s[_s.length-1],Gi=mw(Wn,wa,B);_l({selectedIndex:Gi===-1?null:Gi})}else{const _s=mw(Wn,At,B);_l({selectedIndex:_s===-1?null:_s})}},[Jt,At,w,d,xt,Ke,B,_l]),Nt(()=>{w&&(Ee.current=Dt,ke.current.length=Dt.length)},[w,Dt]),Nt(()=>{const un=_e.current;if(un&&(un.hasQuery?bt&&Tt.set("activeIndex",0):bt==="always"&&Tt.set("activeIndex",0),_e.current=null),!Jt&&!fa)return;const _s=_t||an?Dt:Ee.current,wa=Tt.state.activeIndex;if(wa==null){if(bt==="always"&&_s.length>0){Tt.set("activeIndex",0);return}Oe.current!==dS&&(Oe.current=dS,Tt.state.onItemHighlighted(void 0,qS(vo,void 0,{index:-1})));return}if(wa>=_s.length){Oe.current!==dS&&(Oe.current=dS,Tt.state.onItemHighlighted(void 0,qS(vo,void 0,{index:-1}))),Tt.set("activeIndex",null);return}const Gi=_s[wa],Da=Oe.current.value,cm=Da!==Eht&&Bv(Gi,Da,Tt.state.isItemEqualToValue);(Oe.current.index!==wa||!cm)&&(Oe.current={value:Gi,index:wa},Tt.state.onItemHighlighted(Gi,qS(vo,void 0,{index:wa})))},[Pr,bt,an,_t,Dt,fa,Jt,Tt]),Nt(()=>{if(d==="none"){ae(String(ct)!=="");return}ae(Ke?Array.isArray(At)&&At.length>0:At!=null)},[ae,d,ct,At,Ke]),y.useEffect(()=>{_t&&bt&&Dt.length===0&&_l({activeIndex:null})},[_t,bt,Dt.length,_l]),gv(Ve,()=>{!Jt||Ve===""||Ve===String(at)||xe(!0)}),gv(At,()=>{if(d!=="none"&&(P(Fe),H(At!==W.initialValue),X()?ne.commit(At):ne.commit(At,!0),Ye&&!Pt&&!Ol)){const un=ou(At,R);ct!==un&&Zl(un,Ht(vo))}}),gv(ct,()=>{d==="none"&&(P(Fe),H(ct!==W.initialValue),X()?ne.commit(ct):ne.commit(ct,!0))}),gv(w,()=>{if(!Ye||Pt||Ol||he)return;const un=ou(At,R);ct!==un&&Zl(un,Ht(vo))});const Sy=hye({open:fa?!0:Jt,onOpenChange:im,elements:{reference:Ol?Ya:uo,floating:lr}});let jg,Tg;fa||(jg=S?"grid":"listbox",Tg=Jt?"true":"false");const P1=y.useMemo(()=>{const un=uo?.tagName==="INPUT",Wn=uo==null||un,_s=Wn||Jt,wa=Wn?{autoComplete:"off",spellCheck:"false",autoCorrect:"off",autoCapitalize:"none"}:{};return _s&&(wa.role="combobox",wa["aria-expanded"]=Tg,wa["aria-haspopup"]=jg,wa["aria-controls"]=Jt?cs?.id:void 0,wa["aria-autocomplete"]=U),{reference:wa,floating:{role:"presentation"}}},[uo,Jt,Tg,jg,cs?.id,U]),WN=e_(Sy,{enabled:!g&&!$e&&C,event:"mousedown-only",toggle:!1,touchOpenDelay:Ol?0:100,reason:tgn}),om=t_(Sy,{enabled:!g&&!$e&&!fa,outsidePressEvent:{mouse:"sloppy",touch:"intentional"},bubbles:fa?!0:void 0,outsidePress(un){const Wn=yi(un);return!dn(Ya,Wn)&&!dn(Ge.current,Wn)&&!dn(Re.current,Wn)&&!dn(Ks,Wn)}}),Ux=yye(Sy,{enabled:!g&&!$e,id:pe,listRef:ke,activeIndex:Pr,selectedIndex:Os,virtual:!0,loopFocus:I,allowEscape:I&&!bt,focusItemOnOpen:he||d==="none"&&!bt?!1:"auto",focusItemOnHover:N,resetOnPointerLeave:!T,cols:S?2:1,orientation:S?"horizontal":void 0,rtl:ue==="rtl",disabledIndices:dh,onNavigate(un,Wn){!Wn&&!Jt||Hr==="ending"||_l(Wn?{activeIndex:un,type:ye.current?"keyboard":"pointer"}:{activeIndex:un})}}),N_=y.useMemo(()=>wo(Ux.reference,om.reference,WN.reference,P1.reference),[Ux.reference,om.reference,WN.reference,P1.reference]),I_=y.useMemo(()=>wo(sy,Ux.floating,om.floating,P1.floating),[Ux.floating,om.floating,P1.floating]),$1=y.useMemo(()=>{const un=Ux.item;return un?{...un,onFocus:void 0}:vs},[Ux.item]);XO(()=>{Tt.update({inline:F,popupProps:I_,inputProps:N_,triggerProps:Oc,itemProps:$1,setOpen:im,setInputValue:Zl,setSelectedValue:Eg,setIndices:_l,onItemHighlighted:_r,handleSelection:Bx,forceMount:us,requestSubmit:A1})}),Nt(()=>{Tt.update({id:pe,selectedValue:At,open:Jt,mounted:Lp,transitionStatus:Hr,items:w,inline:F,popupProps:I_,inputProps:N_,triggerProps:Oc,openMethod:fo,itemProps:$1,selectionMode:d,name:Fe,form:h,disabled:$e,readOnly:g,required:v,grid:S,isGrouped:Me,virtualized:M,onOpenChangeComplete:ss,openOnInputClick:C,itemToStringLabel:R,modal:L,autoHighlight:bt,isItemEqualToValue:B,submitOnItemClick:q,hasInputValue:Pt,requestSubmit:A1,inputOwnsFormValue:d==="none"&&(F||!Tt.state.inputInsidePopup)})},[Tt,pe,At,Jt,Lp,Hr,w,I_,N_,$1,fo,Oc,d,Fe,$e,g,v,ne,S,Me,M,ss,C,R,L,B,q,Pt,F,A1,bt,h]);const TZ=Su(b,ne.inputRef),NZ=y.useMemo(()=>({query:Ve,hasItems:_t,filteredItems:Mt,flatFilteredItems:Dt}),[Ve,_t,Mt,Dt]),A_=y.useMemo(()=>Array.isArray(fn)?"":$m(fn,$),[fn,$]),lm=Ke&&Array.isArray(At)&&At.length>0,M1=Ke||d==="none"&&kc?void 0:Fe,QN=y.useMemo(()=>!Ke||!Array.isArray(At)||!Fe?null:At.map(un=>{const Wn=$m(un,$);return o.jsx("input",{type:"hidden",form:h,name:Fe,value:Wn},Wn)}),[Ke,At,h,Fe,$]),qx=o.jsxs(y.Fragment,{children:[e.children,o.jsx("input",{...ne.getInputValidationProps({onFocus(){if(Ol){Ya?.focus();return}(le.current||Ya)?.focus()},onChange(un){if(un.nativeEvent.defaultPrevented||$e||g){un.preventBaseUIHandler?.();return}const Wn=un.currentTarget.value,_s=Ht(vo,un.nativeEvent);function wa(){if(Ke)return;if(d==="none"){H(Wn!==W.initialValue),Zl(Wn,_s),X()&&ne.commit(Wn);return}const Gi=Ee.current.find(Da=>$m(Da,$).toLowerCase()===Wn.toLowerCase()||ou(Da,R).toLowerCase()===Wn.toLowerCase());Gi!=null&&(H(Gi!==W.initialValue),Eg?.(Gi,_s),X()&&ne.commit(Gi))}w?wa():(us(),queueMicrotask(wa))}}),id:pe&&M1==null?`${pe}-hidden-input`:void 0,form:h,name:M1,autoComplete:D,disabled:$e,required:v&&!lm,readOnly:g,value:A_,ref:TZ,style:M1?QT:Lw,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),QN]});return o.jsx(ght.Provider,{value:Tt,children:o.jsx(vht.Provider,{value:Sy,children:o.jsx(yht.Provider,{value:NZ,children:o.jsx(bht.Provider,{value:ct,children:qx})})})})}function jht(e){const{multiple:t=!1,defaultValue:n,value:r,onValueChange:s,autoComplete:a,...i}=e;return o.jsx(FIn,{...i,selectionMode:t?"multiple":"single",selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:s,formAutoComplete:a})}function zIn(e){return e==null?void 0:`${e}-label`}function UU(e,t){return e??t}function BIn(e){const{children:t,placeholder:n}=e,r=ly(),s=pt(r,on.itemToStringLabel),a=pt(r,on.selectedValue),i=pt(r,on.items),l=pt(r,on.selectionMode)==="multiple",c=pt(r,on.hasSelectedValue),u=!c&&n!=null&&t==null,d=pt(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=_ht(a,i,s):f=Xbe(a,i,s),o.jsx(y.Fragment,{children:f})}const Tht={...dP,...y1,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":""}:null},UIn=y.createContext(void 0);function qIn(){return y.useContext(UIn)}const Nht=y.createContext(void 0);function Kbe(e){const t=y.useContext(Nht);if(t===void 0&&!e)throw new Error(gr(21));return t}const Iht=y.forwardRef(function(t,n){const r=ly(),{buttonRef:s,getButtonProps:a}=hd({native:!1}),i=Su(n,s);function l(u){r.state.setOpen(!1,Ht(Xve,u.nativeEvent,u.currentTarget))}const c=a({onClick:l});return o.jsx("span",{ref:i,...c,"aria-label":"Dismiss",tabIndex:void 0,style:QT})}),Aht=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}=Yh(),{labelId:g}=gx(),v=qIn(),S=!!Kbe(!0),w=ly(),{filteredItems:O}=b1(),_=xht(),C=ay(),E=pt(w,on.required),T=pt(w,on.disabled),N=pt(w,on.readOnly),I=pt(w,on.name),R=pt(w,on.form),$=pt(w,on.selectionMode),B=pt(w,on.autoHighlight),M=pt(w,on.inputProps),F=pt(w,on.triggerProps),V=pt(w,on.open),L=pt(w,on.mounted),z=pt(w,on.selectedValue),U=pt(w,on.popupSide),D=pt(w,on.positionerElement),G=pt(w,on.id),q=pt(w,on.inline),P=pt(w,on.modal),H=!!B,W=L&&D?U:null,X=d||T||a,ae=O.length===0,ee=S||q,J=!ee||P,ie=Ni(i??(ee?void 0:G)),ce=UU(g,void 0),Y=S?yE:u,[ne,ue]=y.useState(null),pe=y.useRef(!1),re=y.useRef(null),he=y.useRef(!1),xe=$==="none"&&!S,be=ht(se=>{const te=S||w.state.inline;te&&!w.state.hasInputValue&&w.state.setInputValue("",Ht(vo)),w.update({inputElement:se,inputInsidePopup:te,inputOwnsFormValue:xe})}),Ie=S||!m?c:m.getValidationProps(c),ke={...Y,open:V,disabled:X,readOnly:N,popupSide:W,listEmpty:ae};function Te(se){if(!v)return;let te;const{highlightedChipIndex:me}=v,ye=v.chipsRef.current.length,Ne=C==="rtl",Re=Ne?"ArrowRight":"ArrowLeft",Ge=Ne?"ArrowLeft":"ArrowRight";if(me!==void 0){if(se.key===Re)se.preventDefault(),me>0?te=me-1:te=void 0;else if(se.key===Ge)se.preventDefault(),me<ye-1?te=me+1:te=void 0;else if(se.key==="Backspace"||se.key==="Delete"){se.preventDefault();const He=me>=z.length-1?z.length-2:me;te=He>=0?He:void 0,w.state.setIndices({activeIndex:null,selectedIndex:null,type:"keyboard"})}return te}return se.key===Re&&(se.currentTarget.selectionStart??0)===0&&z.length>0?(se.preventDefault(),te=ye>0?ye-1:void 0):se.key==="Backspace"&&se.currentTarget.value===""&&z.length>0&&(w.state.setIndices({activeIndex:null,selectedIndex:null,type:"keyboard"}),se.preventDefault()),te}const Le=Cn("input",t,{state:ke,ref:[n,w.state.inputRef,be],props:[M,F,{type:"text",value:t.value??ne??_,"aria-readonly":N||void 0,"aria-required":E||void 0,"aria-labelledby":ce,disabled:X,readOnly:N,required:$==="none"?E:void 0,form:R,...xe&&I&&{name:I},id:ie,onFocus(){if(p(!0),!q||!he.current)return;he.current=!1;const se=re.current;se==null||!Object.hasOwn(w.state.valuesRef.current,se)||w.state.setIndices({activeIndex:se})},onBlur(){f(!0),p(!1);const se=w.state.activeIndex;if(q&&se!==null&&B!=="always"&&(re.current=se,he.current=!0,w.state.setIndices({activeIndex:null})),h==="onBlur"){const te=$==="none"?_:z;m.commit(te)}},onCompositionStart(se){lP||(pe.current=!0,ue(se.currentTarget.value))},onCompositionEnd(se){pe.current=!1;const te=se.currentTarget.value;ue(null),w.state.setInputValue(te,Ht(tk,se.nativeEvent))},onChange(se){const te=se.nativeEvent.inputType,me=!te||te==="insertReplacementText",ye=pe.current||!me;if(pe.current){const He=se.currentTarget.value;ue(He),He===""&&!w.state.openOnInputClick&&!w.state.inputInsidePopup&&w.state.setOpen(!1,Ht(ib,se.nativeEvent));const Oe=He.trim(),_e=H&&Oe!=="";!N&&!X&&Oe&&ye&&(w.state.setOpen(!0,Ht(tk,se.nativeEvent)),H||w.state.setIndices({activeIndex:null,selectedIndex:null,type:w.state.keyboardActiveRef.current?"keyboard":"pointer"})),V&&w.state.activeIndex!==null&&!_e&&w.state.setIndices({activeIndex:null,selectedIndex:null,type:w.state.keyboardActiveRef.current?"keyboard":"pointer"});return}w.state.setInputValue(se.currentTarget.value,Ht(tk,se.nativeEvent));const Ne=se.currentTarget.value==="",Re=Ht(ib,se.nativeEvent);Ne&&!w.state.inputInsidePopup&&($==="single"&&w.state.setSelectedValue(null,Re),w.state.openOnInputClick||w.state.setOpen(!1,Re));const Ge=se.currentTarget.value.trim();!N&&!X&&Ge&&ye&&(w.state.setOpen(!0,Ht(tk,se.nativeEvent)),H||w.state.setIndices({activeIndex:null,selectedIndex:null,type:w.state.keyboardActiveRef.current?"keyboard":"pointer"})),V&&w.state.activeIndex!==null&&!H&&w.state.setIndices({activeIndex:null,selectedIndex:null,type:w.state.keyboardActiveRef.current?"keyboard":"pointer"})},onKeyDown(se){if(X||N||se.ctrlKey||se.shiftKey||se.altKey||se.metaKey)return;w.state.keyboardActiveRef.current=!0;const te=se.currentTarget,me=te.scrollWidth-te.clientWidth,ye=C==="rtl";if(se.key==="Home"){Kl(se);const Ge=s$e&&ye?te.value.length:0;te.setSelectionRange(Ge,Ge),te.scrollLeft=0;return}if(se.key==="End"){Kl(se);const Ge=s$e&&ye?0:te.value.length;te.setSelectionRange(Ge,Ge),te.scrollLeft=ye?-me:me;return}if(!L&&se.key==="Escape"){const Ge=$==="multiple"&&Array.isArray(z)?z.length===0:z===null,He=Ht(JO,se.nativeEvent),Oe=$==="multiple"?[]:null;w.state.setInputValue("",He),w.state.setSelectedValue(Oe,He),!Ge&&!w.state.inline&&!He.isPropagationAllowed&&se.stopPropagation();return}if(v&&se.key==="Backspace"&&te.value===""&&v.highlightedChipIndex===void 0&&Array.isArray(z)&&z.length>0){const Ge=v.chipsRef.current.length,He=Ge>0?Ge-1:z.length-1,Oe=z.filter((_e,Ee)=>Ee!==He);w.state.setIndices({activeIndex:null,selectedIndex:null,type:w.state.keyboardActiveRef.current?"keyboard":"pointer"}),w.state.setSelectedValue(Oe,Ht(vo,se.nativeEvent));return}const Ne=v?.highlightedChipIndex!==void 0,Re=Te(se);if(v?.setHighlightedChipIndex(Re),Re!==void 0?v?.chipsRef.current[Re]?.focus():Ne&&w.state.inputRef.current?.focus(),se.which!==229&&se.key==="Enter"&&V){const Ge=w.state.activeIndex,He=se.nativeEvent;if(Ge===null){if(q)return;w.state.setOpen(!1,Ht(vo,He));return}Kl(se);const Oe=w.state.listRef.current[Ge];Oe&&(w.state.selectionEventRef.current=He,Oe.click(),w.state.selectionEventRef.current=null)}},onPointerMove(){w.state.keyboardActiveRef.current=!1},onPointerDown(){w.state.keyboardActiveRef.current=!1}},Ie],stateAttributesMapping:Tht}),le=S?o.jsx(uht.Provider,{value:cht,children:Le}):Le;return o.jsxs(y.Fragment,{children:[V&&J&&o.jsx(Iht,{ref:w.state.startDismissRef}),le]})});function Jbe(e){const t=e.getBoundingClientRect(),n=Gs(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 dL=2,Rht=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}=Yh(),{labelId:v}=gx(),b=ly(),{filteredItems:S}=b1(),w=pt(b,on.selectionMode),O=pt(b,on.disabled),_=pt(b,on.readOnly),C=pt(b,on.required),E=pt(b,on.mounted),T=pt(b,on.popupSide),N=pt(b,on.positionerElement),I=pt(b,on.listElement),R=pt(b,on.triggerProps),$=pt(b,on.triggerElement),B=pt(b,on.inputInsidePopup),M=pt(b,on.id),F=pt(b,on.labelId),V=pt(b,on.open),L=pt(b,on.selectedValue),z=pt(b,on.activeIndex),U=pt(b,on.selectedIndex),D=pt(b,on.hasSelectedValue),G=BU(),q=xht(),P=to(),H=f||O||i,W=S.length===0,X=E&&N?T:null;o_({id:B?l:void 0});const ae=B?l??M:l,ee=UU(v,F),J=y.useRef("");function ie(be){J.current=be.pointerType}const ce=G.useState("domReferenceElement");y.useEffect(()=>{B&&$&&$!==ce&&G.set("domReferenceElement",$)},[$,ce,G,B]);const{reference:Y}=bye(G,{enabled:!V&&!_&&!O&&w==="single",listRef:b.state.labelsRef,activeIndex:z,selectedIndex:U,onMatch(be){const Ie=b.state.valuesRef.current[be];Ie!==void 0&&b.state.setSelectedValue(Ie,Ht("none"))}}),{reference:ne}=e_(G,{enabled:!_&&!O,event:"mousedown"}),{buttonRef:ue,getButtonProps:pe}=hd({native:a,disabled:H}),re={...d,open:V,disabled:H,popupSide:X,listEmpty:W,placeholder:w==="none"?!1:!D},he=ht(be=>{b.set("triggerElement",be)});return Cn("button",t,{ref:[n,ue,he],state:re,props:[R,ne,Y,{id:ae,tabIndex:B?0:-1,role:B?"combobox":void 0,"aria-expanded":V?"true":"false","aria-haspopup":B?"dialog":"listbox","aria-controls":V?I?.id:void 0,"aria-required":B&&C||void 0,"aria-labelledby":ee,onPointerDown:ie,onPointerEnter:ie,onFocus(){h(!0),!(H||_)&&P.start(0,b.state.forceMount)},onBlur(be){if(!dn(N,be.relatedTarget)&&(p(!0),h(!1),m==="onBlur")){const Ie=w==="none"?q:L;g.commit(Ie)}},onMouseDown(be){if(H||_||(B||G.set("domReferenceElement",be.currentTarget),b.state.forceMount(),J.current!=="touch"&&(b.state.inputRef.current?.focus(),B||be.preventDefault()),V))return;const Ie=cr(be.currentTarget);function ke(Te){if(!$)return;const Le=yi(Te),le=b.state.positionerElement,se=b.state.listElement;if(dn($,Le)||dn(le,Le)||dn(se,Le)||Le===$)return;const te=Jbe($),me=Te.clientX>=te.left-dL&&Te.clientX<=te.right+dL,ye=Te.clientY>=te.top-dL&&Te.clientY<=te.bottom+dL;me&&ye||b.state.setOpen(!1,Ht("cancel-open",Te))}B&&Ie.addEventListener("mouseup",ke,{once:!0})},onKeyDown(be){H||_||(be.key==="ArrowDown"||be.key==="ArrowUp")&&(Kl(be),b.state.setOpen(!0,Ht(az,be.nativeEvent)),b.state.inputRef.current?.focus())}},g?g.getValidationProps(u):u,pe],stateAttributesMapping:Tht})}),VIn=y.createContext(null);function HIn(){return y.useContext(VIn)}function ZIn(e){const{children:t}=e,{filteredItems:n}=b1(),r=HIn(),s=r?r.items:n;return s?o.jsx(y.Fragment,{children:s.map(t)}):null}const Pht=y.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function WIn(){return y.useContext(Pht)}function fN(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:s}=e,a=ht(s),i=y.useRef(0),l=lc(GIn).current,c=lc(QIn).current,[u,d]=y.useState(0),f=y.useRef(u),p=ht((b,S)=>{c.set(b,S??null),f.current+=1,d(f.current)}),h=ht(b=>{c.delete(b),f.current+=1,d(f.current)}),m=y.useMemo(()=>{const b=new Map;return Array.from(c.keys()).filter(w=>w.isConnected).sort(YIn).forEach((w,O)=>{const _=c.get(w)??{};b.set(w,{..._,index:O})}),b},[c,u]);Nt(()=>{if(typeof MutationObserver!="function"||m.size===0)return;const b=new MutationObserver(S=>{const w=new Set,O=_=>w.has(_)?w.delete(_):w.add(_);S.forEach(_=>{_.removedNodes.forEach(O),_.addedNodes.forEach(O)}),w.size===0&&(f.current+=1,d(f.current))});return m.forEach((S,w)=>{w.parentElement&&b.observe(w.parentElement,{childList:!0})}),()=>{b.disconnect()}},[m]),Nt(()=>{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]),Nt(()=>()=>{n.current=[]},[n]),Nt(()=>()=>{r&&(r.current=[])},[r]);const g=ht(b=>(l.add(b),()=>{l.delete(b)}));Nt(()=>{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(Pht.Provider,{value:v,children:t})}function QIn(){return new Map}function GIn(){return new Set}function YIn(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 $ht=y.forwardRef(function(t,n){var r;const{render:s,className:a,style:i,children:l,...c}=t,u=ly(),d=BU(),f=!!Kbe(!0),{filteredItems:p,hasItems:h}=b1(),m=pt(u,on.selectionMode),g=pt(u,on.grid),v=pt(u,on.popupProps),b=pt(u,on.virtualized),S=m==="multiple",w=p.length===0,O=ht(I=>{u.set("positionerElement",I)}),_=ht(I=>{u.set("listElement",I)}),C=y.useMemo(()=>typeof l=="function"?r||(r=o.jsx(ZIn,{children:l})):l,[l]),E={empty:w},T=d.useState("floatingId"),N=Cn("div",t,{state:E,ref:[n,_,f?null:O],props:[v,{children:C,tabIndex:-1,id:T,role:g?"grid":"listbox","aria-multiselectable":S?"true":void 0,onKeyDown(I){if(!(u.state.disabled||u.state.readOnly)&&I.key==="Enter"){const R=u.state.activeIndex;if(R==null)return;Kl(I);const $=I.nativeEvent,B=u.state.listRef.current[R];B&&(u.state.selectionEventRef.current=$,B.click(),u.state.selectionEventRef.current=null)}},onKeyDownCapture(){u.state.keyboardActiveRef.current=!0},onPointerMoveCapture(){u.state.keyboardActiveRef.current=!1}},c]});return b?N:o.jsx(fN,{elementsRef:u.state.listRef,labelsRef:h?void 0:u.state.labelsRef,children:N})}),XIn="⁠",KIn=200;function JIn(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 eAn(){const e=to(),t=y.useRef(null);return y.useEffect(()=>{if(Qve)return;const n=t.current;if(n==null)return;const r=JIn(n);if(r==null)return;const s=r.nodeValue??"",a=`${s}${XIn}`;return r.nodeValue=a,e.start(KIn,()=>{r.nodeValue===a&&(r.nodeValue=s)}),()=>{e.clear(),r.nodeValue===a&&(r.nodeValue=s)}},[t,e]),t}const Mht=y.createContext(void 0);function tAn(){const e=y.useContext(Mht);if(e===void 0)throw new Error(gr(20));return e}const Dht=y.forwardRef(function(t,n){const{keepMounted:r=!1,...s}=t,a=ly(),i=pt(a,on.mounted),l=pt(a,on.forceMounted);return i||r||l?o.jsx(Mht.Provider,{value:r,children:o.jsx(FM,{ref:n,...s})}):null}),nAn=20;function qU(e,t,n,r){const[s,a]=y.useState(!1);Nt(()=>{if(!e||!t||n==null){a(!1);return}const i=cr(n).documentElement.clientWidth,l=n.offsetWidth;a(i>0&&l>0&&l>=i-nAn)},[e,t,n]),zpt(e&&(!t||s),r)}const Lht=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=aye,style:b,...S}=t,w=ly(),{filteredItems:O}=b1(),_=BU(),C=tAn(),E=pt(w,on.modal),T=pt(w,on.open),N=pt(w,on.mounted),I=pt(w,on.openMethod),R=pt(w,on.positionerElement),$=pt(w,on.triggerElement),B=pt(w,on.inputElement),M=pt(w,on.inputGroupElement),F=pt(w,on.inputInsidePopup),V=pt(w,on.transitionStatus),L=O.length===0,U=KT({anchor:a??(F?$:M??B),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});qU(T&&E,I==="touch",R,$);const D={open:T,side:U.side,align:U.align,anchorHidden:U.anchorHidden,empty:L};Nt(()=>{w.set("popupSide",U.side)},[w,U.side]);const G=ht(P=>{w.set("positionerElement",P)}),q=JT(t,D,{styles:U.positionerStyles,transitionStatus:V,props:S,refs:[n,G],hidden:!N,inert:!T});return o.jsxs(Nht.Provider,{value:U,children:[N&&E&&o.jsx(iD,{inert:eN(!T),cutout:M??B??$}),q]})}),rAn={...ff,...Bl},Fht=y.forwardRef(function(t,n){const{render:r,className:s,style:a,initialFocus:i,finalFocus:l,...c}=t,u=ly(),d=Kbe(),f=BU(),{filteredItems:p}=b1(),h=pt(u,on.mounted),m=pt(u,on.open),g=pt(u,on.openMethod),v=pt(u,on.transitionStatus),b=pt(u,on.inputInsidePopup),S=pt(u,on.inputElement),w=pt(u,on.modal),O=p.length===0;Ul({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=Cn("div",t,{state:_,ref:[n,u.state.popupRef],props:[{role:b?"dialog":"presentation",tabIndex:-1,onFocus(R){const $=yi(R.nativeEvent);g!=="touch"&&(dn(u.state.listElement,$)||$===R.currentTarget)&&u.state.inputRef.current?.focus()}},r_(v),c],stateAttributesMapping:rAn}),T=i===void 0?b?R=>R==="touch"?u.state.popupRef.current:S:!1:i;let N;l!=null?N=l:N=b?void 0:!1;const I=!b||w;return o.jsx(GT,{context:f,disabled:!h,modal:I,openInteractionType:g,initialFocus:T,returnFocus:N,getInsideElements:()=>[u.state.startDismissRef.current,u.state.endDismissRef.current],children:o.jsxs(y.Fragment,{children:[C,I&&o.jsx(Iht,{ref:u.state.endDismissRef})]})})});let exe=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function vx(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}=WIn(),p=y.useRef(-1),[h,m]=y.useState(a??(s===exe.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 S=t!==void 0;d.current[h]=S?t:r?.current?.textContent??b.textContent}},[h,u,d,t,r]);return Nt(()=>{if(a!=null)return;const b=g.current;if(b)return i(b,n),()=>{l(b)}},[a,i,l,n]),Nt(()=>{if(a==null)return c(b=>{const S=g.current?b.get(g.current)?.index:null;S!=null&&m(S)})},[a,c,m]),y.useMemo(()=>({ref:v,index:h}),[h,v])}const zht=y.createContext(void 0);function Bht(){const e=y.useContext(zht);if(!e)throw new Error(gr(19));return e}const sAn=y.createContext(!1);function aAn(){return y.useContext(sAn)}const Uht=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=vx({index:l,textRef:p,indexGuessBehavior:exe.GuessFromOrder}),m=ly(),g=aAn(),{flatFilteredItems:v,hasItems:b}=b1(),S=pt(m,on.open),w=pt(m,on.selectionMode),O=pt(m,on.readOnly),_=pt(m,on.virtualized),C=pt(m,on.isItemEqualToValue),E=w!=="none",T=l??(_?mw(v,i,C):h.index),N=h.index!==-1,I=pt(m,on.id),R=pt(m,on.isActive,T),$=pt(m,on.isSelected,i),B=pt(m,on.itemProps),M=y.useRef(null),F=I!=null&&N?`${I}-${T}`:void 0,V=$&&E;Nt(()=>{if(!(N&&(_||l!=null)))return;const W=m.state.listRef.current;return W[T]=M.current,()=>{delete W[T]}},[N,_,T,l,m]),Nt(()=>{if(!N||b)return;const H=m.state.valuesRef.current;return H[T]=i,w!=="none"&&m.state.allValuesRef.current.push(i),()=>{delete H[T]}},[N,b,T,i,m,w]),Nt(()=>{if(!S){f.current=!1;return}if(!N||b)return;const H=m.state.selectedValue,W=Array.isArray(H)?H[H.length-1]:H;Bv(i,W,C)&&m.set("selectedIndex",T)},[N,b,S,m,T,i,C]);const{getButtonProps:L,buttonRef:z}=hd({disabled:c,focusableWhenDisabled:!0,native:u,composite:!0}),U={disabled:c,selected:V,highlighted:R};function D(H){function W(){m.state.handleSelection(H,i)}m.state.submitOnItemClick?(ko.flushSync(W),m.state.requestSubmit()):W()}const G={id:F,role:g?"gridcell":"option","aria-selected":E?V:void 0,tabIndex:void 0,onPointerDownCapture(H){f.current=!0,H.preventDefault()},onMouseDown(H){H.preventDefault()},onClick(H){c||O||D(H.nativeEvent)},onMouseUp(H){const W=f.current;f.current=!1,!(c||O||H.button!==0||W||!R)&&D(H.nativeEvent)}},q=Cn("div",t,{ref:[z,n,h.ref,M],state:U,props:[B,G,d,L]}),P=y.useMemo(()=>({selected:V,textRef:p}),[V,p]);return o.jsx(zht.Provider,{value:P,children:q})})),iAn=y.forwardRef(function(t,n){const r=t.keepMounted??!1,{selected:s}=Bht();return r||s?o.jsx(oAn,{...t,ref:n}):null}),oAn=y.memo(y.forwardRef((e,t)=>{const{render:n,className:r,style:s,keepMounted:a,...i}=e,{selected:l}=Bht(),c=y.useRef(null),{transitionStatus:u,setMounted:d}=gg(l),p=Cn("span",e,{ref:[t,c],state:{selected:l,transitionStatus:u},props:[{"aria-hidden":!0,children:"✔️"},i],stateAttributesMapping:Bl});return Ul({open:l,ref:c,onComplete(){l||d(!1)}}),p})),qht=y.forwardRef(function(t,n){const{render:r,className:s,style:a,children:i,...l}=t,{filteredItems:c}=b1(),u=ly(),d=eAn(),f=c.length===0?i:null;return Cn("div",t,{ref:[n,u.state.emptyRef,d],props:[{children:f,role:"status","aria-live":"polite","aria-atomic":!0},l]})}),lAn=y.forwardRef(function(t,n){const{className:r,render:s,orientation:a="horizontal",style:i,...l}=t;return Cn("div",t,{state:{orientation:a},ref:n,props:[{role:"separator","aria-orientation":a},l]})});function cAn(e){return e==="link"?"ghost":e}function Vht({variant:e,size:t,error:n,className:r}){const s=cAn(e);return K(QM({variant:s,size:t}),"w-full min-w-32 justify-between",Ylt[s],"data-[placeholder]:text-neutral3",n&&"border-error hover:border-error focus-visible:border-error",r)}const ps={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",ns.colors),searchIcon:K("mr-2 h-3.5 w-3.5 shrink-0 text-neutral3",ns.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",ns.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",ns.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",ns.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 Hht({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(S=>S.value))},v=m.length===0?r:`${m.length} selected`;return o.jsxs("div",{className:ps.root,children:[o.jsxs(jht,{multiple:!0,items:e,value:m,onValueChange:g,disabled:l,open:d,onOpenChange:f,children:[o.jsxs(Rht,{className:Vht({variant:c,size:u,error:!!h,className:i}),children:[o.jsx("span",{className:K("truncate",m.length===0&&ps.placeholder),children:v}),o.jsx("span",{className:"flex shrink-0 items-center",children:o.jsx(nD,{className:ps.chevron})})]}),o.jsx(Dht,{container:p,children:o.jsx(Lht,{align:"start",sideOffset:4,className:ps.positioner,children:o.jsxs(Fht,{className:ps.popup,children:[o.jsxs("div",{className:ps.searchContainer,children:[o.jsx(Uj,{className:ps.searchIcon}),o.jsx(Aht,{className:ps.searchInput,placeholder:s})]}),o.jsx(qht,{className:ps.empty,children:a}),o.jsx($ht,{className:ps.list,children:b=>{const S=t.includes(b.value);return o.jsxs(Uht,{value:b,className:ps.itemMulti,children:[o.jsx("span",{className:K(ps.checkbox,S?ps.checkboxSelected:ps.checkboxUnselected),children:S&&o.jsx(hx,{className:ps.checkboxIcon})}),o.jsxs("span",{className:ps.optionContent,children:[b.start,o.jsxs("span",{className:ps.optionText,children:[o.jsx("span",{className:ps.optionLabel,children:b.label}),b.description&&o.jsx("span",{className:ps.optionDescription,children:b.description})]}),b.end?o.jsx("div",{className:ps.optionEnd,children:b.end}):null]})]},b.value)}})]})})})]}),h&&o.jsx("span",{className:ps.error,children:h})]})}const Zht=y.createContext(void 0);function uAn({container:e,children:t}){return o.jsx(Zht.Provider,{value:e??void 0,children:t})}function lD(e){const t=y.useContext(Zht);return e??t??void 0}function Hc({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=lD(p),v=b=>{b&&n?.(b.value)};return o.jsxs("div",{className:ps.root,children:[o.jsxs(jht,{autoHighlight:!0,items:e,value:m,onValueChange:v,disabled:l,open:d,onOpenChange:f,children:[o.jsxs(Rht,{className:Vht({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(BIn,{placeholder:r})})]}),o.jsx("span",{className:"flex shrink-0 items-center",children:o.jsx(nD,{className:ps.chevron})})]}),o.jsx(Dht,{container:g,children:o.jsx(Lht,{align:"start",sideOffset:4,className:ps.positioner,children:o.jsxs(Fht,{className:ps.popup,children:[o.jsxs("div",{className:ps.searchContainer,children:[o.jsx(Uj,{className:ps.searchIcon}),o.jsx(Aht,{className:ps.searchInput,placeholder:s})]}),o.jsx(qht,{className:ps.empty,children:a}),o.jsx($ht,{className:ps.list,children:b=>o.jsxs(Uht,{value:b,className:ps.item,children:[b.start,o.jsxs("span",{className:ps.optionText,children:[o.jsx("span",{className:ps.optionLabel,children:b.label}),b.description&&o.jsx("span",{className:ps.optionDescription,children:b.description})]}),o.jsxs("span",{className:ps.itemRightSlot,children:[b.end?o.jsx("div",{className:ps.optionEnd,children:b.end}):null,o.jsx("span",{className:ps.checkContainer,children:o.jsx(iAn,{children:o.jsx(hx,{className:ps.checkIcon})})})]})]},b.value)})]})})})]}),h&&o.jsx("span",{className:ps.error,children:h})]})}var M4e=1,dAn=.9,fAn=.8,pAn=.17,ZY=.1,WY=.999,hAn=.9999,mAn=.99,gAn=/[\\\/_+.#"@\[\(\{&]/,vAn=/[\\\/_+.#"@\[\(\{&]/g,yAn=/[\s-]/,Wht=/[\s-]/g;function Mde(e,t,n,r,s,a,i){if(a===t.length)return s===e.length?M4e:mAn;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=Mde(e,t,n,r,u+1,a+1,i),f>d&&(u===s?f*=M4e:gAn.test(e.charAt(u-1))?(f*=fAn,h=e.slice(s,u-1).match(vAn),h&&s>0&&(f*=Math.pow(WY,h.length))):yAn.test(e.charAt(u-1))?(f*=dAn,m=e.slice(s,u-1).match(Wht),m&&s>0&&(f*=Math.pow(WY,m.length))):(f*=pAn,s>0&&(f*=Math.pow(WY,u-s))),e.charAt(u)!==t.charAt(a)&&(f*=hAn)),(f<ZY&&n.charAt(u-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(u-1)!==r.charAt(a))&&(p=Mde(e,t,n,r,u+1,a+2,i),p*ZY>f&&(f=p*ZY)),f>d&&(d=f),u=n.indexOf(c,u+1);return i[l]=d,d}function D4e(e){return e.toLowerCase().replace(Wht," ")}function bAn(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Mde(e,t,D4e(e),D4e(t),0,0,{})}var QY="focusScope.autoFocusOnMount",GY="focusScope.autoFocusOnUnmount",L4e={bubbles:!1,cancelable:!0},xAn="FocusScope",Qht=y.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...i}=e,[l,c]=y.useState(null),u=Cj(s),d=Cj(a),f=y.useRef(null),p=mg(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(w){if(h.paused||!l)return;const O=w.target;l.contains(O)?f.current=O:A0(f.current,{select:!0})},v=function(w){if(h.paused||!l)return;const O=w.relatedTarget;O!==null&&(l.contains(O)||A0(f.current,{select:!0}))},b=function(w){if(document.activeElement===document.body)for(const _ of w)_.removedNodes.length>0&&A0(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",v);const S=new MutationObserver(b);return l&&S.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",v),S.disconnect()}}},[r,l,h.paused]),y.useEffect(()=>{if(l){z4e.add(h);const g=document.activeElement;if(!l.contains(g)){const b=new CustomEvent(QY,L4e);l.addEventListener(QY,u),l.dispatchEvent(b),b.defaultPrevented||(wAn(CAn(Ght(l)),{select:!0}),document.activeElement===g&&A0(l))}return()=>{l.removeEventListener(QY,u),setTimeout(()=>{const b=new CustomEvent(GY,L4e);l.addEventListener(GY,d),l.dispatchEvent(b),b.defaultPrevented||A0(g??document.body,{select:!0}),l.removeEventListener(GY,d),z4e.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 S=g.currentTarget,[w,O]=SAn(S);w&&O?!g.shiftKey&&b===O?(g.preventDefault(),n&&A0(w,{select:!0})):g.shiftKey&&b===w&&(g.preventDefault(),n&&A0(O,{select:!0})):b===S&&g.preventDefault()}},[n,r,h.paused]);return o.jsx(uf.div,{tabIndex:-1,...i,ref:p,onKeyDown:m})});Qht.displayName=xAn;function wAn(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(A0(r,{select:t}),document.activeElement!==n)return}function SAn(e){const t=Ght(e),n=F4e(t,e),r=F4e(t.reverse(),e);return[n,r]}function Ght(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 F4e(e,t){for(const n of e)if(!kAn(n,{upTo:t}))return n}function kAn(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 OAn(e){return e instanceof HTMLInputElement&&"select"in e}function A0(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&OAn(e)&&t&&e.select()}}var z4e=_An();function _An(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=B4e(e,t),e.unshift(t)},remove(t){e=B4e(e,t),e[0]?.resume()}}}function B4e(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function CAn(e){return e.filter(t=>t.tagName!=="A")}var YY=0;function EAn(){y.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??U4e()),document.body.insertAdjacentElement("beforeend",e[1]??U4e()),YY++,()=>{YY===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),YY--}},[])}function U4e(){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 sv=function(){return sv=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},sv.apply(this,arguments)};function Yht(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 jAn(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 $8="right-scroll-bar-position",M8="width-before-scroll-bar",TAn="with-scroll-bars-hidden",NAn="--removed-body-scroll-bar-size";function XY(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function IAn(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 AAn=typeof window<"u"?y.useLayoutEffect:y.useEffect,q4e=new WeakMap;function RAn(e,t){var n=IAn(null,function(r){return e.forEach(function(s){return XY(s,r)})});return AAn(function(){var r=q4e.get(n);if(r){var s=new Set(r),a=new Set(e),i=n.current;s.forEach(function(l){a.has(l)||XY(l,null)}),a.forEach(function(l){s.has(l)||XY(l,i)})}q4e.set(n,e)},[e]),n}function PAn(e){return e}function $An(e,t){t===void 0&&(t=PAn);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 MAn(e){e===void 0&&(e={});var t=$An(null);return t.options=sv({async:!0,ssr:!1},e),t}var Xht=function(e){var t=e.sideCar,n=Yht(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,sv({},n))};Xht.isSideCarExport=!0;function DAn(e,t){return e.useMedium(t),Xht}var Kht=MAn(),KY=function(){},VU=y.forwardRef(function(e,t){var n=y.useRef(null),r=y.useState({onScrollCapture:KY,onWheelCapture:KY,onTouchMoveCapture:KY}),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,S=b===void 0?"div":b,w=e.gapMode,O=Yht(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),_=p,C=RAn([n,t]),E=sv(sv({},O),s);return y.createElement(y.Fragment,null,d&&y.createElement(_,{sideCar:Kht,removeScrollBar:u,shards:f,noRelative:h,noIsolation:m,inert:g,setCallbacks:a,allowPinchZoom:!!v,lockRef:n,gapMode:w}),i?y.cloneElement(y.Children.only(l),sv(sv({},E),{ref:C})):y.createElement(S,sv({},E,{className:c,ref:C}),l))});VU.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};VU.classNames={fullWidth:M8,zeroRight:$8};var LAn=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function FAn(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=LAn();return t&&e.setAttribute("nonce",t),e}function zAn(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function BAn(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var UAn=function(){var e=0,t=null;return{add:function(n){e==0&&(t=FAn())&&(zAn(t,n),BAn(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},qAn=function(){var e=UAn();return function(t,n){y.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Jht=function(){var e=qAn(),t=function(n){var r=n.styles,s=n.dynamic;return e(r,s),null};return t},VAn={left:0,top:0,right:0,gap:0},JY=function(e){return parseInt(e||"",10)||0},HAn=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[JY(n),JY(r),JY(s)]},ZAn=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return VAn;var t=HAn(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])}},WAn=Jht(),tj="data-scroll-locked",QAn=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(TAn,` {
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 SWr({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(Qe,{children:o.jsx(cp,{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 kWr({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}=bZr(),{batchInsertItems:b}=Ai(),S=y.useCallback(async I=>{try{const R=await m(I);l(R),a("preview")}catch{}},[m]),w=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(R=>({input:R.input,groundTruth:R.groundTruth,metadata:R.metadata}))}),f({success:I.length,errors:0})}catch{f({success:0,errors:I.length})}u({current:I.length,total:I.length}),h(!1),a("complete")},[i,b,e]),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,E=()=>{switch(s){case"upload":return o.jsx(wWr,{onFileSelect:S,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(SWr,{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(xWr,{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(Wt,{}),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":"",")"]})]})]})]})}},T=()=>{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:w,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(kr,{open:t,onOpenChange:_,children:o.jsxs(yr,{className:"max-w-2xl max-h-[90vh]",children:[o.jsxs(br,{children:[o.jsx(hr,{children:N[s]}),o.jsx(Ns,{children:"Import dataset items from a JSON file."})]}),o.jsx(Ar,{className:"min-h-[200px] max-h-[50vh] overflow-y-auto",children:E()}),o.jsx(cc,{className:"px-6 pt-4 flex justify-end gap-2",children:T()})]})})}const XCe=e=>{const t=Ze(),{data:n}=cM(e),r=n?.experiments;return St({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})},OWr=e=>{const t=Ze(),{data:n}=cM(e),r=n?.experiments;return St({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 _Wr(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 t5t({datasetId:e,experimentId:t,featuredItemId:n}){const r=Ze(),{data:s}=Nx(e),{data:a,isLoading:i}=XCe(e),{data:l,isLoading:c}=OWr(e),u=y.useMemo(()=>t?(a??[]).filter(Oe=>Oe.experimentId===t):a,[a,t]),d=y.useMemo(()=>t?(l??[]).filter(Oe=>Oe.experimentId===t):l,[l,t]),{updateExperimentResult:f}=Ai(),[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),[S,w]=y.useState(!1),[O,_]=y.useState(!1),[C,E]=y.useState(!1),[T,N]=y.useState(""),[I,R]=y.useState(""),[$,B]=y.useState(""),[M,F]=y.useState([]),[V,L]=y.useState(!1),[z,U]=y.useState(null),D=y.useMemo(()=>z??u??[],[z,u]);y.useEffect(()=>{U(null)},[e,t]),y.useEffect(()=>{u&&z===null&&U(u)},[u,z]);const G=y.useMemo(()=>{const Oe=new Set;if(s?.tags)for(const _e of s.tags)Oe.add(_e);for(const _e of D)for(const Ee of _e.tags)Oe.add(Ee);return[...Oe].sort()},[s,D]),q=y.useCallback(Oe=>{!s||!e||(s.tags??[]).includes(Oe)},[s,e]),P=y.useMemo(()=>m?m==="__untagged__"?D.filter(Oe=>Oe.tags.length===0):D.filter(Oe=>Oe.tags.includes(m)):D,[D,m]),H=y.useMemo(()=>{const Oe=new Map;for(const _e of D)for(const Ee of _e.tags)Oe.set(Ee,(Oe.get(Ee)??0)+1);return[...Oe.entries()].sort((_e,Ee)=>Ee[1]-_e[1])},[D]),W=y.useMemo(()=>D.filter(Oe=>Oe.tags.length===0).length,[D]),X=y.useMemo(()=>{let Oe=0;return m&&Oe++,S&&Oe++,Oe},[m,S]),ae=y.useCallback((Oe,_e)=>{U(je=>(je??[]).map($e=>$e.id===Oe?{...$e,tags:_e}:$e));const Ee=D.find(je=>je.id===Oe);Ee?.experimentId&&Ee?.datasetId&&f.mutate({datasetId:Ee.datasetId,experimentId:Ee.experimentId,resultId:Ee.id,tags:_e})},[D,f]),ee=y.useCallback((Oe,_e)=>{const Ee=D.find(je=>je.id===Oe);Ee?.traceId&&_e!==void 0&&r.createFeedback({feedback:{traceId:Ee.traceId,source:"studio",feedbackSource:"studio",feedbackType:"rating",value:_e==="positive"?1:-1,experimentId:Ee.experimentId??void 0,sourceId:Ee.id}}).catch(()=>{}),U(je=>(je??[]).map($e=>$e.id===Oe?{...$e,rating:_e}:$e))},[D,r]),J=y.useCallback((Oe,_e)=>{const Ee=D.find(je=>je.id===Oe);Ee?.traceId&&r.createFeedback({feedback:{traceId:Ee.traceId,source:"studio",feedbackSource:"studio",feedbackType:"comment",value:_e,comment:_e,experimentId:Ee.experimentId??void 0,sourceId:Ee.id}}).catch(()=>{}),U(je=>(je??[]).map($e=>$e.id===Oe?{...$e,comment:_e}:$e))},[D,r]),ie=y.useCallback(Oe=>{const _e=D.find(Ee=>Ee.id===Oe);U(Ee=>(Ee??[]).filter(je=>je.id!==Oe)),b(Ee=>{const je=new Set(Ee);return je.delete(Oe),je}),p===Oe&&h(null),_e?.experimentId&&_e?.datasetId&&f.mutate({datasetId:_e.datasetId,experimentId:_e.experimentId,resultId:_e.id,status:null})},[D,f,p]),ce=y.useCallback(Oe=>{const _e=D.find(Ee=>Ee.id===Oe);U(Ee=>(Ee??[]).filter(je=>je.id!==Oe)),b(Ee=>{const je=new Set(Ee);return je.delete(Oe),je}),p===Oe&&h(null),_e?.experimentId&&_e?.datasetId&&f.mutate({datasetId:_e.datasetId,experimentId:_e.experimentId,resultId:_e.id,status:"complete"})},[D,f,p]),Y=y.useMemo(()=>{const Oe=S?d??[]:P;return!S||!m?Oe:m==="__untagged__"?Oe.filter(_e=>_e.tags.length===0):Oe.filter(_e=>_e.tags.includes(m))},[S,d,P,m]),ne=S?c:!1,ue=y.useMemo(()=>new Set(Y.map(Oe=>Oe.id)),[Y]),pe=y.useMemo(()=>[...v].filter(Oe=>ue.has(Oe)).length,[v,ue]),re=Y.length>0&&pe===Y.length,he=pe>0&&!re,xe=y.useCallback(Oe=>{b(_e=>{const Ee=new Set(_e);return Ee.has(Oe)?Ee.delete(Oe):Ee.add(Oe),Ee})},[]),be=y.useCallback(()=>{b(re?new Set:new Set(Y.map(Oe=>Oe.id)))},[re,Y]),Ie=y.useCallback(Oe=>{for(const _e of v){const Ee=D.find(je=>je.id===_e);Ee&&!Ee.tags.includes(Oe)&&ae(_e,[...Ee.tags,Oe])}},[D,v,ae]),ke=y.useCallback(Oe=>{for(const _e of v){const Ee=D.find(je=>je.id===_e);Ee&&Ee.tags.includes(Oe)&&ae(_e,Ee.tags.filter(je=>je!==Oe))}},[D,v,ae]),Te=y.useCallback(()=>{for(const Oe of v)ce(Oe);b(new Set)},[v,ce]),Le=y.useCallback(()=>{for(const Oe of v)ie(Oe);b(new Set)},[v,ie]),le=y.useCallback(()=>{N(""),E(!0)},[]),se=y.useCallback(async()=>{if(!(!I||!$)){_(!0),E(!1);try{const Oe=D.filter(Ee=>v.has(Ee.id));if(Oe.length===0){_(!1);return}const _e=await r.clusterFailures({modelId:`${I}/${$}`,items:Oe.map(Ee=>({id:Ee.id,input:Ee.input,output:Ee.output??void 0,error:typeof Ee.error=="string"?Ee.error:Ee.error?String(Ee.error):void 0,scores:Ee.scores,existingTags:Ee.tags.length>0?Ee.tags:void 0})),availableTags:G.length>0?G:void 0,prompt:T||void 0});_e.proposedTags&&_e.proposedTags.length>0&&(F(_e.proposedTags.map(Ee=>({...Ee,accepted:!0}))),L(!0))}catch(Oe){console.error("Analysis failed:",Oe)}finally{_(!1)}}},[I,$,D,v,r,G,T]),te=y.useCallback(()=>{for(const Oe of M){if(!Oe.accepted)continue;const _e=D.find(Ee=>Ee.id===Oe.itemId);if(_e){const Ee=[...new Set([..._e.tags,...Oe.tags])];ae(_e.id,Ee)}}L(!1)},[M,D,ae]),me=y.useCallback(Oe=>{h(_e=>_e===Oe?null:Oe)},[]),ye=y.useMemo(()=>p?Y.find(Oe=>Oe.id===p)??null:null,[p,Y]),Ne=p?Y.findIndex(Oe=>Oe.id===p):-1,Re=Ne>0?()=>h(Y[Ne-1].id):void 0,Ge=Ne>=0&&Ne<Y.length-1?()=>h(Y[Ne+1].id):void 0,He="auto minmax(15rem,1fr) 10rem 8rem 6rem 6rem";return i?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Wt,{className:"w-6 h-6"})}):o.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[o.jsx(kr,{open:C,onOpenChange:E,children:o.jsxs(yr,{children:[o.jsxs(br,{children:[o.jsx(hr,{children:"Analyze Items"}),o.jsx(Ns,{children:"Use an LLM to automatically suggest tags for the selected items."})]}),o.jsxs("div",{className:"space-y-4 py-2",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx(Rt,{className:"text-xs mb-1 block",children:"Provider"}),o.jsx(by,{value:I,onValueChange:R})]}),o.jsxs("div",{children:[o.jsx(Rt,{className:"text-xs mb-1 block",children:"Model"}),o.jsx(xy,{llmId:I,value:$,onValueChange:B})]})]}),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(Rt,{className:"text-xs",children:"Instructions (optional)"}),o.jsx(zl,{value:T,onChange:Oe=>N(Oe.target.value),placeholder:"E.g., Focus on safety issues and factual errors...",rows:3,className:"text-xs mt-1"})]})]}),o.jsxs(cc,{children:[o.jsx(fe,{variant:"outline",onClick:()=>E(!1),children:"Cancel"}),o.jsxs(fe,{onClick:se,disabled:!I||!$||O,children:[O?o.jsx(Wt,{className:"w-4 h-4 mr-1"}):null,"Analyze"]})]})]})}),o.jsx(kr,{open:V,onOpenChange:L,children:o.jsxs(yr,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[o.jsxs(br,{children:[o.jsx(hr,{children:"Review Proposed Tags"}),o.jsxs(Ns,{children:[M.filter(Oe=>Oe.accepted).length," of ",M.length," proposals selected"]})]}),o.jsx("div",{className:"space-y-3 py-2",children:M.map((Oe,_e)=>{const Ee=D.find(je=>je.id===Oe.itemId);return o.jsx("div",{className:K("p-3 border rounded-lg",!Oe.accepted&&"opacity-50"),children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(Uo,{checked:Oe.accepted,onCheckedChange:je=>F($e=>$e.map((Fe,Ke)=>Ke===_e?{...Fe,accepted:!!je}:Fe))}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 truncate block",children:Ee?typeof Ee.input=="string"?Ee.input.slice(0,100):JSON.stringify(Ee.input).slice(0,100):Oe.itemId}),o.jsx("div",{className:"flex gap-1 flex-wrap mt-1.5",children:Oe.tags.map((je,$e)=>o.jsx(V3t,{tag:je,onRename:Fe=>F(Ke=>Ke.map((Ye,Pt)=>Pt===_e?{...Ye,tags:Ye.tags.map((_t,an)=>an===$e?Fe:_t)}:Ye)),onRemove:()=>F(Fe=>Fe.map((Ke,Ye)=>Ye===_e?{...Ke,tags:Ke.tags.filter((Pt,_t)=>_t!==$e)}:Ke))},`${je}-${$e}`))}),Oe.reason&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-1 block italic",children:Oe.reason})]})]})},Oe.itemId)})}),o.jsxs(cc,{children:[o.jsx(fe,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),o.jsxs(fe,{onClick:te,disabled:M.filter(Oe=>Oe.accepted).length===0,children:["Accept ",M.filter(Oe=>Oe.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(vt,{children:[o.jsx(vt.Trigger,{asChild:!0,children:o.jsxs(fe,{variant:"outline",size:"md",children:[o.jsx(cat,{}),"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(vt.Content,{align:"start",className:K("min-w-48"),children:[o.jsxs(vt.Sub,{children:[o.jsxs(vt.SubTrigger,{children:["Status",S&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(vt.SubContent,{children:[o.jsx(vt.CheckboxItem,{checked:!S,onCheckedChange:()=>{w(!1),h(null)},onSelect:Oe=>Oe.preventDefault(),children:"Review Queue"}),o.jsx(vt.CheckboxItem,{checked:S,onCheckedChange:()=>{w(!0),h(null)},onSelect:Oe=>Oe.preventDefault(),children:"Completed"})]})]}),o.jsxs(vt.Sub,{children:[o.jsxs(vt.SubTrigger,{children:["Tags",m&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(vt.SubContent,{children:[o.jsx(vt.CheckboxItem,{checked:!m,onCheckedChange:()=>g(null),onSelect:Oe=>Oe.preventDefault(),children:"All"}),W>0&&o.jsx(vt.CheckboxItem,{checked:m==="__untagged__",onCheckedChange:()=>g(m==="__untagged__"?null:"__untagged__"),onSelect:Oe=>Oe.preventDefault(),children:"Untagged"}),H.length>0&&o.jsx(vt.Separator,{}),H.map(([Oe])=>o.jsx(vt.CheckboxItem,{checked:m===Oe,onCheckedChange:()=>g(m===Oe?null:Oe),onSelect:_e=>_e.preventDefault(),children:Oe},Oe))]})]}),X>0&&o.jsxs(o.Fragment,{children:[o.jsx(vt.Separator,{}),o.jsxs(vt.Item,{onSelect:()=>{g(null),w(!1),h(null)},children:[o.jsx(ys,{}),"Clear all filters"]})]})]})]}),X>0&&o.jsxs(fe,{variant:"outline",size:"md",onClick:()=>{g(null),w(!1),h(null)},children:[o.jsx(ys,{}),"Reset"]})]}),!S&&v.size>0&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(q3t,{selectedCount:v.size,vocabulary:G,onApplyTag:Ie,onRemoveTag:ke,onNewTag:Oe=>Ie(Oe)}),o.jsxs(vt,{children:[o.jsx(vt.Trigger,{asChild:!0,children:o.jsxs(fe,{disabled:O,children:[O?o.jsx(Wt,{className:"w-4 h-4"}):o.jsx(Qe,{size:"sm",children:o.jsx(Hs,{})}),"Actions"]})}),o.jsxs(vt.Content,{align:"end",children:[o.jsxs(vt.Item,{onSelect:Te,children:[o.jsx(Qe,{size:"sm",children:o.jsx(Fk,{})}),"Complete"]}),o.jsxs(vt.Item,{onSelect:Le,children:[o.jsx(Qe,{size:"sm",children:o.jsx(Zc,{})}),"Remove"]}),o.jsx(vt.Separator,{}),o.jsxs(vt.Item,{onSelect:le,children:[o.jsx(Qe,{size:"sm",children:o.jsx(eg,{})}),"Analyze"]})]})]})]})]}),ne?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Wt,{className:"w-6 h-6"})}):Y.length===0?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsxs("div",{className:"text-center px-8",children:[o.jsx(ge,{variant:"ui-sm",className:"text-neutral3 block",children:S?"No completed reviews yet":"No items to review"}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-2 block",children:S?"Items marked as complete will appear here for auditing.":"When experiment results are flagged for review, they will appear here."})]})}):o.jsxs(we,{columns:He,className:"min-w-0",children:[o.jsxs(we.Top,{hasLeadingCell:!0,children:[S?o.jsx(we.TopCell,{children:" "}):o.jsx(we.TopSelectCell,{checked:re?!0:he?"indeterminate":!1,onToggle:()=>be(),"aria-label":"Select all"}),o.jsxs(we.TopCells,{colStart:2,children:[o.jsx(we.TopCell,{children:"Input"}),o.jsx(we.TopCell,{children:"Comment"}),o.jsx(we.TopCell,{children:"Tags"}),o.jsx(we.TopCell,{children:"Rating"}),o.jsx(we.TopCell,{children:"Scores"})]})]}),Y.map(Oe=>{const _e=Oe.scores?Object.entries(Oe.scores):[],Ee=p===Oe.id,je=o.jsxs(o.Fragment,{children:[o.jsx(we.Cell,{height:"compact",className:"min-w-0 text-neutral4",children:o.jsx("span",{className:"block truncate",children:_Wr(Oe.input,200)})}),o.jsx(we.Cell,{height:"compact",className:"min-w-0",children:Oe.comment?o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 truncate",children:Oe.comment}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsx(we.Cell,{height:"compact",className:"min-w-0",children:Oe.tags.length>0?o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 truncate",children:Oe.tags.join(", ")}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsxs(we.Cell,{height:"compact",children:[Oe.rating==="positive"&&o.jsx(Qe,{size:"sm",className:"text-positive1",children:o.jsx(ove,{})}),Oe.rating==="negative"&&o.jsx(Qe,{size:"sm",className:"text-negative1",children:o.jsx(ive,{})}),!Oe.rating&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})]}),o.jsx(we.Cell,{height:"compact",children:_e.length>0?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(Qe,{size:"sm",className:"text-neutral3",children:o.jsx(Jm,{})}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 font-mono",children:_e[0][1].toFixed(2)}),_e.length>1&&o.jsxs(zt,{variant:"default",children:["+",_e.length-1]})]}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})})]});return o.jsxs(we.RowWrapper,{children:[S?o.jsx(we.Cell,{height:"compact",className:"justify-items-center px-4",children:o.jsx("div",{role:"img","aria-label":Oe.error?"Error":"Success",title:Oe.error?"Error":"Success",className:K("w-2 h-2 rounded-full",Oe.error?"bg-red-700":"bg-green-600")})}):o.jsx(we.SelectCell,{checked:v.has(Oe.id),onToggle:()=>xe(Oe.id),"aria-label":`Select item ${Oe.id}`}),o.jsx(we.RowButton,{flushLeft:!0,colStart:2,featured:Ee,onClick:()=>me(Oe.id),children:je})]},Oe.id)})]})]}),ye&&o.jsx(U3t,{item:ye,isCompleted:S,tagVocabulary:G,onRate:Oe=>ee(ye.id,Oe),onSetTags:Oe=>{ae(ye.id,Oe);for(const _e of Oe)G.includes(_e)||q(_e)},onComment:Oe=>J(ye.id,Oe),onRemove:()=>ie(ye.id),onComplete:S?void 0:()=>ce(ye.id),onPrevious:Re,onNext:Ge,onClose:()=>h(null)})]})]})}function CWr({datasetId:e,onAddItemClick:t,onNavigateToDataset:n}){const{navigate:r}=vn(),[s,a]=Pi(),{tab:i,activeVersion:l,handleTabChange:c}=YCe(s,a),[u,d]=y.useState(!1),[f,p]=y.useState(!1),[h,m]=y.useState(!1),[g,v]=y.useState([]),[b,S]=y.useState(!1),[w,O]=y.useState([]),[_,C]=y.useState(!1),[E,T]=y.useState([]),[N,I]=y.useState(0),[R,$]=y.useState(null),[B,M]=y.useState(""),[F]=Lxe(B,300),{data:V}=Nx(e),{data:L=[],total:z,isLoading:U,setEndOfListElement:D,isFetchingNextPage:G,hasNextPage:q}=DO(e,F||void 0,l),{total:P}=DO(e,void 0,l),[H,W]=y.useState({}),{data:X,isLoading:ae}=cM(e,void 0,H),{data:ee}=cM(e),{deleteItems:J}=Ai(),ie=X?.experiments??[],ce=ee?.experiments??[],Y=ZZr({hasSearchQuery:!!F,filteredItemsLength:L.length,unfilteredItemsTotal:P,itemsTotal:z}),{data:ne}=XCe(e),ue=ne?.length??0,pe=te=>{$(te)},re=()=>{$(null)},he=te=>{v(te),m(!0)},xe=te=>{O(te),S(!0)},be=te=>{S(te),te||(O([]),I(me=>me+1))},Ie=te=>{r(`/datasets/${e}/items?items=${te.join(",")}`)},ke=te=>{r(`/datasets/${e}/versions?ids=${te.join(",")}`)},Te=te=>{T(te),C(!0)},Le=async()=>{await J.mutateAsync({datasetId:e,itemIds:E}),Be.success(`Deleted ${E.length} items`),C(!1),T([]),I(te=>te+1)},le=te=>{m(!1),v([]),I(me=>me+1),n?.(te)},se=te=>{m(te),te||(v([]),I(me=>me+1))};return o.jsxs(o.Fragment,{children:[o.jsxs(gc,{defaultTab:"items",value:i,onValueChange:c,className:"grid grid-rows-[auto_1fr] h-full",children:[o.jsxs(vc,{children:[o.jsxs(Er,{value:"items",children:["Items ",o.jsx(Qs,{color:"gray",children:Y})]}),o.jsxs(Er,{value:"experiments",children:["Experiments",o.jsx(Qs,{color:"gray",children:ie.length})]}),o.jsxs(Er,{value:"review",children:["Review",ue>0&&o.jsx(Qs,{color:"orange",children:ue})]})]}),o.jsx(qr,{value:"items",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(bWr,{datasetId:e,items:L,isLoading:U,featuredItemId:R,onItemSelect:pe,onItemClose:re,onAddClick:t??(()=>{}),onImportClick:()=>d(!0),onImportJsonClick:()=>p(!0),onBulkDeleteClick:Te,onCreateDatasetClick:he,onAddToDatasetClick:xe,onCompareItemsClick:Ie,datasetName:V?.name,clearSelectionTrigger:N,setEndOfListElement:D,isFetchingNextPage:G,hasNextPage:q,searchQuery:B,activeSearchQuery:F,onSearchChange:M,currentDatasetVersion:V?.version,onCompareVersionsClick:ke})}),o.jsx(qr,{value:"experiments",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(lWr,{experiments:ie,allExperiments:ce,isLoading:ae,datasetId:e,filters:H,onFiltersChange:W})}),o.jsx(qr,{value:"review",className:"overflow-auto mt-2 pb-0",children:o.jsx(t5t,{datasetId:e})})]}),o.jsx(eWr,{datasetId:e,open:u,onOpenChange:d}),o.jsx(kWr,{datasetId:e,open:f,onOpenChange:p}),o.jsx($Zr,{open:h,onOpenChange:se,items:g,onSuccess:le}),o.jsx(MZr,{open:b,onOpenChange:be,items:w,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 ",E.length," item",E.length!==1?"s":"","? This action cannot be undone."]})]}),o.jsxs(jt.Footer,{children:[o.jsx(jt.Cancel,{children:"Cancel"}),o.jsx(jt.Action,{onClick:Le,children:J.isPending?"Deleting...":"Delete"})]})]})})]})}function EWr(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 TZe({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 jWr({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}=Ai(),g=async w=>{w.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 E;if(d.trim())try{E=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:E}),Be.success("Item added successfully"),h(null),a("{}"),l(""),u(""),f(""),n(!1),r?.()}catch(T){const N=EWr(T);N?h(N):Be.error(`Failed to add item: ${T instanceof Error?T.message:"Unknown error"}`)}},v=w=>{a(w),p?.field==="input"&&h(null)},b=w=>{l(w),p?.field==="groundTruth"&&h(null)},S=()=>{a("{}"),l(""),u(""),f(""),h(null),n(!1)};return o.jsx(kr,{open:t,onOpenChange:n,children:o.jsxs(yr,{className:"max-w-lg",children:[o.jsx(br,{children:o.jsx(hr,{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(Rt,{htmlFor:"item-input",children:"Input (JSON) *"}),o.jsx(Gr,{value:s,onChange:v,showCopyButton:!1,className:"min-h-[120px]"}),p?.field==="input"&&o.jsx(TZe,{field:"input",errors:p.errors})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{htmlFor:"item-ground-truth",children:"Ground Truth (JSON, optional)"}),o.jsx(Gr,{value:i,onChange:b,showCopyButton:!1,className:"min-h-[80px]"}),p?.field==="groundTruth"&&o.jsx(TZe,{field:"groundTruth",errors:p.errors})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{htmlFor:"item-trajectory",children:"Expected Trajectory (JSON, optional)"}),o.jsx(Gr,{value:c,onChange:u,showCopyButton:!1,className:"min-h-[80px]"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{htmlFor:"item-request-context",children:"Request Context (JSON, optional)"}),o.jsx(Gr,{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:S,children:"Cancel"}),o.jsx(fe,{type:"submit",variant:"primary",disabled:m.isPending,children:m.isPending?"Adding...":"Add Item"})]})]})})]})})}function TWr({item:e}){return o.jsx(ca,{withMargins:!1,children:o.jsxs(ca.Column,{children:[o.jsxs(ca.Title,{size:"smaller",children:[o.jsx(VT,{}),o.jsx("span",{className:"truncate",children:e.id}),o.jsx(Ia,{content:e.id,tooltip:`Copy item ID: ${e.id}`})]}),o.jsxs(ca.Description,{children:[o.jsxs(ac,{children:[o.jsx(Kst,{})," Created ",Kn(new Date(e.createdAt),"MMM d, yyyy h:mm aaa")]}),e.datasetVersion!=null&&o.jsxs(ac,{children:[o.jsx(qO,{})," Version v",e.datasetVersion]})]})]})})}function KCe({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(Fxe,{children:[o.jsx(va.CodeSection,{title:"Input",icon:o.jsx(zk,{}),codeStr:t}),o.jsx(va.CodeSection,{title:"Ground Truth",icon:o.jsx(Wm,{}),codeStr:n}),s&&o.jsx(va.CodeSection,{title:"Expected Trajectory",icon:o.jsx(Sat,{}),codeStr:s}),o.jsx(va.CodeSection,{title:"Metadata",icon:o.jsx(VO,{}),codeStr:r})]})}function NWr({selectedScorers:e,setSelectedScorers:t,disabled:n=!1,container:r}){const{data:s,isLoading:a}=Dp(),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(Rt,{children:"Scorers (Optional)"}),o.jsx(Hht,{options:i,value:e,onValueChange:t,placeholder:"Select scorers...",searchPlaceholder:"Search scorers...",emptyText:"No scorers available",disabled:n||a,container:r})]})}const IWr=[{value:"agent",label:"Agent"},{value:"workflow",label:"Workflow"},{value:"scorer",label:"Scorer"}];function AWr({targetType:e,setTargetType:t,targetId:n,setTargetId:r,container:s}){const{data:a,isLoading:i}=tm(),{data:l,isLoading:c}=wy(),{data:u,isLoading:d}=Dp(),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(Rt,{children:"Target Type"}),o.jsx(Hc,{options:IWr,value:e,onValueChange:h,placeholder:"Select target type",searchPlaceholder:"Search types...",emptyText:"No types available",container:s})]}),e&&o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Rt,{children:m}),o.jsx(Hc,{options:f,value:n,onValueChange:r,placeholder:`Select ${e}`,searchPlaceholder:"Search...",emptyText:"No targets available",disabled:p,container:s})]})]})}function RWr({requestContextSchema:e,onChange:t}){const n=y.useMemo(()=>{try{return dg(cg(e))}catch(r){return console.error("Failed to parse requestContextSchema:",r),null}},[e]);return n?o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{children:"Request Context"}),o.jsx(zV,{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 PWr({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}=Ai(),S=!!(n&&Object.keys(n).length>0),w=l&&u,O=b.isPending,_=()=>{c(""),d(""),p([]),m({}),v("")},C=()=>{if(S){const N=Object.entries(h).filter(([,I])=>I!==void 0&&I!=="");return N.length>0?Object.fromEntries(N):void 0}if(g.trim()){let N;try{N=JSON.parse(g)}catch{throw new Error("Request Context must be valid JSON")}if(!N||typeof N!="object"||Array.isArray(N))throw new Error("Request Context must be a JSON object");return N}},E=async()=>{if(!w)return;let N;try{N=C()}catch(I){const R=I instanceof Error?I.message:"Request Context must be valid JSON";yu.error(R);return}try{const I=await b.mutateAsync({datasetId:e,targetType:l,targetId:u,scorerIds:f.length>0?f:void 0,version:t,requestContext:N});yu.success("Experiment triggered successfully"),s(!1),a?.(I.experimentId),_()}catch(I){const R=I instanceof Error?I.message:"Failed to trigger experiment";yu.error(R)}},T=()=>{O||(s(!1),_())};return o.jsx(kr,{open:r,onOpenChange:T,children:o.jsxs(yr,{ref:i,children:[o.jsxs(br,{children:[o.jsx(hr,{children:"Run Experiment"}),o.jsx(Ns,{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(AWr,{targetType:l,setTargetType:c,targetId:u,setTargetId:d,container:i}),l&&l!=="scorer"&&o.jsx(NWr,{selectedScorers:f,setSelectedScorers:p,disabled:O,container:i}),S?o.jsx(RWr,{requestContextSchema:n,onChange:m}):o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{children:"Request Context (JSON, optional)"}),o.jsx(Gr,{value:g,onChange:v,showCopyButton:!1,className:"min-h-[80px]"})]})]}),o.jsxs(cc,{className:"px-6 pt-4",children:[o.jsx(fe,{onClick:T,disabled:O,children:"Cancel"}),o.jsx(fe,{variant:"primary",onClick:E,disabled:!w||O,children:O?o.jsxs(o.Fragment,{children:[o.jsx(Wt,{className:"w-4 h-4"}),"Running..."]}):"Run"})]})]})})}const $Wr=e=>{const t=Ze();return St({queryKey:["experiment-trace-light",e],queryFn:async()=>{if(!e)throw new Error("Trace ID is required");return t.getTraceLight(e)},enabled:!!e})};function MWr({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=G6(e?.input),S=G6(e?.output),w=G6(e?.groundTruth),O=u&&e.status!=="needs-review"&&e.status!=="complete",_=Array.isArray(e.tags)?e.tags:[];return o.jsxs(Sn,{collapsed:m,children:[o.jsxs(Sn.Header,{children:[o.jsxs(Sn.Heading,{children:["Result ",o.jsxs("b",{children:["# ",e.id.length>12?`${e.id.slice(0,12)}…`:e.id]})]}),o.jsxs(Rr,{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(nat,{}):o.jsx(tat,{})}),o.jsx(Sn.NextPrevNav,{onPrevious:n,onNext:r,previousLabel:"Previous result",nextLabel:"Next result"}),o.jsxs(fe,{size:"md",onClick:a,disabled:!e.traceId,children:[o.jsx(J1e,{}),"Trace"]}),o.jsx(Sn.CloseButton,{onClick:s,tooltip:"Close result panel"})]})]}),!m&&o.jsxs(Sn.Content,{children:[o.jsxs("div",{className:"grid gap-4 mb-6",children:[o.jsxs(Bt,{children:[o.jsx(Bt.Key,{children:"Item Id"}),o.jsx(Bt.ValueWithCopyBtn,{copyTooltip:"Copy Item Id to clipboard",copyValue:e.itemId,children:e.itemId}),o.jsx(Bt.Key,{children:"Created"}),o.jsx(Bt.Value,{children: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:G6(e?.error&&typeof e.error=="object"?e.error.message:e?.error)})}),t&&t.length>0&&o.jsxs(we,{columns:"1fr 1fr",children:[o.jsxs(we.Top,{children:[o.jsx(we.TopCell,{children:"Scorer"}),o.jsx(we.TopCell,{children:"Score"})]}),t.map(C=>o.jsxs(we.RowButton,{featured:c===C.id,onClick:()=>l?.(C.id),children:[o.jsx(we.Cell,{height:"compact",children:C.scorerId}),o.jsx(we.MonoCell,{children:C.score.toFixed(3)})]},C.id))]}),(e.status||_.length>0||O)&&o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Sn.SectionHeading,{icon:o.jsx(VO,{}),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(DB,{}),"Flag for Review"]})}),e.status==="needs-review"&&i&&o.jsx("div",{children:o.jsxs(fe,{size:"sm",onClick:i,children:[o.jsx(Ca,{}),"Review"]})})]})]}),o.jsxs("div",{className:"grid gap-3",children:[o.jsx(Sn.CodeSection,{title:"Input",icon:o.jsx(VT,{}),codeStr:b}),o.jsx(Sn.CodeSection,{title:"Output",icon:o.jsx(Wm,{}),codeStr:S}),o.jsx(Sn.CodeSection,{title:"Ground Truth",icon:o.jsx(ave,{}),codeStr:w})]})]})]})}function G6(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function DWr({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(zo,{columns:h}):o.jsxs(we,{columns:h,className:"min-w-0",children:[o.jsxs(we.Top,{hasLeadingCell:p,children:[p&&o.jsx(we.TopCell,{children:" "}),p?o.jsx(we.TopCells,{colStart:2,children:s.map(g=>o.jsx(we.TopCell,{children:g.label},g.name))}):s.map(g=>o.jsx(we.TopCell,{children:g.label},g.name))]}),e.length===0?o.jsx(we.NoMatch,{message:"No results yet"}):o.jsxs(o.Fragment,{children:[e.map(g=>{const v=!!g.error,b=g.id===n,S=o.jsxs(o.Fragment,{children:[o.jsx(we.IdCell,{id:g.itemId}),o.jsx(we.Cell,{height:"compact",children:o.jsxs(Yn,{children:[o.jsx(Hn,{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(Zn,{children:v?"Error":"Success"})]})}),m&&o.jsx(we.MonoCell,{children:FWr(LWr(g.input),200)}),i?.map(w=>{const _=a?.[g.itemId]?.find(C=>C.scorerId===w);return o.jsx(we.Cell,{height:"compact",className:"font-mono text-neutral3 text-ui-smd",children:_!=null?_.score.toFixed(3):"-"},w)})]});return p?o.jsxs(we.RowWrapper,{children:[o.jsx(we.SelectCell,{checked:d.has(g.id),onToggle:()=>f(g.id),"aria-label":`Select result ${g.itemId}`}),o.jsx(we.RowButton,{flushLeft:!0,colStart:2,featured:b,onClick:()=>r(g.id),children:S})]},g.id):o.jsx(we.RowButton,{featured:b,onClick:()=>r(g.id),children:S},g.id)}),o.jsx(we.NextPageLoading,{isLoading:c,hasMore:u,setEndOfListElement:l})]})]})}function LWr(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function FWr(e,t){return e.length<=t?e:e.slice(0,t-1)+"..."}function zWr(e){const t=e.scorer;return t?.hasJudge===!1?!0:t?.hasJudge===!0?!1:!e.preprocessPrompt&&!e.analyzePrompt&&!e.generateScorePrompt&&!e.generateReasonPrompt}function BWr({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=zWr(e),p=f?"N/A — code-based scorer":"N/A — step not configured";return o.jsxs(Sn,{collapsed:u,children:[o.jsxs(Sn.Header,{children:[o.jsxs(Sn.Heading,{children:["Score ",o.jsx("b",{children:e.scorerId})]}),o.jsxs(Rr,{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(nat,{}):o.jsx(tat,{})}),(n||t)&&o.jsx(Sn.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(J1e,{}),"Trace"]}),o.jsx(Sn.CloseButton,{onClick:r,tooltip:"Close score panel"})]})]}),!u&&o.jsx(Sn.Content,{children:o.jsxs("div",{className:"grid gap-3",children:[o.jsx(Sn.CodeSection,{title:`Score: ${e.score}`,icon:o.jsx(Jm,{}),codeStr:e.reason||p,simplified:!0}),!f&&o.jsxs(o.Fragment,{children:[o.jsx(Sn.CodeSection,{title:"Preprocess Prompt",icon:o.jsx(th,{}),codeStr:e.preprocessPrompt||p,simplified:!0}),o.jsx(Sn.CodeSection,{title:"Analyze Prompt",icon:o.jsx(th,{}),codeStr:e.analyzePrompt||p,simplified:!0}),o.jsx(Sn.CodeSection,{title:"Generate Score Prompt",icon:o.jsx(th,{}),codeStr:e.generateScorePrompt||p,simplified:!0}),o.jsx(Sn.CodeSection,{title:"Generate Reason Prompt",icon:o.jsx(th,{}),codeStr:e.generateReasonPrompt||p,simplified:!0})]})]})})]})}const NZe=[{name:"scorer",label:"Scorer",size:"1fr"},{name:"avg",label:"Avg Score",size:"1fr"},{name:"count",label:"Items Scored",size:"1fr"}];function UWr({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(Vr,{iconSlot:o.jsx(Jm,{className:"w-8 h-8 text-neutral3"}),titleSlot:a,descriptionSlot:i})})}return o.jsxs(hn,{children:[o.jsxs(hn.Header,{columns:NZe,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:NZe,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 n5t({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),[S,w]=y.useState(!1),[O,_]=y.useState(!1),[C,E]=y.useState(!1),[T,N]=y.useState(!1),{updateExperimentResult:I}=Ai(),R=y.useCallback(se=>{b(te=>{const me=new Set(te);return me.has(se)?me.delete(se):me.add(se),me})},[]),$=y.useCallback(()=>b(new Set),[]),B=y.useCallback(()=>{const se=r.filter(te=>!!te.error).map(te=>te.id);b(new Set(se))},[r]),M=y.useCallback(async se=>{if(S||se.length===0)return;w(!0);let te=0;const me=new Set;try{for(const ye of se)try{await I.mutateAsync({datasetId:t,experimentId:e,resultId:ye,status:"needs-review"}),te++,me.add(ye)}catch{}}finally{w(!1)}me.size>0&&b(ye=>{const Ne=new Set(ye);for(const Re of me)Ne.delete(Re);return Ne}),te>0&&Be(`${te} result${te>1?"s":""} flagged for review`)},[t,e,S,I]),F=r.find(se=>se.id===c)??null,[V,L]=y.useState("summary"),[z,U]=y.useState(null),D=se=>{L(se),se!=="reviews"&&U(null)},{data:G}=XCe(t),q=(G??[]).filter(se=>se.experimentId===e).length,{data:P}=L3t(e,n),H=y.useMemo(()=>{if(!P)return[];const se=new Set;for(const te of Object.values(P))for(const me of te)se.add(me.scorerId);return[...se].sort()},[P]),W=se=>{u(se),f(null),h(void 0),g(null)},X=se=>{W(se===c?null:se)},ae=()=>{W(null)},ee=()=>{if(!F)return;const se=r.findIndex(te=>te.id===F.id);if(se>=0&&se<r.length-1)return()=>W(r[se+1].id)},J=()=>{if(!F)return;const se=r.findIndex(te=>te.id===F.id);if(se>0)return()=>W(r[se-1].id)},ie=F?P?.[F.itemId]:void 0,ce=ie?.find(se=>se.id===m)??null,Y=se=>{g(se===m?null:se),f(null),h(void 0)},ne=()=>{if(!m||!ie)return;const se=ie.findIndex(te=>te.id===m);if(se>=0&&se<ie.length-1)return()=>g(ie[se+1].id)},ue=()=>{if(!m||!ie)return;const se=ie.findIndex(te=>te.id===m);if(se>0)return()=>g(ie[se-1].id)},{data:pe,isLoading:re}=$Wr(d),he=pe?.spans,{data:xe,isLoading:be}=QD(d,p),Ie=xe?.span,{handlePreviousSpan:ke,handleNextSpan:Te}=gSe(he,p??null,h),Le=(()=>{const se=[],te=!!ce,me=!!d;return se.push(O?"auto":te||me?"2fr":"1fr"),te&&se.push(T?"auto":"3fr"),me&&se.push(C?"auto":"3fr"),me&&p&&se.push("3fr"),se.join(" ")})(),le=y.useMemo(()=>[{name:"itemId",label:"Item ID",size:"7rem"},{name:"status",label:"Status",size:"5rem"},{name:"input",label:"Input",size:"minmax(15rem,1fr)"},...H.map(se=>({name:se,label:se,size:"12rem"}))],[H]);return o.jsxs(gc,{defaultTab:"summary",value:V,onValueChange:D,className:"grid grid-rows-[auto_1fr] h-full overflow-hidden",children:[o.jsxs(vc,{children:[o.jsx(Er,{value:"summary",children:"Summary"}),o.jsx(Er,{value:"results",children:"Results"}),o.jsxs(Er,{value:"reviews",children:["Reviews",q>0&&o.jsx(Qs,{color:"orange",children:q})]})]}),o.jsx(qr,{value:"summary",className:"overflow-y-auto mt-5",children:o.jsx(UWr,{scoresByItemId:P,experimentStatus:n})}),o.jsx(qr,{value:"reviews",className:"overflow-auto mt-2 pb-0",children:o.jsx(t5t,{datasetId:t,experimentId:e,featuredItemId:z})}),o.jsxs(qr,{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:S,onClick:()=>M([...v]),children:[o.jsx(Qe,{size:"sm",children:o.jsx(DB,{})}),"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:B,children:"Select loaded failures"})})]}),o.jsxs("div",{className:K("grid w-full h-full grid-cols-1 gap-4 overflow-y-auto",F&&"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(DWr,{results:r,isLoading:s,featuredResultId:c,onResultClick:X,columns:le,scoresByItemId:P,scorerIds:H,setEndOfListElement:a,isFetchingNextPage:i,hasNextPage:l,selectedIds:v,onToggleSelect:R})})}),F&&o.jsxs("div",{className:"grid gap-4 max-h-full min-h-0 overflow-auto content-start",style:{gridTemplateRows:Le},children:[o.jsx(MWr,{result:F,scores:ie,onPrevious:J(),onNext:ee(),onClose:ae,onScoreClick:Y,featuredScoreId:m,onShowTrace:()=>{F.traceId&&(f(F.traceId),h(void 0),g(null),_(!0),E(!1))},onOpenInReview:()=>{U(F.id),L("reviews")},onFlagForReview:se=>M([se]),collapsed:O,onCollapsedChange:_}),ce&&o.jsx(BWr,{score:ce,onNext:ne(),onPrevious:ue(),onClose:()=>g(null),onShowTrace:()=>{ce.traceId&&(f(ce.traceId),h(void 0),_(!0),N(!0),E(!1))},collapsed:T,onCollapsedChange:N}),d&&o.jsxs(o.Fragment,{children:[o.jsx(cSe,{traceId:d,spans:he,isLoading:re,onClose:()=>{f(null),h(void 0),_(!1),N(!1)},onSpanSelect:h,initialSpanId:p??null,placement:"traces-list",showUnavailableFeaturesMsg:!1,collapsed:C,onCollapsedChange:E,LinkComponent:LN,traceHref:`/traces/${d}`}),p&&o.jsx(uSe,{traceId:d,spanId:p,span:Ie,isLoading:be,onPrevious:ke,onNext:Te,onClose:()=>h(void 0)})]})]})]})]})]})}const qWr={pending:o.jsx(UO,{}),running:o.jsx(sue,{}),completed:o.jsx(da,{}),failed:o.jsx(ys,{})};function VWr({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:qWr[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 HWr({onPrevious:e,onNext:t,previousAriaLabel:n="Previous",nextAriaLabel:r="Next"}){return o.jsxs(Rr,{spacing:"close",children:[o.jsxs(fe,{onClick:e,disabled:!e,"aria-label":n,children:[o.jsx($U,{})," Prev"]}),o.jsxs(fe,{onClick:t,disabled:!t,"aria-label":r,children:["Next",o.jsx(RU,{})]})]})}function JCe({delta:e}){const t=e>0?o.jsx(Qs,{size:"small",color:"green",intensity:"muted",children:o.jsx(wM,{})}):e<0?o.jsx(Qs,{size:"small",color:"red",intensity:"muted",children:o.jsx(Brn,{})}):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 Y6(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function ZWr({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(Ur,{withLeftSeparator:!0,children:[o.jsxs(Ur.Toolbar,{children:[o.jsx(HWr,{onPrevious:a,onNext:i,previousAriaLabel:"Previous comparison item",nextAriaLabel:"Next comparison item"}),o.jsx(Rr,{children:o.jsx(fe,{onClick:l,"aria-label":"Close comparison detail panel",children:o.jsx(ys,{})})})]}),o.jsxs(Ur.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(VT,{})," ",e.itemId]})})}),d?o.jsx(o.Fragment,{children:o.jsxs(Fxe,{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(JCe,{delta:v})]})]},h)})})]}),o.jsx(va.CodeSection,{title:o.jsxs(o.Fragment,{children:[o.jsx(Qs,{color:"purple",children:"Baseline "})," Experiment Output"]}),icon:o.jsx(Wm,{}),codeStr:Y6(c?.output)}),o.jsx(va.CodeSection,{title:o.jsxs(o.Fragment,{children:[o.jsx(Qs,{color:"cyan",children:"Contender "})," Experiment Output"]}),icon:o.jsx(Wm,{}),codeStr:Y6(u?.output)}),o.jsx(va.CodeSection,{title:"Item Input",icon:o.jsx(zk,{}),codeStr:Y6(e.input)}),o.jsx(va.CodeSection,{title:"Item Ground Truth",icon:o.jsx(ave,{}),codeStr:Y6(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 WWr({items:e,baselineId:t,contenderId:n,scorerIds:r,featuredItemId:s,columns:a,onItemClick:i}){return o.jsx(Ur,{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(JCe,{delta:m})]}):o.jsx("span",{className:"text-neutral1",children:"-"})},f)})})]})},l.itemId)})})})]})})}const QWr={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 IZe({datasetId:e,experiment:t,type:n}){const{Link:r}=vn(),{label:s,color:a,customStyle:i}=QWr[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(Qs,{size:"small",color:a,children:[s,o.jsx(Zh,{})]}),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(Qs,{size:"small",color:a,children:[o.jsx(mc,{})," ",s]})]}),o.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-ui-sm text-neutral3",children:[o.jsxs(ac,{children:[o.jsx(ave,{})," ",t.targetType," / ",t.targetId]}),o.jsxs(ac,{children:[o.jsx(pat,{})," v",t.datasetVersion??"—"]}),l&&o.jsxs(ac,{children:[o.jsx(Jst,{})," ",Kn(l,"MMM d, yyyy HH:mm")]})]})]})}function GWr({datasetId:e,experimentIdA:t,experimentIdB:n,onSwap:r}){const[s,a]=y.useState(null),{data:i,isLoading:l,error:c}=cZr(e,t,n),{data:u}=yB(e,t),{data:d}=yB(e,n),f=u&&d&&u.datasetVersion!==d.datasetVersion,p=y.useMemo(()=>{if(!i)return[];const E=new Set;for(const T of i.items)for(const N of Object.values(T.results))if(N)for(const I of Object.keys(N.scores))E.add(I);return[...E].sort()},[i]),h=y.useMemo(()=>{if(!i||p.length===0)return[];const E=i.baselineId,T=t===E?n:t;return p.map(N=>{let I=0,R=0,$=0,B=0;for(const L of i.items){const z=L.results[E]?.scores[N],U=L.results[T]?.scores[N];z!=null&&(I+=z,$++),U!=null&&(R+=U,B++)}const M=$>0?I/$:null,F=B>0?R/B:null,V=M!=null&&F!=null?F-M:null;return{scorerId:N,avgA:M,avgB:F,delta:V}})},[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(E=>({name:E,label:E,size:"1fr"}))],[p,s]),v=i?.items.find(E=>E.itemId===s)??null,b=E=>{a(E===s?null:E)},S=()=>{a(null)},w=()=>{if(!i||!s)return;const E=i.items.findIndex(T=>T.itemId===s);if(E>=0&&E<i.items.length-1)return()=>a(i.items[E+1].itemId)},O=()=>{if(!i||!s)return;const E=i.items.findIndex(T=>T.itemId===s);if(E>0)return()=>a(i.items[E-1].itemId)};if(l)return o.jsx("div",{className:"flex items-center justify-center h-64",children:o.jsx(Wt,{})});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(IZe,{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(Yn,{children:[o.jsx(Hn,{asChild:!0,children:o.jsx(fe,{onClick:r,children:"VS"})}),o.jsx(Zn,{children:"Switch the order"})]})})}),o.jsx(IZe,{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(CLe,{children:[o.jsx(Qs,{color:"purple",size:"small",intensity:"muted",children:"Baseline"}),o.jsx(Qs,{color:"purple",size:"small",children:"Avg"})]})}),o.jsx(hn.HeaderCol,{className:"flex justify-center",children:o.jsxs(CLe,{children:[o.jsx(Qs,{color:"cyan",size:"small",intensity:"muted",children:"Contender"}),o.jsx(Qs,{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:E,avgA:T,avgB:N,delta:I})=>o.jsxs(hn.Row,{columns:m,children:[o.jsx(hn.TextCell,{children:E}),o.jsx(hn.TextCell,{className:"text-center font-mono",children:T!=null?T.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(JCe,{delta:I}):"-"})]},E))})})]}),o.jsxs(Nv,{className:K({"grid-cols-[1fr_2fr]":!!v}),children:[o.jsx(WWr,{items:i.items,baselineId:_,contenderId:C,scorerIds:p,featuredItemId:s,columns:g,onItemClick:b}),!!v&&o.jsx(ZWr,{item:v,baselineId:_,contenderId:C,baselineVersion:u?.datasetVersion,contenderVersion:d?.datasetVersion,onPrevious:O(),onNext:w(),onClose:S})]})]})}function YWr({datasetId:e,itemId:t,onVersionSelect:n,onCompareVersionsClick:r,activeVersion:s}){const{data:a,isLoading:i}=GCe(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(S=>{const w=new Set(S);if(w.has(b))w.delete(b);else if(w.size>=2){const[O]=Array.from(w);return new Set([O,b])}else w.add(b);return w})},m=()=>{c(!1),d(new Set)},g=()=>{c(!0)},v=()=>{u.size===2&&r?.([...u])};return o.jsxs(Ur,{className:"min-w-56",children:[l?o.jsx(Ur.Toolbar,{className:"grid justify-stretch gap-3 w-full",children:o.jsxs(Rr,{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(Ur.Toolbar,{children:o.jsxs(fe,{onClick:g,className:"w-full",children:[o.jsx(Rw,{})," Compare Ver."]})})}),i?o.jsx(XWr,{}):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 S=String(b.datasetVersion),w=typeof b.updatedAt=="string"?new Date(b.updatedAt):b.updatedAt;return o.jsxs(hn.Row,{isSelected:l&&u.has(S),children:[l&&o.jsx(hn.LabelCell,{children:o.jsx(Uo,{checked:u.has(S),disabled:b.isDeleted,onCheckedChange:()=>{},onClick:O=>{O.stopPropagation(),b.isDeleted||h(S)},"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:w,isLatest:b.isLatest,isDeleted:b.isDeleted})})]},String(b.datasetVersion))})})})]})]})}function XWr(){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 KWr(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 JWr({datasetId:e,versionA:t,versionB:n,onVersionChange:r}){const{data:s}=ZCe(e),a=(s??[]).map(i=>({value:String(i.version),label:`${KWr(i.version,i.createdAt)}${i.isCurrent?" (current)":""}`}));return o.jsxs(Ur.Toolbar,{className:"grid grid-cols-[1fr_1fr_1fr_10rem] gap-4 w-full",children:[o.jsx("div",{}),o.jsx(sc,{label:"Version A",labelIsHidden:!0,name:"version-a",placeholder:"Select version",options:a,value:t??"",onValueChange:i=>r?.(i,n??"")}),o.jsx(sc,{label:"Version B",labelIsHidden:!0,name:"version-b",options:a,value:n??"",onValueChange:i=>r?.(t??"",i)}),o.jsx("div",{})]})}const eQr=[{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"}],tQr={added:{color:"blue",borderColor:"border-blue-900",icon:o.jsx(Fr,{}),tooltip:"Added in this version"},changed:{color:"orange",borderColor:"border-yellow-900",icon:o.jsx(xat,{}),tooltip:"Changed in this version"},same:{color:"green",borderColor:"border-green-900",icon:o.jsx(ian,{}),tooltip:"Same in both versions"}};function Cne({red:e=!1,tooltip:t}){return o.jsxs(Yn,{children:[o.jsx(Hn,{asChild:!0,children:o.jsx(Xrn,{className:K("text-neutral3/40 w-5 h-5 ",{"text-red-900":e})})}),t&&o.jsx(Zn,{children:t})]})}function CS({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}=tQr[e];return o.jsxs(Yn,{children:[o.jsx(Hn,{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(Qs,{color:n,size:"small",children:r})]})}),o.jsx(Zn,{children:s})]})}function nQr(e,t){return e&&t&&e.datasetVersion===t.datasetVersion?"same":e&&t&&e.datasetVersion!==t.datasetVersion?"changed":e?"added":"removed"}function rQr({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=nQr(u,d);return o.jsxs(hn.Row,{columns:eQr,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(CS,{variant:"added",version:u.datasetVersion}):f==="changed"&&l?o.jsx(CS,{variant:"changed",version:u.datasetVersion}):o.jsx(CS,{version:u.datasetVersion})}):o.jsx(hn.Cell,{className:"justify-center flex items-center",children:o.jsx(Cne,{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(CS,{variant:"added",version:d.datasetVersion}):f==="changed"&&!l?o.jsx(CS,{variant:"changed",version:d.datasetVersion}):o.jsx(CS,{version:d.datasetVersion})}):o.jsx(hn.Cell,{className:"justify-center flex items-center",children:o.jsx(Cne,{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(CS,{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(Cne,{tooltip:o.jsxs(o.Fragment,{children:["Comparing is available",o.jsx("br",{})," only for changed items"]})})})]},c)})})})})}const AZe={needsReview:"#facc15",complete:"#22c55e"},sQr=[{label:"Needs Review",color:AZe.needsReview},{label:"Reviewed",color:AZe.complete}];function aQr({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,S=b?`${b} · ${m.experimentId.slice(0,8)}`:m.experimentId.slice(0,8);h.push({name:S,values:[m.needsReview,m.complete]})}return{data:h,maxVal:f,totalInPipeline:p}},[e,t,n]),c=a.length>0;return o.jsxs(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.TitleAndDescription,{title:"Review Pipeline",description:"Items in review across experiments."}),c&&o.jsx(Ut.Summary,{value:String(l),label:"Items in pipeline"})]}),r?o.jsx(Ut.Loading,{}):s?o.jsx(Ut.Error,{message:"Failed to load review data"}):o.jsx(Ut.Content,{children:c?o.jsx(Jj,{data:a,segments:sQr,maxVal:i,fmt:u=>String(u)}):o.jsx(Ut.NoData,{message:"No items have been sent to review yet"})})]})}function eEe(){const e=Ze();return St({queryKey:["experiment-review-summary"],queryFn:()=>e.getExperimentReviewSummary()})}function r5t(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 iQr(e,t){const n=new Map,r=r5t(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 oQr(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 lQr=10;function cQr(){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}=hy({page:d,perPage:lQr}),{data:g,isLoading:v,error:b}=kZ(),{data:S}=eEe(),w=y.useMemo(()=>p?.datasets??[],[p?.datasets]),O=p?.pagination?.hasMore??!1,_=y.useMemo(()=>g?.experiments??[],[g?.experiments]),C=y.useMemo(()=>EZr(w),[w]),E=y.useMemo(()=>iQr(S,_),[S,_]),T=h||v,N=m||b,I=()=>t(!0),R=y.useCallback(()=>f(U=>U+1),[]),$=y.useCallback(()=>f(U=>Math.max(0,U-1)),[]),B=y.useCallback(U=>{r(U),f(0)},[]),M=y.useCallback(U=>{a(U),f(0)},[]),F=y.useCallback(U=>{l(U),f(0)},[]),V=y.useCallback(U=>{u(U),f(0)},[]);if(N&&is(N))return o.jsx(ar,{children:o.jsx(Ms,{})});if(N&&ls(N))return o.jsx(ar,{children:o.jsx(Ss,{resource:"datasets"})});if(N)return o.jsx(ar,{children:o.jsx(Ii,{title:"Failed to load datasets",message:N.message})});if(w.length===0&&!T&&d===0)return o.jsxs(o.Fragment,{children:[o.jsx(ar,{children:o.jsx(AZr,{onCreateClick:I})}),o.jsx(Hme,{open:e,onOpenChange:t})]});const L=s!=="all"||i!=="all"||c!=="all"||n!=="",z=()=>{r(""),a("all"),l("all"),u("all"),f(0)};return o.jsxs(Ft,{children:[o.jsx(Ft.TopArea,{children:o.jsx(PZr,{search:n,onSearchChange:B,targetFilter:s,onTargetFilterChange:M,experimentFilter:i,onExperimentFilterChange:F,tagFilter:c,onTagFilterChange:V,tagOptions:C,onReset:z,hasActiveFilters:L,onCreateClick:I})}),o.jsx(IZr,{datasets:w,experiments:_,reviewByDataset:E,isLoading:T,search:n,targetFilter:s,experimentFilter:i,tagFilter:c,currentPage:d,hasMore:O,onNextPage:R,onPrevPage:$}),o.jsx(Hme,{open:e,onOpenChange:t})]})}function X6({children:e}){return o.jsxs(Ft,{height:"full",children:[o.jsx("div",{}),o.jsx(Ft.MainArea,{isCentered:!0,children:e})]})}function uQr(){const{datasetId:e}=mr(),t=Xs(),[n,r]=Pi(),{activeVersion:s}=YCe(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}=Nx(e),{data:S=[],isLoading:w}=DO(e,void 0,s),O=!w&&S.length===0;if(b)return null;if(v&&is(v))return o.jsx(X6,{children:o.jsx(Ms,{})});if(v&&ls(v))return o.jsx(X6,{children:o.jsx(Ss,{resource:"datasets"})});if(v&&eSe(v)||!b&&!v&&!g)return o.jsx(X6,{children:o.jsx(Vr,{iconSlot:o.jsx(zb,{}),titleSlot:"Dataset not found",descriptionSlot:`No dataset with id "${e}".`,actionSlot:o.jsxs(fe,{as:li,to:"/datasets",children:[o.jsx(mc,{}),"Back to Datasets"]})})});if(v)return o.jsx(X6,{children:o.jsx(Ii,{title:"Failed to load dataset",message:v instanceof Error?v.message:"An unexpected error occurred. Please try again."})});const _=E=>{t(`/datasets/${e}/experiments/${E}`)},C=()=>{t("/datasets")};return o.jsxs(o.Fragment,{children:[o.jsxs(Ft,{height:"full",children:[o.jsx(Ft.TopArea,{children:o.jsxs(Ft.Row,{children:[o.jsxs(Ft.Column,{children:[g?.description&&o.jsx("p",{className:"text-ui-smd text-neutral3 mb-1",children:g.description}),o.jsxs(Bt,{numOfCol:2,children:[o.jsx(Bt.Key,{children:"Created at"}),o.jsx(Bt.Value,{children:g?.createdAt?Kn(new Date(g.createdAt),"MMM d, yyyy"):""}),o.jsx(Bt.Key,{children:"Latest version"}),o.jsxs(Bt.Value,{children:["v",g?.version??""]})]})]}),o.jsx(Ft.Column,{children:o.jsxs(Rr,{children:[O?o.jsxs(Yn,{children:[o.jsx(Hn,{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(Bk,{}),s!=null?`Run on v${s}`:"Run Experiment"]})})})}),o.jsx(Zn,{children:"Add items to the dataset before running an experiment"})]}):o.jsxs(fe,{variant:"primary",onClick:()=>i(!0),children:[o.jsx(Bk,{}),s!=null?`Run on v${s}`:"Run Experiment"]}),o.jsxs(vt,{children:[o.jsx(vt.Trigger,{asChild:!0,children:o.jsx(fe,{size:"lg","aria-label":"Dataset actions menu",children:o.jsx(LB,{})})}),o.jsxs(vt.Content,{align:"end",className:"w-48",children:[o.jsxs(vt.Item,{onSelect:()=>d(!0),children:[o.jsx(Ph,{})," Edit Dataset"]}),o.jsxs(vt.Item,{onSelect:()=>m(!0),children:[o.jsx(ef,{})," Duplicate Dataset"]}),o.jsxs(vt.Item,{onSelect:()=>p(!0),className:"text-red-500 focus:text-red-400",children:[o.jsx(Zc,{})," Delete Dataset"]})]})]})]})})]})}),o.jsx(Ft.MainArea,{children:o.jsx(CWr,{datasetId:e,onAddItemClick:()=>c(!0)})})]}),o.jsx(PWr,{datasetId:e,version:s??void 0,requestContextSchema:g?.requestContextSchema,open:a,onOpenChange:i,onSuccess:_}),o.jsx(jWr,{datasetId:e,open:l,onOpenChange:c}),g&&o.jsx(zZr,{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(DZr,{open:h,onOpenChange:m,sourceDatasetId:g.id,sourceDatasetName:g.name,sourceDatasetDescription:g.description,sourceDatasetTargetType:g.targetType}),g&&o.jsx(UZr,{open:f,onOpenChange:p,datasetId:g.id,datasetName:g.name,onSuccess:C})]})}function s5t({experiment:e}){const{Link:t,paths:n}=vn(),{data:r}=tm(),{data:s}=wy(),{data:a}=Dp(),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(Ft.TopArea,{children:o.jsxs(Ft.Row,{children:[o.jsx(Ft.Column,{children:o.jsxs(Bt,{numOfCol:2,children:[o.jsx(Bt.Key,{children:"Created at"}),o.jsx(Bt.Value,{children:Kn(new Date(e.createdAt),"MMM d, yyyy 'at' h:mm a")}),e.completedAt&&o.jsxs(o.Fragment,{children:[o.jsx(Bt.Key,{children:"Completed at"}),o.jsx(Bt.Value,{children:Kn(new Date(e.completedAt),"MMM d, yyyy 'at' h:mm a")})]}),o.jsx(Bt.Key,{children:"Target"}),o.jsx(Bt.ValueLink,{href:i(),as:t,children:l()}),e.agentVersion&&o.jsxs(o.Fragment,{children:[o.jsx(Bt.Key,{children:"Version"}),c?o.jsx(Bt.ValueLink,{href:c,as:t,children:e.agentVersion}):o.jsx(Bt.Value,{children:e.agentVersion})]})]})}),o.jsx(Ft.Column,{children:o.jsx(VWr,{experiment:e})})]})})}function K6({children:e}){return o.jsxs(Ft,{height:"full",children:[o.jsx("div",{}),o.jsx(Ft.MainArea,{isCentered:!0,children:e})]})}function dQr(){const{datasetId:e,experimentId:t}=mr(),{data:n,isLoading:r,error:s}=yB(e,t),{data:a,isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u}=xZ({datasetId:e,experimentId:t,experimentStatus:n?.status});return!e||!t||r?null:s&&is(s)?o.jsx(K6,{children:o.jsx(Ms,{})}):s&&ls(s)?o.jsx(K6,{children:o.jsx(Ss,{resource:"datasets"})}):s&&eSe(s)||!r&&!s&&!n?o.jsx(K6,{children:o.jsx(Vr,{iconSlot:o.jsx(Jge,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${t}".`,actionSlot:o.jsxs(fe,{as:li,to:`/datasets/${e}?tab=experiments`,children:[o.jsx(mc,{}),"Back to Dataset"]})})}):s?o.jsx(K6,{children:o.jsx(Ii,{title:"Failed to load experiment",message:s instanceof Error?s.message:"An unexpected error occurred. Please try again."})}):o.jsxs(Ft,{height:"full",children:[o.jsx(s5t,{experiment:n}),o.jsx(Ft.MainArea,{children:o.jsx(n5t,{experimentId:t,datasetId:e,experimentStatus:n.status,results:a??[],isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u})})]})}function fQr(){const{datasetId:e}=mr(),[t,n]=Pi(),{error:r}=Nx(e??""),s=t.get("baseline")??"",a=t.get("contender")??"";return r&&is(r)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})}):r&&ls(r)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ss,{resource:"datasets"})})}):!e||!s||!a?o.jsx(ms,{children:o.jsx(Uv,{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(ms,{children:o.jsx(Uv,{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(Rw,{})," Dataset Experiments Comparison"]}),o.jsxs(ca.Description,{children:["Comparing"," ",o.jsx(li,{to:`/datasets/${e}/experiments/${s}`,children:s.slice(0,8)})," vs"," ",o.jsx(li,{to:`/datasets/${e}/experiments/${a}`,children:a.slice(0,8)})]})]}),o.jsx(ca.Column,{children:o.jsxs(fe,{as:li,to:`/datasets/${e}`,children:[o.jsx(mc,{}),"Back to Dataset"]})})]}),o.jsx(GWr,{datasetId:e,experimentIdA:s,experimentIdB:a,onSwap:()=>{n({baseline:a,contender:s})}})]})})})}function pQr(){const{datasetId:e,itemId:t}=mr(),{Link:n}=vn(),r=Xs(),{data:s,isLoading:a,error:i}=GCe(e??"",t??""),{updateItem:l,deleteItem:c}=Ai(),{data:u}=Nx(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),[S,w]=y.useState(m.input),[O,_]=y.useState(m.groundTruth),[C,E]=y.useState(m.metadata),[T,N]=y.useState(m.trajectory),[I,R]=y.useState(m.requestContext),[$,B]=y.useState(g);g!==$&&(B(g),w(m.input),_(m.groundTruth),E(m.metadata),N(m.trajectory),R(m.requestContext));const[M,F]=y.useState(!1),V=X=>{h(f?X:X.isLatest?null:X)},L=()=>{h(null)},z=!f&&p!=null,U=()=>{z||b(!0)},D=()=>{z||F(!0)},G=async()=>{if(!e||!t)return;let X;try{X=JSON.parse(S)}catch{Be.error("Input must be valid JSON");return}let ae;if(O.trim())try{ae=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=T!==m.trajectory;if(ie&&T.trim())try{J=JSON.parse(T)}catch{Be.error("Expected Trajectory must be valid JSON");return}let ce;const Y=I!==m.requestContext;if(Y&&I.trim())try{ce=JSON.parse(I)}catch{Be.error("Request Context must be valid JSON");return}try{await l.mutateAsync({datasetId:e,itemId:t,input:X,groundTruth:ae,metadata:ee,...ie?{expectedTrajectory:J??null}:{},...Y?{requestContext:ce}:{}}),Be.success("Item updated successfully"),b(!1)}catch(ne){Be.error(`Failed to update item: ${ne instanceof Error?ne.message:"Unknown error"}`)}},q=()=>{d&&(w(JSON.stringify(d.input,null,2)),_(d.groundTruth?JSON.stringify(d.groundTruth,null,2):""),E(d.metadata?JSON.stringify(d.metadata,null,2):""),N(d.expectedTrajectory!=null?JSON.stringify(d.expectedTrajectory,null,2):""),R(d.requestContext?JSON.stringify(d.requestContext,null,2):"")),b(!1)},P=async()=>{if(!(!e||!t))try{await c.mutateAsync({datasetId:e,itemId:t}),Be.success("Item deleted successfully"),F(!1),r(`/datasets/${e}`)}catch(X){Be.error(`Failed to delete item: ${X instanceof Error?X.message:"Unknown error"}`)}},H=p??d,W=H?{id:t??"",datasetId:e??"",datasetVersion:H.datasetVersion,input:H.input,groundTruth:H.groundTruth,expectedTrajectory:H.expectedTrajectory,metadata:H.metadata,createdAt:H.createdAt,updatedAt:H.updatedAt}:null;return i&&is(i)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})}):i&&ls(i)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ss,{resource:"datasets"})})}):a?null:!e||!t||!s||s.length===0?o.jsx(ms,{children:o.jsx(Uv,{children:o.jsx("div",{className:"text-neutral3 p-4",children:"Item not found"})})}):o.jsxs(o.Fragment,{children:[o.jsx(ms,{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(VT,{}),t," ",o.jsx(Ia,{content:t})]}),o.jsx(ca.Description,{children:o.jsxs(ac,{children:["Item of ",o.jsx(zb,{})," ",u?.name]})}),o.jsxs(ca.Description,{children:[o.jsxs(ac,{children:[o.jsx(Kst,{})," Created at"," ",d?.createdAt?Kn(new Date(d.createdAt),"MMM d, yyyy"):""]}),o.jsxs(ac,{children:[o.jsx(qO,{})," Latest version v",d?.datasetVersion??""]})]})]}),o.jsx(ca.Column,{children:!v&&!f&&o.jsxs(Rr,{children:[o.jsxs(fe,{onClick:U,disabled:z,title:z?"Return to latest version to edit":void 0,children:[o.jsx(xat,{})," Edit"]}),o.jsxs(fe,{onClick:D,disabled:z,title:z?"Return to latest version to delete":void 0,children:[o.jsx(Zc,{})," Delete"]})]})})]}),o.jsxs(Nv,{className:v?"grid-cols-1":"grid-cols-[1fr_auto]",children:[o.jsxs(Ur,{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&&z&&p&&o.jsx(Rn,{variant:"warning",title:"Previous version",action:o.jsxs(Rn.Button,{onClick:L,children:[o.jsx(Wst,{})," Return to the latest version"]}),children:o.jsxs(Rn.Message,{children:["Viewing version v",p.datasetVersion]})}),v?o.jsx(e5t,{inputValue:S,setInputValue:w,groundTruthValue:O,setGroundTruthValue:_,metadataValue:C,setMetadataValue:E,trajectoryValue:T,setTrajectoryValue:N,requestContextValue:I,setRequestContextValue:R,validationErrors:null,onSave:G,onCancel:q,isSaving:l.isPending}):W?o.jsx(KCe,{item:W,Link:n}):o.jsx("div",{className:"text-neutral4 text-sm",children:"Item data not available"})]}),!v&&o.jsx(Ur,{children:o.jsx(YWr,{datasetId:e,itemId:t,onClose:()=>{},onVersionSelect:V,onCompareVersionsClick:X=>{r(`/datasets/${e}/items/${t}/versions?ids=${X.join(",")}`)},activeVersion:p?.datasetVersion??null})})]})]})})}),o.jsx(jt,{open:M,onOpenChange:F,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:P,children:c.isPending?"Deleting...":"Delete"})]})]})})]})}function RZe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function hQr(){const{datasetId:e}=mr(),[t,n]=Pi(),r=t.get("items")?.split(",").filter(Boolean)??[],{data:s,error:a}=Nx(e??""),{Link:i}=vn(),[l,c]=y.useState(!1),{data:u}=Ume(e??"",r[0]??""),{data:d}=Ume(e??"",r[1]??"");return a&&is(a)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})}):a&&ls(a)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ss,{resource:"datasets"})})}):!e||r.length<2?o.jsx(ms,{children:o.jsx(Uv,{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(ms,{children:[o.jsx(my,{owner:"dataset-items-compare",children:o.jsxs(fe,{as:li,to:`/datasets/${e}`,variant:"outline",children:[o.jsx(mc,{}),"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(Rw,{}),"Compare Dataset Items"]}),o.jsx(ca.Description,{children:o.jsxs(ac,{children:["Comparing ",r.length," items of"," ",o.jsx(li,{to:`/datasets/${e}`,className:"text-info1 hover:underline",children:s?.name||e?.slice(0,8)})]})})]}),o.jsx(ca.Column,{children:o.jsx(Rr,{children:o.jsx(fe,{variant:"primary",onClick:()=>c(f=>!f),children:l?o.jsxs(o.Fragment,{children:[o.jsx(iat,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx(Ksn,{})," Diff View"]})})})})]}),o.jsx(Nv,{className:"grid-cols-[1fr_3vw_1fr]",children:r.map((f,p)=>o.jsxs(y.Fragment,{children:[o.jsx(mQr,{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(Rxt,{codeA:RZe(u),codeB:RZe(d)})]})})]})}function mQr({datasetId:e,itemId:t,Link:n,idx:r,itemIds:s,onItemChange:a,showContent:i=!0}){const{data:l,isLoading:c}=Ume(e,t),{data:u}=DO(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(Ur,{children:[o.jsxs(Ur.Toolbar,{className:"flex gap-4",children:[o.jsxs(Aa,{name:`compare-item-${r}`,value:t,onValueChange:a,children:[o.jsx(Pa,{"aria-label":"Item",children:o.jsx(Ra,{placeholder:"Select item"})}),o.jsx($a,{children:f.map(p=>o.jsx(Qr,{value:p.value,disabled:p.disabled,children:p.label},p.value))})]}),o.jsxs(fe,{as:n,to:`/datasets/${e}/items/${t}`,children:[o.jsx(qO,{}),"Versions"]})]}),i&&o.jsx(Ur.Content,{children:c?o.jsx("div",{className:"text-neutral4 text-sm",children:"Loading..."}):l?o.jsxs(o.Fragment,{children:[o.jsx(TWr,{item:l}),o.jsx(KCe,{item:l,Link:n})]}):o.jsxs("div",{className:"text-neutral4 text-sm",children:["Item ",t.slice(0,8)," not found"]})})]})}function PZe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function gQr(){const{datasetId:e,itemId:t}=mr(),[n,r]=Pi(),[s,a]=y.useState(!1),i=n.get("ids")?.split(",").map(Number).filter(h=>!isNaN(h)&&h>0)??[],{data:l,error:c}=Nx(e??""),{Link:u}=vn(),{data:d}=GCe(e??"",t??""),{data:f}=Wme(e??"",t??"",i[0]??0,l?.version),{data:p}=Wme(e??"",t??"",i[1]??0,l?.version);return c&&is(c)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})}):c&&ls(c)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ss,{resource:"datasets"})})}):!e||!t||i.length<2?o.jsx(ms,{children:o.jsx(Uv,{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(ms,{children:[o.jsx(my,{owner:"dataset-item-versions-compare",children:o.jsxs(fe,{as:li,to:`/datasets/${e}/items/${t}`,variant:"outline",children:[o.jsx(mc,{}),"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(Rw,{}),"Compare Dataset Item Versions"]}),o.jsx(ca.Description,{children:o.jsxs(ac,{children:["Comparing ",i.length," versions of"," ",o.jsx(li,{to:`/datasets/${e}/items/${t}`,className:"text-info1 hover:underline",children:t})]})})]}),o.jsx(ca.Column,{children:o.jsx(Rr,{children:o.jsx(fe,{variant:"primary",onClick:()=>a(h=>!h),children:s?o.jsxs(o.Fragment,{children:[o.jsx(iat,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx($an,{})," Diff View"]})})})})]}),o.jsx(Nv,{className:"grid-cols-[1fr_3vw_1fr]",children:i.map((h,m)=>o.jsxs(y.Fragment,{children:[o.jsx(vQr,{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(Rxt,{codeA:PZe(f),codeB:PZe(p)})]})})]})}function vQr({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}=Wme(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(Qs,{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(Ur,{children:[o.jsxs(Ur.Toolbar,{className:"grid gap-4 grid-cols-[auto_1fr]",children:[o.jsx(qO,{className:"w-6 h-6 opacity-50"}),o.jsxs(Aa,{name:`compare-version-${l}`,value:String(n),onValueChange:g=>u(Number(g)),children:[o.jsx(Pa,{"aria-label":"Version",className:"w-full",children:o.jsx(Ra,{placeholder:"Select version"})}),o.jsx($a,{children:h.map(g=>o.jsx(Qr,{value:g.value,disabled:g.disabled,children:g.label},g.value))})]})]}),c&&o.jsx(Ur.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(KCe,{item:m,Link:i})})]})}function yQr(){const{datasetId:e}=mr(),[t]=Pi(),n=t.get("ids")?.split(",").map(Number).filter(g=>!isNaN(g)&&g>0)??[],r=Xs(),{data:s,error:a}=Nx(e??""),i=DO(e??"",void 0,n[0]??null),l=DO(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&&is(a))return o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})});if(a&&ls(a))return o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ss,{resource:"datasets"})})});if(!e||n.length<2)return o.jsx(ms,{children:o.jsx(Uv,{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(ms,{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(oon,{})," Compare Dataset Versions"]}),o.jsx(ca.Description,{children:o.jsxs(ac,{children:[o.jsx(qO,{})," Comparing ",n.length," versions of"," ",s?.name||e?.slice(0,8)]})})]}),o.jsx(ca.Column,{children:o.jsxs(fe,{as:li,to:`/datasets/${e}`,children:[o.jsx(mc,{}),"Back to Dataset"]})})]}),o.jsx(Nv,{children:o.jsxs(Ur,{children:[o.jsx(JWr,{datasetId:e,versionA:String(n[0]),versionB:String(n[1]),onVersionChange:m}),o.jsx(rQr,{datasetId:e,versionA:n[0],versionB:n[1],allItems:d,itemsAMap:f,itemsBMap:p,onItemClick:h})]})})]})})})}function bQr(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 xQr({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=bQr(n);return o.jsxs(o.Fragment,{children:[o.jsxs(Wr,{children:[o.jsx(Wr.Label,{children:"Total Scorers"}),i?o.jsx(Wr.Loading,{}):f!=null?o.jsxs(o.Fragment,{children:[o.jsx(Wr.Value,{children:String(f)}),o.jsx(Wr.NoChange,{message:"Static count"})]}):o.jsx(Wr.NoData,{})]}),o.jsxs(Wr,{children:[o.jsx(Wr.Label,{children:"Total Datasets"}),l?o.jsx(Wr.Loading,{}):p!=null?o.jsxs(o.Fragment,{children:[o.jsx(Wr.Value,{children:String(p)}),o.jsx(Wr.NoChange,{message:"Static count"})]}):o.jsx(Wr.NoData,{})]}),o.jsxs(Wr,{children:[o.jsx(Wr.Label,{children:"Avg Score"}),u?o.jsx(Wr.Loading,{}):r!=null?o.jsxs(o.Fragment,{children:[o.jsx(Wr.Value,{children:String(r)}),m?o.jsx(Wr.Change,{changePct:m.changePct,prevValue:m.prevValue}):o.jsx(Wr.NoChange,{})]}):o.jsx(Wr.NoData,{})]}),o.jsxs(Wr,{children:[o.jsx(Wr.Label,{children:"Total Experiments"}),c?o.jsx(Wr.Loading,{}):h!=null?o.jsxs(o.Fragment,{children:[o.jsx(Wr.Value,{children:String(h)}),g?o.jsx(Wr.Change,{changePct:g.changePct,prevValue:g.prevValue}):o.jsx(Wr.NoChange,{})]}):o.jsx(Wr.NoData,{})]}),o.jsxs(Wr,{children:[o.jsx(Wr.Label,{children:"Needs Review"}),d?o.jsx(Wr.Loading,{}):a!=null?o.jsxs(o.Fragment,{children:[o.jsx(Wr.Value,{children:String(a)}),a>0?o.jsx(Wr.NoChange,{message:"items pending review"}):o.jsx(Wr.NoChange,{message:"All caught up"})]}):o.jsx(Wr.NoData,{})]})]})}const $Ze="auto 1fr auto auto auto auto auto auto auto";function wQr(e){return e?(typeof e=="string"?new Date(e):e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}const SQr={completed:"success",running:"warning",failed:"error",pending:"neutral"};function kQr({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(zo,{columns:$Ze}):o.jsxs(we,{columns:$Ze,children:[o.jsxs(we.Top,{children:[o.jsx(we.TopCell,{children:"Experiment"}),o.jsx(we.TopCell,{children:"Dataset"}),o.jsx(we.TopCell,{children:"Target"}),o.jsx(we.TopCell,{children:"Status"}),o.jsx(we.TopCell,{className:"text-center",children:"Items"}),o.jsx(we.TopCell,{className:"text-center",children:"Succeeded"}),o.jsx(we.TopCell,{className:"text-center",children:"Failed"}),o.jsx(we.TopCell,{className:"text-center",children:"Review"}),o.jsx(we.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,S=b>0?Math.round(g/b*100):0;return o.jsxs(we.RowLink,{to:l.experimentLink(p.id),LinkComponent:c,children:[o.jsx(we.NameCell,{className:"font-mono",children:p.id.slice(0,8)}),o.jsx(we.TextCell,{children:h}),o.jsx(we.Cell,{children:o.jsxs("span",{className:"truncate",children:[p.targetType," ",p.targetId]})}),o.jsx(we.Cell,{children:o.jsx(Sh,{variant:SQr[m]??"neutral",withDot:!0,children:m})}),o.jsx(we.TextCell,{className:"text-center",children:b}),o.jsx(we.TextCell,{className:"text-center",children:o.jsxs("span",{className:g>0?"text-accent1":"",children:[g," (",S,"%)"]})}),o.jsx(we.TextCell,{className:"text-center",children:o.jsx("span",{className:v>0?"text-accent2":"",children:v})}),o.jsx(we.Cell,{className:"text-center",children:(()=>{const w=n?.get(p.id);if(!w)return o.jsx("span",{className:"text-neutral2",children:"—"});const O=w.needsReview+w.complete;return O===0?o.jsx("span",{className:"text-neutral2",children:"—"}):w.needsReview>0?o.jsxs(Qs,{size:"small",color:"yellow",children:[w.needsReview," pending"]}):o.jsxs(Qs,{size:"small",color:"green",children:[w.complete,"/",O," reviewed"]})})()}),o.jsx(we.TextCell,{children:wQr(p.createdAt)})]},p.id)})]})}const OQr=[{value:"all",label:"All statuses"},{value:"completed",label:"Completed"},{value:"running",label:"Running"},{value:"failed",label:"Failed"},{value:"pending",label:"Pending"}];function _Qr(e){return[{value:"all",label:"All datasets"},...(e??[]).map(t=>({value:t.id,label:t.name}))]}const J6={completed:"#22c55e",running:"#facc15",pending:"#fb923c",failed:"#f87171"},CQr=[{label:"Completed",color:J6.completed},{label:"Running",color:J6.running},{label:"Pending",color:J6.pending},{label:"Failed",color:J6.failed}];function EQr({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(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.TitleAndDescription,{title:"Experiments by Dataset",description:"Experiment status breakdown per dataset."}),i&&o.jsx(Ut.Summary,{value:String(e?.length??0),label:"Total experiments"})]}),n?o.jsx(Ut.Loading,{}):r?o.jsx(Ut.Error,{message:"Failed to load experiments data"}):o.jsx(Ut.Content,{children:i?o.jsx(Jj,{data:s,segments:CQr,maxVal:a,fmt:l=>String(l)}):o.jsx(Ut.NoData,{message:"No experiments have been run yet"})})]})}const jQr=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vr,{iconSlot:o.jsx(cf,{}),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(Ca,{})]})})})});function TQr({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(vf,{label:"Search experiments",placeholder:"Filter by experiment, dataset, or target",value:e,onSearch:t}),o.jsxs(Rr,{children:[o.jsx(sc,{label:"Status",labelIsHidden:!0,name:"filter-status",options:[...OQr],value:n,onValueChange:r,className:"whitespace-nowrap"}),o.jsx(sc,{label:"Dataset",labelIsHidden:!0,name:"filter-dataset",options:i,value:s,onValueChange:a,className:"whitespace-nowrap"}),l&&c&&o.jsxs(fe,{onClick:l,size:"sm",variant:"default",children:[o.jsx(ys,{className:"size-3"})," Reset"]})]})]})}function NQr(){const{data:e,isLoading:t,error:n}=Dp(),{data:r,isLoading:s,error:a}=hy(),{data:i,isLoading:l,error:c}=kZ(),{data:u,isLoading:d,isError:f,error:p}=yUr(),{data:h,isLoading:m,isError:g,error:v}=eEe(),b=r?.datasets,S=i?.experiments,w=y.useMemo(()=>oQr(h),[h]),O=n||a||c||p||v;return O&&is(O)?o.jsx(ar,{children:o.jsx(Ms,{})}):O&&ls(O)?o.jsx(ar,{children:o.jsx(Ss,{resource:"evaluation"})}):O?o.jsx(ar,{children:o.jsx(Ii,{title:"Failed to load evaluation data",message:O.message})}):o.jsx(Ft,{width:"wide",height:"full",children:o.jsxs("div",{className:"flex flex-col gap-6",children:[o.jsx(Kde,{children:o.jsx(xQr,{scorers:e,datasets:b,experiments:S,avgScore:u?.avgScore??null,prevAvgScore:u?.prevAvgScore??null,totalNeedsReview:w.needsReview,isLoadingScorers:t,isLoadingDatasets:s,isLoadingExperiments:l,isLoadingScores:d,isLoadingReview:m})}),o.jsx(lUr,{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(RZr,{experiments:S,isLoading:l,isError:!!c}),o.jsx(EQr,{experiments:S,datasets:b,isLoading:l,isError:!!c})]}),o.jsx(aQr,{reviewSummary:h,experiments:S,datasets:b,isLoading:m,isError:!!g})]})})}function IQr(){const[e,t]=y.useState(""),[n,r]=y.useState("all"),[s,a]=y.useState("all"),{data:i,isLoading:l,error:c}=hy(),{data:u,isLoading:d,error:f}=kZ(),{data:p}=eEe(),h=y.useMemo(()=>i?.datasets??[],[i?.datasets]),m=y.useMemo(()=>u?.experiments??[],[u?.experiments]),g=y.useMemo(()=>_Qr(h),[h]),v=y.useMemo(()=>r5t(p),[p]),b=l||d,S=f||c;if(S&&is(S))return o.jsx(ar,{children:o.jsx(Ms,{})});if(f&&ls(f))return o.jsx(ar,{children:o.jsx(Ss,{resource:"experiments"})});if(c&&ls(c))return o.jsx(ar,{children:o.jsx(Ss,{resource:"datasets"})});if(S)return o.jsx(ar,{children:o.jsx(Ii,{title:"Failed to load experiments",message:S.message})});if(m.length===0&&!b)return o.jsx(ar,{children:o.jsx(jQr,{})});const w=n!=="all"||s!=="all"||e!=="",O=()=>{t(""),r("all"),a("all")};return o.jsxs(Ft,{children:[o.jsx(Ft.TopArea,{children:o.jsx(TQr,{search:e,onSearchChange:t,statusFilter:n,onStatusFilterChange:r,datasetFilter:s,onDatasetFilterChange:a,datasetOptions:g,onReset:O,hasActiveFilters:w})}),o.jsx(kQr,{experiments:m,datasets:h,reviewByExperiment:v,isLoading:b,search:e,statusFilter:n,datasetFilter:s})]})}function e8({children:e}){return o.jsxs(Ft,{height:"full",children:[o.jsx("div",{}),o.jsx(Ft.MainArea,{isCentered:!0,children:e})]})}function AQr(){const{experimentId:e}=mr(),{data:t,isLoading:n}=kZ(),s=t?.experiments?.find(h=>h.id===e)?.datasetId??"",{data:a,isLoading:i,error:l}=yB(s,e??""),{data:c,isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p}=xZ({datasetId:s,experimentId:e??"",experimentStatus:a?.status});return!e||n||i?null:l&&is(l)?o.jsx(e8,{children:o.jsx(Ms,{})}):l&&ls(l)?o.jsx(e8,{children:o.jsx(Ss,{resource:"datasets"})}):l&&eSe(l)||!n&&!s||!i&&!l&&!a?o.jsx(e8,{children:o.jsx(Vr,{iconSlot:o.jsx(Jge,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${e}".`,actionSlot:o.jsxs(fe,{as:li,to:"/experiments",children:[o.jsx(mc,{}),"Back to Experiments"]})})}):l?o.jsx(e8,{children:o.jsx(Ii,{title:"Failed to load experiment",message:l instanceof Error?l.message:"An unexpected error occurred. Please try again."})}):o.jsxs(Ft,{height:"full",children:[o.jsx(s5t,{experiment:a}),o.jsx(Ft.MainArea,{children:o.jsx(n5t,{experimentId:e,datasetId:s,experimentStatus:a.status,results:c??[],isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p})})]})}function RQr({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 a5t({connections:e,isAdmin:t,disconnectPending:n,onDisconnect:r}){return o.jsx("ul",{className:"space-y-1",children:e.map(s=>o.jsx(RQr,{connection:s,isAdmin:t,disconnectPending:n,onDisconnect:()=>r(s.connectionId)},s.connectionId))})}function PQr({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(a5t,{connections:a,isAdmin:t,disconnectPending:n,onDisconnect:r})]},s))})}function $Qr({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(PQr,{groups:r,isAdmin:s,disconnectPending:l,onDisconnect:u}):o.jsx(a5t,{connections:n,isAdmin:s,disconnectPending:l,onDisconnect:u}),c?o.jsx("p",{className:"text-red-600",children:String(c)}):null]})}function MQr({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 MZe=e=>e.authorId?.trim()||"shared",DQr=(e,t)=>{if(!t||new Set(e.map(MZe)).size<=1)return null;const r=new Map;for(const a of e){const i=MZe(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},LQr=["*","tool-providers:*","tool-providers:admin"];function FQr(){const{data:e}=em();return e?.permissions?.some(t=>LQr.includes(t))??!1}function zQr(){const[e,t]=y.useState(""),[n,r]=y.useState(""),[s,a]=y.useState(""),i=BN(),l=uH(e||null),c=tAt(e||null,n||null),u=eAt(),d=KIt(),f=FQr(),p=i.data?.providers??[],h=l.data?.data??[],m=y.useMemo(()=>c.data?.items??[],[c.data?.items]),g=y.useMemo(()=>DQr(m,f),[m,f]),v=w=>{t(w),r("")},b=()=>{!e||!n||u.mutate({providerId:e,toolkit:n,label:s.trim()||null},{onSuccess:()=>{a(""),c.refetch()}})},S=w=>{d.mutate({providerId:e,connectionId:w})};return o.jsxs("div",{className:"p-6 max-w-3xl space-y-6 text-sm",children:[o.jsx("h1",{className:"text-2xl font-semibold",children:"Integrations"}),o.jsx("p",{className:"text-gray-500",children:"Minimal page to verify the ToolProvider backend. Pick a provider and toolkit, then connect."}),o.jsx(MQr,{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($Qr,{providerId:e,toolkit:n,connections:m,groupedByAuthor:g,isAdmin:f,isLoading:c.isLoading,error:c.error,disconnectPending:d.isPending,disconnectError:d.error,onDisconnect:S})]})}function BQr({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(Ch,{className:"h-10 w-10"}),o.jsx("h1",{className:"text-xl font-semibold text-neutral6",children:e})]}),t,n,r]})})}function i5t({redirectUri:e,onSuccess:t,initialMode:n="signin",errorMessage:r}){const{data:s,isLoading:a}=wc(),{mutate:i,isPending:l,error:c}=rAr(),{mutate:u,isPending:d,error:f}=aAr(),{mutate:p,isPending:h}=kIt(),[m,g]=y.useState(n),[v,b]=y.useState(""),[S,w]=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,E=C.type==="sso"||C.type==="both",T=C.type==="credentials"||C.type==="both",N=C.sso,I=C.signUpEnabled!==!1,R=m==="signin"||!I,$=R?l:d,B=R?c:f,M=()=>{t?t():e?window.location.href=e:window.location.href="/"},F=D=>{D.preventDefault(),R?i({email:S,password:O},{onSuccess:M}):u({email:S,password:O,name:v||void 0},{onSuccess:M})},V=()=>{p({redirectUri:e},{onSuccess:D=>{window.location.href=D.url}})},L=()=>{g(R?"signup":"signin")},z=C.description?o.jsxs("div",{className:"flex items-start gap-2.5 rounded-md border border-border1 bg-surface1 p-3",children:[o.jsx(tf,{className:"mt-0.5 h-4 w-4 shrink-0 text-neutral4"}),o.jsx("p",{className:"text-sm text-neutral3",children:C.description})]}):null,U=r?o.jsx("div",{className:"rounded-md bg-red-500/10 p-3 text-sm text-red-400",children:r}):null;return o.jsxs(BQr,{title:R?"Sign in to Mastra Studio":"Create your account",description:z,errorBanner:U,children:[T&&o.jsxs("form",{onSubmit:F,className:"space-y-4",children:[!R&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"name",className:"block text-sm text-neutral4",children:"Name"}),o.jsx(kn,{id:"name",type:"text",value:v,onChange:D=>b(D.target.value),placeholder:"Your name",variant:"default",size:"lg"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"email",className:"block text-sm text-neutral4",children:"Email"}),o.jsx(kn,{id:"email",type:"email",value:S,onChange:D=>w(D.target.value),placeholder:"you@example.com",required:!0,variant:"default",size:"lg"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"password",className:"block text-sm text-neutral4",children:"Password"}),o.jsx(kn,{id:"password",type:"password",value:O,onChange:D=>_(D.target.value),placeholder:R?"Enter your password":"Create a password",required:!0,variant:"default",size:"lg"})]}),B&&o.jsx("div",{className:"rounded-md bg-red-500/10 p-3 text-sm text-red-400",children:B.message}),o.jsx(fe,{type:"submit",disabled:$,className:"w-full",size:"lg",children:$?R?"Signing in...":"Creating account...":R?"Sign in":"Create account"}),I&&o.jsxs("div",{className:"text-center text-sm",children:[o.jsx("span",{className:"text-neutral3",children:R?"Don't have an account? ":"Already have an account? "}),o.jsx("button",{type:"button",onClick:L,className:"text-neutral6 hover:underline",children:R?"Sign up":"Sign in"})]})]}),E&&T&&o.jsxs("div",{className:"relative",children:[o.jsx("div",{className:"absolute inset-0 flex items-center",children:o.jsx("div",{className:"w-full border-t border-border1"})}),o.jsx("div",{className:"relative flex justify-center text-sm",children:o.jsx("span",{className:"bg-surface1 px-2 text-neutral3",children:"or continue with"})})]}),E&&N&&o.jsxs(fe,{onClick:V,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 UQr(){const[e]=Pi(),t=Xs(),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(i5t,{redirectUri:n,onSuccess:i,initialMode:s,errorMessage:a})}function qQr(){const[e,t]=Pi(),n=uvr(e,t),r=pvr(e,t),[s,a]=y.useState(),[i,l]=y.useState(!1),{data:c=[],isPending:u}=fSe(),{data:d=[],isPending:f}=pSe({entityType:n.selectedEntityOption?.entityType,rootOnly:!0}),{data:p=[],isPending:h}=hSe(),{data:m=[],isPending:g}=mSe(),v=y.useMemo(()=>Rmr({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(()=>Dmr({rootEntityType:n.selectedEntityOption?.entityType,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,tokens:n.filterTokens}),[n.filterTokens,n.selectedDateFrom,n.selectedDateTo,n.selectedEntityOption]),{data:S=[],isLoading:w,error:O,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:E}=lvr({filters:b}),{logIdMap:T,featuredLog:N,handleLogClick:I,handlePreviousLog:R,handleNextLog:$}=gvr(S,n.featuredLogId,n.handleFeaturedChange,n.featuredTraceId),{data:B,isLoading:M}=dSe(n.featuredTraceId??null),{data:F,isLoading:V}=QD(n.featuredTraceId??"",n.featuredSpanId??""),L=y.useCallback(()=>n.applyFilterTokens(Lmr(v,n.filterTokens)),[v,n]),z=y.useCallback(()=>n.handleFeaturedChange({logId:null}),[n]),U=y.useCallback(X=>n.handleFeaturedChange({traceId:X,spanId:null}),[n]),D=y.useCallback((X,ae)=>n.handleFeaturedChange({traceId:X,spanId:ae}),[n]),G=y.useCallback(()=>{n.handleFeaturedChange({traceId:null,spanId:null}),l(!1)},[n]),q=y.useCallback(()=>n.handleFeaturedChange({spanId:null}),[n]),P=y.useCallback(X=>n.handleFeaturedChange({spanId:X??null}),[n]),H=o.jsxs(Ft.TopArea,{children:[o.jsx(Ft.Row,{children:o.jsxs(Ft.Column,{className:"flex flex-wrap items-start justify-start gap-2",children:[o.jsx(lwe,{preset:n.datePreset,onPresetChange:n.handleDatePresetChange,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,onDateChange:n.handleDateChange,disabled:w,presets:["last-24h","last-3d","last-7d","last-14d","last-30d","custom"]}),o.jsx(Dxe,{fields:v,tokens:n.filterTokens,onTokensChange:n.handleFilterTokensChange,disabled:w,onStartTextFilter:a})]})}),o.jsx(evr,{isLoading:w,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(Ft,{width:"wide",height:"full",children:[H,o.jsx(Ft.MainArea,{isCentered:!0,children:o.jsx(Ggr,{error:O,resource:"logs",errorTitle:"Failed to load logs"})})]});const W=!!n.selectedEntityOption||n.filterTokens.length>0;return S.length===0&&!w&&!W?o.jsxs(Ft,{width:"wide",height:"full",children:[H,o.jsx(Ft.MainArea,{isCentered:!0,children:o.jsx(svr,{datePreset:n.datePreset,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo})})]}):o.jsxs(Ft,{width:"wide",height:"full",children:[H,o.jsx(Ygr,{logCollapsed:i,listSlot:o.jsx(Jgr,{logs:S,isLoading:w,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:E,logIdMap:T,featuredLogId:n.featuredLogId,onLogClick:I}),logPanelSlot:N?o.jsx(Qgr,{log:N,onClose:z,onTraceClick:U,onSpanClick:D,onPrevious:R,onNext:$,collapsed:i,onCollapsedChange:l}):null,tracePanelSlot:n.featuredTraceId?o.jsx(xgr,{traceId:n.featuredTraceId,spans:B?.spans,isLoading:M,onClose:G,onSpanSelect:P,selectedSpanId:n.featuredSpanId}):null,spanPanelSlot:n.featuredTraceId&&n.featuredSpanId?o.jsx(bgr,{spanId:n.featuredSpanId,span:F?.span,isLoading:V,onClose:q}):null})]})}function VQr({server:e}){const{paths:t,Link:n}=vn(),s=Ze().options.baseUrl,a=s?`${s}/api/mcp/${e.id}/sse`:"",{data:i}=t3t(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(we.RowLink,{to:t.mcpServerLink(e.id),LinkComponent:n,children:[o.jsx(we.NameCell,{children:f}),o.jsx(we.DescriptionCell,{children:a}),o.jsx(we.TextCell,{className:"text-center",children:u||""}),o.jsx(we.TextCell,{className:"text-center",children:c||""}),o.jsx(we.TextCell,{className:"text-center",children:d||""})]})}function HQr({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(zo,{columns:"auto 1fr auto auto auto"}):o.jsxs(we,{columns:"auto 1fr auto auto auto",children:[o.jsxs(we.Top,{children:[o.jsx(we.TopCell,{children:"Name"}),o.jsx(we.TopCell,{children:"URL"}),o.jsx(we.TopCellSmart,{long:"Agents",short:o.jsx(Vo,{}),tooltip:"Agent Tools",className:"text-center"}),o.jsx(we.TopCellSmart,{long:"Tools",short:o.jsx(sf,{}),tooltip:"Tools",className:"text-center"}),o.jsx(we.TopCellSmart,{long:"Workflows",short:o.jsx(ld,{}),tooltip:"Workflow Tools",className:"text-center"})]}),r.length===0&&n?o.jsx(we.NoMatch,{message:"No MCP Servers match your search"}):null,r.map(s=>o.jsx(VQr,{server:s},s.id))]})}const ZQr=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vr,{iconSlot:o.jsx(cf,{}),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(Ca,{})]})})}),WQr=()=>{const{data:e=[],isLoading:t,error:n}=pZ(),[r,s]=y.useState("");return n&&is(n)?o.jsx(ar,{children:o.jsx(Ms,{})}):n&&ls(n)?o.jsx(ar,{children:o.jsx(Ss,{resource:"MCP servers"})}):n?o.jsx(ar,{children:o.jsx(Ii,{title:"Failed to load MCP servers",message:n.message})}):e.length===0&&!t?o.jsx(ar,{children:o.jsx(ZQr,{})}):o.jsxs(Ft,{children:[o.jsx(Ft.TopArea,{children:o.jsx("div",{className:"max-w-120",children:o.jsx(vf,{onSearch:s,label:"Filter MCP servers",placeholder:"Filter by name"})})}),o.jsx(HQr,{mcpServers:e,isLoading:t,search:r})]})},QQr=(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 GQr({tools:e,agents:t,isLoading:n,search:r=""}){const{paths:s,Link:a}=vn(),i=y.useMemo(()=>QQr(e,t),[e,t]),l=y.useMemo(()=>i.filter(c=>c.id.toLowerCase().includes(r.toLowerCase())),[i,r]);return n?o.jsx(zo,{columns:"auto 1fr auto"}):o.jsxs(we,{columns:"auto 1fr auto",children:[o.jsxs(we.Top,{children:[o.jsx(we.TopCell,{children:"Name"}),o.jsx(we.TopCell,{children:"Description"}),o.jsx(we.TopCellSmart,{long:"Agents",short:o.jsx(Vo,{}),tooltip:"Attached Agents",className:"text-center"})]}),l.length===0&&r?o.jsx(we.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(we.RowLink,{to:s.toolLink(c.id),LinkComponent:a,children:[o.jsx(we.NameCell,{children:u}),o.jsx(we.DescriptionCell,{children:d}),o.jsx(we.TextCell,{className:"text-center",children:f||""})]},c.id)})]})}const YQr=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vr,{iconSlot:o.jsx(cf,{}),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(Ca,{})]})})}),XQr=()=>{const e=Ze();return An({mutationFn:async({toolId:t,input:n,requestContext:r})=>{const s=new zO;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}}})},KQr=({toolId:e})=>{const{canExecute:t}=al(),n=t("tools"),{data:r={}}=tm(),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}=mIr(e,{enabled:!s}),c=s||a,{mutateAsync:u,isPending:d,data:f}=XQr(),{requestContext:p}=ks();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?dg(cg(ax(c?.inputSchema))):xs({});return i?o.jsxs("div",{className:"p-6",children:[o.jsx(On,{className:"h-8 w-48 mb-4"}),o.jsx(On,{className:"h-32 w-full"})]}):l?null:c?n?o.jsx(FCe,{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 JQr({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}=zN(),{data:p={},isLoading:h,isError:m,error:g}=tm(),{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 S=new Map;Object.values(p).forEach(_=>{_.tools&&Object.values(_.tools).forEach(C=>{S.has(C.id)||S.set(C.id,C)})}),Object.values(c).forEach(_=>{S.has(_.id)||S.set(_.id,_)});const w=Array.from(S.values()).map(_=>({label:_.id,value:_.id})),O=_=>{t?t(_):_&&_!==e&&v(b.toolLink(_))};return o.jsx(Hc,{options:w,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 eGr=({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(Uv,{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(Uv,{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(zt,{icon:o.jsx(j_t,{className:"text-neutral6"}),className:"rounded-r-sm text-neutral4!",children:"Version"}),o.jsx(zt,{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(zt,{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(Ia,{tooltip:"Copy HTTP Stream URL",content:r})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(zt,{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(Ia,{tooltip:"Copy SSE URL",content:n})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(zt,{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(Ia,{tooltip:"Copy Command Line Config",content:a})})]})]})]})]}),o.jsx("div",{className:"h-full overflow-y-scroll border-l border-border1",children:o.jsx(tGr,{server:t})})]})},tGr=({server:e})=>{const{data:t={},isLoading:n}=t3t(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(Qe,{size:"lg",className:"bg-surface4 rounded-md p-1",children:o.jsx(Yw,{})}),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(rGr,{tool:a,serverId:e.id},s)})})]})};function nGr(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 rGr=({tool:e,serverId:t})=>{const n=y.useRef(null),{Link:r,paths:s}=vn(),a=y3t[e.toolType||"tool"],i=nGr(e._meta);return o.jsxs(pf,{onClick:()=>n.current?.click(),children:[o.jsx(Lpt,{children:o.jsx(a,{className:"group-hover/entity:text-accent6"})}),o.jsxs(mf,{children:[o.jsx(hf,{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(zt,{className:"text-[10px] py-0",children:"App"})]})}),o.jsx(Ip,{children:e.description})]})]})},sGr=()=>{const{serverId:e}=mr(),{data:t=[],isLoading:n}=pZ(),r=t.find(s=>s.id===e);return o.jsx("div",{className:"h-full w-full overflow-hidden",children:o.jsx(eGr,{isLoading:n,server:r})})};function aGr(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 iGr=({toolId:e,serverId:t})=>{const{canExecute:n}=al(),r=n("tools"),s=Ze(),{data:a,isLoading:i,error:l}=TCe(t,e),{mutateAsync:c,isPending:u,data:d}=w7r(t,e),f=a?aGr(a._meta):void 0,{data:p}=St({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(On,{className:"h-8 w-48 mb-4"}),o.jsx(On,{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=dg(cg(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(e3t,{html:p,toolName:a.name??a.id,onToolCall:h})}),o.jsx(FCe,{executionResult:d,isExecutingTool:u,zodInputSchema:g,handleExecuteTool:m,toolDescription:a.description||"",toolId:a.id})]})},oGr=()=>{const{serverId:e,toolId:t}=mr(),{data:n,isLoading:r}=TCe(e,t);return r||!n?null:o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(iGr,{toolId:t,serverId:e})})},DZe={agents:zs.AGENT,workflows:zs.WORKFLOW_RUN,tools:zs.TOOL};function lGr(){const{data:e,isLoading:t,isError:n}=vmr(),{getTracesHref:r,getBucketTracesHref:s}=DN(),{Link:a}=vn(),i=Xs();return o.jsx(rmr,{data:e,isLoading:t,isError:n,onPointClick:(l,c)=>{Number.isFinite(c.tsMs)&&i(s({rootEntityType:DZe[l]},c.tsMs,"1h"))},actions:l=>o.jsx(VD,{href:r({rootEntityType:DZe[l]}),LinkComponent:a})})}function cGr(){const e=Cmr(),t=Emr(),{getTracesHref:n}=DN(),{Link:r}=vn();return o.jsx(amr,{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 uGr(){const{data:e,isLoading:t,isError:n}=Z_t();return o.jsx(HD,{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 dGr(){const{data:e,isLoading:t,isError:n}=hmr();return o.jsx(HD,{label:"Total Model Cost",value:e?.cost!=null?Gm(e.cost,e.costUnit):null,prevValue:e?.previousCost!=null?Gm(e.previousCost,e.costUnit):void 0,changePct:e?.costChangePercent??null,isLoading:t,isError:n})}function fGr(){const{data:e,isLoading:t,isError:n}=mmr();return o.jsx(HD,{label:"Total Tokens",value:e?.value!=null?rc(e.value):null,prevValue:e?.previousValue!=null?rc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function pGr(){const{data:e,isLoading:t,isError:n}=Omr();return o.jsx(HD,{label:"Total Threads",value:e?.value!=null?rc(e.value):null,prevValue:e?.previousValue!=null?rc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function hGr(){const{data:e,isLoading:t,isError:n}=_mr();return o.jsx(HD,{label:"Total Resources",value:e?.value!=null?rc(e.value):null,prevValue:e?.previousValue!=null?rc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function mGr({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=>gGr(f,a));return o.jsxs("div",{className:K("grid grid-cols-[1fr_auto] gap-3 items-start"),children:[o.jsx(Mxe,{fields:a,tokens:i,onTokensChange:l,disabled:s,autoFocusFieldId:c}),u&&o.jsx(Pxe,{disabled:s,onClear:d?e:void 0,onRemoveAll:t,onSave:n,onRemoveSaved:r})]})}function gGr(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 vGr(){const{data:e,isLoading:t,isError:n}=gmr(),{getTracesHref:r}=DN(),{Link:s}=vn();return o.jsx(imr,{rows:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:()=>r({rootEntityType:zs.AGENT}),actions:o.jsx(VD,{href:r({rootEntityType:zs.AGENT}),LinkComponent:s})})}function yGr(){const{data:e,isLoading:t,isError:n}=bmr(),{getTracesHref:r}=DN(),{Link:s}=vn();return o.jsx(lmr,{data:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:a=>r({rootEntityType:zs.AGENT,entityName:a.name}),actions:o.jsx(VD,{href:r({rootEntityType:zs.AGENT}),LinkComponent:s})})}function bGr(){const{data:e,isLoading:t,isError:n}=kmr(),{getTracesHref:r}=DN(),{Link:s}=vn();return o.jsx(dmr,{data:e?.data,interval:e?.interval,isLoading:t,isError:n,actions:o.jsx(VD,{href:r(),LinkComponent:s})})}const t8={agents:zs.AGENT,workflows:zs.WORKFLOW_RUN,tools:zs.TOOL};function xGr(){const{data:e,isLoading:t,isError:n}=ymr(),{getTracesHref:r,getLogsHref:s}=DN(),{Link:a}=vn();return o.jsx(fmr,{data:e,isLoading:t,isError:n,LinkComponent:a,getRowHref:(i,l)=>r({rootEntityType:t8[i],entityName:l.name}),getErrorSegmentHref:(i,l)=>l.errors>0?s({rootEntityType:t8[i],entityName:l.name,status:"error"}):void 0,actions:i=>o.jsxs(o.Fragment,{children:[o.jsx(VD,{href:r({rootEntityType:t8[i]}),LinkComponent:a}),o.jsx(tmr,{href:s({rootEntityType:t8[i],status:"error"}),LinkComponent:a})]})})}const wGr=new Set(["ObservabilityStorageClickhouseVNext","ObservabilityStorageDuckDB","ObservabilityInMemory","ObservabilitySpanner"]),Ene="period",n8="dateFrom",r8="dateTo";function SGr(){const[e,t]=Pi(),n=e.get(Ene),r=Qhr(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(n8)),p=d(e.get(r8));if(!(!f&&!p))return{from:f,to:p}},[r,e.toString()]),a=y.useMemo(()=>Bhr(e),[e.toString()]),i=y.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d==="24h"?p.delete(Ene):p.set(Ene,d),d!=="custom"&&(p.delete(n8),p.delete(r8)),p},{replace:!0})},[t]),l=y.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d?.from?p.set(n8,d.from.toISOString()):p.delete(n8),d?.to?p.set(r8,d.to.toISOString()):p.delete(r8),p},{replace:!0})},[t]),c=y.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return qhr(p,d),p},{replace:!0})},[t]),u=y.useRef(!1);return y.useEffect(()=>{if(u.current||(u.current=!0,Fhr(e)))return;const d=q_t();d&&t(f=>{const p=new URLSearchParams(f);for(const[h,m]of d)p.append(h,m);return p},{replace:!0})},[]),o.jsx(Yhr,{preset:r,filterTokens:a,onPresetChange:i,onFilterTokensChange:c,customRange:s,onCustomRangeChange:l,children:o.jsx(kGr,{})})}function kGr(){const[e]=Pi(),{error:t,isLoading:n}=Z_t(),{filterTokens:r,setFilterTokens:s}=TV(),[a,i]=y.useState(),{data:l,isLoading:c}=W4(),u=l?.observabilityStorageType,d=u?wGr.has(u):!1,f=u==="ObservabilityInMemory",{data:p,isLoading:h}=fSe(),{data:m,isLoading:g}=pSe(),{data:v,isLoading:b}=mSe(),{data:S,isLoading:w}=hSe(),O=y.useMemo(()=>zhr({availableTags:p??[],availableEntityNames:m??[],availableServiceNames:v??[],availableEnvironments:S??[],loading:{tags:h,entityNames:g,serviceNames:b,environments:w}}),[p,m,v,S,h,g,b,w]),[_,C]=y.useState(()=>q_t()!==null),E=y.useCallback(()=>{Dhr(e),C(!0),Be.success("Filters setting for Metrics saved")},[e]),T=y.useCallback(()=>{Lhr(),C(!1),Be.success("Filters setting for Metrics cleared up")},[]),N=y.useCallback(()=>{s([])},[s]),I=y.useCallback(()=>{const R=r.map($=>{const B=O.find(M=>M.id===$.fieldId);return B?B.kind==="text"?{fieldId:$.fieldId,value:""}:B.kind==="pick-multi"?B.multi?{fieldId:$.fieldId,value:[]}:{fieldId:$.fieldId,value:"Any"}:B.kind==="multi-select"?{fieldId:$.fieldId,value:[]}:$:$});s(R)},[O,r,s]);return t&&is(t)?o.jsx(ar,{children:o.jsx(Ms,{})}):t&&ls(t)?o.jsx(ar,{children:o.jsx(Ss,{resource:"metrics"})}):t?o.jsx(ar,{children:o.jsx(Ii,{title:"Failed to load metrics",message:t.message})}):o.jsxs(Ft,{width:"wide",height:"full",children:[o.jsxs(Ft.TopArea,{children:[o.jsx(Ft.Row,{children:o.jsxs(Ft.Column,{className:"flex flex-wrap items-start justify-start gap-2",children:[o.jsx(emr,{}),o.jsx(Dxe,{fields:O,tokens:r,onTokensChange:s,disabled:n,onStartTextFilter:i})]})}),o.jsx(mGr,{isLoading:n,filterFields:O,filterTokens:r,onFilterTokensChange:s,onClear:I,onRemoveAll:N,onSave:E,onRemoveSaved:_?T: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(Kde,{children:[o.jsx(uGr,{}),o.jsx(dGr,{}),o.jsx(fGr,{}),o.jsx(pGr,{}),o.jsx(hGr,{})]}),o.jsxs(Kde,{children:[o.jsx(vGr,{}),o.jsx(yGr,{}),o.jsx(bGr,{}),o.jsx(cGr,{}),o.jsx(xGr,{}),o.jsx(lGr,{})]})]}):o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vr,{iconSlot:o.jsx(cf,{}),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(Ca,{})]})})})]})}function OGr(){const{paths:e}=vn(),{data:t,isLoading:n,error:r}=b3t(),{isCmsAvailable:s}=Y4(),[a,i]=y.useState(""),l=t?.promptBlocks??[];return r&&is(r)?o.jsx(ar,{children:o.jsx(Ms,{})}):r&&ls(r)?o.jsx(ar,{children:o.jsx(Ss,{resource:"prompt blocks"})}):r?o.jsx(ar,{children:o.jsx(Ii,{title:"Failed to load prompt blocks",message:r.message})}):l.length===0&&!n?o.jsx(ar,{children:o.jsx(oqr,{})}):o.jsxs(Ft,{children:[o.jsx(Ft.TopArea,{children:o.jsxs(Ft.Row,{align:"center",stack:"responsive",children:[o.jsx("div",{className:"max-w-120 flex-1",children:o.jsx(vf,{onSearch:i,label:"Filter prompts",placeholder:"Filter by name or description"})}),s&&o.jsxs(fe,{as:li,to:e.cmsPromptBlockCreateLink(),variant:"primary",className:"shrink-0",children:[o.jsx(Fr,{}),"Create Prompt"]})]})}),o.jsx(iqr,{promptBlocks:l,isLoading:n,search:a})]})}function _Gr(){return o.jsx(Ft,{width:"narrow",children:o.jsx(Ft.MainArea,{children:o.jsx(Z7r,{children:o.jsx(r3t,{})})})})}const CGr=[{title:"Mastra APIs",description:"Explore and test the available REST API endpoints with the interactive Swagger UI.",icon:ran,href:"/swagger-ui",external:!1},{title:"Documentation",description:"Read the official Mastra documentation for guides, references, and tutorials.",icon:Yst,href:"https://mastra.ai/en/docs",external:!0},{title:"Github",description:"Browse the source code, report issues, and contribute to the Mastra project.",icon:Ca,href:"https://github.com/mastra-ai/mastra",external:!0},{title:"Community",description:"Join the Mastra Discord community for help, discussion, and collaboration.",icon:J2,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:aat,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:Xst,href:"https://mastra.ai/contact?ref=studio",external:!0}];function EGr(){return o.jsx(Ft,{width:"narrow",children:o.jsx(Ft.MainArea,{children:o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 max-w-3xl",children:CGr.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(Ca,{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 jGr(){const{data:e={},isLoading:t,error:n}=Dp(),[r,s]=y.useState(""),[a,i]=y.useState("all");if(n&&is(n))return o.jsx(ar,{children:o.jsx(Ms,{})});if(n&&ls(n))return o.jsx(ar,{children:o.jsx(Ss,{resource:"scorers"})});if(n)return o.jsx(ar,{children:o.jsx(Ii,{title:"Failed to load scorers",message:n.message})});if(Object.keys(e).length===0&&!t)return o.jsx(ar,{children:o.jsx(uUr,{})});const l=a!=="all"||r!=="",c=()=>{s(""),i("all")};return o.jsxs(Ft,{children:[o.jsx(Ft.TopArea,{children:o.jsx(fUr,{search:r,onSearchChange:s,sourceFilter:a,onSourceFilterChange:i,onReset:c,hasActiveFilters:l})}),o.jsx(cUr,{scorers:e,isLoading:t,search:r,sourceFilter:a})]})}function TGr(){const{scorerId:e}=mr(),[t,n]=Pi(),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}=iUr(e),{data:d={},isLoading:f,error:p}=tm(),{isLoading:h,error:m}=wy(),{data:g=[],isLoading:v,error:b,isFetchingNextPage:S,hasNextPage:w,setEndOfListElement:O}=aUr({scorerId:e,entityId:i?.value==="all"?void 0:i?.value,entityType:i?.type==="ALL"?void 0:i?.type}),_=y.useMemo(()=>c?.agentIds?.filter(U=>d[U]).map(U=>({value:U,label:d[U].name,type:"AGENT"}))||[],[c?.agentIds,d]),C=y.useMemo(()=>c?.workflowIds?.map(U=>({value:U,label:U,type:"WORKFLOW"}))||[],[c?.workflowIds]),E=y.useMemo(()=>[{value:"all",label:"All Entities",type:"ALL"},..._,...C],[_,C]),T=t.get("entity")??"all",N=E.find(U=>U.value===T);N&&N.value!==i?.value&&l(N),y.useEffect(()=>{if(u){const U=u instanceof Error?u.message:"Failed to load scorer";Be.error(`Error loading scorer: ${U}`)}},[u]),y.useEffect(()=>{if(p){const U=p instanceof Error?p.message:"Failed to load agents";Be.error(`Error loading agents: ${U}`)}},[p]),y.useEffect(()=>{if(m){const U=m instanceof Error?m.message:"Failed to load workflows";Be.error(`Error loading workflows: ${U}`)}},[m]);const I=U=>{U?.value&&n(D=>{const G=new URLSearchParams(D);return G.set("entity",U.value),G})};y.useEffect(()=>{const U=t.get("scoreId")??void 0;if(U===s)return;if(!U){a(void 0);return}g.find(G=>G.id===U)&&a(U)},[t,g]);const R=y.useCallback(U=>{a(U||void 0),n(D=>{const G=new URLSearchParams(D);return U?G.set("scoreId",U):G.delete("scoreId"),G})},[n]);if(!c)return null;const $=is(u)||is(p)||is(m),B=u&&ls(u),M=!$&&!B&&(u||p||m),F=!v&&g.length===0,V=i?.value!=="all",L=c?.scorer?.source==="stored"?o.jsx(my,{owner:"scorer-detail",children:o.jsxs(fe,{variant:"default",as:li,to:`/cms/scorers/${e}/edit`,size:"sm",children:[o.jsx(Ph,{})," Edit"]})}):null;if($||B||M||F&&!V){const U=(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(Ft,{width:"wide",height:"full",children:[L,o.jsx(Ft.MainArea,{isCentered:!0,children:$?o.jsx(Ms,{}):B?o.jsx(Ss,{resource:"scorers"}):M?o.jsx(Ii,{title:"Failed to load scorer",message:U}):o.jsx(eUr,{})})]})}return o.jsxs(Ft,{width:"wide",children:[L,o.jsx(Ft.TopArea,{children:o.jsx(tUr,{selectedEntity:i,entityOptions:E,onEntityChange:I,onReset:()=>{n(U=>{const D=new URLSearchParams(U);return D.set("entity","all"),D})},isLoading:v||f||h})}),o.jsx(JBr,{scores:g,isLoading:v,selectedScoreId:s,isFetchingNextPage:S,hasNextPage:w,setEndOfListElement:O,onScoreClick:R,errorMsg:b?.message})]})}function NGr({label:e,description:t,htmlFor:n,className:r,children:s}){return o.jsxs("div",{className:K("flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",r),"data-slot":"settings-row",children:[o.jsxs("div",{children:[n?o.jsx(Rt,{htmlFor:n,className:"text-sm font-medium",children:e}):o.jsx("p",{className:"text-sm font-medium",children:e}),t&&o.jsx("p",{className:"text-sm text-neutral3",children:t})]}),s]})}const o5t=[{value:"dark",label:"Dark"},{value:"light",label:"Light"},{value:"system",label:"System"}],IGr=e=>o5t.some(t=>t.value===e),AGr=()=>{const{baseUrl:e,headers:t,apiPrefix:n}=bSe(),{theme:r,setTheme:s}=cN();return o.jsx(Ft,{width:"narrow",children:o.jsxs(Ft.MainArea,{className:"flex flex-col gap-5 mt-6",children:[o.jsx(dfe,{title:"Theme",description:"Customize the appearance of the studio.",children:o.jsx(NGr,{label:"Theme mode",htmlFor:"theme",children:o.jsxs(Aa,{value:r,onValueChange:a=>{IGr(a)&&s(a)},children:[o.jsx(Pa,{id:"theme",className:"w-full sm:w-48",children:o.jsx(Ra,{})}),o.jsx($a,{children:o5t.map(a=>o.jsx(Qr,{value:a.value,children:a.label},a.value))})]})})}),o.jsx(dfe,{title:"Mastra Connection",description:"Configure the Mastra instance URL, API prefix, and request headers used by the studio.",children:o.jsx(a3t,{initialConfig:{baseUrl:e,headers:t,apiPrefix:n}})})]})})};function RGr(){const[e]=Pi(),t=Xs(),n=e.get("redirect")||"/",r=()=>{n.startsWith("http")?window.location.href=n:t(n,{replace:!0})};return o.jsx(i5t,{redirectUri:n,onSuccess:r,initialMode:"signup"})}function PGr(e){return e.replace(/\/$/,"").split("/").pop()}function OZ({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 $Gr({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(Vo,{})," ",a.agents.length]}),a?.tools&&a.tools.length>0&&o.jsxs("li",{children:[o.jsx(sf,{})," ",a.tools.length]}),a?.networks&&a.networks.length>0&&o.jsxs("li",{children:[o.jsx(vat,{})," ",a.networks.length]}),a?.workflows&&a.workflows.length>0&&o.jsxs("li",{children:[o.jsx(UB,{})," ",a.workflows.length]}),a?.mcp&&a.mcp.length>0&&o.jsxs("li",{children:[o.jsx(Yw,{})," ",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(O_t,{})," ",PGr(a.githubUrl)]})})]},a.slug)})})}function MGr({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(qj,{name:"search-templates",label:"Search templates",labelIsHidden:!0,value:i,onChange:f=>l?.(f.target.value),placeholder:"Search Template"}),o.jsx(sc,{label:"Filter by tag",labelIsHidden:!0,name:"filter-tag",value:t,onValueChange:s,options:e}),o.jsx(sc,{label:"Filter by provider",labelIsHidden:!0,name:"filter-provider",value:r,onValueChange:a,options:n}),c&&o.jsxs(fe,{onClick:c,children:["Reset ",o.jsx(ys,{})]})]})}function DGr(){const{data:e,isLoading:t}=eyr(),{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(S=>{f.push({value:S,label:S})});const p=[{value:"all",label:"Any provider"}];(s||[]).forEach(S=>{p.push({value:S,label:S})});const h=(S,w)=>{w==="tag"?i(S):w==="provider"&&c(S)},m=S=>{d(S)},g=()=>{i("all"),c("all"),d("")},v=n.filter(S=>!(u&&!S.title.toLowerCase().includes(u)&&!S.description.toLowerCase().includes(u)||a!=="all"&&!S.tags.includes(a)||l!=="all"&&!S.supportedProviders.includes(l))),b=u||a!=="all"||l!=="all";return o.jsxs(ms,{children:[o.jsx(Lbe,{children:o.jsxs(Fpt,{children:[o.jsx(Qe,{children:o.jsx(_v,{})}),"Templates"]})}),o.jsxs("div",{className:K("overflow-y-auto w-full h-full px-8 pb-12 z-10"),children:[o.jsx(MGr,{selectedTag:a,onTagChange:S=>h(S,"tag"),tagOptions:f,selectedProvider:l,onProviderChange:S=>h(S,"provider"),providerOptions:p,searchTerm:u,onSearchChange:m,onReset:b?g:void 0,className:"max-w-[80rem]",isLoading:t}),o.jsx($Gr,{templates:v,linkComponent:li,className:"max-w-[80rem] mx-auto",isLoading:t})]})]})}const LGr="1.42.0-alpha.4";function FGr({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(cp,{className:"text-yellow-500"}),title:"Template Installed with Warnings"}:{icon:o.jsx(Nan,{}),title:"Template Installation Failed"},{icon:l,title:c}=i();return o.jsxs(OZ,{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 zGr({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(OZ,{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(yat,{})]}),o.jsx(sc,{name:"template-provider",options:e,label:"Template AI Model Provider",onValueChange:n,value:t,placeholder:"Select",layout:"horizontal"}),t&&Object.entries(r||{}).length>0&&o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"text-neutral3 text-ui-md",children:"Set required Environmental Variables"}),o.jsx("div",{className:"grid grid-cols-[1fr_1fr] gap-4 items-start",children:l?o.jsxs("div",{className:K("flex items-center justify-center col-span-2 text-neutral3 text-ui-sm gap-4","[&_svg]:opacity-50 [&_svg]:w-[1.1em] [&_svg]:h-[1.1em]","animate-in fade-in duration-300"),children:[o.jsx(Wt,{})," Loading variables..."]}):Object.entries(r).map(([p,h])=>o.jsxs(y.Fragment,{children:[o.jsx(aO,{name:`env-${p}`,labelIsHidden:!0,label:"Key",value:p,disabled:!0,className:"w-full"}),o.jsx(aO,{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(s3t,{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(Wt,{className:"w-4 h-4"})," Installing..."]}):o.jsxs(o.Fragment,{children:["Install ",o.jsx(Zh,{})]})})]})})}function BGr({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(_v,{}),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(c1,{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(eve,{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(O_t,{}),n?.split("/")?.pop()]})]}),s&&o.jsx(i0e,{data:s,labelsAreHidden:!0,isLoading:r})]})]})}function UGr({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(OZ,{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(S7n,{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(Tin,{}),l||"Something went wrong"]}),u&&o.jsx(w7n,{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(Wt,{}),o.jsx("p",{children:"This may take some time..."})]})]})}function qGr({name:e,installedEntities:t}){return o.jsxs(OZ,{className:K("grid items-center justify-items-center gap-4 content-center","[&>svg]:w-8 [&>svg]:h-8"),children:[o.jsx(yat,{}),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(i0e,{data:t})]})}function VGr(){const{templateSlug:e}=mr(),[t,n]=Pi(),[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,S]=y.useState(""),[w,O]=y.useState(!1),[_,C]=y.useState(!1),[E,T]=y.useState([]),{data:N,isLoading:I}=tyr({repoOrSlug:e,owner:"mastra-ai"}),$=LGr?.includes("beta")??!1?"beta":"main",{data:B,isLoading:M}=nyr({repo:N?.githubUrl?new URL(N.githubUrl).pathname.split("/")[2]:`template-${e}`,owner:"mastra-ai",branch:$}),{data:F,isLoading:V}=ryr(),{mutateAsync:L,isPending:z}=syr(),{mutateAsync:U}=ayr(),{streamInstall:D,streamResult:G,isStreaming:q}=oyr(F),{observeInstall:P,streamResult:H,isStreaming:W}=lyr(F);y.useEffect(()=>{const ne=t.get("runId");ne&&!g&&!h&&!q&&!W&&(console.info("🔄 Checking completed run after hot reload:",{runId:ne}),S(ne),U({runId:ne}).then(ue=>{const pe=ue.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:xe}=pe.result.validationResults,be=`Template installation completed but ${he} validation issue${he>1?"s":""} remain unresolved.`;m(be),T(xe||[])}else{const he=pe?.result?.message||pe?.result?.error||"Template installation failed";m(typeof he=="string"?he:String(he))}}).catch(ue=>{console.error("❌ Failed to fetch run details:",ue),m("Failed to retrieve installation status after reload")}))},[t,g,h,q,W,U]),y.useEffect(()=>{const ne=t.get("runId"),ue=t.get("resume"),pe=t.get("provider");if(ne&&ue==="true"&&pe&&!q&&!W&&!w&&!_&&F){S(ne),O(!0);try{U({runId:ne}).then(re=>{if(re.snapshot?.status==="running")return P.mutateAsync({runId:ne})}).then(()=>{n(re=>{const he=new URLSearchParams(re);return he.delete("resume"),he})}).catch(re=>{console.error("❌ Failed to resume template installation:",re),re.message?.includes("404")||re.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(re){console.error("❌ Auto-resume failed with error:",re),m("Failed to resume template installation. Please refresh and try again.")}}},[t,e,q,W,w,_,F,U,P,n]);const X=[{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"groq",label:"Groq"},{value:"google",label:"Google"}],ae=[{key:"tools",label:"Tools",value:N?.tools?.length?N.tools.map(ne=>ne).join(", "):"n/a",icon:o.jsx(sf,{})},{key:"agents",label:"Agents",value:N?.agents?.length?N.agents.map(ne=>ne).join(", "):"n/a",icon:o.jsx(Vo,{})},{key:"workflows",label:"Workflows",value:N?.workflows?.length?N.workflows.map(ne=>ne).join(", "):"n/a",icon:o.jsx(UB,{})},{key:"providers",label:"Providers",value:N?.supportedProviders?.length?N.supportedProviders.join(", "):"n/a",icon:o.jsx(W0,{})},{key:"tags",label:"Tags",value:N?.tags?.length?N.tags.join(", "):"n/a",icon:o.jsx(VO,{})}],ee=[{...ae[0]},{...ae[1]},{...ae[2]}].filter(ne=>ne.value!=="n/a");y.useEffect(()=>{B&&d(B)},[B]),y.useEffect(()=>{const ne=G||H;ne?.phase==="error"&&ne?.error&&m(typeof ne.error=="string"?ne.error:String(ne.error))},[G?.phase,G?.error,H?.phase,H?.error]);const J=ne=>{s(ne)},ie=async ne=>(i(ne.provider),c(ne.modelId),{message:"Model updated successfully"}),ce=async()=>{const ne=Object.entries(u).reduce((ue,[pe,re])=>(re===""&&ue.push(pe),ue),[]);if(ne.length>0){p(ne);return}if(N){m(null),v(!1),S(""),C(!0);try{const pe={repo:N.githubUrl||`https://github.com/mastra-ai/template-${N.slug}`,ref:$,slug:N.slug,variables:u},{runId:re}=await L({});S(re),n(he=>{const xe=new URLSearchParams(he);return xe.set("runId",re),xe.set("resume","true"),xe.set("provider",r||"openai"),xe}),await D.mutateAsync({inputData:pe,selectedModel:{provider:a,modelId:l},runId:re})}catch(ue){C(!1),m(ue?.message||"Template installation failed"),console.error("Template installation failed",ue)}}},Y=ne=>{const{name:ue,value:pe}=ne.target;pe.trim()===""?p(re=>[...re,ue]):p(re=>re.filter(he=>he!==ue)),d(re=>({...re,[ue]:pe}))};return o.jsx(ms,{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(BGr,{isLoading:I,title:N?.title,description:N?.longDescription,imageURL:N?.imageURL,githubUrl:N?.githubUrl,infoData:ae,templateSlug:e}),N&&o.jsxs(o.Fragment,{children:[(q||W)&&o.jsx(UGr,{name:N.title,streamResult:W?H:G,runId:b,workflowInfo:F}),g&&o.jsx(qGr,{name:N.title,installedEntities:ee,linkComponent:li}),h&&o.jsx(FGr,{errorMsg:h,validationErrors:E.length>0?E:G?.validationResults?.errors||H?.validationResults?.errors}),!q&&!W&&!g&&!h&&o.jsx(zGr,{providerOptions:X,selectedProvider:r,onProviderChange:J,variables:u,setVariables:d,errors:f,setErrors:p,handleInstallTemplate:ce,handleVariableChange:Y,isLoadingEnvVars:M||V,isInstalling:z,defaultModelProvider:a,defaultModelId:l,onModelUpdate:ie})]})]})})})}const HGr=()=>{const{toolId:e,agentId:t}=mr();return o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(FUr,{toolId:e,agentId:t})})},ZGr=()=>{const{toolId:e}=mr();return o.jsx("div",{className:"h-full w-full overflow-y-hidden",children:o.jsx(KQr,{toolId:e})})};function WGr(){const{traceId:e}=mr(),[t,n]=Pi(),r=Xs(),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:S,isLoading:w,error:O}=dSe(e),_=y.useMemo(()=>S?.spans??[],[S?.spans]),C=y.useMemo(()=>_.find(ie=>ie.parentSpanId==null),[_]),{data:E,isLoading:T}=QD(e,c??"");y.useEffect(()=>g(0),[e,c]);const{data:N,isLoading:I}=Dp(),{data:R,isLoading:$}=m3t({traceId:e,spanId:c??void 0,page:m}),[B,M]=y.useState(0);y.useEffect(()=>M(0),[e,c]);const{data:F,isLoading:V}=X3t({traceId:e,page:B});y.useEffect(()=>{if(l&&R?.scores&&!d){const ie=R.scores.find(ce=>ce.id===l);ie&&f(ie)}},[l,R?.scores,d]);const L=y.useCallback(ie=>{const ce=new URLSearchParams(t);for(const[Y,ne]of Object.entries(ie))ne===null||ne===""?ce.delete(Y):ce.set(Y,ne);n(ce,{replace:!0})},[t,n]),z=y.useCallback(ie=>{const ce=ie??null,Y=ce===c;u(ce),Y||(f(void 0),h("details"),L({spanId:ce,tab:null,scoreId:null}))},[c,L]),U=y.useCallback(()=>{u(null),f(void 0),h("details"),L({spanId:null,tab:null,scoreId:null})},[L]),D=y.useCallback(ie=>{u(ie),f(void 0),h("details"),L({spanId:ie,tab:null,scoreId:null})},[L]),{handlePreviousSpan:G,handleNextSpan:q}=gSe(_,c,D),P=y.useCallback(ie=>{const ce=ie;h(ce),f(void 0),L({tab:ce==="details"?null:ce,scoreId:null})},[L]),H=y.useCallback(ie=>{f(ie),L({scoreId:ie.id})},[L]),W=y.useCallback(()=>{f(void 0),L({scoreId:null})},[L]),X=y.useCallback(()=>{r("/observability")},[r]),ae=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(my,{owner:"trace-detail",children:o.jsxs(Rr,{children:[o.jsxs(fe,{tooltip:"Evaluate Trace","aria-label":"Evaluate Trace",onClick:ae,children:[o.jsx(jsn,{}),"Evaluate"]}),o.jsxs(fe,{tooltip:"Save as Dataset Item","aria-label":"Save as Dataset Item",onClick:()=>b(!0),children:[o.jsx(nd,{}),"Save"]})]})}):null,J=C?o.jsx(Ft.Row,{children:o.jsx(Ft.Column,{children:o.jsx(K_t,{rootSpan:C,numOfCol:3})})}):null;return O?o.jsxs(Ft,{height:"full",children:[ee,J&&o.jsx(Ft.TopArea,{children:J}),o.jsx(Ft.MainArea,{isCentered:!0,children:o.jsx(tCt,{error:O,resource:"traces",errorTitle:"Failed to load trace"})})]}):o.jsxs(Ft,{children:[ee,J&&o.jsx(Ft.TopArea,{children:J}),o.jsx(Z3t,{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(cSe,{traceId:e,spans:_,isLoading:w,onClose:X,onSpanSelect:z,onEvaluateTrace:ae,initialSpanId:c,placement:"trace-page",timelineChartWidth:c?"default":"wide"}),c&&!w&&o.jsxs("div",{className:K("grid gap-4 max-h-full min-h-0 overflow-auto",d?"grid-rows-[1fr_1fr]":"grid-rows-[1fr]"),children:[o.jsx(uSe,{traceId:e,spanId:c,span:E?.span,isLoading:T,onClose:U,onPrevious:G,onNext:q,activeTab:p,onTabChange:P,feedbackTabBadge:F?.pagination?.total??void 0,feedbackTabSlot:()=>o.jsx(Q3t,{feedbackData:F,onPageChange:M,isLoadingFeedbackData:V}),scoringTabBadge:R?.pagination?.total??void 0,scoringTabSlot:({span:ie,traceId:ce,spanId:Y})=>o.jsxs("div",{className:"grid gap-6",children:[o.jsx(Y3t,{traceId:ce,isTopLevelSpan:!ie.parentSpanId,spanId:Y,entityType:ie.attributes?.agentId||ie.entityType===zs.AGENT?"Agent":ie.attributes?.workflowId||ie.entityType===zs.WORKFLOW_RUN?"Workflow":void 0,scorers:N,isLoadingScorers:I}),o.jsx(G3t,{scoresData:R,onPageChange:g,isLoadingScoresData:$,onScoreSelect:H})]})}),d&&o.jsx(DCe,{score:d,onClose:W})]})]})]})}function QGr(){const{data:e,isLoading:t,error:n}=wy(),[r,s]=y.useState("");return n&&is(n)?o.jsx(ar,{children:o.jsx(Ms,{})}):n&&ls(n)?o.jsx(ar,{children:o.jsx(Ss,{resource:"workflows"})}):n?o.jsx(ar,{children:o.jsx(Ii,{title:"Failed to load workflows",message:n.message})}):Object.keys(e||{}).length===0&&!t?o.jsx(ar,{children:o.jsx(ODr,{})}):o.jsxs(Ft,{children:[o.jsx(Ft.TopArea,{children:o.jsxs(Ft.Row,{align:"center",stack:"responsive",children:[o.jsx("div",{className:"max-w-120 flex-1",children:o.jsx(vf,{onSearch:s,label:"Filter workflows",placeholder:"Filter by name or description"})}),o.jsxs(fe,{as:li,to:"/workflows/schedules",variant:"primary",className:"shrink-0",children:[o.jsx(SM,{}),"Schedules"]})]})}),o.jsx(kDr,{workflows:e||{},isLoading:t,search:r})]})}const GGr={active:"bg-accent1",paused:"bg-accent3"},YGr={active:"text-accent1",paused:"text-accent3"},l5t=({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 ${GGr[e]}`,"aria-hidden":!0}),o.jsx("span",{className:`text-ui-sm ${YGr[e]}`,children:e})]}),gj=e=>!e||e<=0?"—":new Date(e).toLocaleString(),y2=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 c5t({status:e}){const{icon:t,color:n}=XGr(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 XGr(e){switch(e){case"success":return{icon:o.jsx(da,{size:14}),color:"text-accent1"};case"failed":return{icon:o.jsx(ys,{size:14}),color:"text-accent2"};case"running":return{icon:o.jsx(Wt,{}),color:"text-neutral3"};case"suspended":return{icon:o.jsx(Kge,{size:14}),color:"text-accent3"};case"canceled":return{icon:o.jsx(cf,{size:14}),color:"text-neutral3"};case"pending":case"waiting":return{icon:o.jsx(UO,{size:14}),color:"text-neutral3"};default:return{icon:null,color:"text-neutral3"}}}const LZe="auto auto auto auto 1fr";function KGr(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 JGr(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 eYr=3e4,tYr=5*6e4;function nYr({triggers:e,isLoading:t,workflowId:n,hasNextPage:r,isFetchingNextPage:s,setEndOfListElement:a}){const{Link:i,paths:l}=vn();return t?o.jsx(zo,{columns:LZe}):e.length===0?o.jsx(ge,{variant:"ui-md",className:"text-neutral4 p-4",children:"No trigger history yet."}):o.jsxs(we,{columns:LZe,className:"min-w-0",children:[o.jsxs(we.Top,{children:[o.jsx(we.TopCell,{children:"Run"}),o.jsx(we.TopCell,{children:"Status"}),o.jsx(we.TopCell,{children:"Started"}),o.jsx(we.TopCell,{children:"Duration"}),o.jsx(we.TopCell,{children:" "})]}),e.map(c=>{const u=c.actualFireAt-c.scheduledFireAt,d=JGr(u),f=`Scheduled ${gj(c.scheduledFireAt)} — published ${gj(c.actualFireAt)} (drift ${d})`,p=c.outcome==="failed",h=p?c.error:c.run?.error,m=Math.abs(u),g=!p&&m>eYr&&m<=tYr,v=`${c.scheduleId}-${c.runId}-${c.actualFireAt}`,b=!!(n&&c.runId&&!p),S=o.jsx("span",{className:b?"text-accent1 font-mono text-ui-sm whitespace-nowrap":"text-neutral3 font-mono text-ui-sm whitespace-nowrap",children:c.runId}),w=o.jsxs(o.Fragment,{children:[o.jsx(we.Cell,{height:"compact",children:S}),o.jsx(we.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(cp,{size:14}),"publish failed"]}):c.run?o.jsx(c5t,{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(Yn,{children:[o.jsx(Hn,{asChild:!0,children:o.jsx("span",{className:"text-accent2 inline-flex",children:o.jsx(cp,{size:14})})}),o.jsx(Zn,{children:h})]}):null]})}),o.jsx(we.Cell,{height:"compact",children:o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx("span",{title:f,children:y2(c.actualFireAt)}),g?o.jsxs(Yn,{children:[o.jsx(Hn,{asChild:!0,children:o.jsx("span",{className:"text-accent3 inline-flex",children:o.jsx(cp,{size:14})})}),o.jsxs(Zn,{children:["Published ",d," after the scheduled fire time"]})]}):null]})}),o.jsx(we.Cell,{height:"compact",children:c.run?o.jsx("span",{children:KGr(c.run.durationMs)}):o.jsx("span",{className:"text-neutral4",children:"—"})}),o.jsx(we.Cell,{height:"compact",children:" "})]});return b?o.jsx(we.RowLink,{to:l.workflowRunLink(n,c.runId),LinkComponent:i,children:w},v):o.jsx(we.RowStatic,{children:w},v)}),o.jsx(we.NextPageLoading,{isLoading:s,hasMore:r,setEndOfListElement:a})]})}const rYr=e=>{const t=Ze();return St({queryKey:["schedule",e],enabled:!!e,queryFn:async()=>{if(!e)throw new Error("scheduleId is required");return t.getSchedule(e)}})},FZe=25,sYr=e=>{const t=Ze(),{inView:n,setRef:r}=b_(),s=O1({queryKey:["schedule-triggers",e],enabled:!!e,initialPageParam:void 0,queryFn:async({pageParam:u})=>e?t.listScheduleTriggers(e,{limit:FZe,toActualFireAt:u}):{triggers:[]},getNextPageParam:u=>{if(!(!u?.triggers?.length||u.triggers.length<FZe))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}},aYr=e=>{const t=Ze(),n=zr();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 s8({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 iYr(){const{scheduleId:e}=mr(),{paths:t}=vn(),{data:n,error:r}=rYr(e),{data:s,isLoading:a,error:i,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u}=sYr(e),d=aYr(e);if(r&&is(r))return o.jsx(ar,{children:o.jsx(Ms,{})});if(r&&ls(r))return o.jsx(ar,{children:o.jsx(Ss,{resource:"schedules"})});if(r)return o.jsx(ar,{children:o.jsx(Ii,{title:"Failed to load schedule",message:r.message})});const f=n?.target.type==="workflow"?n.target.workflowId:void 0;return o.jsxs(Ft,{children:[o.jsx(Ft.TopArea,{children:o.jsx(Ft.Row,{className:"justify-end",children:o.jsxs(Ft.Column,{className:"flex justify-end gap-2",children:[o.jsxs(fe,{as:li,to:t.schedulesLink(),variant:"ghost",children:[o.jsx(mc,{}),"Back to schedules"]}),f?o.jsx(fe,{as:li,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(sve,{}),"Pause"]}):o.jsxs(o.Fragment,{children:[o.jsx(Bk,{}),"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(s8,{label:"Workflow",children:f?o.jsx(li,{to:t.workflowLink(f),className:"text-accent1 hover:underline",children:f}):"—"}),o.jsxs(s8,{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(s8,{label:"Status",children:o.jsx(l5t,{status:n.status})}),o.jsx(s8,{label:"Next fire",children:o.jsx("span",{title:gj(n.nextFireAt),children:y2(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(Ii,{title:"Failed to load trigger history",message:i.message}):o.jsx(nYr,{triggers:s??[],isLoading:a,workflowId:f,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u})]})]}):null]})}const zZe="minmax(0, 1.2fr) minmax(0, 1.4fr) minmax(0, 1fr) auto auto auto";function oYr({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(zo,{columns:zZe}):o.jsxs(we,{columns:zZe,className:"min-w-0",children:[o.jsxs(we.Top,{children:[o.jsx(we.TopCell,{children:"Workflow"}),o.jsx(we.TopCell,{children:"Schedule ID"}),o.jsx(we.TopCell,{children:"Cron"}),o.jsx(we.TopCell,{children:"Status"}),o.jsx(we.TopCell,{children:"Next fire"}),o.jsx(we.TopCell,{children:"Last run"})]}),a.length===0&&n?o.jsx(we.NoMatch,{message:"No schedules match your search"}):null,a.length===0&&!n?o.jsx(we.NoMatch,{message:"No schedules configured"}):null,a.map(i=>o.jsxs(we.RowLink,{to:r.scheduleLink(i.id),LinkComponent:s,children:[o.jsx(we.NameCell,{children:i.target.workflowId}),o.jsx(we.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(we.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(we.Cell,{height:"compact",children:o.jsx(l5t,{status:i.status})}),o.jsx(we.Cell,{height:"compact",children:o.jsx("span",{className:"whitespace-nowrap",title:gj(i.nextFireAt),children:y2(i.nextFireAt)})}),o.jsx(we.Cell,{height:"compact",children:i.lastRun?o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx(c5t,{status:i.lastRun.status}),o.jsx("span",{className:"text-neutral4 text-ui-sm",title:gj(i.lastFireAt),children:i.lastFireAt?y2(i.lastFireAt):""})]}):i.lastFireAt?o.jsx("span",{className:"whitespace-nowrap",title:gj(i.lastFireAt),children:y2(i.lastFireAt)}):o.jsx("span",{className:"text-neutral4",children:"Never"})})]},i.id))]})}function lYr({workflowId:e}={}){const{data:t,isLoading:n,error:r}=xSe(e?{workflowId:e}:{}),[s,a]=y.useState("");return r?o.jsx(Ii,{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(vf,{onSearch:a,label:"Filter schedules",placeholder:"Filter by id or workflow"})}),o.jsx("div",{className:"overflow-y-auto",children:o.jsx(oYr,{schedules:t??[],isLoading:n,search:s})})]})}function cYr(){const[e]=Pi(),t=e.get("workflowId")??void 0,{error:n}=xSe(t?{workflowId:t}:{});return n&&is(n)?o.jsx(ar,{children:o.jsx(Ms,{})}):n&&ls(n)?o.jsx(ar,{children:o.jsx(Ss,{resource:"schedules"})}):o.jsx(Ft,{children:o.jsx("div",{className:"h-full",children:o.jsx(lYr,{workflowId:t})})})}const BZe=()=>{const{workflowId:e}=mr(),{data:t,isLoading:n,error:r}=YD(e);return r&&is(r)?o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})}):r&&ls(r)?o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ss,{resource:"workflows"})}):o.jsx(iRt,{workflowId:e,workflow:t??void 0,isLoading:n})};function uYr(e,t){if(e==null)return{};var n,r,s=Nft(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 Qme(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 dYr(e){if(Array.isArray(e))return Qme(e)}function fYr(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function pYr(e,t){if(e){if(typeof e=="string")return Qme(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)?Qme(e,t):void 0}}function hYr(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
767
+ ]`})]})]})}function SWr({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(Qe,{children:o.jsx(cp,{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 kWr({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}=bZr(),{batchInsertItems:b}=Ai(),S=y.useCallback(async I=>{try{const R=await m(I);l(R),a("preview")}catch{}},[m]),w=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(R=>({input:R.input,groundTruth:R.groundTruth,metadata:R.metadata}))}),f({success:I.length,errors:0})}catch{f({success:0,errors:I.length})}u({current:I.length,total:I.length}),h(!1),a("complete")},[i,b,e]),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,E=()=>{switch(s){case"upload":return o.jsx(wWr,{onFileSelect:S,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(SWr,{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(xWr,{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(Wt,{}),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":"",")"]})]})]})]})}},T=()=>{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:w,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(kr,{open:t,onOpenChange:_,children:o.jsxs(yr,{className:"max-w-2xl max-h-[90vh]",children:[o.jsxs(br,{children:[o.jsx(hr,{children:N[s]}),o.jsx(Ns,{children:"Import dataset items from a JSON file."})]}),o.jsx(Ar,{className:"min-h-[200px] max-h-[50vh] overflow-y-auto",children:E()}),o.jsx(cc,{className:"px-6 pt-4 flex justify-end gap-2",children:T()})]})})}const XCe=e=>{const t=Ze(),{data:n}=cM(e),r=n?.experiments;return St({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})},OWr=e=>{const t=Ze(),{data:n}=cM(e),r=n?.experiments;return St({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 _Wr(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 t5t({datasetId:e,experimentId:t,featuredItemId:n}){const r=Ze(),{data:s}=Nx(e),{data:a,isLoading:i}=XCe(e),{data:l,isLoading:c}=OWr(e),u=y.useMemo(()=>t?(a??[]).filter(Oe=>Oe.experimentId===t):a,[a,t]),d=y.useMemo(()=>t?(l??[]).filter(Oe=>Oe.experimentId===t):l,[l,t]),{updateExperimentResult:f}=Ai(),[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),[S,w]=y.useState(!1),[O,_]=y.useState(!1),[C,E]=y.useState(!1),[T,N]=y.useState(""),[I,R]=y.useState(""),[$,B]=y.useState(""),[M,F]=y.useState([]),[V,L]=y.useState(!1),[z,U]=y.useState(null),D=y.useMemo(()=>z??u??[],[z,u]);y.useEffect(()=>{U(null)},[e,t]),y.useEffect(()=>{u&&z===null&&U(u)},[u,z]);const G=y.useMemo(()=>{const Oe=new Set;if(s?.tags)for(const _e of s.tags)Oe.add(_e);for(const _e of D)for(const Ee of _e.tags)Oe.add(Ee);return[...Oe].sort()},[s,D]),q=y.useCallback(Oe=>{!s||!e||(s.tags??[]).includes(Oe)},[s,e]),P=y.useMemo(()=>m?m==="__untagged__"?D.filter(Oe=>Oe.tags.length===0):D.filter(Oe=>Oe.tags.includes(m)):D,[D,m]),H=y.useMemo(()=>{const Oe=new Map;for(const _e of D)for(const Ee of _e.tags)Oe.set(Ee,(Oe.get(Ee)??0)+1);return[...Oe.entries()].sort((_e,Ee)=>Ee[1]-_e[1])},[D]),W=y.useMemo(()=>D.filter(Oe=>Oe.tags.length===0).length,[D]),X=y.useMemo(()=>{let Oe=0;return m&&Oe++,S&&Oe++,Oe},[m,S]),ae=y.useCallback((Oe,_e)=>{U(je=>(je??[]).map($e=>$e.id===Oe?{...$e,tags:_e}:$e));const Ee=D.find(je=>je.id===Oe);Ee?.experimentId&&Ee?.datasetId&&f.mutate({datasetId:Ee.datasetId,experimentId:Ee.experimentId,resultId:Ee.id,tags:_e})},[D,f]),ee=y.useCallback((Oe,_e)=>{const Ee=D.find(je=>je.id===Oe);Ee?.traceId&&_e!==void 0&&r.createFeedback({feedback:{traceId:Ee.traceId,source:"studio",feedbackSource:"studio",feedbackType:"rating",value:_e==="positive"?1:-1,experimentId:Ee.experimentId??void 0,sourceId:Ee.id}}).catch(()=>{}),U(je=>(je??[]).map($e=>$e.id===Oe?{...$e,rating:_e}:$e))},[D,r]),J=y.useCallback((Oe,_e)=>{const Ee=D.find(je=>je.id===Oe);Ee?.traceId&&r.createFeedback({feedback:{traceId:Ee.traceId,source:"studio",feedbackSource:"studio",feedbackType:"comment",value:_e,comment:_e,experimentId:Ee.experimentId??void 0,sourceId:Ee.id}}).catch(()=>{}),U(je=>(je??[]).map($e=>$e.id===Oe?{...$e,comment:_e}:$e))},[D,r]),ie=y.useCallback(Oe=>{const _e=D.find(Ee=>Ee.id===Oe);U(Ee=>(Ee??[]).filter(je=>je.id!==Oe)),b(Ee=>{const je=new Set(Ee);return je.delete(Oe),je}),p===Oe&&h(null),_e?.experimentId&&_e?.datasetId&&f.mutate({datasetId:_e.datasetId,experimentId:_e.experimentId,resultId:_e.id,status:null})},[D,f,p]),ce=y.useCallback(Oe=>{const _e=D.find(Ee=>Ee.id===Oe);U(Ee=>(Ee??[]).filter(je=>je.id!==Oe)),b(Ee=>{const je=new Set(Ee);return je.delete(Oe),je}),p===Oe&&h(null),_e?.experimentId&&_e?.datasetId&&f.mutate({datasetId:_e.datasetId,experimentId:_e.experimentId,resultId:_e.id,status:"complete"})},[D,f,p]),Y=y.useMemo(()=>{const Oe=S?d??[]:P;return!S||!m?Oe:m==="__untagged__"?Oe.filter(_e=>_e.tags.length===0):Oe.filter(_e=>_e.tags.includes(m))},[S,d,P,m]),ne=S?c:!1,ue=y.useMemo(()=>new Set(Y.map(Oe=>Oe.id)),[Y]),pe=y.useMemo(()=>[...v].filter(Oe=>ue.has(Oe)).length,[v,ue]),re=Y.length>0&&pe===Y.length,he=pe>0&&!re,xe=y.useCallback(Oe=>{b(_e=>{const Ee=new Set(_e);return Ee.has(Oe)?Ee.delete(Oe):Ee.add(Oe),Ee})},[]),be=y.useCallback(()=>{b(re?new Set:new Set(Y.map(Oe=>Oe.id)))},[re,Y]),Ie=y.useCallback(Oe=>{for(const _e of v){const Ee=D.find(je=>je.id===_e);Ee&&!Ee.tags.includes(Oe)&&ae(_e,[...Ee.tags,Oe])}},[D,v,ae]),ke=y.useCallback(Oe=>{for(const _e of v){const Ee=D.find(je=>je.id===_e);Ee&&Ee.tags.includes(Oe)&&ae(_e,Ee.tags.filter(je=>je!==Oe))}},[D,v,ae]),Te=y.useCallback(()=>{for(const Oe of v)ce(Oe);b(new Set)},[v,ce]),Le=y.useCallback(()=>{for(const Oe of v)ie(Oe);b(new Set)},[v,ie]),le=y.useCallback(()=>{N(""),E(!0)},[]),se=y.useCallback(async()=>{if(!(!I||!$)){_(!0),E(!1);try{const Oe=D.filter(Ee=>v.has(Ee.id));if(Oe.length===0){_(!1);return}const _e=await r.clusterFailures({modelId:`${I}/${$}`,items:Oe.map(Ee=>({id:Ee.id,input:Ee.input,output:Ee.output??void 0,error:typeof Ee.error=="string"?Ee.error:Ee.error?String(Ee.error):void 0,scores:Ee.scores,existingTags:Ee.tags.length>0?Ee.tags:void 0})),availableTags:G.length>0?G:void 0,prompt:T||void 0});_e.proposedTags&&_e.proposedTags.length>0&&(F(_e.proposedTags.map(Ee=>({...Ee,accepted:!0}))),L(!0))}catch(Oe){console.error("Analysis failed:",Oe)}finally{_(!1)}}},[I,$,D,v,r,G,T]),te=y.useCallback(()=>{for(const Oe of M){if(!Oe.accepted)continue;const _e=D.find(Ee=>Ee.id===Oe.itemId);if(_e){const Ee=[...new Set([..._e.tags,...Oe.tags])];ae(_e.id,Ee)}}L(!1)},[M,D,ae]),me=y.useCallback(Oe=>{h(_e=>_e===Oe?null:Oe)},[]),ye=y.useMemo(()=>p?Y.find(Oe=>Oe.id===p)??null:null,[p,Y]),Ne=p?Y.findIndex(Oe=>Oe.id===p):-1,Re=Ne>0?()=>h(Y[Ne-1].id):void 0,Ge=Ne>=0&&Ne<Y.length-1?()=>h(Y[Ne+1].id):void 0,He="auto minmax(15rem,1fr) 10rem 8rem 6rem 6rem";return i?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Wt,{className:"w-6 h-6"})}):o.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[o.jsx(kr,{open:C,onOpenChange:E,children:o.jsxs(yr,{children:[o.jsxs(br,{children:[o.jsx(hr,{children:"Analyze Items"}),o.jsx(Ns,{children:"Use an LLM to automatically suggest tags for the selected items."})]}),o.jsxs("div",{className:"space-y-4 py-2",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx(Rt,{className:"text-xs mb-1 block",children:"Provider"}),o.jsx(by,{value:I,onValueChange:R})]}),o.jsxs("div",{children:[o.jsx(Rt,{className:"text-xs mb-1 block",children:"Model"}),o.jsx(xy,{llmId:I,value:$,onValueChange:B})]})]}),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(Rt,{className:"text-xs",children:"Instructions (optional)"}),o.jsx(zl,{value:T,onChange:Oe=>N(Oe.target.value),placeholder:"E.g., Focus on safety issues and factual errors...",rows:3,className:"text-xs mt-1"})]})]}),o.jsxs(cc,{children:[o.jsx(fe,{variant:"outline",onClick:()=>E(!1),children:"Cancel"}),o.jsxs(fe,{onClick:se,disabled:!I||!$||O,children:[O?o.jsx(Wt,{className:"w-4 h-4 mr-1"}):null,"Analyze"]})]})]})}),o.jsx(kr,{open:V,onOpenChange:L,children:o.jsxs(yr,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[o.jsxs(br,{children:[o.jsx(hr,{children:"Review Proposed Tags"}),o.jsxs(Ns,{children:[M.filter(Oe=>Oe.accepted).length," of ",M.length," proposals selected"]})]}),o.jsx("div",{className:"space-y-3 py-2",children:M.map((Oe,_e)=>{const Ee=D.find(je=>je.id===Oe.itemId);return o.jsx("div",{className:K("p-3 border rounded-lg",!Oe.accepted&&"opacity-50"),children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(Uo,{checked:Oe.accepted,onCheckedChange:je=>F($e=>$e.map((Fe,Ke)=>Ke===_e?{...Fe,accepted:!!je}:Fe))}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 truncate block",children:Ee?typeof Ee.input=="string"?Ee.input.slice(0,100):JSON.stringify(Ee.input).slice(0,100):Oe.itemId}),o.jsx("div",{className:"flex gap-1 flex-wrap mt-1.5",children:Oe.tags.map((je,$e)=>o.jsx(V3t,{tag:je,onRename:Fe=>F(Ke=>Ke.map((Ye,Pt)=>Pt===_e?{...Ye,tags:Ye.tags.map((_t,an)=>an===$e?Fe:_t)}:Ye)),onRemove:()=>F(Fe=>Fe.map((Ke,Ye)=>Ye===_e?{...Ke,tags:Ke.tags.filter((Pt,_t)=>_t!==$e)}:Ke))},`${je}-${$e}`))}),Oe.reason&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-1 block italic",children:Oe.reason})]})]})},Oe.itemId)})}),o.jsxs(cc,{children:[o.jsx(fe,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),o.jsxs(fe,{onClick:te,disabled:M.filter(Oe=>Oe.accepted).length===0,children:["Accept ",M.filter(Oe=>Oe.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(vt,{children:[o.jsx(vt.Trigger,{asChild:!0,children:o.jsxs(fe,{variant:"outline",size:"md",children:[o.jsx(cat,{}),"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(vt.Content,{align:"start",className:K("min-w-48"),children:[o.jsxs(vt.Sub,{children:[o.jsxs(vt.SubTrigger,{children:["Status",S&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(vt.SubContent,{children:[o.jsx(vt.CheckboxItem,{checked:!S,onCheckedChange:()=>{w(!1),h(null)},onSelect:Oe=>Oe.preventDefault(),children:"Review Queue"}),o.jsx(vt.CheckboxItem,{checked:S,onCheckedChange:()=>{w(!0),h(null)},onSelect:Oe=>Oe.preventDefault(),children:"Completed"})]})]}),o.jsxs(vt.Sub,{children:[o.jsxs(vt.SubTrigger,{children:["Tags",m&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(vt.SubContent,{children:[o.jsx(vt.CheckboxItem,{checked:!m,onCheckedChange:()=>g(null),onSelect:Oe=>Oe.preventDefault(),children:"All"}),W>0&&o.jsx(vt.CheckboxItem,{checked:m==="__untagged__",onCheckedChange:()=>g(m==="__untagged__"?null:"__untagged__"),onSelect:Oe=>Oe.preventDefault(),children:"Untagged"}),H.length>0&&o.jsx(vt.Separator,{}),H.map(([Oe])=>o.jsx(vt.CheckboxItem,{checked:m===Oe,onCheckedChange:()=>g(m===Oe?null:Oe),onSelect:_e=>_e.preventDefault(),children:Oe},Oe))]})]}),X>0&&o.jsxs(o.Fragment,{children:[o.jsx(vt.Separator,{}),o.jsxs(vt.Item,{onSelect:()=>{g(null),w(!1),h(null)},children:[o.jsx(ys,{}),"Clear all filters"]})]})]})]}),X>0&&o.jsxs(fe,{variant:"outline",size:"md",onClick:()=>{g(null),w(!1),h(null)},children:[o.jsx(ys,{}),"Reset"]})]}),!S&&v.size>0&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(q3t,{selectedCount:v.size,vocabulary:G,onApplyTag:Ie,onRemoveTag:ke,onNewTag:Oe=>Ie(Oe)}),o.jsxs(vt,{children:[o.jsx(vt.Trigger,{asChild:!0,children:o.jsxs(fe,{disabled:O,children:[O?o.jsx(Wt,{className:"w-4 h-4"}):o.jsx(Qe,{size:"sm",children:o.jsx(Hs,{})}),"Actions"]})}),o.jsxs(vt.Content,{align:"end",children:[o.jsxs(vt.Item,{onSelect:Te,children:[o.jsx(Qe,{size:"sm",children:o.jsx(Fk,{})}),"Complete"]}),o.jsxs(vt.Item,{onSelect:Le,children:[o.jsx(Qe,{size:"sm",children:o.jsx(Zc,{})}),"Remove"]}),o.jsx(vt.Separator,{}),o.jsxs(vt.Item,{onSelect:le,children:[o.jsx(Qe,{size:"sm",children:o.jsx(eg,{})}),"Analyze"]})]})]})]})]}),ne?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Wt,{className:"w-6 h-6"})}):Y.length===0?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsxs("div",{className:"text-center px-8",children:[o.jsx(ge,{variant:"ui-sm",className:"text-neutral3 block",children:S?"No completed reviews yet":"No items to review"}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-2 block",children:S?"Items marked as complete will appear here for auditing.":"When experiment results are flagged for review, they will appear here."})]})}):o.jsxs(we,{columns:He,className:"min-w-0",children:[o.jsxs(we.Top,{hasLeadingCell:!0,children:[S?o.jsx(we.TopCell,{children:" "}):o.jsx(we.TopSelectCell,{checked:re?!0:he?"indeterminate":!1,onToggle:()=>be(),"aria-label":"Select all"}),o.jsxs(we.TopCells,{colStart:2,children:[o.jsx(we.TopCell,{children:"Input"}),o.jsx(we.TopCell,{children:"Comment"}),o.jsx(we.TopCell,{children:"Tags"}),o.jsx(we.TopCell,{children:"Rating"}),o.jsx(we.TopCell,{children:"Scores"})]})]}),Y.map(Oe=>{const _e=Oe.scores?Object.entries(Oe.scores):[],Ee=p===Oe.id,je=o.jsxs(o.Fragment,{children:[o.jsx(we.Cell,{height:"compact",className:"min-w-0 text-neutral4",children:o.jsx("span",{className:"block truncate",children:_Wr(Oe.input,200)})}),o.jsx(we.Cell,{height:"compact",className:"min-w-0",children:Oe.comment?o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 truncate",children:Oe.comment}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsx(we.Cell,{height:"compact",className:"min-w-0",children:Oe.tags.length>0?o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 truncate",children:Oe.tags.join(", ")}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsxs(we.Cell,{height:"compact",children:[Oe.rating==="positive"&&o.jsx(Qe,{size:"sm",className:"text-positive1",children:o.jsx(ove,{})}),Oe.rating==="negative"&&o.jsx(Qe,{size:"sm",className:"text-negative1",children:o.jsx(ive,{})}),!Oe.rating&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})]}),o.jsx(we.Cell,{height:"compact",children:_e.length>0?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(Qe,{size:"sm",className:"text-neutral3",children:o.jsx(Jm,{})}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 font-mono",children:_e[0][1].toFixed(2)}),_e.length>1&&o.jsxs(zt,{variant:"default",children:["+",_e.length-1]})]}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})})]});return o.jsxs(we.RowWrapper,{children:[S?o.jsx(we.Cell,{height:"compact",className:"justify-items-center px-4",children:o.jsx("div",{role:"img","aria-label":Oe.error?"Error":"Success",title:Oe.error?"Error":"Success",className:K("w-2 h-2 rounded-full",Oe.error?"bg-red-700":"bg-green-600")})}):o.jsx(we.SelectCell,{checked:v.has(Oe.id),onToggle:()=>xe(Oe.id),"aria-label":`Select item ${Oe.id}`}),o.jsx(we.RowButton,{flushLeft:!0,colStart:2,featured:Ee,onClick:()=>me(Oe.id),children:je})]},Oe.id)})]})]}),ye&&o.jsx(U3t,{item:ye,isCompleted:S,tagVocabulary:G,onRate:Oe=>ee(ye.id,Oe),onSetTags:Oe=>{ae(ye.id,Oe);for(const _e of Oe)G.includes(_e)||q(_e)},onComment:Oe=>J(ye.id,Oe),onRemove:()=>ie(ye.id),onComplete:S?void 0:()=>ce(ye.id),onPrevious:Re,onNext:Ge,onClose:()=>h(null)})]})]})}function CWr({datasetId:e,onAddItemClick:t,onNavigateToDataset:n}){const{navigate:r}=vn(),[s,a]=Pi(),{tab:i,activeVersion:l,handleTabChange:c}=YCe(s,a),[u,d]=y.useState(!1),[f,p]=y.useState(!1),[h,m]=y.useState(!1),[g,v]=y.useState([]),[b,S]=y.useState(!1),[w,O]=y.useState([]),[_,C]=y.useState(!1),[E,T]=y.useState([]),[N,I]=y.useState(0),[R,$]=y.useState(null),[B,M]=y.useState(""),[F]=Lxe(B,300),{data:V}=Nx(e),{data:L=[],total:z,isLoading:U,setEndOfListElement:D,isFetchingNextPage:G,hasNextPage:q}=DO(e,F||void 0,l),{total:P}=DO(e,void 0,l),[H,W]=y.useState({}),{data:X,isLoading:ae}=cM(e,void 0,H),{data:ee}=cM(e),{deleteItems:J}=Ai(),ie=X?.experiments??[],ce=ee?.experiments??[],Y=ZZr({hasSearchQuery:!!F,filteredItemsLength:L.length,unfilteredItemsTotal:P,itemsTotal:z}),{data:ne}=XCe(e),ue=ne?.length??0,pe=te=>{$(te)},re=()=>{$(null)},he=te=>{v(te),m(!0)},xe=te=>{O(te),S(!0)},be=te=>{S(te),te||(O([]),I(me=>me+1))},Ie=te=>{r(`/datasets/${e}/items?items=${te.join(",")}`)},ke=te=>{r(`/datasets/${e}/versions?ids=${te.join(",")}`)},Te=te=>{T(te),C(!0)},Le=async()=>{await J.mutateAsync({datasetId:e,itemIds:E}),Be.success(`Deleted ${E.length} items`),C(!1),T([]),I(te=>te+1)},le=te=>{m(!1),v([]),I(me=>me+1),n?.(te)},se=te=>{m(te),te||(v([]),I(me=>me+1))};return o.jsxs(o.Fragment,{children:[o.jsxs(gc,{defaultTab:"items",value:i,onValueChange:c,className:"grid grid-rows-[auto_1fr] h-full",children:[o.jsxs(vc,{children:[o.jsxs(Er,{value:"items",children:["Items ",o.jsx(Qs,{color:"gray",children:Y})]}),o.jsxs(Er,{value:"experiments",children:["Experiments",o.jsx(Qs,{color:"gray",children:ie.length})]}),o.jsxs(Er,{value:"review",children:["Review",ue>0&&o.jsx(Qs,{color:"orange",children:ue})]})]}),o.jsx(qr,{value:"items",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(bWr,{datasetId:e,items:L,isLoading:U,featuredItemId:R,onItemSelect:pe,onItemClose:re,onAddClick:t??(()=>{}),onImportClick:()=>d(!0),onImportJsonClick:()=>p(!0),onBulkDeleteClick:Te,onCreateDatasetClick:he,onAddToDatasetClick:xe,onCompareItemsClick:Ie,datasetName:V?.name,clearSelectionTrigger:N,setEndOfListElement:D,isFetchingNextPage:G,hasNextPage:q,searchQuery:B,activeSearchQuery:F,onSearchChange:M,currentDatasetVersion:V?.version,onCompareVersionsClick:ke})}),o.jsx(qr,{value:"experiments",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(lWr,{experiments:ie,allExperiments:ce,isLoading:ae,datasetId:e,filters:H,onFiltersChange:W})}),o.jsx(qr,{value:"review",className:"overflow-auto mt-2 pb-0",children:o.jsx(t5t,{datasetId:e})})]}),o.jsx(eWr,{datasetId:e,open:u,onOpenChange:d}),o.jsx(kWr,{datasetId:e,open:f,onOpenChange:p}),o.jsx($Zr,{open:h,onOpenChange:se,items:g,onSuccess:le}),o.jsx(MZr,{open:b,onOpenChange:be,items:w,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 ",E.length," item",E.length!==1?"s":"","? This action cannot be undone."]})]}),o.jsxs(jt.Footer,{children:[o.jsx(jt.Cancel,{children:"Cancel"}),o.jsx(jt.Action,{onClick:Le,children:J.isPending?"Deleting...":"Delete"})]})]})})]})}function EWr(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 TZe({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 jWr({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}=Ai(),g=async w=>{w.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 E;if(d.trim())try{E=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:E}),Be.success("Item added successfully"),h(null),a("{}"),l(""),u(""),f(""),n(!1),r?.()}catch(T){const N=EWr(T);N?h(N):Be.error(`Failed to add item: ${T instanceof Error?T.message:"Unknown error"}`)}},v=w=>{a(w),p?.field==="input"&&h(null)},b=w=>{l(w),p?.field==="groundTruth"&&h(null)},S=()=>{a("{}"),l(""),u(""),f(""),h(null),n(!1)};return o.jsx(kr,{open:t,onOpenChange:n,children:o.jsxs(yr,{className:"max-w-lg",children:[o.jsx(br,{children:o.jsx(hr,{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(Rt,{htmlFor:"item-input",children:"Input (JSON) *"}),o.jsx(Gr,{value:s,onChange:v,showCopyButton:!1,className:"min-h-[120px]"}),p?.field==="input"&&o.jsx(TZe,{field:"input",errors:p.errors})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{htmlFor:"item-ground-truth",children:"Ground Truth (JSON, optional)"}),o.jsx(Gr,{value:i,onChange:b,showCopyButton:!1,className:"min-h-[80px]"}),p?.field==="groundTruth"&&o.jsx(TZe,{field:"groundTruth",errors:p.errors})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{htmlFor:"item-trajectory",children:"Expected Trajectory (JSON, optional)"}),o.jsx(Gr,{value:c,onChange:u,showCopyButton:!1,className:"min-h-[80px]"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{htmlFor:"item-request-context",children:"Request Context (JSON, optional)"}),o.jsx(Gr,{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:S,children:"Cancel"}),o.jsx(fe,{type:"submit",variant:"primary",disabled:m.isPending,children:m.isPending?"Adding...":"Add Item"})]})]})})]})})}function TWr({item:e}){return o.jsx(ca,{withMargins:!1,children:o.jsxs(ca.Column,{children:[o.jsxs(ca.Title,{size:"smaller",children:[o.jsx(VT,{}),o.jsx("span",{className:"truncate",children:e.id}),o.jsx(Ia,{content:e.id,tooltip:`Copy item ID: ${e.id}`})]}),o.jsxs(ca.Description,{children:[o.jsxs(ac,{children:[o.jsx(Kst,{})," Created ",Kn(new Date(e.createdAt),"MMM d, yyyy h:mm aaa")]}),e.datasetVersion!=null&&o.jsxs(ac,{children:[o.jsx(qO,{})," Version v",e.datasetVersion]})]})]})})}function KCe({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(Fxe,{children:[o.jsx(va.CodeSection,{title:"Input",icon:o.jsx(zk,{}),codeStr:t}),o.jsx(va.CodeSection,{title:"Ground Truth",icon:o.jsx(Wm,{}),codeStr:n}),s&&o.jsx(va.CodeSection,{title:"Expected Trajectory",icon:o.jsx(Sat,{}),codeStr:s}),o.jsx(va.CodeSection,{title:"Metadata",icon:o.jsx(VO,{}),codeStr:r})]})}function NWr({selectedScorers:e,setSelectedScorers:t,disabled:n=!1,container:r}){const{data:s,isLoading:a}=Dp(),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(Rt,{children:"Scorers (Optional)"}),o.jsx(Hht,{options:i,value:e,onValueChange:t,placeholder:"Select scorers...",searchPlaceholder:"Search scorers...",emptyText:"No scorers available",disabled:n||a,container:r})]})}const IWr=[{value:"agent",label:"Agent"},{value:"workflow",label:"Workflow"},{value:"scorer",label:"Scorer"}];function AWr({targetType:e,setTargetType:t,targetId:n,setTargetId:r,container:s}){const{data:a,isLoading:i}=tm(),{data:l,isLoading:c}=wy(),{data:u,isLoading:d}=Dp(),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(Rt,{children:"Target Type"}),o.jsx(Hc,{options:IWr,value:e,onValueChange:h,placeholder:"Select target type",searchPlaceholder:"Search types...",emptyText:"No types available",container:s})]}),e&&o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Rt,{children:m}),o.jsx(Hc,{options:f,value:n,onValueChange:r,placeholder:`Select ${e}`,searchPlaceholder:"Search...",emptyText:"No targets available",disabled:p,container:s})]})]})}function RWr({requestContextSchema:e,onChange:t}){const n=y.useMemo(()=>{try{return dg(cg(e))}catch(r){return console.error("Failed to parse requestContextSchema:",r),null}},[e]);return n?o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{children:"Request Context"}),o.jsx(zV,{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 PWr({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}=Ai(),S=!!(n&&Object.keys(n).length>0),w=l&&u,O=b.isPending,_=()=>{c(""),d(""),p([]),m({}),v("")},C=()=>{if(S){const N=Object.entries(h).filter(([,I])=>I!==void 0&&I!=="");return N.length>0?Object.fromEntries(N):void 0}if(g.trim()){let N;try{N=JSON.parse(g)}catch{throw new Error("Request Context must be valid JSON")}if(!N||typeof N!="object"||Array.isArray(N))throw new Error("Request Context must be a JSON object");return N}},E=async()=>{if(!w)return;let N;try{N=C()}catch(I){const R=I instanceof Error?I.message:"Request Context must be valid JSON";yu.error(R);return}try{const I=await b.mutateAsync({datasetId:e,targetType:l,targetId:u,scorerIds:f.length>0?f:void 0,version:t,requestContext:N});yu.success("Experiment triggered successfully"),s(!1),a?.(I.experimentId),_()}catch(I){const R=I instanceof Error?I.message:"Failed to trigger experiment";yu.error(R)}},T=()=>{O||(s(!1),_())};return o.jsx(kr,{open:r,onOpenChange:T,children:o.jsxs(yr,{ref:i,children:[o.jsxs(br,{children:[o.jsx(hr,{children:"Run Experiment"}),o.jsx(Ns,{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(AWr,{targetType:l,setTargetType:c,targetId:u,setTargetId:d,container:i}),l&&l!=="scorer"&&o.jsx(NWr,{selectedScorers:f,setSelectedScorers:p,disabled:O,container:i}),S?o.jsx(RWr,{requestContextSchema:n,onChange:m}):o.jsxs("div",{className:"space-y-2",children:[o.jsx(Rt,{children:"Request Context (JSON, optional)"}),o.jsx(Gr,{value:g,onChange:v,showCopyButton:!1,className:"min-h-[80px]"})]})]}),o.jsxs(cc,{className:"px-6 pt-4",children:[o.jsx(fe,{onClick:T,disabled:O,children:"Cancel"}),o.jsx(fe,{variant:"primary",onClick:E,disabled:!w||O,children:O?o.jsxs(o.Fragment,{children:[o.jsx(Wt,{className:"w-4 h-4"}),"Running..."]}):"Run"})]})]})})}const $Wr=e=>{const t=Ze();return St({queryKey:["experiment-trace-light",e],queryFn:async()=>{if(!e)throw new Error("Trace ID is required");return t.getTraceLight(e)},enabled:!!e})};function MWr({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=G6(e?.input),S=G6(e?.output),w=G6(e?.groundTruth),O=u&&e.status!=="needs-review"&&e.status!=="complete",_=Array.isArray(e.tags)?e.tags:[];return o.jsxs(Sn,{collapsed:m,children:[o.jsxs(Sn.Header,{children:[o.jsxs(Sn.Heading,{children:["Result ",o.jsxs("b",{children:["# ",e.id.length>12?`${e.id.slice(0,12)}…`:e.id]})]}),o.jsxs(Rr,{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(nat,{}):o.jsx(tat,{})}),o.jsx(Sn.NextPrevNav,{onPrevious:n,onNext:r,previousLabel:"Previous result",nextLabel:"Next result"}),o.jsxs(fe,{size:"md",onClick:a,disabled:!e.traceId,children:[o.jsx(J1e,{}),"Trace"]}),o.jsx(Sn.CloseButton,{onClick:s,tooltip:"Close result panel"})]})]}),!m&&o.jsxs(Sn.Content,{children:[o.jsxs("div",{className:"grid gap-4 mb-6",children:[o.jsxs(Bt,{children:[o.jsx(Bt.Key,{children:"Item Id"}),o.jsx(Bt.ValueWithCopyBtn,{copyTooltip:"Copy Item Id to clipboard",copyValue:e.itemId,children:e.itemId}),o.jsx(Bt.Key,{children:"Created"}),o.jsx(Bt.Value,{children: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:G6(e?.error&&typeof e.error=="object"?e.error.message:e?.error)})}),t&&t.length>0&&o.jsxs(we,{columns:"1fr 1fr",children:[o.jsxs(we.Top,{children:[o.jsx(we.TopCell,{children:"Scorer"}),o.jsx(we.TopCell,{children:"Score"})]}),t.map(C=>o.jsxs(we.RowButton,{featured:c===C.id,onClick:()=>l?.(C.id),children:[o.jsx(we.Cell,{height:"compact",children:C.scorerId}),o.jsx(we.MonoCell,{children:C.score.toFixed(3)})]},C.id))]}),(e.status||_.length>0||O)&&o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Sn.SectionHeading,{icon:o.jsx(VO,{}),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(DB,{}),"Flag for Review"]})}),e.status==="needs-review"&&i&&o.jsx("div",{children:o.jsxs(fe,{size:"sm",onClick:i,children:[o.jsx(Ca,{}),"Review"]})})]})]}),o.jsxs("div",{className:"grid gap-3",children:[o.jsx(Sn.CodeSection,{title:"Input",icon:o.jsx(VT,{}),codeStr:b}),o.jsx(Sn.CodeSection,{title:"Output",icon:o.jsx(Wm,{}),codeStr:S}),o.jsx(Sn.CodeSection,{title:"Ground Truth",icon:o.jsx(ave,{}),codeStr:w})]})]})]})}function G6(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function DWr({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(zo,{columns:h}):o.jsxs(we,{columns:h,className:"min-w-0",children:[o.jsxs(we.Top,{hasLeadingCell:p,children:[p&&o.jsx(we.TopCell,{children:" "}),p?o.jsx(we.TopCells,{colStart:2,children:s.map(g=>o.jsx(we.TopCell,{children:g.label},g.name))}):s.map(g=>o.jsx(we.TopCell,{children:g.label},g.name))]}),e.length===0?o.jsx(we.NoMatch,{message:"No results yet"}):o.jsxs(o.Fragment,{children:[e.map(g=>{const v=!!g.error,b=g.id===n,S=o.jsxs(o.Fragment,{children:[o.jsx(we.IdCell,{id:g.itemId}),o.jsx(we.Cell,{height:"compact",children:o.jsxs(Yn,{children:[o.jsx(Hn,{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(Zn,{children:v?"Error":"Success"})]})}),m&&o.jsx(we.MonoCell,{children:FWr(LWr(g.input),200)}),i?.map(w=>{const _=a?.[g.itemId]?.find(C=>C.scorerId===w);return o.jsx(we.Cell,{height:"compact",className:"font-mono text-neutral3 text-ui-smd",children:_!=null?_.score.toFixed(3):"-"},w)})]});return p?o.jsxs(we.RowWrapper,{children:[o.jsx(we.SelectCell,{checked:d.has(g.id),onToggle:()=>f(g.id),"aria-label":`Select result ${g.itemId}`}),o.jsx(we.RowButton,{flushLeft:!0,colStart:2,featured:b,onClick:()=>r(g.id),children:S})]},g.id):o.jsx(we.RowButton,{featured:b,onClick:()=>r(g.id),children:S},g.id)}),o.jsx(we.NextPageLoading,{isLoading:c,hasMore:u,setEndOfListElement:l})]})]})}function LWr(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function FWr(e,t){return e.length<=t?e:e.slice(0,t-1)+"..."}function zWr(e){const t=e.scorer;return t?.hasJudge===!1?!0:t?.hasJudge===!0?!1:!e.preprocessPrompt&&!e.analyzePrompt&&!e.generateScorePrompt&&!e.generateReasonPrompt}function BWr({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=zWr(e),p=f?"N/A — code-based scorer":"N/A — step not configured";return o.jsxs(Sn,{collapsed:u,children:[o.jsxs(Sn.Header,{children:[o.jsxs(Sn.Heading,{children:["Score ",o.jsx("b",{children:e.scorerId})]}),o.jsxs(Rr,{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(nat,{}):o.jsx(tat,{})}),(n||t)&&o.jsx(Sn.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(J1e,{}),"Trace"]}),o.jsx(Sn.CloseButton,{onClick:r,tooltip:"Close score panel"})]})]}),!u&&o.jsx(Sn.Content,{children:o.jsxs("div",{className:"grid gap-3",children:[o.jsx(Sn.CodeSection,{title:`Score: ${e.score}`,icon:o.jsx(Jm,{}),codeStr:e.reason||p,simplified:!0}),!f&&o.jsxs(o.Fragment,{children:[o.jsx(Sn.CodeSection,{title:"Preprocess Prompt",icon:o.jsx(th,{}),codeStr:e.preprocessPrompt||p,simplified:!0}),o.jsx(Sn.CodeSection,{title:"Analyze Prompt",icon:o.jsx(th,{}),codeStr:e.analyzePrompt||p,simplified:!0}),o.jsx(Sn.CodeSection,{title:"Generate Score Prompt",icon:o.jsx(th,{}),codeStr:e.generateScorePrompt||p,simplified:!0}),o.jsx(Sn.CodeSection,{title:"Generate Reason Prompt",icon:o.jsx(th,{}),codeStr:e.generateReasonPrompt||p,simplified:!0})]})]})})]})}const NZe=[{name:"scorer",label:"Scorer",size:"1fr"},{name:"avg",label:"Avg Score",size:"1fr"},{name:"count",label:"Items Scored",size:"1fr"}];function UWr({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(Vr,{iconSlot:o.jsx(Jm,{className:"w-8 h-8 text-neutral3"}),titleSlot:a,descriptionSlot:i})})}return o.jsxs(hn,{children:[o.jsxs(hn.Header,{columns:NZe,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:NZe,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 n5t({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),[S,w]=y.useState(!1),[O,_]=y.useState(!1),[C,E]=y.useState(!1),[T,N]=y.useState(!1),{updateExperimentResult:I}=Ai(),R=y.useCallback(se=>{b(te=>{const me=new Set(te);return me.has(se)?me.delete(se):me.add(se),me})},[]),$=y.useCallback(()=>b(new Set),[]),B=y.useCallback(()=>{const se=r.filter(te=>!!te.error).map(te=>te.id);b(new Set(se))},[r]),M=y.useCallback(async se=>{if(S||se.length===0)return;w(!0);let te=0;const me=new Set;try{for(const ye of se)try{await I.mutateAsync({datasetId:t,experimentId:e,resultId:ye,status:"needs-review"}),te++,me.add(ye)}catch{}}finally{w(!1)}me.size>0&&b(ye=>{const Ne=new Set(ye);for(const Re of me)Ne.delete(Re);return Ne}),te>0&&Be(`${te} result${te>1?"s":""} flagged for review`)},[t,e,S,I]),F=r.find(se=>se.id===c)??null,[V,L]=y.useState("summary"),[z,U]=y.useState(null),D=se=>{L(se),se!=="reviews"&&U(null)},{data:G}=XCe(t),q=(G??[]).filter(se=>se.experimentId===e).length,{data:P}=L3t(e,n),H=y.useMemo(()=>{if(!P)return[];const se=new Set;for(const te of Object.values(P))for(const me of te)se.add(me.scorerId);return[...se].sort()},[P]),W=se=>{u(se),f(null),h(void 0),g(null)},X=se=>{W(se===c?null:se)},ae=()=>{W(null)},ee=()=>{if(!F)return;const se=r.findIndex(te=>te.id===F.id);if(se>=0&&se<r.length-1)return()=>W(r[se+1].id)},J=()=>{if(!F)return;const se=r.findIndex(te=>te.id===F.id);if(se>0)return()=>W(r[se-1].id)},ie=F?P?.[F.itemId]:void 0,ce=ie?.find(se=>se.id===m)??null,Y=se=>{g(se===m?null:se),f(null),h(void 0)},ne=()=>{if(!m||!ie)return;const se=ie.findIndex(te=>te.id===m);if(se>=0&&se<ie.length-1)return()=>g(ie[se+1].id)},ue=()=>{if(!m||!ie)return;const se=ie.findIndex(te=>te.id===m);if(se>0)return()=>g(ie[se-1].id)},{data:pe,isLoading:re}=$Wr(d),he=pe?.spans,{data:xe,isLoading:be}=QD(d,p),Ie=xe?.span,{handlePreviousSpan:ke,handleNextSpan:Te}=gSe(he,p??null,h),Le=(()=>{const se=[],te=!!ce,me=!!d;return se.push(O?"auto":te||me?"2fr":"1fr"),te&&se.push(T?"auto":"3fr"),me&&se.push(C?"auto":"3fr"),me&&p&&se.push("3fr"),se.join(" ")})(),le=y.useMemo(()=>[{name:"itemId",label:"Item ID",size:"7rem"},{name:"status",label:"Status",size:"5rem"},{name:"input",label:"Input",size:"minmax(15rem,1fr)"},...H.map(se=>({name:se,label:se,size:"12rem"}))],[H]);return o.jsxs(gc,{defaultTab:"summary",value:V,onValueChange:D,className:"grid grid-rows-[auto_1fr] h-full overflow-hidden",children:[o.jsxs(vc,{children:[o.jsx(Er,{value:"summary",children:"Summary"}),o.jsx(Er,{value:"results",children:"Results"}),o.jsxs(Er,{value:"reviews",children:["Reviews",q>0&&o.jsx(Qs,{color:"orange",children:q})]})]}),o.jsx(qr,{value:"summary",className:"overflow-y-auto mt-5",children:o.jsx(UWr,{scoresByItemId:P,experimentStatus:n})}),o.jsx(qr,{value:"reviews",className:"overflow-auto mt-2 pb-0",children:o.jsx(t5t,{datasetId:t,experimentId:e,featuredItemId:z})}),o.jsxs(qr,{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:S,onClick:()=>M([...v]),children:[o.jsx(Qe,{size:"sm",children:o.jsx(DB,{})}),"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:B,children:"Select loaded failures"})})]}),o.jsxs("div",{className:K("grid w-full h-full grid-cols-1 gap-4 overflow-y-auto",F&&"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(DWr,{results:r,isLoading:s,featuredResultId:c,onResultClick:X,columns:le,scoresByItemId:P,scorerIds:H,setEndOfListElement:a,isFetchingNextPage:i,hasNextPage:l,selectedIds:v,onToggleSelect:R})})}),F&&o.jsxs("div",{className:"grid gap-4 max-h-full min-h-0 overflow-auto content-start",style:{gridTemplateRows:Le},children:[o.jsx(MWr,{result:F,scores:ie,onPrevious:J(),onNext:ee(),onClose:ae,onScoreClick:Y,featuredScoreId:m,onShowTrace:()=>{F.traceId&&(f(F.traceId),h(void 0),g(null),_(!0),E(!1))},onOpenInReview:()=>{U(F.id),L("reviews")},onFlagForReview:se=>M([se]),collapsed:O,onCollapsedChange:_}),ce&&o.jsx(BWr,{score:ce,onNext:ne(),onPrevious:ue(),onClose:()=>g(null),onShowTrace:()=>{ce.traceId&&(f(ce.traceId),h(void 0),_(!0),N(!0),E(!1))},collapsed:T,onCollapsedChange:N}),d&&o.jsxs(o.Fragment,{children:[o.jsx(cSe,{traceId:d,spans:he,isLoading:re,onClose:()=>{f(null),h(void 0),_(!1),N(!1)},onSpanSelect:h,initialSpanId:p??null,placement:"traces-list",showUnavailableFeaturesMsg:!1,collapsed:C,onCollapsedChange:E,LinkComponent:LN,traceHref:`/traces/${d}`}),p&&o.jsx(uSe,{traceId:d,spanId:p,span:Ie,isLoading:be,onPrevious:ke,onNext:Te,onClose:()=>h(void 0)})]})]})]})]})]})}const qWr={pending:o.jsx(UO,{}),running:o.jsx(sue,{}),completed:o.jsx(da,{}),failed:o.jsx(ys,{})};function VWr({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:qWr[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 HWr({onPrevious:e,onNext:t,previousAriaLabel:n="Previous",nextAriaLabel:r="Next"}){return o.jsxs(Rr,{spacing:"close",children:[o.jsxs(fe,{onClick:e,disabled:!e,"aria-label":n,children:[o.jsx($U,{})," Prev"]}),o.jsxs(fe,{onClick:t,disabled:!t,"aria-label":r,children:["Next",o.jsx(RU,{})]})]})}function JCe({delta:e}){const t=e>0?o.jsx(Qs,{size:"small",color:"green",intensity:"muted",children:o.jsx(wM,{})}):e<0?o.jsx(Qs,{size:"small",color:"red",intensity:"muted",children:o.jsx(Brn,{})}):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 Y6(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function ZWr({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(Ur,{withLeftSeparator:!0,children:[o.jsxs(Ur.Toolbar,{children:[o.jsx(HWr,{onPrevious:a,onNext:i,previousAriaLabel:"Previous comparison item",nextAriaLabel:"Next comparison item"}),o.jsx(Rr,{children:o.jsx(fe,{onClick:l,"aria-label":"Close comparison detail panel",children:o.jsx(ys,{})})})]}),o.jsxs(Ur.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(VT,{})," ",e.itemId]})})}),d?o.jsx(o.Fragment,{children:o.jsxs(Fxe,{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(JCe,{delta:v})]})]},h)})})]}),o.jsx(va.CodeSection,{title:o.jsxs(o.Fragment,{children:[o.jsx(Qs,{color:"purple",children:"Baseline "})," Experiment Output"]}),icon:o.jsx(Wm,{}),codeStr:Y6(c?.output)}),o.jsx(va.CodeSection,{title:o.jsxs(o.Fragment,{children:[o.jsx(Qs,{color:"cyan",children:"Contender "})," Experiment Output"]}),icon:o.jsx(Wm,{}),codeStr:Y6(u?.output)}),o.jsx(va.CodeSection,{title:"Item Input",icon:o.jsx(zk,{}),codeStr:Y6(e.input)}),o.jsx(va.CodeSection,{title:"Item Ground Truth",icon:o.jsx(ave,{}),codeStr:Y6(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 WWr({items:e,baselineId:t,contenderId:n,scorerIds:r,featuredItemId:s,columns:a,onItemClick:i}){return o.jsx(Ur,{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(JCe,{delta:m})]}):o.jsx("span",{className:"text-neutral1",children:"-"})},f)})})]})},l.itemId)})})})]})})}const QWr={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 IZe({datasetId:e,experiment:t,type:n}){const{Link:r}=vn(),{label:s,color:a,customStyle:i}=QWr[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(Qs,{size:"small",color:a,children:[s,o.jsx(Zh,{})]}),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(Qs,{size:"small",color:a,children:[o.jsx(mc,{})," ",s]})]}),o.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-ui-sm text-neutral3",children:[o.jsxs(ac,{children:[o.jsx(ave,{})," ",t.targetType," / ",t.targetId]}),o.jsxs(ac,{children:[o.jsx(pat,{})," v",t.datasetVersion??"—"]}),l&&o.jsxs(ac,{children:[o.jsx(Jst,{})," ",Kn(l,"MMM d, yyyy HH:mm")]})]})]})}function GWr({datasetId:e,experimentIdA:t,experimentIdB:n,onSwap:r}){const[s,a]=y.useState(null),{data:i,isLoading:l,error:c}=cZr(e,t,n),{data:u}=yB(e,t),{data:d}=yB(e,n),f=u&&d&&u.datasetVersion!==d.datasetVersion,p=y.useMemo(()=>{if(!i)return[];const E=new Set;for(const T of i.items)for(const N of Object.values(T.results))if(N)for(const I of Object.keys(N.scores))E.add(I);return[...E].sort()},[i]),h=y.useMemo(()=>{if(!i||p.length===0)return[];const E=i.baselineId,T=t===E?n:t;return p.map(N=>{let I=0,R=0,$=0,B=0;for(const L of i.items){const z=L.results[E]?.scores[N],U=L.results[T]?.scores[N];z!=null&&(I+=z,$++),U!=null&&(R+=U,B++)}const M=$>0?I/$:null,F=B>0?R/B:null,V=M!=null&&F!=null?F-M:null;return{scorerId:N,avgA:M,avgB:F,delta:V}})},[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(E=>({name:E,label:E,size:"1fr"}))],[p,s]),v=i?.items.find(E=>E.itemId===s)??null,b=E=>{a(E===s?null:E)},S=()=>{a(null)},w=()=>{if(!i||!s)return;const E=i.items.findIndex(T=>T.itemId===s);if(E>=0&&E<i.items.length-1)return()=>a(i.items[E+1].itemId)},O=()=>{if(!i||!s)return;const E=i.items.findIndex(T=>T.itemId===s);if(E>0)return()=>a(i.items[E-1].itemId)};if(l)return o.jsx("div",{className:"flex items-center justify-center h-64",children:o.jsx(Wt,{})});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(IZe,{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(Yn,{children:[o.jsx(Hn,{asChild:!0,children:o.jsx(fe,{onClick:r,children:"VS"})}),o.jsx(Zn,{children:"Switch the order"})]})})}),o.jsx(IZe,{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(CLe,{children:[o.jsx(Qs,{color:"purple",size:"small",intensity:"muted",children:"Baseline"}),o.jsx(Qs,{color:"purple",size:"small",children:"Avg"})]})}),o.jsx(hn.HeaderCol,{className:"flex justify-center",children:o.jsxs(CLe,{children:[o.jsx(Qs,{color:"cyan",size:"small",intensity:"muted",children:"Contender"}),o.jsx(Qs,{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:E,avgA:T,avgB:N,delta:I})=>o.jsxs(hn.Row,{columns:m,children:[o.jsx(hn.TextCell,{children:E}),o.jsx(hn.TextCell,{className:"text-center font-mono",children:T!=null?T.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(JCe,{delta:I}):"-"})]},E))})})]}),o.jsxs(Nv,{className:K({"grid-cols-[1fr_2fr]":!!v}),children:[o.jsx(WWr,{items:i.items,baselineId:_,contenderId:C,scorerIds:p,featuredItemId:s,columns:g,onItemClick:b}),!!v&&o.jsx(ZWr,{item:v,baselineId:_,contenderId:C,baselineVersion:u?.datasetVersion,contenderVersion:d?.datasetVersion,onPrevious:O(),onNext:w(),onClose:S})]})]})}function YWr({datasetId:e,itemId:t,onVersionSelect:n,onCompareVersionsClick:r,activeVersion:s}){const{data:a,isLoading:i}=GCe(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(S=>{const w=new Set(S);if(w.has(b))w.delete(b);else if(w.size>=2){const[O]=Array.from(w);return new Set([O,b])}else w.add(b);return w})},m=()=>{c(!1),d(new Set)},g=()=>{c(!0)},v=()=>{u.size===2&&r?.([...u])};return o.jsxs(Ur,{className:"min-w-56",children:[l?o.jsx(Ur.Toolbar,{className:"grid justify-stretch gap-3 w-full",children:o.jsxs(Rr,{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(Ur.Toolbar,{children:o.jsxs(fe,{onClick:g,className:"w-full",children:[o.jsx(Rw,{})," Compare Ver."]})})}),i?o.jsx(XWr,{}):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 S=String(b.datasetVersion),w=typeof b.updatedAt=="string"?new Date(b.updatedAt):b.updatedAt;return o.jsxs(hn.Row,{isSelected:l&&u.has(S),children:[l&&o.jsx(hn.LabelCell,{children:o.jsx(Uo,{checked:u.has(S),disabled:b.isDeleted,onCheckedChange:()=>{},onClick:O=>{O.stopPropagation(),b.isDeleted||h(S)},"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:w,isLatest:b.isLatest,isDeleted:b.isDeleted})})]},String(b.datasetVersion))})})})]})]})}function XWr(){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 KWr(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 JWr({datasetId:e,versionA:t,versionB:n,onVersionChange:r}){const{data:s}=ZCe(e),a=(s??[]).map(i=>({value:String(i.version),label:`${KWr(i.version,i.createdAt)}${i.isCurrent?" (current)":""}`}));return o.jsxs(Ur.Toolbar,{className:"grid grid-cols-[1fr_1fr_1fr_10rem] gap-4 w-full",children:[o.jsx("div",{}),o.jsx(sc,{label:"Version A",labelIsHidden:!0,name:"version-a",placeholder:"Select version",options:a,value:t??"",onValueChange:i=>r?.(i,n??"")}),o.jsx(sc,{label:"Version B",labelIsHidden:!0,name:"version-b",options:a,value:n??"",onValueChange:i=>r?.(t??"",i)}),o.jsx("div",{})]})}const eQr=[{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"}],tQr={added:{color:"blue",borderColor:"border-blue-900",icon:o.jsx(Fr,{}),tooltip:"Added in this version"},changed:{color:"orange",borderColor:"border-yellow-900",icon:o.jsx(xat,{}),tooltip:"Changed in this version"},same:{color:"green",borderColor:"border-green-900",icon:o.jsx(ian,{}),tooltip:"Same in both versions"}};function Cne({red:e=!1,tooltip:t}){return o.jsxs(Yn,{children:[o.jsx(Hn,{asChild:!0,children:o.jsx(Xrn,{className:K("text-neutral3/40 w-5 h-5 ",{"text-red-900":e})})}),t&&o.jsx(Zn,{children:t})]})}function CS({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}=tQr[e];return o.jsxs(Yn,{children:[o.jsx(Hn,{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(Qs,{color:n,size:"small",children:r})]})}),o.jsx(Zn,{children:s})]})}function nQr(e,t){return e&&t&&e.datasetVersion===t.datasetVersion?"same":e&&t&&e.datasetVersion!==t.datasetVersion?"changed":e?"added":"removed"}function rQr({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=nQr(u,d);return o.jsxs(hn.Row,{columns:eQr,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(CS,{variant:"added",version:u.datasetVersion}):f==="changed"&&l?o.jsx(CS,{variant:"changed",version:u.datasetVersion}):o.jsx(CS,{version:u.datasetVersion})}):o.jsx(hn.Cell,{className:"justify-center flex items-center",children:o.jsx(Cne,{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(CS,{variant:"added",version:d.datasetVersion}):f==="changed"&&!l?o.jsx(CS,{variant:"changed",version:d.datasetVersion}):o.jsx(CS,{version:d.datasetVersion})}):o.jsx(hn.Cell,{className:"justify-center flex items-center",children:o.jsx(Cne,{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(CS,{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(Cne,{tooltip:o.jsxs(o.Fragment,{children:["Comparing is available",o.jsx("br",{})," only for changed items"]})})})]},c)})})})})}const AZe={needsReview:"#facc15",complete:"#22c55e"},sQr=[{label:"Needs Review",color:AZe.needsReview},{label:"Reviewed",color:AZe.complete}];function aQr({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,S=b?`${b} · ${m.experimentId.slice(0,8)}`:m.experimentId.slice(0,8);h.push({name:S,values:[m.needsReview,m.complete]})}return{data:h,maxVal:f,totalInPipeline:p}},[e,t,n]),c=a.length>0;return o.jsxs(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.TitleAndDescription,{title:"Review Pipeline",description:"Items in review across experiments."}),c&&o.jsx(Ut.Summary,{value:String(l),label:"Items in pipeline"})]}),r?o.jsx(Ut.Loading,{}):s?o.jsx(Ut.Error,{message:"Failed to load review data"}):o.jsx(Ut.Content,{children:c?o.jsx(Jj,{data:a,segments:sQr,maxVal:i,fmt:u=>String(u)}):o.jsx(Ut.NoData,{message:"No items have been sent to review yet"})})]})}function eEe(){const e=Ze();return St({queryKey:["experiment-review-summary"],queryFn:()=>e.getExperimentReviewSummary()})}function r5t(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 iQr(e,t){const n=new Map,r=r5t(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 oQr(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 lQr=10;function cQr(){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}=hy({page:d,perPage:lQr}),{data:g,isLoading:v,error:b}=kZ(),{data:S}=eEe(),w=y.useMemo(()=>p?.datasets??[],[p?.datasets]),O=p?.pagination?.hasMore??!1,_=y.useMemo(()=>g?.experiments??[],[g?.experiments]),C=y.useMemo(()=>EZr(w),[w]),E=y.useMemo(()=>iQr(S,_),[S,_]),T=h||v,N=m||b,I=()=>t(!0),R=y.useCallback(()=>f(U=>U+1),[]),$=y.useCallback(()=>f(U=>Math.max(0,U-1)),[]),B=y.useCallback(U=>{r(U),f(0)},[]),M=y.useCallback(U=>{a(U),f(0)},[]),F=y.useCallback(U=>{l(U),f(0)},[]),V=y.useCallback(U=>{u(U),f(0)},[]);if(N&&is(N))return o.jsx(ar,{children:o.jsx(Ms,{})});if(N&&ls(N))return o.jsx(ar,{children:o.jsx(Ss,{resource:"datasets"})});if(N)return o.jsx(ar,{children:o.jsx(Ii,{title:"Failed to load datasets",message:N.message})});if(w.length===0&&!T&&d===0)return o.jsxs(o.Fragment,{children:[o.jsx(ar,{children:o.jsx(AZr,{onCreateClick:I})}),o.jsx(Hme,{open:e,onOpenChange:t})]});const L=s!=="all"||i!=="all"||c!=="all"||n!=="",z=()=>{r(""),a("all"),l("all"),u("all"),f(0)};return o.jsxs(Ft,{children:[o.jsx(Ft.TopArea,{children:o.jsx(PZr,{search:n,onSearchChange:B,targetFilter:s,onTargetFilterChange:M,experimentFilter:i,onExperimentFilterChange:F,tagFilter:c,onTagFilterChange:V,tagOptions:C,onReset:z,hasActiveFilters:L,onCreateClick:I})}),o.jsx(IZr,{datasets:w,experiments:_,reviewByDataset:E,isLoading:T,search:n,targetFilter:s,experimentFilter:i,tagFilter:c,currentPage:d,hasMore:O,onNextPage:R,onPrevPage:$}),o.jsx(Hme,{open:e,onOpenChange:t})]})}function X6({children:e}){return o.jsxs(Ft,{height:"full",children:[o.jsx("div",{}),o.jsx(Ft.MainArea,{isCentered:!0,children:e})]})}function uQr(){const{datasetId:e}=mr(),t=Xs(),[n,r]=Pi(),{activeVersion:s}=YCe(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}=Nx(e),{data:S=[],isLoading:w}=DO(e,void 0,s),O=!w&&S.length===0;if(b)return null;if(v&&is(v))return o.jsx(X6,{children:o.jsx(Ms,{})});if(v&&ls(v))return o.jsx(X6,{children:o.jsx(Ss,{resource:"datasets"})});if(v&&eSe(v)||!b&&!v&&!g)return o.jsx(X6,{children:o.jsx(Vr,{iconSlot:o.jsx(zb,{}),titleSlot:"Dataset not found",descriptionSlot:`No dataset with id "${e}".`,actionSlot:o.jsxs(fe,{as:li,to:"/datasets",children:[o.jsx(mc,{}),"Back to Datasets"]})})});if(v)return o.jsx(X6,{children:o.jsx(Ii,{title:"Failed to load dataset",message:v instanceof Error?v.message:"An unexpected error occurred. Please try again."})});const _=E=>{t(`/datasets/${e}/experiments/${E}`)},C=()=>{t("/datasets")};return o.jsxs(o.Fragment,{children:[o.jsxs(Ft,{height:"full",children:[o.jsx(Ft.TopArea,{children:o.jsxs(Ft.Row,{children:[o.jsxs(Ft.Column,{children:[g?.description&&o.jsx("p",{className:"text-ui-smd text-neutral3 mb-1",children:g.description}),o.jsxs(Bt,{numOfCol:2,children:[o.jsx(Bt.Key,{children:"Created at"}),o.jsx(Bt.Value,{children:g?.createdAt?Kn(new Date(g.createdAt),"MMM d, yyyy"):""}),o.jsx(Bt.Key,{children:"Latest version"}),o.jsxs(Bt.Value,{children:["v",g?.version??""]})]})]}),o.jsx(Ft.Column,{children:o.jsxs(Rr,{children:[O?o.jsxs(Yn,{children:[o.jsx(Hn,{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(Bk,{}),s!=null?`Run on v${s}`:"Run Experiment"]})})})}),o.jsx(Zn,{children:"Add items to the dataset before running an experiment"})]}):o.jsxs(fe,{variant:"primary",onClick:()=>i(!0),children:[o.jsx(Bk,{}),s!=null?`Run on v${s}`:"Run Experiment"]}),o.jsxs(vt,{children:[o.jsx(vt.Trigger,{asChild:!0,children:o.jsx(fe,{size:"lg","aria-label":"Dataset actions menu",children:o.jsx(LB,{})})}),o.jsxs(vt.Content,{align:"end",className:"w-48",children:[o.jsxs(vt.Item,{onSelect:()=>d(!0),children:[o.jsx(Ph,{})," Edit Dataset"]}),o.jsxs(vt.Item,{onSelect:()=>m(!0),children:[o.jsx(ef,{})," Duplicate Dataset"]}),o.jsxs(vt.Item,{onSelect:()=>p(!0),className:"text-red-500 focus:text-red-400",children:[o.jsx(Zc,{})," Delete Dataset"]})]})]})]})})]})}),o.jsx(Ft.MainArea,{children:o.jsx(CWr,{datasetId:e,onAddItemClick:()=>c(!0)})})]}),o.jsx(PWr,{datasetId:e,version:s??void 0,requestContextSchema:g?.requestContextSchema,open:a,onOpenChange:i,onSuccess:_}),o.jsx(jWr,{datasetId:e,open:l,onOpenChange:c}),g&&o.jsx(zZr,{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(DZr,{open:h,onOpenChange:m,sourceDatasetId:g.id,sourceDatasetName:g.name,sourceDatasetDescription:g.description,sourceDatasetTargetType:g.targetType}),g&&o.jsx(UZr,{open:f,onOpenChange:p,datasetId:g.id,datasetName:g.name,onSuccess:C})]})}function s5t({experiment:e}){const{Link:t,paths:n}=vn(),{data:r}=tm(),{data:s}=wy(),{data:a}=Dp(),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(Ft.TopArea,{children:o.jsxs(Ft.Row,{children:[o.jsx(Ft.Column,{children:o.jsxs(Bt,{numOfCol:2,children:[o.jsx(Bt.Key,{children:"Created at"}),o.jsx(Bt.Value,{children:Kn(new Date(e.createdAt),"MMM d, yyyy 'at' h:mm a")}),e.completedAt&&o.jsxs(o.Fragment,{children:[o.jsx(Bt.Key,{children:"Completed at"}),o.jsx(Bt.Value,{children:Kn(new Date(e.completedAt),"MMM d, yyyy 'at' h:mm a")})]}),o.jsx(Bt.Key,{children:"Target"}),o.jsx(Bt.ValueLink,{href:i(),as:t,children:l()}),e.agentVersion&&o.jsxs(o.Fragment,{children:[o.jsx(Bt.Key,{children:"Version"}),c?o.jsx(Bt.ValueLink,{href:c,as:t,children:e.agentVersion}):o.jsx(Bt.Value,{children:e.agentVersion})]})]})}),o.jsx(Ft.Column,{children:o.jsx(VWr,{experiment:e})})]})})}function K6({children:e}){return o.jsxs(Ft,{height:"full",children:[o.jsx("div",{}),o.jsx(Ft.MainArea,{isCentered:!0,children:e})]})}function dQr(){const{datasetId:e,experimentId:t}=mr(),{data:n,isLoading:r,error:s}=yB(e,t),{data:a,isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u}=xZ({datasetId:e,experimentId:t,experimentStatus:n?.status});return!e||!t||r?null:s&&is(s)?o.jsx(K6,{children:o.jsx(Ms,{})}):s&&ls(s)?o.jsx(K6,{children:o.jsx(Ss,{resource:"datasets"})}):s&&eSe(s)||!r&&!s&&!n?o.jsx(K6,{children:o.jsx(Vr,{iconSlot:o.jsx(Jge,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${t}".`,actionSlot:o.jsxs(fe,{as:li,to:`/datasets/${e}?tab=experiments`,children:[o.jsx(mc,{}),"Back to Dataset"]})})}):s?o.jsx(K6,{children:o.jsx(Ii,{title:"Failed to load experiment",message:s instanceof Error?s.message:"An unexpected error occurred. Please try again."})}):o.jsxs(Ft,{height:"full",children:[o.jsx(s5t,{experiment:n}),o.jsx(Ft.MainArea,{children:o.jsx(n5t,{experimentId:t,datasetId:e,experimentStatus:n.status,results:a??[],isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u})})]})}function fQr(){const{datasetId:e}=mr(),[t,n]=Pi(),{error:r}=Nx(e??""),s=t.get("baseline")??"",a=t.get("contender")??"";return r&&is(r)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})}):r&&ls(r)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ss,{resource:"datasets"})})}):!e||!s||!a?o.jsx(ms,{children:o.jsx(Uv,{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(ms,{children:o.jsx(Uv,{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(Rw,{})," Dataset Experiments Comparison"]}),o.jsxs(ca.Description,{children:["Comparing"," ",o.jsx(li,{to:`/datasets/${e}/experiments/${s}`,children:s.slice(0,8)})," vs"," ",o.jsx(li,{to:`/datasets/${e}/experiments/${a}`,children:a.slice(0,8)})]})]}),o.jsx(ca.Column,{children:o.jsxs(fe,{as:li,to:`/datasets/${e}`,children:[o.jsx(mc,{}),"Back to Dataset"]})})]}),o.jsx(GWr,{datasetId:e,experimentIdA:s,experimentIdB:a,onSwap:()=>{n({baseline:a,contender:s})}})]})})})}function pQr(){const{datasetId:e,itemId:t}=mr(),{Link:n}=vn(),r=Xs(),{data:s,isLoading:a,error:i}=GCe(e??"",t??""),{updateItem:l,deleteItem:c}=Ai(),{data:u}=Nx(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),[S,w]=y.useState(m.input),[O,_]=y.useState(m.groundTruth),[C,E]=y.useState(m.metadata),[T,N]=y.useState(m.trajectory),[I,R]=y.useState(m.requestContext),[$,B]=y.useState(g);g!==$&&(B(g),w(m.input),_(m.groundTruth),E(m.metadata),N(m.trajectory),R(m.requestContext));const[M,F]=y.useState(!1),V=X=>{h(f?X:X.isLatest?null:X)},L=()=>{h(null)},z=!f&&p!=null,U=()=>{z||b(!0)},D=()=>{z||F(!0)},G=async()=>{if(!e||!t)return;let X;try{X=JSON.parse(S)}catch{Be.error("Input must be valid JSON");return}let ae;if(O.trim())try{ae=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=T!==m.trajectory;if(ie&&T.trim())try{J=JSON.parse(T)}catch{Be.error("Expected Trajectory must be valid JSON");return}let ce;const Y=I!==m.requestContext;if(Y&&I.trim())try{ce=JSON.parse(I)}catch{Be.error("Request Context must be valid JSON");return}try{await l.mutateAsync({datasetId:e,itemId:t,input:X,groundTruth:ae,metadata:ee,...ie?{expectedTrajectory:J??null}:{},...Y?{requestContext:ce}:{}}),Be.success("Item updated successfully"),b(!1)}catch(ne){Be.error(`Failed to update item: ${ne instanceof Error?ne.message:"Unknown error"}`)}},q=()=>{d&&(w(JSON.stringify(d.input,null,2)),_(d.groundTruth?JSON.stringify(d.groundTruth,null,2):""),E(d.metadata?JSON.stringify(d.metadata,null,2):""),N(d.expectedTrajectory!=null?JSON.stringify(d.expectedTrajectory,null,2):""),R(d.requestContext?JSON.stringify(d.requestContext,null,2):"")),b(!1)},P=async()=>{if(!(!e||!t))try{await c.mutateAsync({datasetId:e,itemId:t}),Be.success("Item deleted successfully"),F(!1),r(`/datasets/${e}`)}catch(X){Be.error(`Failed to delete item: ${X instanceof Error?X.message:"Unknown error"}`)}},H=p??d,W=H?{id:t??"",datasetId:e??"",datasetVersion:H.datasetVersion,input:H.input,groundTruth:H.groundTruth,expectedTrajectory:H.expectedTrajectory,metadata:H.metadata,createdAt:H.createdAt,updatedAt:H.updatedAt}:null;return i&&is(i)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})}):i&&ls(i)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ss,{resource:"datasets"})})}):a?null:!e||!t||!s||s.length===0?o.jsx(ms,{children:o.jsx(Uv,{children:o.jsx("div",{className:"text-neutral3 p-4",children:"Item not found"})})}):o.jsxs(o.Fragment,{children:[o.jsx(ms,{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(VT,{}),t," ",o.jsx(Ia,{content:t})]}),o.jsx(ca.Description,{children:o.jsxs(ac,{children:["Item of ",o.jsx(zb,{})," ",u?.name]})}),o.jsxs(ca.Description,{children:[o.jsxs(ac,{children:[o.jsx(Kst,{})," Created at"," ",d?.createdAt?Kn(new Date(d.createdAt),"MMM d, yyyy"):""]}),o.jsxs(ac,{children:[o.jsx(qO,{})," Latest version v",d?.datasetVersion??""]})]})]}),o.jsx(ca.Column,{children:!v&&!f&&o.jsxs(Rr,{children:[o.jsxs(fe,{onClick:U,disabled:z,title:z?"Return to latest version to edit":void 0,children:[o.jsx(xat,{})," Edit"]}),o.jsxs(fe,{onClick:D,disabled:z,title:z?"Return to latest version to delete":void 0,children:[o.jsx(Zc,{})," Delete"]})]})})]}),o.jsxs(Nv,{className:v?"grid-cols-1":"grid-cols-[1fr_auto]",children:[o.jsxs(Ur,{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&&z&&p&&o.jsx(Rn,{variant:"warning",title:"Previous version",action:o.jsxs(Rn.Button,{onClick:L,children:[o.jsx(Wst,{})," Return to the latest version"]}),children:o.jsxs(Rn.Message,{children:["Viewing version v",p.datasetVersion]})}),v?o.jsx(e5t,{inputValue:S,setInputValue:w,groundTruthValue:O,setGroundTruthValue:_,metadataValue:C,setMetadataValue:E,trajectoryValue:T,setTrajectoryValue:N,requestContextValue:I,setRequestContextValue:R,validationErrors:null,onSave:G,onCancel:q,isSaving:l.isPending}):W?o.jsx(KCe,{item:W,Link:n}):o.jsx("div",{className:"text-neutral4 text-sm",children:"Item data not available"})]}),!v&&o.jsx(Ur,{children:o.jsx(YWr,{datasetId:e,itemId:t,onClose:()=>{},onVersionSelect:V,onCompareVersionsClick:X=>{r(`/datasets/${e}/items/${t}/versions?ids=${X.join(",")}`)},activeVersion:p?.datasetVersion??null})})]})]})})}),o.jsx(jt,{open:M,onOpenChange:F,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:P,children:c.isPending?"Deleting...":"Delete"})]})]})})]})}function RZe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function hQr(){const{datasetId:e}=mr(),[t,n]=Pi(),r=t.get("items")?.split(",").filter(Boolean)??[],{data:s,error:a}=Nx(e??""),{Link:i}=vn(),[l,c]=y.useState(!1),{data:u}=Ume(e??"",r[0]??""),{data:d}=Ume(e??"",r[1]??"");return a&&is(a)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})}):a&&ls(a)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ss,{resource:"datasets"})})}):!e||r.length<2?o.jsx(ms,{children:o.jsx(Uv,{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(ms,{children:[o.jsx(my,{owner:"dataset-items-compare",children:o.jsxs(fe,{as:li,to:`/datasets/${e}`,variant:"outline",children:[o.jsx(mc,{}),"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(Rw,{}),"Compare Dataset Items"]}),o.jsx(ca.Description,{children:o.jsxs(ac,{children:["Comparing ",r.length," items of"," ",o.jsx(li,{to:`/datasets/${e}`,className:"text-info1 hover:underline",children:s?.name||e?.slice(0,8)})]})})]}),o.jsx(ca.Column,{children:o.jsx(Rr,{children:o.jsx(fe,{variant:"primary",onClick:()=>c(f=>!f),children:l?o.jsxs(o.Fragment,{children:[o.jsx(iat,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx(Ksn,{})," Diff View"]})})})})]}),o.jsx(Nv,{className:"grid-cols-[1fr_3vw_1fr]",children:r.map((f,p)=>o.jsxs(y.Fragment,{children:[o.jsx(mQr,{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(Rxt,{codeA:RZe(u),codeB:RZe(d)})]})})]})}function mQr({datasetId:e,itemId:t,Link:n,idx:r,itemIds:s,onItemChange:a,showContent:i=!0}){const{data:l,isLoading:c}=Ume(e,t),{data:u}=DO(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(Ur,{children:[o.jsxs(Ur.Toolbar,{className:"flex gap-4",children:[o.jsxs(Aa,{name:`compare-item-${r}`,value:t,onValueChange:a,children:[o.jsx(Pa,{"aria-label":"Item",children:o.jsx(Ra,{placeholder:"Select item"})}),o.jsx($a,{children:f.map(p=>o.jsx(Qr,{value:p.value,disabled:p.disabled,children:p.label},p.value))})]}),o.jsxs(fe,{as:n,to:`/datasets/${e}/items/${t}`,children:[o.jsx(qO,{}),"Versions"]})]}),i&&o.jsx(Ur.Content,{children:c?o.jsx("div",{className:"text-neutral4 text-sm",children:"Loading..."}):l?o.jsxs(o.Fragment,{children:[o.jsx(TWr,{item:l}),o.jsx(KCe,{item:l,Link:n})]}):o.jsxs("div",{className:"text-neutral4 text-sm",children:["Item ",t.slice(0,8)," not found"]})})]})}function PZe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function gQr(){const{datasetId:e,itemId:t}=mr(),[n,r]=Pi(),[s,a]=y.useState(!1),i=n.get("ids")?.split(",").map(Number).filter(h=>!isNaN(h)&&h>0)??[],{data:l,error:c}=Nx(e??""),{Link:u}=vn(),{data:d}=GCe(e??"",t??""),{data:f}=Wme(e??"",t??"",i[0]??0,l?.version),{data:p}=Wme(e??"",t??"",i[1]??0,l?.version);return c&&is(c)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})}):c&&ls(c)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ss,{resource:"datasets"})})}):!e||!t||i.length<2?o.jsx(ms,{children:o.jsx(Uv,{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(ms,{children:[o.jsx(my,{owner:"dataset-item-versions-compare",children:o.jsxs(fe,{as:li,to:`/datasets/${e}/items/${t}`,variant:"outline",children:[o.jsx(mc,{}),"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(Rw,{}),"Compare Dataset Item Versions"]}),o.jsx(ca.Description,{children:o.jsxs(ac,{children:["Comparing ",i.length," versions of"," ",o.jsx(li,{to:`/datasets/${e}/items/${t}`,className:"text-info1 hover:underline",children:t})]})})]}),o.jsx(ca.Column,{children:o.jsx(Rr,{children:o.jsx(fe,{variant:"primary",onClick:()=>a(h=>!h),children:s?o.jsxs(o.Fragment,{children:[o.jsx(iat,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx($an,{})," Diff View"]})})})})]}),o.jsx(Nv,{className:"grid-cols-[1fr_3vw_1fr]",children:i.map((h,m)=>o.jsxs(y.Fragment,{children:[o.jsx(vQr,{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(Rxt,{codeA:PZe(f),codeB:PZe(p)})]})})]})}function vQr({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}=Wme(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(Qs,{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(Ur,{children:[o.jsxs(Ur.Toolbar,{className:"grid gap-4 grid-cols-[auto_1fr]",children:[o.jsx(qO,{className:"w-6 h-6 opacity-50"}),o.jsxs(Aa,{name:`compare-version-${l}`,value:String(n),onValueChange:g=>u(Number(g)),children:[o.jsx(Pa,{"aria-label":"Version",className:"w-full",children:o.jsx(Ra,{placeholder:"Select version"})}),o.jsx($a,{children:h.map(g=>o.jsx(Qr,{value:g.value,disabled:g.disabled,children:g.label},g.value))})]})]}),c&&o.jsx(Ur.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(KCe,{item:m,Link:i})})]})}function yQr(){const{datasetId:e}=mr(),[t]=Pi(),n=t.get("ids")?.split(",").map(Number).filter(g=>!isNaN(g)&&g>0)??[],r=Xs(),{data:s,error:a}=Nx(e??""),i=DO(e??"",void 0,n[0]??null),l=DO(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&&is(a))return o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})});if(a&&ls(a))return o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ss,{resource:"datasets"})})});if(!e||n.length<2)return o.jsx(ms,{children:o.jsx(Uv,{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(ms,{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(oon,{})," Compare Dataset Versions"]}),o.jsx(ca.Description,{children:o.jsxs(ac,{children:[o.jsx(qO,{})," Comparing ",n.length," versions of"," ",s?.name||e?.slice(0,8)]})})]}),o.jsx(ca.Column,{children:o.jsxs(fe,{as:li,to:`/datasets/${e}`,children:[o.jsx(mc,{}),"Back to Dataset"]})})]}),o.jsx(Nv,{children:o.jsxs(Ur,{children:[o.jsx(JWr,{datasetId:e,versionA:String(n[0]),versionB:String(n[1]),onVersionChange:m}),o.jsx(rQr,{datasetId:e,versionA:n[0],versionB:n[1],allItems:d,itemsAMap:f,itemsBMap:p,onItemClick:h})]})})]})})})}function bQr(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 xQr({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=bQr(n);return o.jsxs(o.Fragment,{children:[o.jsxs(Wr,{children:[o.jsx(Wr.Label,{children:"Total Scorers"}),i?o.jsx(Wr.Loading,{}):f!=null?o.jsxs(o.Fragment,{children:[o.jsx(Wr.Value,{children:String(f)}),o.jsx(Wr.NoChange,{message:"Static count"})]}):o.jsx(Wr.NoData,{})]}),o.jsxs(Wr,{children:[o.jsx(Wr.Label,{children:"Total Datasets"}),l?o.jsx(Wr.Loading,{}):p!=null?o.jsxs(o.Fragment,{children:[o.jsx(Wr.Value,{children:String(p)}),o.jsx(Wr.NoChange,{message:"Static count"})]}):o.jsx(Wr.NoData,{})]}),o.jsxs(Wr,{children:[o.jsx(Wr.Label,{children:"Avg Score"}),u?o.jsx(Wr.Loading,{}):r!=null?o.jsxs(o.Fragment,{children:[o.jsx(Wr.Value,{children:String(r)}),m?o.jsx(Wr.Change,{changePct:m.changePct,prevValue:m.prevValue}):o.jsx(Wr.NoChange,{})]}):o.jsx(Wr.NoData,{})]}),o.jsxs(Wr,{children:[o.jsx(Wr.Label,{children:"Total Experiments"}),c?o.jsx(Wr.Loading,{}):h!=null?o.jsxs(o.Fragment,{children:[o.jsx(Wr.Value,{children:String(h)}),g?o.jsx(Wr.Change,{changePct:g.changePct,prevValue:g.prevValue}):o.jsx(Wr.NoChange,{})]}):o.jsx(Wr.NoData,{})]}),o.jsxs(Wr,{children:[o.jsx(Wr.Label,{children:"Needs Review"}),d?o.jsx(Wr.Loading,{}):a!=null?o.jsxs(o.Fragment,{children:[o.jsx(Wr.Value,{children:String(a)}),a>0?o.jsx(Wr.NoChange,{message:"items pending review"}):o.jsx(Wr.NoChange,{message:"All caught up"})]}):o.jsx(Wr.NoData,{})]})]})}const $Ze="auto 1fr auto auto auto auto auto auto auto";function wQr(e){return e?(typeof e=="string"?new Date(e):e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}const SQr={completed:"success",running:"warning",failed:"error",pending:"neutral"};function kQr({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(zo,{columns:$Ze}):o.jsxs(we,{columns:$Ze,children:[o.jsxs(we.Top,{children:[o.jsx(we.TopCell,{children:"Experiment"}),o.jsx(we.TopCell,{children:"Dataset"}),o.jsx(we.TopCell,{children:"Target"}),o.jsx(we.TopCell,{children:"Status"}),o.jsx(we.TopCell,{className:"text-center",children:"Items"}),o.jsx(we.TopCell,{className:"text-center",children:"Succeeded"}),o.jsx(we.TopCell,{className:"text-center",children:"Failed"}),o.jsx(we.TopCell,{className:"text-center",children:"Review"}),o.jsx(we.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,S=b>0?Math.round(g/b*100):0;return o.jsxs(we.RowLink,{to:l.experimentLink(p.id),LinkComponent:c,children:[o.jsx(we.NameCell,{className:"font-mono",children:p.id.slice(0,8)}),o.jsx(we.TextCell,{children:h}),o.jsx(we.Cell,{children:o.jsxs("span",{className:"truncate",children:[p.targetType," ",p.targetId]})}),o.jsx(we.Cell,{children:o.jsx(Sh,{variant:SQr[m]??"neutral",withDot:!0,children:m})}),o.jsx(we.TextCell,{className:"text-center",children:b}),o.jsx(we.TextCell,{className:"text-center",children:o.jsxs("span",{className:g>0?"text-accent1":"",children:[g," (",S,"%)"]})}),o.jsx(we.TextCell,{className:"text-center",children:o.jsx("span",{className:v>0?"text-accent2":"",children:v})}),o.jsx(we.Cell,{className:"text-center",children:(()=>{const w=n?.get(p.id);if(!w)return o.jsx("span",{className:"text-neutral2",children:"—"});const O=w.needsReview+w.complete;return O===0?o.jsx("span",{className:"text-neutral2",children:"—"}):w.needsReview>0?o.jsxs(Qs,{size:"small",color:"yellow",children:[w.needsReview," pending"]}):o.jsxs(Qs,{size:"small",color:"green",children:[w.complete,"/",O," reviewed"]})})()}),o.jsx(we.TextCell,{children:wQr(p.createdAt)})]},p.id)})]})}const OQr=[{value:"all",label:"All statuses"},{value:"completed",label:"Completed"},{value:"running",label:"Running"},{value:"failed",label:"Failed"},{value:"pending",label:"Pending"}];function _Qr(e){return[{value:"all",label:"All datasets"},...(e??[]).map(t=>({value:t.id,label:t.name}))]}const J6={completed:"#22c55e",running:"#facc15",pending:"#fb923c",failed:"#f87171"},CQr=[{label:"Completed",color:J6.completed},{label:"Running",color:J6.running},{label:"Pending",color:J6.pending},{label:"Failed",color:J6.failed}];function EQr({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(Ut,{children:[o.jsxs(Ut.TopBar,{children:[o.jsx(Ut.TitleAndDescription,{title:"Experiments by Dataset",description:"Experiment status breakdown per dataset."}),i&&o.jsx(Ut.Summary,{value:String(e?.length??0),label:"Total experiments"})]}),n?o.jsx(Ut.Loading,{}):r?o.jsx(Ut.Error,{message:"Failed to load experiments data"}):o.jsx(Ut.Content,{children:i?o.jsx(Jj,{data:s,segments:CQr,maxVal:a,fmt:l=>String(l)}):o.jsx(Ut.NoData,{message:"No experiments have been run yet"})})]})}const jQr=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vr,{iconSlot:o.jsx(cf,{}),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(Ca,{})]})})})});function TQr({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(vf,{label:"Search experiments",placeholder:"Filter by experiment, dataset, or target",value:e,onSearch:t}),o.jsxs(Rr,{children:[o.jsx(sc,{label:"Status",labelIsHidden:!0,name:"filter-status",options:[...OQr],value:n,onValueChange:r,className:"whitespace-nowrap"}),o.jsx(sc,{label:"Dataset",labelIsHidden:!0,name:"filter-dataset",options:i,value:s,onValueChange:a,className:"whitespace-nowrap"}),l&&c&&o.jsxs(fe,{onClick:l,size:"sm",variant:"default",children:[o.jsx(ys,{className:"size-3"})," Reset"]})]})]})}function NQr(){const{data:e,isLoading:t,error:n}=Dp(),{data:r,isLoading:s,error:a}=hy(),{data:i,isLoading:l,error:c}=kZ(),{data:u,isLoading:d,isError:f,error:p}=yUr(),{data:h,isLoading:m,isError:g,error:v}=eEe(),b=r?.datasets,S=i?.experiments,w=y.useMemo(()=>oQr(h),[h]),O=n||a||c||p||v;return O&&is(O)?o.jsx(ar,{children:o.jsx(Ms,{})}):O&&ls(O)?o.jsx(ar,{children:o.jsx(Ss,{resource:"evaluation"})}):O?o.jsx(ar,{children:o.jsx(Ii,{title:"Failed to load evaluation data",message:O.message})}):o.jsx(Ft,{width:"wide",height:"full",children:o.jsxs("div",{className:"flex flex-col gap-6",children:[o.jsx(Kde,{children:o.jsx(xQr,{scorers:e,datasets:b,experiments:S,avgScore:u?.avgScore??null,prevAvgScore:u?.prevAvgScore??null,totalNeedsReview:w.needsReview,isLoadingScorers:t,isLoadingDatasets:s,isLoadingExperiments:l,isLoadingScores:d,isLoadingReview:m})}),o.jsx(lUr,{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(RZr,{experiments:S,isLoading:l,isError:!!c}),o.jsx(EQr,{experiments:S,datasets:b,isLoading:l,isError:!!c})]}),o.jsx(aQr,{reviewSummary:h,experiments:S,datasets:b,isLoading:m,isError:!!g})]})})}function IQr(){const[e,t]=y.useState(""),[n,r]=y.useState("all"),[s,a]=y.useState("all"),{data:i,isLoading:l,error:c}=hy(),{data:u,isLoading:d,error:f}=kZ(),{data:p}=eEe(),h=y.useMemo(()=>i?.datasets??[],[i?.datasets]),m=y.useMemo(()=>u?.experiments??[],[u?.experiments]),g=y.useMemo(()=>_Qr(h),[h]),v=y.useMemo(()=>r5t(p),[p]),b=l||d,S=f||c;if(S&&is(S))return o.jsx(ar,{children:o.jsx(Ms,{})});if(f&&ls(f))return o.jsx(ar,{children:o.jsx(Ss,{resource:"experiments"})});if(c&&ls(c))return o.jsx(ar,{children:o.jsx(Ss,{resource:"datasets"})});if(S)return o.jsx(ar,{children:o.jsx(Ii,{title:"Failed to load experiments",message:S.message})});if(m.length===0&&!b)return o.jsx(ar,{children:o.jsx(jQr,{})});const w=n!=="all"||s!=="all"||e!=="",O=()=>{t(""),r("all"),a("all")};return o.jsxs(Ft,{children:[o.jsx(Ft.TopArea,{children:o.jsx(TQr,{search:e,onSearchChange:t,statusFilter:n,onStatusFilterChange:r,datasetFilter:s,onDatasetFilterChange:a,datasetOptions:g,onReset:O,hasActiveFilters:w})}),o.jsx(kQr,{experiments:m,datasets:h,reviewByExperiment:v,isLoading:b,search:e,statusFilter:n,datasetFilter:s})]})}function e8({children:e}){return o.jsxs(Ft,{height:"full",children:[o.jsx("div",{}),o.jsx(Ft.MainArea,{isCentered:!0,children:e})]})}function AQr(){const{experimentId:e}=mr(),{data:t,isLoading:n}=kZ(),s=t?.experiments?.find(h=>h.id===e)?.datasetId??"",{data:a,isLoading:i,error:l}=yB(s,e??""),{data:c,isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p}=xZ({datasetId:s,experimentId:e??"",experimentStatus:a?.status});return!e||n||i?null:l&&is(l)?o.jsx(e8,{children:o.jsx(Ms,{})}):l&&ls(l)?o.jsx(e8,{children:o.jsx(Ss,{resource:"datasets"})}):l&&eSe(l)||!n&&!s||!i&&!l&&!a?o.jsx(e8,{children:o.jsx(Vr,{iconSlot:o.jsx(Jge,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${e}".`,actionSlot:o.jsxs(fe,{as:li,to:"/experiments",children:[o.jsx(mc,{}),"Back to Experiments"]})})}):l?o.jsx(e8,{children:o.jsx(Ii,{title:"Failed to load experiment",message:l instanceof Error?l.message:"An unexpected error occurred. Please try again."})}):o.jsxs(Ft,{height:"full",children:[o.jsx(s5t,{experiment:a}),o.jsx(Ft.MainArea,{children:o.jsx(n5t,{experimentId:e,datasetId:s,experimentStatus:a.status,results:c??[],isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p})})]})}function RQr({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 a5t({connections:e,isAdmin:t,disconnectPending:n,onDisconnect:r}){return o.jsx("ul",{className:"space-y-1",children:e.map(s=>o.jsx(RQr,{connection:s,isAdmin:t,disconnectPending:n,onDisconnect:()=>r(s.connectionId)},s.connectionId))})}function PQr({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(a5t,{connections:a,isAdmin:t,disconnectPending:n,onDisconnect:r})]},s))})}function $Qr({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(PQr,{groups:r,isAdmin:s,disconnectPending:l,onDisconnect:u}):o.jsx(a5t,{connections:n,isAdmin:s,disconnectPending:l,onDisconnect:u}),c?o.jsx("p",{className:"text-red-600",children:String(c)}):null]})}function MQr({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 MZe=e=>e.authorId?.trim()||"shared",DQr=(e,t)=>{if(!t||new Set(e.map(MZe)).size<=1)return null;const r=new Map;for(const a of e){const i=MZe(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},LQr=["*","tool-providers:*","tool-providers:admin"];function FQr(){const{data:e}=em();return e?.permissions?.some(t=>LQr.includes(t))??!1}function zQr(){const[e,t]=y.useState(""),[n,r]=y.useState(""),[s,a]=y.useState(""),i=BN(),l=uH(e||null),c=tAt(e||null,n||null),u=eAt(),d=KIt(),f=FQr(),p=i.data?.providers??[],h=l.data?.data??[],m=y.useMemo(()=>c.data?.items??[],[c.data?.items]),g=y.useMemo(()=>DQr(m,f),[m,f]),v=w=>{t(w),r("")},b=()=>{!e||!n||u.mutate({providerId:e,toolkit:n,label:s.trim()||null},{onSuccess:()=>{a(""),c.refetch()}})},S=w=>{d.mutate({providerId:e,connectionId:w})};return o.jsxs("div",{className:"p-6 max-w-3xl space-y-6 text-sm",children:[o.jsx("h1",{className:"text-2xl font-semibold",children:"Integrations"}),o.jsx("p",{className:"text-gray-500",children:"Minimal page to verify the ToolProvider backend. Pick a provider and toolkit, then connect."}),o.jsx(MQr,{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($Qr,{providerId:e,toolkit:n,connections:m,groupedByAuthor:g,isAdmin:f,isLoading:c.isLoading,error:c.error,disconnectPending:d.isPending,disconnectError:d.error,onDisconnect:S})]})}function BQr({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(Ch,{className:"h-10 w-10"}),o.jsx("h1",{className:"text-xl font-semibold text-neutral6",children:e})]}),t,n,r]})})}function i5t({redirectUri:e,onSuccess:t,initialMode:n="signin",errorMessage:r}){const{data:s,isLoading:a}=wc(),{mutate:i,isPending:l,error:c}=rAr(),{mutate:u,isPending:d,error:f}=aAr(),{mutate:p,isPending:h}=kIt(),[m,g]=y.useState(n),[v,b]=y.useState(""),[S,w]=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,E=C.type==="sso"||C.type==="both",T=C.type==="credentials"||C.type==="both",N=C.sso,I=C.signUpEnabled!==!1,R=m==="signin"||!I,$=R?l:d,B=R?c:f,M=()=>{t?t():e?window.location.href=e:window.location.href="/"},F=D=>{D.preventDefault(),R?i({email:S,password:O},{onSuccess:M}):u({email:S,password:O,name:v||void 0},{onSuccess:M})},V=()=>{p({redirectUri:e},{onSuccess:D=>{window.location.href=D.url}})},L=()=>{g(R?"signup":"signin")},z=C.description?o.jsxs("div",{className:"flex items-start gap-2.5 rounded-md border border-border1 bg-surface1 p-3",children:[o.jsx(tf,{className:"mt-0.5 h-4 w-4 shrink-0 text-neutral4"}),o.jsx("p",{className:"text-sm text-neutral3",children:C.description})]}):null,U=r?o.jsx("div",{className:"rounded-md bg-red-500/10 p-3 text-sm text-red-400",children:r}):null;return o.jsxs(BQr,{title:R?"Sign in to Mastra Studio":"Create your account",description:z,errorBanner:U,children:[T&&o.jsxs("form",{onSubmit:F,className:"space-y-4",children:[!R&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"name",className:"block text-sm text-neutral4",children:"Name"}),o.jsx(kn,{id:"name",type:"text",value:v,onChange:D=>b(D.target.value),placeholder:"Your name",variant:"default",size:"lg"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"email",className:"block text-sm text-neutral4",children:"Email"}),o.jsx(kn,{id:"email",type:"email",value:S,onChange:D=>w(D.target.value),placeholder:"you@example.com",required:!0,variant:"default",size:"lg"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"password",className:"block text-sm text-neutral4",children:"Password"}),o.jsx(kn,{id:"password",type:"password",value:O,onChange:D=>_(D.target.value),placeholder:R?"Enter your password":"Create a password",required:!0,variant:"default",size:"lg"})]}),B&&o.jsx("div",{className:"rounded-md bg-red-500/10 p-3 text-sm text-red-400",children:B.message}),o.jsx(fe,{type:"submit",disabled:$,className:"w-full",size:"lg",children:$?R?"Signing in...":"Creating account...":R?"Sign in":"Create account"}),I&&o.jsxs("div",{className:"text-center text-sm",children:[o.jsx("span",{className:"text-neutral3",children:R?"Don't have an account? ":"Already have an account? "}),o.jsx("button",{type:"button",onClick:L,className:"text-neutral6 hover:underline",children:R?"Sign up":"Sign in"})]})]}),E&&T&&o.jsxs("div",{className:"relative",children:[o.jsx("div",{className:"absolute inset-0 flex items-center",children:o.jsx("div",{className:"w-full border-t border-border1"})}),o.jsx("div",{className:"relative flex justify-center text-sm",children:o.jsx("span",{className:"bg-surface1 px-2 text-neutral3",children:"or continue with"})})]}),E&&N&&o.jsxs(fe,{onClick:V,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 UQr(){const[e]=Pi(),t=Xs(),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(i5t,{redirectUri:n,onSuccess:i,initialMode:s,errorMessage:a})}function qQr(){const[e,t]=Pi(),n=uvr(e,t),r=pvr(e,t),[s,a]=y.useState(),[i,l]=y.useState(!1),{data:c=[],isPending:u}=fSe(),{data:d=[],isPending:f}=pSe({entityType:n.selectedEntityOption?.entityType,rootOnly:!0}),{data:p=[],isPending:h}=hSe(),{data:m=[],isPending:g}=mSe(),v=y.useMemo(()=>Rmr({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(()=>Dmr({rootEntityType:n.selectedEntityOption?.entityType,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,tokens:n.filterTokens}),[n.filterTokens,n.selectedDateFrom,n.selectedDateTo,n.selectedEntityOption]),{data:S=[],isLoading:w,error:O,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:E}=lvr({filters:b}),{logIdMap:T,featuredLog:N,handleLogClick:I,handlePreviousLog:R,handleNextLog:$}=gvr(S,n.featuredLogId,n.handleFeaturedChange,n.featuredTraceId),{data:B,isLoading:M}=dSe(n.featuredTraceId??null),{data:F,isLoading:V}=QD(n.featuredTraceId??"",n.featuredSpanId??""),L=y.useCallback(()=>n.applyFilterTokens(Lmr(v,n.filterTokens)),[v,n]),z=y.useCallback(()=>n.handleFeaturedChange({logId:null}),[n]),U=y.useCallback(X=>n.handleFeaturedChange({traceId:X,spanId:null}),[n]),D=y.useCallback((X,ae)=>n.handleFeaturedChange({traceId:X,spanId:ae}),[n]),G=y.useCallback(()=>{n.handleFeaturedChange({traceId:null,spanId:null}),l(!1)},[n]),q=y.useCallback(()=>n.handleFeaturedChange({spanId:null}),[n]),P=y.useCallback(X=>n.handleFeaturedChange({spanId:X??null}),[n]),H=o.jsxs(Ft.TopArea,{children:[o.jsx(Ft.Row,{children:o.jsxs(Ft.Column,{className:"flex flex-wrap items-start justify-start gap-2",children:[o.jsx(lwe,{preset:n.datePreset,onPresetChange:n.handleDatePresetChange,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,onDateChange:n.handleDateChange,disabled:w,presets:["last-24h","last-3d","last-7d","last-14d","last-30d","custom"]}),o.jsx(Dxe,{fields:v,tokens:n.filterTokens,onTokensChange:n.handleFilterTokensChange,disabled:w,onStartTextFilter:a})]})}),o.jsx(evr,{isLoading:w,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(Ft,{width:"wide",height:"full",children:[H,o.jsx(Ft.MainArea,{isCentered:!0,children:o.jsx(Ggr,{error:O,resource:"logs",errorTitle:"Failed to load logs"})})]});const W=!!n.selectedEntityOption||n.filterTokens.length>0;return S.length===0&&!w&&!W?o.jsxs(Ft,{width:"wide",height:"full",children:[H,o.jsx(Ft.MainArea,{isCentered:!0,children:o.jsx(svr,{datePreset:n.datePreset,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo})})]}):o.jsxs(Ft,{width:"wide",height:"full",children:[H,o.jsx(Ygr,{logCollapsed:i,listSlot:o.jsx(Jgr,{logs:S,isLoading:w,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:E,logIdMap:T,featuredLogId:n.featuredLogId,onLogClick:I}),logPanelSlot:N?o.jsx(Qgr,{log:N,onClose:z,onTraceClick:U,onSpanClick:D,onPrevious:R,onNext:$,collapsed:i,onCollapsedChange:l}):null,tracePanelSlot:n.featuredTraceId?o.jsx(xgr,{traceId:n.featuredTraceId,spans:B?.spans,isLoading:M,onClose:G,onSpanSelect:P,selectedSpanId:n.featuredSpanId}):null,spanPanelSlot:n.featuredTraceId&&n.featuredSpanId?o.jsx(bgr,{spanId:n.featuredSpanId,span:F?.span,isLoading:V,onClose:q}):null})]})}function VQr({server:e}){const{paths:t,Link:n}=vn(),s=Ze().options.baseUrl,a=s?`${s}/api/mcp/${e.id}/sse`:"",{data:i}=t3t(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(we.RowLink,{to:t.mcpServerLink(e.id),LinkComponent:n,children:[o.jsx(we.NameCell,{children:f}),o.jsx(we.DescriptionCell,{children:a}),o.jsx(we.TextCell,{className:"text-center",children:u||""}),o.jsx(we.TextCell,{className:"text-center",children:c||""}),o.jsx(we.TextCell,{className:"text-center",children:d||""})]})}function HQr({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(zo,{columns:"auto 1fr auto auto auto"}):o.jsxs(we,{columns:"auto 1fr auto auto auto",children:[o.jsxs(we.Top,{children:[o.jsx(we.TopCell,{children:"Name"}),o.jsx(we.TopCell,{children:"URL"}),o.jsx(we.TopCellSmart,{long:"Agents",short:o.jsx(Vo,{}),tooltip:"Agent Tools",className:"text-center"}),o.jsx(we.TopCellSmart,{long:"Tools",short:o.jsx(sf,{}),tooltip:"Tools",className:"text-center"}),o.jsx(we.TopCellSmart,{long:"Workflows",short:o.jsx(ld,{}),tooltip:"Workflow Tools",className:"text-center"})]}),r.length===0&&n?o.jsx(we.NoMatch,{message:"No MCP Servers match your search"}):null,r.map(s=>o.jsx(VQr,{server:s},s.id))]})}const ZQr=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vr,{iconSlot:o.jsx(cf,{}),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(Ca,{})]})})}),WQr=()=>{const{data:e=[],isLoading:t,error:n}=pZ(),[r,s]=y.useState("");return n&&is(n)?o.jsx(ar,{children:o.jsx(Ms,{})}):n&&ls(n)?o.jsx(ar,{children:o.jsx(Ss,{resource:"MCP servers"})}):n?o.jsx(ar,{children:o.jsx(Ii,{title:"Failed to load MCP servers",message:n.message})}):e.length===0&&!t?o.jsx(ar,{children:o.jsx(ZQr,{})}):o.jsxs(Ft,{children:[o.jsx(Ft.TopArea,{children:o.jsx("div",{className:"max-w-120",children:o.jsx(vf,{onSearch:s,label:"Filter MCP servers",placeholder:"Filter by name"})})}),o.jsx(HQr,{mcpServers:e,isLoading:t,search:r})]})},QQr=(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 GQr({tools:e,agents:t,isLoading:n,search:r=""}){const{paths:s,Link:a}=vn(),i=y.useMemo(()=>QQr(e,t),[e,t]),l=y.useMemo(()=>i.filter(c=>c.id.toLowerCase().includes(r.toLowerCase())),[i,r]);return n?o.jsx(zo,{columns:"auto 1fr auto"}):o.jsxs(we,{columns:"auto 1fr auto",children:[o.jsxs(we.Top,{children:[o.jsx(we.TopCell,{children:"Name"}),o.jsx(we.TopCell,{children:"Description"}),o.jsx(we.TopCellSmart,{long:"Agents",short:o.jsx(Vo,{}),tooltip:"Attached Agents",className:"text-center"})]}),l.length===0&&r?o.jsx(we.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(we.RowLink,{to:s.toolLink(c.id),LinkComponent:a,children:[o.jsx(we.NameCell,{children:u}),o.jsx(we.DescriptionCell,{children:d}),o.jsx(we.TextCell,{className:"text-center",children:f||""})]},c.id)})]})}const YQr=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vr,{iconSlot:o.jsx(cf,{}),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(Ca,{})]})})}),XQr=()=>{const e=Ze();return An({mutationFn:async({toolId:t,input:n,requestContext:r})=>{const s=new zO;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}}})},KQr=({toolId:e})=>{const{canExecute:t}=al(),n=t("tools"),{data:r={}}=tm(),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}=mIr(e,{enabled:!s}),c=s||a,{mutateAsync:u,isPending:d,data:f}=XQr(),{requestContext:p}=ks();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?dg(cg(ax(c?.inputSchema))):xs({});return i?o.jsxs("div",{className:"p-6",children:[o.jsx(On,{className:"h-8 w-48 mb-4"}),o.jsx(On,{className:"h-32 w-full"})]}):l?null:c?n?o.jsx(FCe,{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 JQr({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}=zN(),{data:p={},isLoading:h,isError:m,error:g}=tm(),{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 S=new Map;Object.values(p).forEach(_=>{_.tools&&Object.values(_.tools).forEach(C=>{S.has(C.id)||S.set(C.id,C)})}),Object.values(c).forEach(_=>{S.has(_.id)||S.set(_.id,_)});const w=Array.from(S.values()).map(_=>({label:_.id,value:_.id})),O=_=>{t?t(_):_&&_!==e&&v(b.toolLink(_))};return o.jsx(Hc,{options:w,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 eGr=({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(Uv,{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(Uv,{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(zt,{icon:o.jsx(j_t,{className:"text-neutral6"}),className:"rounded-r-sm text-neutral4!",children:"Version"}),o.jsx(zt,{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(zt,{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(Ia,{tooltip:"Copy HTTP Stream URL",content:r})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(zt,{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(Ia,{tooltip:"Copy SSE URL",content:n})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(zt,{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(Ia,{tooltip:"Copy Command Line Config",content:a})})]})]})]})]}),o.jsx("div",{className:"h-full overflow-y-scroll border-l border-border1",children:o.jsx(tGr,{server:t})})]})},tGr=({server:e})=>{const{data:t={},isLoading:n}=t3t(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(Qe,{size:"lg",className:"bg-surface4 rounded-md p-1",children:o.jsx(Yw,{})}),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(rGr,{tool:a,serverId:e.id},s)})})]})};function nGr(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 rGr=({tool:e,serverId:t})=>{const n=y.useRef(null),{Link:r,paths:s}=vn(),a=y3t[e.toolType||"tool"],i=nGr(e._meta);return o.jsxs(pf,{onClick:()=>n.current?.click(),children:[o.jsx(Lpt,{children:o.jsx(a,{className:"group-hover/entity:text-accent6"})}),o.jsxs(mf,{children:[o.jsx(hf,{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(zt,{className:"text-[10px] py-0",children:"App"})]})}),o.jsx(Ip,{children:e.description})]})]})},sGr=()=>{const{serverId:e}=mr(),{data:t=[],isLoading:n}=pZ(),r=t.find(s=>s.id===e);return o.jsx("div",{className:"h-full w-full overflow-hidden",children:o.jsx(eGr,{isLoading:n,server:r})})};function aGr(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 iGr=({toolId:e,serverId:t})=>{const{canExecute:n}=al(),r=n("tools"),s=Ze(),{data:a,isLoading:i,error:l}=TCe(t,e),{mutateAsync:c,isPending:u,data:d}=w7r(t,e),f=a?aGr(a._meta):void 0,{data:p}=St({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(On,{className:"h-8 w-48 mb-4"}),o.jsx(On,{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=dg(cg(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(e3t,{html:p,toolName:a.name??a.id,onToolCall:h})}),o.jsx(FCe,{executionResult:d,isExecutingTool:u,zodInputSchema:g,handleExecuteTool:m,toolDescription:a.description||"",toolId:a.id})]})},oGr=()=>{const{serverId:e,toolId:t}=mr(),{data:n,isLoading:r}=TCe(e,t);return r||!n?null:o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(iGr,{toolId:t,serverId:e})})},DZe={agents:zs.AGENT,workflows:zs.WORKFLOW_RUN,tools:zs.TOOL};function lGr(){const{data:e,isLoading:t,isError:n}=vmr(),{getTracesHref:r,getBucketTracesHref:s}=DN(),{Link:a}=vn(),i=Xs();return o.jsx(rmr,{data:e,isLoading:t,isError:n,onPointClick:(l,c)=>{Number.isFinite(c.tsMs)&&i(s({rootEntityType:DZe[l]},c.tsMs,"1h"))},actions:l=>o.jsx(VD,{href:r({rootEntityType:DZe[l]}),LinkComponent:a})})}function cGr(){const e=Cmr(),t=Emr(),{getTracesHref:n}=DN(),{Link:r}=vn();return o.jsx(amr,{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 uGr(){const{data:e,isLoading:t,isError:n}=Z_t();return o.jsx(HD,{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 dGr(){const{data:e,isLoading:t,isError:n}=hmr();return o.jsx(HD,{label:"Total Model Cost",value:e?.cost!=null?Gm(e.cost,e.costUnit):null,prevValue:e?.previousCost!=null?Gm(e.previousCost,e.costUnit):void 0,changePct:e?.costChangePercent??null,isLoading:t,isError:n})}function fGr(){const{data:e,isLoading:t,isError:n}=mmr();return o.jsx(HD,{label:"Total Tokens",value:e?.value!=null?rc(e.value):null,prevValue:e?.previousValue!=null?rc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function pGr(){const{data:e,isLoading:t,isError:n}=Omr();return o.jsx(HD,{label:"Total Threads",value:e?.value!=null?rc(e.value):null,prevValue:e?.previousValue!=null?rc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function hGr(){const{data:e,isLoading:t,isError:n}=_mr();return o.jsx(HD,{label:"Total Resources",value:e?.value!=null?rc(e.value):null,prevValue:e?.previousValue!=null?rc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function mGr({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=>gGr(f,a));return o.jsxs("div",{className:K("grid grid-cols-[1fr_auto] gap-3 items-start"),children:[o.jsx(Mxe,{fields:a,tokens:i,onTokensChange:l,disabled:s,autoFocusFieldId:c}),u&&o.jsx(Pxe,{disabled:s,onClear:d?e:void 0,onRemoveAll:t,onSave:n,onRemoveSaved:r})]})}function gGr(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 vGr(){const{data:e,isLoading:t,isError:n}=gmr(),{getTracesHref:r}=DN(),{Link:s}=vn();return o.jsx(imr,{rows:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:()=>r({rootEntityType:zs.AGENT}),actions:o.jsx(VD,{href:r({rootEntityType:zs.AGENT}),LinkComponent:s})})}function yGr(){const{data:e,isLoading:t,isError:n}=bmr(),{getTracesHref:r}=DN(),{Link:s}=vn();return o.jsx(lmr,{data:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:a=>r({rootEntityType:zs.AGENT,entityName:a.name}),actions:o.jsx(VD,{href:r({rootEntityType:zs.AGENT}),LinkComponent:s})})}function bGr(){const{data:e,isLoading:t,isError:n}=kmr(),{getTracesHref:r}=DN(),{Link:s}=vn();return o.jsx(dmr,{data:e?.data,interval:e?.interval,isLoading:t,isError:n,actions:o.jsx(VD,{href:r(),LinkComponent:s})})}const t8={agents:zs.AGENT,workflows:zs.WORKFLOW_RUN,tools:zs.TOOL};function xGr(){const{data:e,isLoading:t,isError:n}=ymr(),{getTracesHref:r,getLogsHref:s}=DN(),{Link:a}=vn();return o.jsx(fmr,{data:e,isLoading:t,isError:n,LinkComponent:a,getRowHref:(i,l)=>r({rootEntityType:t8[i],entityName:l.name}),getErrorSegmentHref:(i,l)=>l.errors>0?s({rootEntityType:t8[i],entityName:l.name,status:"error"}):void 0,actions:i=>o.jsxs(o.Fragment,{children:[o.jsx(VD,{href:r({rootEntityType:t8[i]}),LinkComponent:a}),o.jsx(tmr,{href:s({rootEntityType:t8[i],status:"error"}),LinkComponent:a})]})})}const wGr=new Set(["ObservabilityStorageClickhouseVNext","ObservabilityStorageDuckDB","ObservabilityInMemory","ObservabilitySpanner"]),Ene="period",n8="dateFrom",r8="dateTo";function SGr(){const[e,t]=Pi(),n=e.get(Ene),r=Qhr(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(n8)),p=d(e.get(r8));if(!(!f&&!p))return{from:f,to:p}},[r,e.toString()]),a=y.useMemo(()=>Bhr(e),[e.toString()]),i=y.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d==="24h"?p.delete(Ene):p.set(Ene,d),d!=="custom"&&(p.delete(n8),p.delete(r8)),p},{replace:!0})},[t]),l=y.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d?.from?p.set(n8,d.from.toISOString()):p.delete(n8),d?.to?p.set(r8,d.to.toISOString()):p.delete(r8),p},{replace:!0})},[t]),c=y.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return qhr(p,d),p},{replace:!0})},[t]),u=y.useRef(!1);return y.useEffect(()=>{if(u.current||(u.current=!0,Fhr(e)))return;const d=q_t();d&&t(f=>{const p=new URLSearchParams(f);for(const[h,m]of d)p.append(h,m);return p},{replace:!0})},[]),o.jsx(Yhr,{preset:r,filterTokens:a,onPresetChange:i,onFilterTokensChange:c,customRange:s,onCustomRangeChange:l,children:o.jsx(kGr,{})})}function kGr(){const[e]=Pi(),{error:t,isLoading:n}=Z_t(),{filterTokens:r,setFilterTokens:s}=TV(),[a,i]=y.useState(),{data:l,isLoading:c}=W4(),u=l?.observabilityStorageType,d=u?wGr.has(u):!1,f=u==="ObservabilityInMemory",{data:p,isLoading:h}=fSe(),{data:m,isLoading:g}=pSe(),{data:v,isLoading:b}=mSe(),{data:S,isLoading:w}=hSe(),O=y.useMemo(()=>zhr({availableTags:p??[],availableEntityNames:m??[],availableServiceNames:v??[],availableEnvironments:S??[],loading:{tags:h,entityNames:g,serviceNames:b,environments:w}}),[p,m,v,S,h,g,b,w]),[_,C]=y.useState(()=>q_t()!==null),E=y.useCallback(()=>{Dhr(e),C(!0),Be.success("Filters setting for Metrics saved")},[e]),T=y.useCallback(()=>{Lhr(),C(!1),Be.success("Filters setting for Metrics cleared up")},[]),N=y.useCallback(()=>{s([])},[s]),I=y.useCallback(()=>{const R=r.map($=>{const B=O.find(M=>M.id===$.fieldId);return B?B.kind==="text"?{fieldId:$.fieldId,value:""}:B.kind==="pick-multi"?B.multi?{fieldId:$.fieldId,value:[]}:{fieldId:$.fieldId,value:"Any"}:B.kind==="multi-select"?{fieldId:$.fieldId,value:[]}:$:$});s(R)},[O,r,s]);return t&&is(t)?o.jsx(ar,{children:o.jsx(Ms,{})}):t&&ls(t)?o.jsx(ar,{children:o.jsx(Ss,{resource:"metrics"})}):t?o.jsx(ar,{children:o.jsx(Ii,{title:"Failed to load metrics",message:t.message})}):o.jsxs(Ft,{width:"wide",height:"full",children:[o.jsxs(Ft.TopArea,{children:[o.jsx(Ft.Row,{children:o.jsxs(Ft.Column,{className:"flex flex-wrap items-start justify-start gap-2",children:[o.jsx(emr,{}),o.jsx(Dxe,{fields:O,tokens:r,onTokensChange:s,disabled:n,onStartTextFilter:i})]})}),o.jsx(mGr,{isLoading:n,filterFields:O,filterTokens:r,onFilterTokensChange:s,onClear:I,onRemoveAll:N,onSave:E,onRemoveSaved:_?T: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(Kde,{children:[o.jsx(uGr,{}),o.jsx(dGr,{}),o.jsx(fGr,{}),o.jsx(pGr,{}),o.jsx(hGr,{})]}),o.jsxs(Kde,{children:[o.jsx(vGr,{}),o.jsx(yGr,{}),o.jsx(bGr,{}),o.jsx(cGr,{}),o.jsx(xGr,{}),o.jsx(lGr,{})]})]}):o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Vr,{iconSlot:o.jsx(cf,{}),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(Ca,{})]})})})]})}function OGr(){const{paths:e}=vn(),{data:t,isLoading:n,error:r}=b3t(),{isCmsAvailable:s}=Y4(),[a,i]=y.useState(""),l=t?.promptBlocks??[];return r&&is(r)?o.jsx(ar,{children:o.jsx(Ms,{})}):r&&ls(r)?o.jsx(ar,{children:o.jsx(Ss,{resource:"prompt blocks"})}):r?o.jsx(ar,{children:o.jsx(Ii,{title:"Failed to load prompt blocks",message:r.message})}):l.length===0&&!n?o.jsx(ar,{children:o.jsx(oqr,{})}):o.jsxs(Ft,{children:[o.jsx(Ft.TopArea,{children:o.jsxs(Ft.Row,{align:"center",stack:"responsive",children:[o.jsx("div",{className:"max-w-120 flex-1",children:o.jsx(vf,{onSearch:i,label:"Filter prompts",placeholder:"Filter by name or description"})}),s&&o.jsxs(fe,{as:li,to:e.cmsPromptBlockCreateLink(),variant:"primary",className:"shrink-0",children:[o.jsx(Fr,{}),"Create Prompt"]})]})}),o.jsx(iqr,{promptBlocks:l,isLoading:n,search:a})]})}function _Gr(){return o.jsx(Ft,{width:"narrow",children:o.jsx(Ft.MainArea,{children:o.jsx(Z7r,{children:o.jsx(r3t,{})})})})}const CGr=[{title:"Mastra APIs",description:"Explore and test the available REST API endpoints with the interactive Swagger UI.",icon:ran,href:"/swagger-ui",external:!1},{title:"Documentation",description:"Read the official Mastra documentation for guides, references, and tutorials.",icon:Yst,href:"https://mastra.ai/en/docs",external:!0},{title:"Github",description:"Browse the source code, report issues, and contribute to the Mastra project.",icon:Ca,href:"https://github.com/mastra-ai/mastra",external:!0},{title:"Community",description:"Join the Mastra Discord community for help, discussion, and collaboration.",icon:J2,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:aat,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:Xst,href:"https://mastra.ai/contact?ref=studio",external:!0}];function EGr(){return o.jsx(Ft,{width:"narrow",children:o.jsx(Ft.MainArea,{children:o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 max-w-3xl",children:CGr.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(Ca,{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 jGr(){const{data:e={},isLoading:t,error:n}=Dp(),[r,s]=y.useState(""),[a,i]=y.useState("all");if(n&&is(n))return o.jsx(ar,{children:o.jsx(Ms,{})});if(n&&ls(n))return o.jsx(ar,{children:o.jsx(Ss,{resource:"scorers"})});if(n)return o.jsx(ar,{children:o.jsx(Ii,{title:"Failed to load scorers",message:n.message})});if(Object.keys(e).length===0&&!t)return o.jsx(ar,{children:o.jsx(uUr,{})});const l=a!=="all"||r!=="",c=()=>{s(""),i("all")};return o.jsxs(Ft,{children:[o.jsx(Ft.TopArea,{children:o.jsx(fUr,{search:r,onSearchChange:s,sourceFilter:a,onSourceFilterChange:i,onReset:c,hasActiveFilters:l})}),o.jsx(cUr,{scorers:e,isLoading:t,search:r,sourceFilter:a})]})}function TGr(){const{scorerId:e}=mr(),[t,n]=Pi(),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}=iUr(e),{data:d={},isLoading:f,error:p}=tm(),{isLoading:h,error:m}=wy(),{data:g=[],isLoading:v,error:b,isFetchingNextPage:S,hasNextPage:w,setEndOfListElement:O}=aUr({scorerId:e,entityId:i?.value==="all"?void 0:i?.value,entityType:i?.type==="ALL"?void 0:i?.type}),_=y.useMemo(()=>c?.agentIds?.filter(U=>d[U]).map(U=>({value:U,label:d[U].name,type:"AGENT"}))||[],[c?.agentIds,d]),C=y.useMemo(()=>c?.workflowIds?.map(U=>({value:U,label:U,type:"WORKFLOW"}))||[],[c?.workflowIds]),E=y.useMemo(()=>[{value:"all",label:"All Entities",type:"ALL"},..._,...C],[_,C]),T=t.get("entity")??"all",N=E.find(U=>U.value===T);N&&N.value!==i?.value&&l(N),y.useEffect(()=>{if(u){const U=u instanceof Error?u.message:"Failed to load scorer";Be.error(`Error loading scorer: ${U}`)}},[u]),y.useEffect(()=>{if(p){const U=p instanceof Error?p.message:"Failed to load agents";Be.error(`Error loading agents: ${U}`)}},[p]),y.useEffect(()=>{if(m){const U=m instanceof Error?m.message:"Failed to load workflows";Be.error(`Error loading workflows: ${U}`)}},[m]);const I=U=>{U?.value&&n(D=>{const G=new URLSearchParams(D);return G.set("entity",U.value),G})};y.useEffect(()=>{const U=t.get("scoreId")??void 0;if(U===s)return;if(!U){a(void 0);return}g.find(G=>G.id===U)&&a(U)},[t,g]);const R=y.useCallback(U=>{a(U||void 0),n(D=>{const G=new URLSearchParams(D);return U?G.set("scoreId",U):G.delete("scoreId"),G})},[n]);if(!c)return null;const $=is(u)||is(p)||is(m),B=u&&ls(u),M=!$&&!B&&(u||p||m),F=!v&&g.length===0,V=i?.value!=="all",L=c?.scorer?.source==="stored"?o.jsx(my,{owner:"scorer-detail",children:o.jsxs(fe,{variant:"default",as:li,to:`/cms/scorers/${e}/edit`,size:"sm",children:[o.jsx(Ph,{})," Edit"]})}):null;if($||B||M||F&&!V){const U=(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(Ft,{width:"wide",height:"full",children:[L,o.jsx(Ft.MainArea,{isCentered:!0,children:$?o.jsx(Ms,{}):B?o.jsx(Ss,{resource:"scorers"}):M?o.jsx(Ii,{title:"Failed to load scorer",message:U}):o.jsx(eUr,{})})]})}return o.jsxs(Ft,{width:"wide",children:[L,o.jsx(Ft.TopArea,{children:o.jsx(tUr,{selectedEntity:i,entityOptions:E,onEntityChange:I,onReset:()=>{n(U=>{const D=new URLSearchParams(U);return D.set("entity","all"),D})},isLoading:v||f||h})}),o.jsx(JBr,{scores:g,isLoading:v,selectedScoreId:s,isFetchingNextPage:S,hasNextPage:w,setEndOfListElement:O,onScoreClick:R,errorMsg:b?.message})]})}function NGr({label:e,description:t,htmlFor:n,className:r,children:s}){return o.jsxs("div",{className:K("flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",r),"data-slot":"settings-row",children:[o.jsxs("div",{children:[n?o.jsx(Rt,{htmlFor:n,className:"text-sm font-medium",children:e}):o.jsx("p",{className:"text-sm font-medium",children:e}),t&&o.jsx("p",{className:"text-sm text-neutral3",children:t})]}),s]})}const o5t=[{value:"dark",label:"Dark"},{value:"light",label:"Light"},{value:"system",label:"System"}],IGr=e=>o5t.some(t=>t.value===e),AGr=()=>{const{baseUrl:e,headers:t,apiPrefix:n}=bSe(),{theme:r,setTheme:s}=cN();return o.jsx(Ft,{width:"narrow",children:o.jsxs(Ft.MainArea,{className:"flex flex-col gap-5 mt-6",children:[o.jsx(dfe,{title:"Theme",description:"Customize the appearance of the studio.",children:o.jsx(NGr,{label:"Theme mode",htmlFor:"theme",children:o.jsxs(Aa,{value:r,onValueChange:a=>{IGr(a)&&s(a)},children:[o.jsx(Pa,{id:"theme",className:"w-full sm:w-48",children:o.jsx(Ra,{})}),o.jsx($a,{children:o5t.map(a=>o.jsx(Qr,{value:a.value,children:a.label},a.value))})]})})}),o.jsx(dfe,{title:"Mastra Connection",description:"Configure the Mastra instance URL, API prefix, and request headers used by the studio.",children:o.jsx(a3t,{initialConfig:{baseUrl:e,headers:t,apiPrefix:n}})})]})})};function RGr(){const[e]=Pi(),t=Xs(),n=e.get("redirect")||"/",r=()=>{n.startsWith("http")?window.location.href=n:t(n,{replace:!0})};return o.jsx(i5t,{redirectUri:n,onSuccess:r,initialMode:"signup"})}function PGr(e){return e.replace(/\/$/,"").split("/").pop()}function OZ({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 $Gr({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(Vo,{})," ",a.agents.length]}),a?.tools&&a.tools.length>0&&o.jsxs("li",{children:[o.jsx(sf,{})," ",a.tools.length]}),a?.networks&&a.networks.length>0&&o.jsxs("li",{children:[o.jsx(vat,{})," ",a.networks.length]}),a?.workflows&&a.workflows.length>0&&o.jsxs("li",{children:[o.jsx(UB,{})," ",a.workflows.length]}),a?.mcp&&a.mcp.length>0&&o.jsxs("li",{children:[o.jsx(Yw,{})," ",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(O_t,{})," ",PGr(a.githubUrl)]})})]},a.slug)})})}function MGr({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(qj,{name:"search-templates",label:"Search templates",labelIsHidden:!0,value:i,onChange:f=>l?.(f.target.value),placeholder:"Search Template"}),o.jsx(sc,{label:"Filter by tag",labelIsHidden:!0,name:"filter-tag",value:t,onValueChange:s,options:e}),o.jsx(sc,{label:"Filter by provider",labelIsHidden:!0,name:"filter-provider",value:r,onValueChange:a,options:n}),c&&o.jsxs(fe,{onClick:c,children:["Reset ",o.jsx(ys,{})]})]})}function DGr(){const{data:e,isLoading:t}=eyr(),{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(S=>{f.push({value:S,label:S})});const p=[{value:"all",label:"Any provider"}];(s||[]).forEach(S=>{p.push({value:S,label:S})});const h=(S,w)=>{w==="tag"?i(S):w==="provider"&&c(S)},m=S=>{d(S)},g=()=>{i("all"),c("all"),d("")},v=n.filter(S=>!(u&&!S.title.toLowerCase().includes(u)&&!S.description.toLowerCase().includes(u)||a!=="all"&&!S.tags.includes(a)||l!=="all"&&!S.supportedProviders.includes(l))),b=u||a!=="all"||l!=="all";return o.jsxs(ms,{children:[o.jsx(Lbe,{children:o.jsxs(Fpt,{children:[o.jsx(Qe,{children:o.jsx(_v,{})}),"Templates"]})}),o.jsxs("div",{className:K("overflow-y-auto w-full h-full px-8 pb-12 z-10"),children:[o.jsx(MGr,{selectedTag:a,onTagChange:S=>h(S,"tag"),tagOptions:f,selectedProvider:l,onProviderChange:S=>h(S,"provider"),providerOptions:p,searchTerm:u,onSearchChange:m,onReset:b?g:void 0,className:"max-w-[80rem]",isLoading:t}),o.jsx($Gr,{templates:v,linkComponent:li,className:"max-w-[80rem] mx-auto",isLoading:t})]})]})}const LGr="1.42.0";function FGr({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(cp,{className:"text-yellow-500"}),title:"Template Installed with Warnings"}:{icon:o.jsx(Nan,{}),title:"Template Installation Failed"},{icon:l,title:c}=i();return o.jsxs(OZ,{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 zGr({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(OZ,{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(yat,{})]}),o.jsx(sc,{name:"template-provider",options:e,label:"Template AI Model Provider",onValueChange:n,value:t,placeholder:"Select",layout:"horizontal"}),t&&Object.entries(r||{}).length>0&&o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"text-neutral3 text-ui-md",children:"Set required Environmental Variables"}),o.jsx("div",{className:"grid grid-cols-[1fr_1fr] gap-4 items-start",children:l?o.jsxs("div",{className:K("flex items-center justify-center col-span-2 text-neutral3 text-ui-sm gap-4","[&_svg]:opacity-50 [&_svg]:w-[1.1em] [&_svg]:h-[1.1em]","animate-in fade-in duration-300"),children:[o.jsx(Wt,{})," Loading variables..."]}):Object.entries(r).map(([p,h])=>o.jsxs(y.Fragment,{children:[o.jsx(aO,{name:`env-${p}`,labelIsHidden:!0,label:"Key",value:p,disabled:!0,className:"w-full"}),o.jsx(aO,{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(s3t,{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(Wt,{className:"w-4 h-4"})," Installing..."]}):o.jsxs(o.Fragment,{children:["Install ",o.jsx(Zh,{})]})})]})})}function BGr({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(_v,{}),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(c1,{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(eve,{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(O_t,{}),n?.split("/")?.pop()]})]}),s&&o.jsx(i0e,{data:s,labelsAreHidden:!0,isLoading:r})]})]})}function UGr({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(OZ,{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(S7n,{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(Tin,{}),l||"Something went wrong"]}),u&&o.jsx(w7n,{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(Wt,{}),o.jsx("p",{children:"This may take some time..."})]})]})}function qGr({name:e,installedEntities:t}){return o.jsxs(OZ,{className:K("grid items-center justify-items-center gap-4 content-center","[&>svg]:w-8 [&>svg]:h-8"),children:[o.jsx(yat,{}),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(i0e,{data:t})]})}function VGr(){const{templateSlug:e}=mr(),[t,n]=Pi(),[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,S]=y.useState(""),[w,O]=y.useState(!1),[_,C]=y.useState(!1),[E,T]=y.useState([]),{data:N,isLoading:I}=tyr({repoOrSlug:e,owner:"mastra-ai"}),$=LGr?.includes("beta")??!1?"beta":"main",{data:B,isLoading:M}=nyr({repo:N?.githubUrl?new URL(N.githubUrl).pathname.split("/")[2]:`template-${e}`,owner:"mastra-ai",branch:$}),{data:F,isLoading:V}=ryr(),{mutateAsync:L,isPending:z}=syr(),{mutateAsync:U}=ayr(),{streamInstall:D,streamResult:G,isStreaming:q}=oyr(F),{observeInstall:P,streamResult:H,isStreaming:W}=lyr(F);y.useEffect(()=>{const ne=t.get("runId");ne&&!g&&!h&&!q&&!W&&(console.info("🔄 Checking completed run after hot reload:",{runId:ne}),S(ne),U({runId:ne}).then(ue=>{const pe=ue.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:xe}=pe.result.validationResults,be=`Template installation completed but ${he} validation issue${he>1?"s":""} remain unresolved.`;m(be),T(xe||[])}else{const he=pe?.result?.message||pe?.result?.error||"Template installation failed";m(typeof he=="string"?he:String(he))}}).catch(ue=>{console.error("❌ Failed to fetch run details:",ue),m("Failed to retrieve installation status after reload")}))},[t,g,h,q,W,U]),y.useEffect(()=>{const ne=t.get("runId"),ue=t.get("resume"),pe=t.get("provider");if(ne&&ue==="true"&&pe&&!q&&!W&&!w&&!_&&F){S(ne),O(!0);try{U({runId:ne}).then(re=>{if(re.snapshot?.status==="running")return P.mutateAsync({runId:ne})}).then(()=>{n(re=>{const he=new URLSearchParams(re);return he.delete("resume"),he})}).catch(re=>{console.error("❌ Failed to resume template installation:",re),re.message?.includes("404")||re.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(re){console.error("❌ Auto-resume failed with error:",re),m("Failed to resume template installation. Please refresh and try again.")}}},[t,e,q,W,w,_,F,U,P,n]);const X=[{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"groq",label:"Groq"},{value:"google",label:"Google"}],ae=[{key:"tools",label:"Tools",value:N?.tools?.length?N.tools.map(ne=>ne).join(", "):"n/a",icon:o.jsx(sf,{})},{key:"agents",label:"Agents",value:N?.agents?.length?N.agents.map(ne=>ne).join(", "):"n/a",icon:o.jsx(Vo,{})},{key:"workflows",label:"Workflows",value:N?.workflows?.length?N.workflows.map(ne=>ne).join(", "):"n/a",icon:o.jsx(UB,{})},{key:"providers",label:"Providers",value:N?.supportedProviders?.length?N.supportedProviders.join(", "):"n/a",icon:o.jsx(W0,{})},{key:"tags",label:"Tags",value:N?.tags?.length?N.tags.join(", "):"n/a",icon:o.jsx(VO,{})}],ee=[{...ae[0]},{...ae[1]},{...ae[2]}].filter(ne=>ne.value!=="n/a");y.useEffect(()=>{B&&d(B)},[B]),y.useEffect(()=>{const ne=G||H;ne?.phase==="error"&&ne?.error&&m(typeof ne.error=="string"?ne.error:String(ne.error))},[G?.phase,G?.error,H?.phase,H?.error]);const J=ne=>{s(ne)},ie=async ne=>(i(ne.provider),c(ne.modelId),{message:"Model updated successfully"}),ce=async()=>{const ne=Object.entries(u).reduce((ue,[pe,re])=>(re===""&&ue.push(pe),ue),[]);if(ne.length>0){p(ne);return}if(N){m(null),v(!1),S(""),C(!0);try{const pe={repo:N.githubUrl||`https://github.com/mastra-ai/template-${N.slug}`,ref:$,slug:N.slug,variables:u},{runId:re}=await L({});S(re),n(he=>{const xe=new URLSearchParams(he);return xe.set("runId",re),xe.set("resume","true"),xe.set("provider",r||"openai"),xe}),await D.mutateAsync({inputData:pe,selectedModel:{provider:a,modelId:l},runId:re})}catch(ue){C(!1),m(ue?.message||"Template installation failed"),console.error("Template installation failed",ue)}}},Y=ne=>{const{name:ue,value:pe}=ne.target;pe.trim()===""?p(re=>[...re,ue]):p(re=>re.filter(he=>he!==ue)),d(re=>({...re,[ue]:pe}))};return o.jsx(ms,{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(BGr,{isLoading:I,title:N?.title,description:N?.longDescription,imageURL:N?.imageURL,githubUrl:N?.githubUrl,infoData:ae,templateSlug:e}),N&&o.jsxs(o.Fragment,{children:[(q||W)&&o.jsx(UGr,{name:N.title,streamResult:W?H:G,runId:b,workflowInfo:F}),g&&o.jsx(qGr,{name:N.title,installedEntities:ee,linkComponent:li}),h&&o.jsx(FGr,{errorMsg:h,validationErrors:E.length>0?E:G?.validationResults?.errors||H?.validationResults?.errors}),!q&&!W&&!g&&!h&&o.jsx(zGr,{providerOptions:X,selectedProvider:r,onProviderChange:J,variables:u,setVariables:d,errors:f,setErrors:p,handleInstallTemplate:ce,handleVariableChange:Y,isLoadingEnvVars:M||V,isInstalling:z,defaultModelProvider:a,defaultModelId:l,onModelUpdate:ie})]})]})})})}const HGr=()=>{const{toolId:e,agentId:t}=mr();return o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(FUr,{toolId:e,agentId:t})})},ZGr=()=>{const{toolId:e}=mr();return o.jsx("div",{className:"h-full w-full overflow-y-hidden",children:o.jsx(KQr,{toolId:e})})};function WGr(){const{traceId:e}=mr(),[t,n]=Pi(),r=Xs(),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:S,isLoading:w,error:O}=dSe(e),_=y.useMemo(()=>S?.spans??[],[S?.spans]),C=y.useMemo(()=>_.find(ie=>ie.parentSpanId==null),[_]),{data:E,isLoading:T}=QD(e,c??"");y.useEffect(()=>g(0),[e,c]);const{data:N,isLoading:I}=Dp(),{data:R,isLoading:$}=m3t({traceId:e,spanId:c??void 0,page:m}),[B,M]=y.useState(0);y.useEffect(()=>M(0),[e,c]);const{data:F,isLoading:V}=X3t({traceId:e,page:B});y.useEffect(()=>{if(l&&R?.scores&&!d){const ie=R.scores.find(ce=>ce.id===l);ie&&f(ie)}},[l,R?.scores,d]);const L=y.useCallback(ie=>{const ce=new URLSearchParams(t);for(const[Y,ne]of Object.entries(ie))ne===null||ne===""?ce.delete(Y):ce.set(Y,ne);n(ce,{replace:!0})},[t,n]),z=y.useCallback(ie=>{const ce=ie??null,Y=ce===c;u(ce),Y||(f(void 0),h("details"),L({spanId:ce,tab:null,scoreId:null}))},[c,L]),U=y.useCallback(()=>{u(null),f(void 0),h("details"),L({spanId:null,tab:null,scoreId:null})},[L]),D=y.useCallback(ie=>{u(ie),f(void 0),h("details"),L({spanId:ie,tab:null,scoreId:null})},[L]),{handlePreviousSpan:G,handleNextSpan:q}=gSe(_,c,D),P=y.useCallback(ie=>{const ce=ie;h(ce),f(void 0),L({tab:ce==="details"?null:ce,scoreId:null})},[L]),H=y.useCallback(ie=>{f(ie),L({scoreId:ie.id})},[L]),W=y.useCallback(()=>{f(void 0),L({scoreId:null})},[L]),X=y.useCallback(()=>{r("/observability")},[r]),ae=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(my,{owner:"trace-detail",children:o.jsxs(Rr,{children:[o.jsxs(fe,{tooltip:"Evaluate Trace","aria-label":"Evaluate Trace",onClick:ae,children:[o.jsx(jsn,{}),"Evaluate"]}),o.jsxs(fe,{tooltip:"Save as Dataset Item","aria-label":"Save as Dataset Item",onClick:()=>b(!0),children:[o.jsx(nd,{}),"Save"]})]})}):null,J=C?o.jsx(Ft.Row,{children:o.jsx(Ft.Column,{children:o.jsx(K_t,{rootSpan:C,numOfCol:3})})}):null;return O?o.jsxs(Ft,{height:"full",children:[ee,J&&o.jsx(Ft.TopArea,{children:J}),o.jsx(Ft.MainArea,{isCentered:!0,children:o.jsx(tCt,{error:O,resource:"traces",errorTitle:"Failed to load trace"})})]}):o.jsxs(Ft,{children:[ee,J&&o.jsx(Ft.TopArea,{children:J}),o.jsx(Z3t,{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(cSe,{traceId:e,spans:_,isLoading:w,onClose:X,onSpanSelect:z,onEvaluateTrace:ae,initialSpanId:c,placement:"trace-page",timelineChartWidth:c?"default":"wide"}),c&&!w&&o.jsxs("div",{className:K("grid gap-4 max-h-full min-h-0 overflow-auto",d?"grid-rows-[1fr_1fr]":"grid-rows-[1fr]"),children:[o.jsx(uSe,{traceId:e,spanId:c,span:E?.span,isLoading:T,onClose:U,onPrevious:G,onNext:q,activeTab:p,onTabChange:P,feedbackTabBadge:F?.pagination?.total??void 0,feedbackTabSlot:()=>o.jsx(Q3t,{feedbackData:F,onPageChange:M,isLoadingFeedbackData:V}),scoringTabBadge:R?.pagination?.total??void 0,scoringTabSlot:({span:ie,traceId:ce,spanId:Y})=>o.jsxs("div",{className:"grid gap-6",children:[o.jsx(Y3t,{traceId:ce,isTopLevelSpan:!ie.parentSpanId,spanId:Y,entityType:ie.attributes?.agentId||ie.entityType===zs.AGENT?"Agent":ie.attributes?.workflowId||ie.entityType===zs.WORKFLOW_RUN?"Workflow":void 0,scorers:N,isLoadingScorers:I}),o.jsx(G3t,{scoresData:R,onPageChange:g,isLoadingScoresData:$,onScoreSelect:H})]})}),d&&o.jsx(DCe,{score:d,onClose:W})]})]})]})}function QGr(){const{data:e,isLoading:t,error:n}=wy(),[r,s]=y.useState("");return n&&is(n)?o.jsx(ar,{children:o.jsx(Ms,{})}):n&&ls(n)?o.jsx(ar,{children:o.jsx(Ss,{resource:"workflows"})}):n?o.jsx(ar,{children:o.jsx(Ii,{title:"Failed to load workflows",message:n.message})}):Object.keys(e||{}).length===0&&!t?o.jsx(ar,{children:o.jsx(ODr,{})}):o.jsxs(Ft,{children:[o.jsx(Ft.TopArea,{children:o.jsxs(Ft.Row,{align:"center",stack:"responsive",children:[o.jsx("div",{className:"max-w-120 flex-1",children:o.jsx(vf,{onSearch:s,label:"Filter workflows",placeholder:"Filter by name or description"})}),o.jsxs(fe,{as:li,to:"/workflows/schedules",variant:"primary",className:"shrink-0",children:[o.jsx(SM,{}),"Schedules"]})]})}),o.jsx(kDr,{workflows:e||{},isLoading:t,search:r})]})}const GGr={active:"bg-accent1",paused:"bg-accent3"},YGr={active:"text-accent1",paused:"text-accent3"},l5t=({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 ${GGr[e]}`,"aria-hidden":!0}),o.jsx("span",{className:`text-ui-sm ${YGr[e]}`,children:e})]}),gj=e=>!e||e<=0?"—":new Date(e).toLocaleString(),y2=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 c5t({status:e}){const{icon:t,color:n}=XGr(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 XGr(e){switch(e){case"success":return{icon:o.jsx(da,{size:14}),color:"text-accent1"};case"failed":return{icon:o.jsx(ys,{size:14}),color:"text-accent2"};case"running":return{icon:o.jsx(Wt,{}),color:"text-neutral3"};case"suspended":return{icon:o.jsx(Kge,{size:14}),color:"text-accent3"};case"canceled":return{icon:o.jsx(cf,{size:14}),color:"text-neutral3"};case"pending":case"waiting":return{icon:o.jsx(UO,{size:14}),color:"text-neutral3"};default:return{icon:null,color:"text-neutral3"}}}const LZe="auto auto auto auto 1fr";function KGr(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 JGr(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 eYr=3e4,tYr=5*6e4;function nYr({triggers:e,isLoading:t,workflowId:n,hasNextPage:r,isFetchingNextPage:s,setEndOfListElement:a}){const{Link:i,paths:l}=vn();return t?o.jsx(zo,{columns:LZe}):e.length===0?o.jsx(ge,{variant:"ui-md",className:"text-neutral4 p-4",children:"No trigger history yet."}):o.jsxs(we,{columns:LZe,className:"min-w-0",children:[o.jsxs(we.Top,{children:[o.jsx(we.TopCell,{children:"Run"}),o.jsx(we.TopCell,{children:"Status"}),o.jsx(we.TopCell,{children:"Started"}),o.jsx(we.TopCell,{children:"Duration"}),o.jsx(we.TopCell,{children:" "})]}),e.map(c=>{const u=c.actualFireAt-c.scheduledFireAt,d=JGr(u),f=`Scheduled ${gj(c.scheduledFireAt)} — published ${gj(c.actualFireAt)} (drift ${d})`,p=c.outcome==="failed",h=p?c.error:c.run?.error,m=Math.abs(u),g=!p&&m>eYr&&m<=tYr,v=`${c.scheduleId}-${c.runId}-${c.actualFireAt}`,b=!!(n&&c.runId&&!p),S=o.jsx("span",{className:b?"text-accent1 font-mono text-ui-sm whitespace-nowrap":"text-neutral3 font-mono text-ui-sm whitespace-nowrap",children:c.runId}),w=o.jsxs(o.Fragment,{children:[o.jsx(we.Cell,{height:"compact",children:S}),o.jsx(we.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(cp,{size:14}),"publish failed"]}):c.run?o.jsx(c5t,{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(Yn,{children:[o.jsx(Hn,{asChild:!0,children:o.jsx("span",{className:"text-accent2 inline-flex",children:o.jsx(cp,{size:14})})}),o.jsx(Zn,{children:h})]}):null]})}),o.jsx(we.Cell,{height:"compact",children:o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx("span",{title:f,children:y2(c.actualFireAt)}),g?o.jsxs(Yn,{children:[o.jsx(Hn,{asChild:!0,children:o.jsx("span",{className:"text-accent3 inline-flex",children:o.jsx(cp,{size:14})})}),o.jsxs(Zn,{children:["Published ",d," after the scheduled fire time"]})]}):null]})}),o.jsx(we.Cell,{height:"compact",children:c.run?o.jsx("span",{children:KGr(c.run.durationMs)}):o.jsx("span",{className:"text-neutral4",children:"—"})}),o.jsx(we.Cell,{height:"compact",children:" "})]});return b?o.jsx(we.RowLink,{to:l.workflowRunLink(n,c.runId),LinkComponent:i,children:w},v):o.jsx(we.RowStatic,{children:w},v)}),o.jsx(we.NextPageLoading,{isLoading:s,hasMore:r,setEndOfListElement:a})]})}const rYr=e=>{const t=Ze();return St({queryKey:["schedule",e],enabled:!!e,queryFn:async()=>{if(!e)throw new Error("scheduleId is required");return t.getSchedule(e)}})},FZe=25,sYr=e=>{const t=Ze(),{inView:n,setRef:r}=b_(),s=O1({queryKey:["schedule-triggers",e],enabled:!!e,initialPageParam:void 0,queryFn:async({pageParam:u})=>e?t.listScheduleTriggers(e,{limit:FZe,toActualFireAt:u}):{triggers:[]},getNextPageParam:u=>{if(!(!u?.triggers?.length||u.triggers.length<FZe))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}},aYr=e=>{const t=Ze(),n=zr();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 s8({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 iYr(){const{scheduleId:e}=mr(),{paths:t}=vn(),{data:n,error:r}=rYr(e),{data:s,isLoading:a,error:i,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u}=sYr(e),d=aYr(e);if(r&&is(r))return o.jsx(ar,{children:o.jsx(Ms,{})});if(r&&ls(r))return o.jsx(ar,{children:o.jsx(Ss,{resource:"schedules"})});if(r)return o.jsx(ar,{children:o.jsx(Ii,{title:"Failed to load schedule",message:r.message})});const f=n?.target.type==="workflow"?n.target.workflowId:void 0;return o.jsxs(Ft,{children:[o.jsx(Ft.TopArea,{children:o.jsx(Ft.Row,{className:"justify-end",children:o.jsxs(Ft.Column,{className:"flex justify-end gap-2",children:[o.jsxs(fe,{as:li,to:t.schedulesLink(),variant:"ghost",children:[o.jsx(mc,{}),"Back to schedules"]}),f?o.jsx(fe,{as:li,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(sve,{}),"Pause"]}):o.jsxs(o.Fragment,{children:[o.jsx(Bk,{}),"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(s8,{label:"Workflow",children:f?o.jsx(li,{to:t.workflowLink(f),className:"text-accent1 hover:underline",children:f}):"—"}),o.jsxs(s8,{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(s8,{label:"Status",children:o.jsx(l5t,{status:n.status})}),o.jsx(s8,{label:"Next fire",children:o.jsx("span",{title:gj(n.nextFireAt),children:y2(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(Ii,{title:"Failed to load trigger history",message:i.message}):o.jsx(nYr,{triggers:s??[],isLoading:a,workflowId:f,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u})]})]}):null]})}const zZe="minmax(0, 1.2fr) minmax(0, 1.4fr) minmax(0, 1fr) auto auto auto";function oYr({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(zo,{columns:zZe}):o.jsxs(we,{columns:zZe,className:"min-w-0",children:[o.jsxs(we.Top,{children:[o.jsx(we.TopCell,{children:"Workflow"}),o.jsx(we.TopCell,{children:"Schedule ID"}),o.jsx(we.TopCell,{children:"Cron"}),o.jsx(we.TopCell,{children:"Status"}),o.jsx(we.TopCell,{children:"Next fire"}),o.jsx(we.TopCell,{children:"Last run"})]}),a.length===0&&n?o.jsx(we.NoMatch,{message:"No schedules match your search"}):null,a.length===0&&!n?o.jsx(we.NoMatch,{message:"No schedules configured"}):null,a.map(i=>o.jsxs(we.RowLink,{to:r.scheduleLink(i.id),LinkComponent:s,children:[o.jsx(we.NameCell,{children:i.target.workflowId}),o.jsx(we.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(we.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(we.Cell,{height:"compact",children:o.jsx(l5t,{status:i.status})}),o.jsx(we.Cell,{height:"compact",children:o.jsx("span",{className:"whitespace-nowrap",title:gj(i.nextFireAt),children:y2(i.nextFireAt)})}),o.jsx(we.Cell,{height:"compact",children:i.lastRun?o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx(c5t,{status:i.lastRun.status}),o.jsx("span",{className:"text-neutral4 text-ui-sm",title:gj(i.lastFireAt),children:i.lastFireAt?y2(i.lastFireAt):""})]}):i.lastFireAt?o.jsx("span",{className:"whitespace-nowrap",title:gj(i.lastFireAt),children:y2(i.lastFireAt)}):o.jsx("span",{className:"text-neutral4",children:"Never"})})]},i.id))]})}function lYr({workflowId:e}={}){const{data:t,isLoading:n,error:r}=xSe(e?{workflowId:e}:{}),[s,a]=y.useState("");return r?o.jsx(Ii,{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(vf,{onSearch:a,label:"Filter schedules",placeholder:"Filter by id or workflow"})}),o.jsx("div",{className:"overflow-y-auto",children:o.jsx(oYr,{schedules:t??[],isLoading:n,search:s})})]})}function cYr(){const[e]=Pi(),t=e.get("workflowId")??void 0,{error:n}=xSe(t?{workflowId:t}:{});return n&&is(n)?o.jsx(ar,{children:o.jsx(Ms,{})}):n&&ls(n)?o.jsx(ar,{children:o.jsx(Ss,{resource:"schedules"})}):o.jsx(Ft,{children:o.jsx("div",{className:"h-full",children:o.jsx(lYr,{workflowId:t})})})}const BZe=()=>{const{workflowId:e}=mr(),{data:t,isLoading:n,error:r}=YD(e);return r&&is(r)?o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})}):r&&ls(r)?o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ss,{resource:"workflows"})}):o.jsx(iRt,{workflowId:e,workflow:t??void 0,isLoading:n})};function uYr(e,t){if(e==null)return{};var n,r,s=Nft(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 Qme(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 dYr(e){if(Array.isArray(e))return Qme(e)}function fYr(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function pYr(e,t){if(e){if(typeof e=="string")return Qme(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)?Qme(e,t):void 0}}function hYr(){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 Gme(e){return dYr(e)||fYr(e)||pYr(e)||hYr()}function dM(e){"@babel/helpers - typeof";return dM=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},dM(e)}function mYr(e,t){if(dM(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(dM(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function gYr(e){var t=mYr(e,"string");return dM(t)=="symbol"?t:t+""}function u5t(e,t,n){return(t=gYr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function UZe(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 ME(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?UZe(Object(n),!0).forEach(function(r){u5t(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):UZe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function vYr(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 jne={};function yYr(e){if(e.length===0||e.length===1)return e;var t=e.join(".");return jne[t]||(jne[t]=vYr(e)),jne[t]}function bYr(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=yYr(r);return s.reduce(function(a,i){return ME(ME({},a),n[i])},t)}function qZe(e){return e.join(" ")}function xYr(e,t){var n=0;return function(r){return n+=1,r.map(function(s,a){return d5t({node:s,stylesheet:e,useInlineStyles:t,key:"code-segment-".concat(n,"-").concat(a)})})}}function d5t(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=xYr(n,a),p;if(!a)p=ME(ME({},l),{},{className:qZe(l.className)});else{var h=Object.keys(n).reduce(function(b,S){return S.split(".").forEach(function(w){b.includes(w)||b.push(w)}),b},[]),m=l.className&&l.className.includes("token")?["token"]:[],g=l.className&&m.concat(l.className.filter(function(b){return!h.includes(b)}));p=ME(ME({},l),{},{className:qZe(g)||void 0,style:bYr(l.className,Object.assign({},l.style,s),n)})}var v=f(t.children);return De.createElement(u,nO({key:i},p),v)}}const wYr=(function(e,t){var n=e.listLanguages();return n.indexOf(t)!==-1});var SYr=["language","children","style","customStyle","codeTagProps","useInlineStyles","showLineNumbers","showInlineLineNumbers","startingLineNumber","lineNumberContainerStyle","lineNumberStyle","wrapLines","wrapLongLines","lineProps","renderer","PreTag","CodeTag","code","astGenerator"];function VZe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function ow(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?VZe(Object(n),!0).forEach(function(r){u5t(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):VZe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var kYr=/\n/g;function OYr(e){return e.match(kYr)}function _Yr(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 CYr(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)},_Yr({lines:t.replace(/\n$/,"").split(`
770
770
  `),style:i,startingLineNumber:l}))}function EYr(e){return"".concat(e.toString().length,".25em")}function f5t(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 p5t(e,t,n){var r={display:"inline-block",minWidth:EYr(n),paddingRight:"1em",textAlign:"right",userSelect:"none"},s=typeof e=="function"?e(t):e,a=ow(ow({},r),s);return a}function hF(e){var t=e.children,n=e.lineNumber,r=e.lineNumberStyle,s=e.largestLineNumber,a=e.showInlineLineNumbers,i=e.lineProps,l=i===void 0?{}:i,c=e.className,u=c===void 0?[]:c,d=e.showLineNumbers,f=e.wrapLongLines,p=e.wrapLines,h=p===void 0?!1:p,m=h?ow({},typeof l=="function"?l(n):l):{};if(m.className=m.className?[].concat(Gme(m.className.trim().split(/\s+/)),Gme(u)):u,n&&a){var g=p5t(r,n,s);t.unshift(f5t(n,g))}return f&d&&(m.style=ow({display:"flex"},m.style)),{type:"element",tagName:"span",properties:m,children:t}}function h5t(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(hF({children:[s],className:Gme(new Set(t))}));else if(s.children){var a=t.concat(s.properties.className);h5t(s.children,a).forEach(function(i){return n.push(i)})}}return n}function jYr(e,t,n,r,s,a,i,l,c){var u,d=h5t(e.value),f=[],p=-1,h=0;function m(_,C){var E=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return hF({children:_,lineNumber:C,lineNumberStyle:l,largestLineNumber:i,showInlineLineNumbers:s,lineProps:n,className:E,showLineNumbers:r,wrapLongLines:c,wrapLines:t})}function g(_,C){if(r&&C&&s){var E=p5t(l,C,i);_.unshift(f5t(C,E))}return _}function v(_,C){var E=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return t||E.length>0?m(_,C,E):g(_,C)}for(var b=function(){var C=d[h],E=C.children[0].value,T=OYr(E);if(T){var N=E.split(`