modular-studio 0.2.4 → 1.0.3

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.
Files changed (56) hide show
  1. package/README.md +41 -261
  2. package/dist/assets/{graphPopulator-C6jg83nL.js → graphPopulator-DH0qM1Fu.js} +1 -1
  3. package/dist/assets/index-B0RRTCSi.css +1 -0
  4. package/dist/assets/index-LWCi_4Hu.js +662 -0
  5. package/dist/assets/{jszip.min-BlpRodxc.js → jszip.min-DByyLalk.js} +1 -1
  6. package/dist/index.html +2 -2
  7. package/dist-server/bin/modular-studio.js +5 -0
  8. package/dist-server/bin/modular-studio.js.map +1 -1
  9. package/dist-server/server/config.js +1 -1
  10. package/dist-server/server/config.js.map +1 -1
  11. package/dist-server/server/data/mcp-tokens.json +9 -0
  12. package/dist-server/server/index.d.ts.map +1 -1
  13. package/dist-server/server/index.js +2 -0
  14. package/dist-server/server/index.js.map +1 -1
  15. package/dist-server/server/mcp/manager.js +1 -1
  16. package/dist-server/server/mcp/manager.js.map +1 -1
  17. package/dist-server/server/routes/connectors.d.ts.map +1 -1
  18. package/dist-server/server/routes/connectors.js +7 -4
  19. package/dist-server/server/routes/connectors.js.map +1 -1
  20. package/dist-server/server/routes/conversations.d.ts +6 -0
  21. package/dist-server/server/routes/conversations.d.ts.map +1 -0
  22. package/dist-server/server/routes/conversations.js +111 -0
  23. package/dist-server/server/routes/conversations.js.map +1 -0
  24. package/dist-server/server/routes/embeddings.d.ts.map +1 -1
  25. package/dist-server/server/routes/embeddings.js +18 -8
  26. package/dist-server/server/routes/embeddings.js.map +1 -1
  27. package/dist-server/server/routes/health.d.ts.map +1 -1
  28. package/dist-server/server/routes/health.js +1 -0
  29. package/dist-server/server/routes/health.js.map +1 -1
  30. package/dist-server/server/routes/repo-index.d.ts.map +1 -1
  31. package/dist-server/server/routes/repo-index.js +4 -3
  32. package/dist-server/server/routes/repo-index.js.map +1 -1
  33. package/dist-server/server/services/__tests__/embeddingService.test.js +13 -5
  34. package/dist-server/server/services/__tests__/embeddingService.test.js.map +1 -1
  35. package/dist-server/server/services/agentStore.js +1 -1
  36. package/dist-server/server/services/agentStore.js.map +1 -1
  37. package/dist-server/server/services/contentStore.js +1 -1
  38. package/dist-server/server/services/contentStore.js.map +1 -1
  39. package/dist-server/server/services/embeddingService.d.ts +3 -2
  40. package/dist-server/server/services/embeddingService.d.ts.map +1 -1
  41. package/dist-server/server/services/embeddingService.js +14 -1
  42. package/dist-server/server/services/embeddingService.js.map +1 -1
  43. package/dist-server/server/services/githubIndexer.d.ts.map +1 -1
  44. package/dist-server/server/services/githubIndexer.js +9 -3
  45. package/dist-server/server/services/githubIndexer.js.map +1 -1
  46. package/dist-server/server/services/sqliteStore.d.ts +22 -0
  47. package/dist-server/server/services/sqliteStore.d.ts.map +1 -0
  48. package/dist-server/server/services/sqliteStore.js +101 -0
  49. package/dist-server/server/services/sqliteStore.js.map +1 -0
  50. package/dist-server/server/services/worktreeManager.d.ts.map +1 -1
  51. package/dist-server/server/services/worktreeManager.js +15 -3
  52. package/dist-server/server/services/worktreeManager.js.map +1 -1
  53. package/dist-server/tsconfig.server.tsbuildinfo +1 -1
  54. package/package.json +3 -2
  55. package/dist/assets/index-CXhIX28x.js +0 -634
  56. package/dist/assets/index-CeNF0r-K.css +0 -1
@@ -0,0 +1,662 @@
1
+ (function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function a(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(i){if(i.ep)return;i.ep=!0;const l=a(i);fetch(i.href,l)}})();var c8=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function rb(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var zp={exports:{}},Br={};var i0;function rS(){if(i0)return Br;i0=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function a(s,i,l){var c=null;if(l!==void 0&&(c=""+l),i.key!==void 0&&(c=""+i.key),"key"in i){l={};for(var p in i)p!=="key"&&(l[p]=i[p])}else l=i;return i=l.ref,{$$typeof:e,type:s,key:c,ref:i!==void 0?i:null,props:l}}return Br.Fragment=n,Br.jsx=a,Br.jsxs=a,Br}var l0;function iS(){return l0||(l0=1,zp.exports=rS()),zp.exports}var d=iS(),Rp={exports:{}},Te={};var c0;function lS(){if(c0)return Te;c0=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),c=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),x=Symbol.for("react.activity"),b=Symbol.iterator;function v(F){return F===null||typeof F!="object"?null:(F=b&&F[b]||F["@@iterator"],typeof F=="function"?F:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,C={};function M(F,O,Q){this.props=F,this.context=O,this.refs=C,this.updater=Q||k}M.prototype.isReactComponent={},M.prototype.setState=function(F,O){if(typeof F!="object"&&typeof F!="function"&&F!=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,F,O,"setState")},M.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function N(){}N.prototype=M.prototype;function S(F,O,Q){this.props=F,this.context=O,this.refs=C,this.updater=Q||k}var E=S.prototype=new N;E.constructor=S,w(E,M.prototype),E.isPureReactComponent=!0;var I=Array.isArray;function D(){}var A={H:null,A:null,T:null,S:null},L=Object.prototype.hasOwnProperty;function P(F,O,Q){var q=Q.ref;return{$$typeof:e,type:F,key:O,ref:q!==void 0?q:null,props:Q}}function W(F,O){return P(F.type,O,F.props)}function $(F){return typeof F=="object"&&F!==null&&F.$$typeof===e}function V(F){var O={"=":"=0",":":"=2"};return"$"+F.replace(/[=:]/g,function(Q){return O[Q]})}var X=/\/+/g;function H(F,O){return typeof F=="object"&&F!==null&&F.key!=null?V(""+F.key):O.toString(36)}function _(F){switch(F.status){case"fulfilled":return F.value;case"rejected":throw F.reason;default:switch(typeof F.status=="string"?F.then(D,D):(F.status="pending",F.then(function(O){F.status==="pending"&&(F.status="fulfilled",F.value=O)},function(O){F.status==="pending"&&(F.status="rejected",F.reason=O)})),F.status){case"fulfilled":return F.value;case"rejected":throw F.reason}}throw F}function T(F,O,Q,q,ie){var pe=typeof F;(pe==="undefined"||pe==="boolean")&&(F=null);var me=!1;if(F===null)me=!0;else switch(pe){case"bigint":case"string":case"number":me=!0;break;case"object":switch(F.$$typeof){case e:case n:me=!0;break;case g:return me=F._init,T(me(F._payload),O,Q,q,ie)}}if(me)return ie=ie(F),me=q===""?"."+H(F,0):q,I(ie)?(Q="",me!=null&&(Q=me.replace(X,"$&/")+"/"),T(ie,O,Q,"",function(ge){return ge})):ie!=null&&($(ie)&&(ie=W(ie,Q+(ie.key==null||F&&F.key===ie.key?"":(""+ie.key).replace(X,"$&/")+"/")+me)),O.push(ie)),1;me=0;var U=q===""?".":q+":";if(I(F))for(var ce=0;ce<F.length;ce++)q=F[ce],pe=U+H(q,ce),me+=T(q,O,Q,pe,ie);else if(ce=v(F),typeof ce=="function")for(F=ce.call(F),ce=0;!(q=F.next()).done;)q=q.value,pe=U+H(q,ce++),me+=T(q,O,Q,pe,ie);else if(pe==="object"){if(typeof F.then=="function")return T(_(F),O,Q,q,ie);throw O=String(F),Error("Objects are not valid as a React child (found: "+(O==="[object Object]"?"object with keys {"+Object.keys(F).join(", ")+"}":O)+"). If you meant to render a collection of children, use an array instead.")}return me}function B(F,O,Q){if(F==null)return F;var q=[],ie=0;return T(F,q,"","",function(pe){return O.call(Q,pe,ie++)}),q}function G(F){if(F._status===-1){var O=F._result;O=O(),O.then(function(Q){(F._status===0||F._status===-1)&&(F._status=1,F._result=Q)},function(Q){(F._status===0||F._status===-1)&&(F._status=2,F._result=Q)}),F._status===-1&&(F._status=0,F._result=O)}if(F._status===1)return F._result.default;throw F._result}var K=typeof reportError=="function"?reportError:function(F){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var O=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof F=="object"&&F!==null&&typeof F.message=="string"?String(F.message):String(F),error:F});if(!window.dispatchEvent(O))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",F);return}console.error(F)},J={map:B,forEach:function(F,O,Q){B(F,function(){O.apply(this,arguments)},Q)},count:function(F){var O=0;return B(F,function(){O++}),O},toArray:function(F){return B(F,function(O){return O})||[]},only:function(F){if(!$(F))throw Error("React.Children.only expected to receive a single React element child.");return F}};return Te.Activity=x,Te.Children=J,Te.Component=M,Te.Fragment=a,Te.Profiler=i,Te.PureComponent=S,Te.StrictMode=s,Te.Suspense=f,Te.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=A,Te.__COMPILER_RUNTIME={__proto__:null,c:function(F){return A.H.useMemoCache(F)}},Te.cache=function(F){return function(){return F.apply(null,arguments)}},Te.cacheSignal=function(){return null},Te.cloneElement=function(F,O,Q){if(F==null)throw Error("The argument must be a React element, but you passed "+F+".");var q=w({},F.props),ie=F.key;if(O!=null)for(pe in O.key!==void 0&&(ie=""+O.key),O)!L.call(O,pe)||pe==="key"||pe==="__self"||pe==="__source"||pe==="ref"&&O.ref===void 0||(q[pe]=O[pe]);var pe=arguments.length-2;if(pe===1)q.children=Q;else if(1<pe){for(var me=Array(pe),U=0;U<pe;U++)me[U]=arguments[U+2];q.children=me}return P(F.type,ie,q)},Te.createContext=function(F){return F={$$typeof:c,_currentValue:F,_currentValue2:F,_threadCount:0,Provider:null,Consumer:null},F.Provider=F,F.Consumer={$$typeof:l,_context:F},F},Te.createElement=function(F,O,Q){var q,ie={},pe=null;if(O!=null)for(q in O.key!==void 0&&(pe=""+O.key),O)L.call(O,q)&&q!=="key"&&q!=="__self"&&q!=="__source"&&(ie[q]=O[q]);var me=arguments.length-2;if(me===1)ie.children=Q;else if(1<me){for(var U=Array(me),ce=0;ce<me;ce++)U[ce]=arguments[ce+2];ie.children=U}if(F&&F.defaultProps)for(q in me=F.defaultProps,me)ie[q]===void 0&&(ie[q]=me[q]);return P(F,pe,ie)},Te.createRef=function(){return{current:null}},Te.forwardRef=function(F){return{$$typeof:p,render:F}},Te.isValidElement=$,Te.lazy=function(F){return{$$typeof:g,_payload:{_status:-1,_result:F},_init:G}},Te.memo=function(F,O){return{$$typeof:m,type:F,compare:O===void 0?null:O}},Te.startTransition=function(F){var O=A.T,Q={};A.T=Q;try{var q=F(),ie=A.S;ie!==null&&ie(Q,q),typeof q=="object"&&q!==null&&typeof q.then=="function"&&q.then(D,K)}catch(pe){K(pe)}finally{O!==null&&Q.types!==null&&(O.types=Q.types),A.T=O}},Te.unstable_useCacheRefresh=function(){return A.H.useCacheRefresh()},Te.use=function(F){return A.H.use(F)},Te.useActionState=function(F,O,Q){return A.H.useActionState(F,O,Q)},Te.useCallback=function(F,O){return A.H.useCallback(F,O)},Te.useContext=function(F){return A.H.useContext(F)},Te.useDebugValue=function(){},Te.useDeferredValue=function(F,O){return A.H.useDeferredValue(F,O)},Te.useEffect=function(F,O){return A.H.useEffect(F,O)},Te.useEffectEvent=function(F){return A.H.useEffectEvent(F)},Te.useId=function(){return A.H.useId()},Te.useImperativeHandle=function(F,O,Q){return A.H.useImperativeHandle(F,O,Q)},Te.useInsertionEffect=function(F,O){return A.H.useInsertionEffect(F,O)},Te.useLayoutEffect=function(F,O){return A.H.useLayoutEffect(F,O)},Te.useMemo=function(F,O){return A.H.useMemo(F,O)},Te.useOptimistic=function(F,O){return A.H.useOptimistic(F,O)},Te.useReducer=function(F,O,Q){return A.H.useReducer(F,O,Q)},Te.useRef=function(F){return A.H.useRef(F)},Te.useState=function(F){return A.H.useState(F)},Te.useSyncExternalStore=function(F,O,Q){return A.H.useSyncExternalStore(F,O,Q)},Te.useTransition=function(){return A.H.useTransition()},Te.version="19.2.4",Te}var u0;function ki(){return u0||(u0=1,Rp.exports=lS()),Rp.exports}var z=ki();const Vr=rb(z);var $p={exports:{}},Pr={},Op={exports:{}},Fp={};var d0;function cS(){return d0||(d0=1,(function(e){function n(T,B){var G=T.length;T.push(B);e:for(;0<G;){var K=G-1>>>1,J=T[K];if(0<i(J,B))T[K]=B,T[G]=J,G=K;else break e}}function a(T){return T.length===0?null:T[0]}function s(T){if(T.length===0)return null;var B=T[0],G=T.pop();if(G!==B){T[0]=G;e:for(var K=0,J=T.length,F=J>>>1;K<F;){var O=2*(K+1)-1,Q=T[O],q=O+1,ie=T[q];if(0>i(Q,G))q<J&&0>i(ie,Q)?(T[K]=ie,T[q]=G,K=q):(T[K]=Q,T[O]=G,K=O);else if(q<J&&0>i(ie,G))T[K]=ie,T[q]=G,K=q;else break e}}return B}function i(T,B){var G=T.sortIndex-B.sortIndex;return G!==0?G:T.id-B.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,p=c.now();e.unstable_now=function(){return c.now()-p}}var f=[],m=[],g=1,x=null,b=3,v=!1,k=!1,w=!1,C=!1,M=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function E(T){for(var B=a(m);B!==null;){if(B.callback===null)s(m);else if(B.startTime<=T)s(m),B.sortIndex=B.expirationTime,n(f,B);else break;B=a(m)}}function I(T){if(w=!1,E(T),!k)if(a(f)!==null)k=!0,D||(D=!0,V());else{var B=a(m);B!==null&&_(I,B.startTime-T)}}var D=!1,A=-1,L=5,P=-1;function W(){return C?!0:!(e.unstable_now()-P<L)}function $(){if(C=!1,D){var T=e.unstable_now();P=T;var B=!0;try{e:{k=!1,w&&(w=!1,N(A),A=-1),v=!0;var G=b;try{t:{for(E(T),x=a(f);x!==null&&!(x.expirationTime>T&&W());){var K=x.callback;if(typeof K=="function"){x.callback=null,b=x.priorityLevel;var J=K(x.expirationTime<=T);if(T=e.unstable_now(),typeof J=="function"){x.callback=J,E(T),B=!0;break t}x===a(f)&&s(f),E(T)}else s(f);x=a(f)}if(x!==null)B=!0;else{var F=a(m);F!==null&&_(I,F.startTime-T),B=!1}}break e}finally{x=null,b=G,v=!1}B=void 0}}finally{B?V():D=!1}}}var V;if(typeof S=="function")V=function(){S($)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,H=X.port2;X.port1.onmessage=$,V=function(){H.postMessage(null)}}else V=function(){M($,0)};function _(T,B){A=M(function(){T(e.unstable_now())},B)}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(T){T.callback=null},e.unstable_forceFrameRate=function(T){0>T||125<T?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<T?Math.floor(1e3/T):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_next=function(T){switch(b){case 1:case 2:case 3:var B=3;break;default:B=b}var G=b;b=B;try{return T()}finally{b=G}},e.unstable_requestPaint=function(){C=!0},e.unstable_runWithPriority=function(T,B){switch(T){case 1:case 2:case 3:case 4:case 5:break;default:T=3}var G=b;b=T;try{return B()}finally{b=G}},e.unstable_scheduleCallback=function(T,B,G){var K=e.unstable_now();switch(typeof G=="object"&&G!==null?(G=G.delay,G=typeof G=="number"&&0<G?K+G:K):G=K,T){case 1:var J=-1;break;case 2:J=250;break;case 5:J=1073741823;break;case 4:J=1e4;break;default:J=5e3}return J=G+J,T={id:g++,callback:B,priorityLevel:T,startTime:G,expirationTime:J,sortIndex:-1},G>K?(T.sortIndex=G,n(m,T),a(f)===null&&T===a(m)&&(w?(N(A),A=-1):w=!0,_(I,G-K))):(T.sortIndex=J,n(f,T),k||v||(k=!0,D||(D=!0,V()))),T},e.unstable_shouldYield=W,e.unstable_wrapCallback=function(T){var B=b;return function(){var G=b;b=B;try{return T.apply(this,arguments)}finally{b=G}}}})(Fp)),Fp}var p0;function uS(){return p0||(p0=1,Op.exports=cS()),Op.exports}var Ip={exports:{}},At={};var f0;function dS(){if(f0)return At;f0=1;var e=ki();function n(f){var m="https://react.dev/errors/"+f;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var g=2;g<arguments.length;g++)m+="&args[]="+encodeURIComponent(arguments[g])}return"Minified React error #"+f+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(){}var s={d:{f:a,r:function(){throw Error(n(522))},D:a,C:a,L:a,m:a,X:a,S:a,M:a},p:0,findDOMNode:null},i=Symbol.for("react.portal");function l(f,m,g){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:x==null?null:""+x,children:f,containerInfo:m,implementation:g}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(f,m){if(f==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return At.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,At.createPortal=function(f,m){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(n(299));return l(f,m,null,g)},At.flushSync=function(f){var m=c.T,g=s.p;try{if(c.T=null,s.p=2,f)return f()}finally{c.T=m,s.p=g,s.d.f()}},At.preconnect=function(f,m){typeof f=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,s.d.C(f,m))},At.prefetchDNS=function(f){typeof f=="string"&&s.d.D(f)},At.preinit=function(f,m){if(typeof f=="string"&&m&&typeof m.as=="string"){var g=m.as,x=p(g,m.crossOrigin),b=typeof m.integrity=="string"?m.integrity:void 0,v=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;g==="style"?s.d.S(f,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:x,integrity:b,fetchPriority:v}):g==="script"&&s.d.X(f,{crossOrigin:x,integrity:b,fetchPriority:v,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},At.preinitModule=function(f,m){if(typeof f=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var g=p(m.as,m.crossOrigin);s.d.M(f,{crossOrigin:g,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&s.d.M(f)},At.preload=function(f,m){if(typeof f=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var g=m.as,x=p(g,m.crossOrigin);s.d.L(f,g,{crossOrigin:x,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0,type:typeof m.type=="string"?m.type:void 0,fetchPriority:typeof m.fetchPriority=="string"?m.fetchPriority:void 0,referrerPolicy:typeof m.referrerPolicy=="string"?m.referrerPolicy:void 0,imageSrcSet:typeof m.imageSrcSet=="string"?m.imageSrcSet:void 0,imageSizes:typeof m.imageSizes=="string"?m.imageSizes:void 0,media:typeof m.media=="string"?m.media:void 0})}},At.preloadModule=function(f,m){if(typeof f=="string")if(m){var g=p(m.as,m.crossOrigin);s.d.m(f,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:g,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else s.d.m(f)},At.requestFormReset=function(f){s.d.r(f)},At.unstable_batchedUpdates=function(f,m){return f(m)},At.useFormState=function(f,m,g){return c.H.useFormState(f,m,g)},At.useFormStatus=function(){return c.H.useHostTransitionStatus()},At.version="19.2.4",At}var m0;function ib(){if(m0)return Ip.exports;m0=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(n){console.error(n)}}return e(),Ip.exports=dS(),Ip.exports}var h0;function pS(){if(h0)return Pr;h0=1;var e=uS(),n=ki(),a=ib();function s(t){var o="https://react.dev/errors/"+t;if(1<arguments.length){o+="?args[]="+encodeURIComponent(arguments[1]);for(var r=2;r<arguments.length;r++)o+="&args[]="+encodeURIComponent(arguments[r])}return"Minified React error #"+t+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function l(t){var o=t,r=t;if(t.alternate)for(;o.return;)o=o.return;else{t=o;do o=t,(o.flags&4098)!==0&&(r=o.return),t=o.return;while(t)}return o.tag===3?r:null}function c(t){if(t.tag===13){var o=t.memoizedState;if(o===null&&(t=t.alternate,t!==null&&(o=t.memoizedState)),o!==null)return o.dehydrated}return null}function p(t){if(t.tag===31){var o=t.memoizedState;if(o===null&&(t=t.alternate,t!==null&&(o=t.memoizedState)),o!==null)return o.dehydrated}return null}function f(t){if(l(t)!==t)throw Error(s(188))}function m(t){var o=t.alternate;if(!o){if(o=l(t),o===null)throw Error(s(188));return o!==t?null:t}for(var r=t,u=o;;){var h=r.return;if(h===null)break;var y=h.alternate;if(y===null){if(u=h.return,u!==null){r=u;continue}break}if(h.child===y.child){for(y=h.child;y;){if(y===r)return f(h),t;if(y===u)return f(h),o;y=y.sibling}throw Error(s(188))}if(r.return!==u.return)r=h,u=y;else{for(var j=!1,R=h.child;R;){if(R===r){j=!0,r=h,u=y;break}if(R===u){j=!0,u=h,r=y;break}R=R.sibling}if(!j){for(R=y.child;R;){if(R===r){j=!0,r=y,u=h;break}if(R===u){j=!0,u=y,r=h;break}R=R.sibling}if(!j)throw Error(s(189))}}if(r.alternate!==u)throw Error(s(190))}if(r.tag!==3)throw Error(s(188));return r.stateNode.current===r?t:o}function g(t){var o=t.tag;if(o===5||o===26||o===27||o===6)return t;for(t=t.child;t!==null;){if(o=g(t),o!==null)return o;t=t.sibling}return null}var x=Object.assign,b=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),S=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),A=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),P=Symbol.for("react.activity"),W=Symbol.for("react.memo_cache_sentinel"),$=Symbol.iterator;function V(t){return t===null||typeof t!="object"?null:(t=$&&t[$]||t["@@iterator"],typeof t=="function"?t:null)}var X=Symbol.for("react.client.reference");function H(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===X?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case w:return"Fragment";case M:return"Profiler";case C:return"StrictMode";case I:return"Suspense";case D:return"SuspenseList";case P:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case k:return"Portal";case S:return t.displayName||"Context";case N:return(t._context.displayName||"Context")+".Consumer";case E:var o=t.render;return t=t.displayName,t||(t=o.displayName||o.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case A:return o=t.displayName||null,o!==null?o:H(t.type)||"Memo";case L:o=t._payload,t=t._init;try{return H(t(o))}catch{}}return null}var _=Array.isArray,T=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G={pending:!1,data:null,method:null,action:null},K=[],J=-1;function F(t){return{current:t}}function O(t){0>J||(t.current=K[J],K[J]=null,J--)}function Q(t,o){J++,K[J]=t.current,t.current=o}var q=F(null),ie=F(null),pe=F(null),me=F(null);function U(t,o){switch(Q(pe,o),Q(ie,t),Q(q,null),o.nodeType){case 9:case 11:t=(t=o.documentElement)&&(t=t.namespaceURI)?Ay(t):0;break;default:if(t=o.tagName,o=o.namespaceURI)o=Ay(o),t=_y(o,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}O(q),Q(q,t)}function ce(){O(q),O(ie),O(pe)}function ge(t){t.memoizedState!==null&&Q(me,t);var o=q.current,r=_y(o,t.type);o!==r&&(Q(ie,t),Q(q,r))}function be(t){ie.current===t&&(O(q),O(ie)),me.current===t&&(O(me),Or._currentValue=G)}var ye,te;function he(t){if(ye===void 0)try{throw Error()}catch(r){var o=r.stack.trim().match(/\n( *(at )?)/);ye=o&&o[1]||"",te=-1<r.stack.indexOf(`
2
+ at`)?" (<anonymous>)":-1<r.stack.indexOf("@")?"@unknown:0:0":""}return`
3
+ `+ye+t+te}var je=!1;function Ie(t,o){if(!t||je)return"";je=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var u={DetermineComponentFrameRoot:function(){try{if(o){var de=function(){throw Error()};if(Object.defineProperty(de.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(de,[])}catch(re){var ae=re}Reflect.construct(t,[],de)}else{try{de.call()}catch(re){ae=re}t.call(de.prototype)}}else{try{throw Error()}catch(re){ae=re}(de=t())&&typeof de.catch=="function"&&de.catch(function(){})}}catch(re){if(re&&ae&&typeof re.stack=="string")return[re.stack,ae.stack]}return[null,null]}};u.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var h=Object.getOwnPropertyDescriptor(u.DetermineComponentFrameRoot,"name");h&&h.configurable&&Object.defineProperty(u.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var y=u.DetermineComponentFrameRoot(),j=y[0],R=y[1];if(j&&R){var Y=j.split(`
4
+ `),oe=R.split(`
5
+ `);for(h=u=0;u<Y.length&&!Y[u].includes("DetermineComponentFrameRoot");)u++;for(;h<oe.length&&!oe[h].includes("DetermineComponentFrameRoot");)h++;if(u===Y.length||h===oe.length)for(u=Y.length-1,h=oe.length-1;1<=u&&0<=h&&Y[u]!==oe[h];)h--;for(;1<=u&&0<=h;u--,h--)if(Y[u]!==oe[h]){if(u!==1||h!==1)do if(u--,h--,0>h||Y[u]!==oe[h]){var le=`
6
+ `+Y[u].replace(" at new "," at ");return t.displayName&&le.includes("<anonymous>")&&(le=le.replace("<anonymous>",t.displayName)),le}while(1<=u&&0<=h);break}}}finally{je=!1,Error.prepareStackTrace=r}return(r=t?t.displayName||t.name:"")?he(r):""}function ze(t,o){switch(t.tag){case 26:case 27:case 5:return he(t.type);case 16:return he("Lazy");case 13:return t.child!==o&&o!==null?he("Suspense Fallback"):he("Suspense");case 19:return he("SuspenseList");case 0:case 15:return Ie(t.type,!1);case 11:return Ie(t.type.render,!1);case 1:return Ie(t.type,!0);case 31:return he("Activity");default:return""}}function Tt(t){try{var o="",r=null;do o+=ze(t,r),r=t,t=t.return;while(t);return o}catch(u){return`
7
+ Error generating stack: `+u.message+`
8
+ `+u.stack}}var ft=Object.prototype.hasOwnProperty,vt=e.unstable_scheduleCallback,mn=e.unstable_cancelCallback,tn=e.unstable_shouldYield,hn=e.unstable_requestPaint,kt=e.unstable_now,Ba=e.unstable_getCurrentPriorityLevel,Bn=e.unstable_ImmediatePriority,go=e.unstable_UserBlockingPriority,na=e.unstable_NormalPriority,gu=e.unstable_LowPriority,Pa=e.unstable_IdlePriority,yu=e.log,xu=e.unstable_setDisableYieldValue,oa=null,Dt=null;function jn(t){if(typeof yu=="function"&&xu(t),Dt&&typeof Dt.setStrictMode=="function")try{Dt.setStrictMode(oa,t)}catch{}}var zt=Math.clz32?Math.clz32:ku,bu=Math.log,vu=Math.LN2;function ku(t){return t>>>=0,t===0?32:31-(bu(t)/vu|0)|0}var Ha=256,Ua=262144,Ga=4194304;function Pn(t){var o=t&42;if(o!==0)return o;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function qa(t,o,r){var u=t.pendingLanes;if(u===0)return 0;var h=0,y=t.suspendedLanes,j=t.pingedLanes;t=t.warmLanes;var R=u&134217727;return R!==0?(u=R&~y,u!==0?h=Pn(u):(j&=R,j!==0?h=Pn(j):r||(r=R&~t,r!==0&&(h=Pn(r))))):(R=u&~y,R!==0?h=Pn(R):j!==0?h=Pn(j):r||(r=u&~t,r!==0&&(h=Pn(r)))),h===0?0:o!==0&&o!==h&&(o&y)===0&&(y=h&-h,r=o&-o,y>=r||y===32&&(r&4194048)!==0)?o:h}function aa(t,o){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&o)===0}function wu(t,o){switch(t){case 1:case 2:case 4:case 8:case 64:return o+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return o+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function $i(){var t=Ga;return Ga<<=1,(Ga&62914560)===0&&(Ga=4194304),t}function Ys(t){for(var o=[],r=0;31>r;r++)o.push(t);return o}function sa(t,o){t.pendingLanes|=o,o!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Su(t,o,r,u,h,y){var j=t.pendingLanes;t.pendingLanes=r,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=r,t.entangledLanes&=r,t.errorRecoveryDisabledLanes&=r,t.shellSuspendCounter=0;var R=t.entanglements,Y=t.expirationTimes,oe=t.hiddenUpdates;for(r=j&~r;0<r;){var le=31-zt(r),de=1<<le;R[le]=0,Y[le]=-1;var ae=oe[le];if(ae!==null)for(oe[le]=null,le=0;le<ae.length;le++){var re=ae[le];re!==null&&(re.lane&=-536870913)}r&=~de}u!==0&&Oi(t,u,0),y!==0&&h===0&&t.tag!==0&&(t.suspendedLanes|=y&~(j&~o))}function Oi(t,o,r){t.pendingLanes|=o,t.suspendedLanes&=~o;var u=31-zt(o);t.entangledLanes|=o,t.entanglements[u]=t.entanglements[u]|1073741824|r&261930}function Fi(t,o){var r=t.entangledLanes|=o;for(t=t.entanglements;r;){var u=31-zt(r),h=1<<u;h&o|t[u]&o&&(t[u]|=o),r&=~h}}function Ii(t,o){var r=o&-o;return r=(r&42)!==0?1:Vs(r),(r&(t.suspendedLanes|o))!==0?0:r}function Vs(t){switch(t){case 2:t=1;break;case 8:t=4;break;case 32:t=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:t=128;break;case 268435456:t=134217728;break;default:t=0}return t}function Ws(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function Li(){var t=B.p;return t!==0?t:(t=window.event,t===void 0?32:e0(t.type))}function Bi(t,o){var r=B.p;try{return B.p=t,o()}finally{B.p=r}}var Tn=Math.random().toString(36).slice(2),mt="__reactFiber$"+Tn,Nt="__reactProps$"+Tn,Hn="__reactContainer$"+Tn,Ka="__reactEvents$"+Tn,Pi="__reactListeners$"+Tn,Cu="__reactHandles$"+Tn,Hi="__reactResources$"+Tn,ra="__reactMarker$"+Tn;function Xs(t){delete t[mt],delete t[Nt],delete t[Ka],delete t[Pi],delete t[Cu]}function yo(t){var o=t[mt];if(o)return o;for(var r=t.parentNode;r;){if(o=r[Hn]||r[mt]){if(r=o.alternate,o.child!==null||r!==null&&r.child!==null)for(t=Iy(t);t!==null;){if(r=t[mt])return r;t=Iy(t)}return o}t=r,r=t.parentNode}return null}function xo(t){if(t=t[mt]||t[Hn]){var o=t.tag;if(o===5||o===6||o===13||o===31||o===26||o===27||o===3)return t}return null}function bo(t){var o=t.tag;if(o===5||o===26||o===27||o===6)return t.stateNode;throw Error(s(33))}function vo(t){var o=t[Hi];return o||(o=t[Hi]={hoistableStyles:new Map,hoistableScripts:new Map}),o}function it(t){t[ra]=!0}var Ui=new Set,Gi={};function Un(t,o){ko(t,o),ko(t+"Capture",o)}function ko(t,o){for(Gi[t]=o,t=0;t<o.length;t++)Ui.add(o[t])}var Mu=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Zs={},qi={};function Eu(t){return ft.call(qi,t)?!0:ft.call(Zs,t)?!1:Mu.test(t)?qi[t]=!0:(Zs[t]=!0,!1)}function Ya(t,o,r){if(Eu(o))if(r===null)t.removeAttribute(o);else{switch(typeof r){case"undefined":case"function":case"symbol":t.removeAttribute(o);return;case"boolean":var u=o.toLowerCase().slice(0,5);if(u!=="data-"&&u!=="aria-"){t.removeAttribute(o);return}}t.setAttribute(o,""+r)}}function Va(t,o,r){if(r===null)t.removeAttribute(o);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(o);return}t.setAttribute(o,""+r)}}function gn(t,o,r,u){if(u===null)t.removeAttribute(r);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(r);return}t.setAttributeNS(o,r,""+u)}}function $t(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Ki(t){var o=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function ju(t,o,r){var u=Object.getOwnPropertyDescriptor(t.constructor.prototype,o);if(!t.hasOwnProperty(o)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var h=u.get,y=u.set;return Object.defineProperty(t,o,{configurable:!0,get:function(){return h.call(this)},set:function(j){r=""+j,y.call(this,j)}}),Object.defineProperty(t,o,{enumerable:u.enumerable}),{getValue:function(){return r},setValue:function(j){r=""+j},stopTracking:function(){t._valueTracker=null,delete t[o]}}}}function Wa(t){if(!t._valueTracker){var o=Ki(t)?"checked":"value";t._valueTracker=ju(t,o,""+t[o])}}function Yi(t){if(!t)return!1;var o=t._valueTracker;if(!o)return!0;var r=o.getValue(),u="";return t&&(u=Ki(t)?t.checked?"true":"false":t.value),t=u,t!==r?(o.setValue(t),!0):!1}function ia(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var Tu=/[\n"\\]/g;function Ot(t){return t.replace(Tu,function(o){return"\\"+o.charCodeAt(0).toString(16)+" "})}function la(t,o,r,u,h,y,j,R){t.name="",j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?t.type=j:t.removeAttribute("type"),o!=null?j==="number"?(o===0&&t.value===""||t.value!=o)&&(t.value=""+$t(o)):t.value!==""+$t(o)&&(t.value=""+$t(o)):j!=="submit"&&j!=="reset"||t.removeAttribute("value"),o!=null?Qs(t,j,$t(o)):r!=null?Qs(t,j,$t(r)):u!=null&&t.removeAttribute("value"),h==null&&y!=null&&(t.defaultChecked=!!y),h!=null&&(t.checked=h&&typeof h!="function"&&typeof h!="symbol"),R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"?t.name=""+$t(R):t.removeAttribute("name")}function Vi(t,o,r,u,h,y,j,R){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(t.type=y),o!=null||r!=null){if(!(y!=="submit"&&y!=="reset"||o!=null)){Wa(t);return}r=r!=null?""+$t(r):"",o=o!=null?""+$t(o):r,R||o===t.value||(t.value=o),t.defaultValue=o}u=u??h,u=typeof u!="function"&&typeof u!="symbol"&&!!u,t.checked=R?t.checked:!!u,t.defaultChecked=!!u,j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(t.name=j),Wa(t)}function Qs(t,o,r){o==="number"&&ia(t.ownerDocument)===t||t.defaultValue===""+r||(t.defaultValue=""+r)}function Gn(t,o,r,u){if(t=t.options,o){o={};for(var h=0;h<r.length;h++)o["$"+r[h]]=!0;for(r=0;r<t.length;r++)h=o.hasOwnProperty("$"+t[r].value),t[r].selected!==h&&(t[r].selected=h),h&&u&&(t[r].defaultSelected=!0)}else{for(r=""+$t(r),o=null,h=0;h<t.length;h++){if(t[h].value===r){t[h].selected=!0,u&&(t[h].defaultSelected=!0);return}o!==null||t[h].disabled||(o=t[h])}o!==null&&(o.selected=!0)}}function Mm(t,o,r){if(o!=null&&(o=""+$t(o),o!==t.value&&(t.value=o),r==null)){t.defaultValue!==o&&(t.defaultValue=o);return}t.defaultValue=r!=null?""+$t(r):""}function Em(t,o,r,u){if(o==null){if(u!=null){if(r!=null)throw Error(s(92));if(_(u)){if(1<u.length)throw Error(s(93));u=u[0]}r=u}r==null&&(r=""),o=r}r=$t(o),t.defaultValue=r,u=t.textContent,u===r&&u!==""&&u!==null&&(t.value=u),Wa(t)}function Xa(t,o){if(o){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=o;return}}t.textContent=o}var tk=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function jm(t,o,r){var u=o.indexOf("--")===0;r==null||typeof r=="boolean"||r===""?u?t.setProperty(o,""):o==="float"?t.cssFloat="":t[o]="":u?t.setProperty(o,r):typeof r!="number"||r===0||tk.has(o)?o==="float"?t.cssFloat=r:t[o]=(""+r).trim():t[o]=r+"px"}function Tm(t,o,r){if(o!=null&&typeof o!="object")throw Error(s(62));if(t=t.style,r!=null){for(var u in r)!r.hasOwnProperty(u)||o!=null&&o.hasOwnProperty(u)||(u.indexOf("--")===0?t.setProperty(u,""):u==="float"?t.cssFloat="":t[u]="");for(var h in o)u=o[h],o.hasOwnProperty(h)&&r[h]!==u&&jm(t,h,u)}else for(var y in o)o.hasOwnProperty(y)&&jm(t,y,o[y])}function Nu(t){if(t.indexOf("-")===-1)return!1;switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var nk=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),ok=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Wi(t){return ok.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}function qn(){}var Au=null;function _u(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Za=null,Qa=null;function Nm(t){var o=xo(t);if(o&&(t=o.stateNode)){var r=t[Nt]||null;e:switch(t=o.stateNode,o.type){case"input":if(la(t,r.value,r.defaultValue,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name),o=r.name,r.type==="radio"&&o!=null){for(r=t;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll('input[name="'+Ot(""+o)+'"][type="radio"]'),o=0;o<r.length;o++){var u=r[o];if(u!==t&&u.form===t.form){var h=u[Nt]||null;if(!h)throw Error(s(90));la(u,h.value,h.defaultValue,h.defaultValue,h.checked,h.defaultChecked,h.type,h.name)}}for(o=0;o<r.length;o++)u=r[o],u.form===t.form&&Yi(u)}break e;case"textarea":Mm(t,r.value,r.defaultValue);break e;case"select":o=r.value,o!=null&&Gn(t,!!r.multiple,o,!1)}}}var Du=!1;function Am(t,o,r){if(Du)return t(o,r);Du=!0;try{var u=t(o);return u}finally{if(Du=!1,(Za!==null||Qa!==null)&&(Ol(),Za&&(o=Za,t=Qa,Qa=Za=null,Nm(o),t)))for(o=0;o<t.length;o++)Nm(t[o])}}function Js(t,o){var r=t.stateNode;if(r===null)return null;var u=r[Nt]||null;if(u===null)return null;r=u[o];e:switch(o){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(u=!u.disabled)||(t=t.type,u=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!u;break e;default:t=!1}if(t)return null;if(r&&typeof r!="function")throw Error(s(231,o,typeof r));return r}var Kn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),zu=!1;if(Kn)try{var er={};Object.defineProperty(er,"passive",{get:function(){zu=!0}}),window.addEventListener("test",er,er),window.removeEventListener("test",er,er)}catch{zu=!1}var wo=null,Ru=null,Xi=null;function _m(){if(Xi)return Xi;var t,o=Ru,r=o.length,u,h="value"in wo?wo.value:wo.textContent,y=h.length;for(t=0;t<r&&o[t]===h[t];t++);var j=r-t;for(u=1;u<=j&&o[r-u]===h[y-u];u++);return Xi=h.slice(t,1<u?1-u:void 0)}function Zi(t){var o=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&o===13&&(t=13)):t=o,t===10&&(t=13),32<=t||t===13?t:0}function Qi(){return!0}function Dm(){return!1}function Ft(t){function o(r,u,h,y,j){this._reactName=r,this._targetInst=h,this.type=u,this.nativeEvent=y,this.target=j,this.currentTarget=null;for(var R in t)t.hasOwnProperty(R)&&(r=t[R],this[R]=r?r(y):y[R]);return this.isDefaultPrevented=(y.defaultPrevented!=null?y.defaultPrevented:y.returnValue===!1)?Qi:Dm,this.isPropagationStopped=Dm,this}return x(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=Qi)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=Qi)},persist:function(){},isPersistent:Qi}),o}var ca={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ji=Ft(ca),tr=x({},ca,{view:0,detail:0}),ak=Ft(tr),$u,Ou,nr,el=x({},tr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Iu,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==nr&&(nr&&t.type==="mousemove"?($u=t.screenX-nr.screenX,Ou=t.screenY-nr.screenY):Ou=$u=0,nr=t),$u)},movementY:function(t){return"movementY"in t?t.movementY:Ou}}),zm=Ft(el),sk=x({},el,{dataTransfer:0}),rk=Ft(sk),ik=x({},tr,{relatedTarget:0}),Fu=Ft(ik),lk=x({},ca,{animationName:0,elapsedTime:0,pseudoElement:0}),ck=Ft(lk),uk=x({},ca,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),dk=Ft(uk),pk=x({},ca,{data:0}),Rm=Ft(pk),fk={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},mk={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},hk={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function gk(t){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(t):(t=hk[t])?!!o[t]:!1}function Iu(){return gk}var yk=x({},tr,{key:function(t){if(t.key){var o=fk[t.key]||t.key;if(o!=="Unidentified")return o}return t.type==="keypress"?(t=Zi(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?mk[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Iu,charCode:function(t){return t.type==="keypress"?Zi(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Zi(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),xk=Ft(yk),bk=x({},el,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),$m=Ft(bk),vk=x({},tr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Iu}),kk=Ft(vk),wk=x({},ca,{propertyName:0,elapsedTime:0,pseudoElement:0}),Sk=Ft(wk),Ck=x({},el,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),Mk=Ft(Ck),Ek=x({},ca,{newState:0,oldState:0}),jk=Ft(Ek),Tk=[9,13,27,32],Lu=Kn&&"CompositionEvent"in window,or=null;Kn&&"documentMode"in document&&(or=document.documentMode);var Nk=Kn&&"TextEvent"in window&&!or,Om=Kn&&(!Lu||or&&8<or&&11>=or),Fm=" ",Im=!1;function Lm(t,o){switch(t){case"keyup":return Tk.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bm(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Ja=!1;function Ak(t,o){switch(t){case"compositionend":return Bm(o);case"keypress":return o.which!==32?null:(Im=!0,Fm);case"textInput":return t=o.data,t===Fm&&Im?null:t;default:return null}}function _k(t,o){if(Ja)return t==="compositionend"||!Lu&&Lm(t,o)?(t=_m(),Xi=Ru=wo=null,Ja=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1<o.char.length)return o.char;if(o.which)return String.fromCharCode(o.which)}return null;case"compositionend":return Om&&o.locale!=="ko"?null:o.data;default:return null}}var Dk={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Pm(t){var o=t&&t.nodeName&&t.nodeName.toLowerCase();return o==="input"?!!Dk[t.type]:o==="textarea"}function Hm(t,o,r,u){Za?Qa?Qa.push(u):Qa=[u]:Za=u,o=Ul(o,"onChange"),0<o.length&&(r=new Ji("onChange","change",null,r,u),t.push({event:r,listeners:o}))}var ar=null,sr=null;function zk(t){Cy(t,0)}function tl(t){var o=bo(t);if(Yi(o))return t}function Um(t,o){if(t==="change")return o}var Gm=!1;if(Kn){var Bu;if(Kn){var Pu="oninput"in document;if(!Pu){var qm=document.createElement("div");qm.setAttribute("oninput","return;"),Pu=typeof qm.oninput=="function"}Bu=Pu}else Bu=!1;Gm=Bu&&(!document.documentMode||9<document.documentMode)}function Km(){ar&&(ar.detachEvent("onpropertychange",Ym),sr=ar=null)}function Ym(t){if(t.propertyName==="value"&&tl(sr)){var o=[];Hm(o,sr,t,_u(t)),Am(zk,o)}}function Rk(t,o,r){t==="focusin"?(Km(),ar=o,sr=r,ar.attachEvent("onpropertychange",Ym)):t==="focusout"&&Km()}function $k(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return tl(sr)}function Ok(t,o){if(t==="click")return tl(o)}function Fk(t,o){if(t==="input"||t==="change")return tl(o)}function Ik(t,o){return t===o&&(t!==0||1/t===1/o)||t!==t&&o!==o}var Kt=typeof Object.is=="function"?Object.is:Ik;function rr(t,o){if(Kt(t,o))return!0;if(typeof t!="object"||t===null||typeof o!="object"||o===null)return!1;var r=Object.keys(t),u=Object.keys(o);if(r.length!==u.length)return!1;for(u=0;u<r.length;u++){var h=r[u];if(!ft.call(o,h)||!Kt(t[h],o[h]))return!1}return!0}function Vm(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Wm(t,o){var r=Vm(t);t=0;for(var u;r;){if(r.nodeType===3){if(u=t+r.textContent.length,t<=o&&u>=o)return{node:r,offset:o-t};t=u}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=Vm(r)}}function Xm(t,o){return t&&o?t===o?!0:t&&t.nodeType===3?!1:o&&o.nodeType===3?Xm(t,o.parentNode):"contains"in t?t.contains(o):t.compareDocumentPosition?!!(t.compareDocumentPosition(o)&16):!1:!1}function Zm(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var o=ia(t.document);o instanceof t.HTMLIFrameElement;){try{var r=typeof o.contentWindow.location.href=="string"}catch{r=!1}if(r)t=o.contentWindow;else break;o=ia(t.document)}return o}function Hu(t){var o=t&&t.nodeName&&t.nodeName.toLowerCase();return o&&(o==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||o==="textarea"||t.contentEditable==="true")}var Lk=Kn&&"documentMode"in document&&11>=document.documentMode,es=null,Uu=null,ir=null,Gu=!1;function Qm(t,o,r){var u=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;Gu||es==null||es!==ia(u)||(u=es,"selectionStart"in u&&Hu(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),ir&&rr(ir,u)||(ir=u,u=Ul(Uu,"onSelect"),0<u.length&&(o=new Ji("onSelect","select",null,o,r),t.push({event:o,listeners:u}),o.target=es)))}function ua(t,o){var r={};return r[t.toLowerCase()]=o.toLowerCase(),r["Webkit"+t]="webkit"+o,r["Moz"+t]="moz"+o,r}var ts={animationend:ua("Animation","AnimationEnd"),animationiteration:ua("Animation","AnimationIteration"),animationstart:ua("Animation","AnimationStart"),transitionrun:ua("Transition","TransitionRun"),transitionstart:ua("Transition","TransitionStart"),transitioncancel:ua("Transition","TransitionCancel"),transitionend:ua("Transition","TransitionEnd")},qu={},Jm={};Kn&&(Jm=document.createElement("div").style,"AnimationEvent"in window||(delete ts.animationend.animation,delete ts.animationiteration.animation,delete ts.animationstart.animation),"TransitionEvent"in window||delete ts.transitionend.transition);function da(t){if(qu[t])return qu[t];if(!ts[t])return t;var o=ts[t],r;for(r in o)if(o.hasOwnProperty(r)&&r in Jm)return qu[t]=o[r];return t}var eh=da("animationend"),th=da("animationiteration"),nh=da("animationstart"),Bk=da("transitionrun"),Pk=da("transitionstart"),Hk=da("transitioncancel"),oh=da("transitionend"),ah=new Map,Ku="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Ku.push("scrollEnd");function yn(t,o){ah.set(t,o),Un(o,[t])}var nl=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var o=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof t=="object"&&t!==null&&typeof t.message=="string"?String(t.message):String(t),error:t});if(!window.dispatchEvent(o))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)},nn=[],ns=0,Yu=0;function ol(){for(var t=ns,o=Yu=ns=0;o<t;){var r=nn[o];nn[o++]=null;var u=nn[o];nn[o++]=null;var h=nn[o];nn[o++]=null;var y=nn[o];if(nn[o++]=null,u!==null&&h!==null){var j=u.pending;j===null?h.next=h:(h.next=j.next,j.next=h),u.pending=h}y!==0&&sh(r,h,y)}}function al(t,o,r,u){nn[ns++]=t,nn[ns++]=o,nn[ns++]=r,nn[ns++]=u,Yu|=u,t.lanes|=u,t=t.alternate,t!==null&&(t.lanes|=u)}function Vu(t,o,r,u){return al(t,o,r,u),sl(t)}function pa(t,o){return al(t,null,null,o),sl(t)}function sh(t,o,r){t.lanes|=r;var u=t.alternate;u!==null&&(u.lanes|=r);for(var h=!1,y=t.return;y!==null;)y.childLanes|=r,u=y.alternate,u!==null&&(u.childLanes|=r),y.tag===22&&(t=y.stateNode,t===null||t._visibility&1||(h=!0)),t=y,y=y.return;return t.tag===3?(y=t.stateNode,h&&o!==null&&(h=31-zt(r),t=y.hiddenUpdates,u=t[h],u===null?t[h]=[o]:u.push(o),o.lane=r|536870912),y):null}function sl(t){if(50<Nr)throw Nr=0,op=null,Error(s(185));for(var o=t.return;o!==null;)t=o,o=t.return;return t.tag===3?t.stateNode:null}var os={};function Uk(t,o,r,u){this.tag=t,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Yt(t,o,r,u){return new Uk(t,o,r,u)}function Wu(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Yn(t,o){var r=t.alternate;return r===null?(r=Yt(t.tag,o,t.key,t.mode),r.elementType=t.elementType,r.type=t.type,r.stateNode=t.stateNode,r.alternate=t,t.alternate=r):(r.pendingProps=o,r.type=t.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=t.flags&65011712,r.childLanes=t.childLanes,r.lanes=t.lanes,r.child=t.child,r.memoizedProps=t.memoizedProps,r.memoizedState=t.memoizedState,r.updateQueue=t.updateQueue,o=t.dependencies,r.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},r.sibling=t.sibling,r.index=t.index,r.ref=t.ref,r.refCleanup=t.refCleanup,r}function rh(t,o){t.flags&=65011714;var r=t.alternate;return r===null?(t.childLanes=0,t.lanes=o,t.child=null,t.subtreeFlags=0,t.memoizedProps=null,t.memoizedState=null,t.updateQueue=null,t.dependencies=null,t.stateNode=null):(t.childLanes=r.childLanes,t.lanes=r.lanes,t.child=r.child,t.subtreeFlags=0,t.deletions=null,t.memoizedProps=r.memoizedProps,t.memoizedState=r.memoizedState,t.updateQueue=r.updateQueue,t.type=r.type,o=r.dependencies,t.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),t}function rl(t,o,r,u,h,y){var j=0;if(u=t,typeof t=="function")Wu(t)&&(j=1);else if(typeof t=="string")j=Vw(t,r,q.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(t){case P:return t=Yt(31,r,o,h),t.elementType=P,t.lanes=y,t;case w:return fa(r.children,h,y,o);case C:j=8,h|=24;break;case M:return t=Yt(12,r,o,h|2),t.elementType=M,t.lanes=y,t;case I:return t=Yt(13,r,o,h),t.elementType=I,t.lanes=y,t;case D:return t=Yt(19,r,o,h),t.elementType=D,t.lanes=y,t;default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case S:j=10;break e;case N:j=9;break e;case E:j=11;break e;case A:j=14;break e;case L:j=16,u=null;break e}j=29,r=Error(s(130,t===null?"null":typeof t,"")),u=null}return o=Yt(j,r,o,h),o.elementType=t,o.type=u,o.lanes=y,o}function fa(t,o,r,u){return t=Yt(7,t,u,o),t.lanes=r,t}function Xu(t,o,r){return t=Yt(6,t,null,o),t.lanes=r,t}function ih(t){var o=Yt(18,null,null,0);return o.stateNode=t,o}function Zu(t,o,r){return o=Yt(4,t.children!==null?t.children:[],t.key,o),o.lanes=r,o.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},o}var lh=new WeakMap;function on(t,o){if(typeof t=="object"&&t!==null){var r=lh.get(t);return r!==void 0?r:(o={value:t,source:o,stack:Tt(o)},lh.set(t,o),o)}return{value:t,source:o,stack:Tt(o)}}var as=[],ss=0,il=null,lr=0,an=[],sn=0,So=null,Nn=1,An="";function Vn(t,o){as[ss++]=lr,as[ss++]=il,il=t,lr=o}function ch(t,o,r){an[sn++]=Nn,an[sn++]=An,an[sn++]=So,So=t;var u=Nn;t=An;var h=32-zt(u)-1;u&=~(1<<h),r+=1;var y=32-zt(o)+h;if(30<y){var j=h-h%5;y=(u&(1<<j)-1).toString(32),u>>=j,h-=j,Nn=1<<32-zt(o)+h|r<<h|u,An=y+t}else Nn=1<<y|r<<h|u,An=t}function Qu(t){t.return!==null&&(Vn(t,1),ch(t,1,0))}function Ju(t){for(;t===il;)il=as[--ss],as[ss]=null,lr=as[--ss],as[ss]=null;for(;t===So;)So=an[--sn],an[sn]=null,An=an[--sn],an[sn]=null,Nn=an[--sn],an[sn]=null}function uh(t,o){an[sn++]=Nn,an[sn++]=An,an[sn++]=So,Nn=o.id,An=o.overflow,So=t}var wt=null,Xe=null,Oe=!1,Co=null,rn=!1,ed=Error(s(519));function Mo(t){var o=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw cr(on(o,t)),ed}function dh(t){var o=t.stateNode,r=t.type,u=t.memoizedProps;switch(o[mt]=t,o[Nt]=u,r){case"dialog":De("cancel",o),De("close",o);break;case"iframe":case"object":case"embed":De("load",o);break;case"video":case"audio":for(r=0;r<_r.length;r++)De(_r[r],o);break;case"source":De("error",o);break;case"img":case"image":case"link":De("error",o),De("load",o);break;case"details":De("toggle",o);break;case"input":De("invalid",o),Vi(o,u.value,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name,!0);break;case"select":De("invalid",o);break;case"textarea":De("invalid",o),Em(o,u.value,u.defaultValue,u.children)}r=u.children,typeof r!="string"&&typeof r!="number"&&typeof r!="bigint"||o.textContent===""+r||u.suppressHydrationWarning===!0||Ty(o.textContent,r)?(u.popover!=null&&(De("beforetoggle",o),De("toggle",o)),u.onScroll!=null&&De("scroll",o),u.onScrollEnd!=null&&De("scrollend",o),u.onClick!=null&&(o.onclick=qn),o=!0):o=!1,o||Mo(t,!0)}function ph(t){for(wt=t.return;wt;)switch(wt.tag){case 5:case 31:case 13:rn=!1;return;case 27:case 3:rn=!0;return;default:wt=wt.return}}function rs(t){if(t!==wt)return!1;if(!Oe)return ph(t),Oe=!0,!1;var o=t.tag,r;if((r=o!==3&&o!==27)&&((r=o===5)&&(r=t.type,r=!(r!=="form"&&r!=="button")||xp(t.type,t.memoizedProps)),r=!r),r&&Xe&&Mo(t),ph(t),o===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(317));Xe=Fy(t)}else if(o===31){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(317));Xe=Fy(t)}else o===27?(o=Xe,Lo(t.type)?(t=Sp,Sp=null,Xe=t):Xe=o):Xe=wt?cn(t.stateNode.nextSibling):null;return!0}function ma(){Xe=wt=null,Oe=!1}function td(){var t=Co;return t!==null&&(Pt===null?Pt=t:Pt.push.apply(Pt,t),Co=null),t}function cr(t){Co===null?Co=[t]:Co.push(t)}var nd=F(null),ha=null,Wn=null;function Eo(t,o,r){Q(nd,o._currentValue),o._currentValue=r}function Xn(t){t._currentValue=nd.current,O(nd)}function od(t,o,r){for(;t!==null;){var u=t.alternate;if((t.childLanes&o)!==o?(t.childLanes|=o,u!==null&&(u.childLanes|=o)):u!==null&&(u.childLanes&o)!==o&&(u.childLanes|=o),t===r)break;t=t.return}}function ad(t,o,r,u){var h=t.child;for(h!==null&&(h.return=t);h!==null;){var y=h.dependencies;if(y!==null){var j=h.child;y=y.firstContext;e:for(;y!==null;){var R=y;y=h;for(var Y=0;Y<o.length;Y++)if(R.context===o[Y]){y.lanes|=r,R=y.alternate,R!==null&&(R.lanes|=r),od(y.return,r,t),u||(j=null);break e}y=R.next}}else if(h.tag===18){if(j=h.return,j===null)throw Error(s(341));j.lanes|=r,y=j.alternate,y!==null&&(y.lanes|=r),od(j,r,t),j=null}else j=h.child;if(j!==null)j.return=h;else for(j=h;j!==null;){if(j===t){j=null;break}if(h=j.sibling,h!==null){h.return=j.return,j=h;break}j=j.return}h=j}}function is(t,o,r,u){t=null;for(var h=o,y=!1;h!==null;){if(!y){if((h.flags&524288)!==0)y=!0;else if((h.flags&262144)!==0)break}if(h.tag===10){var j=h.alternate;if(j===null)throw Error(s(387));if(j=j.memoizedProps,j!==null){var R=h.type;Kt(h.pendingProps.value,j.value)||(t!==null?t.push(R):t=[R])}}else if(h===me.current){if(j=h.alternate,j===null)throw Error(s(387));j.memoizedState.memoizedState!==h.memoizedState.memoizedState&&(t!==null?t.push(Or):t=[Or])}h=h.return}t!==null&&ad(o,t,r,u),o.flags|=262144}function ll(t){for(t=t.firstContext;t!==null;){if(!Kt(t.context._currentValue,t.memoizedValue))return!0;t=t.next}return!1}function ga(t){ha=t,Wn=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function St(t){return fh(ha,t)}function cl(t,o){return ha===null&&ga(t),fh(t,o)}function fh(t,o){var r=o._currentValue;if(o={context:o,memoizedValue:r,next:null},Wn===null){if(t===null)throw Error(s(308));Wn=o,t.dependencies={lanes:0,firstContext:o},t.flags|=524288}else Wn=Wn.next=o;return r}var Gk=typeof AbortController<"u"?AbortController:function(){var t=[],o=this.signal={aborted:!1,addEventListener:function(r,u){t.push(u)}};this.abort=function(){o.aborted=!0,t.forEach(function(r){return r()})}},qk=e.unstable_scheduleCallback,Kk=e.unstable_NormalPriority,lt={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function sd(){return{controller:new Gk,data:new Map,refCount:0}}function ur(t){t.refCount--,t.refCount===0&&qk(Kk,function(){t.controller.abort()})}var dr=null,rd=0,ls=0,cs=null;function Yk(t,o){if(dr===null){var r=dr=[];rd=0,ls=cp(),cs={status:"pending",value:void 0,then:function(u){r.push(u)}}}return rd++,o.then(mh,mh),o}function mh(){if(--rd===0&&dr!==null){cs!==null&&(cs.status="fulfilled");var t=dr;dr=null,ls=0,cs=null;for(var o=0;o<t.length;o++)(0,t[o])()}}function Vk(t,o){var r=[],u={status:"pending",value:null,reason:null,then:function(h){r.push(h)}};return t.then(function(){u.status="fulfilled",u.value=o;for(var h=0;h<r.length;h++)(0,r[h])(o)},function(h){for(u.status="rejected",u.reason=h,h=0;h<r.length;h++)(0,r[h])(void 0)}),u}var hh=T.S;T.S=function(t,o){Qg=kt(),typeof o=="object"&&o!==null&&typeof o.then=="function"&&Yk(t,o),hh!==null&&hh(t,o)};var ya=F(null);function id(){var t=ya.current;return t!==null?t:Ve.pooledCache}function ul(t,o){o===null?Q(ya,ya.current):Q(ya,o.pool)}function gh(){var t=id();return t===null?null:{parent:lt._currentValue,pool:t}}var us=Error(s(460)),ld=Error(s(474)),dl=Error(s(542)),pl={then:function(){}};function yh(t){return t=t.status,t==="fulfilled"||t==="rejected"}function xh(t,o,r){switch(r=t[r],r===void 0?t.push(o):r!==o&&(o.then(qn,qn),o=r),o.status){case"fulfilled":return o.value;case"rejected":throw t=o.reason,vh(t),t;default:if(typeof o.status=="string")o.then(qn,qn);else{if(t=Ve,t!==null&&100<t.shellSuspendCounter)throw Error(s(482));t=o,t.status="pending",t.then(function(u){if(o.status==="pending"){var h=o;h.status="fulfilled",h.value=u}},function(u){if(o.status==="pending"){var h=o;h.status="rejected",h.reason=u}})}switch(o.status){case"fulfilled":return o.value;case"rejected":throw t=o.reason,vh(t),t}throw ba=o,us}}function xa(t){try{var o=t._init;return o(t._payload)}catch(r){throw r!==null&&typeof r=="object"&&typeof r.then=="function"?(ba=r,us):r}}var ba=null;function bh(){if(ba===null)throw Error(s(459));var t=ba;return ba=null,t}function vh(t){if(t===us||t===dl)throw Error(s(483))}var ds=null,pr=0;function fl(t){var o=pr;return pr+=1,ds===null&&(ds=[]),xh(ds,t,o)}function fr(t,o){o=o.props.ref,t.ref=o!==void 0?o:null}function ml(t,o){throw o.$$typeof===b?Error(s(525)):(t=Object.prototype.toString.call(o),Error(s(31,t==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":t)))}function kh(t){function o(ee,Z){if(t){var ne=ee.deletions;ne===null?(ee.deletions=[Z],ee.flags|=16):ne.push(Z)}}function r(ee,Z){if(!t)return null;for(;Z!==null;)o(ee,Z),Z=Z.sibling;return null}function u(ee){for(var Z=new Map;ee!==null;)ee.key!==null?Z.set(ee.key,ee):Z.set(ee.index,ee),ee=ee.sibling;return Z}function h(ee,Z){return ee=Yn(ee,Z),ee.index=0,ee.sibling=null,ee}function y(ee,Z,ne){return ee.index=ne,t?(ne=ee.alternate,ne!==null?(ne=ne.index,ne<Z?(ee.flags|=67108866,Z):ne):(ee.flags|=67108866,Z)):(ee.flags|=1048576,Z)}function j(ee){return t&&ee.alternate===null&&(ee.flags|=67108866),ee}function R(ee,Z,ne,ue){return Z===null||Z.tag!==6?(Z=Xu(ne,ee.mode,ue),Z.return=ee,Z):(Z=h(Z,ne),Z.return=ee,Z)}function Y(ee,Z,ne,ue){var Ce=ne.type;return Ce===w?le(ee,Z,ne.props.children,ue,ne.key):Z!==null&&(Z.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===L&&xa(Ce)===Z.type)?(Z=h(Z,ne.props),fr(Z,ne),Z.return=ee,Z):(Z=rl(ne.type,ne.key,ne.props,null,ee.mode,ue),fr(Z,ne),Z.return=ee,Z)}function oe(ee,Z,ne,ue){return Z===null||Z.tag!==4||Z.stateNode.containerInfo!==ne.containerInfo||Z.stateNode.implementation!==ne.implementation?(Z=Zu(ne,ee.mode,ue),Z.return=ee,Z):(Z=h(Z,ne.children||[]),Z.return=ee,Z)}function le(ee,Z,ne,ue,Ce){return Z===null||Z.tag!==7?(Z=fa(ne,ee.mode,ue,Ce),Z.return=ee,Z):(Z=h(Z,ne),Z.return=ee,Z)}function de(ee,Z,ne){if(typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint")return Z=Xu(""+Z,ee.mode,ne),Z.return=ee,Z;if(typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case v:return ne=rl(Z.type,Z.key,Z.props,null,ee.mode,ne),fr(ne,Z),ne.return=ee,ne;case k:return Z=Zu(Z,ee.mode,ne),Z.return=ee,Z;case L:return Z=xa(Z),de(ee,Z,ne)}if(_(Z)||V(Z))return Z=fa(Z,ee.mode,ne,null),Z.return=ee,Z;if(typeof Z.then=="function")return de(ee,fl(Z),ne);if(Z.$$typeof===S)return de(ee,cl(ee,Z),ne);ml(ee,Z)}return null}function ae(ee,Z,ne,ue){var Ce=Z!==null?Z.key:null;if(typeof ne=="string"&&ne!==""||typeof ne=="number"||typeof ne=="bigint")return Ce!==null?null:R(ee,Z,""+ne,ue);if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case v:return ne.key===Ce?Y(ee,Z,ne,ue):null;case k:return ne.key===Ce?oe(ee,Z,ne,ue):null;case L:return ne=xa(ne),ae(ee,Z,ne,ue)}if(_(ne)||V(ne))return Ce!==null?null:le(ee,Z,ne,ue,null);if(typeof ne.then=="function")return ae(ee,Z,fl(ne),ue);if(ne.$$typeof===S)return ae(ee,Z,cl(ee,ne),ue);ml(ee,ne)}return null}function re(ee,Z,ne,ue,Ce){if(typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint")return ee=ee.get(ne)||null,R(Z,ee,""+ue,Ce);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case v:return ee=ee.get(ue.key===null?ne:ue.key)||null,Y(Z,ee,ue,Ce);case k:return ee=ee.get(ue.key===null?ne:ue.key)||null,oe(Z,ee,ue,Ce);case L:return ue=xa(ue),re(ee,Z,ne,ue,Ce)}if(_(ue)||V(ue))return ee=ee.get(ne)||null,le(Z,ee,ue,Ce,null);if(typeof ue.then=="function")return re(ee,Z,ne,fl(ue),Ce);if(ue.$$typeof===S)return re(ee,Z,ne,cl(Z,ue),Ce);ml(Z,ue)}return null}function xe(ee,Z,ne,ue){for(var Ce=null,Le=null,ve=Z,Ae=Z=0,$e=null;ve!==null&&Ae<ne.length;Ae++){ve.index>Ae?($e=ve,ve=null):$e=ve.sibling;var Be=ae(ee,ve,ne[Ae],ue);if(Be===null){ve===null&&(ve=$e);break}t&&ve&&Be.alternate===null&&o(ee,ve),Z=y(Be,Z,Ae),Le===null?Ce=Be:Le.sibling=Be,Le=Be,ve=$e}if(Ae===ne.length)return r(ee,ve),Oe&&Vn(ee,Ae),Ce;if(ve===null){for(;Ae<ne.length;Ae++)ve=de(ee,ne[Ae],ue),ve!==null&&(Z=y(ve,Z,Ae),Le===null?Ce=ve:Le.sibling=ve,Le=ve);return Oe&&Vn(ee,Ae),Ce}for(ve=u(ve);Ae<ne.length;Ae++)$e=re(ve,ee,Ae,ne[Ae],ue),$e!==null&&(t&&$e.alternate!==null&&ve.delete($e.key===null?Ae:$e.key),Z=y($e,Z,Ae),Le===null?Ce=$e:Le.sibling=$e,Le=$e);return t&&ve.forEach(function(Go){return o(ee,Go)}),Oe&&Vn(ee,Ae),Ce}function Me(ee,Z,ne,ue){if(ne==null)throw Error(s(151));for(var Ce=null,Le=null,ve=Z,Ae=Z=0,$e=null,Be=ne.next();ve!==null&&!Be.done;Ae++,Be=ne.next()){ve.index>Ae?($e=ve,ve=null):$e=ve.sibling;var Go=ae(ee,ve,Be.value,ue);if(Go===null){ve===null&&(ve=$e);break}t&&ve&&Go.alternate===null&&o(ee,ve),Z=y(Go,Z,Ae),Le===null?Ce=Go:Le.sibling=Go,Le=Go,ve=$e}if(Be.done)return r(ee,ve),Oe&&Vn(ee,Ae),Ce;if(ve===null){for(;!Be.done;Ae++,Be=ne.next())Be=de(ee,Be.value,ue),Be!==null&&(Z=y(Be,Z,Ae),Le===null?Ce=Be:Le.sibling=Be,Le=Be);return Oe&&Vn(ee,Ae),Ce}for(ve=u(ve);!Be.done;Ae++,Be=ne.next())Be=re(ve,ee,Ae,Be.value,ue),Be!==null&&(t&&Be.alternate!==null&&ve.delete(Be.key===null?Ae:Be.key),Z=y(Be,Z,Ae),Le===null?Ce=Be:Le.sibling=Be,Le=Be);return t&&ve.forEach(function(sS){return o(ee,sS)}),Oe&&Vn(ee,Ae),Ce}function Ke(ee,Z,ne,ue){if(typeof ne=="object"&&ne!==null&&ne.type===w&&ne.key===null&&(ne=ne.props.children),typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case v:e:{for(var Ce=ne.key;Z!==null;){if(Z.key===Ce){if(Ce=ne.type,Ce===w){if(Z.tag===7){r(ee,Z.sibling),ue=h(Z,ne.props.children),ue.return=ee,ee=ue;break e}}else if(Z.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===L&&xa(Ce)===Z.type){r(ee,Z.sibling),ue=h(Z,ne.props),fr(ue,ne),ue.return=ee,ee=ue;break e}r(ee,Z);break}else o(ee,Z);Z=Z.sibling}ne.type===w?(ue=fa(ne.props.children,ee.mode,ue,ne.key),ue.return=ee,ee=ue):(ue=rl(ne.type,ne.key,ne.props,null,ee.mode,ue),fr(ue,ne),ue.return=ee,ee=ue)}return j(ee);case k:e:{for(Ce=ne.key;Z!==null;){if(Z.key===Ce)if(Z.tag===4&&Z.stateNode.containerInfo===ne.containerInfo&&Z.stateNode.implementation===ne.implementation){r(ee,Z.sibling),ue=h(Z,ne.children||[]),ue.return=ee,ee=ue;break e}else{r(ee,Z);break}else o(ee,Z);Z=Z.sibling}ue=Zu(ne,ee.mode,ue),ue.return=ee,ee=ue}return j(ee);case L:return ne=xa(ne),Ke(ee,Z,ne,ue)}if(_(ne))return xe(ee,Z,ne,ue);if(V(ne)){if(Ce=V(ne),typeof Ce!="function")throw Error(s(150));return ne=Ce.call(ne),Me(ee,Z,ne,ue)}if(typeof ne.then=="function")return Ke(ee,Z,fl(ne),ue);if(ne.$$typeof===S)return Ke(ee,Z,cl(ee,ne),ue);ml(ee,ne)}return typeof ne=="string"&&ne!==""||typeof ne=="number"||typeof ne=="bigint"?(ne=""+ne,Z!==null&&Z.tag===6?(r(ee,Z.sibling),ue=h(Z,ne),ue.return=ee,ee=ue):(r(ee,Z),ue=Xu(ne,ee.mode,ue),ue.return=ee,ee=ue),j(ee)):r(ee,Z)}return function(ee,Z,ne,ue){try{pr=0;var Ce=Ke(ee,Z,ne,ue);return ds=null,Ce}catch(ve){if(ve===us||ve===dl)throw ve;var Le=Yt(29,ve,null,ee.mode);return Le.lanes=ue,Le.return=ee,Le}}}var va=kh(!0),wh=kh(!1),jo=!1;function cd(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ud(t,o){t=t.updateQueue,o.updateQueue===t&&(o.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function To(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function No(t,o,r){var u=t.updateQueue;if(u===null)return null;if(u=u.shared,(Pe&2)!==0){var h=u.pending;return h===null?o.next=o:(o.next=h.next,h.next=o),u.pending=o,o=sl(t),sh(t,null,r),o}return al(t,u,o,r),sl(t)}function mr(t,o,r){if(o=o.updateQueue,o!==null&&(o=o.shared,(r&4194048)!==0)){var u=o.lanes;u&=t.pendingLanes,r|=u,o.lanes=r,Fi(t,r)}}function dd(t,o){var r=t.updateQueue,u=t.alternate;if(u!==null&&(u=u.updateQueue,r===u)){var h=null,y=null;if(r=r.firstBaseUpdate,r!==null){do{var j={lane:r.lane,tag:r.tag,payload:r.payload,callback:null,next:null};y===null?h=y=j:y=y.next=j,r=r.next}while(r!==null);y===null?h=y=o:y=y.next=o}else h=y=o;r={baseState:u.baseState,firstBaseUpdate:h,lastBaseUpdate:y,shared:u.shared,callbacks:u.callbacks},t.updateQueue=r;return}t=r.lastBaseUpdate,t===null?r.firstBaseUpdate=o:t.next=o,r.lastBaseUpdate=o}var pd=!1;function hr(){if(pd){var t=cs;if(t!==null)throw t}}function gr(t,o,r,u){pd=!1;var h=t.updateQueue;jo=!1;var y=h.firstBaseUpdate,j=h.lastBaseUpdate,R=h.shared.pending;if(R!==null){h.shared.pending=null;var Y=R,oe=Y.next;Y.next=null,j===null?y=oe:j.next=oe,j=Y;var le=t.alternate;le!==null&&(le=le.updateQueue,R=le.lastBaseUpdate,R!==j&&(R===null?le.firstBaseUpdate=oe:R.next=oe,le.lastBaseUpdate=Y))}if(y!==null){var de=h.baseState;j=0,le=oe=Y=null,R=y;do{var ae=R.lane&-536870913,re=ae!==R.lane;if(re?(Re&ae)===ae:(u&ae)===ae){ae!==0&&ae===ls&&(pd=!0),le!==null&&(le=le.next={lane:0,tag:R.tag,payload:R.payload,callback:null,next:null});e:{var xe=t,Me=R;ae=o;var Ke=r;switch(Me.tag){case 1:if(xe=Me.payload,typeof xe=="function"){de=xe.call(Ke,de,ae);break e}de=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=Me.payload,ae=typeof xe=="function"?xe.call(Ke,de,ae):xe,ae==null)break e;de=x({},de,ae);break e;case 2:jo=!0}}ae=R.callback,ae!==null&&(t.flags|=64,re&&(t.flags|=8192),re=h.callbacks,re===null?h.callbacks=[ae]:re.push(ae))}else re={lane:ae,tag:R.tag,payload:R.payload,callback:R.callback,next:null},le===null?(oe=le=re,Y=de):le=le.next=re,j|=ae;if(R=R.next,R===null){if(R=h.shared.pending,R===null)break;re=R,R=re.next,re.next=null,h.lastBaseUpdate=re,h.shared.pending=null}}while(!0);le===null&&(Y=de),h.baseState=Y,h.firstBaseUpdate=oe,h.lastBaseUpdate=le,y===null&&(h.shared.lanes=0),Ro|=j,t.lanes=j,t.memoizedState=de}}function Sh(t,o){if(typeof t!="function")throw Error(s(191,t));t.call(o)}function Ch(t,o){var r=t.callbacks;if(r!==null)for(t.callbacks=null,t=0;t<r.length;t++)Sh(r[t],o)}var ps=F(null),hl=F(0);function Mh(t,o){t=so,Q(hl,t),Q(ps,o),so=t|o.baseLanes}function fd(){Q(hl,so),Q(ps,ps.current)}function md(){so=hl.current,O(ps),O(hl)}var Vt=F(null),ln=null;function Ao(t){var o=t.alternate;Q(st,st.current&1),Q(Vt,t),ln===null&&(o===null||ps.current!==null||o.memoizedState!==null)&&(ln=t)}function hd(t){Q(st,st.current),Q(Vt,t),ln===null&&(ln=t)}function Eh(t){t.tag===22?(Q(st,st.current),Q(Vt,t),ln===null&&(ln=t)):_o()}function _o(){Q(st,st.current),Q(Vt,Vt.current)}function Wt(t){O(Vt),ln===t&&(ln=null),O(st)}var st=F(0);function gl(t){for(var o=t;o!==null;){if(o.tag===13){var r=o.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||kp(r)||wp(r)))return o}else if(o.tag===19&&(o.memoizedProps.revealOrder==="forwards"||o.memoizedProps.revealOrder==="backwards"||o.memoizedProps.revealOrder==="unstable_legacy-backwards"||o.memoizedProps.revealOrder==="together")){if((o.flags&128)!==0)return o}else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===t)break;for(;o.sibling===null;){if(o.return===null||o.return===t)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var Zn=0,Ne=null,Ge=null,ct=null,yl=!1,fs=!1,ka=!1,xl=0,yr=0,ms=null,Wk=0;function nt(){throw Error(s(321))}function gd(t,o){if(o===null)return!1;for(var r=0;r<o.length&&r<t.length;r++)if(!Kt(t[r],o[r]))return!1;return!0}function yd(t,o,r,u,h,y){return Zn=y,Ne=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,T.H=t===null||t.memoizedState===null?cg:Dd,ka=!1,y=r(u,h),ka=!1,fs&&(y=Th(o,r,u,h)),jh(t),y}function jh(t){T.H=vr;var o=Ge!==null&&Ge.next!==null;if(Zn=0,ct=Ge=Ne=null,yl=!1,yr=0,ms=null,o)throw Error(s(300));t===null||ut||(t=t.dependencies,t!==null&&ll(t)&&(ut=!0))}function Th(t,o,r,u){Ne=t;var h=0;do{if(fs&&(ms=null),yr=0,fs=!1,25<=h)throw Error(s(301));if(h+=1,ct=Ge=null,t.updateQueue!=null){var y=t.updateQueue;y.lastEffect=null,y.events=null,y.stores=null,y.memoCache!=null&&(y.memoCache.index=0)}T.H=ug,y=o(r,u)}while(fs);return y}function Xk(){var t=T.H,o=t.useState()[0];return o=typeof o.then=="function"?xr(o):o,t=t.useState()[0],(Ge!==null?Ge.memoizedState:null)!==t&&(Ne.flags|=1024),o}function xd(){var t=xl!==0;return xl=0,t}function bd(t,o,r){o.updateQueue=t.updateQueue,o.flags&=-2053,t.lanes&=~r}function vd(t){if(yl){for(t=t.memoizedState;t!==null;){var o=t.queue;o!==null&&(o.pending=null),t=t.next}yl=!1}Zn=0,ct=Ge=Ne=null,fs=!1,yr=xl=0,ms=null}function Rt(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ct===null?Ne.memoizedState=ct=t:ct=ct.next=t,ct}function rt(){if(Ge===null){var t=Ne.alternate;t=t!==null?t.memoizedState:null}else t=Ge.next;var o=ct===null?Ne.memoizedState:ct.next;if(o!==null)ct=o,Ge=t;else{if(t===null)throw Ne.alternate===null?Error(s(467)):Error(s(310));Ge=t,t={memoizedState:Ge.memoizedState,baseState:Ge.baseState,baseQueue:Ge.baseQueue,queue:Ge.queue,next:null},ct===null?Ne.memoizedState=ct=t:ct=ct.next=t}return ct}function bl(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function xr(t){var o=yr;return yr+=1,ms===null&&(ms=[]),t=xh(ms,t,o),o=Ne,(ct===null?o.memoizedState:ct.next)===null&&(o=o.alternate,T.H=o===null||o.memoizedState===null?cg:Dd),t}function vl(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return xr(t);if(t.$$typeof===S)return St(t)}throw Error(s(438,String(t)))}function kd(t){var o=null,r=Ne.updateQueue;if(r!==null&&(o=r.memoCache),o==null){var u=Ne.alternate;u!==null&&(u=u.updateQueue,u!==null&&(u=u.memoCache,u!=null&&(o={data:u.data.map(function(h){return h.slice()}),index:0})))}if(o==null&&(o={data:[],index:0}),r===null&&(r=bl(),Ne.updateQueue=r),r.memoCache=o,r=o.data[o.index],r===void 0)for(r=o.data[o.index]=Array(t),u=0;u<t;u++)r[u]=W;return o.index++,r}function Qn(t,o){return typeof o=="function"?o(t):o}function kl(t){var o=rt();return wd(o,Ge,t)}function wd(t,o,r){var u=t.queue;if(u===null)throw Error(s(311));u.lastRenderedReducer=r;var h=t.baseQueue,y=u.pending;if(y!==null){if(h!==null){var j=h.next;h.next=y.next,y.next=j}o.baseQueue=h=y,u.pending=null}if(y=t.baseState,h===null)t.memoizedState=y;else{o=h.next;var R=j=null,Y=null,oe=o,le=!1;do{var de=oe.lane&-536870913;if(de!==oe.lane?(Re&de)===de:(Zn&de)===de){var ae=oe.revertLane;if(ae===0)Y!==null&&(Y=Y.next={lane:0,revertLane:0,gesture:null,action:oe.action,hasEagerState:oe.hasEagerState,eagerState:oe.eagerState,next:null}),de===ls&&(le=!0);else if((Zn&ae)===ae){oe=oe.next,ae===ls&&(le=!0);continue}else de={lane:0,revertLane:oe.revertLane,gesture:null,action:oe.action,hasEagerState:oe.hasEagerState,eagerState:oe.eagerState,next:null},Y===null?(R=Y=de,j=y):Y=Y.next=de,Ne.lanes|=ae,Ro|=ae;de=oe.action,ka&&r(y,de),y=oe.hasEagerState?oe.eagerState:r(y,de)}else ae={lane:de,revertLane:oe.revertLane,gesture:oe.gesture,action:oe.action,hasEagerState:oe.hasEagerState,eagerState:oe.eagerState,next:null},Y===null?(R=Y=ae,j=y):Y=Y.next=ae,Ne.lanes|=de,Ro|=de;oe=oe.next}while(oe!==null&&oe!==o);if(Y===null?j=y:Y.next=R,!Kt(y,t.memoizedState)&&(ut=!0,le&&(r=cs,r!==null)))throw r;t.memoizedState=y,t.baseState=j,t.baseQueue=Y,u.lastRenderedState=y}return h===null&&(u.lanes=0),[t.memoizedState,u.dispatch]}function Sd(t){var o=rt(),r=o.queue;if(r===null)throw Error(s(311));r.lastRenderedReducer=t;var u=r.dispatch,h=r.pending,y=o.memoizedState;if(h!==null){r.pending=null;var j=h=h.next;do y=t(y,j.action),j=j.next;while(j!==h);Kt(y,o.memoizedState)||(ut=!0),o.memoizedState=y,o.baseQueue===null&&(o.baseState=y),r.lastRenderedState=y}return[y,u]}function Nh(t,o,r){var u=Ne,h=rt(),y=Oe;if(y){if(r===void 0)throw Error(s(407));r=r()}else r=o();var j=!Kt((Ge||h).memoizedState,r);if(j&&(h.memoizedState=r,ut=!0),h=h.queue,Ed(Dh.bind(null,u,h,t),[t]),h.getSnapshot!==o||j||ct!==null&&ct.memoizedState.tag&1){if(u.flags|=2048,hs(9,{destroy:void 0},_h.bind(null,u,h,r,o),null),Ve===null)throw Error(s(349));y||(Zn&127)!==0||Ah(u,o,r)}return r}function Ah(t,o,r){t.flags|=16384,t={getSnapshot:o,value:r},o=Ne.updateQueue,o===null?(o=bl(),Ne.updateQueue=o,o.stores=[t]):(r=o.stores,r===null?o.stores=[t]:r.push(t))}function _h(t,o,r,u){o.value=r,o.getSnapshot=u,zh(o)&&Rh(t)}function Dh(t,o,r){return r(function(){zh(o)&&Rh(t)})}function zh(t){var o=t.getSnapshot;t=t.value;try{var r=o();return!Kt(t,r)}catch{return!0}}function Rh(t){var o=pa(t,2);o!==null&&Ht(o,t,2)}function Cd(t){var o=Rt();if(typeof t=="function"){var r=t;if(t=r(),ka){jn(!0);try{r()}finally{jn(!1)}}}return o.memoizedState=o.baseState=t,o.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qn,lastRenderedState:t},o}function $h(t,o,r,u){return t.baseState=r,wd(t,Ge,typeof u=="function"?u:Qn)}function Zk(t,o,r,u,h){if(Cl(t))throw Error(s(485));if(t=o.action,t!==null){var y={payload:h,action:t,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(j){y.listeners.push(j)}};T.T!==null?r(!0):y.isTransition=!1,u(y),r=o.pending,r===null?(y.next=o.pending=y,Oh(o,y)):(y.next=r.next,o.pending=r.next=y)}}function Oh(t,o){var r=o.action,u=o.payload,h=t.state;if(o.isTransition){var y=T.T,j={};T.T=j;try{var R=r(h,u),Y=T.S;Y!==null&&Y(j,R),Fh(t,o,R)}catch(oe){Md(t,o,oe)}finally{y!==null&&j.types!==null&&(y.types=j.types),T.T=y}}else try{y=r(h,u),Fh(t,o,y)}catch(oe){Md(t,o,oe)}}function Fh(t,o,r){r!==null&&typeof r=="object"&&typeof r.then=="function"?r.then(function(u){Ih(t,o,u)},function(u){return Md(t,o,u)}):Ih(t,o,r)}function Ih(t,o,r){o.status="fulfilled",o.value=r,Lh(o),t.state=r,o=t.pending,o!==null&&(r=o.next,r===o?t.pending=null:(r=r.next,o.next=r,Oh(t,r)))}function Md(t,o,r){var u=t.pending;if(t.pending=null,u!==null){u=u.next;do o.status="rejected",o.reason=r,Lh(o),o=o.next;while(o!==u)}t.action=null}function Lh(t){t=t.listeners;for(var o=0;o<t.length;o++)(0,t[o])()}function Bh(t,o){return o}function Ph(t,o){if(Oe){var r=Ve.formState;if(r!==null){e:{var u=Ne;if(Oe){if(Xe){t:{for(var h=Xe,y=rn;h.nodeType!==8;){if(!y){h=null;break t}if(h=cn(h.nextSibling),h===null){h=null;break t}}y=h.data,h=y==="F!"||y==="F"?h:null}if(h){Xe=cn(h.nextSibling),u=h.data==="F!";break e}}Mo(u)}u=!1}u&&(o=r[0])}}return r=Rt(),r.memoizedState=r.baseState=o,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bh,lastRenderedState:o},r.queue=u,r=rg.bind(null,Ne,u),u.dispatch=r,u=Cd(!1),y=_d.bind(null,Ne,!1,u.queue),u=Rt(),h={state:o,dispatch:null,action:t,pending:null},u.queue=h,r=Zk.bind(null,Ne,h,y,r),h.dispatch=r,u.memoizedState=t,[o,r,!1]}function Hh(t){var o=rt();return Uh(o,Ge,t)}function Uh(t,o,r){if(o=wd(t,o,Bh)[0],t=kl(Qn)[0],typeof o=="object"&&o!==null&&typeof o.then=="function")try{var u=xr(o)}catch(j){throw j===us?dl:j}else u=o;o=rt();var h=o.queue,y=h.dispatch;return r!==o.memoizedState&&(Ne.flags|=2048,hs(9,{destroy:void 0},Qk.bind(null,h,r),null)),[u,y,t]}function Qk(t,o){t.action=o}function Gh(t){var o=rt(),r=Ge;if(r!==null)return Uh(o,r,t);rt(),o=o.memoizedState,r=rt();var u=r.queue.dispatch;return r.memoizedState=t,[o,u,!1]}function hs(t,o,r,u){return t={tag:t,create:r,deps:u,inst:o,next:null},o=Ne.updateQueue,o===null&&(o=bl(),Ne.updateQueue=o),r=o.lastEffect,r===null?o.lastEffect=t.next=t:(u=r.next,r.next=t,t.next=u,o.lastEffect=t),t}function qh(){return rt().memoizedState}function wl(t,o,r,u){var h=Rt();Ne.flags|=t,h.memoizedState=hs(1|o,{destroy:void 0},r,u===void 0?null:u)}function Sl(t,o,r,u){var h=rt();u=u===void 0?null:u;var y=h.memoizedState.inst;Ge!==null&&u!==null&&gd(u,Ge.memoizedState.deps)?h.memoizedState=hs(o,y,r,u):(Ne.flags|=t,h.memoizedState=hs(1|o,y,r,u))}function Kh(t,o){wl(8390656,8,t,o)}function Ed(t,o){Sl(2048,8,t,o)}function Jk(t){Ne.flags|=4;var o=Ne.updateQueue;if(o===null)o=bl(),Ne.updateQueue=o,o.events=[t];else{var r=o.events;r===null?o.events=[t]:r.push(t)}}function Yh(t){var o=rt().memoizedState;return Jk({ref:o,nextImpl:t}),function(){if((Pe&2)!==0)throw Error(s(440));return o.impl.apply(void 0,arguments)}}function Vh(t,o){return Sl(4,2,t,o)}function Wh(t,o){return Sl(4,4,t,o)}function Xh(t,o){if(typeof o=="function"){t=t();var r=o(t);return function(){typeof r=="function"?r():o(null)}}if(o!=null)return t=t(),o.current=t,function(){o.current=null}}function Zh(t,o,r){r=r!=null?r.concat([t]):null,Sl(4,4,Xh.bind(null,o,t),r)}function jd(){}function Qh(t,o){var r=rt();o=o===void 0?null:o;var u=r.memoizedState;return o!==null&&gd(o,u[1])?u[0]:(r.memoizedState=[t,o],t)}function Jh(t,o){var r=rt();o=o===void 0?null:o;var u=r.memoizedState;if(o!==null&&gd(o,u[1]))return u[0];if(u=t(),ka){jn(!0);try{t()}finally{jn(!1)}}return r.memoizedState=[u,o],u}function Td(t,o,r){return r===void 0||(Zn&1073741824)!==0&&(Re&261930)===0?t.memoizedState=o:(t.memoizedState=r,t=ey(),Ne.lanes|=t,Ro|=t,r)}function eg(t,o,r,u){return Kt(r,o)?r:ps.current!==null?(t=Td(t,r,u),Kt(t,o)||(ut=!0),t):(Zn&42)===0||(Zn&1073741824)!==0&&(Re&261930)===0?(ut=!0,t.memoizedState=r):(t=ey(),Ne.lanes|=t,Ro|=t,o)}function tg(t,o,r,u,h){var y=B.p;B.p=y!==0&&8>y?y:8;var j=T.T,R={};T.T=R,_d(t,!1,o,r);try{var Y=h(),oe=T.S;if(oe!==null&&oe(R,Y),Y!==null&&typeof Y=="object"&&typeof Y.then=="function"){var le=Vk(Y,u);br(t,o,le,Qt(t))}else br(t,o,u,Qt(t))}catch(de){br(t,o,{then:function(){},status:"rejected",reason:de},Qt())}finally{B.p=y,j!==null&&R.types!==null&&(j.types=R.types),T.T=j}}function ew(){}function Nd(t,o,r,u){if(t.tag!==5)throw Error(s(476));var h=ng(t).queue;tg(t,h,o,G,r===null?ew:function(){return og(t),r(u)})}function ng(t){var o=t.memoizedState;if(o!==null)return o;o={memoizedState:G,baseState:G,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qn,lastRenderedState:G},next:null};var r={};return o.next={memoizedState:r,baseState:r,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Qn,lastRenderedState:r},next:null},t.memoizedState=o,t=t.alternate,t!==null&&(t.memoizedState=o),o}function og(t){var o=ng(t);o.next===null&&(o=t.alternate.memoizedState),br(t,o.next.queue,{},Qt())}function Ad(){return St(Or)}function ag(){return rt().memoizedState}function sg(){return rt().memoizedState}function tw(t){for(var o=t.return;o!==null;){switch(o.tag){case 24:case 3:var r=Qt();t=To(r);var u=No(o,t,r);u!==null&&(Ht(u,o,r),mr(u,o,r)),o={cache:sd()},t.payload=o;return}o=o.return}}function nw(t,o,r){var u=Qt();r={lane:u,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Cl(t)?ig(o,r):(r=Vu(t,o,r,u),r!==null&&(Ht(r,t,u),lg(r,o,u)))}function rg(t,o,r){var u=Qt();br(t,o,r,u)}function br(t,o,r,u){var h={lane:u,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null};if(Cl(t))ig(o,h);else{var y=t.alternate;if(t.lanes===0&&(y===null||y.lanes===0)&&(y=o.lastRenderedReducer,y!==null))try{var j=o.lastRenderedState,R=y(j,r);if(h.hasEagerState=!0,h.eagerState=R,Kt(R,j))return al(t,o,h,0),Ve===null&&ol(),!1}catch{}if(r=Vu(t,o,h,u),r!==null)return Ht(r,t,u),lg(r,o,u),!0}return!1}function _d(t,o,r,u){if(u={lane:2,revertLane:cp(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Cl(t)){if(o)throw Error(s(479))}else o=Vu(t,r,u,2),o!==null&&Ht(o,t,2)}function Cl(t){var o=t.alternate;return t===Ne||o!==null&&o===Ne}function ig(t,o){fs=yl=!0;var r=t.pending;r===null?o.next=o:(o.next=r.next,r.next=o),t.pending=o}function lg(t,o,r){if((r&4194048)!==0){var u=o.lanes;u&=t.pendingLanes,r|=u,o.lanes=r,Fi(t,r)}}var vr={readContext:St,use:vl,useCallback:nt,useContext:nt,useEffect:nt,useImperativeHandle:nt,useLayoutEffect:nt,useInsertionEffect:nt,useMemo:nt,useReducer:nt,useRef:nt,useState:nt,useDebugValue:nt,useDeferredValue:nt,useTransition:nt,useSyncExternalStore:nt,useId:nt,useHostTransitionStatus:nt,useFormState:nt,useActionState:nt,useOptimistic:nt,useMemoCache:nt,useCacheRefresh:nt};vr.useEffectEvent=nt;var cg={readContext:St,use:vl,useCallback:function(t,o){return Rt().memoizedState=[t,o===void 0?null:o],t},useContext:St,useEffect:Kh,useImperativeHandle:function(t,o,r){r=r!=null?r.concat([t]):null,wl(4194308,4,Xh.bind(null,o,t),r)},useLayoutEffect:function(t,o){return wl(4194308,4,t,o)},useInsertionEffect:function(t,o){wl(4,2,t,o)},useMemo:function(t,o){var r=Rt();o=o===void 0?null:o;var u=t();if(ka){jn(!0);try{t()}finally{jn(!1)}}return r.memoizedState=[u,o],u},useReducer:function(t,o,r){var u=Rt();if(r!==void 0){var h=r(o);if(ka){jn(!0);try{r(o)}finally{jn(!1)}}}else h=o;return u.memoizedState=u.baseState=h,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:h},u.queue=t,t=t.dispatch=nw.bind(null,Ne,t),[u.memoizedState,t]},useRef:function(t){var o=Rt();return t={current:t},o.memoizedState=t},useState:function(t){t=Cd(t);var o=t.queue,r=rg.bind(null,Ne,o);return o.dispatch=r,[t.memoizedState,r]},useDebugValue:jd,useDeferredValue:function(t,o){var r=Rt();return Td(r,t,o)},useTransition:function(){var t=Cd(!1);return t=tg.bind(null,Ne,t.queue,!0,!1),Rt().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,o,r){var u=Ne,h=Rt();if(Oe){if(r===void 0)throw Error(s(407));r=r()}else{if(r=o(),Ve===null)throw Error(s(349));(Re&127)!==0||Ah(u,o,r)}h.memoizedState=r;var y={value:r,getSnapshot:o};return h.queue=y,Kh(Dh.bind(null,u,y,t),[t]),u.flags|=2048,hs(9,{destroy:void 0},_h.bind(null,u,y,r,o),null),r},useId:function(){var t=Rt(),o=Ve.identifierPrefix;if(Oe){var r=An,u=Nn;r=(u&~(1<<32-zt(u)-1)).toString(32)+r,o="_"+o+"R_"+r,r=xl++,0<r&&(o+="H"+r.toString(32)),o+="_"}else r=Wk++,o="_"+o+"r_"+r.toString(32)+"_";return t.memoizedState=o},useHostTransitionStatus:Ad,useFormState:Ph,useActionState:Ph,useOptimistic:function(t){var o=Rt();o.memoizedState=o.baseState=t;var r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return o.queue=r,o=_d.bind(null,Ne,!0,r),r.dispatch=o,[t,o]},useMemoCache:kd,useCacheRefresh:function(){return Rt().memoizedState=tw.bind(null,Ne)},useEffectEvent:function(t){var o=Rt(),r={impl:t};return o.memoizedState=r,function(){if((Pe&2)!==0)throw Error(s(440));return r.impl.apply(void 0,arguments)}}},Dd={readContext:St,use:vl,useCallback:Qh,useContext:St,useEffect:Ed,useImperativeHandle:Zh,useInsertionEffect:Vh,useLayoutEffect:Wh,useMemo:Jh,useReducer:kl,useRef:qh,useState:function(){return kl(Qn)},useDebugValue:jd,useDeferredValue:function(t,o){var r=rt();return eg(r,Ge.memoizedState,t,o)},useTransition:function(){var t=kl(Qn)[0],o=rt().memoizedState;return[typeof t=="boolean"?t:xr(t),o]},useSyncExternalStore:Nh,useId:ag,useHostTransitionStatus:Ad,useFormState:Hh,useActionState:Hh,useOptimistic:function(t,o){var r=rt();return $h(r,Ge,t,o)},useMemoCache:kd,useCacheRefresh:sg};Dd.useEffectEvent=Yh;var ug={readContext:St,use:vl,useCallback:Qh,useContext:St,useEffect:Ed,useImperativeHandle:Zh,useInsertionEffect:Vh,useLayoutEffect:Wh,useMemo:Jh,useReducer:Sd,useRef:qh,useState:function(){return Sd(Qn)},useDebugValue:jd,useDeferredValue:function(t,o){var r=rt();return Ge===null?Td(r,t,o):eg(r,Ge.memoizedState,t,o)},useTransition:function(){var t=Sd(Qn)[0],o=rt().memoizedState;return[typeof t=="boolean"?t:xr(t),o]},useSyncExternalStore:Nh,useId:ag,useHostTransitionStatus:Ad,useFormState:Gh,useActionState:Gh,useOptimistic:function(t,o){var r=rt();return Ge!==null?$h(r,Ge,t,o):(r.baseState=t,[t,r.queue.dispatch])},useMemoCache:kd,useCacheRefresh:sg};ug.useEffectEvent=Yh;function zd(t,o,r,u){o=t.memoizedState,r=r(u,o),r=r==null?o:x({},o,r),t.memoizedState=r,t.lanes===0&&(t.updateQueue.baseState=r)}var Rd={enqueueSetState:function(t,o,r){t=t._reactInternals;var u=Qt(),h=To(u);h.payload=o,r!=null&&(h.callback=r),o=No(t,h,u),o!==null&&(Ht(o,t,u),mr(o,t,u))},enqueueReplaceState:function(t,o,r){t=t._reactInternals;var u=Qt(),h=To(u);h.tag=1,h.payload=o,r!=null&&(h.callback=r),o=No(t,h,u),o!==null&&(Ht(o,t,u),mr(o,t,u))},enqueueForceUpdate:function(t,o){t=t._reactInternals;var r=Qt(),u=To(r);u.tag=2,o!=null&&(u.callback=o),o=No(t,u,r),o!==null&&(Ht(o,t,r),mr(o,t,r))}};function dg(t,o,r,u,h,y,j){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(u,y,j):o.prototype&&o.prototype.isPureReactComponent?!rr(r,u)||!rr(h,y):!0}function pg(t,o,r,u){t=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(r,u),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(r,u),o.state!==t&&Rd.enqueueReplaceState(o,o.state,null)}function wa(t,o){var r=o;if("ref"in o){r={};for(var u in o)u!=="ref"&&(r[u]=o[u])}if(t=t.defaultProps){r===o&&(r=x({},r));for(var h in t)r[h]===void 0&&(r[h]=t[h])}return r}function fg(t){nl(t)}function mg(t){console.error(t)}function hg(t){nl(t)}function Ml(t,o){try{var r=t.onUncaughtError;r(o.value,{componentStack:o.stack})}catch(u){setTimeout(function(){throw u})}}function gg(t,o,r){try{var u=t.onCaughtError;u(r.value,{componentStack:r.stack,errorBoundary:o.tag===1?o.stateNode:null})}catch(h){setTimeout(function(){throw h})}}function $d(t,o,r){return r=To(r),r.tag=3,r.payload={element:null},r.callback=function(){Ml(t,o)},r}function yg(t){return t=To(t),t.tag=3,t}function xg(t,o,r,u){var h=r.type.getDerivedStateFromError;if(typeof h=="function"){var y=u.value;t.payload=function(){return h(y)},t.callback=function(){gg(o,r,u)}}var j=r.stateNode;j!==null&&typeof j.componentDidCatch=="function"&&(t.callback=function(){gg(o,r,u),typeof h!="function"&&($o===null?$o=new Set([this]):$o.add(this));var R=u.stack;this.componentDidCatch(u.value,{componentStack:R!==null?R:""})})}function ow(t,o,r,u,h){if(r.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){if(o=r.alternate,o!==null&&is(o,r,h,!0),r=Vt.current,r!==null){switch(r.tag){case 31:case 13:return ln===null?Fl():r.alternate===null&&ot===0&&(ot=3),r.flags&=-257,r.flags|=65536,r.lanes=h,u===pl?r.flags|=16384:(o=r.updateQueue,o===null?r.updateQueue=new Set([u]):o.add(u),rp(t,u,h)),!1;case 22:return r.flags|=65536,u===pl?r.flags|=16384:(o=r.updateQueue,o===null?(o={transitions:null,markerInstances:null,retryQueue:new Set([u])},r.updateQueue=o):(r=o.retryQueue,r===null?o.retryQueue=new Set([u]):r.add(u)),rp(t,u,h)),!1}throw Error(s(435,r.tag))}return rp(t,u,h),Fl(),!1}if(Oe)return o=Vt.current,o!==null?((o.flags&65536)===0&&(o.flags|=256),o.flags|=65536,o.lanes=h,u!==ed&&(t=Error(s(422),{cause:u}),cr(on(t,r)))):(u!==ed&&(o=Error(s(423),{cause:u}),cr(on(o,r))),t=t.current.alternate,t.flags|=65536,h&=-h,t.lanes|=h,u=on(u,r),h=$d(t.stateNode,u,h),dd(t,h),ot!==4&&(ot=2)),!1;var y=Error(s(520),{cause:u});if(y=on(y,r),Tr===null?Tr=[y]:Tr.push(y),ot!==4&&(ot=2),o===null)return!0;u=on(u,r),r=o;do{switch(r.tag){case 3:return r.flags|=65536,t=h&-h,r.lanes|=t,t=$d(r.stateNode,u,t),dd(r,t),!1;case 1:if(o=r.type,y=r.stateNode,(r.flags&128)===0&&(typeof o.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&($o===null||!$o.has(y))))return r.flags|=65536,h&=-h,r.lanes|=h,h=yg(h),xg(h,t,r,u),dd(r,h),!1}r=r.return}while(r!==null);return!1}var Od=Error(s(461)),ut=!1;function Ct(t,o,r,u){o.child=t===null?wh(o,null,r,u):va(o,t.child,r,u)}function bg(t,o,r,u,h){r=r.render;var y=o.ref;if("ref"in u){var j={};for(var R in u)R!=="ref"&&(j[R]=u[R])}else j=u;return ga(o),u=yd(t,o,r,j,y,h),R=xd(),t!==null&&!ut?(bd(t,o,h),Jn(t,o,h)):(Oe&&R&&Qu(o),o.flags|=1,Ct(t,o,u,h),o.child)}function vg(t,o,r,u,h){if(t===null){var y=r.type;return typeof y=="function"&&!Wu(y)&&y.defaultProps===void 0&&r.compare===null?(o.tag=15,o.type=y,kg(t,o,y,u,h)):(t=rl(r.type,null,u,o,o.mode,h),t.ref=o.ref,t.return=o,o.child=t)}if(y=t.child,!Gd(t,h)){var j=y.memoizedProps;if(r=r.compare,r=r!==null?r:rr,r(j,u)&&t.ref===o.ref)return Jn(t,o,h)}return o.flags|=1,t=Yn(y,u),t.ref=o.ref,t.return=o,o.child=t}function kg(t,o,r,u,h){if(t!==null){var y=t.memoizedProps;if(rr(y,u)&&t.ref===o.ref)if(ut=!1,o.pendingProps=u=y,Gd(t,h))(t.flags&131072)!==0&&(ut=!0);else return o.lanes=t.lanes,Jn(t,o,h)}return Fd(t,o,r,u,h)}function wg(t,o,r,u){var h=u.children,y=t!==null?t.memoizedState:null;if(t===null&&o.stateNode===null&&(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),u.mode==="hidden"){if((o.flags&128)!==0){if(y=y!==null?y.baseLanes|r:r,t!==null){for(u=o.child=t.child,h=0;u!==null;)h=h|u.lanes|u.childLanes,u=u.sibling;u=h&~y}else u=0,o.child=null;return Sg(t,o,y,r,u)}if((r&536870912)!==0)o.memoizedState={baseLanes:0,cachePool:null},t!==null&&ul(o,y!==null?y.cachePool:null),y!==null?Mh(o,y):fd(),Eh(o);else return u=o.lanes=536870912,Sg(t,o,y!==null?y.baseLanes|r:r,r,u)}else y!==null?(ul(o,y.cachePool),Mh(o,y),_o(),o.memoizedState=null):(t!==null&&ul(o,null),fd(),_o());return Ct(t,o,h,r),o.child}function kr(t,o){return t!==null&&t.tag===22||o.stateNode!==null||(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.sibling}function Sg(t,o,r,u,h){var y=id();return y=y===null?null:{parent:lt._currentValue,pool:y},o.memoizedState={baseLanes:r,cachePool:y},t!==null&&ul(o,null),fd(),Eh(o),t!==null&&is(t,o,u,!0),o.childLanes=h,null}function El(t,o){return o=Tl({mode:o.mode,children:o.children},t.mode),o.ref=t.ref,t.child=o,o.return=t,o}function Cg(t,o,r){return va(o,t.child,null,r),t=El(o,o.pendingProps),t.flags|=2,Wt(o),o.memoizedState=null,t}function aw(t,o,r){var u=o.pendingProps,h=(o.flags&128)!==0;if(o.flags&=-129,t===null){if(Oe){if(u.mode==="hidden")return t=El(o,u),o.lanes=536870912,kr(null,t);if(hd(o),(t=Xe)?(t=Oy(t,rn),t=t!==null&&t.data==="&"?t:null,t!==null&&(o.memoizedState={dehydrated:t,treeContext:So!==null?{id:Nn,overflow:An}:null,retryLane:536870912,hydrationErrors:null},r=ih(t),r.return=o,o.child=r,wt=o,Xe=null)):t=null,t===null)throw Mo(o);return o.lanes=536870912,null}return El(o,u)}var y=t.memoizedState;if(y!==null){var j=y.dehydrated;if(hd(o),h)if(o.flags&256)o.flags&=-257,o=Cg(t,o,r);else if(o.memoizedState!==null)o.child=t.child,o.flags|=128,o=null;else throw Error(s(558));else if(ut||is(t,o,r,!1),h=(r&t.childLanes)!==0,ut||h){if(u=Ve,u!==null&&(j=Ii(u,r),j!==0&&j!==y.retryLane))throw y.retryLane=j,pa(t,j),Ht(u,t,j),Od;Fl(),o=Cg(t,o,r)}else t=y.treeContext,Xe=cn(j.nextSibling),wt=o,Oe=!0,Co=null,rn=!1,t!==null&&uh(o,t),o=El(o,u),o.flags|=4096;return o}return t=Yn(t.child,{mode:u.mode,children:u.children}),t.ref=o.ref,o.child=t,t.return=o,t}function jl(t,o){var r=o.ref;if(r===null)t!==null&&t.ref!==null&&(o.flags|=4194816);else{if(typeof r!="function"&&typeof r!="object")throw Error(s(284));(t===null||t.ref!==r)&&(o.flags|=4194816)}}function Fd(t,o,r,u,h){return ga(o),r=yd(t,o,r,u,void 0,h),u=xd(),t!==null&&!ut?(bd(t,o,h),Jn(t,o,h)):(Oe&&u&&Qu(o),o.flags|=1,Ct(t,o,r,h),o.child)}function Mg(t,o,r,u,h,y){return ga(o),o.updateQueue=null,r=Th(o,u,r,h),jh(t),u=xd(),t!==null&&!ut?(bd(t,o,y),Jn(t,o,y)):(Oe&&u&&Qu(o),o.flags|=1,Ct(t,o,r,y),o.child)}function Eg(t,o,r,u,h){if(ga(o),o.stateNode===null){var y=os,j=r.contextType;typeof j=="object"&&j!==null&&(y=St(j)),y=new r(u,y),o.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,y.updater=Rd,o.stateNode=y,y._reactInternals=o,y=o.stateNode,y.props=u,y.state=o.memoizedState,y.refs={},cd(o),j=r.contextType,y.context=typeof j=="object"&&j!==null?St(j):os,y.state=o.memoizedState,j=r.getDerivedStateFromProps,typeof j=="function"&&(zd(o,r,j,u),y.state=o.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof y.getSnapshotBeforeUpdate=="function"||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(j=y.state,typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount(),j!==y.state&&Rd.enqueueReplaceState(y,y.state,null),gr(o,u,y,h),hr(),y.state=o.memoizedState),typeof y.componentDidMount=="function"&&(o.flags|=4194308),u=!0}else if(t===null){y=o.stateNode;var R=o.memoizedProps,Y=wa(r,R);y.props=Y;var oe=y.context,le=r.contextType;j=os,typeof le=="object"&&le!==null&&(j=St(le));var de=r.getDerivedStateFromProps;le=typeof de=="function"||typeof y.getSnapshotBeforeUpdate=="function",R=o.pendingProps!==R,le||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(R||oe!==j)&&pg(o,y,u,j),jo=!1;var ae=o.memoizedState;y.state=ae,gr(o,u,y,h),hr(),oe=o.memoizedState,R||ae!==oe||jo?(typeof de=="function"&&(zd(o,r,de,u),oe=o.memoizedState),(Y=jo||dg(o,r,Y,u,ae,oe,j))?(le||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(o.flags|=4194308)):(typeof y.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=u,o.memoizedState=oe),y.props=u,y.state=oe,y.context=j,u=Y):(typeof y.componentDidMount=="function"&&(o.flags|=4194308),u=!1)}else{y=o.stateNode,ud(t,o),j=o.memoizedProps,le=wa(r,j),y.props=le,de=o.pendingProps,ae=y.context,oe=r.contextType,Y=os,typeof oe=="object"&&oe!==null&&(Y=St(oe)),R=r.getDerivedStateFromProps,(oe=typeof R=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(j!==de||ae!==Y)&&pg(o,y,u,Y),jo=!1,ae=o.memoizedState,y.state=ae,gr(o,u,y,h),hr();var re=o.memoizedState;j!==de||ae!==re||jo||t!==null&&t.dependencies!==null&&ll(t.dependencies)?(typeof R=="function"&&(zd(o,r,R,u),re=o.memoizedState),(le=jo||dg(o,r,le,u,ae,re,Y)||t!==null&&t.dependencies!==null&&ll(t.dependencies))?(oe||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(u,re,Y),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(u,re,Y)),typeof y.componentDidUpdate=="function"&&(o.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof y.componentDidUpdate!="function"||j===t.memoizedProps&&ae===t.memoizedState||(o.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||j===t.memoizedProps&&ae===t.memoizedState||(o.flags|=1024),o.memoizedProps=u,o.memoizedState=re),y.props=u,y.state=re,y.context=Y,u=le):(typeof y.componentDidUpdate!="function"||j===t.memoizedProps&&ae===t.memoizedState||(o.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||j===t.memoizedProps&&ae===t.memoizedState||(o.flags|=1024),u=!1)}return y=u,jl(t,o),u=(o.flags&128)!==0,y||u?(y=o.stateNode,r=u&&typeof r.getDerivedStateFromError!="function"?null:y.render(),o.flags|=1,t!==null&&u?(o.child=va(o,t.child,null,h),o.child=va(o,null,r,h)):Ct(t,o,r,h),o.memoizedState=y.state,t=o.child):t=Jn(t,o,h),t}function jg(t,o,r,u){return ma(),o.flags|=256,Ct(t,o,r,u),o.child}var Id={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Ld(t){return{baseLanes:t,cachePool:gh()}}function Bd(t,o,r){return t=t!==null?t.childLanes&~r:0,o&&(t|=Zt),t}function Tg(t,o,r){var u=o.pendingProps,h=!1,y=(o.flags&128)!==0,j;if((j=y)||(j=t!==null&&t.memoizedState===null?!1:(st.current&2)!==0),j&&(h=!0,o.flags&=-129),j=(o.flags&32)!==0,o.flags&=-33,t===null){if(Oe){if(h?Ao(o):_o(),(t=Xe)?(t=Oy(t,rn),t=t!==null&&t.data!=="&"?t:null,t!==null&&(o.memoizedState={dehydrated:t,treeContext:So!==null?{id:Nn,overflow:An}:null,retryLane:536870912,hydrationErrors:null},r=ih(t),r.return=o,o.child=r,wt=o,Xe=null)):t=null,t===null)throw Mo(o);return wp(t)?o.lanes=32:o.lanes=536870912,null}var R=u.children;return u=u.fallback,h?(_o(),h=o.mode,R=Tl({mode:"hidden",children:R},h),u=fa(u,h,r,null),R.return=o,u.return=o,R.sibling=u,o.child=R,u=o.child,u.memoizedState=Ld(r),u.childLanes=Bd(t,j,r),o.memoizedState=Id,kr(null,u)):(Ao(o),Pd(o,R))}var Y=t.memoizedState;if(Y!==null&&(R=Y.dehydrated,R!==null)){if(y)o.flags&256?(Ao(o),o.flags&=-257,o=Hd(t,o,r)):o.memoizedState!==null?(_o(),o.child=t.child,o.flags|=128,o=null):(_o(),R=u.fallback,h=o.mode,u=Tl({mode:"visible",children:u.children},h),R=fa(R,h,r,null),R.flags|=2,u.return=o,R.return=o,u.sibling=R,o.child=u,va(o,t.child,null,r),u=o.child,u.memoizedState=Ld(r),u.childLanes=Bd(t,j,r),o.memoizedState=Id,o=kr(null,u));else if(Ao(o),wp(R)){if(j=R.nextSibling&&R.nextSibling.dataset,j)var oe=j.dgst;j=oe,u=Error(s(419)),u.stack="",u.digest=j,cr({value:u,source:null,stack:null}),o=Hd(t,o,r)}else if(ut||is(t,o,r,!1),j=(r&t.childLanes)!==0,ut||j){if(j=Ve,j!==null&&(u=Ii(j,r),u!==0&&u!==Y.retryLane))throw Y.retryLane=u,pa(t,u),Ht(j,t,u),Od;kp(R)||Fl(),o=Hd(t,o,r)}else kp(R)?(o.flags|=192,o.child=t.child,o=null):(t=Y.treeContext,Xe=cn(R.nextSibling),wt=o,Oe=!0,Co=null,rn=!1,t!==null&&uh(o,t),o=Pd(o,u.children),o.flags|=4096);return o}return h?(_o(),R=u.fallback,h=o.mode,Y=t.child,oe=Y.sibling,u=Yn(Y,{mode:"hidden",children:u.children}),u.subtreeFlags=Y.subtreeFlags&65011712,oe!==null?R=Yn(oe,R):(R=fa(R,h,r,null),R.flags|=2),R.return=o,u.return=o,u.sibling=R,o.child=u,kr(null,u),u=o.child,R=t.child.memoizedState,R===null?R=Ld(r):(h=R.cachePool,h!==null?(Y=lt._currentValue,h=h.parent!==Y?{parent:Y,pool:Y}:h):h=gh(),R={baseLanes:R.baseLanes|r,cachePool:h}),u.memoizedState=R,u.childLanes=Bd(t,j,r),o.memoizedState=Id,kr(t.child,u)):(Ao(o),r=t.child,t=r.sibling,r=Yn(r,{mode:"visible",children:u.children}),r.return=o,r.sibling=null,t!==null&&(j=o.deletions,j===null?(o.deletions=[t],o.flags|=16):j.push(t)),o.child=r,o.memoizedState=null,r)}function Pd(t,o){return o=Tl({mode:"visible",children:o},t.mode),o.return=t,t.child=o}function Tl(t,o){return t=Yt(22,t,null,o),t.lanes=0,t}function Hd(t,o,r){return va(o,t.child,null,r),t=Pd(o,o.pendingProps.children),t.flags|=2,o.memoizedState=null,t}function Ng(t,o,r){t.lanes|=o;var u=t.alternate;u!==null&&(u.lanes|=o),od(t.return,o,r)}function Ud(t,o,r,u,h,y){var j=t.memoizedState;j===null?t.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:u,tail:r,tailMode:h,treeForkCount:y}:(j.isBackwards=o,j.rendering=null,j.renderingStartTime=0,j.last=u,j.tail=r,j.tailMode=h,j.treeForkCount=y)}function Ag(t,o,r){var u=o.pendingProps,h=u.revealOrder,y=u.tail;u=u.children;var j=st.current,R=(j&2)!==0;if(R?(j=j&1|2,o.flags|=128):j&=1,Q(st,j),Ct(t,o,u,r),u=Oe?lr:0,!R&&t!==null&&(t.flags&128)!==0)e:for(t=o.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Ng(t,r,o);else if(t.tag===19)Ng(t,r,o);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===o)break e;for(;t.sibling===null;){if(t.return===null||t.return===o)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}switch(h){case"forwards":for(r=o.child,h=null;r!==null;)t=r.alternate,t!==null&&gl(t)===null&&(h=r),r=r.sibling;r=h,r===null?(h=o.child,o.child=null):(h=r.sibling,r.sibling=null),Ud(o,!1,h,r,y,u);break;case"backwards":case"unstable_legacy-backwards":for(r=null,h=o.child,o.child=null;h!==null;){if(t=h.alternate,t!==null&&gl(t)===null){o.child=h;break}t=h.sibling,h.sibling=r,r=h,h=t}Ud(o,!0,r,null,y,u);break;case"together":Ud(o,!1,null,null,void 0,u);break;default:o.memoizedState=null}return o.child}function Jn(t,o,r){if(t!==null&&(o.dependencies=t.dependencies),Ro|=o.lanes,(r&o.childLanes)===0)if(t!==null){if(is(t,o,r,!1),(r&o.childLanes)===0)return null}else return null;if(t!==null&&o.child!==t.child)throw Error(s(153));if(o.child!==null){for(t=o.child,r=Yn(t,t.pendingProps),o.child=r,r.return=o;t.sibling!==null;)t=t.sibling,r=r.sibling=Yn(t,t.pendingProps),r.return=o;r.sibling=null}return o.child}function Gd(t,o){return(t.lanes&o)!==0?!0:(t=t.dependencies,!!(t!==null&&ll(t)))}function sw(t,o,r){switch(o.tag){case 3:U(o,o.stateNode.containerInfo),Eo(o,lt,t.memoizedState.cache),ma();break;case 27:case 5:ge(o);break;case 4:U(o,o.stateNode.containerInfo);break;case 10:Eo(o,o.type,o.memoizedProps.value);break;case 31:if(o.memoizedState!==null)return o.flags|=128,hd(o),null;break;case 13:var u=o.memoizedState;if(u!==null)return u.dehydrated!==null?(Ao(o),o.flags|=128,null):(r&o.child.childLanes)!==0?Tg(t,o,r):(Ao(o),t=Jn(t,o,r),t!==null?t.sibling:null);Ao(o);break;case 19:var h=(t.flags&128)!==0;if(u=(r&o.childLanes)!==0,u||(is(t,o,r,!1),u=(r&o.childLanes)!==0),h){if(u)return Ag(t,o,r);o.flags|=128}if(h=o.memoizedState,h!==null&&(h.rendering=null,h.tail=null,h.lastEffect=null),Q(st,st.current),u)break;return null;case 22:return o.lanes=0,wg(t,o,r,o.pendingProps);case 24:Eo(o,lt,t.memoizedState.cache)}return Jn(t,o,r)}function _g(t,o,r){if(t!==null)if(t.memoizedProps!==o.pendingProps)ut=!0;else{if(!Gd(t,r)&&(o.flags&128)===0)return ut=!1,sw(t,o,r);ut=(t.flags&131072)!==0}else ut=!1,Oe&&(o.flags&1048576)!==0&&ch(o,lr,o.index);switch(o.lanes=0,o.tag){case 16:e:{var u=o.pendingProps;if(t=xa(o.elementType),o.type=t,typeof t=="function")Wu(t)?(u=wa(t,u),o.tag=1,o=Eg(null,o,t,u,r)):(o.tag=0,o=Fd(null,o,t,u,r));else{if(t!=null){var h=t.$$typeof;if(h===E){o.tag=11,o=bg(null,o,t,u,r);break e}else if(h===A){o.tag=14,o=vg(null,o,t,u,r);break e}}throw o=H(t)||t,Error(s(306,o,""))}}return o;case 0:return Fd(t,o,o.type,o.pendingProps,r);case 1:return u=o.type,h=wa(u,o.pendingProps),Eg(t,o,u,h,r);case 3:e:{if(U(o,o.stateNode.containerInfo),t===null)throw Error(s(387));u=o.pendingProps;var y=o.memoizedState;h=y.element,ud(t,o),gr(o,u,null,r);var j=o.memoizedState;if(u=j.cache,Eo(o,lt,u),u!==y.cache&&ad(o,[lt],r,!0),hr(),u=j.element,y.isDehydrated)if(y={element:u,isDehydrated:!1,cache:j.cache},o.updateQueue.baseState=y,o.memoizedState=y,o.flags&256){o=jg(t,o,u,r);break e}else if(u!==h){h=on(Error(s(424)),o),cr(h),o=jg(t,o,u,r);break e}else for(t=o.stateNode.containerInfo,t.nodeType===9?t=t.body:t=t.nodeName==="HTML"?t.ownerDocument.body:t,Xe=cn(t.firstChild),wt=o,Oe=!0,Co=null,rn=!0,r=wh(o,null,u,r),o.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(ma(),u===h){o=Jn(t,o,r);break e}Ct(t,o,u,r)}o=o.child}return o;case 26:return jl(t,o),t===null?(r=Hy(o.type,null,o.pendingProps,null))?o.memoizedState=r:Oe||(r=o.type,t=o.pendingProps,u=Gl(pe.current).createElement(r),u[mt]=o,u[Nt]=t,Mt(u,r,t),it(u),o.stateNode=u):o.memoizedState=Hy(o.type,t.memoizedProps,o.pendingProps,t.memoizedState),null;case 27:return ge(o),t===null&&Oe&&(u=o.stateNode=Ly(o.type,o.pendingProps,pe.current),wt=o,rn=!0,h=Xe,Lo(o.type)?(Sp=h,Xe=cn(u.firstChild)):Xe=h),Ct(t,o,o.pendingProps.children,r),jl(t,o),t===null&&(o.flags|=4194304),o.child;case 5:return t===null&&Oe&&((h=u=Xe)&&(u=$w(u,o.type,o.pendingProps,rn),u!==null?(o.stateNode=u,wt=o,Xe=cn(u.firstChild),rn=!1,h=!0):h=!1),h||Mo(o)),ge(o),h=o.type,y=o.pendingProps,j=t!==null?t.memoizedProps:null,u=y.children,xp(h,y)?u=null:j!==null&&xp(h,j)&&(o.flags|=32),o.memoizedState!==null&&(h=yd(t,o,Xk,null,null,r),Or._currentValue=h),jl(t,o),Ct(t,o,u,r),o.child;case 6:return t===null&&Oe&&((t=r=Xe)&&(r=Ow(r,o.pendingProps,rn),r!==null?(o.stateNode=r,wt=o,Xe=null,t=!0):t=!1),t||Mo(o)),null;case 13:return Tg(t,o,r);case 4:return U(o,o.stateNode.containerInfo),u=o.pendingProps,t===null?o.child=va(o,null,u,r):Ct(t,o,u,r),o.child;case 11:return bg(t,o,o.type,o.pendingProps,r);case 7:return Ct(t,o,o.pendingProps,r),o.child;case 8:return Ct(t,o,o.pendingProps.children,r),o.child;case 12:return Ct(t,o,o.pendingProps.children,r),o.child;case 10:return u=o.pendingProps,Eo(o,o.type,u.value),Ct(t,o,u.children,r),o.child;case 9:return h=o.type._context,u=o.pendingProps.children,ga(o),h=St(h),u=u(h),o.flags|=1,Ct(t,o,u,r),o.child;case 14:return vg(t,o,o.type,o.pendingProps,r);case 15:return kg(t,o,o.type,o.pendingProps,r);case 19:return Ag(t,o,r);case 31:return aw(t,o,r);case 22:return wg(t,o,r,o.pendingProps);case 24:return ga(o),u=St(lt),t===null?(h=id(),h===null&&(h=Ve,y=sd(),h.pooledCache=y,y.refCount++,y!==null&&(h.pooledCacheLanes|=r),h=y),o.memoizedState={parent:u,cache:h},cd(o),Eo(o,lt,h)):((t.lanes&r)!==0&&(ud(t,o),gr(o,null,null,r),hr()),h=t.memoizedState,y=o.memoizedState,h.parent!==u?(h={parent:u,cache:u},o.memoizedState=h,o.lanes===0&&(o.memoizedState=o.updateQueue.baseState=h),Eo(o,lt,u)):(u=y.cache,Eo(o,lt,u),u!==h.cache&&ad(o,[lt],r,!0))),Ct(t,o,o.pendingProps.children,r),o.child;case 29:throw o.pendingProps}throw Error(s(156,o.tag))}function eo(t){t.flags|=4}function qd(t,o,r,u,h){if((o=(t.mode&32)!==0)&&(o=!1),o){if(t.flags|=16777216,(h&335544128)===h)if(t.stateNode.complete)t.flags|=8192;else if(ay())t.flags|=8192;else throw ba=pl,ld}else t.flags&=-16777217}function Dg(t,o){if(o.type!=="stylesheet"||(o.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!Yy(o))if(ay())t.flags|=8192;else throw ba=pl,ld}function Nl(t,o){o!==null&&(t.flags|=4),t.flags&16384&&(o=t.tag!==22?$i():536870912,t.lanes|=o,bs|=o)}function wr(t,o){if(!Oe)switch(t.tailMode){case"hidden":o=t.tail;for(var r=null;o!==null;)o.alternate!==null&&(r=o),o=o.sibling;r===null?t.tail=null:r.sibling=null;break;case"collapsed":r=t.tail;for(var u=null;r!==null;)r.alternate!==null&&(u=r),r=r.sibling;u===null?o||t.tail===null?t.tail=null:t.tail.sibling=null:u.sibling=null}}function Ze(t){var o=t.alternate!==null&&t.alternate.child===t.child,r=0,u=0;if(o)for(var h=t.child;h!==null;)r|=h.lanes|h.childLanes,u|=h.subtreeFlags&65011712,u|=h.flags&65011712,h.return=t,h=h.sibling;else for(h=t.child;h!==null;)r|=h.lanes|h.childLanes,u|=h.subtreeFlags,u|=h.flags,h.return=t,h=h.sibling;return t.subtreeFlags|=u,t.childLanes=r,o}function rw(t,o,r){var u=o.pendingProps;switch(Ju(o),o.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ze(o),null;case 1:return Ze(o),null;case 3:return r=o.stateNode,u=null,t!==null&&(u=t.memoizedState.cache),o.memoizedState.cache!==u&&(o.flags|=2048),Xn(lt),ce(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(t===null||t.child===null)&&(rs(o)?eo(o):t===null||t.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,td())),Ze(o),null;case 26:var h=o.type,y=o.memoizedState;return t===null?(eo(o),y!==null?(Ze(o),Dg(o,y)):(Ze(o),qd(o,h,null,u,r))):y?y!==t.memoizedState?(eo(o),Ze(o),Dg(o,y)):(Ze(o),o.flags&=-16777217):(t=t.memoizedProps,t!==u&&eo(o),Ze(o),qd(o,h,t,u,r)),null;case 27:if(be(o),r=pe.current,h=o.type,t!==null&&o.stateNode!=null)t.memoizedProps!==u&&eo(o);else{if(!u){if(o.stateNode===null)throw Error(s(166));return Ze(o),null}t=q.current,rs(o)?dh(o):(t=Ly(h,u,r),o.stateNode=t,eo(o))}return Ze(o),null;case 5:if(be(o),h=o.type,t!==null&&o.stateNode!=null)t.memoizedProps!==u&&eo(o);else{if(!u){if(o.stateNode===null)throw Error(s(166));return Ze(o),null}if(y=q.current,rs(o))dh(o);else{var j=Gl(pe.current);switch(y){case 1:y=j.createElementNS("http://www.w3.org/2000/svg",h);break;case 2:y=j.createElementNS("http://www.w3.org/1998/Math/MathML",h);break;default:switch(h){case"svg":y=j.createElementNS("http://www.w3.org/2000/svg",h);break;case"math":y=j.createElementNS("http://www.w3.org/1998/Math/MathML",h);break;case"script":y=j.createElement("div"),y.innerHTML="<script><\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof u.is=="string"?j.createElement("select",{is:u.is}):j.createElement("select"),u.multiple?y.multiple=!0:u.size&&(y.size=u.size);break;default:y=typeof u.is=="string"?j.createElement(h,{is:u.is}):j.createElement(h)}}y[mt]=o,y[Nt]=u;e:for(j=o.child;j!==null;){if(j.tag===5||j.tag===6)y.appendChild(j.stateNode);else if(j.tag!==4&&j.tag!==27&&j.child!==null){j.child.return=j,j=j.child;continue}if(j===o)break e;for(;j.sibling===null;){if(j.return===null||j.return===o)break e;j=j.return}j.sibling.return=j.return,j=j.sibling}o.stateNode=y;e:switch(Mt(y,h,u),h){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&eo(o)}}return Ze(o),qd(o,o.type,t===null?null:t.memoizedProps,o.pendingProps,r),null;case 6:if(t&&o.stateNode!=null)t.memoizedProps!==u&&eo(o);else{if(typeof u!="string"&&o.stateNode===null)throw Error(s(166));if(t=pe.current,rs(o)){if(t=o.stateNode,r=o.memoizedProps,u=null,h=wt,h!==null)switch(h.tag){case 27:case 5:u=h.memoizedProps}t[mt]=o,t=!!(t.nodeValue===r||u!==null&&u.suppressHydrationWarning===!0||Ty(t.nodeValue,r)),t||Mo(o,!0)}else t=Gl(t).createTextNode(u),t[mt]=o,o.stateNode=t}return Ze(o),null;case 31:if(r=o.memoizedState,t===null||t.memoizedState!==null){if(u=rs(o),r!==null){if(t===null){if(!u)throw Error(s(318));if(t=o.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(557));t[mt]=o}else ma(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Ze(o),t=!1}else r=td(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=r),t=!0;if(!t)return o.flags&256?(Wt(o),o):(Wt(o),null);if((o.flags&128)!==0)throw Error(s(558))}return Ze(o),null;case 13:if(u=o.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(h=rs(o),u!==null&&u.dehydrated!==null){if(t===null){if(!h)throw Error(s(318));if(h=o.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(s(317));h[mt]=o}else ma(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Ze(o),h=!1}else h=td(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=h),h=!0;if(!h)return o.flags&256?(Wt(o),o):(Wt(o),null)}return Wt(o),(o.flags&128)!==0?(o.lanes=r,o):(r=u!==null,t=t!==null&&t.memoizedState!==null,r&&(u=o.child,h=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(h=u.alternate.memoizedState.cachePool.pool),y=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(y=u.memoizedState.cachePool.pool),y!==h&&(u.flags|=2048)),r!==t&&r&&(o.child.flags|=8192),Nl(o,o.updateQueue),Ze(o),null);case 4:return ce(),t===null&&fp(o.stateNode.containerInfo),Ze(o),null;case 10:return Xn(o.type),Ze(o),null;case 19:if(O(st),u=o.memoizedState,u===null)return Ze(o),null;if(h=(o.flags&128)!==0,y=u.rendering,y===null)if(h)wr(u,!1);else{if(ot!==0||t!==null&&(t.flags&128)!==0)for(t=o.child;t!==null;){if(y=gl(t),y!==null){for(o.flags|=128,wr(u,!1),t=y.updateQueue,o.updateQueue=t,Nl(o,t),o.subtreeFlags=0,t=r,r=o.child;r!==null;)rh(r,t),r=r.sibling;return Q(st,st.current&1|2),Oe&&Vn(o,u.treeForkCount),o.child}t=t.sibling}u.tail!==null&&kt()>Rl&&(o.flags|=128,h=!0,wr(u,!1),o.lanes=4194304)}else{if(!h)if(t=gl(y),t!==null){if(o.flags|=128,h=!0,t=t.updateQueue,o.updateQueue=t,Nl(o,t),wr(u,!0),u.tail===null&&u.tailMode==="hidden"&&!y.alternate&&!Oe)return Ze(o),null}else 2*kt()-u.renderingStartTime>Rl&&r!==536870912&&(o.flags|=128,h=!0,wr(u,!1),o.lanes=4194304);u.isBackwards?(y.sibling=o.child,o.child=y):(t=u.last,t!==null?t.sibling=y:o.child=y,u.last=y)}return u.tail!==null?(t=u.tail,u.rendering=t,u.tail=t.sibling,u.renderingStartTime=kt(),t.sibling=null,r=st.current,Q(st,h?r&1|2:r&1),Oe&&Vn(o,u.treeForkCount),t):(Ze(o),null);case 22:case 23:return Wt(o),md(),u=o.memoizedState!==null,t!==null?t.memoizedState!==null!==u&&(o.flags|=8192):u&&(o.flags|=8192),u?(r&536870912)!==0&&(o.flags&128)===0&&(Ze(o),o.subtreeFlags&6&&(o.flags|=8192)):Ze(o),r=o.updateQueue,r!==null&&Nl(o,r.retryQueue),r=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),u=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(u=o.memoizedState.cachePool.pool),u!==r&&(o.flags|=2048),t!==null&&O(ya),null;case 24:return r=null,t!==null&&(r=t.memoizedState.cache),o.memoizedState.cache!==r&&(o.flags|=2048),Xn(lt),Ze(o),null;case 25:return null;case 30:return null}throw Error(s(156,o.tag))}function iw(t,o){switch(Ju(o),o.tag){case 1:return t=o.flags,t&65536?(o.flags=t&-65537|128,o):null;case 3:return Xn(lt),ce(),t=o.flags,(t&65536)!==0&&(t&128)===0?(o.flags=t&-65537|128,o):null;case 26:case 27:case 5:return be(o),null;case 31:if(o.memoizedState!==null){if(Wt(o),o.alternate===null)throw Error(s(340));ma()}return t=o.flags,t&65536?(o.flags=t&-65537|128,o):null;case 13:if(Wt(o),t=o.memoizedState,t!==null&&t.dehydrated!==null){if(o.alternate===null)throw Error(s(340));ma()}return t=o.flags,t&65536?(o.flags=t&-65537|128,o):null;case 19:return O(st),null;case 4:return ce(),null;case 10:return Xn(o.type),null;case 22:case 23:return Wt(o),md(),t!==null&&O(ya),t=o.flags,t&65536?(o.flags=t&-65537|128,o):null;case 24:return Xn(lt),null;case 25:return null;default:return null}}function zg(t,o){switch(Ju(o),o.tag){case 3:Xn(lt),ce();break;case 26:case 27:case 5:be(o);break;case 4:ce();break;case 31:o.memoizedState!==null&&Wt(o);break;case 13:Wt(o);break;case 19:O(st);break;case 10:Xn(o.type);break;case 22:case 23:Wt(o),md(),t!==null&&O(ya);break;case 24:Xn(lt)}}function Sr(t,o){try{var r=o.updateQueue,u=r!==null?r.lastEffect:null;if(u!==null){var h=u.next;r=h;do{if((r.tag&t)===t){u=void 0;var y=r.create,j=r.inst;u=y(),j.destroy=u}r=r.next}while(r!==h)}}catch(R){Ue(o,o.return,R)}}function Do(t,o,r){try{var u=o.updateQueue,h=u!==null?u.lastEffect:null;if(h!==null){var y=h.next;u=y;do{if((u.tag&t)===t){var j=u.inst,R=j.destroy;if(R!==void 0){j.destroy=void 0,h=o;var Y=r,oe=R;try{oe()}catch(le){Ue(h,Y,le)}}}u=u.next}while(u!==y)}}catch(le){Ue(o,o.return,le)}}function Rg(t){var o=t.updateQueue;if(o!==null){var r=t.stateNode;try{Ch(o,r)}catch(u){Ue(t,t.return,u)}}}function $g(t,o,r){r.props=wa(t.type,t.memoizedProps),r.state=t.memoizedState;try{r.componentWillUnmount()}catch(u){Ue(t,o,u)}}function Cr(t,o){try{var r=t.ref;if(r!==null){switch(t.tag){case 26:case 27:case 5:var u=t.stateNode;break;case 30:u=t.stateNode;break;default:u=t.stateNode}typeof r=="function"?t.refCleanup=r(u):r.current=u}}catch(h){Ue(t,o,h)}}function _n(t,o){var r=t.ref,u=t.refCleanup;if(r!==null)if(typeof u=="function")try{u()}catch(h){Ue(t,o,h)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof r=="function")try{r(null)}catch(h){Ue(t,o,h)}else r.current=null}function Og(t){var o=t.type,r=t.memoizedProps,u=t.stateNode;try{e:switch(o){case"button":case"input":case"select":case"textarea":r.autoFocus&&u.focus();break e;case"img":r.src?u.src=r.src:r.srcSet&&(u.srcset=r.srcSet)}}catch(h){Ue(t,t.return,h)}}function Kd(t,o,r){try{var u=t.stateNode;Nw(u,t.type,r,o),u[Nt]=o}catch(h){Ue(t,t.return,h)}}function Fg(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&Lo(t.type)||t.tag===4}function Yd(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Fg(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&Lo(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Vd(t,o,r){var u=t.tag;if(u===5||u===6)t=t.stateNode,o?(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r).insertBefore(t,o):(o=r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,o.appendChild(t),r=r._reactRootContainer,r!=null||o.onclick!==null||(o.onclick=qn));else if(u!==4&&(u===27&&Lo(t.type)&&(r=t.stateNode,o=null),t=t.child,t!==null))for(Vd(t,o,r),t=t.sibling;t!==null;)Vd(t,o,r),t=t.sibling}function Al(t,o,r){var u=t.tag;if(u===5||u===6)t=t.stateNode,o?r.insertBefore(t,o):r.appendChild(t);else if(u!==4&&(u===27&&Lo(t.type)&&(r=t.stateNode),t=t.child,t!==null))for(Al(t,o,r),t=t.sibling;t!==null;)Al(t,o,r),t=t.sibling}function Ig(t){var o=t.stateNode,r=t.memoizedProps;try{for(var u=t.type,h=o.attributes;h.length;)o.removeAttributeNode(h[0]);Mt(o,u,r),o[mt]=t,o[Nt]=r}catch(y){Ue(t,t.return,y)}}var to=!1,dt=!1,Wd=!1,Lg=typeof WeakSet=="function"?WeakSet:Set,xt=null;function lw(t,o){if(t=t.containerInfo,gp=Zl,t=Zm(t),Hu(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var u=r.getSelection&&r.getSelection();if(u&&u.rangeCount!==0){r=u.anchorNode;var h=u.anchorOffset,y=u.focusNode;u=u.focusOffset;try{r.nodeType,y.nodeType}catch{r=null;break e}var j=0,R=-1,Y=-1,oe=0,le=0,de=t,ae=null;t:for(;;){for(var re;de!==r||h!==0&&de.nodeType!==3||(R=j+h),de!==y||u!==0&&de.nodeType!==3||(Y=j+u),de.nodeType===3&&(j+=de.nodeValue.length),(re=de.firstChild)!==null;)ae=de,de=re;for(;;){if(de===t)break t;if(ae===r&&++oe===h&&(R=j),ae===y&&++le===u&&(Y=j),(re=de.nextSibling)!==null)break;de=ae,ae=de.parentNode}de=re}r=R===-1||Y===-1?null:{start:R,end:Y}}else r=null}r=r||{start:0,end:0}}else r=null;for(yp={focusedElem:t,selectionRange:r},Zl=!1,xt=o;xt!==null;)if(o=xt,t=o.child,(o.subtreeFlags&1028)!==0&&t!==null)t.return=o,xt=t;else for(;xt!==null;){switch(o=xt,y=o.alternate,t=o.flags,o.tag){case 0:if((t&4)!==0&&(t=o.updateQueue,t=t!==null?t.events:null,t!==null))for(r=0;r<t.length;r++)h=t[r],h.ref.impl=h.nextImpl;break;case 11:case 15:break;case 1:if((t&1024)!==0&&y!==null){t=void 0,r=o,h=y.memoizedProps,y=y.memoizedState,u=r.stateNode;try{var xe=wa(r.type,h);t=u.getSnapshotBeforeUpdate(xe,y),u.__reactInternalSnapshotBeforeUpdate=t}catch(Me){Ue(r,r.return,Me)}}break;case 3:if((t&1024)!==0){if(t=o.stateNode.containerInfo,r=t.nodeType,r===9)vp(t);else if(r===1)switch(t.nodeName){case"HEAD":case"HTML":case"BODY":vp(t);break;default:t.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((t&1024)!==0)throw Error(s(163))}if(t=o.sibling,t!==null){t.return=o.return,xt=t;break}xt=o.return}}function Bg(t,o,r){var u=r.flags;switch(r.tag){case 0:case 11:case 15:oo(t,r),u&4&&Sr(5,r);break;case 1:if(oo(t,r),u&4)if(t=r.stateNode,o===null)try{t.componentDidMount()}catch(j){Ue(r,r.return,j)}else{var h=wa(r.type,o.memoizedProps);o=o.memoizedState;try{t.componentDidUpdate(h,o,t.__reactInternalSnapshotBeforeUpdate)}catch(j){Ue(r,r.return,j)}}u&64&&Rg(r),u&512&&Cr(r,r.return);break;case 3:if(oo(t,r),u&64&&(t=r.updateQueue,t!==null)){if(o=null,r.child!==null)switch(r.child.tag){case 27:case 5:o=r.child.stateNode;break;case 1:o=r.child.stateNode}try{Ch(t,o)}catch(j){Ue(r,r.return,j)}}break;case 27:o===null&&u&4&&Ig(r);case 26:case 5:oo(t,r),o===null&&u&4&&Og(r),u&512&&Cr(r,r.return);break;case 12:oo(t,r);break;case 31:oo(t,r),u&4&&Ug(t,r);break;case 13:oo(t,r),u&4&&Gg(t,r),u&64&&(t=r.memoizedState,t!==null&&(t=t.dehydrated,t!==null&&(r=yw.bind(null,r),Fw(t,r))));break;case 22:if(u=r.memoizedState!==null||to,!u){o=o!==null&&o.memoizedState!==null||dt,h=to;var y=dt;to=u,(dt=o)&&!y?ao(t,r,(r.subtreeFlags&8772)!==0):oo(t,r),to=h,dt=y}break;case 30:break;default:oo(t,r)}}function Pg(t){var o=t.alternate;o!==null&&(t.alternate=null,Pg(o)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(o=t.stateNode,o!==null&&Xs(o)),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}var Je=null,It=!1;function no(t,o,r){for(r=r.child;r!==null;)Hg(t,o,r),r=r.sibling}function Hg(t,o,r){if(Dt&&typeof Dt.onCommitFiberUnmount=="function")try{Dt.onCommitFiberUnmount(oa,r)}catch{}switch(r.tag){case 26:dt||_n(r,o),no(t,o,r),r.memoizedState?r.memoizedState.count--:r.stateNode&&(r=r.stateNode,r.parentNode.removeChild(r));break;case 27:dt||_n(r,o);var u=Je,h=It;Lo(r.type)&&(Je=r.stateNode,It=!1),no(t,o,r),zr(r.stateNode),Je=u,It=h;break;case 5:dt||_n(r,o);case 6:if(u=Je,h=It,Je=null,no(t,o,r),Je=u,It=h,Je!==null)if(It)try{(Je.nodeType===9?Je.body:Je.nodeName==="HTML"?Je.ownerDocument.body:Je).removeChild(r.stateNode)}catch(y){Ue(r,o,y)}else try{Je.removeChild(r.stateNode)}catch(y){Ue(r,o,y)}break;case 18:Je!==null&&(It?(t=Je,Ry(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,r.stateNode),js(t)):Ry(Je,r.stateNode));break;case 4:u=Je,h=It,Je=r.stateNode.containerInfo,It=!0,no(t,o,r),Je=u,It=h;break;case 0:case 11:case 14:case 15:Do(2,r,o),dt||Do(4,r,o),no(t,o,r);break;case 1:dt||(_n(r,o),u=r.stateNode,typeof u.componentWillUnmount=="function"&&$g(r,o,u)),no(t,o,r);break;case 21:no(t,o,r);break;case 22:dt=(u=dt)||r.memoizedState!==null,no(t,o,r),dt=u;break;default:no(t,o,r)}}function Ug(t,o){if(o.memoizedState===null&&(t=o.alternate,t!==null&&(t=t.memoizedState,t!==null))){t=t.dehydrated;try{js(t)}catch(r){Ue(o,o.return,r)}}}function Gg(t,o){if(o.memoizedState===null&&(t=o.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{js(t)}catch(r){Ue(o,o.return,r)}}function cw(t){switch(t.tag){case 31:case 13:case 19:var o=t.stateNode;return o===null&&(o=t.stateNode=new Lg),o;case 22:return t=t.stateNode,o=t._retryCache,o===null&&(o=t._retryCache=new Lg),o;default:throw Error(s(435,t.tag))}}function _l(t,o){var r=cw(t);o.forEach(function(u){if(!r.has(u)){r.add(u);var h=xw.bind(null,t,u);u.then(h,h)}})}function Lt(t,o){var r=o.deletions;if(r!==null)for(var u=0;u<r.length;u++){var h=r[u],y=t,j=o,R=j;e:for(;R!==null;){switch(R.tag){case 27:if(Lo(R.type)){Je=R.stateNode,It=!1;break e}break;case 5:Je=R.stateNode,It=!1;break e;case 3:case 4:Je=R.stateNode.containerInfo,It=!0;break e}R=R.return}if(Je===null)throw Error(s(160));Hg(y,j,h),Je=null,It=!1,y=h.alternate,y!==null&&(y.return=null),h.return=null}if(o.subtreeFlags&13886)for(o=o.child;o!==null;)qg(o,t),o=o.sibling}var xn=null;function qg(t,o){var r=t.alternate,u=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:Lt(o,t),Bt(t),u&4&&(Do(3,t,t.return),Sr(3,t),Do(5,t,t.return));break;case 1:Lt(o,t),Bt(t),u&512&&(dt||r===null||_n(r,r.return)),u&64&&to&&(t=t.updateQueue,t!==null&&(u=t.callbacks,u!==null&&(r=t.shared.hiddenCallbacks,t.shared.hiddenCallbacks=r===null?u:r.concat(u))));break;case 26:var h=xn;if(Lt(o,t),Bt(t),u&512&&(dt||r===null||_n(r,r.return)),u&4){var y=r!==null?r.memoizedState:null;if(u=t.memoizedState,r===null)if(u===null)if(t.stateNode===null){e:{u=t.type,r=t.memoizedProps,h=h.ownerDocument||h;t:switch(u){case"title":y=h.getElementsByTagName("title")[0],(!y||y[ra]||y[mt]||y.namespaceURI==="http://www.w3.org/2000/svg"||y.hasAttribute("itemprop"))&&(y=h.createElement(u),h.head.insertBefore(y,h.querySelector("head > title"))),Mt(y,u,r),y[mt]=t,it(y),u=y;break e;case"link":var j=qy("link","href",h).get(u+(r.href||""));if(j){for(var R=0;R<j.length;R++)if(y=j[R],y.getAttribute("href")===(r.href==null||r.href===""?null:r.href)&&y.getAttribute("rel")===(r.rel==null?null:r.rel)&&y.getAttribute("title")===(r.title==null?null:r.title)&&y.getAttribute("crossorigin")===(r.crossOrigin==null?null:r.crossOrigin)){j.splice(R,1);break t}}y=h.createElement(u),Mt(y,u,r),h.head.appendChild(y);break;case"meta":if(j=qy("meta","content",h).get(u+(r.content||""))){for(R=0;R<j.length;R++)if(y=j[R],y.getAttribute("content")===(r.content==null?null:""+r.content)&&y.getAttribute("name")===(r.name==null?null:r.name)&&y.getAttribute("property")===(r.property==null?null:r.property)&&y.getAttribute("http-equiv")===(r.httpEquiv==null?null:r.httpEquiv)&&y.getAttribute("charset")===(r.charSet==null?null:r.charSet)){j.splice(R,1);break t}}y=h.createElement(u),Mt(y,u,r),h.head.appendChild(y);break;default:throw Error(s(468,u))}y[mt]=t,it(y),u=y}t.stateNode=u}else Ky(h,t.type,t.stateNode);else t.stateNode=Gy(h,u,t.memoizedProps);else y!==u?(y===null?r.stateNode!==null&&(r=r.stateNode,r.parentNode.removeChild(r)):y.count--,u===null?Ky(h,t.type,t.stateNode):Gy(h,u,t.memoizedProps)):u===null&&t.stateNode!==null&&Kd(t,t.memoizedProps,r.memoizedProps)}break;case 27:Lt(o,t),Bt(t),u&512&&(dt||r===null||_n(r,r.return)),r!==null&&u&4&&Kd(t,t.memoizedProps,r.memoizedProps);break;case 5:if(Lt(o,t),Bt(t),u&512&&(dt||r===null||_n(r,r.return)),t.flags&32){h=t.stateNode;try{Xa(h,"")}catch(xe){Ue(t,t.return,xe)}}u&4&&t.stateNode!=null&&(h=t.memoizedProps,Kd(t,h,r!==null?r.memoizedProps:h)),u&1024&&(Wd=!0);break;case 6:if(Lt(o,t),Bt(t),u&4){if(t.stateNode===null)throw Error(s(162));u=t.memoizedProps,r=t.stateNode;try{r.nodeValue=u}catch(xe){Ue(t,t.return,xe)}}break;case 3:if(Yl=null,h=xn,xn=ql(o.containerInfo),Lt(o,t),xn=h,Bt(t),u&4&&r!==null&&r.memoizedState.isDehydrated)try{js(o.containerInfo)}catch(xe){Ue(t,t.return,xe)}Wd&&(Wd=!1,Kg(t));break;case 4:u=xn,xn=ql(t.stateNode.containerInfo),Lt(o,t),Bt(t),xn=u;break;case 12:Lt(o,t),Bt(t);break;case 31:Lt(o,t),Bt(t),u&4&&(u=t.updateQueue,u!==null&&(t.updateQueue=null,_l(t,u)));break;case 13:Lt(o,t),Bt(t),t.child.flags&8192&&t.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(zl=kt()),u&4&&(u=t.updateQueue,u!==null&&(t.updateQueue=null,_l(t,u)));break;case 22:h=t.memoizedState!==null;var Y=r!==null&&r.memoizedState!==null,oe=to,le=dt;if(to=oe||h,dt=le||Y,Lt(o,t),dt=le,to=oe,Bt(t),u&8192)e:for(o=t.stateNode,o._visibility=h?o._visibility&-2:o._visibility|1,h&&(r===null||Y||to||dt||Sa(t)),r=null,o=t;;){if(o.tag===5||o.tag===26){if(r===null){Y=r=o;try{if(y=Y.stateNode,h)j=y.style,typeof j.setProperty=="function"?j.setProperty("display","none","important"):j.display="none";else{R=Y.stateNode;var de=Y.memoizedProps.style,ae=de!=null&&de.hasOwnProperty("display")?de.display:null;R.style.display=ae==null||typeof ae=="boolean"?"":(""+ae).trim()}}catch(xe){Ue(Y,Y.return,xe)}}}else if(o.tag===6){if(r===null){Y=o;try{Y.stateNode.nodeValue=h?"":Y.memoizedProps}catch(xe){Ue(Y,Y.return,xe)}}}else if(o.tag===18){if(r===null){Y=o;try{var re=Y.stateNode;h?$y(re,!0):$y(Y.stateNode,!1)}catch(xe){Ue(Y,Y.return,xe)}}}else if((o.tag!==22&&o.tag!==23||o.memoizedState===null||o===t)&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===t)break e;for(;o.sibling===null;){if(o.return===null||o.return===t)break e;r===o&&(r=null),o=o.return}r===o&&(r=null),o.sibling.return=o.return,o=o.sibling}u&4&&(u=t.updateQueue,u!==null&&(r=u.retryQueue,r!==null&&(u.retryQueue=null,_l(t,r))));break;case 19:Lt(o,t),Bt(t),u&4&&(u=t.updateQueue,u!==null&&(t.updateQueue=null,_l(t,u)));break;case 30:break;case 21:break;default:Lt(o,t),Bt(t)}}function Bt(t){var o=t.flags;if(o&2){try{for(var r,u=t.return;u!==null;){if(Fg(u)){r=u;break}u=u.return}if(r==null)throw Error(s(160));switch(r.tag){case 27:var h=r.stateNode,y=Yd(t);Al(t,y,h);break;case 5:var j=r.stateNode;r.flags&32&&(Xa(j,""),r.flags&=-33);var R=Yd(t);Al(t,R,j);break;case 3:case 4:var Y=r.stateNode.containerInfo,oe=Yd(t);Vd(t,oe,Y);break;default:throw Error(s(161))}}catch(le){Ue(t,t.return,le)}t.flags&=-3}o&4096&&(t.flags&=-4097)}function Kg(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var o=t;Kg(o),o.tag===5&&o.flags&1024&&o.stateNode.reset(),t=t.sibling}}function oo(t,o){if(o.subtreeFlags&8772)for(o=o.child;o!==null;)Bg(t,o.alternate,o),o=o.sibling}function Sa(t){for(t=t.child;t!==null;){var o=t;switch(o.tag){case 0:case 11:case 14:case 15:Do(4,o,o.return),Sa(o);break;case 1:_n(o,o.return);var r=o.stateNode;typeof r.componentWillUnmount=="function"&&$g(o,o.return,r),Sa(o);break;case 27:zr(o.stateNode);case 26:case 5:_n(o,o.return),Sa(o);break;case 22:o.memoizedState===null&&Sa(o);break;case 30:Sa(o);break;default:Sa(o)}t=t.sibling}}function ao(t,o,r){for(r=r&&(o.subtreeFlags&8772)!==0,o=o.child;o!==null;){var u=o.alternate,h=t,y=o,j=y.flags;switch(y.tag){case 0:case 11:case 15:ao(h,y,r),Sr(4,y);break;case 1:if(ao(h,y,r),u=y,h=u.stateNode,typeof h.componentDidMount=="function")try{h.componentDidMount()}catch(oe){Ue(u,u.return,oe)}if(u=y,h=u.updateQueue,h!==null){var R=u.stateNode;try{var Y=h.shared.hiddenCallbacks;if(Y!==null)for(h.shared.hiddenCallbacks=null,h=0;h<Y.length;h++)Sh(Y[h],R)}catch(oe){Ue(u,u.return,oe)}}r&&j&64&&Rg(y),Cr(y,y.return);break;case 27:Ig(y);case 26:case 5:ao(h,y,r),r&&u===null&&j&4&&Og(y),Cr(y,y.return);break;case 12:ao(h,y,r);break;case 31:ao(h,y,r),r&&j&4&&Ug(h,y);break;case 13:ao(h,y,r),r&&j&4&&Gg(h,y);break;case 22:y.memoizedState===null&&ao(h,y,r),Cr(y,y.return);break;case 30:break;default:ao(h,y,r)}o=o.sibling}}function Xd(t,o){var r=null;t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),t=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(t=o.memoizedState.cachePool.pool),t!==r&&(t!=null&&t.refCount++,r!=null&&ur(r))}function Zd(t,o){t=null,o.alternate!==null&&(t=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==t&&(o.refCount++,t!=null&&ur(t))}function bn(t,o,r,u){if(o.subtreeFlags&10256)for(o=o.child;o!==null;)Yg(t,o,r,u),o=o.sibling}function Yg(t,o,r,u){var h=o.flags;switch(o.tag){case 0:case 11:case 15:bn(t,o,r,u),h&2048&&Sr(9,o);break;case 1:bn(t,o,r,u);break;case 3:bn(t,o,r,u),h&2048&&(t=null,o.alternate!==null&&(t=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==t&&(o.refCount++,t!=null&&ur(t)));break;case 12:if(h&2048){bn(t,o,r,u),t=o.stateNode;try{var y=o.memoizedProps,j=y.id,R=y.onPostCommit;typeof R=="function"&&R(j,o.alternate===null?"mount":"update",t.passiveEffectDuration,-0)}catch(Y){Ue(o,o.return,Y)}}else bn(t,o,r,u);break;case 31:bn(t,o,r,u);break;case 13:bn(t,o,r,u);break;case 23:break;case 22:y=o.stateNode,j=o.alternate,o.memoizedState!==null?y._visibility&2?bn(t,o,r,u):Mr(t,o):y._visibility&2?bn(t,o,r,u):(y._visibility|=2,gs(t,o,r,u,(o.subtreeFlags&10256)!==0||!1)),h&2048&&Xd(j,o);break;case 24:bn(t,o,r,u),h&2048&&Zd(o.alternate,o);break;default:bn(t,o,r,u)}}function gs(t,o,r,u,h){for(h=h&&((o.subtreeFlags&10256)!==0||!1),o=o.child;o!==null;){var y=t,j=o,R=r,Y=u,oe=j.flags;switch(j.tag){case 0:case 11:case 15:gs(y,j,R,Y,h),Sr(8,j);break;case 23:break;case 22:var le=j.stateNode;j.memoizedState!==null?le._visibility&2?gs(y,j,R,Y,h):Mr(y,j):(le._visibility|=2,gs(y,j,R,Y,h)),h&&oe&2048&&Xd(j.alternate,j);break;case 24:gs(y,j,R,Y,h),h&&oe&2048&&Zd(j.alternate,j);break;default:gs(y,j,R,Y,h)}o=o.sibling}}function Mr(t,o){if(o.subtreeFlags&10256)for(o=o.child;o!==null;){var r=t,u=o,h=u.flags;switch(u.tag){case 22:Mr(r,u),h&2048&&Xd(u.alternate,u);break;case 24:Mr(r,u),h&2048&&Zd(u.alternate,u);break;default:Mr(r,u)}o=o.sibling}}var Er=8192;function ys(t,o,r){if(t.subtreeFlags&Er)for(t=t.child;t!==null;)Vg(t,o,r),t=t.sibling}function Vg(t,o,r){switch(t.tag){case 26:ys(t,o,r),t.flags&Er&&t.memoizedState!==null&&Ww(r,xn,t.memoizedState,t.memoizedProps);break;case 5:ys(t,o,r);break;case 3:case 4:var u=xn;xn=ql(t.stateNode.containerInfo),ys(t,o,r),xn=u;break;case 22:t.memoizedState===null&&(u=t.alternate,u!==null&&u.memoizedState!==null?(u=Er,Er=16777216,ys(t,o,r),Er=u):ys(t,o,r));break;default:ys(t,o,r)}}function Wg(t){var o=t.alternate;if(o!==null&&(t=o.child,t!==null)){o.child=null;do o=t.sibling,t.sibling=null,t=o;while(t!==null)}}function jr(t){var o=t.deletions;if((t.flags&16)!==0){if(o!==null)for(var r=0;r<o.length;r++){var u=o[r];xt=u,Zg(u,t)}Wg(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Xg(t),t=t.sibling}function Xg(t){switch(t.tag){case 0:case 11:case 15:jr(t),t.flags&2048&&Do(9,t,t.return);break;case 3:jr(t);break;case 12:jr(t);break;case 22:var o=t.stateNode;t.memoizedState!==null&&o._visibility&2&&(t.return===null||t.return.tag!==13)?(o._visibility&=-3,Dl(t)):jr(t);break;default:jr(t)}}function Dl(t){var o=t.deletions;if((t.flags&16)!==0){if(o!==null)for(var r=0;r<o.length;r++){var u=o[r];xt=u,Zg(u,t)}Wg(t)}for(t=t.child;t!==null;){switch(o=t,o.tag){case 0:case 11:case 15:Do(8,o,o.return),Dl(o);break;case 22:r=o.stateNode,r._visibility&2&&(r._visibility&=-3,Dl(o));break;default:Dl(o)}t=t.sibling}}function Zg(t,o){for(;xt!==null;){var r=xt;switch(r.tag){case 0:case 11:case 15:Do(8,r,o);break;case 23:case 22:if(r.memoizedState!==null&&r.memoizedState.cachePool!==null){var u=r.memoizedState.cachePool.pool;u!=null&&u.refCount++}break;case 24:ur(r.memoizedState.cache)}if(u=r.child,u!==null)u.return=r,xt=u;else e:for(r=t;xt!==null;){u=xt;var h=u.sibling,y=u.return;if(Pg(u),u===r){xt=null;break e}if(h!==null){h.return=y,xt=h;break e}xt=y}}}var uw={getCacheForType:function(t){var o=St(lt),r=o.data.get(t);return r===void 0&&(r=t(),o.data.set(t,r)),r},cacheSignal:function(){return St(lt).controller.signal}},dw=typeof WeakMap=="function"?WeakMap:Map,Pe=0,Ve=null,_e=null,Re=0,He=0,Xt=null,zo=!1,xs=!1,Qd=!1,so=0,ot=0,Ro=0,Ca=0,Jd=0,Zt=0,bs=0,Tr=null,Pt=null,ep=!1,zl=0,Qg=0,Rl=1/0,$l=null,$o=null,ht=0,Oo=null,vs=null,ro=0,tp=0,np=null,Jg=null,Nr=0,op=null;function Qt(){return(Pe&2)!==0&&Re!==0?Re&-Re:T.T!==null?cp():Li()}function ey(){if(Zt===0)if((Re&536870912)===0||Oe){var t=Ua;Ua<<=1,(Ua&3932160)===0&&(Ua=262144),Zt=t}else Zt=536870912;return t=Vt.current,t!==null&&(t.flags|=32),Zt}function Ht(t,o,r){(t===Ve&&(He===2||He===9)||t.cancelPendingCommit!==null)&&(ks(t,0),Fo(t,Re,Zt,!1)),sa(t,r),((Pe&2)===0||t!==Ve)&&(t===Ve&&((Pe&2)===0&&(Ca|=r),ot===4&&Fo(t,Re,Zt,!1)),Dn(t))}function ty(t,o,r){if((Pe&6)!==0)throw Error(s(327));var u=!r&&(o&127)===0&&(o&t.expiredLanes)===0||aa(t,o),h=u?mw(t,o):sp(t,o,!0),y=u;do{if(h===0){xs&&!u&&Fo(t,o,0,!1);break}else{if(r=t.current.alternate,y&&!pw(r)){h=sp(t,o,!1),y=!1;continue}if(h===2){if(y=o,t.errorRecoveryDisabledLanes&y)var j=0;else j=t.pendingLanes&-536870913,j=j!==0?j:j&536870912?536870912:0;if(j!==0){o=j;e:{var R=t;h=Tr;var Y=R.current.memoizedState.isDehydrated;if(Y&&(ks(R,j).flags|=256),j=sp(R,j,!1),j!==2){if(Qd&&!Y){R.errorRecoveryDisabledLanes|=y,Ca|=y,h=4;break e}y=Pt,Pt=h,y!==null&&(Pt===null?Pt=y:Pt.push.apply(Pt,y))}h=j}if(y=!1,h!==2)continue}}if(h===1){ks(t,0),Fo(t,o,0,!0);break}e:{switch(u=t,y=h,y){case 0:case 1:throw Error(s(345));case 4:if((o&4194048)!==o)break;case 6:Fo(u,o,Zt,!zo);break e;case 2:Pt=null;break;case 3:case 5:break;default:throw Error(s(329))}if((o&62914560)===o&&(h=zl+300-kt(),10<h)){if(Fo(u,o,Zt,!zo),qa(u,0,!0)!==0)break e;ro=o,u.timeoutHandle=Dy(ny.bind(null,u,r,Pt,$l,ep,o,Zt,Ca,bs,zo,y,"Throttled",-0,0),h);break e}ny(u,r,Pt,$l,ep,o,Zt,Ca,bs,zo,y,null,-0,0)}}break}while(!0);Dn(t)}function ny(t,o,r,u,h,y,j,R,Y,oe,le,de,ae,re){if(t.timeoutHandle=-1,de=o.subtreeFlags,de&8192||(de&16785408)===16785408){de={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:qn},Vg(o,y,de);var xe=(y&62914560)===y?zl-kt():(y&4194048)===y?Qg-kt():0;if(xe=Xw(de,xe),xe!==null){ro=y,t.cancelPendingCommit=xe(uy.bind(null,t,o,y,r,u,h,j,R,Y,le,de,null,ae,re)),Fo(t,y,j,!oe);return}}uy(t,o,y,r,u,h,j,R,Y)}function pw(t){for(var o=t;;){var r=o.tag;if((r===0||r===11||r===15)&&o.flags&16384&&(r=o.updateQueue,r!==null&&(r=r.stores,r!==null)))for(var u=0;u<r.length;u++){var h=r[u],y=h.getSnapshot;h=h.value;try{if(!Kt(y(),h))return!1}catch{return!1}}if(r=o.child,o.subtreeFlags&16384&&r!==null)r.return=o,o=r;else{if(o===t)break;for(;o.sibling===null;){if(o.return===null||o.return===t)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function Fo(t,o,r,u){o&=~Jd,o&=~Ca,t.suspendedLanes|=o,t.pingedLanes&=~o,u&&(t.warmLanes|=o),u=t.expirationTimes;for(var h=o;0<h;){var y=31-zt(h),j=1<<y;u[y]=-1,h&=~j}r!==0&&Oi(t,r,o)}function Ol(){return(Pe&6)===0?(Ar(0),!1):!0}function ap(){if(_e!==null){if(He===0)var t=_e.return;else t=_e,Wn=ha=null,vd(t),ds=null,pr=0,t=_e;for(;t!==null;)zg(t.alternate,t),t=t.return;_e=null}}function ks(t,o){var r=t.timeoutHandle;r!==-1&&(t.timeoutHandle=-1,Dw(r)),r=t.cancelPendingCommit,r!==null&&(t.cancelPendingCommit=null,r()),ro=0,ap(),Ve=t,_e=r=Yn(t.current,null),Re=o,He=0,Xt=null,zo=!1,xs=aa(t,o),Qd=!1,bs=Zt=Jd=Ca=Ro=ot=0,Pt=Tr=null,ep=!1,(o&8)!==0&&(o|=o&32);var u=t.entangledLanes;if(u!==0)for(t=t.entanglements,u&=o;0<u;){var h=31-zt(u),y=1<<h;o|=t[h],u&=~y}return so=o,ol(),r}function oy(t,o){Ne=null,T.H=vr,o===us||o===dl?(o=bh(),He=3):o===ld?(o=bh(),He=4):He=o===Od?8:o!==null&&typeof o=="object"&&typeof o.then=="function"?6:1,Xt=o,_e===null&&(ot=1,Ml(t,on(o,t.current)))}function ay(){var t=Vt.current;return t===null?!0:(Re&4194048)===Re?ln===null:(Re&62914560)===Re||(Re&536870912)!==0?t===ln:!1}function sy(){var t=T.H;return T.H=vr,t===null?vr:t}function ry(){var t=T.A;return T.A=uw,t}function Fl(){ot=4,zo||(Re&4194048)!==Re&&Vt.current!==null||(xs=!0),(Ro&134217727)===0&&(Ca&134217727)===0||Ve===null||Fo(Ve,Re,Zt,!1)}function sp(t,o,r){var u=Pe;Pe|=2;var h=sy(),y=ry();(Ve!==t||Re!==o)&&($l=null,ks(t,o)),o=!1;var j=ot;e:do try{if(He!==0&&_e!==null){var R=_e,Y=Xt;switch(He){case 8:ap(),j=6;break e;case 3:case 2:case 9:case 6:Vt.current===null&&(o=!0);var oe=He;if(He=0,Xt=null,ws(t,R,Y,oe),r&&xs){j=0;break e}break;default:oe=He,He=0,Xt=null,ws(t,R,Y,oe)}}fw(),j=ot;break}catch(le){oy(t,le)}while(!0);return o&&t.shellSuspendCounter++,Wn=ha=null,Pe=u,T.H=h,T.A=y,_e===null&&(Ve=null,Re=0,ol()),j}function fw(){for(;_e!==null;)iy(_e)}function mw(t,o){var r=Pe;Pe|=2;var u=sy(),h=ry();Ve!==t||Re!==o?($l=null,Rl=kt()+500,ks(t,o)):xs=aa(t,o);e:do try{if(He!==0&&_e!==null){o=_e;var y=Xt;t:switch(He){case 1:He=0,Xt=null,ws(t,o,y,1);break;case 2:case 9:if(yh(y)){He=0,Xt=null,ly(o);break}o=function(){He!==2&&He!==9||Ve!==t||(He=7),Dn(t)},y.then(o,o);break e;case 3:He=7;break e;case 4:He=5;break e;case 7:yh(y)?(He=0,Xt=null,ly(o)):(He=0,Xt=null,ws(t,o,y,7));break;case 5:var j=null;switch(_e.tag){case 26:j=_e.memoizedState;case 5:case 27:var R=_e;if(j?Yy(j):R.stateNode.complete){He=0,Xt=null;var Y=R.sibling;if(Y!==null)_e=Y;else{var oe=R.return;oe!==null?(_e=oe,Il(oe)):_e=null}break t}}He=0,Xt=null,ws(t,o,y,5);break;case 6:He=0,Xt=null,ws(t,o,y,6);break;case 8:ap(),ot=6;break e;default:throw Error(s(462))}}hw();break}catch(le){oy(t,le)}while(!0);return Wn=ha=null,T.H=u,T.A=h,Pe=r,_e!==null?0:(Ve=null,Re=0,ol(),ot)}function hw(){for(;_e!==null&&!tn();)iy(_e)}function iy(t){var o=_g(t.alternate,t,so);t.memoizedProps=t.pendingProps,o===null?Il(t):_e=o}function ly(t){var o=t,r=o.alternate;switch(o.tag){case 15:case 0:o=Mg(r,o,o.pendingProps,o.type,void 0,Re);break;case 11:o=Mg(r,o,o.pendingProps,o.type.render,o.ref,Re);break;case 5:vd(o);default:zg(r,o),o=_e=rh(o,so),o=_g(r,o,so)}t.memoizedProps=t.pendingProps,o===null?Il(t):_e=o}function ws(t,o,r,u){Wn=ha=null,vd(o),ds=null,pr=0;var h=o.return;try{if(ow(t,h,o,r,Re)){ot=1,Ml(t,on(r,t.current)),_e=null;return}}catch(y){if(h!==null)throw _e=h,y;ot=1,Ml(t,on(r,t.current)),_e=null;return}o.flags&32768?(Oe||u===1?t=!0:xs||(Re&536870912)!==0?t=!1:(zo=t=!0,(u===2||u===9||u===3||u===6)&&(u=Vt.current,u!==null&&u.tag===13&&(u.flags|=16384))),cy(o,t)):Il(o)}function Il(t){var o=t;do{if((o.flags&32768)!==0){cy(o,zo);return}t=o.return;var r=rw(o.alternate,o,so);if(r!==null){_e=r;return}if(o=o.sibling,o!==null){_e=o;return}_e=o=t}while(o!==null);ot===0&&(ot=5)}function cy(t,o){do{var r=iw(t.alternate,t);if(r!==null){r.flags&=32767,_e=r;return}if(r=t.return,r!==null&&(r.flags|=32768,r.subtreeFlags=0,r.deletions=null),!o&&(t=t.sibling,t!==null)){_e=t;return}_e=t=r}while(t!==null);ot=6,_e=null}function uy(t,o,r,u,h,y,j,R,Y){t.cancelPendingCommit=null;do Ll();while(ht!==0);if((Pe&6)!==0)throw Error(s(327));if(o!==null){if(o===t.current)throw Error(s(177));if(y=o.lanes|o.childLanes,y|=Yu,Su(t,r,y,j,R,Y),t===Ve&&(_e=Ve=null,Re=0),vs=o,Oo=t,ro=r,tp=y,np=h,Jg=u,(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?(t.callbackNode=null,t.callbackPriority=0,bw(na,function(){return hy(),null})):(t.callbackNode=null,t.callbackPriority=0),u=(o.flags&13878)!==0,(o.subtreeFlags&13878)!==0||u){u=T.T,T.T=null,h=B.p,B.p=2,j=Pe,Pe|=4;try{lw(t,o,r)}finally{Pe=j,B.p=h,T.T=u}}ht=1,dy(),py(),fy()}}function dy(){if(ht===1){ht=0;var t=Oo,o=vs,r=(o.flags&13878)!==0;if((o.subtreeFlags&13878)!==0||r){r=T.T,T.T=null;var u=B.p;B.p=2;var h=Pe;Pe|=4;try{qg(o,t);var y=yp,j=Zm(t.containerInfo),R=y.focusedElem,Y=y.selectionRange;if(j!==R&&R&&R.ownerDocument&&Xm(R.ownerDocument.documentElement,R)){if(Y!==null&&Hu(R)){var oe=Y.start,le=Y.end;if(le===void 0&&(le=oe),"selectionStart"in R)R.selectionStart=oe,R.selectionEnd=Math.min(le,R.value.length);else{var de=R.ownerDocument||document,ae=de&&de.defaultView||window;if(ae.getSelection){var re=ae.getSelection(),xe=R.textContent.length,Me=Math.min(Y.start,xe),Ke=Y.end===void 0?Me:Math.min(Y.end,xe);!re.extend&&Me>Ke&&(j=Ke,Ke=Me,Me=j);var ee=Wm(R,Me),Z=Wm(R,Ke);if(ee&&Z&&(re.rangeCount!==1||re.anchorNode!==ee.node||re.anchorOffset!==ee.offset||re.focusNode!==Z.node||re.focusOffset!==Z.offset)){var ne=de.createRange();ne.setStart(ee.node,ee.offset),re.removeAllRanges(),Me>Ke?(re.addRange(ne),re.extend(Z.node,Z.offset)):(ne.setEnd(Z.node,Z.offset),re.addRange(ne))}}}}for(de=[],re=R;re=re.parentNode;)re.nodeType===1&&de.push({element:re,left:re.scrollLeft,top:re.scrollTop});for(typeof R.focus=="function"&&R.focus(),R=0;R<de.length;R++){var ue=de[R];ue.element.scrollLeft=ue.left,ue.element.scrollTop=ue.top}}Zl=!!gp,yp=gp=null}finally{Pe=h,B.p=u,T.T=r}}t.current=o,ht=2}}function py(){if(ht===2){ht=0;var t=Oo,o=vs,r=(o.flags&8772)!==0;if((o.subtreeFlags&8772)!==0||r){r=T.T,T.T=null;var u=B.p;B.p=2;var h=Pe;Pe|=4;try{Bg(t,o.alternate,o)}finally{Pe=h,B.p=u,T.T=r}}ht=3}}function fy(){if(ht===4||ht===3){ht=0,hn();var t=Oo,o=vs,r=ro,u=Jg;(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?ht=5:(ht=0,vs=Oo=null,my(t,t.pendingLanes));var h=t.pendingLanes;if(h===0&&($o=null),Ws(r),o=o.stateNode,Dt&&typeof Dt.onCommitFiberRoot=="function")try{Dt.onCommitFiberRoot(oa,o,void 0,(o.current.flags&128)===128)}catch{}if(u!==null){o=T.T,h=B.p,B.p=2,T.T=null;try{for(var y=t.onRecoverableError,j=0;j<u.length;j++){var R=u[j];y(R.value,{componentStack:R.stack})}}finally{T.T=o,B.p=h}}(ro&3)!==0&&Ll(),Dn(t),h=t.pendingLanes,(r&261930)!==0&&(h&42)!==0?t===op?Nr++:(Nr=0,op=t):Nr=0,Ar(0)}}function my(t,o){(t.pooledCacheLanes&=o)===0&&(o=t.pooledCache,o!=null&&(t.pooledCache=null,ur(o)))}function Ll(){return dy(),py(),fy(),hy()}function hy(){if(ht!==5)return!1;var t=Oo,o=tp;tp=0;var r=Ws(ro),u=T.T,h=B.p;try{B.p=32>r?32:r,T.T=null,r=np,np=null;var y=Oo,j=ro;if(ht=0,vs=Oo=null,ro=0,(Pe&6)!==0)throw Error(s(331));var R=Pe;if(Pe|=4,Xg(y.current),Yg(y,y.current,j,r),Pe=R,Ar(0,!1),Dt&&typeof Dt.onPostCommitFiberRoot=="function")try{Dt.onPostCommitFiberRoot(oa,y)}catch{}return!0}finally{B.p=h,T.T=u,my(t,o)}}function gy(t,o,r){o=on(r,o),o=$d(t.stateNode,o,2),t=No(t,o,2),t!==null&&(sa(t,2),Dn(t))}function Ue(t,o,r){if(t.tag===3)gy(t,t,r);else for(;o!==null;){if(o.tag===3){gy(o,t,r);break}else if(o.tag===1){var u=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&($o===null||!$o.has(u))){t=on(r,t),r=yg(2),u=No(o,r,2),u!==null&&(xg(r,u,o,t),sa(u,2),Dn(u));break}}o=o.return}}function rp(t,o,r){var u=t.pingCache;if(u===null){u=t.pingCache=new dw;var h=new Set;u.set(o,h)}else h=u.get(o),h===void 0&&(h=new Set,u.set(o,h));h.has(r)||(Qd=!0,h.add(r),t=gw.bind(null,t,o,r),o.then(t,t))}function gw(t,o,r){var u=t.pingCache;u!==null&&u.delete(o),t.pingedLanes|=t.suspendedLanes&r,t.warmLanes&=~r,Ve===t&&(Re&r)===r&&(ot===4||ot===3&&(Re&62914560)===Re&&300>kt()-zl?(Pe&2)===0&&ks(t,0):Jd|=r,bs===Re&&(bs=0)),Dn(t)}function yy(t,o){o===0&&(o=$i()),t=pa(t,o),t!==null&&(sa(t,o),Dn(t))}function yw(t){var o=t.memoizedState,r=0;o!==null&&(r=o.retryLane),yy(t,r)}function xw(t,o){var r=0;switch(t.tag){case 31:case 13:var u=t.stateNode,h=t.memoizedState;h!==null&&(r=h.retryLane);break;case 19:u=t.stateNode;break;case 22:u=t.stateNode._retryCache;break;default:throw Error(s(314))}u!==null&&u.delete(o),yy(t,r)}function bw(t,o){return vt(t,o)}var Bl=null,Ss=null,ip=!1,Pl=!1,lp=!1,Io=0;function Dn(t){t!==Ss&&t.next===null&&(Ss===null?Bl=Ss=t:Ss=Ss.next=t),Pl=!0,ip||(ip=!0,kw())}function Ar(t,o){if(!lp&&Pl){lp=!0;do for(var r=!1,u=Bl;u!==null;){if(t!==0){var h=u.pendingLanes;if(h===0)var y=0;else{var j=u.suspendedLanes,R=u.pingedLanes;y=(1<<31-zt(42|t)+1)-1,y&=h&~(j&~R),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(r=!0,ky(u,y))}else y=Re,y=qa(u,u===Ve?y:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(y&3)===0||aa(u,y)||(r=!0,ky(u,y));u=u.next}while(r);lp=!1}}function vw(){xy()}function xy(){Pl=ip=!1;var t=0;Io!==0&&_w()&&(t=Io);for(var o=kt(),r=null,u=Bl;u!==null;){var h=u.next,y=by(u,o);y===0?(u.next=null,r===null?Bl=h:r.next=h,h===null&&(Ss=r)):(r=u,(t!==0||(y&3)!==0)&&(Pl=!0)),u=h}ht!==0&&ht!==5||Ar(t),Io!==0&&(Io=0)}function by(t,o){for(var r=t.suspendedLanes,u=t.pingedLanes,h=t.expirationTimes,y=t.pendingLanes&-62914561;0<y;){var j=31-zt(y),R=1<<j,Y=h[j];Y===-1?((R&r)===0||(R&u)!==0)&&(h[j]=wu(R,o)):Y<=o&&(t.expiredLanes|=R),y&=~R}if(o=Ve,r=Re,r=qa(t,t===o?r:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),u=t.callbackNode,r===0||t===o&&(He===2||He===9)||t.cancelPendingCommit!==null)return u!==null&&u!==null&&mn(u),t.callbackNode=null,t.callbackPriority=0;if((r&3)===0||aa(t,r)){if(o=r&-r,o===t.callbackPriority)return o;switch(u!==null&&mn(u),Ws(r)){case 2:case 8:r=go;break;case 32:r=na;break;case 268435456:r=Pa;break;default:r=na}return u=vy.bind(null,t),r=vt(r,u),t.callbackPriority=o,t.callbackNode=r,o}return u!==null&&u!==null&&mn(u),t.callbackPriority=2,t.callbackNode=null,2}function vy(t,o){if(ht!==0&&ht!==5)return t.callbackNode=null,t.callbackPriority=0,null;var r=t.callbackNode;if(Ll()&&t.callbackNode!==r)return null;var u=Re;return u=qa(t,t===Ve?u:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),u===0?null:(ty(t,u,o),by(t,kt()),t.callbackNode!=null&&t.callbackNode===r?vy.bind(null,t):null)}function ky(t,o){if(Ll())return null;ty(t,o,!0)}function kw(){zw(function(){(Pe&6)!==0?vt(Bn,vw):xy()})}function cp(){if(Io===0){var t=ls;t===0&&(t=Ha,Ha<<=1,(Ha&261888)===0&&(Ha=256)),Io=t}return Io}function wy(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:Wi(""+t)}function Sy(t,o){var r=o.ownerDocument.createElement("input");return r.name=o.name,r.value=o.value,t.id&&r.setAttribute("form",t.id),o.parentNode.insertBefore(r,o),t=new FormData(t),r.parentNode.removeChild(r),t}function ww(t,o,r,u,h){if(o==="submit"&&r&&r.stateNode===h){var y=wy((h[Nt]||null).action),j=u.submitter;j&&(o=(o=j[Nt]||null)?wy(o.formAction):j.getAttribute("formAction"),o!==null&&(y=o,j=null));var R=new Ji("action","action",null,u,h);t.push({event:R,listeners:[{instance:null,listener:function(){if(u.defaultPrevented){if(Io!==0){var Y=j?Sy(h,j):new FormData(h);Nd(r,{pending:!0,data:Y,method:h.method,action:y},null,Y)}}else typeof y=="function"&&(R.preventDefault(),Y=j?Sy(h,j):new FormData(h),Nd(r,{pending:!0,data:Y,method:h.method,action:y},y,Y))},currentTarget:h}]})}}for(var up=0;up<Ku.length;up++){var dp=Ku[up],Sw=dp.toLowerCase(),Cw=dp[0].toUpperCase()+dp.slice(1);yn(Sw,"on"+Cw)}yn(eh,"onAnimationEnd"),yn(th,"onAnimationIteration"),yn(nh,"onAnimationStart"),yn("dblclick","onDoubleClick"),yn("focusin","onFocus"),yn("focusout","onBlur"),yn(Bk,"onTransitionRun"),yn(Pk,"onTransitionStart"),yn(Hk,"onTransitionCancel"),yn(oh,"onTransitionEnd"),ko("onMouseEnter",["mouseout","mouseover"]),ko("onMouseLeave",["mouseout","mouseover"]),ko("onPointerEnter",["pointerout","pointerover"]),ko("onPointerLeave",["pointerout","pointerover"]),Un("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Un("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Un("onBeforeInput",["compositionend","keypress","textInput","paste"]),Un("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Un("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Un("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var _r="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Mw=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(_r));function Cy(t,o){o=(o&4)!==0;for(var r=0;r<t.length;r++){var u=t[r],h=u.event;u=u.listeners;e:{var y=void 0;if(o)for(var j=u.length-1;0<=j;j--){var R=u[j],Y=R.instance,oe=R.currentTarget;if(R=R.listener,Y!==y&&h.isPropagationStopped())break e;y=R,h.currentTarget=oe;try{y(h)}catch(le){nl(le)}h.currentTarget=null,y=Y}else for(j=0;j<u.length;j++){if(R=u[j],Y=R.instance,oe=R.currentTarget,R=R.listener,Y!==y&&h.isPropagationStopped())break e;y=R,h.currentTarget=oe;try{y(h)}catch(le){nl(le)}h.currentTarget=null,y=Y}}}}function De(t,o){var r=o[Ka];r===void 0&&(r=o[Ka]=new Set);var u=t+"__bubble";r.has(u)||(My(o,t,2,!1),r.add(u))}function pp(t,o,r){var u=0;o&&(u|=4),My(r,t,u,o)}var Hl="_reactListening"+Math.random().toString(36).slice(2);function fp(t){if(!t[Hl]){t[Hl]=!0,Ui.forEach(function(r){r!=="selectionchange"&&(Mw.has(r)||pp(r,!1,t),pp(r,!0,t))});var o=t.nodeType===9?t:t.ownerDocument;o===null||o[Hl]||(o[Hl]=!0,pp("selectionchange",!1,o))}}function My(t,o,r,u){switch(e0(o)){case 2:var h=Jw;break;case 8:h=eS;break;default:h=Tp}r=h.bind(null,o,r,t),h=void 0,!zu||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(h=!0),u?h!==void 0?t.addEventListener(o,r,{capture:!0,passive:h}):t.addEventListener(o,r,!0):h!==void 0?t.addEventListener(o,r,{passive:h}):t.addEventListener(o,r,!1)}function mp(t,o,r,u,h){var y=u;if((o&1)===0&&(o&2)===0&&u!==null)e:for(;;){if(u===null)return;var j=u.tag;if(j===3||j===4){var R=u.stateNode.containerInfo;if(R===h)break;if(j===4)for(j=u.return;j!==null;){var Y=j.tag;if((Y===3||Y===4)&&j.stateNode.containerInfo===h)return;j=j.return}for(;R!==null;){if(j=yo(R),j===null)return;if(Y=j.tag,Y===5||Y===6||Y===26||Y===27){u=y=j;continue e}R=R.parentNode}}u=u.return}Am(function(){var oe=y,le=_u(r),de=[];e:{var ae=ah.get(t);if(ae!==void 0){var re=Ji,xe=t;switch(t){case"keypress":if(Zi(r)===0)break e;case"keydown":case"keyup":re=xk;break;case"focusin":xe="focus",re=Fu;break;case"focusout":xe="blur",re=Fu;break;case"beforeblur":case"afterblur":re=Fu;break;case"click":if(r.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":re=zm;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":re=rk;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":re=kk;break;case eh:case th:case nh:re=ck;break;case oh:re=Sk;break;case"scroll":case"scrollend":re=ak;break;case"wheel":re=Mk;break;case"copy":case"cut":case"paste":re=dk;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":re=$m;break;case"toggle":case"beforetoggle":re=jk}var Me=(o&4)!==0,Ke=!Me&&(t==="scroll"||t==="scrollend"),ee=Me?ae!==null?ae+"Capture":null:ae;Me=[];for(var Z=oe,ne;Z!==null;){var ue=Z;if(ne=ue.stateNode,ue=ue.tag,ue!==5&&ue!==26&&ue!==27||ne===null||ee===null||(ue=Js(Z,ee),ue!=null&&Me.push(Dr(Z,ue,ne))),Ke)break;Z=Z.return}0<Me.length&&(ae=new re(ae,xe,null,r,le),de.push({event:ae,listeners:Me}))}}if((o&7)===0){e:{if(ae=t==="mouseover"||t==="pointerover",re=t==="mouseout"||t==="pointerout",ae&&r!==Au&&(xe=r.relatedTarget||r.fromElement)&&(yo(xe)||xe[Hn]))break e;if((re||ae)&&(ae=le.window===le?le:(ae=le.ownerDocument)?ae.defaultView||ae.parentWindow:window,re?(xe=r.relatedTarget||r.toElement,re=oe,xe=xe?yo(xe):null,xe!==null&&(Ke=l(xe),Me=xe.tag,xe!==Ke||Me!==5&&Me!==27&&Me!==6)&&(xe=null)):(re=null,xe=oe),re!==xe)){if(Me=zm,ue="onMouseLeave",ee="onMouseEnter",Z="mouse",(t==="pointerout"||t==="pointerover")&&(Me=$m,ue="onPointerLeave",ee="onPointerEnter",Z="pointer"),Ke=re==null?ae:bo(re),ne=xe==null?ae:bo(xe),ae=new Me(ue,Z+"leave",re,r,le),ae.target=Ke,ae.relatedTarget=ne,ue=null,yo(le)===oe&&(Me=new Me(ee,Z+"enter",xe,r,le),Me.target=ne,Me.relatedTarget=Ke,ue=Me),Ke=ue,re&&xe)t:{for(Me=Ew,ee=re,Z=xe,ne=0,ue=ee;ue;ue=Me(ue))ne++;ue=0;for(var Ce=Z;Ce;Ce=Me(Ce))ue++;for(;0<ne-ue;)ee=Me(ee),ne--;for(;0<ue-ne;)Z=Me(Z),ue--;for(;ne--;){if(ee===Z||Z!==null&&ee===Z.alternate){Me=ee;break t}ee=Me(ee),Z=Me(Z)}Me=null}else Me=null;re!==null&&Ey(de,ae,re,Me,!1),xe!==null&&Ke!==null&&Ey(de,Ke,xe,Me,!0)}}e:{if(ae=oe?bo(oe):window,re=ae.nodeName&&ae.nodeName.toLowerCase(),re==="select"||re==="input"&&ae.type==="file")var Le=Um;else if(Pm(ae))if(Gm)Le=Fk;else{Le=$k;var ve=Rk}else re=ae.nodeName,!re||re.toLowerCase()!=="input"||ae.type!=="checkbox"&&ae.type!=="radio"?oe&&Nu(oe.elementType)&&(Le=Um):Le=Ok;if(Le&&(Le=Le(t,oe))){Hm(de,Le,r,le);break e}ve&&ve(t,ae,oe),t==="focusout"&&oe&&ae.type==="number"&&oe.memoizedProps.value!=null&&Qs(ae,"number",ae.value)}switch(ve=oe?bo(oe):window,t){case"focusin":(Pm(ve)||ve.contentEditable==="true")&&(es=ve,Uu=oe,ir=null);break;case"focusout":ir=Uu=es=null;break;case"mousedown":Gu=!0;break;case"contextmenu":case"mouseup":case"dragend":Gu=!1,Qm(de,r,le);break;case"selectionchange":if(Lk)break;case"keydown":case"keyup":Qm(de,r,le)}var Ae;if(Lu)e:{switch(t){case"compositionstart":var $e="onCompositionStart";break e;case"compositionend":$e="onCompositionEnd";break e;case"compositionupdate":$e="onCompositionUpdate";break e}$e=void 0}else Ja?Lm(t,r)&&($e="onCompositionEnd"):t==="keydown"&&r.keyCode===229&&($e="onCompositionStart");$e&&(Om&&r.locale!=="ko"&&(Ja||$e!=="onCompositionStart"?$e==="onCompositionEnd"&&Ja&&(Ae=_m()):(wo=le,Ru="value"in wo?wo.value:wo.textContent,Ja=!0)),ve=Ul(oe,$e),0<ve.length&&($e=new Rm($e,t,null,r,le),de.push({event:$e,listeners:ve}),Ae?$e.data=Ae:(Ae=Bm(r),Ae!==null&&($e.data=Ae)))),(Ae=Nk?Ak(t,r):_k(t,r))&&($e=Ul(oe,"onBeforeInput"),0<$e.length&&(ve=new Rm("onBeforeInput","beforeinput",null,r,le),de.push({event:ve,listeners:$e}),ve.data=Ae)),ww(de,t,oe,r,le)}Cy(de,o)})}function Dr(t,o,r){return{instance:t,listener:o,currentTarget:r}}function Ul(t,o){for(var r=o+"Capture",u=[];t!==null;){var h=t,y=h.stateNode;if(h=h.tag,h!==5&&h!==26&&h!==27||y===null||(h=Js(t,r),h!=null&&u.unshift(Dr(t,h,y)),h=Js(t,o),h!=null&&u.push(Dr(t,h,y))),t.tag===3)return u;t=t.return}return[]}function Ew(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function Ey(t,o,r,u,h){for(var y=o._reactName,j=[];r!==null&&r!==u;){var R=r,Y=R.alternate,oe=R.stateNode;if(R=R.tag,Y!==null&&Y===u)break;R!==5&&R!==26&&R!==27||oe===null||(Y=oe,h?(oe=Js(r,y),oe!=null&&j.unshift(Dr(r,oe,Y))):h||(oe=Js(r,y),oe!=null&&j.push(Dr(r,oe,Y)))),r=r.return}j.length!==0&&t.push({event:o,listeners:j})}var jw=/\r\n?/g,Tw=/\u0000|\uFFFD/g;function jy(t){return(typeof t=="string"?t:""+t).replace(jw,`
9
+ `).replace(Tw,"")}function Ty(t,o){return o=jy(o),jy(t)===o}function qe(t,o,r,u,h,y){switch(r){case"children":typeof u=="string"?o==="body"||o==="textarea"&&u===""||Xa(t,u):(typeof u=="number"||typeof u=="bigint")&&o!=="body"&&Xa(t,""+u);break;case"className":Va(t,"class",u);break;case"tabIndex":Va(t,"tabindex",u);break;case"dir":case"role":case"viewBox":case"width":case"height":Va(t,r,u);break;case"style":Tm(t,u,y);break;case"data":if(o!=="object"){Va(t,"data",u);break}case"src":case"href":if(u===""&&(o!=="a"||r!=="href")){t.removeAttribute(r);break}if(u==null||typeof u=="function"||typeof u=="symbol"||typeof u=="boolean"){t.removeAttribute(r);break}u=Wi(""+u),t.setAttribute(r,u);break;case"action":case"formAction":if(typeof u=="function"){t.setAttribute(r,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof y=="function"&&(r==="formAction"?(o!=="input"&&qe(t,o,"name",h.name,h,null),qe(t,o,"formEncType",h.formEncType,h,null),qe(t,o,"formMethod",h.formMethod,h,null),qe(t,o,"formTarget",h.formTarget,h,null)):(qe(t,o,"encType",h.encType,h,null),qe(t,o,"method",h.method,h,null),qe(t,o,"target",h.target,h,null)));if(u==null||typeof u=="symbol"||typeof u=="boolean"){t.removeAttribute(r);break}u=Wi(""+u),t.setAttribute(r,u);break;case"onClick":u!=null&&(t.onclick=qn);break;case"onScroll":u!=null&&De("scroll",t);break;case"onScrollEnd":u!=null&&De("scrollend",t);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(s(61));if(r=u.__html,r!=null){if(h.children!=null)throw Error(s(60));t.innerHTML=r}}break;case"multiple":t.multiple=u&&typeof u!="function"&&typeof u!="symbol";break;case"muted":t.muted=u&&typeof u!="function"&&typeof u!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(u==null||typeof u=="function"||typeof u=="boolean"||typeof u=="symbol"){t.removeAttribute("xlink:href");break}r=Wi(""+u),t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":u!=null&&typeof u!="function"&&typeof u!="symbol"?t.setAttribute(r,""+u):t.removeAttribute(r);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":u&&typeof u!="function"&&typeof u!="symbol"?t.setAttribute(r,""):t.removeAttribute(r);break;case"capture":case"download":u===!0?t.setAttribute(r,""):u!==!1&&u!=null&&typeof u!="function"&&typeof u!="symbol"?t.setAttribute(r,u):t.removeAttribute(r);break;case"cols":case"rows":case"size":case"span":u!=null&&typeof u!="function"&&typeof u!="symbol"&&!isNaN(u)&&1<=u?t.setAttribute(r,u):t.removeAttribute(r);break;case"rowSpan":case"start":u==null||typeof u=="function"||typeof u=="symbol"||isNaN(u)?t.removeAttribute(r):t.setAttribute(r,u);break;case"popover":De("beforetoggle",t),De("toggle",t),Ya(t,"popover",u);break;case"xlinkActuate":gn(t,"http://www.w3.org/1999/xlink","xlink:actuate",u);break;case"xlinkArcrole":gn(t,"http://www.w3.org/1999/xlink","xlink:arcrole",u);break;case"xlinkRole":gn(t,"http://www.w3.org/1999/xlink","xlink:role",u);break;case"xlinkShow":gn(t,"http://www.w3.org/1999/xlink","xlink:show",u);break;case"xlinkTitle":gn(t,"http://www.w3.org/1999/xlink","xlink:title",u);break;case"xlinkType":gn(t,"http://www.w3.org/1999/xlink","xlink:type",u);break;case"xmlBase":gn(t,"http://www.w3.org/XML/1998/namespace","xml:base",u);break;case"xmlLang":gn(t,"http://www.w3.org/XML/1998/namespace","xml:lang",u);break;case"xmlSpace":gn(t,"http://www.w3.org/XML/1998/namespace","xml:space",u);break;case"is":Ya(t,"is",u);break;case"innerText":case"textContent":break;default:(!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(r=nk.get(r)||r,Ya(t,r,u))}}function hp(t,o,r,u,h,y){switch(r){case"style":Tm(t,u,y);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(s(61));if(r=u.__html,r!=null){if(h.children!=null)throw Error(s(60));t.innerHTML=r}}break;case"children":typeof u=="string"?Xa(t,u):(typeof u=="number"||typeof u=="bigint")&&Xa(t,""+u);break;case"onScroll":u!=null&&De("scroll",t);break;case"onScrollEnd":u!=null&&De("scrollend",t);break;case"onClick":u!=null&&(t.onclick=qn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Gi.hasOwnProperty(r))e:{if(r[0]==="o"&&r[1]==="n"&&(h=r.endsWith("Capture"),o=r.slice(2,h?r.length-7:void 0),y=t[Nt]||null,y=y!=null?y[r]:null,typeof y=="function"&&t.removeEventListener(o,y,h),typeof u=="function")){typeof y!="function"&&y!==null&&(r in t?t[r]=null:t.hasAttribute(r)&&t.removeAttribute(r)),t.addEventListener(o,u,h);break e}r in t?t[r]=u:u===!0?t.setAttribute(r,""):Ya(t,r,u)}}}function Mt(t,o,r){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":De("error",t),De("load",t);var u=!1,h=!1,y;for(y in r)if(r.hasOwnProperty(y)){var j=r[y];if(j!=null)switch(y){case"src":u=!0;break;case"srcSet":h=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,o));default:qe(t,o,y,j,r,null)}}h&&qe(t,o,"srcSet",r.srcSet,r,null),u&&qe(t,o,"src",r.src,r,null);return;case"input":De("invalid",t);var R=y=j=h=null,Y=null,oe=null;for(u in r)if(r.hasOwnProperty(u)){var le=r[u];if(le!=null)switch(u){case"name":h=le;break;case"type":j=le;break;case"checked":Y=le;break;case"defaultChecked":oe=le;break;case"value":y=le;break;case"defaultValue":R=le;break;case"children":case"dangerouslySetInnerHTML":if(le!=null)throw Error(s(137,o));break;default:qe(t,o,u,le,r,null)}}Vi(t,y,R,Y,oe,j,h,!1);return;case"select":De("invalid",t),u=j=y=null;for(h in r)if(r.hasOwnProperty(h)&&(R=r[h],R!=null))switch(h){case"value":y=R;break;case"defaultValue":j=R;break;case"multiple":u=R;default:qe(t,o,h,R,r,null)}o=y,r=j,t.multiple=!!u,o!=null?Gn(t,!!u,o,!1):r!=null&&Gn(t,!!u,r,!0);return;case"textarea":De("invalid",t),y=h=u=null;for(j in r)if(r.hasOwnProperty(j)&&(R=r[j],R!=null))switch(j){case"value":u=R;break;case"defaultValue":h=R;break;case"children":y=R;break;case"dangerouslySetInnerHTML":if(R!=null)throw Error(s(91));break;default:qe(t,o,j,R,r,null)}Em(t,u,h,y);return;case"option":for(Y in r)r.hasOwnProperty(Y)&&(u=r[Y],u!=null)&&(Y==="selected"?t.selected=u&&typeof u!="function"&&typeof u!="symbol":qe(t,o,Y,u,r,null));return;case"dialog":De("beforetoggle",t),De("toggle",t),De("cancel",t),De("close",t);break;case"iframe":case"object":De("load",t);break;case"video":case"audio":for(u=0;u<_r.length;u++)De(_r[u],t);break;case"image":De("error",t),De("load",t);break;case"details":De("toggle",t);break;case"embed":case"source":case"link":De("error",t),De("load",t);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(oe in r)if(r.hasOwnProperty(oe)&&(u=r[oe],u!=null))switch(oe){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,o));default:qe(t,o,oe,u,r,null)}return;default:if(Nu(o)){for(le in r)r.hasOwnProperty(le)&&(u=r[le],u!==void 0&&hp(t,o,le,u,r,void 0));return}}for(R in r)r.hasOwnProperty(R)&&(u=r[R],u!=null&&qe(t,o,R,u,r,null))}function Nw(t,o,r,u){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var h=null,y=null,j=null,R=null,Y=null,oe=null,le=null;for(re in r){var de=r[re];if(r.hasOwnProperty(re)&&de!=null)switch(re){case"checked":break;case"value":break;case"defaultValue":Y=de;default:u.hasOwnProperty(re)||qe(t,o,re,null,u,de)}}for(var ae in u){var re=u[ae];if(de=r[ae],u.hasOwnProperty(ae)&&(re!=null||de!=null))switch(ae){case"type":y=re;break;case"name":h=re;break;case"checked":oe=re;break;case"defaultChecked":le=re;break;case"value":j=re;break;case"defaultValue":R=re;break;case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(s(137,o));break;default:re!==de&&qe(t,o,ae,re,u,de)}}la(t,j,R,Y,oe,le,y,h);return;case"select":re=j=R=ae=null;for(y in r)if(Y=r[y],r.hasOwnProperty(y)&&Y!=null)switch(y){case"value":break;case"multiple":re=Y;default:u.hasOwnProperty(y)||qe(t,o,y,null,u,Y)}for(h in u)if(y=u[h],Y=r[h],u.hasOwnProperty(h)&&(y!=null||Y!=null))switch(h){case"value":ae=y;break;case"defaultValue":R=y;break;case"multiple":j=y;default:y!==Y&&qe(t,o,h,y,u,Y)}o=R,r=j,u=re,ae!=null?Gn(t,!!r,ae,!1):!!u!=!!r&&(o!=null?Gn(t,!!r,o,!0):Gn(t,!!r,r?[]:"",!1));return;case"textarea":re=ae=null;for(R in r)if(h=r[R],r.hasOwnProperty(R)&&h!=null&&!u.hasOwnProperty(R))switch(R){case"value":break;case"children":break;default:qe(t,o,R,null,u,h)}for(j in u)if(h=u[j],y=r[j],u.hasOwnProperty(j)&&(h!=null||y!=null))switch(j){case"value":ae=h;break;case"defaultValue":re=h;break;case"children":break;case"dangerouslySetInnerHTML":if(h!=null)throw Error(s(91));break;default:h!==y&&qe(t,o,j,h,u,y)}Mm(t,ae,re);return;case"option":for(var xe in r)ae=r[xe],r.hasOwnProperty(xe)&&ae!=null&&!u.hasOwnProperty(xe)&&(xe==="selected"?t.selected=!1:qe(t,o,xe,null,u,ae));for(Y in u)ae=u[Y],re=r[Y],u.hasOwnProperty(Y)&&ae!==re&&(ae!=null||re!=null)&&(Y==="selected"?t.selected=ae&&typeof ae!="function"&&typeof ae!="symbol":qe(t,o,Y,ae,u,re));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Me in r)ae=r[Me],r.hasOwnProperty(Me)&&ae!=null&&!u.hasOwnProperty(Me)&&qe(t,o,Me,null,u,ae);for(oe in u)if(ae=u[oe],re=r[oe],u.hasOwnProperty(oe)&&ae!==re&&(ae!=null||re!=null))switch(oe){case"children":case"dangerouslySetInnerHTML":if(ae!=null)throw Error(s(137,o));break;default:qe(t,o,oe,ae,u,re)}return;default:if(Nu(o)){for(var Ke in r)ae=r[Ke],r.hasOwnProperty(Ke)&&ae!==void 0&&!u.hasOwnProperty(Ke)&&hp(t,o,Ke,void 0,u,ae);for(le in u)ae=u[le],re=r[le],!u.hasOwnProperty(le)||ae===re||ae===void 0&&re===void 0||hp(t,o,le,ae,u,re);return}}for(var ee in r)ae=r[ee],r.hasOwnProperty(ee)&&ae!=null&&!u.hasOwnProperty(ee)&&qe(t,o,ee,null,u,ae);for(de in u)ae=u[de],re=r[de],!u.hasOwnProperty(de)||ae===re||ae==null&&re==null||qe(t,o,de,ae,u,re)}function Ny(t){switch(t){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Aw(){if(typeof performance.getEntriesByType=="function"){for(var t=0,o=0,r=performance.getEntriesByType("resource"),u=0;u<r.length;u++){var h=r[u],y=h.transferSize,j=h.initiatorType,R=h.duration;if(y&&R&&Ny(j)){for(j=0,R=h.responseEnd,u+=1;u<r.length;u++){var Y=r[u],oe=Y.startTime;if(oe>R)break;var le=Y.transferSize,de=Y.initiatorType;le&&Ny(de)&&(Y=Y.responseEnd,j+=le*(Y<R?1:(R-oe)/(Y-oe)))}if(--u,o+=8*(y+j)/(h.duration/1e3),t++,10<t)break}}if(0<t)return o/t/1e6}return navigator.connection&&(t=navigator.connection.downlink,typeof t=="number")?t:5}var gp=null,yp=null;function Gl(t){return t.nodeType===9?t:t.ownerDocument}function Ay(t){switch(t){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function _y(t,o){if(t===0)switch(o){case"svg":return 1;case"math":return 2;default:return 0}return t===1&&o==="foreignObject"?0:t}function xp(t,o){return t==="textarea"||t==="noscript"||typeof o.children=="string"||typeof o.children=="number"||typeof o.children=="bigint"||typeof o.dangerouslySetInnerHTML=="object"&&o.dangerouslySetInnerHTML!==null&&o.dangerouslySetInnerHTML.__html!=null}var bp=null;function _w(){var t=window.event;return t&&t.type==="popstate"?t===bp?!1:(bp=t,!0):(bp=null,!1)}var Dy=typeof setTimeout=="function"?setTimeout:void 0,Dw=typeof clearTimeout=="function"?clearTimeout:void 0,zy=typeof Promise=="function"?Promise:void 0,zw=typeof queueMicrotask=="function"?queueMicrotask:typeof zy<"u"?function(t){return zy.resolve(null).then(t).catch(Rw)}:Dy;function Rw(t){setTimeout(function(){throw t})}function Lo(t){return t==="head"}function Ry(t,o){var r=o,u=0;do{var h=r.nextSibling;if(t.removeChild(r),h&&h.nodeType===8)if(r=h.data,r==="/$"||r==="/&"){if(u===0){t.removeChild(h),js(o);return}u--}else if(r==="$"||r==="$?"||r==="$~"||r==="$!"||r==="&")u++;else if(r==="html")zr(t.ownerDocument.documentElement);else if(r==="head"){r=t.ownerDocument.head,zr(r);for(var y=r.firstChild;y;){var j=y.nextSibling,R=y.nodeName;y[ra]||R==="SCRIPT"||R==="STYLE"||R==="LINK"&&y.rel.toLowerCase()==="stylesheet"||r.removeChild(y),y=j}}else r==="body"&&zr(t.ownerDocument.body);r=h}while(r);js(o)}function $y(t,o){var r=t;t=0;do{var u=r.nextSibling;if(r.nodeType===1?o?(r._stashedDisplay=r.style.display,r.style.display="none"):(r.style.display=r._stashedDisplay||"",r.getAttribute("style")===""&&r.removeAttribute("style")):r.nodeType===3&&(o?(r._stashedText=r.nodeValue,r.nodeValue=""):r.nodeValue=r._stashedText||""),u&&u.nodeType===8)if(r=u.data,r==="/$"){if(t===0)break;t--}else r!=="$"&&r!=="$?"&&r!=="$~"&&r!=="$!"||t++;r=u}while(r)}function vp(t){var o=t.firstChild;for(o&&o.nodeType===10&&(o=o.nextSibling);o;){var r=o;switch(o=o.nextSibling,r.nodeName){case"HTML":case"HEAD":case"BODY":vp(r),Xs(r);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(r.rel.toLowerCase()==="stylesheet")continue}t.removeChild(r)}}function $w(t,o,r,u){for(;t.nodeType===1;){var h=r;if(t.nodeName.toLowerCase()!==o.toLowerCase()){if(!u&&(t.nodeName!=="INPUT"||t.type!=="hidden"))break}else if(u){if(!t[ra])switch(o){case"meta":if(!t.hasAttribute("itemprop"))break;return t;case"link":if(y=t.getAttribute("rel"),y==="stylesheet"&&t.hasAttribute("data-precedence"))break;if(y!==h.rel||t.getAttribute("href")!==(h.href==null||h.href===""?null:h.href)||t.getAttribute("crossorigin")!==(h.crossOrigin==null?null:h.crossOrigin)||t.getAttribute("title")!==(h.title==null?null:h.title))break;return t;case"style":if(t.hasAttribute("data-precedence"))break;return t;case"script":if(y=t.getAttribute("src"),(y!==(h.src==null?null:h.src)||t.getAttribute("type")!==(h.type==null?null:h.type)||t.getAttribute("crossorigin")!==(h.crossOrigin==null?null:h.crossOrigin))&&y&&t.hasAttribute("async")&&!t.hasAttribute("itemprop"))break;return t;default:return t}}else if(o==="input"&&t.type==="hidden"){var y=h.name==null?null:""+h.name;if(h.type==="hidden"&&t.getAttribute("name")===y)return t}else return t;if(t=cn(t.nextSibling),t===null)break}return null}function Ow(t,o,r){if(o==="")return null;for(;t.nodeType!==3;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!r||(t=cn(t.nextSibling),t===null))return null;return t}function Oy(t,o){for(;t.nodeType!==8;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!o||(t=cn(t.nextSibling),t===null))return null;return t}function kp(t){return t.data==="$?"||t.data==="$~"}function wp(t){return t.data==="$!"||t.data==="$?"&&t.ownerDocument.readyState!=="loading"}function Fw(t,o){var r=t.ownerDocument;if(t.data==="$~")t._reactRetry=o;else if(t.data!=="$?"||r.readyState!=="loading")o();else{var u=function(){o(),r.removeEventListener("DOMContentLoaded",u)};r.addEventListener("DOMContentLoaded",u),t._reactRetry=u}}function cn(t){for(;t!=null;t=t.nextSibling){var o=t.nodeType;if(o===1||o===3)break;if(o===8){if(o=t.data,o==="$"||o==="$!"||o==="$?"||o==="$~"||o==="&"||o==="F!"||o==="F")break;if(o==="/$"||o==="/&")return null}}return t}var Sp=null;function Fy(t){t=t.nextSibling;for(var o=0;t;){if(t.nodeType===8){var r=t.data;if(r==="/$"||r==="/&"){if(o===0)return cn(t.nextSibling);o--}else r!=="$"&&r!=="$!"&&r!=="$?"&&r!=="$~"&&r!=="&"||o++}t=t.nextSibling}return null}function Iy(t){t=t.previousSibling;for(var o=0;t;){if(t.nodeType===8){var r=t.data;if(r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"){if(o===0)return t;o--}else r!=="/$"&&r!=="/&"||o++}t=t.previousSibling}return null}function Ly(t,o,r){switch(o=Gl(r),t){case"html":if(t=o.documentElement,!t)throw Error(s(452));return t;case"head":if(t=o.head,!t)throw Error(s(453));return t;case"body":if(t=o.body,!t)throw Error(s(454));return t;default:throw Error(s(451))}}function zr(t){for(var o=t.attributes;o.length;)t.removeAttributeNode(o[0]);Xs(t)}var un=new Map,By=new Set;function ql(t){return typeof t.getRootNode=="function"?t.getRootNode():t.nodeType===9?t:t.ownerDocument}var io=B.d;B.d={f:Iw,r:Lw,D:Bw,C:Pw,L:Hw,m:Uw,X:qw,S:Gw,M:Kw};function Iw(){var t=io.f(),o=Ol();return t||o}function Lw(t){var o=xo(t);o!==null&&o.tag===5&&o.type==="form"?og(o):io.r(t)}var Cs=typeof document>"u"?null:document;function Py(t,o,r){var u=Cs;if(u&&typeof o=="string"&&o){var h=Ot(o);h='link[rel="'+t+'"][href="'+h+'"]',typeof r=="string"&&(h+='[crossorigin="'+r+'"]'),By.has(h)||(By.add(h),t={rel:t,crossOrigin:r,href:o},u.querySelector(h)===null&&(o=u.createElement("link"),Mt(o,"link",t),it(o),u.head.appendChild(o)))}}function Bw(t){io.D(t),Py("dns-prefetch",t,null)}function Pw(t,o){io.C(t,o),Py("preconnect",t,o)}function Hw(t,o,r){io.L(t,o,r);var u=Cs;if(u&&t&&o){var h='link[rel="preload"][as="'+Ot(o)+'"]';o==="image"&&r&&r.imageSrcSet?(h+='[imagesrcset="'+Ot(r.imageSrcSet)+'"]',typeof r.imageSizes=="string"&&(h+='[imagesizes="'+Ot(r.imageSizes)+'"]')):h+='[href="'+Ot(t)+'"]';var y=h;switch(o){case"style":y=Ms(t);break;case"script":y=Es(t)}un.has(y)||(t=x({rel:"preload",href:o==="image"&&r&&r.imageSrcSet?void 0:t,as:o},r),un.set(y,t),u.querySelector(h)!==null||o==="style"&&u.querySelector(Rr(y))||o==="script"&&u.querySelector($r(y))||(o=u.createElement("link"),Mt(o,"link",t),it(o),u.head.appendChild(o)))}}function Uw(t,o){io.m(t,o);var r=Cs;if(r&&t){var u=o&&typeof o.as=="string"?o.as:"script",h='link[rel="modulepreload"][as="'+Ot(u)+'"][href="'+Ot(t)+'"]',y=h;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=Es(t)}if(!un.has(y)&&(t=x({rel:"modulepreload",href:t},o),un.set(y,t),r.querySelector(h)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(r.querySelector($r(y)))return}u=r.createElement("link"),Mt(u,"link",t),it(u),r.head.appendChild(u)}}}function Gw(t,o,r){io.S(t,o,r);var u=Cs;if(u&&t){var h=vo(u).hoistableStyles,y=Ms(t);o=o||"default";var j=h.get(y);if(!j){var R={loading:0,preload:null};if(j=u.querySelector(Rr(y)))R.loading=5;else{t=x({rel:"stylesheet",href:t,"data-precedence":o},r),(r=un.get(y))&&Cp(t,r);var Y=j=u.createElement("link");it(Y),Mt(Y,"link",t),Y._p=new Promise(function(oe,le){Y.onload=oe,Y.onerror=le}),Y.addEventListener("load",function(){R.loading|=1}),Y.addEventListener("error",function(){R.loading|=2}),R.loading|=4,Kl(j,o,u)}j={type:"stylesheet",instance:j,count:1,state:R},h.set(y,j)}}}function qw(t,o){io.X(t,o);var r=Cs;if(r&&t){var u=vo(r).hoistableScripts,h=Es(t),y=u.get(h);y||(y=r.querySelector($r(h)),y||(t=x({src:t,async:!0},o),(o=un.get(h))&&Mp(t,o),y=r.createElement("script"),it(y),Mt(y,"link",t),r.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},u.set(h,y))}}function Kw(t,o){io.M(t,o);var r=Cs;if(r&&t){var u=vo(r).hoistableScripts,h=Es(t),y=u.get(h);y||(y=r.querySelector($r(h)),y||(t=x({src:t,async:!0,type:"module"},o),(o=un.get(h))&&Mp(t,o),y=r.createElement("script"),it(y),Mt(y,"link",t),r.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},u.set(h,y))}}function Hy(t,o,r,u){var h=(h=pe.current)?ql(h):null;if(!h)throw Error(s(446));switch(t){case"meta":case"title":return null;case"style":return typeof r.precedence=="string"&&typeof r.href=="string"?(o=Ms(r.href),r=vo(h).hoistableStyles,u=r.get(o),u||(u={type:"style",instance:null,count:0,state:null},r.set(o,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(r.rel==="stylesheet"&&typeof r.href=="string"&&typeof r.precedence=="string"){t=Ms(r.href);var y=vo(h).hoistableStyles,j=y.get(t);if(j||(h=h.ownerDocument||h,j={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(t,j),(y=h.querySelector(Rr(t)))&&!y._p&&(j.instance=y,j.state.loading=5),un.has(t)||(r={rel:"preload",as:"style",href:r.href,crossOrigin:r.crossOrigin,integrity:r.integrity,media:r.media,hrefLang:r.hrefLang,referrerPolicy:r.referrerPolicy},un.set(t,r),y||Yw(h,t,r,j.state))),o&&u===null)throw Error(s(528,""));return j}if(o&&u!==null)throw Error(s(529,""));return null;case"script":return o=r.async,r=r.src,typeof r=="string"&&o&&typeof o!="function"&&typeof o!="symbol"?(o=Es(r),r=vo(h).hoistableScripts,u=r.get(o),u||(u={type:"script",instance:null,count:0,state:null},r.set(o,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,t))}}function Ms(t){return'href="'+Ot(t)+'"'}function Rr(t){return'link[rel="stylesheet"]['+t+"]"}function Uy(t){return x({},t,{"data-precedence":t.precedence,precedence:null})}function Yw(t,o,r,u){t.querySelector('link[rel="preload"][as="style"]['+o+"]")?u.loading=1:(o=t.createElement("link"),u.preload=o,o.addEventListener("load",function(){return u.loading|=1}),o.addEventListener("error",function(){return u.loading|=2}),Mt(o,"link",r),it(o),t.head.appendChild(o))}function Es(t){return'[src="'+Ot(t)+'"]'}function $r(t){return"script[async]"+t}function Gy(t,o,r){if(o.count++,o.instance===null)switch(o.type){case"style":var u=t.querySelector('style[data-href~="'+Ot(r.href)+'"]');if(u)return o.instance=u,it(u),u;var h=x({},r,{"data-href":r.href,"data-precedence":r.precedence,href:null,precedence:null});return u=(t.ownerDocument||t).createElement("style"),it(u),Mt(u,"style",h),Kl(u,r.precedence,t),o.instance=u;case"stylesheet":h=Ms(r.href);var y=t.querySelector(Rr(h));if(y)return o.state.loading|=4,o.instance=y,it(y),y;u=Uy(r),(h=un.get(h))&&Cp(u,h),y=(t.ownerDocument||t).createElement("link"),it(y);var j=y;return j._p=new Promise(function(R,Y){j.onload=R,j.onerror=Y}),Mt(y,"link",u),o.state.loading|=4,Kl(y,r.precedence,t),o.instance=y;case"script":return y=Es(r.src),(h=t.querySelector($r(y)))?(o.instance=h,it(h),h):(u=r,(h=un.get(y))&&(u=x({},r),Mp(u,h)),t=t.ownerDocument||t,h=t.createElement("script"),it(h),Mt(h,"link",u),t.head.appendChild(h),o.instance=h);case"void":return null;default:throw Error(s(443,o.type))}else o.type==="stylesheet"&&(o.state.loading&4)===0&&(u=o.instance,o.state.loading|=4,Kl(u,r.precedence,t));return o.instance}function Kl(t,o,r){for(var u=r.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),h=u.length?u[u.length-1]:null,y=h,j=0;j<u.length;j++){var R=u[j];if(R.dataset.precedence===o)y=R;else if(y!==h)break}y?y.parentNode.insertBefore(t,y.nextSibling):(o=r.nodeType===9?r.head:r,o.insertBefore(t,o.firstChild))}function Cp(t,o){t.crossOrigin==null&&(t.crossOrigin=o.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=o.referrerPolicy),t.title==null&&(t.title=o.title)}function Mp(t,o){t.crossOrigin==null&&(t.crossOrigin=o.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=o.referrerPolicy),t.integrity==null&&(t.integrity=o.integrity)}var Yl=null;function qy(t,o,r){if(Yl===null){var u=new Map,h=Yl=new Map;h.set(r,u)}else h=Yl,u=h.get(r),u||(u=new Map,h.set(r,u));if(u.has(t))return u;for(u.set(t,null),r=r.getElementsByTagName(t),h=0;h<r.length;h++){var y=r[h];if(!(y[ra]||y[mt]||t==="link"&&y.getAttribute("rel")==="stylesheet")&&y.namespaceURI!=="http://www.w3.org/2000/svg"){var j=y.getAttribute(o)||"";j=t+j;var R=u.get(j);R?R.push(y):u.set(j,[y])}}return u}function Ky(t,o,r){t=t.ownerDocument||t,t.head.insertBefore(r,o==="title"?t.querySelector("head > title"):null)}function Vw(t,o,r){if(r===1||o.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof o.precedence!="string"||typeof o.href!="string"||o.href==="")break;return!0;case"link":if(typeof o.rel!="string"||typeof o.href!="string"||o.href===""||o.onLoad||o.onError)break;return o.rel==="stylesheet"?(t=o.disabled,typeof o.precedence=="string"&&t==null):!0;case"script":if(o.async&&typeof o.async!="function"&&typeof o.async!="symbol"&&!o.onLoad&&!o.onError&&o.src&&typeof o.src=="string")return!0}return!1}function Yy(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function Ww(t,o,r,u){if(r.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(r.state.loading&4)===0){if(r.instance===null){var h=Ms(u.href),y=o.querySelector(Rr(h));if(y){o=y._p,o!==null&&typeof o=="object"&&typeof o.then=="function"&&(t.count++,t=Vl.bind(t),o.then(t,t)),r.state.loading|=4,r.instance=y,it(y);return}y=o.ownerDocument||o,u=Uy(u),(h=un.get(h))&&Cp(u,h),y=y.createElement("link"),it(y);var j=y;j._p=new Promise(function(R,Y){j.onload=R,j.onerror=Y}),Mt(y,"link",u),r.instance=y}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(r,o),(o=r.state.preload)&&(r.state.loading&3)===0&&(t.count++,r=Vl.bind(t),o.addEventListener("load",r),o.addEventListener("error",r))}}var Ep=0;function Xw(t,o){return t.stylesheets&&t.count===0&&Xl(t,t.stylesheets),0<t.count||0<t.imgCount?function(r){var u=setTimeout(function(){if(t.stylesheets&&Xl(t,t.stylesheets),t.unsuspend){var y=t.unsuspend;t.unsuspend=null,y()}},6e4+o);0<t.imgBytes&&Ep===0&&(Ep=62500*Aw());var h=setTimeout(function(){if(t.waitingForImages=!1,t.count===0&&(t.stylesheets&&Xl(t,t.stylesheets),t.unsuspend)){var y=t.unsuspend;t.unsuspend=null,y()}},(t.imgBytes>Ep?50:800)+o);return t.unsuspend=r,function(){t.unsuspend=null,clearTimeout(u),clearTimeout(h)}}:null}function Vl(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xl(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var Wl=null;function Xl(t,o){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Wl=new Map,o.forEach(Zw,t),Wl=null,Vl.call(t))}function Zw(t,o){if(!(o.state.loading&4)){var r=Wl.get(t);if(r)var u=r.get(null);else{r=new Map,Wl.set(t,r);for(var h=t.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y<h.length;y++){var j=h[y];(j.nodeName==="LINK"||j.getAttribute("media")!=="not all")&&(r.set(j.dataset.precedence,j),u=j)}u&&r.set(null,u)}h=o.instance,j=h.getAttribute("data-precedence"),y=r.get(j)||u,y===u&&r.set(null,h),r.set(j,h),this.count++,u=Vl.bind(this),h.addEventListener("load",u),h.addEventListener("error",u),y?y.parentNode.insertBefore(h,y.nextSibling):(t=t.nodeType===9?t.head:t,t.insertBefore(h,t.firstChild)),o.state.loading|=4}}var Or={$$typeof:S,Provider:null,Consumer:null,_currentValue:G,_currentValue2:G,_threadCount:0};function Qw(t,o,r,u,h,y,j,R,Y){this.tag=1,this.containerInfo=t,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ys(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ys(0),this.hiddenUpdates=Ys(null),this.identifierPrefix=u,this.onUncaughtError=h,this.onCaughtError=y,this.onRecoverableError=j,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Y,this.incompleteTransitions=new Map}function Vy(t,o,r,u,h,y,j,R,Y,oe,le,de){return t=new Qw(t,o,r,j,Y,oe,le,de,R),o=1,y===!0&&(o|=24),y=Yt(3,null,null,o),t.current=y,y.stateNode=t,o=sd(),o.refCount++,t.pooledCache=o,o.refCount++,y.memoizedState={element:u,isDehydrated:r,cache:o},cd(y),t}function Wy(t){return t?(t=os,t):os}function Xy(t,o,r,u,h,y){h=Wy(h),u.context===null?u.context=h:u.pendingContext=h,u=To(o),u.payload={element:r},y=y===void 0?null:y,y!==null&&(u.callback=y),r=No(t,u,o),r!==null&&(Ht(r,t,o),mr(r,t,o))}function Zy(t,o){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var r=t.retryLane;t.retryLane=r!==0&&r<o?r:o}}function jp(t,o){Zy(t,o),(t=t.alternate)&&Zy(t,o)}function Qy(t){if(t.tag===13||t.tag===31){var o=pa(t,67108864);o!==null&&Ht(o,t,67108864),jp(t,67108864)}}function Jy(t){if(t.tag===13||t.tag===31){var o=Qt();o=Vs(o);var r=pa(t,o);r!==null&&Ht(r,t,o),jp(t,o)}}var Zl=!0;function Jw(t,o,r,u){var h=T.T;T.T=null;var y=B.p;try{B.p=2,Tp(t,o,r,u)}finally{B.p=y,T.T=h}}function eS(t,o,r,u){var h=T.T;T.T=null;var y=B.p;try{B.p=8,Tp(t,o,r,u)}finally{B.p=y,T.T=h}}function Tp(t,o,r,u){if(Zl){var h=Np(u);if(h===null)mp(t,o,u,Ql,r),t0(t,u);else if(nS(h,t,o,r,u))u.stopPropagation();else if(t0(t,u),o&4&&-1<tS.indexOf(t)){for(;h!==null;){var y=xo(h);if(y!==null)switch(y.tag){case 3:if(y=y.stateNode,y.current.memoizedState.isDehydrated){var j=Pn(y.pendingLanes);if(j!==0){var R=y;for(R.pendingLanes|=2,R.entangledLanes|=2;j;){var Y=1<<31-zt(j);R.entanglements[1]|=Y,j&=~Y}Dn(y),(Pe&6)===0&&(Rl=kt()+500,Ar(0))}}break;case 31:case 13:R=pa(y,2),R!==null&&Ht(R,y,2),Ol(),jp(y,2)}if(y=Np(u),y===null&&mp(t,o,u,Ql,r),y===h)break;h=y}h!==null&&u.stopPropagation()}else mp(t,o,u,null,r)}}function Np(t){return t=_u(t),Ap(t)}var Ql=null;function Ap(t){if(Ql=null,t=yo(t),t!==null){var o=l(t);if(o===null)t=null;else{var r=o.tag;if(r===13){if(t=c(o),t!==null)return t;t=null}else if(r===31){if(t=p(o),t!==null)return t;t=null}else if(r===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;t=null}else o!==t&&(t=null)}}return Ql=t,null}function e0(t){switch(t){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Ba()){case Bn:return 2;case go:return 8;case na:case gu:return 32;case Pa:return 268435456;default:return 32}default:return 32}}var _p=!1,Bo=null,Po=null,Ho=null,Fr=new Map,Ir=new Map,Uo=[],tS="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function t0(t,o){switch(t){case"focusin":case"focusout":Bo=null;break;case"dragenter":case"dragleave":Po=null;break;case"mouseover":case"mouseout":Ho=null;break;case"pointerover":case"pointerout":Fr.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ir.delete(o.pointerId)}}function Lr(t,o,r,u,h,y){return t===null||t.nativeEvent!==y?(t={blockedOn:o,domEventName:r,eventSystemFlags:u,nativeEvent:y,targetContainers:[h]},o!==null&&(o=xo(o),o!==null&&Qy(o)),t):(t.eventSystemFlags|=u,o=t.targetContainers,h!==null&&o.indexOf(h)===-1&&o.push(h),t)}function nS(t,o,r,u,h){switch(o){case"focusin":return Bo=Lr(Bo,t,o,r,u,h),!0;case"dragenter":return Po=Lr(Po,t,o,r,u,h),!0;case"mouseover":return Ho=Lr(Ho,t,o,r,u,h),!0;case"pointerover":var y=h.pointerId;return Fr.set(y,Lr(Fr.get(y)||null,t,o,r,u,h)),!0;case"gotpointercapture":return y=h.pointerId,Ir.set(y,Lr(Ir.get(y)||null,t,o,r,u,h)),!0}return!1}function n0(t){var o=yo(t.target);if(o!==null){var r=l(o);if(r!==null){if(o=r.tag,o===13){if(o=c(r),o!==null){t.blockedOn=o,Bi(t.priority,function(){Jy(r)});return}}else if(o===31){if(o=p(r),o!==null){t.blockedOn=o,Bi(t.priority,function(){Jy(r)});return}}else if(o===3&&r.stateNode.current.memoizedState.isDehydrated){t.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Jl(t){if(t.blockedOn!==null)return!1;for(var o=t.targetContainers;0<o.length;){var r=Np(t.nativeEvent);if(r===null){r=t.nativeEvent;var u=new r.constructor(r.type,r);Au=u,r.target.dispatchEvent(u),Au=null}else return o=xo(r),o!==null&&Qy(o),t.blockedOn=r,!1;o.shift()}return!0}function o0(t,o,r){Jl(t)&&r.delete(o)}function oS(){_p=!1,Bo!==null&&Jl(Bo)&&(Bo=null),Po!==null&&Jl(Po)&&(Po=null),Ho!==null&&Jl(Ho)&&(Ho=null),Fr.forEach(o0),Ir.forEach(o0)}function ec(t,o){t.blockedOn===o&&(t.blockedOn=null,_p||(_p=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,oS)))}var tc=null;function a0(t){tc!==t&&(tc=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){tc===t&&(tc=null);for(var o=0;o<t.length;o+=3){var r=t[o],u=t[o+1],h=t[o+2];if(typeof u!="function"){if(Ap(u||r)===null)continue;break}var y=xo(r);y!==null&&(t.splice(o,3),o-=3,Nd(y,{pending:!0,data:h,method:r.method,action:u},u,h))}}))}function js(t){function o(Y){return ec(Y,t)}Bo!==null&&ec(Bo,t),Po!==null&&ec(Po,t),Ho!==null&&ec(Ho,t),Fr.forEach(o),Ir.forEach(o);for(var r=0;r<Uo.length;r++){var u=Uo[r];u.blockedOn===t&&(u.blockedOn=null)}for(;0<Uo.length&&(r=Uo[0],r.blockedOn===null);)n0(r),r.blockedOn===null&&Uo.shift();if(r=(t.ownerDocument||t).$$reactFormReplay,r!=null)for(u=0;u<r.length;u+=3){var h=r[u],y=r[u+1],j=h[Nt]||null;if(typeof y=="function")j||a0(r);else if(j){var R=null;if(y&&y.hasAttribute("formAction")){if(h=y,j=y[Nt]||null)R=j.formAction;else if(Ap(h)!==null)continue}else R=j.action;typeof R=="function"?r[u+1]=R:(r.splice(u,3),u-=3),a0(r)}}}function s0(){function t(y){y.canIntercept&&y.info==="react-transition"&&y.intercept({handler:function(){return new Promise(function(j){return h=j})},focusReset:"manual",scroll:"manual"})}function o(){h!==null&&(h(),h=null),u||setTimeout(r,20)}function r(){if(!u&&!navigation.transition){var y=navigation.currentEntry;y&&y.url!=null&&navigation.navigate(y.url,{state:y.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var u=!1,h=null;return navigation.addEventListener("navigate",t),navigation.addEventListener("navigatesuccess",o),navigation.addEventListener("navigateerror",o),setTimeout(r,100),function(){u=!0,navigation.removeEventListener("navigate",t),navigation.removeEventListener("navigatesuccess",o),navigation.removeEventListener("navigateerror",o),h!==null&&(h(),h=null)}}}function Dp(t){this._internalRoot=t}nc.prototype.render=Dp.prototype.render=function(t){var o=this._internalRoot;if(o===null)throw Error(s(409));var r=o.current,u=Qt();Xy(r,u,t,o,null,null)},nc.prototype.unmount=Dp.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var o=t.containerInfo;Xy(t.current,2,null,t,null,null),Ol(),o[Hn]=null}};function nc(t){this._internalRoot=t}nc.prototype.unstable_scheduleHydration=function(t){if(t){var o=Li();t={blockedOn:null,target:t,priority:o};for(var r=0;r<Uo.length&&o!==0&&o<Uo[r].priority;r++);Uo.splice(r,0,t),r===0&&n0(t)}};var r0=n.version;if(r0!=="19.2.4")throw Error(s(527,r0,"19.2.4"));B.findDOMNode=function(t){var o=t._reactInternals;if(o===void 0)throw typeof t.render=="function"?Error(s(188)):(t=Object.keys(t).join(","),Error(s(268,t)));return t=m(o),t=t!==null?g(t):null,t=t===null?null:t.stateNode,t};var aS={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:T,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var oc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!oc.isDisabled&&oc.supportsFiber)try{oa=oc.inject(aS),Dt=oc}catch{}}return Pr.createRoot=function(t,o){if(!i(t))throw Error(s(299));var r=!1,u="",h=fg,y=mg,j=hg;return o!=null&&(o.unstable_strictMode===!0&&(r=!0),o.identifierPrefix!==void 0&&(u=o.identifierPrefix),o.onUncaughtError!==void 0&&(h=o.onUncaughtError),o.onCaughtError!==void 0&&(y=o.onCaughtError),o.onRecoverableError!==void 0&&(j=o.onRecoverableError)),o=Vy(t,1,!1,null,null,r,u,null,h,y,j,s0),t[Hn]=o.current,fp(t),new Dp(o)},Pr.hydrateRoot=function(t,o,r){if(!i(t))throw Error(s(299));var u=!1,h="",y=fg,j=mg,R=hg,Y=null;return r!=null&&(r.unstable_strictMode===!0&&(u=!0),r.identifierPrefix!==void 0&&(h=r.identifierPrefix),r.onUncaughtError!==void 0&&(y=r.onUncaughtError),r.onCaughtError!==void 0&&(j=r.onCaughtError),r.onRecoverableError!==void 0&&(R=r.onRecoverableError),r.formState!==void 0&&(Y=r.formState)),o=Vy(t,1,!0,o,r??null,u,h,Y,y,j,R,s0),o.context=Wy(null),r=o.current,u=Qt(),u=Vs(u),h=To(u),h.callback=null,No(r,h,u),r=u,o.current.lanes=r,sa(o,r),Dn(o),t[Hn]=o.current,fp(t),new nc(o)},Pr.version="19.2.4",Pr}var g0;function fS(){if(g0)return $p.exports;g0=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(n){console.error(n)}}return e(),$p.exports=pS(),$p.exports}var mS=fS();const hS="modulepreload",gS=function(e){return"/"+e},y0={},ea=function(n,a,s){let i=Promise.resolve();if(a&&a.length>0){let f=function(m){return Promise.all(m.map(g=>Promise.resolve(g).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),p=c?.nonce||c?.getAttribute("nonce");i=f(a.map(m=>{if(m=gS(m),m in y0)return;y0[m]=!0;const g=m.endsWith(".css"),x=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${x}`))return;const b=document.createElement("link");if(b.rel=g?"stylesheet":hS,g||(b.as="script"),b.crossOrigin="",b.href=m,p&&b.setAttribute("nonce",p),document.head.appendChild(b),g)return new Promise((v,k)=>{b.addEventListener("load",v),b.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${m}`)))})}))}function l(c){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=c,window.dispatchEvent(p),!p.defaultPrevented)throw c}return i.then(c=>{for(const p of c||[])p.status==="rejected"&&l(p.reason);return n().catch(l)})},x0=e=>{let n;const a=new Set,s=(m,g)=>{const x=typeof m=="function"?m(n):m;if(!Object.is(x,n)){const b=n;n=g??(typeof x!="object"||x===null)?x:Object.assign({},n,x),a.forEach(v=>v(n,b))}},i=()=>n,p={setState:s,getState:i,getInitialState:()=>f,subscribe:m=>(a.add(m),()=>a.delete(m))},f=n=e(s,i,p);return p},yS=(e=>e?x0(e):x0),xS=e=>e;function bS(e,n=xS){const a=Vr.useSyncExternalStore(e.subscribe,Vr.useCallback(()=>n(e.getState()),[e,n]),Vr.useCallback(()=>n(e.getInitialState()),[e,n]));return Vr.useDebugValue(a),a}const b0=e=>{const n=yS(e),a=s=>bS(n,s);return Object.assign(a,n),a},qt=(e=>e?b0(e):b0);function vS(e,n){let a;try{a=e()}catch{return}return{getItem:i=>{var l;const c=f=>f===null?null:JSON.parse(f,void 0),p=(l=a.getItem(i))!=null?l:null;return p instanceof Promise?p.then(c):c(p)},setItem:(i,l)=>a.setItem(i,JSON.stringify(l,void 0)),removeItem:i=>a.removeItem(i)}}const gf=e=>n=>{try{const a=e(n);return a instanceof Promise?a:{then(s){return gf(s)(a)},catch(s){return this}}}catch(a){return{then(s){return this},catch(s){return gf(s)(a)}}}},kS=(e,n)=>(a,s,i)=>{let l={storage:vS(()=>window.localStorage),partialize:C=>C,version:0,merge:(C,M)=>({...M,...C}),...n},c=!1,p=0;const f=new Set,m=new Set;let g=l.storage;if(!g)return e((...C)=>{console.warn(`[zustand persist middleware] Unable to update item '${l.name}', the given storage is currently unavailable.`),a(...C)},s,i);const x=()=>{const C=l.partialize({...s()});return g.setItem(l.name,{state:C,version:l.version})},b=i.setState;i.setState=(C,M)=>(b(C,M),x());const v=e((...C)=>(a(...C),x()),s,i);i.getInitialState=()=>v;let k;const w=()=>{var C,M;if(!g)return;const N=++p;c=!1,f.forEach(E=>{var I;return E((I=s())!=null?I:v)});const S=((M=l.onRehydrateStorage)==null?void 0:M.call(l,(C=s())!=null?C:v))||void 0;return gf(g.getItem.bind(g))(l.name).then(E=>{if(E)if(typeof E.version=="number"&&E.version!==l.version){if(l.migrate){const I=l.migrate(E.state,E.version);return I instanceof Promise?I.then(D=>[!0,D]):[!0,I]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,E.state];return[!1,void 0]}).then(E=>{var I;if(N!==p)return;const[D,A]=E;if(k=l.merge(A,(I=s())!=null?I:v),a(k,!0),D)return x()}).then(()=>{N===p&&(S?.(k,void 0),k=s(),c=!0,m.forEach(E=>E(k)))}).catch(E=>{N===p&&S?.(void 0,E)})};return i.persist={setOptions:C=>{l={...l,...C},C.storage&&(g=C.storage)},clearStorage:()=>{g?.removeItem(l.name)},getOptions:()=>l,rehydrate:()=>w(),hasHydrated:()=>c,onHydrate:C=>(f.add(C),()=>{f.delete(C)}),onFinishHydration:C=>(m.add(C),()=>{m.delete(C)})},l.skipHydration||w(),k||v},wS=kS,Zo={"ground-truth":{label:"Ground Truth",color:"#e74c3c",icon:"🔴",instruction:"Do not contradict this."},signal:{label:"Signal",color:"#f1c40f",icon:"🟡",instruction:"Interpret — look for the underlying need, not the surface request."},evidence:{label:"Evidence",color:"#3498db",icon:"🔵",instruction:"Cite and weigh against other evidence."},framework:{label:"Framework",color:"#2ecc71",icon:"🟢",instruction:"Use to structure thinking, but not as immutable."},hypothesis:{label:"Hypothesis",color:"#9b59b6",icon:"🟣",instruction:"Help validate or invalidate with evidence and signals."},guideline:{label:"Guideline",color:"#FE5000",icon:"📏",instruction:"Extract and enforce as constraints, workflow rules, and output formatting."}},SS=[[["signal","feedback","user feedback"],"signal"],[["discovery","_temp_"],"hypothesis"],[["roadmap","plans/","plan/"],"framework"],[["intel","competitors","competitive","research","savings-analysis"],"evidence"],[["cmo-handoff","release","demo","newsletter"],"evidence"],[["sales prep","event prep","executive profiler"],"framework"],[["guidelines","contributing","code-style","coding-standards","engineering-rules"],"guideline"],[["products"],"ground-truth",["feedback"]],[["clients/"],"ground-truth",["feedback"]],[["companies"],"evidence"],[["voyage-preparation","navarea-map"],"ground-truth"]],CS=[{patterns:[/^#{1,2}\s*(spec|specification|schema|api|contract|definition|interface)/mi,/\b(MUST|SHALL|REQUIRED)\b/g,/```(json|yaml|graphql|proto|sql)\b/g,/\b(version|v\d+\.\d+)/gi],type:"ground-truth",weight:10,minMatches:2},{patterns:[/\b(user said|customer|feedback|interview|request(ed)?|pain point|frustrat|complain|asked for|wants? to|need(s|ed)?)\b/gi,/\b(nps|csat|satisfaction|churn|retention)\b/gi,/[""][^""]{10,}[""]/g,/\b(quote|verbatim)\b/gi],type:"signal",weight:8,minMatches:2},{patterns:[/\b(analysis|benchmark|comparison|metric|kpi|data|report|finding|result|measured|observed)\b/gi,/\d+(\.\d+)?%/g,/\b(increase|decrease|growth|decline|trend)\b/gi,/\|\s*\w+\s*\|/g],type:"evidence",weight:7,minMatches:2},{patterns:[/\b(framework|methodology|process|template|playbook|checklist|step \d|phase \d|stage \d)\b/gi,/\b(when to|how to|best practice|guideline|principle|pattern)\b/gi,/^\s*[-*]\s*\[[ x]\]/gm,/\b(input|output|trigger|criteria)\b/gi],type:"framework",weight:6,minMatches:2},{patterns:[/\b(hypothesis|proposal|rfc|suggest(ion)?|idea|explore|what if|could we|might|experiment|assumption|validate)\b/gi,/\b(pro(s)?|con(s)?|trade-?off|risk|upside|downside)\b/gi,/\b(option [a-c]|alternative|approach \d)\b/gi],type:"hypothesis",weight:5,minMatches:2},{patterns:[/\b(MUST|SHALL|NEVER|ALWAYS|REQUIRED|FORBIDDEN|DO NOT)\b/g,/\b(convention|standard|guideline|rule|policy|style guide|best practice|coding standard)\b/gi,/\b(naming|branch|commit|pr|pull request)\s*(convention|format|rule|pattern)/gi,/\b(linting|formatting|eslint|prettier|editorconfig)\b/gi],type:"guideline",weight:8,minMatches:2}],MS=[{test:(e,n)=>n==="ground-truth",depth:0},{test:(e,n)=>n==="signal",depth:0},{test:e=>e.length<2e3,depth:0},{test:(e,n)=>n==="hypothesis",depth:1},{test:(e,n)=>n==="evidence"&&e.length>8e3,depth:2},{test:(e,n)=>n==="evidence",depth:1},{test:(e,n)=>n==="framework"&&e.length>8e3,depth:2},{test:(e,n)=>n==="framework",depth:1},{test:(e,n)=>n==="guideline",depth:0}];function Qr(e,n){return yf(e,n).knowledgeType}function yf(e,n){const a=e.toLowerCase();for(const[l,c,p]of SS)if(l.some(f=>a.includes(f))){if(p&&p.some(m=>a.includes(m)))continue;const f=ac(n||"",c);return{knowledgeType:c,depth:f,confidence:"high",reason:`Path matches "${l.find(m=>a.includes(m))}"`}}if(n&&n.length>50){const l=[];for(const c of CS){let p=0,f=0;for(const g of c.patterns){g.lastIndex=0;const x=n.match(g);x&&x.length>0&&(f++,p+=x.length)}const m=c.minMatches??1;f>=m&&l.push({type:c.type,score:p*c.weight,matches:f})}if(l.length>0){l.sort((m,g)=>g.score-m.score);const c=l[0],p=c.score>30?"high":c.score>10?"medium":"low",f=ac(n,c.type);return{knowledgeType:c.type,depth:f,confidence:p,reason:`Content analysis: ${c.matches} pattern groups, score ${c.score}`}}}const s=e.split(".").pop()?.toLowerCase();if(s){const l={json:"ground-truth",yaml:"ground-truth",yml:"ground-truth",toml:"ground-truth",sql:"ground-truth",graphql:"ground-truth",proto:"ground-truth",csv:"evidence",tsv:"evidence",xlsx:"evidence",py:"guideline",ts:"guideline",js:"guideline",tsx:"guideline",jsx:"guideline",log:"guideline",txt:"evidence"};if(l[s]){const c=ac(n||"",l[s]);return{knowledgeType:l[s],depth:c,confidence:"low",reason:`File extension .${s}`}}}return{knowledgeType:"evidence",depth:ac(n||"","evidence"),confidence:"low",reason:"Default"}}function ac(e,n){for(const a of MS)if(a.test(e,n))return a.depth;return 1}const lb=[{id:"markdown",label:"Markdown",icon:"📝",ext:".md"},{id:"html-slides",label:"HTML Slides",icon:"🎯",ext:".html"},{id:"email",label:"Email Draft",icon:"✉️",ext:""},{id:"code",label:"Code",icon:"💻",ext:".py"},{id:"csv",label:"Data Table",icon:"📊",ext:".csv"},{id:"json",label:"JSON",icon:"{}",ext:".json"},{id:"diagram",label:"Diagram",icon:"🔀",ext:".svg"},{id:"slack",label:"Slack Post",icon:"💬",ext:""}];function ES(e){const n=e.toLowerCase();return n.includes("slide")||n.includes("presentation")||n.includes("pitch")||n.includes("deck")?"html-slides":n.includes("email")||n.includes("draft")||n.includes("send to")?"email":n.includes("script")||n.includes("function")||n.includes("code")||n.includes("implement")?"code":n.includes("table")||n.includes("csv")||n.includes("spreadsheet")||n.includes("data")?"csv":n.includes("json")||n.includes("api")||n.includes("schema")?"json":n.includes("diagram")||n.includes("flowchart")||n.includes("architecture")?"diagram":n.includes("slack")||n.includes("post in")?"slack":"markdown"}const Rs=[{label:"Full",pct:1},{label:"Detail",pct:.75},{label:"Summary",pct:.5},{label:"Headlines",pct:.25},{label:"Mention",pct:.1}],v0={model:"claude-opus-4",temperature:.7,systemPrompt:"",planningMode:"single-shot",maxTokens:4096};function ke(e,n,a,s,i,l=0){return{sourceId:e,name:n,path:a,category:s,knowledgeType:Qr(a),depth:l,baseTokens:i}}const jS=[{id:"senior-pm",name:"Senior PM",agentConfig:{model:"claude-opus-4",temperature:.5,planningMode:"chain-of-thought",maxTokens:8192},channels:[ke("knowledge-products","Products","00 - Knowledge/Products/","knowledge",16e3,0),ke("knowledge-products-feedback","Feedback","00 - Knowledge/Products/Feedback/","knowledge",4800,0),ke("signals-odfjell","User feedback / Odfjell","07 - Signals/User feedback/odfjell/","intel",6800,1),ke("signals-kcc","User feedback / KCC","07 - Signals/User feedback/kcc/","intel",5200,1),ke("signals-general","User feedback / General","07 - Signals/User feedback/general/","intel",7500,1),ke("discovery-eu-ets","EU ETS Cost Layer","01 - Discovery/EU ETS Cost Layer/","discovery",3200,2),ke("discovery-weather-routing","Weather Routing v2","01 - Discovery/Weather Routing v2/","discovery",4100,2),ke("discovery-fleet-dashboard","Fleet Dashboard","01 - Discovery/Fleet Dashboard/","discovery",3500,2),ke("roadmap","03 - Roadmap","03 - Roadmap/","knowledge",12e3,1)]},{id:"competitive-intel",name:"Competitive Intel",agentConfig:{model:"claude-opus-4",temperature:.3,planningMode:"react",maxTokens:8192},channels:[ke("knowledge-competitors","Competitors","00 - Knowledge/Competitors/","knowledge",22e3,0),ke("knowledge-competitors-stormgeo","StormGeo","00 - Knowledge/Competitors/Features/stormgeo/","knowledge",4500,0),ke("knowledge-competitors-dtn","DTN","00 - Knowledge/Competitors/Features/dtn/","knowledge",3800,0),ke("knowledge-competitors-sofar","Sofar","00 - Knowledge/Competitors/Features/sofar/","knowledge",3200,0),ke("knowledge-competitors-wni","WNI","00 - Knowledge/Competitors/Features/wni/","knowledge",3600,0),ke("cmo-competitive-intel","05 - Competitive Intel","CMO-Handoff/05 - Competitive Intel/","intel",5800,1),ke("intel-competitive","01 - Competitive Intel","05 - Intel/01 - Competitive Intel/","intel",12e3,0)]},{id:"company-intel",name:"Company Intel",channels:[ke("knowledge-companies","Companies","00 - Knowledge/Companies/","knowledge",14e3,0),ke("cmo-company-profiles","01 - Company Profiles","CMO-Handoff/01 - Company Profiles/","knowledge",28e3,0),ke("cmo-charter-structures","02 - Charter Structures","CMO-Handoff/02 - Charter Structures/","knowledge",8500,1)]},{id:"feedback-manager",name:"Feedback Manager",agentConfig:{model:"claude-sonnet-4",temperature:.4,planningMode:"chain-of-thought",maxTokens:4096},channels:[ke("knowledge-products-feedback","Feedback","00 - Knowledge/Products/Feedback/","knowledge",4800,0),ke("signals-odfjell","User feedback / Odfjell","07 - Signals/User feedback/odfjell/","intel",6800,0),ke("signals-kcc","User feedback / KCC","07 - Signals/User feedback/kcc/","intel",5200,0),ke("signals-baru","User feedback / Baru","07 - Signals/User feedback/baru/","intel",4500,0),ke("signals-general","User feedback / General","07 - Signals/User feedback/general/","intel",7500,0),ke("intel-feedback","04 - Feedback Synthesis","05 - Intel/04 - Feedback Synthesis/","intel",4800,1)]},{id:"odfjell-deep-dive",name:"Odfjell Deep Dive",channels:[ke("odfjell-savings","odfjell-savings-analysis","odfjell-savings-analysis/","intel",14e3,0),ke("knowledge-clients-odfjell","Odfjell","00 - Knowledge/Clients/odfjell/","knowledge",4200,0),ke("signals-odfjell","User feedback / Odfjell","07 - Signals/User feedback/odfjell/","intel",6800,0),ke("cmo-charter-structures","02 - Charter Structures","CMO-Handoff/02 - Charter Structures/","knowledge",8500,1),ke("knowledge-competitors-stormgeo","StormGeo","00 - Knowledge/Competitors/Features/stormgeo/","knowledge",4500,2)]},{id:"voyage-prep-dev",name:"Voyage Prep Dev",channels:[ke("voyage-prep","voyage-preparation","voyage-preparation/","discovery",18e3,0),ke("temp-voyage","_temp_voyage-briefing","_temp_voyage-briefing/","discovery",6400,0),ke("discovery-weather-routing","Weather Routing v2","01 - Discovery/Weather Routing v2/","discovery",4100,1),ke("knowledge-products-nr","Navigation Reports","00 - Knowledge/Products/NR/","knowledge",8200,1)]},{id:"event-prep",name:"Event Prep",channels:[ke("sales-prep-events","Event Prep","06 - Sales Prep/Event Prep/","agents",9500,0),ke("sales-prep-exec","Executive Profiler","06 - Sales Prep/Executive Profiler/","agents",8500,0),ke("cmo-event-prep","07 - Event Prep Profiles","CMO-Handoff/07 - Event Prep Profiles/","agents",3500,0),ke("cmo-company-profiles","01 - Company Profiles","CMO-Handoff/01 - Company Profiles/","knowledge",28e3,2)]},{id:"maritime-intel",name:"Maritime Intel",channels:[ke("intel-maritime","02 - Maritime Intel","05 - Intel/02 - Maritime Intel/","intel",14e3,0),ke("navarea-map","navarea-map","navarea-map/","intel",11e3,0),ke("intel-research","03 - Research","05 - Intel/03 - Research/","intel",7200,1)]},{id:"discovery-all",name:"Discovery",channels:[ke("discovery-eu-ets","EU ETS Cost Layer","01 - Discovery/EU ETS Cost Layer/","discovery",3200,0),ke("discovery-weather-routing","Weather Routing v2","01 - Discovery/Weather Routing v2/","discovery",4100,0),ke("discovery-cii-monitor","CII Monitor","01 - Discovery/CII Monitor/","discovery",2800,0),ke("discovery-fleet-dashboard","Fleet Dashboard","01 - Discovery/Fleet Dashboard/","discovery",3500,0),ke("discovery-voyage-compare","Voyage Compare","01 - Discovery/Voyage Compare/","discovery",2600,0),ke("discovery-port-insights","Port Insights","01 - Discovery/Port Insights/","discovery",2200,0),ke("discovery-api-v2","API v2","01 - Discovery/API v2/","discovery",3800,0),ke("discovery-alerts-engine","Alerts Engine","01 - Discovery/Alerts Engine/","discovery",2400,0),ke("discovery-bunker-opt","Bunker Optimization","01 - Discovery/Bunker Optimization/","discovery",3100,0),ke("discovery-cargo-tracking","Cargo Tracking","01 - Discovery/Cargo Tracking/","discovery",2700,0)]},{id:"all-knowledge",name:"All Knowledge",channels:[ke("knowledge","00 - Knowledge","00 - Knowledge/","knowledge",82e3,2),ke("knowledge-clients","Clients","00 - Knowledge/Clients/","knowledge",18e3,1),ke("knowledge-companies","Companies","00 - Knowledge/Companies/","knowledge",14e3,1),ke("knowledge-competitors","Competitors","00 - Knowledge/Competitors/","knowledge",22e3,1),ke("knowledge-products","Products","00 - Knowledge/Products/","knowledge",16e3,0),ke("knowledge-market","Market","00 - Knowledge/Market/","knowledge",6500,2),ke("knowledge-users","Users","00 - Knowledge/Users/","knowledge",5500,2)]}],Ta=[{id:"mcp-filesystem",name:"Filesystem",npmPackage:"@modelcontextprotocol/server-filesystem",description:"Read, write, and manage local files with configurable access controls",icon:"folder",category:"coding",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-filesystem"],configFields:[{key:"ALLOWED_DIRS",label:"Allowed Directories (comma-separated)",type:"text",placeholder:"/home/user/projects,/tmp",required:!0}],repo:"https://github.com/modelcontextprotocol/servers",tags:["files","local","read","write"],authMethod:"none"},{id:"mcp-memory",name:"Memory (Knowledge Graph)",npmPackage:"@modelcontextprotocol/server-memory",description:"Persistent knowledge graph memory for agent state and relationships",icon:"brain",category:"data",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-memory"],configFields:[],repo:"https://github.com/modelcontextprotocol/servers",tags:["memory","knowledge-graph","state","persistence"],authMethod:"none"},{id:"mcp-fetch",name:"Fetch",npmPackage:"@modelcontextprotocol/server-fetch",description:"Fetch web content and convert to markdown for LLM consumption",icon:"download",category:"research",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-fetch"],configFields:[],repo:"https://github.com/modelcontextprotocol/servers",tags:["web","fetch","scrape","markdown"],authMethod:"none"},{id:"mcp-git",name:"Git",npmPackage:"@modelcontextprotocol/server-git",description:"Read, search, and manipulate Git repositories - log, diff, blame",icon:"git-branch",category:"coding",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"uvx",defaultArgs:["mcp-server-git"],configFields:[{key:"GIT_REPO_PATH",label:"Repository Path",type:"text",placeholder:"/path/to/repo",required:!1}],repo:"https://github.com/modelcontextprotocol/servers",tags:["git","version-control","diff","log"],authMethod:"none",installHint:{macos:"brew install uv",linux:"curl -LsSf https://astral.sh/uv/install.sh | sh",windows:"pip install uv"}},{id:"mcp-sequential-thinking",name:"Sequential Thinking",npmPackage:"@modelcontextprotocol/server-sequential-thinking",description:"Dynamic and reflective problem-solving through structured thought sequences",icon:"list-ordered",category:"research",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-sequential-thinking"],configFields:[],repo:"https://github.com/modelcontextprotocol/servers",tags:["thinking","reasoning","chain-of-thought"],authMethod:"none"},{id:"mcp-time",name:"Time",npmPackage:"@modelcontextprotocol/server-time",description:"Get current time and convert between timezones",icon:"clock",category:"data",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-time"],configFields:[],repo:"https://github.com/modelcontextprotocol/servers",tags:["time","timezone","date"],authMethod:"none"},{id:"mcp-everything",name:"Everything (Test)",npmPackage:"@modelcontextprotocol/server-everything",description:"Reference test server with prompts, resources, and tools for MCP testing",icon:"star",category:"coding",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-everything"],configFields:[],repo:"https://github.com/modelcontextprotocol/servers",tags:["test","reference","debug"],authMethod:"none"},{id:"mcp-brave-search",name:"Brave Search",npmPackage:"@modelcontextprotocol/server-brave-search",description:"Web and local search powered by Brave Search API",icon:"search",category:"research",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-brave-search"],configFields:[{key:"BRAVE_API_KEY",label:"API Key",type:"password",placeholder:"BSA...",required:!0}],website:"https://brave.com/search/api/",tags:["search","web","brave"],authMethod:"api-key"},{id:"mcp-tavily",name:"Tavily Search",npmPackage:"tavily-mcp",description:"AI-optimized search engine with structured results and answer extraction",icon:"search",category:"research",author:"Tavily",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","tavily-mcp"],configFields:[{key:"TAVILY_API_KEY",label:"API Key",type:"password",placeholder:"tvly-...",required:!0}],website:"https://tavily.com",tags:["search","ai-search","research"],authMethod:"api-key"},{id:"mcp-exa",name:"Exa Search",npmPackage:"exa-mcp-server",description:"Neural search engine - find similar content, get page contents",icon:"search",category:"research",author:"Exa",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","exa-mcp-server"],configFields:[{key:"EXA_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],website:"https://exa.ai",tags:["search","neural-search","semantic"],authMethod:"api-key"},{id:"mcp-firecrawl",name:"Firecrawl",npmPackage:"firecrawl-mcp",description:"Web scraping and crawling - extract structured data from any website",icon:"flame",category:"research",author:"Firecrawl",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","firecrawl-mcp"],configFields:[{key:"FIRECRAWL_API_KEY",label:"API Key",type:"password",placeholder:"fc-...",required:!0}],website:"https://firecrawl.dev",tags:["scraping","crawling","web","extract"],authMethod:"api-key"},{id:"mcp-puppeteer",name:"Puppeteer",npmPackage:"@modelcontextprotocol/server-puppeteer",description:"Browser automation - screenshots, navigation, form filling, scraping",icon:"globe",category:"research",author:"MCP Official",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-puppeteer"],configFields:[],tags:["browser","automation","screenshots","scraping"],authMethod:"none"},{id:"mcp-playwright",name:"Playwright",npmPackage:"@playwright/mcp",description:"Browser automation with Playwright - cross-browser testing and scraping",icon:"globe",category:"research",author:"Microsoft",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@playwright/mcp"],configFields:[],tags:["browser","playwright","testing","automation"],authMethod:"none"},{id:"mcp-github",name:"GitHub",npmPackage:"@modelcontextprotocol/server-github",description:"GitHub repos, issues, PRs, code search, and actions",icon:"git-branch",category:"coding",author:"GitHub",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-github"],configFields:[{key:"GITHUB_TOKEN",label:"Personal Access Token",type:"password",placeholder:"ghp_...",required:!0}],website:"https://github.com",tags:["github","git","issues","pr","code"],authMethod:"api-key"},{id:"github-remote",name:"GitHub (Cloud)",npmPackage:"@modelcontextprotocol/server-github-cloud",description:"GitHub repos, issues, PRs – OAuth via GitHub App",icon:"git-branch",category:"coding",author:"GitHub",transport:"sse",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-github-cloud"],url:"https://api.githubcopilot.com/mcp/",authMethod:"oauth",configFields:[],website:"https://github.com",tags:["github","git","issues","pr","code","oauth"]},{id:"mcp-gitlab",name:"GitLab",npmPackage:"@modelcontextprotocol/server-gitlab",description:"GitLab API - projects, issues, merge requests, pipelines",icon:"git-merge",category:"coding",author:"GitLab",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-gitlab"],configFields:[{key:"GITLAB_TOKEN",label:"Access Token",type:"password",placeholder:"glpat-...",required:!0},{key:"GITLAB_URL",label:"Instance URL",type:"url",placeholder:"https://gitlab.com",required:!1}],tags:["gitlab","git","ci-cd","merge-request"],authMethod:"api-key"},{id:"mcp-linear",name:"Linear",npmPackage:"@linear/mcp-server",description:"Linear project management - issues, projects, cycles, and teams",icon:"target",category:"coding",author:"Linear",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@linear/mcp-server"],configFields:[{key:"LINEAR_API_KEY",label:"API Key",type:"password",placeholder:"lin_api_...",required:!0}],website:"https://linear.app",tags:["linear","project-management","issues","agile"],authMethod:"api-key"},{id:"mcp-sentry",name:"Sentry",npmPackage:"@sentry/mcp-server",description:"Error tracking and performance monitoring - issues, events, releases",icon:"shield",category:"coding",author:"Sentry",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@sentry/mcp-server"],configFields:[{key:"SENTRY_AUTH_TOKEN",label:"Auth Token",type:"password",placeholder:"sntrys_...",required:!0}],website:"https://sentry.io",tags:["sentry","errors","monitoring","debugging"],authMethod:"api-key"},{id:"mcp-docker",name:"Docker",npmPackage:"docker-mcp",description:"Manage Docker containers, images, volumes, and networks",icon:"box",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","docker-mcp"],configFields:[],tags:["docker","containers","devops","infrastructure"],authMethod:"none"},{id:"mcp-kubernetes",name:"Kubernetes",npmPackage:"kubernetes-mcp",description:"Kubernetes cluster management - pods, deployments, services, logs",icon:"server",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","kubernetes-mcp"],configFields:[{key:"KUBECONFIG",label:"Kubeconfig Path",type:"text",placeholder:"~/.kube/config",required:!1}],tags:["kubernetes","k8s","devops","orchestration"],authMethod:"none"},{id:"mcp-vercel",name:"Vercel",npmPackage:"@vercel/mcp",description:"Vercel deployments, domains, environment variables, and logs",icon:"triangle",category:"coding",author:"Vercel",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@vercel/mcp"],configFields:[{key:"VERCEL_TOKEN",label:"Access Token",type:"password",placeholder:"",required:!0}],website:"https://vercel.com",tags:["vercel","deploy","hosting","serverless"],authMethod:"api-key"},{id:"mcp-cloudflare",name:"Cloudflare",npmPackage:"@cloudflare/mcp-server-cloudflare",description:"Cloudflare Workers, KV, R2, D1, and DNS management",icon:"cloud",category:"coding",author:"Cloudflare",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@cloudflare/mcp-server-cloudflare"],configFields:[{key:"CLOUDFLARE_API_TOKEN",label:"API Token",type:"password",placeholder:"",required:!0}],website:"https://cloudflare.com",tags:["cloudflare","workers","cdn","dns"],authMethod:"api-key"},{id:"mcp-netlify",name:"Netlify",npmPackage:"netlify-mcp",description:"Netlify sites, deploys, functions, and build hooks",icon:"globe",category:"coding",author:"Netlify",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","netlify-mcp"],configFields:[{key:"NETLIFY_TOKEN",label:"Personal Access Token",type:"password",placeholder:"",required:!0}],tags:["netlify","deploy","hosting","jamstack"],authMethod:"api-key"},{id:"mcp-npm",name:"npm Registry",npmPackage:"npm-mcp",description:"Search npm packages, view details, check versions and dependencies",icon:"package",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","npm-mcp"],configFields:[],tags:["npm","packages","dependencies","registry"],authMethod:"none"},{id:"mcp-postgres",name:"PostgreSQL",npmPackage:"@modelcontextprotocol/server-postgres",description:"Query PostgreSQL databases - schema inspection, read/write operations",icon:"database",category:"data",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-postgres"],configFields:[{key:"DATABASE_URL",label:"Connection String",type:"password",placeholder:"postgresql://user:pass@host:5432/db",required:!0}],tags:["postgres","database","sql","query"],authMethod:"api-key"},{id:"mcp-mysql",name:"MySQL",npmPackage:"mysql-mcp-server",description:"MySQL database operations - queries, schema, migrations",icon:"database",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","mysql-mcp-server"],configFields:[{key:"MYSQL_URL",label:"Connection String",type:"password",placeholder:"mysql://user:pass@host:3306/db",required:!0}],tags:["mysql","database","sql"],authMethod:"api-key"},{id:"mcp-sqlite",name:"SQLite",npmPackage:"@modelcontextprotocol/server-sqlite",description:"SQLite database - local file-based SQL with business intelligence",icon:"database",category:"data",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-sqlite"],configFields:[{key:"SQLITE_PATH",label:"Database File Path",type:"text",placeholder:"/path/to/database.db",required:!0}],tags:["sqlite","database","sql","local"],authMethod:"none"},{id:"mcp-mongodb",name:"MongoDB",npmPackage:"mongodb-mcp-server",description:"MongoDB operations - collections, documents, aggregation pipelines",icon:"database",category:"data",author:"MongoDB",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","mongodb-mcp-server"],configFields:[{key:"MONGODB_URI",label:"Connection URI",type:"password",placeholder:"mongodb+srv://user:pass@cluster.mongodb.net/db",required:!0}],tags:["mongodb","nosql","database","documents"],authMethod:"api-key"},{id:"mcp-redis",name:"Redis",npmPackage:"@modelcontextprotocol/server-redis",description:"Redis key-value store - get, set, scan, pub/sub",icon:"database",category:"data",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-redis"],configFields:[{key:"REDIS_URL",label:"Connection URL",type:"password",placeholder:"redis://localhost:6379",required:!0}],tags:["redis","cache","key-value","pub-sub"],authMethod:"api-key"},{id:"mcp-supabase",name:"Supabase",npmPackage:"@supabase/mcp-server",description:"Supabase - database, auth, storage, edge functions, realtime",icon:"database",category:"data",author:"Supabase",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@supabase/mcp-server"],configFields:[{key:"SUPABASE_URL",label:"Project URL",type:"url",placeholder:"https://xxx.supabase.co",required:!0},{key:"SUPABASE_SERVICE_ROLE_KEY",label:"Service Role Key",type:"password",placeholder:"eyJ...",required:!0}],website:"https://supabase.com",tags:["supabase","database","auth","storage","postgres"],authMethod:"api-key"},{id:"mcp-neon",name:"Neon",npmPackage:"@neondatabase/mcp-server-neon",description:"Neon serverless Postgres - branches, queries, schema management",icon:"database",category:"data",author:"Neon",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@neondatabase/mcp-server-neon"],configFields:[{key:"NEON_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],website:"https://neon.tech",tags:["neon","postgres","serverless","database"],authMethod:"api-key"},{id:"mcp-turso",name:"Turso",npmPackage:"@tursodatabase/mcp-server",description:"Turso edge database - SQLite at the edge, libSQL",icon:"database",category:"data",author:"Turso",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@tursodatabase/mcp-server"],configFields:[{key:"TURSO_DATABASE_URL",label:"Database URL",type:"url",placeholder:"libsql://db-org.turso.io",required:!0},{key:"TURSO_AUTH_TOKEN",label:"Auth Token",type:"password",placeholder:"",required:!0}],website:"https://turso.tech",tags:["turso","sqlite","edge","database"],authMethod:"api-key"},{id:"mcp-pinecone",name:"Pinecone",npmPackage:"@pinecone-database/mcp",description:"Pinecone vector database - upsert, query, delete vectors",icon:"database",category:"data",author:"Pinecone",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@pinecone-database/mcp"],configFields:[{key:"PINECONE_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],website:"https://pinecone.io",tags:["pinecone","vector","embeddings","rag"],authMethod:"api-key"},{id:"mcp-qdrant",name:"Qdrant",npmPackage:"qdrant-mcp",description:"Qdrant vector search - collections, points, filtering, similarity",icon:"database",category:"data",author:"Qdrant",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","qdrant-mcp"],configFields:[{key:"QDRANT_URL",label:"URL",type:"url",placeholder:"http://localhost:6333",required:!0},{key:"QDRANT_API_KEY",label:"API Key",type:"password",placeholder:"",required:!1}],website:"https://qdrant.tech",tags:["qdrant","vector","search","embeddings"],authMethod:"api-key"},{id:"mcp-slack",name:"Slack",npmPackage:"@modelcontextprotocol/server-slack",description:"Slack workspace - channels, messages, threads, search, reactions",icon:"hash",category:"data",author:"Slack",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-slack"],configFields:[{key:"SLACK_BOT_TOKEN",label:"Bot Token",type:"password",placeholder:"xoxb-...",required:!0},{key:"SLACK_TEAM_ID",label:"Team ID",type:"text",placeholder:"T0...",required:!1}],website:"https://slack.com",tags:["slack","messaging","channels","team"],authMethod:"api-key"},{id:"slack-remote",name:"Slack (Cloud)",npmPackage:"",description:"Slack workspace - OAuth, no bot token needed",icon:"hash",category:"data",author:"Slack",transport:"streamable-http",runtimes:["claude","amp","codex"],command:"",defaultArgs:[],url:"https://mcp.slack.com/sse",authMethod:"oauth",configFields:[],website:"https://slack.com",tags:["slack","messaging","channels","team","oauth"]},{id:"mcp-discord",name:"Discord",npmPackage:"discord-mcp",description:"Discord bot - read messages, manage channels, send notifications",icon:"message-circle",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","discord-mcp"],configFields:[{key:"DISCORD_TOKEN",label:"Bot Token",type:"password",placeholder:"",required:!0}],tags:["discord","messaging","bot","community"],authMethod:"api-key"},{id:"mcp-gmail",name:"Gmail",npmPackage:"@gongrzhe/server-gmail-autoauth-mcp",description:"Read, send, search, and manage Gmail with OAuth auto-auth",icon:"mail",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@gongrzhe/server-gmail-autoauth-mcp"],configFields:[{key:"GMAIL_CLIENT_ID",label:"OAuth Client ID",type:"text",placeholder:"...apps.googleusercontent.com",required:!0},{key:"GMAIL_CLIENT_SECRET",label:"OAuth Client Secret",type:"password",placeholder:"GOCSPX-...",required:!0}],tags:["gmail","email","google","oauth"],authMethod:"api-key"},{id:"mcp-email",name:"Email (SMTP/IMAP)",npmPackage:"email-mcp",description:"Send and read emails via SMTP/IMAP - works with any email provider",icon:"mail",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","email-mcp"],configFields:[{key:"SMTP_HOST",label:"SMTP Host",type:"text",placeholder:"smtp.gmail.com",required:!0},{key:"SMTP_USER",label:"Username",type:"text",placeholder:"user@example.com",required:!0},{key:"SMTP_PASS",label:"Password",type:"password",placeholder:"",required:!0}],tags:["email","smtp","imap","send"],authMethod:"api-key"},{id:"mcp-twilio",name:"Twilio",npmPackage:"twilio-mcp",description:"Send SMS, make calls, manage phone numbers via Twilio API",icon:"phone",category:"data",author:"Twilio",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","twilio-mcp"],configFields:[{key:"TWILIO_ACCOUNT_SID",label:"Account SID",type:"text",placeholder:"AC...",required:!0},{key:"TWILIO_AUTH_TOKEN",label:"Auth Token",type:"password",placeholder:"",required:!0}],website:"https://twilio.com",tags:["twilio","sms","phone","messaging"],authMethod:"api-key"},{id:"mcp-notion",name:"Notion",npmPackage:"@notionhq/notion-mcp-server",description:"Notion pages, databases, blocks - read, create, update, search",icon:"book-open",category:"writing",author:"Notion",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@notionhq/notion-mcp-server"],configFields:[{key:"NOTION_TOKEN",label:"Integration Token",type:"password",placeholder:"ntn_...",required:!0}],website:"https://notion.so",tags:["notion","docs","wiki","database","pages"],authMethod:"api-key"},{id:"notion-remote",name:"Notion (Cloud)",npmPackage:"",description:"Notion pages, databases, blocks - OAuth, no API key needed",icon:"book-open",category:"writing",author:"Notion",transport:"streamable-http",runtimes:["claude","amp","codex"],command:"",defaultArgs:[],url:"https://mcp.notion.com/mcp",authMethod:"oauth",configFields:[],website:"https://notion.so",tags:["notion","docs","wiki","database","pages","oauth"],sameServiceAs:"mcp-notion"},{id:"mcp-google-drive",name:"Google Drive",npmPackage:"@modelcontextprotocol/server-gdrive",description:"Google Drive - search, read, create files and folders",icon:"hard-drive",category:"data",author:"MCP Official",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-gdrive"],configFields:[{key:"GOOGLE_CLIENT_ID",label:"OAuth Client ID",type:"text",placeholder:"",required:!0},{key:"GOOGLE_CLIENT_SECRET",label:"OAuth Client Secret",type:"password",placeholder:"",required:!0}],tags:["google-drive","files","docs","sheets","storage"],authMethod:"api-key"},{id:"mcp-google-sheets",name:"Google Sheets",npmPackage:"google-sheets-mcp",description:"Read and write Google Sheets - cells, ranges, formulas",icon:"table",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","google-sheets-mcp"],configFields:[{key:"GOOGLE_CLIENT_ID",label:"OAuth Client ID",type:"text",placeholder:"",required:!0},{key:"GOOGLE_CLIENT_SECRET",label:"OAuth Client Secret",type:"password",placeholder:"",required:!0}],tags:["google-sheets","spreadsheet","data","tables"],authMethod:"api-key"},{id:"mcp-google-calendar",name:"Google Calendar",npmPackage:"google-calendar-mcp",description:"Google Calendar - events, scheduling, availability, reminders",icon:"calendar",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","google-calendar-mcp"],configFields:[{key:"GOOGLE_CLIENT_ID",label:"OAuth Client ID",type:"text",placeholder:"",required:!0},{key:"GOOGLE_CLIENT_SECRET",label:"OAuth Client Secret",type:"password",placeholder:"",required:!0}],tags:["google-calendar","events","scheduling","calendar"],authMethod:"api-key"},{id:"mcp-google-maps",name:"Google Maps",npmPackage:"@modelcontextprotocol/server-google-maps",description:"Google Maps - geocoding, directions, places, distance matrix",icon:"map-pin",category:"data",author:"MCP Official",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-google-maps"],configFields:[{key:"GOOGLE_MAPS_API_KEY",label:"API Key",type:"password",placeholder:"AIza...",required:!0}],tags:["google-maps","geocoding","directions","places"],authMethod:"api-key"},{id:"mcp-confluence",name:"Confluence",npmPackage:"confluence-mcp",description:"Atlassian Confluence - spaces, pages, search, content management",icon:"book-open",category:"writing",author:"Atlassian",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","confluence-mcp"],configFields:[{key:"CONFLUENCE_URL",label:"Instance URL",type:"url",placeholder:"https://your-org.atlassian.net/wiki",required:!0},{key:"CONFLUENCE_TOKEN",label:"API Token",type:"password",placeholder:"",required:!0},{key:"CONFLUENCE_EMAIL",label:"Email",type:"text",placeholder:"user@company.com",required:!0}],tags:["confluence","wiki","docs","atlassian"],authMethod:"api-key"},{id:"mcp-jira",name:"Jira",npmPackage:"jira-mcp",description:"Jira - issues, boards, sprints, epics, JQL search",icon:"clipboard-list",category:"coding",author:"Atlassian",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","jira-mcp"],configFields:[{key:"JIRA_URL",label:"Instance URL",type:"url",placeholder:"https://your-org.atlassian.net",required:!0},{key:"JIRA_EMAIL",label:"Email",type:"text",placeholder:"user@company.com",required:!0},{key:"JIRA_TOKEN",label:"API Token",type:"password",placeholder:"",required:!0}],tags:["jira","issues","agile","boards","atlassian"],authMethod:"api-key"},{id:"mcp-asana",name:"Asana",npmPackage:"asana-mcp",description:"Asana - tasks, projects, sections, comments, assignees",icon:"check-square",category:"coding",author:"Asana",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","asana-mcp"],configFields:[{key:"ASANA_TOKEN",label:"Personal Access Token",type:"password",placeholder:"1/...",required:!0}],website:"https://asana.com",tags:["asana","tasks","project-management"],authMethod:"api-key"},{id:"mcp-todoist",name:"Todoist",npmPackage:"todoist-mcp",description:"Todoist - tasks, projects, labels, filters, productivity",icon:"check-circle",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","todoist-mcp"],configFields:[{key:"TODOIST_API_TOKEN",label:"API Token",type:"password",placeholder:"",required:!0}],website:"https://todoist.com",tags:["todoist","tasks","productivity","todo"],authMethod:"api-key"},{id:"mcp-obsidian",name:"Obsidian",npmPackage:"obsidian-mcp",description:"Obsidian vault - read, search, create notes, manage links",icon:"file-text",category:"writing",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","obsidian-mcp"],configFields:[{key:"OBSIDIAN_VAULT_PATH",label:"Vault Path",type:"text",placeholder:"/path/to/vault",required:!0}],tags:["obsidian","notes","markdown","knowledge-base"],authMethod:"none"},{id:"mcp-airtable",name:"Airtable",npmPackage:"airtable-mcp",description:"Airtable bases, tables, records - CRUD operations and views",icon:"table",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","airtable-mcp"],configFields:[{key:"AIRTABLE_TOKEN",label:"Personal Access Token",type:"password",placeholder:"pat...",required:!0}],website:"https://airtable.com",tags:["airtable","database","spreadsheet","records"]},{id:"mcp-hubspot",name:"HubSpot",npmPackage:"hubspot-mcp",description:"HubSpot CRM - contacts, companies, deals, tickets, engagement",icon:"hexagon",category:"data",author:"HubSpot",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","hubspot-mcp"],configFields:[{key:"HUBSPOT_ACCESS_TOKEN",label:"Private App Token",type:"password",placeholder:"pat-...",required:!0}],website:"https://hubspot.com",tags:["hubspot","crm","sales","contacts","deals"]},{id:"mcp-salesforce",name:"Salesforce",npmPackage:"salesforce-mcp",description:"Salesforce - SOQL queries, objects, records, reports",icon:"cloud",category:"data",author:"Salesforce",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","salesforce-mcp"],configFields:[{key:"SF_LOGIN_URL",label:"Login URL",type:"url",placeholder:"https://login.salesforce.com",required:!0},{key:"SF_USERNAME",label:"Username",type:"text",placeholder:"",required:!0},{key:"SF_PASSWORD",label:"Password + Security Token",type:"password",placeholder:"",required:!0}],tags:["salesforce","crm","soql","sales"],authMethod:"api-key"},{id:"mcp-stripe",name:"Stripe",npmPackage:"@stripe/mcp",description:"Stripe payments - customers, invoices, subscriptions, products",icon:"credit-card",category:"data",author:"Stripe",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@stripe/mcp"],configFields:[{key:"STRIPE_SECRET_KEY",label:"Secret Key",type:"password",placeholder:"sk_...",required:!0}],website:"https://stripe.com",tags:["stripe","payments","billing","subscriptions"]},{id:"mcp-shopify",name:"Shopify",npmPackage:"@shopify/dev-mcp",description:"Shopify store - products, orders, customers, inventory",icon:"shopping-bag",category:"data",author:"Shopify",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@shopify/dev-mcp"],configFields:[{key:"SHOPIFY_STORE_URL",label:"Store URL",type:"url",placeholder:"your-store.myshopify.com",required:!0},{key:"SHOPIFY_ACCESS_TOKEN",label:"Access Token",type:"password",placeholder:"shpat_...",required:!0}],tags:["shopify","ecommerce","products","orders"],authMethod:"api-key"},{id:"mcp-openai",name:"OpenAI",npmPackage:"openai-mcp",description:"OpenAI API - completions, embeddings, DALL-E, Whisper, assistants",icon:"cpu",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","openai-mcp"],configFields:[{key:"OPENAI_API_KEY",label:"API Key",type:"password",placeholder:"sk-...",required:!0}],tags:["openai","gpt","embeddings","dalle","whisper"],authMethod:"api-key"},{id:"mcp-anthropic",name:"Anthropic Claude",npmPackage:"anthropic-mcp",description:"Anthropic API - Claude completions, tool use, system prompts",icon:"cpu",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","anthropic-mcp"],configFields:[{key:"ANTHROPIC_API_KEY",label:"API Key",type:"password",placeholder:"sk-ant-...",required:!0}],tags:["anthropic","claude","ai","llm"],authMethod:"api-key"},{id:"mcp-replicate",name:"Replicate",npmPackage:"replicate-mcp",description:"Replicate - run open-source ML models via API",icon:"cpu",category:"coding",author:"Replicate",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","replicate-mcp"],configFields:[{key:"REPLICATE_API_TOKEN",label:"API Token",type:"password",placeholder:"r8_...",required:!0}],website:"https://replicate.com",tags:["replicate","ml","models","inference"]},{id:"mcp-huggingface",name:"Hugging Face",npmPackage:"huggingface-mcp",description:"Hugging Face - models, datasets, spaces, inference API",icon:"cpu",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","huggingface-mcp"],configFields:[{key:"HF_TOKEN",label:"Access Token",type:"password",placeholder:"hf_...",required:!0}],website:"https://huggingface.co",tags:["huggingface","models","datasets","ml"]},{id:"mcp-aws",name:"AWS",npmPackage:"aws-mcp",description:"AWS services - S3, Lambda, EC2, DynamoDB, CloudWatch",icon:"cloud",category:"coding",author:"AWS",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","aws-mcp"],configFields:[{key:"AWS_ACCESS_KEY_ID",label:"Access Key ID",type:"text",placeholder:"AKIA...",required:!0},{key:"AWS_SECRET_ACCESS_KEY",label:"Secret Access Key",type:"password",placeholder:"",required:!0},{key:"AWS_REGION",label:"Region",type:"text",placeholder:"us-east-1",required:!1}],tags:["aws","s3","lambda","ec2","cloud"],authMethod:"api-key"},{id:"mcp-gcp",name:"Google Cloud",npmPackage:"gcp-mcp",description:"Google Cloud Platform - BigQuery, Cloud Storage, Compute, Pub/Sub",icon:"cloud",category:"coding",author:"Google",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","gcp-mcp"],configFields:[{key:"GOOGLE_APPLICATION_CREDENTIALS",label:"Service Account Key Path",type:"text",placeholder:"/path/to/key.json",required:!0}],tags:["gcp","bigquery","cloud-storage","google-cloud"],authMethod:"none"},{id:"mcp-azure",name:"Azure",npmPackage:"azure-mcp",description:"Azure services - Blob Storage, Functions, Cosmos DB, Key Vault",icon:"cloud",category:"coding",author:"Microsoft",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","azure-mcp"],configFields:[{key:"AZURE_SUBSCRIPTION_ID",label:"Subscription ID",type:"text",placeholder:"",required:!0},{key:"AZURE_TENANT_ID",label:"Tenant ID",type:"text",placeholder:"",required:!0},{key:"AZURE_CLIENT_ID",label:"Client ID",type:"text",placeholder:"",required:!0},{key:"AZURE_CLIENT_SECRET",label:"Client Secret",type:"password",placeholder:"",required:!0}],tags:["azure","cloud","microsoft","blob-storage"],authMethod:"api-key"},{id:"mcp-n8n",name:"n8n",npmPackage:"n8n-mcp",description:"n8n workflow automation - trigger, manage, inspect workflows",icon:"workflow",category:"coding",author:"n8n",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","n8n-mcp"],configFields:[{key:"N8N_URL",label:"Instance URL",type:"url",placeholder:"http://localhost:5678",required:!0},{key:"N8N_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],website:"https://n8n.io",tags:["n8n","automation","workflow","integration"]},{id:"mcp-zapier",name:"Zapier",npmPackage:"zapier-mcp",description:"Zapier - trigger Zaps, manage connections, inspect runs",icon:"zap",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","zapier-mcp"],configFields:[{key:"ZAPIER_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],tags:["zapier","automation","workflow","zaps"],authMethod:"api-key"},{id:"mcp-make",name:"Make (Integromat)",npmPackage:"make-mcp",description:"Make.com - scenarios, modules, connections, execution history",icon:"workflow",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","make-mcp"],configFields:[{key:"MAKE_API_TOKEN",label:"API Token",type:"password",placeholder:"",required:!0}],tags:["make","integromat","automation","scenarios"],authMethod:"api-key"},{id:"mcp-datadog",name:"Datadog",npmPackage:"datadog-mcp",description:"Datadog - metrics, dashboards, monitors, logs, APM",icon:"bar-chart",category:"data",author:"Datadog",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","datadog-mcp"],configFields:[{key:"DD_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0},{key:"DD_APP_KEY",label:"App Key",type:"password",placeholder:"",required:!0}],website:"https://datadoghq.com",tags:["datadog","monitoring","metrics","apm"]},{id:"mcp-grafana",name:"Grafana",npmPackage:"grafana-mcp",description:"Grafana - dashboards, alerts, data sources, panels",icon:"bar-chart",category:"data",author:"Grafana",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","grafana-mcp"],configFields:[{key:"GRAFANA_URL",label:"Instance URL",type:"url",placeholder:"http://localhost:3000",required:!0},{key:"GRAFANA_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],tags:["grafana","dashboards","monitoring","visualization"],authMethod:"api-key"},{id:"mcp-posthog",name:"PostHog",npmPackage:"posthog-mcp",description:"PostHog product analytics - events, funnels, feature flags, surveys",icon:"bar-chart-3",category:"data",author:"PostHog",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","posthog-mcp"],configFields:[{key:"POSTHOG_HOST",label:"Host URL",type:"url",placeholder:"https://app.posthog.com",required:!0},{key:"POSTHOG_API_KEY",label:"Personal API Key",type:"password",placeholder:"phx_...",required:!0}],website:"https://posthog.com",tags:["posthog","analytics","events","product"]},{id:"mcp-mixpanel",name:"Mixpanel",npmPackage:"mixpanel-mcp",description:"Mixpanel - events, funnels, cohorts, user analytics",icon:"bar-chart",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","mixpanel-mcp"],configFields:[{key:"MIXPANEL_TOKEN",label:"Project Token",type:"password",placeholder:"",required:!0},{key:"MIXPANEL_API_SECRET",label:"API Secret",type:"password",placeholder:"",required:!1}],tags:["mixpanel","analytics","events","funnels"],authMethod:"api-key"},{id:"mcp-twitter",name:"Twitter / X",npmPackage:"twitter-mcp",description:"Twitter/X - tweets, search, timeline, DMs, analytics",icon:"message-circle",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","twitter-mcp"],configFields:[{key:"TWITTER_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0},{key:"TWITTER_API_SECRET",label:"API Secret",type:"password",placeholder:"",required:!0},{key:"TWITTER_ACCESS_TOKEN",label:"Access Token",type:"password",placeholder:"",required:!0},{key:"TWITTER_ACCESS_SECRET",label:"Access Token Secret",type:"password",placeholder:"",required:!0}],tags:["twitter","x","social","tweets"],authMethod:"api-key"},{id:"mcp-youtube",name:"YouTube",npmPackage:"youtube-mcp",description:"YouTube - search videos, get transcripts, channel analytics",icon:"play",category:"research",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","youtube-mcp"],configFields:[{key:"YOUTUBE_API_KEY",label:"API Key",type:"password",placeholder:"AIza...",required:!0}],tags:["youtube","video","transcripts","search"],authMethod:"api-key"},{id:"mcp-spotify",name:"Spotify",npmPackage:"spotify-mcp",description:"Spotify - search tracks, manage playlists, playback control",icon:"music",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","spotify-mcp"],configFields:[{key:"SPOTIFY_CLIENT_ID",label:"Client ID",type:"text",placeholder:"",required:!0},{key:"SPOTIFY_CLIENT_SECRET",label:"Client Secret",type:"password",placeholder:"",required:!0}],tags:["spotify","music","playlists","audio"],authMethod:"api-key"},{id:"mcp-figma",name:"Figma",npmPackage:"figma-mcp",description:"Figma - read files, components, styles, export assets",icon:"palette",category:"design",author:"Figma",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","figma-mcp"],configFields:[{key:"FIGMA_ACCESS_TOKEN",label:"Personal Access Token",type:"password",placeholder:"figd_...",required:!0}],website:"https://figma.com",tags:["figma","design","ui","components"]},{id:"mcp-21st-dev",name:"21st.dev Magic",npmPackage:"@21st-dev/magic-mcp",description:"Create crafted UI components inspired by best design engineers",icon:"sparkles",category:"design",author:"21st.dev",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@21st-dev/magic-mcp"],configFields:[{key:"TWENTYFIRST_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],website:"https://21st.dev",tags:["ui","components","design","magic"]},{id:"mcp-cloudinary",name:"Cloudinary",npmPackage:"cloudinary-mcp",description:"Cloudinary - upload, transform, optimize images and videos",icon:"image",category:"design",author:"Cloudinary",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","cloudinary-mcp"],configFields:[{key:"CLOUDINARY_URL",label:"Cloudinary URL",type:"password",placeholder:"cloudinary://api_key:api_secret@cloud_name",required:!0}],tags:["cloudinary","images","media","cdn","transform"],authMethod:"api-key"},{id:"mcp-vault",name:"HashiCorp Vault",npmPackage:"vault-mcp",description:"HashiCorp Vault - secrets management, dynamic credentials",icon:"lock",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","vault-mcp"],configFields:[{key:"VAULT_ADDR",label:"Vault Address",type:"url",placeholder:"http://localhost:8200",required:!0},{key:"VAULT_TOKEN",label:"Token",type:"password",placeholder:"hvs.",required:!0}],tags:["vault","secrets","security","hashicorp"],authMethod:"api-key"},{id:"mcp-1password",name:"1Password",npmPackage:"1password-mcp",description:"1Password - read secrets, vaults, items securely",icon:"lock",category:"data",author:"1Password",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","1password-mcp"],configFields:[{key:"OP_SERVICE_ACCOUNT_TOKEN",label:"Service Account Token",type:"password",placeholder:"ops_...",required:!0}],tags:["1password","secrets","passwords","security"],authMethod:"api-key"},{id:"mcp-snowflake",name:"Snowflake",npmPackage:"snowflake-mcp",description:"Snowflake data warehouse - queries, tables, schemas, warehouses",icon:"database",category:"data",author:"Snowflake",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","snowflake-mcp"],configFields:[{key:"SNOWFLAKE_ACCOUNT",label:"Account",type:"text",placeholder:"org-account",required:!0},{key:"SNOWFLAKE_USER",label:"Username",type:"text",placeholder:"",required:!0},{key:"SNOWFLAKE_PASSWORD",label:"Password",type:"password",placeholder:"",required:!0}],tags:["snowflake","data-warehouse","sql","analytics"],authMethod:"api-key"},{id:"mcp-bigquery",name:"BigQuery",npmPackage:"bigquery-mcp",description:"Google BigQuery - run SQL queries, manage datasets and tables",icon:"database",category:"data",author:"Google",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","bigquery-mcp"],configFields:[{key:"GOOGLE_APPLICATION_CREDENTIALS",label:"Service Account Key Path",type:"text",placeholder:"/path/to/key.json",required:!0},{key:"BIGQUERY_PROJECT_ID",label:"Project ID",type:"text",placeholder:"my-project",required:!0}],tags:["bigquery","sql","analytics","google-cloud"],authMethod:"none"},{id:"mcp-elasticsearch",name:"Elasticsearch",npmPackage:"elasticsearch-mcp",description:"Elasticsearch - search, index, aggregate, analyze data",icon:"search",category:"data",author:"Elastic",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","elasticsearch-mcp"],configFields:[{key:"ELASTICSEARCH_URL",label:"URL",type:"url",placeholder:"http://localhost:9200",required:!0},{key:"ELASTICSEARCH_API_KEY",label:"API Key",type:"password",placeholder:"",required:!1}],tags:["elasticsearch","search","indexing","analytics"],authMethod:"api-key"},{id:"mcp-rabbitmq",name:"RabbitMQ",npmPackage:"rabbitmq-mcp",description:"RabbitMQ - queues, exchanges, publish/consume messages",icon:"send",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","rabbitmq-mcp"],configFields:[{key:"RABBITMQ_URL",label:"Connection URL",type:"password",placeholder:"amqp://user:pass@localhost:5672",required:!0}],tags:["rabbitmq","queue","messaging","amqp"],authMethod:"api-key"},{id:"mcp-kafka",name:"Kafka",npmPackage:"kafka-mcp",description:"Apache Kafka - topics, produce/consume, consumer groups",icon:"send",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","kafka-mcp"],configFields:[{key:"KAFKA_BROKERS",label:"Brokers (comma-separated)",type:"text",placeholder:"localhost:9092",required:!0}],tags:["kafka","streaming","events","queue"],authMethod:"none"},{id:"mcp-plaid",name:"Plaid",npmPackage:"plaid-mcp",description:"Plaid financial data - bank accounts, transactions, balances",icon:"credit-card",category:"data",author:"Plaid",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","plaid-mcp"],configFields:[{key:"PLAID_CLIENT_ID",label:"Client ID",type:"text",placeholder:"",required:!0},{key:"PLAID_SECRET",label:"Secret",type:"password",placeholder:"",required:!0}],website:"https://plaid.com",tags:["plaid","banking","finance","transactions"]},{id:"mcp-quickbooks",name:"QuickBooks",npmPackage:"quickbooks-mcp",description:"QuickBooks - invoices, expenses, customers, reports",icon:"receipt",category:"data",author:"Intuit",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","quickbooks-mcp"],configFields:[{key:"QUICKBOOKS_CLIENT_ID",label:"Client ID",type:"text",placeholder:"",required:!0},{key:"QUICKBOOKS_CLIENT_SECRET",label:"Client Secret",type:"password",placeholder:"",required:!0}],tags:["quickbooks","accounting","invoices","finance"],authMethod:"api-key"},{id:"mcp-xero",name:"Xero",npmPackage:"xero-mcp",description:"Xero accounting - invoices, contacts, bank transactions, reports",icon:"receipt",category:"data",author:"Xero",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","xero-mcp"],configFields:[{key:"XERO_CLIENT_ID",label:"Client ID",type:"text",placeholder:"",required:!0},{key:"XERO_CLIENT_SECRET",label:"Client Secret",type:"password",placeholder:"",required:!0}],tags:["xero","accounting","invoices","finance"],authMethod:"api-key"},{id:"mcp-wordpress",name:"WordPress",npmPackage:"wordpress-mcp",description:"WordPress - posts, pages, media, comments via REST API",icon:"file-text",category:"writing",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","wordpress-mcp"],configFields:[{key:"WORDPRESS_URL",label:"Site URL",type:"url",placeholder:"https://yoursite.com",required:!0},{key:"WORDPRESS_USER",label:"Username",type:"text",placeholder:"",required:!0},{key:"WORDPRESS_APP_PASSWORD",label:"Application Password",type:"password",placeholder:"",required:!0}],tags:["wordpress","cms","blog","content"],authMethod:"api-key"},{id:"mcp-contentful",name:"Contentful",npmPackage:"contentful-mcp",description:"Contentful - content types, entries, assets, spaces",icon:"file-text",category:"writing",author:"Contentful",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","contentful-mcp"],configFields:[{key:"CONTENTFUL_SPACE_ID",label:"Space ID",type:"text",placeholder:"",required:!0},{key:"CONTENTFUL_ACCESS_TOKEN",label:"Access Token",type:"password",placeholder:"",required:!0}],tags:["contentful","cms","headless","content"],authMethod:"api-key"},{id:"mcp-sanity",name:"Sanity",npmPackage:"sanity-mcp",description:"Sanity CMS - documents, GROQ queries, assets, mutations",icon:"file-text",category:"writing",author:"Sanity",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","sanity-mcp"],configFields:[{key:"SANITY_PROJECT_ID",label:"Project ID",type:"text",placeholder:"",required:!0},{key:"SANITY_TOKEN",label:"API Token",type:"password",placeholder:"",required:!0}],tags:["sanity","cms","headless","groq"],authMethod:"api-key"},{id:"mcp-weather",name:"Weather",npmPackage:"weather-mcp",description:"Weather data - current conditions, forecasts, historical data",icon:"cloud",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","weather-mcp"],configFields:[{key:"OPENWEATHER_API_KEY",label:"OpenWeatherMap API Key",type:"password",placeholder:"",required:!0}],tags:["weather","forecast","climate","temperature"],authMethod:"api-key"},{id:"mcp-wolfram",name:"Wolfram Alpha",npmPackage:"wolfram-mcp",description:"Wolfram Alpha computational intelligence - math, science, data",icon:"calculator",category:"research",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","wolfram-mcp"],configFields:[{key:"WOLFRAM_APP_ID",label:"App ID",type:"password",placeholder:"",required:!0}],tags:["wolfram","math","science","computation"],authMethod:"api-key"},{id:"mcp-whois",name:"WHOIS",npmPackage:"whois-mcp",description:"Domain WHOIS lookup - registration, expiry, nameservers",icon:"globe",category:"research",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","whois-mcp"],configFields:[],tags:["whois","domain","dns","lookup"],authMethod:"none"},{id:"mcp-mermaid",name:"Mermaid",npmPackage:"mermaid-mcp",description:"Generate Mermaid diagrams - flowcharts, sequence, gantt, class",icon:"workflow",category:"design",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","mermaid-mcp"],configFields:[],tags:["mermaid","diagrams","flowchart","visualization"],authMethod:"none"},{id:"mcp-screenshot",name:"Screenshot",npmPackage:"screenshot-mcp",description:"Take screenshots of websites - full page, element, viewport",icon:"camera",category:"research",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","screenshot-mcp"],configFields:[],tags:["screenshot","capture","web","image"],authMethod:"none"},{id:"mcp-pdf",name:"PDF Tools",npmPackage:"pdf-mcp",description:"Extract text, tables, and images from PDF documents",icon:"file",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","pdf-mcp"],configFields:[],tags:["pdf","extract","text","documents"],authMethod:"none"},{id:"mcp-csv",name:"CSV Tools",npmPackage:"csv-mcp",description:"Parse, query, transform, and generate CSV/TSV files",icon:"table",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","csv-mcp"],configFields:[],tags:["csv","tsv","data","tables","transform"],authMethod:"none"},{id:"mcp-s3",name:"S3 / Object Storage",npmPackage:"s3-mcp",description:"S3-compatible storage - list, read, write, delete objects",icon:"hard-drive",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","s3-mcp"],configFields:[{key:"S3_ENDPOINT",label:"Endpoint",type:"url",placeholder:"https://s3.amazonaws.com",required:!1},{key:"S3_ACCESS_KEY",label:"Access Key",type:"text",placeholder:"",required:!0},{key:"S3_SECRET_KEY",label:"Secret Key",type:"password",placeholder:"",required:!0},{key:"S3_BUCKET",label:"Bucket Name",type:"text",placeholder:"my-bucket",required:!0}],tags:["s3","storage","objects","bucket"],authMethod:"api-key"},{id:"mcp-ssh",name:"SSH",npmPackage:"ssh-mcp",description:"Execute commands on remote servers via SSH",icon:"terminal",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","ssh-mcp"],configFields:[{key:"SSH_HOST",label:"Host",type:"text",placeholder:"192.168.1.100",required:!0},{key:"SSH_USER",label:"Username",type:"text",placeholder:"root",required:!0},{key:"SSH_KEY_PATH",label:"Private Key Path",type:"text",placeholder:"~/.ssh/id_rsa",required:!1}],tags:["ssh","remote","terminal","server"],authMethod:"none"},{id:"mcp-terraform",name:"Terraform",npmPackage:"terraform-mcp",description:"Terraform - plan, apply, state, modules, resources",icon:"server",category:"coding",author:"HashiCorp",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","terraform-mcp"],configFields:[],tags:["terraform","iac","infrastructure","devops"],authMethod:"none"},{id:"mcp-prometheus",name:"Prometheus",npmPackage:"prometheus-mcp",description:"Prometheus - PromQL queries, metrics, alerts, targets",icon:"bar-chart",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","prometheus-mcp"],configFields:[{key:"PROMETHEUS_URL",label:"URL",type:"url",placeholder:"http://localhost:9090",required:!0}],tags:["prometheus","metrics","monitoring","promql"],authMethod:"none"},{id:"mcp-intercom",name:"Intercom",npmPackage:"intercom-mcp",description:"Intercom - conversations, contacts, companies, articles",icon:"message-circle",category:"data",author:"Intercom",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","intercom-mcp"],configFields:[{key:"INTERCOM_TOKEN",label:"Access Token",type:"password",placeholder:"",required:!0}],tags:["intercom","support","chat","crm"],authMethod:"api-key"},{id:"mcp-zendesk",name:"Zendesk",npmPackage:"zendesk-mcp",description:"Zendesk - tickets, users, organizations, search",icon:"headphones",category:"data",author:"Zendesk",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","zendesk-mcp"],configFields:[{key:"ZENDESK_SUBDOMAIN",label:"Subdomain",type:"text",placeholder:"your-org",required:!0},{key:"ZENDESK_EMAIL",label:"Email",type:"text",placeholder:"agent@company.com",required:!0},{key:"ZENDESK_TOKEN",label:"API Token",type:"password",placeholder:"",required:!0}],tags:["zendesk","support","tickets","helpdesk"],authMethod:"api-key"},{id:"mcp-freshdesk",name:"Freshdesk",npmPackage:"freshdesk-mcp",description:"Freshdesk - tickets, contacts, groups, canned responses",icon:"headphones",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","freshdesk-mcp"],configFields:[{key:"FRESHDESK_DOMAIN",label:"Domain",type:"text",placeholder:"your-org.freshdesk.com",required:!0},{key:"FRESHDESK_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],tags:["freshdesk","support","tickets","helpdesk"],authMethod:"api-key"},{id:"mcp-clickup",name:"ClickUp",npmPackage:"clickup-mcp",description:"ClickUp - tasks, lists, spaces, goals, docs, time tracking",icon:"check-square",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","clickup-mcp"],configFields:[{key:"CLICKUP_TOKEN",label:"Personal API Token",type:"password",placeholder:"pk_...",required:!0}],tags:["clickup","tasks","project-management","productivity"],authMethod:"api-key"},{id:"mcp-trello",name:"Trello",npmPackage:"trello-mcp",description:"Trello - boards, lists, cards, checklists, members",icon:"layout",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","trello-mcp"],configFields:[{key:"TRELLO_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0},{key:"TRELLO_TOKEN",label:"Token",type:"password",placeholder:"",required:!0}],tags:["trello","boards","kanban","cards"],authMethod:"api-key"},{id:"mcp-monday",name:"Monday.com",npmPackage:"monday-mcp",description:"Monday.com - boards, items, columns, updates, automations",icon:"layout",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","monday-mcp"],configFields:[{key:"MONDAY_API_TOKEN",label:"API Token",type:"password",placeholder:"",required:!0}],tags:["monday","boards","project-management","workflow"],authMethod:"api-key"},{id:"mcp-github-actions",name:"GitHub Actions",npmPackage:"github-actions-mcp",description:"GitHub Actions - workflows, runs, jobs, artifacts, secrets",icon:"play-circle",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","github-actions-mcp"],configFields:[{key:"GITHUB_TOKEN",label:"Personal Access Token",type:"password",placeholder:"ghp_...",required:!0}],tags:["github-actions","ci-cd","workflows","automation"],authMethod:"api-key"},{id:"mcp-circleci",name:"CircleCI",npmPackage:"circleci-mcp",description:"CircleCI - pipelines, jobs, workflows, orbs, insights",icon:"play-circle",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","circleci-mcp"],configFields:[{key:"CIRCLECI_TOKEN",label:"Personal API Token",type:"password",placeholder:"",required:!0}],tags:["circleci","ci-cd","pipelines","automation"],authMethod:"api-key"},{id:"mcp-upstash",name:"Upstash",npmPackage:"@upstash/mcp-server",description:"Upstash - serverless Redis and Kafka, QStash message queue",icon:"database",category:"data",author:"Upstash",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@upstash/mcp-server"],configFields:[{key:"UPSTASH_REDIS_REST_URL",label:"Redis REST URL",type:"url",placeholder:"",required:!0},{key:"UPSTASH_REDIS_REST_TOKEN",label:"Redis REST Token",type:"password",placeholder:"",required:!0}],website:"https://upstash.com",tags:["upstash","redis","kafka","serverless"]},{id:"mcp-sendgrid",name:"SendGrid",npmPackage:"sendgrid-mcp",description:"SendGrid - send transactional emails, manage templates, contacts",icon:"mail",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","sendgrid-mcp"],configFields:[{key:"SENDGRID_API_KEY",label:"API Key",type:"password",placeholder:"SG.",required:!0}],tags:["sendgrid","email","transactional","templates"],authMethod:"api-key"},{id:"mcp-resend",name:"Resend",npmPackage:"resend-mcp",description:"Resend - send emails with React Email templates",icon:"mail",category:"data",author:"Resend",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","resend-mcp"],configFields:[{key:"RESEND_API_KEY",label:"API Key",type:"password",placeholder:"re_...",required:!0}],website:"https://resend.com",tags:["resend","email","react-email","transactional"]},{id:"mcp-openapi",name:"OpenAPI",npmPackage:"openapi-mcp",description:"Load any OpenAPI/Swagger spec and call its endpoints as MCP tools",icon:"globe",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","openapi-mcp"],configFields:[{key:"OPENAPI_SPEC_URL",label:"Spec URL",type:"url",placeholder:"https://api.example.com/openapi.json",required:!0}],tags:["openapi","swagger","rest","api"],authMethod:"none"},{id:"mcp-graphql",name:"GraphQL",npmPackage:"graphql-mcp",description:"Query any GraphQL endpoint - introspection, queries, mutations",icon:"globe",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","graphql-mcp"],configFields:[{key:"GRAPHQL_URL",label:"Endpoint URL",type:"url",placeholder:"https://api.example.com/graphql",required:!0},{key:"GRAPHQL_AUTH_HEADER",label:"Auth Header Value",type:"password",placeholder:"Bearer ...",required:!1}],tags:["graphql","api","query","mutation"],authMethod:"api-key"},{id:"mcp-coda",name:"Coda",npmPackage:"coda-mcp",description:"Coda docs - tables, rows, formulas, pages, automations",icon:"file-text",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","coda-mcp"],configFields:[{key:"CODA_API_TOKEN",label:"API Token",type:"password",placeholder:"",required:!0}],tags:["coda","docs","tables","automation"],authMethod:"api-key"},{id:"mcp-segment",name:"Segment",npmPackage:"segment-mcp",description:"Segment - track events, identify users, manage sources & destinations",icon:"bar-chart",category:"data",author:"Twilio",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","segment-mcp"],configFields:[{key:"SEGMENT_WRITE_KEY",label:"Write Key",type:"password",placeholder:"",required:!0}],tags:["segment","analytics","events","cdp"],authMethod:"api-key"},{id:"mcp-amplitude",name:"Amplitude",npmPackage:"amplitude-mcp",description:"Amplitude - events, user analytics, cohorts, retention",icon:"bar-chart",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","amplitude-mcp"],configFields:[{key:"AMPLITUDE_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0},{key:"AMPLITUDE_SECRET_KEY",label:"Secret Key",type:"password",placeholder:"",required:!0}],tags:["amplitude","analytics","events","product"],authMethod:"api-key"},{id:"mcp-context7",name:"Context7",npmPackage:"@upstash/context7-mcp",description:"Pull up-to-date library documentation and code examples on demand",icon:"book-open",category:"domain",author:"Upstash",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@upstash/context7-mcp"],configFields:[],tags:["docs","documentation","libraries","context"],authMethod:"none"},{id:"mcp-aws-kb-retrieval",name:"AWS KB Retrieval",npmPackage:"@modelcontextprotocol/server-aws-kb-retrieval",description:"Retrieve from AWS Bedrock Knowledge Bases using RAG",icon:"database",category:"domain",author:"MCP Official",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-aws-kb-retrieval"],configFields:[{key:"AWS_ACCESS_KEY_ID",label:"Access Key ID",type:"text",placeholder:"AKIA...",required:!0},{key:"AWS_SECRET_ACCESS_KEY",label:"Secret Access Key",type:"password",placeholder:"",required:!0},{key:"AWS_REGION",label:"Region",type:"text",placeholder:"us-east-1",required:!0}],repo:"https://github.com/modelcontextprotocol/servers",tags:["aws","bedrock","rag","knowledge-base"]},{id:"mcp-everart",name:"EverArt",npmPackage:"@modelcontextprotocol/server-everart",description:"AI image generation with multiple models via EverArt platform",icon:"image",category:"design",author:"MCP Official",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-everart"],configFields:[{key:"EVERART_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],repo:"https://github.com/modelcontextprotocol/servers",tags:["image","generation","ai-art","design"]},{id:"mcp-greptile",name:"Greptile",npmPackage:"@greptile/mcp-server",description:"AI-powered codebase search and understanding",icon:"search",category:"coding",author:"Greptile",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@greptile/mcp-server"],configFields:[{key:"GREPTILE_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],website:"https://greptile.com",tags:["code-search","codebase","ai","understanding"]},{id:"mcp-e2b",name:"E2B Code Interpreter",npmPackage:"@e2b/mcp-server",description:"Sandboxed code execution - run Python, JS, and more in secure cloud sandbox",icon:"terminal",category:"coding",author:"E2B",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@e2b/mcp-server"],configFields:[{key:"E2B_API_KEY",label:"API Key",type:"password",placeholder:"e2b_...",required:!0}],website:"https://e2b.dev",tags:["sandbox","code-execution","interpreter","python"]},{id:"mcp-hubspot-dev",name:"HubSpot Developer",npmPackage:"@hubspot/mcp-server",description:"HubSpot developer tools - CMS, projects, functions, deploy",icon:"hexagon",category:"domain",author:"HubSpot",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@hubspot/mcp-server"],configFields:[{key:"HUBSPOT_PORTAL_ID",label:"Portal ID",type:"text",placeholder:"",required:!0}],website:"https://developers.hubspot.com",tags:["hubspot","cms","developer","deploy"]},{id:"mcp-medical-ref",name:"Medical Reference",npmPackage:"medical-ref-mcp",description:"Medical terminology, drug interactions, clinical guidelines lookup",icon:"heart",category:"domain",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","medical-ref-mcp"],configFields:[],tags:["medical","healthcare","drugs","clinical"],authMethod:"none"},{id:"mcp-legal",name:"Legal Research",npmPackage:"legal-mcp",description:"Legal document search - case law, statutes, regulations",icon:"scale",category:"domain",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","legal-mcp"],configFields:[],tags:["legal","law","case-law","regulations"],authMethod:"none"}],vc=[{id:"web-search",name:"Web Search",description:"Search the web using Brave Search API for real-time information retrieval",icon:"search",category:"research",author:"Anthropic",installs:12400,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install web-search",installed:!1},{id:"github",name:"GitHub",description:"GitHub operations — repos, issues, PRs, and code search via gh CLI",icon:"git-branch",category:"coding",author:"Anthropic",installs:9800,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install github",installed:!1},{id:"weather",name:"Weather",description:"Weather data from wttr.in and Open-Meteo for forecasts and conditions",icon:"cloud",category:"data",author:"Community",installs:4200,runtimes:["claude","amp"],installCmd:"npx modular-skills install weather",installed:!1},{id:"coding-agent",name:"Coding Agent",description:"Delegate complex coding tasks to Claude Code or Codex sub-agents",icon:"code",category:"coding",author:"Anthropic",installs:18200,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install coding-agent",installed:!0,installedTarget:"claude",installedScope:"project"},{id:"openai-whisper",name:"OpenAI Whisper",description:"Transcribe audio files to text using OpenAI Whisper API",icon:"mic",category:"data",author:"OpenAI",installs:6700,runtimes:["claude","amp","codex","openai"],installCmd:"npx modular-skills install openai-whisper",installed:!1},{id:"openai-image-gen",name:"Image Generation",description:"Generate images from text prompts using DALL-E or Stable Diffusion",icon:"image",category:"design",author:"OpenAI",installs:8900,runtimes:["claude","amp","openai"],installCmd:"npx modular-skills install openai-image-gen",installed:!1},{id:"notion-api",name:"Notion API",description:"Full Notion integration — read, create, update pages and databases",icon:"book-open",category:"writing",author:"Notion",installs:7300,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install notion-api",installed:!1},{id:"hubspot-integration",name:"HubSpot CRM",description:"HubSpot CRM operations — contacts, companies, deals, and pipelines",icon:"hexagon",category:"data",author:"HubSpot",installs:3100,runtimes:["claude","amp"],installCmd:"npx modular-skills install hubspot-integration",installed:!1},{id:"n8n-workflow-patterns",name:"n8n Workflows",description:"Build and manage n8n automation workflows with proven patterns",icon:"workflow",category:"coding",author:"n8n",installs:2800,runtimes:["claude","amp"],installCmd:"npx modular-skills install n8n-workflow-patterns",installed:!1},{id:"maritime-expert",name:"Maritime Expert",description:"Maritime domain expertise — vessel tracking, port ops, cargo management",icon:"anchor",category:"domain",author:"Nimbalyst",installs:1200,runtimes:["claude","amp"],installCmd:"npx modular-skills install maritime-expert",installed:!0,installedTarget:"claude",installedScope:"project"},{id:"feedback-analyzer",name:"Feedback Analyzer",description:"Extract insights from customer feedback — patterns, sentiment, priorities",icon:"bar-chart-3",category:"research",author:"Nimbalyst",installs:2400,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install feedback-analyzer",installed:!0,installedTarget:"all",installedScope:"global"},{id:"roadmap-builder",name:"Roadmap Builder",description:"Create strategic product roadmaps with OKRs and stakeholder alignment",icon:"map",category:"writing",author:"Community",installs:1800,runtimes:["claude","amp"],installCmd:"npx modular-skills install roadmap-builder",installed:!1},{id:"presentation-generator",name:"Presentation Gen",description:"Generate interactive HTML presentations with animations and styling",icon:"presentation",category:"design",author:"Community",installs:3600,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install presentation-generator",installed:!0,installedTarget:"claude",installedScope:"project"},{id:"clean-code",name:"Clean Code",description:"Pragmatic coding standards — concise, direct, no over-engineering",icon:"sparkles",category:"coding",author:"Community",installs:5400,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install clean-code",installed:!1},{id:"html-style",name:"HTML Style",description:"Apply opinionated styling to unstyled HTML with a cohesive design system",icon:"palette",category:"design",author:"Community",installs:2100,runtimes:["claude","amp"],installCmd:"npx modular-skills install html-style",installed:!1},{id:"find-skills",name:"Find Skills",description:"Meta-skill that discovers and recommends other skills for your task",icon:"compass",category:"research",author:"Anthropic",installs:4800,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install find-skills",installed:!1},{id:"fluidsim",name:"FluidSim",description:"Computational fluid dynamics — Navier-Stokes, shallow water, turbulence",icon:"waves",category:"domain",author:"SciPy",installs:800,runtimes:["claude"],installCmd:"npx modular-skills install fluidsim",installed:!1},{id:"threejs-fundamentals",name:"Three.js",description:"Three.js 3D graphics — scene setup, cameras, lighting, animation",icon:"box",category:"coding",author:"Community",installs:3200,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install threejs-fundamentals",installed:!1},{id:"web-design-guidelines",name:"Web Design Review",description:"Review UI code against Web Interface Guidelines for best practices",icon:"layout",category:"design",author:"Community",installs:2900,runtimes:["claude","amp"],installCmd:"npx modular-skills install web-design-guidelines",installed:!1},{id:"skill-creator",name:"Skill Creator",description:"Build and package new skills with proper manifests and adapters",icon:"wrench",category:"coding",author:"Anthropic",installs:1500,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install skill-creator",installed:!1},{id:"vercel-react",name:"Vercel React",description:"React and Next.js performance optimization patterns from Vercel Engineering",icon:"triangle",category:"coding",author:"Vercel",installs:7100,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install vercel-react",installed:!1},{id:"claude-platform",name:"Claude Platform",description:"Build apps with Claude API — SDK patterns, tool use, streaming",icon:"cpu",category:"coding",author:"Anthropic",installs:11200,runtimes:["claude"],installCmd:"npx modular-skills install claude-platform",installed:!1}];function TS(e){return{id:e.id,name:e.name,description:e.description,icon:e.icon,category:e.category,author:e.author,transport:e.transport,runtimes:e.runtimes,installCmd:`npx -y ${e.npmPackage}`,command:e.command,defaultArgs:e.defaultArgs,configFields:e.configFields,installed:!1,configured:!1}}const NS=Ta.map(TS),AS=[{id:"preset-fullstack-dev",name:"Full-Stack Developer",description:"Complete dev setup with GitHub, filesystem, coding agent, and clean code standards",icon:"code",skills:["coding-agent","clean-code","github","threejs-fundamentals"],mcpServers:["mcp-github","mcp-filesystem","mcp-linear"],canvasDescription:"Knowledge → Agent (Claude Opus) → Code Output | Skills: Coding Agent, Clean Code, GitHub | MCP: GitHub, Filesystem, Linear"},{id:"preset-research-analyst",name:"Research Analyst",description:"Web search, scraping, and analysis tools for deep research",icon:"search",skills:["web-search","feedback-analyzer","find-skills"],mcpServers:["mcp-brave-search","mcp-firecrawl","mcp-puppeteer"],canvasDescription:"Web Sources → Agent (Claude Opus) → Markdown Report | Skills: Web Search, Feedback Analyzer | MCP: Brave, Firecrawl, Puppeteer"},{id:"preset-content-writer",name:"Content Writer",description:"Writing-focused setup with Notion, presentation gen, and design review",icon:"pen-tool",skills:["presentation-generator","html-style","web-design-guidelines","notion-api"],mcpServers:["mcp-notion","mcp-slack"],canvasDescription:"Notion Pages → Agent (Claude Sonnet) → HTML/Markdown | Skills: Presentation Gen, HTML Style | MCP: Notion, Slack"},{id:"preset-data-pipeline",name:"Data Pipeline",description:"Database, API, and CRM integrations for data workflows",icon:"database",skills:["hubspot-integration","n8n-workflow-patterns","weather"],mcpServers:["mcp-postgres","mcp-supabase","mcp-hubspot"],canvasDescription:"CRM + DB → Agent (Claude Sonnet) → JSON/CSV | Skills: HubSpot, n8n Workflows | MCP: PostgreSQL, Supabase, HubSpot"},{id:"preset-maritime-ops",name:"Maritime Operations",description:"Maritime domain with vessel tracking, weather data, and fleet management",icon:"anchor",skills:["maritime-expert","weather","feedback-analyzer"],mcpServers:["mcp-slack","mcp-notion"],canvasDescription:"Maritime Knowledge → Agent (Claude Opus) → Reports | Skills: Maritime Expert, Weather | MCP: Slack, Notion"},{id:"preset-design-system",name:"Design System",description:"Design-focused setup with visual review, styling, and presentation tools",icon:"palette",skills:["web-design-guidelines","html-style","presentation-generator","openai-image-gen"],mcpServers:["mcp-puppeteer"],canvasDescription:"Design Specs → Agent (Claude Sonnet) → HTML/CSS | Skills: Web Design, HTML Style, Image Gen | MCP: Puppeteer"},{id:"preset-senior-pm",name:"Senior PM",description:"Discovery synthesis specialist — turns messy brainstorms into prioritized product strategy with RICE framework",icon:"user",skills:["feedback-analyzer","roadmap-builder"],mcpServers:["mcp-notion","mcp-slack"],canvasDescription:"Knowledge + Signals → Agent (Claude Opus) → Synthesis Report | Skills: Feedback Analyzer, Roadmap Builder | MCP: Notion, Slack"},{id:"preset-feedback-manager",name:"Feedback Manager",description:"Feedback lifecycle specialist — organizes, challenges, and maintains the single source of truth for user feedback",icon:"inbox",skills:["feedback-analyzer"],mcpServers:["mcp-gmail","mcp-notion","mcp-slack"],canvasDescription:"Gmail + Signals → Agent (Claude Sonnet) → Feedback Reports | Skills: Feedback Analyzer | MCP: Gmail, Notion, Slack"},{id:"preset-competitor-scraper",name:"Competitor Feature Scraper",description:"Scrapes competitor websites to extract product features, claims, and screenshots for competitive comparison",icon:"search",skills:["web-search"],mcpServers:["mcp-firecrawl"],canvasDescription:"Competitor Knowledge → Agent (Claude Sonnet) → Feature Profiles | Skills: Web Search | MCP: Firecrawl"}],kc={claude:{label:"Claude",color:"#FE5000"},amp:{label:"Amp",color:"#8B5CF6"},codex:{label:"Codex",color:"#10B981"},openai:{label:"OpenAI",color:"#74AA9C"},gemini:{label:"Gemini",color:"#4285F4"}},k0=[{id:"all",label:"All"},{id:"research",label:"Research"},{id:"coding",label:"Coding"},{id:"data",label:"Data"},{id:"design",label:"Design"},{id:"writing",label:"Writing"},{id:"domain",label:"Domain"}],Ee="/api";async function cb(e,n){const a=new TextDecoder;let s="";for(;;){const{done:i,value:l}=await e.read();if(i)break;s+=a.decode(l,{stream:!0});const c=s.split(`
10
+ `);s=c.pop()??"";for(const p of c){const f=p.trim();if(!f||!f.startsWith("data: "))continue;const m=f.slice(6);if(m==="[DONE]"||n(m))return}}}function ub(e){const{prompt:n,model:a,systemPrompt:s,maxTurns:i,onChunk:l,onDone:c,onError:p}=e,f=new AbortController;return fetch(`${Ee}/agent-sdk/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:n,model:a,systemPrompt:s,maxTurns:i}),signal:f.signal}).then(async m=>{if(!m.ok){const x=await m.text().catch(()=>"");throw new Error(`Agent SDK error ${m.status}: ${x||m.statusText}`)}const g=m.body?.getReader();if(!g)throw new Error("No response body");await cb(g,x=>{try{const b=JSON.parse(x);if(b.type==="text"&&b.content)l(b.content);else if(b.type==="error")return p(new Error(b.message)),!0}catch{}}),c()}).catch(m=>{m instanceof DOMException&&m.name==="AbortError"||p(m instanceof Error?m:new Error(String(m)))}),f}function db(e){const{providerId:n,model:a,messages:s,temperature:i=.7,maxTokens:l=4096,onChunk:c,onDone:p,onError:f}=e,m=new AbortController;return fetch(`${Ee}/llm/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:n,model:a,messages:s,temperature:i,max_tokens:l}),signal:m.signal}).then(async g=>{if(!g.ok){const b=await g.text().catch(()=>"");throw new Error(`LLM error ${g.status}: ${b||g.statusText}`)}const x=g.body?.getReader();if(!x)throw new Error("No response body");await cb(x,b=>{try{const v=JSON.parse(b);v.type==="content_block_delta"&&v.delta?.text?c(v.delta.text):v.choices?.[0]?.delta?.content&&c(v.choices[0].delta.content)}catch{}}),p()}).catch(g=>{g instanceof DOMException&&g.name==="AbortError"||f(g instanceof Error?g:new Error(String(g)))}),m}async function Kc(e){const{providerId:n,model:a,messages:s,temperature:i=.3,maxTokens:l=2048}=e,c=await fetch(`${Ee}/llm/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:n,model:a,messages:s,temperature:i,maxTokens:l})});if(!c.ok){const m=await c.text().catch(()=>"");throw new Error(`LLM error ${c.status}: ${m||c.statusText}`)}const p=await c.text(),f=[];for(const m of p.split(`
11
+ `)){if(!m.startsWith("data: "))continue;const g=m.slice(6).trim();if(g==="[DONE]")break;try{const x=JSON.parse(g);x.type==="content_block_delta"&&x.delta?.text?f.push(x.delta.text):x.choices?.[0]?.delta?.content?f.push(x.choices[0].delta.content):x.type==="text"&&x.content&&f.push(x.content)}catch{}}return f.join("").trim()}async function Yc(e){const n=await fetch(`${Ee}/agent-sdk/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const i=await n.text().catch(()=>"");throw new Error(`Agent SDK error ${n.status}: ${i||n.statusText}`)}const a=await n.text(),s=[];for(const i of a.split(`
12
+ `)){if(!i.startsWith("data: "))continue;const l=i.slice(6).trim();if(l==="[DONE]")break;try{const c=JSON.parse(l);c.type==="text"&&c.content&&s.push(c.content)}catch{}}return s.join("").trim()}const qo=`${Ee}/mcp`;async function lo(e,n){try{const a=await fetch(e,{...n,headers:{"Content-Type":"application/json",...n?.headers}});if(!a.ok)return null;const s=await a.json();return s?.data??s}catch{return null}}const at=qt((e,n)=>({servers:[],loaded:!1,loading:!1,error:void 0,loadServers:async()=>{if(n().loading||n().loaded)return;e({loading:!0,error:void 0});const a=await lo(qo),s=await lo(`${Ee}/claude-config/mcp`);if(!a&&!s){e({servers:[],loaded:!0,loading:!1,error:"Backend unavailable. Start the server with `npm run server` on port 4800."});return}const i=a??[],l=s??[],c=new Set(i.map(f=>f.id)),p=[...i,...l.filter(f=>!c.has(f.id)).map(f=>({id:f.id,name:f.name,type:f.type,command:f.command??"",args:f.args??[],env:f.env??{},url:f.url,headers:f.headers,status:(f.status==="enabled"||f.status==="deferred","disconnected"),tools:[],mcpStatus:f.status}))];e({servers:p,loaded:!0,loading:!1}),await n().syncFromConfig()},syncFromConfig:async()=>{const{useConsoleStore:a}=await ea(async()=>{const{useConsoleStore:c}=await Promise.resolve().then(()=>Ev);return{useConsoleStore:c}},void 0),s=a.getState().mcpServers,i=n().servers,l=new Set(i.map(c=>c.id));for(const c of s)c.added&&!l.has(c.id)&&await n().addServer({id:c.id,name:c.name,command:"",args:[],env:{}})},addServer:async a=>{const s=n().servers.find(l=>l.id===a.id);if(s)return s;const i=await lo(qo,{method:"POST",body:JSON.stringify(a)});return i&&e({servers:[...n().servers,i]}),i},updateServer:async(a,s)=>{const i=await lo(`${qo}/${a}`,{method:"PUT",body:JSON.stringify(s)});return i&&e({servers:n().servers.map(l=>l.id===a?{...l,...i}:l)}),i},connectServer:async a=>{e({servers:n().servers.map(i=>i.id===a?{...i,status:"connecting"}:i)});const s=await lo(`${qo}/${a}/connect`,{method:"POST"});e({servers:n().servers.map(i=>i.id===a?{...i,status:s?.status??"error",tools:s?.tools??[],lastError:s?void 0:"Connection failed"}:i)})},disconnectServer:async a=>{await lo(`${qo}/${a}/disconnect`,{method:"POST"}),e({servers:n().servers.map(s=>s.id===a?{...s,status:"disconnected",tools:[]}:s)})},removeServer:async a=>{await lo(`${qo}/${a}`,{method:"DELETE"}),e({servers:n().servers.filter(s=>s.id!==a)})},callTool:async(a,s,i)=>(await lo(`${qo}/${a}/call`,{method:"POST",body:JSON.stringify({toolName:s,arguments:i})}))?.result??null,refreshHealth:async a=>{const s=await lo(`${qo}/${a}/health`);s&&e({servers:n().servers.map(i=>i.id===a?{...i,status:s.status,tools:s.tools,uptime:s.uptime,lastError:s.lastError}:i)})},getConnectedTools:()=>n().servers.filter(a=>a.status==="connected").flatMap(a=>a.tools)}));let Jr=null;function _S(){Jr||(Jr=setInterval(()=>{const{servers:e,refreshHealth:n}=at.getState();for(const a of e)a.status==="connected"&&n(a.id)},3e4))}function DS(){Jr&&(clearInterval(Jr),Jr=null)}const zS=Object.freeze(Object.defineProperty({__proto__:null,startHealthPolling:_S,stopHealthPolling:DS,useMcpStore:at},Symbol.toStringTag,{value:"Module"}));function pt(e){if(typeof e=="string"||typeof e=="number")return""+e;let n="";if(Array.isArray(e))for(let a=0,s;a<e.length;a++)(s=pt(e[a]))!==""&&(n+=(n&&" ")+s);else for(let a in e)e[a]&&(n+=(n&&" ")+a);return n}var RS={value:()=>{}};function Vc(){for(var e=0,n=arguments.length,a={},s;e<n;++e){if(!(s=arguments[e]+"")||s in a||/[\s.]/.test(s))throw new Error("illegal type: "+s);a[s]=[]}return new wc(a)}function wc(e){this._=e}function $S(e,n){return e.trim().split(/^|\s+/).map(function(a){var s="",i=a.indexOf(".");if(i>=0&&(s=a.slice(i+1),a=a.slice(0,i)),a&&!n.hasOwnProperty(a))throw new Error("unknown type: "+a);return{type:a,name:s}})}wc.prototype=Vc.prototype={constructor:wc,on:function(e,n){var a=this._,s=$S(e+"",a),i,l=-1,c=s.length;if(arguments.length<2){for(;++l<c;)if((i=(e=s[l]).type)&&(i=OS(a[i],e.name)))return i;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++l<c;)if(i=(e=s[l]).type)a[i]=w0(a[i],e.name,n);else if(n==null)for(i in a)a[i]=w0(a[i],e.name,null);return this},copy:function(){var e={},n=this._;for(var a in n)e[a]=n[a].slice();return new wc(e)},call:function(e,n){if((i=arguments.length-2)>0)for(var a=new Array(i),s=0,i,l;s<i;++s)a[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(l=this._[e],s=0,i=l.length;s<i;++s)l[s].value.apply(n,a)},apply:function(e,n,a){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],i=0,l=s.length;i<l;++i)s[i].value.apply(n,a)}};function OS(e,n){for(var a=0,s=e.length,i;a<s;++a)if((i=e[a]).name===n)return i.value}function w0(e,n,a){for(var s=0,i=e.length;s<i;++s)if(e[s].name===n){e[s]=RS,e=e.slice(0,s).concat(e.slice(s+1));break}return a!=null&&e.push({name:n,value:a}),e}var xf="http://www.w3.org/1999/xhtml";const S0={svg:"http://www.w3.org/2000/svg",xhtml:xf,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Wc(e){var n=e+="",a=n.indexOf(":");return a>=0&&(n=e.slice(0,a))!=="xmlns"&&(e=e.slice(a+1)),S0.hasOwnProperty(n)?{space:S0[n],local:e}:e}function FS(e){return function(){var n=this.ownerDocument,a=this.namespaceURI;return a===xf&&n.documentElement.namespaceURI===xf?n.createElement(e):n.createElementNS(a,e)}}function IS(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function pb(e){var n=Wc(e);return(n.local?IS:FS)(n)}function LS(){}function Pf(e){return e==null?LS:function(){return this.querySelector(e)}}function BS(e){typeof e!="function"&&(e=Pf(e));for(var n=this._groups,a=n.length,s=new Array(a),i=0;i<a;++i)for(var l=n[i],c=l.length,p=s[i]=new Array(c),f,m,g=0;g<c;++g)(f=l[g])&&(m=e.call(f,f.__data__,g,l))&&("__data__"in f&&(m.__data__=f.__data__),p[g]=m);return new en(s,this._parents)}function PS(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function HS(){return[]}function fb(e){return e==null?HS:function(){return this.querySelectorAll(e)}}function US(e){return function(){return PS(e.apply(this,arguments))}}function GS(e){typeof e=="function"?e=US(e):e=fb(e);for(var n=this._groups,a=n.length,s=[],i=[],l=0;l<a;++l)for(var c=n[l],p=c.length,f,m=0;m<p;++m)(f=c[m])&&(s.push(e.call(f,f.__data__,m,c)),i.push(f));return new en(s,i)}function mb(e){return function(){return this.matches(e)}}function hb(e){return function(n){return n.matches(e)}}var qS=Array.prototype.find;function KS(e){return function(){return qS.call(this.children,e)}}function YS(){return this.firstElementChild}function VS(e){return this.select(e==null?YS:KS(typeof e=="function"?e:hb(e)))}var WS=Array.prototype.filter;function XS(){return Array.from(this.children)}function ZS(e){return function(){return WS.call(this.children,e)}}function QS(e){return this.selectAll(e==null?XS:ZS(typeof e=="function"?e:hb(e)))}function JS(e){typeof e!="function"&&(e=mb(e));for(var n=this._groups,a=n.length,s=new Array(a),i=0;i<a;++i)for(var l=n[i],c=l.length,p=s[i]=[],f,m=0;m<c;++m)(f=l[m])&&e.call(f,f.__data__,m,l)&&p.push(f);return new en(s,this._parents)}function gb(e){return new Array(e.length)}function e2(){return new en(this._enter||this._groups.map(gb),this._parents)}function Ac(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}Ac.prototype={constructor:Ac,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,n){return this._parent.insertBefore(e,n)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function t2(e){return function(){return e}}function n2(e,n,a,s,i,l){for(var c=0,p,f=n.length,m=l.length;c<m;++c)(p=n[c])?(p.__data__=l[c],s[c]=p):a[c]=new Ac(e,l[c]);for(;c<f;++c)(p=n[c])&&(i[c]=p)}function o2(e,n,a,s,i,l,c){var p,f,m=new Map,g=n.length,x=l.length,b=new Array(g),v;for(p=0;p<g;++p)(f=n[p])&&(b[p]=v=c.call(f,f.__data__,p,n)+"",m.has(v)?i[p]=f:m.set(v,f));for(p=0;p<x;++p)v=c.call(e,l[p],p,l)+"",(f=m.get(v))?(s[p]=f,f.__data__=l[p],m.delete(v)):a[p]=new Ac(e,l[p]);for(p=0;p<g;++p)(f=n[p])&&m.get(b[p])===f&&(i[p]=f)}function a2(e){return e.__data__}function s2(e,n){if(!arguments.length)return Array.from(this,a2);var a=n?o2:n2,s=this._parents,i=this._groups;typeof e!="function"&&(e=t2(e));for(var l=i.length,c=new Array(l),p=new Array(l),f=new Array(l),m=0;m<l;++m){var g=s[m],x=i[m],b=x.length,v=r2(e.call(g,g&&g.__data__,m,s)),k=v.length,w=p[m]=new Array(k),C=c[m]=new Array(k),M=f[m]=new Array(b);a(g,x,w,C,M,v,n);for(var N=0,S=0,E,I;N<k;++N)if(E=w[N]){for(N>=S&&(S=N+1);!(I=C[S])&&++S<k;);E._next=I||null}}return c=new en(c,s),c._enter=p,c._exit=f,c}function r2(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function i2(){return new en(this._exit||this._groups.map(gb),this._parents)}function l2(e,n,a){var s=this.enter(),i=this,l=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),n!=null&&(i=n(i),i&&(i=i.selection())),a==null?l.remove():a(l),s&&i?s.merge(i).order():i}function c2(e){for(var n=e.selection?e.selection():e,a=this._groups,s=n._groups,i=a.length,l=s.length,c=Math.min(i,l),p=new Array(i),f=0;f<c;++f)for(var m=a[f],g=s[f],x=m.length,b=p[f]=new Array(x),v,k=0;k<x;++k)(v=m[k]||g[k])&&(b[k]=v);for(;f<i;++f)p[f]=a[f];return new en(p,this._parents)}function u2(){for(var e=this._groups,n=-1,a=e.length;++n<a;)for(var s=e[n],i=s.length-1,l=s[i],c;--i>=0;)(c=s[i])&&(l&&c.compareDocumentPosition(l)^4&&l.parentNode.insertBefore(c,l),l=c);return this}function d2(e){e||(e=p2);function n(x,b){return x&&b?e(x.__data__,b.__data__):!x-!b}for(var a=this._groups,s=a.length,i=new Array(s),l=0;l<s;++l){for(var c=a[l],p=c.length,f=i[l]=new Array(p),m,g=0;g<p;++g)(m=c[g])&&(f[g]=m);f.sort(n)}return new en(i,this._parents).order()}function p2(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function f2(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function m2(){return Array.from(this)}function h2(){for(var e=this._groups,n=0,a=e.length;n<a;++n)for(var s=e[n],i=0,l=s.length;i<l;++i){var c=s[i];if(c)return c}return null}function g2(){let e=0;for(const n of this)++e;return e}function y2(){return!this.node()}function x2(e){for(var n=this._groups,a=0,s=n.length;a<s;++a)for(var i=n[a],l=0,c=i.length,p;l<c;++l)(p=i[l])&&e.call(p,p.__data__,l,i);return this}function b2(e){return function(){this.removeAttribute(e)}}function v2(e){return function(){this.removeAttributeNS(e.space,e.local)}}function k2(e,n){return function(){this.setAttribute(e,n)}}function w2(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function S2(e,n){return function(){var a=n.apply(this,arguments);a==null?this.removeAttribute(e):this.setAttribute(e,a)}}function C2(e,n){return function(){var a=n.apply(this,arguments);a==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,a)}}function M2(e,n){var a=Wc(e);if(arguments.length<2){var s=this.node();return a.local?s.getAttributeNS(a.space,a.local):s.getAttribute(a)}return this.each((n==null?a.local?v2:b2:typeof n=="function"?a.local?C2:S2:a.local?w2:k2)(a,n))}function yb(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function E2(e){return function(){this.style.removeProperty(e)}}function j2(e,n,a){return function(){this.style.setProperty(e,n,a)}}function T2(e,n,a){return function(){var s=n.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,a)}}function N2(e,n,a){return arguments.length>1?this.each((n==null?E2:typeof n=="function"?T2:j2)(e,n,a??"")):$s(this.node(),e)}function $s(e,n){return e.style.getPropertyValue(n)||yb(e).getComputedStyle(e,null).getPropertyValue(n)}function A2(e){return function(){delete this[e]}}function _2(e,n){return function(){this[e]=n}}function D2(e,n){return function(){var a=n.apply(this,arguments);a==null?delete this[e]:this[e]=a}}function z2(e,n){return arguments.length>1?this.each((n==null?A2:typeof n=="function"?D2:_2)(e,n)):this.node()[e]}function xb(e){return e.trim().split(/^|\s+/)}function Hf(e){return e.classList||new bb(e)}function bb(e){this._node=e,this._names=xb(e.getAttribute("class")||"")}bb.prototype={add:function(e){var n=this._names.indexOf(e);n<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var n=this._names.indexOf(e);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function vb(e,n){for(var a=Hf(e),s=-1,i=n.length;++s<i;)a.add(n[s])}function kb(e,n){for(var a=Hf(e),s=-1,i=n.length;++s<i;)a.remove(n[s])}function R2(e){return function(){vb(this,e)}}function $2(e){return function(){kb(this,e)}}function O2(e,n){return function(){(n.apply(this,arguments)?vb:kb)(this,e)}}function F2(e,n){var a=xb(e+"");if(arguments.length<2){for(var s=Hf(this.node()),i=-1,l=a.length;++i<l;)if(!s.contains(a[i]))return!1;return!0}return this.each((typeof n=="function"?O2:n?R2:$2)(a,n))}function I2(){this.textContent=""}function L2(e){return function(){this.textContent=e}}function B2(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function P2(e){return arguments.length?this.each(e==null?I2:(typeof e=="function"?B2:L2)(e)):this.node().textContent}function H2(){this.innerHTML=""}function U2(e){return function(){this.innerHTML=e}}function G2(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function q2(e){return arguments.length?this.each(e==null?H2:(typeof e=="function"?G2:U2)(e)):this.node().innerHTML}function K2(){this.nextSibling&&this.parentNode.appendChild(this)}function Y2(){return this.each(K2)}function V2(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function W2(){return this.each(V2)}function X2(e){var n=typeof e=="function"?e:pb(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function Z2(){return null}function Q2(e,n){var a=typeof e=="function"?e:pb(e),s=n==null?Z2:typeof n=="function"?n:Pf(n);return this.select(function(){return this.insertBefore(a.apply(this,arguments),s.apply(this,arguments)||null)})}function J2(){var e=this.parentNode;e&&e.removeChild(this)}function eC(){return this.each(J2)}function tC(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function nC(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function oC(e){return this.select(e?nC:tC)}function aC(e){return arguments.length?this.property("__data__",e):this.node().__data__}function sC(e){return function(n){e.call(this,n,this.__data__)}}function rC(e){return e.trim().split(/^|\s+/).map(function(n){var a="",s=n.indexOf(".");return s>=0&&(a=n.slice(s+1),n=n.slice(0,s)),{type:n,name:a}})}function iC(e){return function(){var n=this.__on;if(n){for(var a=0,s=-1,i=n.length,l;a<i;++a)l=n[a],(!e.type||l.type===e.type)&&l.name===e.name?this.removeEventListener(l.type,l.listener,l.options):n[++s]=l;++s?n.length=s:delete this.__on}}}function lC(e,n,a){return function(){var s=this.__on,i,l=sC(n);if(s){for(var c=0,p=s.length;c<p;++c)if((i=s[c]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=l,i.options=a),i.value=n;return}}this.addEventListener(e.type,l,a),i={type:e.type,name:e.name,value:n,listener:l,options:a},s?s.push(i):this.__on=[i]}}function cC(e,n,a){var s=rC(e+""),i,l=s.length,c;if(arguments.length<2){var p=this.node().__on;if(p){for(var f=0,m=p.length,g;f<m;++f)for(i=0,g=p[f];i<l;++i)if((c=s[i]).type===g.type&&c.name===g.name)return g.value}return}for(p=n?lC:iC,i=0;i<l;++i)this.each(p(s[i],n,a));return this}function wb(e,n,a){var s=yb(e),i=s.CustomEvent;typeof i=="function"?i=new i(n,a):(i=s.document.createEvent("Event"),a?(i.initEvent(n,a.bubbles,a.cancelable),i.detail=a.detail):i.initEvent(n,!1,!1)),e.dispatchEvent(i)}function uC(e,n){return function(){return wb(this,e,n)}}function dC(e,n){return function(){return wb(this,e,n.apply(this,arguments))}}function pC(e,n){return this.each((typeof n=="function"?dC:uC)(e,n))}function*fC(){for(var e=this._groups,n=0,a=e.length;n<a;++n)for(var s=e[n],i=0,l=s.length,c;i<l;++i)(c=s[i])&&(yield c)}var Sb=[null];function en(e,n){this._groups=e,this._parents=n}function wi(){return new en([[document.documentElement]],Sb)}function mC(){return this}en.prototype=wi.prototype={constructor:en,select:BS,selectAll:GS,selectChild:VS,selectChildren:QS,filter:JS,data:s2,enter:e2,exit:i2,join:l2,merge:c2,selection:mC,order:u2,sort:d2,call:f2,nodes:m2,node:h2,size:g2,empty:y2,each:x2,attr:M2,style:N2,property:z2,classed:F2,text:P2,html:q2,raise:Y2,lower:W2,append:X2,insert:Q2,remove:eC,clone:oC,datum:aC,on:cC,dispatch:pC,[Symbol.iterator]:fC};function Jt(e){return typeof e=="string"?new en([[document.querySelector(e)]],[document.documentElement]):new en([[e]],Sb)}function hC(e){let n;for(;n=e.sourceEvent;)e=n;return e}function vn(e,n){if(e=hC(e),n===void 0&&(n=e.currentTarget),n){var a=n.ownerSVGElement||n;if(a.createSVGPoint){var s=a.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(n.getScreenCTM().inverse()),[s.x,s.y]}if(n.getBoundingClientRect){var i=n.getBoundingClientRect();return[e.clientX-i.left-n.clientLeft,e.clientY-i.top-n.clientTop]}}return[e.pageX,e.pageY]}const gC={passive:!1},si={capture:!0,passive:!1};function Lp(e){e.stopImmediatePropagation()}function _s(e){e.preventDefault(),e.stopImmediatePropagation()}function Cb(e){var n=e.document.documentElement,a=Jt(e).on("dragstart.drag",_s,si);"onselectstart"in n?a.on("selectstart.drag",_s,si):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function Mb(e,n){var a=e.document.documentElement,s=Jt(e).on("dragstart.drag",null);n&&(s.on("click.drag",_s,si),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in a?s.on("selectstart.drag",null):(a.style.MozUserSelect=a.__noselect,delete a.__noselect)}const sc=e=>()=>e;function bf(e,{sourceEvent:n,subject:a,target:s,identifier:i,active:l,x:c,y:p,dx:f,dy:m,dispatch:g}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:a,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:l,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:p,enumerable:!0,configurable:!0},dx:{value:f,enumerable:!0,configurable:!0},dy:{value:m,enumerable:!0,configurable:!0},_:{value:g}})}bf.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function yC(e){return!e.ctrlKey&&!e.button}function xC(){return this.parentNode}function bC(e,n){return n??{x:e.x,y:e.y}}function vC(){return navigator.maxTouchPoints||"ontouchstart"in this}function Eb(){var e=yC,n=xC,a=bC,s=vC,i={},l=Vc("start","drag","end"),c=0,p,f,m,g,x=0;function b(E){E.on("mousedown.drag",v).filter(s).on("touchstart.drag",C).on("touchmove.drag",M,gC).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(E,I){if(!(g||!e.call(this,E,I))){var D=S(this,n.call(this,E,I),E,I,"mouse");D&&(Jt(E.view).on("mousemove.drag",k,si).on("mouseup.drag",w,si),Cb(E.view),Lp(E),m=!1,p=E.clientX,f=E.clientY,D("start",E))}}function k(E){if(_s(E),!m){var I=E.clientX-p,D=E.clientY-f;m=I*I+D*D>x}i.mouse("drag",E)}function w(E){Jt(E.view).on("mousemove.drag mouseup.drag",null),Mb(E.view,m),_s(E),i.mouse("end",E)}function C(E,I){if(e.call(this,E,I)){var D=E.changedTouches,A=n.call(this,E,I),L=D.length,P,W;for(P=0;P<L;++P)(W=S(this,A,E,I,D[P].identifier,D[P]))&&(Lp(E),W("start",E,D[P]))}}function M(E){var I=E.changedTouches,D=I.length,A,L;for(A=0;A<D;++A)(L=i[I[A].identifier])&&(_s(E),L("drag",E,I[A]))}function N(E){var I=E.changedTouches,D=I.length,A,L;for(g&&clearTimeout(g),g=setTimeout(function(){g=null},500),A=0;A<D;++A)(L=i[I[A].identifier])&&(Lp(E),L("end",E,I[A]))}function S(E,I,D,A,L,P){var W=l.copy(),$=vn(P||D,I),V,X,H;if((H=a.call(E,new bf("beforestart",{sourceEvent:D,target:b,identifier:L,active:c,x:$[0],y:$[1],dx:0,dy:0,dispatch:W}),A))!=null)return V=H.x-$[0]||0,X=H.y-$[1]||0,function _(T,B,G){var K=$,J;switch(T){case"start":i[L]=_,J=c++;break;case"end":delete i[L],--c;case"drag":$=vn(G||B,I),J=c;break}W.call(T,E,new bf(T,{sourceEvent:B,subject:H,target:b,identifier:L,active:J,x:$[0]+V,y:$[1]+X,dx:$[0]-K[0],dy:$[1]-K[1],dispatch:W}),A)}}return b.filter=function(E){return arguments.length?(e=typeof E=="function"?E:sc(!!E),b):e},b.container=function(E){return arguments.length?(n=typeof E=="function"?E:sc(E),b):n},b.subject=function(E){return arguments.length?(a=typeof E=="function"?E:sc(E),b):a},b.touchable=function(E){return arguments.length?(s=typeof E=="function"?E:sc(!!E),b):s},b.on=function(){var E=l.on.apply(l,arguments);return E===l?b:E},b.clickDistance=function(E){return arguments.length?(x=(E=+E)*E,b):Math.sqrt(x)},b}function Uf(e,n,a){e.prototype=n.prototype=a,a.constructor=e}function jb(e,n){var a=Object.create(e.prototype);for(var s in n)a[s]=n[s];return a}function Si(){}var ri=.7,_c=1/ri,Ds="\\s*([+-]?\\d+)\\s*",ii="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Fn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",kC=/^#([0-9a-f]{3,8})$/,wC=new RegExp(`^rgb\\(${Ds},${Ds},${Ds}\\)$`),SC=new RegExp(`^rgb\\(${Fn},${Fn},${Fn}\\)$`),CC=new RegExp(`^rgba\\(${Ds},${Ds},${Ds},${ii}\\)$`),MC=new RegExp(`^rgba\\(${Fn},${Fn},${Fn},${ii}\\)$`),EC=new RegExp(`^hsl\\(${ii},${Fn},${Fn}\\)$`),jC=new RegExp(`^hsla\\(${ii},${Fn},${Fn},${ii}\\)$`),C0={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Uf(Si,$a,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:M0,formatHex:M0,formatHex8:TC,formatHsl:NC,formatRgb:E0,toString:E0});function M0(){return this.rgb().formatHex()}function TC(){return this.rgb().formatHex8()}function NC(){return Tb(this).formatHsl()}function E0(){return this.rgb().formatRgb()}function $a(e){var n,a;return e=(e+"").trim().toLowerCase(),(n=kC.exec(e))?(a=n[1].length,n=parseInt(n[1],16),a===6?j0(n):a===3?new Gt(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):a===8?rc(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):a===4?rc(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|n&240,((n&15)<<4|n&15)/255):null):(n=wC.exec(e))?new Gt(n[1],n[2],n[3],1):(n=SC.exec(e))?new Gt(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=CC.exec(e))?rc(n[1],n[2],n[3],n[4]):(n=MC.exec(e))?rc(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=EC.exec(e))?A0(n[1],n[2]/100,n[3]/100,1):(n=jC.exec(e))?A0(n[1],n[2]/100,n[3]/100,n[4]):C0.hasOwnProperty(e)?j0(C0[e]):e==="transparent"?new Gt(NaN,NaN,NaN,0):null}function j0(e){return new Gt(e>>16&255,e>>8&255,e&255,1)}function rc(e,n,a,s){return s<=0&&(e=n=a=NaN),new Gt(e,n,a,s)}function AC(e){return e instanceof Si||(e=$a(e)),e?(e=e.rgb(),new Gt(e.r,e.g,e.b,e.opacity)):new Gt}function vf(e,n,a,s){return arguments.length===1?AC(e):new Gt(e,n,a,s??1)}function Gt(e,n,a,s){this.r=+e,this.g=+n,this.b=+a,this.opacity=+s}Uf(Gt,vf,jb(Si,{brighter(e){return e=e==null?_c:Math.pow(_c,e),new Gt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ri:Math.pow(ri,e),new Gt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Gt(_a(this.r),_a(this.g),_a(this.b),Dc(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:T0,formatHex:T0,formatHex8:_C,formatRgb:N0,toString:N0}));function T0(){return`#${Na(this.r)}${Na(this.g)}${Na(this.b)}`}function _C(){return`#${Na(this.r)}${Na(this.g)}${Na(this.b)}${Na((isNaN(this.opacity)?1:this.opacity)*255)}`}function N0(){const e=Dc(this.opacity);return`${e===1?"rgb(":"rgba("}${_a(this.r)}, ${_a(this.g)}, ${_a(this.b)}${e===1?")":`, ${e})`}`}function Dc(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function _a(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Na(e){return e=_a(e),(e<16?"0":"")+e.toString(16)}function A0(e,n,a,s){return s<=0?e=n=a=NaN:a<=0||a>=1?e=n=NaN:n<=0&&(e=NaN),new kn(e,n,a,s)}function Tb(e){if(e instanceof kn)return new kn(e.h,e.s,e.l,e.opacity);if(e instanceof Si||(e=$a(e)),!e)return new kn;if(e instanceof kn)return e;e=e.rgb();var n=e.r/255,a=e.g/255,s=e.b/255,i=Math.min(n,a,s),l=Math.max(n,a,s),c=NaN,p=l-i,f=(l+i)/2;return p?(n===l?c=(a-s)/p+(a<s)*6:a===l?c=(s-n)/p+2:c=(n-a)/p+4,p/=f<.5?l+i:2-l-i,c*=60):p=f>0&&f<1?0:c,new kn(c,p,f,e.opacity)}function DC(e,n,a,s){return arguments.length===1?Tb(e):new kn(e,n,a,s??1)}function kn(e,n,a,s){this.h=+e,this.s=+n,this.l=+a,this.opacity=+s}Uf(kn,DC,jb(Si,{brighter(e){return e=e==null?_c:Math.pow(_c,e),new kn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ri:Math.pow(ri,e),new kn(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,n=isNaN(e)||isNaN(this.s)?0:this.s,a=this.l,s=a+(a<.5?a:1-a)*n,i=2*a-s;return new Gt(Bp(e>=240?e-240:e+120,i,s),Bp(e,i,s),Bp(e<120?e+240:e-120,i,s),this.opacity)},clamp(){return new kn(_0(this.h),ic(this.s),ic(this.l),Dc(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Dc(this.opacity);return`${e===1?"hsl(":"hsla("}${_0(this.h)}, ${ic(this.s)*100}%, ${ic(this.l)*100}%${e===1?")":`, ${e})`}`}}));function _0(e){return e=(e||0)%360,e<0?e+360:e}function ic(e){return Math.max(0,Math.min(1,e||0))}function Bp(e,n,a){return(e<60?n+(a-n)*e/60:e<180?a:e<240?n+(a-n)*(240-e)/60:n)*255}const Gf=e=>()=>e;function zC(e,n){return function(a){return e+a*n}}function RC(e,n,a){return e=Math.pow(e,a),n=Math.pow(n,a)-e,a=1/a,function(s){return Math.pow(e+s*n,a)}}function $C(e){return(e=+e)==1?Nb:function(n,a){return a-n?RC(n,a,e):Gf(isNaN(n)?a:n)}}function Nb(e,n){var a=n-e;return a?zC(e,a):Gf(isNaN(e)?n:e)}const zc=(function e(n){var a=$C(n);function s(i,l){var c=a((i=vf(i)).r,(l=vf(l)).r),p=a(i.g,l.g),f=a(i.b,l.b),m=Nb(i.opacity,l.opacity);return function(g){return i.r=c(g),i.g=p(g),i.b=f(g),i.opacity=m(g),i+""}}return s.gamma=e,s})(1);function OC(e,n){n||(n=[]);var a=e?Math.min(n.length,e.length):0,s=n.slice(),i;return function(l){for(i=0;i<a;++i)s[i]=e[i]*(1-l)+n[i]*l;return s}}function FC(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function IC(e,n){var a=n?n.length:0,s=e?Math.min(a,e.length):0,i=new Array(s),l=new Array(a),c;for(c=0;c<s;++c)i[c]=ei(e[c],n[c]);for(;c<a;++c)l[c]=n[c];return function(p){for(c=0;c<s;++c)l[c]=i[c](p);return l}}function LC(e,n){var a=new Date;return e=+e,n=+n,function(s){return a.setTime(e*(1-s)+n*s),a}}function $n(e,n){return e=+e,n=+n,function(a){return e*(1-a)+n*a}}function BC(e,n){var a={},s={},i;(e===null||typeof e!="object")&&(e={}),(n===null||typeof n!="object")&&(n={});for(i in n)i in e?a[i]=ei(e[i],n[i]):s[i]=n[i];return function(l){for(i in a)s[i]=a[i](l);return s}}var kf=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Pp=new RegExp(kf.source,"g");function PC(e){return function(){return e}}function HC(e){return function(n){return e(n)+""}}function Ab(e,n){var a=kf.lastIndex=Pp.lastIndex=0,s,i,l,c=-1,p=[],f=[];for(e=e+"",n=n+"";(s=kf.exec(e))&&(i=Pp.exec(n));)(l=i.index)>a&&(l=n.slice(a,l),p[c]?p[c]+=l:p[++c]=l),(s=s[0])===(i=i[0])?p[c]?p[c]+=i:p[++c]=i:(p[++c]=null,f.push({i:c,x:$n(s,i)})),a=Pp.lastIndex;return a<n.length&&(l=n.slice(a),p[c]?p[c]+=l:p[++c]=l),p.length<2?f[0]?HC(f[0].x):PC(n):(n=f.length,function(m){for(var g=0,x;g<n;++g)p[(x=f[g]).i]=x.x(m);return p.join("")})}function ei(e,n){var a=typeof n,s;return n==null||a==="boolean"?Gf(n):(a==="number"?$n:a==="string"?(s=$a(n))?(n=s,zc):Ab:n instanceof $a?zc:n instanceof Date?LC:FC(n)?OC:Array.isArray(n)?IC:typeof n.valueOf!="function"&&typeof n.toString!="function"||isNaN(n)?BC:$n)(e,n)}var D0=180/Math.PI,wf={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function _b(e,n,a,s,i,l){var c,p,f;return(c=Math.sqrt(e*e+n*n))&&(e/=c,n/=c),(f=e*a+n*s)&&(a-=e*f,s-=n*f),(p=Math.sqrt(a*a+s*s))&&(a/=p,s/=p,f/=p),e*s<n*a&&(e=-e,n=-n,f=-f,c=-c),{translateX:i,translateY:l,rotate:Math.atan2(n,e)*D0,skewX:Math.atan(f)*D0,scaleX:c,scaleY:p}}var lc;function UC(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?wf:_b(n.a,n.b,n.c,n.d,n.e,n.f)}function GC(e){return e==null||(lc||(lc=document.createElementNS("http://www.w3.org/2000/svg","g")),lc.setAttribute("transform",e),!(e=lc.transform.baseVal.consolidate()))?wf:(e=e.matrix,_b(e.a,e.b,e.c,e.d,e.e,e.f))}function Db(e,n,a,s){function i(m){return m.length?m.pop()+" ":""}function l(m,g,x,b,v,k){if(m!==x||g!==b){var w=v.push("translate(",null,n,null,a);k.push({i:w-4,x:$n(m,x)},{i:w-2,x:$n(g,b)})}else(x||b)&&v.push("translate("+x+n+b+a)}function c(m,g,x,b){m!==g?(m-g>180?g+=360:g-m>180&&(m+=360),b.push({i:x.push(i(x)+"rotate(",null,s)-2,x:$n(m,g)})):g&&x.push(i(x)+"rotate("+g+s)}function p(m,g,x,b){m!==g?b.push({i:x.push(i(x)+"skewX(",null,s)-2,x:$n(m,g)}):g&&x.push(i(x)+"skewX("+g+s)}function f(m,g,x,b,v,k){if(m!==x||g!==b){var w=v.push(i(v)+"scale(",null,",",null,")");k.push({i:w-4,x:$n(m,x)},{i:w-2,x:$n(g,b)})}else(x!==1||b!==1)&&v.push(i(v)+"scale("+x+","+b+")")}return function(m,g){var x=[],b=[];return m=e(m),g=e(g),l(m.translateX,m.translateY,g.translateX,g.translateY,x,b),c(m.rotate,g.rotate,x,b),p(m.skewX,g.skewX,x,b),f(m.scaleX,m.scaleY,g.scaleX,g.scaleY,x,b),m=g=null,function(v){for(var k=-1,w=b.length,C;++k<w;)x[(C=b[k]).i]=C.x(v);return x.join("")}}}var qC=Db(UC,"px, ","px)","deg)"),KC=Db(GC,", ",")",")"),YC=1e-12;function z0(e){return((e=Math.exp(e))+1/e)/2}function VC(e){return((e=Math.exp(e))-1/e)/2}function WC(e){return((e=Math.exp(2*e))-1)/(e+1)}const Sc=(function e(n,a,s){function i(l,c){var p=l[0],f=l[1],m=l[2],g=c[0],x=c[1],b=c[2],v=g-p,k=x-f,w=v*v+k*k,C,M;if(w<YC)M=Math.log(b/m)/n,C=function(A){return[p+A*v,f+A*k,m*Math.exp(n*A*M)]};else{var N=Math.sqrt(w),S=(b*b-m*m+s*w)/(2*m*a*N),E=(b*b-m*m-s*w)/(2*b*a*N),I=Math.log(Math.sqrt(S*S+1)-S),D=Math.log(Math.sqrt(E*E+1)-E);M=(D-I)/n,C=function(A){var L=A*M,P=z0(I),W=m/(a*N)*(P*WC(n*L+I)-VC(I));return[p+W*v,f+W*k,m*P/z0(n*L+I)]}}return C.duration=M*1e3*n/Math.SQRT2,C}return i.rho=function(l){var c=Math.max(.001,+l),p=c*c,f=p*p;return e(c,p,f)},i})(Math.SQRT2,2,4);var Os=0,Wr=0,Hr=0,zb=1e3,Rc,Xr,$c=0,Oa=0,Xc=0,li=typeof performance=="object"&&performance.now?performance:Date,Rb=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function qf(){return Oa||(Rb(XC),Oa=li.now()+Xc)}function XC(){Oa=0}function Oc(){this._call=this._time=this._next=null}Oc.prototype=$b.prototype={constructor:Oc,restart:function(e,n,a){if(typeof e!="function")throw new TypeError("callback is not a function");a=(a==null?qf():+a)+(n==null?0:+n),!this._next&&Xr!==this&&(Xr?Xr._next=this:Rc=this,Xr=this),this._call=e,this._time=a,Sf()},stop:function(){this._call&&(this._call=null,this._time=1/0,Sf())}};function $b(e,n,a){var s=new Oc;return s.restart(e,n,a),s}function ZC(){qf(),++Os;for(var e=Rc,n;e;)(n=Oa-e._time)>=0&&e._call.call(void 0,n),e=e._next;--Os}function R0(){Oa=($c=li.now())+Xc,Os=Wr=0;try{ZC()}finally{Os=0,JC(),Oa=0}}function QC(){var e=li.now(),n=e-$c;n>zb&&(Xc-=n,$c=e)}function JC(){for(var e,n=Rc,a,s=1/0;n;)n._call?(s>n._time&&(s=n._time),e=n,n=n._next):(a=n._next,n._next=null,n=e?e._next=a:Rc=a);Xr=e,Sf(s)}function Sf(e){if(!Os){Wr&&(Wr=clearTimeout(Wr));var n=e-Oa;n>24?(e<1/0&&(Wr=setTimeout(R0,e-li.now()-Xc)),Hr&&(Hr=clearInterval(Hr))):(Hr||($c=li.now(),Hr=setInterval(QC,zb)),Os=1,Rb(R0))}}function $0(e,n,a){var s=new Oc;return n=n==null?0:+n,s.restart(i=>{s.stop(),e(i+n)},n,a),s}var eM=Vc("start","end","cancel","interrupt"),tM=[],Ob=0,O0=1,Cf=2,Cc=3,F0=4,Mf=5,Mc=6;function Zc(e,n,a,s,i,l){var c=e.__transition;if(!c)e.__transition={};else if(a in c)return;nM(e,a,{name:n,index:s,group:i,on:eM,tween:tM,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:Ob})}function Kf(e,n){var a=En(e,n);if(a.state>Ob)throw new Error("too late; already scheduled");return a}function Ln(e,n){var a=En(e,n);if(a.state>Cc)throw new Error("too late; already running");return a}function En(e,n){var a=e.__transition;if(!a||!(a=a[n]))throw new Error("transition not found");return a}function nM(e,n,a){var s=e.__transition,i;s[n]=a,a.timer=$b(l,0,a.time);function l(m){a.state=O0,a.timer.restart(c,a.delay,a.time),a.delay<=m&&c(m-a.delay)}function c(m){var g,x,b,v;if(a.state!==O0)return f();for(g in s)if(v=s[g],v.name===a.name){if(v.state===Cc)return $0(c);v.state===F0?(v.state=Mc,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete s[g]):+g<n&&(v.state=Mc,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete s[g])}if($0(function(){a.state===Cc&&(a.state=F0,a.timer.restart(p,a.delay,a.time),p(m))}),a.state=Cf,a.on.call("start",e,e.__data__,a.index,a.group),a.state===Cf){for(a.state=Cc,i=new Array(b=a.tween.length),g=0,x=-1;g<b;++g)(v=a.tween[g].value.call(e,e.__data__,a.index,a.group))&&(i[++x]=v);i.length=x+1}}function p(m){for(var g=m<a.duration?a.ease.call(null,m/a.duration):(a.timer.restart(f),a.state=Mf,1),x=-1,b=i.length;++x<b;)i[x].call(e,g);a.state===Mf&&(a.on.call("end",e,e.__data__,a.index,a.group),f())}function f(){a.state=Mc,a.timer.stop(),delete s[n];for(var m in s)return;delete e.__transition}}function Ec(e,n){var a=e.__transition,s,i,l=!0,c;if(a){n=n==null?null:n+"";for(c in a){if((s=a[c]).name!==n){l=!1;continue}i=s.state>Cf&&s.state<Mf,s.state=Mc,s.timer.stop(),s.on.call(i?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete a[c]}l&&delete e.__transition}}function oM(e){return this.each(function(){Ec(this,e)})}function aM(e,n){var a,s;return function(){var i=Ln(this,e),l=i.tween;if(l!==a){s=a=l;for(var c=0,p=s.length;c<p;++c)if(s[c].name===n){s=s.slice(),s.splice(c,1);break}}i.tween=s}}function sM(e,n,a){var s,i;if(typeof a!="function")throw new Error;return function(){var l=Ln(this,e),c=l.tween;if(c!==s){i=(s=c).slice();for(var p={name:n,value:a},f=0,m=i.length;f<m;++f)if(i[f].name===n){i[f]=p;break}f===m&&i.push(p)}l.tween=i}}function rM(e,n){var a=this._id;if(e+="",arguments.length<2){for(var s=En(this.node(),a).tween,i=0,l=s.length,c;i<l;++i)if((c=s[i]).name===e)return c.value;return null}return this.each((n==null?aM:sM)(a,e,n))}function Yf(e,n,a){var s=e._id;return e.each(function(){var i=Ln(this,s);(i.value||(i.value={}))[n]=a.apply(this,arguments)}),function(i){return En(i,s).value[n]}}function Fb(e,n){var a;return(typeof n=="number"?$n:n instanceof $a?zc:(a=$a(n))?(n=a,zc):Ab)(e,n)}function iM(e){return function(){this.removeAttribute(e)}}function lM(e){return function(){this.removeAttributeNS(e.space,e.local)}}function cM(e,n,a){var s,i=a+"",l;return function(){var c=this.getAttribute(e);return c===i?null:c===s?l:l=n(s=c,a)}}function uM(e,n,a){var s,i=a+"",l;return function(){var c=this.getAttributeNS(e.space,e.local);return c===i?null:c===s?l:l=n(s=c,a)}}function dM(e,n,a){var s,i,l;return function(){var c,p=a(this),f;return p==null?void this.removeAttribute(e):(c=this.getAttribute(e),f=p+"",c===f?null:c===s&&f===i?l:(i=f,l=n(s=c,p)))}}function pM(e,n,a){var s,i,l;return function(){var c,p=a(this),f;return p==null?void this.removeAttributeNS(e.space,e.local):(c=this.getAttributeNS(e.space,e.local),f=p+"",c===f?null:c===s&&f===i?l:(i=f,l=n(s=c,p)))}}function fM(e,n){var a=Wc(e),s=a==="transform"?KC:Fb;return this.attrTween(e,typeof n=="function"?(a.local?pM:dM)(a,s,Yf(this,"attr."+e,n)):n==null?(a.local?lM:iM)(a):(a.local?uM:cM)(a,s,n))}function mM(e,n){return function(a){this.setAttribute(e,n.call(this,a))}}function hM(e,n){return function(a){this.setAttributeNS(e.space,e.local,n.call(this,a))}}function gM(e,n){var a,s;function i(){var l=n.apply(this,arguments);return l!==s&&(a=(s=l)&&hM(e,l)),a}return i._value=n,i}function yM(e,n){var a,s;function i(){var l=n.apply(this,arguments);return l!==s&&(a=(s=l)&&mM(e,l)),a}return i._value=n,i}function xM(e,n){var a="attr."+e;if(arguments.length<2)return(a=this.tween(a))&&a._value;if(n==null)return this.tween(a,null);if(typeof n!="function")throw new Error;var s=Wc(e);return this.tween(a,(s.local?gM:yM)(s,n))}function bM(e,n){return function(){Kf(this,e).delay=+n.apply(this,arguments)}}function vM(e,n){return n=+n,function(){Kf(this,e).delay=n}}function kM(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?bM:vM)(n,e)):En(this.node(),n).delay}function wM(e,n){return function(){Ln(this,e).duration=+n.apply(this,arguments)}}function SM(e,n){return n=+n,function(){Ln(this,e).duration=n}}function CM(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?wM:SM)(n,e)):En(this.node(),n).duration}function MM(e,n){if(typeof n!="function")throw new Error;return function(){Ln(this,e).ease=n}}function EM(e){var n=this._id;return arguments.length?this.each(MM(n,e)):En(this.node(),n).ease}function jM(e,n){return function(){var a=n.apply(this,arguments);if(typeof a!="function")throw new Error;Ln(this,e).ease=a}}function TM(e){if(typeof e!="function")throw new Error;return this.each(jM(this._id,e))}function NM(e){typeof e!="function"&&(e=mb(e));for(var n=this._groups,a=n.length,s=new Array(a),i=0;i<a;++i)for(var l=n[i],c=l.length,p=s[i]=[],f,m=0;m<c;++m)(f=l[m])&&e.call(f,f.__data__,m,l)&&p.push(f);return new mo(s,this._parents,this._name,this._id)}function AM(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,a=e._groups,s=n.length,i=a.length,l=Math.min(s,i),c=new Array(s),p=0;p<l;++p)for(var f=n[p],m=a[p],g=f.length,x=c[p]=new Array(g),b,v=0;v<g;++v)(b=f[v]||m[v])&&(x[v]=b);for(;p<s;++p)c[p]=n[p];return new mo(c,this._parents,this._name,this._id)}function _M(e){return(e+"").trim().split(/^|\s+/).every(function(n){var a=n.indexOf(".");return a>=0&&(n=n.slice(0,a)),!n||n==="start"})}function DM(e,n,a){var s,i,l=_M(n)?Kf:Ln;return function(){var c=l(this,e),p=c.on;p!==s&&(i=(s=p).copy()).on(n,a),c.on=i}}function zM(e,n){var a=this._id;return arguments.length<2?En(this.node(),a).on.on(e):this.each(DM(a,e,n))}function RM(e){return function(){var n=this.parentNode;for(var a in this.__transition)if(+a!==e)return;n&&n.removeChild(this)}}function $M(){return this.on("end.remove",RM(this._id))}function OM(e){var n=this._name,a=this._id;typeof e!="function"&&(e=Pf(e));for(var s=this._groups,i=s.length,l=new Array(i),c=0;c<i;++c)for(var p=s[c],f=p.length,m=l[c]=new Array(f),g,x,b=0;b<f;++b)(g=p[b])&&(x=e.call(g,g.__data__,b,p))&&("__data__"in g&&(x.__data__=g.__data__),m[b]=x,Zc(m[b],n,a,b,m,En(g,a)));return new mo(l,this._parents,n,a)}function FM(e){var n=this._name,a=this._id;typeof e!="function"&&(e=fb(e));for(var s=this._groups,i=s.length,l=[],c=[],p=0;p<i;++p)for(var f=s[p],m=f.length,g,x=0;x<m;++x)if(g=f[x]){for(var b=e.call(g,g.__data__,x,f),v,k=En(g,a),w=0,C=b.length;w<C;++w)(v=b[w])&&Zc(v,n,a,w,b,k);l.push(b),c.push(g)}return new mo(l,c,n,a)}var IM=wi.prototype.constructor;function LM(){return new IM(this._groups,this._parents)}function BM(e,n){var a,s,i;return function(){var l=$s(this,e),c=(this.style.removeProperty(e),$s(this,e));return l===c?null:l===a&&c===s?i:i=n(a=l,s=c)}}function Ib(e){return function(){this.style.removeProperty(e)}}function PM(e,n,a){var s,i=a+"",l;return function(){var c=$s(this,e);return c===i?null:c===s?l:l=n(s=c,a)}}function HM(e,n,a){var s,i,l;return function(){var c=$s(this,e),p=a(this),f=p+"";return p==null&&(f=p=(this.style.removeProperty(e),$s(this,e))),c===f?null:c===s&&f===i?l:(i=f,l=n(s=c,p))}}function UM(e,n){var a,s,i,l="style."+n,c="end."+l,p;return function(){var f=Ln(this,e),m=f.on,g=f.value[l]==null?p||(p=Ib(n)):void 0;(m!==a||i!==g)&&(s=(a=m).copy()).on(c,i=g),f.on=s}}function GM(e,n,a){var s=(e+="")=="transform"?qC:Fb;return n==null?this.styleTween(e,BM(e,s)).on("end.style."+e,Ib(e)):typeof n=="function"?this.styleTween(e,HM(e,s,Yf(this,"style."+e,n))).each(UM(this._id,e)):this.styleTween(e,PM(e,s,n),a).on("end.style."+e,null)}function qM(e,n,a){return function(s){this.style.setProperty(e,n.call(this,s),a)}}function KM(e,n,a){var s,i;function l(){var c=n.apply(this,arguments);return c!==i&&(s=(i=c)&&qM(e,c,a)),s}return l._value=n,l}function YM(e,n,a){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(n==null)return this.tween(s,null);if(typeof n!="function")throw new Error;return this.tween(s,KM(e,n,a??""))}function VM(e){return function(){this.textContent=e}}function WM(e){return function(){var n=e(this);this.textContent=n??""}}function XM(e){return this.tween("text",typeof e=="function"?WM(Yf(this,"text",e)):VM(e==null?"":e+""))}function ZM(e){return function(n){this.textContent=e.call(this,n)}}function QM(e){var n,a;function s(){var i=e.apply(this,arguments);return i!==a&&(n=(a=i)&&ZM(i)),n}return s._value=e,s}function JM(e){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,QM(e))}function eE(){for(var e=this._name,n=this._id,a=Lb(),s=this._groups,i=s.length,l=0;l<i;++l)for(var c=s[l],p=c.length,f,m=0;m<p;++m)if(f=c[m]){var g=En(f,n);Zc(f,e,a,m,c,{time:g.time+g.delay+g.duration,delay:0,duration:g.duration,ease:g.ease})}return new mo(s,this._parents,e,a)}function tE(){var e,n,a=this,s=a._id,i=a.size();return new Promise(function(l,c){var p={value:c},f={value:function(){--i===0&&l()}};a.each(function(){var m=Ln(this,s),g=m.on;g!==e&&(n=(e=g).copy(),n._.cancel.push(p),n._.interrupt.push(p),n._.end.push(f)),m.on=n}),i===0&&l()})}var nE=0;function mo(e,n,a,s){this._groups=e,this._parents=n,this._name=a,this._id=s}function Lb(){return++nE}var co=wi.prototype;mo.prototype={constructor:mo,select:OM,selectAll:FM,selectChild:co.selectChild,selectChildren:co.selectChildren,filter:NM,merge:AM,selection:LM,transition:eE,call:co.call,nodes:co.nodes,node:co.node,size:co.size,empty:co.empty,each:co.each,on:zM,attr:fM,attrTween:xM,style:GM,styleTween:YM,text:XM,textTween:JM,remove:$M,tween:rM,delay:kM,duration:CM,ease:EM,easeVarying:TM,end:tE,[Symbol.iterator]:co[Symbol.iterator]};function oE(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var aE={time:null,delay:0,duration:250,ease:oE};function sE(e,n){for(var a;!(a=e.__transition)||!(a=a[n]);)if(!(e=e.parentNode))throw new Error(`transition ${n} not found`);return a}function rE(e){var n,a;e instanceof mo?(n=e._id,e=e._name):(n=Lb(),(a=aE).time=qf(),e=e==null?null:e+"");for(var s=this._groups,i=s.length,l=0;l<i;++l)for(var c=s[l],p=c.length,f,m=0;m<p;++m)(f=c[m])&&Zc(f,e,n,m,c,a||sE(f,n));return new mo(s,this._parents,e,n)}wi.prototype.interrupt=oM;wi.prototype.transition=rE;const cc=e=>()=>e;function iE(e,{sourceEvent:n,target:a,transform:s,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:a,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:i}})}function fo(e,n,a){this.k=e,this.x=n,this.y=a}fo.prototype={constructor:fo,scale:function(e){return e===1?this:new fo(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new fo(this.k,this.x+this.k*e,this.y+this.k*n)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Qc=new fo(1,0,0);Bb.prototype=fo.prototype;function Bb(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Qc;return e.__zoom}function Hp(e){e.stopImmediatePropagation()}function Ur(e){e.preventDefault(),e.stopImmediatePropagation()}function lE(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function cE(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function I0(){return this.__zoom||Qc}function uE(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function dE(){return navigator.maxTouchPoints||"ontouchstart"in this}function pE(e,n,a){var s=e.invertX(n[0][0])-a[0][0],i=e.invertX(n[1][0])-a[1][0],l=e.invertY(n[0][1])-a[0][1],c=e.invertY(n[1][1])-a[1][1];return e.translate(i>s?(s+i)/2:Math.min(0,s)||Math.max(0,i),c>l?(l+c)/2:Math.min(0,l)||Math.max(0,c))}function Pb(){var e=lE,n=cE,a=pE,s=uE,i=dE,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],p=250,f=Sc,m=Vc("start","zoom","end"),g,x,b,v=500,k=150,w=0,C=10;function M(H){H.property("__zoom",I0).on("wheel.zoom",L,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",W).filter(i).on("touchstart.zoom",$).on("touchmove.zoom",V).on("touchend.zoom touchcancel.zoom",X).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}M.transform=function(H,_,T,B){var G=H.selection?H.selection():H;G.property("__zoom",I0),H!==G?I(H,_,T,B):G.interrupt().each(function(){D(this,arguments).event(B).start().zoom(null,typeof _=="function"?_.apply(this,arguments):_).end()})},M.scaleBy=function(H,_,T,B){M.scaleTo(H,function(){var G=this.__zoom.k,K=typeof _=="function"?_.apply(this,arguments):_;return G*K},T,B)},M.scaleTo=function(H,_,T,B){M.transform(H,function(){var G=n.apply(this,arguments),K=this.__zoom,J=T==null?E(G):typeof T=="function"?T.apply(this,arguments):T,F=K.invert(J),O=typeof _=="function"?_.apply(this,arguments):_;return a(S(N(K,O),J,F),G,c)},T,B)},M.translateBy=function(H,_,T,B){M.transform(H,function(){return a(this.__zoom.translate(typeof _=="function"?_.apply(this,arguments):_,typeof T=="function"?T.apply(this,arguments):T),n.apply(this,arguments),c)},null,B)},M.translateTo=function(H,_,T,B,G){M.transform(H,function(){var K=n.apply(this,arguments),J=this.__zoom,F=B==null?E(K):typeof B=="function"?B.apply(this,arguments):B;return a(Qc.translate(F[0],F[1]).scale(J.k).translate(typeof _=="function"?-_.apply(this,arguments):-_,typeof T=="function"?-T.apply(this,arguments):-T),K,c)},B,G)};function N(H,_){return _=Math.max(l[0],Math.min(l[1],_)),_===H.k?H:new fo(_,H.x,H.y)}function S(H,_,T){var B=_[0]-T[0]*H.k,G=_[1]-T[1]*H.k;return B===H.x&&G===H.y?H:new fo(H.k,B,G)}function E(H){return[(+H[0][0]+ +H[1][0])/2,(+H[0][1]+ +H[1][1])/2]}function I(H,_,T,B){H.on("start.zoom",function(){D(this,arguments).event(B).start()}).on("interrupt.zoom end.zoom",function(){D(this,arguments).event(B).end()}).tween("zoom",function(){var G=this,K=arguments,J=D(G,K).event(B),F=n.apply(G,K),O=T==null?E(F):typeof T=="function"?T.apply(G,K):T,Q=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),q=G.__zoom,ie=typeof _=="function"?_.apply(G,K):_,pe=f(q.invert(O).concat(Q/q.k),ie.invert(O).concat(Q/ie.k));return function(me){if(me===1)me=ie;else{var U=pe(me),ce=Q/U[2];me=new fo(ce,O[0]-U[0]*ce,O[1]-U[1]*ce)}J.zoom(null,me)}})}function D(H,_,T){return!T&&H.__zooming||new A(H,_)}function A(H,_){this.that=H,this.args=_,this.active=0,this.sourceEvent=null,this.extent=n.apply(H,_),this.taps=0}A.prototype={event:function(H){return H&&(this.sourceEvent=H),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(H,_){return this.mouse&&H!=="mouse"&&(this.mouse[1]=_.invert(this.mouse[0])),this.touch0&&H!=="touch"&&(this.touch0[1]=_.invert(this.touch0[0])),this.touch1&&H!=="touch"&&(this.touch1[1]=_.invert(this.touch1[0])),this.that.__zoom=_,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(H){var _=Jt(this.that).datum();m.call(H,this.that,new iE(H,{sourceEvent:this.sourceEvent,target:M,transform:this.that.__zoom,dispatch:m}),_)}};function L(H,..._){if(!e.apply(this,arguments))return;var T=D(this,_).event(H),B=this.__zoom,G=Math.max(l[0],Math.min(l[1],B.k*Math.pow(2,s.apply(this,arguments)))),K=vn(H);if(T.wheel)(T.mouse[0][0]!==K[0]||T.mouse[0][1]!==K[1])&&(T.mouse[1]=B.invert(T.mouse[0]=K)),clearTimeout(T.wheel);else{if(B.k===G)return;T.mouse=[K,B.invert(K)],Ec(this),T.start()}Ur(H),T.wheel=setTimeout(J,k),T.zoom("mouse",a(S(N(B,G),T.mouse[0],T.mouse[1]),T.extent,c));function J(){T.wheel=null,T.end()}}function P(H,..._){if(b||!e.apply(this,arguments))return;var T=H.currentTarget,B=D(this,_,!0).event(H),G=Jt(H.view).on("mousemove.zoom",O,!0).on("mouseup.zoom",Q,!0),K=vn(H,T),J=H.clientX,F=H.clientY;Cb(H.view),Hp(H),B.mouse=[K,this.__zoom.invert(K)],Ec(this),B.start();function O(q){if(Ur(q),!B.moved){var ie=q.clientX-J,pe=q.clientY-F;B.moved=ie*ie+pe*pe>w}B.event(q).zoom("mouse",a(S(B.that.__zoom,B.mouse[0]=vn(q,T),B.mouse[1]),B.extent,c))}function Q(q){G.on("mousemove.zoom mouseup.zoom",null),Mb(q.view,B.moved),Ur(q),B.event(q).end()}}function W(H,..._){if(e.apply(this,arguments)){var T=this.__zoom,B=vn(H.changedTouches?H.changedTouches[0]:H,this),G=T.invert(B),K=T.k*(H.shiftKey?.5:2),J=a(S(N(T,K),B,G),n.apply(this,_),c);Ur(H),p>0?Jt(this).transition().duration(p).call(I,J,B,H):Jt(this).call(M.transform,J,B,H)}}function $(H,..._){if(e.apply(this,arguments)){var T=H.touches,B=T.length,G=D(this,_,H.changedTouches.length===B).event(H),K,J,F,O;for(Hp(H),J=0;J<B;++J)F=T[J],O=vn(F,this),O=[O,this.__zoom.invert(O),F.identifier],G.touch0?!G.touch1&&G.touch0[2]!==O[2]&&(G.touch1=O,G.taps=0):(G.touch0=O,K=!0,G.taps=1+!!g);g&&(g=clearTimeout(g)),K&&(G.taps<2&&(x=O[0],g=setTimeout(function(){g=null},v)),Ec(this),G.start())}}function V(H,..._){if(this.__zooming){var T=D(this,_).event(H),B=H.changedTouches,G=B.length,K,J,F,O;for(Ur(H),K=0;K<G;++K)J=B[K],F=vn(J,this),T.touch0&&T.touch0[2]===J.identifier?T.touch0[0]=F:T.touch1&&T.touch1[2]===J.identifier&&(T.touch1[0]=F);if(J=T.that.__zoom,T.touch1){var Q=T.touch0[0],q=T.touch0[1],ie=T.touch1[0],pe=T.touch1[1],me=(me=ie[0]-Q[0])*me+(me=ie[1]-Q[1])*me,U=(U=pe[0]-q[0])*U+(U=pe[1]-q[1])*U;J=N(J,Math.sqrt(me/U)),F=[(Q[0]+ie[0])/2,(Q[1]+ie[1])/2],O=[(q[0]+pe[0])/2,(q[1]+pe[1])/2]}else if(T.touch0)F=T.touch0[0],O=T.touch0[1];else return;T.zoom("touch",a(S(J,F,O),T.extent,c))}}function X(H,..._){if(this.__zooming){var T=D(this,_).event(H),B=H.changedTouches,G=B.length,K,J;for(Hp(H),b&&clearTimeout(b),b=setTimeout(function(){b=null},v),K=0;K<G;++K)J=B[K],T.touch0&&T.touch0[2]===J.identifier?delete T.touch0:T.touch1&&T.touch1[2]===J.identifier&&delete T.touch1;if(T.touch1&&!T.touch0&&(T.touch0=T.touch1,delete T.touch1),T.touch0)T.touch0[1]=this.__zoom.invert(T.touch0[0]);else if(T.end(),T.taps===2&&(J=vn(J,this),Math.hypot(x[0]-J[0],x[1]-J[1])<C)){var F=Jt(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return M.wheelDelta=function(H){return arguments.length?(s=typeof H=="function"?H:cc(+H),M):s},M.filter=function(H){return arguments.length?(e=typeof H=="function"?H:cc(!!H),M):e},M.touchable=function(H){return arguments.length?(i=typeof H=="function"?H:cc(!!H),M):i},M.extent=function(H){return arguments.length?(n=typeof H=="function"?H:cc([[+H[0][0],+H[0][1]],[+H[1][0],+H[1][1]]]),M):n},M.scaleExtent=function(H){return arguments.length?(l[0]=+H[0],l[1]=+H[1],M):[l[0],l[1]]},M.translateExtent=function(H){return arguments.length?(c[0][0]=+H[0][0],c[1][0]=+H[1][0],c[0][1]=+H[0][1],c[1][1]=+H[1][1],M):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},M.constrain=function(H){return arguments.length?(a=H,M):a},M.duration=function(H){return arguments.length?(p=+H,M):p},M.interpolate=function(H){return arguments.length?(f=H,M):f},M.on=function(){var H=m.on.apply(m,arguments);return H===m?M:H},M.clickDistance=function(H){return arguments.length?(w=(H=+H)*H,M):Math.sqrt(w)},M.tapDistance=function(H){return arguments.length?(C=+H,M):C},M}const In={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:n,sourceHandle:a,targetHandle:s})=>`Couldn't create edge for ${e} handle id: "${e==="source"?a:s}", edge id: ${n}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},ci=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Hb=["Enter"," ","Escape"],Ub={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:n,y:a})=>`Moved selected node ${e}. New position, x: ${n}, y: ${a}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Fs;(function(e){e.Strict="strict",e.Loose="loose"})(Fs||(Fs={}));var Da;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Da||(Da={}));var ui;(function(e){e.Partial="partial",e.Full="full"})(ui||(ui={}));const Gb={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Xo;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Xo||(Xo={}));var Fc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Fc||(Fc={}));var Se;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Se||(Se={}));const L0={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function qb(e){return e===null?null:e?"valid":"invalid"}const Kb=e=>"id"in e&&"source"in e&&"target"in e,fE=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Vf=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Ci=(e,n=[0,0])=>{const{width:a,height:s}=ho(e),i=e.origin??n,l=a*i[0],c=s*i[1];return{x:e.position.x-l,y:e.position.y-c}},mE=(e,n={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const a=e.reduce((s,i)=>{const l=typeof i=="string";let c=!n.nodeLookup&&!l?i:void 0;n.nodeLookup&&(c=l?n.nodeLookup.get(i):Vf(i)?i:n.nodeLookup.get(i.id));const p=c?Ic(c,n.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Jc(s,p)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return eu(a)},Mi=(e,n={})=>{let a={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return e.forEach(i=>{(n.filter===void 0||n.filter(i))&&(a=Jc(a,Ic(i)),s=!0)}),s?eu(a):{x:0,y:0,width:0,height:0}},Wf=(e,n,[a,s,i]=[0,0,1],l=!1,c=!1)=>{const p={...ji(n,[a,s,i]),width:n.width/i,height:n.height/i},f=[];for(const m of e.values()){const{measured:g,selectable:x=!0,hidden:b=!1}=m;if(c&&!x||b)continue;const v=g.width??m.width??m.initialWidth??null,k=g.height??m.height??m.initialHeight??null,w=di(p,Ls(m)),C=(v??0)*(k??0),M=l&&w>0;(!m.internals.handleBounds||M||w>=C||m.dragging)&&f.push(m)}return f},hE=(e,n)=>{const a=new Set;return e.forEach(s=>{a.add(s.id)}),n.filter(s=>a.has(s.source)||a.has(s.target))};function gE(e,n){const a=new Map,s=n?.nodes?new Set(n.nodes.map(i=>i.id)):null;return e.forEach(i=>{i.measured.width&&i.measured.height&&(n?.includeHiddenNodes||!i.hidden)&&(!s||s.has(i.id))&&a.set(i.id,i)}),a}async function yE({nodes:e,width:n,height:a,panZoom:s,minZoom:i,maxZoom:l},c){if(e.size===0)return Promise.resolve(!0);const p=gE(e,c),f=Mi(p),m=Xf(f,n,a,c?.minZoom??i,c?.maxZoom??l,c?.padding??.1);return await s.setViewport(m,{duration:c?.duration,ease:c?.ease,interpolate:c?.interpolate}),Promise.resolve(!0)}function Yb({nodeId:e,nextPosition:n,nodeLookup:a,nodeOrigin:s=[0,0],nodeExtent:i,onError:l}){const c=a.get(e),p=c.parentId?a.get(c.parentId):void 0,{x:f,y:m}=p?p.internals.positionAbsolute:{x:0,y:0},g=c.origin??s;let x=c.extent||i;if(c.extent==="parent"&&!c.expandParent)if(!p)l?.("005",In.error005());else{const v=p.measured.width,k=p.measured.height;v&&k&&(x=[[f,m],[f+v,m+k]])}else p&&Bs(c.extent)&&(x=[[c.extent[0][0]+f,c.extent[0][1]+m],[c.extent[1][0]+f,c.extent[1][1]+m]]);const b=Bs(x)?Fa(n,x,c.measured):n;return(c.measured.width===void 0||c.measured.height===void 0)&&l?.("015",In.error015()),{position:{x:b.x-f+(c.measured.width??0)*g[0],y:b.y-m+(c.measured.height??0)*g[1]},positionAbsolute:b}}async function xE({nodesToRemove:e=[],edgesToRemove:n=[],nodes:a,edges:s,onBeforeDelete:i}){const l=new Set(e.map(b=>b.id)),c=[];for(const b of a){if(b.deletable===!1)continue;const v=l.has(b.id),k=!v&&b.parentId&&c.find(w=>w.id===b.parentId);(v||k)&&c.push(b)}const p=new Set(n.map(b=>b.id)),f=s.filter(b=>b.deletable!==!1),g=hE(c,f);for(const b of f)p.has(b.id)&&!g.find(k=>k.id===b.id)&&g.push(b);if(!i)return{edges:g,nodes:c};const x=await i({nodes:c,edges:g});return typeof x=="boolean"?x?{edges:g,nodes:c}:{edges:[],nodes:[]}:x}const Is=(e,n=0,a=1)=>Math.min(Math.max(e,n),a),Fa=(e={x:0,y:0},n,a)=>({x:Is(e.x,n[0][0],n[1][0]-(a?.width??0)),y:Is(e.y,n[0][1],n[1][1]-(a?.height??0))});function Vb(e,n,a){const{width:s,height:i}=ho(a),{x:l,y:c}=a.internals.positionAbsolute;return Fa(e,[[l,c],[l+s,c+i]],n)}const B0=(e,n,a)=>e<n?Is(Math.abs(e-n),1,n)/n:e>a?-Is(Math.abs(e-a),1,n)/n:0,Wb=(e,n,a=15,s=40)=>{const i=B0(e.x,s,n.width-s)*a,l=B0(e.y,s,n.height-s)*a;return[i,l]},Jc=(e,n)=>({x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),x2:Math.max(e.x2,n.x2),y2:Math.max(e.y2,n.y2)}),Ef=({x:e,y:n,width:a,height:s})=>({x:e,y:n,x2:e+a,y2:n+s}),eu=({x:e,y:n,x2:a,y2:s})=>({x:e,y:n,width:a-e,height:s-n}),Ls=(e,n=[0,0])=>{const{x:a,y:s}=Vf(e)?e.internals.positionAbsolute:Ci(e,n);return{x:a,y:s,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Ic=(e,n=[0,0])=>{const{x:a,y:s}=Vf(e)?e.internals.positionAbsolute:Ci(e,n);return{x:a,y:s,x2:a+(e.measured?.width??e.width??e.initialWidth??0),y2:s+(e.measured?.height??e.height??e.initialHeight??0)}},Xb=(e,n)=>eu(Jc(Ef(e),Ef(n))),di=(e,n)=>{const a=Math.max(0,Math.min(e.x+e.width,n.x+n.width)-Math.max(e.x,n.x)),s=Math.max(0,Math.min(e.y+e.height,n.y+n.height)-Math.max(e.y,n.y));return Math.ceil(a*s)},P0=e=>Sn(e.width)&&Sn(e.height)&&Sn(e.x)&&Sn(e.y),Sn=e=>!isNaN(e)&&isFinite(e),bE=(e,n)=>{},Ei=(e,n=[1,1])=>({x:n[0]*Math.round(e.x/n[0]),y:n[1]*Math.round(e.y/n[1])}),ji=({x:e,y:n},[a,s,i],l=!1,c=[1,1])=>{const p={x:(e-a)/i,y:(n-s)/i};return l?Ei(p,c):p},Lc=({x:e,y:n},[a,s,i])=>({x:e*i+a,y:n*i+s});function Ts(e,n){if(typeof e=="number")return Math.floor((n-n/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const a=parseFloat(e);if(!Number.isNaN(a))return Math.floor(a)}if(typeof e=="string"&&e.endsWith("%")){const a=parseFloat(e);if(!Number.isNaN(a))return Math.floor(n*a*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function vE(e,n,a){if(typeof e=="string"||typeof e=="number"){const s=Ts(e,a),i=Ts(e,n);return{top:s,right:i,bottom:s,left:i,x:i*2,y:s*2}}if(typeof e=="object"){const s=Ts(e.top??e.y??0,a),i=Ts(e.bottom??e.y??0,a),l=Ts(e.left??e.x??0,n),c=Ts(e.right??e.x??0,n);return{top:s,right:c,bottom:i,left:l,x:l+c,y:s+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function kE(e,n,a,s,i,l){const{x:c,y:p}=Lc(e,[n,a,s]),{x:f,y:m}=Lc({x:e.x+e.width,y:e.y+e.height},[n,a,s]),g=i-f,x=l-m;return{left:Math.floor(c),top:Math.floor(p),right:Math.floor(g),bottom:Math.floor(x)}}const Xf=(e,n,a,s,i,l)=>{const c=vE(l,n,a),p=(n-c.x)/e.width,f=(a-c.y)/e.height,m=Math.min(p,f),g=Is(m,s,i),x=e.x+e.width/2,b=e.y+e.height/2,v=n/2-x*g,k=a/2-b*g,w=kE(e,v,k,g,n,a),C={left:Math.min(w.left-c.left,0),top:Math.min(w.top-c.top,0),right:Math.min(w.right-c.right,0),bottom:Math.min(w.bottom-c.bottom,0)};return{x:v-C.left+C.right,y:k-C.top+C.bottom,zoom:g}},pi=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Bs(e){return e!=null&&e!=="parent"}function ho(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Zb(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Qb(e,n={width:0,height:0},a,s,i){const l={...e},c=s.get(a);if(c){const p=c.origin||i;l.x+=c.internals.positionAbsolute.x-(n.width??0)*p[0],l.y+=c.internals.positionAbsolute.y-(n.height??0)*p[1]}return l}function H0(e,n){if(e.size!==n.size)return!1;for(const a of e)if(!n.has(a))return!1;return!0}function wE(){let e,n;return{promise:new Promise((s,i)=>{e=s,n=i}),resolve:e,reject:n}}function SE(e){return{...Ub,...e||{}}}function ti(e,{snapGrid:n=[0,0],snapToGrid:a=!1,transform:s,containerBounds:i}){const{x:l,y:c}=Cn(e),p=ji({x:l-(i?.left??0),y:c-(i?.top??0)},s),{x:f,y:m}=a?Ei(p,n):p;return{xSnapped:f,ySnapped:m,...p}}const Zf=e=>({width:e.offsetWidth,height:e.offsetHeight}),Jb=e=>e?.getRootNode?.()||window?.document,CE=["INPUT","SELECT","TEXTAREA"];function e1(e){const n=e.composedPath?.()?.[0]||e.target;return n?.nodeType!==1?!1:CE.includes(n.nodeName)||n.hasAttribute("contenteditable")||!!n.closest(".nokey")}const t1=e=>"clientX"in e,Cn=(e,n)=>{const a=t1(e),s=a?e.clientX:e.touches?.[0].clientX,i=a?e.clientY:e.touches?.[0].clientY;return{x:s-(n?.left??0),y:i-(n?.top??0)}},U0=(e,n,a,s,i)=>{const l=n.querySelectorAll(`.${e}`);return!l||!l.length?null:Array.from(l).map(c=>{const p=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:e,nodeId:i,position:c.getAttribute("data-handlepos"),x:(p.left-a.left)/s,y:(p.top-a.top)/s,...Zf(c)}})};function n1({sourceX:e,sourceY:n,targetX:a,targetY:s,sourceControlX:i,sourceControlY:l,targetControlX:c,targetControlY:p}){const f=e*.125+i*.375+c*.375+a*.125,m=n*.125+l*.375+p*.375+s*.125,g=Math.abs(f-e),x=Math.abs(m-n);return[f,m,g,x]}function uc(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function G0({pos:e,x1:n,y1:a,x2:s,y2:i,c:l}){switch(e){case Se.Left:return[n-uc(n-s,l),a];case Se.Right:return[n+uc(s-n,l),a];case Se.Top:return[n,a-uc(a-i,l)];case Se.Bottom:return[n,a+uc(i-a,l)]}}function o1({sourceX:e,sourceY:n,sourcePosition:a=Se.Bottom,targetX:s,targetY:i,targetPosition:l=Se.Top,curvature:c=.25}){const[p,f]=G0({pos:a,x1:e,y1:n,x2:s,y2:i,c}),[m,g]=G0({pos:l,x1:s,y1:i,x2:e,y2:n,c}),[x,b,v,k]=n1({sourceX:e,sourceY:n,targetX:s,targetY:i,sourceControlX:p,sourceControlY:f,targetControlX:m,targetControlY:g});return[`M${e},${n} C${p},${f} ${m},${g} ${s},${i}`,x,b,v,k]}function a1({sourceX:e,sourceY:n,targetX:a,targetY:s}){const i=Math.abs(a-e)/2,l=a<e?a+i:a-i,c=Math.abs(s-n)/2,p=s<n?s+c:s-c;return[l,p,i,c]}function ME({sourceNode:e,targetNode:n,selected:a=!1,zIndex:s=0,elevateOnSelect:i=!1,zIndexMode:l="basic"}){if(l==="manual")return s;const c=i&&a?s+1e3:s,p=Math.max(e.parentId||i&&e.selected?e.internals.z:0,n.parentId||i&&n.selected?n.internals.z:0);return c+p}function EE({sourceNode:e,targetNode:n,width:a,height:s,transform:i}){const l=Jc(Ic(e),Ic(n));l.x===l.x2&&(l.x2+=1),l.y===l.y2&&(l.y2+=1);const c={x:-i[0]/i[2],y:-i[1]/i[2],width:a/i[2],height:s/i[2]};return di(c,eu(l))>0}const jE=({source:e,sourceHandle:n,target:a,targetHandle:s})=>`xy-edge__${e}${n||""}-${a}${s||""}`,TE=(e,n)=>n.some(a=>a.source===e.source&&a.target===e.target&&(a.sourceHandle===e.sourceHandle||!a.sourceHandle&&!e.sourceHandle)&&(a.targetHandle===e.targetHandle||!a.targetHandle&&!e.targetHandle)),NE=(e,n,a={})=>{if(!e.source||!e.target)return n;const s=a.getEdgeId||jE;let i;return Kb(e)?i={...e}:i={...e,id:s(e)},TE(i,n)?n:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,n.concat(i))};function s1({sourceX:e,sourceY:n,targetX:a,targetY:s}){const[i,l,c,p]=a1({sourceX:e,sourceY:n,targetX:a,targetY:s});return[`M ${e},${n}L ${a},${s}`,i,l,c,p]}const q0={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},AE=({source:e,sourcePosition:n=Se.Bottom,target:a})=>n===Se.Left||n===Se.Right?e.x<a.x?{x:1,y:0}:{x:-1,y:0}:e.y<a.y?{x:0,y:1}:{x:0,y:-1},K0=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function _E({source:e,sourcePosition:n=Se.Bottom,target:a,targetPosition:s=Se.Top,center:i,offset:l,stepPosition:c}){const p=q0[n],f=q0[s],m={x:e.x+p.x*l,y:e.y+p.y*l},g={x:a.x+f.x*l,y:a.y+f.y*l},x=AE({source:m,sourcePosition:n,target:g}),b=x.x!==0?"x":"y",v=x[b];let k=[],w,C;const M={x:0,y:0},N={x:0,y:0},[,,S,E]=a1({sourceX:e.x,sourceY:e.y,targetX:a.x,targetY:a.y});if(p[b]*f[b]===-1){b==="x"?(w=i.x??m.x+(g.x-m.x)*c,C=i.y??(m.y+g.y)/2):(w=i.x??(m.x+g.x)/2,C=i.y??m.y+(g.y-m.y)*c);const D=[{x:w,y:m.y},{x:w,y:g.y}],A=[{x:m.x,y:C},{x:g.x,y:C}];p[b]===v?k=b==="x"?D:A:k=b==="x"?A:D}else{const D=[{x:m.x,y:g.y}],A=[{x:g.x,y:m.y}];if(b==="x"?k=p.x===v?A:D:k=p.y===v?D:A,n===s){const V=Math.abs(e[b]-a[b]);if(V<=l){const X=Math.min(l-1,l-V);p[b]===v?M[b]=(m[b]>e[b]?-1:1)*X:N[b]=(g[b]>a[b]?-1:1)*X}}if(n!==s){const V=b==="x"?"y":"x",X=p[b]===f[V],H=m[V]>g[V],_=m[V]<g[V];(p[b]===1&&(!X&&H||X&&_)||p[b]!==1&&(!X&&_||X&&H))&&(k=b==="x"?D:A)}const L={x:m.x+M.x,y:m.y+M.y},P={x:g.x+N.x,y:g.y+N.y},W=Math.max(Math.abs(L.x-k[0].x),Math.abs(P.x-k[0].x)),$=Math.max(Math.abs(L.y-k[0].y),Math.abs(P.y-k[0].y));W>=$?(w=(L.x+P.x)/2,C=k[0].y):(w=k[0].x,C=(L.y+P.y)/2)}return[[e,{x:m.x+M.x,y:m.y+M.y},...k,{x:g.x+N.x,y:g.y+N.y},a],w,C,S,E]}function DE(e,n,a,s){const i=Math.min(K0(e,n)/2,K0(n,a)/2,s),{x:l,y:c}=n;if(e.x===l&&l===a.x||e.y===c&&c===a.y)return`L${l} ${c}`;if(e.y===c){const m=e.x<a.x?-1:1,g=e.y<a.y?1:-1;return`L ${l+i*m},${c}Q ${l},${c} ${l},${c+i*g}`}const p=e.x<a.x?1:-1,f=e.y<a.y?-1:1;return`L ${l},${c+i*f}Q ${l},${c} ${l+i*p},${c}`}function jf({sourceX:e,sourceY:n,sourcePosition:a=Se.Bottom,targetX:s,targetY:i,targetPosition:l=Se.Top,borderRadius:c=5,centerX:p,centerY:f,offset:m=20,stepPosition:g=.5}){const[x,b,v,k,w]=_E({source:{x:e,y:n},sourcePosition:a,target:{x:s,y:i},targetPosition:l,center:{x:p,y:f},offset:m,stepPosition:g});return[x.reduce((M,N,S)=>{let E="";return S>0&&S<x.length-1?E=DE(x[S-1],N,x[S+1],c):E=`${S===0?"M":"L"}${N.x} ${N.y}`,M+=E,M},""),b,v,k,w]}function Y0(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function zE(e){const{sourceNode:n,targetNode:a}=e;if(!Y0(n)||!Y0(a))return null;const s=n.internals.handleBounds||V0(n.handles),i=a.internals.handleBounds||V0(a.handles),l=W0(s?.source??[],e.sourceHandle),c=W0(e.connectionMode===Fs.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!l||!c)return e.onError?.("008",In.error008(l?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const p=l?.position||Se.Bottom,f=c?.position||Se.Top,m=Ia(n,l,p),g=Ia(a,c,f);return{sourceX:m.x,sourceY:m.y,targetX:g.x,targetY:g.y,sourcePosition:p,targetPosition:f}}function V0(e){if(!e)return null;const n=[],a=[];for(const s of e)s.width=s.width??1,s.height=s.height??1,s.type==="source"?n.push(s):s.type==="target"&&a.push(s);return{source:n,target:a}}function Ia(e,n,a=Se.Left,s=!1){const i=(n?.x??0)+e.internals.positionAbsolute.x,l=(n?.y??0)+e.internals.positionAbsolute.y,{width:c,height:p}=n??ho(e);if(s)return{x:i+c/2,y:l+p/2};switch(n?.position??a){case Se.Top:return{x:i+c/2,y:l};case Se.Right:return{x:i+c,y:l+p/2};case Se.Bottom:return{x:i+c/2,y:l+p};case Se.Left:return{x:i,y:l+p/2}}}function W0(e,n){return e&&(n?e.find(a=>a.id===n):e[0])||null}function Tf(e,n){return e?typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`:""}function RE(e,{id:n,defaultColor:a,defaultMarkerStart:s,defaultMarkerEnd:i}){const l=new Set;return e.reduce((c,p)=>([p.markerStart||s,p.markerEnd||i].forEach(f=>{if(f&&typeof f=="object"){const m=Tf(f,n);l.has(m)||(c.push({id:m,color:f.color||a,...f}),l.add(m))}}),c),[]).sort((c,p)=>c.id.localeCompare(p.id))}const r1=1e3,$E=10,Qf={nodeOrigin:[0,0],nodeExtent:ci,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},OE={...Qf,checkEquality:!0};function Jf(e,n){const a={...e};for(const s in n)n[s]!==void 0&&(a[s]=n[s]);return a}function FE(e,n,a){const s=Jf(Qf,a);for(const i of e.values())if(i.parentId)tm(i,e,n,s);else{const l=Ci(i,s.nodeOrigin),c=Bs(i.extent)?i.extent:s.nodeExtent,p=Fa(l,c,ho(i));i.internals.positionAbsolute=p}}function IE(e,n){if(!e.handles)return e.measured?n?.internals.handleBounds:void 0;const a=[],s=[];for(const i of e.handles){const l={id:i.id,width:i.width??1,height:i.height??1,nodeId:e.id,x:i.x,y:i.y,position:i.position,type:i.type};i.type==="source"?a.push(l):i.type==="target"&&s.push(l)}return{source:a,target:s}}function em(e){return e==="manual"}function Nf(e,n,a,s={}){const i=Jf(OE,s),l={i:0},c=new Map(n),p=i?.elevateNodesOnSelect&&!em(i.zIndexMode)?r1:0;let f=e.length>0;n.clear(),a.clear();for(const m of e){let g=c.get(m.id);if(i.checkEquality&&m===g?.internals.userNode)n.set(m.id,g);else{const x=Ci(m,i.nodeOrigin),b=Bs(m.extent)?m.extent:i.nodeExtent,v=Fa(x,b,ho(m));g={...i.defaults,...m,measured:{width:m.measured?.width,height:m.measured?.height},internals:{positionAbsolute:v,handleBounds:IE(m,g),z:i1(m,p,i.zIndexMode),userNode:m}},n.set(m.id,g)}(g.measured===void 0||g.measured.width===void 0||g.measured.height===void 0)&&!g.hidden&&(f=!1),m.parentId&&tm(g,n,a,s,l)}return f}function LE(e,n){if(!e.parentId)return;const a=n.get(e.parentId);a?a.set(e.id,e):n.set(e.parentId,new Map([[e.id,e]]))}function tm(e,n,a,s,i){const{elevateNodesOnSelect:l,nodeOrigin:c,nodeExtent:p,zIndexMode:f}=Jf(Qf,s),m=e.parentId,g=n.get(m);if(!g){console.warn(`Parent node ${m} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}LE(e,a),i&&!g.parentId&&g.internals.rootParentIndex===void 0&&f==="auto"&&(g.internals.rootParentIndex=++i.i,g.internals.z=g.internals.z+i.i*$E),i&&g.internals.rootParentIndex!==void 0&&(i.i=g.internals.rootParentIndex);const x=l&&!em(f)?r1:0,{x:b,y:v,z:k}=BE(e,g,c,p,x,f),{positionAbsolute:w}=e.internals,C=b!==w.x||v!==w.y;(C||k!==e.internals.z)&&n.set(e.id,{...e,internals:{...e.internals,positionAbsolute:C?{x:b,y:v}:w,z:k}})}function i1(e,n,a){const s=Sn(e.zIndex)?e.zIndex:0;return em(a)?s:s+(e.selected?n:0)}function BE(e,n,a,s,i,l){const{x:c,y:p}=n.internals.positionAbsolute,f=ho(e),m=Ci(e,a),g=Bs(e.extent)?Fa(m,e.extent,f):m;let x=Fa({x:c+g.x,y:p+g.y},s,f);e.extent==="parent"&&(x=Vb(x,f,n));const b=i1(e,i,l),v=n.internals.z??0;return{x:x.x,y:x.y,z:v>=b?v+1:b}}function nm(e,n,a,s=[0,0]){const i=[],l=new Map;for(const c of e){const p=n.get(c.parentId);if(!p)continue;const f=l.get(c.parentId)?.expandedRect??Ls(p),m=Xb(f,c.rect);l.set(c.parentId,{expandedRect:m,parent:p})}return l.size>0&&l.forEach(({expandedRect:c,parent:p},f)=>{const m=p.internals.positionAbsolute,g=ho(p),x=p.origin??s,b=c.x<m.x?Math.round(Math.abs(m.x-c.x)):0,v=c.y<m.y?Math.round(Math.abs(m.y-c.y)):0,k=Math.max(g.width,Math.round(c.width)),w=Math.max(g.height,Math.round(c.height)),C=(k-g.width)*x[0],M=(w-g.height)*x[1];(b>0||v>0||C||M)&&(i.push({id:f,type:"position",position:{x:p.position.x-b+C,y:p.position.y-v+M}}),a.get(f)?.forEach(N=>{e.some(S=>S.id===N.id)||i.push({id:N.id,type:"position",position:{x:N.position.x+b,y:N.position.y+v}})})),(g.width<c.width||g.height<c.height||b||v)&&i.push({id:f,type:"dimensions",setAttributes:!0,dimensions:{width:k+(b?x[0]*b-C:0),height:w+(v?x[1]*v-M:0)}})}),i}function PE(e,n,a,s,i,l,c){const p=s?.querySelector(".xyflow__viewport");let f=!1;if(!p)return{changes:[],updatedInternals:f};const m=[],g=window.getComputedStyle(p),{m22:x}=new window.DOMMatrixReadOnly(g.transform),b=[];for(const v of e.values()){const k=n.get(v.id);if(!k)continue;if(k.hidden){n.set(k.id,{...k,internals:{...k.internals,handleBounds:void 0}}),f=!0;continue}const w=Zf(v.nodeElement),C=k.measured.width!==w.width||k.measured.height!==w.height;if(!!(w.width&&w.height&&(C||!k.internals.handleBounds||v.force))){const N=v.nodeElement.getBoundingClientRect(),S=Bs(k.extent)?k.extent:l;let{positionAbsolute:E}=k.internals;k.parentId&&k.extent==="parent"?E=Vb(E,w,n.get(k.parentId)):S&&(E=Fa(E,S,w));const I={...k,measured:w,internals:{...k.internals,positionAbsolute:E,handleBounds:{source:U0("source",v.nodeElement,N,x,k.id),target:U0("target",v.nodeElement,N,x,k.id)}}};n.set(k.id,I),k.parentId&&tm(I,n,a,{nodeOrigin:i,zIndexMode:c}),f=!0,C&&(m.push({id:k.id,type:"dimensions",dimensions:w}),k.expandParent&&k.parentId&&b.push({id:k.id,parentId:k.parentId,rect:Ls(I,i)}))}}if(b.length>0){const v=nm(b,n,a,i);m.push(...v)}return{changes:m,updatedInternals:f}}async function HE({delta:e,panZoom:n,transform:a,translateExtent:s,width:i,height:l}){if(!n||!e.x&&!e.y)return Promise.resolve(!1);const c=await n.setViewportConstrained({x:a[0]+e.x,y:a[1]+e.y,zoom:a[2]},[[0,0],[i,l]],s),p=!!c&&(c.x!==a[0]||c.y!==a[1]||c.k!==a[2]);return Promise.resolve(p)}function X0(e,n,a,s,i,l){let c=i;const p=s.get(c)||new Map;s.set(c,p.set(a,n)),c=`${i}-${e}`;const f=s.get(c)||new Map;if(s.set(c,f.set(a,n)),l){c=`${i}-${e}-${l}`;const m=s.get(c)||new Map;s.set(c,m.set(a,n))}}function l1(e,n,a){e.clear(),n.clear();for(const s of a){const{source:i,target:l,sourceHandle:c=null,targetHandle:p=null}=s,f={edgeId:s.id,source:i,target:l,sourceHandle:c,targetHandle:p},m=`${i}-${c}--${l}-${p}`,g=`${l}-${p}--${i}-${c}`;X0("source",f,g,e,i,c),X0("target",f,m,e,l,p),n.set(s.id,s)}}function c1(e,n){if(!e.parentId)return!1;const a=n.get(e.parentId);return a?a.selected?!0:c1(a,n):!1}function Z0(e,n,a){let s=e;do{if(s?.matches?.(n))return!0;if(s===a)return!1;s=s?.parentElement}while(s);return!1}function UE(e,n,a,s){const i=new Map;for(const[l,c]of e)if((c.selected||c.id===s)&&(!c.parentId||!c1(c,e))&&(c.draggable||n&&typeof c.draggable>"u")){const p=e.get(l);p&&i.set(l,{id:l,position:p.position||{x:0,y:0},distance:{x:a.x-p.internals.positionAbsolute.x,y:a.y-p.internals.positionAbsolute.y},extent:p.extent,parentId:p.parentId,origin:p.origin,expandParent:p.expandParent,internals:{positionAbsolute:p.internals.positionAbsolute||{x:0,y:0}},measured:{width:p.measured.width??0,height:p.measured.height??0}})}return i}function Up({nodeId:e,dragItems:n,nodeLookup:a,dragging:s=!0}){const i=[];for(const[c,p]of n){const f=a.get(c)?.internals.userNode;f&&i.push({...f,position:p.position,dragging:s})}if(!e)return[i[0],i];const l=a.get(e)?.internals.userNode;return[l?{...l,position:n.get(e)?.position||l.position,dragging:s}:i[0],i]}function GE({dragItems:e,snapGrid:n,x:a,y:s}){const i=e.values().next().value;if(!i)return null;const l={x:a-i.distance.x,y:s-i.distance.y},c=Ei(l,n);return{x:c.x-l.x,y:c.y-l.y}}function qE({onNodeMouseDown:e,getStoreItems:n,onDragStart:a,onDrag:s,onDragStop:i}){let l={x:null,y:null},c=0,p=new Map,f=!1,m={x:0,y:0},g=null,x=!1,b=null,v=!1,k=!1,w=null;function C({noDragClassName:N,handleSelector:S,domNode:E,isSelectable:I,nodeId:D,nodeClickDistance:A=0}){b=Jt(E);function L({x:V,y:X}){const{nodeLookup:H,nodeExtent:_,snapGrid:T,snapToGrid:B,nodeOrigin:G,onNodeDrag:K,onSelectionDrag:J,onError:F,updateNodePositions:O}=n();l={x:V,y:X};let Q=!1;const q=p.size>1,ie=q&&_?Ef(Mi(p)):null,pe=q&&B?GE({dragItems:p,snapGrid:T,x:V,y:X}):null;for(const[me,U]of p){if(!H.has(me))continue;let ce={x:V-U.distance.x,y:X-U.distance.y};B&&(ce=pe?{x:Math.round(ce.x+pe.x),y:Math.round(ce.y+pe.y)}:Ei(ce,T));let ge=null;if(q&&_&&!U.extent&&ie){const{positionAbsolute:te}=U.internals,he=te.x-ie.x+_[0][0],je=te.x+U.measured.width-ie.x2+_[1][0],Ie=te.y-ie.y+_[0][1],ze=te.y+U.measured.height-ie.y2+_[1][1];ge=[[he,Ie],[je,ze]]}const{position:be,positionAbsolute:ye}=Yb({nodeId:me,nextPosition:ce,nodeLookup:H,nodeExtent:ge||_,nodeOrigin:G,onError:F});Q=Q||U.position.x!==be.x||U.position.y!==be.y,U.position=be,U.internals.positionAbsolute=ye}if(k=k||Q,!!Q&&(O(p,!0),w&&(s||K||!D&&J))){const[me,U]=Up({nodeId:D,dragItems:p,nodeLookup:H});s?.(w,p,me,U),K?.(w,me,U),D||J?.(w,U)}}async function P(){if(!g)return;const{transform:V,panBy:X,autoPanSpeed:H,autoPanOnNodeDrag:_}=n();if(!_){f=!1,cancelAnimationFrame(c);return}const[T,B]=Wb(m,g,H);(T!==0||B!==0)&&(l.x=(l.x??0)-T/V[2],l.y=(l.y??0)-B/V[2],await X({x:T,y:B})&&L(l)),c=requestAnimationFrame(P)}function W(V){const{nodeLookup:X,multiSelectionActive:H,nodesDraggable:_,transform:T,snapGrid:B,snapToGrid:G,selectNodesOnDrag:K,onNodeDragStart:J,onSelectionDragStart:F,unselectNodesAndEdges:O}=n();x=!0,(!K||!I)&&!H&&D&&(X.get(D)?.selected||O()),I&&K&&D&&e?.(D);const Q=ti(V.sourceEvent,{transform:T,snapGrid:B,snapToGrid:G,containerBounds:g});if(l=Q,p=UE(X,_,Q,D),p.size>0&&(a||J||!D&&F)){const[q,ie]=Up({nodeId:D,dragItems:p,nodeLookup:X});a?.(V.sourceEvent,p,q,ie),J?.(V.sourceEvent,q,ie),D||F?.(V.sourceEvent,ie)}}const $=Eb().clickDistance(A).on("start",V=>{const{domNode:X,nodeDragThreshold:H,transform:_,snapGrid:T,snapToGrid:B}=n();g=X?.getBoundingClientRect()||null,v=!1,k=!1,w=V.sourceEvent,H===0&&W(V),l=ti(V.sourceEvent,{transform:_,snapGrid:T,snapToGrid:B,containerBounds:g}),m=Cn(V.sourceEvent,g)}).on("drag",V=>{const{autoPanOnNodeDrag:X,transform:H,snapGrid:_,snapToGrid:T,nodeDragThreshold:B,nodeLookup:G}=n(),K=ti(V.sourceEvent,{transform:H,snapGrid:_,snapToGrid:T,containerBounds:g});if(w=V.sourceEvent,(V.sourceEvent.type==="touchmove"&&V.sourceEvent.touches.length>1||D&&!G.has(D))&&(v=!0),!v){if(!f&&X&&x&&(f=!0,P()),!x){const J=Cn(V.sourceEvent,g),F=J.x-m.x,O=J.y-m.y;Math.sqrt(F*F+O*O)>B&&W(V)}(l.x!==K.xSnapped||l.y!==K.ySnapped)&&p&&x&&(m=Cn(V.sourceEvent,g),L(K))}}).on("end",V=>{if(!(!x||v)&&(f=!1,x=!1,cancelAnimationFrame(c),p.size>0)){const{nodeLookup:X,updateNodePositions:H,onNodeDragStop:_,onSelectionDragStop:T}=n();if(k&&(H(p,!1),k=!1),i||_||!D&&T){const[B,G]=Up({nodeId:D,dragItems:p,nodeLookup:X,dragging:!1});i?.(V.sourceEvent,p,B,G),_?.(V.sourceEvent,B,G),D||T?.(V.sourceEvent,G)}}}).filter(V=>{const X=V.target;return!V.button&&(!N||!Z0(X,`.${N}`,E))&&(!S||Z0(X,S,E))});b.call($)}function M(){b?.on(".drag",null)}return{update:C,destroy:M}}function KE(e,n,a){const s=[],i={x:e.x-a,y:e.y-a,width:a*2,height:a*2};for(const l of n.values())di(i,Ls(l))>0&&s.push(l);return s}const YE=250;function VE(e,n,a,s){let i=[],l=1/0;const c=KE(e,a,n+YE);for(const p of c){const f=[...p.internals.handleBounds?.source??[],...p.internals.handleBounds?.target??[]];for(const m of f){if(s.nodeId===m.nodeId&&s.type===m.type&&s.id===m.id)continue;const{x:g,y:x}=Ia(p,m,m.position,!0),b=Math.sqrt(Math.pow(g-e.x,2)+Math.pow(x-e.y,2));b>n||(b<l?(i=[{...m,x:g,y:x}],l=b):b===l&&i.push({...m,x:g,y:x}))}}if(!i.length)return null;if(i.length>1){const p=s.type==="source"?"target":"source";return i.find(f=>f.type===p)??i[0]}return i[0]}function u1(e,n,a,s,i,l=!1){const c=s.get(e);if(!c)return null;const p=i==="strict"?c.internals.handleBounds?.[n]:[...c.internals.handleBounds?.source??[],...c.internals.handleBounds?.target??[]],f=(a?p?.find(m=>m.id===a):p?.[0])??null;return f&&l?{...f,...Ia(c,f,f.position,!0)}:f}function d1(e,n){return e||(n?.classList.contains("target")?"target":n?.classList.contains("source")?"source":null)}function WE(e,n){let a=null;return n?a=!0:e&&!n&&(a=!1),a}const p1=()=>!0;function XE(e,{connectionMode:n,connectionRadius:a,handleId:s,nodeId:i,edgeUpdaterType:l,isTarget:c,domNode:p,nodeLookup:f,lib:m,autoPanOnConnect:g,flowId:x,panBy:b,cancelConnection:v,onConnectStart:k,onConnect:w,onConnectEnd:C,isValidConnection:M=p1,onReconnectEnd:N,updateConnection:S,getTransform:E,getFromHandle:I,autoPanSpeed:D,dragThreshold:A=1,handleDomNode:L}){const P=Jb(e.target);let W=0,$;const{x:V,y:X}=Cn(e),H=d1(l,L),_=p?.getBoundingClientRect();let T=!1;if(!_||!H)return;const B=u1(i,H,s,f,n);if(!B)return;let G=Cn(e,_),K=!1,J=null,F=!1,O=null;function Q(){if(!g||!_)return;const[be,ye]=Wb(G,_,D);b({x:be,y:ye}),W=requestAnimationFrame(Q)}const q={...B,nodeId:i,type:H,position:B.position},ie=f.get(i);let me={inProgress:!0,isValid:null,from:Ia(ie,q,Se.Left,!0),fromHandle:q,fromPosition:q.position,fromNode:ie,to:G,toHandle:null,toPosition:L0[q.position],toNode:null,pointer:G};function U(){T=!0,S(me),k?.(e,{nodeId:i,handleId:s,handleType:H})}A===0&&U();function ce(be){if(!T){const{x:ze,y:Tt}=Cn(be),ft=ze-V,vt=Tt-X;if(!(ft*ft+vt*vt>A*A))return;U()}if(!I()||!q){ge(be);return}const ye=E();G=Cn(be,_),$=VE(ji(G,ye,!1,[1,1]),a,f,q),K||(Q(),K=!0);const te=f1(be,{handle:$,connectionMode:n,fromNodeId:i,fromHandleId:s,fromType:c?"target":"source",isValidConnection:M,doc:P,lib:m,flowId:x,nodeLookup:f});O=te.handleDomNode,J=te.connection,F=WE(!!$,te.isValid);const he=f.get(i),je=he?Ia(he,q,Se.Left,!0):me.from,Ie={...me,from:je,isValid:F,to:te.toHandle&&F?Lc({x:te.toHandle.x,y:te.toHandle.y},ye):G,toHandle:te.toHandle,toPosition:F&&te.toHandle?te.toHandle.position:L0[q.position],toNode:te.toHandle?f.get(te.toHandle.nodeId):null,pointer:G};S(Ie),me=Ie}function ge(be){if(!("touches"in be&&be.touches.length>0)){if(T){($||O)&&J&&F&&w?.(J);const{inProgress:ye,...te}=me,he={...te,toPosition:me.toHandle?me.toPosition:null};C?.(be,he),l&&N?.(be,he)}v(),cancelAnimationFrame(W),K=!1,F=!1,J=null,O=null,P.removeEventListener("mousemove",ce),P.removeEventListener("mouseup",ge),P.removeEventListener("touchmove",ce),P.removeEventListener("touchend",ge)}}P.addEventListener("mousemove",ce),P.addEventListener("mouseup",ge),P.addEventListener("touchmove",ce),P.addEventListener("touchend",ge)}function f1(e,{handle:n,connectionMode:a,fromNodeId:s,fromHandleId:i,fromType:l,doc:c,lib:p,flowId:f,isValidConnection:m=p1,nodeLookup:g}){const x=l==="target",b=n?c.querySelector(`.${p}-flow__handle[data-id="${f}-${n?.nodeId}-${n?.id}-${n?.type}"]`):null,{x:v,y:k}=Cn(e),w=c.elementFromPoint(v,k),C=w?.classList.contains(`${p}-flow__handle`)?w:b,M={handleDomNode:C,isValid:!1,connection:null,toHandle:null};if(C){const N=d1(void 0,C),S=C.getAttribute("data-nodeid"),E=C.getAttribute("data-handleid"),I=C.classList.contains("connectable"),D=C.classList.contains("connectableend");if(!S||!N)return M;const A={source:x?S:s,sourceHandle:x?E:i,target:x?s:S,targetHandle:x?i:E};M.connection=A;const P=I&&D&&(a===Fs.Strict?x&&N==="source"||!x&&N==="target":S!==s||E!==i);M.isValid=P&&m(A),M.toHandle=u1(S,N,E,g,a,!0)}return M}const Af={onPointerDown:XE,isValid:f1};function ZE({domNode:e,panZoom:n,getTransform:a,getViewScale:s}){const i=Jt(e);function l({translateExtent:p,width:f,height:m,zoomStep:g=1,pannable:x=!0,zoomable:b=!0,inversePan:v=!1}){const k=S=>{if(S.sourceEvent.type!=="wheel"||!n)return;const E=a(),I=S.sourceEvent.ctrlKey&&pi()?10:1,D=-S.sourceEvent.deltaY*(S.sourceEvent.deltaMode===1?.05:S.sourceEvent.deltaMode?1:.002)*g,A=E[2]*Math.pow(2,D*I);n.scaleTo(A)};let w=[0,0];const C=S=>{(S.sourceEvent.type==="mousedown"||S.sourceEvent.type==="touchstart")&&(w=[S.sourceEvent.clientX??S.sourceEvent.touches[0].clientX,S.sourceEvent.clientY??S.sourceEvent.touches[0].clientY])},M=S=>{const E=a();if(S.sourceEvent.type!=="mousemove"&&S.sourceEvent.type!=="touchmove"||!n)return;const I=[S.sourceEvent.clientX??S.sourceEvent.touches[0].clientX,S.sourceEvent.clientY??S.sourceEvent.touches[0].clientY],D=[I[0]-w[0],I[1]-w[1]];w=I;const A=s()*Math.max(E[2],Math.log(E[2]))*(v?-1:1),L={x:E[0]-D[0]*A,y:E[1]-D[1]*A},P=[[0,0],[f,m]];n.setViewportConstrained({x:L.x,y:L.y,zoom:E[2]},P,p)},N=Pb().on("start",C).on("zoom",x?M:null).on("zoom.wheel",b?k:null);i.call(N,{})}function c(){i.on("zoom",null)}return{update:l,destroy:c,pointer:vn}}const tu=e=>({x:e.x,y:e.y,zoom:e.k}),Gp=({x:e,y:n,zoom:a})=>Qc.translate(e,n).scale(a),Ns=(e,n)=>e.target.closest(`.${n}`),m1=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),QE=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,qp=(e,n=0,a=QE,s=()=>{})=>{const i=typeof n=="number"&&n>0;return i||s(),i?e.transition().duration(n).ease(a).on("end",s):e},h1=e=>{const n=e.ctrlKey&&pi()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n};function JE({zoomPanValues:e,noWheelClassName:n,d3Selection:a,d3Zoom:s,panOnScrollMode:i,panOnScrollSpeed:l,zoomOnPinch:c,onPanZoomStart:p,onPanZoom:f,onPanZoomEnd:m}){return g=>{if(Ns(g,n))return g.ctrlKey&&g.preventDefault(),!1;g.preventDefault(),g.stopImmediatePropagation();const x=a.property("__zoom").k||1;if(g.ctrlKey&&c){const C=vn(g),M=h1(g),N=x*Math.pow(2,M);s.scaleTo(a,N,C,g);return}const b=g.deltaMode===1?20:1;let v=i===Da.Vertical?0:g.deltaX*b,k=i===Da.Horizontal?0:g.deltaY*b;!pi()&&g.shiftKey&&i!==Da.Vertical&&(v=g.deltaY*b,k=0),s.translateBy(a,-(v/x)*l,-(k/x)*l,{internal:!0});const w=tu(a.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(f?.(g,w),e.panScrollTimeout=setTimeout(()=>{m?.(g,w),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,p?.(g,w))}}function ej({noWheelClassName:e,preventScrolling:n,d3ZoomHandler:a}){return function(s,i){const l=s.type==="wheel",c=!n&&l&&!s.ctrlKey,p=Ns(s,e);if(s.ctrlKey&&l&&p&&s.preventDefault(),c||p)return null;s.preventDefault(),a.call(this,s,i)}}function tj({zoomPanValues:e,onDraggingChange:n,onPanZoomStart:a}){return s=>{if(s.sourceEvent?.internal)return;const i=tu(s.transform);e.mouseButton=s.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,s.sourceEvent?.type==="mousedown"&&n(!0),a&&a?.(s.sourceEvent,i)}}function nj({zoomPanValues:e,panOnDrag:n,onPaneContextMenu:a,onTransformChange:s,onPanZoom:i}){return l=>{e.usedRightMouseButton=!!(a&&m1(n,e.mouseButton??0)),l.sourceEvent?.sync||s([l.transform.x,l.transform.y,l.transform.k]),i&&!l.sourceEvent?.internal&&i?.(l.sourceEvent,tu(l.transform))}}function oj({zoomPanValues:e,panOnDrag:n,panOnScroll:a,onDraggingChange:s,onPanZoomEnd:i,onPaneContextMenu:l}){return c=>{if(!c.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,l&&m1(n,e.mouseButton??0)&&!e.usedRightMouseButton&&c.sourceEvent&&l(c.sourceEvent),e.usedRightMouseButton=!1,s(!1),i)){const p=tu(c.transform);e.prevViewport=p,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(c.sourceEvent,p)},a?150:0)}}}function aj({zoomActivationKeyPressed:e,zoomOnScroll:n,zoomOnPinch:a,panOnDrag:s,panOnScroll:i,zoomOnDoubleClick:l,userSelectionActive:c,noWheelClassName:p,noPanClassName:f,lib:m,connectionInProgress:g}){return x=>{const b=e||n,v=a&&x.ctrlKey,k=x.type==="wheel";if(x.button===1&&x.type==="mousedown"&&(Ns(x,`${m}-flow__node`)||Ns(x,`${m}-flow__edge`)))return!0;if(!s&&!b&&!i&&!l&&!a||c||g&&!k||Ns(x,p)&&k||Ns(x,f)&&(!k||i&&k&&!e)||!a&&x.ctrlKey&&k)return!1;if(!a&&x.type==="touchstart"&&x.touches?.length>1)return x.preventDefault(),!1;if(!b&&!i&&!v&&k||!s&&(x.type==="mousedown"||x.type==="touchstart")||Array.isArray(s)&&!s.includes(x.button)&&x.type==="mousedown")return!1;const w=Array.isArray(s)&&s.includes(x.button)||!x.button||x.button<=1;return(!x.ctrlKey||k)&&w}}function sj({domNode:e,minZoom:n,maxZoom:a,translateExtent:s,viewport:i,onPanZoom:l,onPanZoomStart:c,onPanZoomEnd:p,onDraggingChange:f}){const m={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},g=e.getBoundingClientRect(),x=Pb().scaleExtent([n,a]).translateExtent(s),b=Jt(e).call(x);N({x:i.x,y:i.y,zoom:Is(i.zoom,n,a)},[[0,0],[g.width,g.height]],s);const v=b.on("wheel.zoom"),k=b.on("dblclick.zoom");x.wheelDelta(h1);function w($,V){return b?new Promise(X=>{x?.interpolate(V?.interpolate==="linear"?ei:Sc).transform(qp(b,V?.duration,V?.ease,()=>X(!0)),$)}):Promise.resolve(!1)}function C({noWheelClassName:$,noPanClassName:V,onPaneContextMenu:X,userSelectionActive:H,panOnScroll:_,panOnDrag:T,panOnScrollMode:B,panOnScrollSpeed:G,preventScrolling:K,zoomOnPinch:J,zoomOnScroll:F,zoomOnDoubleClick:O,zoomActivationKeyPressed:Q,lib:q,onTransformChange:ie,connectionInProgress:pe,paneClickDistance:me,selectionOnDrag:U}){H&&!m.isZoomingOrPanning&&M();const ce=_&&!Q&&!H;x.clickDistance(U?1/0:!Sn(me)||me<0?0:me);const ge=ce?JE({zoomPanValues:m,noWheelClassName:$,d3Selection:b,d3Zoom:x,panOnScrollMode:B,panOnScrollSpeed:G,zoomOnPinch:J,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:p}):ej({noWheelClassName:$,preventScrolling:K,d3ZoomHandler:v});if(b.on("wheel.zoom",ge,{passive:!1}),!H){const ye=tj({zoomPanValues:m,onDraggingChange:f,onPanZoomStart:c});x.on("start",ye);const te=nj({zoomPanValues:m,panOnDrag:T,onPaneContextMenu:!!X,onPanZoom:l,onTransformChange:ie});x.on("zoom",te);const he=oj({zoomPanValues:m,panOnDrag:T,panOnScroll:_,onPaneContextMenu:X,onPanZoomEnd:p,onDraggingChange:f});x.on("end",he)}const be=aj({zoomActivationKeyPressed:Q,panOnDrag:T,zoomOnScroll:F,panOnScroll:_,zoomOnDoubleClick:O,zoomOnPinch:J,userSelectionActive:H,noPanClassName:V,noWheelClassName:$,lib:q,connectionInProgress:pe});x.filter(be),O?b.on("dblclick.zoom",k):b.on("dblclick.zoom",null)}function M(){x.on("zoom",null)}async function N($,V,X){const H=Gp($),_=x?.constrain()(H,V,X);return _&&await w(_),new Promise(T=>T(_))}async function S($,V){const X=Gp($);return await w(X,V),new Promise(H=>H(X))}function E($){if(b){const V=Gp($),X=b.property("__zoom");(X.k!==$.zoom||X.x!==$.x||X.y!==$.y)&&x?.transform(b,V,null,{sync:!0})}}function I(){const $=b?Bb(b.node()):{x:0,y:0,k:1};return{x:$.x,y:$.y,zoom:$.k}}function D($,V){return b?new Promise(X=>{x?.interpolate(V?.interpolate==="linear"?ei:Sc).scaleTo(qp(b,V?.duration,V?.ease,()=>X(!0)),$)}):Promise.resolve(!1)}function A($,V){return b?new Promise(X=>{x?.interpolate(V?.interpolate==="linear"?ei:Sc).scaleBy(qp(b,V?.duration,V?.ease,()=>X(!0)),$)}):Promise.resolve(!1)}function L($){x?.scaleExtent($)}function P($){x?.translateExtent($)}function W($){const V=!Sn($)||$<0?0:$;x?.clickDistance(V)}return{update:C,destroy:M,setViewport:S,setViewportConstrained:N,getViewport:I,scaleTo:D,scaleBy:A,setScaleExtent:L,setTranslateExtent:P,syncViewport:E,setClickDistance:W}}var Ps;(function(e){e.Line="line",e.Handle="handle"})(Ps||(Ps={}));function rj({width:e,prevWidth:n,height:a,prevHeight:s,affectsX:i,affectsY:l}){const c=e-n,p=a-s,f=[c>0?1:c<0?-1:0,p>0?1:p<0?-1:0];return c&&i&&(f[0]=f[0]*-1),p&&l&&(f[1]=f[1]*-1),f}function Q0(e){const n=e.includes("right")||e.includes("left"),a=e.includes("bottom")||e.includes("top"),s=e.includes("left"),i=e.includes("top");return{isHorizontal:n,isVertical:a,affectsX:s,affectsY:i}}function Ko(e,n){return Math.max(0,n-e)}function Yo(e,n){return Math.max(0,e-n)}function dc(e,n,a){return Math.max(0,n-e,e-a)}function J0(e,n){return e?!n:n}function ij(e,n,a,s,i,l,c,p){let{affectsX:f,affectsY:m}=n;const{isHorizontal:g,isVertical:x}=n,b=g&&x,{xSnapped:v,ySnapped:k}=a,{minWidth:w,maxWidth:C,minHeight:M,maxHeight:N}=s,{x:S,y:E,width:I,height:D,aspectRatio:A}=e;let L=Math.floor(g?v-e.pointerX:0),P=Math.floor(x?k-e.pointerY:0);const W=I+(f?-L:L),$=D+(m?-P:P),V=-l[0]*I,X=-l[1]*D;let H=dc(W,w,C),_=dc($,M,N);if(c){let G=0,K=0;f&&L<0?G=Ko(S+L+V,c[0][0]):!f&&L>0&&(G=Yo(S+W+V,c[1][0])),m&&P<0?K=Ko(E+P+X,c[0][1]):!m&&P>0&&(K=Yo(E+$+X,c[1][1])),H=Math.max(H,G),_=Math.max(_,K)}if(p){let G=0,K=0;f&&L>0?G=Yo(S+L,p[0][0]):!f&&L<0&&(G=Ko(S+W,p[1][0])),m&&P>0?K=Yo(E+P,p[0][1]):!m&&P<0&&(K=Ko(E+$,p[1][1])),H=Math.max(H,G),_=Math.max(_,K)}if(i){if(g){const G=dc(W/A,M,N)*A;if(H=Math.max(H,G),c){let K=0;!f&&!m||f&&!m&&b?K=Yo(E+X+W/A,c[1][1])*A:K=Ko(E+X+(f?L:-L)/A,c[0][1])*A,H=Math.max(H,K)}if(p){let K=0;!f&&!m||f&&!m&&b?K=Ko(E+W/A,p[1][1])*A:K=Yo(E+(f?L:-L)/A,p[0][1])*A,H=Math.max(H,K)}}if(x){const G=dc($*A,w,C)/A;if(_=Math.max(_,G),c){let K=0;!f&&!m||m&&!f&&b?K=Yo(S+$*A+V,c[1][0])/A:K=Ko(S+(m?P:-P)*A+V,c[0][0])/A,_=Math.max(_,K)}if(p){let K=0;!f&&!m||m&&!f&&b?K=Ko(S+$*A,p[1][0])/A:K=Yo(S+(m?P:-P)*A,p[0][0])/A,_=Math.max(_,K)}}}P=P+(P<0?_:-_),L=L+(L<0?H:-H),i&&(b?W>$*A?P=(J0(f,m)?-L:L)/A:L=(J0(f,m)?-P:P)*A:g?(P=L/A,m=f):(L=P*A,f=m));const T=f?S+L:S,B=m?E+P:E;return{width:I+(f?-L:L),height:D+(m?-P:P),x:l[0]*L*(f?-1:1)+T,y:l[1]*P*(m?-1:1)+B}}const g1={width:0,height:0,x:0,y:0},lj={...g1,pointerX:0,pointerY:0,aspectRatio:1};function cj(e){return[[0,0],[e.measured.width,e.measured.height]]}function uj(e,n,a){const s=n.position.x+e.position.x,i=n.position.y+e.position.y,l=e.measured.width??0,c=e.measured.height??0,p=a[0]*l,f=a[1]*c;return[[s-p,i-f],[s+l-p,i+c-f]]}function dj({domNode:e,nodeId:n,getStoreItems:a,onChange:s,onEnd:i}){const l=Jt(e);let c={controlDirection:Q0("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function p({controlPosition:m,boundaries:g,keepAspectRatio:x,resizeDirection:b,onResizeStart:v,onResize:k,onResizeEnd:w,shouldResize:C}){let M={...g1},N={...lj};c={boundaries:g,resizeDirection:b,keepAspectRatio:x,controlDirection:Q0(m)};let S,E=null,I=[],D,A,L,P=!1;const W=Eb().on("start",$=>{const{nodeLookup:V,transform:X,snapGrid:H,snapToGrid:_,nodeOrigin:T,paneDomNode:B}=a();if(S=V.get(n),!S)return;E=B?.getBoundingClientRect()??null;const{xSnapped:G,ySnapped:K}=ti($.sourceEvent,{transform:X,snapGrid:H,snapToGrid:_,containerBounds:E});M={width:S.measured.width??0,height:S.measured.height??0,x:S.position.x??0,y:S.position.y??0},N={...M,pointerX:G,pointerY:K,aspectRatio:M.width/M.height},D=void 0,S.parentId&&(S.extent==="parent"||S.expandParent)&&(D=V.get(S.parentId),A=D&&S.extent==="parent"?cj(D):void 0),I=[],L=void 0;for(const[J,F]of V)if(F.parentId===n&&(I.push({id:J,position:{...F.position},extent:F.extent}),F.extent==="parent"||F.expandParent)){const O=uj(F,S,F.origin??T);L?L=[[Math.min(O[0][0],L[0][0]),Math.min(O[0][1],L[0][1])],[Math.max(O[1][0],L[1][0]),Math.max(O[1][1],L[1][1])]]:L=O}v?.($,{...M})}).on("drag",$=>{const{transform:V,snapGrid:X,snapToGrid:H,nodeOrigin:_}=a(),T=ti($.sourceEvent,{transform:V,snapGrid:X,snapToGrid:H,containerBounds:E}),B=[];if(!S)return;const{x:G,y:K,width:J,height:F}=M,O={},Q=S.origin??_,{width:q,height:ie,x:pe,y:me}=ij(N,c.controlDirection,T,c.boundaries,c.keepAspectRatio,Q,A,L),U=q!==J,ce=ie!==F,ge=pe!==G&&U,be=me!==K&&ce;if(!ge&&!be&&!U&&!ce)return;if((ge||be||Q[0]===1||Q[1]===1)&&(O.x=ge?pe:M.x,O.y=be?me:M.y,M.x=O.x,M.y=O.y,I.length>0)){const je=pe-G,Ie=me-K;for(const ze of I)ze.position={x:ze.position.x-je+Q[0]*(q-J),y:ze.position.y-Ie+Q[1]*(ie-F)},B.push(ze)}if((U||ce)&&(O.width=U&&(!c.resizeDirection||c.resizeDirection==="horizontal")?q:M.width,O.height=ce&&(!c.resizeDirection||c.resizeDirection==="vertical")?ie:M.height,M.width=O.width,M.height=O.height),D&&S.expandParent){const je=Q[0]*(O.width??0);O.x&&O.x<je&&(M.x=je,N.x=N.x-(O.x-je));const Ie=Q[1]*(O.height??0);O.y&&O.y<Ie&&(M.y=Ie,N.y=N.y-(O.y-Ie))}const ye=rj({width:M.width,prevWidth:J,height:M.height,prevHeight:F,affectsX:c.controlDirection.affectsX,affectsY:c.controlDirection.affectsY}),te={...M,direction:ye};C?.($,te)!==!1&&(P=!0,k?.($,te),s(O,B))}).on("end",$=>{P&&(w?.($,{...M}),i?.({...M}),P=!1)});l.call(W)}function f(){l.on(".drag",null)}return{update:p,destroy:f}}var Kp={exports:{}},Yp={},Vp={exports:{}},Wp={};var ex;function pj(){if(ex)return Wp;ex=1;var e=ki();function n(x,b){return x===b&&(x!==0||1/x===1/b)||x!==x&&b!==b}var a=typeof Object.is=="function"?Object.is:n,s=e.useState,i=e.useEffect,l=e.useLayoutEffect,c=e.useDebugValue;function p(x,b){var v=b(),k=s({inst:{value:v,getSnapshot:b}}),w=k[0].inst,C=k[1];return l(function(){w.value=v,w.getSnapshot=b,f(w)&&C({inst:w})},[x,v,b]),i(function(){return f(w)&&C({inst:w}),x(function(){f(w)&&C({inst:w})})},[x]),c(v),v}function f(x){var b=x.getSnapshot;x=x.value;try{var v=b();return!a(x,v)}catch{return!0}}function m(x,b){return b()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?m:p;return Wp.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:g,Wp}var tx;function fj(){return tx||(tx=1,Vp.exports=pj()),Vp.exports}var nx;function mj(){if(nx)return Yp;nx=1;var e=ki(),n=fj();function a(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var s=typeof Object.is=="function"?Object.is:a,i=n.useSyncExternalStore,l=e.useRef,c=e.useEffect,p=e.useMemo,f=e.useDebugValue;return Yp.useSyncExternalStoreWithSelector=function(m,g,x,b,v){var k=l(null);if(k.current===null){var w={hasValue:!1,value:null};k.current=w}else w=k.current;k=p(function(){function M(D){if(!N){if(N=!0,S=D,D=b(D),v!==void 0&&w.hasValue){var A=w.value;if(v(A,D))return E=A}return E=D}if(A=E,s(S,D))return A;var L=b(D);return v!==void 0&&v(A,L)?(S=D,A):(S=D,E=L)}var N=!1,S,E,I=x===void 0?null:x;return[function(){return M(g())},I===null?void 0:function(){return M(I())}]},[g,x,b,v]);var C=i(m,k[0],k[1]);return c(function(){w.hasValue=!0,w.value=C},[C]),f(C),C},Yp}var ox;function hj(){return ox||(ox=1,Kp.exports=mj()),Kp.exports}var gj=hj();const yj=rb(gj),xj={},ax=e=>{let n;const a=new Set,s=(g,x)=>{const b=typeof g=="function"?g(n):g;if(!Object.is(b,n)){const v=n;n=x??(typeof b!="object"||b===null)?b:Object.assign({},n,b),a.forEach(k=>k(n,v))}},i=()=>n,f={setState:s,getState:i,getInitialState:()=>m,subscribe:g=>(a.add(g),()=>a.delete(g)),destroy:()=>{(xj?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),a.clear()}},m=n=e(s,i,f);return f},bj=e=>e?ax(e):ax,{useDebugValue:vj}=Vr,{useSyncExternalStoreWithSelector:kj}=yj,wj=e=>e;function y1(e,n=wj,a){const s=kj(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,a);return vj(s),s}const sx=(e,n)=>{const a=bj(e),s=(i,l=n)=>y1(a,i,l);return Object.assign(s,a),s},Sj=(e,n)=>e?sx(e,n):sx;function et(e,n){if(Object.is(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(const[s,i]of e)if(!Object.is(i,n.get(s)))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(const s of e)if(!n.has(s))return!1;return!0}const a=Object.keys(e);if(a.length!==Object.keys(n).length)return!1;for(const s of a)if(!Object.prototype.hasOwnProperty.call(n,s)||!Object.is(e[s],n[s]))return!1;return!0}var nu=ib();const ou=z.createContext(null),Cj=ou.Provider,x1=In.error001();function Fe(e,n){const a=z.useContext(ou);if(a===null)throw new Error(x1);return y1(a,e,n)}function tt(){const e=z.useContext(ou);if(e===null)throw new Error(x1);return z.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const rx={display:"none"},Mj={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},b1="react-flow__node-desc",v1="react-flow__edge-desc",Ej="react-flow__aria-live",jj=e=>e.ariaLiveMessage,Tj=e=>e.ariaLabelConfig;function Nj({rfId:e}){const n=Fe(jj);return d.jsx("div",{id:`${Ej}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Mj,children:n})}function Aj({rfId:e,disableKeyboardA11y:n}){const a=Fe(Tj);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${b1}-${e}`,style:rx,children:n?a["node.a11yDescription.default"]:a["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${v1}-${e}`,style:rx,children:a["edge.a11yDescription.default"]}),!n&&d.jsx(Nj,{rfId:e})]})}const au=z.forwardRef(({position:e="top-left",children:n,className:a,style:s,...i},l)=>{const c=`${e}`.split("-");return d.jsx("div",{className:pt(["react-flow__panel",a,...c]),style:s,ref:l,...i,children:n})});au.displayName="Panel";function _j({proOptions:e,position:n="bottom-right"}){return e?.hideAttribution?null:d.jsx(au,{position:n,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:d.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Dj=e=>{const n=[],a=[];for(const[,s]of e.nodeLookup)s.selected&&n.push(s.internals.userNode);for(const[,s]of e.edgeLookup)s.selected&&a.push(s);return{selectedNodes:n,selectedEdges:a}},pc=e=>e.id;function zj(e,n){return et(e.selectedNodes.map(pc),n.selectedNodes.map(pc))&&et(e.selectedEdges.map(pc),n.selectedEdges.map(pc))}function Rj({onSelectionChange:e}){const n=tt(),{selectedNodes:a,selectedEdges:s}=Fe(Dj,zj);return z.useEffect(()=>{const i={nodes:a,edges:s};e?.(i),n.getState().onSelectionChangeHandlers.forEach(l=>l(i))},[a,s,e]),null}const $j=e=>!!e.onSelectionChangeHandlers;function Oj({onSelectionChange:e}){const n=Fe($j);return e||n?d.jsx(Rj,{onSelectionChange:e}):null}const k1=[0,0],Fj={x:0,y:0,zoom:1},Ij=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],ix=[...Ij,"rfId"],Lj=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),lx={translateExtent:ci,nodeOrigin:k1,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Bj(e){const{setNodes:n,setEdges:a,setMinZoom:s,setMaxZoom:i,setTranslateExtent:l,setNodeExtent:c,reset:p,setDefaultNodesAndEdges:f}=Fe(Lj,et),m=tt();z.useEffect(()=>(f(e.defaultNodes,e.defaultEdges),()=>{g.current=lx,p()}),[]);const g=z.useRef(lx);return z.useEffect(()=>{for(const x of ix){const b=e[x],v=g.current[x];b!==v&&(typeof e[x]>"u"||(x==="nodes"?n(b):x==="edges"?a(b):x==="minZoom"?s(b):x==="maxZoom"?i(b):x==="translateExtent"?l(b):x==="nodeExtent"?c(b):x==="ariaLabelConfig"?m.setState({ariaLabelConfig:SE(b)}):x==="fitView"?m.setState({fitViewQueued:b}):x==="fitViewOptions"?m.setState({fitViewOptions:b}):m.setState({[x]:b})))}g.current=e},ix.map(x=>e[x])),null}function cx(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Pj(e){const[n,a]=z.useState(e==="system"?null:e);return z.useEffect(()=>{if(e!=="system"){a(e);return}const s=cx(),i=()=>a(s?.matches?"dark":"light");return i(),s?.addEventListener("change",i),()=>{s?.removeEventListener("change",i)}},[e]),n!==null?n:cx()?.matches?"dark":"light"}const ux=typeof document<"u"?document:null;function fi(e=null,n={target:ux,actInsideInputWithModifier:!0}){const[a,s]=z.useState(!1),i=z.useRef(!1),l=z.useRef(new Set([])),[c,p]=z.useMemo(()=>{if(e!==null){const m=(Array.isArray(e)?e:[e]).filter(x=>typeof x=="string").map(x=>x.replace("+",`
13
+ `).replace(`
14
+
15
+ `,`
16
+ +`).split(`
17
+ `)),g=m.reduce((x,b)=>x.concat(...b),[]);return[m,g]}return[[],[]]},[e]);return z.useEffect(()=>{const f=n?.target??ux,m=n?.actInsideInputWithModifier??!0;if(e!==null){const g=v=>{if(i.current=v.ctrlKey||v.metaKey||v.shiftKey||v.altKey,(!i.current||i.current&&!m)&&e1(v))return!1;const w=px(v.code,p);if(l.current.add(v[w]),dx(c,l.current,!1)){const C=v.composedPath?.()?.[0]||v.target,M=C?.nodeName==="BUTTON"||C?.nodeName==="A";n.preventDefault!==!1&&(i.current||!M)&&v.preventDefault(),s(!0)}},x=v=>{const k=px(v.code,p);dx(c,l.current,!0)?(s(!1),l.current.clear()):l.current.delete(v[k]),v.key==="Meta"&&l.current.clear(),i.current=!1},b=()=>{l.current.clear(),s(!1)};return f?.addEventListener("keydown",g),f?.addEventListener("keyup",x),window.addEventListener("blur",b),window.addEventListener("contextmenu",b),()=>{f?.removeEventListener("keydown",g),f?.removeEventListener("keyup",x),window.removeEventListener("blur",b),window.removeEventListener("contextmenu",b)}}},[e,s]),a}function dx(e,n,a){return e.filter(s=>a||s.length===n.size).some(s=>s.every(i=>n.has(i)))}function px(e,n){return n.includes(e)?"code":"key"}const Hj=()=>{const e=tt();return z.useMemo(()=>({zoomIn:n=>{const{panZoom:a}=e.getState();return a?a.scaleBy(1.2,{duration:n?.duration}):Promise.resolve(!1)},zoomOut:n=>{const{panZoom:a}=e.getState();return a?a.scaleBy(1/1.2,{duration:n?.duration}):Promise.resolve(!1)},zoomTo:(n,a)=>{const{panZoom:s}=e.getState();return s?s.scaleTo(n,{duration:a?.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(n,a)=>{const{transform:[s,i,l],panZoom:c}=e.getState();return c?(await c.setViewport({x:n.x??s,y:n.y??i,zoom:n.zoom??l},a),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[n,a,s]=e.getState().transform;return{x:n,y:a,zoom:s}},setCenter:async(n,a,s)=>e.getState().setCenter(n,a,s),fitBounds:async(n,a)=>{const{width:s,height:i,minZoom:l,maxZoom:c,panZoom:p}=e.getState(),f=Xf(n,s,i,l,c,a?.padding??.1);return p?(await p.setViewport(f,{duration:a?.duration,ease:a?.ease,interpolate:a?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(n,a={})=>{const{transform:s,snapGrid:i,snapToGrid:l,domNode:c}=e.getState();if(!c)return n;const{x:p,y:f}=c.getBoundingClientRect(),m={x:n.x-p,y:n.y-f},g=a.snapGrid??i,x=a.snapToGrid??l;return ji(m,s,x,g)},flowToScreenPosition:n=>{const{transform:a,domNode:s}=e.getState();if(!s)return n;const{x:i,y:l}=s.getBoundingClientRect(),c=Lc(n,a);return{x:c.x+i,y:c.y+l}}}),[])};function w1(e,n){const a=[],s=new Map,i=[];for(const l of e)if(l.type==="add"){i.push(l);continue}else if(l.type==="remove"||l.type==="replace")s.set(l.id,[l]);else{const c=s.get(l.id);c?c.push(l):s.set(l.id,[l])}for(const l of n){const c=s.get(l.id);if(!c){a.push(l);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){a.push({...c[0].item});continue}const p={...l};for(const f of c)Uj(f,p);a.push(p)}return i.length&&i.forEach(l=>{l.index!==void 0?a.splice(l.index,0,{...l.item}):a.push({...l.item})}),a}function Uj(e,n){switch(e.type){case"select":{n.selected=e.selected;break}case"position":{typeof e.position<"u"&&(n.position=e.position),typeof e.dragging<"u"&&(n.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(n.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(n.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(n.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(n.resizing=e.resizing);break}}}function Gj(e,n){return w1(e,n)}function qj(e,n){return w1(e,n)}function ja(e,n){return{id:e,type:"select",selected:n}}function As(e,n=new Set,a=!1){const s=[];for(const[i,l]of e){const c=n.has(i);!(l.selected===void 0&&!c)&&l.selected!==c&&(a&&(l.selected=c),s.push(ja(l.id,c)))}return s}function fx({items:e=[],lookup:n}){const a=[],s=new Map(e.map(i=>[i.id,i]));for(const[i,l]of e.entries()){const c=n.get(l.id),p=c?.internals?.userNode??c;p!==void 0&&p!==l&&a.push({id:l.id,item:l,type:"replace"}),p===void 0&&a.push({item:l,type:"add",index:i})}for(const[i]of n)s.get(i)===void 0&&a.push({id:i,type:"remove"});return a}function mx(e){return{id:e.id,type:"remove"}}const hx=e=>fE(e),Kj=e=>Kb(e);function S1(e){return z.forwardRef(e)}const Yj=typeof window<"u"?z.useLayoutEffect:z.useEffect;function gx(e){const[n,a]=z.useState(BigInt(0)),[s]=z.useState(()=>Vj(()=>a(i=>i+BigInt(1))));return Yj(()=>{const i=s.get();i.length&&(e(i),s.reset())},[n]),s}function Vj(e){let n=[];return{get:()=>n,reset:()=>{n=[]},push:a=>{n.push(a),e()}}}const C1=z.createContext(null);function Wj({children:e}){const n=tt(),a=z.useCallback(p=>{const{nodes:f=[],setNodes:m,hasDefaultNodes:g,onNodesChange:x,nodeLookup:b,fitViewQueued:v,onNodesChangeMiddlewareMap:k}=n.getState();let w=f;for(const M of p)w=typeof M=="function"?M(w):M;let C=fx({items:w,lookup:b});for(const M of k.values())C=M(C);g&&m(w),C.length>0?x?.(C):v&&window.requestAnimationFrame(()=>{const{fitViewQueued:M,nodes:N,setNodes:S}=n.getState();M&&S(N)})},[]),s=gx(a),i=z.useCallback(p=>{const{edges:f=[],setEdges:m,hasDefaultEdges:g,onEdgesChange:x,edgeLookup:b}=n.getState();let v=f;for(const k of p)v=typeof k=="function"?k(v):k;g?m(v):x&&x(fx({items:v,lookup:b}))},[]),l=gx(i),c=z.useMemo(()=>({nodeQueue:s,edgeQueue:l}),[]);return d.jsx(C1.Provider,{value:c,children:e})}function Xj(){const e=z.useContext(C1);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Zj=e=>!!e.panZoom;function om(){const e=Hj(),n=tt(),a=Xj(),s=Fe(Zj),i=z.useMemo(()=>{const l=x=>n.getState().nodeLookup.get(x),c=x=>{a.nodeQueue.push(x)},p=x=>{a.edgeQueue.push(x)},f=x=>{const{nodeLookup:b,nodeOrigin:v}=n.getState(),k=hx(x)?x:b.get(x.id),w=k.parentId?Qb(k.position,k.measured,k.parentId,b,v):k.position,C={...k,position:w,width:k.measured?.width??k.width,height:k.measured?.height??k.height};return Ls(C)},m=(x,b,v={replace:!1})=>{c(k=>k.map(w=>{if(w.id===x){const C=typeof b=="function"?b(w):b;return v.replace&&hx(C)?C:{...w,...C}}return w}))},g=(x,b,v={replace:!1})=>{p(k=>k.map(w=>{if(w.id===x){const C=typeof b=="function"?b(w):b;return v.replace&&Kj(C)?C:{...w,...C}}return w}))};return{getNodes:()=>n.getState().nodes.map(x=>({...x})),getNode:x=>l(x)?.internals.userNode,getInternalNode:l,getEdges:()=>{const{edges:x=[]}=n.getState();return x.map(b=>({...b}))},getEdge:x=>n.getState().edgeLookup.get(x),setNodes:c,setEdges:p,addNodes:x=>{const b=Array.isArray(x)?x:[x];a.nodeQueue.push(v=>[...v,...b])},addEdges:x=>{const b=Array.isArray(x)?x:[x];a.edgeQueue.push(v=>[...v,...b])},toObject:()=>{const{nodes:x=[],edges:b=[],transform:v}=n.getState(),[k,w,C]=v;return{nodes:x.map(M=>({...M})),edges:b.map(M=>({...M})),viewport:{x:k,y:w,zoom:C}}},deleteElements:async({nodes:x=[],edges:b=[]})=>{const{nodes:v,edges:k,onNodesDelete:w,onEdgesDelete:C,triggerNodeChanges:M,triggerEdgeChanges:N,onDelete:S,onBeforeDelete:E}=n.getState(),{nodes:I,edges:D}=await xE({nodesToRemove:x,edgesToRemove:b,nodes:v,edges:k,onBeforeDelete:E}),A=D.length>0,L=I.length>0;if(A){const P=D.map(mx);C?.(D),N(P)}if(L){const P=I.map(mx);w?.(I),M(P)}return(L||A)&&S?.({nodes:I,edges:D}),{deletedNodes:I,deletedEdges:D}},getIntersectingNodes:(x,b=!0,v)=>{const k=P0(x),w=k?x:f(x),C=v!==void 0;return w?(v||n.getState().nodes).filter(M=>{const N=n.getState().nodeLookup.get(M.id);if(N&&!k&&(M.id===x.id||!N.internals.positionAbsolute))return!1;const S=Ls(C?M:N),E=di(S,w);return b&&E>0||E>=S.width*S.height||E>=w.width*w.height}):[]},isNodeIntersecting:(x,b,v=!0)=>{const w=P0(x)?x:f(x);if(!w)return!1;const C=di(w,b);return v&&C>0||C>=b.width*b.height||C>=w.width*w.height},updateNode:m,updateNodeData:(x,b,v={replace:!1})=>{m(x,k=>{const w=typeof b=="function"?b(k):b;return v.replace?{...k,data:w}:{...k,data:{...k.data,...w}}},v)},updateEdge:g,updateEdgeData:(x,b,v={replace:!1})=>{g(x,k=>{const w=typeof b=="function"?b(k):b;return v.replace?{...k,data:w}:{...k,data:{...k.data,...w}}},v)},getNodesBounds:x=>{const{nodeLookup:b,nodeOrigin:v}=n.getState();return mE(x,{nodeLookup:b,nodeOrigin:v})},getHandleConnections:({type:x,id:b,nodeId:v})=>Array.from(n.getState().connectionLookup.get(`${v}-${x}${b?`-${b}`:""}`)?.values()??[]),getNodeConnections:({type:x,handleId:b,nodeId:v})=>Array.from(n.getState().connectionLookup.get(`${v}${x?b?`-${x}-${b}`:`-${x}`:""}`)?.values()??[]),fitView:async x=>{const b=n.getState().fitViewResolver??wE();return n.setState({fitViewQueued:!0,fitViewOptions:x,fitViewResolver:b}),a.nodeQueue.push(v=>[...v]),b.promise}}},[]);return z.useMemo(()=>({...i,...e,viewportInitialized:s}),[s])}const yx=e=>e.selected,Qj=typeof window<"u"?window:void 0;function Jj({deleteKeyCode:e,multiSelectionKeyCode:n}){const a=tt(),{deleteElements:s}=om(),i=fi(e,{actInsideInputWithModifier:!1}),l=fi(n,{target:Qj});z.useEffect(()=>{if(i){const{edges:c,nodes:p}=a.getState();s({nodes:p.filter(yx),edges:c.filter(yx)}),a.setState({nodesSelectionActive:!1})}},[i]),z.useEffect(()=>{a.setState({multiSelectionActive:l})},[l])}function eT(e){const n=tt();z.useEffect(()=>{const a=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const s=Zf(e.current);(s.height===0||s.width===0)&&n.getState().onError?.("004",In.error004()),n.setState({width:s.width||500,height:s.height||500})};if(e.current){a(),window.addEventListener("resize",a);const s=new ResizeObserver(()=>a());return s.observe(e.current),()=>{window.removeEventListener("resize",a),s&&e.current&&s.unobserve(e.current)}}},[])}const su={position:"absolute",width:"100%",height:"100%",top:0,left:0},tT=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function nT({onPaneContextMenu:e,zoomOnScroll:n=!0,zoomOnPinch:a=!0,panOnScroll:s=!1,panOnScrollSpeed:i=.5,panOnScrollMode:l=Da.Free,zoomOnDoubleClick:c=!0,panOnDrag:p=!0,defaultViewport:f,translateExtent:m,minZoom:g,maxZoom:x,zoomActivationKeyCode:b,preventScrolling:v=!0,children:k,noWheelClassName:w,noPanClassName:C,onViewportChange:M,isControlledViewport:N,paneClickDistance:S,selectionOnDrag:E}){const I=tt(),D=z.useRef(null),{userSelectionActive:A,lib:L,connectionInProgress:P}=Fe(tT,et),W=fi(b),$=z.useRef();eT(D);const V=z.useCallback(X=>{M?.({x:X[0],y:X[1],zoom:X[2]}),N||I.setState({transform:X})},[M,N]);return z.useEffect(()=>{if(D.current){$.current=sj({domNode:D.current,minZoom:g,maxZoom:x,translateExtent:m,viewport:f,onDraggingChange:T=>I.setState(B=>B.paneDragging===T?B:{paneDragging:T}),onPanZoomStart:(T,B)=>{const{onViewportChangeStart:G,onMoveStart:K}=I.getState();K?.(T,B),G?.(B)},onPanZoom:(T,B)=>{const{onViewportChange:G,onMove:K}=I.getState();K?.(T,B),G?.(B)},onPanZoomEnd:(T,B)=>{const{onViewportChangeEnd:G,onMoveEnd:K}=I.getState();K?.(T,B),G?.(B)}});const{x:X,y:H,zoom:_}=$.current.getViewport();return I.setState({panZoom:$.current,transform:[X,H,_],domNode:D.current.closest(".react-flow")}),()=>{$.current?.destroy()}}},[]),z.useEffect(()=>{$.current?.update({onPaneContextMenu:e,zoomOnScroll:n,zoomOnPinch:a,panOnScroll:s,panOnScrollSpeed:i,panOnScrollMode:l,zoomOnDoubleClick:c,panOnDrag:p,zoomActivationKeyPressed:W,preventScrolling:v,noPanClassName:C,userSelectionActive:A,noWheelClassName:w,lib:L,onTransformChange:V,connectionInProgress:P,selectionOnDrag:E,paneClickDistance:S})},[e,n,a,s,i,l,c,p,W,v,C,A,w,L,V,P,E,S]),d.jsx("div",{className:"react-flow__renderer",ref:D,style:su,children:k})}const oT=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function aT(){const{userSelectionActive:e,userSelectionRect:n}=Fe(oT,et);return e&&n?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:n.width,height:n.height,transform:`translate(${n.x}px, ${n.y}px)`}}):null}const Xp=(e,n)=>a=>{a.target===n.current&&e?.(a)},sT=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function rT({isSelecting:e,selectionKeyPressed:n,selectionMode:a=ui.Full,panOnDrag:s,paneClickDistance:i,selectionOnDrag:l,onSelectionStart:c,onSelectionEnd:p,onPaneClick:f,onPaneContextMenu:m,onPaneScroll:g,onPaneMouseEnter:x,onPaneMouseMove:b,onPaneMouseLeave:v,children:k}){const w=tt(),{userSelectionActive:C,elementsSelectable:M,dragging:N,connectionInProgress:S}=Fe(sT,et),E=M&&(e||C),I=z.useRef(null),D=z.useRef(),A=z.useRef(new Set),L=z.useRef(new Set),P=z.useRef(!1),W=G=>{if(P.current||S){P.current=!1;return}f?.(G),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},$=G=>{if(Array.isArray(s)&&s?.includes(2)){G.preventDefault();return}m?.(G)},V=g?G=>g(G):void 0,X=G=>{P.current&&(G.stopPropagation(),P.current=!1)},H=G=>{const{domNode:K}=w.getState();if(D.current=K?.getBoundingClientRect(),!D.current)return;const J=G.target===I.current;if(!J&&!!G.target.closest(".nokey")||!e||!(l&&J||n)||G.button!==0||!G.isPrimary)return;G.target?.setPointerCapture?.(G.pointerId),P.current=!1;const{x:Q,y:q}=Cn(G.nativeEvent,D.current);w.setState({userSelectionRect:{width:0,height:0,startX:Q,startY:q,x:Q,y:q}}),J||(G.stopPropagation(),G.preventDefault())},_=G=>{const{userSelectionRect:K,transform:J,nodeLookup:F,edgeLookup:O,connectionLookup:Q,triggerNodeChanges:q,triggerEdgeChanges:ie,defaultEdgeOptions:pe,resetSelectedElements:me}=w.getState();if(!D.current||!K)return;const{x:U,y:ce}=Cn(G.nativeEvent,D.current),{startX:ge,startY:be}=K;if(!P.current){const Ie=n?0:i;if(Math.hypot(U-ge,ce-be)<=Ie)return;me(),c?.(G)}P.current=!0;const ye={startX:ge,startY:be,x:U<ge?U:ge,y:ce<be?ce:be,width:Math.abs(U-ge),height:Math.abs(ce-be)},te=A.current,he=L.current;A.current=new Set(Wf(F,ye,J,a===ui.Partial,!0).map(Ie=>Ie.id)),L.current=new Set;const je=pe?.selectable??!0;for(const Ie of A.current){const ze=Q.get(Ie);if(ze)for(const{edgeId:Tt}of ze.values()){const ft=O.get(Tt);ft&&(ft.selectable??je)&&L.current.add(Tt)}}if(!H0(te,A.current)){const Ie=As(F,A.current,!0);q(Ie)}if(!H0(he,L.current)){const Ie=As(O,L.current);ie(Ie)}w.setState({userSelectionRect:ye,userSelectionActive:!0,nodesSelectionActive:!1})},T=G=>{G.button===0&&(G.target?.releasePointerCapture?.(G.pointerId),!C&&G.target===I.current&&w.getState().userSelectionRect&&W?.(G),w.setState({userSelectionActive:!1,userSelectionRect:null}),P.current&&(p?.(G),w.setState({nodesSelectionActive:A.current.size>0})))},B=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:pt(["react-flow__pane",{draggable:B,dragging:N,selection:e}]),onClick:E?void 0:Xp(W,I),onContextMenu:Xp($,I),onWheel:Xp(V,I),onPointerEnter:E?void 0:x,onPointerMove:E?_:b,onPointerUp:E?T:void 0,onPointerDownCapture:E?H:void 0,onClickCapture:E?X:void 0,onPointerLeave:v,ref:I,style:su,children:[k,d.jsx(aT,{})]})}function _f({id:e,store:n,unselect:a=!1,nodeRef:s}){const{addSelectedNodes:i,unselectNodesAndEdges:l,multiSelectionActive:c,nodeLookup:p,onError:f}=n.getState(),m=p.get(e);if(!m){f?.("012",In.error012(e));return}n.setState({nodesSelectionActive:!1}),m.selected?(a||m.selected&&c)&&(l({nodes:[m],edges:[]}),requestAnimationFrame(()=>s?.current?.blur())):i([e])}function M1({nodeRef:e,disabled:n=!1,noDragClassName:a,handleSelector:s,nodeId:i,isSelectable:l,nodeClickDistance:c}){const p=tt(),[f,m]=z.useState(!1),g=z.useRef();return z.useEffect(()=>{g.current=qE({getStoreItems:()=>p.getState(),onNodeMouseDown:x=>{_f({id:x,store:p,nodeRef:e})},onDragStart:()=>{m(!0)},onDragStop:()=>{m(!1)}})},[]),z.useEffect(()=>{if(!(n||!e.current||!g.current))return g.current.update({noDragClassName:a,handleSelector:s,domNode:e.current,isSelectable:l,nodeId:i,nodeClickDistance:c}),()=>{g.current?.destroy()}},[a,s,n,l,e,i,c]),f}const iT=e=>n=>n.selected&&(n.draggable||e&&typeof n.draggable>"u");function E1(){const e=tt();return z.useCallback(a=>{const{nodeExtent:s,snapToGrid:i,snapGrid:l,nodesDraggable:c,onError:p,updateNodePositions:f,nodeLookup:m,nodeOrigin:g}=e.getState(),x=new Map,b=iT(c),v=i?l[0]:5,k=i?l[1]:5,w=a.direction.x*v*a.factor,C=a.direction.y*k*a.factor;for(const[,M]of m){if(!b(M))continue;let N={x:M.internals.positionAbsolute.x+w,y:M.internals.positionAbsolute.y+C};i&&(N=Ei(N,l));const{position:S,positionAbsolute:E}=Yb({nodeId:M.id,nextPosition:N,nodeLookup:m,nodeExtent:s,nodeOrigin:g,onError:p});M.position=S,M.internals.positionAbsolute=E,x.set(M.id,M)}f(x)},[])}const am=z.createContext(null),lT=am.Provider;am.Consumer;const j1=()=>z.useContext(am),cT=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),uT=(e,n,a)=>s=>{const{connectionClickStartHandle:i,connectionMode:l,connection:c}=s,{fromHandle:p,toHandle:f,isValid:m}=c,g=f?.nodeId===e&&f?.id===n&&f?.type===a;return{connectingFrom:p?.nodeId===e&&p?.id===n&&p?.type===a,connectingTo:g,clickConnecting:i?.nodeId===e&&i?.id===n&&i?.type===a,isPossibleEndHandle:l===Fs.Strict?p?.type!==a:e!==p?.nodeId||n!==p?.id,connectionInProcess:!!p,clickConnectionInProcess:!!i,valid:g&&m}};function dT({type:e="source",position:n=Se.Top,isValidConnection:a,isConnectable:s=!0,isConnectableStart:i=!0,isConnectableEnd:l=!0,id:c,onConnect:p,children:f,className:m,onMouseDown:g,onTouchStart:x,...b},v){const k=c||null,w=e==="target",C=tt(),M=j1(),{connectOnClick:N,noPanClassName:S,rfId:E}=Fe(cT,et),{connectingFrom:I,connectingTo:D,clickConnecting:A,isPossibleEndHandle:L,connectionInProcess:P,clickConnectionInProcess:W,valid:$}=Fe(uT(M,k,e),et);M||C.getState().onError?.("010",In.error010());const V=_=>{const{defaultEdgeOptions:T,onConnect:B,hasDefaultEdges:G}=C.getState(),K={...T,..._};if(G){const{edges:J,setEdges:F}=C.getState();F(NE(K,J))}B?.(K),p?.(K)},X=_=>{if(!M)return;const T=t1(_.nativeEvent);if(i&&(T&&_.button===0||!T)){const B=C.getState();Af.onPointerDown(_.nativeEvent,{handleDomNode:_.currentTarget,autoPanOnConnect:B.autoPanOnConnect,connectionMode:B.connectionMode,connectionRadius:B.connectionRadius,domNode:B.domNode,nodeLookup:B.nodeLookup,lib:B.lib,isTarget:w,handleId:k,nodeId:M,flowId:B.rfId,panBy:B.panBy,cancelConnection:B.cancelConnection,onConnectStart:B.onConnectStart,onConnectEnd:(...G)=>C.getState().onConnectEnd?.(...G),updateConnection:B.updateConnection,onConnect:V,isValidConnection:a||((...G)=>C.getState().isValidConnection?.(...G)??!0),getTransform:()=>C.getState().transform,getFromHandle:()=>C.getState().connection.fromHandle,autoPanSpeed:B.autoPanSpeed,dragThreshold:B.connectionDragThreshold})}T?g?.(_):x?.(_)},H=_=>{const{onClickConnectStart:T,onClickConnectEnd:B,connectionClickStartHandle:G,connectionMode:K,isValidConnection:J,lib:F,rfId:O,nodeLookup:Q,connection:q}=C.getState();if(!M||!G&&!i)return;if(!G){T?.(_.nativeEvent,{nodeId:M,handleId:k,handleType:e}),C.setState({connectionClickStartHandle:{nodeId:M,type:e,id:k}});return}const ie=Jb(_.target),pe=a||J,{connection:me,isValid:U}=Af.isValid(_.nativeEvent,{handle:{nodeId:M,id:k,type:e},connectionMode:K,fromNodeId:G.nodeId,fromHandleId:G.id||null,fromType:G.type,isValidConnection:pe,flowId:O,doc:ie,lib:F,nodeLookup:Q});U&&me&&V(me);const ce=structuredClone(q);delete ce.inProgress,ce.toPosition=ce.toHandle?ce.toHandle.position:null,B?.(_,ce),C.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":k,"data-nodeid":M,"data-handlepos":n,"data-id":`${E}-${M}-${k}-${e}`,className:pt(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",S,m,{source:!w,target:w,connectable:s,connectablestart:i,connectableend:l,clickconnecting:A,connectingfrom:I,connectingto:D,valid:$,connectionindicator:s&&(!P||L)&&(P||W?l:i)}]),onMouseDown:X,onTouchStart:X,onClick:N?H:void 0,ref:v,...b,children:f})}const Hs=z.memo(S1(dT));function pT({data:e,isConnectable:n,sourcePosition:a=Se.Bottom}){return d.jsxs(d.Fragment,{children:[e?.label,d.jsx(Hs,{type:"source",position:a,isConnectable:n})]})}function fT({data:e,isConnectable:n,targetPosition:a=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(Hs,{type:"target",position:a,isConnectable:n}),e?.label,d.jsx(Hs,{type:"source",position:s,isConnectable:n})]})}function mT(){return null}function hT({data:e,isConnectable:n,targetPosition:a=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(Hs,{type:"target",position:a,isConnectable:n}),e?.label]})}const Bc={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},xx={input:pT,default:fT,output:hT,group:mT};function gT(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}const yT=e=>{const{width:n,height:a,x:s,y:i}=Mi(e.nodeLookup,{filter:l=>!!l.selected});return{width:Sn(n)?n:null,height:Sn(a)?a:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${s}px,${i}px)`}};function xT({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:a}){const s=tt(),{width:i,height:l,transformString:c,userSelectionActive:p}=Fe(yT,et),f=E1(),m=z.useRef(null);z.useEffect(()=>{a||m.current?.focus({preventScroll:!0})},[a]);const g=!p&&i!==null&&l!==null;if(M1({nodeRef:m,disabled:!g}),!g)return null;const x=e?v=>{const k=s.getState().nodes.filter(w=>w.selected);e(v,k)}:void 0,b=v=>{Object.prototype.hasOwnProperty.call(Bc,v.key)&&(v.preventDefault(),f({direction:Bc[v.key],factor:v.shiftKey?4:1}))};return d.jsx("div",{className:pt(["react-flow__nodesselection","react-flow__container",n]),style:{transform:c},children:d.jsx("div",{ref:m,className:"react-flow__nodesselection-rect",onContextMenu:x,tabIndex:a?void 0:-1,onKeyDown:a?void 0:b,style:{width:i,height:l}})})}const bx=typeof window<"u"?window:void 0,bT=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function T1({children:e,onPaneClick:n,onPaneMouseEnter:a,onPaneMouseMove:s,onPaneMouseLeave:i,onPaneContextMenu:l,onPaneScroll:c,paneClickDistance:p,deleteKeyCode:f,selectionKeyCode:m,selectionOnDrag:g,selectionMode:x,onSelectionStart:b,onSelectionEnd:v,multiSelectionKeyCode:k,panActivationKeyCode:w,zoomActivationKeyCode:C,elementsSelectable:M,zoomOnScroll:N,zoomOnPinch:S,panOnScroll:E,panOnScrollSpeed:I,panOnScrollMode:D,zoomOnDoubleClick:A,panOnDrag:L,defaultViewport:P,translateExtent:W,minZoom:$,maxZoom:V,preventScrolling:X,onSelectionContextMenu:H,noWheelClassName:_,noPanClassName:T,disableKeyboardA11y:B,onViewportChange:G,isControlledViewport:K}){const{nodesSelectionActive:J,userSelectionActive:F}=Fe(bT,et),O=fi(m,{target:bx}),Q=fi(w,{target:bx}),q=Q||L,ie=Q||E,pe=g&&q!==!0,me=O||F||pe;return Jj({deleteKeyCode:f,multiSelectionKeyCode:k}),d.jsx(nT,{onPaneContextMenu:l,elementsSelectable:M,zoomOnScroll:N,zoomOnPinch:S,panOnScroll:ie,panOnScrollSpeed:I,panOnScrollMode:D,zoomOnDoubleClick:A,panOnDrag:!O&&q,defaultViewport:P,translateExtent:W,minZoom:$,maxZoom:V,zoomActivationKeyCode:C,preventScrolling:X,noWheelClassName:_,noPanClassName:T,onViewportChange:G,isControlledViewport:K,paneClickDistance:p,selectionOnDrag:pe,children:d.jsxs(rT,{onSelectionStart:b,onSelectionEnd:v,onPaneClick:n,onPaneMouseEnter:a,onPaneMouseMove:s,onPaneMouseLeave:i,onPaneContextMenu:l,onPaneScroll:c,panOnDrag:q,isSelecting:!!me,selectionMode:x,selectionKeyPressed:O,paneClickDistance:p,selectionOnDrag:pe,children:[e,J&&d.jsx(xT,{onSelectionContextMenu:H,noPanClassName:T,disableKeyboardA11y:B})]})})}T1.displayName="FlowRenderer";const vT=z.memo(T1),kT=e=>n=>e?Wf(n.nodeLookup,{x:0,y:0,width:n.width,height:n.height},n.transform,!0).map(a=>a.id):Array.from(n.nodeLookup.keys());function wT(e){return Fe(z.useCallback(kT(e),[e]),et)}const ST=e=>e.updateNodeInternals;function CT(){const e=Fe(ST),[n]=z.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(a=>{const s=new Map;a.forEach(i=>{const l=i.target.getAttribute("data-id");s.set(l,{id:l,nodeElement:i.target,force:!0})}),e(s)}));return z.useEffect(()=>()=>{n?.disconnect()},[n]),n}function MT({node:e,nodeType:n,hasDimensions:a,resizeObserver:s}){const i=tt(),l=z.useRef(null),c=z.useRef(null),p=z.useRef(e.sourcePosition),f=z.useRef(e.targetPosition),m=z.useRef(n),g=a&&!!e.internals.handleBounds;return z.useEffect(()=>{l.current&&!e.hidden&&(!g||c.current!==l.current)&&(c.current&&s?.unobserve(c.current),s?.observe(l.current),c.current=l.current)},[g,e.hidden]),z.useEffect(()=>()=>{c.current&&(s?.unobserve(c.current),c.current=null)},[]),z.useEffect(()=>{if(l.current){const x=m.current!==n,b=p.current!==e.sourcePosition,v=f.current!==e.targetPosition;(x||b||v)&&(m.current=n,p.current=e.sourcePosition,f.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:l.current,force:!0}]])))}},[e.id,n,e.sourcePosition,e.targetPosition]),l}function ET({id:e,onClick:n,onMouseEnter:a,onMouseMove:s,onMouseLeave:i,onContextMenu:l,onDoubleClick:c,nodesDraggable:p,elementsSelectable:f,nodesConnectable:m,nodesFocusable:g,resizeObserver:x,noDragClassName:b,noPanClassName:v,disableKeyboardA11y:k,rfId:w,nodeTypes:C,nodeClickDistance:M,onError:N}){const{node:S,internals:E,isParent:I}=Fe(U=>{const ce=U.nodeLookup.get(e),ge=U.parentLookup.has(e);return{node:ce,internals:ce.internals,isParent:ge}},et);let D=S.type||"default",A=C?.[D]||xx[D];A===void 0&&(N?.("003",In.error003(D)),D="default",A=C?.default||xx.default);const L=!!(S.draggable||p&&typeof S.draggable>"u"),P=!!(S.selectable||f&&typeof S.selectable>"u"),W=!!(S.connectable||m&&typeof S.connectable>"u"),$=!!(S.focusable||g&&typeof S.focusable>"u"),V=tt(),X=Zb(S),H=MT({node:S,nodeType:D,hasDimensions:X,resizeObserver:x}),_=M1({nodeRef:H,disabled:S.hidden||!L,noDragClassName:b,handleSelector:S.dragHandle,nodeId:e,isSelectable:P,nodeClickDistance:M}),T=E1();if(S.hidden)return null;const B=ho(S),G=gT(S),K=P||L||n||a||s||i,J=a?U=>a(U,{...E.userNode}):void 0,F=s?U=>s(U,{...E.userNode}):void 0,O=i?U=>i(U,{...E.userNode}):void 0,Q=l?U=>l(U,{...E.userNode}):void 0,q=c?U=>c(U,{...E.userNode}):void 0,ie=U=>{const{selectNodesOnDrag:ce,nodeDragThreshold:ge}=V.getState();P&&(!ce||!L||ge>0)&&_f({id:e,store:V,nodeRef:H}),n&&n(U,{...E.userNode})},pe=U=>{if(!(e1(U.nativeEvent)||k)){if(Hb.includes(U.key)&&P){const ce=U.key==="Escape";_f({id:e,store:V,unselect:ce,nodeRef:H})}else if(L&&S.selected&&Object.prototype.hasOwnProperty.call(Bc,U.key)){U.preventDefault();const{ariaLabelConfig:ce}=V.getState();V.setState({ariaLiveMessage:ce["node.a11yDescription.ariaLiveMessage"]({direction:U.key.replace("Arrow","").toLowerCase(),x:~~E.positionAbsolute.x,y:~~E.positionAbsolute.y})}),T({direction:Bc[U.key],factor:U.shiftKey?4:1})}}},me=()=>{if(k||!H.current?.matches(":focus-visible"))return;const{transform:U,width:ce,height:ge,autoPanOnNodeFocus:be,setCenter:ye}=V.getState();if(!be)return;Wf(new Map([[e,S]]),{x:0,y:0,width:ce,height:ge},U,!0).length>0||ye(S.position.x+B.width/2,S.position.y+B.height/2,{zoom:U[2]})};return d.jsx("div",{className:pt(["react-flow__node",`react-flow__node-${D}`,{[v]:L},S.className,{selected:S.selected,selectable:P,parent:I,draggable:L,dragging:_}]),ref:H,style:{zIndex:E.z,transform:`translate(${E.positionAbsolute.x}px,${E.positionAbsolute.y}px)`,pointerEvents:K?"all":"none",visibility:X?"visible":"hidden",...S.style,...G},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:J,onMouseMove:F,onMouseLeave:O,onContextMenu:Q,onClick:ie,onDoubleClick:q,onKeyDown:$?pe:void 0,tabIndex:$?0:void 0,onFocus:$?me:void 0,role:S.ariaRole??($?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${b1}-${w}`,"aria-label":S.ariaLabel,...S.domAttributes,children:d.jsx(lT,{value:e,children:d.jsx(A,{id:e,data:S.data,type:D,positionAbsoluteX:E.positionAbsolute.x,positionAbsoluteY:E.positionAbsolute.y,selected:S.selected??!1,selectable:P,draggable:L,deletable:S.deletable??!0,isConnectable:W,sourcePosition:S.sourcePosition,targetPosition:S.targetPosition,dragging:_,dragHandle:S.dragHandle,zIndex:E.z,parentId:S.parentId,...B})})})}var jT=z.memo(ET);const TT=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function N1(e){const{nodesDraggable:n,nodesConnectable:a,nodesFocusable:s,elementsSelectable:i,onError:l}=Fe(TT,et),c=wT(e.onlyRenderVisibleElements),p=CT();return d.jsx("div",{className:"react-flow__nodes",style:su,children:c.map(f=>d.jsx(jT,{id:f,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:p,nodesDraggable:n,nodesConnectable:a,nodesFocusable:s,elementsSelectable:i,nodeClickDistance:e.nodeClickDistance,onError:l},f))})}N1.displayName="NodeRenderer";const NT=z.memo(N1);function AT(e){return Fe(z.useCallback(a=>{if(!e)return a.edges.map(i=>i.id);const s=[];if(a.width&&a.height)for(const i of a.edges){const l=a.nodeLookup.get(i.source),c=a.nodeLookup.get(i.target);l&&c&&EE({sourceNode:l,targetNode:c,width:a.width,height:a.height,transform:a.transform})&&s.push(i.id)}return s},[e]),et)}const _T=({color:e="none",strokeWidth:n=1})=>{const a={strokeWidth:n,...e&&{stroke:e}};return d.jsx("polyline",{className:"arrow",style:a,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},DT=({color:e="none",strokeWidth:n=1})=>{const a={strokeWidth:n,...e&&{stroke:e,fill:e}};return d.jsx("polyline",{className:"arrowclosed",style:a,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},vx={[Fc.Arrow]:_T,[Fc.ArrowClosed]:DT};function zT(e){const n=tt();return z.useMemo(()=>Object.prototype.hasOwnProperty.call(vx,e)?vx[e]:(n.getState().onError?.("009",In.error009(e)),null),[e])}const RT=({id:e,type:n,color:a,width:s=12.5,height:i=12.5,markerUnits:l="strokeWidth",strokeWidth:c,orient:p="auto-start-reverse"})=>{const f=zT(n);return f?d.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:l,orient:p,refX:"0",refY:"0",children:d.jsx(f,{color:a,strokeWidth:c})}):null},A1=({defaultColor:e,rfId:n})=>{const a=Fe(l=>l.edges),s=Fe(l=>l.defaultEdgeOptions),i=z.useMemo(()=>RE(a,{id:n,defaultColor:e,defaultMarkerStart:s?.markerStart,defaultMarkerEnd:s?.markerEnd}),[a,s,n,e]);return i.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:i.map(l=>d.jsx(RT,{id:l.id,type:l.type,color:l.color,width:l.width,height:l.height,markerUnits:l.markerUnits,strokeWidth:l.strokeWidth,orient:l.orient},l.id))})}):null};A1.displayName="MarkerDefinitions";var $T=z.memo(A1);function _1({x:e,y:n,label:a,labelStyle:s,labelShowBg:i=!0,labelBgStyle:l,labelBgPadding:c=[2,4],labelBgBorderRadius:p=2,children:f,className:m,...g}){const[x,b]=z.useState({x:1,y:0,width:0,height:0}),v=pt(["react-flow__edge-textwrapper",m]),k=z.useRef(null);return z.useEffect(()=>{if(k.current){const w=k.current.getBBox();b({x:w.x,y:w.y,width:w.width,height:w.height})}},[a]),a?d.jsxs("g",{transform:`translate(${e-x.width/2} ${n-x.height/2})`,className:v,visibility:x.width?"visible":"hidden",...g,children:[i&&d.jsx("rect",{width:x.width+2*c[0],x:-c[0],y:-c[1],height:x.height+2*c[1],className:"react-flow__edge-textbg",style:l,rx:p,ry:p}),d.jsx("text",{className:"react-flow__edge-text",y:x.height/2,dy:"0.3em",ref:k,style:s,children:a}),f]}):null}_1.displayName="EdgeText";const OT=z.memo(_1);function ru({path:e,labelX:n,labelY:a,label:s,labelStyle:i,labelShowBg:l,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:f,interactionWidth:m=20,...g}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...g,d:e,fill:"none",className:pt(["react-flow__edge-path",g.className])}),m?d.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:m,className:"react-flow__edge-interaction"}):null,s&&Sn(n)&&Sn(a)?d.jsx(OT,{x:n,y:a,label:s,labelStyle:i,labelShowBg:l,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:f}):null]})}function kx({pos:e,x1:n,y1:a,x2:s,y2:i}){return e===Se.Left||e===Se.Right?[.5*(n+s),a]:[n,.5*(a+i)]}function D1({sourceX:e,sourceY:n,sourcePosition:a=Se.Bottom,targetX:s,targetY:i,targetPosition:l=Se.Top}){const[c,p]=kx({pos:a,x1:e,y1:n,x2:s,y2:i}),[f,m]=kx({pos:l,x1:s,y1:i,x2:e,y2:n}),[g,x,b,v]=n1({sourceX:e,sourceY:n,targetX:s,targetY:i,sourceControlX:c,sourceControlY:p,targetControlX:f,targetControlY:m});return[`M${e},${n} C${c},${p} ${f},${m} ${s},${i}`,g,x,b,v]}function z1(e){return z.memo(({id:n,sourceX:a,sourceY:s,targetX:i,targetY:l,sourcePosition:c,targetPosition:p,label:f,labelStyle:m,labelShowBg:g,labelBgStyle:x,labelBgPadding:b,labelBgBorderRadius:v,style:k,markerEnd:w,markerStart:C,interactionWidth:M})=>{const[N,S,E]=D1({sourceX:a,sourceY:s,sourcePosition:c,targetX:i,targetY:l,targetPosition:p}),I=e.isInternal?void 0:n;return d.jsx(ru,{id:I,path:N,labelX:S,labelY:E,label:f,labelStyle:m,labelShowBg:g,labelBgStyle:x,labelBgPadding:b,labelBgBorderRadius:v,style:k,markerEnd:w,markerStart:C,interactionWidth:M})})}const FT=z1({isInternal:!1}),R1=z1({isInternal:!0});FT.displayName="SimpleBezierEdge";R1.displayName="SimpleBezierEdgeInternal";function $1(e){return z.memo(({id:n,sourceX:a,sourceY:s,targetX:i,targetY:l,label:c,labelStyle:p,labelShowBg:f,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:x,style:b,sourcePosition:v=Se.Bottom,targetPosition:k=Se.Top,markerEnd:w,markerStart:C,pathOptions:M,interactionWidth:N})=>{const[S,E,I]=jf({sourceX:a,sourceY:s,sourcePosition:v,targetX:i,targetY:l,targetPosition:k,borderRadius:M?.borderRadius,offset:M?.offset,stepPosition:M?.stepPosition}),D=e.isInternal?void 0:n;return d.jsx(ru,{id:D,path:S,labelX:E,labelY:I,label:c,labelStyle:p,labelShowBg:f,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:x,style:b,markerEnd:w,markerStart:C,interactionWidth:N})})}const O1=$1({isInternal:!1}),F1=$1({isInternal:!0});O1.displayName="SmoothStepEdge";F1.displayName="SmoothStepEdgeInternal";function I1(e){return z.memo(({id:n,...a})=>{const s=e.isInternal?void 0:n;return d.jsx(O1,{...a,id:s,pathOptions:z.useMemo(()=>({borderRadius:0,offset:a.pathOptions?.offset}),[a.pathOptions?.offset])})})}const IT=I1({isInternal:!1}),L1=I1({isInternal:!0});IT.displayName="StepEdge";L1.displayName="StepEdgeInternal";function B1(e){return z.memo(({id:n,sourceX:a,sourceY:s,targetX:i,targetY:l,label:c,labelStyle:p,labelShowBg:f,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:x,style:b,markerEnd:v,markerStart:k,interactionWidth:w})=>{const[C,M,N]=s1({sourceX:a,sourceY:s,targetX:i,targetY:l}),S=e.isInternal?void 0:n;return d.jsx(ru,{id:S,path:C,labelX:M,labelY:N,label:c,labelStyle:p,labelShowBg:f,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:x,style:b,markerEnd:v,markerStart:k,interactionWidth:w})})}const LT=B1({isInternal:!1}),P1=B1({isInternal:!0});LT.displayName="StraightEdge";P1.displayName="StraightEdgeInternal";function H1(e){return z.memo(({id:n,sourceX:a,sourceY:s,targetX:i,targetY:l,sourcePosition:c=Se.Bottom,targetPosition:p=Se.Top,label:f,labelStyle:m,labelShowBg:g,labelBgStyle:x,labelBgPadding:b,labelBgBorderRadius:v,style:k,markerEnd:w,markerStart:C,pathOptions:M,interactionWidth:N})=>{const[S,E,I]=o1({sourceX:a,sourceY:s,sourcePosition:c,targetX:i,targetY:l,targetPosition:p,curvature:M?.curvature}),D=e.isInternal?void 0:n;return d.jsx(ru,{id:D,path:S,labelX:E,labelY:I,label:f,labelStyle:m,labelShowBg:g,labelBgStyle:x,labelBgPadding:b,labelBgBorderRadius:v,style:k,markerEnd:w,markerStart:C,interactionWidth:N})})}const BT=H1({isInternal:!1}),U1=H1({isInternal:!0});BT.displayName="BezierEdge";U1.displayName="BezierEdgeInternal";const wx={default:U1,straight:P1,step:L1,smoothstep:F1,simplebezier:R1},Sx={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},PT=(e,n,a)=>a===Se.Left?e-n:a===Se.Right?e+n:e,HT=(e,n,a)=>a===Se.Top?e-n:a===Se.Bottom?e+n:e,Cx="react-flow__edgeupdater";function Mx({position:e,centerX:n,centerY:a,radius:s=10,onMouseDown:i,onMouseEnter:l,onMouseOut:c,type:p}){return d.jsx("circle",{onMouseDown:i,onMouseEnter:l,onMouseOut:c,className:pt([Cx,`${Cx}-${p}`]),cx:PT(n,s,e),cy:HT(a,s,e),r:s,stroke:"transparent",fill:"transparent"})}function UT({isReconnectable:e,reconnectRadius:n,edge:a,sourceX:s,sourceY:i,targetX:l,targetY:c,sourcePosition:p,targetPosition:f,onReconnect:m,onReconnectStart:g,onReconnectEnd:x,setReconnecting:b,setUpdateHover:v}){const k=tt(),w=(E,I)=>{if(E.button!==0)return;const{autoPanOnConnect:D,domNode:A,connectionMode:L,connectionRadius:P,lib:W,onConnectStart:$,cancelConnection:V,nodeLookup:X,rfId:H,panBy:_,updateConnection:T}=k.getState(),B=I.type==="target",G=(F,O)=>{b(!1),x?.(F,a,I.type,O)},K=F=>m?.(a,F),J=(F,O)=>{b(!0),g?.(E,a,I.type),$?.(F,O)};Af.onPointerDown(E.nativeEvent,{autoPanOnConnect:D,connectionMode:L,connectionRadius:P,domNode:A,handleId:I.id,nodeId:I.nodeId,nodeLookup:X,isTarget:B,edgeUpdaterType:I.type,lib:W,flowId:H,cancelConnection:V,panBy:_,isValidConnection:(...F)=>k.getState().isValidConnection?.(...F)??!0,onConnect:K,onConnectStart:J,onConnectEnd:(...F)=>k.getState().onConnectEnd?.(...F),onReconnectEnd:G,updateConnection:T,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:E.currentTarget})},C=E=>w(E,{nodeId:a.target,id:a.targetHandle??null,type:"target"}),M=E=>w(E,{nodeId:a.source,id:a.sourceHandle??null,type:"source"}),N=()=>v(!0),S=()=>v(!1);return d.jsxs(d.Fragment,{children:[(e===!0||e==="source")&&d.jsx(Mx,{position:p,centerX:s,centerY:i,radius:n,onMouseDown:C,onMouseEnter:N,onMouseOut:S,type:"source"}),(e===!0||e==="target")&&d.jsx(Mx,{position:f,centerX:l,centerY:c,radius:n,onMouseDown:M,onMouseEnter:N,onMouseOut:S,type:"target"})]})}function GT({id:e,edgesFocusable:n,edgesReconnectable:a,elementsSelectable:s,onClick:i,onDoubleClick:l,onContextMenu:c,onMouseEnter:p,onMouseMove:f,onMouseLeave:m,reconnectRadius:g,onReconnect:x,onReconnectStart:b,onReconnectEnd:v,rfId:k,edgeTypes:w,noPanClassName:C,onError:M,disableKeyboardA11y:N}){let S=Fe(ye=>ye.edgeLookup.get(e));const E=Fe(ye=>ye.defaultEdgeOptions);S=E?{...E,...S}:S;let I=S.type||"default",D=w?.[I]||wx[I];D===void 0&&(M?.("011",In.error011(I)),I="default",D=w?.default||wx.default);const A=!!(S.focusable||n&&typeof S.focusable>"u"),L=typeof x<"u"&&(S.reconnectable||a&&typeof S.reconnectable>"u"),P=!!(S.selectable||s&&typeof S.selectable>"u"),W=z.useRef(null),[$,V]=z.useState(!1),[X,H]=z.useState(!1),_=tt(),{zIndex:T,sourceX:B,sourceY:G,targetX:K,targetY:J,sourcePosition:F,targetPosition:O}=Fe(z.useCallback(ye=>{const te=ye.nodeLookup.get(S.source),he=ye.nodeLookup.get(S.target);if(!te||!he)return{zIndex:S.zIndex,...Sx};const je=zE({id:e,sourceNode:te,targetNode:he,sourceHandle:S.sourceHandle||null,targetHandle:S.targetHandle||null,connectionMode:ye.connectionMode,onError:M});return{zIndex:ME({selected:S.selected,zIndex:S.zIndex,sourceNode:te,targetNode:he,elevateOnSelect:ye.elevateEdgesOnSelect,zIndexMode:ye.zIndexMode}),...je||Sx}},[S.source,S.target,S.sourceHandle,S.targetHandle,S.selected,S.zIndex]),et),Q=z.useMemo(()=>S.markerStart?`url('#${Tf(S.markerStart,k)}')`:void 0,[S.markerStart,k]),q=z.useMemo(()=>S.markerEnd?`url('#${Tf(S.markerEnd,k)}')`:void 0,[S.markerEnd,k]);if(S.hidden||B===null||G===null||K===null||J===null)return null;const ie=ye=>{const{addSelectedEdges:te,unselectNodesAndEdges:he,multiSelectionActive:je}=_.getState();P&&(_.setState({nodesSelectionActive:!1}),S.selected&&je?(he({nodes:[],edges:[S]}),W.current?.blur()):te([e])),i&&i(ye,S)},pe=l?ye=>{l(ye,{...S})}:void 0,me=c?ye=>{c(ye,{...S})}:void 0,U=p?ye=>{p(ye,{...S})}:void 0,ce=f?ye=>{f(ye,{...S})}:void 0,ge=m?ye=>{m(ye,{...S})}:void 0,be=ye=>{if(!N&&Hb.includes(ye.key)&&P){const{unselectNodesAndEdges:te,addSelectedEdges:he}=_.getState();ye.key==="Escape"?(W.current?.blur(),te({edges:[S]})):he([e])}};return d.jsx("svg",{style:{zIndex:T},children:d.jsxs("g",{className:pt(["react-flow__edge",`react-flow__edge-${I}`,S.className,C,{selected:S.selected,animated:S.animated,inactive:!P&&!i,updating:$,selectable:P}]),onClick:ie,onDoubleClick:pe,onContextMenu:me,onMouseEnter:U,onMouseMove:ce,onMouseLeave:ge,onKeyDown:A?be:void 0,tabIndex:A?0:void 0,role:S.ariaRole??(A?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":S.ariaLabel===null?void 0:S.ariaLabel||`Edge from ${S.source} to ${S.target}`,"aria-describedby":A?`${v1}-${k}`:void 0,ref:W,...S.domAttributes,children:[!X&&d.jsx(D,{id:e,source:S.source,target:S.target,type:S.type,selected:S.selected,animated:S.animated,selectable:P,deletable:S.deletable??!0,label:S.label,labelStyle:S.labelStyle,labelShowBg:S.labelShowBg,labelBgStyle:S.labelBgStyle,labelBgPadding:S.labelBgPadding,labelBgBorderRadius:S.labelBgBorderRadius,sourceX:B,sourceY:G,targetX:K,targetY:J,sourcePosition:F,targetPosition:O,data:S.data,style:S.style,sourceHandleId:S.sourceHandle,targetHandleId:S.targetHandle,markerStart:Q,markerEnd:q,pathOptions:"pathOptions"in S?S.pathOptions:void 0,interactionWidth:S.interactionWidth}),L&&d.jsx(UT,{edge:S,isReconnectable:L,reconnectRadius:g,onReconnect:x,onReconnectStart:b,onReconnectEnd:v,sourceX:B,sourceY:G,targetX:K,targetY:J,sourcePosition:F,targetPosition:O,setUpdateHover:V,setReconnecting:H})]})})}var qT=z.memo(GT);const KT=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function G1({defaultMarkerColor:e,onlyRenderVisibleElements:n,rfId:a,edgeTypes:s,noPanClassName:i,onReconnect:l,onEdgeContextMenu:c,onEdgeMouseEnter:p,onEdgeMouseMove:f,onEdgeMouseLeave:m,onEdgeClick:g,reconnectRadius:x,onEdgeDoubleClick:b,onReconnectStart:v,onReconnectEnd:k,disableKeyboardA11y:w}){const{edgesFocusable:C,edgesReconnectable:M,elementsSelectable:N,onError:S}=Fe(KT,et),E=AT(n);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx($T,{defaultColor:e,rfId:a}),E.map(I=>d.jsx(qT,{id:I,edgesFocusable:C,edgesReconnectable:M,elementsSelectable:N,noPanClassName:i,onReconnect:l,onContextMenu:c,onMouseEnter:p,onMouseMove:f,onMouseLeave:m,onClick:g,reconnectRadius:x,onDoubleClick:b,onReconnectStart:v,onReconnectEnd:k,rfId:a,onError:S,edgeTypes:s,disableKeyboardA11y:w},I))]})}G1.displayName="EdgeRenderer";const YT=z.memo(G1),VT=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function WT({children:e}){const n=Fe(VT);return d.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:n},children:e})}function XT(e){const n=om(),a=z.useRef(!1);z.useEffect(()=>{!a.current&&n.viewportInitialized&&e&&(setTimeout(()=>e(n),1),a.current=!0)},[e,n.viewportInitialized])}const ZT=e=>e.panZoom?.syncViewport;function QT(e){const n=Fe(ZT),a=tt();return z.useEffect(()=>{e&&(n?.(e),a.setState({transform:[e.x,e.y,e.zoom]}))},[e,n]),null}function JT(e){return e.connection.inProgress?{...e.connection,to:ji(e.connection.to,e.transform)}:{...e.connection}}function e5(e){return JT}function t5(e){const n=e5();return Fe(n,et)}const n5=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function o5({containerStyle:e,style:n,type:a,component:s}){const{nodesConnectable:i,width:l,height:c,isValid:p,inProgress:f}=Fe(n5,et);return!(l&&i&&f)?null:d.jsx("svg",{style:e,width:l,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:pt(["react-flow__connection",qb(p)]),children:d.jsx(q1,{style:n,type:a,CustomComponent:s,isValid:p})})})}const q1=({style:e,type:n=Xo.Bezier,CustomComponent:a,isValid:s})=>{const{inProgress:i,from:l,fromNode:c,fromHandle:p,fromPosition:f,to:m,toNode:g,toHandle:x,toPosition:b,pointer:v}=t5();if(!i)return;if(a)return d.jsx(a,{connectionLineType:n,connectionLineStyle:e,fromNode:c,fromHandle:p,fromX:l.x,fromY:l.y,toX:m.x,toY:m.y,fromPosition:f,toPosition:b,connectionStatus:qb(s),toNode:g,toHandle:x,pointer:v});let k="";const w={sourceX:l.x,sourceY:l.y,sourcePosition:f,targetX:m.x,targetY:m.y,targetPosition:b};switch(n){case Xo.Bezier:[k]=o1(w);break;case Xo.SimpleBezier:[k]=D1(w);break;case Xo.Step:[k]=jf({...w,borderRadius:0});break;case Xo.SmoothStep:[k]=jf(w);break;default:[k]=s1(w)}return d.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:e})};q1.displayName="ConnectionLine";const a5={};function Ex(e=a5){z.useRef(e),tt(),z.useEffect(()=>{},[e])}function s5(){tt(),z.useRef(!1),z.useEffect(()=>{},[])}function K1({nodeTypes:e,edgeTypes:n,onInit:a,onNodeClick:s,onEdgeClick:i,onNodeDoubleClick:l,onEdgeDoubleClick:c,onNodeMouseEnter:p,onNodeMouseMove:f,onNodeMouseLeave:m,onNodeContextMenu:g,onSelectionContextMenu:x,onSelectionStart:b,onSelectionEnd:v,connectionLineType:k,connectionLineStyle:w,connectionLineComponent:C,connectionLineContainerStyle:M,selectionKeyCode:N,selectionOnDrag:S,selectionMode:E,multiSelectionKeyCode:I,panActivationKeyCode:D,zoomActivationKeyCode:A,deleteKeyCode:L,onlyRenderVisibleElements:P,elementsSelectable:W,defaultViewport:$,translateExtent:V,minZoom:X,maxZoom:H,preventScrolling:_,defaultMarkerColor:T,zoomOnScroll:B,zoomOnPinch:G,panOnScroll:K,panOnScrollSpeed:J,panOnScrollMode:F,zoomOnDoubleClick:O,panOnDrag:Q,onPaneClick:q,onPaneMouseEnter:ie,onPaneMouseMove:pe,onPaneMouseLeave:me,onPaneScroll:U,onPaneContextMenu:ce,paneClickDistance:ge,nodeClickDistance:be,onEdgeContextMenu:ye,onEdgeMouseEnter:te,onEdgeMouseMove:he,onEdgeMouseLeave:je,reconnectRadius:Ie,onReconnect:ze,onReconnectStart:Tt,onReconnectEnd:ft,noDragClassName:vt,noWheelClassName:mn,noPanClassName:tn,disableKeyboardA11y:hn,nodeExtent:kt,rfId:Ba,viewport:Bn,onViewportChange:go}){return Ex(e),Ex(n),s5(),XT(a),QT(Bn),d.jsx(vT,{onPaneClick:q,onPaneMouseEnter:ie,onPaneMouseMove:pe,onPaneMouseLeave:me,onPaneContextMenu:ce,onPaneScroll:U,paneClickDistance:ge,deleteKeyCode:L,selectionKeyCode:N,selectionOnDrag:S,selectionMode:E,onSelectionStart:b,onSelectionEnd:v,multiSelectionKeyCode:I,panActivationKeyCode:D,zoomActivationKeyCode:A,elementsSelectable:W,zoomOnScroll:B,zoomOnPinch:G,zoomOnDoubleClick:O,panOnScroll:K,panOnScrollSpeed:J,panOnScrollMode:F,panOnDrag:Q,defaultViewport:$,translateExtent:V,minZoom:X,maxZoom:H,onSelectionContextMenu:x,preventScrolling:_,noDragClassName:vt,noWheelClassName:mn,noPanClassName:tn,disableKeyboardA11y:hn,onViewportChange:go,isControlledViewport:!!Bn,children:d.jsxs(WT,{children:[d.jsx(YT,{edgeTypes:n,onEdgeClick:i,onEdgeDoubleClick:c,onReconnect:ze,onReconnectStart:Tt,onReconnectEnd:ft,onlyRenderVisibleElements:P,onEdgeContextMenu:ye,onEdgeMouseEnter:te,onEdgeMouseMove:he,onEdgeMouseLeave:je,reconnectRadius:Ie,defaultMarkerColor:T,noPanClassName:tn,disableKeyboardA11y:hn,rfId:Ba}),d.jsx(o5,{style:w,type:k,component:C,containerStyle:M}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(NT,{nodeTypes:e,onNodeClick:s,onNodeDoubleClick:l,onNodeMouseEnter:p,onNodeMouseMove:f,onNodeMouseLeave:m,onNodeContextMenu:g,nodeClickDistance:be,onlyRenderVisibleElements:P,noPanClassName:tn,noDragClassName:vt,disableKeyboardA11y:hn,nodeExtent:kt,rfId:Ba}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}K1.displayName="GraphView";const r5=z.memo(K1),jx=({nodes:e,edges:n,defaultNodes:a,defaultEdges:s,width:i,height:l,fitView:c,fitViewOptions:p,minZoom:f=.5,maxZoom:m=2,nodeOrigin:g,nodeExtent:x,zIndexMode:b="basic"}={})=>{const v=new Map,k=new Map,w=new Map,C=new Map,M=s??n??[],N=a??e??[],S=g??[0,0],E=x??ci;l1(w,C,M);const I=Nf(N,v,k,{nodeOrigin:S,nodeExtent:E,zIndexMode:b});let D=[0,0,1];if(c&&i&&l){const A=Mi(v,{filter:$=>!!(($.width||$.initialWidth)&&($.height||$.initialHeight))}),{x:L,y:P,zoom:W}=Xf(A,i,l,f,m,p?.padding??.1);D=[L,P,W]}return{rfId:"1",width:i??0,height:l??0,transform:D,nodes:N,nodesInitialized:I,nodeLookup:v,parentLookup:k,edges:M,edgeLookup:C,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:a!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:f,maxZoom:m,translateExtent:ci,nodeExtent:E,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Fs.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:S,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:c??!1,fitViewOptions:p,fitViewResolver:null,connection:{...Gb},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:bE,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Ub,zIndexMode:b,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},i5=({nodes:e,edges:n,defaultNodes:a,defaultEdges:s,width:i,height:l,fitView:c,fitViewOptions:p,minZoom:f,maxZoom:m,nodeOrigin:g,nodeExtent:x,zIndexMode:b})=>Sj((v,k)=>{async function w(){const{nodeLookup:C,panZoom:M,fitViewOptions:N,fitViewResolver:S,width:E,height:I,minZoom:D,maxZoom:A}=k();M&&(await yE({nodes:C,width:E,height:I,panZoom:M,minZoom:D,maxZoom:A},N),S?.resolve(!0),v({fitViewResolver:null}))}return{...jx({nodes:e,edges:n,width:i,height:l,fitView:c,fitViewOptions:p,minZoom:f,maxZoom:m,nodeOrigin:g,nodeExtent:x,defaultNodes:a,defaultEdges:s,zIndexMode:b}),setNodes:C=>{const{nodeLookup:M,parentLookup:N,nodeOrigin:S,elevateNodesOnSelect:E,fitViewQueued:I,zIndexMode:D}=k(),A=Nf(C,M,N,{nodeOrigin:S,nodeExtent:x,elevateNodesOnSelect:E,checkEquality:!0,zIndexMode:D});I&&A?(w(),v({nodes:C,nodesInitialized:A,fitViewQueued:!1,fitViewOptions:void 0})):v({nodes:C,nodesInitialized:A})},setEdges:C=>{const{connectionLookup:M,edgeLookup:N}=k();l1(M,N,C),v({edges:C})},setDefaultNodesAndEdges:(C,M)=>{if(C){const{setNodes:N}=k();N(C),v({hasDefaultNodes:!0})}if(M){const{setEdges:N}=k();N(M),v({hasDefaultEdges:!0})}},updateNodeInternals:C=>{const{triggerNodeChanges:M,nodeLookup:N,parentLookup:S,domNode:E,nodeOrigin:I,nodeExtent:D,debug:A,fitViewQueued:L,zIndexMode:P}=k(),{changes:W,updatedInternals:$}=PE(C,N,S,E,I,D,P);$&&(FE(N,S,{nodeOrigin:I,nodeExtent:D,zIndexMode:P}),L?(w(),v({fitViewQueued:!1,fitViewOptions:void 0})):v({}),W?.length>0&&(A&&console.log("React Flow: trigger node changes",W),M?.(W)))},updateNodePositions:(C,M=!1)=>{const N=[];let S=[];const{nodeLookup:E,triggerNodeChanges:I,connection:D,updateConnection:A,onNodesChangeMiddlewareMap:L}=k();for(const[P,W]of C){const $=E.get(P),V=!!($?.expandParent&&$?.parentId&&W?.position),X={id:P,type:"position",position:V?{x:Math.max(0,W.position.x),y:Math.max(0,W.position.y)}:W.position,dragging:M};if($&&D.inProgress&&D.fromNode.id===$.id){const H=Ia($,D.fromHandle,Se.Left,!0);A({...D,from:H})}V&&$.parentId&&N.push({id:P,parentId:$.parentId,rect:{...W.internals.positionAbsolute,width:W.measured.width??0,height:W.measured.height??0}}),S.push(X)}if(N.length>0){const{parentLookup:P,nodeOrigin:W}=k(),$=nm(N,E,P,W);S.push(...$)}for(const P of L.values())S=P(S);I(S)},triggerNodeChanges:C=>{const{onNodesChange:M,setNodes:N,nodes:S,hasDefaultNodes:E,debug:I}=k();if(C?.length){if(E){const D=Gj(C,S);N(D)}I&&console.log("React Flow: trigger node changes",C),M?.(C)}},triggerEdgeChanges:C=>{const{onEdgesChange:M,setEdges:N,edges:S,hasDefaultEdges:E,debug:I}=k();if(C?.length){if(E){const D=qj(C,S);N(D)}I&&console.log("React Flow: trigger edge changes",C),M?.(C)}},addSelectedNodes:C=>{const{multiSelectionActive:M,edgeLookup:N,nodeLookup:S,triggerNodeChanges:E,triggerEdgeChanges:I}=k();if(M){const D=C.map(A=>ja(A,!0));E(D);return}E(As(S,new Set([...C]),!0)),I(As(N))},addSelectedEdges:C=>{const{multiSelectionActive:M,edgeLookup:N,nodeLookup:S,triggerNodeChanges:E,triggerEdgeChanges:I}=k();if(M){const D=C.map(A=>ja(A,!0));I(D);return}I(As(N,new Set([...C]))),E(As(S,new Set,!0))},unselectNodesAndEdges:({nodes:C,edges:M}={})=>{const{edges:N,nodes:S,nodeLookup:E,triggerNodeChanges:I,triggerEdgeChanges:D}=k(),A=C||S,L=M||N,P=[];for(const $ of A){if(!$.selected)continue;const V=E.get($.id);V&&(V.selected=!1),P.push(ja($.id,!1))}const W=[];for(const $ of L)$.selected&&W.push(ja($.id,!1));I(P),D(W)},setMinZoom:C=>{const{panZoom:M,maxZoom:N}=k();M?.setScaleExtent([C,N]),v({minZoom:C})},setMaxZoom:C=>{const{panZoom:M,minZoom:N}=k();M?.setScaleExtent([N,C]),v({maxZoom:C})},setTranslateExtent:C=>{k().panZoom?.setTranslateExtent(C),v({translateExtent:C})},resetSelectedElements:()=>{const{edges:C,nodes:M,triggerNodeChanges:N,triggerEdgeChanges:S,elementsSelectable:E}=k();if(!E)return;const I=M.reduce((A,L)=>L.selected?[...A,ja(L.id,!1)]:A,[]),D=C.reduce((A,L)=>L.selected?[...A,ja(L.id,!1)]:A,[]);N(I),S(D)},setNodeExtent:C=>{const{nodes:M,nodeLookup:N,parentLookup:S,nodeOrigin:E,elevateNodesOnSelect:I,nodeExtent:D,zIndexMode:A}=k();C[0][0]===D[0][0]&&C[0][1]===D[0][1]&&C[1][0]===D[1][0]&&C[1][1]===D[1][1]||(Nf(M,N,S,{nodeOrigin:E,nodeExtent:C,elevateNodesOnSelect:I,checkEquality:!1,zIndexMode:A}),v({nodeExtent:C}))},panBy:C=>{const{transform:M,width:N,height:S,panZoom:E,translateExtent:I}=k();return HE({delta:C,panZoom:E,transform:M,translateExtent:I,width:N,height:S})},setCenter:async(C,M,N)=>{const{width:S,height:E,maxZoom:I,panZoom:D}=k();if(!D)return Promise.resolve(!1);const A=typeof N?.zoom<"u"?N.zoom:I;return await D.setViewport({x:S/2-C*A,y:E/2-M*A,zoom:A},{duration:N?.duration,ease:N?.ease,interpolate:N?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{v({connection:{...Gb}})},updateConnection:C=>{v({connection:C})},reset:()=>v({...jx()})}},Object.is);function l5({initialNodes:e,initialEdges:n,defaultNodes:a,defaultEdges:s,initialWidth:i,initialHeight:l,initialMinZoom:c,initialMaxZoom:p,initialFitViewOptions:f,fitView:m,nodeOrigin:g,nodeExtent:x,zIndexMode:b,children:v}){const[k]=z.useState(()=>i5({nodes:e,edges:n,defaultNodes:a,defaultEdges:s,width:i,height:l,fitView:m,minZoom:c,maxZoom:p,fitViewOptions:f,nodeOrigin:g,nodeExtent:x,zIndexMode:b}));return d.jsx(Cj,{value:k,children:d.jsx(Wj,{children:v})})}function c5({children:e,nodes:n,edges:a,defaultNodes:s,defaultEdges:i,width:l,height:c,fitView:p,fitViewOptions:f,minZoom:m,maxZoom:g,nodeOrigin:x,nodeExtent:b,zIndexMode:v}){return z.useContext(ou)?d.jsx(d.Fragment,{children:e}):d.jsx(l5,{initialNodes:n,initialEdges:a,defaultNodes:s,defaultEdges:i,initialWidth:l,initialHeight:c,fitView:p,initialFitViewOptions:f,initialMinZoom:m,initialMaxZoom:g,nodeOrigin:x,nodeExtent:b,zIndexMode:v,children:e})}const u5={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function d5({nodes:e,edges:n,defaultNodes:a,defaultEdges:s,className:i,nodeTypes:l,edgeTypes:c,onNodeClick:p,onEdgeClick:f,onInit:m,onMove:g,onMoveStart:x,onMoveEnd:b,onConnect:v,onConnectStart:k,onConnectEnd:w,onClickConnectStart:C,onClickConnectEnd:M,onNodeMouseEnter:N,onNodeMouseMove:S,onNodeMouseLeave:E,onNodeContextMenu:I,onNodeDoubleClick:D,onNodeDragStart:A,onNodeDrag:L,onNodeDragStop:P,onNodesDelete:W,onEdgesDelete:$,onDelete:V,onSelectionChange:X,onSelectionDragStart:H,onSelectionDrag:_,onSelectionDragStop:T,onSelectionContextMenu:B,onSelectionStart:G,onSelectionEnd:K,onBeforeDelete:J,connectionMode:F,connectionLineType:O=Xo.Bezier,connectionLineStyle:Q,connectionLineComponent:q,connectionLineContainerStyle:ie,deleteKeyCode:pe="Backspace",selectionKeyCode:me="Shift",selectionOnDrag:U=!1,selectionMode:ce=ui.Full,panActivationKeyCode:ge="Space",multiSelectionKeyCode:be=pi()?"Meta":"Control",zoomActivationKeyCode:ye=pi()?"Meta":"Control",snapToGrid:te,snapGrid:he,onlyRenderVisibleElements:je=!1,selectNodesOnDrag:Ie,nodesDraggable:ze,autoPanOnNodeFocus:Tt,nodesConnectable:ft,nodesFocusable:vt,nodeOrigin:mn=k1,edgesFocusable:tn,edgesReconnectable:hn,elementsSelectable:kt=!0,defaultViewport:Ba=Fj,minZoom:Bn=.5,maxZoom:go=2,translateExtent:na=ci,preventScrolling:gu=!0,nodeExtent:Pa,defaultMarkerColor:yu="#b1b1b7",zoomOnScroll:xu=!0,zoomOnPinch:oa=!0,panOnScroll:Dt=!1,panOnScrollSpeed:jn=.5,panOnScrollMode:zt=Da.Free,zoomOnDoubleClick:bu=!0,panOnDrag:vu=!0,onPaneClick:ku,onPaneMouseEnter:Ha,onPaneMouseMove:Ua,onPaneMouseLeave:Ga,onPaneScroll:Pn,onPaneContextMenu:qa,paneClickDistance:aa=1,nodeClickDistance:wu=0,children:$i,onReconnect:Ys,onReconnectStart:sa,onReconnectEnd:Su,onEdgeContextMenu:Oi,onEdgeDoubleClick:Fi,onEdgeMouseEnter:Ii,onEdgeMouseMove:Vs,onEdgeMouseLeave:Ws,reconnectRadius:Li=10,onNodesChange:Bi,onEdgesChange:Tn,noDragClassName:mt="nodrag",noWheelClassName:Nt="nowheel",noPanClassName:Hn="nopan",fitView:Ka,fitViewOptions:Pi,connectOnClick:Cu,attributionPosition:Hi,proOptions:ra,defaultEdgeOptions:Xs,elevateNodesOnSelect:yo=!0,elevateEdgesOnSelect:xo=!1,disableKeyboardA11y:bo=!1,autoPanOnConnect:vo,autoPanOnNodeDrag:it,autoPanSpeed:Ui,connectionRadius:Gi,isValidConnection:Un,onError:ko,style:Mu,id:Zs,nodeDragThreshold:qi,connectionDragThreshold:Eu,viewport:Ya,onViewportChange:Va,width:gn,height:$t,colorMode:Ki="light",debug:ju,onScroll:Wa,ariaLabelConfig:Yi,zIndexMode:ia="basic",...Tu},Ot){const la=Zs||"1",Vi=Pj(Ki),Qs=z.useCallback(Gn=>{Gn.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Wa?.(Gn)},[Wa]);return d.jsx("div",{"data-testid":"rf__wrapper",...Tu,onScroll:Qs,style:{...Mu,...u5},ref:Ot,className:pt(["react-flow",i,Vi]),id:Zs,role:"application",children:d.jsxs(c5,{nodes:e,edges:n,width:gn,height:$t,fitView:Ka,fitViewOptions:Pi,minZoom:Bn,maxZoom:go,nodeOrigin:mn,nodeExtent:Pa,zIndexMode:ia,children:[d.jsx(r5,{onInit:m,onNodeClick:p,onEdgeClick:f,onNodeMouseEnter:N,onNodeMouseMove:S,onNodeMouseLeave:E,onNodeContextMenu:I,onNodeDoubleClick:D,nodeTypes:l,edgeTypes:c,connectionLineType:O,connectionLineStyle:Q,connectionLineComponent:q,connectionLineContainerStyle:ie,selectionKeyCode:me,selectionOnDrag:U,selectionMode:ce,deleteKeyCode:pe,multiSelectionKeyCode:be,panActivationKeyCode:ge,zoomActivationKeyCode:ye,onlyRenderVisibleElements:je,defaultViewport:Ba,translateExtent:na,minZoom:Bn,maxZoom:go,preventScrolling:gu,zoomOnScroll:xu,zoomOnPinch:oa,zoomOnDoubleClick:bu,panOnScroll:Dt,panOnScrollSpeed:jn,panOnScrollMode:zt,panOnDrag:vu,onPaneClick:ku,onPaneMouseEnter:Ha,onPaneMouseMove:Ua,onPaneMouseLeave:Ga,onPaneScroll:Pn,onPaneContextMenu:qa,paneClickDistance:aa,nodeClickDistance:wu,onSelectionContextMenu:B,onSelectionStart:G,onSelectionEnd:K,onReconnect:Ys,onReconnectStart:sa,onReconnectEnd:Su,onEdgeContextMenu:Oi,onEdgeDoubleClick:Fi,onEdgeMouseEnter:Ii,onEdgeMouseMove:Vs,onEdgeMouseLeave:Ws,reconnectRadius:Li,defaultMarkerColor:yu,noDragClassName:mt,noWheelClassName:Nt,noPanClassName:Hn,rfId:la,disableKeyboardA11y:bo,nodeExtent:Pa,viewport:Ya,onViewportChange:Va}),d.jsx(Bj,{nodes:e,edges:n,defaultNodes:a,defaultEdges:s,onConnect:v,onConnectStart:k,onConnectEnd:w,onClickConnectStart:C,onClickConnectEnd:M,nodesDraggable:ze,autoPanOnNodeFocus:Tt,nodesConnectable:ft,nodesFocusable:vt,edgesFocusable:tn,edgesReconnectable:hn,elementsSelectable:kt,elevateNodesOnSelect:yo,elevateEdgesOnSelect:xo,minZoom:Bn,maxZoom:go,nodeExtent:Pa,onNodesChange:Bi,onEdgesChange:Tn,snapToGrid:te,snapGrid:he,connectionMode:F,translateExtent:na,connectOnClick:Cu,defaultEdgeOptions:Xs,fitView:Ka,fitViewOptions:Pi,onNodesDelete:W,onEdgesDelete:$,onDelete:V,onNodeDragStart:A,onNodeDrag:L,onNodeDragStop:P,onSelectionDrag:_,onSelectionDragStart:H,onSelectionDragStop:T,onMove:g,onMoveStart:x,onMoveEnd:b,noPanClassName:Hn,nodeOrigin:mn,rfId:la,autoPanOnConnect:vo,autoPanOnNodeDrag:it,autoPanSpeed:Ui,onError:ko,connectionRadius:Gi,isValidConnection:Un,selectNodesOnDrag:Ie,nodeDragThreshold:qi,connectionDragThreshold:Eu,onBeforeDelete:J,debug:ju,ariaLabelConfig:Yi,zIndexMode:ia}),d.jsx(Oj,{onSelectionChange:X}),$i,d.jsx(_j,{proOptions:ra,position:Hi}),d.jsx(Aj,{rfId:la,disableKeyboardA11y:bo})]})})}S1(d5);function p5({dimensions:e,lineWidth:n,variant:a,className:s}){return d.jsx("path",{strokeWidth:n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:pt(["react-flow__background-pattern",a,s])})}function f5({radius:e,className:n}){return d.jsx("circle",{cx:e,cy:e,r:e,className:pt(["react-flow__background-pattern","dots",n])})}var Jo;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Jo||(Jo={}));const m5={[Jo.Dots]:1,[Jo.Lines]:1,[Jo.Cross]:6},h5=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Y1({id:e,variant:n=Jo.Dots,gap:a=20,size:s,lineWidth:i=1,offset:l=0,color:c,bgColor:p,style:f,className:m,patternClassName:g}){const x=z.useRef(null),{transform:b,patternId:v}=Fe(h5,et),k=s||m5[n],w=n===Jo.Dots,C=n===Jo.Cross,M=Array.isArray(a)?a:[a,a],N=[M[0]*b[2]||1,M[1]*b[2]||1],S=k*b[2],E=Array.isArray(l)?l:[l,l],I=C?[S,S]:N,D=[E[0]*b[2]||1+I[0]/2,E[1]*b[2]||1+I[1]/2],A=`${v}${e||""}`;return d.jsxs("svg",{className:pt(["react-flow__background",m]),style:{...f,...su,"--xy-background-color-props":p,"--xy-background-pattern-color-props":c},ref:x,"data-testid":"rf__background",children:[d.jsx("pattern",{id:A,x:b[0]%N[0],y:b[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${D[0]},-${D[1]})`,children:w?d.jsx(f5,{radius:S/2,className:g}):d.jsx(p5,{dimensions:I,lineWidth:i,variant:n,className:g})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${A})`})]})}Y1.displayName="Background";z.memo(Y1);function g5(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function y5(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function x5(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function b5(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function v5(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function fc({children:e,className:n,...a}){return d.jsx("button",{type:"button",className:pt(["react-flow__controls-button",n]),...a,children:e})}const k5=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function V1({style:e,showZoom:n=!0,showFitView:a=!0,showInteractive:s=!0,fitViewOptions:i,onZoomIn:l,onZoomOut:c,onFitView:p,onInteractiveChange:f,className:m,children:g,position:x="bottom-left",orientation:b="vertical","aria-label":v}){const k=tt(),{isInteractive:w,minZoomReached:C,maxZoomReached:M,ariaLabelConfig:N}=Fe(k5,et),{zoomIn:S,zoomOut:E,fitView:I}=om(),D=()=>{S(),l?.()},A=()=>{E(),c?.()},L=()=>{I(i),p?.()},P=()=>{k.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),f?.(!w)},W=b==="horizontal"?"horizontal":"vertical";return d.jsxs(au,{className:pt(["react-flow__controls",W,m]),position:x,style:e,"data-testid":"rf__controls","aria-label":v??N["controls.ariaLabel"],children:[n&&d.jsxs(d.Fragment,{children:[d.jsx(fc,{onClick:D,className:"react-flow__controls-zoomin",title:N["controls.zoomIn.ariaLabel"],"aria-label":N["controls.zoomIn.ariaLabel"],disabled:M,children:d.jsx(g5,{})}),d.jsx(fc,{onClick:A,className:"react-flow__controls-zoomout",title:N["controls.zoomOut.ariaLabel"],"aria-label":N["controls.zoomOut.ariaLabel"],disabled:C,children:d.jsx(y5,{})})]}),a&&d.jsx(fc,{className:"react-flow__controls-fitview",onClick:L,title:N["controls.fitView.ariaLabel"],"aria-label":N["controls.fitView.ariaLabel"],children:d.jsx(x5,{})}),s&&d.jsx(fc,{className:"react-flow__controls-interactive",onClick:P,title:N["controls.interactive.ariaLabel"],"aria-label":N["controls.interactive.ariaLabel"],children:w?d.jsx(v5,{}):d.jsx(b5,{})}),g]})}V1.displayName="Controls";z.memo(V1);function w5({id:e,x:n,y:a,width:s,height:i,style:l,color:c,strokeColor:p,strokeWidth:f,className:m,borderRadius:g,shapeRendering:x,selected:b,onClick:v}){const{background:k,backgroundColor:w}=l||{},C=c||k||w;return d.jsx("rect",{className:pt(["react-flow__minimap-node",{selected:b},m]),x:n,y:a,rx:g,ry:g,width:s,height:i,style:{fill:C,stroke:p,strokeWidth:f},shapeRendering:x,onClick:v?M=>v(M,e):void 0})}const S5=z.memo(w5),C5=e=>e.nodes.map(n=>n.id),Zp=e=>e instanceof Function?e:()=>e;function M5({nodeStrokeColor:e,nodeColor:n,nodeClassName:a="",nodeBorderRadius:s=5,nodeStrokeWidth:i,nodeComponent:l=S5,onClick:c}){const p=Fe(C5,et),f=Zp(n),m=Zp(e),g=Zp(a),x=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:p.map(b=>d.jsx(j5,{id:b,nodeColorFunc:f,nodeStrokeColorFunc:m,nodeClassNameFunc:g,nodeBorderRadius:s,nodeStrokeWidth:i,NodeComponent:l,onClick:c,shapeRendering:x},b))})}function E5({id:e,nodeColorFunc:n,nodeStrokeColorFunc:a,nodeClassNameFunc:s,nodeBorderRadius:i,nodeStrokeWidth:l,shapeRendering:c,NodeComponent:p,onClick:f}){const{node:m,x:g,y:x,width:b,height:v}=Fe(k=>{const w=k.nodeLookup.get(e);if(!w)return{node:void 0,x:0,y:0,width:0,height:0};const C=w.internals.userNode,{x:M,y:N}=w.internals.positionAbsolute,{width:S,height:E}=ho(C);return{node:C,x:M,y:N,width:S,height:E}},et);return!m||m.hidden||!Zb(m)?null:d.jsx(p,{x:g,y:x,width:b,height:v,style:m.style,selected:!!m.selected,className:s(m),color:n(m),borderRadius:i,strokeColor:a(m),strokeWidth:l,shapeRendering:c,onClick:f,id:m.id})}const j5=z.memo(E5);var T5=z.memo(M5);const N5=200,A5=150,_5=e=>!e.hidden,D5=e=>{const n={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:n,boundingRect:e.nodeLookup.size>0?Xb(Mi(e.nodeLookup,{filter:_5}),n):n,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},z5="react-flow__minimap-desc";function W1({style:e,className:n,nodeStrokeColor:a,nodeColor:s,nodeClassName:i="",nodeBorderRadius:l=5,nodeStrokeWidth:c,nodeComponent:p,bgColor:f,maskColor:m,maskStrokeColor:g,maskStrokeWidth:x,position:b="bottom-right",onClick:v,onNodeClick:k,pannable:w=!1,zoomable:C=!1,ariaLabel:M,inversePan:N,zoomStep:S=1,offsetScale:E=5}){const I=tt(),D=z.useRef(null),{boundingRect:A,viewBB:L,rfId:P,panZoom:W,translateExtent:$,flowWidth:V,flowHeight:X,ariaLabelConfig:H}=Fe(D5,et),_=e?.width??N5,T=e?.height??A5,B=A.width/_,G=A.height/T,K=Math.max(B,G),J=K*_,F=K*T,O=E*K,Q=A.x-(J-A.width)/2-O,q=A.y-(F-A.height)/2-O,ie=J+O*2,pe=F+O*2,me=`${z5}-${P}`,U=z.useRef(0),ce=z.useRef();U.current=K,z.useEffect(()=>{if(D.current&&W)return ce.current=ZE({domNode:D.current,panZoom:W,getTransform:()=>I.getState().transform,getViewScale:()=>U.current}),()=>{ce.current?.destroy()}},[W]),z.useEffect(()=>{ce.current?.update({translateExtent:$,width:V,height:X,inversePan:N,pannable:w,zoomStep:S,zoomable:C})},[w,C,N,S,$,V,X]);const ge=v?te=>{const[he,je]=ce.current?.pointer(te)||[0,0];v(te,{x:he,y:je})}:void 0,be=k?z.useCallback((te,he)=>{const je=I.getState().nodeLookup.get(he).internals.userNode;k(te,je)},[]):void 0,ye=M??H["minimap.ariaLabel"];return d.jsx(au,{position:b,style:{...e,"--xy-minimap-background-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-background-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-color-props":typeof g=="string"?g:void 0,"--xy-minimap-mask-stroke-width-props":typeof x=="number"?x*K:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof a=="string"?a:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:pt(["react-flow__minimap",n]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:_,height:T,viewBox:`${Q} ${q} ${ie} ${pe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":me,ref:D,onClick:ge,children:[ye&&d.jsx("title",{id:me,children:ye}),d.jsx(T5,{onClick:be,nodeColor:s,nodeStrokeColor:a,nodeBorderRadius:l,nodeClassName:i,nodeStrokeWidth:c,nodeComponent:p}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${Q-O},${q-O}h${ie+O*2}v${pe+O*2}h${-ie-O*2}z
18
+ M${L.x},${L.y}h${L.width}v${L.height}h${-L.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}W1.displayName="MiniMap";z.memo(W1);const R5=e=>n=>e?`${Math.max(1/n.transform[2],1)}`:void 0,$5={[Ps.Line]:"right",[Ps.Handle]:"bottom-right"};function O5({nodeId:e,position:n,variant:a=Ps.Handle,className:s,style:i=void 0,children:l,color:c,minWidth:p=10,minHeight:f=10,maxWidth:m=Number.MAX_VALUE,maxHeight:g=Number.MAX_VALUE,keepAspectRatio:x=!1,resizeDirection:b,autoScale:v=!0,shouldResize:k,onResizeStart:w,onResize:C,onResizeEnd:M}){const N=j1(),S=typeof e=="string"?e:N,E=tt(),I=z.useRef(null),D=a===Ps.Handle,A=Fe(z.useCallback(R5(D&&v),[D,v]),et),L=z.useRef(null),P=n??$5[a];z.useEffect(()=>{if(!(!I.current||!S))return L.current||(L.current=dj({domNode:I.current,nodeId:S,getStoreItems:()=>{const{nodeLookup:$,transform:V,snapGrid:X,snapToGrid:H,nodeOrigin:_,domNode:T}=E.getState();return{nodeLookup:$,transform:V,snapGrid:X,snapToGrid:H,nodeOrigin:_,paneDomNode:T}},onChange:($,V)=>{const{triggerNodeChanges:X,nodeLookup:H,parentLookup:_,nodeOrigin:T}=E.getState(),B=[],G={x:$.x,y:$.y},K=H.get(S);if(K&&K.expandParent&&K.parentId){const J=K.origin??T,F=$.width??K.measured.width??0,O=$.height??K.measured.height??0,Q={id:K.id,parentId:K.parentId,rect:{width:F,height:O,...Qb({x:$.x??K.position.x,y:$.y??K.position.y},{width:F,height:O},K.parentId,H,J)}},q=nm([Q],H,_,T);B.push(...q),G.x=$.x?Math.max(J[0]*F,$.x):void 0,G.y=$.y?Math.max(J[1]*O,$.y):void 0}if(G.x!==void 0&&G.y!==void 0){const J={id:S,type:"position",position:{...G}};B.push(J)}if($.width!==void 0&&$.height!==void 0){const F={id:S,type:"dimensions",resizing:!0,setAttributes:b?b==="horizontal"?"width":"height":!0,dimensions:{width:$.width,height:$.height}};B.push(F)}for(const J of V){const F={...J,type:"position"};B.push(F)}X(B)},onEnd:({width:$,height:V})=>{const X={id:S,type:"dimensions",resizing:!1,dimensions:{width:$,height:V}};E.getState().triggerNodeChanges([X])}})),L.current.update({controlPosition:P,boundaries:{minWidth:p,minHeight:f,maxWidth:m,maxHeight:g},keepAspectRatio:x,resizeDirection:b,onResizeStart:w,onResize:C,onResizeEnd:M,shouldResize:k}),()=>{L.current?.destroy()}},[P,p,f,m,g,x,w,C,M,k]);const W=P.split("-");return d.jsx("div",{className:pt(["react-flow__resize-control","nodrag",...W,a,s]),ref:I,style:{...i,scale:A,...c&&{[D?"backgroundColor":"borderColor"]:c}},children:l})}z.memo(O5);const F5=typeof localStorage<"u"?localStorage.getItem("modular-theme"):null,Pc=qt((e,n)=>({theme:F5==="light"?"light":"dark",toggleTheme:()=>{const a=n().theme==="dark"?"light":"dark";localStorage.setItem("modular-theme",a),e({theme:a})}})),I5={bg:"#111114",surface:"rgba(28, 28, 32, 0.9)",surfaceOpaque:"#1c1c20",surfaceElevated:"#25252a",surfaceHover:"#1f1f24",border:"#2a2a30",borderSubtle:"#222226",textPrimary:"#f0f0f0",textSecondary:"#888",textMuted:"#666",textDim:"#555",textFaint:"#444",inputBg:"#141417",badgeBg:"#25252a",dotGrid:"#222228",minimapBg:"#111114",minimapMask:"rgba(17,17,20,0.8)",minimapNode:"#25252a",controlsBg:"#1c1c20",controlsBorder:"#2a2a30",tileActiveBg:"#25252a",tileHoverBg:"#1f1f24",tileBg:"#1c1c20",tileBorderHover:"#3a3a40",agentBg:"#151210",agentBorder:"#2d2720",agentLabel:"#9a8e82",agentMeta:"#6d6058",agentArrow:"#6d6058",agentLineNum:"#2d2720",agentText:"#8a7e72",tokenLabel:"#999",tokenDivider:"#777",tokenTrackBg:"#25252a",jackRingBase:"#0a0a0a",jackLabelOnRing:"#999",jackLabelBeside:"#666",cableShadow:"rgba(0,0,0,0.4)",cableHighlight:"rgba(255,255,255,0.06)",responseBg:"rgba(28, 28, 32, 0.9)",responseText:"#bbb",statusSuccess:"#00ff88",statusError:"#ff3344",statusWarning:"#ffaa00",statusInfo:"#3498db",statusSuccessBg:"rgba(0,255,136,0.07)",statusErrorBg:"rgba(255,51,68,0.08)",statusWarningBg:"rgba(255,170,0,0.08)",statusSuccessGlow:"0 0 6px rgba(0,255,136,0.5)",statusErrorGlow:"0 0 6px rgba(255,51,68,0.5)",statusWarningGlow:"0 0 6px rgba(255,170,0,0.5)",cableSkills:"#f1c40f",cableMcp:"#2ecc71",cableKnowledge:"#e74c3c"},L5={bg:"#f0f1f3",surface:"rgba(255,255,255,0.95)",surfaceOpaque:"#ffffff",surfaceElevated:"#eeeef2",surfaceHover:"#f5f5f8",border:"#ccccd4",borderSubtle:"#dddde2",textPrimary:"#1a1a20",textSecondary:"#3a3a45",textMuted:"#555560",textDim:"#5c5c66",textFaint:"#71717a",inputBg:"#f5f5f8",badgeBg:"#e5e5ea",dotGrid:"#d0d0d8",minimapBg:"#f0f1f3",minimapMask:"rgba(240,241,243,0.8)",minimapNode:"#dddde2",controlsBg:"#ffffff",controlsBorder:"#ccccd4",tileActiveBg:"#e8e8ee",tileHoverBg:"#f0f0f5",tileBg:"#ffffff",tileBorderHover:"#bbbbc4",agentBg:"#f8f8fa",agentBorder:"#dddde2",agentLabel:"#555560",agentMeta:"#888890",agentArrow:"#888890",agentLineNum:"#ccccd4",agentText:"#666670",tokenLabel:"#555560",tokenDivider:"#888890",tokenTrackBg:"#dddde2",jackRingBase:"#e8e8ee",jackLabelOnRing:"#555",jackLabelBeside:"#777",cableShadow:"rgba(0,0,0,0.12)",cableHighlight:"rgba(255,255,255,0.3)",responseBg:"rgba(255,255,255,0.95)",responseText:"#444",statusSuccess:"#16a34a",statusError:"#dc2626",statusWarning:"#ca8a04",statusInfo:"#2563eb",statusSuccessBg:"rgba(22,163,74,0.08)",statusErrorBg:"rgba(220,38,38,0.08)",statusWarningBg:"rgba(202,138,4,0.08)",statusSuccessGlow:"0 0 6px rgba(22,163,74,0.3)",statusErrorGlow:"0 0 6px rgba(220,38,38,0.3)",statusWarningGlow:"0 0 6px rgba(202,138,4,0.3)",cableSkills:"#B45309",cableMcp:"#16a34a",cableKnowledge:"#dc2626"};function we(){const e=Pc(a=>a.theme);return{...e==="dark"?I5:L5,isDark:e==="dark"}}const zs=z.forwardRef(function({label:n,error:a,className:s="",style:i,...l},c){const p=we();return d.jsxs("div",{className:"flex flex-col gap-1",children:[n&&d.jsx("label",{className:"text-[13px] tracking-wider uppercase font-semibold",style:{color:p.textMuted,fontFamily:"'Geist Mono', monospace"},children:n}),d.jsx("input",{ref:c,className:`w-full px-3 py-2 rounded-md outline-none nodrag ${s}`,style:{background:p.inputBg,border:`1px solid ${a?p.statusError:p.border}`,color:p.textPrimary,fontFamily:"'Geist Sans', sans-serif",fontSize:16,lineHeight:1.5,...i},...l}),a&&d.jsx("span",{className:"text-[13px]",style:{color:p.statusError},children:a})]})}),Aa=z.forwardRef(function({label:n,error:a,showCount:s,maxChars:i,value:l,className:c="",style:p,...f},m){const g=we(),x=typeof l=="string"?l.length:0;return d.jsxs("div",{className:"flex flex-col gap-1",children:[(n||s)&&d.jsxs("div",{className:"flex items-center justify-between",children:[n&&d.jsx("label",{className:"text-[13px] tracking-wider uppercase font-semibold",style:{color:g.textMuted,fontFamily:"'Geist Mono', monospace"},children:n}),s&&d.jsxs("span",{className:"text-[13px]",style:{color:i&&x>i?g.statusError:g.textFaint},children:[x,i?` / ${i}`:""]})]}),d.jsx("textarea",{ref:m,value:l,className:`w-full px-3 py-2.5 rounded-md outline-none resize-none nowheel nodrag ${c}`,style:{background:g.inputBg,border:`1px solid ${a?g.statusError:g.border}`,color:g.textPrimary,fontFamily:"'Geist Sans', sans-serif",fontSize:16,lineHeight:1.5,minHeight:64,...p},...f}),a&&d.jsx("span",{className:"text-[13px]",style:{color:g.statusError},children:a})]})});const X1=(...e)=>e.filter((n,a,s)=>!!n&&n.trim()!==""&&s.indexOf(n)===a).join(" ").trim();const B5=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const P5=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(n,a,s)=>s?s.toUpperCase():a.toLowerCase());const Tx=e=>{const n=P5(e);return n.charAt(0).toUpperCase()+n.slice(1)};var H5={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 U5=e=>{for(const n in e)if(n.startsWith("aria-")||n==="role"||n==="title")return!0;return!1};const G5=z.forwardRef(({color:e="currentColor",size:n=24,strokeWidth:a=2,absoluteStrokeWidth:s,className:i="",children:l,iconNode:c,...p},f)=>z.createElement("svg",{ref:f,...H5,width:n,height:n,stroke:e,strokeWidth:s?Number(a)*24/Number(n):a,className:X1("lucide",i),...!l&&!U5(p)&&{"aria-hidden":"true"},...p},[...c.map(([m,g])=>z.createElement(m,g)),...Array.isArray(l)?l:[l]]));const fe=(e,n)=>{const a=z.forwardRef(({className:s,...i},l)=>z.createElement(G5,{ref:l,iconNode:n,className:X1(`lucide-${B5(Tx(e))}`,`lucide-${e}`,s),...i}));return a.displayName=Tx(e),a};const q5=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Df=fe("activity",q5);const K5=[["path",{d:"M12 6v16",key:"nqf5sj"}],["path",{d:"m19 13 2-1a9 9 0 0 1-18 0l2 1",key:"y7qv08"}],["path",{d:"M9 11h6",key:"1fldmi"}],["circle",{cx:"12",cy:"4",r:"2",key:"muu5ef"}]],Y5=fe("anchor",K5);const V5=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],W5=fe("arrow-down-right",V5);const X5=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Z5=fe("arrow-down",X5);const Q5=[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]],J5=fe("arrow-right-left",Q5);const eN=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],Nx=fe("arrow-up-right",eN);const tN=[["path",{d:"M16 7h.01",key:"1kdx03"}],["path",{d:"M3.4 18H12a8 8 0 0 0 8-8V7a4 4 0 0 0-7.28-2.3L2 20",key:"oj1oa8"}],["path",{d:"m20 7 2 .5-2 .5",key:"12nv4d"}],["path",{d:"M10 18v3",key:"1yea0a"}],["path",{d:"M14 17.75V21",key:"1pymcb"}],["path",{d:"M7 18a6 6 0 0 0 3.84-10.61",key:"1npnn0"}]],nN=fe("bird",tN);const oN=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],Z1=fe("book-open",oN);const aN=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Ti=fe("bot",aN);const sN=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],sm=fe("box",sN);const rN=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],Ni=fe("brain",rN);const iN=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],lN=fe("bug",iN);const cN=[["path",{d:"M12 5c.67 0 1.35.09 2 .26 1.78-2 5.03-2.84 6.42-2.26 1.4.58-.42 7-.42 7 .57 1.07 1 2.24 1 3.44C21 17.9 16.97 21 12 21s-9-3-9-7.56c0-1.25.5-2.4 1-3.44 0 0-1.89-6.42-.5-7 1.39-.58 4.72.23 6.5 2.23A9.04 9.04 0 0 1 12 5Z",key:"x6xyqk"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M11.25 16.25h1.5L12 17l-.75-.75Z",key:"12kq1m"}]],uN=fe("cat",cN);const dN=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],rm=fe("chart-column",dN);const pN=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],_t=fe("check",pN);const fN=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Mn=fe("chevron-down",fN);const mN=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ta=fe("chevron-right",mN);const hN=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Q1=fe("chevron-up",hN);const gN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],im=fe("circle-alert",gN);const yN=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Hc=fe("circle-check-big",yN);const xN=[["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"}]],mi=fe("circle-x",xN);const bN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],vN=fe("circle",bN);const kN=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]],wN=fe("clipboard-list",kN);const SN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],CN=fe("clock",SN);const MN=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],EN=fe("cloud",MN);const jN=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],J1=fe("code",jN);const TN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]],NN=fe("compass",TN);const AN=[["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"}]],ev=fe("copy",AN);const _N=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Ai=fe("cpu",_N);const DN=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],_i=fe("database",DN);const zN=[["path",{d:"M11.25 16.25h1.5L12 17z",key:"w7jh35"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M4.42 11.247A13.152 13.152 0 0 0 4 14.556C4 18.728 7.582 21 12 21s8-2.272 8-6.444a11.702 11.702 0 0 0-.493-3.309",key:"u7s9ue"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M8.5 8.5c-.384 1.05-1.083 2.028-2.344 2.5-1.931.722-3.576-.297-3.656-1-.113-.994 1.177-6.53 4-7 1.923-.321 3.651.845 3.651 2.235A7.497 7.497 0 0 1 14 5.277c0-1.39 1.844-2.598 3.767-2.277 2.823.47 4.113 6.006 4 7-.08.703-1.725 1.722-3.656 1-1.261-.472-1.855-1.45-2.239-2.5",key:"v8hric"}]],RN=fe("dog",zN);const $N=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],iu=fe("download",$N);const ON=[["path",{d:"M10 11h.01",key:"d2at3l"}],["path",{d:"M14 6h.01",key:"k028ub"}],["path",{d:"M18 6h.01",key:"1v4wsw"}],["path",{d:"M6.5 13.1h.01",key:"1748ia"}],["path",{d:"M22 5c0 9-4 12-6 12s-6-3-6-12c0-2 2-3 6-3s6 1 6 3",key:"172yzv"}],["path",{d:"M17.4 9.9c-.8.8-2 .8-2.8 0",key:"1obv0w"}],["path",{d:"M10.1 7.1C9 7.2 7.7 7.7 6 8.6c-3.5 2-4.7 3.9-3.7 5.6 4.5 7.8 9.5 8.4 11.2 7.4.9-.5 1.9-2.1 1.9-4.7",key:"rqjl8i"}],["path",{d:"M9.1 16.5c.3-1.1 1.4-1.7 2.4-1.4",key:"1mr6wy"}]],FN=fe("drama",ON);const IN=[["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"}]],tv=fe("external-link",IN);const LN=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],BN=fe("eye-off",LN);const PN=[["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"}]],HN=fe("eye",PN);const UN=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],GN=fe("file-code",UN);const qN=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Di=fe("file-text",qN);const KN=[["path",{d:"M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4",key:"1slcih"}]],nv=fe("flame",KN);const YN=[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]],VN=fe("folder-git-2",YN);const WN=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],lm=fe("folder-open",WN);const XN=[["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"}]],ZN=fe("folder",XN);const QN=[["path",{d:"M10.5 3 8 9l4 13 4-13-2.5-6",key:"b3dvk1"}],["path",{d:"M17 3a2 2 0 0 1 1.6.8l3 4a2 2 0 0 1 .013 2.382l-7.99 10.986a2 2 0 0 1-3.247 0l-7.99-10.986A2 2 0 0 1 2.4 7.8l2.998-3.997A2 2 0 0 1 7 3z",key:"7w4byz"}],["path",{d:"M2 9h20",key:"16fsjt"}]],JN=fe("gem",QN);const e3=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],Us=fe("git-branch",e3);const t3=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ov=fe("globe",t3);const n3=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],o3=fe("grid-3x3",n3);const a3=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],s3=fe("grip-vertical",a3);const r3=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],i3=fe("hard-drive",r3);const l3=[["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"}]],c3=fe("hash",l3);const u3=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],d3=fe("heart",u3);const p3=[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]],f3=fe("hexagon",p3);const m3=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],h3=fe("image",m3);const g3=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],y3=fe("info",g3);const x3=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],b3=fe("key-round",x3);const v3=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],k3=fe("layers",v3);const w3=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],av=fe("layout-grid",w3);const S3=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],C3=fe("library",S3);const M3=[["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"}]],Uc=fe("lightbulb",M3);const E3=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],Ax=fe("list-ordered",E3);const j3=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],yt=fe("loader-circle",j3);const T3=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],N3=fe("mail",T3);const A3=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],_3=fe("map",A3);const D3=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],sv=fe("maximize-2",D3);const z3=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],R3=fe("mic",z3);const $3=[["path",{d:"M6 18h8",key:"1borvv"}],["path",{d:"M3 22h18",key:"8prr45"}],["path",{d:"M14 22a7 7 0 1 0 0-14h-1",key:"1jwaiy"}],["path",{d:"M9 14h2",key:"197e7h"}],["path",{d:"M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z",key:"1bmzmy"}],["path",{d:"M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3",key:"1drr47"}]],O3=fe("microscope",$3);const F3=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],cm=fe("minimize-2",F3);const I3=[["path",{d:"M5 12h14",key:"1ays0h"}]],L3=fe("minus",I3);const B3=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],P3=fe("monitor",B3);const H3=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],rv=fe("moon",H3);const U3=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],iv=fe("package",U3);const G3=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],lv=fe("palette",G3);const q3=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]],K3=fe("panels-top-left",q3);const Y3=[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]],cv=fe("pen-tool",Y3);const V3=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],_x=fe("pencil-line",V3);const W3=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],uv=fe("play",W3);const X3=[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]],dv=fe("plug-zap",X3);const Z3=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],zi=fe("plug",Z3);const Q3=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],bt=fe("plus",Q3);const J3=[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]],e4=fe("presentation",J3);const t4=[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]],n4=fe("rocket",t4);const o4=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],um=fe("rotate-ccw",o4);const a4=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Dx=fe("rotate-cw",a4);const s4=[["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"}]],dm=fe("save",s4);const r4=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],lu=fe("search",r4);const i4=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],l4=fe("send",i4);const c4=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],u4=fe("server",c4);const d4=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],pm=fe("settings",d4);const p4=[["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"}]],fm=fe("shield",p4);const f4=[["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}],["path",{d:"M3.103 6.034h17.794",key:"awc11p"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z",key:"o988cm"}]],m4=fe("shopping-bag",f4);const h4=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],La=fe("sparkles",h4);const g4=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],pv=fe("square",g4);const y4=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],x4=fe("star",y4);const b4=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],fv=fe("sun",b4);const v4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],cu=fe("target",v4);const k4=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],hi=fe("terminal",k4);const w4=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],uu=fe("trash-2",w4);const S4=[["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"}]],mv=fe("triangle-alert",S4);const C4=[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]],M4=fe("triangle",C4);const E4=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],hv=fe("upload",E4);const j4=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],T4=fe("users",j4);const N4=[["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"}]],A4=fe("wand-sparkles",N4);const _4=[["path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"knzxuh"}],["path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"2jd2cc"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}]],D4=fe("waves",_4);const z4=[["path",{d:"m10.586 5.414-5.172 5.172",key:"4mc350"}],["path",{d:"m18.586 13.414-5.172 5.172",key:"8c96vv"}],["path",{d:"M6 12h12",key:"8npq4p"}],["circle",{cx:"12",cy:"20",r:"2",key:"144qzu"}],["circle",{cx:"12",cy:"4",r:"2",key:"muu5ef"}],["circle",{cx:"20",cy:"12",r:"2",key:"1xzzfp"}],["circle",{cx:"4",cy:"12",r:"2",key:"1hvhnz"}]],R4=fe("waypoints",z4);const $4=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],O4=fe("workflow",$4);const F4=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],gv=fe("wrench",F4);const I4=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],jt=fe("x",I4);const L4=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],pn=fe("zap",L4);function Rn({options:e,value:n,onChange:a,label:s,placeholder:i="Select...",size:l="md"}){const c=we(),[p,f]=z.useState(!1),[m,g]=z.useState({x:0,y:0,w:0}),x=z.useRef(null),b=e.find(w=>w.value===n),v={sm:28,md:32};z.useEffect(()=>{if(!p)return;const w=()=>f(!1);return document.addEventListener("click",w),()=>document.removeEventListener("click",w)},[p]);const k=()=>{if(!x.current)return;const w=x.current.getBoundingClientRect();g({x:w.left,y:w.bottom+4,w:w.width}),f(!p)};return d.jsxs("div",{className:"flex flex-col gap-1",children:[s&&d.jsx("label",{className:"text-[13px] tracking-wider uppercase font-semibold",style:{color:c.textMuted,fontFamily:"'Geist Mono', monospace"},children:s}),d.jsxs("button",{ref:x,type:"button",onClick:w=>{w.stopPropagation(),k()},className:"flex items-center justify-between gap-2 w-full rounded-lg cursor-pointer border outline-none nodrag",style:{height:v[l],padding:"0 10px",fontSize:13,fontFamily:"'Geist Mono', monospace",background:c.inputBg,borderColor:c.border,color:b?c.textPrimary:c.textMuted},children:[d.jsxs("span",{className:"flex items-center gap-1.5 truncate",children:[b?.icon,b?.label||i]}),d.jsx(Mn,{size:12,style:{color:c.textDim,transform:p?"rotate(180deg)":"none",transition:"transform 0.15s"}})]}),p&&nu.createPortal(d.jsx("div",{className:"fixed z-[250] rounded-lg overflow-hidden py-1",style:{left:m.x,top:m.y,width:m.w,background:c.surfaceElevated,border:`1px solid ${c.border}`,boxShadow:`0 8px 24px ${c.isDark?"rgba(0,0,0,0.5)":"rgba(0,0,0,0.12)"}`,maxHeight:200,overflowY:"auto"},onClick:w=>w.stopPropagation(),children:e.map(w=>d.jsxs("button",{type:"button",onClick:()=>{a(w.value),f(!1)},className:"flex items-center gap-2 w-full px-3 py-1.5 text-[13px] text-left cursor-pointer border-none bg-transparent",style:{fontFamily:"'Geist Mono', monospace",color:w.value===n?"#FE5000":c.textSecondary,background:w.value===n?"#FE500008":"transparent"},onMouseEnter:C=>C.currentTarget.style.background=c.isDark?"#ffffff08":"#00000005",onMouseLeave:C=>C.currentTarget.style.background=w.value===n?"#FE500008":"transparent",children:[w.icon,d.jsx("span",{className:"flex-1 truncate",children:w.label}),w.value===n&&d.jsx(_t,{size:10})]},w.value))}),document.body)]})}const po=[{id:"anthropic",name:"Claude",authMethod:"api-key",status:"disconnected",baseUrl:"https://api.anthropic.com/v1",models:[],docsUrl:"https://docs.anthropic.com/en/api",keyPageUrl:"https://console.anthropic.com/settings/keys",pricingUrl:"https://www.anthropic.com/pricing",icon:"Bot",color:"#D4A574",authHeader:"x-api-key",headerNote:"Uses x-api-key header (not Bearer)"},{id:"openai",name:"OpenAI",authMethod:"api-key",status:"disconnected",baseUrl:"https://api.openai.com/v1",models:[],docsUrl:"https://platform.openai.com/docs",keyPageUrl:"https://platform.openai.com/api-keys",pricingUrl:"https://openai.com/pricing",icon:"Sparkles",color:"#10A37F",authHeader:"bearer"},{id:"google",name:"Google AI",authMethod:"api-key",status:"disconnected",baseUrl:"https://generativelanguage.googleapis.com/v1beta",models:[],docsUrl:"https://ai.google.dev/docs",keyPageUrl:"https://aistudio.google.com/app/apikey",pricingUrl:"https://ai.google.dev/pricing",icon:"Gem",color:"#4285F4",authHeader:"query-param",headerNote:"Uses ?key= query parameter"},{id:"claude-agent-sdk",name:"Claude (Agent SDK)",authMethod:"claude-agent-sdk",status:"disconnected",baseUrl:"",apiKey:"",models:[],docsUrl:"https://docs.anthropic.com/en/docs/claude-code/sdk",keyPageUrl:"",icon:"Terminal",color:"#D4A574",authHeader:"bearer",headerNote:"Zero-config — authenticates via Claude Code login"},{id:"openrouter",name:"OpenRouter",authMethod:"api-key",status:"disconnected",baseUrl:"https://openrouter.ai/api/v1",models:[],docsUrl:"https://openrouter.ai/docs",keyPageUrl:"https://openrouter.ai/keys",pricingUrl:"https://openrouter.ai/models",icon:"Route",color:"#6366F1",authHeader:"bearer",headerNote:"HTTP-Referer header recommended"}],yv="modular-providers";function zx(e){const n=e instanceof Error?e.message:String(e);return/failed to fetch|networkerror|load failed/i.test(n)?"Cannot reach backend API. Start server with `npm run server` (port 4800).":n}function B4(e,n){const a=(n||"").trim().replace(/\/+$/,"");return a&&((e==="openai"||a.includes("api.openai.com"))&&!a.endsWith("/v1")?`${a}/v1`:a)}let Gr=null,Qp=0;const P4=3e4,za=new Set,Jp=new Map;let ef=!1;async function gi(){const e=Date.now();if(Gr!==null&&e-Qp<P4)return Gr;try{Gr=(await fetch(`${Ee}/providers`,{method:"GET",signal:AbortSignal.timeout(2e3)})).ok,Qp=e}catch{Gr=!1,Qp=e}return Gr}async function mm(e){if(!await gi()){za.add(e.id);return}const a=e.id.includes("anthropic")||e.id==="claude-agent-sdk"?"anthropic":e.id.includes("google")?"google":e.id.includes("openrouter")?"openrouter":e.id.includes("openai")?"openai":"custom",s=l=>!l||/^[•]+$/.test(l),i={baseUrl:e.baseUrl,authMethod:e.authMethod,name:e.name,type:a};s(e.apiKey)||(i.apiKey=e.apiKey),s(e.accessToken)||(i.accessToken=e.accessToken),await fetch(`${Ee}/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}),za.delete(e.id)}function mc(e,n){const a=Jp.get(n);a&&clearTimeout(a);const s=setTimeout(()=>{const i=e.find(l=>l.id===n);i&&mm(i).catch(()=>{za.add(n)}).finally(()=>{Jp.delete(n)})},400);Jp.set(n,s)}async function zf(e){if(!(ef||za.size===0)){ef=!0;try{if(!await gi())return;const a=[...za];for(const s of a){const i=e.find(l=>l.id===s);if(!i){za.delete(s);continue}try{await mm(i)}catch{}}}finally{ef=!1}}}function H4(){try{const e=localStorage.getItem(yv);if(!e)return po;const n=JSON.parse(e),a=po.map(l=>{const c=n.find(f=>f.id===l.id);if(!c)return l;const p=c.authMethod??l.authMethod;return{...l,authMethod:p,apiKey:l.apiKey,accessToken:l.accessToken,baseUrl:c.baseUrl??l.baseUrl,status:c.status??l.status}}).concat(n.filter(l=>!po.some(c=>c.id===l.id)).map(l=>{const c=l.authMethod??"api-key";return{...po[po.length-1],...l,authMethod:c,apiKey:"",accessToken:"",id:l.id??"custom-"+Date.now(),name:l.name??"Custom",status:l.status??"disconnected",models:l.models??[{id:"custom-model",label:"Custom Model"}]}})),s=new Set,i=[];for(let l=a.length-1;l>=0;l--)s.has(a[l].id)||(s.add(a[l].id),i.unshift(a[l]));return i}catch{return po}}const U4=new Set(po.map(e=>e.id));function Et(e){const n=e.map(a=>{const s=U4.has(a.id);return{id:a.id,name:a.name,baseUrl:a.baseUrl,status:a.status,authMethod:a.authMethod,models:s?void 0:a.models,authHeader:s?void 0:a.authHeader,icon:s?void 0:a.icon,color:s?void 0:a.color,docsUrl:s?void 0:a.docsUrl,keyPageUrl:s?void 0:a.keyPageUrl,headerNote:s?void 0:a.headerNote}});localStorage.setItem(yv,JSON.stringify(n))}const Qe=qt((e,n)=>({providers:H4(),selectedProviderId:"",testing:{},setProviderKey:(a,s)=>{e(i=>{const l=i.providers.map(c=>{if(c.id!==a)return c;const p=!!s.trim(),f=c.authMethod==="oauth"?c.status:p?"configured":"disconnected";return{...c,apiKey:s,status:f}});return Et(l),mc(l,a),{providers:l}})},setProviderAccessToken:(a,s)=>{e(i=>{const l=i.providers.map(c=>c.id===a?{...c,accessToken:s,status:s.trim()?"configured":c.status}:c);return Et(l),mc(l,a),{providers:l}})},setProviderAuthMethod:(a,s)=>{e(i=>{const l=i.providers.map(c=>{if(c.id!==a)return c;const p=!!c.apiKey?.trim();return{...c,authMethod:s,status:s==="oauth"||p?"configured":"disconnected",lastError:void 0}});return Et(l),mc(l,a),{providers:l}})},setProviderBaseUrl:(a,s)=>{e(i=>{const l=B4(a,s),c=i.providers.map(p=>p.id===a?{...p,baseUrl:l}:p);return Et(c),mc(c,a),{providers:c}})},setProviderStatus:(a,s)=>{e(i=>{const l=i.providers.map(c=>c.id===a?{...c,status:s}:c);return Et(l),{providers:l}})},setProviderModels:(a,s)=>{e(i=>{const l=i.providers.map(c=>c.id===a?{...c,models:s}:c);return Et(l),{providers:l}})},getProviderForModel:a=>n().providers.find(s=>(Array.isArray(s.models)?s.models:[]).some(i=>i.id===a)),getActiveProvider:()=>n().providers.find(a=>a.id===n().selectedProviderId),getAllModels:()=>n().providers.flatMap(a=>{const s=Array.isArray(a.models)?a.models:[];return s.length===0?[]:a.status==="connected"||a.status==="configured"?s.map(i=>({id:i.id,label:i.label,providerId:a.id,providerName:a.name,providerColor:a.color})):[]}),selectProvider:a=>e({selectedProviderId:a}),testConnection:async a=>{e(s=>({testing:{...s.testing,[a]:!0}}));try{const s=n().providers.find(l=>l.id===a);if(s?.authMethod==="oauth"&&!s.apiKey?.trim()){const l='Codex sign-in not completed yet. Use "Sign in with Codex" first.';return e(c=>({testing:{...c.testing,[a]:!1},providers:c.providers.map(p=>p.id===a?{...p,status:"error",lastError:l}:p)})),Et(n().providers),{ok:!1,error:l}}if(s?.authMethod==="claude-agent-sdk")try{const l=await fetch(`${Ee}/agent-sdk/status`);if(l.status===429)return e(x=>({testing:{...x.testing,[a]:!1}})),{ok:!1,error:"Rate limited — try again in a moment"};const c=await l.json(),p=c?.data,f=p?.authenticated===!0,m=f&&p?.email?`${p.displayName||"User"} (${p.email})`:void 0,g=Array.isArray(p?.models)?p.models.map(x=>({id:x,label:x})):[];return e(x=>({testing:{...x.testing,[a]:!1},providers:x.providers.map(b=>b.id===a?{...b,status:f?"connected":"error",models:g.length>0?g:b.models,lastError:f?m:p?.error||"Not authenticated"}:b)})),Et(n().providers),f?{ok:!0,models:g.map(x=>x.id)}:{ok:!1,error:c?.data?.error||"Not authenticated — run `claude` in your terminal first"}}catch(l){const c=zx(l);return e(p=>({testing:{...p.testing,[a]:!1},providers:p.providers.map(f=>f.id===a?{...f,status:"error",lastError:c}:f)})),Et(n().providers),{ok:!1,error:c}}if(await gi()){const l=n().providers.find(g=>g.id===a),c=l?.apiKey&&!/^[•]+$/.test(l.apiKey);l&&c&&await fetch(`${Ee}/providers/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:l.apiKey,baseUrl:l.baseUrl})});const p={baseUrl:l?.baseUrl||""};c&&(p.apiKey=l.apiKey);const m=await(await fetch(`${Ee}/providers/${a}/test`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)})).json();if(m.status==="ok"){const g=m.data?.models??m.models??[],x=g.map(b=>({id:b,label:b}));return e(b=>({testing:{...b.testing,[a]:!1},providers:b.providers.map(v=>v.id===a?{...v,status:"connected",models:x.length?x:v.models,lastError:void 0}:v)})),Et(n().providers),{ok:!0,models:g}}else return e(g=>({testing:{...g.testing,[a]:!1},providers:g.providers.map(x=>x.id===a?{...x,status:"error",lastError:m.error}:x)})),Et(n().providers),{ok:!1,error:m.error}}else return n().providers.find(c=>c.id===a)?.apiKey?(e(c=>({testing:{...c.testing,[a]:!1},providers:c.providers.map(p=>p.id===a?{...p,status:"connected",lastError:void 0}:p)})),Et(n().providers),{ok:!0}):(e(c=>({testing:{...c.testing,[a]:!1}})),{ok:!1,error:"No API key configured"})}catch(s){const i=zx(s);return e(l=>({testing:{...l.testing,[a]:!1},providers:l.providers.map(c=>c.id===a?{...c,status:"error",lastError:i}:c)})),Et(n().providers),{ok:!1,error:i}}},saveProvider:async a=>{const s=n().providers,i=s.find(l=>l.id===a);if(i){Et(s);try{await mm(i)}catch{za.add(a)}zf(n().providers).catch(()=>{})}},deleteProvider:a=>{e(s=>{const i=s.providers.filter(l=>l.id!==a);return Et(i),{providers:i}}),gi().then(s=>{s&&fetch(`${Ee}/providers/${a}`,{method:"DELETE"}).catch(()=>{})})},addCustomProvider:()=>{const s={id:"custom-"+Date.now(),name:"Custom Provider",authMethod:"api-key",status:"disconnected",baseUrl:"http://localhost:11434/v1",models:[{id:"custom-model",label:"Custom Model"}],docsUrl:"",keyPageUrl:"",icon:"Server",color:"#888888",authHeader:"bearer",headerNote:"For Ollama, vLLM, or any OpenAI-compatible API"};e(i=>{const l=[...i.providers,s];return Et(l),{providers:l}})},loadFromBackend:async()=>{try{const a=await fetch(`${Ee}/providers`);if(!a.ok)return;const s=await a.json(),i=Array.isArray(s)?s:Array.isArray(s?.data)?s.data:[];if(i.length>0){const l=po.map(v=>{const k=i.find(M=>M.id===v.id);if(!k)return v;const w=!!k.hasStoredKey,C=!!k.hasStoredAccessToken;return{...v,...k,name:v.id==="anthropic"?"Claude":k.name||v.name,apiKey:w?"":v.apiKey,accessToken:C?"":v.accessToken,_hasStoredKey:w,_hasStoredAccessToken:C,status:w||C?"configured":k.status||v.status,models:Array.isArray(k.models)?k.models:v.models}}),c=i.filter(v=>!po.some(k=>k.id===v.id)).map(v=>({...v,models:Array.isArray(v.models)?v.models:[]})),p=[...l,...c],f=n().selectedProviderId,m=p.find(v=>v.id===f),g=!!(m&&(m.status==="connected"||m.status==="configured")&&Array.isArray(m.models)&&m.models.length>0),x=p.find(v=>(v.status==="connected"||v.status==="configured")&&Array.isArray(v.models)&&v.models.length>0),b=g?f:x?.id||"";e({providers:p,selectedProviderId:b}),Et(n().providers),await zf(n().providers)}}catch{}}}));gi().then(e=>{e&&(Qe.getState().loadFromBackend(),zf(Qe.getState().providers).catch(()=>{}))});function du(){const e=se.getState(),n=[];e.agentMeta.name&&n.push(`Agent: ${e.agentMeta.name}`),e.agentMeta.description&&n.push(`Description: ${e.agentMeta.description}`),e.instructionState.persona&&n.push(`Persona: ${e.instructionState.persona}`),e.instructionState.objectives.primary&&n.push(`Primary objective: ${e.instructionState.objectives.primary}`),e.instructionState.constraints.scopeDefinition&&n.push(`Scope: ${e.instructionState.constraints.scopeDefinition}`);const a=e.skills.filter(i=>i.enabled).map(i=>i.name);a.length&&n.push(`Skills: ${a.join(", ")}`);const s=e.mcpServers.filter(i=>i.enabled).map(i=>i.name);return s.length&&n.push(`MCP servers: ${s.join(", ")}`),n.join(`
19
+ `)}const hm={workflow:`You are an expert AI agent architect. Given the agent context below, generate a workflow — a sequence of 3-8 steps the agent should follow for every request.
20
+
21
+ Output ONLY a JSON array:
22
+ [{"label": "<step name>", "action": "<what the agent does>", "condition": false, "loop": false}]
23
+
24
+ Rules:
25
+ - Each step should be concrete and actionable
26
+ - Include verification/review steps where appropriate
27
+ - If the agent uses tools, reference them in the action text
28
+ - Steps should form a logical flow (gather → analyze → synthesize → verify → output)`,memory:`You are an expert AI agent architect. Given the agent context below, generate memory configuration and initial facts.
29
+
30
+ Output ONLY a JSON object:
31
+ {
32
+ "maxMessages": <10-50>,
33
+ "summarizeAfter": <5-25>,
34
+ "summarizeEnabled": <true|false>,
35
+ "suggestedFacts": ["<pre-loaded fact relevant to the agent's domain>"]
36
+ }
37
+
38
+ Rules:
39
+ - Conversational agents need higher maxMessages and summarization
40
+ - One-shot tools can have lower limits and no summarization
41
+ - Facts should be domain-relevant knowledge the agent should always have
42
+ - Generate 2-5 facts that help the agent do its job better`,knowledge:`You are an expert AI agent architect. Given the agent context below, suggest knowledge sources this agent should have access to.
43
+
44
+ Output ONLY a JSON array:
45
+ [{"name": "<source name>", "type": "<ground-truth|signal|evidence|framework|hypothesis|artifact>", "description": "<what it contains>"}]
46
+
47
+ Rules:
48
+ - Suggest 3-6 knowledge sources
49
+ - Use appropriate types: ground-truth for authoritative docs, signal for real-time data, evidence for research, framework for methodologies
50
+ - Be specific to the agent's domain`};async function pu(e,n){const a=Qe.getState(),s=a.providers.find(l=>l.id===a.selectedProviderId);if(!s)throw new Error("No provider configured — add one in Settings");const i=typeof s.models?.[0]=="object"?s.models[0].id:s.models?.[0]||"claude-sonnet-4-20250514";return s.authMethod==="claude-agent-sdk"?Yc({prompt:n,model:i,systemPrompt:e,maxTurns:1}):Kc({providerId:s.id,model:i,messages:[{role:"system",content:e},{role:"user",content:n}],temperature:.4,maxTokens:2048})}function fu(e){try{return JSON.parse(e)}catch{}const n=e.match(/```(?:json)?\s*([\s\S]*?)```/);if(n)try{return JSON.parse(n[1].trim())}catch{}const a=e.match(/[\[{][\s\S]*[\]}]/);if(a)try{return JSON.parse(a[0])}catch{}throw new Error("Could not parse LLM response as JSON")}async function G4(e){const n=du(),a=e.map((l,c)=>`${c+1}. ${l}`).join(`
51
+ `),s=`You are an expert AI agent architect. The user has sketched out workflow steps for their agent. Refine them into proper, actionable workflow steps.
52
+
53
+ User's draft steps:
54
+ ${a}
55
+
56
+ Agent context:
57
+ ${n||"(no agent identity set yet)"}
58
+
59
+ Output ONLY a JSON array:
60
+ [{"label": "<clear step name>", "action": "<specific what the agent does>", "condition": false, "loop": false}]
61
+
62
+ Rules:
63
+ - Keep the user's intent and ordering — don't add unrelated steps
64
+ - Make labels concise and action-oriented
65
+ - Fill in the "action" field with specific details about HOW the step works
66
+ - You may split or merge steps if it makes the flow clearer
67
+ - Add verification/output steps if the user forgot them`,i=await pu(s,a);return fu(i)}async function gm(){const e=du();if(!e)throw new Error("Add agent identity/persona first — the generator needs context");const n=await pu(hm.workflow,e);return fu(n)}async function xv(){const e=du();if(!e)throw new Error("Add agent identity/persona first — the generator needs context");const n=await pu(hm.memory,e);return fu(n)}async function q4(){const e=du();if(!e)throw new Error("Add agent identity/persona first — the generator needs context");const n=await pu(hm.knowledge,e);return fu(n)}const K4=Object.freeze(Object.defineProperty({__proto__:null,generateKnowledge:q4,generateMemoryConfig:xv,generateWorkflow:gm,refineWorkflowSteps:G4},Symbol.toStringTag,{value:"Module"}));function bv(e){if(e.length===0)return"";const n=["## Workflow","Follow these steps for every request:",""];return e.forEach((a,s)=>{const i=s+1,l=a.label||`Step ${i}`;let c=`${i}. **${l}:** ${a.action}`;if(a.condition==="if"&&a.conditionText?c+=` *(if ${a.conditionText})*`:a.condition==="unless"&&a.conditionText&&(c+=` *(unless ${a.conditionText})*`),a.tool&&(c+=` [tool: ${a.tool}]`),a.loopTarget){const p=e.findIndex(f=>f.id===a.loopTarget);p>=0&&(c+=` → loop to step ${p+1} (max ${a.loopMax}×)`)}n.push(c)}),n.join(`
68
+ `)}z.memo(function(){const n=we(),[a,s]=z.useState(null),[i,l]=z.useState(null),c=se(D=>D.workflowSteps),p=se(D=>D.updateWorkflowSteps),[f,m]=z.useState(!1),g=z.useCallback(async()=>{if(!f){m(!0);try{const A=(await gm()).map((L,P)=>({id:`gen-${Date.now()}-${P}`,label:L.label,action:L.action,tool:"",condition:L.condition?"if":"always",conditionText:"",loopTarget:"",loopMax:L.loop?3:0}));p(A)}catch{}finally{m(!1)}}},[f,p]),b=at(D=>D.servers).filter(D=>D.status==="connected"),v=se(D=>D.channels),k=z.useMemo(()=>v.filter(D=>D.type==="skill"),[v]),w=[{value:"",label:"-- no tool --"},...b.map(D=>({value:`mcp:${D.id}`,label:`${D.name}`})),...k.map(D=>({value:`skill:${D.name}`,label:`${D.name}`}))],C=z.useCallback((D,A)=>{const L=[...c];L[D]={...L[D],...A},p(L)},[c,p]),M=z.useCallback(D=>{p(c.filter((A,L)=>L!==D)),i===D&&l(null)},[c,p,i]),N=z.useCallback(()=>{const D={id:`step-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,label:"",action:"",tool:"",condition:"always",conditionText:"",loopTarget:"",loopMax:3};p([...c,D]),l(c.length)},[c,p]),S=z.useCallback((D,A)=>{if(A<0||A>=c.length)return;const L=[...c],[P]=L.splice(D,1);L.splice(A,0,P),p(L)},[c,p]),E={background:n.inputBg,border:`1px solid ${n.border}`,color:n.textPrimary,fontFamily:"'Geist Mono', monospace",fontSize:13},I={width:8,height:8,border:"none",borderRadius:"50%"};return d.jsxs("div",{className:"rounded-lg overflow-visible",style:{background:n.surfaceOpaque,border:`1px solid ${n.border}`,boxShadow:`0 2px 12px ${n.isDark?"rgba(0,0,0,0.5)":"rgba(0,0,0,0.08)"}`,width:"100%"},children:[d.jsx(Hs,{type:"target",position:Se.Left,id:"workflow-in",style:{...I,background:"#e67e22",top:"50%",left:-4}}),d.jsx(Hs,{type:"source",position:Se.Right,id:"workflow-out",style:{...I,background:"#9b59b6",top:"50%",right:-4}}),d.jsxs("div",{className:"flex flex-col overflow-visible rounded-lg",children:[d.jsxs("div",{className:"flex items-center gap-2 px-5 shrink-0 select-none",style:{height:40,background:n.surfaceElevated,borderBottom:`1px solid ${n.border}`},children:[d.jsx(Ax,{size:13,style:{color:"#e67e22"}}),d.jsx("span",{className:"text-[12px] font-bold tracking-widest uppercase",style:{fontFamily:"'Geist Mono', monospace",color:n.textPrimary},children:"Workflow"}),d.jsxs("span",{className:"text-[13px] ml-1",style:{color:n.textDim,fontFamily:"'Geist Mono', monospace"},children:[c.length," ",c.length===1?"step":"steps"]}),d.jsx("div",{className:"flex-1"}),d.jsxs("button",{type:"button",onClick:g,disabled:f,className:"flex items-center gap-1 text-[13px] px-2 py-0.5 rounded cursor-pointer border-none nodrag",style:{background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace",opacity:f?.6:1},children:[f?d.jsx(yt,{size:9,className:"animate-spin motion-reduce:animate-none"}):d.jsx(La,{size:9}),"Generate"]})]}),d.jsx("div",{className:"flex-1 overflow-y-auto nowheel nodrag",style:{maxHeight:700},children:d.jsxs("div",{className:"flex flex-col items-center py-3 px-5",children:[d.jsx("div",{className:"flex items-center justify-center rounded-full mb-1",style:{width:28,height:28,background:"#e67e2215",border:"2px solid #e67e2240"},children:d.jsx(Z5,{size:12,style:{color:"#e67e22"}})}),c.map((D,A)=>{const L=i===A,P=D.condition!=="always",W=!!D.tool,$=!!D.loopTarget,V=$?c.findIndex(X=>X.id===D.loopTarget):-1;return d.jsxs("div",{className:"flex flex-col items-center w-full",children:[d.jsx("div",{style:{width:2,height:16,background:"#e67e2230"}}),d.jsxs("div",{className:"relative w-full rounded-lg",style:{background:a===A?"#FE500008":n.surfaceElevated,border:`1.5px solid ${L?"#e67e2260":n.borderSubtle}`,maxWidth:310},children:[d.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 cursor-pointer",onClick:()=>l(L?null:A),style:{borderBottom:L?`1px solid ${n.borderSubtle}`:"none"},children:[d.jsx("button",{type:"button",className:"p-0 border-none bg-transparent cursor-grab nodrag",style:{color:n.textDim},draggable:!0,onDragStart:X=>{X.stopPropagation(),s(A)},onDragEnd:()=>s(null),onDragOver:X=>{X.preventDefault(),a!==null&&a!==A&&S(a,A)},onClick:X=>X.stopPropagation(),children:d.jsx(s3,{size:11})}),d.jsx("span",{className:"text-[12px] shrink-0 w-5 h-5 flex items-center justify-center rounded-full font-bold",style:{background:"#e67e2218",color:"#e67e22",fontFamily:"'Geist Mono', monospace",fontSize:13},children:A+1}),d.jsx("span",{className:"flex-1 text-[13px] font-semibold truncate",style:{color:D.label?n.textPrimary:n.textMuted,fontFamily:"'Geist Sans', sans-serif"},children:D.label||`Step ${A+1}`}),P&&d.jsxs("span",{className:"flex items-center gap-0.5 text-[12px] px-1.5 py-0.5 rounded",style:{background:"#3498db15",color:"#3498db"},children:[d.jsx(Us,{size:8}),D.condition]}),W&&d.jsx("span",{className:"flex items-center gap-0.5 text-[12px] px-1.5 py-0.5 rounded",style:{background:"#2ecc7115",color:"#2ecc71"},children:d.jsx(gv,{size:8})}),$&&d.jsx("span",{className:"flex items-center gap-0.5 text-[12px] px-1.5 py-0.5 rounded",style:{background:"#9b59b615",color:"#9b59b6"},children:d.jsx(Dx,{size:8})}),d.jsx("button",{type:"button",onClick:X=>{X.stopPropagation(),M(A)},className:"p-0.5 border-none bg-transparent cursor-pointer nodrag",style:{color:n.textDim},children:d.jsx(jt,{size:10})})]}),!L&&D.action&&d.jsx("div",{className:"px-2.5 pb-1.5",children:d.jsx("span",{className:"text-[12px]",style:{color:n.textMuted},children:D.action})}),L&&d.jsxs("div",{className:"flex flex-col gap-1.5 px-2.5 py-2 nodrag",children:[d.jsx(zs,{value:D.label,onChange:X=>C(A,{label:X.target.value}),placeholder:`Step ${A+1} label`}),d.jsx(Aa,{value:D.action,onChange:X=>C(A,{action:X.target.value}),placeholder:"What the agent does in this step...",style:{minHeight:40}}),d.jsxs("div",{className:"flex gap-1.5",children:[d.jsx("div",{className:"flex-1",children:d.jsx(Rn,{options:w,value:D.tool,onChange:X=>C(A,{tool:X}),size:"sm"})}),d.jsx("div",{style:{width:90},children:d.jsx(Rn,{options:[{value:"always",label:"Always"},{value:"if",label:"If..."},{value:"unless",label:"Unless..."}],value:D.condition,onChange:X=>C(A,{condition:X}),size:"sm"})})]}),D.condition!=="always"&&d.jsx(zs,{value:D.conditionText,onChange:X=>C(A,{conditionText:X.target.value}),placeholder:`${D.condition==="if"?"If":"Unless"} condition...`}),c.length>1&&d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx(Dx,{size:9,style:{color:n.textDim}}),d.jsx("div",{className:"flex-1",children:d.jsx(Rn,{options:[{value:"",label:"No loop"},...c.filter((X,H)=>H!==A).map(X=>({value:X.id,label:`Step ${c.indexOf(X)+1}${X.label?`: ${X.label}`:""}`}))],value:D.loopTarget||"",onChange:X=>C(A,{loopTarget:X}),size:"sm"})}),D.loopTarget&&d.jsxs("span",{className:"flex items-center gap-0.5 text-[13px]",style:{color:n.textDim},children:["max ",d.jsx(zs,{type:"number",min:1,max:10,value:D.loopMax,onChange:X=>C(A,{loopMax:parseInt(X.target.value)||3}),style:{width:32,textAlign:"center",padding:"2px 2px",...E,fontSize:13}}),"x"]})]})]}),$&&V>=0&&V<A&&d.jsx("div",{className:"absolute flex items-center justify-center",style:{right:-28,top:"50%",transform:"translateY(-50%)",width:22,height:22,borderRadius:"50%",background:"#9b59b610",border:"1px dashed #9b59b640"},children:d.jsxs("span",{className:"text-[7px] font-bold",style:{color:"#9b59b6",fontFamily:"'Geist Mono', monospace"},children:[D.loopMax,"x"]})})]})]},D.id)}),c.length>0&&d.jsx("div",{style:{width:2,height:16,background:"#e67e2230"}}),d.jsxs("button",{type:"button",onClick:N,className:"flex items-center justify-center gap-1.5 text-[12px] px-5 py-3 rounded-lg cursor-pointer border-none nodrag",style:{background:"#e67e2210",border:"1.5px dashed #e67e2240",color:"#e67e22",fontFamily:"'Geist Mono', monospace",fontWeight:600},children:[d.jsx(bt,{size:12})," ADD STEP"]}),c.length===0&&d.jsxs("div",{className:"px-4 py-4 text-center text-[12px]",style:{color:n.textFaint},children:[d.jsx(Ax,{size:18,style:{margin:"0 auto 6px",opacity:.3}}),d.jsx("div",{children:"Define step-by-step reasoning plan"}),d.jsx("div",{style:{color:n.textMuted,marginTop:4,fontSize:13},children:"Visual flowchart builder"})]}),c.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("div",{style:{width:2,height:10,background:"#e67e2220"}}),d.jsx("div",{className:"flex items-center justify-center rounded-full",style:{width:20,height:20,background:"#e67e2210",border:"2px solid #e67e2230"},children:d.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:"#e67e2240"}})})]})]})})]})]})});function Ye(e){if(!e)return 0;const n=e.match(/```[\s\S]*?```/g),a=n?n.reduce((i,l)=>i+l.length,0):0,s=e.length-a;return Math.ceil(s/4+a/2.5)}function Rf(e){const n=e.match(/^[^\n]*?[.!?](?:\s|$)/);return n?n[0].trim():e.split(`
69
+ `)[0].slice(0,200)}function $f(e){const n=e.split(/\n\s*\n/)[0];return n?n.trim().slice(0,1e3):""}function Gs(e,n){return`n${e}-${n}`}function yi(e){let n=e.tokens;for(const a of e.children)n+=yi(a);return e.totalTokens=n,n}function mu(e){let n=1;for(const a of e.children)n+=mu(a);return n}function qs(e,n){const a=n.split(`
70
+ `);let s=0;const i={nodeId:Gs(0,s++),title:e,depth:0,text:"",tokens:0,totalTokens:0,children:[]},l=[i];let c=[],p=0;function f(g){const x=c.join(`
71
+ `).trim(),b=l[l.length-1];b.text=x,b.tokens=Ye(x),b.meta?(b.meta.lineEnd=g,b.meta.firstSentence=Rf(x),b.meta.firstParagraph=$f(x)):x&&(b.meta={lineStart:p,lineEnd:g,firstSentence:Rf(x),firstParagraph:$f(x),sourceType:"markdown"}),c=[]}const m=/^(#{1,6})\s+(.+)$/;for(let g=0;g<a.length;g++){const x=a[g],b=m.exec(x);if(b){f(g-1);const v=b[1].length,k=b[2].trim(),w={nodeId:Gs(v,s++),title:k,depth:v,text:"",tokens:0,totalTokens:0,children:[],meta:{lineStart:g,lineEnd:g,firstSentence:"",firstParagraph:"",sourceType:"markdown"}};for(;l.length>1&&l[l.length-1].depth>=v;)l.pop();l[l.length-1].children.push(w),l.push(w),p=g+1}else c.push(x)}return f(a.length-1),yi(i),{source:e,sourceType:"markdown",root:i,totalTokens:i.totalTokens,nodeCount:mu(i),created:Date.now()}}function Y4(e,n,a="structured"){let s=0;const i={nodeId:Gs(0,s++),title:e,depth:0,text:"",tokens:0,totalTokens:0,children:[]},l=new Map;for(const c of n){const p=c.group||"default";l.has(p)||l.set(p,[]),l.get(p).push(c)}for(const[c,p]of l){const f=p.map(g=>`${g.label}: ${g.value}`).join(`
72
+ `),m={nodeId:Gs(1,s++),title:c==="default"?e:c,depth:1,text:f,tokens:Ye(f),totalTokens:0,children:[],meta:{firstSentence:p[0]?`${p[0].label}: ${p[0].value}`:"",firstParagraph:f.slice(0,1e3),sourceType:a,fieldGroup:c}};i.children.push(m)}return yi(i),{source:e,sourceType:a,root:i,totalTokens:i.totalTokens,nodeCount:mu(i),created:Date.now()}}function V4(e,n,a="chronological",s=10){let i=0;const l={nodeId:Gs(0,i++),title:e,depth:0,text:"",tokens:0,totalTokens:0,children:[]};if(n.length===0)return yi(l),{source:e,sourceType:a,root:l,totalTokens:0,nodeCount:1,created:Date.now()};const c=s*60*1e3;let p=[n[0]];const f=[];for(let m=1;m<n.length;m++)n[m].timestamp-n[m-1].timestamp>c&&(f.push(p),p=[]),p.push(n[m]);f.push(p);for(const m of f){const x=`${new Date(m[0].timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`,b=m.map(k=>k.speaker?`${k.speaker}: ${k.text}`:k.text).join(`
73
+ `),v={nodeId:Gs(1,i++),title:x,depth:1,text:b,tokens:Ye(b),totalTokens:0,children:[],meta:{firstSentence:m[0].text.slice(0,200),firstParagraph:b.slice(0,1e3),sourceType:a,timestamp:m[0].timestamp}};l.children.push(v)}return yi(l),{source:e,sourceType:a,root:l,totalTokens:l.totalTokens,nodeCount:mu(l),created:Date.now()}}function Rx(e,n,a="flat"){const s={nodeId:"n0-0",title:e,depth:0,text:n.trim(),tokens:Ye(n),totalTokens:Ye(n),children:[],meta:{firstSentence:Rf(n),firstParagraph:$f(n),sourceType:a}};return{source:e,sourceType:a,root:s,totalTokens:s.totalTokens,nodeCount:1,created:Date.now()}}const W4=300*1e3,wn=qt((e,n)=>({indexes:{},loading:{},errors:{},indexFile:async a=>{const s=n(),i=s.indexes[a];if(i&&!i.stale&&Date.now()-i.fetchedAt<W4)return i.index;if(s.loading[a])return i?.index??null;e(l=>({loading:{...l.loading,[a]:!0},errors:{...l.errors,[a]:""}}));try{const c=await(await fetch(`${Ee}/knowledge/read?path=${encodeURIComponent(a)}`)).json();if(c.status!=="ok"||!c.data)throw new Error(c.error??"Failed to read file");const p=qs(a,c.data.content),f={index:p,fetchedAt:Date.now(),stale:!1};return e(m=>({indexes:{...m.indexes,[a]:f},loading:{...m.loading,[a]:!1}})),p}catch(l){const c=l instanceof Error?l.message:"Index failed";return e(p=>({loading:{...p.loading,[a]:!1},errors:{...p.errors,[a]:c}})),null}},getIndex:a=>n().indexes[a]?.index??null,indexFiles:async a=>{await Promise.allSettled(a.map(s=>n().indexFile(s)))},invalidate:a=>{e(s=>{const i=s.indexes[a];return i?{indexes:{...s.indexes,[a]:{...i,stale:!0}}}:s})},clearAll:()=>e({indexes:{},loading:{},errors:{}})}));function vv(e,n,a){if(n===4&&e.depth>0||n===3&&e.depth>a)return null;let s="",i=!1;n===0?s=e.text:n===1?e.children.length===0&&e.meta?.firstParagraph?(s=e.meta.firstParagraph,i=e.text.length>s.length):s=e.text:n===2?(s=e.meta?.firstSentence??"",i=e.text.length>s.length):s="";const l=[];for(const c of e.children){const p=vv(c,n,a);p&&l.push(p)}return{nodeId:e.nodeId,title:e.title,depth:e.depth,text:s,tokens:Ye(s),children:l,truncated:i}}function kv(e){let n=e.tokens+Ye(e.title);for(const a of e.children)n+=kv(a);return n}function xi(e,n,a){const s=Math.max(0,Math.min(4,n));let l=vv(e.root,s,2);l||(l={nodeId:e.root.nodeId,title:e.root.title,depth:0,text:"",tokens:0,children:[],truncated:!0});let c=kv(l);return{source:e.source,filtered:l,totalTokens:c,depthLevel:s,budgetUsed:c,budgetLimit:1/0}}function bi(e){const n=[];e.depth>0&&n.push(`${"#".repeat(e.depth)} ${e.title}`),e.text&&n.push(e.text),e.truncated&&e.depth>0&&n.push(`_[${e.title}: truncated at this depth level]_`);for(const a of e.children)n.push(bi(a));return n.join(`
74
+
75
+ `)}function X4(e,n,a){const s=[],i=e.filter(v=>v.enabled),l=se.getState(),c=l.instructionState,p=l.workflowSteps,f=l.agentMeta,m=[];if(f.name||a?.name){const v=[];v.push(`Name: ${f.name||a?.name||"Assistant"}`),(f.description||a?.description)&&v.push(`Description: ${f.description||a?.description}`),f.avatar&&v.push(`Avatar: ${f.avatar}`),f.tags&&f.tags.length>0&&v.push(`Tags: ${f.tags.join(", ")}`),m.push(`<identity>
76
+ ${v.join(`
77
+ `)}
78
+ </identity>`)}if(c.persona||c.objectives.primary){const v=[];if(c.persona&&v.push(`Persona: ${c.persona}`),c.tone!=="neutral"&&v.push(`Tone: ${c.tone}`),c.expertise!==3){const k=["Beginner","Novice","Intermediate","Advanced","Expert"];v.push(`Expertise Level: ${k[c.expertise-1]} (${c.expertise}/5)`)}c.objectives.primary&&(v.push(`Primary Objective: ${c.objectives.primary}`),c.objectives.successCriteria.length>0&&v.push(`Success Criteria:
79
+ ${c.objectives.successCriteria.map(k=>`- ${k}`).join(`
80
+ `)}`),c.objectives.failureModes.length>0&&v.push(`Failure Modes to Avoid:
81
+ ${c.objectives.failureModes.map(k=>`- ${k}`).join(`
82
+ `)}`)),m.push(`<instructions>
83
+ ${v.join(`
84
+
85
+ `)}
86
+ </instructions>`)}const g=[];if(c.constraints.neverMakeUp&&g.push("Never fabricate information or make up facts"),c.constraints.askBeforeActions&&g.push("Ask for permission before taking significant actions"),c.constraints.stayInScope&&g.push(`Stay within the defined scope: ${c.constraints.scopeDefinition||"as specified"}`),c.constraints.useOnlyTools&&g.push("Only use tools and capabilities that are explicitly provided"),c.constraints.limitWords&&g.push(`Keep responses under ${c.constraints.wordLimit} words`),c.constraints.customConstraints&&g.push(`Additional constraints: ${c.constraints.customConstraints}`),g.length>0&&m.push(`<constraints>
87
+ ${g.map(v=>`- ${v}`).join(`
88
+ `)}
89
+ </constraints>`),p.length>0){const v=bv(p);m.push(`<workflow>
90
+ ${v}
91
+ </workflow>`)}if(i.length>0){const v={},k=["ground-truth","signal","evidence","framework","hypothesis","guideline"];for(const M of i)v[M.knowledgeType]||(v[M.knowledgeType]=[]),v[M.knowledgeType].push(M);const w=wn.getState(),C=[];for(const M of k){const N=v[M];if(!N||N.length===0)continue;const S=Zo[M],E=[];for(const I of N){const D=Rs[I.depth],A=w.getIndex(I.path);if(A){const L=xi(A,0),P=bi(L.filtered);P.trim()?E.push(`<source name="${I.name}" type="${S.label}" depth="${D.label}" tokens="${L.totalTokens}">
92
+ ${P}
93
+ </source>`):E.push(`- ${I.name} (${D.label}, title only) [${I.path}]`)}else E.push(`- ${I.name} (${D.label}, ~${Math.round(I.baseTokens*D.pct).toLocaleString()} tokens) [${I.path}]`)}C.push(`[${S.label.toUpperCase()}] ${S.instruction}
94
+ ${E.join(`
95
+ `)}`)}m.push(`<knowledge>
96
+ ${C.join(`
97
+
98
+ `)}
99
+ </knowledge>`)}const x=at.getState().getConnectedTools(),b=l.skills.filter(v=>v.enabled);if(x.length>0||b.length>0){const v=[];x.length>0&&(v.push("MCP Tools:"),v.push(...x.map(k=>`- ${k.name}: ${k.description||"No description"}`))),b.length>0&&(v.length>0&&v.push(""),v.push("Skills:"),v.push(...b.map(k=>`- ${k.name}: ${k.description||"No description"}`))),m.push(`<tools>
100
+ ${v.join(`
101
+ `)}
102
+ </tools>`)}return m.length>0&&s.push({role:"system",content:m.join(`
103
+
104
+ `)}),s.push({role:"user",content:n||"(no prompt provided)"}),s}const $x=/(?:^|[\s`"'([<{])([A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+\.[A-Za-z0-9._-]+)(?=$|[\s`"')\]}>:,;.!?])/g;function ym(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/")}function Z4(e){const n=ym(e),a=n.lastIndexOf("/");return a>0?n.slice(0,a):n}function Of(e,n){$x.lastIndex=0;let a;for(;(a=$x.exec(e))!==null;){const s=a[1].replace(/^\.?\//,"");s.includes("/")&&n.add(s)}}function wv(e,n){Of(e.title,n),e.text&&Of(e.text,n);for(const a of e.children)wv(a,n)}function Q4(e){const n=new Map;for(const a of e){const s=ym(a).replace(/^\.?\//,"");if(!s.includes("/"))continue;const i=s.split("/").filter(Boolean);if(i.length<2)continue;const l=i.length>=3?`${i[0]}/${i[1]}/`:`${i[0]}/`,c=i.length>=3?`${i[2]}${i.length>3?"/":""}`:i[1];n.has(l)||n.set(l,new Set),n.get(l).add(c)}return[...n.entries()].sort(([a],[s])=>a.localeCompare(s)).slice(0,14).map(([a,s])=>{const i=[...s].sort(),l=i.slice(0,8),c=i.length>l.length?", ...":"";return` ${a} -> ${l.join(", ")}${c}`})}function J4(e){const n=e.filter(s=>s.enabled&&s.repoMeta);if(n.length===0)return"";const a=[];for(const s of n){const i=s.repoMeta,l=i.features;if(l.length===0)continue;const c=l[0],f=`src/${c.toLowerCase().replace(/\s+/g,"-")}/index.ts`,m=[`### Example: answering a question about ${i.name}`,`Q: "How does ${c} work?"`,`1. Check Data Flow in "${c}" section → see what files import/depend on each other`,"2. Check Key Files → exports and types tell you the API surface without opening files",`3. Need actual implementation? → \`get_file_contents("${f}")\``];i.baseUrl&&m.push(`4. Need to share a link? → \`${i.baseUrl}{exact_file_path}\``),a.push(m.join(`
105
+ `))}return a.length===0?"":a.join(`
106
+
107
+ `)}function Sv(e,n){const a=e.filter(g=>g.enabled),s=[],i=a.filter(g=>g.repoMeta);for(const g of i){const x=g.repoMeta,b=g.path?Z4(g.path):"",v=b?a.filter(C=>C.path&&ym(C.path).startsWith(`${b}/`)):[g],k=new Set;for(const C of v){if(C.content&&Of(C.content,k),!C.path)continue;const M=n(C.path);M&&wv(M.root,k)}const w=Q4([...k]);s.push(`## ${x.name}`),x.stack.length>0&&s.push(`- Stack: ${x.stack.join(", ")}`),x.baseUrl&&s.push(`- Base URL: ${x.baseUrl}`),s.push(`- ${x.totalFiles} files, key features: ${x.features.join(", ")}`),x.baseUrl&&w.length>0&&(s.push(`- File lookup table (${k.size} paths): use \`${x.baseUrl}{filePath}\``),s.push(...w)),s.push("- You can explore this codebase in depth — read files, trace dependencies, check implementations."),s.push("")}const l=a.filter(g=>!g.repoMeta&&g.content);for(const g of l){const x=Zo[g.knowledgeType],b=x?x.label:g.knowledgeType;s.push(`## Document: ${g.name}`),s.push(`- Type: ${b}`),s.push("")}if(s.length===0)return"";const c=`You have access to the following codebases and knowledge sources:
108
+ `,p=J4(e),f=p?`
109
+ ## How to Use This Knowledge
110
+ ${p}
111
+ `:"";return`<orientation>
112
+ ${c}
113
+ ${s.join(`
114
+ `)}
115
+ ${f}Approach:
116
+ - Your knowledge about these codebases is already loaded in your context below. Use it directly.
117
+ - For file contents not in your context, use get_file_contents or read_file tools — NOT the knowledge graph.
118
+ - Do NOT call search_nodes or read_graph to find basic structure — that information is already here.
119
+ - Use each repo's base URL + file path from the lookup table to build exact file links.
120
+ - Explore files and trace dependencies BEFORE asking the user for information.
121
+ </orientation>`}function Cv(e){const{frame:n,orientationBlock:a,hasRepos:s,knowledgeFormatGuide:i,frameworkBlock:l,memoryBlock:c,knowledgeBlock:p}=e,f=[n];if(a&&f.push(a),s&&f.push(i),l&&f.push(l),c&&f.push(c),p){const m=eA(p);f.push(m)}return f.filter(Boolean).join(`
122
+
123
+ `)}function eA(e){if(!e.includes("<knowledge>"))return e;const n=e.match(/<knowledge[^>]*>(.*?)<\/knowledge>/s);if(!n)return e;const a=n[1],s=/<source[^>]*type="([^"]*)"[^>]*>(.*?)<\/source>/gs,i=[],l=[],c={"ground-truth":0,"Ground Truth":0,guideline:1,Guideline:1,framework:2,Framework:2,hypothesis:3,Hypothesis:3,signal:4,Signal:4,evidence:5,Evidence:5};let p=0,f;for(;(f=s.exec(a))!==null;){if(f.index>p){const k=a.slice(p,f.index).trim();k&&l.push(k)}const b=f[1],v=c[b]??3;i.push({type:b,fullMatch:f[0],order:v}),p=f.index+f[0].length}if(p<a.length){const b=a.slice(p).trim();b&&l.push(b)}i.sort((b,v)=>b.order-v.order);const m=[];l.length>0&&m.push(...l),i.length>0&&m.push(...i.map(b=>b.fullMatch));const g=e.match(/<knowledge[^>]*>/);return`${g?g[0]:"<knowledge>"}
124
+ ${m.join(`
125
+
126
+ `)}
127
+ </knowledge>`}const tA={agentMeta:{name:"React Code Reviewer",description:"Senior React engineer specializing in code quality, TypeScript best practices, and accessibility compliance",icon:"search",category:"coding",tags:["react","code-review","typescript","accessibility"],avatar:"bug"},instructionState:{persona:"You are a senior React engineer with 8+ years of experience in building production-ready applications. You have deep expertise in TypeScript, modern React patterns, performance optimization, and web accessibility standards.",tone:"formal",expertise:5,constraints:{neverMakeUp:!0,askBeforeActions:!1,stayInScope:!0,useOnlyTools:!1,limitWords:!1,wordLimit:500,customConstraints:"Always provide specific line numbers and actionable suggestions",scopeDefinition:"Code review for React/TypeScript applications with focus on quality, performance, and accessibility"},objectives:{primary:"Provide thorough, actionable code reviews that improve code quality and maintainability",successCriteria:["Identify potential bugs and performance issues","Suggest accessibility improvements","Maintain consistency with React/TypeScript best practices","Provide specific, actionable feedback with examples"],failureModes:["Generic or vague feedback without specific suggestions","Missing critical accessibility issues","Approving code with TypeScript type safety violations","Ignoring performance implications"]},rawPrompt:"",autoSync:!0},workflowSteps:[{id:"step-analyze-diff",label:"Analyze Code Changes",action:"Read and understand the code diff, identifying the scope and purpose of changes",tool:"",condition:"always",conditionValue:""},{id:"step-style-check",label:"Check Code Style",action:"Verify code follows React/TypeScript best practices and coding standards",tool:"skill:clean-code",condition:"always",conditionValue:""},{id:"step-accessibility",label:"Review Accessibility",action:"Check for accessibility violations and suggest improvements for screen readers and keyboard navigation",tool:"",condition:"always",conditionValue:""},{id:"step-categorize-issues",label:"Categorize Issues",action:"Classify identified issues by severity: critical (blocking), major (important), minor (nice-to-have)",tool:"",condition:"always",conditionValue:""},{id:"step-write-review",label:"Write Comprehensive Review",action:"Compose detailed review with specific line references, code examples, and actionable suggestions",tool:"",condition:"always",conditionValue:""}],channels:[{sourceId:"react-style-guide",name:"React Style Guide",path:"docs/react-style-guide.md",category:"knowledge",knowledgeType:"framework",enabled:!0,depth:2,baseTokens:1500},{sourceId:"accessibility-checklist",name:"Accessibility Checklist",path:"docs/accessibility-checklist.md",category:"knowledge",knowledgeType:"evidence",enabled:!0,depth:3,baseTokens:800}],skills:[{id:"clean-code",name:"Clean Code",icon:"✨",enabled:!0,added:!0,description:"Pragmatic coding standards - concise, direct, no over-engineering",category:"development"}],mcpServers:[{id:"github",name:"GitHub",icon:"🐙",connected:!0,enabled:!0,added:!0,capabilities:["input","output"],category:"development",description:"Access GitHub repositories, PRs, and issues"}]},nA={agentMeta:{name:"Senior PM",description:"Senior Product Manager specializing in discovery synthesis, product strategy, and opportunity analysis. Turns messy brainstorms into clear product strategy.",icon:"user",category:"strategy",tags:["discovery","strategy","synthesis","prioritization"],avatar:"target"},instructionState:{persona:"You are a Senior Product Manager with 10+ years building B2B SaaS products. You excel at discovery work, synthesizing messy conversations into clear product strategy, and translating customer/team insights into prioritized roadmap decisions.",tone:"formal",expertise:5,constraints:{neverMakeUp:!0,askBeforeActions:!1,stayInScope:!0,useOnlyTools:!1,limitWords:!1,wordLimit:500,customConstraints:"Strategic but practical — connect dots between insights and execution. Framework-driven — use opportunity solution trees, RICE, impact mapping. Hypothesis-oriented — frame everything as assumptions to validate. Trade-off aware — always consider what we are NOT doing. Customer-outcome focused — start with customer value, not features.",scopeDefinition:"Discovery synthesis, product strategy, opportunity analysis, roadmap prioritization"},objectives:{primary:"Synthesize product team discussions into clear, prioritized product opportunities with actionable next steps",successCriteria:["TL;DR with top 3 takeaways","Key opportunities grouped by theme","Customer pain points identified","Prioritization using RICE or similar framework","Discovery plan with validation steps"],failureModes:["Listing features without strategic context","Missing underlying customer needs behind surface requests","No prioritization or all items marked equal priority","Skipping hypothesis formation and validation planning"]},rawPrompt:"",autoSync:!0},workflowSteps:[{id:"step-tldr",label:"TL;DR",action:"Extract top 3 takeaways in one sentence each",tool:"",condition:"always"},{id:"step-opportunities",label:"Key Opportunities",action:"Identify product ideas/improvements discussed, grouped by theme",tool:"",condition:"always"},{id:"step-pain-points",label:"Customer Pain Points",action:"Extract problems being solved and underlying needs",tool:"",condition:"always"},{id:"step-strategic",label:"Strategic Implications",action:"Analyze how findings affect roadmap and positioning",tool:"",condition:"always"},{id:"step-hypotheses",label:"Assumptions & Hypotheses",action:"Frame beliefs that need validation with evidence and signals",tool:"",condition:"always"},{id:"step-prioritize",label:"Prioritization",action:"Recommend what to tackle first using RICE (Reach, Impact, Confidence, Effort)",tool:"",condition:"always"},{id:"step-discovery-plan",label:"Discovery Plan",action:"Define how to validate key hypotheses — research needed, experiments",tool:"",condition:"always"},{id:"step-risks",label:"Dependencies & Risks",action:"Flag technical, organizational, and market blockers",tool:"",condition:"always"},{id:"step-next-steps",label:"Next Steps",action:"List concrete actions with owners and timelines",tool:"",condition:"always"}],channels:[{sourceId:"knowledge-products",name:"Products",path:"00 - Knowledge/Products/",category:"knowledge",knowledgeType:"ground-truth",enabled:!0,depth:0,baseTokens:16e3},{sourceId:"knowledge-products-feedback",name:"Feedback",path:"00 - Knowledge/Products/Feedback/",category:"knowledge",knowledgeType:"signal",enabled:!0,depth:0,baseTokens:4800},{sourceId:"signals-odfjell",name:"User feedback / Odfjell",path:"07 - Signals/User feedback/odfjell/",category:"intel",knowledgeType:"signal",enabled:!0,depth:1,baseTokens:6800},{sourceId:"signals-kcc",name:"User feedback / KCC",path:"07 - Signals/User feedback/kcc/",category:"intel",knowledgeType:"signal",enabled:!0,depth:1,baseTokens:5200},{sourceId:"signals-general",name:"User feedback / General",path:"07 - Signals/User feedback/general/",category:"intel",knowledgeType:"signal",enabled:!0,depth:1,baseTokens:7500},{sourceId:"discovery-eu-ets",name:"EU ETS Cost Layer",path:"01 - Discovery/EU ETS Cost Layer/",category:"discovery",knowledgeType:"hypothesis",enabled:!0,depth:2,baseTokens:3200},{sourceId:"discovery-weather-routing",name:"Weather Routing v2",path:"01 - Discovery/Weather Routing v2/",category:"discovery",knowledgeType:"hypothesis",enabled:!0,depth:2,baseTokens:4100},{sourceId:"discovery-fleet-dashboard",name:"Fleet Dashboard",path:"01 - Discovery/Fleet Dashboard/",category:"discovery",knowledgeType:"hypothesis",enabled:!0,depth:2,baseTokens:3500},{sourceId:"roadmap",name:"03 - Roadmap",path:"03 - Roadmap/",category:"knowledge",knowledgeType:"framework",enabled:!0,depth:1,baseTokens:12e3}],skills:[{id:"feedback-analyzer",name:"Feedback Analyzer",icon:"📊",enabled:!0,added:!0,description:"Extract insights from customer feedback",category:"analysis"},{id:"roadmap-builder",name:"Roadmap Builder",icon:"🗺️",enabled:!0,added:!0,description:"Create strategic product roadmaps with OKRs",category:"content"}],mcpServers:[{id:"notion",name:"Notion",icon:"📓",connected:!0,enabled:!0,added:!0,capabilities:["input","output"],category:"productivity",description:"Read and write Notion pages and databases"},{id:"slack",name:"Slack",icon:"💬",connected:!0,enabled:!0,added:!0,capabilities:["input","output"],category:"communication",description:"Read and post Slack messages"}]},oA={agentMeta:{name:"Feedback Manager",description:"Feedback lifecycle specialist — organizes, challenges, and maintains the single source of truth for user feedback. Monitors Gmail, connects feedback to product features, proposes improvements.",icon:"inbox",category:"feedback",tags:["feedback","triage","patterns","improvement"],avatar:"chart"},instructionState:{persona:"You are a specialized Product Manager focused on feedback management and intelligence. You maintain the single source of truth for all user feedback, ensuring it's organized, challenged, contextualized with current product features, and continuously refined.",tone:"neutral",expertise:4,constraints:{neverMakeUp:!0,askBeforeActions:!0,stayInScope:!0,useOnlyTools:!1,limitWords:!1,wordLimit:500,customConstraints:`Curious and probing — always ask "why?" and "what's the underlying need?". Pattern-oriented — look for recurring themes. Feature-aware — reference specific product capabilities. Actionable — turn feedback into concrete improvement proposals. Organized — maintain clean, accessible feedback repository.`,scopeDefinition:"Feedback triage, pattern recognition, improvement proposals, repository maintenance"},objectives:{primary:"Process and organize user feedback into actionable insights, maintaining a clean feedback repository with pattern detection and improvement proposals",successCriteria:["New feedback triaged within workflow","Patterns detected across feedback sources","Improvement proposals with rationale and priority","Feedback connected to current product capabilities","Repository organized and deduplicated"],failureModes:["Taking feedback at face value without probing deeper","Missing recurring patterns across sources","No connection between feedback and existing product features","Feedback stored without actionable improvement proposals"]},rawPrompt:"",autoSync:!0},workflowSteps:[{id:"step-initial-analysis",label:"Initial Analysis",action:"Quick pattern detection, sentiment analysis, theme identification, extract key quotes using feedback-analyzer skill",tool:"skill:feedback-analyzer",condition:"always"},{id:"step-triage",label:"Triage",action:"Ask clarifying questions: which product/feature, user role, frequency/severity, blocking vs inconvenient",tool:"",condition:"always"},{id:"step-deep-dive",label:"Deep Dive",action:"Uncover real pain point, identify job-to-be-done, find behavioral patterns, challenge assumptions",tool:"",condition:"always"},{id:"step-strategic-synthesis",label:"Strategic Synthesis",action:"Alignment with product strategy, opportunity sizing, prioritization recommendation",tool:"",condition:"always"},{id:"step-contextualize",label:"Contextualize with Product",action:"Check if capability exists, identify gap/enhancement/misunderstanding, find related features",tool:"",condition:"always"},{id:"step-categorize",label:"Categorize & Store",action:"Tag by product, type (Bug/Enhancement/Feature), user type, severity, frequency, status",tool:"",condition:"always"},{id:"step-patterns",label:"Pattern Recognition",action:"Check against existing patterns, update PATTERNS.md if new theme, flag recurring issues",tool:"",condition:"always"}],channels:[{sourceId:"knowledge-products-feedback",name:"Feedback",path:"00 - Knowledge/Products/Feedback/",category:"knowledge",knowledgeType:"signal",enabled:!0,depth:0,baseTokens:4800},{sourceId:"signals-odfjell",name:"User feedback / Odfjell",path:"07 - Signals/User feedback/odfjell/",category:"intel",knowledgeType:"signal",enabled:!0,depth:0,baseTokens:6800},{sourceId:"signals-kcc",name:"User feedback / KCC",path:"07 - Signals/User feedback/kcc/",category:"intel",knowledgeType:"signal",enabled:!0,depth:0,baseTokens:5200},{sourceId:"signals-baru",name:"User feedback / Baru",path:"07 - Signals/User feedback/baru/",category:"intel",knowledgeType:"signal",enabled:!0,depth:0,baseTokens:4500},{sourceId:"signals-general",name:"User feedback / General",path:"07 - Signals/User feedback/general/",category:"intel",knowledgeType:"signal",enabled:!0,depth:0,baseTokens:7500},{sourceId:"intel-feedback",name:"04 - Feedback Synthesis",path:"05 - Intel/04 - Feedback Synthesis/",category:"intel",knowledgeType:"evidence",enabled:!0,depth:1,baseTokens:4800}],skills:[{id:"feedback-analyzer",name:"Feedback Analyzer",icon:"📊",enabled:!0,added:!0,description:"Extract insights from customer feedback — patterns, sentiment, priorities",category:"analysis"}],mcpServers:[{id:"gmail",name:"Gmail",icon:"📧",connected:!0,enabled:!0,added:!0,capabilities:["input"],category:"communication",description:"Read Gmail OnWatch label for captain feedback"},{id:"notion",name:"Notion",icon:"📓",connected:!0,enabled:!0,added:!0,capabilities:["input","output"],category:"productivity",description:"CSM Team Hub and feedback databases"},{id:"slack",name:"Slack",icon:"💬",connected:!0,enabled:!0,added:!0,capabilities:["output"],category:"communication",description:"Send critical feedback alerts"}]},aA={agentMeta:{name:"Competitor Feature Scraper",description:"Systematically scrapes competitor product pages to extract features, claims, screenshots, and target users. Produces structured feature profiles for competitive comparison.",icon:"search",category:"intel",tags:["competitors","scraping","features","intel"],avatar:"microscope"},instructionState:{persona:"You are a specialized competitive intelligence agent that systematically scrapes competitor websites to extract product features, claims, metrics, and screenshots. You produce structured feature profiles that feed into the competitive comparison matrix.",tone:"neutral",expertise:4,constraints:{neverMakeUp:!0,askBeforeActions:!1,stayInScope:!0,useOnlyTools:!0,limitWords:!1,wordLimit:500,customConstraints:'Only extract factual claims from competitor pages — never infer or embellish. Mark unverified claims as "Claimed". Save raw scrape data for re-processing. Respect rate limits (max 10 parallel scrapes).',scopeDefinition:"Competitor product page scraping, feature extraction, structured profile generation"},objectives:{primary:"Scrape competitor websites and produce structured FEATURES.md profiles with feature names, descriptions, claims, screenshots, and taxonomy mapping",successCriteria:["All discoverable product pages scraped","Each feature has name, description, and source URL","Screenshots downloaded for key features","Features mapped to taxonomy categories","Raw scrape data saved for re-processing"],failureModes:["Missing product pages due to incomplete site discovery","Inferring features not actually claimed by competitor","No screenshots captured for visual comparison","Features not mapped to standard taxonomy"]},rawPrompt:"",autoSync:!0},workflowSteps:[{id:"step-setup",label:"Setup",action:"Verify Firecrawl is available, create output directories for competitor",tool:"bash",condition:"always"},{id:"step-discover",label:"Discover Pages",action:"Use Firecrawl map to find all product/feature pages, filter for relevant URLs",tool:"skill:firecrawl",condition:"always"},{id:"step-scrape",label:"Scrape Pages",action:"Scrape each feature page for content + screenshot (up to 10 concurrent)",tool:"skill:firecrawl",condition:"always"},{id:"step-extract",label:"Extract Features",action:"Extract feature name, description, key claims, metrics, target user, screenshot URL",tool:"",condition:"always"},{id:"step-taxonomy",label:"Map to Taxonomy",action:"Read _FEATURE_TAXONOMY.md and map each feature to taxonomy categories",tool:"",condition:"always"},{id:"step-write",label:"Write Profile",action:"Generate structured FEATURES.md with summary table and detailed feature sections",tool:"",condition:"always"}],channels:[{sourceId:"knowledge-competitors",name:"Competitors",path:"00 - Knowledge/Competitors/",category:"knowledge",knowledgeType:"evidence",enabled:!0,depth:0,baseTokens:22e3},{sourceId:"intel-competitive",name:"01 - Competitive Intel",path:"05 - Intel/01 - Competitive Intel/",category:"intel",knowledgeType:"evidence",enabled:!0,depth:0,baseTokens:12e3},{sourceId:"cmo-competitive-intel",name:"05 - Competitive Intel",path:"CMO-Handoff/05 - Competitive Intel/",category:"intel",knowledgeType:"evidence",enabled:!0,depth:1,baseTokens:5800}],skills:[{id:"web-search",name:"Web Search",icon:"🔎",enabled:!0,added:!0,description:"Search the web for competitor information",category:"analysis"}],mcpServers:[{id:"firecrawl",name:"Firecrawl",icon:"🔥",connected:!0,enabled:!0,added:!0,capabilities:["input"],category:"data",description:"Web scraping, crawling, and site mapping"}]},sA={"senior-pm":nA,"feedback-manager":oA,"competitor-scraper":aA};let Vo;function tf(e){return e==="coding"?"development":e==="research"?"analysis":e==="design"||e==="writing"?"content":e==="domain"?"domain":"content"}function Ox(e){return e==="coding"?"development":e==="research"?"data":e==="writing"?"productivity":"data"}function Fx(e,n){return e.map(a=>a.id===n?{...a,enabled:!a.enabled}:a)}function Ix(e,n){return e.map(a=>a.id===n?{...a,added:!0,enabled:!0}:a)}function Lx(e,n){return e.map(a=>a.id===n?{...a,added:!1,enabled:!1}:a)}function Mv(e){if(!e.enabled)return 0;const n=Rs[e.depth]??Rs[0];return Math.round(e.baseTokens*n.pct)}const se=qt()(wS((e,n)=>({channels:[],prompt:"",selectedModel:"claude-opus-4",selectedPreset:"",outputFormat:"markdown",outputFormats:["markdown"],tokenBudget:2e5,navigationMode:"tree-aware",running:!1,showFilePicker:!1,showMcpPicker:!1,showSkillPicker:!1,showSaveModal:!1,showConnectorPicker:!1,showConnectionPicker:!1,showMarketplace:!1,activeMarketplaceTab:"skills",showSettings:!1,activeSettingsTab:"providers",response:"",exportTarget:"claude",registrySkills:vc.map(a=>({...a})),registryMcpServers:NS.map(a=>({...a})),agentConfig:{...v0},agentMeta:{name:"",description:"",icon:"brain",category:"general",tags:[],avatar:"bot"},mcpServers:[],skills:vc.filter(a=>a.installed).map(a=>({id:a.id,name:a.name,icon:a.icon,enabled:!1,added:!1,description:a.description,category:tf(a.category)})),agents:[],connectors:[],pendingKnowledge:[],suggestedSkills:[],instructionState:{persona:"",tone:"neutral",expertise:3,constraints:{neverMakeUp:!1,askBeforeActions:!1,stayInScope:!1,useOnlyTools:!1,limitWords:!1,wordLimit:500,customConstraints:"",scopeDefinition:""},objectives:{primary:"",successCriteria:[],failureModes:[]},rawPrompt:"",autoSync:!0},workflowSteps:[],outputTemplateConfig:{},agentPattern:"prompt-chain",verification:{enabled:!1,strategy:"none",rules:[],crossRefSources:[],confidenceRequired:!1,autoRetryOnFail:!1,maxRetries:2},errorHandling:{onStepFailure:"abort",retryCount:1,fallbackAction:"",checkpointEnabled:!1,timeoutSeconds:0,gracefulDegradation:!1},evaluation:{enabled:!1,criteria:[],expectedOutputFormat:"",qualityRubric:""},totalTokens:()=>{const{channels:a,prompt:s}=n(),i=a.reduce((c,p)=>c+Mv(p),0),l=Math.ceil(s.length/4);return i+l},loadPreset:a=>{const s=jS.find(c=>c.id===a);if(!s)return;const i=s.channels.map(c=>({...c,enabled:!0})),l={...v0,...s.agentConfig};e({channels:i,selectedPreset:a,response:"",agentConfig:l})},setOutputFormat:a=>e({outputFormat:a,outputFormats:[a]}),toggleOutputFormat:a=>{const s=n().outputFormats,i=s.includes(a)?s.filter(l=>l!==a):[...s,a];i.length!==0&&e({outputFormats:i,outputFormat:i[0]})},cycleKnowledgeType:a=>{const s=["ground-truth","signal","evidence","framework","hypothesis","guideline"];e({channels:n().channels.map(i=>{if(i.sourceId!==a)return i;const l=s.indexOf(i.knowledgeType);return{...i,knowledgeType:s[(l+1)%s.length]}})})},addChannel:a=>{const{channels:s}=n();if(s.some(l=>l.sourceId===a.sourceId))return;const i={...a};if(a.path){const l=yf(a.path,a.content);(!a.knowledgeType||a.knowledgeType==="evidence")&&(i.knowledgeType=l.knowledgeType),(a.depth===void 0||a.depth===null)&&(i.depth=l.depth)}e({channels:[...s,{...i,enabled:!0}],selectedPreset:""})},removeChannel:a=>{e({channels:n().channels.filter(s=>s.sourceId!==a),selectedPreset:""})},toggleChannel:a=>{e({channels:n().channels.map(s=>s.sourceId===a?{...s,enabled:!s.enabled}:s)})},setChannelDepth:(a,s)=>{e({channels:n().channels.map(i=>i.sourceId===a?{...i,depth:Math.max(0,Math.min(4,s))}:i)})},setPrompt:a=>{const s=ES(a);e({prompt:a,outputFormat:s})},setModel:a=>e(s=>({selectedModel:a,agentConfig:{...s.agentConfig,model:a}})),setTokenBudget:a=>e({tokenBudget:a}),setNavigationMode:a=>e({navigationMode:a}),setShowFilePicker:a=>e({showFilePicker:a}),setShowMcpPicker:a=>e({showMcpPicker:a}),setShowSkillPicker:a=>e({showSkillPicker:a}),setShowSaveModal:a=>e({showSaveModal:a}),setShowConnectorPicker:a=>e({showConnectorPicker:a}),setShowConnectionPicker:a=>e({showConnectionPicker:a}),setShowMarketplace:(a,s)=>e({showMarketplace:a,...s?{activeMarketplaceTab:s}:{}}),setShowSettings:(a,s)=>e({showSettings:a,...s?{activeSettingsTab:s}:{}}),setAgentMeta:a=>e({agentMeta:{...n().agentMeta,...a}}),setChannelKnowledgeType:(a,s)=>{const i=["ground-truth","signal","evidence","framework","hypothesis","guideline"],l=i[Math.max(0,Math.min(i.length-1,s))];e({channels:n().channels.map(c=>c.sourceId===a?{...c,knowledgeType:l}:c)})},reorderChannels:(a,s)=>{const i=[...n().channels],[l]=i.splice(a,1);i.splice(s,0,l),e({channels:i,selectedPreset:""})},run:()=>{const{running:a,prompt:s,channels:i}=n();if(a){n().cancelRun();return}const c=Qe.getState().getActiveProvider(),p=c?.authMethod==="claude-agent-sdk";if(!p&&!c?.apiKey){e({response:"Error: No API key configured. Open Settings → Providers to add your API key."});return}e({running:!0,response:""});const f=X4(i,s),m=n().agentConfig.model;let g="";if(p){const b=f.filter(w=>w.role==="system").map(w=>w.content),v=f.filter(w=>w.role==="user").map(w=>w.content).join(`
128
+ `);Vo=ub({prompt:v||s,model:m,systemPrompt:b.join(`
129
+ `)||void 0,onChunk:w=>{g+=w,e({response:g})},onDone:()=>{e({running:!1}),Vo=void 0},onError:w=>{e({running:!1,response:`Error: ${w.message}`}),Vo=void 0}});return}Vo=db({providerId:c?.id||"",model:m,messages:f,onChunk:b=>{g+=b,e({response:g})},onDone:()=>{e({running:!1}),Vo=void 0},onError:b=>{e({running:!1,response:`Error: ${b.message}`}),Vo=void 0}})},cancelRun:()=>{const a=Vo;a&&a.abort(),e({running:!1}),Vo=void 0},clearChannels:()=>e({channels:[],selectedPreset:"",response:""}),setAgentModel:a=>e({agentConfig:{...n().agentConfig,model:a}}),setAgentTemperature:a=>e({agentConfig:{...n().agentConfig,temperature:a}}),setAgentSystemPrompt:a=>e({agentConfig:{...n().agentConfig,systemPrompt:a}}),setAgentPlanningMode:a=>e({agentConfig:{...n().agentConfig,planningMode:a}}),setAgentMaxTokens:a=>e({agentConfig:{...n().agentConfig,maxTokens:a}}),toggleMcp:a=>{e({mcpServers:Fx(n().mcpServers,a)})},addMcp:a=>{e({mcpServers:Ix(n().mcpServers,a)})},removeMcp:a=>{e({mcpServers:Lx(n().mcpServers,a)})},upsertMcpServer:a=>{if(n().mcpServers.find(i=>i.id===a.id)){e({mcpServers:n().mcpServers.map(i=>i.id===a.id?{...i,name:a.name,description:a.description??i.description,connected:a.connected??i.connected}:i)});return}e({mcpServers:[...n().mcpServers,{id:a.id,name:a.name,icon:"plug",connected:a.connected??!1,enabled:!1,added:!1,capabilities:["input","output"],category:"data",description:a.description??"Custom MCP server"}]})},removeMcpServer:a=>{e({mcpServers:n().mcpServers.filter(s=>s.id!==a)})},toggleSkill:a=>{e({skills:Fx(n().skills,a)})},addSkill:a=>{e({skills:Ix(n().skills,a)})},removeSkill:a=>{e({skills:Lx(n().skills,a)})},upsertSkill:a=>{if(n().skills.find(i=>i.id===a.id)){e({skills:n().skills.map(i=>i.id===a.id?{...i,name:a.name||i.name,description:a.description&&a.description.length>0?a.description:i.description,skillUrl:a.skillUrl??i.skillUrl,installedFrom:a.installedFrom??i.installedFrom,installs:a.installs??i.installs}:i)});return}e({skills:[...n().skills,{id:a.id,name:a.name,icon:"zap",enabled:!1,added:!1,description:a.description??"Installed from skills.sh",category:"development",skillUrl:a.skillUrl,installedFrom:a.installedFrom,installs:a.installs}]})},loadAgent:a=>{(async()=>{try{const s=await fetch(`${Ee}/agents/${encodeURIComponent(a)}`);if(!s.ok)return;const i=await s.json(),l=i.data??i;n().restoreFullState(l)}catch{}})()},restoreFullState:a=>{const s={};a.agentMeta&&(s.agentMeta=a.agentMeta),a.instructionState&&(s.instructionState=a.instructionState),a.workflowSteps&&(s.workflowSteps=a.workflowSteps),a.mcpServers&&(s.mcpServers=a.mcpServers),a.skills&&(s.skills=a.skills),a.connectors&&(s.connectors=a.connectors),a.agentConfig&&(s.agentConfig=a.agentConfig),a.exportTarget&&(s.exportTarget=a.exportTarget),a.outputFormat&&(s.outputFormat=a.outputFormat),a.outputFormats&&(s.outputFormats=a.outputFormats),a.tokenBudget&&(s.tokenBudget=a.tokenBudget),a.prompt&&(s.prompt=a.prompt),a.channels&&(s.channels=a.channels),s.selectedPreset="",s.response="",e(s),a.mcpServers&&(async()=>{try{const{useMcpStore:i}=await ea(async()=>{const{useMcpStore:l}=await Promise.resolve().then(()=>zS);return{useMcpStore:l}},void 0);await i.getState().syncFromConfig()}catch{}})()},setInstructionState:a=>{e({instructionState:a})},setWorkflowSteps:a=>{e({workflowSteps:a})},toggleConnector:a=>{e({connectors:n().connectors.map(s=>s.id===a?{...s,enabled:!s.enabled}:s)})},addConnector:a=>{const{connectors:s}=n();s.some(i=>i.id===a.id)||e({connectors:[...s,a]})},removeConnector:a=>{e({connectors:n().connectors.filter(s=>s.id!==a)})},updateConnectorScope:(a,s)=>{e({connectors:n().connectors.map(i=>i.id===a?{...i,hint:s}:i)})},setExportTarget:a=>e({exportTarget:a}),addPendingKnowledge:a=>{e({pendingKnowledge:[...n().pendingKnowledge,a]})},acceptPendingKnowledge:a=>{const s=n().pendingKnowledge.find(l=>l.id===a);if(!s)return;const i={sourceId:`feedback-${a}`,name:s.name,path:"",category:"knowledge",knowledgeType:s.type||"evidence",enabled:!0,depth:0,baseTokens:500};e({channels:[...n().channels,i],pendingKnowledge:n().pendingKnowledge.filter(l=>l.id!==a)})},dismissPendingKnowledge:a=>{e({pendingKnowledge:n().pendingKnowledge.filter(s=>s.id!==a)})},addSuggestedSkill:a=>{e({suggestedSkills:[...n().suggestedSkills,a]})},acceptSuggestedSkill:a=>{e({suggestedSkills:n().suggestedSkills.map(s=>s.id===a?{...s,installing:!0}:s)}),setTimeout(()=>{n().suggestedSkills.find(i=>i.id===a)&&(e({suggestedSkills:n().suggestedSkills.map(i=>i.id===a?{...i,installing:!1,installed:!0}:i)}),setTimeout(()=>{e({suggestedSkills:n().suggestedSkills.filter(i=>i.id!==a)})},1200))},1500)},dismissSuggestedSkill:a=>{e({suggestedSkills:n().suggestedSkills.filter(s=>s.id!==a)})},installRegistrySkill:(a,s,i)=>{const l=n().registrySkills.find(m=>m.id===a),c=n().registrySkills.map(m=>m.id===a?{...m,installed:!0,installedTarget:s,installedScope:i}:m),f=n().skills.some(m=>m.id===a)?n().skills:l?[...n().skills,{id:l.id,name:l.name,icon:l.icon,enabled:!0,added:!0,description:l.description,category:tf(l.category)}]:n().skills;e({registrySkills:c,skills:f})},installRegistryMcp:a=>{const s=n().registryMcpServers.find(p=>p.id===a),i=n().registryMcpServers.map(p=>p.id===a?{...p,installed:!0,configured:!0}:p),c=n().mcpServers.some(p=>p.id===a)?n().mcpServers:s?[...n().mcpServers,{id:s.id,name:s.name,icon:s.icon,connected:!0,enabled:!0,added:!0,capabilities:["input","output"],category:Ox(s.category),description:s.description}]:n().mcpServers;e({registryMcpServers:i,mcpServers:c})},addFileChannel:a=>{const{channels:s}=n(),i=`file:${a.path}`;if(s.some(p=>p.sourceId===i))return;const l=yf(a.path,a.content),c={sourceId:i,name:a.path.split("/").pop()??a.path,path:a.path,category:"knowledge",knowledgeType:a.knowledgeType||l.knowledgeType,enabled:!0,depth:l.depth,baseTokens:a.tokenEstimate};e({channels:[...s,c],selectedPreset:""})},setInstructionPersona:a=>{e({instructionState:{...n().instructionState,persona:a}})},setInstructionTone:a=>{e({instructionState:{...n().instructionState,tone:a}})},setInstructionExpertise:a=>{e({instructionState:{...n().instructionState,expertise:Math.max(1,Math.min(5,a))}})},setInstructionConstraints:a=>{e({instructionState:{...n().instructionState,constraints:{...n().instructionState.constraints,...a}}})},setInstructionObjectives:a=>{e({instructionState:{...n().instructionState,objectives:{...n().instructionState.objectives,...a}}})},setInstructionRawPrompt:a=>{e({instructionState:{...n().instructionState,rawPrompt:a}})},setInstructionAutoSync:a=>{e({instructionState:{...n().instructionState,autoSync:a}})},addWorkflowStep:a=>{const s={...a,id:`step-${Date.now()}-${Math.random().toString(36).substr(2,9)}`};e({workflowSteps:[...n().workflowSteps,s]})},updateWorkflowStep:(a,s)=>{e({workflowSteps:n().workflowSteps.map(i=>i.id===a?{...i,...s}:i)})},removeWorkflowStep:a=>{e({workflowSteps:n().workflowSteps.filter(s=>s.id!==a)})},reorderWorkflowSteps:(a,s)=>{const i=[...n().workflowSteps],[l]=i.splice(a,1);i.splice(s,0,l),e({workflowSteps:i})},updateInstruction:a=>{e({instructionState:{...n().instructionState,...a}})},updateWorkflowSteps:a=>{const s=a.map((i,l)=>({...i,id:i.id||`step-${Date.now()}-${l}-${Math.random().toString(36).substr(2,5)}`}));e({workflowSteps:s})},setAgentPattern:a=>e({agentPattern:a}),updateVerification:a=>e({verification:{...n().verification,...a}}),updateErrorHandling:a=>e({errorHandling:{...n().errorHandling,...a}}),updateEvaluation:a=>e({evaluation:{...n().evaluation,...a}}),setOutputTemplateConfig:(a,s)=>{e({outputTemplateConfig:{...n().outputTemplateConfig,[a]:s}})},removeOutputTemplateConfig:a=>{const s={...n().outputTemplateConfig};delete s[a],e({outputTemplateConfig:s})},hydrateFromGenerated:a=>{e({agentMeta:{name:a.agentMeta.name||"",description:a.agentMeta.description||"",icon:"brain",category:"general",tags:a.agentMeta.tags||[],avatar:a.agentMeta.avatar||"bot"}}),e({instructionState:{persona:a.instructionState.persona||"",tone:a.instructionState.tone||"neutral",expertise:a.instructionState.expertise||3,constraints:{neverMakeUp:a.instructionState.constraints?.neverMakeUp??!0,askBeforeActions:a.instructionState.constraints?.askBeforeActions??!1,stayInScope:a.instructionState.constraints?.stayInScope??!0,useOnlyTools:a.instructionState.constraints?.useOnlyTools??!1,limitWords:a.instructionState.constraints?.limitWords??!1,wordLimit:a.instructionState.constraints?.wordLimit??0,customConstraints:(a.instructionState.constraints?.customConstraints||[]).join(`
130
+ `),scopeDefinition:a.instructionState.constraints?.scopeDefinition||""},objectives:{primary:a.instructionState.objectives?.primary||"",successCriteria:a.instructionState.objectives?.successCriteria||[],failureModes:a.instructionState.objectives?.failureModes||[]},rawPrompt:"",autoSync:!0}});const s=(a.workflowSteps||[]).map((f,m)=>({id:`gen-step-${m}-${Date.now()}`,label:f.label,action:f.action,tool:"",condition:f.condition?"if":"always",loop:f.loop,maxIterations:f.loop?3:0}));e({workflowSteps:s});const i=(a.mcpServerIds||[]).map(f=>{const m=Ta.find(g=>g.id===f);return m?{id:m.id,name:m.name,icon:m.icon||"server",connected:!1,enabled:!0,added:!0,capabilities:[],category:Ox(m.category),description:m.description}:null}).filter(Boolean);e({mcpServers:i});const l=(a.skillIds||[]).map(f=>{const m=vc.find(g=>g.id===f);return m?{id:m.id,name:m.name,icon:m.icon,enabled:!0,added:!0,description:m.description,category:tf(m.category)}:null}).filter(Boolean);e({skills:l});const c=["ground-truth","signal","evidence","framework","hypothesis","guideline"],p=n().channels;if(a.knowledgeSelections&&a.knowledgeSelections.length>0){const f=p.map(m=>{const g=a.knowledgeSelections.find(k=>k.sourceId===m.sourceId);if(!g)return{...m,enabled:!1};const x=c.indexOf(g.type),b=x>=0?c[x]:m.knowledgeType||"evidence",v=typeof g.depth=="number"&&g.depth>=0&&g.depth<=4?g.depth:m.depth;return{...m,enabled:!0,knowledgeType:b,depth:v}});e({channels:f})}else if(a.knowledgeSuggestions&&a.knowledgeSuggestions.length>0){const f=a.knowledgeSuggestions.map((m,g)=>{const x=c.indexOf(m.type),b=x>=0?c[x]:"evidence";return{sourceId:`gen-knowledge-${g}-${Date.now()}`,name:m.name,path:"",category:"knowledge",knowledgeType:b,enabled:!0,depth:0,baseTokens:2e3}});e({channels:f})}e({response:"",selectedPreset:""})},loadDemoPreset:a=>{if(!a){const i=tA;e({agentMeta:{...i.agentMeta},instructionState:{...i.instructionState},workflowSteps:[...i.workflowSteps],channels:[...i.channels],skills:[...i.skills],mcpServers:[...i.mcpServers],selectedPreset:"",response:""});return}const s=sA[a];s&&e({agentMeta:{...s.agentMeta},instructionState:{...s.instructionState},workflowSteps:[...s.workflowSteps],channels:[...s.channels],skills:[...s.skills],mcpServers:[...s.mcpServers],selectedPreset:"",response:""})},resetAgent:()=>{e({agentMeta:{name:"",description:"",icon:"brain",category:"general",tags:[],avatar:"bot"},instructionState:{persona:"",tone:"neutral",expertise:3,constraints:{neverMakeUp:!1,askBeforeActions:!1,stayInScope:!1,useOnlyTools:!1,limitWords:!1,wordLimit:500,customConstraints:"",scopeDefinition:""},objectives:{primary:"",successCriteria:[],failureModes:[]},rawPrompt:"",autoSync:!0},workflowSteps:[]})},collectContextState:()=>({channels:n().channels,mcpServers:n().mcpServers,skills:n().skills,connectors:n().connectors}),restoreContextState:a=>{e({channels:a.channels,mcpServers:a.mcpServers,skills:a.skills,connectors:a.connectors})}}),{name:"modular-console",partialize:e=>({channels:e.channels,mcpServers:e.mcpServers,skills:e.skills,connectors:e.connectors,agentMeta:e.agentMeta,instructionState:e.instructionState,workflowSteps:e.workflowSteps,selectedModel:e.selectedModel,outputFormat:e.outputFormat,tokenBudget:e.tokenBudget,agentConfig:e.agentConfig}),version:1}));function xm(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")||"modular-agent"}function bm(){const e=se.getState();return{id:xm(e.agentMeta.name),version:"1.0.0",savedAt:new Date().toISOString(),agentMeta:{...e.agentMeta},instructionState:{...e.instructionState},workflowSteps:e.workflowSteps.map(a=>({...a})),channels:e.channels.map(a=>({...a})),mcpServers:e.mcpServers.map(a=>({...a})),skills:e.skills.map(a=>({...a})),connectors:e.connectors.map(a=>({...a})),agentConfig:{...e.agentConfig},exportTarget:e.exportTarget,outputFormat:e.outputFormat,outputFormats:[...e.outputFormats],tokenBudget:e.tokenBudget,prompt:e.prompt}}const Ev=Object.freeze(Object.defineProperty({__proto__:null,agentNameToId:xm,collectFullState:bm,getEffectiveTokens:Mv,useConsoleStore:se},Symbol.toStringTag,{value:"Module"}));function rA({value:e,onChange:n,children:a,t:s,ariaLabel:i}){return d.jsx("select",{value:e,onChange:l=>n(l.target.value),"aria-label":i,className:"appearance-none cursor-pointer outline-none text-[14px] h-8 pl-3 pr-7 rounded-lg",style:{fontFamily:"'Geist Sans', sans-serif",background:s.surfaceOpaque,border:`1px solid ${s.border}`,color:s.isDark?s.textSecondary:"#1a1a20",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3E%3Cpath d='M0 2l4 4 4-4' fill='none' stroke='%23${s.isDark?"555":"999"}' stroke-width='1.5'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 8px center"},children:a})}function iA({onSettingsClick:e}){const n=se(b=>b.selectedModel),a=se(b=>b.setModel),s=se(b=>b.running),i=se(b=>b.run),l=Pc(b=>b.toggleTheme),c=we(),p=se(b=>b.setShowMarketplace),f=Qe(b=>b.getAllModels),m=Qe(b=>b.providers),g=z.useMemo(()=>f(),[f,m]),x=g.length>0;return d.jsxs("div",{className:"flex items-center h-[48px] px-4 gap-3 shrink-0 border-b select-none",style:{background:c.surface,backdropFilter:"blur(12px)",borderColor:c.border},children:[d.jsxs("div",{className:"flex items-center gap-2 mr-4",children:[d.jsx("div",{className:"w-2 h-2 rounded-full",style:{background:"#FE5000",boxShadow:"0 0 8px rgba(254,80,0,0.4)"}}),d.jsx("span",{className:"text-[17px] font-bold tracking-[3px] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:c.textPrimary},children:"MODULAR"})]}),d.jsx(rA,{value:x?`${Qe.getState().selectedProviderId}::${n}`:"__no_models__",onChange:b=>{if(b==="__no_models__")return;const[v,...k]=b.split("::"),w=k.join("::");Qe.getState().selectProvider(v),a(w)},t:c,ariaLabel:"Select AI model",children:g.map(b=>d.jsxs("option",{value:`${b.providerId}::${b.id}`,children:[b.providerName," — ",b.label]},`${b.providerId}-${b.id}`))}),!x&&d.jsx("button",{onClick:()=>se.getState().setShowSettings(!0,"providers"),style:{background:"none",border:`1px solid ${c.border}`,borderRadius:6,padding:"4px 10px",color:"#FE5000",cursor:"pointer",fontFamily:"'Geist Mono', monospace",fontSize:"12px"},children:"⚡ Connect a model provider"}),d.jsx("div",{className:"flex-1"}),d.jsxs("button",{type:"button",onClick:()=>p(!0),className:"flex items-center justify-center gap-1.5 h-8 px-2.5 rounded-lg text-[14px] font-medium cursor-pointer border-none",style:{background:"#FE500012",color:"#FE5000",transition:"background 0.15s"},onMouseEnter:b=>{b.currentTarget.style.background="#FE500025"},onMouseLeave:b=>{b.currentTarget.style.background="#FE500012"},"aria-label":"Open Marketplace",children:[d.jsx(m4,{size:13}),"Marketplace"]}),d.jsx("button",{type:"button",onClick:e,className:"flex items-center justify-center w-11 h-11 rounded-md cursor-pointer border-none bg-transparent hover-accent-text focus-visible:outline focus-visible:outline-2",style:{color:c.textDim},"aria-label":"LLM settings",children:d.jsx(pm,{size:14})}),d.jsx("button",{type:"button",onClick:l,className:"flex items-center justify-center w-11 h-11 rounded-md cursor-pointer border-none bg-transparent hover-accent-text focus-visible:outline focus-visible:outline-2",style:{color:c.textDim},"aria-label":c.isDark?"Switch to light mode":"Switch to dark mode",children:c.isDark?d.jsx(fv,{size:14}):d.jsx(rv,{size:14})}),d.jsxs("button",{type:"button",onClick:i,className:"flex items-center justify-center gap-1.5 h-8 px-4 rounded-lg text-[14px] font-semibold tracking-wider uppercase cursor-pointer border-none",style:{background:s?"#CC4000":"#FE5000",color:"#fff",boxShadow:s?"0 0 12px rgba(254,80,0,0.5)":"0 0 8px rgba(254,80,0,0.25)",opacity:s?.8:1,animation:s?"run-pulse-ring 1.5s ease infinite":"none",transition:"background 0.2s ease, opacity 0.2s ease"},children:[s?d.jsx(pv,{size:12,fill:"white"}):d.jsx(uv,{size:12,fill:"white"}),s?"Stop":"Run",d.jsx("span",{className:"text-[13px] opacity-60 tracking-normal font-normal ml-1",children:s?"click to cancel":"Ctrl+Enter"})]})]})}function lA(){const e=se(c=>c.totalTokens),n=se(c=>c.tokenBudget),a=we(),s=e(),i=Math.min(s/n*100,100);let l=a.statusSuccess;return i>80?l=a.statusError:i>55&&(l=a.statusWarning),d.jsxs("div",{className:"w-full px-4 py-2 flex items-center gap-3 shrink-0 border-t",style:{background:a.surfaceOpaque,borderColor:a.border},children:[d.jsx("span",{className:"text-[12px] tracking-wider uppercase shrink-0 font-medium",style:{fontFamily:"'Geist Mono', monospace",color:a.tokenLabel},children:"Token Budget"}),d.jsx("div",{className:"flex-1 h-[6px] rounded-full overflow-hidden",style:{background:a.tokenTrackBg},children:d.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${i}%`,background:`linear-gradient(90deg, ${l}cc, ${l})`,boxShadow:`0 0 6px ${l}30`}})}),d.jsx("span",{className:"text-[13px] shrink-0 tabular-nums",style:{fontFamily:"'Geist Mono', monospace",color:l,minWidth:56,textAlign:"right",whiteSpace:"nowrap"},children:s>=1e3?`${(s/1e3).toFixed(1)}K`:s}),d.jsxs("span",{className:"text-[13px] shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:a.tokenDivider,minWidth:64,whiteSpace:"nowrap"},children:["/ ",n>=1e3?`${(n/1e3).toFixed(0)}K`:n]})]})}const Bx=`${Ee}/knowledge`,nf=qt(e=>({tree:[],loaded:!1,scanning:!1,error:null,lastDir:"",scanDirectory:async n=>{e({scanning:!0,error:null});try{const s=await(await fetch(`${Bx}/scan?dir=${encodeURIComponent(n)}&depth=3`)).json();s.status==="ok"&&s.data?e({tree:s.data,loaded:!0,scanning:!1,lastDir:n}):e({scanning:!1,error:s.error??"Scan failed"})}catch(a){e({scanning:!1,error:a instanceof Error?a.message:"Network error"})}},readFile:async n=>{try{const s=await(await fetch(`${Bx}/read?path=${encodeURIComponent(n)}`)).json();return s.status==="ok"&&s.data?s.data:null}catch{return null}}}));function cA(e){return e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function jv(e,n){if(!n)return!0;const a=n.toLowerCase();return!!(e.name.toLowerCase().includes(a)||e.path.toLowerCase().includes(a)||e.children?.some(s=>jv(s,n)))}function Tv({node:e,depth:n,onAdd:a,filter:s}){const[i,l]=z.useState(n<1||!!s),c=e.type==="directory"&&e.children&&e.children.length>0,p=we();return jv(e,s)?d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-2 rounded cursor-pointer transition-colors",style:{paddingLeft:8+n*16},onMouseEnter:f=>{f.currentTarget.style.background=p.surfaceHover},onMouseLeave:f=>{f.currentTarget.style.background="transparent"},children:[c?d.jsx("button",{type:"button",onClick:()=>l(!i),className:"w-4 h-4 flex items-center justify-center text-[12px] cursor-pointer border-none bg-transparent",style:{color:p.textMuted},"aria-label":i?"Collapse folder":"Expand folder",children:i?"▼":"▶"}):d.jsx("span",{className:"w-4"}),d.jsx("div",{className:"w-[6px] h-[6px] rounded-full shrink-0",style:{background:e.type==="directory"?"#f1c40f":"#3498db"}}),d.jsx("span",{className:"flex-1 text-[13px] truncate",style:{fontFamily:"'Geist Mono', monospace",color:p.textPrimary},children:e.name}),e.tokenEstimate&&d.jsx("span",{className:"text-[13px] shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:p.textDim},children:cA(e.tokenEstimate)}),e.type==="file"&&d.jsx("button",{type:"button",onClick:()=>a(e),className:"px-2 py-0.5 rounded text-[12px] tracking-[1px] uppercase cursor-pointer border transition-colors shrink-0",style:{fontFamily:"'Geist Mono', monospace",background:"transparent",borderColor:p.border,color:p.textMuted},onMouseEnter:f=>{f.currentTarget.style.borderColor="#FE5000",f.currentTarget.style.color="#FE5000"},onMouseLeave:f=>{f.currentTarget.style.borderColor=p.border,f.currentTarget.style.color=p.textMuted},"aria-label":`Add ${e.name}`,children:"+ ADD"})]}),c&&i&&e.children.map(f=>d.jsx(Tv,{node:f,depth:n+1,onAdd:a,filter:s},f.path))]}):null}function uA(){const e=se(S=>S.showFilePicker),n=se(S=>S.setShowFilePicker),a=se(S=>S.addFileChannel),{tree:s,loaded:i,scanning:l,scanDirectory:c}=nf(),p=nf(S=>S.readFile),f=nf(S=>S.lastDir),[m,g]=z.useState(""),[x,b]=z.useState(""),v=z.useRef(null),k=z.useRef(null),w=we();z.useEffect(()=>{e&&(g(""),b(f),setTimeout(()=>v.current?.focus(),100))},[e,f]),z.useEffect(()=>{if(!e)return;const S=E=>{E.key==="Escape"&&n(!1)};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[e,n]);const C=z.useCallback(S=>{if(S.key!=="Tab"||!k.current)return;const E=k.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(E.length===0)return;const I=E[0],D=E[E.length-1];S.shiftKey?document.activeElement===I&&(S.preventDefault(),D.focus()):document.activeElement===D&&(S.preventDefault(),I.focus())},[]);if(!e)return null;const M=async S=>{if(S.type!=="file")return;const E=f.replace(/\\/g,"/")+"/"+S.path,I=await p(E);I&&a(I)},N=()=>{x.trim()&&c(x.trim())};return d.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>n(!1),children:[d.jsx("div",{className:"absolute inset-0",style:{background:"rgba(0,0,0,0.7)"}}),d.jsxs("div",{ref:k,role:"dialog","aria-modal":"true","aria-label":"Add Knowledge Source",className:"relative w-[560px] max-h-[70vh] flex flex-col rounded-lg overflow-hidden",style:{background:w.surfaceOpaque,border:`1px solid ${w.border}`,boxShadow:"0 24px 48px rgba(0,0,0,0.8)",animation:"modal-in 0.2s ease-out"},onClick:S=>S.stopPropagation(),onKeyDown:C,children:[d.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b",style:{borderColor:w.border},children:[d.jsx("span",{className:"text-[13px] font-bold tracking-[3px] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:w.textPrimary},children:"ADD KNOWLEDGE SOURCE"}),d.jsx("button",{type:"button",onClick:()=>n(!1),className:"text-[17px] cursor-pointer border-none bg-transparent",style:{color:w.textMuted},onMouseEnter:S=>{S.currentTarget.style.color="#FE5000"},onMouseLeave:S=>{S.currentTarget.style.color=w.textMuted},"aria-label":"Close file picker",children:"✕"})]}),d.jsxs("div",{className:"px-4 py-2 border-b flex items-center gap-2",style:{borderColor:w.border},children:[d.jsx("input",{type:"text",value:x,onChange:S=>b(S.target.value),onKeyDown:S=>{S.key==="Enter"&&N()},placeholder:"Directory path to scan...",className:"flex-1 outline-none text-[13px]",style:{background:w.inputBg,border:`1px solid ${w.border}`,borderRadius:4,color:w.textPrimary,fontFamily:"'Geist Mono', monospace",padding:"6px 10px"},"aria-label":"Directory path to scan"}),d.jsx("button",{type:"button",onClick:N,disabled:l,className:"px-3 py-1 rounded text-[12px] tracking-wide uppercase cursor-pointer border-none",style:{background:"#FE5000",color:"#fff",opacity:l?.6:1},"aria-label":"Scan directory",children:l?"Scanning...":"Scan"})]}),d.jsx("div",{className:"px-4 py-2 border-b",style:{borderColor:w.borderSubtle},children:d.jsx("input",{ref:v,type:"text",value:m,onChange:S=>g(S.target.value),placeholder:"Filter results...",className:"w-full outline-none text-[13px]",style:{background:w.inputBg,border:`1px solid ${w.border}`,borderRadius:4,color:w.textPrimary,fontFamily:"'Geist Mono', monospace",padding:"6px 10px"},onFocus:S=>{S.currentTarget.style.borderColor="#FE500050"},onBlur:S=>{S.currentTarget.style.borderColor=w.border},"aria-label":"Filter knowledge sources"})}),d.jsx("div",{className:"flex-1 overflow-y-auto py-2 px-1",children:i&&s.length>0?s.map(S=>d.jsx(Tv,{node:S,depth:0,onAdd:E=>{M(E)},filter:m},S.path)):i&&s.length===0?d.jsx("div",{className:"flex items-center justify-center py-8",children:d.jsx("span",{className:"text-[13px]",style:{color:w.textDim},children:"No files found. Try scanning a directory."})}):d.jsx("div",{className:"flex items-center justify-center py-8",children:d.jsx("span",{className:"text-[13px]",style:{color:w.textDim},children:"Enter a directory path and click Scan to browse files."})})})]})]})}const hc=qt((e,n)=>({skills:[],loaded:!1,loading:!1,error:void 0,loadSkills:async()=>{if(!n().loading){e({loading:!0,error:void 0});try{const a=await fetch(`${Ee}/claude-config/skills`);if(!a.ok){e({loaded:!0,loading:!1,error:`Failed to load skills (${a.status})`});return}const i=(await a.json())?.data??[];e({skills:i.map(l=>({...l,enabled:!0})),loaded:!0,loading:!1})}catch{e({loaded:!0,loading:!1,error:"Backend unavailable. Start the server with `npm run server` on port 4800."})}}},toggleSkill:a=>{e({skills:n().skills.map(s=>s.id===a?{...s,enabled:!s.enabled}:s)})}})),vm={presentation:e4,mic:R3,cloud:EN,code:J1,"bar-chart-3":rm,anchor:Y5,"git-branch":Us,palette:lv,search:lu,image:h3,"book-open":Z1,hexagon:f3,workflow:O4,map:_3,sparkles:La,compass:NN,waves:D4,box:sm,layout:K3,wrench:gv,cpu:Ai,triangle:M4,"pen-tool":cv,mail:N3,hash:c3,github:Us,"file-text":Di,flame:nv,database:_i,globe:ov,folder:ZN,target:cu,"clipboard-list":wN,"hard-drive":i3,shield:fm,brain:Ni};function of({icon:e,size:n=14,...a}){const s=vm[e];return s?d.jsx(s,{size:n,...a}):d.jsx(zi,{size:n,...a})}function dA({icon:e,size:n=14,...a}){const s=vm[e];return s?d.jsx(s,{size:n,...a}):d.jsx(pn,{size:n,...a})}function pA({icon:e,size:n=14,...a}){const s=vm[e];return s?d.jsx(s,{size:n,...a}):d.jsx(pn,{size:n,...a})}function Nv({open:e,onClose:n,title:a,searchPlaceholder:s,width:i=520,hideSearch:l,children:c}){const[p,f]=z.useState(""),m=z.useRef(null),g=z.useRef(null),x=we();z.useEffect(()=>{e&&(f(""),setTimeout(()=>m.current?.focus(),100))},[e]),z.useEffect(()=>{if(!e)return;const v=k=>{k.key==="Escape"&&n()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[e,n]);const b=z.useCallback(v=>{if(v.key!=="Tab"||!g.current)return;const k=g.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(k.length===0)return;const w=k[0],C=k[k.length-1];v.shiftKey?document.activeElement===w&&(v.preventDefault(),C.focus()):document.activeElement===C&&(v.preventDefault(),w.focus())},[]);return e?nu.createPortal(d.jsxs("div",{className:"fixed inset-0 z-[200] flex items-center justify-center",onClick:n,children:[d.jsx("div",{className:"absolute inset-0",style:{background:"rgba(0,0,0,0.6)",backdropFilter:"blur(4px)"}}),d.jsxs("div",{ref:g,role:"dialog","aria-modal":"true","aria-label":a,className:"relative max-h-[70vh] flex flex-col rounded-xl overflow-hidden",style:{width:i,background:x.surfaceOpaque,border:`1px solid ${x.border}`,boxShadow:"0 24px 48px rgba(0,0,0,0.6)",animation:"modal-in 0.2s ease-out"},onClick:v=>v.stopPropagation(),onKeyDown:b,children:[d.jsxs("div",{className:"flex items-center justify-between px-5 py-4",style:{borderBottom:`1px solid ${x.border}`},children:[d.jsx("span",{className:"text-[14px] font-semibold",style:{color:x.textPrimary},children:a}),d.jsx("button",{type:"button",onClick:n,className:"p-1 rounded-md cursor-pointer border-none bg-transparent",style:{color:x.textDim},"aria-label":"Close",children:d.jsx(jt,{size:16})})]}),!l&&d.jsx("div",{className:"px-5 py-3",style:{borderBottom:`1px solid ${x.borderSubtle}`},children:d.jsxs("div",{className:"relative",children:[d.jsx(lu,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2",style:{color:x.textDim}}),d.jsx("input",{ref:m,type:"text",value:p,onChange:v=>f(v.target.value),placeholder:s??"Search...",className:"w-full outline-none text-[13px] pl-9 pr-3 py-1.5 rounded-lg",style:{background:x.inputBg,border:`1px solid ${x.border}`,color:x.textPrimary,fontFamily:"'Geist Sans', sans-serif"},"aria-label":"Search"})]})}),d.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:c(p)})]})]}),document.body):null}const qr=new Map;function fA(e){return e==="Pass"?"#2ecc71":e==="Fail"?"#e74c3c":"#888"}const Px={GEN:"Gen Agent Trust Hub",SOC:"Socket",SNK:"Snyk"};function km({skillPath:e}){const n=we(),[a,s]=z.useState(()=>qr.get(e)??null),[i,l]=z.useState(null);z.useEffect(()=>{if(qr.has(e)){s(qr.get(e));return}let p=!1;return fetch(`${Ee}/skills/audit/${e}`).then(f=>f.json()).then(f=>{p||(qr.set(e,f),s(f))}).catch(()=>{if(p)return;const f={gen:"Pending",socket:"Pending",snyk:"Pending"};qr.set(e,f),s(f)}),()=>{p=!0}},[e]);const c=[{key:"gen",label:"GEN",value:a?.gen??null},{key:"soc",label:"SOC",value:a?.socket??null},{key:"snk",label:"SNK",value:a?.snyk??null}];return d.jsx("div",{style:{position:"relative",display:"inline-flex",alignItems:"center",gap:3},children:c.map(p=>{const f=a===null,m=f?"#888":fA(p.value),g=f?`${Px[p.label]}: Loading...`:`${Px[p.label]}: ${p.value??"Pending"}`;return d.jsxs("div",{style:{position:"relative",display:"inline-flex",alignItems:"center",gap:2,cursor:"default"},onMouseEnter:()=>l(p.key),onMouseLeave:()=>l(null),children:[f?d.jsx(yt,{size:8,style:{color:"#888"},className:"animate-spin"}):d.jsx("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",background:m,flexShrink:0}}),d.jsx("span",{style:{fontSize:12,fontFamily:"'Geist Mono', monospace",fontWeight:600,color:m,lineHeight:1},children:p.label}),i===p.key&&d.jsx("div",{style:{position:"absolute",bottom:"100%",left:"50%",transform:"translateX(-50%)",marginBottom:4,background:n.surfaceOpaque,border:`1px solid ${n.border}`,borderRadius:4,padding:"2px 6px",whiteSpace:"nowrap",fontSize:12,color:n.textPrimary,boxShadow:"0 4px 12px rgba(0,0,0,0.4)",zIndex:100,pointerEvents:"none"},children:g})]},p.key)})})}const mA={content:"Content",analysis:"Analysis",development:"Development",domain:"Domain"},hA=["content","analysis","development","domain"];function gA(e,n){const a=`${e} ${n}`.toLowerCase();return/analysis|insight|research|intel|feedback/.test(a)?"analysis":/code|dev|api|build|test|automation|github/.test(a)?"development":/content|write|presentation|slides|copy/.test(a)?"content":"domain"}function yA(){const e=se(x=>x.showSkillPicker),n=se(x=>x.setShowSkillPicker),a=se(x=>x.skills),s=se(x=>x.addSkill),i=se(x=>x.upsertSkill),l=hc(x=>x.skills),c=hc(x=>x.loaded),p=hc(x=>x.loading),f=hc(x=>x.loadSkills),m=we();z.useEffect(()=>{e&&!c&&!p&&f()},[e,c,p,f]),z.useEffect(()=>{if(l.length!==0)for(const x of l)i({id:x.id,name:x.name,description:x.description||"Installed skill"})},[l,i]);const g=z.useMemo(()=>{const x=new Set(a.filter(v=>v.added).map(v=>v.id)),b=new Map(a.map(v=>[v.id,v]));for(const v of l)b.has(v.id)||b.set(v.id,{id:v.id,name:v.name,icon:"zap",enabled:v.enabled,added:x.has(v.id),description:v.description||"Installed skill",category:gA(v.name,v.description||"")});return Array.from(b.values())},[a,l]);return d.jsx(Nv,{open:e,onClose:()=>n(!1),title:"Add Skill",searchPlaceholder:"Search skills...",children:x=>{const b=g.filter(k=>{if(!x)return!0;const w=x.toLowerCase();return k.name.toLowerCase().includes(w)||k.description.toLowerCase().includes(w)});return hA.map(k=>({category:k,label:mA[k],skills:b.filter(w=>w.category===k)})).filter(k=>k.skills.length>0).map(k=>d.jsxs("div",{children:[d.jsx("div",{className:"px-5 py-1.5",children:d.jsx("span",{className:"text-[12px] font-medium tracking-wider uppercase",style:{color:m.textDim},children:k.label})}),k.skills.map(w=>d.jsxs("div",{className:"flex items-center gap-3 px-5 py-2.5 hover-row cursor-default",children:[d.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center shrink-0",style:{background:m.surfaceElevated},children:d.jsx(dA,{icon:w.icon,size:16,style:{color:m.textSecondary}})}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"text-[17px] font-medium",style:{color:m.textPrimary},children:w.name}),w.skillUrl?.startsWith("https://skills.sh/")&&d.jsx(km,{skillPath:w.skillUrl.replace("https://skills.sh/","")})]}),d.jsx("span",{className:"text-[14px]",style:{color:m.textDim},children:w.description})]}),w.added?d.jsxs("span",{className:"flex items-center gap-1 text-[14px] px-2.5 py-1 rounded-md",style:{color:m.statusSuccess,background:m.statusSuccessBg},children:[d.jsx(_t,{size:12})," Added"]}):d.jsxs("button",{type:"button",onClick:()=>s(w.id),className:"flex items-center gap-1 text-[14px] px-2.5 py-1 rounded-md cursor-pointer border-none",style:{color:"#FE5000",background:"#FE500012",transition:"background 0.15s ease"},onMouseEnter:C=>{C.currentTarget.style.background="#FE500025"},onMouseLeave:C=>{C.currentTarget.style.background="#FE500012"},"aria-label":`Add ${w.name}`,children:[d.jsx(bt,{size:12})," Add"]})]},w.id))]},k.category))}})}function vi({content:e,children:n,position:a="top",delay:s=300}){const i=we(),[l,c]=z.useState(!1),[p,f]=z.useState({x:0,y:0}),m=z.useRef(void 0),g=z.useRef(null),x=()=>{m.current=setTimeout(()=>{if(!g.current)return;const k=g.current.getBoundingClientRect();f({x:k.left+k.width/2,y:a==="top"?k.top-8:k.bottom+8}),c(!0)},s)},b=()=>{clearTimeout(m.current),c(!1)},v=i.isDark?"#333":"#222";return d.jsxs(d.Fragment,{children:[d.jsx("span",{ref:g,onMouseEnter:x,onMouseLeave:b,className:"inline-flex",children:n}),l&&nu.createPortal(d.jsxs("div",{className:"fixed z-[300] pointer-events-none px-2.5 py-1.5 rounded text-[12px]",style:{left:p.x,top:p.y,transform:a==="top"?"translate(-50%, -100%)":"translate(-50%, 0)",background:v,color:"#fff",fontFamily:"'Geist Mono', monospace",boxShadow:"0 2px 8px rgba(0,0,0,0.3)",maxWidth:250,whiteSpace:"normal",lineHeight:1.4},children:[e,d.jsx("div",{style:{position:"absolute",left:"50%",transform:"translateX(-50%)",...a==="top"?{bottom:-4,borderLeft:"5px solid transparent",borderRight:"5px solid transparent",borderTop:`5px solid ${v}`}:{top:-4,borderLeft:"5px solid transparent",borderRight:"5px solid transparent",borderBottom:`5px solid ${v}`},width:0,height:0}})]}),document.body)]})}function xA(){const e=se(q=>q.showMarketplace),n=se(q=>q.activeMarketplaceTab),a=se(q=>q.setShowMarketplace),s=se(q=>q.registrySkills),i=se(q=>q.installRegistrySkill),l=se(q=>q.upsertSkill),c=se(q=>q.skills),[p,f]=z.useState(""),[m,g]=z.useState("all"),[x,b]=z.useState(null),[v,k]=z.useState(null),[w,C]=z.useState(()=>new Set),[M,N]=z.useState([]),[S,E]=z.useState(!1),[I,D]=z.useState(null),[A,L]=z.useState(null),P=z.useRef(null),W=z.useRef(null),$=we(),V=new Set(Array.isArray(c)?c.filter(q=>q.added).map(q=>q.id??""):[]),X=z.useCallback(q=>{if(q.key!=="Tab"||!W.current)return;const ie=W.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(ie.length===0)return;const pe=ie[0],me=ie[ie.length-1];q.shiftKey?document.activeElement===pe&&(q.preventDefault(),me.focus()):document.activeElement===me&&(q.preventDefault(),pe.focus())},[]);z.useEffect(()=>{e&&(f(""),g("all"),b(null),k(null),N([]),E(!1),D(null),L(null),setTimeout(()=>P.current?.focus(),100))},[e]),z.useEffect(()=>{if(!e)return;const q=ie=>{ie.key==="Escape"&&a(!1)};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[e,a]);const H=z.useCallback(q=>{a(!0,q),f(""),g("all"),N([]),D(null),E(!1)},[a]),_=z.useCallback((q,ie,pe)=>{b(q),L(null),setTimeout(()=>{i(q,ie,pe),b(null)},1200)},[i]),T=z.useCallback(async q=>{k(q.id);try{const ie=await fetch(`${Ee}/skills/install`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({skillId:q.id})});if(!ie.ok)throw new Error(`HTTP ${ie.status}`);C(pe=>new Set(pe).add(q.id)),l({id:q.id,name:q.name,description:`Installed from skills.sh (${q.repo})`,skillUrl:q.url})}catch(ie){D(ie instanceof Error?ie.message:"Install failed")}finally{k(null)}},[l]);z.useEffect(()=>{if(!e||n!=="skills"){E(!1),N([]),D(null);return}const q=p.trim();if(q.length<2){E(!1),N([]),D(null);return}const ie=new AbortController,pe=setTimeout(async()=>{E(!0),D(null);try{const me=await fetch(`${Ee}/skills/search?q=${encodeURIComponent(q)}`,{signal:ie.signal});if(!me.ok)throw new Error(`HTTP ${me.status}`);const U=await me.json();N(Array.isArray(U.data)?U.data:[]),D(U.error??null)}catch(me){if(ie.signal.aborted)return;N([]),D(me instanceof Error?me.message:"Search failed")}finally{ie.signal.aborted||E(!1)}},300);return()=>{ie.abort(),clearTimeout(pe)}},[n,p,e]);const B=()=>{if(typeof window>"u")return 4;const q=window.innerWidth;return q<=1024?2:q<=1440?3:4},[G,K]=z.useState(B);if(z.useEffect(()=>{const q=()=>K(B());return window.addEventListener("resize",q),()=>window.removeEventListener("resize",q)},[]),!e)return null;const J=(q,ie)=>{if(!p)return!0;const pe=p.toLowerCase();return q.toLowerCase().includes(pe)||ie.toLowerCase().includes(pe)},F=s.filter(q=>J(q.name,q.description)&&(m==="all"||q.category===m)),O=AS.filter(q=>J(q.name,q.description)),Q={display:"grid",gridTemplateColumns:`repeat(${G}, 1fr)`,gap:12,padding:16,alignContent:"start"};return d.jsx(d.Fragment,{children:d.jsxs("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>a(!1),children:[d.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.90)",backdropFilter:"blur(4px)"}}),d.jsxs("div",{ref:W,role:"dialog","aria-modal":"true","aria-label":"Marketplace",style:{position:"relative",display:"flex",flexDirection:"column",borderRadius:6,overflow:"hidden",isolation:"isolate",zIndex:1,width:"90vw",maxWidth:1600,height:"80vh",background:$.surfaceOpaque,border:`1px solid ${$.border}`,boxShadow:"0 24px 48px rgba(0,0,0,0.6)",animation:"modal-in 0.2s ease-out"},onClick:q=>q.stopPropagation(),onKeyDown:X,children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"12px 16px",borderBottom:`1px solid ${$.border}`},children:[d.jsx("span",{style:{fontSize:17,fontWeight:600,flexShrink:0,color:$.textPrimary,fontFamily:"'Geist Mono', monospace"},children:"Marketplace"}),d.jsxs("div",{style:{position:"relative",width:240,flexShrink:0},children:[d.jsx(lu,{size:13,style:{position:"absolute",left:10,top:"50%",transform:"translateY(-50%)",color:$.textDim}}),d.jsx("input",{ref:P,type:"text",value:p,onChange:q=>f(q.target.value),placeholder:"Search...",style:{width:"100%",outline:"none",fontSize:14,paddingLeft:32,paddingRight:12,paddingTop:6,paddingBottom:6,borderRadius:6,background:$.inputBg,border:`1px solid ${$.border}`,color:$.textPrimary,fontFamily:"'Geist Sans', sans-serif"}})]}),d.jsx("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",borderBottom:`1px solid ${$.borderSubtle}`},children:["skills","mcp","presets"].map(q=>d.jsx("button",{type:"button",onClick:()=>H(q),style:{padding:"6px 12px",fontSize:13,fontWeight:500,letterSpacing:"0.025em",textTransform:"uppercase",cursor:"pointer",border:"none",color:n===q?"#FE5000":$.textDim,borderBottom:n===q?"2px solid #FE5000":"2px solid transparent",background:"transparent",marginBottom:-1,transition:"color 150ms ease"},children:q==="mcp"?"MCP Servers":q==="presets"?"Presets":"Skills"},q))}),d.jsx(vi,{content:"Close marketplace (Esc)",children:d.jsx("button",{type:"button",onClick:()=>a(!1),style:{padding:4,borderRadius:6,cursor:"pointer",border:"none",background:"transparent",flexShrink:0,color:$.textDim},"aria-label":"Close marketplace",children:d.jsx(jt,{size:16})})})]}),n==="skills"&&d.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 16px",borderBottom:`1px solid ${$.borderSubtle}`,gap:12,flexWrap:"wrap"},children:[d.jsx("div",{style:{display:"flex",alignItems:"center",gap:4,flexWrap:"wrap",flex:1},children:k0.map(q=>d.jsx("button",{type:"button",onClick:()=>g(q.id),style:{fontSize:12,padding:"2px 10px",borderRadius:9999,cursor:"pointer",border:"none",fontWeight:500,background:m===q.id?"#FE5000":$.surfaceElevated,color:m===q.id?"#fff":$.textSecondary,transition:"background 150ms ease, color 150ms ease"},children:q.label},q.id))}),d.jsx("div",{style:{display:"flex",alignItems:"center",gap:12,flexShrink:0},children:Object.entries(kc).map(([q,ie])=>d.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:13,color:$.textDim},children:[d.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:ie.color,display:"inline-block",flexShrink:0}}),ie.label]},q))})]}),n==="mcp"&&d.jsx("div",{style:{display:"flex",alignItems:"center",padding:"8px 16px",gap:4,flexWrap:"wrap",borderBottom:`1px solid ${$.borderSubtle}`},children:k0.map(q=>d.jsx("button",{type:"button",onClick:()=>g(q.id),style:{fontSize:12,padding:"2px 10px",borderRadius:9999,cursor:"pointer",border:"none",fontWeight:500,background:m===q.id?"#FE5000":$.surfaceElevated,color:m===q.id?"#fff":$.textSecondary,transition:"background 150ms ease, color 150ms ease"},children:q.label},q.id))}),d.jsxs("div",{style:{flex:1,overflowY:"auto"},children:[n==="skills"&&d.jsxs(d.Fragment,{children:[F.length>0&&d.jsx("div",{style:Q,children:F.map(q=>d.jsx(bA,{skill:q,isInLibrary:V.has(q.id),installing:x===q.id,dropdownOpen:A===q.id,onToggleDropdown:()=>L(A===q.id?null:q.id),onInstall:_,t:$},q.id))}),F.length===0&&!S&&!I&&M.length===0&&d.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px 0"},children:d.jsx("span",{style:{fontSize:14,color:$.textFaint},children:"No skills match your search"})}),(p.trim().length>=2||S||I||M.length>0)&&d.jsx("div",{style:{padding:"16px 16px 8px",borderTop:`1px solid ${$.borderSubtle}`},children:d.jsx("span",{style:{fontSize:12,letterSpacing:"0.05em",textTransform:"uppercase",color:$.textDim,fontFamily:"'Geist Mono', monospace"},children:"From skill.sh"})}),S&&d.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"24px 0"},children:d.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:13,color:$.textDim},children:[d.jsx(yt,{size:12,style:{animation:"spin 1s linear infinite"}}),"Searching skill.sh..."]})}),!S&&I&&d.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"24px 16px"},children:d.jsx("span",{style:{fontSize:13,color:$.statusError},children:"skill.sh search unavailable"})}),!S&&!I&&M.length>0&&d.jsx("div",{style:{...Q,paddingTop:0},children:M.map(q=>d.jsx(vA,{skill:q,installing:v===q.id,installed:w.has(q.id),onInstall:()=>T(q),t:$},q.id))}),!S&&!I&&p.trim().length>=2&&M.length===0&&d.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"24px 16px"},children:d.jsx("span",{style:{fontSize:13,color:$.textFaint},children:"No results from skill.sh"})})]}),n==="mcp"&&d.jsxs("div",{style:{textAlign:"center",padding:40},children:[d.jsx("p",{style:{color:$.textDim,marginBottom:12},children:"Browse and connect MCP servers"}),d.jsx("button",{onClick:()=>{a(!1),se.getState().setShowConnectionPicker(!0)},style:{background:"#FE5000",color:"#fff",border:"none",borderRadius:6,padding:"8px 16px",cursor:"pointer",fontFamily:"'Geist Mono', monospace"},children:"Open Connection Picker"})]}),n==="presets"&&d.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[O.map(q=>d.jsx(kA,{preset:q,t:$,onLoad:()=>a(!1)},q.id)),O.length===0&&d.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px 0"},children:d.jsx("span",{style:{fontSize:14,color:$.textFaint},children:"No presets match your search"})})]})]})]})]})})}function bA({skill:e,isInLibrary:n,installing:a,dropdownOpen:s,onToggleDropdown:i,onInstall:l,t:c}){const[p,f]=z.useState(!1),[m,g]=z.useState("claude"),[x,b]=z.useState("project"),v=n||e.installed;return d.jsxs("div",{style:{background:c.surfaceElevated,border:`1px solid ${v?c.borderSubtle:c.border}`,borderRadius:6,padding:"10px 12px",display:"flex",flexDirection:"column",gap:5,opacity:v?.55:1,position:"relative",transition:"border-color 150ms ease",minHeight:120},onMouseEnter:k=>{v||(k.currentTarget.style.borderColor="#FE500050")},onMouseLeave:k=>{k.currentTarget.style.borderColor=v?c.borderSubtle:c.border},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6},children:[d.jsx("span",{style:{fontSize:13,fontWeight:600,color:c.textPrimary,fontFamily:"'Geist Mono', monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:e.name}),d.jsxs("span",{style:{fontSize:13,color:c.textDim,background:c.badgeBg,borderRadius:3,padding:"1px 4px",whiteSpace:"nowrap",flexShrink:0,fontFamily:"'Geist Mono', monospace"},children:[e.installs>=1e3?`${(e.installs/1e3).toFixed(1)}k`:e.installs,"↓"]})]}),d.jsx("span",{style:{fontSize:12,color:c.textDim,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"'Geist Sans', sans-serif"},children:e.author}),d.jsxs("div",{style:{flex:1},children:[d.jsx("span",{style:{fontSize:12,color:c.textMuted,fontFamily:"'Geist Sans', sans-serif",lineHeight:1.4,display:p?"block":"-webkit-box",WebkitLineClamp:p?"unset":2,WebkitBoxOrient:"vertical",overflow:p?"visible":"hidden"},children:e.description}),d.jsx("button",{type:"button",onClick:()=>f(!p),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:c.textDim,display:"inline-flex",alignItems:"center",marginTop:1},children:p?d.jsx(Q1,{size:9}):d.jsx(Mn,{size:9})})]}),d.jsx(km,{skillPath:e.id}),d.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:2},children:[d.jsx("div",{style:{display:"flex",gap:4,alignItems:"center"},children:e.runtimes.map(k=>d.jsx("span",{title:kc[k].label,style:{width:7,height:7,borderRadius:"50%",background:kc[k].color,display:"inline-block",flexShrink:0}},k))}),v?d.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:13,color:c.statusSuccess,background:c.statusSuccessBg,borderRadius:4,padding:"2px 6px"},children:[d.jsx(_t,{size:9})," In Library"]}):a?d.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:13,color:"#FE5000",background:"#FE500010",borderRadius:4,padding:"2px 6px"},children:[d.jsx(yt,{size:9,className:"animate-spin"})," Installing"]}):d.jsxs("button",{type:"button",onClick:i,style:{fontSize:13,padding:"2px 8px",borderRadius:4,cursor:"pointer",border:`1px solid ${s?"#FE5000":c.border}`,color:s?"#FE5000":c.textSecondary,background:"transparent",display:"inline-flex",alignItems:"center",gap:3,transition:"border-color 150ms ease, color 150ms ease"},onMouseEnter:k=>{k.currentTarget.style.borderColor="#FE5000",k.currentTarget.style.color="#FE5000"},onMouseLeave:k=>{s||(k.currentTarget.style.borderColor=c.border,k.currentTarget.style.color=c.textSecondary)},children:["Install ",d.jsx(Mn,{size:8})]})]}),s&&d.jsxs("div",{style:{position:"absolute",right:0,bottom:"calc(100% + 4px)",background:c.surfaceOpaque,border:`1px solid ${c.border}`,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",borderRadius:6,padding:10,zIndex:20,width:220,display:"flex",flexDirection:"column",gap:8},children:[d.jsxs("div",{children:[d.jsx("span",{style:{fontSize:13,fontWeight:600,color:c.textDim,fontFamily:"'Geist Mono', monospace",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Target"}),d.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:["all",...e.runtimes].map(k=>d.jsx("button",{type:"button",onClick:()=>g(k),style:{fontSize:13,padding:"2px 6px",borderRadius:4,cursor:"pointer",border:"none",background:m===k?"#FE5000":c.surfaceElevated,color:m===k?"#fff":c.textSecondary,fontWeight:500},children:k==="all"?"All":kc[k].label},k))})]}),d.jsxs("div",{children:[d.jsx("span",{style:{fontSize:13,fontWeight:600,color:c.textDim,fontFamily:"'Geist Mono', monospace",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Scope"}),d.jsx("div",{style:{display:"flex",gap:4,marginTop:4},children:["project","global"].map(k=>d.jsx("button",{type:"button",onClick:()=>b(k),style:{fontSize:13,padding:"2px 6px",borderRadius:4,cursor:"pointer",border:"none",background:x===k?"#FE5000":c.surfaceElevated,color:x===k?"#fff":c.textSecondary,fontWeight:500,textTransform:"capitalize"},children:k},k))})]}),d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,background:c.inputBg,borderRadius:4,padding:"4px 6px"},children:[d.jsx(hi,{size:9,style:{color:c.textDim,flexShrink:0}}),d.jsxs("code",{style:{fontSize:12,color:c.textMuted,fontFamily:"'Geist Mono', monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[e.installCmd," --target ",m," --scope ",x]})]}),d.jsx("button",{type:"button",onClick:()=>l(e.id,m,x),style:{width:"100%",padding:"6px",borderRadius:4,border:"none",background:"#FE5000",color:"#fff",fontSize:12,fontWeight:600,cursor:"pointer"},children:"Confirm Install"})]})]})}function vA({skill:e,installing:n,installed:a,onInstall:s,t:i}){const[l,c]=z.useState(!1),p=e.url.replace("https://skills.sh/","");return d.jsxs("div",{style:{background:i.surfaceElevated,border:`1px solid ${i.border}`,borderRadius:6,padding:"10px 12px",display:"flex",flexDirection:"column",gap:5,position:"relative",transition:"border-color 150ms ease",minHeight:120},onMouseEnter:f=>{f.currentTarget.style.borderColor="#FE500050"},onMouseLeave:f=>{f.currentTarget.style.borderColor=i.border},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6},children:[d.jsx("span",{style:{fontSize:13,fontWeight:600,color:i.textPrimary,fontFamily:"'Geist Mono', monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:e.name}),d.jsxs("span",{style:{fontSize:13,color:i.textDim,background:i.badgeBg,borderRadius:3,padding:"1px 4px",whiteSpace:"nowrap",flexShrink:0,fontFamily:"'Geist Mono', monospace"},children:[e.installs,"↓"]})]}),d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[d.jsx("span",{style:{fontSize:12,color:i.textDim,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,fontFamily:"'Geist Sans', sans-serif"},children:e.repo}),d.jsx(vi,{content:"View on skills.sh",children:d.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:i.textDim,flexShrink:0,display:"inline-flex"},"aria-label":`Open ${e.name} on skills.sh`,onMouseEnter:f=>{f.currentTarget.style.color="#FE5000"},onMouseLeave:f=>{f.currentTarget.style.color=i.textDim},children:d.jsx(tv,{size:10})})})]}),d.jsxs("div",{style:{flex:1},children:[d.jsx("span",{style:{fontSize:12,color:i.textMuted,fontFamily:"'Geist Sans', sans-serif",lineHeight:1.4,display:l?"block":"-webkit-box",WebkitLineClamp:l?"unset":2,WebkitBoxOrient:"vertical",overflow:l?"visible":"hidden"},children:e.url}),d.jsx("button",{type:"button",onClick:()=>c(!l),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:i.textDim,display:"inline-flex",alignItems:"center",marginTop:1},children:l?d.jsx(Q1,{size:9}):d.jsx(Mn,{size:9})})]}),d.jsx(km,{skillPath:p}),d.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:2},children:[d.jsx(pn,{size:10,style:{color:i.textDim}}),a?d.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:13,color:i.statusSuccess,background:i.statusSuccessBg,borderRadius:4,padding:"2px 6px"},children:[d.jsx(_t,{size:9})," Installed"]}):n?d.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:13,color:"#FE5000",background:"#FE500010",borderRadius:4,padding:"2px 6px"},children:[d.jsx(yt,{size:9,className:"animate-spin"})," Installing"]}):d.jsxs("button",{type:"button",onClick:s,style:{fontSize:13,padding:"2px 8px",borderRadius:4,cursor:"pointer",border:`1px solid ${i.border}`,color:"#FE5000",background:"#FE500010",display:"inline-flex",alignItems:"center",gap:3},children:[d.jsx(iu,{size:9})," Install"]})]})]})}function kA({preset:e,t:n,onLoad:a}){return d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"0 16px",minHeight:56,borderBottom:`1px solid ${n.borderSubtle}`,transition:"background 100ms ease"},onMouseEnter:s=>{s.currentTarget.style.background=n.surfaceHover},onMouseLeave:s=>{s.currentTarget.style.background="transparent"},children:[d.jsx("div",{style:{width:24,height:24,borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,background:"#FE500010"},children:d.jsx(pA,{icon:e.icon,size:14,style:{color:"#FE5000"}})}),d.jsxs("div",{style:{flex:1,minWidth:0},children:[d.jsx("div",{style:{fontSize:14,fontWeight:500,color:n.textPrimary},children:e.name}),d.jsx("div",{style:{fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:2,color:n.textMuted},title:e.description,spellCheck:!1,children:e.description}),d.jsxs("div",{style:{display:"flex",gap:4,marginTop:2},children:[e.skills.slice(0,3).map(s=>d.jsx("span",{style:{fontSize:12,padding:"0 4px",borderRadius:2,color:n.cableSkills,background:n.cableSkills+"10"},children:s},s)),e.mcpServers.slice(0,2).map(s=>d.jsx("span",{style:{fontSize:12,padding:"0 4px",borderRadius:2,color:n.cableMcp,background:n.cableMcp+"10"},children:s},s))]})]}),d.jsx("button",{type:"button",onClick:a,style:{fontSize:12,padding:"4px 8px",borderRadius:6,cursor:"pointer",flexShrink:0,background:"transparent",border:`1px solid ${n.border}`,color:n.textSecondary,whiteSpace:"nowrap",minWidth:80,transition:"border-color 150ms ease, color 150ms ease, background 150ms ease"},onMouseEnter:s=>{s.currentTarget.style.borderColor="#FE5000",s.currentTarget.style.color="#fff",s.currentTarget.style.background="#FE5000"},onMouseLeave:s=>{s.currentTarget.style.borderColor=n.border,s.currentTarget.style.color=n.textSecondary,s.currentTarget.style.background="transparent"},children:"Load Preset"})]})}async function wA(e){const n=await fetch(`${Ee}/mcp/oauth/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverUrl:e})});if(!n.ok){const s=await n.json().catch(()=>({error:"Request failed"}));throw new Error(s.error||`HTTP ${n.status}`)}const{authUrl:a}=await n.json();return new Promise((s,i)=>{const l=window.open(a,"mcp-oauth","width=600,height=700,popup=yes");if(!l){i(new Error("Popup blocked — allow popups for this site"));return}const c=()=>{window.removeEventListener("message",p),clearInterval(f),clearTimeout(m)},p=g=>{const x=g.data;x?.type&&(x.type==="mcp-oauth-success"?(c(),s()):x.type==="mcp-oauth-error"&&(c(),i(new Error(x.error||"OAuth flow failed"))))};window.addEventListener("message",p);const f=setInterval(()=>{l.closed&&(c(),i(new Error("OAuth flow cancelled")))},500),m=setTimeout(()=>{c(),l.close(),i(new Error("OAuth flow timed out"))},3e5)})}async function SA(e){const n=await fetch(`${Ee}/mcp/oauth/status?serverUrl=${encodeURIComponent(e)}`);return n.ok?await n.json():{connected:!1}}const af=(e="none")=>{switch(e){case"oauth":return{bg:"#FE500010",color:"#FE5000",text:"OAuth"};case"api-key":return{bg:"#3498db10",color:"#3498db",text:"API Key"};default:return{bg:"#2ecc7110",color:"#2ecc71",text:"Local"}}};function sf({mcpConnected:e}){let n="#555",a="Not configured";return e&&(n="#00cc66",a="Connected"),d.jsx("span",{style:{display:"inline-block",width:7,height:7,borderRadius:"50%",background:n,flexShrink:0},title:a})}function Hx({title:e,collapsed:n,onToggle:a,t:s}){return d.jsxs("div",{className:"flex items-center gap-2 px-5 py-2 cursor-pointer select-none",onClick:a,children:[n?d.jsx(ta,{size:12,style:{color:s.textDim}}):d.jsx(Mn,{size:12,style:{color:s.textDim}}),d.jsx("span",{className:"text-[11px] tracking-[0.12em] uppercase font-bold",style:{color:s.textDim,fontFamily:"'Geist Mono', monospace"},children:e})]})}function CA(){const e=se(T=>T.showConnectionPicker),n=se(T=>T.setShowConnectionPicker),a=se(T=>T.connectors),s=se(T=>T.addConnector),i=se(T=>T.upsertMcpServer),l=we(),[c,p]=z.useState({}),[f,m]=z.useState({}),[g,x]=z.useState({}),[b,v]=z.useState(!1),[k,w]=z.useState(!1),[C,M]=z.useState("All"),[N,S]=z.useState({}),E=at(T=>T.servers),I=at(T=>T.addServer),D=Ta.filter(T=>T.authMethod==="oauth"&&!!T.url),A=["All",...Array.from(new Set(Ta.map(T=>T.category)))];z.useEffect(()=>{e&&D.forEach(T=>{SA(T.url).then(B=>{if(p(G=>({...G,[T.url]:B.connected})),B.connected){const G=T.id;se.getState().connectors.some(K=>K.service===G)||s({id:`conn-${T.id}-oauth`,service:G,name:T.name,mcpServerId:T.id,direction:"both",enabled:!0,config:{},status:"connected",authMethod:"oauth"})}}).catch(()=>{})})},[e]);const L=async T=>{m(B=>({...B,[T.url]:!0})),x(B=>({...B,[T.url]:""}));try{await wA(T.url),p(G=>({...G,[T.url]:!0})),await I({id:T.id,name:T.name,type:"http",command:"",args:[],env:{},url:T.url,headers:{},autoConnect:!0}),await i({id:T.id,name:T.name,description:T.description,connected:!0});const B=T.id;a.some(G=>G.service===B)||s({id:`conn-${T.id}-oauth-${Date.now()}`,service:B,name:T.name,mcpServerId:T.id,direction:"both",enabled:!0,config:{},status:"connected",authMethod:"oauth"})}catch(B){x(G=>({...G,[T.url]:B.message}))}finally{m(B=>({...B,[T.url]:!1}))}},P=T=>{const B=Ta.find(G=>G.id===T);B&&S(G=>({...G,[T]:{entry:B,expanded:!G[T]?.expanded,configValues:G[T]?.configValues||{}}}))},W=(T,B,G)=>{S(K=>({...K,[T]:{...K[T],configValues:{...K[T]?.configValues,[B]:G}}}))},$=async T=>{const G=N[T.id]?.configValues||{};if(await i({id:T.id,name:T.name,description:T.description,connected:!1}),T.configFields&&T.configFields.length>0){const K={};T.configFields.forEach(J=>{G[J.key]&&(K[J.key]=G[J.key])}),await I({id:T.id,name:T.name,type:T.transport==="stdio"?"stdio":"http",command:T.command||"",args:T.defaultArgs||[],env:K,autoConnect:!0})}S(K=>({...K,[T.id]:{...K[T.id],expanded:!1}}))},V=T=>E.some(B=>B.id===T)||a.some(B=>B.mcpServerId===T),X=T=>E.find(G=>G.id===T)?.status==="connected",H=T=>{const B=c[T.url]??!1,G=f[T.url]??!1,K=g[T.url],J=V(T.id),F=af("oauth");return d.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5 hover-row cursor-default",children:[d.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center shrink-0",style:{background:l.surfaceElevated},children:d.jsx(of,{icon:T.icon,size:16,style:{color:l.textSecondary}})}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(sf,{mcpConnected:B}),d.jsx("span",{className:"text-[13px] font-medium",style:{color:l.textPrimary},children:T.name}),d.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full uppercase",style:{background:F.bg,color:F.color,fontFamily:"'Geist Mono', monospace",fontWeight:600},children:F.text})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-[11px]",style:{color:l.textDim},children:T.description}),K&&d.jsx("span",{className:"text-[10px] ml-2",style:{color:"#ff4444"},children:K})]})]}),J&&B?d.jsxs("span",{className:"flex items-center gap-1 text-[11px] px-2.5 py-1 rounded-md",style:{color:l.statusSuccess,background:l.statusSuccessBg},children:[d.jsx(_t,{size:12})," Connected"]}):d.jsxs("button",{type:"button",onClick:()=>L(T),disabled:G,className:"flex items-center gap-1.5 text-[11px] px-3 py-1 rounded-md cursor-pointer border-none",style:{background:"#FE500018",color:"#FE5000",fontWeight:600,opacity:G?.7:1},children:[G?d.jsx(yt,{size:12,className:"animate-spin"}):d.jsx(bt,{size:12}),G?"Connecting...":"Connect"]})]},T.id)},_=T=>{if(T.authMethod==="oauth"){const O=c[T.url]??!1,Q=af("oauth");return d.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5 hover-row cursor-default",children:[d.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center shrink-0",style:{background:l.surfaceElevated},children:d.jsx(of,{icon:T.icon,size:16,style:{color:l.textSecondary}})}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(sf,{mcpConnected:O}),d.jsx("span",{className:"text-[13px] font-medium",style:{color:l.textPrimary},children:T.name}),d.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full uppercase",style:{background:Q.bg,color:Q.color,fontFamily:"'Geist Mono', monospace",fontWeight:600},children:Q.text})]}),d.jsx("span",{className:"text-[11px]",style:{color:l.textDim},children:T.description})]}),d.jsxs("button",{type:"button",onClick:()=>T.url&&L(T),className:"flex items-center gap-1.5 text-[11px] px-3 py-1 rounded-md cursor-pointer border-none",style:{background:"#FE500018",color:"#FE5000",fontWeight:600},children:[d.jsx(bt,{size:12}),"Connect via OAuth"]})]},T.id)}const B=V(T.id),G=X(T.id),K=af(T.authMethod),J=N[T.id],F=T.configFields&&T.configFields.length>0;return d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5 hover-row cursor-default",children:[d.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center shrink-0",style:{background:l.surfaceElevated},children:d.jsx(of,{icon:T.icon,size:16,style:{color:l.textSecondary}})}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(sf,{mcpConnected:G}),d.jsx("span",{className:"text-[13px] font-medium",style:{color:l.textPrimary},children:T.name}),d.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full uppercase",style:{background:K.bg,color:K.color,fontFamily:"'Geist Mono', monospace",fontWeight:600},children:K.text})]}),d.jsx("span",{className:"text-[11px]",style:{color:l.textDim},children:T.description})]}),B?d.jsxs("span",{className:"flex items-center gap-1 text-[11px] px-2.5 py-1 rounded-md",style:{color:l.statusSuccess,background:l.statusSuccessBg},children:[d.jsx(_t,{size:12})," Added"]}):d.jsxs("button",{type:"button",onClick:()=>F?P(T.id):$(T),className:"flex items-center gap-1.5 text-[11px] px-3 py-1 rounded-md cursor-pointer border-none",style:{background:"#FE500018",color:"#FE5000",fontWeight:600},children:[d.jsx(bt,{size:12}),"Add"]})]}),F&&J?.expanded&&d.jsxs("div",{className:"px-4 py-3 ml-11 mr-4 mb-2 rounded-lg",style:{background:l.surfaceElevated},children:[d.jsx("div",{className:"text-[12px] font-medium mb-2",style:{color:l.textPrimary},children:"Configuration"}),d.jsxs("div",{className:"space-y-2",children:[T.configFields.map(O=>d.jsxs("div",{children:[d.jsxs("label",{className:"text-[11px]",style:{color:l.textDim},children:[O.label," ",O.required&&"*"]}),d.jsx("input",{type:O.type==="password"||O.key.toLowerCase().includes("token")||O.key.toLowerCase().includes("key")?"password":"text",placeholder:O.placeholder,value:J.configValues[O.key]||"",onChange:Q=>W(T.id,O.key,Q.target.value),className:"w-full mt-1 px-2 py-1 text-[12px] rounded border outline-none",style:{background:l.inputBg,border:`1px solid ${l.border}`,color:l.textPrimary,fontFamily:"'Geist Mono', monospace"}})]},O.key)),d.jsxs("div",{className:"flex gap-2 mt-3",children:[d.jsxs("button",{type:"button",onClick:()=>$(T),disabled:T.configFields.some(O=>O.required&&!J.configValues[O.key]),className:"flex items-center gap-1 text-[11px] px-3 py-1.5 rounded-md cursor-pointer border-none",style:{background:"#FE5000",color:"white",fontWeight:600,opacity:T.configFields.some(O=>O.required&&!J.configValues[O.key])?.5:1},children:[d.jsx(_t,{size:12}),"Save & Add"]}),d.jsx("button",{type:"button",onClick:()=>P(T.id),className:"text-[11px] px-3 py-1.5 rounded-md cursor-pointer border-none",style:{background:l.border,color:l.textDim},children:"Cancel"})]})]})]})]},T.id)};return d.jsx(Nv,{open:e,onClose:()=>n(!1),title:"Add Connection",searchPlaceholder:"Search connections...",width:600,children:T=>{const B=T?.toLowerCase()??"",G=D.filter(J=>!B||J.name.toLowerCase().includes(B)||J.description.toLowerCase().includes(B)),K=Ta.filter(J=>{const F=!B||J.name.toLowerCase().includes(B)||J.description.toLowerCase().includes(B)||J.tags&&J.tags.some(Q=>Q.toLowerCase().includes(B)),O=C==="All"||J.category===C;return F&&O});return d.jsxs(d.Fragment,{children:[G.length>0&&d.jsxs(d.Fragment,{children:[d.jsx(Hx,{title:"Quick Connect",collapsed:b,onToggle:()=>v(!b),t:l}),!b&&d.jsx("div",{className:"pb-2",children:G.map(H)})]}),d.jsx(Hx,{title:"MCP Library",collapsed:k,onToggle:()=>w(!k),t:l}),!k&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"flex gap-1 px-5 py-2 overflow-x-auto",children:A.map(J=>d.jsx("button",{type:"button",onClick:()=>M(J),className:"text-[11px] px-2 py-1 rounded-md cursor-pointer border-none whitespace-nowrap",style:{background:C===J?"#FE5000":"transparent",color:C===J?"white":l.textDim,fontFamily:"'Geist Mono', monospace",fontWeight:600},children:J},J))}),d.jsx("div",{className:"max-h-[400px] overflow-y-auto pb-2",children:K.map(_)})]})]})}})}const MA=[{id:"providers",label:"Providers"},{id:"mcp",label:"MCP Servers"},{id:"general",label:"General"}];function Gc(e,n){switch(e){case"connected":return n.statusSuccess;case"configured":return n.statusWarning;case"error":return n.statusError;default:return n.textMuted}}function EA({provider:e}){const n=we(),[a,s]=z.useState(!1),[i,l]=z.useState(!1),[c,p]=z.useState(e.apiKey||""),[f,m]=z.useState(e.baseUrl),[g,x]=z.useState(null),b=Qe($=>$.setProviderKey),v=Qe($=>$.setProviderAuthMethod),k=Qe($=>$.setProviderBaseUrl),w=Qe($=>$.testConnection),C=Qe($=>$.testing[e.id]),M=Qe($=>$.deleteProvider),N=Qe($=>$.saveProvider),S=e.id.startsWith("custom-"),E=e.id==="openai",I=E&&e.authMethod==="oauth",D=e.id==="anthropic"?"Claude":e.name,A=Array.isArray(e.models)?e.models:[];z.useEffect(()=>{e.apiKey&&e.apiKey.trim().length>0&&p(e.apiKey),m(e.baseUrl)},[e.apiKey,e.baseUrl]);const L=z.useCallback(()=>{b(e.id,c),k(e.id,f),N(e.id)},[e.id,c,f,b,k,N]),P=z.useCallback(async()=>{L();const $=await w(e.id);x($)},[e.id,L,w]),W={background:n.inputBg,border:`1px solid ${n.border}`,color:n.textPrimary,fontFamily:"'Geist Sans', sans-serif"};return d.jsxs("div",{style:{background:a?n.surfaceElevated:"transparent",borderBottom:`1px solid ${n.borderSubtle}`},children:[d.jsxs("div",{role:"button",tabIndex:0,className:"nodrag nowheel w-full flex items-center gap-3 px-4 py-3 cursor-pointer border-none bg-transparent text-left",onClick:()=>s(!a),style:{color:n.textPrimary},children:[d.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:Gc(e.status,n),boxShadow:`0 0 6px ${Gc(e.status,n)}40`}}),d.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center shrink-0",style:{background:e.color+"20"},children:d.jsx(Ai,{size:14,style:{color:e.color}})}),d.jsx("span",{className:"text-[14px] font-semibold flex-1",style:{fontFamily:"'Geist Mono', monospace"},children:D}),d.jsx("span",{className:"text-[12px]",style:{color:n.textMuted},children:e.status==="connected"?`${A.length} models`:e.status})]}),a&&d.jsxs("div",{className:"px-4 pb-4 flex flex-col gap-3",children:[E&&d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:n.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Auth Mode"}),d.jsxs("select",{value:e.authMethod,onChange:$=>v(e.id,$.target.value),className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none",style:W,children:[d.jsx("option",{value:"api-key",children:"API Key"}),d.jsx("option",{value:"oauth",children:"Local Session (experimental)"})]})]}),e.authMethod==="claude-agent-sdk"?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-center gap-2 text-[14px] px-3 py-2.5 rounded-lg",style:{background:n.badgeBg,border:`1px solid ${n.borderSubtle}`},children:[d.jsx(hi,{size:14,style:{color:e.color}}),d.jsx("span",{style:{color:n.textSecondary},children:"Authenticates via your Claude Code login — no API key needed."})]}),e.status==="connected"&&d.jsxs("div",{className:"flex items-center gap-2 text-[14px] px-3 py-2 rounded-lg",style:{background:n.statusSuccessBg,border:`1px solid ${n.statusSuccess}30`,color:n.statusSuccess},children:[d.jsx(Hc,{size:14}),d.jsxs("span",{children:["Authenticated",e.lastError?` — ${e.lastError}`:" via Claude Code"]})]}),e.status==="error"&&d.jsxs("div",{className:"flex items-center gap-2 text-[14px] px-3 py-2 rounded-lg",style:{background:n.statusErrorBg,border:`1px solid ${n.statusError}30`,color:n.statusError},children:[d.jsx(mi,{size:14}),d.jsx("span",{children:e.lastError||"Not authenticated — install Claude Code and run claude login"})]}),d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:n.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Available Models"}),d.jsx("div",{className:"flex flex-wrap gap-1",children:A.map($=>d.jsx("span",{className:"text-[12px] px-2 py-0.5 rounded",style:{background:e.color+"15",color:e.color,fontFamily:"'Geist Mono', monospace"},children:$.label},$.id))})]}),d.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[d.jsxs("button",{type:"button",onClick:P,disabled:C,className:"nodrag nowheel flex items-center gap-1.5 text-[14px] px-3 py-1.5 rounded-lg cursor-pointer font-semibold border-none",style:{background:"#FE5000",color:"#fff",opacity:C?.6:1},children:[C?d.jsx(yt,{size:12,className:"animate-spin"}):d.jsx(dv,{size:12}),"Check Status"]}),d.jsx("button",{type:"button",onClick:P,disabled:C,className:"nodrag nowheel flex items-center gap-1 text-[13px] px-2.5 py-1.5 rounded-lg cursor-pointer border-none",style:{color:n.textSecondary,background:n.badgeBg,opacity:C?.6:1},children:"Refresh Models"})]})]}):d.jsxs(d.Fragment,{children:[I?d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex items-start gap-2 text-[14px] px-3 py-2.5 rounded-lg",style:{background:n.badgeBg,border:`1px solid ${n.borderSubtle}`},children:[d.jsx(hi,{size:14,style:{color:e.color,marginTop:1}}),d.jsx("span",{style:{color:n.textSecondary},children:"Codex browser sign-in (guided): open OpenAI dashboard, create key, and complete login flow."})]}),d.jsx("button",{type:"button",onClick:async()=>{try{const V=await(await fetch(`${Ee}/auth/codex/start`,{method:"POST"})).json(),X=V?.data?.sessionId,H=V?.data?.authUrl;if(!X||!H)return;window.open(H,"_blank","noopener,noreferrer");const _=window.prompt("Paste your OpenAI API key to complete Codex login");if(!_)return;const G=(await(await fetch(`${Ee}/auth/codex/complete/${X}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:_.trim()})})).json())?.data?.apiKey;if(!G)return;b(e.id,G),p(G),k(e.id,f),N(e.id),await P()}catch{}},className:"nodrag nowheel flex items-center justify-center gap-1.5 text-[14px] px-3 py-2 rounded-lg cursor-pointer font-semibold border-none",style:{background:"#FE5000",color:"#fff"},children:"Sign in with Codex"})]}):d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:n.textMuted,fontFamily:"'Geist Mono', monospace"},children:"API Key"}),d.jsxs("div",{className:"relative",children:[d.jsx("input",{type:i?"text":"password",value:c,onChange:$=>p($.target.value),onBlur:L,placeholder:e._hasStoredKey?"Key stored on server":"sk-...",className:"nodrag nowheel w-full text-[14px] px-3 py-2 pr-9 rounded-lg outline-none",style:W}),d.jsx("button",{type:"button",onClick:()=>l(!i),className:"nodrag nowheel absolute right-2 top-1/2 -translate-y-1/2 cursor-pointer border-none bg-transparent p-0.5",style:{color:n.textDim},children:i?d.jsx(BN,{size:14}):d.jsx(HN,{size:14})})]})]}),d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:n.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Base URL"}),d.jsx("input",{type:"text",value:f,onChange:$=>m($.target.value),onBlur:L,className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none",style:W})]}),d.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[d.jsxs("button",{type:"button",onClick:P,disabled:C,className:"nodrag nowheel flex items-center gap-1.5 text-[14px] px-3 py-1.5 rounded-lg cursor-pointer font-semibold border-none",style:{background:"#FE5000",color:"#fff",opacity:C?.6:1},children:[C?d.jsx(yt,{size:12,className:"animate-spin"}):d.jsx(zi,{size:12}),"Test Connection"]}),d.jsx("button",{type:"button",onClick:P,disabled:C,className:"nodrag nowheel flex items-center gap-1 text-[13px] px-2.5 py-1.5 rounded-lg cursor-pointer border-none",style:{color:n.textSecondary,background:n.badgeBg,opacity:C?.6:1},children:"Refresh Models"}),e.keyPageUrl&&!I&&d.jsxs("a",{href:e.keyPageUrl,target:"_blank",rel:"noopener noreferrer",className:"nodrag nowheel flex items-center gap-1 text-[13px] px-2 py-1.5 rounded-lg no-underline",style:{color:n.textSecondary,background:n.badgeBg},children:[d.jsx(tv,{size:10}),"Get API Key"]}),S&&d.jsxs("button",{type:"button",onClick:()=>M(e.id),className:"nodrag nowheel flex items-center gap-1 text-[13px] px-2 py-1.5 rounded-lg cursor-pointer border-none ml-auto",style:{color:n.statusError,background:n.statusErrorBg},children:[d.jsx(uu,{size:10}),"Remove"]})]}),g&&d.jsxs("div",{className:"flex items-center gap-2 text-[14px] px-3 py-2 rounded-lg",style:{background:g.ok?n.statusSuccessBg:n.statusErrorBg,border:`1px solid ${g.ok?n.statusSuccess+"30":n.statusError+"30"}`,color:g.ok?n.statusSuccess:n.statusError},children:[g.ok?d.jsx(Hc,{size:14}):d.jsx(mi,{size:14}),g.ok?`Connected${g.models?` — ${g.models.length} models available`:""}`:g.error||"Connection failed"]})]}),e.headerNote&&d.jsx("span",{className:"text-[12px]",style:{color:n.textFaint},children:e.headerNote})]})]})}function jA(){const e=we(),n=Qe(s=>s.providers),a=Qe(s=>s.addCustomProvider);return d.jsxs("div",{className:"flex flex-col",children:[d.jsx("div",{className:"flex flex-col",children:n.filter((s,i,l)=>l.findIndex(c=>c.id===s.id)===i).map(s=>d.jsx(EA,{provider:s},s.id))}),d.jsx("div",{className:"p-4",children:d.jsxs("button",{type:"button",onClick:a,className:"nodrag nowheel flex items-center gap-2 text-[14px] px-3 py-2 rounded-lg cursor-pointer w-full justify-center",style:{border:`1px dashed ${e.border}`,background:"transparent",color:e.textMuted},children:[d.jsx(bt,{size:12}),"Add Custom Provider"]})})]})}function TA({server:e}){const n=we(),[a,s]=z.useState(!1),[i,l]=z.useState(e.name),[c,p]=z.useState(e.command),[f,m]=z.useState(e.args.join(`
131
+ `)),[g,x]=z.useState(Object.entries(e.env).map(([P,W])=>`${P}=${W}`).join(`
132
+ `)),[b,v]=z.useState(!1),[k,w]=z.useState(!1),C=at(P=>P.connectServer),M=at(P=>P.disconnectServer),N=at(P=>P.updateServer),S=at(P=>P.removeServer),E=se(P=>P.upsertMcpServer),I=se(P=>P.removeMcpServer);z.useEffect(()=>{l(e.name),p(e.command),m(e.args.join(`
133
+ `)),x(Object.entries(e.env).map(([P,W])=>`${P}=${W}`).join(`
134
+ `))},[e.name,e.command,e.args,e.env]);const D=z.useCallback(()=>{e.status==="connected"?M(e.id):C(e.id)},[e.id,e.status,C,M]),A=z.useCallback(async()=>{v(!0),w(!1);const P=f.split(`
135
+ `).map(X=>X.trim()).filter(Boolean),W={};for(const X of g.split(`
136
+ `)){const[H,..._]=X.split("=");H?.trim()&&_.length>0&&(W[H.trim()]=_.join("=").trim())}const $=e.status==="connected",V=await N(e.id,{name:i.trim(),command:c.trim(),args:P,env:W});V&&(E({id:V.id,name:V.name,description:V.command,connected:V.status==="connected"}),$&&await C(e.id),w(!0),setTimeout(()=>w(!1),1500)),v(!1)},[f,c,g,i,e.id,e.status,N,E,C]),L={background:n.inputBg,border:`1px solid ${n.border}`,color:n.textPrimary,fontFamily:"'Geist Sans', sans-serif"};return d.jsxs("div",{style:{background:a?n.surfaceElevated:"transparent",borderBottom:`1px solid ${n.borderSubtle}`},children:[d.jsxs("div",{role:"button",tabIndex:0,className:"nodrag nowheel w-full flex items-center gap-3 px-4 py-3 cursor-pointer border-none bg-transparent text-left",onClick:()=>s(!a),style:{color:n.textPrimary},children:[d.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:Gc(e.status,n),boxShadow:`0 0 6px ${Gc(e.status,n)}40`}}),d.jsx(u4,{size:14,style:{color:n.textDim}}),d.jsxs("div",{className:"flex-1",children:[d.jsxs("div",{className:"text-[14px] font-semibold",style:{color:n.textPrimary,fontFamily:"'Geist Mono', monospace"},children:[e.name,e.mcpStatus&&e.mcpStatus!=="enabled"&&d.jsx("span",{className:"text-[12px] px-1.5 py-0.5 rounded ml-2 uppercase",style:{fontFamily:"'Geist Mono', monospace",fontWeight:600,background:e.mcpStatus==="deferred"?n.statusWarningBg:n.statusErrorBg,color:e.mcpStatus==="deferred"?n.statusWarning:n.statusError},children:e.mcpStatus})]}),d.jsx("div",{className:"text-[12px]",style:{color:n.textMuted},children:e.status==="connected"?`${e.tools.length} tools available`:e.status==="error"?e.lastError||"Connection error":"Not connected"})]}),d.jsxs("button",{type:"button",onClick:P=>{P.stopPropagation(),D()},className:"nodrag nowheel flex items-center gap-1 text-[13px] px-2.5 py-1 rounded-lg cursor-pointer border-none",style:{background:e.status==="connected"?n.statusErrorBg:n.statusSuccessBg,color:e.status==="connected"?n.statusError:n.statusSuccess},children:[e.status==="connecting"?d.jsx(yt,{size:10,className:"animate-spin"}):e.status==="connected"?d.jsx(dv,{size:10}):d.jsx(zi,{size:10}),e.status==="connecting"?"Connecting...":e.status==="connected"?"Disconnect":"Connect"]}),d.jsx(pm,{size:12,style:{color:n.textDim}})]}),a&&d.jsxs("div",{className:"px-4 pb-4 flex flex-col gap-3",children:[d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:n.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Name"}),d.jsx("input",{type:"text",value:i,onChange:P=>l(P.target.value),className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none",style:L})]}),d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:n.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Command"}),d.jsx("input",{type:"text",value:c,onChange:P=>p(P.target.value),className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none",style:L})]}),d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:n.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Arguments (one per line)"}),d.jsx("textarea",{value:f,onChange:P=>m(P.target.value),className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none resize-none",style:{...L,minHeight:"60px"},rows:3})]}),d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:n.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Environment (key=value, one per line)"}),d.jsx("textarea",{value:g,onChange:P=>x(P.target.value),className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none resize-none",style:{...L,minHeight:"60px"},rows:3})]}),e.tools.length>0&&d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:n.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Available Tools"}),d.jsx("div",{className:"flex flex-wrap gap-1",children:e.tools.map(P=>d.jsx("span",{className:"text-[12px] px-2 py-0.5 rounded",style:{background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace"},children:P.name},P.name))})]}),d.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[d.jsx("button",{type:"button",onClick:A,disabled:b,className:"nodrag nowheel flex items-center gap-1 text-[13px] px-2.5 py-1.5 rounded-lg cursor-pointer border-none",style:{color:"#fff",background:"#FE5000",opacity:b?.7:1},children:b?"Saving...":k?"Saved":"Save"}),d.jsxs("button",{type:"button",onClick:()=>{S(e.id),I(e.id)},className:"nodrag nowheel flex items-center gap-1 text-[13px] px-2.5 py-1.5 rounded-lg cursor-pointer border-none",style:{color:n.statusError,background:n.statusErrorBg},children:[d.jsx(uu,{size:10}),"Delete"]})]})]})]})}function NA(){const e=we(),n=se(W=>W.mcpServers),a=at(W=>W.servers),s=at(W=>W.loaded),i=at(W=>W.loading),l=at(W=>W.loadServers),c=at(W=>W.addServer),p=at(W=>W.error),f=se(W=>W.upsertMcpServer),m=n.map(W=>{const $=a.find(V=>V.id===W.id);return{...W,status:$?.status||"disconnected",tools:$?.tools||[],lastError:$?.lastError||void 0,command:$?.command||W.description||"",args:$?.args||[],env:$?.env||{}}}),g=a.filter(W=>!n.some($=>$.id===W.id)).map(W=>({...W,isRuntimeOnly:!0})),x=[...m,...g],[b,v]=z.useState(!1),[k,w]=z.useState(""),[C,M]=z.useState(""),[N,S]=z.useState(""),[E,I]=z.useState(""),[D,A]=z.useState(!1);z.useEffect(()=>{!s&&!i&&l()},[s,i,l]),z.useEffect(()=>{for(const W of m)f({id:W.id,name:W.name,description:W.description||W.command,connected:W.status==="connected"})},[m,f]);const L=z.useCallback(async()=>{if(!(!k.trim()||!C.trim())){A(!0);try{const W=N.split(`
137
+ `).filter(X=>X.trim()).map(X=>X.trim()),$={};E.split(`
138
+ `).forEach(X=>{const[H,..._]=X.split("=");H?.trim()&&_.length>0&&($[H.trim()]=_.join("=").trim())});const V=await c({name:k.trim(),command:C.trim(),args:W,env:$});V&&f({id:V.id,name:V.name,description:V.command,connected:V.status==="connected"}),w(""),M(""),S(""),I(""),v(!1)}finally{A(!1)}}},[k,C,N,E,c,f]),P={background:e.inputBg,border:`1px solid ${e.border}`,color:e.textPrimary,fontFamily:"'Geist Sans', sans-serif"};return d.jsxs("div",{className:"flex flex-col",children:[i&&d.jsxs("div",{className:"px-4 py-8 text-center text-[14px]",style:{color:e.textMuted},children:[d.jsx(yt,{size:16,className:"animate-spin mx-auto mb-2"}),"Loading MCP servers..."]}),p&&d.jsx("div",{className:"mx-4 mt-3 px-3 py-2 rounded-lg text-[14px]",style:{background:e.statusErrorBg,color:e.statusError,border:`1px solid ${e.statusError}30`},children:p}),s&&x.map(W=>d.jsx(TA,{server:W},W.id)),s&&x.length===0&&!b&&d.jsx("div",{className:"px-4 py-8 text-center text-[14px]",style:{color:e.textMuted},children:"No MCP servers configured. Add a server below."}),b&&d.jsxs("div",{className:"p-4",style:{borderTop:`1px solid ${e.borderSubtle}`,background:e.surfaceElevated},children:[d.jsx("div",{className:"text-[14px] font-semibold mb-3",style:{color:e.textPrimary,fontFamily:"'Geist Mono', monospace"},children:"Add MCP Server"}),d.jsxs("div",{className:"flex flex-col gap-3",children:[d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:e.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Name"}),d.jsx("input",{type:"text",value:k,onChange:W=>w(W.target.value),placeholder:"My MCP Server",className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none",style:P})]}),d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:e.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Command"}),d.jsx("input",{type:"text",value:C,onChange:W=>M(W.target.value),placeholder:"uv",className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none",style:P})]}),d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:e.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Arguments (one per line)"}),d.jsx("textarea",{value:N,onChange:W=>S(W.target.value),placeholder:`tool
139
+ run
140
+ --python
141
+ /path/to/server.py`,className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none resize-none",style:{...P,minHeight:"60px"},rows:3})]}),d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:e.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Environment (key=value, one per line)"}),d.jsx("textarea",{value:E,onChange:W=>I(W.target.value),placeholder:`API_KEY=your_key
142
+ DEBUG=1`,className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none resize-none",style:{...P,minHeight:"60px"},rows:3})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs("button",{type:"button",onClick:L,disabled:D||!k.trim()||!C.trim(),className:"nodrag nowheel flex items-center gap-1.5 text-[14px] px-3 py-1.5 rounded-lg cursor-pointer font-semibold border-none",style:{background:"#FE5000",color:"#fff",opacity:D||!k.trim()||!C.trim()?.6:1},children:[D?d.jsx(yt,{size:12,className:"animate-spin"}):d.jsx(bt,{size:12}),"Add Server"]}),d.jsx("button",{type:"button",onClick:()=>v(!1),className:"nodrag nowheel text-[14px] px-3 py-1.5 rounded-lg cursor-pointer border-none",style:{color:e.textMuted,background:e.badgeBg},children:"Cancel"})]})]})]}),s&&!b&&d.jsx("div",{className:"p-4",children:d.jsxs("button",{type:"button",onClick:()=>v(!0),className:"nodrag nowheel flex items-center gap-2 text-[14px] px-3 py-2 rounded-lg cursor-pointer w-full justify-center",style:{border:`1px dashed ${e.border}`,background:"transparent",color:e.textMuted},children:[d.jsx(bt,{size:12}),"Add MCP Server"]})})]})}function AA(){const e=we(),n=Pc(N=>N.theme),a=Pc(N=>N.toggleTheme),[s,i]=z.useState(()=>localStorage.getItem("modular-edge-style")||"smoothstep"),[l,c]=z.useState(()=>localStorage.getItem("modular-grid-snap")!=="false"),[p,f]=z.useState(()=>localStorage.getItem("modular-minimap")!=="false"),[m,g]=z.useState(()=>localStorage.getItem("modular-bg-style")||"dots"),x=(N,S)=>localStorage.setItem(N,S),b=[{id:"system",label:"System",icon:P3},{id:"light",label:"Light",icon:fv},{id:"dark",label:"Dark",icon:rv}],v=[{id:"smoothstep",label:"SmoothStep",icon:R4},{id:"bezier",label:"Bezier",icon:Us},{id:"step",label:"Step",icon:W5}],k=[{id:"dots",label:"Dots"},{id:"lines",label:"Lines"},{id:"none",label:"None"}],w={color:e.textMuted,fontFamily:"'Geist Mono', monospace"},C={borderBottom:`1px solid ${e.borderSubtle}`},M=N=>{(N==="light"?"light":"dark")!==n&&a(),x("modular-theme",N)};return d.jsxs("div",{className:"flex flex-col",children:[d.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:C,children:[d.jsx("span",{className:"text-[12px] tracking-wider uppercase",style:w,children:"Theme"}),d.jsx("div",{className:"flex gap-1",children:b.map(N=>{const S=N.id==="system"&&n==="dark"&&localStorage.getItem("modular-theme")==="system"||N.id===n;return d.jsxs("button",{type:"button",onClick:()=>M(N.id),className:"nodrag nowheel flex items-center gap-1 text-[13px] px-2.5 py-1 rounded-md cursor-pointer border-none",style:{background:S?"#FE500020":e.badgeBg,color:S?"#FE5000":e.textDim},children:[d.jsx(N.icon,{size:11}),N.label]},N.id)})})]}),d.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:C,children:[d.jsx("span",{className:"text-[12px] tracking-wider uppercase",style:w,children:"Edge Routing"}),d.jsx("div",{className:"flex gap-1",children:v.map(N=>d.jsxs("button",{type:"button",onClick:()=>{i(N.id),x("modular-edge-style",N.id)},className:"nodrag nowheel flex items-center gap-1 text-[13px] px-2.5 py-1 rounded-md cursor-pointer border-none",style:{background:s===N.id?"#FE500020":e.badgeBg,color:s===N.id?"#FE5000":e.textDim},children:[d.jsx(N.icon,{size:11}),N.label]},N.id))})]}),d.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:C,children:[d.jsx("span",{className:"text-[12px] tracking-wider uppercase",style:w,children:"Grid Snap"}),d.jsx("button",{type:"button",onClick:()=>{const N=!l;c(N),x("modular-grid-snap",String(N))},className:"nodrag nowheel w-9 h-5 rounded-full cursor-pointer border-none relative transition-colors",style:{background:l?"#FE5000":e.badgeBg},children:d.jsx("div",{className:"absolute top-0.5 w-4 h-4 rounded-full transition-transform",style:{background:"#fff",left:l?"18px":"2px",boxShadow:"0 1px 3px rgba(0,0,0,0.3)"}})})]}),d.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:C,children:[d.jsx("span",{className:"text-[12px] tracking-wider uppercase",style:w,children:d.jsxs("span",{className:"flex items-center gap-1.5",children:[d.jsx(cm,{size:11})," Minimap"]})}),d.jsx("button",{type:"button",onClick:()=>{const N=!p;f(N),x("modular-minimap",String(N))},className:"nodrag nowheel w-9 h-5 rounded-full cursor-pointer border-none relative transition-colors",style:{background:p?"#FE5000":e.badgeBg},children:d.jsx("div",{className:"absolute top-0.5 w-4 h-4 rounded-full transition-transform",style:{background:"#fff",left:p?"18px":"2px",boxShadow:"0 1px 3px rgba(0,0,0,0.3)"}})})]}),d.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:C,children:[d.jsx("span",{className:"text-[12px] tracking-wider uppercase",style:w,children:d.jsxs("span",{className:"flex items-center gap-1.5",children:[d.jsx(o3,{size:11})," Background"]})}),d.jsx("div",{className:"flex gap-1",children:k.map(N=>d.jsx("button",{type:"button",onClick:()=>{g(N.id),x("modular-bg-style",N.id)},className:"nodrag nowheel text-[13px] px-2.5 py-1 rounded-md cursor-pointer border-none",style:{background:m===N.id?"#FE500020":e.badgeBg,color:m===N.id?"#FE5000":e.textDim},children:N.label},N.id))})]})]})}function _A({open:e,onClose:n}){const a=we(),s=se(f=>f.activeSettingsTab),[i,l]=z.useState(s||"providers");z.useEffect(()=>{e&&s&&l(s)},[e,s]);const c=z.useRef(null),p=z.useCallback(f=>{if(f.key!=="Tab"||!c.current)return;const m=c.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(m.length===0)return;const g=m[0],x=m[m.length-1];f.shiftKey?document.activeElement===g&&(f.preventDefault(),x.focus()):document.activeElement===x&&(f.preventDefault(),g.focus())},[]);return z.useEffect(()=>{if(!e)return;const f=m=>{m.key==="Escape"&&n()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[e,n]),e?d.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center",onClick:n,children:[d.jsx("div",{className:"absolute inset-0",style:{background:a.isDark?"rgba(0,0,0,0.7)":"rgba(0,0,0,0.35)",backdropFilter:"blur(12px)"}}),d.jsxs("div",{ref:c,role:"dialog","aria-modal":"true","aria-label":"Settings",className:"relative w-[560px] max-h-[80vh] rounded-xl overflow-hidden flex flex-col",style:{background:a.surfaceOpaque,border:`1px solid ${a.border}`,boxShadow:"0 24px 48px rgba(0,0,0,0.4)"},onClick:f=>f.stopPropagation(),onKeyDown:p,children:[d.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b shrink-0",style:{borderColor:a.borderSubtle},children:[d.jsx("span",{className:"text-[14px] tracking-wider uppercase flex-1 font-bold",style:{color:a.textPrimary,fontFamily:"'Geist Mono', monospace"},children:"Settings"}),d.jsx("button",{type:"button",onClick:n,className:"nodrag nowheel cursor-pointer border-none bg-transparent p-1 rounded-md",style:{color:a.textDim},"aria-label":"Close settings",children:d.jsx(jt,{size:14})})]}),d.jsx("div",{className:"flex gap-1 px-4 pt-2 border-b shrink-0 overflow-x-auto",style:{borderColor:a.borderSubtle,scrollbarWidth:"none"},children:MA.map(f=>d.jsx("button",{type:"button",onClick:()=>l(f.id),className:"nodrag nowheel text-[13px] tracking-wider uppercase px-3 py-2 cursor-pointer border-none bg-transparent font-semibold",style:{color:i===f.id?"#FE5000":a.textDim,borderBottom:i===f.id?"2px solid #FE5000":"2px solid transparent",fontFamily:"'Geist Mono', monospace",marginBottom:"-1px"},children:f.label},f.id))}),d.jsxs("div",{className:"flex-1 overflow-y-auto",style:{scrollbarWidth:"thin"},children:[i==="providers"&&d.jsx(jA,{}),i==="mcp"&&d.jsx(NA,{}),i==="general"&&d.jsx(AA,{})]})]})]}):null}const Av="modular-agent-library-v1";function rf(){return`${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function DA(){try{const e=localStorage.getItem(Av);if(!e)return[];const n=JSON.parse(e);return Array.isArray(n)?n:[]}catch{return[]}}function Ux(e){try{localStorage.setItem(Av,JSON.stringify(e))}catch{}}const zA=qt((e,n)=>({agents:[],agentLibrary:DA(),sharedFacts:[],edges:[],activeAgentId:null,addAgent:a=>e(s=>({agents:[...s.agents,{...a,factIds:[],knowledgeSourceIds:[],mcpServerIds:[],skillIds:[]}]})),addAgentFromLibrary:a=>{const s=n().agentLibrary.find(l=>l.id===a);if(!s)return;n().addAgent({id:`${s.id}-${Date.now()}`,name:s.name,description:s.description,avatar:s.avatar,version:s.version});const i=n().agents[n().agents.length-1]?.id;i&&n().updateAgent(i,{mcpServerIds:s.mcpServerIds,skillIds:s.skillIds})},addAgentFromBackend:a=>{(async()=>{try{const s=await fetch(`${Ee}/agents/${encodeURIComponent(a)}`);if(!s.ok)return;const i=await s.json(),l=i.data??i,c=l.agentMeta??{};n().addAgent({id:`${a}-${Date.now()}`,name:c.name||a,description:c.description||"",avatar:c.avatar||"bot",version:l.version||"1.0.0"});const p=n().agents[n().agents.length-1]?.id;if(!p)return;n().updateAgent(p,{mcpServerIds:(l.mcpServers??[]).map(f=>f.id),skillIds:(l.skills??[]).map(f=>f.id)})}catch{}})()},upsertLibraryAgent:a=>e(s=>{const i=s.agentLibrary.some(l=>l.id===a.id)?s.agentLibrary.map(l=>l.id===a.id?a:l):[...s.agentLibrary,a];return Ux(i),{agentLibrary:i}}),removeLibraryAgent:a=>e(s=>{const i=s.agentLibrary.filter(l=>l.id!==a);return Ux(i),{agentLibrary:i}}),removeAgent:a=>e(s=>({agents:s.agents.filter(i=>i.id!==a),edges:s.edges.filter(i=>i.fromAgentId!==a&&i.toAgentId!==a)})),updateAgent:(a,s)=>e(i=>({agents:i.agents.map(l=>l.id===a?{...l,...s}:l)})),setActiveAgent:a=>e({activeAgentId:a}),addSharedFact:(a,s,i,l=[])=>{const c=`sf-${rf()}`;return e(p=>({sharedFacts:[...p.sharedFacts,{id:c,content:a,scope:s,originAgentId:i,sharedWith:[],tags:l,timestamp:Date.now()}]})),c},removeSharedFact:a=>e(s=>({sharedFacts:s.sharedFacts.filter(i=>i.id!==a)})),propagateFact:(a,s)=>e(i=>({sharedFacts:i.sharedFacts.map(l=>l.id===a?{...l,sharedWith:[...new Set([...l.sharedWith,...s])]}:l),edges:[...i.edges,...s.filter(l=>!i.edges.some(c=>c.type==="fact_propagation"&&c.fromAgentId===i.sharedFacts.find(p=>p.id===a)?.originAgentId&&c.toAgentId===l)).map(l=>({id:`edge-${rf()}`,fromAgentId:i.sharedFacts.find(c=>c.id===a)?.originAgentId||"",toAgentId:l,type:"fact_propagation",label:"shared fact"}))]})),markFactPromoted:(a,s,i)=>e(l=>({sharedFacts:l.sharedFacts.map(c=>c.id===a?{...c,promotedTo:{agentId:s,target:i,at:Date.now()}}:c)})),addEdge:a=>e(s=>({edges:[...s.edges,{...a,id:`edge-${rf()}`}]})),removeEdge:a=>e(s=>({edges:s.edges.filter(i=>i.id!==a)})),getAgentFacts:a=>n().sharedFacts.filter(s=>s.originAgentId===a),getSharedFactsForAgent:a=>n().sharedFacts.filter(s=>s.scope==="global"||s.originAgentId===a||s.sharedWith.includes(a))}));function RA(e){return{...e}}const $A={"claude-opus-4":"claude-opus-4","claude-sonnet-4":"claude-sonnet-4","claude-haiku-3.5":"claude-haiku-3.5","gpt-4o":"gpt-4o","gpt-4.1":"gpt-4.1"};function _v(e,n){if(!e||!e.persona&&!e.objectives.primary&&!e.constraints.customConstraints)return n||"You are an analyst combining multiple knowledge sources to produce structured output.";const a=[];e.persona&&a.push(`You are ${e.persona}.`),e.tone!=="neutral"&&a.push(`Use a ${e.tone} tone.`),e.objectives.primary&&a.push(`
143
+ Primary objective: ${e.objectives.primary}`),e.objectives.successCriteria.length>0&&a.push("Success criteria: "+e.objectives.successCriteria.join("; "));const s=[];return e.constraints.neverMakeUp&&s.push("Never make up information"),e.constraints.askBeforeActions&&s.push("Ask before taking actions"),e.constraints.stayInScope&&s.push(`Stay in scope${e.constraints.scopeDefinition?": "+e.constraints.scopeDefinition:""}`),e.constraints.useOnlyTools&&s.push("Only use provided tools"),e.constraints.limitWords&&s.push(`Keep responses under ${e.constraints.wordLimit} words`),e.constraints.customConstraints&&s.push(e.constraints.customConstraints),s.length>0&&a.push(`
144
+ Constraints:
145
+ `+s.map(i=>`- ${i}`).join(`
146
+ `)),n&&a.push(`
147
+ `+n),a.join(`
148
+ `)}function Ks(e){const n=e.channels.filter(C=>C.enabled),a=$A[e.selectedModel]??e.selectedModel,s=e.agentMeta.name||qA(e.prompt,n),i=e.agentMeta.description||KA(e.prompt,n),l=e.skills.filter(C=>C.enabled&&C.added),c=e.mcpServers.filter(C=>C.enabled&&C.added),p=l.map(C=>C.name),f=c.map(C=>({name:C.name,transport:"stdio",command:`npx @${C.name.toLowerCase().replace(/\s+/g,"")}hq/mcp`})),m=n.map(C=>C.path),g=e.outputFormats.length>0?e.outputFormats:[e.outputFormat],x=[],b=_v(e.instructionState,e.prompt);x.push(b);const v=e.agentConfig?.temperature??.7,k=e.agentConfig?.planningMode??"single-shot",w=[...(e.connectors??[]).filter(C=>C.enabled).map(C=>({service:C.service,direction:C.direction,config:C.config,type:"connector"})),...(e.mcpServers??[]).filter(C=>C.enabled!==!1).map(C=>({service:C.name||C.id,type:"mcp",id:C.id}))];return{name:s,description:i,model:a,icon:e.agentMeta.icon||"brain",category:e.agentMeta.category||"general",temperature:v,planningMode:k,tools:p,mcp_servers:f,reads:m,output_format:g,token_budget:e.tokenBudget,prompt:e.prompt,system:x.join(`
149
+
150
+ `),connections:w}}function On(e){return e.includes(`
151
+ `)||e.includes(":")||e.includes("#")||e.includes('"')?`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:e}function OA(e){const n=["---"];if(n.push(`name: ${On(e.name)}`),n.push(`description: ${On(e.description)}`),n.push(`model: ${e.model}`),n.push(`temperature: ${e.temperature}`),n.push(`icon: ${e.icon}`),n.push(`category: ${e.category}`),e.tools.length>0){n.push("tools:");for(const a of e.tools)n.push(` - ${a}`)}if(e.mcp_servers.length>0){n.push("mcp_servers:");for(const a of e.mcp_servers)n.push(` - name: ${On(a.name)}`),n.push(` transport: ${a.transport}`),a.command&&n.push(` command: ${On(a.command)}`)}if(e.reads.length>0){n.push("reads:");for(const a of e.reads)n.push(` - ${On(a)}`)}if(e.output_format.length>0){n.push("output_format:");for(const a of e.output_format)n.push(` - ${a}`)}return n.push(`token_budget: ${e.token_budget}`),n.push("---"),n.join(`
152
+ `)}function FA(e,n){const a=n.channels.filter(p=>p.enabled),s=n.instructionState,i=n.workflowSteps,l=[""];if(s?.persona&&(l.push("## Persona"),l.push(s.persona),s.tone!=="neutral"&&l.push(`
153
+ Tone: ${s.tone}`),s.expertise!==3&&l.push(`Expertise level: ${s.expertise}/5`),l.push("")),l.push("## Role"),l.push(e.system),l.push(""),s?.objectives.primary){if(l.push("## Objectives"),l.push(`**Primary:** ${s.objectives.primary}`),s.objectives.successCriteria.length>0){l.push(`
154
+ **Success Criteria:**`);for(const p of s.objectives.successCriteria)l.push(`- ${p}`)}if(s.objectives.failureModes.length>0){l.push(`
155
+ **Failure Modes:**`);for(const p of s.objectives.failureModes)l.push(`- ${p}`)}l.push("")}if(s){const p=[];if(s.constraints.neverMakeUp&&p.push("Never make up information"),s.constraints.askBeforeActions&&p.push("Ask before taking actions"),s.constraints.stayInScope&&p.push(`Stay in scope${s.constraints.scopeDefinition?": "+s.constraints.scopeDefinition:""}`),s.constraints.useOnlyTools&&p.push("Only use provided tools"),s.constraints.limitWords&&p.push(`Keep responses under ${s.constraints.wordLimit} words`),s.constraints.customConstraints&&p.push(s.constraints.customConstraints),p.length>0){l.push("## Constraints");for(const f of p)l.push(`- ${f}`);l.push("")}}if(e.prompt&&(l.push("## Default Prompt"),l.push(e.prompt),l.push("")),l.push("## Workflow"),i&&i.length>0)i.forEach((p,f)=>{const m=`${f+1}. ${p.label}`,g=p.action?` — ${p.action}`:"",x=p.condition!=="always"&&p.conditionText?` (${p.condition} ${p.conditionText})`:"";l.push(`${m}${g}${x}`)});else if(a.length>0){l.push("1. Read all knowledge sources");const p=new Map;for(const m of a){const g=m.knowledgeType;p.has(g)||p.set(g,[]),p.get(g).push(m)}let f=2;for(const[m,g]of p){const x=Zo[m];if(x){const b=g.map(v=>v.name).join(", ");l.push(`${f}. Process ${x.label.toLowerCase()} sources: ${b}`),f++}}l.push(`${f}. Synthesize findings`),l.push(`${f+1}. Generate output`)}else l.push("1. Analyze the provided context"),l.push("2. Identify patterns and key insights"),l.push("3. Synthesize findings"),l.push("4. Generate output");l.push("");const c=n.outputFormats.map(p=>lb.find(m=>m.id===p)?.label??p);return l.push("## Output Format"),l.push(c.length>0?c.join(", "):"Markdown"),l.push(""),l.join(`
156
+ `)}function Dv(e){const n=Ks(e),a=OA(n),s=FA(n,e);return a+`
157
+ `+s}function IA(e){const n=Ks(e),a=[];if(a.push(`name: ${On(n.name)}`),a.push(`model: ${n.model}`),n.tools.length>0){a.push("tools:");for(const i of n.tools)a.push(` - ${i}`)}if(n.mcp_servers.length>0){a.push("mcp:");for(const i of n.mcp_servers)a.push(` ${i.name.toLowerCase().replace(/\s+/g,"-")}:`),i.command&&a.push(` command: ${On(i.command)}`)}if(n.reads.length>0){a.push("context_files:");for(const i of n.reads)a.push(` - ${On(i)}`)}const s=_v(e.instructionState,e.prompt);if(s){a.push("instructions: |");for(const i of s.split(`
158
+ `))a.push(` ${i}`)}return a.join(`
159
+ `)+`
160
+ `}function LA(e){const n=Ks(e),a={name:n.name,model:n.model,instructions:n.system,tools:n.tools,mcp_servers:n.mcp_servers.map(s=>({name:s.name,transport:s.transport})),context_files:n.reads};return JSON.stringify(a,null,2)}function BA(e){const n=Ks(e),a={};for(const i of n.mcp_servers)a[i.name.toLowerCase().replace(/\s+/g,"-")]={command:i.command||""};const s={template:n.name,agent:"claude-code",context_files:n.reads,mcp_config:a,tools:n.tools,output_format:n.output_format};return JSON.stringify(s,null,2)}function PA(e){const n=Ks(e),a=n.name.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""),s=[];if(s.push("agents:"),s.push(` ${a}:`),s.push(` model: ${n.model}`),s.push(` temperature: ${n.temperature}`),n.tools.length>0){s.push(" skills:");for(const i of n.tools)s.push(` - ${i}`)}if(n.mcp_servers.length>0){s.push(" mcp:"),s.push(" servers:");for(const i of n.mcp_servers){const l=i.name.toLowerCase().replace(/\s+/g,"-");s.push(` ${l}:`),i.command&&s.push(` command: ${On(i.command)}`)}}if(n.reads.length>0){s.push(" context:");for(const i of n.reads)s.push(` - ${On(i)}`)}return s.join(`
161
+ `)+`
162
+ `}function HA(e){const n=Ks(e),a=e.outputTemplateConfig?Object.fromEntries(Object.entries(e.outputTemplateConfig).map(([i,l])=>[i,RA(l)])):void 0,s={modular_version:"1.0",agent:{name:n.name,description:n.description,model:n.model,temperature:n.temperature,system_prompt:n.system,planning_mode:n.planningMode,knowledge:n.reads.map(i=>({path:i})),skills:n.tools,mcp_servers:n.mcp_servers,output_formats:n.output_format,token_budget:n.token_budget,connections:n.connections,...e.instructionState?{instructionState:e.instructionState}:{},...e.workflowSteps&&e.workflowSteps.length>0?{workflowSteps:e.workflowSteps}:{},...a&&Object.keys(a).length>0?{output:{templates:a}}:{}}};return JSON.stringify(s,null,2)}function UA(e){return Dv(e)}function ni(e,n){switch(e){case"claude":return Dv(n);case"amp":return IA(n);case"codex":return LA(n);case"vibe-kanban":return BA(n);case"openclaw":return PA(n);case"generic":return HA(n)}}const zv={claude:{name:"Claude Code",ext:".md",mime:"text/markdown"},amp:{name:"Amp",ext:".yaml",mime:"text/yaml"},codex:{name:"Codex",ext:".json",mime:"application/json"},"vibe-kanban":{name:"Vibe Kanban",ext:".json",mime:"application/json"},openclaw:{name:"OpenClaw",ext:".yaml",mime:"text/yaml"},generic:{name:"Generic JSON",ext:".json",mime:"application/json"}};function hu(e,n,a=".md"){const s={".md":"text/markdown",".json":"application/json",".yaml":"text/yaml"},i=new Blob([e],{type:s[a]||"text/plain"}),l=URL.createObjectURL(i),c=document.createElement("a");c.href=l,c.download=`${n}${a}`,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(l)}function GA(e){const n=(e.agentMeta.name||"modular-agent").toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""),a=["claude","amp","codex","vibe-kanban","openclaw","generic"];for(const s of a){const i=ni(s,e),l=zv[s],c=s==="claude"?n:`${n}-${s}`;hu(i,c,l.ext)}}function qA(e,n){if(e){const a=e.split(/\s+/).slice(0,4).join("-").toLowerCase().replace(/[^a-z0-9-]/g,"");if(a.length>3)return a}return n.length>0?n[0].name.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""):"modular-agent"}function KA(e,n){return e&&e.length>10?e.length>80?e.slice(0,77)+"...":e:`Analysis using ${n.length} sources via Modular`}function YA(){const e=se.getState();at.getState();const n={version:"1.0",kind:"agent",identity:{name:e.agentMeta.name||"modular-agent",display_name:e.agentMeta.name||void 0,description:e.agentMeta.description||void 0,avatar:e.agentMeta.avatar||void 0,author:"Modular Studio",tags:e.agentMeta.tags?.length>0?e.agentMeta.tags:void 0,agent_version:"1.0.0"},instructions:{},context:{}},a={};e.instructionState.persona&&(a.persona=e.instructionState.persona),e.instructionState.tone!=="neutral"&&(a.tone=e.instructionState.tone),e.instructionState.expertise!==3&&(a.expertise=e.instructionState.expertise);const s=[];e.instructionState.constraints.neverMakeUp&&s.push("Never fabricate information or make up facts"),e.instructionState.constraints.askBeforeActions&&s.push("Ask for permission before taking significant actions"),e.instructionState.constraints.stayInScope&&s.push(`Stay within defined scope: ${e.instructionState.constraints.scopeDefinition||"as specified"}`),e.instructionState.constraints.useOnlyTools&&s.push("Only use explicitly provided tools and capabilities"),e.instructionState.constraints.limitWords&&s.push(`Keep responses under ${e.instructionState.constraints.wordLimit} words`),e.instructionState.constraints.customConstraints&&s.push(e.instructionState.constraints.customConstraints),s.length>0&&(a.constraints=s),e.instructionState.objectives.primary&&(a.objectives={primary:e.instructionState.objectives.primary},e.instructionState.objectives.successCriteria.length>0&&(a.objectives.success_criteria=e.instructionState.objectives.successCriteria),e.instructionState.objectives.failureModes.length>0&&(a.objectives.failure_modes=e.instructionState.objectives.failureModes)),e.instructionState.constraints.scopeDefinition&&(a.scope=e.instructionState.constraints.scopeDefinition),n.instructions=a;const i={},l=e.channels.filter(f=>f.enabled);l.length>0&&(i.knowledge=l.map(f=>({type:"file",ref:f.path||f.name,knowledge_type:f.knowledgeType,depth:f.depth})));const c=e.skills.filter(f=>f.enabled);c.length>0&&(i.skills=c.map(f=>({ref:f.name,source:"registry"})));const p=e.mcpServers.filter(f=>f.enabled);return p.length>0&&(i.mcp_servers=p.map(f=>({name:f.name,description:f.description,transport:"stdio",command:void 0,env:void 0}))),n.context=i,e.workflowSteps.length>0&&(n.workflow={steps:e.workflowSteps.map(f=>({id:f.id,action:f.action,tool:f.tool||void 0,condition:f.condition!=="always"?f.condition:void 0}))}),jc(n)}function jc(e,n=0){const a=" ".repeat(n);return Array.isArray(e)?e.map(s=>`${a}- ${jc(s,0).trim()}`).join(`
163
+ `):typeof e=="object"&&e!==null?Object.entries(e).filter(([,s])=>s!=null).map(([s,i])=>{if(Array.isArray(i))return i.length===0?null:`${a}${s}:
164
+ ${jc(i,n+1)}`;if(typeof i=="object")return`${a}${s}:
165
+ ${jc(i,n+1)}`;{const l=typeof i=="string"&&(i.includes(`
166
+ `)||i.includes(":")||i.includes("#"))?`"${i.replace(/"/g,'\\"')}"`:String(i);return`${a}${s}: ${l}`}}).filter(Boolean).join(`
167
+ `):String(e)}const Gx=[{id:"brain",Icon:Ni},{id:"code",Icon:J1},{id:"search",Icon:lu},{id:"bar-chart-3",Icon:rm},{id:"pen-tool",Icon:cv},{id:"file-text",Icon:Di},{id:"globe",Icon:ov},{id:"layers",Icon:k3},{id:"zap",Icon:pn},{id:"database",Icon:_i},{id:"shield",Icon:fm},{id:"settings",Icon:pm},{id:"sparkles",Icon:La},{id:"target",Icon:cu},{id:"book-open",Icon:Z1},{id:"lightbulb",Icon:Uc},{id:"terminal",Icon:hi},{id:"box",Icon:sm},{id:"layout-grid",Icon:av},{id:"cpu",Icon:Ai}],VA=["coding","research","analysis","writing","data","design","domain-specific","general"],qx=[{id:"claude",name:"Claude Code",ext:".md",Icon:hi},{id:"amp",name:"Amp",ext:".yaml",Icon:pn},{id:"codex",name:"Codex",ext:".json",Icon:Ai},{id:"vibe-kanban",name:"Vibe Kanban",ext:".json",Icon:av},{id:"openclaw",name:"OpenClaw",ext:".yaml",Icon:iv},{id:"generic",name:"Generic JSON",ext:".json",Icon:sm}];function WA(){const e=se(O=>O.showSaveModal),n=se(O=>O.setShowSaveModal),a=se(O=>O.agentMeta),s=se(O=>O.setAgentMeta),i=se(O=>O.channels),l=se(O=>O.selectedModel),c=se(O=>O.outputFormat),p=se(O=>O.outputFormats),f=se(O=>O.prompt),m=se(O=>O.tokenBudget),g=se(O=>O.mcpServers),x=se(O=>O.skills),b=se(O=>O.exportTarget),v=se(O=>O.setExportTarget),k=se(O=>O.agentConfig),w=se(O=>O.connectors),C=se(O=>O.instructionState),M=se(O=>O.workflowSteps),N=zA(O=>O.upsertLibraryAgent),[S,E]=z.useState(!1),[I,D]=z.useState(!1),[A,L]=z.useState(!0),P=z.useRef(null),W=z.useRef(null),$=we(),V=z.useCallback(O=>{if(O.key!=="Tab"||!W.current)return;const Q=W.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(Q.length===0)return;const q=Q[0],ie=Q[Q.length-1];O.shiftKey?document.activeElement===q&&(O.preventDefault(),ie.focus()):document.activeElement===ie&&(O.preventDefault(),q.focus())},[]);z.useEffect(()=>{e?(D(!0),setTimeout(()=>P.current?.focus(),100)):D(!1)},[e]),z.useEffect(()=>{if(!e)return;const O=Q=>{Q.key==="Escape"&&n(!1)};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[e,n]);const X=z.useMemo(()=>({channels:i,selectedModel:l,outputFormat:c,outputFormats:p,prompt:f,tokenBudget:m,mcpServers:g,skills:x,agentMeta:a,agentConfig:k,connectors:w,instructionState:C,workflowSteps:M}),[i,l,c,p,f,m,g,x,a,k,w,C,M]),H=z.useMemo(()=>ni(b,X),[X,b]),_=O=>{L(!1),v(O),setTimeout(()=>L(!0),30)},T=()=>{const O=a.name||"modular-agent",Q=O.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");N({id:Q,name:O,description:a.description||"Saved from builder",avatar:a.avatar||"bot",version:"1.0.0",mcpServerIds:g.filter(pe=>pe.added).map(pe=>pe.id),skillIds:x.filter(pe=>pe.added).map(pe=>pe.id)});const q=bm();fetch(`${Ee}/agents/${encodeURIComponent(Q)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(q)}).catch(()=>{});const ie=zv[b];hu(H,Q,ie.ext)},B=async()=>{await navigator.clipboard.writeText(H),E(!0),setTimeout(()=>E(!1),2e3)},G=()=>{GA(X)},K=()=>{const O=YA(),q=(a.name||"modular-agent").toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""),ie=new Blob([O],{type:"text/yaml;charset=utf-8"}),pe=URL.createObjectURL(ie),me=document.createElement("a");me.href=pe,me.download=`${q}.yaml`,document.body.appendChild(me),me.click(),document.body.removeChild(me),URL.revokeObjectURL(pe)};if(!e)return null;const J=Gx.find(O=>O.id===a.icon),F=qx.find(O=>O.id===b);return d.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>n(!1),children:[d.jsx("div",{className:"absolute inset-0",style:{background:"rgba(0,0,0,0.7)",backdropFilter:"blur(4px)",opacity:I?1:0,transition:"opacity 0.15s ease"}}),d.jsxs("div",{ref:W,role:"dialog","aria-modal":"true","aria-label":"Save as agent",className:"relative flex flex-col rounded-xl overflow-hidden",style:{width:880,maxHeight:"85vh",background:$.surface,border:`1px solid ${$.border}`,boxShadow:"0 24px 48px rgba(0,0,0,0.4)",opacity:I?1:0,transform:I?"scale(1)":"scale(0.97)",transition:"opacity 0.15s ease, transform 0.15s ease"},onClick:O=>O.stopPropagation(),onKeyDown:V,children:[d.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5",style:{borderBottom:`1px solid ${$.borderSubtle}`},children:[d.jsx("span",{className:"text-[14px] font-bold tracking-[3px] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:$.textPrimary},children:"SAVE AS AGENT"}),d.jsx("button",{type:"button",onClick:()=>n(!1),className:"p-1 rounded-md cursor-pointer border-none",style:{background:"transparent",color:$.textMuted},"aria-label":"Close",children:d.jsx(jt,{size:16})})]}),d.jsx("div",{className:"flex gap-2 px-5 py-3",style:{borderBottom:`1px solid ${$.borderSubtle}`},children:qx.map(O=>{const Q=b===O.id;return d.jsxs("button",{type:"button",onClick:()=>_(O.id),className:"flex flex-col items-center gap-1 rounded-lg cursor-pointer border-none",style:{width:80,padding:"8px 4px",background:Q?"#FE500012":"transparent",border:Q?"1.5px solid #FE5000":`1.5px solid ${$.borderSubtle}`,transition:"all 0.12s ease"},children:[d.jsx(O.Icon,{size:18,style:{color:Q?"#FE5000":$.textMuted}}),d.jsx("span",{className:"text-[12px] font-semibold leading-tight text-center",style:{fontFamily:"'Geist Mono', monospace",color:Q?"#FE5000":$.textSecondary},children:O.name}),d.jsx("span",{className:"text-[13px] px-1.5 py-0.5 rounded",style:{fontFamily:"'Geist Mono', monospace",background:Q?"#FE500020":$.badgeBg,color:Q?"#FE5000":$.textDim},children:O.ext})]},O.id)})}),d.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[d.jsxs("div",{className:"flex flex-col",style:{width:340,borderRight:`1px solid ${$.borderSubtle}`},children:[d.jsxs("div",{className:"flex-1 overflow-y-auto p-5 flex flex-col gap-4",children:[d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx("label",{className:"text-[13px] font-semibold uppercase tracking-wider",style:{color:$.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Agent Name"}),d.jsx("input",{ref:P,type:"text",value:a.name,onChange:O=>s({name:O.target.value}),placeholder:"my-analysis-agent",className:"w-full outline-none text-[17px] rounded-lg px-3 py-2 nodrag",style:{background:$.inputBg,border:`1px solid ${$.border}`,color:$.textPrimary,fontFamily:"'Geist Sans', sans-serif"}})]}),d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx("label",{className:"text-[13px] font-semibold uppercase tracking-wider",style:{color:$.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Description"}),d.jsx("textarea",{value:a.description,onChange:O=>s({description:O.target.value}),placeholder:"Deep research and synthesis agent...",className:"w-full outline-none text-[17px] rounded-lg px-3 py-2 resize-none",rows:3,style:{background:$.inputBg,border:`1px solid ${$.border}`,color:$.textPrimary,fontFamily:"'Geist Sans', sans-serif",lineHeight:1.5}})]}),d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx("label",{className:"text-[13px] font-semibold uppercase tracking-wider",style:{color:$.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Icon"}),d.jsx("div",{className:"grid grid-cols-10 gap-1",children:Gx.map(({id:O,Icon:Q})=>d.jsx("button",{type:"button",onClick:()=>s({icon:O}),className:"flex items-center justify-center w-7 h-7 rounded-md cursor-pointer border-none",style:{background:a.icon===O?"#FE500020":"transparent",border:a.icon===O?"1px solid #FE500040":"1px solid transparent",color:a.icon===O?"#FE5000":$.textMuted,transition:"all 0.1s ease"},children:d.jsx(Q,{size:14})},O))})]}),d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx("label",{className:"text-[13px] font-semibold uppercase tracking-wider",style:{color:$.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Category"}),d.jsx("select",{value:a.category,onChange:O=>s({category:O.target.value}),className:"w-full outline-none text-[17px] rounded-lg px-3 py-2 cursor-pointer",style:{background:$.inputBg,border:`1px solid ${$.border}`,color:$.textPrimary,fontFamily:"'Geist Sans', sans-serif"},children:VA.map(O=>d.jsx("option",{value:O,children:O.charAt(0).toUpperCase()+O.slice(1).replace("-"," ")},O))})]})]}),d.jsxs("div",{className:"flex flex-col gap-2 px-5 py-4",style:{borderTop:`1px solid ${$.borderSubtle}`},children:[d.jsxs("div",{className:"flex gap-2",children:[d.jsxs("button",{type:"button",onClick:T,className:"flex items-center justify-center gap-1.5 flex-1 py-2 rounded-lg text-[14px] font-semibold tracking-wider uppercase cursor-pointer border-none",style:{background:"#FE5000",color:"#fff",boxShadow:"0 0 8px rgba(254,80,0,0.25)"},children:[d.jsx(iu,{size:13}),"Download"]}),d.jsxs("button",{type:"button",onClick:B,className:"flex items-center justify-center gap-1.5 flex-1 py-2 rounded-lg text-[14px] font-semibold tracking-wider uppercase cursor-pointer",style:{background:"transparent",border:`1px solid ${$.border}`,color:S?$.statusSuccess:$.textSecondary,transition:"color 0.15s ease"},children:[S?d.jsx(_t,{size:13}):d.jsx(ev,{size:13}),S?"Copied":"Copy"]})]}),d.jsxs("button",{type:"button",onClick:G,className:"flex items-center justify-center gap-1.5 w-full py-2 rounded-lg text-[14px] font-semibold tracking-wider uppercase cursor-pointer",style:{background:"transparent",border:`1px solid ${$.borderSubtle}`,color:$.textMuted},children:[d.jsx(iv,{size:13}),"Export All Targets"]}),d.jsxs("button",{type:"button",onClick:K,className:"flex items-center justify-center gap-1.5 w-full py-2 rounded-lg text-[14px] font-semibold tracking-wider uppercase cursor-pointer",style:{background:"transparent",border:`1px solid ${$.borderSubtle}`,color:$.textMuted},children:[d.jsx(Di,{size:13}),"Export as YAML"]})]})]}),d.jsxs("div",{className:"flex flex-col flex-1",style:{background:$.isDark?"#0d0d10":"#f5f5f8"},children:[d.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${$.borderSubtle}`},children:[d.jsxs("div",{className:"flex items-center gap-2",children:[J&&d.jsx(J.Icon,{size:14,style:{color:"#FE5000"}}),d.jsx("span",{className:"text-[14px] font-bold tracking-[2px] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:$.textMuted},children:"Preview"}),d.jsxs("span",{className:"text-[13px] px-1.5 py-0.5 rounded",style:{fontFamily:"'Geist Mono', monospace",background:"#FE500018",color:"#FE5000"},children:[F.name," ",F.ext]})]}),d.jsxs("span",{className:"text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:$.textDim},children:[H.split(`
168
+ `).length," lines"]})]}),d.jsx("div",{className:"flex-1 overflow-auto p-4",style:{opacity:A?1:0,transition:"opacity 0.12s ease"},children:d.jsx("pre",{className:"text-[14px] leading-relaxed whitespace-pre-wrap break-all m-0",style:{fontFamily:"'Geist Mono', monospace",color:$.textSecondary},children:H.split(`
169
+ `).map((O,Q)=>d.jsxs("div",{className:"flex",children:[d.jsx("span",{className:"inline-block text-right select-none shrink-0",style:{width:32,color:$.textFaint,marginRight:12},children:Q+1}),d.jsx("span",{style:{color:XA(O,b,$)},children:O||" "})]},Q))})})]})]})]})]})}function XA(e,n,a){return e.trim()?n==="codex"||n==="vibe-kanban"||n==="generic"?/^\s*"\w[\w_-]*"\s*:/.test(e)?"#67d4e8":/:\s*"[^"]*"\s*,?$/.test(e)?"#a8d4a0":/:\s*(\d+\.?\d*|true|false|null)\s*,?$/.test(e)?"#d4a86a":a.textSecondary:e==="---"?"#FE5000":e.startsWith("##")||e.startsWith("# ")?a.textPrimary:/^\s*#/.test(e)?a.isDark?"#666":"#999":/^\s*\w[\w_-]*\s*:/.test(e)?"#67d4e8":/^\s+-\s/.test(e)||/^\d+\./.test(e)?a.textSecondary:a.textMuted:a.textMuted}function ZA(){const e=se.getState();return{channels:e.channels,mcpServers:e.mcpServers,skills:e.skills,instructionState:{...e.instructionState},workflowSteps:[...e.workflowSteps],agentConfig:{...e.agentConfig},prompt:e.prompt,selectedModel:e.selectedModel}}function Kx(e,n){const a=[];e.instructionState.persona!==n.instructionState.persona&&n.instructionState.persona.length>0&&a.push({type:"major",category:"instruction",description:"Persona updated"}),e.instructionState.objectives.primary!==n.instructionState.objectives.primary&&a.push({type:"major",category:"instruction",description:"Primary objective changed"}),e.selectedModel!==n.selectedModel&&a.push({type:"major",category:"model",description:`Model → ${n.selectedModel}`}),e.instructionState.tone!==n.instructionState.tone&&a.push({type:"major",category:"instruction",description:`Tone → ${n.instructionState.tone}`});const s=e.channels.filter(N=>N.enabled).map(N=>N.sourceId),i=n.channels.filter(N=>N.enabled).map(N=>N.sourceId),l=i.filter(N=>!s.includes(N)),c=s.filter(N=>!i.includes(N));l.length>0&&a.push({type:"minor",category:"knowledge",description:`+${l.length} knowledge source(s)`}),c.length>0&&a.push({type:"minor",category:"knowledge",description:`-${c.length} knowledge source(s)`});const p=e.skills.filter(N=>N.added).map(N=>N.id),f=n.skills.filter(N=>N.added).map(N=>N.id),m=f.filter(N=>!p.includes(N)),g=p.filter(N=>!f.includes(N));m.length>0&&a.push({type:"minor",category:"skill",description:`+${m.length} skill(s)`}),g.length>0&&a.push({type:"minor",category:"skill",description:`-${g.length} skill(s)`});const x=e.mcpServers.filter(N=>N.added).map(N=>N.id),b=n.mcpServers.filter(N=>N.added).map(N=>N.id),v=b.filter(N=>!x.includes(N)),k=x.filter(N=>!b.includes(N));if(v.length>0&&a.push({type:"minor",category:"mcp",description:`+${v.length} MCP server(s)`}),k.length>0&&a.push({type:"minor",category:"mcp",description:`-${k.length} MCP server(s)`}),n.workflowSteps.length!==e.workflowSteps.length){const N=n.workflowSteps.length-e.workflowSteps.length;a.push({type:"minor",category:"workflow",description:`${N>0?"+":""}${N} workflow step(s)`})}const w=e.instructionState.objectives.successCriteria.length,C=n.instructionState.objectives.successCriteria.length;C!==w&&a.push({type:"minor",category:"instruction",description:`Success criteria ${C>w?"added":"removed"}`});const M=["neverMakeUp","askBeforeActions","stayInScope","useOnlyTools","limitWords"];for(const N of M)e.instructionState.constraints[N]!==n.instructionState.constraints[N]&&a.push({type:"patch",category:"instruction",description:`Constraint "${N}" toggled`});e.instructionState.constraints.customConstraints!==n.instructionState.constraints.customConstraints&&a.push({type:"patch",category:"instruction",description:"Custom constraints updated"}),e.instructionState.expertise!==n.instructionState.expertise&&a.push({type:"patch",category:"instruction",description:`Expertise level → ${n.instructionState.expertise}`}),e.prompt!==n.prompt&&a.push({type:"patch",category:"prompt",description:"Prompt text changed"});for(const N of n.channels){const S=e.channels.find(E=>E.sourceId===N.sourceId);S&&S.depth!==N.depth&&a.push({type:"patch",category:"knowledge",description:`"${N.name}" depth changed`})}if(n.workflowSteps.length===e.workflowSteps.length)for(let N=0;N<n.workflowSteps.length;N++){const S=e.workflowSteps[N],E=n.workflowSteps[N];if(S&&E&&(S.label!==E.label||S.action!==E.action||S.tool!==E.tool||S.condition!==E.condition)){a.push({type:"patch",category:"workflow",description:`Step "${E.label||N+1}" modified`});break}}return e.agentConfig.temperature!==n.agentConfig.temperature&&a.push({type:"patch",category:"config",description:`Temperature → ${n.agentConfig.temperature}`}),e.agentConfig.maxTokens!==n.agentConfig.maxTokens&&a.push({type:"patch",category:"config",description:`Max tokens → ${n.agentConfig.maxTokens}`}),a}function QA(e,n){const[a,s,i]=e.split(".").map(Number),l=n.some(f=>f.type==="major"),c=n.some(f=>f.type==="minor");if(l){const f={major:a+1,minor:0,patch:0};return{...f,version:`${f.major}.${f.minor}.${f.patch}`}}if(c){const f={major:a,minor:s+1,patch:0};return{...f,version:`${f.major}.${f.minor}.${f.patch}`}}const p={major:a,minor:s,patch:i+1};return{...p,version:`${p.major}.${p.minor}.${p.patch}`}}function JA(e){if(e.length===0)return"No changes";if(e.length===1)return e[0].description;const n=[...new Set(e.map(a=>a.category))];return`${e.length} changes (${n.join(", ")})`}const Ra=qt((e,n)=>({versions:[],currentVersion:"0.1.0",dirty:!1,autoVersion:!0,maxVersions:50,latestVersion:()=>{const a=n().versions;return a.length>0?a[a.length-1]:void 0},getVersion:a=>n().versions.find(s=>s.version===a),checkpoint:a=>{const s=ZA(),i=n().latestVersion()?.snapshot,l=i?Kx(i,s):[{type:"minor",category:"init",description:"Initial version"}];if(i&&l.length===0)return;const c=i?QA(n().currentVersion,l):{major:0,minor:1,patch:0,version:"0.1.0"},p={id:`v-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,version:c.version,major:c.major,minor:c.minor,patch:c.patch,timestamp:Date.now(),label:a||JA(l),changes:l,snapshot:s},f=[...n().versions,p].slice(-n().maxVersions);e({versions:f,currentVersion:c.version,dirty:!1})},restoreVersion:a=>{const s=n().getVersion(a);if(!s)return;const i=se.getState();i.clearChannels();for(const l of s.snapshot.channels)i.addChannel(l),l.enabled||i.toggleChannel(l.sourceId);i.setPrompt(s.snapshot.prompt),i.setModel(s.snapshot.selectedModel),i.updateInstruction({persona:s.snapshot.instructionState.persona,tone:s.snapshot.instructionState.tone,expertise:s.snapshot.instructionState.expertise,constraints:s.snapshot.instructionState.constraints,objectives:s.snapshot.instructionState.objectives,rawPrompt:s.snapshot.instructionState.rawPrompt,autoSync:s.snapshot.instructionState.autoSync}),i.updateWorkflowSteps(s.snapshot.workflowSteps),e({currentVersion:s.version,dirty:!1})},deleteVersion:a=>e({versions:n().versions.filter(s=>s.id!==a)}),setAutoVersion:a=>e({autoVersion:a}),setDirty:()=>e({dirty:!0}),_detectAndVersion:(a,s)=>{if(Kx(a,s).length===0||(e({dirty:!0}),!n().autoVersion))return;const l=n().latestVersion();l&&Date.now()-l.timestamp<2e3||n().checkpoint()}}));let gc=null,lf=null;se.subscribe(e=>{const n={channels:e.channels,mcpServers:e.mcpServers,skills:e.skills,instructionState:e.instructionState,workflowSteps:e.workflowSteps,agentConfig:e.agentConfig,prompt:e.prompt,selectedModel:e.selectedModel};if(!gc){gc=n;return}lf&&clearTimeout(lf);const a=gc;lf=setTimeout(()=>{Ra.getState()._detectAndVersion(a,n),gc=n},1500)});const e_={full:0,detail:1,summary:2,headlines:3,mention:4},t_={opus:"claude-opus-4",sonnet:"claude-sonnet-4",haiku:"claude-haiku-3.5","claude-opus-4":"claude-opus-4","claude-sonnet-4":"claude-sonnet-4","claude-haiku-3.5":"claude-haiku-3.5","gpt-4o":"gpt-4o","gpt-4.1":"gpt-4.1"},Yx=new Set(["markdown","html-slides","email","code","csv","json","diagram","slack"]);function n_(e){const n=e.trim();return n.startsWith("{")?o_(n):n.startsWith("---")?a_(n):s_(n)}function o_(e){let n;try{n=JSON.parse(e)}catch{return{}}if(n.modular_version&&n.agent){const s=n.agent,i=Qo({...s,system:s.system_prompt,reads:s.knowledge?.map(l=>l.path),output_format:s.output_formats,token_budget:s.token_budget});return i.detectedFormat="generic",s.instructionState&&(i.instructionState=s.instructionState),s.workflowSteps&&(i.workflowSteps=s.workflowSteps),i}if(n.template&&n.context_files){const s=Qo({name:n.template,reads:n.context_files,tools:n.tools,output_format:n.output_format});return s.detectedFormat="vibe-kanban",s}if(n.instructions&&!n.system){const s=Qo({...n,system:n.instructions,reads:n.context_files||n.reads});return s.detectedFormat="codex",s}const a=Qo(n);return a.detectedFormat="generic",a}function a_(e){const{frontmatter:n,body:a}=r_(e),s=Qo(n);if(s.detectedFormat="claude",!s.prompt){const p=a.match(/## Default Prompt\n([\s\S]*?)(?=\n## |$)/);p&&(s.prompt=p[1].trim())}if(!s.prompt){const p=a.match(/(?:##? Role)\n([\s\S]*?)(?=\n##? |$)/);p&&(s.prompt=p[1].trim())}if(!s.channels||s.channels.length===0){const p=l_(a);p.length>0&&(s.channels=p)}const i=a.match(/## Persona\n([\s\S]*?)(?=\n## |$)/),l=a.match(/## Constraints\n([\s\S]*?)(?=\n## |$)/),c=a.match(/## Objectives\n([\s\S]*?)(?=\n## |$)/);return(i||l||c)&&(s.instructionState={persona:i?i[1].trim():"",tone:"neutral",expertise:3,constraints:{neverMakeUp:!1,askBeforeActions:!1,stayInScope:!1,useOnlyTools:!1,limitWords:!1,wordLimit:500,customConstraints:l?l[1].trim():"",scopeDefinition:""},objectives:{primary:c?c[1].trim():"",successCriteria:[],failureModes:[]},rawPrompt:"",autoSync:!0}),s}function s_(e){const n=Rv(e);if(n.agents&&typeof n.agents=="object"&&!Array.isArray(n.agents)){const s=n.agents,i=Object.keys(s)[0];if(i){const l=s[i],c=Qo({name:i.replace(/-/g," "),model:l.model,temperature:l.temperature,tools:l.skills,reads:l.context});return c.detectedFormat="openclaw",c}}if(n.mcp&&typeof n.mcp=="object"&&!Array.isArray(n.mcp)){const s=Qo({...n,system:n.instructions,reads:n.context_files});return s.detectedFormat="amp",s}const a=Qo(n);return a.detectedFormat="amp",a}function Qo(e){const n={},a={name:zn(e.name)||"",description:zn(e.description)||"",icon:zn(e.icon)||"brain",category:zn(e.category)||"general",tags:Array.isArray(e.tags)?e.tags:[],avatar:zn(e.avatar)||""};if(n.agentMeta=a,e.model){const l=zn(e.model);n.selectedModel=t_[l]??l}e.token_budget!==void 0&&(n.tokenBudget=Number(e.token_budget));const s=e.modular;if(s?.tokenBudget!==void 0&&(n.tokenBudget=Number(s.tokenBudget)),Array.isArray(e.output_format)){const l=e.output_format.filter(c=>Yx.has(c));l.length>0&&(n.outputFormat=l[0])}else if(e.output_format){const l=zn(e.output_format);Yx.has(l)&&(n.outputFormat=l)}!n.outputFormat&&s?.outputFormat&&(n.outputFormat=s.outputFormat),Array.isArray(e.reads)&&(n.channels=e.reads.map((l,c)=>{const p=void 0;return{sourceId:p?.id??`imported-${c}`,name:p?.name??l.split("/").filter(Boolean).pop()??l,path:l,category:p?.category??"knowledge",knowledgeType:Qr(p?p.path:l),enabled:!0,depth:0,baseTokens:p?.tokenEstimate??5e3}})),!n.channels&&s?.channels&&(n.channels=s.channels.map((l,c)=>{const p=i_(l.type)?l.type:Qr(l.path),f=e_[l.depth?.toLowerCase()]??0,m=(l.path,void 0);return{sourceId:m?.id??`imported-${c}`,name:m?.name??l.path.split("/").filter(Boolean).pop()??l.path,path:l.path,category:m?.category??"knowledge",knowledgeType:p,enabled:!0,depth:f,baseTokens:m?.tokenEstimate??5e3}})),!n.prompt&&e.system&&(n.prompt=zn(e.system)),e.prompt&&(n.prompt=zn(e.prompt));const i=zn(e.system);if(i){const l=c_(i);n.instructionState={persona:l.persona,tone:"neutral",expertise:3,constraints:{neverMakeUp:!1,askBeforeActions:!1,stayInScope:!1,useOnlyTools:!1,limitWords:!1,wordLimit:500,customConstraints:l.constraints,scopeDefinition:""},objectives:{primary:l.objective,successCriteria:[],failureModes:[]},rawPrompt:"",autoSync:!0}}return n}function zn(e){return typeof e=="string"?e:e==null?"":String(e)}function r_(e){const n=e.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);return n?{frontmatter:Rv(n[1]),body:n[2]}:{frontmatter:{},body:e}}function Rv(e){const n={},a=e.split(`
170
+ `);let s="",i=null,l=null,c=null,p="",f=0,m=[];const g=()=>{if(p&&m.length>0){const x=i||n;x[p]=m.join(`
171
+ `),p="",m=[]}};for(const x of a){if(p)if(x.search(/\S/)>=f&&x.trim()!==""){m.push(x.slice(f));continue}else g();const b=x.match(/^(\w[\w_-]*)\s*:\s*(.*)$/);if(b){c&&l&&(l.push(c),c=null),l=null,i=null;const v=b[1],k=b[2].trim();k===""||k==="|"?k==="|"?(p=v,f=2,m=[]):(s=v,i={},n[v]=i):k.startsWith("[")&&k.endsWith("]")?n[v]=k.slice(1,-1).split(",").map(w=>w.trim()).filter(Boolean):n[v]=Ma(k);continue}if(i){const v=x.match(/^ (\w[\w_-]*)\s*:\s*(.*)$/);if(v){c&&l&&(l.push(c),c=null);const k=v[1],w=v[2].trim();w===""||w==="|"?w==="|"?(p=k,f=4,m=[]):(l=[],i[k]=l):(l=null,i[k]=Ma(w));continue}if(l){const k=x.match(/^ - (.+)$/);if(k&&!k[1].includes(":")){c&&(l.push(c),c=null),l.push(Ma(k[1].trim()));continue}}if(l){const k=x.match(/^ - (\w[\w_-]*)\s*:\s*(.*)$/);if(k){c&&l.push(c),c={[k[1]]:Ma(k[2])};continue}const w=x.match(/^ (\w[\w_-]*)\s*:\s*(.*)$/);if(w&&c){c[w[1]]=Ma(w[2]);continue}}}if(!i){const v=x.match(/^ - (.+)$/);if(v&&l){if(!v[1].includes(":"))l.push(Ma(v[1].trim()));else{const w=v[1].match(/^(\w[\w_-]*)\s*:\s*(.*)$/);w&&(c&&l.push(c),c={[w[1]]:Ma(w[2])})}continue}const k=x.match(/^(\w[\w_-]*)\s*:$/);if(k){s=k[1],l=[],n[s]=l;continue}}}return g(),c&&l&&l.push(c),n}function Ma(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function i_(e){return["ground-truth","signal","evidence","framework","hypothesis","guideline"].includes(e)}function l_(e){const n=[],a=e.split(`
172
+ `);let s=0;for(const i of a){const l=i.match(/[-*]\s+(?:\*\*.*?\*\*:?\s*)?([A-Za-z0-9_/-]+(?:\/\*)?)/);if(l){const c=l[1];c.includes("/")&&(n.push({sourceId:`body-${s}`,name:c.split("/").filter(Boolean).pop()??c,path:c,category:"knowledge",knowledgeType:Qr(c),enabled:!0,depth:0,baseTokens:5e3}),s++)}}return n}function c_(e){const n=e.replace(/\r\n/g,`
173
+ `).trim();if(!n)return{persona:"",constraints:"",objective:""};const a=n.split(/\n\s*\n/).map(M=>M.trim()).filter(Boolean),i=n.split(`
174
+ `).map(M=>M.trim()).filter(Boolean).map(M=>{const N=M.match(/^[-*]\s+(.+)$/);if(N)return N[1].trim();const S=M.match(/^\d+\.\s+(.+)$/);return S?S[1].trim():""}).filter(Boolean),l=/\b(never|always|must|must not|do not|don't|forbidden|required|only|avoid|without)\b/i,c=/\b(objective|goal|task|deliver|ensure|help|outcome|success|mission)\b/i,p=i.filter(M=>l.test(M)),f=i.filter(M=>!l.test(M)&&c.test(M)),m=n.match(/(?:^|\n)(?:#+\s*)?(?:objective|objectives|goal|goals|mission)\s*:?\s*\n?([\s\S]*?)(?=\n(?:#+\s*)?[A-Za-z][^\n]*:\s*|\n\s*\n|$)/i),g=n.match(/(?:^|\n)(?:#+\s*)?(?:constraint|constraints|guardrails|rules)\s*:?\s*\n?([\s\S]*?)(?=\n(?:#+\s*)?[A-Za-z][^\n]*:\s*|\n\s*\n|$)/i),x=m?.[1]?.split(`
175
+ `).map(M=>M.replace(/^[-*]\s+/,"").trim()).find(Boolean)??"",b=g?.[1]?.split(`
176
+ `).map(M=>M.replace(/^[-*]\s+/,"").trim()).filter(Boolean).join(`
177
+ `)??"",k=(a.find(M=>{const N=M.toLowerCase();return!(/^(constraints?|guardrails?|rules|objectives?|goals?|mission)\s*:/.test(N)||c.test(M)||l.test(M))})??a[0]??"").split(new RegExp("(?<=[.!?])\\s+")).map(M=>M.trim()).find(Boolean)??"",w=x||f[0]||a.find(M=>c.test(M))||"",C=b||p.join(`
178
+ `);return{persona:k,constraints:C,objective:typeof w=="string"?w.trim():""}}const Vx={strategy:"summarize_and_recent",windowSize:20,summarizeAfter:10,summaryModel:"same",tokenBudget:2e4,maxMessages:20,summarizeEnabled:!0},u_={enabled:!0,store:"local_sqlite",embeddingModel:"text-embedding-3-small",recall:{strategy:"top_k",k:5,minScore:.7},write:{mode:"auto_extract",extractTypes:["user_preferences","decisions","facts"]},scope:"per_user",maxEntries:1e3,ttl:null,tokenBudget:5e3},d_={enabled:!0,maxTokens:2e3,persist:!1,format:"freeform",content:"",tokenBudget:2e3},p_={isolation:"reset_each_run",allowPromoteToShared:!1,domains:{shared:{enabled:!0},agentPrivate:{enabled:!0},runScratchpad:{enabled:!0}}},We=qt((e,n)=>({session:{...Vx},longTerm:{...u_},working:{...d_},facts:[],sandbox:{...p_},sessionMemory:{...Vx},longTermMemory:[],workingMemory:"",setSessionConfig:a=>{e(s=>{const i={...s.session,...a};"maxMessages"in a&&(i.windowSize=i.maxMessages),"windowSize"in a&&(i.maxMessages=i.windowSize),"summarizeEnabled"in a&&!i.summarizeEnabled&&(i.strategy="sliding_window"),"strategy"in a&&(i.summarizeEnabled=a.strategy==="summarize_and_recent");const l=i;return{session:l,sessionMemory:l}})},setLongTermConfig:a=>{e(s=>({longTerm:{...s.longTerm,...a}}))},setRecallConfig:a=>{e(s=>({longTerm:{...s.longTerm,recall:{...s.longTerm.recall,...a}}}))},setWriteConfig:a=>{e(s=>({longTerm:{...s.longTerm,write:{...s.longTerm.write,...a}}}))},toggleExtractType:a=>{e(s=>{const i=s.longTerm.write.extractTypes,l=i.includes(a)?i.filter(c=>c!==a):[...i,a];return{longTerm:{...s.longTerm,write:{...s.longTerm.write,extractTypes:l}}}})},setWorkingConfig:a=>{e(s=>({working:{...s.working,...a}}))},updateScratchpad:a=>{e(s=>({working:{...s.working,content:a},workingMemory:a}))},addFact:(a,s=[],i="fact",l="shared",c="fact",p)=>{const f={id:`fact-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,content:a,tags:s,type:i,timestamp:Date.now(),domain:l,granularity:c,embeddingPending:!0,...p&&{ownerAgentId:p}};e(m=>{const g=[...m.facts,f];return{facts:g,longTermMemory:g}})},removeFact:a=>{e(s=>{const i=s.facts.filter(l=>l.id!==a);return{facts:i,longTermMemory:i}})},updateFact:(a,s)=>{e(i=>({facts:i.facts.map(l=>l.id===a?{...l,...s}:l)}))},addEpisode:(a,s=[])=>{const i={id:`episode-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,content:a,tags:s,type:"fact",timestamp:Date.now(),domain:"shared",granularity:"episode",embeddingPending:!0};e(l=>{const c=[...l.facts,i];return{facts:c,longTermMemory:c}})},computeEmbeddings:async()=>{const s=n().facts.filter(i=>i.embeddingPending&&!i.embedding);if(s.length!==0)try{const i=await fetch("/api/knowledge/embed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({texts:s.map(c=>c.content)})});if(!i.ok)return;const l=await i.json();if(!l.embeddings||l.embeddings.length!==s.length)return;e(c=>({facts:c.facts.map(p=>{const f=s.findIndex(m=>m.id===p.id);return f===-1?p:{...p,embedding:l.embeddings[f],embeddingPending:!1}})}))}catch{}},setSandboxConfig:a=>{e(s=>({sandbox:{...s.sandbox,...a}}))},setSandboxDomain:(a,s)=>{e(i=>({sandbox:{...i.sandbox,domains:{...i.sandbox.domains,[a]:{enabled:s}}}}))},getFactsByDomain:a=>n().facts.filter(s=>s.domain===a),getRecallableFacts:a=>{const{facts:s,sandbox:i}=n();return s.filter(l=>l.domain==="run_scratchpad"?!1:l.domain==="agent_private"?i.domains.agentPrivate.enabled?!!a&&l.ownerAgentId===a:!1:l.domain==="shared"?i.domains.shared.enabled:!1)},toYaml:()=>{const{session:a,longTerm:s,working:i,facts:l,sandbox:c}=n();return{memory:{session:{strategy:a.strategy,window_size:a.windowSize,summarize_after:a.summarizeAfter,summary_model:a.summaryModel,token_budget:a.tokenBudget},long_term:{enabled:s.enabled,store:s.store,embedding_model:s.embeddingModel,recall:{strategy:s.recall.strategy,k:s.recall.k,min_score:s.recall.minScore},write:{mode:s.write.mode,extract_types:s.write.extractTypes},scope:s.scope,max_entries:s.maxEntries,ttl:s.ttl,token_budget:s.tokenBudget,...l.length>0?{seed_facts:l.map(p=>({content:p.content,type:p.type,tags:p.tags,domain:p.domain,granularity:p.granularity}))}:{}},working:{enabled:i.enabled,max_tokens:i.maxTokens,persist:i.persist,format:i.format,token_budget:i.tokenBudget},sandbox:{isolation:c.isolation,allow_promote_to_shared:c.allowPromoteToShared,domains:{shared:c.domains.shared.enabled,agent_private:c.domains.agentPrivate.enabled,run_scratchpad:c.domains.runScratchpad.enabled}}}}}}));function Zr({checked:e,onChange:n,label:a,size:s="md",disabled:i}){const l=we(),c=s==="sm"?28:36,p=s==="sm"?16:20,f=s==="sm"?12:16;return d.jsxs("button",{type:"button",role:"switch","aria-checked":e,onClick:()=>!i&&n(!e),className:"flex items-center gap-2 cursor-pointer border-none bg-transparent p-0 nodrag",style:{opacity:i?.5:1,cursor:i?"not-allowed":"pointer"},children:[d.jsx("div",{className:"relative rounded-full transition-colors",style:{width:c,height:p,background:e?"#FE5000":l.border},children:d.jsx("div",{className:"absolute top-[2px] rounded-full bg-white transition-transform",style:{width:f,height:f,transform:`translateX(${e?c-f-2:2}px)`,transition:"transform 0.15s ease"}})}),a&&d.jsx("span",{className:"text-[13px]",style:{color:l.textSecondary},children:a})]})}function f_(e,n,a){return`You are an expert AI agent architect. Given a user's rough description of an agent they want to build, produce a COMPLETE agent configuration as JSON.
179
+
180
+ You have access to these MCP servers (pick ONLY from this list):
181
+ <mcp_servers>
182
+ ${e}
183
+ </mcp_servers>
184
+
185
+ You have access to these skills (pick ONLY from this list):
186
+ <skills>
187
+ ${n}
188
+ </skills>
189
+
190
+ The user has these REAL knowledge sources already connected (indexed repos, documents, files):
191
+ <connected_knowledge>
192
+ ${a}
193
+ </connected_knowledge>
194
+
195
+ Produce a JSON response with this EXACT structure:
196
+ {
197
+ "agentMeta": {
198
+ "name": "<short agent name>",
199
+ "description": "<one-line description>",
200
+ "avatar": "<icon id: bot|brain|zap|flame|lightbulb|target|rocket|shield|microscope|chart|palette|file|drama|star|gem|bird|bug|cat|dog|heart>",
201
+ "tags": ["<tag1>", "<tag2>"]
202
+ },
203
+ "instructionState": {
204
+ "persona": "<2-4 sentence persona using 'You are...' framing>",
205
+ "tone": "<formal|neutral|casual>",
206
+ "expertise": <1-5>,
207
+ "constraints": {
208
+ "neverMakeUp": <true|false>,
209
+ "askBeforeActions": <true|false>,
210
+ "stayInScope": <true|false>,
211
+ "useOnlyTools": <true|false>,
212
+ "limitWords": <true|false>,
213
+ "wordLimit": <number or 0>,
214
+ "customConstraints": ["<constraint>"],
215
+ "scopeDefinition": "<what agent handles and does NOT handle>"
216
+ },
217
+ "objectives": {
218
+ "primary": "<primary goal>",
219
+ "successCriteria": ["<criterion>"],
220
+ "failureModes": ["<failure to avoid>"]
221
+ }
222
+ },
223
+ "workflowSteps": [
224
+ {
225
+ "label": "<step name>",
226
+ "action": "<what the agent does>",
227
+ "condition": false,
228
+ "loop": false
229
+ }
230
+ ],
231
+ "mcpServerIds": ["<mcp-id from the list above>"],
232
+ "skillIds": ["<skill-id from the list above>"],
233
+ "knowledgeSelections": [
234
+ {
235
+ "sourceId": "<exact sourceId from connected_knowledge>",
236
+ "type": "<ground-truth|signal|evidence|framework|hypothesis|guideline>",
237
+ "depth": <0-4>,
238
+ "reason": "<why this source is relevant>"
239
+ }
240
+ ],
241
+ "knowledgeGaps": [
242
+ {
243
+ "name": "<what's missing>",
244
+ "type": "<ground-truth|signal|evidence|framework|hypothesis|guideline>",
245
+ "description": "<what the user should connect and why>"
246
+ }
247
+ ],
248
+ "memoryConfig": {
249
+ "maxMessages": <10-50>,
250
+ "summarizeAfter": <5-25>,
251
+ "summarizeEnabled": <true|false>,
252
+ "suggestedFacts": ["<pre-loaded fact for long-term memory>"]
253
+ },
254
+ "outputSuggestions": ["<notion|slack|html-slides|email|github|hubspot>"]
255
+ }
256
+
257
+ Rules:
258
+ 1. Pick MCP servers and skills ONLY from the provided lists — use exact IDs
259
+ 2. Suggest 2-6 MCP servers and 1-4 skills that are genuinely useful for this agent
260
+ 3. Generate 3-8 workflow steps that form a coherent process
261
+ 4. **Knowledge: select from REAL connected sources using their exact sourceId**
262
+ - Set the appropriate knowledge type (ground-truth for specs, signal for feedback, etc.)
263
+ - Set depth: 0=Full, 1=Detail(75%), 2=Summary(50%), 3=Headlines(25%), 4=Mention(10%)
264
+ - If no connected sources exist or none are relevant, leave knowledgeSelections empty
265
+ 5. **Knowledge gaps: suggest what REAL documents/repos the user should connect**
266
+ - Be specific: "Odfjell fleet spec PDF" not "Company documentation"
267
+ - Only suggest gaps that would genuinely improve the agent
268
+ 6. Be opinionated — make real choices, don't hedge
269
+ 7. Memory config: enable summarization for conversational agents, disable for one-shot tools
270
+
271
+ Output ONLY the JSON object. No markdown fences, no explanation.`}async function m_(e){if(!e.trim())throw new Error("Describe the agent you want to build");const n=Qe.getState(),a=n.providers.filter(S=>(S.status==="connected"||S.status==="configured")&&Array.isArray(S.models)&&S.models.length>0),s=n.providers.find(S=>S.id===n.selectedProviderId&&a.includes(S))||a[0];if(!s)throw new Error("No provider with models available. Connect a provider and refresh models in Settings.");const i=s.models[0],l=typeof i=="string"?i:i?.id||"";if(!l)throw new Error(`Provider ${s.name} has no selectable model.`);const c=s.authMethod==="claude-agent-sdk",p=se.getState(),f=p.mcpServers.filter(S=>S.added).map(S=>S.id),m=p.skills.filter(S=>S.added).map(S=>S.id),g=f.length>0?Ta.filter(S=>f.includes(S.id)):[],x=m.length>0?vc.filter(S=>m.includes(S.id)):[],b=g.length>0?g.map(S=>`${S.id}: ${S.description}`).join(`
272
+ `):"none",v=x.length>0?x.map(S=>`${S.id}: ${S.description}`).join(`
273
+ `):"none",k=p.channels,w=k.length>0?k.map(S=>`- sourceId: "${S.sourceId}" | name: "${S.name}" | path: "${S.path||"(no path)"}" | type: ${S.knowledgeType||"unclassified"} | tokens: ${S.baseTokens} | depth: ${S.depth}`).join(`
274
+ `):"No knowledge sources connected yet. Suggest what the user should add in knowledgeGaps.",C=f_(b,v,w),M=c?await Yc({prompt:e,model:l,systemPrompt:C,maxTurns:1}):await Kc({providerId:s.id,model:l,messages:[{role:"system",content:C},{role:"user",content:e}],temperature:.4,maxTokens:4096});let N;try{N=JSON.parse(M)}catch{}if(!N){const S=M.match(/```(?:json)?\s*([\s\S]*?)```/);if(S)try{N=JSON.parse(S[1].trim())}catch{}}if(!N){const S=M.match(/\{[\s\S]*\}/);if(S)try{N=JSON.parse(S[0])}catch{}}if(!N)throw new Error("Could not parse generated agent config");return h_(N),N}function h_(e){const n=se.getState().channels;if(n.length===0)return;function a(c){const p=e.instructionState.constraints.customConstraints;Array.isArray(p)?p.push(c):typeof p=="string"?e.instructionState.constraints.customConstraints=p?`${p}
275
+ ${c}`:c:e.instructionState.constraints.customConstraints=[c]}const s=n.filter(c=>c.repoMeta);if(s.length>0){const c=s.map(f=>{const m=f.repoMeta,g=m.stack.length>0?m.stack.join(", "):"unknown stack";return`${m.name} (${g})`});e.instructionState.persona+=` You have deep access to ${c.join(" and ")}.`,a("Explore connected codebases autonomously — read files, check structure, trace dependencies before asking the user for information.");const p=s.flatMap(f=>f.repoMeta.features).filter(Boolean);if(p.length>0){const f=[...new Set(p)];e.instructionState.persona+=` Key capabilities include: ${f.join(", ")}.`}}const i=new Map;for(const c of n){if(!c.knowledgeType)continue;const p=i.get(c.knowledgeType)??[];p.push(c.name),i.set(c.knowledgeType,p)}const l={"ground-truth":c=>`Do not contradict information from: ${c}`,signal:c=>`When interpreting ${c}, look for underlying user needs, not surface requests`,guideline:c=>`Follow the conventions and rules defined in: ${c}`};for(const[c,p]of i){const f=l[c];f&&a(f(p.join(", ")))}}function g_(e){const n=se.getState(),a=[n.agentMeta.name&&`Agent: ${n.agentMeta.name}`,n.agentMeta.description&&`Description: ${n.agentMeta.description}`,n.instructionState.persona&&`Persona: ${n.instructionState.persona.slice(0,200)}`,n.instructionState.objectives.primary&&`Objective: ${n.instructionState.objectives.primary}`,n.instructionState.constraints.customConstraints&&`Constraints: ${n.instructionState.constraints.customConstraints.slice(0,200)}`,n.workflowSteps.length>0&&`Workflow: ${n.workflowSteps.map(i=>i.label).join(" → ")}`,n.channels.filter(i=>i.enabled).length>0&&`Knowledge: ${n.channels.filter(i=>i.enabled).map(i=>i.name).join(", ")}`,n.mcpServers.filter(i=>i.enabled!==!1).length>0&&`MCP: ${n.mcpServers.filter(i=>i.enabled!==!1).map(i=>i.name).join(", ")}`,n.skills.filter(i=>i.enabled!==!1).length>0&&`Skills: ${n.skills.filter(i=>i.enabled!==!1).map(i=>i.name).join(", ")}`].filter(Boolean).join(`
276
+ `),s=e.map((i,l)=>`${l+1}. [${i.id}] "${i.content}" (type: ${i.type}, tags: ${i.tags.join(",")})`).join(`
277
+ `);return`You are an expert agent architect analyzing runtime memory facts to improve an agent's design.
278
+
279
+ <agent_context>
280
+ ${a}
281
+ </agent_context>
282
+
283
+ <facts>
284
+ ${s}
285
+ </facts>
286
+
287
+ Analyze each fact and determine if it should be PROMOTED from runtime memory into a structured agent component. Facts that encode persistent patterns, preferences, or capabilities should graduate into the agent's design.
288
+
289
+ Promotion targets:
290
+ - "instruction": Fact describes HOW the agent should behave → append to persona or instructions
291
+ - "constraint": Fact is a rule or limitation → add as a constraint
292
+ - "workflow": Fact describes a recurring process → add as a workflow step
293
+ - "knowledge": Fact points to a data source the agent needs → add as knowledge source
294
+ - "mcp": Fact mentions a tool/API the agent should use → suggest MCP server
295
+ - "skill": Fact describes a capability the agent needs → suggest a skill
296
+ - "keep": Fact is volatile/contextual → keep in runtime memory
297
+
298
+ Output ONLY valid JSON:
299
+ {
300
+ "promotions": [
301
+ {
302
+ "factId": "<id from facts list>",
303
+ "factContent": "<the fact text>",
304
+ "target": "<promotion target>",
305
+ "confidence": <0.0-1.0>,
306
+ "suggestion": "<human-readable suggestion>",
307
+ "reason": "<why this promotion improves the agent>",
308
+ "payload": {
309
+ "constraintText": "<if target=constraint>",
310
+ "workflowStep": { "label": "<step name>", "action": "<what to do>" },
311
+ "knowledgeSource": { "name": "<source name>", "type": "<ground-truth|signal|evidence|framework>" },
312
+ "mcpServerId": "<id from MCP registry if target=mcp>",
313
+ "skillId": "<skill id if target=skill>",
314
+ "instructionAppend": "<text to append to persona if target=instruction>"
315
+ }
316
+ }
317
+ ],
318
+ "summary": "<one sentence summary of recommended changes>",
319
+ "versionImpact": "<major|minor|patch|none>"
320
+ }
321
+
322
+ Rules:
323
+ - Only promote facts with confidence >= 0.6
324
+ - Facts that are temporary/contextual should stay as "keep"
325
+ - Prefer fewer high-confidence promotions over many low-confidence ones
326
+ - Include payload fields ONLY for the relevant target (omit others)
327
+ - versionImpact: major if persona/objective changes, minor if adding knowledge/tools/steps, patch if constraints only`}async function y_(e){const n=Qe.getState(),a=n.providers.find(i=>i.id===n.selectedProviderId);if(!a)throw new Error("No provider configured — add one in Settings");const s=typeof a.models?.[0]=="object"?a.models[0].id:a.models?.[0]||"claude-sonnet-4-20250514";return a.authMethod==="claude-agent-sdk"?Yc({prompt:e,model:s,maxTurns:1}):Kc({providerId:a.id,model:s,messages:[{role:"user",content:e}],temperature:.3,maxTokens:4096})}function x_(e){try{return JSON.parse(e)}catch{}const n=e.match(/```(?:json)?\s*([\s\S]*?)```/);if(n)try{return JSON.parse(n[1].trim())}catch{}const a=e.match(/\{[\s\S]*\}/);if(a)try{return JSON.parse(a[0])}catch{}throw new Error("Could not parse analysis response")}async function b_(e){if(e.length===0)return{promotions:[],summary:"No facts to analyze",versionImpact:"none"};const n=g_(e),a=await y_(n),s=x_(a);return s.promotions=s.promotions.filter(i=>i.confidence>=.6&&i.target!=="keep").sort((i,l)=>l.confidence-i.confidence),s}function Wx(){return{status:"unknown",latencyMs:null,toolCount:null,errorMessage:null,checkedAt:0}}const Xx=qt((e,n)=>({mcpHealth:{},skillHealth:{},setMcpHealth:(a,s)=>e(i=>({mcpHealth:{...i.mcpHealth,[a]:s}})),setSkillHealth:(a,s)=>e(i=>({skillHealth:{...i.skillHealth,[a]:s}})),setMcpChecking:a=>e(s=>({mcpHealth:{...s.mcpHealth,[a]:{...s.mcpHealth[a]||Wx(),status:"checking"}}})),setSkillChecking:a=>e(s=>({skillHealth:{...s.skillHealth,[a]:{...s.skillHealth[a]||Wx(),status:"checking"}}})),clearHealth:()=>e({mcpHealth:{},skillHealth:{}})})),Ff={"ground-truth":.3,guideline:.15,framework:.15,evidence:.2,signal:.12,hypothesis:.08},v_=.03,k_={0:1.5,1:1.2,2:1,3:.6,4:.2};function w_(e,n){if(e.length===0)return[];if(n<=0)return e.map(c=>({name:c.name,knowledgeType:c.knowledgeType,allocatedTokens:0,weight:0,cappedBySize:!1}));const a=new Map;for(const c of e)a.has(c.knowledgeType)||a.set(c.knowledgeType,[]),a.get(c.knowledgeType).push(c);const s=[];for(const[c,p]of a){const f=Ff[c],m=p.length;for(const g of p){const x=g.depthMultiplier??1,b=f/m*x,v=Math.max(b,v_);s.push({name:g.name,knowledgeType:g.knowledgeType,allocatedTokens:0,weight:v,cappedBySize:!1})}}const i=s.reduce((c,p)=>c+p.weight,0);if(i>0)for(const c of s)c.weight=c.weight/i;for(const c of s)c.allocatedTokens=Math.round(c.weight*n);const l=new Map(e.map(c=>[c.name,c]));for(let c=0;c<3;c++){let p=0;const f=[];for(const m of s){const g=l.get(m.name);m.allocatedTokens>g.rawTokens?(p+=m.allocatedTokens-g.rawTokens,m.allocatedTokens=g.rawTokens,m.cappedBySize=!0):m.cappedBySize||f.push(m)}if(p>0&&f.length>0){const m=f.reduce((g,x)=>g+x.weight,0);if(m>0)for(const g of f){const x=Math.round(g.weight/m*p);g.allocatedTokens+=x}}else break}return s}function wm({loading:e,onClick:n,label:a="Generate"}){return d.jsxs("button",{type:"button",onClick:s=>{s.stopPropagation(),n()},disabled:e,"aria-label":a,className:"flex items-center gap-1 text-[13px] px-2 py-1 rounded cursor-pointer border-none",style:{background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace",opacity:e?.6:1},children:[e?d.jsx(yt,{size:9,className:"animate-spin motion-reduce:animate-none"}):d.jsx(La,{size:9}),a]})}function Ri({icon:e,label:n,color:a,badge:s,collapsed:i,onToggle:l,children:c}){const p=we();return d.jsxs("div",{role:"region","aria-label":n,style:{borderBottom:`1px solid ${p.isDark?"#1e1e22":"#e8e8ec"}`},children:[d.jsxs("button",{type:"button",onClick:l,"aria-expanded":!i,className:"flex items-center gap-2 w-full px-5 py-3.5 border-none cursor-pointer select-none",style:{background:"transparent"},children:[d.jsx(e,{size:10,style:{color:a,flexShrink:0}}),i?d.jsx(ta,{size:12,style:{color:p.textDim}}):d.jsx(Mn,{size:12,style:{color:p.textDim}}),d.jsx("span",{className:"text-[12px] font-bold tracking-[0.08em] uppercase flex-1 text-left",style:{fontFamily:"'Geist Mono', monospace",color:p.textSecondary},children:n}),s&&d.jsx("span",{className:"text-[13px] px-2 py-0.5 rounded-full",style:{fontFamily:"'Geist Mono', monospace",color:p.textDim,background:p.badgeBg},children:s})]}),!i&&d.jsx("div",{className:"px-5 pb-4",children:c})]})}function S_(){const e=we(),n=se(k=>k.hydrateFromGenerated),a=We(k=>k.setSessionConfig),s=We(k=>k.addFact),[i,l]=z.useState(""),[c,p]=z.useState(!1),[f,m]=z.useState(""),[g,x]=z.useState(null),b=z.useCallback(async()=>{if(!(!i.trim()||c)){p(!0),m("");try{const k=await m_(i);if(x(k),n(k),k.memoryConfig){a({maxMessages:k.memoryConfig.maxMessages,summarizeAfter:k.memoryConfig.summarizeAfter,summarizeEnabled:k.memoryConfig.summarizeEnabled});for(const w of k.memoryConfig.suggestedFacts||[])s(w,["generated"])}}catch(k){m(k instanceof Error?k.message:"Generation failed")}finally{p(!1)}}},[i,c,n,a,s]),v=g?{mcp:g.mcpServerIds?.length||0,skills:g.skillIds?.length||0,steps:g.workflowSteps?.length||0,knowledge:g.knowledgeSelections?.length||g.knowledgeSuggestions?.length||0,gaps:g.knowledgeGaps?.length||0}:null;return d.jsxs("div",{style:{borderBottom:`1px solid ${e.isDark?"#1e1e22":"#e8e8ec"}`},children:[d.jsxs("div",{className:"px-5 py-3 flex items-center gap-2",style:{background:e.isDark?"#1a1a1e":"#f0f0f5"},children:[d.jsx(A4,{size:13,style:{color:"#FE5000"}}),d.jsx("span",{className:"text-[12px] font-bold tracking-[0.08em] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:e.textSecondary},children:"Generate Agent"})]}),d.jsxs("div",{className:"px-5 py-3 flex flex-col gap-2",children:[d.jsx("div",{className:"flex flex-wrap gap-1",children:[{label:"Code Review",icon:"🔍",prompt:"A code review agent that uses framework sources for coding standards, ground-truth for API specs, and strict constraints. Reviews PRs for correctness, style, and security."},{label:"Research",icon:"🔬",prompt:"A research agent that uses evidence and signal sources with broad exploration. Synthesizes data from multiple sources, identifies patterns, and generates structured research reports."},{label:"Maritime Ops",icon:"⚓",prompt:"A maritime operations agent with ground-truth for SOLAS/MARPOL regulations, evidence from vessel data, and signal from crew feedback. Supports voyage planning, compliance checks, and operational reporting."},{label:"Writing",icon:"✍️",prompt:"A writing agent that uses framework sources for style guides, ground-truth for facts and references, and hypothesis for draft content. Produces polished documents with consistent voice and accurate citations."}].map(k=>d.jsxs("button",{type:"button",onClick:()=>l(k.prompt),className:"text-[12px] px-2 py-1 rounded-full cursor-pointer",title:k.prompt,style:{fontFamily:"'Geist Mono', monospace",fontWeight:500,background:e.isDark?"#1c1c20":"#eeeef3",color:e.textDim,border:`1px solid ${e.border}`,transition:"border-color 150ms"},onMouseEnter:w=>{w.currentTarget.style.borderColor="#FE5000",w.currentTarget.style.color="#FE5000"},onMouseLeave:w=>{w.currentTarget.style.borderColor=e.border,w.currentTarget.style.color=e.textDim},onFocus:w=>{w.currentTarget.style.borderColor="#FE5000",w.currentTarget.style.color="#FE5000"},onBlur:w=>{w.currentTarget.style.borderColor=e.border,w.currentTarget.style.color=e.textDim},children:[k.icon," ",k.label]},k.label))}),d.jsx(Aa,{value:i,onChange:k=>l(k.target.value),placeholder:`Describe your agent in plain language...
328
+
329
+ e.g. "A PM agent that tracks competitors, uses GitHub and Notion, and outputs weekly reports to Slack"`,rows:4,style:{minHeight:80}}),f&&d.jsx("div",{role:"alert",className:"text-[12px] px-2 py-1 rounded",style:{background:"#ff000015",color:"#ff4444",border:"1px solid #ff000020"},children:f}),v&&d.jsx("div",{className:"flex flex-wrap gap-1",children:[{label:"MCP",count:v.mcp,color:"#2ecc71"},{label:"Skills",count:v.skills,color:"#f1c40f"},{label:"Steps",count:v.steps,color:"#e67e22"},{label:"Sources",count:v.knowledge,color:"#3498db"},...v.gaps>0?[{label:"Gaps",count:v.gaps,color:"#e74c3c"}]:[]].map(k=>d.jsxs("span",{className:"text-[13px] px-1.5 py-0.5 rounded",style:{fontFamily:"'Geist Mono', monospace",background:`${k.color}15`,color:k.color,border:`1px solid ${k.color}30`},children:[k.count," ",k.label]},k.label))}),g?.knowledgeGaps&&g.knowledgeGaps.length>0&&d.jsxs("div",{className:"flex flex-col gap-1 px-2 py-2 rounded",style:{background:"#e74c3c10",border:"1px solid #e74c3c20"},children:[d.jsx("span",{className:"text-[13px] font-bold uppercase tracking-wider",style:{color:"#e74c3c",fontFamily:"'Geist Mono', monospace"},children:"Missing Sources"}),g.knowledgeGaps.map((k,w)=>d.jsxs("div",{className:"flex items-start gap-1.5 text-[12px]",style:{color:e.textSecondary},children:[d.jsx(im,{size:10,style:{color:"#e74c3c",marginTop:2,flexShrink:0}}),d.jsxs("div",{children:[d.jsx("span",{style:{color:e.textPrimary,fontWeight:600},children:k.name}),d.jsxs("span",{style:{color:e.textDim},children:[" (",k.type,")"]}),k.description&&d.jsx("div",{style:{color:e.textDim,fontSize:13,marginTop:1},children:k.description})]})]},w))]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsxs("button",{type:"button",onClick:b,disabled:c||!i.trim(),className:"flex items-center gap-1.5 px-4 py-2.5 rounded text-[13px] font-semibold tracking-wider uppercase cursor-pointer border-none flex-1 justify-center",style:{background:c?"#CC4000":"#FE5000",color:"#fff",opacity:c||!i.trim()?.6:1,fontFamily:"'Geist Mono', monospace"},children:[c?d.jsx(yt,{size:11,className:"animate-spin motion-reduce:animate-none"}):d.jsx(La,{size:11}),c?"Generating...":g?"Regenerate":"Generate"]}),g&&d.jsx("button",{type:"button",onClick:()=>{l(""),x(null),m("")},className:"flex items-center gap-1 px-2 py-2 rounded text-[12px]",style:{background:"transparent",border:`1px solid ${e.border}`,color:e.textDim,cursor:"pointer"},children:d.jsx(um,{size:10})})]})]})]})}function C_(){const e=we(),n=se(U=>U.channels),a=se(U=>U.setChannelDepth),s=se(U=>U.removeChannel),i=se(U=>U.addChannel),l=se(U=>U.setChannelKnowledgeType),c=se(U=>U.setShowFilePicker),p=se(U=>U.setShowConnectionPicker),f=se(U=>U.connectors),m=se(U=>U.removeConnector),g=wn(U=>U.indexes),x=wn(U=>U.loading),b=wn(U=>U.errors),[v,k]=z.useState(!1),[w,C]=z.useState(!1),[M,N]=z.useState(!1),[S,E]=z.useState(""),[I,D]=z.useState(!1),[A,L]=z.useState(null),[P,W]=z.useState({}),[$,V]=z.useState(null),X=["Maximum","High","Normal","Low","Minimal"],H=["ground-truth","signal","evidence","framework","hypothesis","guideline"],_=U=>{const ce=new Set(n.filter(be=>be.enabled).map(be=>be.knowledgeType)),ge=Array.from(ce).reduce((be,ye)=>be+(Ff[ye]||0),0);return ge>0?Math.round(Ff[U]/ge*100):0},T=U=>{const ce=g[U.path];if(ce){const ge=Rs[U.depth];return Math.round(ce.index.totalTokens*ge.pct)}return U.baseTokens??0},B=n.filter(U=>U.enabled).length,G=n.filter(U=>U.enabled&&g[U.path]).length,K=n.filter(U=>U.enabled).reduce((U,ce)=>U+T(ce),0),J=n.filter(U=>U.enabled&&/\.compressed\.md$/i.test(U.path||"")),F=J.reduce((U,ce)=>U+(ce.baseTokens||0),0),O=J.reduce((U,ce)=>U+T(ce),0),Q=F>0?Math.max(0,(F-O)/F*100):0,q=U=>U>=1e3?`${(U/1e3).toFixed(0)}K`:`${U}`,ie=z.useCallback(async()=>{C(!0);const U=n.filter(ce=>ce.enabled&&ce.path).map(ce=>ce.path);U.length>0&&await wn.getState().indexFiles(U),C(!1)},[n]),pe=z.useCallback(async()=>{if(!(!S.trim()||M)){N(!0);try{const U=S.trim(),ce=/github\.com\//i.test(U)||U.endsWith(".git"),ge=ce?`${Ee}/repo/index-github`:`${Ee}/repo/index`,te=await(await fetch(ge,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ce?{url:U,persist:!0}:{path:U})})).json();if(te.status==="ok"&&te.data){const he=te.data.totalTokens??te.data.scan?.totalTokens??5e3,je=te.data.scan,Ie=Array.isArray(je?.stack)?je.stack:je?.stack&&typeof je.stack=="object"?Object.values(je.stack).filter(ze=>typeof ze=="string"&&ze!=="unknown"&&ze!=="none"):[];for(const ze of te.data.files){const Tt=`${te.data.outputDir}/${ze}`,ft=ze.includes("overview");i({sourceId:`repo-${ze}-${Date.now()}`,name:ze.replace(".compressed.md","").replace(".md","").replace(/^\d+-/,""),path:Tt,category:"knowledge",knowledgeType:"ground-truth",depth:ce?2:1,baseTokens:Math.round(he/Math.max(te.data.files.length,1)),...ft&&te.data.overviewMarkdown?{content:te.data.overviewMarkdown}:{},...ft&&je?{repoMeta:{name:te.data.name??"",stack:Ie,totalFiles:je.totalFiles??0,baseUrl:je.baseUrl,features:(je.features??[]).map(vt=>vt.name)}}:{},...te.data.contentSourceId?{contentSourceId:te.data.contentSourceId}:{}})}D(!1),E(""),await wn.getState().indexFiles(te.data.files.map(ze=>`${te.data.outputDir}/${ze}`)),je&&ea(async()=>{const{populateGraphFromScan:ze}=await import("./graphPopulator-DH0qM1Fu.js");return{populateGraphFromScan:ze}},[]).then(({populateGraphFromScan:ze})=>{ze(te.data.name??S,je).catch(()=>{})})}}catch{}N(!1)}},[S,M,i]),me=["#2ecc71","#3498db","#f1c40f","#e67e22","#999"];return z.useEffect(()=>{fetch(`${Ee}/connectors/auth`).then(U=>U.json()).then(U=>{U.data&&W(U.data)}).catch(()=>{})},[]),d.jsxs(Ri,{icon:_i,label:"Knowledge",color:"#3498db",badge:`${G}/${B} indexed · ${q(K)} tokens`,collapsed:v,onToggle:()=>k(!v),children:[d.jsx("div",{className:"flex justify-end mb-2",children:d.jsx(wm,{loading:w,onClick:ie,label:"Index"})}),d.jsx("div",{className:"flex flex-col",children:n.map(U=>{const ce=Zo[U.knowledgeType]||Zo.evidence,ge=U.depth??0,be=/\.compressed\.md$/i.test(U.path||""),ye=(4-ge)/4*100,te=me[ge]||"#999",he=!!g[U.path],je=!!x[U.path],Ie=!!b[U.path],ze=T(U),Tt=$===U.sourceId,ft=_(U.knowledgeType);return d.jsxs("div",{className:"py-1.5",style:{borderBottom:`1px solid ${e.isDark?"#1a1a1e":"#eee"}`},children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsxs("div",{style:{position:"relative",flexShrink:0},children:[d.jsx("div",{style:{width:8,height:8,borderRadius:2,background:ce.color}}),he&&d.jsx("div",{style:{position:"absolute",top:-2,right:-2,width:4,height:4,borderRadius:"50%",background:"#00ff88"}}),je&&d.jsx("div",{style:{position:"absolute",top:-2,right:-2,width:4,height:4,borderRadius:"50%",background:"#ffaa00"}}),Ie&&d.jsx("div",{style:{position:"absolute",top:-2,right:-2,width:4,height:4,borderRadius:"50%",background:"#ff3344"}})]}),d.jsx("button",{type:"button",onClick:()=>V(Tt?null:U.sourceId),className:"flex-1 truncate text-[13px] text-left border-none bg-transparent cursor-pointer p-0",title:U.name,style:{color:U.enabled?e.textPrimary:e.textDim,lineHeight:1.2},children:U.name}),d.jsx(vi,{content:`${ce.icon} ${ce.label} — ${ce.instruction}
330
+ Budget: ~${ft}% · Detail: ${X[ge]}`,position:"top",children:d.jsx("span",{className:"text-[7px] px-1.5 py-0.5 rounded-full shrink-0 cursor-default select-none",style:{fontFamily:"'Geist Mono', monospace",fontWeight:600,background:`${ce.color}18`,color:ce.color,border:`1px solid ${ce.color}30`},children:ce.label})}),be&&d.jsx("span",{className:"text-[12px] px-1 py-0.5 rounded shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:"#24292F",background:"#24292F12",border:"1px solid #24292F30"},title:"GitHub indexed & compressed context",children:"GH"}),d.jsx("span",{className:"text-[13px] shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:he?e.textPrimary:e.textDim},title:he?`Indexed: ${g[U.path].index.nodeCount} nodes`:"Estimated",children:q(ze)}),d.jsx("button",{type:"button","aria-label":`Remove ${U.name}`,onClick:()=>s(U.sourceId),className:"border-none bg-transparent cursor-pointer rounded shrink-0 flex items-center justify-center",style:{color:e.textFaint,width:20,height:20,padding:0},children:d.jsx(jt,{size:9})})]}),d.jsxs("div",{className:"flex items-center gap-1 mt-0.5 pl-4",children:[d.jsx("button",{type:"button","aria-label":"Less detail",onClick:()=>a(U.sourceId,Math.min(4,ge+1)),className:"border-none bg-transparent cursor-pointer rounded shrink-0 flex items-center justify-center",style:{color:ge>=4?e.textFaint:e.textDim,width:20,height:20,padding:0},children:d.jsx(L3,{size:9})}),d.jsx("div",{className:"flex-1",style:{height:4,background:`${te}18`,borderRadius:2,overflow:"hidden"},children:d.jsx("div",{style:{width:`${ye}%`,height:"100%",background:te,borderRadius:2,transition:"width 200ms"}})}),d.jsx("button",{type:"button","aria-label":"More detail",onClick:()=>a(U.sourceId,Math.max(0,ge-1)),className:"border-none bg-transparent cursor-pointer rounded shrink-0 flex items-center justify-center",style:{color:ge<=0?e.textFaint:e.textDim,width:20,height:20,padding:0},children:d.jsx(bt,{size:9})}),d.jsx("span",{className:"text-[12px] shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim,width:44,textAlign:"right"},children:X[ge]})]}),Tt&&d.jsxs("div",{className:"mt-1.5 ml-4 px-2.5 py-2 rounded-md",style:{background:e.isDark?"#1a1a1e":"#f5f5f8",border:`1px solid ${e.isDark?"#2a2a30":"#e0e0e5"}`},children:[d.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[d.jsx("span",{className:"text-[12px] tracking-[0.1em] uppercase shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim,width:32},children:"Type"}),d.jsx("div",{className:"flex flex-wrap gap-1",children:H.map((vt,mn)=>{const tn=Zo[vt],hn=U.knowledgeType===vt;return d.jsx("button",{type:"button",onClick:()=>l(U.sourceId,mn),className:"text-[7px] px-1.5 py-0.5 rounded-full cursor-pointer border-none",style:{fontFamily:"'Geist Mono', monospace",fontWeight:600,background:hn?`${tn.color}25`:"transparent",color:hn?tn.color:e.textFaint,border:`1px solid ${hn?`${tn.color}40`:"transparent"}`},children:tn.label},vt)})})]}),d.jsxs("div",{className:"flex items-start gap-1.5 mb-2",children:[d.jsx(y3,{size:9,style:{color:ce.color,marginTop:1,flexShrink:0}}),d.jsx("span",{className:"text-[13px]",style:{color:e.textDim,lineHeight:1.3},children:ce.instruction})]}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsxs("span",{className:"text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:["Budget: ~",ft,"%"]}),d.jsxs("span",{className:"text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:["Detail: ",X[ge]]}),d.jsxs("span",{className:"text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:["Tokens: ",q(ze)]})]})]})]},U.sourceId)})}),f.filter(U=>U.enabled&&U.direction!=="write").length>0&&d.jsxs("div",{className:"mt-2 pt-2",style:{borderTop:`1px solid ${e.isDark?"#1a1a1e":"#eee"}`},children:[d.jsx("div",{className:"text-[13px] tracking-[0.1em] uppercase mb-1.5",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:"Connectors"}),f.filter(U=>U.enabled&&U.direction!=="write").map(U=>{const ge={notion:"#000",slack:"#4A154B",hubspot:"#FF7A59",github:"#24292F",granola:"#8B5CF6","google-drive":"#4285F4"}[U.service]||"#666",be=P[U.service],ye=be?.status==="connected",te=A===U.service;return d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center gap-2 py-2",style:{borderBottom:te?"none":`1px solid ${e.isDark?"#1a1a1e":"#eee"}`},children:[d.jsxs("div",{style:{position:"relative",flexShrink:0},children:[d.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:ge}}),d.jsx("div",{style:{position:"absolute",top:-2,right:-2,width:4,height:4,borderRadius:"50%",background:ye?"#00ff88":be?.hasApiKey?"#ffaa00":"#666"}})]}),d.jsx("span",{className:"flex-1 truncate text-[14px]",style:{color:e.textPrimary},children:U.name}),d.jsx("span",{className:"text-[12px] px-1.5 py-0.5 rounded-full uppercase",style:{fontFamily:"'Geist Mono', monospace",color:U.direction==="both"?"#b88ad4":"#6aafe6",background:U.direction==="both"?"#9b59b610":"#3498db10"},children:U.direction}),d.jsx("button",{type:"button","aria-label":`Configure ${U.name} credentials`,onClick:()=>L(te?null:U.service),className:"border-none bg-transparent cursor-pointer p-2.5 rounded min-w-[44px] min-h-[44px] flex items-center justify-center",style:{color:ye?"#00ff88":e.textDim},children:d.jsx(b3,{size:10})}),d.jsx("button",{type:"button","aria-label":`Remove ${U.name}`,onClick:()=>m(U.id),className:"border-none bg-transparent cursor-pointer p-2.5 rounded min-w-[44px] min-h-[44px] flex items-center justify-center hover:bg-[#ff000010]",style:{color:e.textFaint},children:d.jsx(jt,{size:10})})]}),te&&d.jsxs("div",{className:"flex items-center gap-2 pb-2 pl-4",style:{borderBottom:`1px solid ${e.isDark?"#1a1a1e":"#eee"}`},children:[d.jsx("span",{className:"text-[13px]",style:{color:e.textDim},children:ye?"✓ Connected":"Authentication required"}),d.jsx("button",{type:"button",onClick:()=>se.getState().setShowSettings(!0),className:"text-[13px] px-2 py-1 rounded cursor-pointer border-none",style:{background:"#FE500012",color:"#FE5000"},children:"Open Settings"})]})]},U.id)})]}),d.jsxs("div",{className:"flex gap-2 mt-3",children:[d.jsxs("button",{type:"button",onClick:()=>c(!0),className:"flex items-center justify-center gap-1.5 flex-1 px-2.5 py-2 rounded text-[12px] tracking-wide uppercase cursor-pointer",style:{background:"transparent",border:`1px solid ${e.border}`,color:e.textDim,fontFamily:"'Geist Mono', monospace",transition:"border-color 150ms, color 150ms"},onMouseEnter:U=>{U.currentTarget.style.borderColor="#FE5000",U.currentTarget.style.color="#FE5000"},onMouseLeave:U=>{U.currentTarget.style.borderColor=e.border,U.currentTarget.style.color=e.textDim},onFocus:U=>{U.currentTarget.style.borderColor="#FE5000",U.currentTarget.style.color="#FE5000"},onBlur:U=>{U.currentTarget.style.borderColor=e.border,U.currentTarget.style.color=e.textDim},children:[d.jsx(bt,{size:10})," Files"]}),d.jsxs("button",{type:"button","aria-label":"Add connection",onClick:()=>p(!0),className:"flex items-center justify-center gap-1.5 flex-1 px-2.5 py-2.5 rounded text-[12px] tracking-wide uppercase cursor-pointer min-h-[44px] motion-reduce:transition-none",style:{background:"transparent",border:`1px solid ${e.border}`,color:e.textDim,fontFamily:"'Geist Mono', monospace",transition:"border-color 150ms, color 150ms"},onMouseEnter:U=>{U.currentTarget.style.borderColor="#9b59b6",U.currentTarget.style.color="#9b59b6"},onMouseLeave:U=>{U.currentTarget.style.borderColor=e.border,U.currentTarget.style.color=e.textDim},onFocus:U=>{U.currentTarget.style.borderColor="#9b59b6",U.currentTarget.style.color="#9b59b6"},onBlur:U=>{U.currentTarget.style.borderColor=e.border,U.currentTarget.style.color=e.textDim},children:[d.jsx(bt,{size:10})," Connect"]}),d.jsxs("button",{type:"button","aria-label":"Index repository",onClick:()=>D(!I),className:"flex items-center justify-center gap-1.5 flex-1 px-2.5 py-2.5 rounded text-[12px] tracking-wide uppercase cursor-pointer min-h-[44px] motion-reduce:transition-none",style:{background:I?"#24292F15":"transparent",border:`1px solid ${I?"#24292F":e.border}`,color:I?"#24292F":e.textDim,fontFamily:"'Geist Mono', monospace",transition:"border-color 150ms, color 150ms"},onMouseEnter:U=>{I||(U.currentTarget.style.borderColor="#24292F",U.currentTarget.style.color="#24292F")},onMouseLeave:U=>{I||(U.currentTarget.style.borderColor=e.border,U.currentTarget.style.color=e.textDim)},onFocus:U=>{I||(U.currentTarget.style.borderColor="#24292F",U.currentTarget.style.color="#24292F")},onBlur:U=>{I||(U.currentTarget.style.borderColor=e.border,U.currentTarget.style.color=e.textDim)},children:[d.jsx(VN,{size:10})," Repo"]})]}),I&&d.jsxs("div",{className:"mt-2 flex gap-1.5",children:[d.jsx("input",{type:"text",value:S,onChange:U=>E(U.target.value),placeholder:"/path/to/repo or https://github.com/org/repo","aria-label":"Repository path",className:"flex-1 px-2.5 py-1.5 rounded text-[13px] outline-none",style:{background:e.inputBg,border:`1px solid ${e.border}`,color:e.textPrimary,fontFamily:"'Geist Sans', sans-serif"},onKeyDown:U=>{U.key==="Enter"&&pe()}}),d.jsx("button",{type:"button",onClick:pe,disabled:M||!S.trim(),className:"px-3 py-1.5 rounded text-[12px] font-semibold tracking-wider uppercase cursor-pointer border-none",style:{background:"#24292F",color:"#fff",fontFamily:"'Geist Mono', monospace",opacity:M||!S.trim()?.5:1},"aria-label":"Index repository",children:M?d.jsx(yt,{size:10,className:"animate-spin motion-reduce:animate-none"}):"Index"})]}),J.length>0&&d.jsxs("div",{className:"mt-3 px-2.5 py-2 rounded-lg",style:{border:"1px solid #24292F30",background:"#24292F08"},children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-[13px] tracking-[0.1em] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:"#24292F"},children:"GitHub Context Compression"}),d.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"#00A86B"},children:["-",Q.toFixed(1),"%"]})]}),d.jsxs("div",{className:"mt-1 text-[12px]",style:{color:e.textDim},children:["Raw ",q(F)," → Effective ",q(O)," tokens (",J.length," channels)"]})]}),n.length>0&&d.jsxs("div",{className:"mt-3",children:[d.jsx("div",{className:"text-[13px] tracking-[0.1em] uppercase mb-1.5",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:"Context allocation"}),d.jsx("div",{className:"flex gap-0.5 h-1 rounded overflow-hidden",children:Object.entries(Zo).map(([U,ce])=>{const ge=n.filter(ye=>ye.enabled&&ye.knowledgeType===U).reduce((ye,te)=>ye+T(te),0);if(ge===0)return null;const be=K>0?ge/K*100:0;return d.jsx("div",{style:{width:`${be}%`,background:ce.color,borderRadius:2}},U)})}),d.jsx("div",{className:"flex justify-between mt-1",children:d.jsxs("span",{className:"text-[13px]",style:{fontFamily:"'Geist Mono', monospace",color:"#FE5000"},children:[q(K)," used"]})})]})]})}function M_(){const e=we(),n=se(M=>M.mcpServers),a=se(M=>M.removeMcp),s=at(M=>M.servers),i=Xx(M=>M.mcpHealth),[l,c]=z.useState(!1),[p,f]=z.useState(!1),m=n.filter(M=>M.added),g=m.length,x=m.filter(M=>i[M.id]?.status==="error").length,b=(M,N)=>s.find(S=>S.id===M)??s.find(S=>S.name===N),v=(M,N)=>{const S=i[M];if(S){if(S.status==="healthy")return"ok";if(S.status==="degraded")return"warn";if(S.status==="error")return"err";if(S.status==="checking")return"warn"}const E=b(M,N);return E?E.status==="connected"?"ok":E.status==="error"?"err":E.status==="connecting"?"warn":"off":"off"},k=z.useCallback(async()=>{f(!0);const{setMcpHealth:M,setMcpChecking:N}=Xx.getState();await Promise.allSettled(m.map(async S=>{const E=b(S.id,S.name);if(!E){M(S.id,{status:"error",latencyMs:0,toolCount:0,tools:[],errorMessage:`Not found: ${S.id}`,checkedAt:Date.now()});return}N(S.id);const I=performance.now();try{const D=await fetch(`${Ee}/health/mcp/${E.id}`,{signal:AbortSignal.timeout(15e3)}),A=Math.round(performance.now()-I),L=await D.json(),P=L.data??L;M(S.id,{status:P.status??"error",latencyMs:A,toolCount:P.toolCount??P.tools?.length??0,tools:P.tools??[],errorMessage:P.errorMessage??P.error??null,checkedAt:Date.now()})}catch(D){M(S.id,{status:"error",latencyMs:Math.round(performance.now()-I),toolCount:0,tools:[],errorMessage:D instanceof Error?D.message:"Probe failed",checkedAt:Date.now()})}})),f(!1)},[m,s]),w={ok:{bg:"#00ff88",glow:"0 0 6px rgba(0,255,136,0.4)"},warn:{bg:"#ffaa00",glow:"0 0 6px rgba(255,170,0,0.4)"},err:{bg:"#ff3344",glow:"0 0 6px rgba(255,51,68,0.4)"},off:{bg:"#333",glow:"none"}},C=M=>M==null?{active:0,color:e.textFaint}:M<=10?{active:5,color:"#00ff88"}:M<=30?{active:4,color:"#7DFF5A"}:M<=80?{active:3,color:"#FFD84D"}:M<=200?{active:2,color:"#FF9F43"}:{active:1,color:"#FF4D4D"};return d.jsxs(Ri,{icon:zi,label:"MCP Servers",color:"#2ecc71",badge:x>0?`${g} active · ${x} error`:`${g} active`,collapsed:l,onToggle:()=>c(!l),children:[g>0&&d.jsx("div",{className:"flex justify-end mb-2",children:d.jsx(wm,{loading:p,onClick:k,label:"Check Health"})}),d.jsx("div",{className:"flex flex-col",children:m.map(M=>{const N=v(M.id,M.name),S=w[N],E=b(M.id,M.name),I=i[M.id],D=I?.toolCount??E?.tools?.length??0;return d.jsxs("div",{style:{borderBottom:`1px solid ${e.isDark?"#1a1a1e":"#eee"}`},children:[d.jsxs("div",{className:"flex items-center gap-2.5 py-2.5",children:[d.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:S.bg,boxShadow:S.glow,flexShrink:0}}),d.jsx("span",{className:"flex-1 text-[14px]",style:{color:e.textPrimary},children:M.name}),M.type&&d.jsx("span",{className:"text-[12px] px-1.5 py-0.5 rounded",style:{fontFamily:"'Geist Mono', monospace",background:e.badgeBg,color:e.textDim},children:M.type}),D>0&&d.jsxs("span",{className:"text-[12px]",style:{color:e.textDim},children:[D," tools"]}),d.jsx("button",{type:"button","aria-label":`Remove ${M.name}`,onClick:()=>a(M.id),className:"border-none bg-transparent cursor-pointer p-2 rounded hover:bg-[#ff000010] min-w-[44px] min-h-[44px] flex items-center justify-center",style:{color:e.textFaint},children:d.jsx(jt,{size:10})})]}),I&&I.status!=="unknown"&&d.jsxs("div",{className:"flex items-center gap-2 pb-1.5 pl-5 text-[13px]",style:{fontFamily:"'Geist Mono', monospace"},children:[I.latencyMs!=null&&d.jsxs("span",{className:"flex items-end gap-[2px]",title:`${I.latencyMs}ms`,children:[Array.from({length:5}).map((A,L)=>{const P=C(I.latencyMs);return d.jsx("span",{style:{width:3,height:4+L*2,borderRadius:1,background:L<P.active?P.color:e.borderSubtle,opacity:L<P.active?1:.5}},`lat-${M.id}-${L}`)}),d.jsxs("span",{style:{color:e.textFaint,marginLeft:4},children:[I.latencyMs,"ms"]})]}),I.tools&&I.tools.length>0&&d.jsxs("span",{className:"truncate",style:{color:e.textFaint,maxWidth:180},title:I.tools.join(", "),children:[I.tools.slice(0,3).join(", "),I.tools.length>3?` +${I.tools.length-3}`:""]}),I.errorMessage&&d.jsx("span",{style:{color:"#e74c3c"},children:I.errorMessage})]})]},M.id)})})]})}function E_(){const e=we(),n=se(f=>f.skills),a=se(f=>f.removeSkill),s=se(f=>f.setShowSkillPicker),[i,l]=z.useState(!1),c=n.filter(f=>f.added),p=c.length;return d.jsxs(Ri,{icon:pn,label:"Skills",color:"#f1c40f",badge:`${p} active`,collapsed:i,onToggle:()=>l(!i),children:[c.length===0&&d.jsx("div",{className:"text-[12px] py-2",style:{color:e.textFaint},children:"No skills selected for this agent."}),d.jsx("div",{className:"flex flex-col",children:c.map(f=>d.jsxs("div",{className:"flex items-center gap-2 py-1.5",style:{borderBottom:`1px solid ${e.isDark?"#1a1a1e":"#eee"}`},children:[d.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:"#00ff88",boxShadow:"0 0 6px rgba(0,255,136,0.4)",flexShrink:0}}),d.jsx("span",{className:"flex-1 text-[13px] truncate",style:{color:e.textPrimary},children:f.name}),d.jsx("button",{type:"button","aria-label":`Remove ${f.name}`,onClick:()=>a(f.id),className:"border-none bg-transparent cursor-pointer rounded shrink-0 flex items-center justify-center",style:{color:e.textFaint,width:20,height:20,padding:0},children:d.jsx(jt,{size:9})})]},f.id))}),d.jsxs("button",{type:"button","aria-label":"Open Skill Library",onClick:()=>s(!0),className:"flex items-center justify-center gap-1.5 w-full mt-3 px-3 py-2.5 rounded text-[13px] tracking-wide uppercase cursor-pointer min-h-[44px] motion-reduce:transition-none",style:{background:"transparent",border:`1px solid ${e.border}`,color:e.textDim,fontFamily:"'Geist Mono', monospace",transition:"border-color 150ms, color 150ms"},onMouseEnter:f=>{f.currentTarget.style.borderColor="#FE5000",f.currentTarget.style.color="#FE5000"},onMouseLeave:f=>{f.currentTarget.style.borderColor=e.border,f.currentTarget.style.color=e.textDim},onFocus:f=>{f.currentTarget.style.borderColor="#FE5000",f.currentTarget.style.color="#FE5000"},onBlur:f=>{f.currentTarget.style.borderColor=e.border,f.currentTarget.style.color=e.textDim},children:[d.jsx(C3,{size:11})," Skill Library"]})]})}const j_=[{value:"full",label:"Full History"},{value:"sliding_window",label:"Sliding Window"},{value:"summarize_and_recent",label:"Summarize + Recent"},{value:"rag",label:"RAG over History"}],T_=[{value:"local_sqlite",label:"SQLite (local)"},{value:"postgres",label:"PostgreSQL"},{value:"redis",label:"Redis"},{value:"chromadb",label:"ChromaDB"},{value:"pinecone",label:"Pinecone"},{value:"custom",label:"Custom"}],N_=[{value:"text-embedding-3-small",label:"Ada 3 Small"},{value:"text-embedding-3-large",label:"Ada 3 Large"},{value:"voyage-3",label:"Voyage 3"},{value:"custom",label:"Custom"}],A_=[{value:"top_k",label:"Top-K"},{value:"threshold",label:"Threshold"},{value:"hybrid",label:"Hybrid"}],__=[{value:"auto_extract",label:"Auto Extract"},{value:"explicit",label:"Explicit Only"},{value:"both",label:"Both"}],D_=[{value:"per_user",label:"Per User"},{value:"per_agent",label:"Per Agent"},{value:"global",label:"Global"}],z_=[{value:"user_preferences",label:"Preferences",color:"#3498db"},{value:"decisions",label:"Decisions",color:"#e67e22"},{value:"facts",label:"Facts",color:"#2ecc71"},{value:"feedback",label:"Feedback",color:"#9b59b6"},{value:"entities",label:"Entities",color:"#f1c40f"}],R_=[{value:"reset_each_run",label:"Reset Each Run"},{value:"persistent_sandbox",label:"Persistent Sandbox"},{value:"clone_from_shared",label:"Clone from Shared"}],yc={shared:"#2ecc71",agent_private:"#3498db",run_scratchpad:"#e67e22"},cf={preference:"#3498db",decision:"#e67e22",fact:"#2ecc71",entity:"#f1c40f",custom:"#999"};function Ea({children:e}){const n=we();return d.jsx("div",{className:"text-[13px] uppercase tracking-[0.12em] font-semibold mt-2 mb-1",style:{fontFamily:"'Geist Mono', monospace",color:n.textDim},children:e})}function Wo({label:e,value:n,min:a,max:s,step:i,onChange:l,suffix:c}){const p=we(),f=c==="K"?`${(n/1e3).toFixed(0)}K`:`${n}`;return d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"text-[13px] uppercase tracking-wider shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:p.textDim,width:90},children:e}),d.jsx("input",{type:"range",min:a,max:s,step:i,value:n,onChange:m=>l(Number(m.target.value)),"aria-label":e,className:"flex-1",style:{accentColor:"#FE5000"}}),d.jsx("span",{className:"text-[12px] w-10 text-right",style:{fontFamily:"'Geist Mono', monospace",color:p.textSecondary},children:f})]})}function $_(){const e=we(),n=We(_=>_.session),a=We(_=>_.longTerm),s=We(_=>_.working),i=We(_=>_.facts),l=We(_=>_.setSessionConfig),c=We(_=>_.setLongTermConfig),p=We(_=>_.setRecallConfig),f=We(_=>_.setWriteConfig),m=We(_=>_.toggleExtractType),g=We(_=>_.setWorkingConfig),x=We(_=>_.addFact),b=We(_=>_.removeFact),v=We(_=>_.sandbox),k=We(_=>_.setSandboxConfig),w=We(_=>_.setSandboxDomain),[C,M]=z.useState(!1),[N,S]=z.useState(""),[E,I]=z.useState("shared"),[D,A]=z.useState(!1),[L,P]=z.useState(!1),W=z.useCallback(async()=>{A(!0);try{const _=await xv();l({maxMessages:_.maxMessages,summarizeAfter:_.summarizeAfter,summarizeEnabled:_.summarizeEnabled});for(const T of _.suggestedFacts||[])x(T,["generated"])}catch{}A(!1)},[l,x]),$=n.tokenBudget+a.tokenBudget+s.tokenBudget,V=_=>_>=1e3?`${(_/1e3).toFixed(0)}K`:`${_}`,X=[];a.enabled&&X.push("long-term"),s.enabled&&X.push("scratchpad");const H=i.length>0?`${i.length} facts${X.length?" · "+X.join(" · "):""}`:X.length?X.join(" · "):"session only";return d.jsxs(Ri,{icon:Ni,label:"Memory",color:"#e74c3c",badge:H,collapsed:C,onToggle:()=>M(!C),children:[d.jsxs("div",{className:"flex items-center justify-between mb-2",children:[d.jsx(Ea,{children:"Conversation Window"}),d.jsx(wm,{loading:D,onClick:W,label:"Configure"})]}),d.jsx(Wo,{label:"Messages",value:n.windowSize,min:5,max:100,step:5,onChange:_=>l({windowSize:_})}),d.jsx("div",{className:"mt-1.5",children:d.jsx(Zr,{checked:n.summarizeEnabled,onChange:_=>l({summarizeEnabled:_}),label:"Summarize older messages",size:"sm"})}),d.jsx(Ea,{children:"Seed Facts"}),d.jsxs("div",{className:"flex flex-col gap-1 mb-2",children:[i.map(_=>{const T=yc[_.domain]||"#999";return d.jsxs("div",{className:"flex items-center gap-1.5 text-[13px] py-1 px-2 rounded",style:{background:e.surfaceElevated,color:e.textSecondary},children:[d.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:cf[_.type]||"#999",flexShrink:0}}),d.jsx("span",{className:"flex-1 truncate",style:{fontFamily:"'Geist Sans', sans-serif"},children:_.content}),d.jsx("span",{className:"text-[12px] px-1 py-0.5 rounded",style:{background:`${T}15`,color:T,fontFamily:"'Geist Mono', monospace",border:`1px solid ${T}30`},children:_.domain.replace("_"," ")}),_.tags.length>0&&_.tags.map(B=>d.jsx("span",{className:"text-[12px] px-1 py-0.5 rounded",style:{background:`${cf[_.type]||"#999"}15`,color:cf[_.type]||"#999",fontFamily:"'Geist Mono', monospace"},children:B},B)),d.jsx("button",{type:"button","aria-label":"Remove fact",onClick:()=>b(_.id),className:"border-none bg-transparent cursor-pointer p-2 rounded shrink-0 hover:bg-[#ff000010] min-w-[44px] min-h-[44px] flex items-center justify-center",style:{color:e.textFaint},children:d.jsx(jt,{size:9})})]},_.id)}),i.length===0&&d.jsx("div",{className:"text-[12px] py-2 text-center",style:{color:e.textFaint},children:"Pre-load facts the agent should always know"})]}),d.jsxs("div",{className:"flex gap-1",children:[d.jsx(zs,{value:N,onChange:_=>S(_.target.value),onKeyDown:_=>{_.key==="Enter"&&N.trim()&&(x(N.trim(),[],"fact",E),S(""))},placeholder:"Add a seed fact..."}),d.jsxs("select",{value:E,onChange:_=>I(_.target.value),"aria-label":"Fact domain",className:"text-[13px] px-1 rounded border-none cursor-pointer",style:{background:e.surfaceElevated,color:e.textDim,fontFamily:"'Geist Mono', monospace",width:70},children:[d.jsx("option",{value:"shared",children:"shared"}),d.jsx("option",{value:"agent_private",children:"private"}),d.jsx("option",{value:"run_scratchpad",children:"scratch"})]}),d.jsx("button",{type:"button","aria-label":"Add fact",onClick:()=>{N.trim()&&(x(N.trim(),[],"fact",E),S(""))},className:"px-2 border-none rounded cursor-pointer shrink-0 min-w-[44px] min-h-[44px] flex items-center justify-center",style:{background:e.surfaceElevated,color:e.textDim},children:d.jsx(bt,{size:12})})]}),d.jsxs("button",{type:"button","aria-expanded":L,onClick:()=>P(!L),className:"flex items-center gap-1 mt-3 text-[13px] tracking-wider uppercase cursor-pointer border-none bg-transparent w-full min-h-[44px] motion-reduce:transition-none",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim,padding:"0 8px",transition:"color 150ms"},onMouseEnter:_=>{_.currentTarget.style.color="#FE5000"},onMouseLeave:_=>{_.currentTarget.style.color=e.textDim},onFocus:_=>{_.currentTarget.style.color="#FE5000"},onBlur:_=>{_.currentTarget.style.color=e.textDim},children:[L?d.jsx(Mn,{size:10}):d.jsx(ta,{size:10}),"Advanced memory config"]}),L&&d.jsxs("div",{className:"mt-2 pt-2 flex flex-col gap-1.5",style:{borderTop:`1px solid ${e.isDark?"#1e1e22":"#e8e8ec"}`},children:[d.jsx(Ea,{children:"Sandbox Isolation"}),d.jsx(Rn,{options:R_,value:v.isolation,onChange:_=>k({isolation:_}),size:"sm"}),d.jsx("div",{className:"flex flex-col gap-1 mt-1",children:d.jsx(Zr,{checked:v.allowPromoteToShared,onChange:_=>k({allowPromoteToShared:_}),label:"Allow promote to shared",size:"sm"})}),d.jsx(Ea,{children:"Memory Domains"}),d.jsx("div",{className:"flex flex-wrap gap-1",children:[{key:"shared",label:"Shared",color:yc.shared},{key:"agentPrivate",label:"Agent Private",color:yc.agent_private},{key:"runScratchpad",label:"Run Scratchpad",color:yc.run_scratchpad}].map(_=>{const T=v.domains[_.key].enabled;return d.jsx("button",{type:"button","aria-label":`Toggle ${_.label}`,"aria-pressed":T,onClick:()=>w(_.key,!T),className:"text-[13px] px-3 py-2 rounded-full cursor-pointer border-none min-h-[44px]",style:{fontFamily:"'Geist Mono', monospace",background:T?`${_.color}20`:e.isDark?"#1c1c20":"#f0f0f5",color:T?_.color:e.textDim,border:`1px solid ${T?`${_.color}40`:"transparent"}`},children:_.label},_.key)})}),d.jsx(Ea,{children:"Session Strategy"}),d.jsx(Rn,{options:j_,value:n.strategy,onChange:_=>l({strategy:_}),size:"sm"}),n.strategy==="summarize_and_recent"&&d.jsx(Wo,{label:"Summarize at",value:n.summarizeAfter,min:5,max:n.windowSize,step:5,onChange:_=>l({summarizeAfter:_})}),d.jsx(Wo,{label:"Token budget",value:n.tokenBudget,min:1e3,max:6e4,step:1e3,onChange:_=>l({tokenBudget:_}),suffix:"K"}),d.jsx(Ea,{children:"Long-Term Memory"}),d.jsx(Zr,{checked:a.enabled,onChange:_=>c({enabled:_}),label:"Enabled",size:"sm"}),a.enabled&&d.jsxs("div",{className:"flex flex-col gap-2 mt-1",children:[d.jsxs("div",{className:"flex gap-2",children:[d.jsx("div",{className:"flex-1",children:d.jsx(Rn,{options:T_,value:a.store,onChange:_=>c({store:_}),size:"sm",label:"Store"})}),d.jsx("div",{className:"flex-1",children:d.jsx(Rn,{options:D_,value:a.scope,onChange:_=>c({scope:_}),size:"sm",label:"Scope"})})]}),d.jsx(Rn,{options:N_,value:a.embeddingModel,onChange:_=>c({embeddingModel:_}),size:"sm",label:"Embedding Model"}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("div",{className:"flex-1",children:d.jsx(Rn,{options:A_,value:a.recall.strategy,onChange:_=>p({strategy:_}),size:"sm",label:"Recall"})}),d.jsx("div",{className:"flex-1",children:d.jsx(Wo,{label:"K",value:a.recall.k,min:1,max:20,step:1,onChange:_=>p({k:_})})})]}),d.jsx(Wo,{label:"Min score",value:Math.round(a.recall.minScore*100),min:0,max:100,step:5,onChange:_=>p({minScore:_/100})}),d.jsx(Rn,{options:__,value:a.write.mode,onChange:_=>f({mode:_}),size:"sm",label:"Write Mode"}),d.jsx("div",{className:"flex flex-wrap gap-1",children:z_.map(_=>{const T=a.write.extractTypes.includes(_.value);return d.jsx("button",{type:"button","aria-label":`Toggle ${_.label}`,"aria-pressed":a.write.extractTypes.includes(_.value),onClick:()=>m(_.value),className:"text-[13px] px-3 py-2 rounded-full cursor-pointer border-none min-h-[44px]",style:{fontFamily:"'Geist Mono', monospace",background:T?`${_.color}20`:e.isDark?"#1c1c20":"#f0f0f5",color:T?_.color:e.textDim,border:`1px solid ${T?`${_.color}40`:"transparent"}`},children:_.label},_.value)})}),d.jsx(Wo,{label:"Max entries",value:a.maxEntries,min:100,max:1e4,step:100,onChange:_=>c({maxEntries:_})}),d.jsx(Wo,{label:"Token budget",value:a.tokenBudget,min:1e3,max:3e4,step:1e3,onChange:_=>c({tokenBudget:_}),suffix:"K"})]}),d.jsx(Ea,{children:"Working Memory"}),d.jsx(Zr,{checked:s.enabled,onChange:_=>g({enabled:_}),label:"Scratchpad",size:"sm"}),s.enabled&&d.jsx(Wo,{label:"Max tokens",value:s.maxTokens,min:500,max:8e3,step:500,onChange:_=>g({maxTokens:_})})]}),(a.enabled||s.enabled)&&$>0&&d.jsxs("div",{className:"mt-3",children:[d.jsx("div",{className:"text-[13px] tracking-[0.1em] uppercase mb-1.5",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:"Memory budget"}),d.jsxs("div",{className:"flex gap-0.5 h-1.5 rounded overflow-hidden",children:[d.jsx("div",{style:{width:`${n.tokenBudget/$*100}%`,background:"#3498db",borderRadius:2},title:`Session: ${V(n.tokenBudget)}`}),a.enabled&&d.jsx("div",{style:{width:`${a.tokenBudget/$*100}%`,background:"#2ecc71",borderRadius:2},title:`Long-term: ${V(a.tokenBudget)}`}),s.enabled&&d.jsx("div",{style:{width:`${s.tokenBudget/$*100}%`,background:"#f1c40f",borderRadius:2},title:`Working: ${V(s.tokenBudget)}`})]}),d.jsxs("div",{className:"flex justify-between mt-1",children:[d.jsx("div",{className:"flex gap-2",children:[{label:"Session",color:"#3498db",tokens:n.tokenBudget},...a.enabled?[{label:"Long-term",color:"#2ecc71",tokens:a.tokenBudget}]:[],...s.enabled?[{label:"Working",color:"#f1c40f",tokens:s.tokenBudget}]:[]].map(_=>d.jsxs("span",{className:"flex items-center gap-1 text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:[d.jsx("div",{style:{width:4,height:4,borderRadius:1,background:_.color}}),_.label]},_.label))}),d.jsx("span",{className:"text-[13px]",style:{fontFamily:"'Geist Mono', monospace",color:"#FE5000"},children:V($)})]})]})]})}const O_={instruction:{icon:Ti,color:"#9b59b6",label:"Instruction",verb:"Add to persona"},constraint:{icon:im,color:"#2ecc71",label:"Constraint",verb:"Add constraint"},workflow:{icon:pn,color:"#e67e22",label:"Workflow",verb:"Add step"},knowledge:{icon:_i,color:"#3498db",label:"Knowledge",verb:"Add source"},mcp:{icon:zi,color:"#2ecc71",label:"MCP Server",verb:"Add server"},skill:{icon:pn,color:"#f1c40f",label:"Skill",verb:"Add skill"}};function F_(){const e=we(),n=We(D=>D.facts),a=We(D=>D.removeFact),s=se(D=>D.updateInstruction),i=se(D=>D.instructionState),l=se(D=>D.addWorkflowStep),c=se(D=>D.addChannel),p=Ra(D=>D.checkpoint),[f,m]=z.useState(!0),[g,x]=z.useState(!1),[b,v]=z.useState(null),[k,w]=z.useState(new Set),[C,M]=z.useState(""),N=z.useCallback(async()=>{if(n.length!==0){x(!0),M(""),w(new Set);try{const D=await b_(n);v(D),f&&m(!1)}catch(D){M(D instanceof Error?D.message:"Analysis failed")}x(!1)}},[n,f]),S=z.useCallback(D=>{const A=D.payload;switch(D.target){case"instruction":if(A.instructionAppend){const L=i.persona;s({persona:L?`${L}
331
+
332
+ ${A.instructionAppend}`:A.instructionAppend})}break;case"constraint":if(A.constraintText){const L=i.constraints.customConstraints;s({constraints:{...i.constraints,customConstraints:L?`${L}
333
+ ${A.constraintText}`:A.constraintText}})}break;case"workflow":A.workflowStep&&l({label:A.workflowStep.label,action:A.workflowStep.action,tool:"",condition:"always",conditionText:""});break;case"knowledge":A.knowledgeSource&&c({sourceId:`promoted-${crypto.randomUUID().slice(0,8)}`,name:A.knowledgeSource.name,path:"",category:"file",knowledgeType:A.knowledgeSource.type,depth:0,baseTokens:500});break}w(L=>new Set([...L,D.factId])),a(D.factId)},[i,s,l,c,a]),E=z.useCallback(()=>{if(b){for(const D of b.promotions)k.has(D.factId)||S(D);p("Facts promoted to agent design")}},[b,k,S,p]);if(n.length===0&&!b)return null;const I=b?b.promotions.filter(D=>!k.has(D.factId)).length:0;return d.jsxs(Ri,{icon:Uc,label:"Insights",color:"#FE5000",badge:b?`${I} suggestion${I!==1?"s":""}`:`${n.length} facts to analyze`,collapsed:f,onToggle:()=>m(!f),children:[!b&&d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx("div",{className:"text-[12px] leading-relaxed",style:{color:e.textDim},children:"Analyze your accumulated facts and discover which ones should become permanent parts of your agent — instructions, constraints, workflow steps, or knowledge sources."}),d.jsxs("button",{type:"button",onClick:N,disabled:g||n.length===0,className:"flex items-center justify-center gap-1.5 w-full px-3 py-2.5 rounded text-[13px] tracking-wide uppercase cursor-pointer border-none",style:{background:g?"#CC4000":"#FE5000",color:"#fff",fontFamily:"'Geist Mono', monospace",opacity:g||n.length===0?.6:1},children:[g?d.jsx(yt,{size:11,className:"animate-spin motion-reduce:animate-none"}):d.jsx(Uc,{size:11}),g?"Analyzing...":`Analyze ${n.length} fact${n.length!==1?"s":""}`]})]}),C&&d.jsx("div",{role:"alert",className:"text-[12px] px-2 py-1.5 rounded mt-1",style:{background:"#ff000012",color:"#ff4444",border:"1px solid #ff000020"},children:C}),b&&d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"text-[12px] leading-relaxed px-2 py-1.5 rounded",style:{background:"#FE500008",color:e.textSecondary,border:"1px solid #FE500015"},children:[b.summary,b.versionImpact!=="none"&&d.jsxs("span",{className:"text-[12px] ml-1.5 px-1.5 py-0.5 rounded-full",style:{fontFamily:"'Geist Mono', monospace",background:b.versionImpact==="major"?"#e74c3c20":b.versionImpact==="minor"?"#f1c40f20":"#2ecc7120",color:b.versionImpact==="major"?"#e74c3c":b.versionImpact==="minor"?"#f1c40f":"#2ecc71"},children:[b.versionImpact," bump"]})]}),b.promotions.map(D=>{const A=O_[D.target],L=k.has(D.factId);if(!A)return null;const P=A.icon;return d.jsxs("div",{className:"rounded-lg overflow-hidden",style:{border:`1px solid ${L?"#2ecc7130":e.border}`,opacity:L?.5:1,transition:"opacity 300ms"},children:[d.jsxs("div",{className:"px-3 py-2 text-[13px]",style:{background:e.surfaceElevated,color:e.textSecondary},children:['"',D.factContent,'"']}),d.jsxs("div",{className:"px-3 py-2 flex items-start gap-2",style:{borderTop:`1px solid ${e.isDark?"#1e1e22":"#eee"}`},children:[d.jsx("div",{className:"mt-0.5",style:{width:16,height:16,borderRadius:4,background:`${A.color}15`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:d.jsx(P,{size:9,style:{color:A.color}})}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[d.jsx("span",{className:"text-[12px] px-1.5 py-0.5 rounded-full",style:{fontFamily:"'Geist Mono', monospace",background:`${A.color}15`,color:A.color},children:A.label}),d.jsxs("span",{className:"text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textFaint},children:[Math.round(D.confidence*100),"%"]})]}),d.jsx("div",{className:"text-[12px] leading-snug",style:{color:e.textPrimary},children:D.suggestion}),d.jsx("div",{className:"text-[13px] mt-0.5",style:{color:e.textDim},children:D.reason})]}),L?d.jsxs("div",{className:"flex items-center gap-1 text-[13px] px-2 py-1 shrink-0",style:{color:"#2ecc71"},children:[d.jsx(_t,{size:9})," Applied"]}):d.jsxs("button",{type:"button","aria-label":A.verb,onClick:()=>S(D),className:"flex items-center gap-1 text-[13px] px-2 py-1 rounded cursor-pointer border-none shrink-0",style:{background:`${A.color}15`,color:A.color,fontFamily:"'Geist Mono', monospace"},children:[d.jsx(Nx,{size:9}),A.verb]})]})]},D.factId)}),I>0&&d.jsxs("div",{className:"flex gap-2 mt-1",children:[d.jsxs("button",{type:"button",onClick:E,className:"flex items-center justify-center gap-1.5 flex-1 px-3 py-2 rounded text-[12px] tracking-wide uppercase cursor-pointer border-none",style:{background:"#FE5000",color:"#fff",fontFamily:"'Geist Mono', monospace"},children:[d.jsx(Nx,{size:10})," Apply all (",I,")"]}),d.jsxs("button",{type:"button",onClick:()=>{v(null),w(new Set)},className:"flex items-center gap-1 px-3 py-2 rounded text-[12px] cursor-pointer",style:{background:"transparent",border:`1px solid ${e.border}`,color:e.textDim,fontFamily:"'Geist Mono', monospace"},children:[d.jsx(um,{size:9})," Re-analyze"]})]}),I===0&&b.promotions.length>0&&d.jsxs("div",{className:"flex items-center justify-center gap-1.5 py-2 text-[12px]",style:{color:"#2ecc71"},children:[d.jsx(_t,{size:11})," All suggestions applied",d.jsx("button",{type:"button",onClick:()=>{v(null),w(new Set)},className:"ml-2 text-[13px] cursor-pointer border-none bg-transparent underline",style:{color:e.textDim},children:"Re-analyze"})]}),b.promotions.length===0&&d.jsx("div",{className:"text-[12px] text-center py-2",style:{color:e.textDim},children:"All facts are contextual — no promotions suggested"})]})]})}function I_(){const e=we(),{collectContextState:n,restoreContextState:a}=se(),[s,i]=z.useState(""),[l,c]=z.useState(!1),[p,f]=z.useState(!1),[m,g]=z.useState([]);z.useEffect(()=>{const w=[];for(let C=0;C<localStorage.length;C++){const M=localStorage.key(C);M&&M.startsWith("modular-ctx-")&&w.push(M.replace("modular-ctx-",""))}g(w)},[]);const x=()=>{a({channels:[],mcpServers:[],skills:[],connectors:[]})},b=()=>{if(!s.trim())return;const w=n();localStorage.setItem(`modular-ctx-${s}`,JSON.stringify(w)),i(""),c(!1),g(C=>[...new Set([...C,s])])},v=w=>{const C=localStorage.getItem(`modular-ctx-${w}`);C&&a(JSON.parse(C)),f(!1)},k=()=>{window.confirm("Clear all context (channels, MCPs, skills, connectors)?")&&a({channels:[],mcpServers:[],skills:[],connectors:[]})};return d.jsxs("div",{className:"sticky top-0 z-10 px-5 py-2.5 border-b flex items-center gap-2",style:{background:e.surfaceElevated,borderColor:e.border},children:[d.jsx("span",{className:"text-[13px] uppercase tracking-wider font-semibold flex-shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim,minWidth:55},children:"Context"}),d.jsx("button",{type:"button","aria-label":"Demo",onClick:x,className:"p-1.5 rounded border-none cursor-pointer transition-colors",style:{background:"transparent",color:e.textDim},onMouseEnter:w=>{w.currentTarget.style.color="#FE5000"},onMouseLeave:w=>{w.currentTarget.style.color=e.textDim},onFocus:w=>{w.currentTarget.style.color="#FE5000"},onBlur:w=>{w.currentTarget.style.color=e.textDim},children:d.jsx(cu,{size:10})}),d.jsx("button",{type:"button","aria-label":"Save",onClick:()=>c(!0),className:"p-1.5 rounded border-none cursor-pointer transition-colors",style:{background:"transparent",color:e.textDim},onMouseEnter:w=>{w.currentTarget.style.color="#FE5000"},onMouseLeave:w=>{w.currentTarget.style.color=e.textDim},onFocus:w=>{w.currentTarget.style.color="#FE5000"},onBlur:w=>{w.currentTarget.style.color=e.textDim},children:d.jsx(dm,{size:10})}),d.jsxs("div",{className:"relative",children:[d.jsx("button",{type:"button","aria-label":"Load",onClick:()=>f(!p),className:"p-1.5 rounded border-none cursor-pointer transition-colors",style:{background:"transparent",color:e.textDim},onMouseEnter:w=>{w.currentTarget.style.color="#FE5000"},onMouseLeave:w=>{w.currentTarget.style.color=e.textDim},onFocus:w=>{w.currentTarget.style.color="#FE5000"},onBlur:w=>{w.currentTarget.style.color=e.textDim},children:d.jsx(lm,{size:10})}),p&&m.length>0&&d.jsx("div",{className:"absolute top-full mt-1 left-0 rounded shadow-lg z-20 min-w-max",style:{background:e.surfaceElevated,border:`1px solid ${e.border}`},children:m.map(w=>d.jsx("button",{type:"button",onClick:()=>v(w),className:"block w-full text-left px-3 py-1.5 text-[12px] border-none cursor-pointer",style:{background:"transparent",color:e.textSecondary},onMouseEnter:C=>{C.currentTarget.style.background="#FE500010"},onFocus:C=>{C.currentTarget.style.background="#FE500010"},onBlur:C=>{C.currentTarget.style.background="transparent"},children:w},w))})]}),d.jsx("button",{type:"button","aria-label":"Clear",onClick:k,className:"p-1.5 rounded border-none cursor-pointer transition-colors",style:{background:"transparent",color:e.textDim},onMouseEnter:w=>{w.currentTarget.style.color="#ff4444"},onMouseLeave:w=>{w.currentTarget.style.color=e.textDim},onFocus:w=>{w.currentTarget.style.color="#ff4444"},onBlur:w=>{w.currentTarget.style.color=e.textDim},children:d.jsx(uu,{size:10})}),l&&d.jsxs("div",{className:"absolute top-12 left-5 rounded shadow-lg p-2 z-20 min-w-max",style:{background:e.surfaceElevated,border:`1px solid ${e.border}`},children:[d.jsx("input",{type:"text",value:s,onChange:w=>i(w.target.value),placeholder:"Context name...",autoFocus:!0,className:"px-2 py-1 rounded text-[12px] outline-none mb-1 block",style:{background:e.inputBg,border:`1px solid ${e.border}`,color:e.textPrimary},onKeyDown:w=>{w.key==="Enter"&&b()}}),d.jsxs("div",{className:"flex gap-1",children:[d.jsx("button",{type:"button",onClick:b,className:"flex-1 px-2 py-1 rounded text-[13px] font-semibold border-none cursor-pointer",style:{background:"#FE5000",color:"#fff"},children:"Save"}),d.jsx("button",{type:"button",onClick:()=>{i(""),c(!1)},className:"flex-1 px-2 py-1 rounded text-[13px] border-none cursor-pointer",style:{background:e.border,color:e.textDim},children:"Cancel"})]})]})]})}function L_(){return d.jsxs("div",{className:"flex flex-col",children:[d.jsx(I_,{}),d.jsx(S_,{}),d.jsx(C_,{}),d.jsx(M_,{}),d.jsx(E_,{}),d.jsx($_,{}),d.jsx(F_,{})]})}const $v=[{id:"bot",icon:Ti},{id:"brain",icon:Ni},{id:"zap",icon:pn},{id:"flame",icon:nv},{id:"lightbulb",icon:Uc},{id:"target",icon:cu},{id:"rocket",icon:n4},{id:"shield",icon:fm},{id:"microscope",icon:O3},{id:"chart",icon:rm},{id:"palette",icon:lv},{id:"file",icon:Di},{id:"drama",icon:FN},{id:"star",icon:x4},{id:"gem",icon:JN},{id:"bird",icon:nN},{id:"bug",icon:lN},{id:"cat",icon:uN},{id:"dog",icon:RN},{id:"heart",icon:d3}];function B_({avatarId:e,size:n=20}){const a=$v.find(s=>s.id===e)?.icon??Ti;return d.jsx(a,{size:n})}function P_({open:e,onClose:n,onSave:a,onDelete:s,initial:i="",title:l}){const c=we(),[p,f]=z.useState(i),m=z.useRef(null);z.useEffect(()=>{f(i)},[i,e]),z.useEffect(()=>{e&&m.current&&m.current.focus()},[e]);const g=v=>{v.key==="Escape"&&n()},x=v=>{v.target===v.currentTarget&&n()},b=()=>{a(p),n()};return e?d.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},onClick:x,children:d.jsxs("div",{style:{background:c.surfaceOpaque,border:`1px solid ${c.border}`,borderRadius:"12px",width:480,maxHeight:"80vh",overflow:"auto",display:"flex",flexDirection:"column"},onClick:v=>v.stopPropagation(),onKeyDown:g,children:[d.jsxs("div",{className:"flex items-center justify-between px-6 py-4",style:{borderBottom:`1px solid ${c.border}`},children:[d.jsx("span",{style:{color:c.textPrimary,fontSize:17,fontWeight:600},children:l}),d.jsx("button",{type:"button",onClick:n,className:"border-none bg-transparent cursor-pointer p-1 rounded flex items-center justify-center min-w-[44px] min-h-[44px]",style:{color:c.textDim},"aria-label":"Close",children:d.jsx(jt,{size:16})})]}),d.jsx("div",{className:"px-6 py-4 flex flex-col gap-3 flex-1",children:d.jsx(Aa,{ref:m,value:p,onChange:v=>f(v.target.value),onKeyDown:g,placeholder:"Enter text...",style:{minHeight:80}})}),d.jsxs("div",{className:"flex items-center justify-between px-6 py-4",style:{borderTop:`1px solid ${c.border}`},children:[s?d.jsx("button",{type:"button",onClick:s,className:"text-[16px] px-4 py-2 rounded cursor-pointer border-none",style:{color:"#e74c3c",background:"transparent",border:"1px solid #e74c3c30"},children:"Delete"}):d.jsx("div",{}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("button",{type:"button",onClick:n,className:"text-[16px] px-4 py-2 rounded cursor-pointer border-none",style:{color:c.textPrimary,background:"transparent",border:`1px solid ${c.border}`},children:"Cancel"}),d.jsx("button",{type:"button",onClick:b,className:"text-[16px] px-5 py-2 rounded cursor-pointer border-none",style:{background:"#FE5000",color:"white"},children:"Save"})]})]})]})}):null}function H_({open:e,onClose:n}){const a=we(),s=se(C=>C.workflowSteps),i=se(C=>C.addWorkflowStep),l=se(C=>C.updateWorkflowStep),c=se(C=>C.removeWorkflowStep),p=se(C=>C.updateWorkflowSteps),f=C=>{C.key==="Escape"&&n()},m=C=>{C.target===C.currentTarget&&n()},g=()=>{i({label:"",action:"action",tool:"",condition:"always"})},[x,b]=z.useState(!1),[v,k]=z.useState(""),w=z.useCallback(async()=>{b(!0),k("");try{const C=s.filter(M=>M.label.trim()).map(M=>M.label.trim());if(C.length>0){const{refineWorkflowSteps:M}=await ea(async()=>{const{refineWorkflowSteps:S}=await Promise.resolve().then(()=>K4);return{refineWorkflowSteps:S}},void 0),N=await M(C);N&&p(N)}else{const M=await gm();M&&p(M)}}catch(C){k(C instanceof Error?C.message:"Generation failed")}b(!1)},[p,s]);return e?d.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},onClick:m,children:d.jsxs("div",{style:{background:a.surfaceOpaque,border:`1px solid ${a.border}`,borderRadius:"12px",width:640,maxHeight:"85vh",overflow:"auto",display:"flex",flexDirection:"column"},onClick:C=>C.stopPropagation(),onKeyDown:f,children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,paddingLeft:20,paddingRight:20,paddingTop:16,paddingBottom:16,borderBottom:`1px solid ${a.border}`},children:[d.jsx("div",{style:{width:4,height:18,borderRadius:2,background:"#e67e22",opacity:.8}}),d.jsx("span",{style:{color:a.textPrimary,fontSize:17,fontWeight:600,flex:1},children:"Workflow Editor"}),d.jsxs("span",{style:{color:a.textMuted,fontSize:13,fontFamily:"'Geist Mono', monospace"},children:[s.length," ",s.length===1?"step":"steps"]}),d.jsx("button",{type:"button",onClick:n,className:"border-none bg-transparent cursor-pointer p-1 rounded flex items-center justify-center min-w-[44px] min-h-[44px]",style:{color:a.textDim},"aria-label":"Close",children:d.jsx(jt,{size:16})})]}),d.jsx("div",{style:{padding:24,flex:1,overflowY:"auto"},children:s.length===0?d.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:200},children:d.jsx("span",{style:{color:a.textMuted,fontSize:16},children:'No workflow steps yet. Click "Add Step" to begin.'})}):d.jsx("div",{style:{display:"flex",flexDirection:"column"},children:s.map((C,M)=>d.jsxs("div",{children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,paddingTop:12,paddingBottom:12},children:[d.jsx("div",{style:{width:28,height:28,borderRadius:"50%",background:"#e67e22",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:d.jsx("span",{style:{color:"white",fontSize:13,fontWeight:600,fontFamily:"'Geist Mono', monospace"},children:M+1})}),d.jsx("div",{style:{flex:1},children:d.jsx("input",{type:"text",value:C.label,onChange:N=>l(C.id,{label:N.target.value}),placeholder:"Step label",className:"w-full px-3 py-2 rounded-md outline-none nodrag",style:{background:a.inputBg,border:`1px solid ${a.border}`,color:a.textPrimary,fontFamily:"'Geist Sans', sans-serif",fontSize:14,lineHeight:1.5}})}),d.jsx("span",{style:{fontSize:13,fontFamily:"'Geist Mono', monospace",fontWeight:600,paddingLeft:8,paddingRight:8,paddingTop:3,paddingBottom:3,borderRadius:4,background:"#e67e2220",color:"#e67e22",textTransform:"uppercase",flexShrink:0},children:C.action||"action"}),d.jsx("button",{type:"button",onClick:()=>c(C.id),className:"border-none bg-transparent cursor-pointer p-1 flex items-center justify-center",style:{color:a.textDim,minWidth:32,minHeight:32},children:d.jsx(jt,{size:12})})]}),M<s.length-1&&d.jsx("div",{style:{width:2,height:12,background:"#e67e2220",marginLeft:12}})]},C.id))})}),v&&d.jsx("div",{style:{padding:"0 24px 12px"},children:d.jsx("div",{className:"text-[13px] px-3 py-2 rounded",style:{background:"#ff000012",color:"#e74c3c",border:"1px solid #e74c3c20"},children:v})}),d.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:20,paddingRight:20,paddingTop:16,paddingBottom:16,borderTop:`1px solid ${a.border}`},children:[d.jsxs("button",{type:"button",onClick:g,className:"flex items-center gap-1 text-[14px] px-3 py-2 rounded cursor-pointer border-none",style:{color:a.textPrimary,background:"transparent",border:`1px solid ${a.border}`},children:[d.jsx(bt,{size:11}),"Add Step"]}),d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[d.jsxs("button",{type:"button",onClick:w,disabled:x,className:"flex items-center gap-1 text-[14px] px-3 py-2 rounded cursor-pointer border-none",style:{color:a.textPrimary,background:"transparent",border:`1px solid ${a.border}`,opacity:x?.6:1},children:[x?d.jsx(yt,{size:11,style:{animation:"spin 1s linear infinite"}}):d.jsx(La,{size:11}),"Generate"]}),d.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-1 text-[14px] px-5 py-2 rounded cursor-pointer border-none",style:{background:"#FE5000",color:"white"},children:[d.jsx(_t,{size:11}),"Done"]})]})]})]})}):null}const U_=`You are an expert prompt engineer. Your job is to take a user's rough brain dump about an AI agent they want to build, and transform it into structured, high-quality agent instructions following Anthropic's prompting best practices.
334
+
335
+ Given the user's rough input, produce a JSON response with this exact structure:
336
+ {
337
+ "persona": "<2-4 sentence persona description. Be specific about expertise, domain, and communication style. Use 'You are...' framing>",
338
+ "tone": "<one of: formal, neutral, casual>",
339
+ "expertise": <1-5 number, where 1=beginner-friendly and 5=expert-level>,
340
+ "constraints": [
341
+ "<clear, actionable constraint in imperative voice>"
342
+ ],
343
+ "scopeDefinition": "<one sentence: what the agent handles and what it does NOT handle>",
344
+ "objectives": {
345
+ "primary": "<one clear sentence describing the agent's primary goal>",
346
+ "successCriteria": ["<measurable criterion>"],
347
+ "failureModes": ["<specific failure to avoid>"]
348
+ }
349
+ }
350
+
351
+ Follow these rules:
352
+ 1. Be specific — replace vague descriptions with concrete, actionable language
353
+ 2. Use XML-tag-friendly language (the output will be assembled into a system prompt)
354
+ 3. Infer reasonable constraints from the domain (e.g., a medical agent should cite sources)
355
+ 4. Generate 2-4 success criteria and 2-3 failure modes based on the domain
356
+ 5. Keep the persona concise but distinctive — give it a clear identity
357
+ 6. If the input mentions tools, APIs, or specific capabilities, reference them in constraints
358
+ 7. Think step by step about what makes an excellent agent for this use case before writing
359
+
360
+ Output ONLY the JSON object. No markdown fences, no explanation.`;async function G_(e,n){if(!n.trim())throw new Error("Nothing to refine");const a=Qe.getState(),s=a.providers.find(g=>g.id===a.selectedProviderId);if(!s)throw new Error("No provider configured — add one in Settings");const i=typeof s.models?.[0]=="object"?s.models[0].id:s.models?.[0]||"claude-sonnet-4-20250514",l=U_,p=s.authMethod==="claude-agent-sdk"?await Yc({prompt:n,model:i,systemPrompt:l,maxTurns:1}):await Kc({providerId:s.id,model:i,messages:[{role:"system",content:l},{role:"user",content:n}],temperature:.3,maxTokens:1024});try{return JSON.parse(p)}catch{}const f=p.match(/```(?:json)?\s*([\s\S]*?)```/);if(f)try{return JSON.parse(f[1].trim())}catch{}const m=p.match(/\{[\s\S]*\}/);if(m)try{return JSON.parse(m[0])}catch{}throw new Error("Could not parse agent structure from LLM response")}function uf(e){return e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}const Ov=z.forwardRef(function({variant:n="secondary",size:a="md",icon:s,iconRight:i,loading:l,children:c,className:p="",style:f,disabled:m,...g},x){const b=we(),v={sm:28,md:32},k={sm:"0 8px",md:"0 14px"},w={sm:12,md:13},M={primary:{bg:"#FE5000",color:"#fff",border:"transparent",hoverBg:"#e54700"},secondary:{bg:b.surfaceElevated,color:b.textSecondary,border:b.border,hoverBg:b.isDark?"#2a2a30":"#eee"},ghost:{bg:"transparent",color:b.textSecondary,border:"transparent",hoverBg:b.isDark?"#ffffff08":"#00000008"},danger:{bg:b.statusErrorBg,color:b.statusError,border:"transparent",hoverBg:b.isDark?"#ff4d4f20":"#ff4d4f15"}}[n];return d.jsxs("button",{ref:x,type:"button",disabled:m||l,className:`ds-btn flex items-center justify-center gap-1.5 rounded-lg cursor-pointer border font-semibold tracking-wide uppercase nodrag ${p}`,style:{height:v[a],padding:k[a],fontSize:w[a],fontFamily:"'Geist Mono', monospace",background:M.bg,color:M.color,borderColor:M.border,opacity:m?.5:1,cursor:m?"not-allowed":"pointer",transition:"background 0.15s, opacity 0.15s",...f},onMouseEnter:N=>{m||(N.currentTarget.style.background=M.hoverBg)},onMouseLeave:N=>{N.currentTarget.style.background=M.bg},...g,children:[l?d.jsx("span",{className:"animate-spin text-[12px]",children:"⟳"}):s,c,i]})});function q_({variant:e="neutral",children:n,dot:a,size:s="sm"}){const i=we(),c={success:{bg:i.statusSuccessBg,fg:i.statusSuccess},warning:{bg:i.statusWarningBg,fg:i.statusWarning},error:{bg:i.statusErrorBg,fg:i.statusError},info:{bg:"#3498db15",fg:"#3498db"},neutral:{bg:i.badgeBg,fg:i.textSecondary}}[e],p=s==="sm"?8:9,f=s==="sm"?"1px 6px":"2px 8px";return d.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full font-semibold uppercase tracking-wider",style:{background:c.bg,color:c.fg,fontSize:p,padding:f,fontFamily:"'Geist Mono', monospace"},children:[a&&d.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:c.fg}}),n]})}function K_({open:e,onClose:n,title:a,children:s,footer:i,width:l=520}){const c=we(),p=z.useRef(null);return z.useEffect(()=>{if(!e)return;const f=m=>{m.key==="Escape"&&n()};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[e,n]),z.useEffect(()=>{e&&p.current?.focus()},[e]),e?nu.createPortal(d.jsxs("div",{className:"fixed inset-0 z-[200] flex items-center justify-center",onClick:n,children:[d.jsx("div",{className:"absolute inset-0",style:{background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)"}}),d.jsxs("div",{ref:p,tabIndex:-1,onClick:f=>f.stopPropagation(),className:"relative flex flex-col rounded-xl overflow-hidden outline-none",style:{width:l,maxWidth:"90vw",maxHeight:"80vh",background:c.surfaceOpaque,border:`1px solid ${c.border}`,boxShadow:`0 16px 48px ${c.isDark?"rgba(0,0,0,0.6)":"rgba(0,0,0,0.15)"}`},children:[a&&d.jsxs("div",{className:"flex items-center justify-between px-4 py-3 shrink-0",style:{borderBottom:`1px solid ${c.borderSubtle}`},children:[d.jsx("span",{className:"text-[17px] font-bold",style:{fontFamily:"'Geist Mono', monospace",color:c.textPrimary},children:a}),d.jsx("button",{type:"button",onClick:n,className:"flex items-center justify-center w-7 h-7 rounded-md cursor-pointer border-none bg-transparent",style:{color:c.textDim},children:d.jsx(jt,{size:14})})]}),d.jsx("div",{className:"flex-1 overflow-y-auto",children:s}),i&&d.jsx("div",{className:"flex items-center justify-end gap-2 px-4 py-3 shrink-0",style:{borderTop:`1px solid ${c.borderSubtle}`},children:i})]})]}),document.body):null}const Y_=z.forwardRef(function({icon:n,size:a="md",variant:s="ghost",tooltip:i,active:l,className:c="",style:p,...f},m){const g=we(),x=a==="sm"?24:32,v={ghost:{bg:l?"#FE500020":"transparent",color:l?"#FE5000":g.textDim,hoverBg:g.isDark?"#ffffff10":"#00000008"},secondary:{bg:g.surfaceElevated,color:g.textSecondary,hoverBg:g.isDark?"#2a2a30":"#eee"},danger:{bg:"transparent",color:g.statusError,hoverBg:g.statusErrorBg}}[s];return d.jsx("button",{ref:m,type:"button",title:i,"aria-label":i,className:`ds-icon-btn flex items-center justify-center rounded-md cursor-pointer border-none nodrag ${c}`,style:{width:x,height:x,background:v.bg,color:v.color,transition:"background 0.15s",...p},onMouseEnter:k=>k.currentTarget.style.background=v.hoverBg,onMouseLeave:k=>k.currentTarget.style.background=v.bg,...f,children:n})});function V_({type:e}){const n={major:"#FE5000",minor:"#3498db",patch:"#888"};return d.jsx(vN,{size:6,fill:n[e],stroke:"none"})}function W_({v:e,isCurrent:n,onRestore:a,onDelete:s}){const i=we(),[l,c]=z.useState(!1);return d.jsxs("div",{className:"rounded-lg overflow-hidden",style:{border:`1px solid ${n?"#FE500040":i.borderSubtle}`,background:n?"#FE500008":"transparent"},children:[d.jsxs("button",{type:"button",onClick:()=>c(!l),className:"w-full min-h-[36px] flex items-center gap-2 px-3 py-2 cursor-pointer border-none bg-transparent text-left",children:[d.jsx(ta,{size:10,style:{color:i.textDim,transform:l?"rotate(90deg)":"none",transition:"transform 0.15s"}}),d.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[d.jsxs("span",{className:"text-[14px] font-bold shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:n?"#FE5000":i.textPrimary},children:["v",e.version]}),d.jsx("span",{className:"text-[12px] truncate",style:{color:i.textMuted},children:e.label||"Checkpoint"})]}),n&&d.jsx(q_,{variant:"success",size:"sm",dot:!0,children:"CURRENT"}),d.jsx("span",{className:"text-[13px] shrink-0",style:{color:i.textFaint},children:new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),l&&d.jsxs("div",{className:"px-3 pb-2 flex flex-col gap-1.5",children:[e.changes.length===0&&d.jsx("div",{className:"text-[12px]",style:{color:i.textMuted},children:"No changelog entries recorded for this version."}),e.changes.map((p,f)=>d.jsxs("div",{className:"flex items-center gap-2 text-[12px]",style:{color:i.textSecondary},children:[d.jsx(V_,{type:p.type}),d.jsx("span",{className:"uppercase text-[12px] font-semibold w-14 shrink-0",style:{color:i.textDim},children:p.category}),d.jsx("span",{children:p.description})]},f)),d.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[!n&&d.jsx(Ov,{variant:"secondary",size:"sm",icon:d.jsx(um,{size:10}),onClick:a,children:"Restore"}),d.jsx(Y_,{icon:d.jsx(uu,{size:11}),variant:"danger",size:"sm",tooltip:"Delete version",onClick:s})]})]})]})}function X_(){const e=we(),{versions:n,currentVersion:a,dirty:s,checkpoint:i}=Ra(),[l,c]=z.useState(!1);return d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",onClick:()=>c(!0),className:"flex items-center gap-1.5 px-2 h-8 rounded-lg cursor-pointer border-none",style:{background:s?"#FE500015":"transparent",color:s?"#FE5000":e.textDim,fontFamily:"'Geist Mono', monospace",fontSize:12,fontWeight:600,transition:"background 0.15s"},title:"Version history",children:[d.jsx(Us,{size:12}),"v",a,s&&d.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#FE5000] animate-pulse"})]}),d.jsx(K_,{open:l,onClose:()=>c(!1),title:"Version History",width:480,footer:d.jsx(Ov,{variant:"primary",size:"sm",icon:d.jsx(dm,{size:10}),onClick:()=>{i()},children:"Save Checkpoint"}),children:d.jsxs("div",{className:"flex flex-col gap-1.5 p-3 max-h-[60vh] overflow-y-auto overscroll-contain pr-1",children:[n.length===0&&d.jsxs("div",{className:"py-8 text-center",children:[d.jsx(Us,{size:20,style:{margin:"0 auto 8px",color:e.textFaint,opacity:.3}}),d.jsx("div",{className:"text-[12px]",style:{color:e.textFaint},children:"No versions yet"}),d.jsx("div",{className:"text-[12px] mt-1",style:{color:e.textMuted},children:"Make changes to your agent — versions are created automatically"})]}),[...n].reverse().map(p=>d.jsx(W_,{v:p,isCurrent:p.version===a,onRestore:()=>{Ra.getState().restoreVersion(p.version),c(!1)},onDelete:()=>Ra.getState().deleteVersion(p.id)},p.id))]})})]})}function Z_({value:e,onChange:n,t:a}){return d.jsx("select",{value:e,onChange:s=>n(s.target.value),className:"appearance-none cursor-pointer outline-none text-[14px] h-8 pl-3 pr-7 rounded-lg",style:{fontFamily:"'Geist Sans', sans-serif",background:a.surfaceOpaque,border:`1px solid ${a.border}`,color:a.isDark?a.textSecondary:"#1a1a20",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3E%3Cpath d='M0 2l4 4 4-4' fill='none' stroke='%23${a.isDark?"555":"999"}' stroke-width='1.5'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 8px center"},children:lb.map(s=>d.jsx("option",{value:s.id,children:s.label},s.id))})}function Q_(){const e=we(),n=se(_=>_.agentMeta),a=se(_=>_.setAgentMeta),s=se(_=>_.outputFormat),i=se(_=>_.setOutputFormat),l=se(_=>_.loadAgent),c=se(_=>_.resetAgent),p=se(_=>_.channels),f=se(_=>_.selectedModel),m=se(_=>_.outputFormats),g=se(_=>_.prompt),x=se(_=>_.tokenBudget),b=se(_=>_.mcpServers),v=se(_=>_.skills),[k,w]=z.useState([]),[C,M]=z.useState(!1),[N,S]=z.useState(!1),[E,I]=z.useState(""),[D,A]=z.useState(!1),[L,P]=z.useState(!1),W=z.useRef(null);z.useEffect(()=>()=>{W.current&&window.clearTimeout(W.current)},[]);const $=z.useCallback(async()=>{try{const _=await fetch(`${Ee}/agents`);if(!_.ok)return;const T=await _.json();w(T.data??[])}catch{}},[]),V=()=>{const _=se.getState(),T=UA({channels:p,selectedModel:f,outputFormat:s,outputFormats:m,prompt:g,tokenBudget:x,mcpServers:b,skills:v,agentMeta:n,agentConfig:_.agentConfig,connectors:_.connectors,instructionState:_.instructionState,workflowSteps:_.workflowSteps}),B=T.match(/^name:\s*(.+)$/m)?.[1]?.trim()??"modular-agent";hu(T,B)},X=z.useCallback(()=>{P(!0),W.current&&window.clearTimeout(W.current),W.current=window.setTimeout(()=>{P(!1)},2e3)},[]),H=z.useCallback(async _=>{const T=(_??n.name).trim();if(!T){I(n.name),S(!0);return}T!==n.name&&a({name:T}),A(!0);try{const B=xm(T),G=bm();if(G.id=B,G.agentMeta={...G.agentMeta,name:T},!(await fetch(`${Ee}/agents/${encodeURIComponent(B)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)})).ok)return;S(!1),X()}catch{}finally{A(!1)}},[n.name,a,X]);return d.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 shrink-0 border-b select-none",style:{position:"sticky",top:0,zIndex:10,background:e.surface,borderColor:e.border},children:[d.jsx("span",{className:"text-[14px] font-bold tracking-[0.12em] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:e.textPrimary,minWidth:"100px"},children:n.name||"New Agent"}),d.jsx(X_,{}),d.jsx(Z_,{value:s,onChange:_=>i(_),t:e}),d.jsx("div",{className:"flex-1"}),d.jsxs("button",{type:"button",onClick:()=>c(),className:"flex items-center justify-center gap-1.5 h-8 px-2.5 rounded-lg text-[14px] font-medium cursor-pointer border-none",style:{background:"#FE500012",color:"#FE5000",transition:"background 0.15s"},onMouseEnter:_=>{_.currentTarget.style.background="#FE500025"},onMouseLeave:_=>{_.currentTarget.style.background="#FE500012"},title:"Create new agent",children:[d.jsx(bt,{size:13}),"New"]}),d.jsxs("div",{className:"relative",children:[d.jsxs("button",{type:"button",onClick:()=>{M(!C),C||$()},className:"flex items-center justify-center gap-1.5 h-8 px-2.5 rounded-lg text-[14px] font-medium cursor-pointer border-none",style:{background:"#FE500012",color:"#FE5000",transition:"background 0.15s"},onMouseEnter:_=>{_.currentTarget.style.background="#FE500025"},onMouseLeave:_=>{_.currentTarget.style.background="#FE500012"},title:"Load saved agent",children:[d.jsx(lm,{size:13}),"Load"]}),C&&d.jsx("div",{className:"absolute top-full right-0 mt-1 z-50 min-w-[260px] max-h-[300px] overflow-y-auto rounded-lg shadow-lg",style:{background:e.surface,border:`1px solid ${e.border}`},children:k.length===0?d.jsx("div",{className:"px-3 py-4 text-[14px] text-center",style:{color:e.textDim},children:"No saved agents found"}):k.map(_=>d.jsxs("button",{type:"button",onClick:()=>{l(_.id),M(!1)},className:"w-full text-left px-3 py-2 border-none cursor-pointer block",style:{background:"transparent",color:e.textPrimary},onMouseEnter:T=>{T.currentTarget.style.background=e.surfaceHover},onMouseLeave:T=>{T.currentTarget.style.background="transparent"},children:[d.jsx("div",{className:"text-[14px] font-medium",children:_.agentMeta?.name||_.id}),_.agentMeta?.description&&d.jsx("div",{className:"text-[12px] mt-0.5",style:{color:e.textDim},children:_.agentMeta.description.length>80?_.agentMeta.description.slice(0,80)+"…":_.agentMeta.description})]},_.id))})]}),d.jsxs("button",{type:"button",onClick:()=>{H()},className:"flex items-center justify-center h-8 px-2.5 rounded-lg text-[14px] font-medium cursor-pointer border-none",style:{background:L?"#2ecc7115":"#FE500012",color:L?"#2ecc71":"#FE5000",transition:"background 0.15s",opacity:D?.6:1},onMouseEnter:_=>{L||(_.currentTarget.style.background="#FE500025")},onMouseLeave:_=>{L||(_.currentTarget.style.background="#FE500012")},title:L?"Agent saved":"Save agent",disabled:D,children:[L?d.jsx(_t,{size:13}):d.jsx(dm,{size:13}),"Save"]}),d.jsxs("label",{className:"cursor-pointer",children:[d.jsx("input",{type:"file",accept:".agent.yaml,.agent.yml,.yaml,.yml",style:{display:"none"},onChange:_=>{const T=_.target.files?.[0];if(T){const B=new FileReader;B.onload=()=>{try{console.log("Agent import functionality not implemented yet")}catch(G){console.error("Failed to import agent:",G)}},B.readAsText(T)}}}),d.jsxs("button",{type:"button",className:"flex items-center justify-center gap-1.5 h-8 px-2.5 rounded-lg text-[14px] font-medium cursor-pointer border-none",style:{background:"#FE500012",color:"#FE5000",transition:"background 0.15s"},onMouseEnter:_=>{_.currentTarget.style.background="#FE500025"},onMouseLeave:_=>{_.currentTarget.style.background="#FE500012"},title:"Import agent definition",children:[d.jsx(hv,{size:13}),"Import"]})]}),d.jsxs("button",{type:"button",onClick:V,className:"flex items-center justify-center gap-1.5 h-8 px-2.5 rounded-lg text-[14px] font-medium cursor-pointer border-none",style:{background:"#FE500012",color:"#FE5000",transition:"background 0.15s"},onMouseEnter:_=>{_.currentTarget.style.background="#FE500025"},onMouseLeave:_=>{_.currentTarget.style.background="#FE500012"},title:"Export agent definition",children:[d.jsx(iu,{size:13}),"Export"]}),N&&d.jsxs("div",{className:"flex items-center gap-1.5 h-8 px-2 rounded-lg",style:{background:e.surfaceOpaque,border:`1px solid ${e.border}`},children:[d.jsx("input",{type:"text",value:E,onChange:_=>I(_.target.value),onKeyDown:_=>{_.key==="Enter"&&H(E),_.key==="Escape"&&S(!1)},className:"w-44 h-6 px-2 text-[14px] rounded-md outline-none",style:{background:e.inputBg,border:`1px solid ${e.borderSubtle}`,color:e.textPrimary},placeholder:"Agent name required",autoFocus:!0}),d.jsx("button",{type:"button",onClick:()=>{H(E)},className:"flex items-center justify-center w-6 h-6 rounded-md border-none cursor-pointer",style:{background:"#FE5000",color:"#fff"},children:d.jsx(_t,{size:12})}),d.jsx("button",{type:"button",onClick:()=>S(!1),className:"flex items-center justify-center w-6 h-6 rounded-md border-none cursor-pointer",style:{background:"transparent",color:e.textDim},children:d.jsx(jt,{size:12})})]})]})}function Kr({label:e,color:n,collapsed:a,onToggle:s,right:i,t:l}){return d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"14px 20px",userSelect:"none",borderTop:`1px solid ${l.isDark?"#222226":"#e8e8ec"}`,background:`${n}08`},children:[d.jsxs("button",{type:"button",onClick:s,"aria-expanded":!a,style:{display:"flex",alignItems:"center",gap:10,flex:1,cursor:"pointer",border:"none",background:"transparent",padding:0,textAlign:"left"},children:[a?d.jsx(ta,{size:12,style:{color:l.textDim}}):d.jsx(Mn,{size:12,style:{color:l.textDim}}),d.jsx("div",{style:{width:3,height:14,borderRadius:2,background:n,opacity:.8}}),d.jsx("span",{style:{fontSize:12,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",fontFamily:"'Geist Mono', monospace",color:l.textPrimary},children:e})]}),i]})}function df({loading:e,onClick:n}){return d.jsxs("button",{type:"button",onClick:a=>{a.stopPropagation(),n()},disabled:e,style:{display:"flex",alignItems:"center",gap:4,fontSize:13,padding:"4px 8px",borderRadius:4,cursor:"pointer",border:"none",background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace"},children:[e?d.jsx(yt,{size:9,style:{animation:"spin 1s linear infinite"}}):d.jsx(La,{size:9}),"Generate"]})}function J_(){const e=we(),n=se(te=>te.agentMeta),a=se(te=>te.setAgentMeta),s=se(te=>te.instructionState),i=se(te=>te.updateInstruction),l=se(te=>te.workflowSteps),c=se(te=>te.channels),p=se(te=>te.mcpServers),f=se(te=>te.skills),m=se(te=>te.tokenBudget),[g,x]=z.useState(!0),[b,v]=z.useState(!0),[k,w]=z.useState(!1),[C,M]=z.useState(!1),[N,S]=z.useState(!1),[E,I]=z.useState(!1),[D,A]=z.useState(!1),[L,P]=z.useState(null),[W,$]=z.useState(!1),[V,X]=z.useState(null),[H,_]=z.useState(!1),{persona:T,tone:B,expertise:G,constraints:K,objectives:J,rawPrompt:F,autoSync:O}=s,Q=te=>{if(V){if(V.mode==="constraint")if(V.index!==void 0){const he=K.customConstraints.split(`
361
+ `).filter(Boolean);he[V.index]=te,i({constraints:{...K,customConstraints:he.join(`
362
+ `)}})}else{const he=K.customConstraints?K.customConstraints+`
363
+ `+te:te;i({constraints:{...K,customConstraints:he}})}else if(V.mode==="criteria")if(V.index!==void 0){const he=[...J.successCriteria];he[V.index]=te,i({objectives:{...J,successCriteria:he}})}else i({objectives:{...J,successCriteria:[...J.successCriteria,te]}});$(!1),X(null)}},q=()=>{if(!(!V||V.index===void 0)){if(V.mode==="constraint"){const te=K.customConstraints.split(`
364
+ `).filter(Boolean);te.splice(V.index,1),i({constraints:{...K,customConstraints:te.join(`
365
+ `)}})}else if(V.mode==="criteria"){const te=J.successCriteria.filter((he,je)=>je!==V.index);i({objectives:{...J,successCriteria:te}})}$(!1),X(null)}},ie=te=>{a({tags:te.split(",").map(he=>he.trim()).filter(Boolean)})},pe=z.useCallback(async()=>{P("all");try{const te=await G_("full",T);if(typeof te=="object"&&te!==null){const he=te;he.persona&&i({persona:he.persona}),he.constraints&&i({constraints:{...K,customConstraints:he.constraints.join(`
366
+ `)}}),he.objectives&&i({objectives:{...J,primary:he.objectives.primary||J.primary}})}}catch{}P(null)},[T,c,p,f,K,J,i]),me={identity:!!(n.name&&n.description),persona:T.length>20,constraints:K.neverMakeUp||K.customConstraints.length>0,workflow:l.length>0},U=Object.values(me).filter(Boolean).length,ce=c.reduce((te,he)=>te+(he.effectiveTokens??he.baseTokens??0),0),ge=Math.ceil(T.length/4)+Math.ceil(K.customConstraints.length/4),be=l.reduce((te,he)=>te+Math.ceil(he.label.length/4),0),ye=ce+ge+be;return d.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:20},children:[d.jsx(Q_,{}),d.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:e.surfaceOpaque,border:`1px solid ${e.border}`,boxShadow:`0 2px 12px ${e.isDark?"rgba(0,0,0,0.3)":"rgba(0,0,0,0.06)"}`},children:[d.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3.5 select-none",style:{borderBottom:`1px solid ${e.border}`,background:e.surfaceElevated},children:[d.jsx(Ti,{size:14,style:{color:"#FE5000"}}),d.jsx(vi,{content:"Build your agent step by step",children:d.jsx("span",{className:"text-[13px] font-bold tracking-[0.08em] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:e.textPrimary},children:"Agent"})}),d.jsx("div",{className:"flex-1"}),d.jsxs("div",{className:"flex items-center gap-1",children:[Object.entries(me).map(([te,he])=>d.jsx("div",{title:te,style:{width:6,height:6,borderRadius:"50%",background:he?"#FE5000":e.borderSubtle,transition:"background 200ms"}},te)),d.jsxs("span",{className:"text-[13px] ml-1",style:{color:e.textDim,fontFamily:"'Geist Mono', monospace"},children:[U,"/4"]})]})]}),d.jsx(Kr,{label:"Identity",color:"#FE5000",collapsed:!g,onToggle:()=>x(!g),t:e}),g&&d.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsxs("div",{className:"relative",children:[d.jsx("button",{type:"button","aria-label":"Choose avatar",onClick:()=>I(!E),className:"w-11 h-11 rounded-lg cursor-pointer flex items-center justify-center",style:{background:e.surfaceElevated,border:`1.5px solid ${e.border}`,color:"#FE5000"},children:d.jsx(B_,{avatarId:n.avatar,size:20})}),E&&d.jsx("div",{className:"absolute top-13 left-0 z-50 grid grid-cols-5 gap-0.5 p-2 rounded-lg",style:{background:e.surfaceOpaque,border:`1px solid ${e.border}`,boxShadow:"0 8px 24px rgba(0,0,0,0.2)",width:185},children:$v.map(te=>{const he=te.icon;return d.jsx("button",{type:"button",title:te.id,onClick:()=>{a({avatar:te.id}),I(!1)},className:"w-8 h-8 rounded cursor-pointer flex items-center justify-center border-none",style:{background:n.avatar===te.id?"#FE500020":"transparent",color:n.avatar===te.id?"#FE5000":e.textSecondary},children:d.jsx(he,{size:15})},te.id)})})]}),d.jsx("div",{className:"flex-1",children:D?d.jsx(zs,{value:n.name,onChange:te=>a({name:te.target.value}),onBlur:()=>A(!1),onKeyDown:te=>te.key==="Enter"&&A(!1),autoFocus:!0,style:{fontSize:19,padding:"6px 10px"}}):d.jsx("button",{type:"button",onClick:()=>A(!0),className:"text-left font-semibold cursor-pointer border-none bg-transparent p-0 w-full",style:{color:n.name?e.textPrimary:e.textMuted,fontSize:19,fontFamily:"'Geist Sans', sans-serif"},children:n.name||"Click to name your agent"})})]}),d.jsx(Aa,{label:"Description",value:n.description,onChange:te=>a({description:te.target.value}),placeholder:"One-line summary of what this agent does...",style:{minHeight:40}}),d.jsx(zs,{label:"Tags",value:n.tags.join(", "),onChange:te=>ie(te.target.value),placeholder:"pm, analysis, competitor"})]}),d.jsx(Kr,{label:"Persona",color:"#9b59b6",collapsed:!b,onToggle:()=>v(!b),t:e,right:d.jsx(df,{loading:L==="all",onClick:pe})}),b&&d.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[d.jsx(Aa,{label:"Who is this agent?",value:T,onChange:te=>i({persona:te.target.value}),placeholder:"Describe the agent's role, expertise, and personality...",style:{minHeight:64}}),d.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx("span",{className:"text-[13px] tracking-wider uppercase font-semibold",style:{color:e.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Tone"}),d.jsx("div",{className:"flex rounded-md overflow-hidden",style:{border:`1px solid ${e.border}`},children:["formal","neutral","casual"].map(te=>d.jsx("button",{type:"button",onClick:()=>i({tone:te}),className:"flex-1 text-center text-[13px] py-1.5 cursor-pointer border-none",style:{background:B===te?"#FE5000":"transparent",color:B===te?"#fff":e.textDim,transition:"all 150ms"},children:te.charAt(0).toUpperCase()+te.slice(1)},te))})]}),d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx("span",{className:"text-[13px] tracking-wider uppercase font-semibold",style:{color:e.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Expertise"}),d.jsx("div",{className:"flex rounded-md overflow-hidden",style:{border:`1px solid ${e.border}`},children:[{l:"Junior",v:1},{l:"Mid",v:3},{l:"Senior",v:5}].map(te=>d.jsx("button",{type:"button",onClick:()=>i({expertise:te.v}),className:"flex-1 text-center text-[13px] py-1.5 cursor-pointer border-none",style:{background:G===te.v?"#FE5000":"transparent",color:G===te.v?"#fff":e.textDim,transition:"all 150ms"},children:te.l},te.v))})]})]})]}),d.jsx(Kr,{label:"Constraints",color:"#2ecc71",collapsed:!k,onToggle:()=>w(!k),t:e,right:d.jsx(df,{loading:L==="constraints",onClick:()=>{}})}),k&&d.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("span",{className:"text-[13px] tracking-wider uppercase font-semibold",style:{color:e.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Safety"}),d.jsx("div",{className:"flex gap-1",children:[{id:"autonomous",label:"Autonomous",desc:"No guardrails",apply:{neverMakeUp:!1,askBeforeActions:!1,stayInScope:!1,useOnlyTools:!1,limitWords:!1}},{id:"balanced",label:"Balanced",desc:"Cite sources, stay in scope",apply:{neverMakeUp:!0,askBeforeActions:!1,stayInScope:!0,useOnlyTools:!1,limitWords:!1}},{id:"careful",label:"Careful",desc:"All guardrails on",apply:{neverMakeUp:!0,askBeforeActions:!0,stayInScope:!0,useOnlyTools:!0,limitWords:!1}}].map(te=>{const he=te.id==="careful"?K.neverMakeUp&&K.askBeforeActions&&K.stayInScope&&K.useOnlyTools:te.id==="balanced"?K.neverMakeUp&&K.stayInScope&&!K.askBeforeActions&&!K.useOnlyTools:!K.neverMakeUp&&!K.askBeforeActions&&!K.stayInScope&&!K.useOnlyTools;return d.jsx(vi,{content:te.desc,children:d.jsx("button",{type:"button",onClick:()=>i({constraints:{...K,...te.apply}}),className:"text-[13px] px-3 py-1.5 rounded-md cursor-pointer border-none font-medium",style:{background:he?"#2ecc7120":"transparent",color:he?"#2ecc71":e.textDim,border:`1px solid ${he?"#2ecc7140":e.border}`,fontFamily:"'Geist Mono', monospace",transition:"all 0.15s"},children:te.label})},te.id)})})]}),d.jsxs("div",{children:[d.jsx("span",{className:"text-[13px] tracking-wider uppercase font-semibold block mb-1.5",style:{color:e.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Custom Rules"}),K.customConstraints.split(`
367
+ `).filter(Boolean).map((te,he)=>d.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg mb-1.5",style:{background:e.isDark?"#2e1a0a":"#fdf5ee",border:`1px solid ${e.isDark?"#e67e2230":"#e67e2240"}`},children:[d.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:"#e67e22",flexShrink:0}}),d.jsx("span",{className:"flex-1 text-[13px]",style:{color:e.textPrimary,lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100%"},children:te}),d.jsx("button",{type:"button",onClick:()=>{X({mode:"constraint",index:he,title:"Edit Custom Rule",initial:te}),$(!0)},className:"border-none bg-transparent cursor-pointer p-1 rounded min-w-[44px] min-h-[44px] flex items-center justify-center",style:{color:e.textDim},"aria-label":"Edit rule",children:d.jsx(_x,{size:11})})]},he)),d.jsxs("button",{type:"button",onClick:()=>{X({mode:"constraint",title:"Add Custom Rule"}),$(!0)},className:"flex items-center gap-1 text-[12px] cursor-pointer border-none bg-transparent mt-1.5",style:{color:e.textDim},children:[d.jsx(bt,{size:10})," Add rule"]})]})]}),d.jsx(Kr,{label:"Objectives",color:"#e74c3c",collapsed:!C,onToggle:()=>M(!C),t:e,right:d.jsx(df,{loading:L==="objectives",onClick:()=>{}})}),C&&d.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[d.jsx(Aa,{label:"Primary Objective",value:J.primary,onChange:te=>i({objectives:{...J,primary:te.target.value}}),placeholder:"What is this agent's main goal?",style:{minHeight:40}}),d.jsxs("div",{children:[d.jsx("span",{className:"text-[13px] tracking-wider uppercase font-semibold block mb-1.5",style:{color:e.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Success Criteria"}),J.successCriteria.map((te,he)=>d.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg mb-1.5",style:{background:e.isDark?"#1a2e1a":"#f0faf0",border:`1px solid ${e.isDark?"#2ecc7130":"#2ecc7140"}`},children:[d.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:"#2ecc71",flexShrink:0}}),d.jsx("span",{className:"flex-1 text-[13px]",style:{color:e.textPrimary,lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100%"},children:te}),d.jsx("button",{type:"button",onClick:()=>{X({mode:"criteria",index:he,title:"Edit Success Criterion",initial:te}),$(!0)},className:"border-none bg-transparent cursor-pointer p-1 rounded min-w-[44px] min-h-[44px] flex items-center justify-center",style:{color:e.textDim},"aria-label":"Edit criterion",children:d.jsx(_x,{size:11})})]},he)),d.jsxs("button",{type:"button",onClick:()=>{X({mode:"criteria",title:"Add Success Criterion"}),$(!0)},className:"flex items-center gap-1 text-[12px] cursor-pointer border-none bg-transparent mt-1.5",style:{color:e.textDim},children:[d.jsx(bt,{size:10})," Add criterion"]})]})]}),d.jsx(Kr,{label:"System Prompt",color:"#555",collapsed:!N,onToggle:()=>S(!N),t:e,right:d.jsxs("div",{className:"flex items-center gap-1.5",onClick:te=>te.stopPropagation(),children:[d.jsx(Zr,{checked:O,onChange:te=>i({autoSync:te}),label:""}),d.jsx("span",{className:"text-[13px]",style:{color:e.textDim},children:"Auto"})]})}),N&&d.jsx("div",{className:"px-5 py-4",children:d.jsx(Aa,{value:F,onChange:te=>i({rawPrompt:te.target.value}),placeholder:"System prompt will be auto-generated from sections above, or type manually...",style:{minHeight:120,fontFamily:"'Geist Mono', monospace",fontSize:13}})})]}),d.jsx(P_,{open:W,onClose:()=>{$(!1),X(null)},onSave:Q,onDelete:V?.index!==void 0?q:void 0,initial:V?.initial,title:V?.title||""}),d.jsx(H_,{open:H,onClose:()=>_(!1)}),d.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:e.surfaceOpaque,border:`1px solid ${e.border}`,boxShadow:`0 2px 12px ${e.isDark?"rgba(0,0,0,0.3)":"rgba(0,0,0,0.06)"}`},children:[d.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3.5 select-none",style:{background:e.surfaceElevated},children:[d.jsx("div",{style:{width:3,height:14,borderRadius:2,background:"#e67e22",opacity:.8}}),d.jsx("span",{className:"text-[13px] font-bold tracking-[0.08em] uppercase flex-1",style:{fontFamily:"'Geist Mono', monospace",color:e.textPrimary},children:"Workflow"}),d.jsxs("span",{className:"text-[13px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:[l.length," steps"]})]}),d.jsx("div",{className:"px-5 py-4 flex flex-col items-center",children:l.length===0?d.jsxs("button",{type:"button",onClick:()=>_(!0),className:"flex items-center justify-center gap-1.5 text-[13px] px-4 py-2.5 rounded-lg cursor-pointer border-none",style:{background:"#e67e2215",color:"#e67e22",fontFamily:"'Geist Mono', monospace",fontWeight:600},children:[d.jsx(bt,{size:12})," Define workflow steps"]}):d.jsxs(d.Fragment,{children:[l.map((te,he)=>d.jsxs("div",{className:"w-full",children:[d.jsxs("div",{className:"flex items-center gap-3 py-2",children:[d.jsx("div",{style:{width:24,height:24,borderRadius:"50%",background:e.surfaceElevated,border:"1.5px solid #e67e2230",display:"flex",alignItems:"center",justifyContent:"center"},children:d.jsx("span",{style:{fontFamily:"'Geist Mono', monospace",fontSize:13,fontWeight:700,color:"#e67e22"},children:he+1})}),d.jsx("span",{style:{flex:1,fontSize:14,color:e.textPrimary},children:te.label||"Unnamed step"}),d.jsx("span",{className:"text-[12px] px-2 py-0.5 rounded",style:{background:e.badgeBg,color:e.textDim,fontFamily:"'Geist Mono', monospace"},children:te.action||"action"})]}),he<l.length-1&&d.jsx("div",{style:{width:2,height:12,background:"#e67e2220",marginLeft:11}})]},te.id)),d.jsx("button",{type:"button",onClick:()=>_(!0),className:"text-[12px] px-3 py-2 mt-3 rounded cursor-pointer border-none",style:{background:e.border,color:e.textDim},children:"Edit workflow"})]})})]}),d.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:e.surfaceOpaque,border:`1px solid ${e.border}`,padding:"16px 20px"},children:[d.jsxs("div",{className:"flex items-center justify-between mb-2.5",children:[d.jsx("span",{className:"text-[12px] font-bold tracking-[0.08em] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:"Context Budget"}),d.jsxs("span",{className:"text-[13px] font-semibold",style:{fontFamily:"'Geist Mono', monospace",color:"#FE5000"},children:[uf(ye)," / ",uf(m)]})]}),d.jsx("div",{style:{height:8,background:e.isDark?"#25252a":"#dddde2",borderRadius:4,overflow:"hidden"},children:d.jsx("div",{style:{width:`${Math.min(ye/m*100,100)}%`,height:"100%",borderRadius:4,background:"linear-gradient(90deg, #FE5000, #ff8c55)",transition:"width 500ms"}})}),d.jsx("div",{className:"flex gap-3 mt-2.5",children:[{label:"Knowledge",tokens:ce,color:"#3498db"},{label:"Instructions",tokens:ge,color:"#9b59b6"},{label:"Workflow",tokens:be,color:"#e67e22"}].map(te=>d.jsxs("span",{className:"flex items-center gap-1 text-[12px]",style:{color:e.textDim},children:[d.jsx("span",{style:{width:8,height:8,borderRadius:2,background:te.color}}),te.label," ",uf(te.tokens)]},te.label))})]})]})}const pf="";let ff=null;const uo=qt((e,n)=>({panelOpen:!1,panelHeight:40,activeTab:"chat",conversationId:null,conversations:[],messages:[],inputText:"",streaming:!1,lastPipelineStats:null,testCases:[],runningTests:!1,setPanelOpen:a=>e({panelOpen:a}),setPanelHeight:a=>e({panelHeight:Math.max(20,Math.min(80,a))}),setActiveTab:a=>e({activeTab:a}),setInputText:a=>e({inputText:a}),addMessage:a=>{const s=n(),i={...a,id:`msg-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,timestamp:Date.now()};let l=s.conversationId;!l&&s.messages.length===0&&(l=`conv-${Date.now()}-${Math.random().toString(36).slice(2,8)}`),e({messages:[...s.messages,i],conversationId:l}),ff&&clearTimeout(ff),ff=setTimeout(()=>{n().saveToServer().catch(console.error)},1e3)},updateLastAssistant:a=>{const s=[...n().messages];for(let i=s.length-1;i>=0;i--)if(s[i].role==="assistant"){s[i]={...s[i],content:a};break}e({messages:s})},clearMessages:()=>e({messages:[],lastPipelineStats:null}),setStreaming:a=>e({streaming:a}),setLastPipelineStats:a=>e({lastPipelineStats:a}),addTestCase:a=>e({testCases:[...n().testCases,{...a,id:`test-${Date.now()}-${Math.random().toString(36).slice(2,6)}`}]}),updateTestCase:(a,s)=>e({testCases:n().testCases.map(i=>i.id===a?{...i,...s}:i)}),removeTestCase:a=>e({testCases:n().testCases.filter(s=>s.id!==a)}),setRunningTests:a=>e({runningTests:a}),saveCurrentAsTest:(a,s)=>{const l=[...n().messages].reverse().find(c=>c.role==="user");l&&n().addTestCase({name:a,input:l.content,expectedBehavior:s,passed:null})},saveToServer:async()=>{const a=n();if(!(!a.conversationId||a.messages.length===0))try{const s=a.messages[0]?.content?.slice(0,50)||"Untitled Conversation";await fetch(`${pf}/api/conversations`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:a.conversationId,title:s,messages:a.messages,lastModified:Date.now()})})}catch(s){console.error("Failed to save conversation:",s)}},listFromServer:async()=>{try{const a=await fetch(`${pf}/api/conversations`);if(a.ok){const s=await a.json();e({conversations:s})}}catch(a){console.error("Failed to list conversations:",a)}},loadFromServer:async a=>{try{const s=await fetch(`${pf}/api/conversations/${a}`);if(s.ok){const i=await s.json();e({conversationId:i.id,messages:i.messages||[],lastPipelineStats:null})}}catch(s){console.error("Failed to load conversation:",s)}}}));function Tc(e){return e?e.includes(`
368
+ `)?`|
369
+ ${e.split(`
370
+ `).map(n=>" "+n).join(`
371
+ `)}`:/[:#"'{}\[\],&*?|>!%@`]/.test(e)?`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:e:'""'}function Zx(e,n=0){const a=" ".repeat(n);return e.map(s=>`${a}- ${Tc(s)}`).join(`
372
+ `)}function e6(e){const n=e.agentMeta,a=e.agentConfig,s=[];return s.push(`name: ${Tc(n.name||"Untitled Agent")}`),n.description&&s.push(`description: ${Tc(n.description)}`),s.push('version: "1.0.0"'),n.tags?.length&&s.push(`tags:
373
+ ${Zx(n.tags)}`),n.avatar&&s.push(`avatar: ${n.avatar}`),n.icon&&s.push(`icon: ${n.icon}`),s.push(""),s.push("# Runtime"),s.push(`model: ${Tc(e.selectedModel)}`),a?.temperature!==void 0&&s.push(`temperature: ${a.temperature}`),a?.planningMode&&s.push(`planning: ${a.planningMode}`),s.push(`token_budget: ${e.tokenBudget}`),s.push(""),s.push("# Output"),s.push(`output_format: ${e.outputFormat}`),e.outputFormats.length>1&&s.push(`output_formats:
374
+ ${Zx(e.outputFormats)}`),s.join(`
375
+ `)+`
376
+ `}function t6(e){const n=e.instructionState,a=e.agentMeta,s=[];if(s.push(`# ${a.name||"Agent"}`),s.push(""),a.description&&(s.push(a.description),s.push("")),n?.persona&&(s.push("## Persona"),s.push(""),s.push(n.persona),s.push("")),n?.tone&&n.tone!=="neutral"&&(s.push(`**Tone:** ${n.tone}`),s.push("")),n?.expertise&&n.expertise!==3){const i=["Beginner","Novice","Intermediate","Advanced","Expert"];s.push(`**Expertise:** ${i[n.expertise-1]} (${n.expertise}/5)`),s.push("")}return s.join(`
377
+ `)}function n6(e){const n=e.instructionState,a=["# Instructions",""];n?.objectives?.primary&&(a.push("## Objective"),a.push(""),a.push(n.objectives.primary),a.push(""),n.objectives.successCriteria.length>0&&(a.push("### Success Criteria"),a.push(""),n.objectives.successCriteria.forEach(i=>a.push(`- ${i}`)),a.push("")),n.objectives.failureModes.length>0&&(a.push("### Failure Modes to Avoid"),a.push(""),n.objectives.failureModes.forEach(i=>a.push(`- ${i}`)),a.push("")));const s=[];if(n?.constraints){const i=n.constraints;i.neverMakeUp&&s.push("Never fabricate information or make up facts"),i.askBeforeActions&&s.push("Ask for permission before taking significant actions"),i.stayInScope&&s.push(`Stay within scope${i.scopeDefinition?": "+i.scopeDefinition:""}`),i.useOnlyTools&&s.push("Only use tools and capabilities that are explicitly provided"),i.limitWords&&s.push(`Keep responses under ${i.wordLimit} words`),i.customConstraints&&i.customConstraints.split(`
378
+ `).filter(Boolean).forEach(l=>s.push(l.trim()))}return s.length>0&&(a.push("## Constraints"),a.push(""),s.forEach(i=>a.push(`- ${i}`)),a.push("")),e.workflowSteps&&e.workflowSteps.length>0&&(a.push("## Workflow"),a.push(""),e.workflowSteps.forEach((i,l)=>{a.push(`${l+1}. **${i.label}** — ${i.action}`)}),a.push("")),e.prompt&&!n?.persona&&!n?.objectives?.primary&&(a.push("## Additional Instructions"),a.push(""),a.push(e.prompt),a.push("")),a.join(`
379
+ `)}function o6(e){const n=["# Tools",""],a=e.mcpServers.filter(i=>i.enabled&&i.added),s=e.skills.filter(i=>i.enabled&&i.added);return a.length>0&&(n.push("## MCP Servers"),n.push(""),a.forEach(i=>{n.push(`### ${i.name}`),n.push(""),i.description&&n.push(i.description),n.push(""),n.push("```yaml"),n.push(`id: ${i.id}`),n.push("transport: stdio"),n.push("command: npx"),n.push(`args: ["@${i.id}/mcp"]`),n.push("```"),n.push("")})),s.length>0&&(n.push("## Skills"),n.push(""),s.forEach(i=>{n.push(`- **${i.name}**${i.description?" — "+i.description:""}`)}),n.push("")),a.length===0&&s.length===0&&(n.push("No tools configured."),n.push("")),n.join(`
380
+ `)}function a6(e){const n=["# Knowledge",""],a=e.channels.filter(i=>i.enabled),s=(e.connectors??[]).filter(i=>i.enabled);return a.length>0&&(n.push("## Sources"),n.push(""),a.forEach(i=>{const l=i.knowledgeType||"signal";n.push(`### ${i.name||i.path}`),n.push(""),n.push(`- **Path:** \`${i.path}\``),n.push(`- **Type:** ${l}`),i.content&&n.push(`- **Content Preview:** ${i.content.slice(0,100)}${i.content.length>100?"...":""}`),i.hint&&n.push(`- **Hint:** ${i.hint}`),n.push("")})),s.length>0&&(n.push("## Connectors"),n.push(""),s.forEach(i=>{n.push(`- **${i.name}** (${i.service}) — ${i.direction}${i.hint?", scope: "+i.hint:""}`)}),n.push("")),n.push("## Budget"),n.push(""),n.push(`Token budget: ${e.tokenBudget}`),n.push(""),n.join(`
381
+ `)}function s6(e){return["# Memory","","<!-- Initial memory for this agent. Add seed context, key facts, or preferences here. -->",""].join(`
382
+ `)}function Fv(e){return{"agent.yaml":e6(e),"SOUL.md":t6(e),"INSTRUCTIONS.md":n6(e),"TOOLS.md":o6(e),"KNOWLEDGE.md":a6(e),"MEMORY.md":s6()}}async function r6(e){const n=Fv(e),a=(e.agentMeta.name||"modular-agent").toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");try{const s=(await ea(async()=>{const{default:m}=await import("./jszip.min-DByyLalk.js").then(g=>g.j);return{default:m}},[])).default,i=new s,l=i.folder(a);for(const[m,g]of Object.entries(n))l.file(m,g);const c=await i.generateAsync({type:"blob"}),p=URL.createObjectURL(c),f=document.createElement("a");f.href=p,f.download=`${a}.zip`,f.click(),URL.revokeObjectURL(p)}catch{for(const[s,i]of Object.entries(n)){const l=new Blob([i],{type:"text/plain"}),c=URL.createObjectURL(l),p=document.createElement("a");p.href=c,p.download=s,p.click(),URL.revokeObjectURL(c)}}}function Iv(e){const n={};return e["agent.yaml"]&&(n.agentYaml=Lv(e["agent.yaml"])),e["SOUL.md"]&&(n.soul=e["SOUL.md"]),e["INSTRUCTIONS.md"]&&(n.instructions=e["INSTRUCTIONS.md"]),e["TOOLS.md"]&&(n.tools=e["TOOLS.md"]),e["KNOWLEDGE.md"]&&(n.knowledge=e["KNOWLEDGE.md"]),e["MEMORY.md"]&&(n.memory=e["MEMORY.md"]),n}function Lv(e){const n={};let a=null,s="";for(const i of e.split(`
383
+ `)){const l=i.trim();if(!l||l.startsWith("#"))continue;if(l.startsWith("- ")&&a!==null){a.push(l.slice(2).replace(/^["']|["']$/g,"")),n[s]=a;continue}a=null;const c=l.indexOf(":");if(c===-1)continue;const p=l.slice(0,c).trim();if(p==="__proto__"||p==="constructor"||p==="prototype")continue;const f=l.slice(c+1).trim();if(!f){s=p,a=[];continue}const m=f.replace(/^["']|["']$/g,"");m==="true"?n[p]=!0:m==="false"?n[p]=!1:/^\d+(\.\d+)?$/.test(m)?n[p]=Number(m):n[p]=m}return n}function Bv(e){const n={};if(e.agentYaml){const a=e.agentYaml;n.agentMeta={name:a.name||"",description:a.description||"",avatar:a.avatar||"",icon:a.icon||"",category:a.category||"general",tags:Array.isArray(a.tags)?a.tags:[]},a.model&&(n.selectedModel=a.model),a.token_budget&&(n.tokenBudget=a.token_budget),a.output_format&&(n.outputFormat=a.output_format),n.agentConfig={temperature:a.temperature??.7,planningMode:a.planning??"single-shot",model:a.model??""}}if(e.soul||e.instructions){const a={persona:"",tone:"neutral",expertise:3,constraints:{neverMakeUp:!1,askBeforeActions:!1,stayInScope:!1,useOnlyTools:!1,limitWords:!1,wordLimit:500,customConstraints:"",scopeDefinition:""},objectives:{primary:"",successCriteria:[],failureModes:[]},rawPrompt:"",autoSync:!1};if(e.soul){const s=e.soul.split(`
384
+ `);let i="",l="";for(const c of s){const p=c.trim();p.startsWith("## ")?(i==="persona"&&l.trim()&&(a.persona=l.trim()),i=p.toLowerCase().includes("persona")?"persona":"",l=""):!p.startsWith("#")&&p&&(i||!a.persona)&&(l+=c+`
385
+ `,!a.persona&&!i&&(a.persona=l.trim()))}i==="persona"&&l.trim()&&(a.persona=l.trim())}if(e.instructions){const s=e.instructions.split(`
386
+ `);let i="",l=!1,c=[];for(const p of s){const f=p.trim();if(f.startsWith("## ")){i==="successCriteria"&&c.length>0?a.objectives.successCriteria=c:i==="failureModes"&&c.length>0&&(a.objectives.failureModes=c);const m=f.toLowerCase();m.includes("objective")?i="objective":m.includes("constraint")&&(i="constraints"),l=!1,c=[]}else if(f.startsWith("### ")){const m=f.toLowerCase();m.includes("success")?(i="successCriteria",l=!0,c=[]):m.includes("failure")&&(i="failureModes",l=!0,c=[])}else if(f.startsWith("- ")){if(l)c.push(f.substring(2));else if(i==="constraints"){const m=f.substring(2);if((m.toLowerCase().includes("never fabricate")||m.toLowerCase().includes("never make up"))&&(a.constraints.neverMakeUp=!0),m.toLowerCase().includes("ask")&&m.toLowerCase().includes("permission")&&(a.constraints.askBeforeActions=!0),m.toLowerCase().includes("scope")&&(a.constraints.stayInScope=!0),m.toLowerCase().includes("only use tools")&&(a.constraints.useOnlyTools=!0),m.toLowerCase().includes("word")&&/\d+/.test(m)){a.constraints.limitWords=!0;const g=m.match(/(\d+)/);g&&(a.constraints.wordLimit=parseInt(g[1]))}}}else i==="objective"&&f&&!f.startsWith("#")&&(a.objectives.primary||(a.objectives.primary=f))}i==="successCriteria"&&c.length>0?a.objectives.successCriteria=c:i==="failureModes"&&c.length>0&&(a.objectives.failureModes=c)}n.instructionState=a}return n}async function Pv(e){try{const n=(await ea(async()=>{const{default:b}=await import("./jszip.min-DByyLalk.js").then(v=>v.j);return{default:b}},[])).default,a=new n,s=10*1024*1024;if(e.size>s)throw new Error(`ZIP file too large (${(e.size/1024/1024).toFixed(1)}MB). Maximum is 10MB.`);const i=await a.loadAsync(e),l=2*1024*1024,c={},p=["agent.yaml","SOUL.md","INSTRUCTIONS.md","TOOLS.md","KNOWLEDGE.md","MEMORY.md"];for(const[b,v]of Object.entries(i.files)){if(v.dir)continue;const k=b.split("/").pop()||"";if(p.includes(k))try{const w=await v.async("text");if(w.length>l){console.warn(`Skipping ${k}: exceeds 2MB limit`);continue}c[k]=w}catch(w){console.warn(`Failed to read ${k}:`,w)}}if(!c["agent.yaml"])throw new Error("agent.yaml is required but not found in the ZIP file");const f=Iv(c),m=Bv(f),{useConsoleStore:g}=await ea(async()=>{const{useConsoleStore:b}=await Promise.resolve().then(()=>Ev);return{useConsoleStore:b}},void 0);g.getState().restoreFullState(m)}catch(n){throw console.error("Import failed:",n),n instanceof Error?n:new Error("Unknown import error")}}const i6=Object.freeze(Object.defineProperty({__proto__:null,agentDirectoryToState:Bv,downloadAgentDirectory:r6,exportAgentDirectory:Fv,importAgentFromZip:Pv,parseAgentDirectory:Iv,parseSimpleYaml:Lv},Symbol.toStringTag,{value:"Module"}));function Qx(){return`${Date.now()}-${Math.random().toString(36).slice(2,6)}`}function l6(e){let n=0,a=0,s=0,i=0,l=0;const c=e.map(f=>f.timestamp),p=c.length>=2?Math.max(...c)-Math.min(...c):0;for(const f of e)f.kind==="llm_call"&&(n+=(f.inputTokens||0)+(f.outputTokens||0),a+=f.costUsd||0),f.kind==="tool_call"&&(s++,f.toolError&&i++),f.kind==="retrieval"&&l++;return{totalTokens:n,totalCostUsd:a,toolCalls:s,toolErrors:i,retrievals:l,durationMs:p}}const fn=qt((e,n)=>({traces:[],activeTraceId:null,maxTraces:50,startTrace:(a,s)=>{const i=`trace-${Qx()}`,l={id:i,conversationId:a,agentVersion:s,startedAt:Date.now(),events:[]};return e(c=>({traces:[...c.traces,l].slice(-c.maxTraces),activeTraceId:i})),i},addEvent:(a,s)=>e(i=>({traces:i.traces.map(l=>l.id===a?{...l,events:[...l.events,{...s,id:Qx(),timestamp:Date.now()}]}:l)})),endTrace:a=>e(s=>({traces:s.traces.map(i=>i.id===a?{...i,summary:l6(i.events)}:i),activeTraceId:s.activeTraceId===a?null:s.activeTraceId})),getTrace:a=>n().traces.find(s=>s.id===a),getActiveTrace:()=>{const a=n().activeTraceId;return a?n().traces.find(s=>s.id===a):void 0},clearTraces:()=>e({traces:[],activeTraceId:null})}));function c6(e){const n=e.toLowerCase();return["what is","where is","how does","who is","when did","which","define","explain"].some(i=>n.includes(i))||/["'`].+["'`]/.test(e)||/[A-Z][a-z]+[A-Z]/.test(e)||/[A-Z_]{3,}/.test(e)?"specific":["summarize","summary","overview","what happened","recap","yesterday","last week","last month","today","recently","so far","progress","status update"].some(i=>n.includes(i))?"summary":"exploratory"}const u6={fact:1,episode:.8,raw:.6};function d6(e,n){if(e.length!==n.length||e.length===0)return 0;let a=0,s=0,i=0;for(let c=0;c<e.length;c++)a+=e[c]*n[c],s+=e[c]*e[c],i+=n[c]*n[c];const l=Math.sqrt(s)*Math.sqrt(i);return l===0?0:a/l}async function p6(e){try{const n=await fetch("/api/knowledge/embed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({texts:[e]})});return n.ok?(await n.json()).embeddings?.[0]??null:null}catch{return null}}async function Hv(e){const n=Date.now(),a=We.getState(),{longTerm:s,sandbox:i}=a;if(!s.enabled)return{facts:[],contextBlock:"",tokenEstimate:0,durationMs:0};let l=a.getRecallableFacts(e.agentId);i.isolation==="reset_each_run"?l=l.filter(A=>A.domain!=="run_scratchpad"):i.isolation==="clone_from_shared"&&(l=l.filter(A=>A.domain==="shared"));const c=c6(e.userMessage),p={specific:{k:3,granularityBoost:{fact:1.3,episode:.7,raw:.5}},summary:{k:5,granularityBoost:{fact:.8,episode:1.3,raw:.6}},exploratory:{k:8,granularityBoost:{fact:1,episode:1,raw:1}}},{k:f,granularityBoost:m}=p[c],g=l.some(A=>A.embedding&&A.embedding.length>0);let x=null;g&&(x=await p6(e.userMessage));const b=l.map(A=>{let L;x&&A.embedding&&A.embedding.length>0?L=d6(x,A.embedding):L=h6(A.content,e.userMessage);const P=u6[A.granularity??"fact"],W=m[A.granularity??"fact"]??1;return{fact:A,score:L*P*W}}),{strategy:v,k,minScore:w}=s.recall,C=Math.min(f,k||f);let M;v==="threshold"?M=b.filter(A=>A.score>=w).sort((A,L)=>L.score-A.score):v==="hybrid"?M=b.filter(A=>A.score>=w).sort((A,L)=>L.score-A.score).slice(0,C):M=b.sort((A,L)=>L.score-A.score).slice(0,C);const N=M.map(A=>A.fact),S=g6(N),E=Math.ceil(S.length/4),I=Date.now()-n;return fn.getState().addEvent(e.traceId,{kind:"memory_recall",sourceName:"memory:pre-recall",memoryFactCount:N.length,memoryFactIds:N.map(A=>A.id),memoryDomain:N.length>0?[...new Set(N.map(A=>A.domain))].join(","):void 0,durationMs:I}),{facts:N,contextBlock:S,tokenEstimate:E,durationMs:I}}function f6(e){const n=Date.now(),a=We.getState(),{longTerm:s,sandbox:i}=a;if(!s.enabled||!e.assistantResponse)return{extracted:[],stored:[],durationMs:0};const{write:l}=s;if(l.mode==="explicit")return{extracted:[],stored:[],durationMs:0};const c=y6(e.assistantResponse,e.userMessage,l.extractTypes),p=k6(i.isolation,e.sandboxRunId),f=[];for(const x of c){if(x.confidence<.5)continue;const b=w6(p,i),k={decisions:"decision",user_preferences:"preference",facts:"fact",feedback:"fact",entities:"entity"}[x.type]||x.type;a.addFact(x.content,[x.type],k,b,"fact",e.agentId);const w=We.getState().facts,C=w[w.length-1];C&&f.push(C)}const m=Date.now()-n;return fn.getState().addEvent(e.traceId,{kind:"memory_write",sourceName:"memory:post-write",memoryFactCount:f.length,memoryFactIds:f.map(x=>x.id),memoryDomain:p,durationMs:m}),{extracted:c,stored:f,durationMs:m}}function m6(){const e=We.getState(),n=e.facts.filter(a=>a.domain==="run_scratchpad").map(a=>a.id);for(const a of n)e.removeFact(a)}function h6(e,n){const a=new Set(e.toLowerCase().split(/\s+/).filter(l=>l.length>2)),s=n.toLowerCase().split(/\s+/).filter(l=>l.length>2);if(s.length===0)return .1;let i=0;for(const l of s)a.has(l)&&i++;return i/s.length}function g6(e){return e.length===0?"":`<memory_recall>
387
+ Relevant facts from memory:
388
+ ${e.map(a=>{const s=a.domain!=="shared"?` [${a.domain}]`:"";return`- [${a.type}]${s} ${a.content}`}).join(`
389
+ `)}
390
+ </memory_recall>`}function y6(e,n,a){const s=[],i=e.split(/[.!?\n]+/).map(l=>l.trim()).filter(l=>l.length>10);for(const l of i){const c=l.toLowerCase();a.includes("decisions")&&x6(c)?s.push({content:l,type:"decisions",confidence:.7}):a.includes("user_preferences")&&b6(c,n)?s.push({content:l,type:"user_preferences",confidence:.6}):a.includes("facts")&&v6(c)&&s.push({content:l,type:"facts",confidence:.5})}return s.slice(0,5)}function x6(e){return["decided","will use","chosen","selected","going with","we should","let's go with"].some(a=>e.includes(a))}function b6(e,n){const a=n.toLowerCase();return["prefer","like","want","favorite","always use","rather"].some(i=>a.includes(i)||e.includes(i))}function v6(e){return["is a","are used","works by","consists of","requires","means"].some(a=>e.includes(a))}function k6(e,n){return n||e==="reset_each_run"?"run_scratchpad":e==="clone_from_shared"?"agent_private":"shared"}function w6(e,n){return e==="shared"&&!n.allowPromoteToShared?"agent_private":e}function S6(e){const n=[];if(n.push("<provenance>"),e.sources.length>0)for(const a of e.sources)n.push(` <source path="${a.path}" type="${a.type}" sections="${a.sections}" depth="${a.depth}" />`);if(e.derivations.length>0){n.push(" <derivation>");for(const a of e.derivations)n.push(` <step from="${a.from}" method="${a.method}" to="${a.to}" />`);n.push(" </derivation>")}return n.push("</provenance>"),e.conflictResolution&&(n.push(""),n.push("<context_provenance>"),n.push(e.conflictResolution.instructions),n.push("</context_provenance>")),n.join(`
391
+ `)}function oi(e){const n=se.getState(),{instructionState:a,workflowSteps:s,agentMeta:i}=n,l=[];if(i.name){const f=[`Name: ${i.name}`];i.description&&f.push(`Description: ${i.description}`),i.avatar&&f.push(`Avatar: ${i.avatar}`),i.tags?.length&&f.push(`Tags: ${i.tags.join(", ")}`),l.push(`<identity>
392
+ ${f.join(`
393
+ `)}
394
+ </identity>`)}if(a.persona||a.objectives.primary){const f=[];if(a.persona&&f.push(`Persona: ${a.persona}`),a.tone!=="neutral"&&f.push(`Tone: ${a.tone}`),a.expertise!==3){const m=["Beginner","Novice","Intermediate","Advanced","Expert"];f.push(`Expertise Level: ${m[a.expertise-1]} (${a.expertise}/5)`)}a.objectives.primary&&(f.push(`Primary Objective: ${a.objectives.primary}`),a.objectives.successCriteria.length>0&&f.push(`Success Criteria:
395
+ ${a.objectives.successCriteria.map(m=>`- ${m}`).join(`
396
+ `)}`),a.objectives.failureModes.length>0&&f.push(`Failure Modes to Avoid:
397
+ ${a.objectives.failureModes.map(m=>`- ${m}`).join(`
398
+ `)}`)),l.push(`<instructions>
399
+ ${f.join(`
400
+
401
+ `)}
402
+ </instructions>`)}const c=[];if(a.constraints.neverMakeUp&&c.push("Never fabricate information or make up facts"),a.constraints.askBeforeActions&&c.push("Ask for permission before taking significant actions"),a.constraints.stayInScope&&c.push(`Stay within the defined scope: ${a.constraints.scopeDefinition||"as specified"}`),a.constraints.useOnlyTools&&c.push("Only use tools and capabilities that are explicitly provided"),a.constraints.limitWords&&c.push(`Keep responses under ${a.constraints.wordLimit} words`),a.constraints.customConstraints&&c.push(`Additional constraints: ${a.constraints.customConstraints}`),c.length>0&&l.push(`<constraints>
403
+ ${c.map(f=>`- ${f}`).join(`
404
+ `)}
405
+ </constraints>`),s.length>0){const f=bv(s);l.push(`<workflow>
406
+ ${f}
407
+ </workflow>`)}const p=C6();if(p&&l.push(p),e){const f=S6(e);l.push(f)}return l.join(`
408
+
409
+ `)}function Uv(){return`<knowledge_format>
410
+ The knowledge below is produced by an automated indexing pipeline. Here is how to read it:
411
+
412
+ ## Heading Hierarchy = Depth Levels
413
+ - # (H1) = Feature name — top-level grouping
414
+ - ## (H2) = Section: Architecture, Key Files, Data Flow, State Management, Components
415
+ - ### (H3) = Individual file entry with metadata
416
+
417
+ ## How to Read a Key File Entry
418
+ Each file under "Key Files" has structured metadata:
419
+ - **Category**: What the file DOES (component=UI, store=state, service=logic, route=endpoint, util=helper, test=tests, config=settings, type=contracts)
420
+ - **Exports**: The public API surface — function/class/constant names this file makes available
421
+ - **Types**: TypeScript interfaces/types defined in this file
422
+ - **Size/Tokens**: File size and estimated token count for budget decisions
423
+ - **Imports**: Direct dependencies of this file
424
+
425
+ ## How to Use Data Flow (CRITICAL)
426
+ The "Data Flow" section contains the import graph between files. Each line is:
427
+ source_file → imported_module
428
+ This IS the dependency graph. You do NOT need to open files to trace dependencies.
429
+ Example: if Data Flow shows \`App.tsx → ./providers/AuthProvider\`, you already know App depends on AuthProvider.
430
+
431
+ ## Escalation Strategy
432
+ 1. **Check the knowledge docs first** — most answers are already here (exports, types, data flow, architecture)
433
+ 2. **Use get_file_contents ONLY when you need actual implementation details** — the code itself, not its structure
434
+ 3. **Build exact file URLs** using the base URL from orientation + the file path from Key Files
435
+
436
+ ## What You Can Answer WITHOUT Reading Files
437
+ - "What does X export?" → Check Exports field
438
+ - "What depends on X?" → Check Data Flow
439
+ - "What state does X manage?" → Check State Management section
440
+ - "What type is X?" → Check Types field
441
+ - "What stack/framework?" → Check Architecture section
442
+ </knowledge_format>`}function C6(){const e=at.getState().getConnectedTools(),{skills:n}=se.getState(),a=n.filter(m=>m.enabled),i=se.getState().channels.some(m=>m.enabled&&m.repoMeta);if(e.length===0&&a.length===0)return"";const l=[];if(e.length>0){l.push("## Available MCP Tools");for(const m of e)l.push(`- **${m.name}**: ${m.description||"No description"}`)}if(a.length>0){l.length>0&&l.push(""),l.push("## Available Skills");for(const m of a)l.push(`- **${m.name}**: ${m.description||"No description"}`)}l.push(""),l.push("## Tool Usage Patterns");const c=e.filter(m=>/get_file|read_file|file_content/i.test(m.name));c.length>0&&i&&(l.push("### File Access"),l.push("- **FIRST**: Check your loaded knowledge (Key Files, Data Flow, Exports) — most structural questions are answered there"),l.push("- **THEN**: Use file tools ONLY for actual source code / implementation details"),l.push(`- Tool: \`${c[0].name}\` — pass a single file path, NOT a directory`));const p=e.filter(m=>/search|find|grep|query/i.test(m.name)&&!/search_nodes/i.test(m.name));if(p.length>0){l.push("### Search");for(const m of p)l.push(`- \`${m.name}\`: Use for finding files or symbols not in loaded knowledge`)}return e.filter(m=>/search_nodes|read_graph|knowledge_graph/i.test(m.name)).length>0&&i&&(l.push("### Knowledge Graph (Low Priority)"),l.push("- Your loaded knowledge already contains structure, dependencies, and exports"),l.push("- Do NOT use graph tools to find basic repo structure — it is already in your context"),l.push("- Use graph tools ONLY for cross-repo relationship queries not covered by loaded knowledge")),l.push(""),l.push("## Anti-Patterns (NEVER do these)"),c.length>0&&l.push(`- NEVER pass a directory path to \`${c[0].name}\` — it only accepts single files`),i&&(l.push("- NEVER open a file just to check its exports or types — that information is in your loaded knowledge"),l.push("- NEVER fabricate file URLs — use base URL from orientation + exact file path from Key Files"),l.push("- NEVER call search_nodes/read_graph for structure already in your context")),i&&(l.push(""),l.push("## Recommended Workflow"),l.push("1. Check orientation block → find which repo/feature is relevant"),l.push("2. Check loaded knowledge → exports, data flow, types, architecture"),l.push("3. Need implementation details? → `get_file_contents` with exact file path"),l.push("4. Need something not indexed? → search tools"),l.push("5. Need cross-repo relationships? → graph tools")),`<tool_guide>
443
+ ${l.join(`
444
+ `)}
445
+ </tool_guide>`}const M6=[{headingPatterns:[/(naming|branch|commit|file|variable|function|class|component)\s*(naming|convention|format|pattern|rule|standard)/i],contentPatterns:[/\b(format|pattern|example|convention):/i,/\b(feat|fix|chore|docs|refactor|test|style)\//,/\b(camelCase|PascalCase|snake_case|kebab-case|SCREAMING_SNAKE)\b/i],target:"naming"},{headingPatterns:[/^(rules?|constraints?|conventions?|standards?|guidelines?|requirements?|policies?|must|never|always)/i,/^(code\s*style|coding\s*standards?|linting|formatting)/i,/^(security|safety|boundaries)/i],contentPatterns:[/\b(MUST|SHALL|MUST NOT|SHALL NOT|REQUIRED|NEVER|ALWAYS|DO NOT|FORBIDDEN)\b/,/\b(rule|convention|standard|pattern|format):/i,/^[-*]\s*(always|never|do not|must|required|forbidden)/im],target:"constraint"},{headingPatterns:[/^(workflow|process|checklist|steps?|pipeline|review|procedure)/i,/^(before|after)\s*(commit|merge|push|deploy|review|submit)/i,/^(ci|cd|testing|deploy|release)\s*(process|steps|workflow)?/i],contentPatterns:[/\b(step\s*\d|first|then|next|finally|before|after)\b/i,/^\d+\.\s+/m,/^[-*]\s*\[[\sx]?\]/m],target:"workflow"},{headingPatterns:[/^(persona|identity|tone|voice|style|character|vibe)/i,/^(communication|behavior|personality)/i,/^(soul|core\s*truths?|principles?)/i,/who\s*(you|i)\s*a(m|re)/i],contentPatterns:[/\b(tone|voice|style|personality|character):/i,/\bbe\s+(concise|direct|formal|casual|friendly|professional|warm|snarky)/i],target:"persona"},{headingPatterns:[/^(tools?|tooling|stack|tech|preferred\s*stack|dependencies|preferred)/i,/^(use|prefer|recommended)\s*(tools?|frameworks?|libraries?)/i],contentPatterns:[/\b(prefer|use|recommended|required):\s*/i,/\b(npm|yarn|pnpm|pip|cargo|go)\s+(run|install|test|build)\b/i],target:"tool"},{headingPatterns:[/^(output|response|format|template|formatting|structure)/i,/^(how to|writing|documentation)\s*(format|style|write|structure)/i,/^(pr|pull\s*request|commit|changelog|report)\s*(template|format|description)/i],contentPatterns:[/\b(format|template|structure|layout|output|response)\b.*\b(must|should|always)/i,/\b(markdown|json|yaml|table|list|bullet|heading|section)\b/i,/```[\s\S]*?```/],target:"output"}];function E6(e){const n=[],a=e.split(`
446
+ `);let s="",i=0,l=[];for(const c of a){const p=c.match(/^(#{1,6})\s+(.+)/);p?((s||l.length>0)&&n.push({heading:s,level:i,content:l.join(`
447
+ `).trim()}),i=p[1].length,s=p[2],l=[]):l.push(c)}return(s||l.length>0)&&n.push({heading:s,level:i,content:l.join(`
448
+ `).trim()}),n}function j6(e,n){return n.headingPatterns.some(i=>i.test(e.heading))?!0:n.contentPatterns.filter(i=>i.test(e.content)).length>=2}function T6(e){const n=[],a=e.content.split(`
449
+ `);for(const s of a){const i=s.replace(/^[-*]\s*/,"").trim();!i||i.startsWith("#")||i.startsWith("```")||(/\b(MUST|SHALL|NEVER|ALWAYS|DO NOT|FORBIDDEN|REQUIRED|should|must not)\b/i.test(i)||/^(use|prefer|avoid|ensure|keep|maintain|follow|check|run|test|verify|write|create|name)/i.test(i)&&s.match(/^[-*]\s/))&&n.push(i)}return n}function N6(e){const n=[],a=e.content.split(`
450
+ `);for(const s of a){const i=s.trim(),l=i.match(/^\d+\.\s+(.+)/);if(l){n.push(l[1]);continue}const c=i.match(/^[-*]\s*\[[\sx]?\]\s*(.+)/);c&&n.push(c[1])}if(n.length===0)for(const s of a){const i=s.match(/^[-*]\s+(.+)/);i&&i[1].length>10&&n.push(i[1])}return n}function A6(e){const n=[],a=`${e.heading}
451
+ ${e.content}`,s=a.match(/branch.*?(?:format|pattern|naming|convention).*?[:`]\s*(.+?)(?:\n|$)/i)||a.match(/(?:feat|fix|chore|hotfix)\/[<\[{]?\w+/);if(s){const p=a.match(/(?:example|e\.g\.|e\.g).*?[:`]\s*(.+?)(?:\n|$)/i);n.push({target:"branch",pattern:s[1]||s[0],example:p?.[1]?.trim()})}const i=a.match(/commit.*?(?:format|pattern|message|convention).*?[:`]\s*(.+?)(?:\n|$)/i)||a.match(/(?:type)\(scope\):\s*description/i);i&&n.push({target:"commit",pattern:i[1]||i[0]});const l=a.match(/file.*?(?:naming|convention|pattern).*?[:`]\s*(.+?)(?:\n|$)/i);l&&n.push({target:"file",pattern:l[1]});const c=a.match(/(?:pr|pull\s*request).*?(?:format|title|naming).*?[:`]\s*(.+?)(?:\n|$)/i);return c&&n.push({target:"pr",pattern:c[1]}),n}function _6(e,n){const a=E6(e),s={constraints:[],workflowSteps:[],personaHints:[],toolHints:[],outputRules:[],namingPatterns:[],residual:"",source:n},i=[];for(const l of a){let c=!1;for(const p of M6)if(j6(l,p)){switch(c=!0,p.target){case"constraint":s.constraints.push(...T6(l));break;case"workflow":s.workflowSteps.push(...N6(l));break;case"persona":l.content.trim()&&s.personaHints.push(l.content.trim());break;case"tool":for(const f of l.content.split(`
452
+ `)){const m=f.match(/^[-*]\s+(.+)/);m&&s.toolHints.push(m[1].trim())}break;case"naming":s.namingPatterns.push(...A6(l));break;case"output":{for(const m of l.content.split(`
453
+ `)){const g=m.match(/^[-*]\s+(.+)/);g&&g[1].length>10&&s.outputRules.push(g[1].trim())}const f=l.content.match(/```[\s\S]*?```/g);if(f)for(const m of f)s.outputRules.push(m);break}}break}!c&&l.content.trim()&&i.push(l.heading?`${"#".repeat(l.level)} ${l.heading}
454
+ ${l.content}`:l.content)}return s.residual=i.join(`
455
+
456
+ `),s}function xc(e,n){const a=e.replace(/\b(must|never|always|should|do not|avoid|use|prefer)\b/gi,"").split(/\s+/).filter(i=>i.length>=3),s=new Set(n.replace(/\b(must|never|always|should|do not|avoid|use|prefer)\b/gi,"").split(/\s+/).filter(i=>i.length>=3));return a.some(i=>s.has(i))}function D6(e){const n=e.flatMap(g=>g.constraints),a=e.flatMap(g=>g.workflowSteps),s=e.flatMap(g=>g.personaHints),i=e.flatMap(g=>g.toolHints),l=e.map(g=>g.residual).filter(Boolean),c=[...new Set(n)],p=[];for(let g=0;g<c.length;g++)for(let x=g+1;x<c.length;x++){const b=c[g].toLowerCase(),v=c[x].toLowerCase();(b.includes("must")&&v.includes("never")&&xc(b,v)||b.includes("never")&&v.includes("must")&&xc(b,v)||b.includes("use ")&&v.includes("avoid ")&&xc(b,v)||b.includes("avoid ")&&v.includes("use ")&&xc(b,v))&&p.push(`⚠️ Conflict: "${c[g]}" vs "${c[x]}"`)}const f=e.flatMap(g=>g.namingPatterns).map(g=>{const x=g.example?` (e.g. ${g.example})`:"";return`${g.target} naming: ${g.pattern}${x}`}),m=[...c,...f];return{conflicts:p,constraintsBlock:m.length>0?`<framework_constraints source="guidelines">
457
+ ${m.map(g=>`- ${g}`).join(`
458
+ `)}${p.length>0?`
459
+
460
+ Conflicts detected:
461
+ `+p.join(`
462
+ `):""}
463
+ </framework_constraints>`:"",workflowBlock:a.length>0?`<framework_workflow>
464
+ ${a.map((g,x)=>`${x+1}. ${g}`).join(`
465
+ `)}
466
+ </framework_workflow>`:"",personaBlock:s.length>0?`<framework_persona>
467
+ ${s.join(`
468
+
469
+ `)}
470
+ </framework_persona>`:"",toolHintsBlock:i.length>0?`<tool_hints>
471
+ ${i.map(g=>`- ${g}`).join(`
472
+ `)}
473
+ </tool_hints>`:"",outputBlock:e.flatMap(g=>g.outputRules).length>0?`<output_format>
474
+ Format your responses according to these rules:
475
+ ${e.flatMap(g=>g.outputRules).map(g=>g.startsWith("```")?g:`- ${g}`).join(`
476
+ `)}
477
+ </output_format>`:"",residualKnowledge:l.length>0?l.join(`
478
+
479
+ ---
480
+
481
+ `):""}}async function Gv(e,n){const a=wn.getState(),s=fn.getState(),i=new Set(["framework","guideline"]),l=e.filter(x=>i.has(x.knowledgeType)),c=e.filter(x=>!i.has(x.knowledgeType));let p="",f,m="";const g=e.filter(x=>x.path);if(g.length>0){const x=Date.now();await a.indexFiles(g.map(b=>b.path)),s.addEvent(n,{kind:"retrieval",sourceName:"pipeline:fetch",query:`${g.length} sources`,resultCount:g.filter(b=>a.getIndex(b.path)!=null).length,durationMs:Date.now()-x})}if(l.length>0){const x=l.map(b=>{let v=b.path?a.getIndex(b.path):null;if(!v&&b.content){const C=`content://${b.contentSourceId||b.sourceId}`;v=qs(C,b.content)}if(!v)return null;const k=xi(v,0),w=bi(k.filtered);return w.trim()?_6(w,b.name):null}).filter(b=>b!==null);if(x.length>0){const b=D6(x);p=[b.constraintsBlock,b.workflowBlock,b.personaBlock,b.toolHintsBlock,b.outputBlock].filter(Boolean).join(`
482
+
483
+ `),f={constraints:x.reduce((k,w)=>k+w.constraints.length,0),workflowSteps:x.reduce((k,w)=>k+w.workflowSteps.length,0),personaHints:x.reduce((k,w)=>k+w.personaHints.length,0),toolHints:x.reduce((k,w)=>k+w.toolHints.length,0),outputRules:x.reduce((k,w)=>k+w.outputRules.length,0),namingPatterns:x.reduce((k,w)=>k+w.namingPatterns.length,0),sources:x.map(k=>k.source)},b.residualKnowledge.trim()&&(m=`<knowledge type="framework-residual">
484
+ ${b.residualKnowledge}
485
+ </knowledge>`),s.addEvent(n,{kind:"retrieval",sourceName:"pipeline:framework",query:`${x.length} framework sources`,resultCount:x.reduce((k,w)=>k+w.constraints.length+w.workflowSteps.length,0),durationMs:0})}}return{frameworkBlock:p,frameworkSummary:f,regularChannels:c,residualKnowledgeBlock:m}}function Sm(e){const n=[];n.push(`Source: ${e.source} (${e.totalTokens} tokens, ${e.nodeCount} nodes)`),n.push("");function a(s,i){if(s.depth===0&&s.children.length>0){for(const m of s.children)a(m,i);return}const l=" ".repeat(i),c=s.totalTokens>0?` [${s.totalTokens} tokens]`:"",p=s.children.length>0?` (${s.children.length} subsections)`:"",f=s.meta?.firstSentence?` — ${s.meta.firstSentence}`:"";n.push(`${l}[${s.nodeId}] ${s.title}${c}${p}${f}`);for(const m of s.children)a(m,i+1)}return a(e.root,0),n.join(`
486
+ `)}function Cm(e,n){return`You are selecting which parts of the knowledge base to include in context for a coding task.
487
+
488
+ TASK: ${n.task}
489
+ TOKEN BUDGET: ${n.tokenBudget} tokens available for knowledge
490
+
491
+ Below are the available knowledge sources with their tree structure. Each node shows:
492
+ - [nodeId] Title [total tokens] (subsections) — first sentence
493
+
494
+ YOUR JOB: Select which branches to include and at what depth:
495
+ - depth 0 (Full): Include everything — use for critical sections you need to read carefully
496
+ - depth 1 (Detail): First paragraph per leaf — use for important context
497
+ - depth 2 (Summary): First sentence per section — use for orientation
498
+ - depth 3 (Headlines): Just titles — use for awareness
499
+ - depth 4 (Mention): Skip content — just note it exists
500
+
501
+ RULES:
502
+ - Stay within the token budget (depths reduce tokens: Full=100%, Detail=75%, Summary=50%, Headlines=25%, Mention=10%)
503
+ - Prioritize sections directly relevant to the task
504
+ - Include architectural context at Summary/Headlines even if not directly relevant
505
+ - Be specific about WHY you selected each branch
506
+
507
+ SOURCES:
508
+ ${e.join(`
509
+
510
+ ---
511
+
512
+ `)}
513
+
514
+ Respond with a JSON array of selections:
515
+ [
516
+ { "nodeId": "n1-0", "depth": 0, "reason": "Need full implementation details for the order store", "priority": 0 },
517
+ { "nodeId": "n1-3", "depth": 2, "reason": "Architecture context for understanding the module", "priority": 2 },
518
+ ...
519
+ ]${n.existingContext?`
520
+
521
+ ALREADY IN CONTEXT (don't duplicate):
522
+ ${n.existingContext}`:""}`}function qv(e,n){if(e.nodeId===n)return e;for(const a of e.children){const s=qv(a,n);if(s)return s}return null}function Kv(e,n){const a=[];if(n===4)return"";if(n===3){e.depth>0&&a.push(`${"#".repeat(e.depth)} ${e.title}`);for(const s of e.children)s.depth<=2&&a.push(`${"#".repeat(s.depth)} ${s.title}`);return a.join(`
523
+ `)}e.depth>0&&a.push(`${"#".repeat(e.depth)} ${e.title}`),n===0?e.text&&a.push(e.text):n===1?e.children.length===0&&e.meta?.firstParagraph?a.push(e.meta.firstParagraph):e.text&&a.push(e.text):n===2&&e.meta?.firstSentence&&a.push(e.meta.firstSentence);for(const s of e.children){const i=Kv(s,n);i&&a.push(i)}return a.join(`
524
+
525
+ `)}function z6(e,n){const a=[],s=new Map;for(const c of e)s.set(c.source,c);for(const c of n.selections){let p=null;for(const m of e)if(p=qv(m.root,c.nodeId),p)break;if(!p)continue;const f=Kv(p,c.depth);f.trim()&&a.push({priority:c.priority,nodeId:c.nodeId,content:f,tokens:Ye(f),depth:c.depth})}a.sort((c,p)=>c.priority-p.priority);const i=a.map(c=>c.content).join(`
526
+
527
+ ---
528
+
529
+ `),l=a.map(c=>({nodeId:c.nodeId,tokens:c.tokens,depth:c.depth}));return{content:i,tokens:Ye(i),breakdown:l}}function qc(e){const n=e.match(/\[[\s\S]*\]/);if(!n)return[];try{const a=JSON.parse(n[0]);return Array.isArray(a)?a.filter(s=>s.nodeId&&typeof s.depth=="number").map(s=>({nodeId:s.nodeId,depth:Math.max(0,Math.min(4,s.depth)),reason:s.reason||"",priority:s.priority??2})):[]}catch{return[]}}function R6(e,n){const a=n.length>4e3?n.slice(0,4e3)+"...[truncated]":n;return`You are auditing whether the provided context contains enough information to complete a coding task.
530
+
531
+ TASK: ${e}
532
+
533
+ CURRENT CONTEXT:
534
+ ${a}
535
+
536
+ YOUR JOB: Identify what critical information is MISSING from the context to complete this task. Look for:
537
+ - Missing implementation details or code examples
538
+ - Missing architectural context or relationships
539
+ - Missing configuration or setup information
540
+ - Missing error handling or edge case patterns
541
+
542
+ Respond with a JSON array of missing information gaps (maximum 3):
543
+ ["Missing error handling patterns for API failures", "Missing database schema for user table", "Missing authentication flow details"]
544
+
545
+ If the context appears complete for the task, respond with: []`}function $6(e){const n=e.match(/\[[\s\S]*?\]/);if(!n)return[];try{const a=JSON.parse(n[0]);return Array.isArray(a)?a.filter(s=>typeof s=="string"&&s.trim().length>0).slice(0,3):[]}catch{return[]}}function O6(e){return`You are writing a hypothetical documentation passage that would perfectly answer this query.
546
+
547
+ QUERY: ${e}
548
+
549
+ Write a comprehensive documentation passage that would ideally exist in a codebase to answer this question. Include:
550
+ - Relevant code examples
551
+ - Implementation details
552
+ - Configuration options
553
+ - Common patterns and best practices
554
+
555
+ Write as if this documentation already exists and covers exactly what the user needs to know:`}function F6(e){return e.trim().split(/\s+/).length>=10}function I6(e,n=8){return e.toLowerCase().replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim().split(" ").slice(0,n).join(" ")}function L6(e,n){const a=new Set,s=[];let i=0;for(let l=0;l<e.length;l++){const c=e[l];if(n.has(l)){s.push(c);continue}const p=I6(c);if(p.length<10){s.push(c);continue}if(a.has(p)){i++;continue}a.add(p),s.push(c)}return{result:s,removed:i}}const B6=[/^(as mentioned|as noted|as described|as stated|as shown|as seen)\b/i,/^(it is worth noting|it should be noted|it is important to note|note that)\b/i,/^(in this section|in the following|the following section|this section)\b/i,/^(let's|let us|we will|we'll|we can|we should)\s+(look at|examine|explore|consider|discuss|review|take a look)/i,/^(basically|essentially|fundamentally|generally speaking|in general)\b/i,/^(it goes without saying|needless to say|obviously|of course|clearly)\b/i,/^(furthermore|moreover|additionally|in addition|also|besides|what's more)\s*,?\s*$/i,/^(in conclusion|to summarize|to sum up|in summary|overall)\s*,?\s*$/i];function P6(e){const n=e.trim();if(!n)return 1;let a=0;for(const p of B6)if(p.test(n)){a+=.6;break}const s=n.split(/\s+/).length;s<4&&(a+=.3);const i=new Set(["the","a","an","is","are","was","were","be","been","being","have","has","had","do","does","did","will","would","could","should","may","might","shall","can","this","that","these","those","it","its","to","of","in","for","on","with","at","by","from","as","into","about"]),l=n.toLowerCase().split(/\s+/);return l.filter(p=>i.has(p)).length/l.length>.7&&s>5&&(a+=.2),Math.min(1,a)}function H6(e,n=.5,a){let s=0;const i=[];for(let l=0;l<e.length;l++){const c=e[l];if(a.has(l)){i.push(c);continue}const f=c.split(new RegExp("(?<=[.!?])\\s+")).filter(m=>P6(m)>=n?(s++,!1):!0);f.length>0&&i.push(f.join(" "))}return{result:i,removed:s}}function U6(e){let n=0;return{result:e.replace(/```[\s\S]*?```/g,s=>{const i=s.split(`
556
+ `),l=i[0],c=i[i.length-1],f=i.slice(1,-1).filter(m=>{const g=m.trim();return g.startsWith("//")&&!g.startsWith("///")&&!g.startsWith("//!")||g.startsWith("#")&&!g.startsWith("#!")&&!g.startsWith("# ")?(n++,!1):!!g});return[l,...f,c].join(`
557
+ `)}),removedComments:n}}function G6(e,n={}){const{dedup:a=!0,removeFiller:s=!0,compressCode:i=!0,aggressiveness:l=.5,tokenBudget:c,preservePatterns:p=[]}=n,f=Ye(e);let m=e,g=0,x=0,b=0;if(i){const M=U6(m);m=M.result,b=M.removedComments}let v=m.split(/\n\s*\n/).filter(M=>M.trim());const k=p.map(M=>new RegExp(M,"i")),w=M=>{const N=new Set;if(k.length===0)return N;for(let S=0;S<M.length;S++)k.some(E=>E.test(M[S]))&&N.add(S);return N};if(a){const M=L6(v,w(v));v=M.result,g=M.removed}if(s){const M=.3+.4*(1-l),N=H6(v,M,w(v));v=N.result,x=N.removed}if(m=v.join(`
558
+
559
+ `),c){let M=Ye(m);if(M>c){const N=w(v);for(;v.length>1&&M>c;){let S=-1;for(let E=v.length-1;E>=0;E--)if(!N.has(E)){S=E;break}if(S<0)break;v.splice(S,1),m=v.join(`
560
+
561
+ `),M=Ye(m)}}}const C=Ye(m);return{content:m,originalTokens:f,compressedTokens:C,ratio:f>0?C/f:1,removals:{duplicates:g,filler:x,codeComments:b}}}function q6(e){switch(e.type){case"markdown":return qs(e.name,e.content||"");case"structured":return Y4(e.name,e.fields||[],e.sourceType);case"chronological":return V4(e.name,e.entries||[],e.sourceType);case"flat":return Rx(e.name,e.content||"",e.sourceType);default:return Rx(e.name,e.content||"")}}function K6(e){const n=Date.now(),a=e.sources.map(q6),s=Date.now()-n,i=a.map(Sm),l=Cm(i,{task:e.task,tokenBudget:e.tokenBudget});return{indexes:a,headlines:i,navigationPrompt:l,indexMs:s}}function Jx(e,n,a,s){const i=Date.now(),l=a.manualSelections||qc(n),c=Date.now()-i,p={source:a.sources.map(w=>w.name).join(", "),selections:l,taskRelevance:a.task},f=z6(e,p),m=Date.now();let g,x={originalTokens:0,compressedTokens:0,ratio:1,removals:{duplicates:0,filler:0,codeComments:0}};if(a.compression?.enabled!==!1&&f.content)if(f.breakdown.map(C=>({content:f.content,priority:l.find(M=>M.nodeId===C.nodeId)?.priority??2})).length>0){const C=G6(f.content,{tokenBudget:a.tokenBudget,aggressiveness:a.compression?.aggressiveness??.5});g=C.content,x={originalTokens:C.originalTokens,compressedTokens:C.compressedTokens,ratio:C.ratio,removals:C.removals}}else g=f.content;else g=f.content,x.originalTokens=Ye(f.content),x.compressedTokens=x.originalTokens;const b=Date.now()-m,v=s+c+b,k=Ye(g);return{context:g,tokens:k,utilization:a.tokenBudget>0?k/a.tokenBudget:0,sources:e.map(w=>({name:w.source,type:w.sourceType,totalTokens:w.totalTokens,indexedNodes:w.nodeCount})),navigation:{selections:l,prompt:void 0},compression:x,indexes:e,timing:{indexMs:s,navigationMs:c,compressionMs:b,totalMs:v}}}const Y6=[/\bnot\b/i,/\bhowever\b/i,/\bcontrary to\b/i,/\bunlike\b/i,/\bfails to\b/i,/\bbut\b/i,/\balthough\b/i,/\bwhile\b/i,/\bwhereas\b/i,/\binstead\b/i,/\brather than\b/i,/\bon the other hand\b/i,/\bin contrast\b/i,/\bnevertheless\b/i,/\bnonetheless\b/i,/\bdespite\b/i,/\bin spite of\b/i],V6=[/\blimitations?\b/i,/\brestrictions?\b/i,/\bchallenges?\b/i,/\bproblems?\b/i,/\bissues?\b/i,/\brisks?\b/i,/\bdisadvantages?\b/i,/\bcons\b/i,/\bweaknesses?\b/i,/\bfailures?\b/i,/\berrors?\b/i,/\bmistakes?\b/i,/\balternatives?\b/i,/\bother approaches?\b/i,/\bdifferent view\b/i,/\bopposing\b/i,/\bcounter\b/i],W6=[/\bresults?\b/i,/\bbenefits?\b/i,/\badvantages?\b/i,/\bpros\b/i,/\bstrengths?\b/i,/\bsuccesses?\b/i,/\bachievements?\b/i,/\bimprovements?\b/i,/\bgains?\b/i,/\bpositive\b/i,/\brecommendations?\b/i,/\bbest practices?\b/i];function eb(e){const n=new Set;return(e.match(/\b[A-Z][a-z]+(?:\s+[A-Z][a-z]*)*\b/g)||[]).forEach(p=>n.add(p.toLowerCase())),(e.match(/"([^"]+)"/g)||[]).forEach(p=>n.add(p.replace(/"/g,"").toLowerCase())),(e.match(/`([^`]+)`/g)||[]).forEach(p=>n.add(p.replace(/`/g,"").toLowerCase())),(e.match(/\*\*([^*]+)\*\*/g)||[]).forEach(p=>n.add(p.replace(/\*\*/g,"").toLowerCase())),(e.match(/\*([^*]+)\*/g)||[]).forEach(p=>n.add(p.replace(/\*/g,"").toLowerCase())),n}function X6(e,n){const a=eb(e.content),s=eb(n.content);if(a.size===0&&s.size===0)return 0;const i=new Set(Array.from(a).filter(c=>s.has(c))),l=new Set([...Array.from(a),...Array.from(s)]);return i.size/l.size}function Z6(e){return Y6.some(n=>n.test(e))}function tb(e){const n=e.toLowerCase();return V6.some(a=>a.test(n))?"contrasting":W6.some(a=>a.test(n))?"supporting":"neutral"}function Q6(e,n,a=.2){const s=[],i=[],l=new Set(e.map(c=>`${c.source}:${c.section}`));for(const c of e){let p=null,f="",m=0;for(const g of n){const x=`${g.source}:${g.section}`;if(x===`${c.source}:${c.section}`||l.has(x))continue;const b=X6(c,g);if(b<a)continue;let v=0,k="";const w=tb(c.section),C=tb(g.section);w==="supporting"&&C==="contrasting"?(v+=.6,k=`contrasting section types: "${c.section}" vs "${g.section}"`):w==="contrasting"&&C==="supporting"&&(v+=.6,k=`contrasting section types: "${c.section}" vs "${g.section}"`),Z6(g.content)&&(v+=.4,k?k+=" + negation patterns":k="negation patterns detected"),v+=b*.3,v>m&&(m=v,p=g,f=k)}if(p&&m>.3){const g=`${p.source}:${p.section}`;s.some(x=>`${x.source}:${x.section}`===g)||s.push(p),i.push({supporting:c,contrasting:p,reason:f})}}return{supporting:e,contrasting:s,pairs:i}}function J6(e){return[/\bshould we\b/i,/\bcompare\b/i,/\bwhich is better\b/i,/\bpros and cons\b/i,/\bevaluate\b/i,/\banalyz(e|ation)/i,/\bassess\b/i,/\balternatives?\b/i,/\bdecid[ei](on)?\b/i,/\btrade-?offs?\b/i,/\badvantages?\b/i,/\bdisadvantages?\b/i,/\bvs\.?\s/i,/\bversus\b/i,/\bweigh\b/i].some(a=>a.test(e))}function mf(e){const n=e.toLowerCase();return/\b(compare|vs|versus|evaluate|pros and cons|advantages|disadvantages|should we|tradeoffs?|better|worse|choose|decide|recommend)\b/.test(n)?"analytical":n.length<50||/\b(what is|how does|who is|when did|where is|define|definition)\b/.test(n)||/\b(version|spec|api|format|syntax|command)\b/.test(n)?"factual":"exploratory"}function eD(e){switch(e){case"factual":return .9;case"analytical":return .5;case"exploratory":return .7}}function tD(e,n=500){if(e.tokens<=n)return[{content:e.text,nodeId:e.nodeId,source:"",section:e.title,parentNodeId:void 0,depth:e.depth,knowledgeType:"signal"}];const a=e.text.split(/\n\s*\n/),s=[];let i="",l=0;for(const c of a){const p=i?`${i}
562
+
563
+ ${c}`:c;Ye(p)>n&&i?(s.push({content:i.trim(),nodeId:`${e.nodeId}-${l++}`,source:"",section:`${e.title} (part ${l})`,parentNodeId:e.nodeId,depth:e.depth+1,knowledgeType:"signal"}),i=c):i=p}return i.trim()&&s.push({content:i.trim(),nodeId:`${e.nodeId}-${l}`,source:"",section:`${e.title} (part ${l+1})`,parentNodeId:e.nodeId,depth:e.depth+1,knowledgeType:"signal"}),s}function nD(e){const n=[];for(const{treeIndex:a,knowledgeType:s}of e){const i=[{node:a.root}];for(;i.length>0;){const{node:l,parentId:c}=i.pop();if((l.children.length===0||l.text&&l.text.trim().length>0)&&l.text&&l.text.trim().length>0){const p=tD(l);for(const f of p)f.source=a.source,f.knowledgeType=s,f.parentNodeId=c,n.push(f)}for(const p of l.children)i.push({node:p,parentId:l.nodeId})}}return n}async function oD(e){if(e.length===0)return[];const n=[],a=[];for(let c=0;c<e.length;c++)e[c]&&e[c].trim().length>0&&(n.push(c),a.push(e[c]));if(a.length===0)return e.map(()=>[]);const s=await fetch(`${Ee}/embeddings/embed`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({texts:a})});if(!s.ok)throw new Error(`Embedding service error: ${s.status} ${s.statusText}`);const i=await s.json(),l=e.map(()=>[]);for(let c=0;c<n.length;c++)l[n[c]]=i.embeddings[c];return l}function ai(e,n){if(e.length!==n.length||e.length===0)return 0;let a=0,s=0,i=0;for(let c=0;c<e.length;c++)a+=e[c]*n[c],s+=e[c]*e[c],i+=n[c]*n[c];const l=Math.sqrt(s)*Math.sqrt(i);return l===0?0:a/l}function aD(e){if(e.length<=1)return 1;const n=e.map(i=>i.embedding).filter(i=>i);if(n.length<=1)return 1;let a=0,s=0;for(let i=0;i<n.length;i++)for(let l=i+1;l<n.length;l++)a+=ai(n[i],n[l]),s++;return s===0?1:1-a/s}function sD(e,n,a){if(e.length===0)return[];const s=[],i=[...e];let l=0;for(;i.length>0&&l<a;){let c=-1/0,p=-1;for(let g=0;g<i.length;g++){const x=i[g];if(!x.embedding)continue;const b=Ye(x.content);if(l+b>a)continue;const v=x.relevanceScore;let k=0;for(const C of s)if(C.embedding){const M=ai(x.embedding,C.embedding);k=Math.max(k,M)}const w=n*v-(1-n)*k;w>c&&(c=w,p=g)}if(p===-1)break;const f=i.splice(p,1)[0],m=Ye(f.content);s.push(f),l+=m}return s}async function rD(e,n,a){const s=Date.now();let i=nD(n);if(i.length===0)return{chunks:[],diversityScore:1,collapseWarning:!1,totalChunks:0,queryType:mf(e),retrievalMs:Date.now()-s,embeddingMs:0,budgetUsed:0,budgetTotal:a};const l=Date.now(),c=i.filter(W=>W.content&&W.content.trim().length>0);if(c.length===0)return{chunks:[],diversityScore:1,collapseWarning:!1,totalChunks:i.length,queryType:mf(e),retrievalMs:Date.now()-s,embeddingMs:0,budgetUsed:0,budgetTotal:a};i=c;const p=[e,...i.map(W=>W.content)],f=await oD(p),m=Date.now()-l,g=f[0],x=f.slice(1);i.forEach((W,$)=>{W.embedding=x[$]});const b=.3,v=i.map(W=>({...W,relevanceScore:W.embedding?ai(g,W.embedding):0,inclusionReason:"direct"})).filter(W=>W.relevanceScore>b),k=new Map(i.map(W=>[W.nodeId,W])),w=new Map;for(const W of v)if(w.set(W.nodeId,W),W.parentNodeId){const $=k.get(W.parentNodeId);if($&&$.embedding&&!w.has($.nodeId)){const V=W.relevanceScore*.6;V>b&&w.set($.nodeId,{...$,relevanceScore:V,inclusionReason:"parent-expansion"})}}const C=.5,M=.4;for(const W of v)if(W.relevanceScore>C&&W.parentNodeId&&W.embedding){const $=i.filter(V=>V.parentNodeId===W.parentNodeId&&V.nodeId!==W.nodeId&&!w.has(V.nodeId));for(const V of $)if(V.embedding&&ai(W.embedding,V.embedding)>M){const H=ai(g,V.embedding);w.set(V.nodeId,{...V,relevanceScore:H,inclusionReason:"sibling-coherence"})}}const N=mf(e),S=eD(N),E=Array.from(w.values()),I=sD(E,S,a),D=aD(I),A=D<.3,L=I.reduce((W,$)=>W+Ye($.content),0),P=Date.now()-s;return{chunks:I,diversityScore:D,collapseWarning:A,totalChunks:i.length,queryType:N,retrievalMs:P,embeddingMs:m,budgetUsed:L,budgetTotal:a}}const Yv={"ground-truth":1,evidence:.8,signal:.6,hypothesis:.4},Vv={full:1,summary:.7,headline:.4};function If(e,n){const a=[],s=[],i=new Map;n.forEach(c=>{i.set(c.name,c),c.path&&i.set(c.path,c)});for(const c of e.sources){const p=i.get(c.name);if(!p)continue;const f=Wv(p.knowledgeType),m=uD(p.depth);a.push({path:p.path||p.name,type:f,sections:c.indexedNodes,depth:m,method:"tree-index",chunkCount:Math.floor(c.totalTokens/100)}),s.push({from:p.path||p.name,method:"tree-index",to:`index-${c.name}`}),e.compression.ratio<1&&s.push({from:`index-${c.name}`,method:"rtk-compression",to:`compressed-${c.name}`})}const l={weights:Yv,depthWeights:Vv,instructions:pD()};return{sources:a,derivations:s,conflictResolution:l}}function iD(e){return e.map(n=>{const a=Wv(n.type),s=dD(n.depth),i=cD(a,s);return{content:n.content,provenance:{source:n.source,section:n.section,type:a,depth:s,method:n.method,confidence:i}}})}function lD(e){const n=[],a=new Set,s=fD(e);for(const[i,l]of Object.entries(s)){if(l.length<2)continue;const c=mD(l);for(const p of c){const f=p.map(g=>`${g.provenance.source}:${g.provenance.section}`).sort().join("|");if(a.has(f))continue;a.add(f);const m=hD(p);m&&n.push({conflictingChunks:p,resolution:m})}}return n}function cD(e,n){const a=Yv[e]||.5,s=Vv[n]||.5;return a*s}function Wv(e){switch(e){case"ground-truth":return"ground-truth";case"evidence":return"evidence";case"signal":return"signal";case"hypothesis":return"hypothesis";default:return"signal"}}function uD(e){switch(e){case 0:return"full";case 1:return"summary";case 2:return"headline";default:return"summary"}}function dD(e){switch(e){case"full":return"full";case"summary":return"summary";case"headline":return"headline";default:return"summary"}}function pD(){return`When sources conflict, apply this priority order:
564
+ 1. Source reliability: ground-truth > evidence > signal > hypothesis
565
+ 2. Content depth: full > summary > headline
566
+ 3. Recency: prefer more recent information when timestamps are available
567
+ 4. Specificity: prefer specific details over general statements
568
+
569
+ When presenting conflicting information, acknowledge the conflict and explain your reasoning based on source reliability.`}function fD(e){const n={};for(const a of e){const s=a.provenance.section||"general";n[s]||(n[s]=[]),n[s].push(a)}return n}function mD(e){const n=[];for(let a=0;a<e.length;a++)for(let s=a+1;s<e.length;s++){const i=e[a],l=e[s];i.provenance.source!==l.provenance.source&&i.provenance.section===l.provenance.section&&gD(i.content,l.content)<.7&&n.push([i,l])}return n}function hD(e){let n=e[0],a=n.provenance.confidence;for(const i of e)i.provenance.confidence>a&&(n=i,a=i.provenance.confidence);const s=`Preferred ${n.provenance.type} source (confidence: ${a.toFixed(2)}) over other sources`;return{preferredChunk:n,reason:s,confidence:a}}function gD(e,n){const a=new Set(e.toLowerCase().split(/\s+/)),s=new Set(n.toLowerCase().split(/\s+/)),i=new Set([...a].filter(c=>s.has(c))),l=new Set([...a,...s]);return i.size/l.size}function Lf(e,n,a,s,i,l){return`<chunk source="${n}" section="${a}" type="${s}" depth="${i}" method="${l}">
570
+ ${e}
571
+ </chunk>`}function yD(e,n){const a=[];if(!e.context)return a;const s=new Map;for(const l of n)s.set(l.name,l),l.path&&s.set(l.path,l);const i=xD(e.context);for(const l of i){let c;for(const f of e.sources)if(l.content.length>0&&s.has(f.name)){c=s.get(f.name);break}const p=c?Rs[c.depth]?.label??"full":"full";a.push({content:l.content,source:c?.path||c?.name||"unknown",section:l.heading||"main",type:c?.knowledgeType||"signal",depth:p,method:"tree-index-pipeline",node:{}})}return a}function xD(e){const n=e.split(`
572
+ `),a=[];let s="",i=[];for(const l of n){const c=l.match(/^#{1,4}\s+(.+)/);if(c){if(i.length>0){const p=i.join(`
573
+ `).trim();p&&a.push({heading:s,content:p})}s=c[1],i=[]}else i.push(l)}if(i.length>0){const l=i.join(`
574
+ `).trim();l&&a.push({heading:s,content:l})}return a}function bD(e,n,a){const s=If(e,n);if(!J6(a))return{knowledgeBlock:`<knowledge sources="${e.sources.map(w=>`${w.name} (${w.type}, ${w.totalTokens} tokens, ${w.indexedNodes} nodes)`).join(", ")}">
575
+ ${e.context}
576
+ </knowledge>`,provenance:s};const i=yD(e,n);if(i.length===0)return{knowledgeBlock:`<knowledge sources="${e.sources.map(w=>`${w.name} (${w.type}, ${w.totalTokens} tokens, ${w.indexedNodes} nodes)`).join(", ")}">
577
+ ${e.context}
578
+ </knowledge>`,provenance:s};const l=iD(i),c=lD(l),p=Q6(i,i),f=p.supporting.map(v=>Lf(v.content,v.source,v.section,v.type,v.depth,v.method)),m=p.contrasting.map(v=>Lf(v.content,v.source,v.section,v.type,v.depth,v.method));let g="";if(f.length>0&&(g+=`<supporting>
579
+ ${f.join(`
580
+
581
+ `)}
582
+ </supporting>`),m.length>0&&(g&&(g+=`
583
+
584
+ `),g+=`<contrasting>
585
+ ${m.join(`
586
+
587
+ `)}
588
+ </contrasting>`),c.length>0){g&&(g+=`
589
+
590
+ `),g+=`<conflicts_resolved>
591
+ `;for(const v of c)g+=`Conflict: ${v.conflictingChunks.map(k=>k.provenance.source).join(" vs ")}
592
+ `,g+=`Resolution: ${v.resolution.reason}
593
+
594
+ `;g+="</conflicts_resolved>"}return g||(g=e.context),{knowledgeBlock:`<knowledge sources="${e.sources.map(v=>`${v.name} (${v.type}, ${v.totalTokens} tokens, ${v.indexedNodes} nodes)`).join(", ")}">
595
+ ${g}
596
+ </knowledge>`,provenance:s}}function vD(e){const n=e.filter(l=>l.enabled);if(n.length===0)return"";const a={},s=["ground-truth","signal","evidence","framework","hypothesis","guideline"];for(const l of n)a[l.knowledgeType]||(a[l.knowledgeType]=[]),a[l.knowledgeType].push(l);const i=[];for(const l of s){const c=a[l];if(!c?.length)continue;const p=Zo[l],f=c.map(m=>{const g=Rs[m.depth];return`- ${m.name} (${g.label}, ~${Math.round(m.baseTokens*g.pct).toLocaleString()} tokens) [${m.path}]`});i.push(`[${p.label.toUpperCase()}] ${p.instruction}
597
+ ${f.join(`
598
+ `)}`)}return`<knowledge>
599
+ ${i.join(`
600
+
601
+ `)}
602
+ </knowledge>`}async function Nc(e,n,a){const s=await fetch(`${Ee}/llm/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,model:a,messages:[{role:"system",content:"You are a context navigation agent. Respond with ONLY a JSON array, no markdown, no explanation."},{role:"user",content:e}]}),signal:AbortSignal.timeout(3e4)});if(!s.ok)throw new Error(`Navigation LLM call failed: ${s.status}`);const l=(await s.text()).split(`
603
+ `).filter(p=>p.startsWith("data: ")).map(p=>p.slice(6)).filter(p=>p!=="[DONE]");let c="";for(const p of l)try{const m=JSON.parse(p).choices?.[0]?.delta?.content;m&&(c+=m)}catch{}return c}async function kD(e,n,a,s,i){const l=fn.getState(),c=Date.now();try{const p=e.join(". "),f=Math.floor(s.totalBudget*.2),m=new Set(a.map(w=>w.nodeId)),g=n.map(Sm),x=Cm(g,{task:p,tokenBudget:f}),b=await Nc(x,s.providerId,s.model),k=qc(b).filter(w=>!m.has(w.nodeId));return l.addEvent(i,{kind:"llm_call",model:s.model,durationMs:Date.now()-c,toolResult:`Gap navigation selected ${k.length} new branches for ${e.length} gaps`}),k}catch(p){return l.addEvent(i,{kind:"error",errorMessage:`Gap navigation failed: ${p instanceof Error?p.message:"Unknown"}`,durationMs:Date.now()-c}),[]}}async function Xv(e,n,a,s,i){const l=wn.getState(),c=fn.getState(),{userMessage:p,navigationMode:f="tree-aware",providerId:m,model:g}=s,x=e.filter(M=>M.enabled);let b=a,v=null,k=null,w;const C=[];for(const M of n)if(M.content){const N=`content://${M.contentSourceId||M.sourceId}`,S=qs(N,M.content),E=bi(xi(S,0).filtered);E.trim()&&C.push({name:M.name,type:"markdown",content:E,sourceType:M.knowledgeType})}else if(M.path){const N=l.getIndex(M.path);if(N){const S=bi(xi(N,0).filtered);S.trim()&&C.push({name:M.name,type:"markdown",content:S,sourceType:M.knowledgeType})}}if(f==="tree-aware"&&n.length>0){const M=x.reduce((S,E)=>S+E.baseTokens,0),N=[];for(const S of n)if(S.content){if(S.content.trim().length===0)continue;const E=`content://${S.contentSourceId||S.sourceId}`,I=qs(E,S.content);N.push({treeIndex:I,knowledgeType:S.knowledgeType})}else if(S.path){const E=l.getIndex(S.path);E&&N.push({treeIndex:E,knowledgeType:S.knowledgeType})}if(N.length>0)try{if(c.addEvent(i,{kind:"retrieval",sourceName:"tree-aware-retrieval",query:p,resultCount:N.length,durationMs:0}),w=await rD(p,N,M),c.addEvent(i,{kind:"retrieval",sourceName:"tree-aware-retrieval",query:p,resultCount:w.chunks.length,durationMs:w.retrievalMs}),w.chunks.length>0){const S=w.chunks.map(L=>Lf(L.content,L.source,L.section,L.knowledgeType,L.depth.toString(),"tree-aware")),E=N.map(L=>`${L.treeIndex.source} (${L.knowledgeType}, ${L.treeIndex.totalTokens} tokens, ${L.treeIndex.nodeCount} nodes)`).join(", "),I=`Query type: ${w.queryType}, Diversity: ${w.diversityScore.toFixed(2)}, Total chunks: ${w.totalChunks}`;b=`<knowledge sources="${E}" method="tree-aware" metadata="${I}">
604
+ ${S.join(`
605
+
606
+ `)}
607
+ </knowledge>`;const D=S.join(`
608
+
609
+ `),A=Ye(D);v={context:D,tokens:A,utilization:M>0?A/M:0,sources:N.map(L=>({name:L.treeIndex.source,type:L.treeIndex.sourceType,totalTokens:L.treeIndex.totalTokens,indexedNodes:L.treeIndex.nodeCount})),navigation:{selections:[]},compression:{originalTokens:w.totalChunks>0?N.reduce((L,P)=>L+P.treeIndex.totalTokens,0):0,compressedTokens:A,ratio:M>0?A/Math.max(1,N.reduce((L,P)=>L+P.treeIndex.totalTokens,0)):1,removals:{duplicates:0,filler:0,codeComments:0}},indexes:N.map(L=>L.treeIndex),timing:{indexMs:0,navigationMs:0,compressionMs:w.retrievalMs,totalMs:w.retrievalMs}},v&&(k=If(v,n)),w.collapseWarning&&c.addEvent(i,{kind:"error",errorMessage:`Low diversity score (${w.diversityScore.toFixed(2)}) - chunks may be too similar`,durationMs:0})}}catch(S){const E=S instanceof Error?S.message:"Unknown error";c.addEvent(i,{kind:"error",errorMessage:`Tree-aware retrieval failed: ${E} — falling back to pipeline`,durationMs:0})}}if(C.length>0&&(f!=="tree-aware"||!b)){const M=x.reduce(($,V)=>$+V.baseTokens,0),N=new Map;for(const $ of n)N.set($.name,$.depth);const S=C.map($=>({name:$.name,knowledgeType:$.sourceType,rawTokens:Ye($.content||""),depthMultiplier:k_[N.get($.name)??2]??1})),E=w_(S,M),I=new Map;for(const $ of E)I.set($.name,$.allocatedTokens);for(const $ of C){const X=(I.get($.name)??M)*4;$.content&&$.content.length>X&&($.content=$.content.slice(0,X))}const D=f==="agent-driven",A=K6({task:p,sources:C,tokenBudget:M});c.addEvent(i,{kind:"retrieval",sourceName:"pipeline:index",query:p,resultCount:A.indexes.length,durationMs:A.indexMs});let L="",P=x.filter($=>$.path&&l.getIndex($.path)!=null||$.content).map($=>({nodeId:$.name,depth:$.depth,priority:$.knowledgeType==="ground-truth"?0:$.knowledgeType==="signal"?1:2}));if(D&&A.indexes.length>0){const $=Date.now();try{let V=p;if(F6(p))try{const T=O6(p),B=await Nc(T,m,g);B.length>20&&(V=B,c.addEvent(i,{kind:"llm_call",model:g,durationMs:Date.now()-$,toolResult:`HyDE generated ${B.length} chars for navigation`}))}catch(T){c.addEvent(i,{kind:"error",errorMessage:`HyDE failed: ${T instanceof Error?T.message:"Unknown"} — using original query`,durationMs:0})}const X=A.indexes.map(Sm),H=Cm(X,{task:V,tokenBudget:M});L=await Nc(H,m,g);const _=qc(L);_.length>0&&(P=_),c.addEvent(i,{kind:"llm_call",model:g,durationMs:Date.now()-$,toolResult:`Agent selected ${_.length} branches`})}catch(V){c.addEvent(i,{kind:"error",errorMessage:`Navigation failed: ${V instanceof Error?V.message:"Unknown"} — using manual depths`,durationMs:Date.now()-$})}}v=Jx(A.indexes,L,{task:p,sources:C,tokenBudget:M,manualSelections:L?void 0:P,compression:{enabled:!0,aggressiveness:.5}},A.indexMs),c.addEvent(i,{kind:"retrieval",sourceName:"pipeline:compress",resultCount:v.sources.length,durationMs:v.timing.compressionMs});const W=qc(L);if(D&&W.length>0&&v.context.trim())try{const $=R6(p,v.context),V=await Nc($,m,g),X=$6(V);if(X.length>0){const H=await kD(X,A.indexes,W,{providerId:m,model:g,totalBudget:M},i);if(H.length>0){const _=[...W,...H],T=JSON.stringify(_);v=Jx(A.indexes,T,{task:p,sources:C,tokenBudget:M,manualSelections:void 0,compression:{enabled:!0,aggressiveness:.5}},A.indexMs),c.addEvent(i,{kind:"retrieval",sourceName:"pipeline:re-navigation",resultCount:H.length,durationMs:0})}}}catch($){c.addEvent(i,{kind:"error",errorMessage:`Corrective re-navigation failed: ${$ instanceof Error?$.message:"Unknown"}`,durationMs:0})}if(v.context.trim()){const $=bD(v,n,p);b=$.knowledgeBlock,k=$.provenance}else v&&(k=If(v,n))}return b||(b=vD(e)),k&&c.addEvent(i,{kind:"provenance",provenanceSources:k.sources.map(M=>({path:M.path,type:M.type,sections:M.sections,depth:M.depth,chunkCount:M.chunkCount||0})),provenanceDerivations:k.derivations,resultCount:k.sources.length}),{knowledgeBlock:b,pipelineResult:v,provenance:k,retrievalResult:w}}const hf=new Map;async function wD(e){const{url:n,ref:a,subdir:s}=e;if(!n||typeof n!="string")throw new Error("GitHub URL is required");try{const i={url:n,persist:!0};a&&typeof a=="string"&&(i.ref=a),s&&typeof s=="string"&&(i.subdir=s);const l=await fetch(`${Ee}/repo/index-github`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok){const v=await l.text();throw new Error(`Failed to index GitHub repo: ${l.status} ${v}`)}const c=await l.json();if(c.status!=="ok"||!c.data)throw new Error(c.error||"Indexing failed");const{data:p}=c,f=p.totalTokens??p.scan?.totalTokens??5e3,m=p.scan,g=Array.isArray(m?.stack)?m.stack:m?.stack&&typeof m.stack=="object"?Object.values(m.stack).filter(v=>typeof v=="string"&&v!=="unknown"&&v!=="none"):[],x=se.getState().addChannel;let b=0;for(const v of p.files){const k=`${p.outputDir}/${v}`,w=v.includes("overview"),C={sourceId:`repo-${v}-${Date.now()}`,name:v.replace(".compressed.md","").replace(".md","").replace(/^\d+-/,""),path:k,category:"knowledge",knowledgeType:"ground-truth",depth:w?1:2,baseTokens:Math.floor(f/p.files.length),repoMeta:{name:p.name||nb(n),totalFiles:m?.totalFiles??p.files.length,stack:g,features:m?.features?.map(M=>M.name)??[],baseUrl:m?.baseUrl}};w&&p.overviewMarkdown&&(C.content=p.overviewMarkdown),x(C),b++}return`Successfully indexed GitHub repository "${nb(n)}". Added ${b} knowledge sources:
610
+ `+p.files.map(v=>`- ${v.replace(".compressed.md","").replace(".md","").replace(/^\d+-/,"")}`).join(`
611
+ `)+`
612
+
613
+ Repository stats: ${m?.totalFiles??p.files.length} files, ${g.length} tech stack items, ${f} tokens`}catch(i){throw new Error(`GitHub indexing failed: ${i instanceof Error?i.message:String(i)}`)}}async function SD(e){const{path:n}=e;if(!n||typeof n!="string")throw new Error("Local repository path is required");try{const a=await fetch(`${Ee}/repo/index`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})});if(!a.ok){const p=await a.text();throw new Error(`Failed to index local repo: ${a.status} ${p}`)}const s=await a.json();if(s.status!=="ok"||!s.data)throw new Error(s.error||"Indexing failed");const{data:i}=s,l=se.getState().addChannel;let c=0;for(const p of i.files){const f=`${i.outputDir}/${p}`,m={sourceId:`local-repo-${p}-${Date.now()}`,name:p.replace(".compressed.md","").replace(".md","").replace(/^\d+-/,""),path:f,category:"knowledge",knowledgeType:"ground-truth",depth:2,baseTokens:Math.floor((i.totalTokens??5e3)/i.files.length)};l(m),c++}return`Successfully indexed local repository at "${n}". Added ${c} knowledge sources:
614
+ `+i.files.map(p=>`- ${p.replace(".compressed.md","").replace(".md","").replace(/^\d+-/,"")}`).join(`
615
+ `)}catch(a){throw new Error(`Local repository indexing failed: ${a instanceof Error?a.message:String(a)}`)}}async function CD(e){const{path:n}=e;if(!n||typeof n!="string")throw new Error("Directory path is required");try{const a=await fetch(`${Ee}/repo/scan`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})});if(!a.ok){const p=await a.text();throw new Error(`Failed to scan directory: ${a.status} ${p}`)}const s=await a.json();if(s.status!=="ok"||!s.data)throw new Error(s.error||"Scan failed");const{data:i}=s,l=Array.isArray(i.stack)?i.stack:Object.values(i.stack).filter(p=>typeof p=="string"&&p!=="unknown"&&p!=="none");let c=`Directory scan results for "${n}":
616
+
617
+ `;return c+=`📁 Files: ${i.totalFiles}
618
+ `,c+=`📊 Estimated tokens: ${i.totalTokens}
619
+
620
+ `,l.length>0&&(c+=`🛠️ Tech stack detected:
621
+ ${l.map(p=>`- ${p}`).join(`
622
+ `)}
623
+
624
+ `),i.features.length>0&&(c+=`✨ Features found:
625
+ ${i.features.map(p=>`- ${p.name}${p.description?": "+p.description:""}`).join(`
626
+ `)}
627
+
628
+ `),c+="Use `index_local_repo` to add this as a knowledge source.",c}catch(a){throw new Error(`Directory scanning failed: ${a instanceof Error?a.message:String(a)}`)}}async function MD(e){const{path:n}=e;if(!n||typeof n!="string")throw new Error("File path is required");try{const a=await fetch(`${Ee}/knowledge/index`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})});if(!a.ok){const p=await a.text();throw new Error(`Failed to index file: ${a.status} ${p}`)}const s=await a.json();if(s.status!=="ok"||!s.data)throw new Error(s.error||"Indexing failed");const{data:i}=s,l=se.getState().addChannel,c={sourceId:`file-${Date.now()}`,name:i.name,path:n,category:"knowledge",knowledgeType:"evidence",depth:1,baseTokens:i.tokens};return l(c),`Successfully indexed "${i.name}" (${i.tokens} tokens) as a knowledge source.`}catch(a){throw new Error(`File indexing failed: ${a instanceof Error?a.message:String(a)}`)}}async function ED(e){const{query:n,limit:a=5}=e;if(!n||typeof n!="string")throw new Error("Search query is required");try{const s=se.getState().channels.filter(k=>k.enabled&&(k.content||k.path));if(s.length===0)return"No knowledge sources indexed yet. Use `index_github_repo` or `index_knowledge_file` to add sources first.";const i=[];for(const k of s){let w=k.content;if(!w&&k.path)if(hf.has(k.path))w=hf.get(k.path);else try{const C=await fetch(`${Ee}/knowledge/read?path=${encodeURIComponent(k.path)}`);C.ok&&(w=await C.text(),hf.set(k.path,w))}catch(C){console.error(`Failed to fetch content for ${k.path}:`,C)}if(w){const C=w.split(/(?=^#{1,3}\s)/m).filter(M=>M.trim());for(const M of C)M.trim().length>20&&i.push({text:M.trim().slice(0,1024),source:k.name})}}if(i.length===0)return"Knowledge sources exist but have no inline content to search. Try reading specific files with `read_file`.";const l=[n,...i.map(k=>k.text)],c=await fetch(`${Ee}/embeddings/embed`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({texts:l})});if(!c.ok)throw new Error(`Embedding service error: ${c.status}`);const{embeddings:p}=await c.json(),f=p[0],m=p.slice(1),g=(k,w)=>{let C=0,M=0,N=0;for(let S=0;S<k.length;S++)C+=k[S]*w[S],M+=k[S]**2,N+=w[S]**2;return C/(Math.sqrt(M)*Math.sqrt(N)||1)},x=i.map((k,w)=>({...k,score:g(f,m[w])}));x.sort((k,w)=>w.score-k.score);const b=x.slice(0,Number(a)||5);let v=`Found ${b.length} relevant chunks for "${n}":
629
+
630
+ `;for(const k of b)v+=`**[${k.source}]** (relevance: ${(k.score*100).toFixed(0)}%)
631
+ `,v+=k.text.slice(0,500)+(k.text.length>500?"...":"")+`
632
+
633
+ ---
634
+
635
+ `;return v}catch(s){throw new Error(`Knowledge search failed: ${s instanceof Error?s.message:String(s)}`)}}async function jD(e){const{path:n}=e;if(!n||typeof n!="string")throw new Error("File path is required");try{const a=await fetch(`${Ee}/knowledge/read?path=${encodeURIComponent(n)}`);if(!a.ok){const i=await a.text();throw new Error(`Failed to read file: ${a.status} ${i}`)}const s=await a.text();return s.length>8e3?s.substring(0,8e3)+`
636
+
637
+ [Content truncated - file is very large]`:s}catch(a){throw new Error(`File reading failed: ${a instanceof Error?a.message:String(a)}`)}}function nb(e){const n=e.match(/github\.com\/([^\/]+\/[^\/]+)/);return n?n[1]:e}function Zv(){return[{name:"index_github_repo",description:"Clone and index a GitHub repository to make its code available as knowledge context. Returns an overview and feature documentation.",inputSchema:{type:"object",properties:{url:{type:"string",description:"GitHub repository URL"},ref:{type:"string",description:"Git reference (branch, tag, or commit) to clone (optional)"},subdir:{type:"string",description:"Subdirectory to focus on (optional)"}},required:["url"]},execute:wD},{name:"index_local_repo",description:"Index a local repository to make its code available as knowledge context.",inputSchema:{type:"object",properties:{path:{type:"string",description:"Local repository path"}},required:["path"]},execute:SD},{name:"scan_directory",description:"Scan a local directory to discover its structure, tech stack, and features.",inputSchema:{type:"object",properties:{path:{type:"string",description:"Directory path to scan"}},required:["path"]},execute:CD},{name:"index_knowledge_file",description:"Index a markdown or text file to make it available as knowledge context.",inputSchema:{type:"object",properties:{path:{type:"string",description:"Path to the markdown or text file"}},required:["path"]},execute:MD},{name:"search_knowledge",description:"Semantically search across all indexed knowledge sources using embeddings.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Search query text"},limit:{type:"number",description:"Maximum number of results to return (default: 10)"}},required:["query"]},execute:ED},{name:"read_file",description:"Read the content of a file from an allowed directory.",inputSchema:{type:"object",properties:{path:{type:"string",description:"File path to read"}},required:["path"]},execute:jD}]}function Qv(){const e=[],n=at.getState();for(const s of n.servers)if(s.status==="connected")for(const i of s.tools)e.push({name:i.name,description:i.description||"No description",inputSchema:i.inputSchema||{type:"object",properties:{}},origin:{kind:"mcp",serverId:s.id,serverName:s.name}});for(const s of Zv())e.push({name:s.name,description:s.description,inputSchema:s.inputSchema,origin:{kind:"builtin",serverId:"modular-studio",serverName:"Modular Studio"}});const a=new Map;for(const s of e)a.set(s.name,(a.get(s.name)??0)+1);return e.map(s=>(a.get(s.name)??0)>1?{...s,name:`${s.origin.serverId}__${s.name}`}:s)}function Jv(e){return e==="anthropic"||e==="openai"||e==="openrouter"}function TD(e){return e.map(n=>({name:n.name,description:n.description,input_schema:n.inputSchema}))}function ND(e){return e.map(n=>({type:"function",function:{name:n.name,description:n.description,parameters:n.inputSchema}}))}function AD(e,n){const a=e.find(i=>i.name===n);if(a)return a.origin;const s=n.includes("__")?n.split("__").slice(1).join("__"):null;return s?e.find(i=>i.name===s)?.origin??null:null}async function _D(e,n,a){const s=AD(a,e);if(!s)return{result:"",serverId:"",error:`Tool "${e}" not found in registry`};if(s.kind==="builtin"){const c=Zv().find(p=>p.name===e);if(!c)return{result:"",serverId:s.serverId,error:`Built-in tool "${e}" not found`};try{return{result:await c.execute(n),serverId:s.serverId}}catch(p){const f=p instanceof Error?p.message:String(p);return{result:"",serverId:s.serverId,error:f}}}const i=at.getState();try{const l=await i.callTool(s.serverId,e,n);if(l==null)return e==="get_file_contents"?{result:"No content returned. This path may be a directory - use list_directory first, or check the file tree in your context.",serverId:s.serverId}:{result:"Tool returned no result. Check arguments.",serverId:s.serverId};let c;return l&&typeof l=="object"&&"content"in l?(c=l.content.filter(f=>f.type==="text"&&f.text).map(f=>f.text).join(`
638
+ `),c||(c=JSON.stringify(l))):c=typeof l=="string"?l:JSON.stringify(l),{result:c,serverId:s.serverId}}catch(l){const c=l instanceof Error?l.message:String(l);return{result:"",serverId:s.serverId,error:c}}}async function DD(e,n,a,s){const c=Qe.getState().providers.find(g=>g.id===e)?.type??"openai",p=c==="anthropic"?TD(s):ND(s),f=await fetch(`${Ee}/llm/chat-tools`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,model:n,messages:a,tools:p})});if(!f.ok){const g=await f.text().catch(()=>"");throw new Error(`LLM tool call failed (${f.status}): ${g||f.statusText}`)}const m=await f.json();return c==="anthropic"?zD(m):RD(m)}function zD(e){const n=e.content??[],a=e.usage,s=e.stop_reason??"end_turn",i=n.filter(c=>c.type==="text").map(c=>c.text??""),l=n.filter(c=>c.type==="tool_use");return{content:i.join(""),toolCalls:l.map(c=>({id:c.id??`tc-${Date.now()}`,name:c.name??"",args:c.input??{}})),inputTokens:a?.input_tokens??0,outputTokens:a?.output_tokens??0,rawAssistantMessage:{role:"assistant",content:n},stopReason:s}}function RD(e){const n=e.choices??[],a=e.usage,s=n[0]?.message,i=n[0]?.finish_reason??"stop";return{content:s?.content??"",toolCalls:(s?.tool_calls??[]).map(l=>{let c={};try{c=JSON.parse(l.function.arguments)}catch{c={_raw:l.function.arguments,_parseError:!0}}return{id:l.id,name:l.function.name,args:c}}),inputTokens:a?.prompt_tokens??0,outputTokens:a?.completion_tokens??0,rawAssistantMessage:{role:"assistant",...s},stopReason:i}}function $D(e,n){return e==="anthropic"?[{role:"user",content:n.map(a=>({type:"tool_result",tool_use_id:a.id,content:a.error?`Error: ${a.error}`:a.result,...a.error?{is_error:!0}:{}}))}]:n.map(a=>({role:"tool",tool_call_id:a.id,content:a.error?`Error: ${a.error}`:a.result}))}async function OD(e){const{providerId:n,model:a,messages:s,traceId:i,maxTurns:l=10,callbacks:c}=e,p=fn.getState(),g=Qe.getState().providers.find(C=>C.id===n)?.type??"openai",x=Qv(),b=[];let v=0,k=0;const w=[...s];if(x.length===0||!Jv(g)){c.onError(new Error("No tools available or provider does not support tool calling"));return}try{for(let C=0;C<l;C++){const M=Date.now(),N=await DD(n,a,w,x);if(v+=N.inputTokens,k+=N.outputTokens,p.addEvent(i,{kind:"llm_call",model:a,inputTokens:N.inputTokens,outputTokens:N.outputTokens,durationMs:Date.now()-M}),N.content&&c.onChunk(N.content),N.toolCalls.length===0){c.onDone({turns:C+1,toolCalls:b,totalInputTokens:v,totalOutputTokens:k});return}w.push(N.rawAssistantMessage);const S=[];for(const I of N.toolCalls){c.onToolCallStart(I.name,I.args);const D=Date.now(),A=await _D(I.name,I.args,x),L=Date.now()-D,P={id:I.id,name:I.name,args:I.args,result:A.result,error:A.error,durationMs:L,serverId:A.serverId};S.push(P),b.push(P),p.addEvent(i,{kind:"tool_call",toolName:I.name,toolArgs:I.args,toolResult:(A.error||A.result).slice(0,500),toolError:A.error,mcpServerId:A.serverId,durationMs:L}),c.onToolCallEnd(P)}const E=$D(g,S);w.push(...E)}c.onDone({turns:l,toolCalls:b,totalInputTokens:v,totalOutputTokens:k})}catch(C){c.onError(C instanceof Error?C:new Error(String(C)))}}async function FD(e){const{providerId:n,model:a,messages:s,userMessage:i,systemPrompt:l,traceId:c,onChunk:p}=e,f=fn.getState(),m=Qv(),b=Qe.getState().providers.find(M=>M.id===n)?.type??"openai",v=m.length>0&&Jv(b)&&n!=="claude-agent-sdk";let k=[],w=0,C="";if(v){const M=Date.now();f.addEvent(c,{kind:"llm_call",model:a,inputTokens:s.reduce((N,S)=>N+Ye(typeof S.content=="string"?S.content:JSON.stringify(S.content)),0)}),await new Promise((N,S)=>{OD({providerId:n,model:a,messages:s,traceId:c,maxTurns:10,callbacks:{onChunk:E=>{C+=E,p(E)},onToolCallStart:(E,I)=>{p(`
639
+
640
+ 🔧 Calling **${E}**...
641
+ `)},onToolCallEnd:E=>{E.error?p(`❌ ${E.name} failed: ${E.error}
642
+ `):p(`✅ ${E.name} (${E.durationMs}ms)
643
+ `)},onDone:E=>{k=E.toolCalls,w=E.turns,f.addEvent(c,{kind:"llm_call",model:a,outputTokens:E.totalOutputTokens,durationMs:Date.now()-M}),N()},onError:E=>S(E)}})})}else{const M=Date.now();f.addEvent(c,{kind:"llm_call",model:a,inputTokens:s.reduce((S,E)=>S+Ye(typeof E.content=="string"?E.content:JSON.stringify(E.content)),0)});let N="";await new Promise((S,E)=>{const I={onChunk:D=>{N+=D,C+=D,p(D)},onDone:()=>{f.addEvent(c,{kind:"llm_call",model:a,outputTokens:Ye(N),durationMs:Date.now()-M}),S()},onError:D=>E(D)};n==="claude-agent-sdk"?ub({prompt:i,model:a,systemPrompt:l,...I}):db({providerId:n,model:a,messages:s,...I})})}return{fullResponse:C,toolCallResults:k,toolTurns:w}}async function ID(e){const{fullResponse:n,userMessage:a,agentId:s,sandboxRunId:i,traceId:l,activeChannels:c,memoryStats:p}=e,f=fn.getState(),m=We.getState();let g=p;if(m.longTerm.enabled&&n){const v=f6({userMessage:a,assistantResponse:n,agentId:s,traceId:l,sandboxRunId:i});g&&(g={...g,writtenFacts:v.stored.length,writeMs:v.durationMs,domains:v.stored.length>0?[...new Set([...g.domains,...v.stored.map(k=>k.domain)])]:g.domains})}f.endTrace(l);const x=[],b=wn.getState();for(const v of c){let k=function(N){N.depth>0&&N.depth<=2&&C.push({nodeId:N.nodeId,title:N.title,depth:N.depth,tokens:N.totalTokens});for(const S of N.children)k(S)},w=v.path?b.getIndex(v.path):null;if(!w&&v.content){const N=`content://${v.contentSourceId||v.sourceId}`;w=qs(N,v.content)}if(!w)continue;const C=[];k(w.root);const M=xi(w,v.depth);x.push({name:v.name,path:v.path||`content://${v.contentSourceId||v.sourceId}`,nodeCount:w.nodeCount,totalTokens:w.totalTokens,filteredTokens:M.totalTokens,depth:v.depth,knowledgeType:v.knowledgeType,headings:C})}return{heatmap:x,memoryStats:g}}function Bf(){const{agentConfig:e}=se.getState(),{selectedProviderId:n,providers:a}=Qe.getState(),s=a.find(c=>c.id===n),i=Array.isArray(s?.models)?s.models:[];if(!s||s.status!=="connected"&&s.status!=="configured"||i.length===0)return{providerId:"",model:"",error:"No provider/model configured. Open Settings → Providers, connect one provider, refresh models, then retry."};const l=i.some(c=>c.id===e.model);return{providerId:s.id,model:l?e.model:i[0].id}}async function LD(e){const{userMessage:n,channels:a,history:s,providerId:i,model:l,onChunk:c,onDone:p,onError:f}=e,m=fn.getState(),x=Ra.getState().currentVersion||"0.0.0",b=m.startTrace(`chat-${Date.now()}`,x);try{let v=oi();const k=a.filter(Q=>Q.enabled),{frameworkBlock:w,frameworkSummary:C,regularChannels:M,residualKnowledgeBlock:N}=k.length>0?await Gv(k,b):{frameworkBlock:"",frameworkSummary:void 0,regularChannels:[],residualKnowledgeBlock:""};let{knowledgeBlock:S,pipelineResult:E,provenance:I,retrievalResult:D}=k.length>0?await Xv(a,M,N,{userMessage:n,navigationMode:e.navigationMode,providerId:i,model:l},b):{knowledgeBlock:"",pipelineResult:null,provenance:null,retrievalResult:void 0};const A=(e.connectors||[]).filter(Q=>Q.enabled&&Q.direction!=="write");if(A.length>0){const q=`<connectors>
644
+ Available data connectors (use via MCP tools):
645
+ ${A.map(ie=>{const pe=ie.hint?` (scope: ${ie.hint})`:"";return`- ${ie.name} [${ie.service}] — ${ie.direction}${pe}`}).join(`
646
+ `)}
647
+ </connectors>`;S=S?`${S}
648
+
649
+ ${q}`:q}const L=We.getState();let P="",W;if(L.longTerm.enabled){L.sandbox.isolation==="reset_each_run"&&m6();const Q=await Hv({userMessage:n,agentId:e.agentId,traceId:b,sandboxRunId:e.sandboxRunId});Q.contextBlock&&(P=Q.contextBlock),W={recalledFacts:Q.facts.length,writtenFacts:0,recallMs:Q.durationMs,writeMs:0,recallTokens:Q.tokenEstimate,domains:[...new Set(Q.facts.map(q=>q.domain))]}}I&&(v=oi(I));const $=Sv(a,wn.getState().getIndex),V=a.some(Q=>Q.enabled&&Q.repoMeta),X=Cv({frame:v,orientationBlock:$,hasRepos:V,knowledgeFormatGuide:Uv(),frameworkBlock:w,memoryBlock:P,knowledgeBlock:S}),H=Ye(X),_=[{role:"system",content:X},...s.map(Q=>({role:Q.role,content:Q.content})),{role:"user",content:n}],{fullResponse:T,toolCallResults:B,toolTurns:G}=await FD({providerId:i,model:l,messages:_,userMessage:n,systemPrompt:X,traceId:b,onChunk:c}),{heatmap:K,memoryStats:J}=await ID({fullResponse:T,userMessage:n,agentId:e.agentId,sandboxRunId:e.sandboxRunId,traceId:b,activeChannels:k,memoryStats:W}),F=H+s.reduce((Q,q)=>Q+Ye(q.content),0)+Ye(n),O=D?{queryType:D.queryType,diversityScore:D.diversityScore,collapseWarning:D.collapseWarning,totalChunks:D.totalChunks,selectedChunks:D.chunks.length,budgetUsed:D.budgetUsed,budgetTotal:D.budgetTotal,retrievalMs:D.retrievalMs,embeddingMs:D.embeddingMs,chunks:D.chunks.map(Q=>({section:Q.section,source:Q.source,relevanceScore:Q.relevanceScore||0,inclusionReason:Q.inclusionReason||"unknown",knowledgeType:Q.knowledgeType,tokens:Ye(Q.content)}))}:void 0;p({pipeline:E,systemTokens:H,totalContextTokens:F,heatmap:K,frameworkSummary:C,toolCalls:B.length>0?B:void 0,toolTurns:G>0?G:void 0,memory:J,retrieval:O})}catch(v){m.addEvent(b,{kind:"error",errorMessage:v instanceof Error?v.message:"Unknown error"}),m.endTrace(b),f(v instanceof Error?v:new Error("Unknown error"))}}const ob={llm_call:{icon:Ti,color:"#9b59b6",label:"LLM Call"},tool_call:{icon:pn,color:"#2ecc71",label:"Tool Call"},retrieval:{icon:_i,color:"#3498db",label:"Retrieval"},error:{icon:mv,color:"#e74c3c",label:"Error"},token_usage:{icon:Ai,color:"#f1c40f",label:"Tokens"},fact_extracted:{icon:Df,color:"#FE5000",label:"Fact"},handoff:{icon:J5,color:"#1abc9c",label:"Handoff"}};function BD({event:e}){const n=we(),[a,s]=z.useState(!1),i=ob[e.kind]||ob.error,l=i.icon,c=e.toolArgs||e.toolResult||e.toolError||e.errorStack||e.pageRefs;return d.jsxs("div",{style:{borderBottom:`1px solid ${n.isDark?"#1a1a1e":"#f0f0f5"}`},children:[d.jsxs("button",{type:"button",onClick:()=>c&&s(!a),className:"flex items-center gap-2 w-full px-3 py-2 border-none bg-transparent text-left",style:{cursor:c?"pointer":"default"},children:[d.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:e.toolError||e.errorMessage?"#e74c3c":i.color,flexShrink:0}}),d.jsx(l,{size:10,style:{color:i.color,flexShrink:0}}),d.jsxs("span",{className:"text-[12px] flex-1 truncate",style:{fontFamily:"'Geist Sans', sans-serif",color:n.textPrimary},children:[e.kind==="tool_call"&&`${e.mcpServerName||e.mcpServerId}.${e.toolName}`,e.kind==="llm_call"&&`${e.model||"LLM"} — ${e.inputTokens||"?"}→${e.outputTokens||"?"} tokens`,e.kind==="retrieval"&&`${e.sourceName||e.sourceId} (${e.resultCount||0} results)`,e.kind==="error"&&(e.rootCause||e.errorMessage||"Unknown error"),e.kind==="fact_extracted"&&"Fact extracted from conversation",e.kind==="handoff"&&`→ ${e.toAgentId}`,e.kind==="token_usage"&&`${(e.inputTokens||0)+(e.outputTokens||0)} tokens`]}),e.durationMs!=null&&d.jsxs("span",{className:"text-[12px] shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:e.durationMs>2e3?"#e74c3c":n.textFaint},children:[e.durationMs,"ms"]}),e.costUsd!=null&&e.costUsd>0&&d.jsxs("span",{className:"text-[12px] shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:n.textFaint},children:["$",e.costUsd.toFixed(4)]}),c&&(a?d.jsx(Mn,{size:9,style:{color:n.textFaint}}):d.jsx(ta,{size:9,style:{color:n.textFaint}}))]}),a&&d.jsxs("div",{className:"px-3 pb-2 ml-6 text-[13px] flex flex-col gap-1",style:{fontFamily:"'Geist Mono', monospace",color:n.textDim},children:[e.toolArgs&&d.jsxs("div",{children:[d.jsx("span",{style:{color:n.textFaint},children:"Args:"}),d.jsx("pre",{className:"mt-0.5 p-1.5 rounded overflow-x-auto",style:{background:n.isDark?"#0d0d10":"#f5f5fa",margin:0,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(e.toolArgs,null,2).slice(0,500)})]}),e.toolResult&&d.jsxs("div",{children:[d.jsx("span",{style:{color:n.textFaint},children:"Result:"}),d.jsx("pre",{className:"mt-0.5 p-1.5 rounded overflow-x-auto",style:{background:n.isDark?"#0d0d10":"#f5f5fa",margin:0,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:e.toolResult.slice(0,500)})]}),e.toolError&&d.jsxs("div",{style:{color:"#e74c3c"},children:[d.jsx("span",{style:{color:"#e74c3c99"},children:"Error:"})," ",e.toolError]}),e.rootCause&&d.jsxs("div",{style:{color:"#e74c3c"},children:[d.jsx("span",{style:{color:"#e74c3c99"},children:"Root cause:"})," ",e.rootCause]}),e.pageRefs&&e.pageRefs.length>0&&d.jsxs("div",{children:[d.jsx("span",{style:{color:n.textFaint},children:"Page refs:"})," ",e.pageRefs.join(", ")]}),e.errorStack&&d.jsxs("details",{children:[d.jsx("summary",{style:{cursor:"pointer",color:n.textFaint},children:"Stack trace"}),d.jsx("pre",{className:"mt-0.5 p-1.5 rounded overflow-x-auto",style:{background:n.isDark?"#0d0d10":"#f5f5fa",margin:0,fontSize:"8px"},children:e.errorStack})]})]})]})}function PD({trace:e}){const n=we(),a=e.summary;return a?d.jsxs("div",{className:"flex gap-3 px-3 py-1.5 text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:n.textDim,borderBottom:`1px solid ${n.isDark?"#1a1a1e":"#f0f0f5"}`},children:[d.jsxs("span",{children:[a.totalTokens.toLocaleString()," tokens"]}),a.totalCostUsd>0&&d.jsxs("span",{children:["$",a.totalCostUsd.toFixed(4)]}),d.jsxs("span",{children:[a.toolCalls," tools"]}),a.toolErrors>0&&d.jsxs("span",{style:{color:"#e74c3c"},children:[a.toolErrors," errors"]}),d.jsxs("span",{children:[a.retrievals," retrievals"]}),d.jsxs("span",{children:[(a.durationMs/1e3).toFixed(1),"s"]})]}):null}function HD(){const e=we(),n=fn(c=>c.traces),a=fn(c=>c.clearTraces),[s,i]=z.useState(null),l=s?n.find(c=>c.id===s):n[n.length-1];return n.length===0?d.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-2",children:[d.jsx(Df,{size:20,style:{color:e.textFaint}}),d.jsx("div",{className:"text-[13px]",style:{color:e.textDim},children:"No traces yet"}),d.jsx("div",{className:"text-[13px] text-center px-4",style:{color:e.textFaint},children:"Run a conversation to capture execution traces — tool calls, retrievals, errors, and token usage."})]}):d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsxs("div",{className:"flex items-center justify-between px-3 py-2",style:{borderBottom:`1px solid ${e.isDark?"#1e1e22":"#e8e8ec"}`},children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Df,{size:11,style:{color:"#FE5000"}}),d.jsx("span",{className:"text-[12px] uppercase tracking-wider font-bold",style:{fontFamily:"'Geist Mono', monospace",color:e.textPrimary},children:"Traces"}),d.jsx("span",{className:"text-[13px] px-1.5 py-0.5 rounded-full",style:{background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace"},children:n.length})]}),d.jsxs("div",{className:"flex items-center gap-1",children:[n.length>1&&d.jsx("select",{value:l?.id||"",onChange:c=>i(c.target.value),className:"text-[13px] px-1 py-0.5 rounded border-none outline-none cursor-pointer",style:{background:e.surfaceElevated,color:e.textDim,fontFamily:"'Geist Mono', monospace"},children:n.map((c,p)=>d.jsxs("option",{value:c.id,children:["Run #",p+1," (",c.events.length," events)"]},c.id))}),d.jsx("button",{type:"button","aria-label":"Clear traces",onClick:a,className:"p-2.5 border-none bg-transparent cursor-pointer rounded min-w-[44px] min-h-[44px] flex items-center justify-center",style:{color:e.textFaint},children:d.jsx(jt,{size:10})})]})]}),l&&d.jsx(PD,{trace:l}),d.jsx("div",{className:"flex-1 overflow-y-auto",children:l?.events.map(c=>d.jsx(BD,{event:c},c.id))})]})}const UD={toolCalling:"Tool Calling",streaming:"Streaming",structuredOutput:"Structured Output",memoryHooks:"Memory Hooks",agentLoop:"Agent Loop",mcpBridge:"MCP Bridge"},gt="supported",dn="degraded",Yr="unsupported",bc={anthropic:{toolCalling:{status:gt},streaming:{status:gt},structuredOutput:{status:gt},memoryHooks:{status:gt},agentLoop:{status:gt},mcpBridge:{status:gt}},"claude-agent-sdk":{toolCalling:{status:gt},streaming:{status:gt},structuredOutput:{status:gt},memoryHooks:{status:gt},agentLoop:{status:gt},mcpBridge:{status:gt}},openai:{toolCalling:{status:gt},streaming:{status:gt},structuredOutput:{status:gt},memoryHooks:{status:dn,note:"Requires external memory layer"},agentLoop:{status:gt},mcpBridge:{status:dn,note:"Via OpenAI-compatible proxy"}},google:{toolCalling:{status:gt},streaming:{status:gt},structuredOutput:{status:dn,note:"JSON mode only, no strict schema"},memoryHooks:{status:Yr,note:"Not natively supported"},agentLoop:{status:dn,note:"Manual orchestration required"},mcpBridge:{status:Yr,note:"No MCP support"}},openrouter:{toolCalling:{status:dn,note:"Depends on underlying model"},streaming:{status:gt},structuredOutput:{status:dn,note:"Depends on underlying model"},memoryHooks:{status:dn,note:"Depends on underlying model"},agentLoop:{status:dn,note:"Depends on underlying model"},mcpBridge:{status:Yr,note:"Not available through proxy"}},custom:{toolCalling:{status:dn,note:"Depends on implementation"},streaming:{status:dn,note:"Depends on implementation"},structuredOutput:{status:dn,note:"Depends on implementation"},memoryHooks:{status:Yr,note:"Unknown provider"},agentLoop:{status:dn,note:"Depends on implementation"},mcpBridge:{status:Yr,note:"Unknown provider"}}};function GD(e){return bc[e]?bc[e]:(e.startsWith("custom"),bc.custom)}function qD(e,n){const a=[];for(const s of n){const i=e[s],l=UD[s];i.status==="unsupported"?a.push({level:"error",capability:s,message:`${l} is not supported by this provider${i.note?`: ${i.note}`:""}`}):i.status==="degraded"?a.push({level:"warning",capability:s,message:`${l} has limited support${i.note?`: ${i.note}`:""}`}):a.push({level:"ok",capability:s,message:`${l} is fully supported`})}return a}function KD({matrix:e,requiredCapabilities:n}){const a=we();if(n.length===0)return null;const s=qD(e,n),i=s.filter(c=>c.level==="error"),l=s.filter(c=>c.level==="warning");return i.length===0&&l.length===0?null:d.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.map(c=>d.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded-lg text-[12px]",style:{background:a.statusErrorBg,color:a.statusError,border:`1px solid ${a.statusError}30`},role:"alert",children:[d.jsx(mi,{size:12,className:"shrink-0 mt-0.5"}),d.jsx("span",{children:c.message})]},c.capability)),l.map(c=>d.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded-lg text-[12px]",style:{background:a.statusWarningBg,color:a.statusWarning,border:`1px solid ${a.statusWarning}30`},role:"status",children:[d.jsx(mv,{size:12,className:"shrink-0 mt-0.5"}),d.jsx("span",{children:c.message})]},c.capability))]})}function YD(){return`run-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}const ab={id:"",status:"idle",agents:[],sharedFacts:[],contractFacts:[]},Ut=qt(e=>({...ab,startRun:(n,a,s)=>e({id:YD(),teamId:a,featureSpec:s,status:"running",agents:n.map(i=>({agentId:i.agentId,name:i.name,status:"waiting",turns:0,facts:[],toolCalls:[],isAgentSdk:i.isAgentSdk})),sharedFacts:[],contractFacts:[],startedAt:Date.now(),completedAt:void 0,error:void 0}),updateAgent:(n,a)=>e(s=>({agents:s.agents.map(i=>i.agentId===n?{...i,...a}:i)})),addFact:(n,a)=>e(s=>a==="shared"?{sharedFacts:[...s.sharedFacts,n]}:a==="contract"?{contractFacts:[...s.contractFacts,n]}:{agents:s.agents.map(i=>i.agentId===a.agentId?{...i,facts:[...i.facts,n]}:i)}),setStatus:(n,a)=>e({status:n,error:a,completedAt:n==="completed"||n==="error"?Date.now():void 0}),reset:()=>e({...ab})})),VD={observation:"#3498db",inference:"#f1c40f",decision:"#2ecc71",hypothesis:"#9b59b6",contract:"#FE5000"};function ek({fact:e}){const n=VD[e.epistemicType]??"#888";return d.jsx("span",{style:{fontSize:12,padding:"2px 6px",borderRadius:4,background:n+"15",color:n,fontFamily:"'Geist Mono', monospace"},children:e.key})}function WD({text:e}){const[n,a]=z.useState(!1);return d.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(e),a(!0),setTimeout(()=>a(!1),1500)},style:{background:"none",border:"none",cursor:"pointer",padding:2,opacity:.6},title:"Copy output",children:n?d.jsx(_t,{size:12,style:{color:"#2ecc71"}}):d.jsx(ev,{size:12})})}function XD({agent:e,expanded:n}){const a=we(),[s,i]=z.useState(n??!1),l={waiting:d.jsx(CN,{size:14,style:{color:a.textDim}}),running:d.jsx(yt,{size:14,className:"animate-spin",style:{color:"#FE5000"}}),completed:d.jsx(Hc,{size:14,style:{color:"#2ecc71"}}),error:d.jsx(mi,{size:14,style:{color:"#dc2626"}})}[e.status],c=e.status==="completed"?e.output:e.currentMessage,p=(c?.length??0)>300;return d.jsxs("div",{style:{padding:12,borderRadius:8,border:`1px solid ${e.status==="running"?"#FE500040":a.border}`,background:e.status==="running"?"#FE500008":a.surface},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:c?8:0},children:[l,d.jsx("span",{style:{fontSize:14,fontWeight:600,color:a.textPrimary,fontFamily:"'Geist Mono', monospace"},children:e.name}),e.isAgentSdk&&d.jsx("span",{style:{fontSize:10,padding:"2px 6px",borderRadius:4,background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace",fontWeight:600,border:"1px solid #FE500030"},children:"Agent SDK"}),d.jsxs("span",{style:{fontSize:12,color:a.textDim,marginLeft:"auto",display:"flex",alignItems:"center",gap:6},children:[e.status==="running"?`Turn ${e.turns}`:e.status,e.tokens&&(e.tokens.input>0||e.tokens.output>0)&&d.jsxs("span",{style:{fontSize:11,color:a.textFaint},children:[((e.tokens.input+e.tokens.output)/1e3).toFixed(1),"k tok"]})]})]}),c&&d.jsxs("div",{style:{position:"relative"},children:[d.jsx("div",{style:{fontSize:13,padding:10,borderRadius:6,background:a.inputBg,color:a.textPrimary,lineHeight:1.6,whiteSpace:"pre-wrap",overflowY:"auto",maxHeight:s?"none":200},children:c}),d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginTop:4},children:[p&&d.jsx("button",{type:"button",onClick:()=>i(!s),style:{background:"none",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:12,color:"#FE5000",display:"flex",alignItems:"center",gap:4,fontFamily:"'Geist Mono', monospace"},children:s?d.jsxs(d.Fragment,{children:[d.jsx(Mn,{size:12})," Collapse"]}):d.jsxs(d.Fragment,{children:[d.jsx(ta,{size:12})," Expand (",Math.ceil((c?.length??0)/1e3),"k chars)"]})}),c&&d.jsx(WD,{text:c})]})]}),e.toolCalls.length>0&&d.jsxs("div",{style:{marginTop:8},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[d.jsx(pn,{size:12,style:{color:"#2ecc71"}}),d.jsxs("span",{style:{fontSize:12,fontWeight:600,color:a.textSecondary,fontFamily:"'Geist Mono', monospace"},children:["Tool Calls (",e.toolCalls.length,")"]})]}),d.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:e.toolCalls.map((f,m)=>d.jsxs("div",{style:{fontSize:12,padding:6,borderRadius:4,background:"#2ecc7115",border:"1px solid #2ecc7130",color:a.textSecondary,fontFamily:"'Geist Mono', monospace"},children:[d.jsx("div",{style:{fontWeight:600,color:"#2ecc71",marginBottom:2},children:f.tool}),f.args&&d.jsx("div",{style:{color:a.textDim,fontSize:11,lineHeight:1.4},children:f.args.length>100?f.args.slice(0,100)+"…":f.args})]},m))})]}),e.facts.length>0&&d.jsx("div",{style:{marginTop:8,display:"flex",flexWrap:"wrap",gap:4},children:e.facts.map((f,m)=>d.jsx(ek,{fact:f},m))})]})}function ZD({facts:e}){const n=we();return e.length===0?null:d.jsxs("div",{style:{padding:12,borderRadius:8,border:`1px solid ${n.border}`,background:n.surface},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[d.jsx(Ni,{size:14,style:{color:"#FE5000"}}),d.jsxs("span",{style:{fontSize:13,fontWeight:600,color:n.textPrimary,fontFamily:"'Geist Mono', monospace"},children:["Shared Memory (",e.length,")"]})]}),d.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:e.map((a,s)=>d.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[d.jsx(ek,{fact:a}),d.jsx("span",{style:{fontSize:12,color:n.textDim,flex:1},children:a.value})]},s))})]})}function QD(){const e=we(),n=Ut(x=>x.status),a=Ut(x=>x.agents),s=Ut(x=>x.sharedFacts),i=Ut(x=>x.startedAt),l=Ut(x=>x.completedAt),c=Ut(x=>x.error),[p,f]=z.useState(!1);if(n==="idle")return null;const m=l&&i?((l-i)/1e3).toFixed(1):i?((Date.now()-i)/1e3).toFixed(0):"0",g=d.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,height:"100%"},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n==="running"&&d.jsx(yt,{size:14,className:"animate-spin",style:{color:"#FE5000"}}),n==="completed"&&d.jsx(Hc,{size:14,style:{color:"#2ecc71"}}),n==="error"&&d.jsx(mi,{size:14,style:{color:"#dc2626"}}),d.jsx("span",{style:{fontSize:13,fontWeight:600,color:e.textPrimary},children:n==="running"?"Running...":n==="completed"?"Completed":"Error"}),d.jsxs("span",{style:{fontSize:12,color:e.textDim},children:[m,"s"]}),d.jsx("button",{type:"button",onClick:()=>f(!p),style:{marginLeft:"auto",background:"none",border:"none",cursor:"pointer",padding:4,color:e.textDim},title:p?"Minimize":"Maximize results",children:p?d.jsx(cm,{size:14}):d.jsx(sv,{size:14})})]}),c&&d.jsx("div",{style:{fontSize:13,color:"#dc2626",padding:8,borderRadius:6,background:"#dc262610"},children:c}),d.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,flex:1,overflowY:"auto"},children:a.map(x=>d.jsx(XD,{agent:x,expanded:p},x.agentId))}),d.jsx(ZD,{facts:s})]});return p?d.jsx("div",{style:{position:"fixed",inset:0,zIndex:100,background:e.bg,padding:24,overflowY:"auto"},children:g}):g}function JD({retrieval:e}){const n=we();if(!e)return null;const a=new Map;for(const x of e.chunks){const b=a.get(x.source)||[];b.push(x),a.set(x.source,b)}const s=x=>({"ground-truth":"#e74c3c",signal:"#f1c40f",evidence:"#3498db",framework:"#2ecc71",guideline:"#FE5000",hypothesis:"#9b59b6"})[x]||n.textDim,i=x=>({"ground-truth":"🔴 Ground Truth",signal:"🟡 Signal",evidence:"🔵 Evidence",framework:"🟢 Framework",guideline:"📏 Guideline",hypothesis:"🟣 Hypothesis"})[x]||x,l=x=>{const b={direct:{background:"#2ecc71",color:"#fff"},"parent-expansion":{background:"#f1c40f",color:"#333"},"sibling-coherence":{background:"#3498db",color:"#fff"},unknown:{background:n.border,color:n.textDim}};return b[x]||b.unknown},c=x=>({direct:"● Direct match","parent-expansion":"↑ Parent expanded","sibling-coherence":"↔ Sibling context",unknown:"? Unknown"})[x]||x,p=x=>({direct:"●","parent-expansion":"↑","sibling-coherence":"↔",unknown:"?"})[x]||"?",f=Array.from(a.keys()),m=e.chunks.length,g=e.chunks.reduce((x,b)=>x+b.tokens,0);return d.jsxs("div",{style:{maxHeight:400,overflowY:"auto",padding:12,fontFamily:"'Geist Mono', monospace",fontSize:12},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12,paddingBottom:8,borderBottom:`1px solid ${n.border}30`},children:[d.jsx("span",{style:{fontSize:10,color:n.textDim,textTransform:"uppercase",fontWeight:700},children:"Retrieved Context"}),d.jsxs("span",{style:{fontSize:10,color:n.textDim},children:[m," chunks selected → ",g.toLocaleString()," tokens sent to LLM"]}),d.jsxs("span",{style:{fontSize:10,color:n.textDim,marginLeft:"auto"},children:["Budget: ",e.budgetUsed.toLocaleString()," / ",e.budgetTotal.toLocaleString()," tokens"]})]}),d.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:10},children:f.map((x,b)=>{const v=a.get(x)||[],k=v.reduce((M,N)=>M+N.tokens,0),w=v[0]?.knowledgeType||"signal",C=v.reduce((M,N)=>{const S=N.inclusionReason||"unknown";return M[S]=(M[S]||0)+1,M},{});return d.jsxs("div",{style:{width:280,border:`1px solid ${n.border}40`,borderRadius:8,padding:10,background:n.isDark?"#ffffff04":"#00000003"},children:[d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[d.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:s(w),flexShrink:0}}),d.jsx("div",{style:{fontSize:12,fontWeight:600,color:n.textPrimary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:x.split("/").pop()||x}),d.jsxs("span",{style:{fontSize:10,color:"#FE5000",fontWeight:600,flexShrink:0},children:[k.toLocaleString()," tok"]})]}),d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[d.jsx("span",{style:{fontSize:9,color:n.textDim},children:i(w)}),d.jsxs("span",{style:{fontSize:9,color:n.textDim,marginLeft:"auto"},children:[v.length," chunk",v.length>1?"s":""]})]}),d.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginBottom:8},children:Object.entries(C).map(([M,N])=>d.jsxs("span",{title:c(M),style:{fontSize:9,padding:"2px 5px",borderRadius:3,...l(M)},children:[p(M)," ",N]},M))}),d.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[v.sort((M,N)=>N.relevanceScore-M.relevanceScore).slice(0,5).map((M,N)=>d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[d.jsx("div",{style:{width:20,height:3,borderRadius:1,background:"#333",overflow:"hidden",flexShrink:0},children:d.jsx("div",{style:{width:`${M.relevanceScore*100}%`,height:"100%",background:"#2ecc71"}})}),d.jsxs("span",{style:{fontSize:9,width:22,textAlign:"right",color:n.textDim,flexShrink:0},children:[(M.relevanceScore*100).toFixed(0),"%"]}),d.jsx("span",{style:{fontSize:10,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:n.textPrimary},children:M.section}),d.jsx("span",{style:{fontSize:8,color:n.textFaint,flexShrink:0},children:M.tokens})]},N)),v.length>5&&d.jsxs("span",{style:{fontSize:9,color:n.textDim,paddingTop:2},children:["+",v.length-5," more"]})]})]},b)})}),d.jsxs("div",{style:{display:"flex",gap:12,marginTop:12,paddingTop:8,borderTop:`1px solid ${n.border}30`,flexWrap:"wrap"},children:[d.jsx("span",{style:{fontSize:9,color:n.textDim,fontWeight:600},children:"HOW CHUNKS ARE SELECTED:"}),[{icon:"●",label:"Direct match (semantic similarity)",color:"#2ecc71"},{icon:"↑",label:"Parent expanded (tree context)",color:"#f1c40f"},{icon:"↔",label:"Sibling coherence (related sections)",color:"#3498db"}].map(x=>d.jsxs("span",{style:{fontSize:9,color:x.color,display:"flex",alignItems:"center",gap:3},children:[d.jsx("span",{style:{fontWeight:700},children:x.icon})," ",x.label]},x.icon))]})]})}async function e8(e,n){const a=new TextDecoder;let s="";for(;;){const{done:i,value:l}=await e.read();if(i)break;s+=a.decode(l,{stream:!0});const c=s.split(`
650
+ `);s=c.pop()??"";for(const p of c){const f=p.trim();if(!f||!f.startsWith("data: "))continue;const m=f.slice(6);if(m==="[DONE]"||n(m))return}}}function sb(e){const n=new AbortController;Ut.getState().startRun(e.agents.map(i=>({agentId:i.agentId,name:i.name,isAgentSdk:e.isAgentSdk})),e.teamId);const s={teamId:e.teamId,systemPrompt:e.systemPrompt,task:e.task,providerId:e.providerId,model:e.model,agents:e.agents.map(i=>({agentId:i.agentId,name:i.name,systemPrompt:i.systemPrompt,rolePrompt:i.rolePrompt,repoUrl:i.repoUrl})),tools:e.tools};return fetch(`${Ee}/runtime/run-team`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s),signal:n.signal}).then(async i=>{if(!i.ok){const p=await i.text().catch(()=>"");throw new Error(`Runtime error ${i.status}: ${p||i.statusText}`)}const l=i.body?.getReader();if(!l)throw new Error("No response body");let c=!1;await e8(l,p=>{try{const f=JSON.parse(p);if(f.type==="error")return c=!0,Ut.getState().setStatus("error",f.error||"Runtime execution failed"),!0;t8(f)}catch{}}),!c&&Ut.getState().status!=="error"&&Ut.getState().setStatus("completed")}).catch(i=>{i instanceof DOMException&&i.name==="AbortError"||Ut.getState().setStatus("error",i instanceof Error?i.message:String(i))}),n}function t8(e){const n=Ut.getState();switch(e.type){case"start":e.isAgentSdk!==void 0&&n.agents.forEach(a=>{n.updateAgent(a.agentId,{isAgentSdk:e.isAgentSdk})});break;case"turn":e.agentId&&n.updateAgent(e.agentId,{status:"running",turns:e.turn??0,currentMessage:e.message,...e.tokens&&{tokens:e.tokens}});break;case"fact":e.fact&&(e.agentId&&n.addFact(e.fact,{agentId:e.agentId}),n.addFact(e.fact,"shared"));break;case"tool_call":if(e.agentId){const a=n.agents.find(s=>s.agentId===e.agentId);a&&n.updateAgent(e.agentId,{toolCalls:[...a.toolCalls,{tool:e.tool??"",args:e.args??""}]})}break;case"done":e.agentId&&n.updateAgent(e.agentId,{status:"completed",output:e.result,...e.tokens&&{tokens:e.tokens}});break}}function n8(){const e=we(),n=uo(g=>g.lastPipelineStats),[a,s]=z.useState(!1);if(!n)return null;const i=n.pipeline,l=g=>g>=1e3?`${(g/1e3).toFixed(1)}K`:`${g}`,c=["#2ecc71","#3498db","#f1c40f","#e67e22","#999"],p=["Full","Detail","Summary","Headlines","Mention"],f=g=>g>.5?"#2ecc71":g>.3?"#f1c40f":"#e74c3c",m=g=>{switch(g){case"factual":return"#3498db";case"analytical":return"#e67e22";case"exploratory":return"#9b59b6";default:return e.textDim}};return d.jsxs("div",{style:{borderTop:`1px solid ${e.border}`},children:[n.retrieval&&d.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5",style:{fontFamily:"'Geist Mono', monospace",fontSize:11,borderBottom:`1px solid ${e.border}30`},children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("span",{style:{color:e.textDim},children:"Diversity"}),d.jsx("div",{style:{width:40,height:4,borderRadius:2,background:"#333",overflow:"hidden"},children:d.jsx("div",{style:{width:`${n.retrieval.diversityScore*100}%`,height:"100%",background:f(n.retrieval.diversityScore),borderRadius:2}})}),d.jsxs("span",{style:{fontFamily:"'Geist Mono', monospace",color:f(n.retrieval.diversityScore),fontSize:11},children:[(n.retrieval.diversityScore*100).toFixed(0),"%"]})]}),d.jsxs("span",{style:{color:e.textDim},children:[n.retrieval.selectedChunks,"/",n.retrieval.totalChunks," chunks"]}),d.jsxs("span",{style:{color:e.textDim},children:["Budget ",Math.round(n.retrieval.budgetUsed/n.retrieval.budgetTotal*100),"%"]}),d.jsx("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,background:m(n.retrieval.queryType)+"15",color:m(n.retrieval.queryType)},children:n.retrieval.queryType}),d.jsxs("span",{style:{fontSize:11,color:e.textFaint,marginLeft:"auto"},children:[n.retrieval.embeddingMs+n.retrieval.retrievalMs,"ms"]}),n.retrieval.collapseWarning&&d.jsx("span",{style:{fontSize:11,color:"#e74c3c"},children:"⚠ Low diversity"})]}),d.jsxs("button",{type:"button",onClick:()=>s(!a),className:"flex items-center gap-3 px-4 py-1.5 text-[13px] w-full border-none cursor-pointer min-h-[44px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim,background:"transparent",transition:"background-color 150ms"},onMouseEnter:g=>{g.currentTarget.style.background=e.isDark?"#ffffff08":"#00000005"},onMouseLeave:g=>{g.currentTarget.style.background="transparent"},"aria-label":"Toggle pipeline statistics","aria-expanded":a,children:[d.jsx(pn,{size:9,style:{color:"#FE5000",flexShrink:0}}),d.jsxs("span",{title:"Total context tokens sent to LLM",children:["Context: ",l(n.totalContextTokens)]}),d.jsxs("span",{title:"System prompt tokens (persona + instructions)",children:["System: ",l(n.systemTokens)]}),i&&d.jsxs(d.Fragment,{children:[d.jsxs("span",{title:"How much the knowledge was compressed before sending",style:{color:i.compression.ratio<.8?"#2ecc71":e.textDim},children:["Compressed: ",Math.round((1-i.compression.ratio)*100),"%"]}),d.jsxs("span",{title:"Number of knowledge sources indexed",children:[i.sources.length," source",i.sources.length!==1?"s":""]}),d.jsxs("span",{title:"Pipeline processing time",children:[i.timing.totalMs,"ms"]})]}),d.jsx(Mn,{size:8,className:"ml-auto",style:{transform:a?"none":"rotate(-90deg)",transition:"transform 150ms"}})]}),a&&d.jsx("div",{style:{maxHeight:280,overflowY:"auto",borderBottom:`1px solid ${e.border}30`},children:n.retrieval?d.jsx(JD,{retrieval:n.retrieval}):n.heatmap.length>0&&d.jsx("div",{className:"px-4 pb-2 flex flex-col gap-2",children:n.heatmap.map(g=>d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[d.jsx("span",{className:"text-[12px] font-medium",style:{color:e.textPrimary},children:g.name}),d.jsx("span",{className:"text-[12px] px-1.5 py-0.5 rounded",style:{fontFamily:"'Geist Mono', monospace",background:c[g.depth]+"18",color:c[g.depth]},children:p[g.depth]}),d.jsxs("span",{className:"text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textFaint},children:[l(g.filteredTokens),"/",l(g.totalTokens)]})]}),g.headings.length>0&&d.jsxs("div",{className:"flex flex-col gap-0.5 pl-2",children:[g.headings.slice(0,8).map(x=>{const b=Math.max(...g.headings.map(w=>w.tokens),1),v=Math.max(5,x.tokens/b*100),k=c[Math.min(x.depth,4)];return d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("span",{className:"text-[10px] truncate w-20 text-right",style:{fontFamily:"'Geist Mono', monospace",color:e.textFaint},children:x.title}),d.jsx("div",{style:{flex:1,height:3,background:`${k}18`,borderRadius:1,overflow:"hidden"},children:d.jsx("div",{style:{width:`${v}%`,height:"100%",background:k,borderRadius:1}})}),d.jsx("span",{className:"text-[8px] w-6 text-right",style:{fontFamily:"'Geist Mono', monospace",color:e.textFaint},children:l(x.tokens)})]},x.nodeId)}),g.headings.length>8&&d.jsxs("span",{className:"text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textFaint},children:["+",g.headings.length-8," more"]})]})]},g.path))})})]})}function o8(){const e=we(),n=uo(E=>E.messages),a=uo(E=>E.inputText),s=uo(E=>E.setInputText),i=uo(E=>E.streaming),l=uo(E=>E.addMessage),c=uo(E=>E.setStreaming),p=uo(E=>E.updateLastAssistant),f=uo(E=>E.setLastPipelineStats),m=se(E=>E.channels),g=se(E=>E.connectors),x=se(E=>E.mcpServers),b=se(E=>E.agentMeta),v=se(E=>E.navigationMode),k=(()=>{const E=["streaming"];return g.length>0&&E.push("toolCalling"),x.length>0&&E.push("mcpBridge"),E})(),w=Bf(),C=GD(w.providerId||"custom"),M=z.useRef(null);z.useEffect(()=>{const E=window.matchMedia("(prefers-reduced-motion: reduce)").matches;M.current?.scrollIntoView({behavior:E?"auto":"smooth"})},[n]);const N=z.useCallback(async()=>{if(!a.trim()||i)return;const E=a.trim();s(""),l({role:"user",content:E}),l({role:"assistant",content:""}),c(!0);let I="";try{const{providerId:D,model:A,error:L}=Bf();if(L){p(L),c(!1);return}await LD({userMessage:E,channels:m,connectors:g,history:n.filter(P=>!(P.role==="assistant"&&P.content.trim()==="")).map(P=>({role:P.role,content:P.content})),agentMeta:{name:b.name,description:b.description,avatar:b.avatar,tags:b.tags},providerId:D,model:A,navigationMode:v,onChunk:P=>{I+=P,p(I)},onDone:P=>{f(P)},onError:P=>{p(I+`
651
+
652
+ _Error: ${P.message}_`)}})}catch(D){p(I+`
653
+
654
+ _Error: ${D instanceof Error?D.message:"Unknown error"}_`)}finally{c(!1)}},[a,i,n,m,g,b,v,s,l,c,p,f]),S=E=>{(E.metaKey||E.ctrlKey)&&E.key==="Enter"&&(E.preventDefault(),N())};return d.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[d.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-3 flex flex-col gap-3","aria-live":"polite","aria-relevant":"additions",children:[n.length===0&&d.jsx("div",{className:"flex-1 flex items-center justify-center p-8",children:d.jsxs("div",{className:"max-w-md text-center space-y-4",children:[d.jsx("div",{className:"text-[16px] font-semibold",style:{color:e.textPrimary,fontFamily:"'Geist Mono', monospace"},children:"Ready to test your agent"}),d.jsx("div",{className:"text-[13px] leading-relaxed",style:{color:e.textDim},children:"Start a conversation to see how your agent responds with the current knowledge and configuration."}),d.jsxs("div",{className:"flex flex-wrap gap-2 justify-center mt-6",children:[d.jsx("button",{type:"button",onClick:()=>s("What is this codebase about?"),className:"px-3 py-2 rounded-lg border cursor-pointer text-[12px] hover:border-[#FE5000] transition-colors",style:{background:e.surface,border:`1px solid ${e.border}`,color:e.textSecondary,fontFamily:"'Geist Mono', monospace"},children:"What is this codebase about?"}),d.jsx("button",{type:"button",onClick:()=>s("Explain the main architecture"),className:"px-3 py-2 rounded-lg border cursor-pointer text-[12px] hover:border-[#FE5000] transition-colors",style:{background:e.surface,border:`1px solid ${e.border}`,color:e.textSecondary,fontFamily:"'Geist Mono', monospace"},children:"Explain the main architecture"}),d.jsx("button",{type:"button",onClick:()=>s("What are the key features?"),className:"px-3 py-2 rounded-lg border cursor-pointer text-[12px] hover:border-[#FE5000] transition-colors",style:{background:e.surface,border:`1px solid ${e.border}`,color:e.textSecondary,fontFamily:"'Geist Mono', monospace"},children:"What are the key features?"})]})]})}),n.map(E=>d.jsx("div",{className:"max-w-[85%] px-3.5 py-2.5 rounded-xl text-[14px] leading-relaxed",style:{alignSelf:E.role==="user"?"flex-end":"flex-start",background:E.role==="user"?"#FE500015":e.isDark?"#1c1c20":"#f0f0f5",border:`1px solid ${E.role==="user"?"#FE500020":e.border}`,color:E.role==="user"?e.textPrimary:e.textSecondary,borderBottomRightRadius:E.role==="user"?4:12,borderBottomLeftRadius:E.role==="assistant"?4:12},children:E.content||(i&&E.role==="assistant"?"...":"")},E.id)),d.jsx("div",{ref:M})]}),k.length>0&&d.jsx("div",{className:"px-4 py-1.5",children:d.jsx(KD,{matrix:C,requiredCapabilities:k})}),d.jsx(n8,{}),d.jsxs("div",{className:"px-4 py-3 flex gap-2",style:{borderTop:`1px solid ${e.border}`},children:[d.jsx("input",{type:"text",value:a,onChange:E=>s(E.target.value),onKeyDown:S,placeholder:"Test your agent...","aria-label":"Test message",className:"flex-1 px-3.5 py-2.5 rounded-lg outline-none text-[14px]",style:{background:e.inputBg,border:`1px solid ${e.border}`,color:e.textPrimary,fontFamily:"'Geist Sans', sans-serif"}}),d.jsx("button",{type:"button","aria-label":"Send message",onClick:N,disabled:i||!a.trim(),className:"px-4 rounded-lg cursor-pointer border-none text-[12px] font-semibold tracking-wider uppercase min-h-[44px] min-w-[44px]",style:{background:"#FE5000",color:"#fff",fontFamily:"'Geist Mono', monospace",opacity:i||!a.trim()?.5:1},children:d.jsx(l4,{size:12})})]})]})}function a8(){const e=we(),[n,a]=z.useState([{id:"agent-1",name:"Agent 1",rolePrompt:"",repoUrl:"",source:"blank"},{id:"agent-2",name:"Agent 2",rolePrompt:"",repoUrl:"",source:"blank"}]),[s,i]=z.useState(""),[l,c]=z.useState([]),[p,f]=z.useState(null),m=z.useRef(null),g=Ut(A=>A.status),x=Ut(A=>A.reset),b=g==="running";z.useEffect(()=>{fetch(`${Ee}/agents`).then(A=>A.ok?A.json():{data:[]}).then(A=>{const L=A.data??A??[];c(L.map(P=>({id:P.id,name:P.agentMeta?.name||P.id,description:P.agentMeta?.description||""})))}).catch(()=>{})},[]);const v=()=>{const A=n.length+1;a([...n,{id:`agent-${Date.now()}`,name:`Agent ${A}`,rolePrompt:"",repoUrl:"",source:"blank"}])},k=async(A,L)=>{try{const P=await fetch(`${Ee}/agents/${encodeURIComponent(L)}`);if(!P.ok)return;const W=await P.json(),$=W.data??W,V=$.agentMeta??{},X=[],H=$.instructionState??{};V.name&&X.push(`You are ${V.name}. ${V.description||""}`),H.persona&&X.push(`Persona: ${H.persona}`),H.objectives?.primary&&X.push(`Primary Objective: ${H.objectives.primary}`),H.constraints?.customConstraints&&X.push(`Constraints: ${H.constraints.customConstraints}`);const _=X.join(`
655
+
656
+ `);a(T=>T.map(B=>B.id===A?{...B,name:V.name||L,savedSystemPrompt:_,source:L}:B))}catch{}f(null)},w=A=>{n.length<=1||a(n.filter(L=>L.id!==A))},C=(A,L)=>{a(n.map(P=>P.id===A?{...P,...L}:P))},[M,N]=z.useState(null),[S,E]=z.useState(null),I=z.useCallback(async()=>{if(!s.trim()||b)return;N(null),E(null);const{providerId:A,model:L,error:P}=Bf();if(P){N(P),console.error("[TeamRunner] Provider error:",P);return}const V=Qe.getState().providers.find(X=>X.id===A)?.authMethod==="claude-agent-sdk";console.log("[TeamRunner] Starting team run with provider:",A,"model:",L,"Agent SDK:",V);try{const X=fn.getState(),_=Ra.getState().currentVersion||"0.0.0",T=X.startTrace(`team-${Date.now()}`,_);let B=oi();const G=se.getState(),K=G.channels,J=K.filter(U=>U.enabled);let F="",O="",Q=null;if(J.length>0){console.log("[TeamRunner] Preparing knowledge..."),E("Preparing knowledge...");const U=await Gv(J,T);O=U.frameworkBlock;const ce=await Xv(K,U.regularChannels,U.residualKnowledgeBlock,{userMessage:s,navigationMode:"manual",providerId:A,model:L},T);F=ce.knowledgeBlock,Q=ce.provenance}const q=G.connectors.filter(U=>U.enabled&&U.direction!=="write");if(q.length>0){const ce=`<connectors>
657
+ Available data connectors (use via MCP tools):
658
+ ${q.map(ge=>{const be=ge.hint?` (scope: ${ge.hint})`:"";return`- ${ge.name} [${ge.service}] — ${ge.direction}${be}`}).join(`
659
+ `)}
660
+ </connectors>`;F=F?`${F}
661
+
662
+ ${ce}`:ce}const ie=We.getState();let pe="";if(ie.longTerm.enabled){console.log("[TeamRunner] Recalling memory..."),E("Recalling memory...");const U=await Hv({userMessage:s,agentId:"team",traceId:T});U.contextBlock&&(pe=U.contextBlock)}if(Q&&(B=oi(Q)),J.length>0||F||pe){const U=Sv(K,wn.getState().getIndex),ce=K.some(be=>be.enabled&&be.repoMeta);B=Cv({frame:B,orientationBlock:U,hasRepos:ce,knowledgeFormatGuide:Uv(),frameworkBlock:O,memoryBlock:pe,knowledgeBlock:F})}console.log("[TeamRunner] Running team..."),E("Running team..."),N(null);const me={teamId:`team-${Date.now()}`,systemPrompt:B,task:s.trim(),providerId:A,model:L,isAgentSdk:V,agents:n.map(U=>({agentId:U.id,name:U.name,systemPrompt:U.savedSystemPrompt||void 0,rolePrompt:U.rolePrompt||void 0,repoUrl:U.repoUrl||void 0}))};m.current=sb(me),E(null)}catch(X){console.error("[TeamRunner] Knowledge pipeline error:",X),E(null),N(`Knowledge pipeline error: ${X instanceof Error?X.message:"Unknown error"}`);const H=oi(),_={teamId:`team-${Date.now()}`,systemPrompt:H,task:s.trim(),providerId:A,model:L,isAgentSdk:V,agents:n.map(T=>({agentId:T.id,name:T.name,systemPrompt:T.savedSystemPrompt||void 0,rolePrompt:T.rolePrompt||void 0,repoUrl:T.repoUrl||void 0}))};m.current=sb(_),E(null)}},[s,n,b]),D=()=>{m.current?.abort(),m.current=null};return d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsxs("div",{className:"px-4 py-3 flex flex-col gap-2 overflow-y-auto",style:{maxHeight:"45%"},children:[d.jsxs("div",{className:"flex items-center justify-between mb-1",children:[d.jsxs("span",{className:"text-[12px] font-bold tracking-[0.08em] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:["Team Agents (",n.length,")"]}),d.jsxs("button",{type:"button",onClick:v,disabled:n.length>=5,className:"flex items-center gap-1 text-[12px] px-2 py-1 rounded cursor-pointer border-none",style:{background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace",opacity:n.length>=5?.4:1},children:[d.jsx(bt,{size:10})," Add"]})]}),n.map(A=>d.jsxs("div",{style:{padding:10,borderRadius:8,border:`1px solid ${A.source!=="blank"?"#FE500030":e.border}`,background:e.surface},children:[d.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[d.jsx(T4,{size:12,style:{color:A.source!=="blank"?"#FE5000":e.textDim}}),d.jsx("input",{type:"text",value:A.name,onChange:L=>C(A.id,{name:L.target.value}),className:"flex-1 text-[13px] font-semibold px-1.5 py-0.5 rounded outline-none border-none",style:{background:"transparent",color:e.textPrimary,fontFamily:"'Geist Mono', monospace"}}),d.jsx("button",{type:"button",onClick:()=>f(p===A.id?null:A.id),className:"text-[11px] px-2 py-0.5 rounded cursor-pointer border-none",style:{background:"#FE500010",color:"#FE5000",fontFamily:"'Geist Mono', monospace"},children:A.source!=="blank"?"↻ Swap":"↗ Load"}),n.length>1&&d.jsx("button",{type:"button",onClick:()=>w(A.id),className:"border-none cursor-pointer p-0.5 rounded",style:{background:"transparent",color:e.textDim},children:d.jsx(jt,{size:12})})]}),p===A.id&&l.length>0&&d.jsxs("div",{className:"mb-2 flex flex-col gap-1 p-2 rounded",style:{background:e.inputBg,border:`1px solid ${e.border}`},children:[d.jsx("span",{className:"text-[11px] uppercase font-bold tracking-[0.08em] mb-1",style:{color:e.textDim,fontFamily:"'Geist Mono', monospace"},children:"Load from library"}),l.map(L=>d.jsxs("button",{type:"button",onClick:()=>k(A.id,L.id),className:"text-left text-[12px] px-2 py-1.5 rounded cursor-pointer border-none w-full",style:{background:"transparent",color:e.textPrimary},onMouseEnter:P=>{P.currentTarget.style.background=e.surfaceHover},onMouseLeave:P=>{P.currentTarget.style.background="transparent"},children:[d.jsx("span",{style:{fontWeight:600},children:L.name}),L.description&&d.jsxs("span",{style:{color:e.textDim,marginLeft:6},children:["— ",L.description.slice(0,40)]})]},L.id)),l.length===0&&d.jsx("span",{className:"text-[12px]",style:{color:e.textFaint},children:"No saved agents. Save one from the Agent Builder first."})]}),A.source!=="blank"&&d.jsx("div",{className:"mb-1.5",children:d.jsxs("span",{className:"text-[11px] px-1.5 py-0.5 rounded",style:{background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace"},children:["↗ ",A.source]})}),d.jsx("input",{type:"text",value:A.rolePrompt,onChange:L=>C(A.id,{rolePrompt:L.target.value}),placeholder:"Role override (optional — appended to agent instructions)",className:"w-full text-[12px] px-2 py-1.5 rounded outline-none mb-1.5",style:{background:e.inputBg,border:`1px solid ${e.borderSubtle}`,color:e.textSecondary}}),d.jsx("input",{type:"text",value:A.repoUrl,onChange:L=>C(A.id,{repoUrl:L.target.value}),placeholder:"Repository URL (optional — e.g., https://github.com/user/repo)",className:"w-full text-[12px] px-2 py-1.5 rounded outline-none",style:{background:e.inputBg,border:`1px solid ${e.borderSubtle}`,color:e.textSecondary}})]},A.id))]}),d.jsxs("div",{className:"px-4 py-2",style:{borderTop:`1px solid ${e.border}`},children:[d.jsx("textarea",{value:s,onChange:A=>i(A.target.value),placeholder:"Describe the task for the team...",rows:3,className:"w-full text-[13px] px-3 py-2.5 rounded-lg outline-none resize-none",style:{background:e.inputBg,border:`1px solid ${e.border}`,color:e.textPrimary,lineHeight:1.5}}),S&&d.jsx("div",{className:"text-[12px] px-3 py-2 rounded mb-2",style:{background:"#10b98115",color:"#10b981",border:"1px solid #10b98130"},children:S}),M&&d.jsx("div",{className:"text-[12px] px-3 py-2 rounded mb-2",style:{background:"#dc262615",color:"#dc2626",border:"1px solid #dc262630"},children:M}),d.jsxs("div",{className:"flex gap-2 mt-2",children:[b?d.jsxs("button",{type:"button",onClick:D,className:"flex items-center gap-1.5 px-4 py-2 rounded-lg cursor-pointer border-none text-[12px] font-bold tracking-[0.08em] uppercase min-h-[44px]",style:{background:"#dc2626",color:"#fff",fontFamily:"'Geist Mono', monospace"},children:[d.jsx(pv,{size:12})," Stop"]}):d.jsxs("button",{type:"button",onClick:I,disabled:!s.trim(),className:"flex items-center gap-1.5 px-4 py-2 rounded-lg cursor-pointer border-none text-[12px] font-bold tracking-[0.08em] uppercase min-h-[44px]",style:{background:"#FE5000",color:"#fff",fontFamily:"'Geist Mono', monospace",opacity:s.trim()?1:.5},children:[d.jsx(uv,{size:12})," Run Team"]}),g!=="idle"&&!b&&d.jsx("button",{type:"button",onClick:x,className:"text-[12px] px-3 py-2 rounded-lg cursor-pointer border-none",style:{background:e.border,color:e.textDim},children:"Clear"})]})]}),d.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3",style:{borderTop:`1px solid ${e.border}`},children:d.jsx(QD,{})})]})}function s8(){const e=we(),[n,a]=z.useState(null),[s,i]=z.useState(!1),[l,c]=z.useState(null),[p,f]=z.useState(!1),m=z.useRef(null),g=z.useCallback(()=>{const E=se.getState();return{channels:E.channels,selectedModel:E.selectedModel,outputFormat:E.outputFormat,outputFormats:E.outputFormats,prompt:E.prompt,tokenBudget:E.tokenBudget,mcpServers:E.mcpServers,skills:E.skills,agentMeta:E.agentMeta,agentConfig:E.agentConfig,connectors:E.connectors,instructionState:E.instructionState,workflowSteps:E.workflowSteps}},[]),x=z.useCallback(async()=>{try{const{downloadAgentDirectory:E}=await ea(async()=>{const{downloadAgentDirectory:I}=await Promise.resolve().then(()=>i6);return{downloadAgentDirectory:I}},void 0);await E(g()),a("dir"),setTimeout(()=>a(null),2e3)}catch(E){console.error("Directory export failed:",E)}},[g]),b=z.useCallback(async E=>{try{const I=g();let D,A;E==="md"?(D=ni("claude",I),A=".md"):E==="yaml"?(D=ni("openclaw",I),A=".yaml"):(D=ni("generic",I),A=".json");const L=(I.agentMeta.name||"modular-agent").toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");hu(D,L,A),await navigator.clipboard.writeText(D),a(E),setTimeout(()=>a(null),2e3)}catch{}},[g]),v=z.useCallback(async E=>{if(!E.name.endsWith(".zip")){c("Please select a ZIP file containing an agent directory");return}i(!0),c(null);try{await Pv(E),a("import"),setTimeout(()=>a(null),2e3)}catch(I){const D=I instanceof Error?I.message:"Unknown import error";c(D),setTimeout(()=>c(null),5e3)}finally{i(!1)}},[]),k=z.useCallback(()=>{m.current?.click()},[]),w=z.useCallback(E=>{const I=E.target.files?.[0];I&&v(I),E.target&&(E.target.value="")},[v]),C=z.useCallback(E=>{E.preventDefault(),E.stopPropagation(),f(!0)},[]),M=z.useCallback(E=>{E.preventDefault(),E.stopPropagation(),f(!1)},[]),N=z.useCallback(E=>{E.preventDefault(),E.stopPropagation(),f(!1);const D=Array.from(E.dataTransfer.files).find(A=>A.name.endsWith(".zip"));if(!D){c("Please drop a ZIP file containing an agent directory"),setTimeout(()=>c(null),5e3);return}v(D)},[v]),S=[{id:"dir",icon:lm,label:"Agent Directory",fmt:".zip",primary:!0},{id:"md",icon:Di,label:"Claude Code / .claude",fmt:".md",primary:!1},{id:"yaml",icon:GN,label:"OpenClaw Agent",fmt:".yaml",primary:!1},{id:"json",icon:iu,label:"Vibe Kanban / BloopAI",fmt:".json",primary:!1}];return d.jsxs("div",{className:"px-4 py-3",style:{borderTop:`1px solid ${e.border}`},onDragOver:C,onDragLeave:M,onDrop:N,children:[d.jsxs("div",{className:"mb-4",children:[d.jsx("div",{className:"text-[12px] font-bold tracking-[0.08em] uppercase mb-2.5",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:"Import from"}),d.jsxs("button",{type:"button","aria-label":"Import agent from ZIP",onClick:k,disabled:s,className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg cursor-pointer w-full text-left min-h-[44px] motion-reduce:transition-none",style:{background:p?"#FE500020":"#FE500010",border:`1px solid ${p?"#FE500060":"#FE500030"}`,transition:"all 150ms",opacity:s?.6:1},onMouseEnter:E=>{s||(E.currentTarget.style.borderColor="#FE500040")},onMouseLeave:E=>{s||(E.currentTarget.style.borderColor="#FE500030")},onFocus:E=>{s||(E.currentTarget.style.borderColor="#FE500040")},onBlur:E=>{s||(E.currentTarget.style.borderColor="#FE500030")},children:[d.jsx("div",{className:"w-6 h-6 rounded flex items-center justify-center",style:{background:e.surfaceElevated},children:n==="import"?d.jsx(_t,{size:12,style:{color:"#00ff88"}}):s?d.jsx("div",{className:"w-3 h-3 border border-t-0 border-l-0",style:{borderColor:"#FE5000",borderRadius:"50%",animation:"spin 1s linear infinite"}}):d.jsx(hv,{size:12,style:{color:e.textDim}})}),d.jsx("span",{className:"flex-1 text-[13px]",style:{color:e.textPrimary},children:p?"Drop ZIP file here":s?"Importing...":"Import Agent"}),d.jsx("span",{className:"text-[13px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:".zip"})]}),l&&d.jsxs("div",{className:"mt-2 p-2 rounded-lg flex items-start gap-2",style:{background:"#dc262615",border:"1px solid #dc262630"},children:[d.jsx(im,{size:14,style:{color:"#dc2626",flexShrink:0,marginTop:1}}),d.jsx("span",{className:"text-[12px] leading-relaxed",style:{color:"#dc2626"},children:l})]}),d.jsx("input",{ref:m,type:"file",accept:".zip",style:{display:"none"},onChange:w,"aria-label":"Import agent ZIP file"})]}),d.jsxs("div",{children:[d.jsx("div",{className:"text-[12px] font-bold tracking-[0.08em] uppercase mb-2.5",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:"Export to"}),d.jsx("div",{className:"flex flex-col gap-1.5",children:S.map(E=>{const I=E.icon,D=E.id==="dir"?x:()=>b(E.id);return d.jsxs("button",{type:"button","aria-label":`Export as ${E.fmt}`,onClick:D,className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg cursor-pointer w-full text-left min-h-[44px] motion-reduce:transition-none",style:{background:E.primary?"#FE500010":e.isDark?"#1c1c20":"#f0f0f5",border:`1px solid ${E.primary?"#FE500030":e.border}`,transition:"border-color 150ms"},onMouseEnter:A=>{A.currentTarget.style.borderColor="#FE500040"},onMouseLeave:A=>{A.currentTarget.style.borderColor=e.border},onFocus:A=>{A.currentTarget.style.borderColor="#FE500040"},onBlur:A=>{A.currentTarget.style.borderColor=e.border},children:[d.jsx("div",{className:"w-6 h-6 rounded flex items-center justify-center",style:{background:e.surfaceElevated},children:n===E.id?d.jsx(_t,{size:12,style:{color:"#00ff88"}}):d.jsx(I,{size:12,style:{color:e.textDim}})}),d.jsx("span",{className:"flex-1 text-[13px]",style:{color:e.textPrimary},children:E.label}),d.jsx("span",{className:"text-[13px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:E.fmt})]},E.id)})})]})]})}function r8({onCollapse:e,onExpand:n,onMinimize:a,isExpanded:s}){const i=we(),[l,c]=z.useState("chat");return d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsxs("div",{className:"flex items-center gap-2 px-4 py-3",style:{borderBottom:`1px solid ${i.border}`},children:[d.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:"#00ff88",boxShadow:"0 0 6px rgba(0,255,136,0.4)"}}),d.jsx("span",{className:"text-[12px] font-bold tracking-[0.08em] uppercase flex-1",style:{fontFamily:"'Geist Mono', monospace",color:i.textSecondary},children:l==="chat"?"Conversation Tester":l==="team"?"Team Runner":l==="traces"?"Execution Traces":"Export"}),d.jsxs("div",{className:"flex gap-0.5 rounded-md overflow-hidden",role:"tablist",style:{border:`1px solid ${i.border}`},children:[d.jsx("button",{type:"button",role:"tab",id:"tab-chat","aria-selected":l==="chat","aria-controls":"tabpanel-chat",onClick:()=>c("chat"),className:"text-[13px] px-2.5 py-2 cursor-pointer border-none min-h-[44px]",style:{background:l==="chat"?"#FE5000":"transparent",color:l==="chat"?"#fff":i.textDim,fontFamily:"'Geist Mono', monospace"},children:"Chat"}),d.jsx("button",{type:"button",role:"tab",id:"tab-team","aria-selected":l==="team","aria-controls":"tabpanel-team",onClick:()=>c("team"),className:"text-[13px] px-2.5 py-2 cursor-pointer border-none min-h-[44px]",style:{background:l==="team"?"#FE5000":"transparent",color:l==="team"?"#fff":i.textDim,fontFamily:"'Geist Mono', monospace"},children:"Team"}),d.jsx("button",{type:"button",role:"tab",id:"tab-traces","aria-selected":l==="traces","aria-controls":"tabpanel-traces",onClick:()=>c("traces"),className:"text-[13px] px-2.5 py-2 cursor-pointer border-none min-h-[44px]",style:{background:l==="traces"?"#FE5000":"transparent",color:l==="traces"?"#fff":i.textDim,fontFamily:"'Geist Mono', monospace"},children:"Traces"}),d.jsx("button",{type:"button",role:"tab",id:"tab-export","aria-selected":l==="export","aria-controls":"tabpanel-export",onClick:()=>c("export"),className:"text-[13px] px-2.5 py-2 cursor-pointer border-none min-h-[44px]",style:{background:l==="export"?"#FE5000":"transparent",color:l==="export"?"#fff":i.textDim,fontFamily:"'Geist Mono', monospace"},children:"Export"})]}),s&&a&&d.jsx("button",{type:"button",onClick:a,"aria-label":"Minimize test panel",className:"w-7 h-7 rounded-md border-none cursor-pointer flex items-center justify-center",style:{background:"transparent",color:i.textDim},children:d.jsx(cm,{size:14})}),!s&&n&&d.jsx("button",{type:"button",onClick:n,"aria-label":"Expand test panel",className:"w-7 h-7 rounded-md border-none cursor-pointer flex items-center justify-center",style:{background:"transparent",color:i.textDim},children:d.jsx(sv,{size:14})}),e&&d.jsx("button",{type:"button",onClick:e,"aria-label":"Collapse test panel",className:"w-7 h-7 rounded-md border-none cursor-pointer flex items-center justify-center",style:{background:"transparent",color:i.textDim},children:d.jsx(ta,{size:14})})]}),l==="chat"&&d.jsx("div",{role:"tabpanel",id:"tabpanel-chat","aria-labelledby":"tab-chat",className:"flex flex-col flex-1 min-h-0",children:d.jsx(o8,{})}),l==="team"&&d.jsx("div",{role:"tabpanel",id:"tabpanel-team","aria-labelledby":"tab-team",className:"flex flex-col flex-1 min-h-0",children:d.jsx(a8,{})}),l==="traces"&&d.jsx("div",{role:"tabpanel",id:"tabpanel-traces","aria-labelledby":"tab-traces",className:"flex-1 overflow-y-auto",children:d.jsx(HD,{})}),l==="export"&&d.jsx("div",{role:"tabpanel",id:"tabpanel-export","aria-labelledby":"tab-export",className:"flex-1 overflow-y-auto",children:d.jsx(s8,{})})]})}function i8(){const e=we(),[n,a]=z.useState(!0),[s,i]=z.useState(!1);return d.jsxs("div",{role:"main",className:"flex-1 flex overflow-hidden",style:{background:e.bg},children:[!s&&d.jsx("nav",{"aria-label":"Agent sources",className:"flex flex-col overflow-y-auto",style:{width:"30%",minWidth:300,maxWidth:480,background:e.isDark?"#161619":"#f8f8fa",borderRight:`1px solid ${e.border}`},children:d.jsx(L_,{})}),!s&&d.jsx("section",{"aria-label":"Agent builder",className:"flex-1 overflow-y-auto",style:{padding:"24px 32px"},children:d.jsx(J_,{})}),d.jsx("aside",{"aria-label":"Test and export",className:"flex flex-col overflow-hidden",style:{width:n?48:s?"100%":400,minWidth:n?48:s?"100%":400,background:e.isDark?"#161619":"#f8f8fa",borderLeft:s?"none":`1px solid ${e.border}`,transition:"width 200ms ease, min-width 200ms ease"},children:n?d.jsx("button",{type:"button",onClick:()=>a(!1),className:"flex flex-col items-center justify-center gap-2 h-full cursor-pointer border-none",style:{background:"transparent",color:e.textDim},"aria-label":"Open test panel",children:d.jsx("span",{style:{writingMode:"vertical-rl",textOrientation:"mixed",fontSize:13,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",fontFamily:"'Geist Mono', monospace",color:e.textDim},children:"Test ▶"})}):d.jsx(r8,{onCollapse:()=>a(!0),onExpand:()=>i(!0),onMinimize:()=>i(!1),isExpanded:s})})]})}function l8(){const e=we(),n=se(v=>v.showFilePicker),a=se(v=>v.setShowFilePicker),s=se(v=>v.setShowSkillPicker),i=se(v=>v.setShowConnectionPicker),l=se(v=>v.setShowMarketplace),c=se(v=>v.run),p=se(v=>v.running),f=se(v=>v.showSettings),m=se(v=>v.setShowSettings),g=at(v=>v.loadServers),x=z.useRef(null),b=z.useCallback(v=>{const k=v.target.files?.[0];if(!k)return;const w=new FileReader;w.onload=C=>{const M=C.target?.result;if(!M)return;const N=n_(M),S=se.getState();if(N.channels){S.clearChannels();for(const E of N.channels)S.addChannel(E)}N.selectedModel&&S.setModel(N.selectedModel),N.outputFormat&&S.setOutputFormat(N.outputFormat),N.prompt&&S.setPrompt(N.prompt),N.tokenBudget&&S.setTokenBudget(N.tokenBudget),N.agentMeta&&S.setAgentMeta(N.agentMeta),N.instructionState&&S.setInstructionState(N.instructionState),N.workflowSteps&&S.setWorkflowSteps(N.workflowSteps)},w.readAsText(k),v.target.value=""},[]);return z.useEffect(()=>{const v=k=>{(k.metaKey||k.ctrlKey)&&k.key==="k"&&(k.preventDefault(),a(!n)),(k.metaKey||k.ctrlKey)&&k.key==="Enter"&&(k.preventDefault(),p||c()),k.key==="Escape"&&(a(!1),s(!1),i(!1),l(!1),m(!1),se.getState().setShowSaveModal(!1))};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[a,n,s,i,l,c,p]),z.useEffect(()=>{g()},[g]),d.jsxs("div",{"data-theme":e.isDark?"dark":"light",style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",background:e.bg},children:[d.jsx("input",{ref:x,type:"file",accept:".md,.yaml,.yml,.json",onChange:b,style:{display:"none"},"aria-hidden":"true"}),d.jsx(iA,{onSettingsClick:()=>m(!0,"providers")}),d.jsx(i8,{}),d.jsx("div",{"aria-live":"polite",id:"canvas-announcements",style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}}),d.jsx(lA,{}),d.jsx(uA,{}),d.jsx(yA,{}),d.jsx(CA,{}),d.jsx(xA,{}),d.jsx(_A,{open:f,onClose:()=>m(!1)}),d.jsx(WA,{})]})}mS.createRoot(document.getElementById("root")).render(d.jsx(z.StrictMode,{children:d.jsx(l8,{})}));export{c8 as c,rb as g,at as u};